Skip to content

Commit

Permalink
Create new detailed pages deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
courtney-sims committed Oct 16, 2024
1 parent 0c7b346 commit 9724518
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/little-cheetahs-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": minor
---

feat: Adds new detailed pages deployment output type
43 changes: 43 additions & 0 deletions packages/wrangler/src/__tests__/output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,49 @@ describe("writeOutput()", () => {
},
]);
});
it("should write an alias and environment for pages-deploy-detailed outputs", () => {
vi.stubEnv("WRANGLER_OUTPUT_FILE_DIRECTORY", "output");
vi.stubEnv("WRANGLER_OUTPUT_FILE_PATH", "");
writeOutput({
type: "wrangler-session",
version: 1,
wrangler_version: "0.0.0.0",
command_line_args: ["--help"],
log_file_path: "some/log/path.log",
});
writeOutput({
type: "pages-deploy-detailed",
version: 1,
pages_project: "pages",
deployment_id: "ABCDE12345",
url: "test.com",
alias: "dev.com",
environment: "production",
});

const outputFilePaths = readdirSync("output");
expect(outputFilePaths.length).toEqual(1);
expect(outputFilePaths[0]).toMatch(/wrangler-output-.+\.json/);
const outputFile = readFileSync(join("output", outputFilePaths[0]), "utf8");
expect(outputFile).toContainEntries([
{
type: "wrangler-session",
version: 1,
wrangler_version: "0.0.0.0",
command_line_args: ["--help"],
log_file_path: "some/log/path.log",
},
{
type: "pages-deploy-detailed",
version: 1,
pages_project: "pages",
deployment_id: "ABCDE12345",
url: "test.com",
alias: "dev.com",
environment: "production",
},
]);
});
});

expect.extend({
Expand Down
18 changes: 17 additions & 1 deletion packages/wrangler/src/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export type OutputEntry =
| OutputEntryDeployment
| OutputEntryPagesDeployment
| OutputEntryVersionUpload
| OutputEntryVersionDeployment;
| OutputEntryVersionDeployment
| OutputEntryPagesDeploymentDetailed;

export type StampedOutputEntry = { timestamp: string } & OutputEntry;

Expand Down Expand Up @@ -108,6 +109,21 @@ export interface OutputEntryPagesDeployment
url: string | undefined;
}

export interface OutputEntryPagesDeploymentDetailed
extends OutputEntryBase<"pages-deploy-detailed"> {
version: 1;
/** The name of the Pages project. */
pages_project: string | null;
/** A GUID that identifies this Pages deployment. */
deployment_id: string | null;
/** The URL associated with this deployment */
url: string | undefined;
/** The Alias url, if it exists */
alias: string | undefined;
/** The environment being deployed to */
environment: "production" | "preview";
}

export interface OutputEntryVersionUpload
extends OutputEntryBase<"version-upload"> {
version: 1;
Expand Down
10 changes: 10 additions & 0 deletions packages/wrangler/src/pages/deploy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,16 @@ ${failureMessage}`,
url: deploymentResponse.url,
});

writeOutput({
type: "pages-deploy-detailed",
version: 1,
pages_project: deploymentResponse.project_name,
deployment_id: deploymentResponse.id,
url: deploymentResponse.url,
alias,
environment: deploymentResponse.environment,
});

await metrics.sendMetricsEvent("create pages deployment");
};

Expand Down

0 comments on commit 9724518

Please sign in to comment.