netlify-cli 17.3.1 → 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.
- package/README.md +3 -139
- package/npm-shrinkwrap.json +82 -82
- package/package.json +16 -15
- package/src/commands/addons/addons-auth.mjs +27 -30
- package/src/commands/addons/addons-config.mjs +145 -154
- package/src/commands/addons/addons-create.mjs +94 -108
- package/src/commands/addons/addons-delete.mjs +36 -41
- package/src/commands/addons/addons-list.mjs +38 -42
- package/src/commands/addons/addons.mjs +26 -28
- package/src/commands/addons/index.mjs +1 -1
- package/src/commands/api/api.mjs +45 -53
- package/src/commands/api/index.mjs +1 -1
- package/src/commands/base-command.mjs +597 -684
- package/src/commands/blobs/blobs-delete.mjs +35 -0
- package/src/commands/blobs/blobs-get.mjs +44 -0
- package/src/commands/blobs/blobs-list.mjs +48 -0
- package/src/commands/blobs/blobs-set.mjs +54 -0
- package/src/commands/blobs/blobs.mjs +32 -0
- package/src/commands/blobs/index.mjs +1 -0
- package/src/commands/build/build.mjs +55 -67
- package/src/commands/build/index.mjs +1 -1
- package/src/commands/completion/completion.mjs +41 -46
- package/src/commands/completion/index.mjs +1 -1
- package/src/commands/deploy/deploy.mjs +675 -710
- package/src/commands/deploy/index.mjs +1 -1
- package/src/commands/dev/dev-exec.mjs +20 -32
- package/src/commands/dev/dev.mjs +217 -302
- package/src/commands/dev/index.mjs +1 -1
- package/src/commands/dev/types.d.ts +30 -0
- package/src/commands/env/env-clone.mjs +157 -184
- package/src/commands/env/env-get.mjs +49 -68
- package/src/commands/env/env-import.mjs +100 -119
- package/src/commands/env/env-list.mjs +104 -129
- package/src/commands/env/env-set.mjs +160 -185
- package/src/commands/env/env-unset.mjs +104 -122
- package/src/commands/env/env.mjs +28 -30
- package/src/commands/env/index.mjs +1 -1
- package/src/commands/functions/functions-build.mjs +29 -41
- package/src/commands/functions/functions-create.mjs +533 -601
- package/src/commands/functions/functions-invoke.mjs +193 -216
- package/src/commands/functions/functions-list.mjs +45 -55
- package/src/commands/functions/functions-serve.mjs +51 -61
- package/src/commands/functions/functions.mjs +26 -32
- package/src/commands/functions/index.mjs +1 -1
- package/src/commands/index.mjs +2 -2
- package/src/commands/init/index.mjs +1 -1
- package/src/commands/init/init.mjs +138 -167
- package/src/commands/integration/deploy.mjs +337 -399
- package/src/commands/integration/index.mjs +12 -13
- package/src/commands/link/index.mjs +1 -1
- package/src/commands/link/link.mjs +298 -317
- package/src/commands/lm/index.mjs +1 -1
- package/src/commands/lm/lm-info.mjs +23 -31
- package/src/commands/lm/lm-install.mjs +13 -17
- package/src/commands/lm/lm-setup.mjs +80 -84
- package/src/commands/lm/lm-uninstall.mjs +7 -12
- package/src/commands/lm/lm.mjs +18 -22
- package/src/commands/login/index.mjs +1 -1
- package/src/commands/login/login.mjs +35 -41
- package/src/commands/logout/index.mjs +1 -1
- package/src/commands/logout/logout.mjs +25 -31
- package/src/commands/main.mjs +166 -201
- package/src/commands/open/index.mjs +1 -1
- package/src/commands/open/open-admin.mjs +15 -18
- package/src/commands/open/open-site.mjs +16 -19
- package/src/commands/open/open.mjs +24 -27
- package/src/commands/recipes/common.mjs +23 -34
- package/src/commands/recipes/index.mjs +1 -1
- package/src/commands/recipes/recipes-list.mjs +13 -20
- package/src/commands/recipes/recipes.mjs +59 -72
- package/src/commands/serve/index.mjs +1 -1
- package/src/commands/serve/serve.mjs +142 -189
- package/src/commands/sites/index.mjs +2 -2
- package/src/commands/sites/sites-create-template.mjs +214 -236
- package/src/commands/sites/sites-create.mjs +145 -157
- package/src/commands/sites/sites-delete.mjs +75 -81
- package/src/commands/sites/sites-list.mjs +63 -66
- package/src/commands/sites/sites.mjs +18 -20
- package/src/commands/status/index.mjs +1 -1
- package/src/commands/status/status-hooks.mjs +32 -34
- package/src/commands/status/status.mjs +99 -106
- package/src/commands/switch/index.mjs +1 -1
- package/src/commands/switch/switch.mjs +32 -37
- package/src/commands/types.d.ts +31 -0
- package/src/commands/unlink/index.mjs +1 -1
- package/src/commands/unlink/unlink.mjs +23 -29
- package/src/commands/watch/index.mjs +1 -1
- package/src/commands/watch/watch.mjs +91 -105
- package/src/functions-templates/javascript/hello/{{name}}.js +2 -3
- package/src/lib/account.mjs +4 -5
- package/src/lib/api.mjs +22 -20
- package/src/lib/blobs/blobs.mjs +36 -45
- package/src/lib/build.mjs +82 -85
- package/src/lib/completion/constants.mjs +2 -4
- package/src/lib/completion/generate-autocompletion.mjs +33 -36
- package/src/lib/completion/get-autocompletion.mjs +31 -35
- package/src/lib/completion/index.mjs +1 -1
- package/src/lib/completion/script.mjs +12 -19
- package/src/lib/edge-functions/bootstrap.mjs +3 -5
- package/src/lib/edge-functions/consts.mjs +9 -10
- package/src/lib/edge-functions/deploy.mjs +28 -34
- package/src/lib/edge-functions/editor-helper.mjs +29 -42
- package/src/lib/edge-functions/headers.mjs +24 -26
- package/src/lib/edge-functions/internal.mjs +38 -44
- package/src/lib/edge-functions/proxy.mjs +229 -228
- package/src/lib/edge-functions/registry.mjs +473 -574
- package/src/lib/exec-fetcher.mjs +115 -122
- package/src/lib/fs.mjs +28 -27
- package/src/lib/functions/background.mjs +16 -20
- package/src/lib/functions/config.mjs +12 -9
- package/src/lib/functions/form-submissions-handler.mjs +143 -149
- package/src/lib/functions/local-proxy.mjs +40 -44
- package/src/lib/functions/memoized-build.mjs +19 -21
- package/src/lib/functions/netlify-function.mjs +269 -249
- package/src/lib/functions/registry.mjs +509 -568
- package/src/lib/functions/runtimes/go/index.mjs +62 -71
- package/src/lib/functions/runtimes/index.mjs +8 -15
- package/src/lib/functions/runtimes/js/builders/netlify-lambda.mjs +55 -64
- package/src/lib/functions/runtimes/js/builders/zisi.mjs +135 -154
- package/src/lib/functions/runtimes/js/constants.mjs +1 -1
- package/src/lib/functions/runtimes/js/index.mjs +92 -109
- package/src/lib/functions/runtimes/js/worker.mjs +43 -45
- package/src/lib/functions/runtimes/rust/index.mjs +64 -73
- package/src/lib/functions/scheduled.mjs +70 -88
- package/src/lib/functions/server.mjs +269 -327
- package/src/lib/functions/synchronous.mjs +118 -147
- package/src/lib/functions/utils.mjs +38 -46
- package/src/lib/geo-location.mjs +69 -81
- package/src/lib/http-agent.mjs +87 -90
- package/src/lib/images/proxy.mjs +97 -89
- package/src/lib/log.mjs +6 -9
- package/src/lib/path.mjs +2 -1
- package/src/lib/render-error-template.mjs +19 -20
- package/src/lib/settings.mjs +17 -19
- package/src/lib/spinner.mjs +21 -23
- package/src/lib/string.mjs +4 -2
- package/src/recipes/vscode/index.mjs +69 -85
- package/src/recipes/vscode/settings.mjs +53 -58
- package/src/utils/addons/compare.mjs +31 -32
- package/src/utils/addons/diffs/index.mjs +16 -17
- package/src/utils/addons/diffs/options.mjs +99 -101
- package/src/utils/addons/prepare.mjs +100 -97
- package/src/utils/addons/prompts.mjs +73 -76
- package/src/utils/addons/render.mjs +33 -36
- package/src/utils/addons/validation.mjs +19 -15
- package/src/utils/banner.mjs +11 -16
- package/src/utils/build-info.mjs +65 -66
- package/src/utils/command-helpers.mjs +185 -199
- package/src/utils/create-deferred.mjs +9 -12
- package/src/utils/create-stream-promise.mjs +54 -47
- package/src/utils/deploy/constants.mjs +9 -11
- package/src/utils/deploy/deploy-site.mjs +162 -182
- package/src/utils/deploy/hash-config.mjs +21 -21
- package/src/utils/deploy/hash-files.mjs +34 -38
- package/src/utils/deploy/hash-fns.mjs +149 -154
- package/src/utils/deploy/hasher-segments.mjs +58 -52
- package/src/utils/deploy/upload-files.mjs +99 -113
- package/src/utils/deploy/util.mjs +85 -91
- package/src/utils/detect-server-settings.mjs +236 -268
- package/src/utils/dev.mjs +163 -178
- package/src/utils/dot-env.mjs +37 -42
- package/src/utils/env/index.mjs +148 -148
- package/src/utils/execa.mjs +9 -13
- package/src/utils/feature-flags.mjs +6 -5
- package/src/utils/framework-server.mjs +43 -52
- package/src/utils/functions/constants.mjs +1 -1
- package/src/utils/functions/functions.mjs +30 -40
- package/src/utils/functions/get-functions.mjs +28 -29
- package/src/utils/functions/index.mjs +3 -3
- package/src/utils/get-global-config.mjs +33 -36
- package/src/utils/get-package-json.mjs +14 -15
- package/src/utils/get-repo-data.mjs +54 -64
- package/src/utils/get-site.mjs +14 -14
- package/src/utils/gh-auth.mjs +79 -100
- package/src/utils/gitignore.mjs +37 -40
- package/src/utils/headers.mjs +33 -35
- package/src/utils/hooks/requires-site-info.mjs +26 -22
- package/src/utils/init/config-github.mjs +207 -219
- package/src/utils/init/config-manual.mjs +83 -100
- package/src/utils/init/config.mjs +25 -26
- package/src/utils/init/node-version.mjs +23 -30
- package/src/utils/init/plugins.mjs +12 -8
- package/src/utils/init/utils.mjs +152 -172
- package/src/utils/live-tunnel.mjs +118 -141
- package/src/utils/lm/install.mjs +220 -259
- package/src/utils/lm/requirements.mjs +54 -63
- package/src/utils/lm/steps.mjs +31 -31
- package/src/utils/lm/ui.mjs +13 -20
- package/src/utils/open-browser.mjs +31 -32
- package/src/utils/parse-raw-flags.mjs +39 -35
- package/src/utils/proxy-server.mjs +84 -71
- package/src/utils/proxy.mjs +696 -750
- package/src/utils/read-repo-url.mjs +48 -47
- package/src/utils/redirects.mjs +49 -49
- package/src/utils/request-id.mjs +2 -4
- package/src/utils/rules-proxy.mjs +96 -100
- package/src/utils/run-build.mjs +109 -132
- package/src/utils/shell.mjs +99 -106
- package/src/utils/sign-redirect.mjs +14 -14
- package/src/utils/sites/utils.mjs +48 -55
- package/src/utils/state-config.mjs +101 -101
- package/src/utils/static-server.mjs +28 -34
- package/src/utils/telemetry/index.mjs +2 -2
- package/src/utils/telemetry/report-error.mjs +45 -49
- package/src/utils/telemetry/request.mjs +36 -43
- package/src/utils/telemetry/telemetry.mjs +90 -105
- package/src/utils/telemetry/utils.mjs +5 -6
- package/src/utils/telemetry/validation.mjs +55 -53
- package/src/utils/types.d.ts +46 -0
- package/src/utils/validation.mjs +10 -13
package/src/commands/main.mjs
CHANGED
|
@@ -1,227 +1,192 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
28
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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 {
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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';
|