Skip to content

Commit 750d8cc

Browse files
authored
feat(command-deploy): add a --prodIfUnlocked flag (#1988)
1 parent 4982036 commit 750d8cc

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

docs/commands/deploy.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ netlify deploy
8787
- `dir` (*string*) - Specify a folder to deploy
8888
- `functions` (*string*) - Specify a functions folder to deploy
8989
- `prod` (*boolean*) - Deploy to production
90+
- `prodIfUnlocked` (*boolean*) - Deploy to production if unlocked, create a draft otherwise
9091
- `alias` (*string*) - Specifies the alias for deployment. Useful for creating predictable deployment URLs. Maximum 37 characters.
9192
- `branch` (*string*) - Serves the same functionality as --alias. Deprecated and will be removed in future versions
9293
- `open` (*boolean*) - Open site after deploy
@@ -107,6 +108,7 @@ netlify deploy
107108
netlify deploy
108109
netlify deploy --prod
109110
netlify deploy --prod --open
111+
netlify deploy --prodIfUnlocked
110112
netlify deploy --message "A message with an $ENV_VAR"
111113
netlify deploy --auth $NETLIFY_AUTH_TOKEN
112114
netlify deploy --trigger

src/commands/deploy.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ class DeployCommand extends Command {
350350
warn('--branch flag has been renamed to --alias and will be removed in future versions')
351351
}
352352

353-
const deployToProduction = flags.prod
354353
await this.authenticate(flags.auth)
355354

356355
await this.config.runHook('analytics', {
@@ -406,6 +405,8 @@ class DeployCommand extends Command {
406405
}
407406
}
408407

408+
const deployToProduction = flags.prod || (flags.prodIfUnlocked && !siteData.published_deploy.locked)
409+
409410
if (flags.trigger) {
410411
return triggerDeploy({ api, siteId, siteData, log, error })
411412
}
@@ -545,6 +546,7 @@ DeployCommand.examples = [
545546
'netlify deploy',
546547
'netlify deploy --prod',
547548
'netlify deploy --prod --open',
549+
'netlify deploy --prodIfUnlocked',
548550
'netlify deploy --message "A message with an $ENV_VAR"',
549551
'netlify deploy --auth $NETLIFY_AUTH_TOKEN',
550552
'netlify deploy --trigger',
@@ -563,7 +565,12 @@ DeployCommand.flags = {
563565
char: 'p',
564566
description: 'Deploy to production',
565567
default: false,
566-
exclusive: ['alias', 'branch'],
568+
exclusive: ['alias', 'branch', 'prodIfUnlocked'],
569+
}),
570+
prodIfUnlocked: flagsLib.boolean({
571+
description: 'Deploy to production if unlocked, create a draft otherwise',
572+
default: false,
573+
exclusive: ['alias', 'branch', 'prod'],
567574
}),
568575
alias: flagsLib.string({
569576
description:

0 commit comments

Comments
 (0)