Skip to content

Commit e2e5d2e

Browse files
Add deploy non-preview confirmation flag
1 parent 30d29d6 commit e2e5d2e

4 files changed

Lines changed: 38 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/cli-hydrogen': patch
3+
---
4+
5+
Add an `--allow-non-preview` confirmation bypass to `hydrogen deploy`.

packages/cli/oclif.manifest.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,14 @@
360360
"allowNo": false,
361361
"type": "boolean"
362362
},
363+
"allow-non-preview": {
364+
"description": "Allow deployment to a non-preview environment without confirmation.",
365+
"env": "SHOPIFY_HYDROGEN_FLAG_ALLOW_NON_PREVIEW",
366+
"name": "allow-non-preview",
367+
"required": false,
368+
"allowNo": false,
369+
"type": "boolean"
370+
},
363371
"no-verify": {
364372
"description": "Skip the routability verification step after deployment.",
365373
"name": "no-verify",

packages/cli/src/commands/hydrogen/deploy.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,20 @@ describe('deploy', async () => {
10791079
message: expect.any(String),
10801080
});
10811081
});
1082+
1083+
it("doesn't render a user confirmation on deploy when the allow-non-preview flag is provided", async () => {
1084+
await runDeploy({
1085+
...deployParams,
1086+
env: 'production',
1087+
allowNonPreview: true,
1088+
});
1089+
1090+
expect(renderConfirmationPrompt).not.toHaveBeenCalledWith({
1091+
confirmationMessage: 'Yes, confirm deploy',
1092+
cancellationMessage: 'No, cancel deploy',
1093+
message: expect.any(String),
1094+
});
1095+
});
10821096
});
10831097

10841098
describe('user provides a preview environment', () => {

packages/cli/src/commands/hydrogen/deploy.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ export default class Deploy extends Command {
9999
env: 'SHOPIFY_HYDROGEN_FLAG_FORCE',
100100
required: false,
101101
}),
102+
'allow-non-preview': Flags.boolean({
103+
description:
104+
'Allow deployment to a non-preview environment without confirmation.',
105+
default: false,
106+
env: 'SHOPIFY_HYDROGEN_FLAG_ALLOW_NON_PREVIEW',
107+
required: false,
108+
}),
102109
'no-verify': Flags.boolean({
103110
description: 'Skip the routability verification step after deployment.',
104111
default: false,
@@ -216,6 +223,7 @@ interface OxygenDeploymentOptions {
216223
environmentFile?: string;
217224
force: boolean;
218225
forceClientSourcemap?: boolean;
226+
allowNonPreview?: boolean;
219227
noVerify: boolean;
220228
lockfileCheck: boolean;
221229
jsonOutput: boolean;
@@ -268,6 +276,7 @@ export async function runDeploy(
268276
environmentFile,
269277
force: forceOnUncommittedChanges,
270278
forceClientSourcemap = false,
279+
allowNonPreview = false,
271280
noVerify,
272281
lockfileCheck,
273282
jsonOutput,
@@ -540,7 +549,8 @@ export async function runDeploy(
540549
if (
541550
!isCI &&
542551
!config.defaultEnvironment &&
543-
(userProvidedEnvironmentTag || userChosenEnvironmentTag)
552+
(userProvidedEnvironmentTag || userChosenEnvironmentTag) &&
553+
!allowNonPreview
544554
) {
545555
let chosenEnvironment = findEnvironmentByBranchOrThrow(
546556
deploymentData!.environments!,

0 commit comments

Comments
 (0)