-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode-serve.mjs
More file actions
27 lines (25 loc) · 1.09 KB
/
Copy pathnode-serve.mjs
File metadata and controls
27 lines (25 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env node
/*
* node-serve — start the Node backend that serves the ports.
*
* Resolves the abap2UI5 checkout (the in-repo .abap2UI5 clone by default) and
* launches its express shim on http://localhost:3000. Run `npm run node:setup`
* once first; rebuild after changing ports with `npm run node:build`.
*/
import { spawn } from 'child_process';
import fs from 'fs';
import path from 'path';
import { resolveA2UI5 } from './lib-a2ui5.mjs';
const A2 = resolveA2UI5();
if (!A2) {
console.error('abap2UI5 checkout not found — run `npm run node:setup` first (clones it into .abap2UI5).');
process.exit(1);
}
if (!fs.existsSync(path.join(A2, 'node/output/init.mjs'))) {
console.error(`backend not built at ${A2}/node/output — run \`npm run node:build\` (or \`npm run node:setup\`) first.`);
process.exit(1);
}
console.log(`node-serve: abap2UI5 at ${A2}`);
console.log('open http://localhost:3000/?app_start=z2ui5_cl_smpc_app_000');
const child = spawn('node', [path.join(A2, 'node/srv/express.mjs')], { stdio: 'inherit', env: process.env });
child.on('exit', (code) => process.exit(code ?? 0));