@omen.foundation/node-microservice-runtime 0.1.67 → 0.1.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/scripts/deprecate-all-versions.js +72 -0
- package/scripts/generate-openapi.mjs +114 -0
- package/scripts/lib/cli-utils.mjs +58 -0
- package/scripts/prepare-cjs.mjs +44 -0
- package/scripts/publish-service.mjs +1119 -0
- package/scripts/validate-service.mjs +103 -0
- package/scripts/ws-test.mjs +25 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { runCommand } from './lib/cli-utils.mjs';
|
|
6
|
+
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
|
|
9
|
+
function parseArgs(argv) {
|
|
10
|
+
const args = {
|
|
11
|
+
entry: 'dist/main.js',
|
|
12
|
+
output: 'beam_openApi.json',
|
|
13
|
+
envFile: undefined,
|
|
14
|
+
cid: process.env.CID,
|
|
15
|
+
pid: process.env.PID,
|
|
16
|
+
host: process.env.HOST,
|
|
17
|
+
namePrefix: process.env.NAME_PREFIX,
|
|
18
|
+
service: undefined,
|
|
19
|
+
skipBuild: false,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const queue = [...argv];
|
|
23
|
+
while (queue.length > 0) {
|
|
24
|
+
const current = queue.shift();
|
|
25
|
+
switch (current) {
|
|
26
|
+
case '--entry':
|
|
27
|
+
args.entry = queue.shift();
|
|
28
|
+
break;
|
|
29
|
+
case '--output':
|
|
30
|
+
args.output = queue.shift();
|
|
31
|
+
break;
|
|
32
|
+
case '--env-file':
|
|
33
|
+
args.envFile = queue.shift();
|
|
34
|
+
break;
|
|
35
|
+
case '--cid':
|
|
36
|
+
args.cid = queue.shift();
|
|
37
|
+
break;
|
|
38
|
+
case '--pid':
|
|
39
|
+
args.pid = queue.shift();
|
|
40
|
+
break;
|
|
41
|
+
case '--host':
|
|
42
|
+
args.host = queue.shift();
|
|
43
|
+
break;
|
|
44
|
+
case '--routing-key':
|
|
45
|
+
case '--name-prefix':
|
|
46
|
+
args.namePrefix = queue.shift();
|
|
47
|
+
break;
|
|
48
|
+
case '--service':
|
|
49
|
+
args.service = queue.shift();
|
|
50
|
+
break;
|
|
51
|
+
case '--skip-build':
|
|
52
|
+
args.skipBuild = true;
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
throw new Error(`Unknown argument: ${current}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!args.envFile && process.env.npm_config_env_file) {
|
|
60
|
+
args.envFile = process.env.npm_config_env_file;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return args;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function main() {
|
|
67
|
+
const args = parseArgs(process.argv.slice(2));
|
|
68
|
+
|
|
69
|
+
if (!args.skipBuild) {
|
|
70
|
+
await runCommand('npm', ['run', 'build']);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const generateScript = path.resolve(__dirname, 'generate-openapi.mjs');
|
|
74
|
+
const commandArgs = ['--entry', args.entry, '--output', args.output];
|
|
75
|
+
|
|
76
|
+
if (args.envFile) {
|
|
77
|
+
commandArgs.push('--env-file', args.envFile);
|
|
78
|
+
}
|
|
79
|
+
if (args.cid) {
|
|
80
|
+
commandArgs.push('--cid', args.cid);
|
|
81
|
+
}
|
|
82
|
+
if (args.pid) {
|
|
83
|
+
commandArgs.push('--pid', args.pid);
|
|
84
|
+
}
|
|
85
|
+
if (args.host) {
|
|
86
|
+
commandArgs.push('--host', args.host);
|
|
87
|
+
}
|
|
88
|
+
if (args.namePrefix) {
|
|
89
|
+
commandArgs.push('--routing-key', args.namePrefix);
|
|
90
|
+
}
|
|
91
|
+
if (args.service) {
|
|
92
|
+
commandArgs.push('--service', args.service);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
await runCommand(process.execPath, [generateScript, ...commandArgs], { shell: false });
|
|
96
|
+
|
|
97
|
+
console.log('Validation completed successfully.');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
main().catch((error) => {
|
|
101
|
+
console.error(error instanceof Error ? error.message : error);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import WebSocket from 'ws';
|
|
2
|
+
|
|
3
|
+
const url = process.argv[2] ?? 'wss://api.beamable.com/socket';
|
|
4
|
+
|
|
5
|
+
const ws = new WebSocket(url);
|
|
6
|
+
|
|
7
|
+
ws.on('open', () => {
|
|
8
|
+
console.log('ws open');
|
|
9
|
+
const payload = JSON.stringify({ id: -1, method: 'get', path: 'gateway/nonce', body: {} });
|
|
10
|
+
console.log('sending', payload);
|
|
11
|
+
ws.send(payload);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
ws.on('message', (data) => {
|
|
15
|
+
console.log('message', data.toString());
|
|
16
|
+
ws.close();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
ws.on('error', (err) => {
|
|
20
|
+
console.error('error', err);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
ws.on('close', (code, reason) => {
|
|
24
|
+
console.log('closed', code, reason.toString());
|
|
25
|
+
});
|