Add Cloudflare Pages deploy scripts
This commit is contained in:
1 parent
b7a0934f83
commit
f80834c6ab
5 files changed
+1133
-9
No files matched your search
@@ -0,0 +1,60 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
|
||||
import {
|
||||
createPagesDeployArgs,
|
||||
resolveDeployPlan,
|
||||
} from "./deploy-cloudflare-pages.mjs";
|
||||
|
||||
describe("deploy-cloudflare-pages", () => {
|
||||
it("deploys prod to the production branch using the latest release branch as source", () => {
|
||||
const plan = resolveDeployPlan("prod", {}, () => [
|
||||
"1710000000\torigin/release/1",
|
||||
"1720000000\torigin/release/2",
|
||||
]);
|
||||
|
||||
assert.deepEqual(plan, {
|
||||
sourceBranch: "release/2",
|
||||
pagesBranch: "main",
|
||||
});
|
||||
assert.deepEqual(createPagesDeployArgs("persona-lenz", plan.pagesBranch), [
|
||||
"exec",
|
||||
"wrangler",
|
||||
"pages",
|
||||
"deploy",
|
||||
"dist",
|
||||
"--project-name",
|
||||
"persona-lenz",
|
||||
"--branch",
|
||||
"main",
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps explicit staging branch override behavior", () => {
|
||||
const plan = resolveDeployPlan(
|
||||
"staging",
|
||||
{ CF_PAGES_STAGING_BRANCH: "release/manual" },
|
||||
() => {
|
||||
throw new Error("should not inspect git refs when branch is explicit");
|
||||
},
|
||||
);
|
||||
|
||||
assert.deepEqual(plan, {
|
||||
sourceBranch: "release/manual",
|
||||
pagesBranch: "release/manual",
|
||||
});
|
||||
});
|
||||
|
||||
it("allows overriding the Cloudflare Pages production branch", () => {
|
||||
const plan = resolveDeployPlan(
|
||||
"prod",
|
||||
{ CF_PAGES_PRODUCTION_BRANCH: "production" },
|
||||
() => ["1720000000\torigin/release/2"],
|
||||
);
|
||||
|
||||
assert.deepEqual(plan, {
|
||||
sourceBranch: "release/2",
|
||||
pagesBranch: "production",
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user