@cascode/cascode-cli 0.1.0-rc1

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,27 @@
1
+ @cascode/cascode-cli (npm wrapper)
2
+
3
+ This package enables a one-line install of the Cascode CLI via npm:
4
+
5
+ npm install -g @cascode/cascode-cli
6
+
7
+ How it works
8
+ - On install, a small script downloads a prebuilt, self-contained `cascode` binary
9
+ for your OS/architecture from the GitHub Releases page.
10
+ - The `cascode` command is provided via the package `bin` and forwards args to the binary.
11
+
12
+ Environment variables
13
+ - `CASCODE_DOWNLOAD_BASE` (optional): override the GitHub Releases base URL, e.g.
14
+ `https://your.mirror.example.com/cascode/releases/download`.
15
+ - `CASCODE_VERSION` (optional): if set, use this version instead of `package.json`.
16
+
17
+ Fallbacks
18
+ - If a prebuilt binary cannot be downloaded (e.g., due to network policy), you can
19
+ install the .NET global tool version:
20
+
21
+ dotnet tool install -g Cascode.Cli
22
+
23
+ Notes
24
+ - Release artifacts are expected to be named `cascode-<rid>.<zip|tar.gz>`, where rid is one of:
25
+ `win-x64`, `win-arm64`, `osx-x64`, `osx-arm64`, `linux-x64`, `linux-arm64`.
26
+ - The repository’s release workflow should publish those assets alongside tags matching the npm package version.
27
+
package/bin/cascode.js ADDED
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawn } = require("child_process");
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+
8
+ function rid() {
9
+ const p = process.platform;
10
+ const a = process.arch;
11
+ if (p === "win32") return a === "arm64" ? "win-arm64" : "win-x64";
12
+ if (p === "darwin") return a === "arm64" ? "osx-arm64" : "osx-x64";
13
+ if (p === "linux") return a === "arm64" ? "linux-arm64" : "linux-x64";
14
+ return `${p}-${a}`;
15
+ }
16
+
17
+ function binPath() {
18
+ const base = path.join(__dirname, "..", "vendor", rid());
19
+ const names = process.platform === "win32" ? ["cascode.exe", "Cascode.Cli.exe"] : ["cascode", "Cascode.Cli"];
20
+ for (const n of names) {
21
+ const p = path.join(base, n);
22
+ if (fs.existsSync(p)) return p;
23
+ }
24
+ return path.join(base, names[0]);
25
+ }
26
+
27
+ const exe = binPath();
28
+ if (!fs.existsSync(exe)) {
29
+ console.error("cascode: no platform binary found at", exe);
30
+ console.error(
31
+ "Install step could not fetch a prebuilt binary. Options:\n" +
32
+ " 1) Ensure your network permits downloads from GitHub Releases and reinstall, or set CASCODE_DOWNLOAD_BASE.\n" +
33
+ " 2) Use the .NET tool: dotnet tool install -g Cascode.Cli\n" +
34
+ " 3) Download a release binary manually from https://github.com/daniellovell/cascode/releases"
35
+ );
36
+ process.exit(1);
37
+ }
38
+
39
+ const args = process.argv.slice(2);
40
+ const child = spawn(exe, args, { stdio: "inherit" });
41
+ child.on("exit", (code, signal) => {
42
+ if (signal) {
43
+ process.kill(process.pid, signal);
44
+ } else {
45
+ process.exit(code ?? 0);
46
+ }
47
+ });
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@cascode/cascode-cli",
3
+ "version": "0.1.0-rc1",
4
+ "description": "Cascode CLI installer wrapper. Installs a prebuilt cascode binary for your platform.",
5
+ "homepage": "https://github.com/daniellovell/cascode",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/daniellovell/cascode.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/daniellovell/cascode/issues"
12
+ },
13
+ "license": "UNLICENSED",
14
+ "private": false,
15
+ "bin": {
16
+ "cascode": "bin/cascode.js"
17
+ },
18
+ "scripts": {
19
+ "postinstall": "node scripts/postinstall.js",
20
+ "prepack": "node -e \"const fs=require('fs'); if(!fs.existsSync('bin/cascode.js')){console.error('Missing bin/cascode.js'); process.exit(1)}\""
21
+ },
22
+ "keywords": [
23
+ "eda",
24
+ "analog",
25
+ "circuit",
26
+ "synthesis",
27
+ "cli"
28
+ ],
29
+ "engines": {
30
+ "node": ">=16"
31
+ },
32
+ "os": [
33
+ "darwin",
34
+ "linux",
35
+ "win32"
36
+ ],
37
+ "dependencies": {
38
+ "tar": "^6.2.1",
39
+ "unzipper": "^0.10.14"
40
+ },
41
+ "files": [
42
+ "bin/",
43
+ "scripts/",
44
+ "vendor/",
45
+ "README.md"
46
+ ]
47
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const https = require("https");
6
+ const { pipeline } = require("stream");
7
+ const zlib = require("zlib");
8
+ const tar = require("tar");
9
+ const unzipper = require("unzipper");
10
+
11
+ function rid() {
12
+ const p = process.platform;
13
+ const a = process.arch;
14
+ if (p === "win32") return a === "arm64" ? "win-arm64" : "win-x64";
15
+ if (p === "darwin") return a === "arm64" ? "osx-arm64" : "osx-x64";
16
+ if (p === "linux") return a === "arm64" ? "linux-arm64" : "linux-x64";
17
+ return `${p}-${a}`;
18
+ }
19
+
20
+ function getPkgVersion() {
21
+ try {
22
+ const pkg = require(path.join(__dirname, "..", "package.json"));
23
+ return pkg.version;
24
+ } catch {
25
+ return process.env.CASCODE_VERSION || "0.0.0";
26
+ }
27
+ }
28
+
29
+ function dl(url) {
30
+ return new Promise((resolve, reject) => {
31
+ https
32
+ .get(url, (res) => {
33
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
34
+ // Follow redirect
35
+ return resolve(dl(res.headers.location));
36
+ }
37
+ if (res.statusCode !== 200) {
38
+ return reject(new Error(`Download failed: ${res.statusCode} ${res.statusMessage}`));
39
+ }
40
+ resolve(res);
41
+ })
42
+ .on("error", reject);
43
+ });
44
+ }
45
+
46
+ async function main() {
47
+ const platformRid = rid();
48
+ const isWin = process.platform === "win32";
49
+ const version = getPkgVersion();
50
+ const base = process.env.CASCODE_DOWNLOAD_BASE || "https://github.com/daniellovell/cascode/releases/download";
51
+ const asset = `cascode-${platformRid}.${isWin ? "zip" : "tar.gz"}`;
52
+ const url = `${base}/v${version}/${asset}`;
53
+
54
+ const destDir = path.join(__dirname, "..", "vendor", platformRid);
55
+ const exeName = isWin ? "cascode.exe" : "cascode";
56
+ const altName = isWin ? "Cascode.Cli.exe" : "Cascode.Cli";
57
+ const destExe = path.join(destDir, exeName);
58
+ if (fs.existsSync(destExe)) {
59
+ return; // already present
60
+ }
61
+ fs.mkdirSync(destDir, { recursive: true });
62
+
63
+ console.log(`cascode: downloading ${asset} ...`);
64
+ try {
65
+ const res = await dl(url);
66
+ if (isWin) {
67
+ await pipeline(res, unzipper.Extract({ path: destDir }), (e) => (e ? Promise.reject(e) : Promise.resolve()));
68
+ } else {
69
+ await pipeline(res, zlib.createGunzip(), tar.x({ cwd: destDir }), (e) => (e ? Promise.reject(e) : Promise.resolve()));
70
+ }
71
+ // Normalize executable name to 'cascode[.exe]'
72
+ const altExe = path.join(destDir, altName);
73
+ if (!fs.existsSync(destExe) && fs.existsSync(altExe)) {
74
+ fs.renameSync(altExe, destExe);
75
+ }
76
+ if (process.platform !== "win32" && fs.existsSync(destExe)) {
77
+ fs.chmodSync(destExe, 0o755);
78
+ }
79
+ console.log("cascode: install complete.");
80
+ } catch (err) {
81
+ console.warn("cascode: prebuilt download failed:", err.message);
82
+ console.warn(
83
+ "You can either retry with network access, set CASCODE_DOWNLOAD_BASE to your mirror, or install the .NET tool: dotnet tool install -g Cascode.Cli"
84
+ );
85
+ }
86
+ }
87
+
88
+ main().catch((e) => {
89
+ console.warn("cascode: unexpected error during install:", e);
90
+ });
@@ -0,0 +1 @@
1
+