@tachyon-sdk/cli 0.6.53

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,62 @@
1
+ # @tachyon-sdk/cli
2
+
3
+ Global npm installer for the Tachyon CLI.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install -g @tachyon-sdk/cli
9
+ ```
10
+
11
+ This installs the `tachyon` command, plus the short alias `tc`.
12
+
13
+ ```sh
14
+ tachyon --version
15
+ tc --version
16
+ ```
17
+
18
+ During `postinstall`, the package downloads the matching native binary from
19
+ the `quantum-box/tachyon-sdk` GitHub Release. The npm package version matches
20
+ the CLI release version, so `@tachyon-sdk/cli@0.6.25` downloads
21
+ `tachyon-cli-v0.6.25`.
22
+
23
+ Supported platforms:
24
+
25
+ | OS | Architecture | Release asset |
26
+ | --- | --- | --- |
27
+ | Linux | x64 | `tachyon-linux-x86_64.tar.gz` |
28
+ | Linux | arm64 | `tachyon-linux-arm64.tar.gz` |
29
+ | macOS | arm64 | `tachyon-darwin-arm64.tar.gz` |
30
+ | macOS | x64 | `tachyon-darwin-x86_64.tar.gz` |
31
+
32
+ ## Configuration
33
+
34
+ The npm installer uses these optional environment variables:
35
+
36
+ | Variable | Purpose |
37
+ | --- | --- |
38
+ | `TACHYON_CLI_SKIP_DOWNLOAD=1` | Skip binary download during install. The wrapper will try again on first run. |
39
+ | `TACHYON_CLI_VERSION` | Override the version used to build the default release tag. |
40
+ | `TACHYON_CLI_TAG` | Override the release tag, for example `tachyon-cli-v0.6.25`. |
41
+ | `TACHYON_CLI_REPOSITORY` | Override the GitHub repository, default `quantum-box/tachyon-sdk`. |
42
+ | `TACHYON_CLI_DOWNLOAD_URL` | Override the full `.tar.gz` download URL. |
43
+
44
+ ## Cloud App internalService Support
45
+
46
+ `@tachyon-sdk/cli@0.6.13` is the first release line that can apply Cloud App
47
+ manifests with `envVars[].valueFrom.internalService`. The CLI collects those
48
+ references, calls the control-plane preflight endpoint before app mutations,
49
+ and then lets the server-side manifest apply path persist the unresolved
50
+ reference for deploy-time resolution.
51
+
52
+ CLI `0.6.12` does not support this field. Run `tachyon self-update` or install
53
+ `@tachyon-sdk/cli@0.6.13` before applying manifests that depend on internal
54
+ Cloud App service URLs.
55
+
56
+ ## Alternative Install
57
+
58
+ The standalone installer remains available:
59
+
60
+ ```sh
61
+ curl -fsSL https://raw.githubusercontent.com/quantum-box/tachyon-sdk/main/scripts/install.sh | sh
62
+ ```
package/bin/tachyon.js ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawnSync } = require("node:child_process");
5
+ const fs = require("node:fs");
6
+ const path = require("node:path");
7
+
8
+ const packageRoot = path.resolve(__dirname, "..");
9
+ const binaryPath = path.join(packageRoot, "vendor", "tachyon");
10
+
11
+ function ensureBinary() {
12
+ if (fs.existsSync(binaryPath)) {
13
+ return;
14
+ }
15
+
16
+ const installScript = path.join(packageRoot, "scripts", "install.js");
17
+ const result = spawnSync(process.execPath, [installScript], {
18
+ stdio: "inherit",
19
+ env: process.env,
20
+ });
21
+
22
+ if (result.error) {
23
+ console.error(`tachyon: failed to install the native binary: ${result.error.message}`);
24
+ process.exit(1);
25
+ }
26
+ if (result.status !== 0) {
27
+ process.exit(result.status ?? 1);
28
+ }
29
+ }
30
+
31
+ function exitFrom(result) {
32
+ if (result.error) {
33
+ console.error(`tachyon: failed to execute ${binaryPath}: ${result.error.message}`);
34
+ process.exit(1);
35
+ }
36
+
37
+ if (result.signal) {
38
+ const signalExitCodes = {
39
+ SIGINT: 130,
40
+ SIGTERM: 143,
41
+ };
42
+ process.exit(signalExitCodes[result.signal] ?? 1);
43
+ }
44
+
45
+ process.exit(result.status ?? 0);
46
+ }
47
+
48
+ ensureBinary();
49
+
50
+ const result = spawnSync(binaryPath, process.argv.slice(2), {
51
+ stdio: "inherit",
52
+ env: process.env,
53
+ });
54
+ exitFrom(result);
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@tachyon-sdk/cli",
3
+ "version": "0.6.53",
4
+ "description": "Command-line interface for the Tachyon Platform",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "tachyon": "bin/tachyon.js",
8
+ "tc": "bin/tachyon.js"
9
+ },
10
+ "files": [
11
+ "bin",
12
+ "scripts/install.js",
13
+ "scripts/platform.js",
14
+ "README.md"
15
+ ],
16
+ "scripts": {
17
+ "postinstall": "node scripts/install.js",
18
+ "check": "node --check bin/tachyon.js && node --check scripts/install.js && node --check scripts/platform.js && node --check scripts/check-version.js && node scripts/check-version.js",
19
+ "prepublishOnly": "npm run check"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/quantum-box/tachyon-sdk.git",
24
+ "directory": "packages/cli"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/quantum-box/tachyon-sdk/issues"
28
+ },
29
+ "homepage": "https://github.com/quantum-box/tachyon-sdk#readme",
30
+ "keywords": [
31
+ "tachyon",
32
+ "cli",
33
+ "cloud",
34
+ "compute"
35
+ ],
36
+ "engines": {
37
+ "node": ">=18"
38
+ },
39
+ "os": [
40
+ "darwin",
41
+ "linux"
42
+ ],
43
+ "cpu": [
44
+ "arm64",
45
+ "x64"
46
+ ],
47
+ "publishConfig": {
48
+ "access": "public"
49
+ }
50
+ }
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { execFileSync } = require("node:child_process");
5
+ const fs = require("node:fs");
6
+ const os = require("node:os");
7
+ const path = require("node:path");
8
+ const { Readable } = require("node:stream");
9
+ const { pipeline } = require("node:stream/promises");
10
+ const { resolvePlatformTarget } = require("./platform");
11
+
12
+ const packageRoot = path.resolve(__dirname, "..");
13
+ const packageJson = require(path.join(packageRoot, "package.json"));
14
+ const vendorDir = path.join(packageRoot, "vendor");
15
+ const binaryPath = path.join(vendorDir, "tachyon");
16
+
17
+ async function main() {
18
+ if (process.env.TACHYON_CLI_SKIP_DOWNLOAD === "1") {
19
+ console.log("Skipping Tachyon CLI binary download because TACHYON_CLI_SKIP_DOWNLOAD=1");
20
+ return;
21
+ }
22
+
23
+ const target = resolvePlatformTarget();
24
+ const version = normalizeVersion(process.env.TACHYON_CLI_VERSION ?? packageJson.version);
25
+ const tag = process.env.TACHYON_CLI_TAG ?? `tachyon-cli-v${version}`;
26
+ const repo = process.env.TACHYON_CLI_REPOSITORY ?? "quantum-box/tachyon-sdk";
27
+ const assetName = `${target.artifactName}.tar.gz`;
28
+ const downloadUrl =
29
+ process.env.TACHYON_CLI_DOWNLOAD_URL ??
30
+ `https://github.com/${repo}/releases/download/${tag}/${assetName}`;
31
+
32
+ fs.mkdirSync(vendorDir, { recursive: true });
33
+
34
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "tachyon-cli-"));
35
+ const archivePath = path.join(tmpDir, assetName);
36
+
37
+ try {
38
+ console.log(`Downloading Tachyon CLI ${version} for ${target.os}/${target.arch}...`);
39
+ await download(downloadUrl, archivePath);
40
+ execFileSync("tar", ["-xzf", archivePath, "-C", tmpDir], {
41
+ stdio: "inherit",
42
+ });
43
+
44
+ const extractedBinary = path.join(tmpDir, "tachyon");
45
+ if (!fs.existsSync(extractedBinary)) {
46
+ throw new Error(`Downloaded archive did not contain the tachyon binary: ${downloadUrl}`);
47
+ }
48
+
49
+ fs.copyFileSync(extractedBinary, binaryPath);
50
+ fs.chmodSync(binaryPath, 0o755);
51
+ console.log(`Installed Tachyon CLI to ${binaryPath}`);
52
+ } finally {
53
+ fs.rmSync(tmpDir, { recursive: true, force: true });
54
+ }
55
+ }
56
+
57
+ function normalizeVersion(version) {
58
+ return version.replace(/^v/, "").trim();
59
+ }
60
+
61
+ async function download(url, destinationPath) {
62
+ const response = await fetch(url, {
63
+ headers: {
64
+ "User-Agent": `@tachyon-sdk/cli/${packageJson.version}`,
65
+ },
66
+ redirect: "follow",
67
+ });
68
+
69
+ if (!response.ok) {
70
+ throw new Error(`Failed to download ${url}: ${response.status} ${response.statusText}`);
71
+ }
72
+ if (!response.body) {
73
+ throw new Error(`Failed to download ${url}: response body is empty`);
74
+ }
75
+
76
+ await pipeline(Readable.fromWeb(response.body), fs.createWriteStream(destinationPath));
77
+ }
78
+
79
+ main().catch((error) => {
80
+ console.error(error instanceof Error ? error.message : String(error));
81
+ process.exit(1);
82
+ });
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ function resolvePlatformTarget(platform = process.platform, arch = process.arch) {
4
+ const osByPlatform = {
5
+ darwin: "darwin",
6
+ linux: "linux",
7
+ };
8
+ const archByNodeArch = {
9
+ arm64: "arm64",
10
+ x64: "x86_64",
11
+ };
12
+
13
+ const os = osByPlatform[platform];
14
+ const artifactArch = archByNodeArch[arch];
15
+
16
+ if (!os || !artifactArch) {
17
+ throw new Error(
18
+ `Unsupported platform: ${platform}/${arch}. Tachyon CLI npm installs currently support macOS and Linux on arm64 or x64.`,
19
+ );
20
+ }
21
+
22
+ return {
23
+ os,
24
+ arch: artifactArch,
25
+ artifactName: `tachyon-${os}-${artifactArch}`,
26
+ };
27
+ }
28
+
29
+ module.exports = {
30
+ resolvePlatformTarget,
31
+ };