codewhale 0.9.8 → 0.9.10
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 +21 -12
- package/package.json +2 -2
- package/scripts/artifacts.js +85 -16
- package/scripts/install.js +532 -53
- package/scripts/run.js +3 -0
- package/scripts/verify-release-assets.js +19 -4
- package/test/install.test.js +64 -2
- package/test/postinstall.test.js +1 -0
- package/test/release-assets.test.js +37 -2
- package/test/source-selection.test.js +866 -0
package/scripts/run.js
CHANGED
|
@@ -9,6 +9,9 @@ function isVersionFlag(args = process.argv.slice(2)) {
|
|
|
9
9
|
|
|
10
10
|
function printVersionFallback(binaryName) {
|
|
11
11
|
const binVersion =
|
|
12
|
+
process.env.CODEWHALE_VERSION ||
|
|
13
|
+
process.env.DEEPSEEK_TUI_VERSION ||
|
|
14
|
+
process.env.DEEPSEEK_VERSION ||
|
|
12
15
|
pkg.codewhaleBinaryVersion || pkg.deepseekBinaryVersion || pkg.version;
|
|
13
16
|
console.log(`${binaryName} (npm wrapper) v${pkg.version}`);
|
|
14
17
|
console.log(`binary version: v${binVersion}`);
|
|
@@ -16,6 +16,7 @@ const pkg = require("../package.json");
|
|
|
16
16
|
|
|
17
17
|
function resolveBinaryVersion() {
|
|
18
18
|
const configuredVersion =
|
|
19
|
+
process.env.CODEWHALE_VERSION ||
|
|
19
20
|
process.env.DEEPSEEK_TUI_VERSION ||
|
|
20
21
|
process.env.DEEPSEEK_VERSION ||
|
|
21
22
|
pkg.codewhaleBinaryVersion || pkg.deepseekBinaryVersion ||
|
|
@@ -24,7 +25,12 @@ function resolveBinaryVersion() {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
function resolveRepo() {
|
|
27
|
-
return
|
|
28
|
+
return (
|
|
29
|
+
process.env.CODEWHALE_GITHUB_REPO ||
|
|
30
|
+
process.env.DEEPSEEK_TUI_GITHUB_REPO ||
|
|
31
|
+
process.env.DEEPSEEK_GITHUB_REPO ||
|
|
32
|
+
"Hmbown/CodeWhale"
|
|
33
|
+
);
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
function hasReleaseBaseOverride() {
|
|
@@ -229,7 +235,11 @@ async function findReleaseWorkflowRun(repo, tag, tagSha, api = githubApi) {
|
|
|
229
235
|
(job) => job.name === "release" && job.conclusion === "success",
|
|
230
236
|
);
|
|
231
237
|
if (releaseJob) {
|
|
232
|
-
|
|
238
|
+
// #5429: pin asset freshness to the successful release job's own
|
|
239
|
+
// started_at, not the run-level run_started_at. A job-level rerun
|
|
240
|
+
// (`gh run rerun --failed`) bumps run_started_at past the asset upload
|
|
241
|
+
// timestamps even though this release job produced those assets.
|
|
242
|
+
return { ...candidate, release_job_started_at: releaseJob.started_at || null };
|
|
233
243
|
}
|
|
234
244
|
}
|
|
235
245
|
|
|
@@ -260,7 +270,12 @@ function assertReleaseAssetsFresh(release, expectedAssets, run) {
|
|
|
260
270
|
throw new Error(`GitHub Release is missing required release asset(s): ${missing.join(", ")}`);
|
|
261
271
|
}
|
|
262
272
|
|
|
263
|
-
|
|
273
|
+
// #5429: compare against the successful release job's started_at when the
|
|
274
|
+
// run record carries it; fall back to the run-level timestamp only when a
|
|
275
|
+
// job baseline is unavailable.
|
|
276
|
+
const baseline = run.release_job_started_at || run.run_started_at || run.created_at;
|
|
277
|
+
const baselineLabel = run.release_job_started_at ? "release job start" : "workflow run start";
|
|
278
|
+
const freshnessBaseline = parseGitHubTime(baseline, baselineLabel);
|
|
264
279
|
const stale = [];
|
|
265
280
|
for (const expected of expectedAssets) {
|
|
266
281
|
const asset = assetsByName.get(expected);
|
|
@@ -269,7 +284,7 @@ function assertReleaseAssetsFresh(release, expectedAssets, run) {
|
|
|
269
284
|
continue;
|
|
270
285
|
}
|
|
271
286
|
const updatedAt = parseGitHubTime(asset.updated_at || asset.created_at, `${expected} update`);
|
|
272
|
-
if (updatedAt <
|
|
287
|
+
if (updatedAt < freshnessBaseline) {
|
|
273
288
|
stale.push(`${expected} updated at ${asset.updated_at || asset.created_at}`);
|
|
274
289
|
}
|
|
275
290
|
}
|
package/test/install.test.js
CHANGED
|
@@ -30,13 +30,20 @@ async function exists(file) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
async function withoutForcedDownload(callback) {
|
|
33
|
+
const previousCodewhale = process.env.CODEWHALE_FORCE_DOWNLOAD;
|
|
33
34
|
const previousTui = process.env.DEEPSEEK_TUI_FORCE_DOWNLOAD;
|
|
34
35
|
const previousLegacy = process.env.DEEPSEEK_FORCE_DOWNLOAD;
|
|
36
|
+
delete process.env.CODEWHALE_FORCE_DOWNLOAD;
|
|
35
37
|
delete process.env.DEEPSEEK_TUI_FORCE_DOWNLOAD;
|
|
36
38
|
delete process.env.DEEPSEEK_FORCE_DOWNLOAD;
|
|
37
39
|
try {
|
|
38
40
|
return await callback();
|
|
39
41
|
} finally {
|
|
42
|
+
if (previousCodewhale === undefined) {
|
|
43
|
+
delete process.env.CODEWHALE_FORCE_DOWNLOAD;
|
|
44
|
+
} else {
|
|
45
|
+
process.env.CODEWHALE_FORCE_DOWNLOAD = previousCodewhale;
|
|
46
|
+
}
|
|
40
47
|
if (previousTui === undefined) {
|
|
41
48
|
delete process.env.DEEPSEEK_TUI_FORCE_DOWNLOAD;
|
|
42
49
|
} else {
|
|
@@ -84,7 +91,7 @@ test("install failure hint explains release base override for blocked GitHub dow
|
|
|
84
91
|
|
|
85
92
|
const hint = installFailureHint(error);
|
|
86
93
|
|
|
87
|
-
assert.match(hint, /
|
|
94
|
+
assert.match(hint, /CODEWHALE_RELEASE_BASE_URL/);
|
|
88
95
|
assert.match(hint, /codewhale-artifacts-sha256\.txt/);
|
|
89
96
|
assert.match(hint, /platform binaries/);
|
|
90
97
|
assert.match(hint, /#npm-binary-download-times-out/);
|
|
@@ -107,7 +114,7 @@ test("install failure hint checks configured release base when override is alrea
|
|
|
107
114
|
|
|
108
115
|
const hint = installFailureHint(error);
|
|
109
116
|
|
|
110
|
-
assert.match(hint, /
|
|
117
|
+
assert.match(hint, /resolves to https:\/\/mirror\.example\/deepseek\//);
|
|
111
118
|
assert.match(hint, /codewhale-artifacts-sha256\.txt/);
|
|
112
119
|
assert.doesNotMatch(hint, /If GitHub is unavailable/);
|
|
113
120
|
} finally {
|
|
@@ -256,6 +263,18 @@ test("resolvePackageVersion honors codewhaleBinaryVersion precedence (#3769)", (
|
|
|
256
263
|
);
|
|
257
264
|
assert.equal(resolvePackageVersion({ version: "9.9.9" }, {}), "9.9.9");
|
|
258
265
|
|
|
266
|
+
assert.equal(
|
|
267
|
+
resolvePackageVersion(
|
|
268
|
+
{ codewhaleBinaryVersion: "1.2.3" },
|
|
269
|
+
{
|
|
270
|
+
CODEWHALE_VERSION: "6.6.6",
|
|
271
|
+
DEEPSEEK_TUI_VERSION: "7.7.7",
|
|
272
|
+
DEEPSEEK_VERSION: "8.8.8",
|
|
273
|
+
},
|
|
274
|
+
),
|
|
275
|
+
"6.6.6",
|
|
276
|
+
);
|
|
277
|
+
|
|
259
278
|
// Legacy env vars still take precedence over package fields, unchanged.
|
|
260
279
|
assert.equal(
|
|
261
280
|
resolvePackageVersion(
|
|
@@ -273,6 +292,49 @@ test("resolvePackageVersion honors codewhaleBinaryVersion precedence (#3769)", (
|
|
|
273
292
|
);
|
|
274
293
|
});
|
|
275
294
|
|
|
295
|
+
test("canonical Codewhale installer variables outrank legacy aliases", () => {
|
|
296
|
+
assert.equal(
|
|
297
|
+
_internal.resolveRepo({
|
|
298
|
+
CODEWHALE_GITHUB_REPO: "example/codewhale",
|
|
299
|
+
DEEPSEEK_TUI_GITHUB_REPO: "legacy/tui",
|
|
300
|
+
DEEPSEEK_GITHUB_REPO: "legacy/root",
|
|
301
|
+
}),
|
|
302
|
+
"example/codewhale",
|
|
303
|
+
);
|
|
304
|
+
assert.equal(
|
|
305
|
+
_internal.isOptionalInstall([], {
|
|
306
|
+
CODEWHALE_OPTIONAL_INSTALL: "1",
|
|
307
|
+
}),
|
|
308
|
+
true,
|
|
309
|
+
);
|
|
310
|
+
assert.equal(
|
|
311
|
+
_internal.isQuietInstall({ CODEWHALE_QUIET_INSTALL: "1" }),
|
|
312
|
+
true,
|
|
313
|
+
);
|
|
314
|
+
assert.equal(
|
|
315
|
+
_internal.shouldForceDownload({ CODEWHALE_FORCE_DOWNLOAD: "1" }),
|
|
316
|
+
true,
|
|
317
|
+
);
|
|
318
|
+
assert.equal(
|
|
319
|
+
_internal.shouldDisableInstall({ CODEWHALE_DISABLE_INSTALL: "1" }),
|
|
320
|
+
true,
|
|
321
|
+
);
|
|
322
|
+
assert.equal(
|
|
323
|
+
_internal.downloadTimeoutMs("runtime", {
|
|
324
|
+
CODEWHALE_DOWNLOAD_TIMEOUT_MS: "1234",
|
|
325
|
+
DEEPSEEK_TUI_DOWNLOAD_TIMEOUT_MS: "9999",
|
|
326
|
+
}),
|
|
327
|
+
1234,
|
|
328
|
+
);
|
|
329
|
+
assert.equal(
|
|
330
|
+
_internal.downloadStallMs("runtime", {
|
|
331
|
+
CODEWHALE_DOWNLOAD_STALL_MS: "5678",
|
|
332
|
+
DEEPSEEK_TUI_DOWNLOAD_STALL_MS: "9999",
|
|
333
|
+
}),
|
|
334
|
+
5678,
|
|
335
|
+
);
|
|
336
|
+
});
|
|
337
|
+
|
|
276
338
|
test("httpRequest handles invalid URL parsing errors", async () => {
|
|
277
339
|
const { httpRequest } = _internal;
|
|
278
340
|
const invalidUrl = "not-a-valid-url";
|
package/test/postinstall.test.js
CHANGED
|
@@ -11,6 +11,7 @@ test("postinstall opts into optional install mode", () => {
|
|
|
11
11
|
test("optional install can be enabled by command-line flag or env", () => {
|
|
12
12
|
assert.equal(_internal.isOptionalInstall(["--optional"], {}), true);
|
|
13
13
|
assert.equal(_internal.isOptionalInstall([], {}), false);
|
|
14
|
+
assert.equal(_internal.isOptionalInstall([], { CODEWHALE_OPTIONAL_INSTALL: "1" }), true);
|
|
14
15
|
assert.equal(_internal.isOptionalInstall([], { DEEPSEEK_TUI_OPTIONAL_INSTALL: "1" }), true);
|
|
15
16
|
assert.equal(_internal.isOptionalInstall([], { DEEPSEEK_OPTIONAL_INSTALL: "1" }), true);
|
|
16
17
|
});
|
|
@@ -120,6 +120,38 @@ test("assertReleaseAssetsFresh accepts assets updated by the release workflow ru
|
|
|
120
120
|
);
|
|
121
121
|
});
|
|
122
122
|
|
|
123
|
+
test("assertReleaseAssetsFresh accepts assets uploaded before a job-level rerun bumped run_started_at (#5429)", () => {
|
|
124
|
+
assert.doesNotThrow(() =>
|
|
125
|
+
assertReleaseAssetsFresh(
|
|
126
|
+
{ assets: [{ name: "codewhale-linux-x64", state: "uploaded", updated_at: "2026-08-15T02:00:00Z" }] },
|
|
127
|
+
["codewhale-linux-x64"],
|
|
128
|
+
{
|
|
129
|
+
database_id: 123,
|
|
130
|
+
// `gh run rerun --failed` moves the run-level start forward…
|
|
131
|
+
run_started_at: "2026-08-15T10:00:00Z",
|
|
132
|
+
// …but the release job that actually uploaded the assets is unchanged.
|
|
133
|
+
release_job_started_at: "2026-08-15T01:00:00Z",
|
|
134
|
+
},
|
|
135
|
+
),
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test("assertReleaseAssetsFresh still rejects assets older than the successful release job", () => {
|
|
140
|
+
assert.throws(
|
|
141
|
+
() =>
|
|
142
|
+
assertReleaseAssetsFresh(
|
|
143
|
+
{ assets: [{ name: "codewhale-linux-x64", state: "uploaded", updated_at: "2026-08-15T00:30:00Z" }] },
|
|
144
|
+
["codewhale-linux-x64"],
|
|
145
|
+
{
|
|
146
|
+
database_id: 123,
|
|
147
|
+
run_started_at: "2026-08-15T10:00:00Z",
|
|
148
|
+
release_job_started_at: "2026-08-15T01:00:00Z",
|
|
149
|
+
},
|
|
150
|
+
),
|
|
151
|
+
/asset set is stale/,
|
|
152
|
+
);
|
|
153
|
+
});
|
|
154
|
+
|
|
123
155
|
test("findReleaseWorkflowRun accepts a successful release job when a downstream job failed", async () => {
|
|
124
156
|
const run = {
|
|
125
157
|
id: 123,
|
|
@@ -136,13 +168,16 @@ test("findReleaseWorkflowRun accepts a successful release job when a downstream
|
|
|
136
168
|
assert.equal(endpoint, "/actions/runs/123/jobs?per_page=100");
|
|
137
169
|
return {
|
|
138
170
|
jobs: [
|
|
139
|
-
{ name: "release", conclusion: "success" },
|
|
171
|
+
{ name: "release", conclusion: "success", started_at: "2026-08-12T07:30:00Z" },
|
|
140
172
|
{ name: "npm", conclusion: "failure" },
|
|
141
173
|
],
|
|
142
174
|
};
|
|
143
175
|
};
|
|
144
176
|
|
|
145
|
-
assert.
|
|
177
|
+
assert.deepEqual(await findReleaseWorkflowRun("owner/repo", "v0.9.6", "abc123", api), {
|
|
178
|
+
...run,
|
|
179
|
+
release_job_started_at: "2026-08-12T07:30:00Z",
|
|
180
|
+
});
|
|
146
181
|
});
|
|
147
182
|
|
|
148
183
|
test("findReleaseWorkflowRun rejects runs without a successful release job", async () => {
|