crcl-cli 0.0.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/bin/crcl.mjs ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from "node:child_process";
3
+ import { existsSync } from "node:fs";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
+ const ext = process.platform === "win32" ? ".exe" : "";
9
+ const bin = path.join(__dirname, "native", `crcl${ext}`);
10
+
11
+ if (!existsSync(bin)) {
12
+ await import("./install.js");
13
+ }
14
+ const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
15
+ process.exit(result.status ?? 1);
package/bin/install.js ADDED
@@ -0,0 +1,64 @@
1
+ import https from "node:https";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { execSync } from "node:child_process";
5
+ import { createRequire } from "node:module";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ const require = createRequire(import.meta.url);
9
+ const { version } = require("../package.json");
10
+
11
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
12
+ const REPO = "circlesac/crcl";
13
+
14
+ const PLATFORMS = {
15
+ "darwin-x64": { artifact: "crcl-darwin-amd64", ext: ".tar.gz" },
16
+ "darwin-arm64": { artifact: "crcl-darwin-arm64", ext: ".tar.gz" },
17
+ "linux-x64": { artifact: "crcl-linux-amd64", ext: ".tar.gz" },
18
+ "linux-arm64": { artifact: "crcl-linux-arm64", ext: ".tar.gz" },
19
+ "win32-x64": { artifact: "crcl-windows-amd64", ext: ".zip" },
20
+ };
21
+
22
+ function download(url) {
23
+ return new Promise((resolve, reject) => {
24
+ https.get(url, (res) => {
25
+ if (res.statusCode === 302 || res.statusCode === 301) {
26
+ return download(res.headers.location).then(resolve).catch(reject);
27
+ }
28
+ if (res.statusCode !== 200) return reject(new Error(`HTTP ${res.statusCode}`));
29
+ const chunks = [];
30
+ res.on("data", (c) => chunks.push(c));
31
+ res.on("end", () => resolve(Buffer.concat(chunks)));
32
+ res.on("error", reject);
33
+ });
34
+ });
35
+ }
36
+
37
+ if (process.env.CI) process.exit(0);
38
+
39
+ const platform = `${process.platform}-${process.arch}`;
40
+ const info = PLATFORMS[platform];
41
+ if (!info) {
42
+ console.error(`Unsupported platform: ${platform}`);
43
+ process.exit(1);
44
+ }
45
+
46
+ const { artifact, ext } = info;
47
+ const url = `https://github.com/${REPO}/releases/download/v${version}/${artifact}${ext}`;
48
+ const nativeDir = path.join(__dirname, "native");
49
+ fs.mkdirSync(nativeDir, { recursive: true });
50
+
51
+ const data = await download(url);
52
+ const tmp = path.join(nativeDir, `tmp${ext}`);
53
+ fs.writeFileSync(tmp, data);
54
+
55
+ if (ext === ".zip") {
56
+ execSync(`powershell -Command "Expand-Archive -Force '${tmp}' '${nativeDir}'"`, { cwd: nativeDir });
57
+ } else {
58
+ execSync(`tar xzf "${tmp}"`, { cwd: nativeDir });
59
+ }
60
+ fs.unlinkSync(tmp);
61
+
62
+ if (process.platform !== "win32") {
63
+ fs.chmodSync(path.join(nativeDir, "crcl"), 0o755);
64
+ }
package/bin/install.sh ADDED
@@ -0,0 +1,26 @@
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ REPO="circlesac/crcl"
5
+ INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
6
+
7
+ OS=$(uname -s | tr '[:upper:]' '[:lower:]')
8
+ ARCH=$(uname -m)
9
+
10
+ case "$ARCH" in
11
+ x86_64) ARCH="amd64" ;;
12
+ aarch64) ARCH="arm64" ;;
13
+ esac
14
+
15
+ case "$OS-$ARCH" in
16
+ darwin-arm64|darwin-amd64|linux-amd64|linux-arm64) ;;
17
+ *) echo "Unsupported platform: $OS-$ARCH"; exit 1 ;;
18
+ esac
19
+
20
+ VERSION=$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name"' | cut -d'"' -f4)
21
+ URL="https://github.com/$REPO/releases/download/$VERSION/crcl-$OS-$ARCH.tar.gz"
22
+
23
+ echo "Installing crcl $VERSION..."
24
+ curl -fsSL "$URL" | tar xz -C "$INSTALL_DIR"
25
+ chmod +x "$INSTALL_DIR/crcl"
26
+ echo "Installed to $INSTALL_DIR/crcl"
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "crcl-cli",
3
+ "version": "0.0.1",
4
+ "description": "Circles CLI — manage orgs, API keys, and authenticate with circles.ac",
5
+ "type": "module",
6
+ "bin": {
7
+ "crcl": "bin/crcl.mjs"
8
+ },
9
+ "files": ["bin"],
10
+ "scripts": {
11
+ "build": "bun build src/index.ts --compile --outfile crcl",
12
+ "dev": "bun run src/index.ts",
13
+ "test": "vitest run",
14
+ "test:coverage": "vitest run --coverage",
15
+ "postinstall": "node bin/install.js"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/circlesac/crcl.git"
20
+ },
21
+ "devDependencies": {
22
+ "@types/bun": "latest",
23
+ "@vitest/coverage-v8": "^4.1.0",
24
+ "typescript": "^5.9.3",
25
+ "vitest": "^4.1.0"
26
+ }
27
+ }