Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional output fields to pages deployments #6990

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading