👷 Remove $type keys
This commit is contained in:
@@ -1,30 +1,25 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process'
|
||||||
import path from 'path';
|
import path from 'path'
|
||||||
import os from 'os';
|
import os from 'os'
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url'
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url)
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename)
|
||||||
|
|
||||||
const isWindows = os.platform() === 'win32';
|
const isWindows = os.platform() === 'win32'
|
||||||
const projectRoot = path.resolve(__dirname, '..');
|
const projectRoot = path.resolve(__dirname, '..')
|
||||||
const platformSharedDir = path.resolve(projectRoot, '..', 'platform_shared');
|
const platformSharedDir = path.resolve(projectRoot, '..', 'platform_shared')
|
||||||
const outputDir = path.resolve(projectRoot, 'src', 'lib', 'platform_shared');
|
const outputDir = path.resolve(projectRoot, 'src', 'lib', 'platform_shared')
|
||||||
|
|
||||||
const pluginPath = isWindows
|
const pluginPath =
|
||||||
? path.join(projectRoot, 'node_modules', '.bin', 'protoc-gen-ts_proto.cmd')
|
isWindows ?
|
||||||
: path.join(projectRoot, 'node_modules', '.bin', 'protoc-gen-ts_proto');
|
path.join(projectRoot, 'node_modules', '.bin', 'protoc-gen-ts_proto.cmd')
|
||||||
|
: path.join(projectRoot, 'node_modules', '.bin', 'protoc-gen-ts_proto')
|
||||||
|
|
||||||
const protoFiles = ['websocket_message.proto', 'rest_message.proto'];
|
const protoFiles = ['websocket_message.proto', 'rest_message.proto']
|
||||||
|
|
||||||
const tsProtoOpts = [
|
const tsProtoOpts = ['useExactTypes=false', 'outputExtensions=true', 'outputSchema=true'].join(',')
|
||||||
'outputTypeAnnotations=true',
|
|
||||||
'useExactTypes=false',
|
|
||||||
'outputExtensions=true',
|
|
||||||
'outputTypeRegistry=true',
|
|
||||||
'outputSchema=true'
|
|
||||||
].join(',');
|
|
||||||
|
|
||||||
const cmd = [
|
const cmd = [
|
||||||
'protoc',
|
'protoc',
|
||||||
@@ -33,17 +28,16 @@ const cmd = [
|
|||||||
`--ts_proto_opt=${tsProtoOpts}`,
|
`--ts_proto_opt=${tsProtoOpts}`,
|
||||||
`-I${platformSharedDir}`,
|
`-I${platformSharedDir}`,
|
||||||
...protoFiles.map(f => path.join(platformSharedDir, f))
|
...protoFiles.map(f => path.join(platformSharedDir, f))
|
||||||
].join(' ');
|
].join(' ')
|
||||||
|
|
||||||
console.log('Compiling protos...');
|
console.log('Compiling protos...')
|
||||||
console.log(` Platform: ${os.platform()}`);
|
console.log(` Platform: ${os.platform()}`)
|
||||||
console.log(` Output: ${outputDir}`);
|
console.log(` Output: ${outputDir}`)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
execSync(cmd, { stdio: 'inherit', cwd: projectRoot });
|
execSync(cmd, { stdio: 'inherit', cwd: projectRoot })
|
||||||
console.log('Proto compilation complete!');
|
console.log('Proto compilation complete!')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Proto compilation failed!');
|
console.error('Proto compilation failed!', error)
|
||||||
process.exit(1);
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user