@heyanon-arp/cli 0.0.15 → 0.0.17
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/bin/heyarp.cjs +47 -0
- package/dist/cli.js +599 -571
- package/dist/cli.js.map +1 -1
- package/package.json +4 -3
package/bin/heyarp.cjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* heyarp launcher shim.
|
|
6
|
+
*
|
|
7
|
+
* Its ONLY job is to gate on the Node.js version BEFORE requiring the real
|
|
8
|
+
* bundle (dist/cli.js). The bundle is built for modern Node (tsup target
|
|
9
|
+
* node22) and uses ES2020 syntax such as optional chaining; on an old Node
|
|
10
|
+
* that syntax throws a cryptic `SyntaxError: Unexpected token .` at PARSE
|
|
11
|
+
* time — before any in-bundle version check could ever run. A user whose
|
|
12
|
+
* `#!/usr/bin/env node` resolves to a stale Node on their PATH (a common
|
|
13
|
+
* macOS footgun: an old /usr/local/bin/node shadowing a newer
|
|
14
|
+
* /opt/homebrew/bin/node) would otherwise see that opaque error instead of
|
|
15
|
+
* a clear "upgrade Node" message.
|
|
16
|
+
*
|
|
17
|
+
* Therefore this file is INTENTIONALLY written in pre-ES2020 style so it
|
|
18
|
+
* parses on any realistic Node and can print a helpful diagnostic. Do NOT
|
|
19
|
+
* introduce optional chaining (`?.`), nullish coalescing (`??`), or other
|
|
20
|
+
* ES2020+ syntax here — that would defeat the entire purpose. (It also
|
|
21
|
+
* means the `engines.node` minimum is read defensively without `?.`.)
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const pkg = require('../package.json');
|
|
25
|
+
const engines = pkg.engines || {};
|
|
26
|
+
const declared = typeof engines.node === 'string' ? engines.node : '>=22';
|
|
27
|
+
const declaredMatch = declared.match(/\d+/);
|
|
28
|
+
const required = declaredMatch ? parseInt(declaredMatch[0], 10) : 22;
|
|
29
|
+
|
|
30
|
+
const current = String(process.versions.node);
|
|
31
|
+
const currentMajor = parseInt(current.split('.')[0], 10);
|
|
32
|
+
|
|
33
|
+
if (Number.isNaN(currentMajor) || currentMajor < required) {
|
|
34
|
+
process.stderr.write(
|
|
35
|
+
`\n heyarp requires Node.js >= ${required}, but this process is Node ${current}.\n\n` +
|
|
36
|
+
` The \`node\` resolved by the shebang is:\n ${process.execPath}\n\n` +
|
|
37
|
+
` A stale Node earlier on your PATH is the usual cause (e.g. an old\n` +
|
|
38
|
+
` /usr/local/bin/node shadowing a newer one). Fix it with one of:\n` +
|
|
39
|
+
` - nvm install ${required} && nvm alias default ${required}\n` +
|
|
40
|
+
` - put your Node >= ${required} directory first on $PATH\n` +
|
|
41
|
+
` - reinstall heyarp under a modern Node\n\n` +
|
|
42
|
+
` Tip: \`which -a node\` lists every node on your PATH.\n\n`,
|
|
43
|
+
);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
require('../dist/cli.js');
|