@dsdenes/devboard 0.1.564 → 0.1.565
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/lib/release.test.ts +55 -1
- package/package.json +1 -1
package/lib/release.test.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { afterAll, describe, expect, test } from "bun:test";
|
|
2
2
|
import { createServer } from "node:net";
|
|
3
3
|
import type { AddressInfo, Socket } from "node:net";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
chmodSync,
|
|
6
|
+
existsSync,
|
|
7
|
+
mkdirSync,
|
|
8
|
+
readFileSync,
|
|
9
|
+
readdirSync,
|
|
10
|
+
rmSync,
|
|
11
|
+
writeFileSync,
|
|
12
|
+
} from "node:fs";
|
|
5
13
|
import { join } from "node:path";
|
|
6
14
|
import {
|
|
7
15
|
checksumName,
|
|
@@ -11,6 +19,7 @@ import {
|
|
|
11
19
|
installHarnessTarball,
|
|
12
20
|
installRelease,
|
|
13
21
|
isReleaseUnreachable,
|
|
22
|
+
latestRelease,
|
|
14
23
|
parseReleaseDescription,
|
|
15
24
|
ReleaseError,
|
|
16
25
|
ReleaseFeedError,
|
|
@@ -267,3 +276,48 @@ describe("release download deadline", () => {
|
|
|
267
276
|
}
|
|
268
277
|
}, 20_000);
|
|
269
278
|
});
|
|
279
|
+
|
|
280
|
+
describe("npm fallback", () => {
|
|
281
|
+
test("uses the configured Gitea release when npm cannot resolve a version", async () => {
|
|
282
|
+
const root = workspace("npm-fallback");
|
|
283
|
+
const npm = join(root, "failing-npm");
|
|
284
|
+
writeFileSync(npm, "#!/bin/sh\necho 'simulated npm outage' >&2\nexit 1\n");
|
|
285
|
+
chmodSync(npm, 0o755);
|
|
286
|
+
const server = Bun.serve({
|
|
287
|
+
port: 0,
|
|
288
|
+
fetch(request) {
|
|
289
|
+
const url = new URL(request.url);
|
|
290
|
+
if (url.pathname.endsWith("/releases/latest")) {
|
|
291
|
+
return Response.json({ tag_name: "v0.1.42", assets: [] });
|
|
292
|
+
}
|
|
293
|
+
return new Response("not found", { status: 404 });
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
try {
|
|
297
|
+
const release = await latestRelease({
|
|
298
|
+
kind: "npm",
|
|
299
|
+
env: { DEVBOARD_NPM: npm },
|
|
300
|
+
fallback: {
|
|
301
|
+
kind: "gitea",
|
|
302
|
+
baseUrl: `http://127.0.0.1:${server.port}`,
|
|
303
|
+
repo: "acme/fixture",
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
expect(release.version).toBe("0.1.42");
|
|
307
|
+
} finally {
|
|
308
|
+
server.stop(true);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
test("names npm when it fails and no fallback is configured", async () => {
|
|
313
|
+
const root = workspace("npm-no-fallback");
|
|
314
|
+
const npm = join(root, "failing-npm");
|
|
315
|
+
writeFileSync(npm, "#!/bin/sh\necho 'simulated npm outage' >&2\nexit 1\n");
|
|
316
|
+
chmodSync(npm, 0o755);
|
|
317
|
+
const error = await latestRelease({ kind: "npm", env: { DEVBOARD_NPM: npm } }).catch(
|
|
318
|
+
(reason: unknown) => reason,
|
|
319
|
+
);
|
|
320
|
+
expect(error).toBeInstanceOf(ReleaseError);
|
|
321
|
+
expect((error as Error).message).toContain("npm could not resolve");
|
|
322
|
+
});
|
|
323
|
+
});
|