securewithtrace 0.44.0 → 0.45.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.
package/README.md CHANGED
@@ -26,7 +26,7 @@ tracecli --help
26
26
 
27
27
  ## Requirements
28
28
 
29
- - Bun runtime available on your PATH
29
+ - [Bun](https://bun.sh/docs/installation) on your PATH (`curl -fsSL https://bun.sh/install | bash`, `brew install oven-sh/bun/bun`, or `npm install -g bun`). `tracecli` tells you if it's missing.
30
30
  - Git (for `tracecli repo clone`)
31
31
  - A Trace account with access to at least one organization
32
32
 
package/bin/tracecli ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawn } from 'node:child_process';
4
+ import { realpathSync } from 'node:fs';
5
+ import { dirname, resolve } from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+
8
+ const installMessage = [
9
+ "tracecli needs the Bun runtime, and `bun` isn't on your PATH.",
10
+ '',
11
+ 'Install Bun with one of:',
12
+ '',
13
+ ' curl -fsSL https://bun.sh/install | bash',
14
+ ' brew install oven-sh/bun/bun',
15
+ ' npm install -g bun',
16
+ '',
17
+ 'Then open a new shell (or reload your profile) and run your command again.',
18
+ 'More options: https://bun.sh/docs/installation',
19
+ '',
20
+ ].join('\n');
21
+
22
+ const launcherPath = realpathSync(fileURLToPath(import.meta.url));
23
+ const bundledEntry = resolve(dirname(launcherPath), '../dist/index.js');
24
+ const child = spawn('bun', [bundledEntry, ...process.argv.slice(2)], {
25
+ stdio: 'inherit',
26
+ windowsHide: false,
27
+ });
28
+
29
+ child.on('error', (error) => {
30
+ if (error && 'code' in error && error.code === 'ENOENT') {
31
+ process.stderr.write(installMessage);
32
+ process.exit(127);
33
+ }
34
+ throw error;
35
+ });
36
+
37
+ for (const signal of ['SIGINT', 'SIGTERM']) {
38
+ process.on(signal, () => {
39
+ child.kill(signal);
40
+ });
41
+ }
42
+
43
+ child.on('exit', (code, signal) => {
44
+ if (signal) {
45
+ process.removeAllListeners(signal);
46
+ process.kill(process.pid, signal);
47
+ return;
48
+ }
49
+ process.exit(code ?? 1);
50
+ });