From 2af55ce3601c6f3f4c7c95125c46d93f75ca2e98 Mon Sep 17 00:00:00 2001 From: Mohamed Khelif Date: Mon, 25 Nov 2024 17:59:06 -0500 Subject: [PATCH] DEVPROD-13059 Add confirmation prompt for deploys (#516) --- .../deploy-utils/src/prepare-prod-deploy/index.ts | 12 ++++++++++++ .../prepare-prod-deploy/prepare-prod-deploy.test.ts | 1 + 2 files changed, 13 insertions(+) diff --git a/packages/deploy-utils/src/prepare-prod-deploy/index.ts b/packages/deploy-utils/src/prepare-prod-deploy/index.ts index 67aeef9ec..b019d2f33 100644 --- a/packages/deploy-utils/src/prepare-prod-deploy/index.ts +++ b/packages/deploy-utils/src/prepare-prod-deploy/index.ts @@ -69,5 +69,17 @@ export const prepareProdDeploy = async () => { const version = getReleaseVersion(commitMessages); console.log(`This deploy is a ${version} release.`); + + const { value: shouldDeploy } = await prompts({ + type: "confirm", + name: "value", + message: "Do you want to deploy?", + initial: true, + }); + if (!shouldDeploy) { + console.log("Deploy cancelled."); + return; + } + createTagAndPush(version); }; diff --git a/packages/deploy-utils/src/prepare-prod-deploy/prepare-prod-deploy.test.ts b/packages/deploy-utils/src/prepare-prod-deploy/prepare-prod-deploy.test.ts index f1413b38d..8017e77c6 100644 --- a/packages/deploy-utils/src/prepare-prod-deploy/prepare-prod-deploy.test.ts +++ b/packages/deploy-utils/src/prepare-prod-deploy/prepare-prod-deploy.test.ts @@ -61,6 +61,7 @@ describe("prepareProdDeploy", () => { it("creates tag with patch", async () => { const consoleSpy = vi.spyOn(console, "log").mockImplementation(vi.fn()); + vi.mocked(prompts).mockResolvedValueOnce({ value: true }); await prepareProdDeploy(); expect(vi.mocked(getCurrentlyDeployedCommit)).toHaveBeenCalledWith( "spruce",