@ketryx/cli 0.1.0-alpha.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 ADDED
@@ -0,0 +1,6 @@
1
+ # Ketryx CLI
2
+
3
+ This package installs the Ketryx CLI for your platform by pulling in the
4
+ matching optional dependency (for example `@ketryx/cli-darwin-arm64`).
5
+
6
+ If you need a specific platform package, you can install it directly instead.
package/bin/ketryx ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+ const { spawn } = require("node:child_process");
3
+ const fs = require("node:fs");
4
+ const path = require("node:path");
5
+
6
+ const platform = process.platform;
7
+ const arch = process.arch;
8
+ const key = `${platform}:${arch}`;
9
+
10
+ const packageMap = require("../platform-map");
11
+
12
+ const packageName = packageMap[key];
13
+ if (!packageName) {
14
+ console.error(`Unsupported platform for Ketryx CLI: ${platform} ${arch}.`);
15
+ process.exit(1);
16
+ }
17
+
18
+ let packageRoot;
19
+ try {
20
+ packageRoot = path.dirname(require.resolve(`${packageName}/package.json`));
21
+ } catch (error) {
22
+ console.error(
23
+ `Ketryx CLI platform package not found (${packageName}). Install it in this workspace.`,
24
+ );
25
+ if (error && error.message) {
26
+ console.error(error.message);
27
+ }
28
+ process.exit(1);
29
+ }
30
+
31
+ const binaryName = platform === "win32" ? "ketryx.exe" : "ketryx";
32
+ const binaryPath = path.join(packageRoot, "bin", binaryName);
33
+ if (!fs.existsSync(binaryPath)) {
34
+ console.error(`Ketryx CLI binary not found at ${binaryPath}.`);
35
+ process.exit(1);
36
+ }
37
+
38
+ const child = spawn(binaryPath, process.argv.slice(2), { stdio: "inherit" });
39
+ child.on("exit", (code, signal) => {
40
+ if (signal) {
41
+ process.kill(process.pid, signal);
42
+ } else {
43
+ process.exit(code ?? 1);
44
+ }
45
+ });
package/install.js ADDED
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+ const fs = require("node:fs");
3
+ const path = require("node:path");
4
+
5
+ const platform = process.platform;
6
+ const arch = process.arch;
7
+ const key = `${platform}:${arch}`;
8
+
9
+ const packageMap = require("./platform-map");
10
+
11
+ const packageName = packageMap[key];
12
+ if (!packageName) {
13
+ console.error(`Unsupported platform for Ketryx CLI: ${platform} ${arch}.`);
14
+ process.exit(1);
15
+ }
16
+
17
+ let packageRoot;
18
+ try {
19
+ packageRoot = path.dirname(require.resolve(`${packageName}/package.json`));
20
+ } catch (error) {
21
+ console.error(
22
+ `Ketryx CLI platform package not found (${packageName}). Make sure optionalDependencies are installed.`,
23
+ );
24
+ if (error && error.message) {
25
+ console.error(error.message);
26
+ }
27
+ process.exit(1);
28
+ }
29
+
30
+ const binaryName = platform === "win32" ? "ketryx.exe" : "ketryx";
31
+ const binaryPath = path.join(packageRoot, "bin", binaryName);
32
+ if (!fs.existsSync(binaryPath)) {
33
+ console.error(`Ketryx CLI binary not found at ${binaryPath}.`);
34
+ process.exit(1);
35
+ }
36
+
37
+ const { execFileSync } = require("node:child_process");
38
+ const expectedVersion = require(path.join(__dirname, "package.json")).version;
39
+ try {
40
+ const actualVersion = execFileSync(binaryPath, ["--version"], { encoding: "utf8" }).trim();
41
+ if (actualVersion !== expectedVersion) {
42
+ throw new Error(`Expected ${expectedVersion} but got ${actualVersion}`);
43
+ }
44
+ } catch (error) {
45
+ console.error("Ketryx CLI version check failed.");
46
+ if (error && error.message) {
47
+ console.error(error.message);
48
+ }
49
+ process.exit(1);
50
+ }
51
+
52
+ const toPath = path.join(__dirname, "bin", "ketryx");
53
+ if (platform !== "win32") {
54
+ const tempPath = path.join(__dirname, "bin-ketryx");
55
+ try {
56
+ fs.linkSync(binaryPath, tempPath);
57
+ fs.renameSync(tempPath, toPath);
58
+ } catch (error) {
59
+ if (error && error.message) {
60
+ console.error(error.message);
61
+ }
62
+ }
63
+ }
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@ketryx/cli",
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "Ketryx CLI",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "ketryx": "bin/ketryx"
8
+ },
9
+ "files": [
10
+ "install.js",
11
+ "LICENSE",
12
+ "platform-map.js",
13
+ "README.md",
14
+ "bin/ketryx"
15
+ ],
16
+ "scripts": {
17
+ "postinstall": "node install.js"
18
+ },
19
+ "optionalDependencies": {
20
+ "@ketryx/cli-darwin-arm64": "0.1.0-alpha.1",
21
+ "@ketryx/cli-darwin-x64": "0.1.0-alpha.1",
22
+ "@ketryx/cli-linux-arm64": "0.1.0-alpha.1",
23
+ "@ketryx/cli-linux-x64": "0.1.0-alpha.1",
24
+ "@ketryx/cli-win32-x64": "0.1.0-alpha.1"
25
+ }
26
+ }
@@ -0,0 +1,8 @@
1
+ // This file is generated by `bun run sync:versions`. Do not edit by hand.
2
+ module.exports = {
3
+ "darwin:arm64": "@ketryx/cli-darwin-arm64",
4
+ "darwin:x64": "@ketryx/cli-darwin-x64",
5
+ "linux:arm64": "@ketryx/cli-linux-arm64",
6
+ "linux:x64": "@ketryx/cli-linux-x64",
7
+ "win32:x64": "@ketryx/cli-win32-x64"
8
+ };