mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +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';
|
||||
|
||||
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 './blitzkit';
|
||||
// export * from './blitz';
|
||||
// export * from './blitzkit';
|
||||
export * from './protos';
|
||||
// export * from './blitzstars';
|
||||
// export * from './databases';
|
||||
export * from './imgur';
|
||||
export * from './math';
|
||||
export * from './patreon';
|
||||
export * from './statistics';
|
||||
// export * from './imgur';
|
||||
// export * from './math';
|
||||
// export * from './patreon';
|
||||
// export * from './statistics';
|
||||
// export * from './streams';
|
||||
export * from './types';
|
||||
// export * from './types';
|
||||
@@ -2,7 +2,7 @@ syntax = "proto3";
|
||||
|
||||
package blitzkit;
|
||||
|
||||
import "packages/core/src/protos/raw/tank_definitions.proto";
|
||||
import "packages/core/src/protos/tank_definitions.proto";
|
||||
|
||||
message ConsumableDefinitions {
|
||||
map<uint32, Consumable> consumables = 1;
|
||||
|
||||
@@ -2,7 +2,7 @@ syntax = "proto3";
|
||||
|
||||
package blitzkit;
|
||||
|
||||
import "packages/core/src/protos/raw/consumable_definitions.proto";
|
||||
import "packages/core/src/protos/consumable_definitions.proto";
|
||||
|
||||
message ProvisionDefinitions {
|
||||
map<uint32, Provision> provisions = 1;
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
import { TankDefinition, TankDefinitions } from '@blitzkit/core';
|
||||
|
||||
export async function 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 { existsSync } from 'fs';
|
||||
import { mkdir, readdir, rm } from 'fs/promises';
|
||||
import { readdir, rm, writeFile } from 'fs/promises';
|
||||
import { promisify } from 'util';
|
||||
|
||||
const ROOT = 'packages/core/src/protos';
|
||||
@@ -15,29 +15,29 @@ if (existsSync('node_modules/.bin/protoc-gen-ts.exe')) {
|
||||
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 = [
|
||||
`--plugin="protoc-gen-ts=./node_modules/.bin/protoc-gen-ts${executableFileExtension}"`,
|
||||
'--ts_opt=esModuleInterop=true',
|
||||
`--js_out="import_style=commonjs,binary:."`,
|
||||
`--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 cp(`${ROOT}/generated/${ROOT}/raw`, `${ROOT}/generated`, {
|
||||
// recursive: true,
|
||||
// });
|
||||
// await rm(`${ROOT}/generated/packages`, { recursive: true, force: true });
|
||||
|
||||
// await writeFile(
|
||||
// `${ROOT}/generated/index.ts`,
|
||||
// files
|
||||
// .map((file) => file.replace('.proto', ''))
|
||||
// .map((file) => `export * from './${file}_pb';`)
|
||||
// .join('\n'),
|
||||
// );
|
||||
await writeFile(
|
||||
`${ROOT}/index.ts`,
|
||||
files
|
||||
.map((file) => file.replace('.proto', ''))
|
||||
.map((file) => `export * from './${file}_pb';`)
|
||||
.join('\n'),
|
||||
);
|
||||
Reference in new issue
Block a user