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
@@ -1,6 +1,6 @@
1
1
  const execa = require('execa')
2
2
 
3
- const { generateDescriptionHelp, generateExamplesHelp, injectEnvVariables } = require('../../utils')
3
+ const { injectEnvVariables } = require('../../utils')
4
4
 
5
5
  /**
6
6
  * The dev:exec command
@@ -24,16 +24,12 @@ const devExec = async (cmd, options, command) => {
24
24
  const createDevExecCommand = (program) =>
25
25
  program
26
26
  .command('dev:exec')
27
- .argument('<...cmd>')
28
- .description('Exec command')
29
- .allowExcessArguments(true)
30
- .addHelpText(
31
- 'after',
32
- generateDescriptionHelp(
33
- 'Runs a command within the netlify dev environment, e.g. with env variables from any installed addons',
34
- ),
27
+ .argument('<...cmd>', `the command that should be executed`)
28
+ .description(
29
+ 'Exec command\nRuns a command within the netlify dev environment, e.g. with env variables from any installed addons',
35
30
  )
36
- .addHelpText('after', generateExamplesHelp(['netlify dev:exec npm run bootstrap']))
31
+ .allowExcessArguments(true)
32
+ .addExamples(['netlify dev:exec npm run bootstrap'])
37
33
  .action(devExec)
38
34
 
39
35
  module.exports = { createDevExecCommand }
@@ -1,7 +1,7 @@
1
1
  // @ts-check
2
2
  const process = require('process')
3
3
 
4
- const { generateExamplesHelp, runProcess } = require('../../utils')
4
+ const { runProcess } = require('../../utils')
5
5
 
6
6
  /**
7
7
  * The dev:trace command
@@ -35,16 +35,13 @@ const createDevTraceCommand = (program) =>
35
35
  `Simulates Netlify's Edge routing logic to match specific requests.
36
36
  This command is designed to mimic cURL's command line, so the flags are more familiar.`,
37
37
  )
38
- .addHelpText(
39
- 'after',
40
- generateExamplesHelp([
41
- 'netlify dev:trace http://localhost/routing-path',
42
- 'netlify dev:trace -w dist-directory http://localhost/routing-path',
43
- 'netlify dev:trace -X POST http://localhost/routing-path',
44
- 'netlify dev:trace -H "Accept-Language es" http://localhost/routing-path',
45
- 'netlify dev:trace --cookie nf_jwt=token http://localhost/routing-path',
46
- ]),
47
- )
38
+ .addExamples([
39
+ 'netlify dev:trace http://localhost/routing-path',
40
+ 'netlify dev:trace -w dist-directory http://localhost/routing-path',
41
+ 'netlify dev:trace -X POST http://localhost/routing-path',
42
+ 'netlify dev:trace -H "Accept-Language es" http://localhost/routing-path',
43
+ 'netlify dev:trace --cookie nf_jwt=token http://localhost/routing-path',
44
+ ])
48
45
  .action(devTrace)
49
46
 
50
47
  module.exports = { createDevTraceCommand }
@@ -4,6 +4,7 @@ const process = require('process')
4
4
  const { promisify } = require('util')
5
5
 
6
6
  const boxen = require('boxen')
7
+ const { Option } = require('commander')
7
8
  const execa = require('execa')
8
9
  const StaticServer = require('static-server')
9
10
  const stripAnsiCc = require('strip-ansi-control-characters')
@@ -18,8 +19,6 @@ const {
18
19
  chalk,
19
20
  detectServerSettings,
20
21
  exit,
21
- generateDescriptionHelp,
22
- generateExamplesHelp,
23
22
  getSiteInformation,
24
23
  injectEnvVariables,
25
24
  log,
@@ -304,46 +303,38 @@ const createDevCommand = (program) => {
304
303
  createDevExecCommand(program)
305
304
  createDevTraceCommand(program)
306
305
 
307
- return (
308
- program
309
- .command('dev')
310
- .description('Local dev server')
311
- .option('-c ,--command <command>', 'command to run')
312
- .option('-p ,--port <port>', 'port of netlify dev', (value) => Number.parseInt(value))
313
- .option('--targetPort <port>', 'port of target app server', (value) => Number.parseInt(value))
314
- .option('--framework <name>', 'framework to use. Defaults to #auto which automatically detects a framework')
315
- // TODO: hidden
316
- .option(
317
- '--staticServerPort <port>',
318
- 'port of the static app server used when no framework is detected',
319
- (value) => Number.parseInt(value),
320
- )
321
- .option('-d ,--dir <path>', 'dir with static files')
322
- .option('-f ,--functions <folder>', 'specify a functions folder to serve')
323
- .option('-o ,--offline', 'disables any features that require network access')
324
- .option('-l, --live', 'start a public live session', false)
325
- // TODO: hidden
326
- .option('-e ,--edgeHandlers', 'activates the Edge Handlers runtime')
327
- // TODO: hidden
328
- .option(
306
+ return program
307
+ .command('dev')
308
+ .description(
309
+ `Local dev server\nThe dev command will run a local dev server with Netlify's proxy and redirect rules`,
310
+ )
311
+ .option('-c ,--command <command>', 'command to run')
312
+ .option('-p ,--port <port>', 'port of netlify dev', (value) => Number.parseInt(value))
313
+ .option('--targetPort <port>', 'port of target app server', (value) => Number.parseInt(value))
314
+ .option('--framework <name>', 'framework to use. Defaults to #auto which automatically detects a framework')
315
+ .option('-d ,--dir <path>', 'dir with static files')
316
+ .option('-f ,--functions <folder>', 'specify a functions folder to serve')
317
+ .option('-o ,--offline', 'disables any features that require network access')
318
+ .option('-l, --live', 'start a public live session', false)
319
+ .addOption(
320
+ new Option('--staticServerPort <port>', 'port of the static app server used when no framework is detected')
321
+ .argParser((value) => Number.parseInt(value))
322
+ .hideHelp(),
323
+ )
324
+ .addOption(new Option('-e ,--edgeHandlers', 'activates the Edge Handlers runtime').hideHelp())
325
+ .addOption(
326
+ new Option(
329
327
  '-t ,--trafficMesh',
330
328
  '(DEPRECATED: use --edgeHandlers or -e instead) uses Traffic Mesh for proxying requests',
331
- )
332
- // TODO: hidden
333
- .option('-g ,--locationDb <path>', 'specify the path to a local GeoIP location database in MMDB format')
334
- .addHelpText(
335
- 'after',
336
- generateDescriptionHelp(`The dev command will run a local dev server with Netlify's proxy and redirect rules`),
337
- )
338
- .addHelpText(
339
- 'after',
340
- generateExamplesHelp([
341
- 'netlify dev',
342
- 'netlify dev -d public',
343
- 'netlify dev -c "hugo server -w" --targetPort 1313',
344
- ]),
345
- )
346
- .action(dev)
347
- )
329
+ ).hideHelp(),
330
+ )
331
+ .addOption(
332
+ new Option(
333
+ '-g ,--locationDb <path>',
334
+ 'specify the path to a local GeoIP location database in MMDB format',
335
+ ).hideHelp(),
336
+ )
337
+ .addExamples(['netlify dev', 'netlify dev -d public', 'netlify dev -c "hugo server -w" --targetPort 1313'])
338
+ .action(dev)
348
339
  }
349
340
  module.exports = { createDevCommand }
@@ -1,5 +1,4 @@
1
- const { generateExamplesHelp } = require('../../utils')
2
-
1
+ // @ts-check
3
2
  const { createEnvGetCommand } = require('./env-get')
4
3
  const { createEnvImportCommand } = require('./env-import')
5
4
  const { createEnvListCommand } = require('./env-list')
@@ -30,16 +29,13 @@ const createEnvCommand = (program) => {
30
29
  return program
31
30
  .command('env')
32
31
  .description('(Beta) Control environment variables for the current site')
33
- .addHelpText(
34
- 'after',
35
- generateExamplesHelp([
36
- 'netlify env:list',
37
- 'netlify env:get VAR_NAME',
38
- 'netlify env:set VAR_NAME value',
39
- 'netlify env:unset VAR_NAME',
40
- 'netlify env:import fileName',
41
- ]),
42
- )
32
+ .addExamples([
33
+ 'netlify env:list',
34
+ 'netlify env:get VAR_NAME',
35
+ 'netlify env:set VAR_NAME value',
36
+ 'netlify env:unset VAR_NAME',
37
+ 'netlify env:import fileName',
38
+ ])
43
39
  .action(env)
44
40
  }
45
41
 
@@ -52,7 +52,7 @@ const createFunctionsBuildCommand = (program) =>
52
52
  .command('functions:build')
53
53
  .alias('function:build')
54
54
  .description('Build functions locally')
55
- .option('-f, --function <directory>', 'Specify a functions directory to build to')
55
+ .option('-f, --functions <directory>', 'Specify a functions directory to build to')
56
56
  .option('-s, --src <directory>', 'Specify the source directory for the functions')
57
57
  .action(functionsBuild)
58
58
 
@@ -21,7 +21,7 @@ const {
21
21
  chalk,
22
22
  error,
23
23
  execa,
24
- generateExamplesHelp,
24
+
25
25
  injectEnvVariables,
26
26
  log,
27
27
  readRepoURL,
@@ -591,14 +591,11 @@ const createFunctionsCreateCommand = (program) =>
591
591
  .option('-n, --name <name>', 'function name')
592
592
  .option('-u, --url <url>', 'pull template from URL')
593
593
  .option('-l, --language <lang>', 'function language')
594
- .addHelpText(
595
- 'after',
596
- generateExamplesHelp([
597
- 'netlify functions:create',
598
- 'netlify functions:create hello-world',
599
- 'netlify functions:create --name hello-world',
600
- ]),
601
- )
594
+ .addExamples([
595
+ 'netlify functions:create',
596
+ 'netlify functions:create hello-world',
597
+ 'netlify functions:create --name hello-world',
598
+ ])
602
599
  .action(functionsCreate)
603
600
 
604
601
  module.exports = { createFunctionsCreateCommand }
@@ -6,7 +6,7 @@ const process = require('process')
6
6
  const inquirer = require('inquirer')
7
7
  const fetch = require('node-fetch')
8
8
 
9
- const { BACKGROUND, NETLIFYDEVWARN, chalk, error, exit, generateExamplesHelp, getFunctions } = require('../../utils')
9
+ const { BACKGROUND, NETLIFYDEVWARN, chalk, error, exit, getFunctions } = require('../../utils')
10
10
 
11
11
  // https://www.netlify.com/docs/functions/#event-triggered-functions
12
12
  const events = [
@@ -258,19 +258,16 @@ const createFunctionsInvokeCommand = (program) =>
258
258
  'simulate Netlify Identity authentication JWT. pass --no-identity to affirm unauthenticated request',
259
259
  )
260
260
  .option('--port <port>', 'Port where netlify dev is accessible. e.g. 8888', (value) => Number.parseInt(value))
261
- .addHelpText(
262
- 'after',
263
- generateExamplesHelp([
264
- 'netlify functions:invoke',
265
- 'netlify functions:invoke myfunction',
266
- 'netlify functions:invoke --name myfunction',
267
- 'netlify functions:invoke --name myfunction --identity',
268
- 'netlify functions:invoke --name myfunction --no-identity',
269
- `netlify functions:invoke myfunction --payload '{"foo": 1}'`,
270
- 'netlify functions:invoke myfunction --querystring "foo=1',
271
- 'netlify functions:invoke myfunction --payload "./pathTo.json"',
272
- ]),
273
- )
261
+ .addExamples([
262
+ 'netlify functions:invoke',
263
+ 'netlify functions:invoke myfunction',
264
+ 'netlify functions:invoke --name myfunction',
265
+ 'netlify functions:invoke --name myfunction --identity',
266
+ 'netlify functions:invoke --name myfunction --no-identity',
267
+ `netlify functions:invoke myfunction --payload '{"foo": 1}'`,
268
+ 'netlify functions:invoke myfunction --querystring "foo=1',
269
+ 'netlify functions:invoke myfunction --payload "./pathTo.json"',
270
+ ])
274
271
  .action(functionsInvoke)
275
272
 
276
273
  module.exports = { createFunctionsInvokeCommand }
@@ -5,7 +5,7 @@ const AsciiTable = require('ascii-table')
5
5
  const {
6
6
  error,
7
7
  exit,
8
- generateDescriptionHelp,
8
+
9
9
  getFunctions,
10
10
  getFunctionsDir,
11
11
  log,
@@ -92,16 +92,15 @@ const createFunctionsListCommand = (program) =>
92
92
  program
93
93
  .command('functions:list')
94
94
  .alias('function:list')
95
- .description('List functions that exist locally')
95
+ .description(
96
+ `List functions that exist locally
97
+ Helpful for making sure that you have formatted your functions correctly
98
+
99
+ NOT the same as listing the functions that have been deployed. For that info you need to go to your Netlify deploy log.`,
100
+ )
96
101
  .option('-n, --name <name>', 'name to print')
97
102
  .option('-f, --functions <dir>', 'Specify a functions directory to list')
98
103
  .option('--json', 'Output function data as JSON')
99
- .addHelpText(
100
- 'after',
101
- generateDescriptionHelp(`Helpful for making sure that you have formatted your functions correctly
102
-
103
- NOT the same as listing the functions that have been deployed. For that info you need to go to your Netlify deploy log.`),
104
- )
105
104
  .action(functionsList)
106
105
 
107
106
  module.exports = { createFunctionsListCommand }
@@ -1,6 +1,5 @@
1
1
  // @ts-check
2
-
3
- const { chalk, generateDescriptionHelp, generateExamplesHelp } = require('../../utils')
2
+ const { chalk } = require('../../utils')
4
3
 
5
4
  const { createFunctionsBuildCommand } = require('./functions-build')
6
5
  const { createFunctionsCreateCommand } = require('./functions-create')
@@ -34,18 +33,14 @@ const createFunctionsCommand = (program) => {
34
33
  return program
35
34
  .command('functions')
36
35
  .alias('function')
37
- .description('Manage netlify functions')
38
- .addHelpText(
39
- 'after',
40
- generateDescriptionHelp(`The ${name} command will help you manage the functions in this site`),
41
- )
42
- .addHelpText(
43
- 'after',
44
- generateExamplesHelp([
45
- 'netlify functions:create --name function-xyz',
46
- 'netlify functions:build --name function-abc --timeout 30s',
47
- ]),
36
+ .description(
37
+ `Manage netlify functions
38
+ The ${name} command will help you manage the functions in this site`,
48
39
  )
40
+ .addExamples([
41
+ 'netlify functions:create --name function-xyz',
42
+ 'netlify functions:build --name function-abc --timeout 30s',
43
+ ])
49
44
  .action(functions)
50
45
  }
51
46
 
@@ -1,5 +1,7 @@
1
- const { BaseCommand } = require('./base-command')
1
+ const baseCommand = require('./base-command')
2
+ const { createMainCommand } = require('./main')
2
3
 
3
4
  module.exports = {
4
- BaseCommand,
5
+ ...baseCommand,
6
+ createMainCommand,
5
7
  }
@@ -223,7 +223,7 @@ const createInitCommand = (program) =>
223
223
  'Configure continuous deployment for a new or existing site. To create a new site without continuous deployment, use `netlify sites:create`',
224
224
  )
225
225
  .option('-m, --manual', 'Manually configure a git remote for CI')
226
- .option('--force', 'Manually configure a git remote for CI')
226
+ .option('--force', 'Reinitialize CI hooks if the linked site is already configured to use CI')
227
227
  .option('--gitRemoteName <name>', 'Name of Git remote to use. e.g. "origin"')
228
228
  .action(init)
229
229
 
@@ -7,16 +7,7 @@ const inquirer = require('inquirer')
7
7
  const isEmpty = require('lodash/isEmpty')
8
8
 
9
9
  const { listSites } = require('../../lib/api')
10
- const {
11
- chalk,
12
- ensureNetlifyIgnore,
13
- error,
14
- exit,
15
- generateExamplesHelp,
16
- getRepoData,
17
- log,
18
- track,
19
- } = require('../../utils')
10
+ const { chalk, ensureNetlifyIgnore, error, exit, getRepoData, log, track } = require('../../utils')
20
11
 
21
12
  /**
22
13
  *
@@ -370,10 +361,7 @@ const createLinkCommand = (program) =>
370
361
  .option('--id <id>', 'ID of site to link to')
371
362
  .option('--name <name>', 'Name of site to link to')
372
363
  .option('--gitRemoteName <name>', 'Name of Git remote to use. e.g. "origin"')
373
- .addHelpText(
374
- 'after',
375
- generateExamplesHelp(['netlify link', 'netlify link --id 123-123-123-123', 'netlify link --name my-site-name']),
376
- )
364
+ .addExamples(['netlify link', 'netlify link --id 123-123-123-123', 'netlify link --name my-site-name'])
377
365
  .action(link)
378
366
 
379
367
  module.exports = { createLinkCommand, link }
@@ -1,6 +1,4 @@
1
1
  // @ts-check
2
-
3
- const { generateDescriptionHelp } = require('../../utils')
4
2
  const { installPlatform } = require('../../utils/lm/install')
5
3
  const { printBanner } = require('../../utils/lm/ui')
6
4
 
@@ -24,13 +22,12 @@ const createLmInstallCommand = (program) =>
24
22
  program
25
23
  .command('lm:install')
26
24
  .alias('lm:init')
27
- .description('Configures your computer to use Netlify Large Media')
28
- .option('-f, --force', 'Force the credentials helper installation')
29
- .addHelpText(
30
- 'after',
31
- generateDescriptionHelp(`It installs the required credentials helper for Git,
32
- and configures your Git environment with the right credentials.`),
25
+ .description(
26
+ `Configures your computer to use Netlify Large Media
27
+ It installs the required credentials helper for Git,
28
+ and configures your Git environment with the right credentials.`,
33
29
  )
30
+ .option('-f, --force', 'Force the credentials helper installation')
34
31
  .action(lmInstall)
35
32
 
36
33
  module.exports = { createLmInstallCommand }
@@ -1,7 +1,4 @@
1
1
  // @ts-check
2
-
3
- const { generateDescriptionHelp, generateExamplesHelp } = require('../../utils')
4
-
5
2
  const { createLmInfoCommand } = require('./lm-info')
6
3
  const { createLmInstallCommand } = require('./lm-install')
7
4
  const { createLmSetupCommand } = require('./lm-setup')
@@ -29,9 +26,8 @@ const createLmCommand = (program) => {
29
26
 
30
27
  program
31
28
  .command('lm')
32
- .description('Handle Netlify Large Media operations')
33
- .addHelpText('after', generateDescriptionHelp('The lm command will help you manage large media for a site'))
34
- .addHelpText('after', generateExamplesHelp(['netlify lm:info', 'netlify lm:install', 'netlify lm:setup']))
29
+ .description('Handle Netlify Large Media operations\nThe lm command will help you manage large media for a site')
30
+ .addExamples(['netlify lm:info', 'netlify lm:install', 'netlify lm:setup'])
35
31
  .action(lm)
36
32
  }
37
33
 
@@ -45,7 +45,10 @@ const login = async (options, command) => {
45
45
  const createLoginCommand = (program) =>
46
46
  program
47
47
  .command('login')
48
- .description('Login to your Netlify account')
48
+ .description(
49
+ `Login to your Netlify account
50
+ Opens a web browser to acquire an OAuth token.`,
51
+ )
49
52
  .option('--new', 'Login to new Netlify account')
50
53
  .action(login)
51
54
 
@@ -1,11 +1,34 @@
1
1
  // @ts-check
2
2
  const process = require('process')
3
3
 
4
+ const { Option } = require('commander')
4
5
  const inquirer = require('inquirer')
5
6
  const { findBestMatch } = require('string-similarity')
6
7
 
8
+ const pkg = require('../../package.json')
7
9
  const { NETLIFY_CYAN, USER_AGENT, chalk, error, execa, exit, getGlobalConfig, log, track, warn } = require('../utils')
8
10
 
11
+ const { createAddonsCommand } = require('./addons')
12
+ const { createApiCommand } = require('./api')
13
+ const { BaseCommand } = require('./base-command')
14
+ const { createBuildCommand } = require('./build')
15
+ const { createCompletionCommand } = require('./completion')
16
+ const { createDeployCommand } = require('./deploy')
17
+ const { createDevCommand } = require('./dev')
18
+ const { createEnvCommand } = require('./env')
19
+ const { createFunctionsCommand } = require('./functions')
20
+ const { createInitCommand } = require('./init')
21
+ const { createLinkCommand } = require('./link')
22
+ const { createLmCommand } = require('./lm')
23
+ const { createLoginCommand } = require('./login')
24
+ const { createLogoutCommand } = require('./logout')
25
+ const { createOpenCommand } = require('./open')
26
+ const { createSitesCommand } = require('./sites')
27
+ const { createStatusCommand } = require('./status')
28
+ const { createSwitchCommand } = require('./switch')
29
+ const { createUnlinkCommand } = require('./unlink')
30
+ const { createWatchCommand } = require('./watch')
31
+
9
32
  const SUGGESTION_TIMEOUT = 1e4
10
33
 
11
34
  const getVersionPage = async () => {
@@ -50,12 +73,30 @@ const mainCommand = async function (options, command) {
50
73
  exit()
51
74
  }
52
75
 
53
- if (command.args[0] === 'version') {
54
- const versionPage = await getVersionPage()
55
- log(versionPage)
76
+ if (command.args[0] === 'version' || options.version) {
77
+ if (options.verbose) {
78
+ const versionPage = await getVersionPage()
79
+ log(versionPage)
80
+ }
81
+ log(USER_AGENT)
56
82
  exit()
57
83
  }
58
84
 
85
+ // if no command show the header and the help
86
+ if (command.args.length === 0) {
87
+ const title = `${chalk.bgBlack.cyan('⬥ Netlify CLI')}`
88
+ const docsMsg = `${chalk.greenBright('Read the docs:')} https://www.netlify.com/docs/cli`
89
+ const supportMsg = `${chalk.magentaBright('Support and bugs:')} ${pkg.bugs.url}`
90
+
91
+ console.log()
92
+ console.log(title)
93
+ console.log(docsMsg)
94
+ console.log(supportMsg)
95
+ console.log()
96
+
97
+ command.help()
98
+ }
99
+
59
100
  if (command.args[0] === 'help') {
60
101
  if (command.args[1]) {
61
102
  const subCommand = command.commands.find((cmd) => cmd.name() === command.args[1])
@@ -102,17 +143,46 @@ const mainCommand = async function (options, command) {
102
143
  }
103
144
 
104
145
  /**
105
- * Creates the `netlify functions:create` command
106
- * @param {import('./base-command').BaseCommand} program
107
- * @returns
146
+ * Creates the `netlify-cli` command
147
+ * Promise is needed as the envinfo is a promise
148
+ * @returns {import('./base-command').BaseCommand}
108
149
  */
109
- const createMainCommand = async (program) =>
150
+ const createMainCommand = () => {
151
+ const program = new BaseCommand('netlify')
152
+ // register all the commands
153
+ createAddonsCommand(program)
154
+ createApiCommand(program)
155
+ createBuildCommand(program)
156
+ createCompletionCommand(program)
157
+ createDeployCommand(program)
158
+ createDevCommand(program)
159
+ createEnvCommand(program)
160
+ createFunctionsCommand(program)
161
+ createInitCommand(program)
162
+ createLinkCommand(program)
163
+ createLmCommand(program)
164
+ createLoginCommand(program)
165
+ createLogoutCommand(program)
166
+ createOpenCommand(program)
167
+ createSitesCommand(program)
168
+ createStatusCommand(program)
169
+ createSwitchCommand(program)
170
+ createUnlinkCommand(program)
171
+ createWatchCommand(program)
172
+
110
173
  program
111
- .version(await getVersionPage(), '-v, --version')
174
+ .version(USER_AGENT, '-V')
112
175
  .showSuggestionAfterError(true)
113
176
  .option('--telemetry-disable', 'Disable telemetry')
114
177
  .option('--telemetry-enable', 'Enables telemetry')
178
+ // needed for custom version output as we display further environment information
179
+ // commanders version output is set to uppercase -V
180
+ .addOption(new Option('-v, --version').hideHelp())
181
+ .addOption(new Option('--verbose').hideHelp())
115
182
  .noHelpOptions()
116
183
  .action(mainCommand)
117
184
 
185
+ return program
186
+ }
187
+
118
188
  module.exports = { createMainCommand }
@@ -51,6 +51,10 @@ Run \`netlify link\` to connect to this folder to a site`)
51
51
  * @returns
52
52
  */
53
53
  const createOpenAdminCommand = (program) =>
54
- program.command('open:admin').description('Opens current site admin UI in Netlify').action(openAdmin)
54
+ program
55
+ .command('open:admin')
56
+ .description('Opens current site admin UI in Netlify')
57
+ .addExamples(['netlify open:admin'])
58
+ .action(openAdmin)
55
59
 
56
60
  module.exports = { createOpenAdminCommand, openAdmin }
@@ -44,6 +44,10 @@ Run \`netlify link\` to connect to this folder to a site`)
44
44
  * @returns
45
45
  */
46
46
  const createOpenSiteCommand = (program) =>
47
- program.command('open:site').description('Opens current site url in browser').action(openSite)
47
+ program
48
+ .command('open:site')
49
+ .description('Opens current site url in browser')
50
+ .addExamples(['netlify open:site'])
51
+ .action(openSite)
48
52
 
49
53
  module.exports = { createOpenSiteCommand, openSite }
@@ -1,5 +1,3 @@
1
- const { generateExamplesHelp } = require('../../utils')
2
-
3
1
  const { createOpenAdminCommand, openAdmin } = require('./open-admin')
4
2
  const { createOpenSiteCommand, openSite } = require('./open-site')
5
3
 
@@ -31,11 +29,10 @@ const createOpenCommand = (program) => {
31
29
 
32
30
  return program
33
31
  .command('open')
34
- .description('Open settings for the site linked to the current folder')
35
- .addHelpText(
36
- 'after',
37
- generateExamplesHelp(['netlify open --site', 'netlify open --admin', 'netlify open:admin', 'netlify open:site']),
38
- )
32
+ .description(`Open settings for the site linked to the current folder`)
33
+ .option('--site', 'Open site')
34
+ .option('--admin', 'Open Netlify site')
35
+ .addExamples(['netlify open --site', 'netlify open --admin', 'netlify open:admin', 'netlify open:site'])
39
36
  .action(open)
40
37
  }
41
38
  module.exports = { createOpenCommand }
@@ -170,7 +170,10 @@ const sitesCreate = async (options, command) => {
170
170
  const createSitesCreateCommand = (program) =>
171
171
  program
172
172
  .command('sites:create')
173
- .description('Create an empty site (advanced)')
173
+ .description(
174
+ `Create an empty site (advanced)
175
+ Create a blank site that isn't associated with any git remote. Does not link to the current working directory.`,
176
+ )
174
177
  .option('-n, --name [name]', 'name of site')
175
178
  .option('-a, --account-slug [slug]', 'account slug to create the site under')
176
179
  .option('-c, --with-ci', 'initialize CI hooks during site creation')