-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Catch erroneous use of `deployments view [deployment-id] --experiment…
…al-versions` command (#5405)
- Loading branch information
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
chore: add `wrangler deployments view [deployment-id] --experimental-versions` command | ||
|
||
This command will display an error message which points the user to run either `wrangler deployments status --experimental-versions` or `wrangler versions view <version-id> --experimental-versions` instead. |
22 changes: 22 additions & 0 deletions
22
packages/wrangler/src/__tests__/versions/deployments/deployments.view.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { UserError } from "../../../errors"; | ||
import { runWrangler } from "../../helpers/run-wrangler"; | ||
|
||
describe("deployments view", () => { | ||
test("error when run with no args", async () => { | ||
const result = runWrangler("deployments view --x-versions"); | ||
|
||
await expect(result).rejects.toMatchInlineSnapshot( | ||
`[Error: \`wrangler deployments view\` has been renamed \`wrangler deployments status --x-versions\`. Please use that command instead.]` | ||
); | ||
await expect(result).rejects.toBeInstanceOf(UserError); | ||
}); | ||
|
||
test("error when run with positional arg", async () => { | ||
const result = runWrangler("deployments view dummy-id --x-versions"); | ||
|
||
await expect(result).rejects.toMatchInlineSnapshot( | ||
`[Error: \`wrangler deployments view <deployment-id>\` has been renamed \`wrangler versions view [version-id] --x-versions\`. Please use that command instead.]` | ||
); | ||
await expect(result).rejects.toBeInstanceOf(UserError); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { UserError } from "../../errors"; | ||
import { printWranglerBanner } from "../../update-check"; | ||
import type { | ||
CommonYargsArgv, | ||
StrictYargsOptionsToInterface, | ||
} from "../../yargs-types"; | ||
|
||
export type VersionsDeploymentsViewArgs = StrictYargsOptionsToInterface< | ||
typeof versionsDeploymentsViewOptions | ||
>; | ||
|
||
export function versionsDeploymentsViewOptions(yargs: CommonYargsArgv) { | ||
return yargs | ||
.option("name", { | ||
describe: "Name of the worker", | ||
type: "string", | ||
requiresArg: true, | ||
}) | ||
.positional("deployment-id", { | ||
describe: | ||
"Deprecated. Deployment ID is now referred to as Version ID. Please use `wrangler versions view [version-id]` instead.", | ||
type: "string", | ||
requiresArg: true, | ||
}); | ||
} | ||
|
||
export async function versionsDeploymentsViewHandler( | ||
args: VersionsDeploymentsViewArgs | ||
) { | ||
await printWranglerBanner(); | ||
|
||
if (args.deploymentId === undefined) { | ||
throw new UserError( | ||
"`wrangler deployments view` has been renamed `wrangler deployments status --x-versions`. Please use that command instead." | ||
); | ||
} else { | ||
throw new UserError( | ||
"`wrangler deployments view <deployment-id>` has been renamed `wrangler versions view [version-id] --x-versions`. Please use that command instead." | ||
); | ||
} | ||
} |