@exulu/backend 1.61.0 → 1.61.1

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.
Files changed (2) hide show
  1. package/bin/backend.cjs +60 -0
  2. package/package.json +2 -1
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Dispatcher for `npx @exulu/backend <subcommand>`.
4
+ *
5
+ * npx refuses to pick a bin when a package has multiple, unless one matches
6
+ * the package's unscoped name. This dispatcher claims that slot and forwards
7
+ * to the real subcommand scripts.
8
+ */
9
+
10
+ const { spawn } = require('child_process');
11
+ const { existsSync } = require('fs');
12
+ const path = require('path');
13
+
14
+ const subcommands = {
15
+ 'setup-python': path.join(__dirname, 'setup-python.cjs'),
16
+ 'exulu-start-whisper': path.join(__dirname, '..', 'dist', 'cli', 'start-whisper.cjs'),
17
+ 'start-whisper': path.join(__dirname, '..', 'dist', 'cli', 'start-whisper.cjs'),
18
+ };
19
+
20
+ function printUsage(stream) {
21
+ stream.write('Usage: npx @exulu/backend <subcommand> [args...]\n\n');
22
+ stream.write('Available subcommands:\n');
23
+ for (const name of Object.keys(subcommands)) {
24
+ stream.write(` ${name}\n`);
25
+ }
26
+ stream.write('\n');
27
+ }
28
+
29
+ const [, , subcommand, ...args] = process.argv;
30
+
31
+ if (!subcommand || subcommand === '--help' || subcommand === '-h') {
32
+ printUsage(process.stdout);
33
+ process.exit(subcommand ? 0 : 1);
34
+ }
35
+
36
+ const target = subcommands[subcommand];
37
+ if (!target) {
38
+ process.stderr.write(`Unknown subcommand: ${subcommand}\n\n`);
39
+ printUsage(process.stderr);
40
+ process.exit(1);
41
+ }
42
+
43
+ if (!existsSync(target)) {
44
+ process.stderr.write(`Subcommand script missing: ${target}\n`);
45
+ process.stderr.write('The @exulu/backend package may not be fully built or installed.\n');
46
+ process.exit(1);
47
+ }
48
+
49
+ const child = spawn(process.execPath, [target, ...args], { stdio: 'inherit' });
50
+ child.on('exit', (code, signal) => {
51
+ if (signal) {
52
+ process.kill(process.pid, signal);
53
+ return;
54
+ }
55
+ process.exit(code ?? 0);
56
+ });
57
+ child.on('error', (err) => {
58
+ process.stderr.write(`Failed to run subcommand: ${err.message}\n`);
59
+ process.exit(1);
60
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@exulu/backend",
3
3
  "author": "Qventu Bv.",
4
- "version": "1.61.0",
4
+ "version": "1.61.1",
5
5
  "main": "./dist/index.js",
6
6
  "private": false,
7
7
  "publishConfig": {
@@ -10,6 +10,7 @@
10
10
  "module": "./dist/index.mjs",
11
11
  "types": "./dist/index.d.ts",
12
12
  "bin": {
13
+ "backend": "./bin/backend.cjs",
13
14
  "setup-python": "./bin/setup-python.cjs",
14
15
  "exulu-start-whisper": "./dist/cli/start-whisper.cjs"
15
16
  },