@elgora/cli 7.4.0 → 7.4.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 (3) hide show
  1. package/README.md +4 -0
  2. package/dist/cli.js +71 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -21,6 +21,10 @@ Or run one command without installing:
21
21
  npx @elgora/cli --help
22
22
  ```
23
23
 
24
+ Every command refuses to start on a Node outside the `engines` range the
25
+ package declares, and says which range it needs. `--version` and `help` still
26
+ answer.
27
+
24
28
  ## Commands
25
29
 
26
30
  - `poster:publish-fund` publishes approved `bounty_challenge.md` bytes and
package/dist/cli.js CHANGED
@@ -6902,6 +6902,70 @@ function resolveChainId(selector) {
6902
6902
  );
6903
6903
  }
6904
6904
 
6905
+ // src/version.ts
6906
+ var CLI_VERSION = true ? "7.4.1" : "0.0.0-dev";
6907
+ var CLI_NODE_ENGINES = true ? ">=24 <25" : ">=24 <25";
6908
+
6909
+ // src/node-engines.ts
6910
+ function unsupportedNodeMessage(running = process.versions.node, range = CLI_NODE_ENGINES) {
6911
+ if (satisfiesRange(running, range)) return null;
6912
+ return `elgora-cli needs Node ${range}; this is Node ${running}. Install a Node inside that range and run the command again. --version and help still answer.`;
6913
+ }
6914
+ function satisfiesRange(version, range) {
6915
+ const running = parseVersion(version);
6916
+ if (!running) return false;
6917
+ return range.split("||").some(
6918
+ (alternative) => alternative.trim().split(/\s+/).filter(Boolean).every((comparator) => satisfiesComparator(running, comparator))
6919
+ );
6920
+ }
6921
+ function satisfiesComparator(running, comparator) {
6922
+ const match = /^(>=|<=|>|<|=|\^|~)?v?(\d+)(?:\.(\d+|x|\*))?(?:\.(\d+|x|\*))?$/.exec(
6923
+ comparator
6924
+ );
6925
+ if (!match) return false;
6926
+ const operator = match[1] ?? "=";
6927
+ const major = Number(match[2]);
6928
+ const minorRaw = match[3];
6929
+ const patchRaw = match[4];
6930
+ const wildcard = minorRaw === void 0 || minorRaw === "x" || minorRaw === "*" || patchRaw === void 0 || patchRaw === "x" || patchRaw === "*";
6931
+ const bound = [
6932
+ major,
6933
+ minorRaw && !["x", "*"].includes(minorRaw) ? Number(minorRaw) : 0,
6934
+ patchRaw && !["x", "*"].includes(patchRaw) ? Number(patchRaw) : 0
6935
+ ];
6936
+ const order = compareVersions(running, bound);
6937
+ switch (operator) {
6938
+ case ">":
6939
+ return order > 0;
6940
+ case ">=":
6941
+ return order >= 0;
6942
+ case "<":
6943
+ return order < 0;
6944
+ case "<=":
6945
+ return order <= 0;
6946
+ case "^":
6947
+ return order >= 0 && running[0] === major;
6948
+ case "~": {
6949
+ const anyMinor = minorRaw === void 0 || minorRaw === "x" || minorRaw === "*";
6950
+ return order >= 0 && running[0] === major && (anyMinor || running[1] === bound[1]);
6951
+ }
6952
+ default:
6953
+ return wildcard ? running[0] === major && (minorRaw === void 0 || ["x", "*"].includes(minorRaw) || running[1] === bound[1]) : order === 0;
6954
+ }
6955
+ }
6956
+ function parseVersion(version) {
6957
+ const match = /^v?(\d+)\.(\d+)\.(\d+)/.exec(version.trim());
6958
+ if (!match) return null;
6959
+ return [Number(match[1]), Number(match[2]), Number(match[3])];
6960
+ }
6961
+ function compareVersions(left, right) {
6962
+ for (let index = 0; index < 3; index += 1) {
6963
+ const difference = (left[index] ?? 0) - (right[index] ?? 0);
6964
+ if (difference !== 0) return difference;
6965
+ }
6966
+ return 0;
6967
+ }
6968
+
6905
6969
  // src/poster-open-winning-submission.ts
6906
6970
  import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
6907
6971
  import path2 from "path";
@@ -8215,9 +8279,6 @@ function usageError4() {
8215
8279
  return new Error(VERIFICATION_RECORD_USAGE);
8216
8280
  }
8217
8281
 
8218
- // src/version.ts
8219
- var CLI_VERSION = true ? "7.4.0" : "0.0.0-dev";
8220
-
8221
8282
  // src/cli.ts
8222
8283
  var dotenvPath = path4.resolve(process.env.DOTENV_CONFIG_PATH ?? ".env");
8223
8284
  var dotenvResult = loadDotenv({
@@ -8434,6 +8495,13 @@ async function run(rawArgv) {
8434
8495
  printCommandHelpOrUsage(subcommand);
8435
8496
  return;
8436
8497
  }
8498
+ const nodeProblem = unsupportedNodeMessage();
8499
+ if (nodeProblem) {
8500
+ process.stderr.write(`${nodeProblem}
8501
+ `);
8502
+ process.exitCode = 1;
8503
+ return;
8504
+ }
8437
8505
  await command(env, rest);
8438
8506
  }
8439
8507
  function printUsage() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elgora/cli",
3
- "version": "7.4.0",
3
+ "version": "7.4.1",
4
4
  "description": "Command-line client for Elgora, a decentralized bounty marketplace for science. Lets Posters, Solvers, and Guardians interact with Elgora's public API and on-chain contracts.",
5
5
  "type": "module",
6
6
  "license": "MIT",