Skip to content

Commit

Permalink
translate source/triggered_by to user-friendly text
Browse files Browse the repository at this point in the history
in all versions/deployments commands
  • Loading branch information
RamIdeas committed Mar 12, 2024
1 parent 8923480 commit 50911dd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
10 changes: 9 additions & 1 deletion packages/wrangler/src/versions/deployments/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as metrics from "../../metrics";
import { printWranglerBanner } from "../../update-check";
import { requireAuth } from "../../user";
import formatLabelledValues from "../../utils/render-labelled-values";
import { getVersionSource } from "../list";
import { ApiDeployment, ApiVersion } from "../types";
import type {
CommonYargsArgv,
Expand Down Expand Up @@ -97,7 +98,7 @@ export async function versionsDeploymentsListHandler(
// explicitly not outputting Deployment ID
Created: new Date(deployment.created_on).toISOString(),
Author: deployment.author_email,
Source: deployment.source,
Source: getDeploymentSource(deployment),
Message: deployment.annotations?.["workers/message"] || BLANK_INPUT,
"Version(s)": formattedVersions.join("\n\n"),
});
Expand All @@ -118,3 +119,10 @@ function getConfig(

return config;
}

export function getDeploymentSource(deployment: ApiDeployment) {
return getVersionSource({
metadata: { source: deployment.source },
annotations: deployment.annotations,
});
}
3 changes: 2 additions & 1 deletion packages/wrangler/src/versions/deployments/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { printWranglerBanner } from "../../update-check";
import { requireAuth } from "../../user";
import formatLabelledValues from "../../utils/render-labelled-values";
import { ApiDeployment, ApiVersion } from "../types";
import { getDeploymentSource } from "./list";
import type {
CommonYargsArgv,
StrictYargsOptionsToInterface,
Expand Down Expand Up @@ -100,7 +101,7 @@ export async function versionsDeploymentsStatusHandler(
// explicitly not outputting Deployment ID
Created: new Date(latestDeployment.created_on).toISOString(),
Author: latestDeployment.author_email,
Source: latestDeployment.source,
Source: getDeploymentSource(latestDeployment),
Message: latestDeployment.annotations?.["workers/message"] || BLANK_INPUT,
"Version(s)": formattedVersions.join("\n\n"),
});
Expand Down
4 changes: 2 additions & 2 deletions packages/wrangler/src/versions/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function versionsListHandler(args: VersionsListArgs) {
"Version ID": version.id,
Created: new Date(version.metadata["created_on"]).toISOString(),
Author: version.metadata.author_email,
Source: version.metadata.source,
Source: getVersionSource(version),
Tag: version.annotations?.["workers/tag"] || BLANK_INPUT,
Message: version.annotations?.["workers/message"] || BLANK_INPUT,
});
Expand All @@ -76,7 +76,7 @@ export function getConfig(
return config;
}

export function getSource(version: {
export function getVersionSource(version: {
metadata: Pick<ApiVersion["metadata"], "source">;
annotations?: Pick<
NonNullable<ApiVersion["annotations"]>,
Expand Down
4 changes: 2 additions & 2 deletions packages/wrangler/src/versions/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as metrics from "../metrics";
import { printWranglerBanner } from "../update-check";
import { requireAuth } from "../user";
import formatLabelledValues from "../utils/render-labelled-values";
import { getConfig } from "./list";
import { getConfig, getVersionSource } from "./list";
import { ApiVersion } from "./types";
import type {
CommonYargsArgv,
Expand Down Expand Up @@ -62,7 +62,7 @@ export async function versionsViewHandler(args: VersionsViewArgs) {
"Version ID": version.id,
Created: new Date(version.metadata["created_on"]).toISOString(),
Author: version.metadata.author_email,
Source: version.metadata.source,
Source: getVersionSource(version),
Tag: version.annotations?.["workers/tag"] || BLANK_INPUT,
Message: version.annotations?.["workers/message"] || BLANK_INPUT,
});
Expand Down

0 comments on commit 50911dd

Please sign in to comment.