@machine0/cli 1.0.99 → 1.0.102

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.
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ // util.styleText, used by a bundled @inquirer/prompts dependency, landed in
4
+ // Node 20.12.0 -- older Node crashes with a SyntaxError at module-link time.
5
+ const MIN_NODE_MAJOR = 20;
6
+ const MIN_NODE_MINOR = 12;
7
+
8
+ /**
9
+ * @param {string} version
10
+ * @returns {boolean}
11
+ */
12
+ function isSupportedNodeVersion(version) {
13
+ const match = /^[\s]*v?(\d+)\.(\d+)/.exec(version || "");
14
+ if (!match) {
15
+ return false;
16
+ }
17
+
18
+ const major = Number(match[1]);
19
+ const minor = Number(match[2]);
20
+
21
+ if (major > MIN_NODE_MAJOR) {
22
+ return true;
23
+ }
24
+ return major === MIN_NODE_MAJOR && minor >= MIN_NODE_MINOR;
25
+ }
26
+
27
+ module.exports = { isSupportedNodeVersion, MIN_NODE_MAJOR, MIN_NODE_MINOR };
package/bin/entry.cjs ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ // This file is the npm `bin` entrypoint and is deliberately NOT part of the
5
+ // bundled dist/cli.bundle.cjs. The bundle statically imports dependencies
6
+ // (e.g. @inquirer/prompts) that use Node APIs unavailable on older Node, so
7
+ // a version check inside the bundle can't run first -- the failure happens
8
+ // at ES module link time, before any code executes. Keeping this check in a
9
+ // separate, dependency-free file lets it run before the bundle is ever
10
+ // loaded, so unsupported Node gets a clear message instead of a raw
11
+ // SyntaxError.
12
+ const {
13
+ isSupportedNodeVersion,
14
+ MIN_NODE_MAJOR,
15
+ MIN_NODE_MINOR,
16
+ } = require("./check-node-version.cjs");
17
+
18
+ if (!isSupportedNodeVersion(process.version)) {
19
+ console.error(
20
+ `machine0 requires Node.js >= ${MIN_NODE_MAJOR}.${MIN_NODE_MINOR}.0, you have ${process.version}.\n` +
21
+ "Upgrade Node.js (e.g. `nvm install --lts`, or download from https://nodejs.org) and try again.",
22
+ );
23
+ process.exit(1);
24
+ }
25
+
26
+ require("../dist/cli.bundle.cjs");