Skip to content

Commit 586c253

Browse files
Create new detailed pages deployment (#6990)
1 parent 616801c commit 586c253

File tree

4 files changed

+75
-1
lines changed

4 files changed

+75
-1
lines changed

.changeset/little-cheetahs-arrive.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": minor
3+
---
4+
5+
feat: Adds new detailed pages deployment output type

packages/wrangler/src/__tests__/output.test.ts

+43
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,49 @@ describe("writeOutput()", () => {
175175
},
176176
]);
177177
});
178+
it("should write an alias and environment for pages-deploy-detailed outputs", () => {
179+
vi.stubEnv("WRANGLER_OUTPUT_FILE_DIRECTORY", "output");
180+
vi.stubEnv("WRANGLER_OUTPUT_FILE_PATH", "");
181+
writeOutput({
182+
type: "wrangler-session",
183+
version: 1,
184+
wrangler_version: "0.0.0.0",
185+
command_line_args: ["--help"],
186+
log_file_path: "some/log/path.log",
187+
});
188+
writeOutput({
189+
type: "pages-deploy-detailed",
190+
version: 1,
191+
pages_project: "pages",
192+
deployment_id: "ABCDE12345",
193+
url: "test.com",
194+
alias: "dev.com",
195+
environment: "production",
196+
});
197+
198+
const outputFilePaths = readdirSync("output");
199+
expect(outputFilePaths.length).toEqual(1);
200+
expect(outputFilePaths[0]).toMatch(/wrangler-output-.+\.json/);
201+
const outputFile = readFileSync(join("output", outputFilePaths[0]), "utf8");
202+
expect(outputFile).toContainEntries([
203+
{
204+
type: "wrangler-session",
205+
version: 1,
206+
wrangler_version: "0.0.0.0",
207+
command_line_args: ["--help"],
208+
log_file_path: "some/log/path.log",
209+
},
210+
{
211+
type: "pages-deploy-detailed",
212+
version: 1,
213+
pages_project: "pages",
214+
deployment_id: "ABCDE12345",
215+
url: "test.com",
216+
alias: "dev.com",
217+
environment: "production",
218+
},
219+
]);
220+
});
178221
});
179222

180223
expect.extend({

packages/wrangler/src/output.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ export type OutputEntry =
7070
| OutputEntryDeployment
7171
| OutputEntryPagesDeployment
7272
| OutputEntryVersionUpload
73-
| OutputEntryVersionDeployment;
73+
| OutputEntryVersionDeployment
74+
| OutputEntryPagesDeploymentDetailed;
7475

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

@@ -108,6 +109,21 @@ export interface OutputEntryPagesDeployment
108109
url: string | undefined;
109110
}
110111

112+
export interface OutputEntryPagesDeploymentDetailed
113+
extends OutputEntryBase<"pages-deploy-detailed"> {
114+
version: 1;
115+
/** The name of the Pages project. */
116+
pages_project: string | null;
117+
/** A GUID that identifies this Pages deployment. */
118+
deployment_id: string | null;
119+
/** The URL associated with this deployment */
120+
url: string | undefined;
121+
/** The Alias url, if it exists */
122+
alias: string | undefined;
123+
/** The environment being deployed to */
124+
environment: "production" | "preview";
125+
}
126+
111127
export interface OutputEntryVersionUpload
112128
extends OutputEntryBase<"version-upload"> {
113129
version: 1;

packages/wrangler/src/pages/deploy.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,16 @@ ${failureMessage}`,
448448
url: deploymentResponse.url,
449449
});
450450

451+
writeOutput({
452+
type: "pages-deploy-detailed",
453+
version: 1,
454+
pages_project: deploymentResponse.project_name,
455+
deployment_id: deploymentResponse.id,
456+
url: deploymentResponse.url,
457+
alias,
458+
environment: deploymentResponse.environment,
459+
});
460+
451461
await metrics.sendMetricsEvent("create pages deployment");
452462
};
453463

0 commit comments

Comments
 (0)