@shiploom/cli 1.1.0 → 1.2.0
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/install.js +32 -5
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// global fetch, no dependencies). The binary itself runs fully offline.
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
|
-
const { createWriteStream, chmodSync, mkdirSync, existsSync } = require("fs");
|
|
6
|
+
const { createWriteStream, chmodSync, mkdirSync, existsSync, readFileSync, writeFileSync, unlinkSync } = require("fs");
|
|
7
7
|
const { get } = require("https");
|
|
8
8
|
const { join } = require("path");
|
|
9
9
|
const { spawnSync } = require("child_process");
|
|
@@ -43,18 +43,45 @@ function download(url, dest) {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
function dataReady(dir) {
|
|
47
|
+
if (!existsSync(join(dir, "schemas", "artifact-frontmatter.schema.json"))) return false;
|
|
48
|
+
try {
|
|
49
|
+
return readFileSync(join(dir, ".data-version"), "utf8").trim() === VERSION;
|
|
50
|
+
} catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function extractTarball(archive, dir) {
|
|
56
|
+
const tar = spawnSync("tar", ["-xzf", archive, "-C", dir], { encoding: "utf8" });
|
|
57
|
+
if (tar.status !== 0) {
|
|
58
|
+
throw new Error(`extract failed (need a 'tar' binary): ${String(tar.stderr || "").trim()}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
46
62
|
(async () => {
|
|
47
63
|
const dir = join(__dirname, "vendor");
|
|
48
64
|
mkdirSync(dir, { recursive: true });
|
|
49
65
|
const dest = join(dir, process.platform === "win32" ? "shiploom.exe" : "shiploom");
|
|
50
66
|
if (existsSync(dest)) {
|
|
51
67
|
const check = spawnSync(dest, ["--version"], { encoding: "utf8" });
|
|
52
|
-
if (check.status === 0 && String(check.stdout).includes(VERSION)) return;
|
|
68
|
+
if (check.status === 0 && String(check.stdout).includes(VERSION) && dataReady(dir)) return;
|
|
53
69
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
70
|
+
const base = `https://github.com/shiploom/ai-builder/releases/download/v${VERSION}`;
|
|
71
|
+
const binName = asset();
|
|
72
|
+
process.stderr.write(`shiploom: downloading ${binName} ...\n`);
|
|
73
|
+
await download(`${base}/${binName}`, dest);
|
|
57
74
|
chmodSync(dest, 0o755);
|
|
75
|
+
// Tool data (schemas + core workflows/policies/hooks/skills/roles) so the
|
|
76
|
+
// binary resolves everything exe-relative outside a repo checkout.
|
|
77
|
+
const dataName = `shiploom-data-${VERSION}.tar.gz`;
|
|
78
|
+
const archive = join(dir, dataName);
|
|
79
|
+
process.stderr.write(`shiploom: downloading ${dataName} ...\n`);
|
|
80
|
+
await download(`${base}/${dataName}`, archive);
|
|
81
|
+
extractTarball(archive, dir);
|
|
82
|
+
unlinkSync(archive);
|
|
83
|
+
writeFileSync(join(dir, ".data-version"), VERSION + "\n");
|
|
84
|
+
if (!dataReady(dir)) throw new Error(`data install incomplete in ${dir}`);
|
|
58
85
|
})().catch((err) => {
|
|
59
86
|
process.stderr.write(`shiploom: install failed: ${err.message}\n`);
|
|
60
87
|
process.exit(1);
|