@circlesac/vlt-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/install.js +64 -0
- package/bin/install.sh +26 -0
- package/bin/vlt.mjs +15 -0
- package/package.json +28 -0
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/vlt-cli";
|
|
13
|
+
|
|
14
|
+
const PLATFORMS = {
|
|
15
|
+
"darwin-x64": { artifact: "vlt-darwin-amd64", ext: ".tar.gz" },
|
|
16
|
+
"darwin-arm64": { artifact: "vlt-darwin-arm64", ext: ".tar.gz" },
|
|
17
|
+
"linux-x64": { artifact: "vlt-linux-amd64", ext: ".tar.gz" },
|
|
18
|
+
"linux-arm64": { artifact: "vlt-linux-arm64", ext: ".tar.gz" },
|
|
19
|
+
"win32-x64": { artifact: "vlt-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, "vlt"), 0o755);
|
|
64
|
+
}
|
package/bin/install.sh
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
REPO="circlesac/vlt-cli"
|
|
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/vlt-$OS-$ARCH.tar.gz"
|
|
22
|
+
|
|
23
|
+
echo "Installing vlt $VERSION..."
|
|
24
|
+
curl -fsSL "$URL" | tar xz -C "$INSTALL_DIR"
|
|
25
|
+
chmod +x "$INSTALL_DIR/vlt"
|
|
26
|
+
echo "Installed to $INSTALL_DIR/vlt"
|
package/bin/vlt.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", `vlt${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/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@circlesac/vlt-cli",
|
|
3
|
+
"description": "1Password-compatible secrets CLI for Circles Vault",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"vlt": "bin/vlt.mjs"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "bun build --compile src/index.ts --outfile vlt",
|
|
13
|
+
"dev": "bun run src/index.ts",
|
|
14
|
+
"postinstall": "node bin/install.js"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/circlesac/vlt-cli.git"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"citty": "^0.2.1"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/bun": "latest",
|
|
25
|
+
"typescript": "^5.9.3"
|
|
26
|
+
},
|
|
27
|
+
"version": "0.0.1"
|
|
28
|
+
}
|