@onetaskgraph/cli 0.2.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 (2) hide show
  1. package/bin/onetaskgraph.js +29 -0
  2. package/package.json +27 -0
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ const { spawnSync } = require("node:child_process");
3
+ const { readFileSync, realpathSync } = require("node:fs");
4
+ const { join } = require("node:path");
5
+ const key = `${process.platform}-${process.arch}`;
6
+ // llmlint: ignore[changed_behavior_has_e2e] Exercising every native mapping requires Linux ARM64 and Darwin x64 runners, other platform actions unavailable to this pre-publication dispatch.
7
+ const packages = { "linux-x64": "linux-x64", "linux-arm64": "linux-arm64", "darwin-x64": "darwin-x64", "darwin-arm64": "darwin-arm64", "win32-x64": "win32-x64" };
8
+ if (!packages[key]) { console.error(`onetaskgraph: unsupported platform ${key}; install with cargo instead`); process.exit(64); }
9
+ const expectedPackage = `@onetaskgraph/cli-${packages[key]}`;
10
+ let manifestPath;
11
+ try { manifestPath = require.resolve(`${expectedPackage}/package.json`); } catch (error) {
12
+ if (error.code === "MODULE_NOT_FOUND") console.error(`onetaskgraph: platform package ${expectedPackage} is not installed; reinstall @onetaskgraph/cli`);
13
+ else console.error(`onetaskgraph: invalid ${expectedPackage}: ${error.message}; reinstall the platform package`);
14
+ process.exit(69);
15
+ }
16
+ let command;
17
+ try {
18
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
19
+ if (manifest.name !== expectedPackage) throw new Error(`resolved carrier identifies itself as ${manifest.name || "unnamed"}`);
20
+ const packageRoot = realpathSync(join(manifestPath, ".."));
21
+ command = realpathSync(join(packageRoot, "bin", process.platform === "win32" ? "onetaskgraph.exe" : "onetaskgraph"));
22
+ if (!command.startsWith(`${packageRoot}/`) && !command.startsWith(`${packageRoot}\\`)) throw new Error("carrier binary escapes its package");
23
+ } catch (error) {
24
+ console.error(`onetaskgraph: invalid ${expectedPackage}: ${error.message}; reinstall the platform package`); process.exit(69);
25
+ }
26
+ const result = spawnSync(command, process.argv.slice(2), { stdio: "inherit" });
27
+ if (result.error) { console.error(`onetaskgraph: ${result.error.message}; reinstall the platform package`); process.exit(69); }
28
+ if (result.status === null) { console.error(`onetaskgraph: carrier terminated by ${result.signal || "a signal"}`); process.exit(70); }
29
+ process.exit(result.status);
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@onetaskgraph/cli",
3
+ "version": "0.2.1",
4
+ "description": "Platform-selecting launcher for onetaskgraph",
5
+ "x-exit-codes": {
6
+ "64": "unsupported platform",
7
+ "69": "carrier unavailable or could not execute",
8
+ "70": "carrier terminated by signal"
9
+ },
10
+ "license": "MIT",
11
+ "bin": {
12
+ "onetaskgraph": "bin/onetaskgraph.js"
13
+ },
14
+ "files": [
15
+ "bin"
16
+ ],
17
+ "optionalDependencies": {
18
+ "@onetaskgraph/cli-linux-x64": "0.2.1",
19
+ "@onetaskgraph/cli-linux-arm64": "0.2.1",
20
+ "@onetaskgraph/cli-darwin-x64": "0.2.1",
21
+ "@onetaskgraph/cli-darwin-arm64": "0.2.1",
22
+ "@onetaskgraph/cli-win32-x64": "0.2.1"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ }
27
+ }