netlify-cli 17.3.2 → 17.4.0

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 (210) hide show
  1. package/README.md +2 -138
  2. package/npm-shrinkwrap.json +76 -76
  3. package/package.json +16 -15
  4. package/src/commands/addons/addons-auth.mjs +27 -30
  5. package/src/commands/addons/addons-config.mjs +145 -154
  6. package/src/commands/addons/addons-create.mjs +94 -108
  7. package/src/commands/addons/addons-delete.mjs +36 -41
  8. package/src/commands/addons/addons-list.mjs +38 -42
  9. package/src/commands/addons/addons.mjs +26 -28
  10. package/src/commands/addons/index.mjs +1 -1
  11. package/src/commands/api/api.mjs +45 -53
  12. package/src/commands/api/index.mjs +1 -1
  13. package/src/commands/base-command.mjs +597 -684
  14. package/src/commands/blobs/blobs-delete.mjs +35 -0
  15. package/src/commands/blobs/blobs-get.mjs +44 -0
  16. package/src/commands/blobs/blobs-list.mjs +48 -0
  17. package/src/commands/blobs/blobs-set.mjs +54 -0
  18. package/src/commands/blobs/blobs.mjs +32 -0
  19. package/src/commands/blobs/index.mjs +1 -0
  20. package/src/commands/build/build.mjs +55 -67
  21. package/src/commands/build/index.mjs +1 -1
  22. package/src/commands/completion/completion.mjs +41 -46
  23. package/src/commands/completion/index.mjs +1 -1
  24. package/src/commands/deploy/deploy.mjs +675 -710
  25. package/src/commands/deploy/index.mjs +1 -1
  26. package/src/commands/dev/dev-exec.mjs +20 -32
  27. package/src/commands/dev/dev.mjs +217 -302
  28. package/src/commands/dev/index.mjs +1 -1
  29. package/src/commands/dev/types.d.ts +30 -0
  30. package/src/commands/env/env-clone.mjs +157 -184
  31. package/src/commands/env/env-get.mjs +49 -68
  32. package/src/commands/env/env-import.mjs +100 -119
  33. package/src/commands/env/env-list.mjs +104 -129
  34. package/src/commands/env/env-set.mjs +160 -185
  35. package/src/commands/env/env-unset.mjs +104 -122
  36. package/src/commands/env/env.mjs +28 -30
  37. package/src/commands/env/index.mjs +1 -1
  38. package/src/commands/functions/functions-build.mjs +29 -41
  39. package/src/commands/functions/functions-create.mjs +533 -601
  40. package/src/commands/functions/functions-invoke.mjs +193 -216
  41. package/src/commands/functions/functions-list.mjs +45 -55
  42. package/src/commands/functions/functions-serve.mjs +51 -61
  43. package/src/commands/functions/functions.mjs +26 -32
  44. package/src/commands/functions/index.mjs +1 -1
  45. package/src/commands/index.mjs +2 -2
  46. package/src/commands/init/index.mjs +1 -1
  47. package/src/commands/init/init.mjs +138 -167
  48. package/src/commands/integration/deploy.mjs +337 -399
  49. package/src/commands/integration/index.mjs +12 -13
  50. package/src/commands/link/index.mjs +1 -1
  51. package/src/commands/link/link.mjs +298 -317
  52. package/src/commands/lm/index.mjs +1 -1
  53. package/src/commands/lm/lm-info.mjs +23 -31
  54. package/src/commands/lm/lm-install.mjs +13 -17
  55. package/src/commands/lm/lm-setup.mjs +80 -84
  56. package/src/commands/lm/lm-uninstall.mjs +7 -12
  57. package/src/commands/lm/lm.mjs +18 -22
  58. package/src/commands/login/index.mjs +1 -1
  59. package/src/commands/login/login.mjs +35 -41
  60. package/src/commands/logout/index.mjs +1 -1
  61. package/src/commands/logout/logout.mjs +25 -31
  62. package/src/commands/main.mjs +166 -201
  63. package/src/commands/open/index.mjs +1 -1
  64. package/src/commands/open/open-admin.mjs +15 -18
  65. package/src/commands/open/open-site.mjs +16 -19
  66. package/src/commands/open/open.mjs +24 -27
  67. package/src/commands/recipes/common.mjs +23 -34
  68. package/src/commands/recipes/index.mjs +1 -1
  69. package/src/commands/recipes/recipes-list.mjs +13 -20
  70. package/src/commands/recipes/recipes.mjs +59 -72
  71. package/src/commands/serve/index.mjs +1 -1
  72. package/src/commands/serve/serve.mjs +142 -189
  73. package/src/commands/sites/index.mjs +2 -2
  74. package/src/commands/sites/sites-create-template.mjs +214 -236
  75. package/src/commands/sites/sites-create.mjs +145 -157
  76. package/src/commands/sites/sites-delete.mjs +75 -81
  77. package/src/commands/sites/sites-list.mjs +63 -66
  78. package/src/commands/sites/sites.mjs +18 -20
  79. package/src/commands/status/index.mjs +1 -1
  80. package/src/commands/status/status-hooks.mjs +32 -34
  81. package/src/commands/status/status.mjs +99 -106
  82. package/src/commands/switch/index.mjs +1 -1
  83. package/src/commands/switch/switch.mjs +32 -37
  84. package/src/commands/types.d.ts +31 -0
  85. package/src/commands/unlink/index.mjs +1 -1
  86. package/src/commands/unlink/unlink.mjs +23 -29
  87. package/src/commands/watch/index.mjs +1 -1
  88. package/src/commands/watch/watch.mjs +91 -105
  89. package/src/functions-templates/javascript/hello/{{name}}.js +2 -3
  90. package/src/lib/account.mjs +4 -5
  91. package/src/lib/api.mjs +22 -20
  92. package/src/lib/blobs/blobs.mjs +36 -45
  93. package/src/lib/build.mjs +82 -85
  94. package/src/lib/completion/constants.mjs +2 -4
  95. package/src/lib/completion/generate-autocompletion.mjs +33 -36
  96. package/src/lib/completion/get-autocompletion.mjs +31 -35
  97. package/src/lib/completion/index.mjs +1 -1
  98. package/src/lib/completion/script.mjs +12 -19
  99. package/src/lib/edge-functions/bootstrap.mjs +3 -5
  100. package/src/lib/edge-functions/consts.mjs +9 -10
  101. package/src/lib/edge-functions/deploy.mjs +28 -34
  102. package/src/lib/edge-functions/editor-helper.mjs +29 -42
  103. package/src/lib/edge-functions/headers.mjs +24 -26
  104. package/src/lib/edge-functions/internal.mjs +38 -44
  105. package/src/lib/edge-functions/proxy.mjs +229 -228
  106. package/src/lib/edge-functions/registry.mjs +473 -574
  107. package/src/lib/exec-fetcher.mjs +115 -122
  108. package/src/lib/fs.mjs +28 -27
  109. package/src/lib/functions/background.mjs +16 -20
  110. package/src/lib/functions/config.mjs +12 -9
  111. package/src/lib/functions/form-submissions-handler.mjs +143 -149
  112. package/src/lib/functions/local-proxy.mjs +40 -44
  113. package/src/lib/functions/memoized-build.mjs +19 -21
  114. package/src/lib/functions/netlify-function.mjs +269 -249
  115. package/src/lib/functions/registry.mjs +509 -568
  116. package/src/lib/functions/runtimes/go/index.mjs +62 -71
  117. package/src/lib/functions/runtimes/index.mjs +8 -15
  118. package/src/lib/functions/runtimes/js/builders/netlify-lambda.mjs +55 -64
  119. package/src/lib/functions/runtimes/js/builders/zisi.mjs +135 -154
  120. package/src/lib/functions/runtimes/js/constants.mjs +1 -1
  121. package/src/lib/functions/runtimes/js/index.mjs +92 -109
  122. package/src/lib/functions/runtimes/js/worker.mjs +43 -45
  123. package/src/lib/functions/runtimes/rust/index.mjs +64 -73
  124. package/src/lib/functions/scheduled.mjs +70 -88
  125. package/src/lib/functions/server.mjs +269 -327
  126. package/src/lib/functions/synchronous.mjs +118 -147
  127. package/src/lib/functions/utils.mjs +38 -46
  128. package/src/lib/geo-location.mjs +69 -81
  129. package/src/lib/http-agent.mjs +87 -90
  130. package/src/lib/images/proxy.mjs +97 -99
  131. package/src/lib/log.mjs +6 -9
  132. package/src/lib/path.mjs +2 -1
  133. package/src/lib/render-error-template.mjs +19 -20
  134. package/src/lib/settings.mjs +17 -19
  135. package/src/lib/spinner.mjs +21 -23
  136. package/src/lib/string.mjs +4 -2
  137. package/src/recipes/vscode/index.mjs +69 -85
  138. package/src/recipes/vscode/settings.mjs +53 -58
  139. package/src/utils/addons/compare.mjs +31 -32
  140. package/src/utils/addons/diffs/index.mjs +16 -17
  141. package/src/utils/addons/diffs/options.mjs +99 -101
  142. package/src/utils/addons/prepare.mjs +100 -97
  143. package/src/utils/addons/prompts.mjs +73 -76
  144. package/src/utils/addons/render.mjs +33 -36
  145. package/src/utils/addons/validation.mjs +19 -15
  146. package/src/utils/banner.mjs +11 -16
  147. package/src/utils/build-info.mjs +65 -66
  148. package/src/utils/command-helpers.mjs +185 -199
  149. package/src/utils/create-deferred.mjs +9 -12
  150. package/src/utils/create-stream-promise.mjs +54 -47
  151. package/src/utils/deploy/constants.mjs +9 -11
  152. package/src/utils/deploy/deploy-site.mjs +162 -182
  153. package/src/utils/deploy/hash-config.mjs +21 -21
  154. package/src/utils/deploy/hash-files.mjs +34 -38
  155. package/src/utils/deploy/hash-fns.mjs +149 -154
  156. package/src/utils/deploy/hasher-segments.mjs +58 -52
  157. package/src/utils/deploy/upload-files.mjs +99 -113
  158. package/src/utils/deploy/util.mjs +85 -91
  159. package/src/utils/detect-server-settings.mjs +236 -268
  160. package/src/utils/dev.mjs +163 -178
  161. package/src/utils/dot-env.mjs +37 -42
  162. package/src/utils/env/index.mjs +148 -148
  163. package/src/utils/execa.mjs +9 -13
  164. package/src/utils/feature-flags.mjs +6 -5
  165. package/src/utils/framework-server.mjs +43 -52
  166. package/src/utils/functions/constants.mjs +1 -1
  167. package/src/utils/functions/functions.mjs +30 -40
  168. package/src/utils/functions/get-functions.mjs +28 -29
  169. package/src/utils/functions/index.mjs +3 -3
  170. package/src/utils/get-global-config.mjs +33 -36
  171. package/src/utils/get-package-json.mjs +14 -15
  172. package/src/utils/get-repo-data.mjs +54 -64
  173. package/src/utils/get-site.mjs +14 -14
  174. package/src/utils/gh-auth.mjs +79 -100
  175. package/src/utils/gitignore.mjs +37 -40
  176. package/src/utils/headers.mjs +33 -35
  177. package/src/utils/hooks/requires-site-info.mjs +26 -22
  178. package/src/utils/init/config-github.mjs +207 -219
  179. package/src/utils/init/config-manual.mjs +83 -100
  180. package/src/utils/init/config.mjs +25 -26
  181. package/src/utils/init/node-version.mjs +23 -30
  182. package/src/utils/init/plugins.mjs +12 -8
  183. package/src/utils/init/utils.mjs +152 -172
  184. package/src/utils/live-tunnel.mjs +118 -141
  185. package/src/utils/lm/install.mjs +220 -259
  186. package/src/utils/lm/requirements.mjs +54 -63
  187. package/src/utils/lm/steps.mjs +31 -31
  188. package/src/utils/lm/ui.mjs +13 -20
  189. package/src/utils/open-browser.mjs +31 -32
  190. package/src/utils/parse-raw-flags.mjs +39 -35
  191. package/src/utils/proxy-server.mjs +84 -71
  192. package/src/utils/proxy.mjs +696 -750
  193. package/src/utils/read-repo-url.mjs +48 -47
  194. package/src/utils/redirects.mjs +49 -49
  195. package/src/utils/request-id.mjs +2 -4
  196. package/src/utils/rules-proxy.mjs +96 -100
  197. package/src/utils/run-build.mjs +109 -132
  198. package/src/utils/shell.mjs +99 -106
  199. package/src/utils/sign-redirect.mjs +14 -14
  200. package/src/utils/sites/utils.mjs +48 -55
  201. package/src/utils/state-config.mjs +101 -101
  202. package/src/utils/static-server.mjs +28 -34
  203. package/src/utils/telemetry/index.mjs +2 -2
  204. package/src/utils/telemetry/report-error.mjs +45 -49
  205. package/src/utils/telemetry/request.mjs +36 -43
  206. package/src/utils/telemetry/telemetry.mjs +90 -105
  207. package/src/utils/telemetry/utils.mjs +5 -6
  208. package/src/utils/telemetry/validation.mjs +55 -53
  209. package/src/utils/types.d.ts +46 -0
  210. package/src/utils/validation.mjs +10 -13
@@ -1,227 +1,192 @@
1
- // @ts-check
2
- import process from 'process'
3
-
4
- import { Option } from 'commander'
5
- import envinfo from 'envinfo'
6
- import { closest } from 'fastest-levenshtein'
7
- import inquirer from 'inquirer'
8
-
9
- import { BANG, chalk, error, exit, log, NETLIFY_CYAN, USER_AGENT, warn } from '../utils/command-helpers.mjs'
10
- import execa from '../utils/execa.mjs'
11
- import getGlobalConfig from '../utils/get-global-config.mjs'
12
- import getPackageJson from '../utils/get-package-json.mjs'
13
- import { track, reportError } from '../utils/telemetry/index.mjs'
14
-
15
- import { createAddonsCommand } from './addons/index.mjs'
16
- import { createApiCommand } from './api/index.mjs'
17
- import BaseCommand from './base-command.mjs'
18
- import { createBuildCommand } from './build/index.mjs'
19
- import { createCompletionCommand } from './completion/index.mjs'
20
- import { createDeployCommand } from './deploy/index.mjs'
21
- import { createDevCommand } from './dev/index.mjs'
22
- import { createEnvCommand } from './env/index.mjs'
23
- import { createFunctionsCommand } from './functions/index.mjs'
24
- import { createInitCommand } from './init/index.mjs'
25
- import { createIntegrationCommand } from './integration/index.mjs'
26
- import { createLinkCommand } from './link/index.mjs'
27
- import { createLmCommand } from './lm/index.mjs'
28
- import { createLoginCommand } from './login/index.mjs'
29
- import { createLogoutCommand } from './logout/index.mjs'
30
- import { createOpenCommand } from './open/index.mjs'
31
- import { createRecipesCommand } from './recipes/index.mjs'
32
- import { createServeCommand } from './serve/serve.mjs'
33
- import { createSitesCommand } from './sites/index.mjs'
34
- import { createStatusCommand } from './status/index.mjs'
35
- import { createSwitchCommand } from './switch/index.mjs'
36
- import { createUnlinkCommand } from './unlink/index.mjs'
37
- import { createWatchCommand } from './watch/index.mjs'
38
-
39
- const SUGGESTION_TIMEOUT = 1e4
40
-
1
+ import process from 'process';
2
+ import { Option } from 'commander';
3
+ // @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'envi... Remove this comment to see the full error message
4
+ import envinfo from 'envinfo';
5
+ import { closest } from 'fastest-levenshtein';
6
+ import inquirer from 'inquirer';
7
+ import { BANG, chalk, error, exit, log, NETLIFY_CYAN, USER_AGENT, warn } from '../utils/command-helpers.mjs';
8
+ // @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message
9
+ import execa from '../utils/execa.mjs';
10
+ import getGlobalConfig from '../utils/get-global-config.mjs';
11
+ import getPackageJson from '../utils/get-package-json.mjs';
12
+ import { track, reportError } from '../utils/telemetry/index.mjs';
13
+ import { createAddonsCommand } from './addons/index.mjs';
14
+ import { createApiCommand } from './api/index.mjs';
15
+ import BaseCommand from './base-command.mjs';
16
+ import { createBlobsCommand } from './blobs/blobs.mjs';
17
+ import { createBuildCommand } from './build/index.mjs';
18
+ import { createCompletionCommand } from './completion/index.mjs';
19
+ import { createDeployCommand } from './deploy/index.mjs';
20
+ import { createDevCommand } from './dev/index.mjs';
21
+ import { createEnvCommand } from './env/index.mjs';
22
+ import { createFunctionsCommand } from './functions/index.mjs';
23
+ import { createInitCommand } from './init/index.mjs';
24
+ import { createIntegrationCommand } from './integration/index.mjs';
25
+ import { createLinkCommand } from './link/index.mjs';
26
+ import { createLmCommand } from './lm/index.mjs';
27
+ import { createLoginCommand } from './login/index.mjs';
28
+ import { createLogoutCommand } from './logout/index.mjs';
29
+ import { createOpenCommand } from './open/index.mjs';
30
+ import { createRecipesCommand } from './recipes/index.mjs';
31
+ import { createServeCommand } from './serve/serve.mjs';
32
+ import { createSitesCommand } from './sites/index.mjs';
33
+ import { createStatusCommand } from './status/index.mjs';
34
+ import { createSwitchCommand } from './switch/index.mjs';
35
+ import { createUnlinkCommand } from './unlink/index.mjs';
36
+ import { createWatchCommand } from './watch/index.mjs';
37
+ const SUGGESTION_TIMEOUT = 1e4;
41
38
  process.on('uncaughtException', async (err) => {
42
- console.log('')
43
- error(
44
- `${chalk.red(
45
- 'Netlify CLI has terminated unexpectedly',
46
- )}\nThis is a problem with the Netlify CLI, not with your application.\nIf you recently updated the CLI, consider reverting to an older version by running:\n\n${chalk.bold(
47
- 'npm install -g netlify-cli@VERSION',
48
- )}\n\nYou can use any version from ${chalk.underline(
49
- 'https://ntl.fyi/cli-versions',
50
- )}.\n\nPlease report this problem at ${chalk.underline(
51
- 'https://ntl.fyi/cli-error',
52
- )} including the error details below.\n`,
53
- { exit: false },
54
- )
55
-
56
- const systemInfo = await getSystemInfo()
57
-
58
- console.log(chalk.dim(err.stack || err))
59
- console.log(chalk.dim(systemInfo))
60
-
61
- reportError(err, { severity: 'error' })
62
-
63
- process.exit(1)
64
- })
65
-
66
- const getSystemInfo = () =>
67
- envinfo.run({
39
+ console.log('');
40
+ error(`${chalk.red('Netlify CLI has terminated unexpectedly')}\nThis is a problem with the Netlify CLI, not with your application.\nIf you recently updated the CLI, consider reverting to an older version by running:\n\n${chalk.bold('npm install -g netlify-cli@VERSION')}\n\nYou can use any version from ${chalk.underline('https://ntl.fyi/cli-versions')}.\n\nPlease report this problem at ${chalk.underline('https://ntl.fyi/cli-error')} including the error details below.\n`, { exit: false });
41
+ const systemInfo = await getSystemInfo();
42
+ console.log(chalk.dim(err.stack || err));
43
+ console.log(chalk.dim(systemInfo));
44
+ reportError(err, { severity: 'error' });
45
+ process.exit(1);
46
+ });
47
+ const getSystemInfo = () => envinfo.run({
68
48
  System: ['OS', 'CPU'],
69
49
  Binaries: ['Node', 'Yarn', 'npm'],
70
50
  Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'],
71
51
  npmGlobalPackages: ['netlify-cli'],
72
- })
73
-
52
+ });
74
53
  const getVersionPage = async () => {
75
- const data = await getSystemInfo()
76
-
77
- return `
54
+ const data = await getSystemInfo();
55
+ return `
78
56
  ────────────────────┐
79
57
  Environment Info │
80
58
  ────────────────────┘
81
59
  ${data}
82
60
  ${USER_AGENT}
83
- `
84
- }
85
-
61
+ `;
62
+ };
86
63
  /**
87
64
  * The main CLI command without any command (root action)
88
65
  * @param {import('commander').OptionValues} options
89
66
  * @param {import('./base-command.mjs').default} command
90
67
  */
68
+ // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
91
69
  const mainCommand = async function (options, command) {
92
- const globalConfig = await getGlobalConfig()
93
-
94
- if (options.telemetryDisable) {
95
- globalConfig.set('telemetryDisabled', true)
96
- console.log('Netlify telemetry has been disabled')
97
- console.log('You can renable it anytime with the --telemetry-enable flag')
98
- exit()
99
- }
100
- if (options.telemetryEnable) {
101
- globalConfig.set('telemetryDisabled', false)
102
- console.log('Netlify telemetry has been enabled')
103
- console.log('You can disable it anytime with the --telemetry-disable flag')
104
- await track('user_telemetryEnabled')
105
- exit()
106
- }
107
-
108
- if (command.args[0] === 'version' || options.version) {
109
- if (options.verbose) {
110
- const versionPage = await getVersionPage()
111
- log(versionPage)
70
+ const globalConfig = await getGlobalConfig();
71
+ if (options.telemetryDisable) {
72
+ globalConfig.set('telemetryDisabled', true);
73
+ console.log('Netlify telemetry has been disabled');
74
+ console.log('You can renable it anytime with the --telemetry-enable flag');
75
+ exit();
112
76
  }
113
- log(USER_AGENT)
114
- exit()
115
- }
116
-
117
- // if no command show the header and the help
118
- if (command.args.length === 0) {
119
- const pkg = await getPackageJson()
120
-
121
- const title = `${chalk.bgBlack.cyan('⬥ Netlify CLI')}`
122
- const docsMsg = `${chalk.greenBright('Read the docs:')} https://docs.netlify.com/cli/get-started/`
123
- const supportMsg = `${chalk.magentaBright('Support and bugs:')} ${pkg.bugs.url}`
124
-
125
- console.log()
126
- console.log(title)
127
- console.log(docsMsg)
128
- console.log(supportMsg)
129
- console.log()
130
-
131
- command.help()
132
- }
133
-
134
- if (command.args[0] === 'help') {
135
- if (command.args[1]) {
136
- const subCommand = command.commands.find((cmd) => cmd.name() === command.args[1])
137
- if (!subCommand) {
138
- error(`command ${command.args[1]} not found`)
139
- }
140
- subCommand.help()
77
+ if (options.telemetryEnable) {
78
+ globalConfig.set('telemetryDisabled', false);
79
+ console.log('Netlify telemetry has been enabled');
80
+ console.log('You can disable it anytime with the --telemetry-disable flag');
81
+ await track('user_telemetryEnabled');
82
+ exit();
141
83
  }
142
- command.help()
143
- }
144
-
145
- warn(`${chalk.yellow(command.args[0])} is not a ${command.name()} command.`)
146
-
147
- const allCommands = command.commands.map((cmd) => cmd.name())
148
- const suggestion = closest(command.args[0], allCommands)
149
-
150
- const applySuggestion = await new Promise((resolve) => {
151
- const prompt = inquirer.prompt({
152
- type: 'confirm',
153
- name: 'suggestion',
154
- message: `Did you mean ${chalk.blue(suggestion)}`,
155
- default: false,
156
- })
157
-
158
- setTimeout(() => {
159
- // @ts-ignore
160
- prompt.ui.close()
161
- resolve(false)
162
- }, SUGGESTION_TIMEOUT)
163
-
164
- // eslint-disable-next-line promise/catch-or-return
165
- prompt.then((value) => resolve(value.suggestion))
166
- })
167
- // create new log line
168
- log()
169
-
170
- if (!applySuggestion) {
171
- error(`Run ${NETLIFY_CYAN(`${command.name()} help`)} for a list of available commands.`)
172
- }
173
-
174
- await execa(process.argv[0], [process.argv[1], suggestion], { stdio: 'inherit' })
175
- }
176
-
84
+ if (command.args[0] === 'version' || options.version) {
85
+ if (options.verbose) {
86
+ const versionPage = await getVersionPage();
87
+ log(versionPage);
88
+ }
89
+ log(USER_AGENT);
90
+ exit();
91
+ }
92
+ // if no command show the header and the help
93
+ if (command.args.length === 0) {
94
+ const pkg = await getPackageJson();
95
+ const title = `${chalk.bgBlack.cyan('⬥ Netlify CLI')}`;
96
+ const docsMsg = `${chalk.greenBright('Read the docs:')} https://ntl.fyi/get-started-with-netlify-cli`;
97
+ const supportMsg = `${chalk.magentaBright('Support and bugs:')} ${pkg.bugs.url}`;
98
+ console.log();
99
+ console.log(title);
100
+ console.log(docsMsg);
101
+ console.log(supportMsg);
102
+ console.log();
103
+ command.help();
104
+ }
105
+ if (command.args[0] === 'help') {
106
+ if (command.args[1]) {
107
+ // @ts-expect-error TS(7006) FIXME: Parameter 'cmd' implicitly has an 'any' type.
108
+ const subCommand = command.commands.find((cmd) => cmd.name() === command.args[1]);
109
+ if (!subCommand) {
110
+ error(`command ${command.args[1]} not found`);
111
+ }
112
+ subCommand.help();
113
+ }
114
+ command.help();
115
+ }
116
+ warn(`${chalk.yellow(command.args[0])} is not a ${command.name()} command.`);
117
+ // @ts-expect-error TS(7006) FIXME: Parameter 'cmd' implicitly has an 'any' type.
118
+ const allCommands = command.commands.map((cmd) => cmd.name());
119
+ const suggestion = closest(command.args[0], allCommands);
120
+ const applySuggestion = await new Promise((resolve) => {
121
+ const prompt = inquirer.prompt({
122
+ type: 'confirm',
123
+ name: 'suggestion',
124
+ message: `Did you mean ${chalk.blue(suggestion)}`,
125
+ default: false,
126
+ });
127
+ setTimeout(() => {
128
+ // @ts-expect-error TS(2445) FIXME: Property 'close' is protected and only accessible ... Remove this comment to see the full error message
129
+ prompt.ui.close();
130
+ resolve(false);
131
+ }, SUGGESTION_TIMEOUT);
132
+ // eslint-disable-next-line promise/catch-or-return
133
+ prompt.then((value) => resolve(value.suggestion));
134
+ });
135
+ // create new log line
136
+ log();
137
+ if (!applySuggestion) {
138
+ error(`Run ${NETLIFY_CYAN(`${command.name()} help`)} for a list of available commands.`);
139
+ }
140
+ // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type.
141
+ await execa(process.argv[0], [process.argv[1], suggestion], { stdio: 'inherit' });
142
+ };
177
143
  /**
178
144
  * Creates the `netlify-cli` command
179
145
  * Promise is needed as the envinfo is a promise
180
146
  * @returns {import('./base-command.mjs').default}
181
147
  */
182
148
  export const createMainCommand = () => {
183
- const program = new BaseCommand('netlify')
184
- // register all the commands
185
- createAddonsCommand(program)
186
- createApiCommand(program)
187
- createBuildCommand(program)
188
- createCompletionCommand(program)
189
- createDeployCommand(program)
190
- createDevCommand(program)
191
- createEnvCommand(program)
192
- createFunctionsCommand(program)
193
- createRecipesCommand(program)
194
- createInitCommand(program)
195
- createIntegrationCommand(program)
196
- createLinkCommand(program)
197
- createLmCommand(program)
198
- createLoginCommand(program)
199
- createLogoutCommand(program)
200
- createOpenCommand(program)
201
- createServeCommand(program)
202
- createSitesCommand(program)
203
- createStatusCommand(program)
204
- createSwitchCommand(program)
205
- createUnlinkCommand(program)
206
- createWatchCommand(program)
207
-
208
- program
209
- .version(USER_AGENT, '-V')
210
- .showSuggestionAfterError(true)
211
- .option('--telemetry-disable', 'Disable telemetry')
212
- .option('--telemetry-enable', 'Enables telemetry')
213
- // needed for custom version output as we display further environment information
214
- // commanders version output is set to uppercase -V
215
- .addOption(new Option('-v, --version').hideHelp())
216
- .addOption(new Option('--verbose').hideHelp())
217
- .noHelpOptions()
218
- .configureOutput({
219
- outputError: (message, write) => {
220
- write(` ${chalk.red(BANG)} Error: ${message.replace(/^error:\s/g, '')}`)
221
- write(` ${chalk.red(BANG)} See more help with --help\n`)
222
- },
149
+ const program = new BaseCommand('netlify');
150
+ // register all the commands
151
+ createAddonsCommand(program);
152
+ createApiCommand(program);
153
+ createBlobsCommand(program);
154
+ createBuildCommand(program);
155
+ createCompletionCommand(program);
156
+ createDeployCommand(program);
157
+ createDevCommand(program);
158
+ createEnvCommand(program);
159
+ createFunctionsCommand(program);
160
+ createRecipesCommand(program);
161
+ createInitCommand(program);
162
+ createIntegrationCommand(program);
163
+ createLinkCommand(program);
164
+ createLmCommand(program);
165
+ createLoginCommand(program);
166
+ createLogoutCommand(program);
167
+ createOpenCommand(program);
168
+ createServeCommand(program);
169
+ createSitesCommand(program);
170
+ createStatusCommand(program);
171
+ createSwitchCommand(program);
172
+ createUnlinkCommand(program);
173
+ createWatchCommand(program);
174
+ program
175
+ .version(USER_AGENT, '-V')
176
+ .showSuggestionAfterError(true)
177
+ .option('--telemetry-disable', 'Disable telemetry')
178
+ .option('--telemetry-enable', 'Enables telemetry')
179
+ // needed for custom version output as we display further environment information
180
+ // commanders version output is set to uppercase -V
181
+ .addOption(new Option('-v, --version').hideHelp())
182
+ .addOption(new Option('--verbose').hideHelp())
183
+ .noHelpOptions()
184
+ .configureOutput({
185
+ outputError: (message, write) => {
186
+ write(` ${chalk.red(BANG)} Error: ${message.replace(/^error:\s/g, '')}`);
187
+ write(` ${chalk.red(BANG)} See more help with --help\n`);
188
+ },
223
189
  })
224
- .action(mainCommand)
225
-
226
- return program
227
- }
190
+ .action(mainCommand);
191
+ return program;
192
+ };
@@ -1 +1 @@
1
- export { createOpenCommand } from './open.mjs'
1
+ export { createOpenCommand } from './open.mjs';
@@ -1,33 +1,30 @@
1
- import { exit, log } from '../../utils/command-helpers.mjs'
2
- import requiresSiteInfo from '../../utils/hooks/requires-site-info.mjs'
3
- import openBrowser from '../../utils/open-browser.mjs'
4
-
1
+ import { exit, log } from '../../utils/command-helpers.mjs';
2
+ import requiresSiteInfo from '../../utils/hooks/requires-site-info.mjs';
3
+ import openBrowser from '../../utils/open-browser.mjs';
5
4
  /**
6
5
  * The open:admin command
7
6
  * @param {import('commander').OptionValues} options
8
7
  * @param {import('../base-command.mjs').default} command
9
8
  */
9
+ // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
10
10
  export const openAdmin = async (options, command) => {
11
- const { siteInfo } = command.netlify
12
-
13
- await command.authenticate()
14
-
15
- log(`Opening "${siteInfo.name}" site admin UI:`)
16
- log(`> ${siteInfo.admin_url}`)
17
-
18
- await openBrowser({ url: siteInfo.admin_url })
19
- exit()
20
- }
21
-
11
+ const { siteInfo } = command.netlify;
12
+ await command.authenticate();
13
+ log(`Opening "${siteInfo.name}" site admin UI:`);
14
+ log(`> ${siteInfo.admin_url}`);
15
+ // @ts-expect-error TS(2345) FIXME: Argument of type '{ url: any; }' is not assignable... Remove this comment to see the full error message
16
+ await openBrowser({ url: siteInfo.admin_url });
17
+ exit();
18
+ };
22
19
  /**
23
20
  * Creates the `netlify open:admin` command
24
21
  * @param {import('../base-command.mjs').default} program
25
22
  * @returns
26
23
  */
27
- export const createOpenAdminCommand = (program) =>
28
- program
24
+ // @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
25
+ export const createOpenAdminCommand = (program) => program
29
26
  .command('open:admin')
30
27
  .description('Opens current site admin UI in Netlify')
31
28
  .addExamples(['netlify open:admin'])
32
29
  .hook('preAction', requiresSiteInfo)
33
- .action(openAdmin)
30
+ .action(openAdmin);
@@ -1,34 +1,31 @@
1
- import { exit, log } from '../../utils/command-helpers.mjs'
2
- import requiresSiteInfo from '../../utils/hooks/requires-site-info.mjs'
3
- import openBrowser from '../../utils/open-browser.mjs'
4
-
1
+ import { exit, log } from '../../utils/command-helpers.mjs';
2
+ import requiresSiteInfo from '../../utils/hooks/requires-site-info.mjs';
3
+ import openBrowser from '../../utils/open-browser.mjs';
5
4
  /**
6
5
  * The open:site command
7
6
  * @param {import('commander').OptionValues} options
8
7
  * @param {import('../base-command.mjs').default} command
9
8
  */
9
+ // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
10
10
  export const openSite = async (options, command) => {
11
- const { siteInfo } = command.netlify
12
-
13
- await command.authenticate()
14
-
15
- const url = siteInfo.ssl_url || siteInfo.url
16
- log(`Opening "${siteInfo.name}" site url:`)
17
- log(`> ${url}`)
18
-
19
- await openBrowser({ url })
20
- exit()
21
- }
22
-
11
+ const { siteInfo } = command.netlify;
12
+ await command.authenticate();
13
+ const url = siteInfo.ssl_url || siteInfo.url;
14
+ log(`Opening "${siteInfo.name}" site url:`);
15
+ log(`> ${url}`);
16
+ // @ts-expect-error TS(2345) FIXME: Argument of type '{ url: any; }' is not assignable... Remove this comment to see the full error message
17
+ await openBrowser({ url });
18
+ exit();
19
+ };
23
20
  /**
24
21
  * Creates the `netlify open:site` command
25
22
  * @param {import('../base-command.mjs').default} program
26
23
  * @returns
27
24
  */
28
- export const createOpenSiteCommand = (program) =>
29
- program
25
+ // @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
26
+ export const createOpenSiteCommand = (program) => program
30
27
  .command('open:site')
31
28
  .description('Opens current site url in browser')
32
29
  .addExamples(['netlify open:site'])
33
30
  .hook('preAction', requiresSiteInfo)
34
- .action(openSite)
31
+ .action(openSite);
@@ -1,39 +1,36 @@
1
- import { log } from '../../utils/command-helpers.mjs'
2
-
3
- import { createOpenAdminCommand, openAdmin } from './open-admin.mjs'
4
- import { createOpenSiteCommand, openSite } from './open-site.mjs'
5
-
1
+ import { log } from '../../utils/command-helpers.mjs';
2
+ import { createOpenAdminCommand, openAdmin } from './open-admin.mjs';
3
+ import { createOpenSiteCommand, openSite } from './open-site.mjs';
6
4
  /**
7
5
  * The open command
8
6
  * @param {import('commander').OptionValues} options
9
7
  * @param {import('../base-command.mjs').default} command
10
8
  */
9
+ // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
11
10
  const open = async (options, command) => {
12
- if (!options.site || !options.admin) {
13
- log(command.helpInformation())
14
- }
15
-
16
- if (options.site) {
17
- await openSite(options, command)
18
- }
19
- // Default open netlify admin
20
- await openAdmin(options, command)
21
- }
22
-
11
+ if (!options.site || !options.admin) {
12
+ log(command.helpInformation());
13
+ }
14
+ if (options.site) {
15
+ await openSite(options, command);
16
+ }
17
+ // Default open netlify admin
18
+ await openAdmin(options, command);
19
+ };
23
20
  /**
24
21
  * Creates the `netlify open` command
25
22
  * @param {import('../base-command.mjs').default} program
26
23
  * @returns
27
24
  */
25
+ // @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
28
26
  export const createOpenCommand = (program) => {
29
- createOpenAdminCommand(program)
30
- createOpenSiteCommand(program)
31
-
32
- return program
33
- .command('open')
34
- .description(`Open settings for the site linked to the current folder`)
35
- .option('--site', 'Open site')
36
- .option('--admin', 'Open Netlify site')
37
- .addExamples(['netlify open --site', 'netlify open --admin', 'netlify open:admin', 'netlify open:site'])
38
- .action(open)
39
- }
27
+ createOpenAdminCommand(program);
28
+ createOpenSiteCommand(program);
29
+ return program
30
+ .command('open')
31
+ .description(`Open settings for the site linked to the current folder`)
32
+ .option('--site', 'Open site')
33
+ .option('--admin', 'Open Netlify site')
34
+ .addExamples(['netlify open --site', 'netlify open --admin', 'netlify open:admin', 'netlify open:site'])
35
+ .action(open);
36
+ };
@@ -1,36 +1,25 @@
1
- import fs from 'fs/promises'
2
- import { dirname, join, resolve } from 'path'
3
- import { fileURLToPath, pathToFileURL } from 'url'
4
-
5
- const directoryPath = dirname(fileURLToPath(import.meta.url))
6
-
1
+ import fs from 'fs/promises';
2
+ import { dirname, join, resolve } from 'path';
3
+ import { fileURLToPath, pathToFileURL } from 'url';
4
+ const directoryPath = dirname(fileURLToPath(import.meta.url));
5
+ // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type.
7
6
  export const getRecipe = async (name) => {
8
- const recipePath = resolve(directoryPath, '../../recipes', name, 'index.mjs')
9
-
10
- // windows needs a URL for absolute paths
11
-
12
- const recipe = await import(pathToFileURL(recipePath).href)
13
-
14
- return recipe
15
- }
16
-
7
+ const recipePath = resolve(directoryPath, '../../recipes', name, 'index.mjs');
8
+ // windows needs a URL for absolute paths
9
+ const recipe = await import(pathToFileURL(recipePath).href);
10
+ return recipe;
11
+ };
17
12
  export const listRecipes = async () => {
18
- const recipesPath = resolve(directoryPath, '../../recipes')
19
- const recipeNames = await fs.readdir(recipesPath)
20
- const recipes = await Promise.all(
21
- recipeNames.map(async (name) => {
22
- const recipePath = join(recipesPath, name, 'index.mjs')
23
-
24
- // windows needs a URL for absolute paths
25
-
26
- const recipe = await import(pathToFileURL(recipePath).href)
27
-
28
- return {
29
- ...recipe,
30
- name,
31
- }
32
- }),
33
- )
34
-
35
- return recipes
36
- }
13
+ const recipesPath = resolve(directoryPath, '../../recipes');
14
+ const recipeNames = await fs.readdir(recipesPath);
15
+ const recipes = await Promise.all(recipeNames.map(async (name) => {
16
+ const recipePath = join(recipesPath, name, 'index.mjs');
17
+ // windows needs a URL for absolute paths
18
+ const recipe = await import(pathToFileURL(recipePath).href);
19
+ return {
20
+ ...recipe,
21
+ name,
22
+ };
23
+ }));
24
+ return recipes;
25
+ };
@@ -1 +1 @@
1
- export { createRecipesCommand, runRecipe } from './recipes.mjs'
1
+ export { createRecipesCommand, runRecipe } from './recipes.mjs';