mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
feat: some work on functional pro ts
This commit is contained in:
1 parent
9b134fab27
commit
57170469f2
6 files changed
+44
-29
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
import { type ShellDefinition, ShellType } from '@blitzkit/core';
|
import { type ShellDefinition, ShellType } from '@blitzkit/core';
|
||||||
|
|
||||||
export function canSplash(type: ShellDefinition['type']): type is ShellType.HE {
|
export function canSplash(type: ShellDefinition['type']): type is ShellType.HE {
|
||||||
return type === ShellType.HE;
|
return type === ShellType.SHELL_TYPE_HE;
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
export * from './blitz';
|
// export * from './blitz';
|
||||||
export * from './blitzkit';
|
// export * from './blitzkit';
|
||||||
export * from './protos';
|
export * from './protos';
|
||||||
// export * from './blitzstars';
|
// export * from './blitzstars';
|
||||||
// export * from './databases';
|
// export * from './databases';
|
||||||
export * from './imgur';
|
// export * from './imgur';
|
||||||
export * from './math';
|
// export * from './math';
|
||||||
export * from './patreon';
|
// export * from './patreon';
|
||||||
export * from './statistics';
|
// export * from './statistics';
|
||||||
// export * from './streams';
|
// export * from './streams';
|
||||||
export * from './types';
|
// export * from './types';
|
||||||
@@ -2,7 +2,7 @@ syntax = "proto3";
|
|||||||
|
|
||||||
package blitzkit;
|
package blitzkit;
|
||||||
|
|
||||||
import "packages/core/src/protos/raw/tank_definitions.proto";
|
import "packages/core/src/protos/tank_definitions.proto";
|
||||||
|
|
||||||
message ConsumableDefinitions {
|
message ConsumableDefinitions {
|
||||||
map<uint32, Consumable> consumables = 1;
|
map<uint32, Consumable> consumables = 1;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ syntax = "proto3";
|
|||||||
|
|
||||||
package blitzkit;
|
package blitzkit;
|
||||||
|
|
||||||
import "packages/core/src/protos/raw/consumable_definitions.proto";
|
import "packages/core/src/protos/consumable_definitions.proto";
|
||||||
|
|
||||||
message ProvisionDefinitions {
|
message ProvisionDefinitions {
|
||||||
map<uint32, Provision> provisions = 1;
|
map<uint32, Provision> provisions = 1;
|
||||||
|
|||||||
@@ -1,3 +1,18 @@
|
|||||||
|
import { TankDefinition, TankDefinitions } from '@blitzkit/core';
|
||||||
|
|
||||||
export async function definitions() {
|
export async function definitions() {
|
||||||
console.log('Building definitions...');
|
console.log('Building definitions...');
|
||||||
|
|
||||||
|
const tankDefinitions = new TankDefinitions();
|
||||||
|
const tanks = tankDefinitions.getTanksMap();
|
||||||
|
|
||||||
|
const testTank = new TankDefinition();
|
||||||
|
|
||||||
|
testTank.setName('asd');
|
||||||
|
|
||||||
|
tanks.set(1, testTank);
|
||||||
|
|
||||||
|
console.log(JSON.stringify(tankDefinitions.toObject(), null, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
definitions();
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { exec as execSync } from 'child_process';
|
import { exec as execSync } from 'child_process';
|
||||||
import { existsSync } from 'fs';
|
import { existsSync } from 'fs';
|
||||||
import { mkdir, readdir, rm } from 'fs/promises';
|
import { readdir, rm, writeFile } from 'fs/promises';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
|
|
||||||
const ROOT = 'packages/core/src/protos';
|
const ROOT = 'packages/core/src/protos';
|
||||||
@@ -15,29 +15,29 @@ if (existsSync('node_modules/.bin/protoc-gen-ts.exe')) {
|
|||||||
executableFileExtension = '';
|
executableFileExtension = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = await readdir(`${ROOT}/raw`);
|
const filesRaw = await readdir(`${ROOT}`);
|
||||||
|
await Promise.all(
|
||||||
|
filesRaw.map(async (file) => {
|
||||||
|
if (!file.endsWith('.proto')) {
|
||||||
|
await rm(`${ROOT}/${file}`);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const files = filesRaw.filter((file) => file.endsWith('.proto'));
|
||||||
const args = [
|
const args = [
|
||||||
`--plugin="protoc-gen-ts=./node_modules/.bin/protoc-gen-ts${executableFileExtension}"`,
|
`--plugin="protoc-gen-ts=./node_modules/.bin/protoc-gen-ts${executableFileExtension}"`,
|
||||||
'--ts_opt=esModuleInterop=true',
|
'--ts_opt=esModuleInterop=true',
|
||||||
`--js_out="import_style=commonjs,binary:."`,
|
`--js_out="import_style=commonjs,binary:."`,
|
||||||
`--ts_out="."`,
|
`--ts_out="."`,
|
||||||
...files.map((file) => `${ROOT}/raw/${file}`),
|
...files.map((file) => `${ROOT}/${file}`),
|
||||||
];
|
];
|
||||||
|
|
||||||
await rm(`${ROOT}/generated`, { recursive: true, force: true });
|
|
||||||
await rm(`temp/protos`, { recursive: true, force: true });
|
|
||||||
await mkdir(`${ROOT}/generated`, { recursive: true });
|
|
||||||
await mkdir(`temp/protos`, { recursive: true });
|
|
||||||
await exec(`protoc ${args.join(' ')}`);
|
await exec(`protoc ${args.join(' ')}`);
|
||||||
// await cp(`${ROOT}/generated/${ROOT}/raw`, `${ROOT}/generated`, {
|
await writeFile(
|
||||||
// recursive: true,
|
`${ROOT}/index.ts`,
|
||||||
// });
|
files
|
||||||
// await rm(`${ROOT}/generated/packages`, { recursive: true, force: true });
|
.map((file) => file.replace('.proto', ''))
|
||||||
|
.map((file) => `export * from './${file}_pb';`)
|
||||||
// await writeFile(
|
.join('\n'),
|
||||||
// `${ROOT}/generated/index.ts`,
|
);
|
||||||
// files
|
|
||||||
// .map((file) => file.replace('.proto', ''))
|
|
||||||
// .map((file) => `export * from './${file}_pb';`)
|
|
||||||
// .join('\n'),
|
|
||||||
// );
|
|
||||||
Reference in new issue
Block a user