instabox 0.8.125 → 0.8.126
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/cli/SHA256SUMS +6 -6
- package/cli/instabox-darwin-amd64 +0 -0
- package/cli/instabox-darwin-arm64 +0 -0
- package/cli/instabox-linux-amd64 +0 -0
- package/cli/instabox-linux-arm64 +0 -0
- package/cli/instabox-windows-amd64.exe +0 -0
- package/cli/instabox-windows-arm64.exe +0 -0
- package/lib/cli.mjs +58 -8
- package/package.json +1 -1
package/cli/SHA256SUMS
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
7025a12c35ccbd7a2df302f915108ac9ca23dc98d6046dcc8ce88cd96e9cc1e7 instabox-darwin-amd64
|
|
2
|
+
50fa1433e3706afd1aacde4428418d9ca5a575f1150c62f45bcb9d9516147004 instabox-darwin-arm64
|
|
3
|
+
6235dc2551d30cc04b2e512f0124967fb74b095e09e3641559cc2151a869f061 instabox-linux-amd64
|
|
4
|
+
ada01b4e599828bdf60b3fef02c2290ea6bf496b0505266a949db909aaef83d5 instabox-linux-arm64
|
|
5
|
+
ac07d784fecbea8c1472bdb93734aef22c90a4007ec37a1f6d064d1f63812125 instabox-windows-amd64.exe
|
|
6
|
+
ee23b49ef781de9625c61bfa81dd8cb837045d267787d0c7e7e7267ec7d97954 instabox-windows-arm64.exe
|
|
Binary file
|
|
Binary file
|
package/cli/instabox-linux-amd64
CHANGED
|
Binary file
|
package/cli/instabox-linux-arm64
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// The Go instabox CLI: find it, install it, hand it the command line.
|
|
2
|
-
import { execFile,
|
|
2
|
+
import { execFile, spawn } from 'node:child_process';
|
|
3
3
|
import { createHash } from 'node:crypto';
|
|
4
4
|
import {
|
|
5
5
|
accessSync,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
rmSync,
|
|
14
14
|
statSync,
|
|
15
15
|
} from 'node:fs';
|
|
16
|
-
import { homedir } from 'node:os';
|
|
16
|
+
import { constants as osConstants, homedir } from 'node:os';
|
|
17
17
|
import { dirname, join, sep } from 'node:path';
|
|
18
18
|
import { fileURLToPath } from 'node:url';
|
|
19
19
|
import { buildName, platformFor } from './platforms.mjs';
|
|
@@ -187,12 +187,62 @@ export function missingBundledCli({ platform = process.platform, arch = process.
|
|
|
187
187
|
return 'this package carries no cli/ (a checkout?); from npm/: ../scripts/build-cli.sh --out ../out/cli && node scripts/bundle-cli.mjs --cli-dir ../out/cli';
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
190
|
+
// The signals that stop a wrapper in place of the CLI: `kill PID`, `timeout`, an agent stopping it,
|
|
191
|
+
// a closed terminal. Each is passed on, so stopping the wrapper stops the CLI too instead of leaving
|
|
192
|
+
// it running. On Windows a console Ctrl-C or close already reaches the CLI, which shares the console,
|
|
193
|
+
// and child.kill there terminates it outright, so nothing is passed on: the wrapper only stays to
|
|
194
|
+
// report the CLI's status.
|
|
195
|
+
export const FORWARDED_SIGNALS = ['SIGINT', 'SIGTERM', 'SIGHUP'];
|
|
196
|
+
|
|
197
|
+
// Hand the command line to the Go CLI and exit with its status. The CLI shares this terminal
|
|
198
|
+
// (stdio inherited), so a TTY behaves as when it is run directly. A CLI ended by a signal ends the
|
|
199
|
+
// wrapper by the same signal (exit 128+n where that cannot be raised).
|
|
200
|
+
export function runCli(path, args, { platform = process.platform } = {}) {
|
|
201
|
+
const forward = platform !== 'win32';
|
|
202
|
+
const listeners = new Map();
|
|
203
|
+
let child;
|
|
204
|
+
const off = () => {
|
|
205
|
+
for (const [sig, fn] of listeners) process.removeListener(sig, fn);
|
|
206
|
+
listeners.clear();
|
|
207
|
+
};
|
|
208
|
+
const fail = (e) => {
|
|
209
|
+
off();
|
|
210
|
+
console.error(`instabox: could not run ${path}: ${e.message}`);
|
|
195
211
|
process.exit(1);
|
|
212
|
+
};
|
|
213
|
+
for (const sig of FORWARDED_SIGNALS) {
|
|
214
|
+
const fn = () => {
|
|
215
|
+
if (!forward || !child || child.exitCode !== null || child.signalCode !== null) return;
|
|
216
|
+
try {
|
|
217
|
+
child.kill(sig);
|
|
218
|
+
} catch {
|
|
219
|
+
// The CLI is already gone; its exit event reports the status.
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
try {
|
|
223
|
+
process.on(sig, fn);
|
|
224
|
+
listeners.set(sig, fn);
|
|
225
|
+
} catch {
|
|
226
|
+
// A signal this platform cannot listen for.
|
|
227
|
+
}
|
|
196
228
|
}
|
|
197
|
-
|
|
229
|
+
try {
|
|
230
|
+
child = spawn(path, args, { stdio: 'inherit' });
|
|
231
|
+
} catch (e) {
|
|
232
|
+
fail(e);
|
|
233
|
+
}
|
|
234
|
+
child.on('error', fail);
|
|
235
|
+
child.on('exit', (code, signal) => {
|
|
236
|
+
off();
|
|
237
|
+
if (code !== null) process.exit(code);
|
|
238
|
+
const n = (signal && osConstants.signals[signal]) || 0;
|
|
239
|
+
if (signal && forward) {
|
|
240
|
+
try {
|
|
241
|
+
process.kill(process.pid, signal);
|
|
242
|
+
} catch {
|
|
243
|
+
// Fall through to the status a shell reports for it.
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
process.exit(n ? 128 + n : 1);
|
|
247
|
+
});
|
|
198
248
|
}
|