mirror of
https://github.com/warmbly/warmbly.git
synced 2026-11-17 16:19:13 +00:00
feat: validate published static asset release inputs and document custom domain rollback behavior
This commit is contained in:
@@ -42,7 +42,8 @@ export function prepareStaticAssets({ target, sourceRoot, destination, sourceSha
|
||||
}
|
||||
}
|
||||
check(output);
|
||||
if (!existsSync(join(output, "index.html")) || !existsSync(join(output, "_headers"))) throw new Error("Frontend index and response headers required");
|
||||
const isRegularFile = (name) => existsSync(join(output, name)) && lstatSync(join(output, name)).isFile();
|
||||
if (!isRegularFile("index.html") || !isRegularFile("_headers")) throw new Error("Frontend index and response headers required");
|
||||
if (existsSync(join(output, "_worker.js")) || existsSync(join(output, "_routes.json"))) throw new Error("Only static artifacts are supported");
|
||||
mkdirSync(dest, { recursive: true });
|
||||
cpSync(output, join(dest, "assets"), { recursive: true });
|
||||
|
||||
@@ -75,3 +75,12 @@ test("changed admin redirect behavior requires explicit review", () => {
|
||||
assert.throws(() => prepareStaticAssets({ target, sourceRoot: root, destination, sourceSha: sha, release: "v0.6.74" }));
|
||||
});
|
||||
});
|
||||
|
||||
test("requires regular frontend entrypoint and response header files", () => {
|
||||
for (const name of ["index.html", "_headers"]) fixture("web", ({ root, target, output, destination }) => {
|
||||
rmSync(join(output, name));
|
||||
mkdirSync(join(output, name));
|
||||
assert.throws(() => prepareStaticAssets({ target, sourceRoot: root, destination, sourceSha: sha, release: "v0.6.74" }), /Frontend index and response headers required/);
|
||||
assert.equal(existsSync(destination), false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user