@sproutboat/toolchain 0.3.2 → 0.4.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/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/acquire.test.ts +12 -0
- package/src/acquire.ts +12 -1
- package/vendor/porffor-1f4ae4a.tar.gz +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @sproutboat/toolchain
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 69bfe69: Vendor the pinned Porffor commit tarball (`packages/toolchain/vendor/`) so `ensurePorffor()` needs no network on the happy path — same pattern as sproutboat-cli's vendored uWebSockets archive. Falls back to the existing checksummed download if the file is missing, or was left stale by a pin bump that forgot to re-vendor.
|
|
8
|
+
|
|
9
|
+
Part of sproutboat-cli #134 item 3.
|
|
10
|
+
|
|
3
11
|
## 0.3.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/package.json
CHANGED
package/src/acquire.test.ts
CHANGED
|
@@ -150,6 +150,18 @@ test("integrity failures stop acquisition and publish no cache entry", async ()
|
|
|
150
150
|
expect((await readdir(cacheRoot)).some((name) => name.startsWith("porffor-"))).toBe(false);
|
|
151
151
|
});
|
|
152
152
|
|
|
153
|
+
test("the default call (no url/expectedSha256 override) never touches the network", async () => {
|
|
154
|
+
const cacheRoot = await mkdtemp(join(tmpdir(), "sb-porffor-vendored-"));
|
|
155
|
+
temporary.push(cacheRoot);
|
|
156
|
+
const dir = await ensurePorffor({
|
|
157
|
+
cacheRoot,
|
|
158
|
+
fetcher: async () => {
|
|
159
|
+
throw new Error("the vendored archive must be used before any network fetch");
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
expect(await readFile(join(dir, "runtime/index.js"), "utf8")).not.toBe("");
|
|
163
|
+
});
|
|
164
|
+
|
|
153
165
|
test("a corrupted warm cache is replaced from the verified archive", async () => {
|
|
154
166
|
const { archive, sha256 } = await fixture();
|
|
155
167
|
const cacheRoot = await mkdtemp(join(tmpdir(), "sb-porffor-corrupt-"));
|
package/src/acquire.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { existsSync } from "node:fs";
|
|
|
3
3
|
import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { resolve } from "node:path";
|
|
6
|
+
// @ts-expect-error Bun's file loader supplies a path; see the pinned-commit
|
|
7
|
+
// check below for why this is safe to trust unconditionally.
|
|
8
|
+
import vendoredPorfforArchive from "../vendor/porffor-1f4ae4a.tar.gz" with { type: "file" };
|
|
6
9
|
import { ensurePorfforPatched } from "./patch";
|
|
7
10
|
import { PORFFOR_ARCHIVE_SHA256, PORFFOR_ARCHIVE_URL, PORFFOR_COMMIT_FULL } from "./pin";
|
|
8
11
|
|
|
@@ -130,7 +133,15 @@ export async function ensurePorffor(options: AcquireOptions = {}): Promise<strin
|
|
|
130
133
|
await rm(dir, { recursive: true, force: true });
|
|
131
134
|
await mkdir(stage);
|
|
132
135
|
const archive = resolve(stage, "source.tar.gz");
|
|
133
|
-
|
|
136
|
+
// The commit tarball ships in the package (`vendor/`), same pattern as
|
|
137
|
+
// sproutboat-cli's vendored uWebSockets archive: no network needed on the
|
|
138
|
+
// happy path. Falls back to downloading it if the file is missing or was
|
|
139
|
+
// left stale by a pin bump (checksum below still catches a wrong file
|
|
140
|
+
// rather than silently accepting it).
|
|
141
|
+
const noOverride = options.url === undefined && options.expectedSha256 === undefined;
|
|
142
|
+
const vendored = noOverride && existsSync(vendoredPorfforArchive) && (await digest(vendoredPorfforArchive)) === expected;
|
|
143
|
+
if (vendored) await writeFile(archive, await readFile(vendoredPorfforArchive));
|
|
144
|
+
else await download(options.url ?? PORFFOR_ARCHIVE_URL, archive, options.fetcher ?? fetch, options.timeoutMs ?? 30_000);
|
|
134
145
|
const actual = await digest(archive);
|
|
135
146
|
if (actual !== expected)
|
|
136
147
|
throw new PorfforToolchainError(
|
|
Binary file
|