@botbuddy/cli 1.63.32 → 1.63.33
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/daemon/bin/darwin-arm64/botbuddy-daemon +0 -0
- package/daemon/bin/linux-x64/botbuddy-daemon +0 -0
- package/daemon-release/darwin-arm64.json +4 -4
- package/daemon-release/linux-x64.json +4 -4
- package/daemon-release/manifest.json +5 -5
- package/package.json +1 -1
- package/src/update-check.mjs +44 -19
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.63.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.63.33",
|
|
3
|
+
"source_commit": "70dd5a394a7180acebe24941d884cec93eb5f1cc",
|
|
4
|
+
"source_sha256": "16eed9e08035023447c0c964ce608a2a7324a24fdbe21df4de3085fda26f3bfc",
|
|
5
5
|
"target": "darwin-arm64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "41ea9976bf224497e18148142d93ae53b231e16d814ee0f7d406cc82d5a6d39f"
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.63.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.63.33",
|
|
3
|
+
"source_commit": "70dd5a394a7180acebe24941d884cec93eb5f1cc",
|
|
4
|
+
"source_sha256": "16eed9e08035023447c0c964ce608a2a7324a24fdbe21df4de3085fda26f3bfc",
|
|
5
5
|
"target": "linux-x64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "94e4da81775defe0589d339d1eac3f6885ee529ec4df71aa35809cb6d498c5b3"
|
|
7
7
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": 1,
|
|
3
|
-
"release_version": "1.63.
|
|
4
|
-
"source_commit": "
|
|
5
|
-
"source_sha256": "
|
|
3
|
+
"release_version": "1.63.33",
|
|
4
|
+
"source_commit": "70dd5a394a7180acebe24941d884cec93eb5f1cc",
|
|
5
|
+
"source_sha256": "16eed9e08035023447c0c964ce608a2a7324a24fdbe21df4de3085fda26f3bfc",
|
|
6
6
|
"targets": {
|
|
7
7
|
"darwin-arm64": {
|
|
8
8
|
"goos": "darwin",
|
|
9
9
|
"goarch": "arm64",
|
|
10
10
|
"binary": "daemon/bin/darwin-arm64/botbuddy-daemon",
|
|
11
|
-
"sha256": "
|
|
11
|
+
"sha256": "41ea9976bf224497e18148142d93ae53b231e16d814ee0f7d406cc82d5a6d39f",
|
|
12
12
|
"mode": "0755"
|
|
13
13
|
},
|
|
14
14
|
"linux-x64": {
|
|
15
15
|
"goos": "linux",
|
|
16
16
|
"goarch": "amd64",
|
|
17
17
|
"binary": "daemon/bin/linux-x64/botbuddy-daemon",
|
|
18
|
-
"sha256": "
|
|
18
|
+
"sha256": "94e4da81775defe0589d339d1eac3f6885ee529ec4df71aa35809cb6d498c5b3",
|
|
19
19
|
"mode": "0755"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/package.json
CHANGED
package/src/update-check.mjs
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
// off to a detached, unref'd `npm install -g` and exits 0.
|
|
14
14
|
|
|
15
15
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
16
|
+
import { readFileSync } from "node:fs";
|
|
16
17
|
import { spawn, spawnSync } from "node:child_process";
|
|
17
18
|
import { homedir } from "node:os";
|
|
18
19
|
import { dirname, join } from "node:path";
|
|
@@ -22,7 +23,11 @@ import { VERSION } from "./version.mjs";
|
|
|
22
23
|
export const UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
23
24
|
export const NPM_LATEST_URL = "https://registry.npmjs.org/@botbuddy/cli/latest";
|
|
24
25
|
export const NPM_LATEST_TIMEOUT_MS = 1500;
|
|
25
|
-
export const UPDATE_COMMAND = "npm
|
|
26
|
+
export const UPDATE_COMMAND = "npm install -g @botbuddy/cli@latest";
|
|
27
|
+
|
|
28
|
+
export function formatUpdateOffer(current, latest) {
|
|
29
|
+
return `\nUpdate available\n Current: v${current}\n Latest: v${latest}\n Run: bb update\n`;
|
|
30
|
+
}
|
|
26
31
|
|
|
27
32
|
export function defaultUpdateCheckCachePath(home = homedir()) {
|
|
28
33
|
return join(home, ".botbuddy", "update-check.json");
|
|
@@ -106,16 +111,26 @@ export async function maybeWarnStale({
|
|
|
106
111
|
await writeCache(cachePath, { checkedAt: now(), latest });
|
|
107
112
|
}
|
|
108
113
|
if (typeof latest !== "string" || !isNewerVersion(latest, version)) return { warned: false, latest: latest ?? null };
|
|
109
|
-
stderr.write(
|
|
114
|
+
stderr.write(formatUpdateOffer(version, latest));
|
|
110
115
|
return { warned: true, latest };
|
|
111
116
|
} catch {
|
|
112
117
|
return { warned: false, latest: null };
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
120
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
121
|
+
export function readInstalledVersion({ npmBin = "npm", shellOpt = {}, probeImpl = spawnSync, readPackage = readFileSync } = {}) {
|
|
122
|
+
const root = probeImpl(npmBin, ["root", "-g"], { encoding: "utf8", ...shellOpt });
|
|
123
|
+
if (root?.error || root?.status !== 0) throw new Error(`npm global root lookup failed for ${npmBin}`);
|
|
124
|
+
const directory = String(root?.stdout ?? "").trim();
|
|
125
|
+
if (!directory) throw new Error("npm global root lookup returned no directory");
|
|
126
|
+
const packageJson = JSON.parse(readPackage(join(directory, "@botbuddy", "cli", "package.json"), "utf8"));
|
|
127
|
+
if (typeof packageJson?.version !== "string" || !parseSemver(packageJson.version)) throw new Error("installed @botbuddy/cli package has no valid version");
|
|
128
|
+
return packageJson.version;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// `botbuddy update` waits for npm because the terminal result, rather than the
|
|
132
|
+
// child-process launch, is the only trustworthy confirmation an update worked.
|
|
133
|
+
export function cmdUpdate({ version = VERSION, spawnImpl = spawn, probeImpl = spawnSync, readInstalledVersion: installedVersion = readInstalledVersion, log = (line) => console.log(line), platform = process.platform, stderr = process.stderr } = {}) {
|
|
119
134
|
// BOT-1566 (Codex P1/P2): on Windows npm is the `npm.cmd` shim, and Node
|
|
120
135
|
// cannot spawn a .cmd file shell-free (docs) — run it through a shell on
|
|
121
136
|
// win32 (args are all static constants, so no injection surface) and select
|
|
@@ -134,34 +149,44 @@ export function cmdUpdate({ version = VERSION, spawnImpl = spawn, probeImpl = sp
|
|
|
134
149
|
try { stderr.write(`botbuddy update: npm was not found — install Node.js/npm, then retry (looked for ${npmBin})\n`); } catch { /* ignore */ }
|
|
135
150
|
return Promise.resolve(1);
|
|
136
151
|
}
|
|
152
|
+
log(`BotBuddy CLI update\n Current: v${version}\n\n$ ${UPDATE_COMMAND}`);
|
|
137
153
|
const child = spawnImpl(npmBin, ["install", "-g", "@botbuddy/cli@latest"], {
|
|
138
154
|
stdio: "inherit",
|
|
139
|
-
detached: true,
|
|
140
155
|
...shellOpt,
|
|
141
156
|
});
|
|
142
|
-
// Node reports a launch failure asynchronously via the `error` event
|
|
143
|
-
//
|
|
144
|
-
//
|
|
157
|
+
// Node reports a launch failure asynchronously via the `error` event. A
|
|
158
|
+
// successfully spawned child can still fail its install, so only `close: 0`
|
|
159
|
+
// plus a readable npm global package metadata record is a success.
|
|
145
160
|
return new Promise((resolve) => {
|
|
146
161
|
if (!child || typeof child.once !== "function") {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
resolve(0);
|
|
162
|
+
try { stderr.write("botbuddy update: npm did not return a trackable process\n"); } catch { /* ignore */ }
|
|
163
|
+
resolve(1);
|
|
150
164
|
return;
|
|
151
165
|
}
|
|
152
166
|
let settled = false;
|
|
153
|
-
child.once("spawn", () => {
|
|
154
|
-
if (settled) return;
|
|
155
|
-
settled = true;
|
|
156
|
-
if (typeof child.unref === "function") child.unref();
|
|
157
|
-
log("updating in background — re-run botbuddy --version to confirm");
|
|
158
|
-
resolve(0);
|
|
159
|
-
});
|
|
160
167
|
child.once("error", (err) => {
|
|
161
168
|
if (settled) return;
|
|
162
169
|
settled = true;
|
|
163
170
|
try { stderr.write(`botbuddy update: failed to launch npm (${err?.message ?? err})\n`); } catch { /* ignore */ }
|
|
164
171
|
resolve(1);
|
|
165
172
|
});
|
|
173
|
+
child.once("close", (code, signal) => {
|
|
174
|
+
if (settled) return;
|
|
175
|
+
settled = true;
|
|
176
|
+
if (code !== 0 || signal) {
|
|
177
|
+
const reason = signal ? `signal ${signal}` : `code ${code ?? "unknown"}`;
|
|
178
|
+
try { stderr.write(`botbuddy update: npm exited with ${reason}; no update was confirmed\n`); } catch { /* ignore */ }
|
|
179
|
+
resolve(1);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
const installed = installedVersion({ npmBin, shellOpt });
|
|
184
|
+
log(`✓ Updated to v${installed}`);
|
|
185
|
+
resolve(0);
|
|
186
|
+
} catch (error) {
|
|
187
|
+
try { stderr.write(`botbuddy update: npm completed but could not verify the installed version (${error?.message ?? error})\n`); } catch { /* ignore */ }
|
|
188
|
+
resolve(1);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
166
191
|
});
|
|
167
192
|
}
|