netlify-cli 8.1.0-rc.1 → 8.1.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +12 -13
  2. package/bin/run +6 -48
  3. package/npm-shrinkwrap.json +2 -2
  4. package/package.json +2 -1
  5. package/src/commands/addons/addons-create.js +5 -3
  6. package/src/commands/addons/addons-delete.js +4 -3
  7. package/src/commands/addons/addons.js +7 -12
  8. package/src/commands/api/api.js +9 -18
  9. package/src/commands/base-command.js +77 -42
  10. package/src/commands/build/build.js +2 -2
  11. package/src/commands/completion/completion.js +6 -12
  12. package/src/commands/deploy/deploy.js +36 -44
  13. package/src/commands/dev/dev-exec.js +6 -10
  14. package/src/commands/dev/dev-trace.js +8 -11
  15. package/src/commands/dev/dev.js +32 -41
  16. package/src/commands/env/env.js +8 -12
  17. package/src/commands/functions/functions-build.js +1 -1
  18. package/src/commands/functions/functions-create.js +6 -9
  19. package/src/commands/functions/functions-invoke.js +11 -14
  20. package/src/commands/functions/functions-list.js +7 -8
  21. package/src/commands/functions/functions.js +8 -13
  22. package/src/commands/index.js +4 -2
  23. package/src/commands/init/init.js +1 -1
  24. package/src/commands/link/link.js +2 -14
  25. package/src/commands/lm/lm-install.js +5 -8
  26. package/src/commands/lm/lm.js +2 -6
  27. package/src/commands/login/login.js +4 -1
  28. package/src/commands/main.js +78 -8
  29. package/src/commands/open/open-admin.js +5 -1
  30. package/src/commands/open/open-site.js +5 -1
  31. package/src/commands/open/open.js +4 -7
  32. package/src/commands/sites/sites-create.js +4 -1
  33. package/src/commands/sites/sites-delete.js +3 -7
  34. package/src/commands/sites/sites.js +2 -5
  35. package/src/commands/status/status-hooks.js +1 -5
  36. package/src/commands/watch/watch.js +2 -2
  37. package/src/utils/command-helpers.js +0 -50
  38. package/src/utils/header.js +0 -18
package/README.md CHANGED
@@ -20,6 +20,7 @@ See the [CLI command line reference](https://cli.netlify.com/commands/) to get s
20
20
  - [addons](#addons)
21
21
  - [api](#api)
22
22
  - [build](#build)
23
+ - [completion](#completion)
23
24
  - [deploy](#deploy)
24
25
  - [dev](#dev)
25
26
  - [env](#env)
@@ -34,7 +35,6 @@ See the [CLI command line reference](https://cli.netlify.com/commands/) to get s
34
35
  - [switch](#switch)
35
36
  - [unlink](#unlink)
36
37
  - [watch](#watch)
37
- - [completion](#completion)
38
38
  - [Contributing](#contributing)
39
39
  - [Development](#development)
40
40
  - [License](#license)
@@ -102,6 +102,15 @@ Run any Netlify API method
102
102
 
103
103
  (Beta) Build on your local machine
104
104
 
105
+ ### [completion](/docs/commands/completion.md)
106
+
107
+ (Beta) Generate shell completion script
108
+
109
+ | Subcommand | description |
110
+ |:--------------------------- |:-----|
111
+ | [`completion:generate`](/docs/commands/completion.md#completiongenerate) | Generates completion script |
112
+
113
+
105
114
  ### [deploy](/docs/commands/deploy.md)
106
115
 
107
116
  Create a new deploy from the contents of a folder
@@ -157,8 +166,8 @@ Handle Netlify Large Media operations
157
166
  | Subcommand | description |
158
167
  |:--------------------------- |:-----|
159
168
  | [`lm:info`](/docs/commands/lm.md#lminfo) | Show large media requirements information. |
160
- | [`lm:install`](/docs/commands/lm.md#lminstall) | Configures your computer to use Netlify Large Media. |
161
- | [`lm:setup`](/docs/commands/lm.md#lmsetup) | Configures your site to use Netlify Large Media. |
169
+ | [`lm:install`](/docs/commands/lm.md#lminstall) | Configures your computer to use Netlify Large Media |
170
+ | [`lm:setup`](/docs/commands/lm.md#lmsetup) | Configures your site to use Netlify Large Media |
162
171
 
163
172
 
164
173
  ### [login](/docs/commands/login.md)
@@ -207,16 +216,6 @@ Unlink a local folder from a Netlify site
207
216
 
208
217
  Watch for site deploy to finish
209
218
 
210
- ### [completion](/docs/commands/completion.md)
211
-
212
- (Beta) Generate shell completion script
213
-
214
- | Subcommand | description |
215
- |:--------------------------- |:-----|
216
- | [`completion:generate:alias`](/docs/commands/completion.md#completiongeneratealias) | Generates completion script for alias |
217
- | [`completion:generate`](/docs/commands/completion.md#completiongenerate) | Generates completion script |
218
-
219
-
220
219
 
221
220
  <!-- AUTO-GENERATED-CONTENT:END -->
222
221
 
package/bin/run CHANGED
@@ -4,27 +4,7 @@ const process = require('process')
4
4
 
5
5
  const updateNotifier = require('update-notifier')
6
6
 
7
- const { createAddonsCommand } = require('../src/commands/addons')
8
- const { createApiCommand } = require('../src/commands/api')
9
- const { BaseCommand } = require('../src/commands/base-command')
10
- const { createBuildCommand } = require('../src/commands/build')
11
- const { createCompletionCommand } = require('../src/commands/completion')
12
- const { createDeployCommand } = require('../src/commands/deploy')
13
- const { createDevCommand } = require('../src/commands/dev')
14
- const { createEnvCommand } = require('../src/commands/env')
15
- const { createFunctionsCommand } = require('../src/commands/functions')
16
- const { createInitCommand } = require('../src/commands/init')
17
- const { createLinkCommand } = require('../src/commands/link')
18
- const { createLmCommand } = require('../src/commands/lm')
19
- const { createLoginCommand } = require('../src/commands/login')
20
- const { createLogoutCommand } = require('../src/commands/logout')
21
- const { createMainCommand } = require('../src/commands/main')
22
- const { createOpenCommand } = require('../src/commands/open')
23
- const { createSitesCommand } = require('../src/commands/sites')
24
- const { createStatusCommand } = require('../src/commands/status')
25
- const { createSwitchCommand } = require('../src/commands/switch')
26
- const { createUnlinkCommand } = require('../src/commands/unlink')
27
- const { createWatchCommand } = require('../src/commands/watch')
7
+ const { createMainCommand } = require('../src/commands')
28
8
 
29
9
  // 12 hours
30
10
  const UPDATE_CHECK_INTERVAL = 432e5
@@ -43,36 +23,14 @@ if (require.main === module) {
43
23
  console.log(error)
44
24
  }
45
25
 
46
- const program = new BaseCommand('netlify')
47
-
48
- createAddonsCommand(program)
49
- createApiCommand(program)
50
- createBuildCommand(program)
51
- createCompletionCommand(program)
52
- createDeployCommand(program)
53
- createDevCommand(program)
54
- createEnvCommand(program)
55
- createFunctionsCommand(program)
56
- createInitCommand(program)
57
- createLinkCommand(program)
58
- createLmCommand(program)
59
- createLoginCommand(program)
60
- createLogoutCommand(program)
61
- createOpenCommand(program)
62
- createSitesCommand(program)
63
- createStatusCommand(program)
64
- createSwitchCommand(program)
65
- createUnlinkCommand(program)
66
- createWatchCommand(program)
67
-
68
26
  /** @type {Error} */
69
27
  let caughtError
70
28
 
71
- createMainCommand(program)
72
- .then(() => program.parseAsync(process.argv))
73
- .catch((error) => {
74
- caughtError = error
75
- })
29
+ const program = createMainCommand()
30
+
31
+ program.parseAsync(process.argv).catch((error) => {
32
+ caughtError = error
33
+ })
76
34
 
77
35
  // long running commands like dev server cannot be caught by a post action hook
78
36
  // they are running on the main command
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "netlify-cli",
3
- "version": "8.1.0-rc.1",
3
+ "version": "8.1.0-rc.2",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "netlify-cli",
9
- "version": "8.1.0-rc.1",
9
+ "version": "8.1.0-rc.2",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "netlify-cli",
3
3
  "description": "Netlify command line tool",
4
- "version": "8.1.0-rc.1",
4
+ "version": "8.1.0-rc.2",
5
5
  "author": "Netlify Inc.",
6
6
  "contributors": [
7
7
  "Mathias Biilmann <matt@netlify.com> (https://twitter.com/biilmann)",
@@ -215,6 +215,7 @@
215
215
  },
216
216
  "ava": {
217
217
  "files": [
218
+ "site/**/*.test.js",
218
219
  "src/**/*.test.js",
219
220
  "tools/**/*.test.js",
220
221
  "tests/*.test.js"
@@ -2,7 +2,7 @@
2
2
  const inquirer = require('inquirer')
3
3
  const isEmpty = require('lodash/isEmpty')
4
4
 
5
- const { chalk, error, generateDescriptionHelp, log, parseRawFlags } = require('../../utils')
5
+ const { chalk, error, log, parseRawFlags } = require('../../utils')
6
6
  const { ADDON_VALIDATION, prepareAddonCommand } = require('../../utils/addons/prepare')
7
7
  const generatePrompts = require('../../utils/addons/prompts')
8
8
  const render = require('../../utils/addons/render')
@@ -118,10 +118,12 @@ const createAddonsCreateCommand = (program) =>
118
118
  .command('addons:create')
119
119
  .alias('addon:create')
120
120
  .argument('<name>', 'Add-on namespace')
121
- .description('Add an add-on extension to your site')
121
+ .description(
122
+ `Add an add-on extension to your site
123
+ Add-ons are a way to extend the functionality of your Netlify site`,
124
+ )
122
125
  // allow for any flags. Handy for variadic configuration options
123
126
  .allowUnknownOption(true)
124
- .addHelpText('after', generateDescriptionHelp('Add-ons are a way to extend the functionality of your Netlify site'))
125
127
  .action(async (addonName, options, command) => {
126
128
  await addonsCreate(addonName, options, command)
127
129
  })
@@ -1,7 +1,7 @@
1
1
  // @ts-check
2
2
  const inquirer = require('inquirer')
3
3
 
4
- const { error, exit, generateDescriptionHelp, log } = require('../../utils')
4
+ const { error, exit, log } = require('../../utils')
5
5
  const { ADDON_VALIDATION, prepareAddonCommand } = require('../../utils/addons/prepare')
6
6
 
7
7
  /**
@@ -51,9 +51,10 @@ const createAddonsDeleteCommand = (program) =>
51
51
  .command('addons:delete')
52
52
  .alias('addon:delete')
53
53
  .argument('<name>', 'Add-on namespace')
54
- .description('Remove an add-on extension to your site')
54
+ .description(
55
+ `Remove an add-on extension to your site\nAdd-ons are a way to extend the functionality of your Netlify site`,
56
+ )
55
57
  .option('-f, --force', 'delete without prompting (useful for CI)')
56
- .addHelpText('after', generateDescriptionHelp('Add-ons are a way to extend the functionality of your Netlify site'))
57
58
  .action(addonsDelete)
58
59
 
59
60
  module.exports = { createAddonsDeleteCommand }
@@ -1,7 +1,5 @@
1
1
  // @ts-check
2
2
 
3
- const { generateExamplesHelp } = require('../../utils')
4
-
5
3
  const { createAddonsAuthCommand } = require('./addons-auth')
6
4
  const { createAddonsConfigCommand } = require('./addons-config')
7
5
  const { createAddonsCreateCommand } = require('./addons-create')
@@ -34,16 +32,13 @@ const createAddonsCommand = (program) => {
34
32
  .alias('addon')
35
33
  .description('(Beta) Manage Netlify Add-ons')
36
34
  .noHelpOptions()
37
- .addHelpText(
38
- 'after',
39
- generateExamplesHelp([
40
- 'netlify addons:create addon-xyz',
41
- 'netlify addons:list',
42
- 'netlify addons:config addon-xyz',
43
- 'netlify addons:delete addon-xyz',
44
- 'netlify addons:auth addon-xyz',
45
- ]),
46
- )
35
+ .addExamples([
36
+ 'netlify addons:create addon-xyz',
37
+ 'netlify addons:list',
38
+ 'netlify addons:config addon-xyz',
39
+ 'netlify addons:delete addon-xyz',
40
+ 'netlify addons:auth addon-xyz',
41
+ ])
47
42
  .action(addons)
48
43
  }
49
44
  module.exports = { createAddonsCommand }
@@ -4,7 +4,7 @@ const AsciiTable = require('ascii-table')
4
4
  // TODO: use static `import` after migrating this repository to pure ES modules
5
5
  const jsClient = import('netlify')
6
6
 
7
- const { chalk, error, exit, generateDescriptionHelp, generateExamplesHelp, log, logJson } = require('../../utils')
7
+ const { chalk, error, exit, log, logJson } = require('../../utils')
8
8
 
9
9
  /**
10
10
  * The api command
@@ -60,25 +60,16 @@ const apiCommand = async (apiMethod, options, command) => {
60
60
  const createApiCommand = (program) =>
61
61
  program
62
62
  .command('api')
63
- .argument('[method]', 'Open API method to run')
64
- .description('Run any Netlify API method')
65
- .option('-d, --data <data>', 'Data to use')
66
- .option('--list', 'List out available API methods', false)
67
- .addHelpText(
68
- 'after',
69
- generateDescriptionHelp(
70
- `For more information on available methods checkout https://open-api.netlify.com/ or run '${chalk.grey(
71
- 'netlify api --list',
72
- )}'`,
73
- ),
74
- )
75
- .addHelpText(
76
- 'after',
77
- generateExamplesHelp([
63
+ .argument('[apiMethod]', 'Open API method to run')
64
+ .description(
65
+ `Run any Netlify API method
66
+ For more information on available methods checkout https://open-api.netlify.com/ or run '${chalk.grey(
78
67
  'netlify api --list',
79
- `netlify api getSite --data '${chalk.grey('{ "site_id": "123456"}')}'`,
80
- ]),
68
+ )}'`,
81
69
  )
70
+ .option('-d, --data <data>', 'Data to use')
71
+ .option('--list', 'List out available API methods', false)
72
+ .addExamples(['netlify api --list', `netlify api getSite --data '{ "site_id": "123456" }'`])
82
73
  .action(apiCommand)
83
74
 
84
75
  module.exports = { createApiCommand }
@@ -3,7 +3,7 @@ const process = require('process')
3
3
  const { format } = require('util')
4
4
 
5
5
  const resolveConfig = require('@netlify/config')
6
- const { Command } = require('commander')
6
+ const { Command, Option } = require('commander')
7
7
  const debug = require('debug')
8
8
  const merge = require('lodash/merge')
9
9
 
@@ -12,15 +12,12 @@ const jsClient = import('netlify')
12
12
 
13
13
  const { getAgent } = require('../lib/http-agent')
14
14
  const {
15
- HELP_$,
16
- HELP_INDENT_WIDTH,
17
- HELP_SEPERATOR_WIDTH,
15
+ NETLIFY_CYAN,
18
16
  StateConfig,
19
17
  USER_AGENT,
20
18
  chalk,
21
19
  error,
22
20
  exit,
23
- formatHelpList,
24
21
  getGlobalConfig,
25
22
  getToken,
26
23
  identify,
@@ -39,8 +36,22 @@ const CLIENT_ID = 'd6f37de6614df7ae58664cfca524744d73807a377f5ee71f1a254f78412e3
39
36
  const NANO_SECS_TO_MSECS = 1e6
40
37
  // The fallback width for the help terminal
41
38
  const FALLBACK_HELP_CMD_WIDTH = 80
42
- // AN option description that should be hidden in the help page
43
- const OPTION_HIDDEN_DESCRIPTION = 'hidden:true'
39
+
40
+ const HELP_$ = NETLIFY_CYAN('$')
41
+ // indent on commands or description on the help page
42
+ const HELP_INDENT_WIDTH = 2
43
+ // seperator width between term and description
44
+ const HELP_SEPERATOR_WIDTH = 5
45
+
46
+ /**
47
+ * Formats a help list correctly with the correct indent
48
+ * @param {string[]} textArray
49
+ * @returns
50
+ */
51
+ const formatHelpList = (textArray) => textArray.join('\n').replace(/^/gm, ' '.repeat(HELP_INDENT_WIDTH))
52
+
53
+ /** A list of base command flags that needs to be sorted down on documentation and on help pages */
54
+ const BASE_FLAGS = new Set(['--debug', '--httpProxy', '--httpProxyCertificateFilename'])
44
55
 
45
56
  /**
46
57
  * Get the duration between a start time and the current time
@@ -87,29 +98,21 @@ class BaseCommand extends Command {
87
98
  return (
88
99
  new BaseCommand(name)
89
100
  // If --silent or --json flag passed disable logger
90
- .option('--json', OPTION_HIDDEN_DESCRIPTION)
91
- .option('--cwd <cwd>', OPTION_HIDDEN_DESCRIPTION)
92
- .option('-o, --offline', OPTION_HIDDEN_DESCRIPTION)
93
-
94
- // Allow hidden flags like
95
- // --json,
96
- // --silent,
97
- // --offline, -o
98
- // --cwd <cwd> Pass a current working directory.
99
-
100
- // this disables the suggestions
101
- // .allowUnknownOption(true)
102
-
103
- // 'Print debugging information'
104
- .option('--debug', OPTION_HIDDEN_DESCRIPTION)
105
- // 'Proxy server address to route requests through'
106
- .option('--httpProxy', OPTION_HIDDEN_DESCRIPTION, process.env.HTTP_PROXY || process.env.HTTPS_PROXY)
107
- // 'Certificate file to use when connecting using a proxy server',
101
+ .addOption(new Option('--json', 'Output return values as JSON').hideHelp(true))
102
+ .addOption(new Option('--silent', 'Silence CLI output').hideHelp(true))
103
+ .addOption(new Option('--cwd <cwd>').hideHelp(true))
104
+ .addOption(new Option('-o, --offline').hideHelp(true))
108
105
  .option(
109
- '--httpProxyCertificateFilename',
110
- OPTION_HIDDEN_DESCRIPTION,
106
+ '--httpProxyCertificateFilename [file]',
107
+ 'Certificate file to use when connecting using a proxy server',
111
108
  process.env.NETLIFY_PROXY_CERTIFICATE_FILENAME,
112
109
  )
110
+ .option(
111
+ '--httpProxy [address]',
112
+ 'Proxy server address to route requests through.',
113
+ process.env.HTTP_PROXY || process.env.HTTPS_PROXY,
114
+ )
115
+ .option('--debug', 'Print debugging information')
113
116
  .hook('preAction', async (_parentCommand, actionCommand) => {
114
117
  debug(`${name}:preAction`)('start')
115
118
  this.analytics = { startTime: process.hrtime.bigint() }
@@ -129,6 +132,18 @@ class BaseCommand extends Command {
129
132
  return this
130
133
  }
131
134
 
135
+ /** The examples list for the command (used inside doc generation and help page) */
136
+ examples = []
137
+
138
+ /**
139
+ * Set examples for the command
140
+ * @param {string[]} examples
141
+ */
142
+ addExamples(examples) {
143
+ this.examples = examples
144
+ return this
145
+ }
146
+
132
147
  /**
133
148
  * Overrides the help output of commander with custom styling
134
149
  * @returns {import('commander').Help}
@@ -199,8 +214,8 @@ class BaseCommand extends Command {
199
214
  const bang = isCommand ? `${HELP_$} ` : ''
200
215
 
201
216
  if (description) {
202
- const pad = termWidth + HELP_SEPERATOR_WIDTH - (isCommand ? 2 : 0)
203
- const fullText = `${bang}${term.padEnd(pad)}${chalk.grey(description)}`
217
+ const pad = termWidth + HELP_SEPERATOR_WIDTH
218
+ const fullText = `${bang}${term.padEnd(pad - (isCommand ? 2 : 0))}${chalk.grey(description)}`
204
219
  return helper.wrap(fullText, helpWidth - HELP_INDENT_WIDTH, pad)
205
220
  }
206
221
 
@@ -211,9 +226,9 @@ class BaseCommand extends Command {
211
226
  let output = []
212
227
 
213
228
  // Description
214
- const commandDescription = helper.commandDescription(command)
215
- if (commandDescription.length !== 0) {
216
- output = [...output, commandDescription, '']
229
+ const [topDescription, ...commandDescription] = (helper.commandDescription(command) || '').split('\n')
230
+ if (topDescription.length !== 0) {
231
+ output = [...output, topDescription, '']
217
232
  }
218
233
 
219
234
  // on the parent help command the version should be displayed
@@ -224,14 +239,6 @@ class BaseCommand extends Command {
224
239
  // Usage
225
240
  output = [...output, chalk.bold('USAGE'), helper.commandUsage(command), '']
226
241
 
227
- // Aliases
228
- // eslint-disable-next-line no-underscore-dangle
229
- if (command._aliases.length !== 0) {
230
- // eslint-disable-next-line no-underscore-dangle
231
- const aliases = command._aliases.map((alias) => formatItem(`${parentCommand.name()} ${alias}`, null, true))
232
- output = [...output, chalk.bold('ALIASES'), formatHelpList(aliases), '']
233
- }
234
-
235
242
  // Arguments
236
243
  const argumentList = helper
237
244
  .visibleArguments(command)
@@ -244,13 +251,41 @@ class BaseCommand extends Command {
244
251
  // Options
245
252
  const optionList = helper
246
253
  .visibleOptions(command)
247
- .filter((option) => option.description !== OPTION_HIDDEN_DESCRIPTION)
254
+ .sort((optionA, optionB) => {
255
+ // base flags should be always at the bottom
256
+ if (BASE_FLAGS.has(optionA.long) || BASE_FLAGS.has(optionB.long)) {
257
+ return -1
258
+ }
259
+ return optionA.long.localeCompare(optionB.long)
260
+ })
248
261
  .map((option) => formatItem(helper.optionTerm(option), helper.optionDescription(option)))
249
262
  if (optionList.length !== 0) {
250
263
  output = [...output, chalk.bold('OPTIONS'), formatHelpList(optionList), '']
251
264
  }
252
265
  }
253
266
 
267
+ // Description
268
+ if (commandDescription.length !== 0) {
269
+ output = [...output, chalk.bold('DESCRIPTION'), formatHelpList(commandDescription), '']
270
+ }
271
+
272
+ // Aliases
273
+ // eslint-disable-next-line no-underscore-dangle
274
+ if (command._aliases.length !== 0) {
275
+ // eslint-disable-next-line no-underscore-dangle
276
+ const aliases = command._aliases.map((alias) => formatItem(`${parentCommand.name()} ${alias}`, null, true))
277
+ output = [...output, chalk.bold('ALIASES'), formatHelpList(aliases), '']
278
+ }
279
+
280
+ if (command.examples.length !== 0) {
281
+ output = [
282
+ ...output,
283
+ chalk.bold('EXAMPLES'),
284
+ formatHelpList(command.examples.map((example) => `${HELP_$} ${example}`)),
285
+ '',
286
+ ]
287
+ }
288
+
254
289
  const commandList = getCommands(command).map((cmd) =>
255
290
  formatItem(cmd.name(), helper.subcommandDescription(cmd), true),
256
291
  )
@@ -471,4 +506,4 @@ class BaseCommand extends Command {
471
506
  }
472
507
  }
473
508
 
474
- module.exports = { BaseCommand }
509
+ module.exports = { BaseCommand, BASE_FLAGS }
@@ -1,6 +1,6 @@
1
1
  // @ts-check
2
2
  const { getBuildOptions, runBuild } = require('../../lib/build')
3
- const { error, exit, generateExamplesHelp, getToken } = require('../../utils')
3
+ const { error, exit, getToken } = require('../../utils')
4
4
 
5
5
  /**
6
6
  * @param {import('../../lib/build').BuildConfig} options
@@ -52,7 +52,7 @@ const createBuildCommand = (program) =>
52
52
  .option('--dry', 'Dry run: show instructions without running them', false)
53
53
  .option('--context [context]', 'Build context')
54
54
  .option('-o, --offline', 'disables any features that require network access', false)
55
- .addHelpText('after', generateExamplesHelp(['netlify build']))
55
+ .addExamples(['netlify build'])
56
56
  .action(build)
57
57
 
58
58
  module.exports = { createBuildCommand }
@@ -1,7 +1,5 @@
1
1
  const { Option } = require('commander')
2
2
 
3
- const { generateDescriptionHelp, generateExamplesHelp } = require('../../utils')
4
-
5
3
  /**
6
4
  * The completion:generate command
7
5
  * @param {import('commander').OptionValues} options
@@ -19,24 +17,20 @@ const completionGenerate = (options, command) => {
19
17
  const createCompletionCommand = (program) => {
20
18
  program
21
19
  .command('completion:generate')
20
+ .description(
21
+ 'Generates completion script\nRun the "completion" command to see instructions about how to use the script generated by this command',
22
+ )
22
23
  .addOption(
23
24
  new Option('-s, --shell <shell>', 'Name of shell').choices(['bash', 'fish', 'zsh']).makeOptionMandatory(true),
24
25
  )
25
- .addHelpText(
26
- 'after',
27
- generateDescriptionHelp(
28
- 'Run the "completion" command to see instructions about how to use the script generated by this command',
29
- ),
30
- )
31
- .addHelpText('after', generateExamplesHelp(['netlify completion --shell zsh']))
26
+ .addExamples(['netlify completion --shell zsh'])
32
27
  .action(completionGenerate)
33
28
 
34
29
  return program
35
30
  .command('completion')
36
- .description('(Beta) Generate shell completion script')
31
+ .description('(Beta) Generate shell completion script\nRun this command to see instructions for your shell.')
37
32
  .addOption(new Option('-s, --shell <shell>', 'Name of shell').choices(['bash', 'fish', 'zsh']))
38
- .addHelpText('after', generateDescriptionHelp('Run this command to see instructions for your shell.'))
39
- .addHelpText('after', generateExamplesHelp(['netlify completion --shell zsh']))
33
+ .addExamples(['netlify completion --shell zsh'])
40
34
  .action((options, command) => command.help())
41
35
  }
42
36
  module.exports = { createCompletionCommand }
@@ -23,8 +23,6 @@ const {
23
23
  deploySite,
24
24
  error,
25
25
  exit,
26
- generateDescriptionHelp,
27
- generateExamplesHelp,
28
26
  getFunctionsManifestPath,
29
27
  getInternalFunctionsDir,
30
28
  getToken,
@@ -580,36 +578,9 @@ const deploy = async (options, command) => {
580
578
  const createDeployCommand = (program) =>
581
579
  program
582
580
  .command('deploy')
583
- .description('Create a new deploy from the contents of a folder')
584
- .option('-d, --dir <path>', 'Specify a folder to deploy')
585
- .option('-f, --functions', 'Specify a functions folder to deploy')
586
- .option('-p, --prod', 'Deploy to production', false)
587
- .option('--prodIfUnlocked', 'Deploy to production if unlocked, create a draft otherwise', false)
588
- .option(
589
- '--alias <name>',
590
- 'Specifies the alias for deployment, the string at the beginning of the deploy subdomain. Useful for creating predictable deployment URLs. Avoid setting an alias string to the same value as a deployed branch. `alias` doesn’t create a branch deploy and can’t be used in conjunction with the branch subdomain feature. Maximum 37 characters.',
591
- )
592
- .option(
593
- '-b, --branch <name>',
594
- 'Serves the same functionality as --alias. Deprecated and will be removed in future versions',
595
- )
596
- .option('-o, --open', 'Open site after deploy', false)
597
- .option('-m, --message <message>', 'A short message to include in the deploy log')
598
- .option('-a, --auth <token>', 'Netlify auth token to deploy with', env.NETLIFY_AUTH_TOKEN)
599
- .option('-s, --site <id>', 'A site ID to deploy to', env.NETLIFY_SITE_ID)
600
- .option('--json', 'Output deployment data as JSON')
601
- .option('--timeout <number>', 'Timeout to wait for deployment to finish', (value) => Number.parseInt(value))
602
- .option('--trigger', 'Trigger a new build of your site on Netlify without uploading local files')
603
- .option('--build', 'Run build command before deploying')
604
- .option(
605
- '--skip-functions-cache',
606
- 'Ignore any functions created as part of a previous `build` or `deploy` commands, forcing them to be bundled again as part of the deployment',
607
- false,
608
- )
609
- .addHelpText(
610
- 'after',
611
- generateDescriptionHelp(
612
- `Deploys from the build settings found in the netlify.toml file, or settings from the API.
581
+ .description(
582
+ `Create a new deploy from the contents of a folder
583
+ Deploys from the build settings found in the netlify.toml file, or settings from the API.
613
584
 
614
585
  The following environment variables can be used to override configuration file lookups and prompts:
615
586
 
@@ -676,20 +647,41 @@ functions/
676
647
  \`\`\`
677
648
 
678
649
  Support for package.json's main field, and intrinsic index.js entrypoints are coming soon.`,
679
- ),
680
650
  )
681
- .addHelpText(
682
- 'after',
683
- generateExamplesHelp([
684
- 'netlify deploy',
685
- 'netlify deploy --prod',
686
- 'netlify deploy --prod --open',
687
- 'netlify deploy --prodIfUnlocked',
688
- 'netlify deploy --message "A message with an $ENV_VAR"',
689
- 'netlify deploy --auth $NETLIFY_AUTH_TOKEN',
690
- 'netlify deploy --trigger',
691
- ]),
651
+ .option('-d, --dir <path>', 'Specify a folder to deploy')
652
+ .option('-f, --functions <folder>', 'Specify a functions folder to deploy')
653
+ .option('-p, --prod', 'Deploy to production', false)
654
+ .option('--prodIfUnlocked', 'Deploy to production if unlocked, create a draft otherwise', false)
655
+ .option(
656
+ '--alias <name>',
657
+ 'Specifies the alias for deployment, the string at the beginning of the deploy subdomain. Useful for creating predictable deployment URLs. Avoid setting an alias string to the same value as a deployed branch. `alias` doesn’t create a branch deploy and can’t be used in conjunction with the branch subdomain feature. Maximum 37 characters.',
658
+ )
659
+ .option(
660
+ '-b, --branch <name>',
661
+ 'Serves the same functionality as --alias. Deprecated and will be removed in future versions',
662
+ )
663
+ .option('-o, --open', 'Open site after deploy', false)
664
+ .option('-m, --message <message>', 'A short message to include in the deploy log')
665
+ .option('-a, --auth <token>', 'Netlify auth token to deploy with', env.NETLIFY_AUTH_TOKEN)
666
+ .option('-s, --site <id>', 'A site ID to deploy to', env.NETLIFY_SITE_ID)
667
+ .option('--json', 'Output deployment data as JSON')
668
+ .option('--timeout <number>', 'Timeout to wait for deployment to finish', (value) => Number.parseInt(value))
669
+ .option('--trigger', 'Trigger a new build of your site on Netlify without uploading local files')
670
+ .option('--build', 'Run build command before deploying')
671
+ .option(
672
+ '--skip-functions-cache',
673
+ 'Ignore any functions created as part of a previous `build` or `deploy` commands, forcing them to be bundled again as part of the deployment',
674
+ false,
692
675
  )
676
+ .addExamples([
677
+ 'netlify deploy',
678
+ 'netlify deploy --prod',
679
+ 'netlify deploy --prod --open',
680
+ 'netlify deploy --prodIfUnlocked',
681
+ 'netlify deploy --message "A message with an $ENV_VAR"',
682
+ 'netlify deploy --auth $NETLIFY_AUTH_TOKEN',
683
+ 'netlify deploy --trigger',
684
+ ])
693
685
  .action(deploy)
694
686
 
695
687
  module.exports = { createDeployCommand }