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
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createDeployCommand } from './deploy.mjs'
|
|
1
|
+
export { createDeployCommand } from './deploy.mjs';
|
|
@@ -1,47 +1,35 @@
|
|
|
1
|
-
import execa from 'execa'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { getEnvelopeEnv, normalizeContext } from '../../utils/env/index.mjs'
|
|
5
|
-
|
|
1
|
+
import execa from 'execa';
|
|
2
|
+
import { getDotEnvVariables, injectEnvVariables } from '../../utils/dev.mjs';
|
|
3
|
+
import { getEnvelopeEnv, normalizeContext } from '../../utils/env/index.mjs';
|
|
6
4
|
/**
|
|
7
5
|
* The dev:exec 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 'cmd' implicitly has an 'any' type.
|
|
11
10
|
const devExec = async (cmd, options, command) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
stdio: 'inherit',
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
|
|
11
|
+
const { api, cachedConfig, config, site, siteInfo } = command.netlify;
|
|
12
|
+
let { env } = cachedConfig;
|
|
13
|
+
if (siteInfo.use_envelope) {
|
|
14
|
+
env = await getEnvelopeEnv({ api, context: options.context, env, siteInfo });
|
|
15
|
+
}
|
|
16
|
+
env = await getDotEnvVariables({ devConfig: { ...config.dev }, env, site });
|
|
17
|
+
injectEnvVariables(env);
|
|
18
|
+
await execa(cmd, command.args.slice(1), {
|
|
19
|
+
stdio: 'inherit',
|
|
20
|
+
});
|
|
21
|
+
};
|
|
27
22
|
/**
|
|
28
23
|
* Creates the `netlify dev:exec` command
|
|
29
24
|
* @param {import('../base-command.mjs').default} program
|
|
30
25
|
* @returns
|
|
31
26
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
|
|
28
|
+
export const createDevExecCommand = (program) => program
|
|
34
29
|
.command('dev:exec')
|
|
35
30
|
.argument('<...cmd>', `the command that should be executed`)
|
|
36
|
-
.option(
|
|
37
|
-
|
|
38
|
-
'Specify a deploy context or branch for environment variables (contexts: "production", "deploy-preview", "branch-deploy", "dev")',
|
|
39
|
-
normalizeContext,
|
|
40
|
-
'dev',
|
|
41
|
-
)
|
|
42
|
-
.description(
|
|
43
|
-
'Exec command\nRuns a command within the netlify dev environment, e.g. with env variables from any installed addons',
|
|
44
|
-
)
|
|
31
|
+
.option('--context <context>', 'Specify a deploy context or branch for environment variables (contexts: "production", "deploy-preview", "branch-deploy", "dev")', normalizeContext, 'dev')
|
|
32
|
+
.description('Exec command\nRuns a command within the netlify dev environment, e.g. with env variables from any installed addons')
|
|
45
33
|
.allowExcessArguments(true)
|
|
46
34
|
.addExamples(['netlify dev:exec npm run bootstrap'])
|
|
47
|
-
.action(devExec)
|
|
35
|
+
.action(devExec);
|
package/src/commands/dev/dev.mjs
CHANGED
|
@@ -1,35 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from '../../utils/command-helpers.mjs'
|
|
20
|
-
import detectServerSettings, { getConfigWithPlugins } from '../../utils/detect-server-settings.mjs'
|
|
21
|
-
import { getDotEnvVariables, getSiteInformation, injectEnvVariables } from '../../utils/dev.mjs'
|
|
22
|
-
import { getEnvelopeEnv, normalizeContext } from '../../utils/env/index.mjs'
|
|
23
|
-
import { ensureNetlifyIgnore } from '../../utils/gitignore.mjs'
|
|
24
|
-
import { getLiveTunnelSlug, startLiveTunnel } from '../../utils/live-tunnel.mjs'
|
|
25
|
-
import openBrowser from '../../utils/open-browser.mjs'
|
|
26
|
-
import { generateInspectSettings, startProxyServer } from '../../utils/proxy-server.mjs'
|
|
27
|
-
import { getProxyUrl } from '../../utils/proxy.mjs'
|
|
28
|
-
import { runDevTimeline } from '../../utils/run-build.mjs'
|
|
29
|
-
import { getGeoCountryArgParser } from '../../utils/validation.mjs'
|
|
30
|
-
|
|
31
|
-
import { createDevExecCommand } from './dev-exec.mjs'
|
|
32
|
-
|
|
1
|
+
import process from 'process';
|
|
2
|
+
import { Option } from 'commander';
|
|
3
|
+
import { getBlobsContext } from '../../lib/blobs/blobs.mjs';
|
|
4
|
+
import { promptEditorHelper } from '../../lib/edge-functions/editor-helper.mjs';
|
|
5
|
+
import { startFunctionsServer } from '../../lib/functions/server.mjs';
|
|
6
|
+
import { printBanner } from '../../utils/banner.mjs';
|
|
7
|
+
import { BANG, chalk, log, NETLIFYDEV, NETLIFYDEVERR, NETLIFYDEVLOG, NETLIFYDEVWARN, normalizeConfig, } from '../../utils/command-helpers.mjs';
|
|
8
|
+
import detectServerSettings, { getConfigWithPlugins } from '../../utils/detect-server-settings.mjs';
|
|
9
|
+
import { getDotEnvVariables, getSiteInformation, injectEnvVariables } from '../../utils/dev.mjs';
|
|
10
|
+
import { getEnvelopeEnv, normalizeContext } from '../../utils/env/index.mjs';
|
|
11
|
+
import { ensureNetlifyIgnore } from '../../utils/gitignore.mjs';
|
|
12
|
+
import { getLiveTunnelSlug, startLiveTunnel } from '../../utils/live-tunnel.mjs';
|
|
13
|
+
import openBrowser from '../../utils/open-browser.mjs';
|
|
14
|
+
import { generateInspectSettings, startProxyServer } from '../../utils/proxy-server.mjs';
|
|
15
|
+
import { getProxyUrl } from '../../utils/proxy.mjs';
|
|
16
|
+
import { runDevTimeline } from '../../utils/run-build.mjs';
|
|
17
|
+
import { getGeoCountryArgParser } from '../../utils/validation.mjs';
|
|
18
|
+
import { createDevExecCommand } from './dev-exec.mjs';
|
|
33
19
|
/**
|
|
34
20
|
*
|
|
35
21
|
* @param {object} config
|
|
@@ -40,309 +26,238 @@ import { createDevExecCommand } from './dev-exec.mjs'
|
|
|
40
26
|
* @param {*} config.state
|
|
41
27
|
* @returns
|
|
42
28
|
*/
|
|
29
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message
|
|
43
30
|
const handleLiveTunnel = async ({ api, options, settings, site, state }) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
31
|
+
const { live } = options;
|
|
32
|
+
if (live) {
|
|
33
|
+
const customSlug = typeof live === 'string' && live.length !== 0 ? live : undefined;
|
|
34
|
+
const slug = getLiveTunnelSlug(state, customSlug);
|
|
35
|
+
let message = `${NETLIFYDEVWARN} Creating live URL with ID ${chalk.yellow(slug)}`;
|
|
36
|
+
if (!customSlug) {
|
|
37
|
+
message += ` (to generate a custom URL, use ${chalk.magenta('--live=<subdomain>')})`;
|
|
38
|
+
}
|
|
39
|
+
log(message);
|
|
40
|
+
const sessionUrl = await startLiveTunnel({
|
|
41
|
+
siteId: site.id,
|
|
42
|
+
netlifyApiToken: api.accessToken,
|
|
43
|
+
localPort: settings.port,
|
|
44
|
+
slug,
|
|
45
|
+
});
|
|
46
|
+
process.env.BASE_URL = sessionUrl;
|
|
47
|
+
return sessionUrl;
|
|
54
48
|
}
|
|
55
|
-
|
|
56
|
-
log(message)
|
|
57
|
-
|
|
58
|
-
const sessionUrl = await startLiveTunnel({
|
|
59
|
-
siteId: site.id,
|
|
60
|
-
netlifyApiToken: api.accessToken,
|
|
61
|
-
localPort: settings.port,
|
|
62
|
-
slug,
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
process.env.BASE_URL = sessionUrl
|
|
66
|
-
|
|
67
|
-
return sessionUrl
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
49
|
+
};
|
|
71
50
|
/**
|
|
72
51
|
* @param {string} args
|
|
73
52
|
*/
|
|
53
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'args' implicitly has an 'any' type.
|
|
74
54
|
const validateShortFlagArgs = (args) => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
`Short flag options like -e or -E don't support the '=' sign
|
|
55
|
+
if (args.startsWith('=')) {
|
|
56
|
+
throw new Error(`Short flag options like -e or -E don't support the '=' sign
|
|
78
57
|
${chalk.red(BANG)} Supported formats:
|
|
79
58
|
netlify dev -e
|
|
80
59
|
netlify dev -e 127.0.0.1:9229
|
|
81
60
|
netlify dev -e127.0.0.1:9229
|
|
82
61
|
netlify dev -E
|
|
83
62
|
netlify dev -E 127.0.0.1:9229
|
|
84
|
-
netlify dev -E127.0.0.1:9229
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
63
|
+
netlify dev -E127.0.0.1:9229`);
|
|
64
|
+
}
|
|
65
|
+
return args;
|
|
66
|
+
};
|
|
90
67
|
/**
|
|
91
68
|
* The dev command
|
|
92
69
|
* @param {import('commander').OptionValues} options
|
|
93
70
|
* @param {import('../base-command.mjs').default} command
|
|
94
71
|
*/
|
|
72
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
|
|
95
73
|
const dev = async (options, command) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
env = await
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
74
|
+
log(`${NETLIFYDEV}`);
|
|
75
|
+
const { api, cachedConfig, config, repositoryRoot, site, siteInfo, state } = command.netlify;
|
|
76
|
+
config.dev = { ...config.dev };
|
|
77
|
+
config.build = { ...config.build };
|
|
78
|
+
/** @type {import('./types.js').DevConfig} */
|
|
79
|
+
const devConfig = {
|
|
80
|
+
framework: '#auto',
|
|
81
|
+
autoLaunch: Boolean(options.open),
|
|
82
|
+
...(config.functionsDirectory && { functions: config.functionsDirectory }),
|
|
83
|
+
...(config.build.publish && { publish: config.build.publish }),
|
|
84
|
+
...(config.build.base && { base: config.build.base }),
|
|
85
|
+
...config.dev,
|
|
86
|
+
...options,
|
|
87
|
+
};
|
|
88
|
+
let { env } = cachedConfig;
|
|
89
|
+
env.NETLIFY_DEV = { sources: ['internal'], value: 'true' };
|
|
90
|
+
if (!options.offline && siteInfo.use_envelope) {
|
|
91
|
+
env = await getEnvelopeEnv({ api, context: options.context, env, siteInfo });
|
|
92
|
+
log(`${NETLIFYDEVLOG} Injecting environment variable values for ${chalk.yellow('all scopes')}`);
|
|
93
|
+
}
|
|
94
|
+
env = await getDotEnvVariables({ devConfig, env, site });
|
|
95
|
+
injectEnvVariables(env);
|
|
96
|
+
await promptEditorHelper({ chalk, config, log, NETLIFYDEVLOG, repositoryRoot, state });
|
|
97
|
+
const { accountId, addonsUrls, capabilities, siteUrl, timeouts } = await getSiteInformation({
|
|
98
|
+
// inherited from base command --offline
|
|
99
|
+
offline: options.offline,
|
|
100
|
+
api,
|
|
101
|
+
site,
|
|
102
|
+
siteInfo,
|
|
103
|
+
});
|
|
104
|
+
/** @type {import('../../utils/types.js').ServerSettings} */
|
|
105
|
+
let settings;
|
|
106
|
+
try {
|
|
107
|
+
settings = await detectServerSettings(devConfig, options, command);
|
|
108
|
+
cachedConfig.config = getConfigWithPlugins(cachedConfig.config, settings);
|
|
109
|
+
}
|
|
110
|
+
catch (error_) {
|
|
111
|
+
if (error_ && typeof error_ === 'object' && 'message' in error_) {
|
|
112
|
+
log(NETLIFYDEVERR, error_.message);
|
|
113
|
+
}
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
command.setAnalyticsPayload({ live: options.live });
|
|
117
|
+
const liveTunnelUrl = await handleLiveTunnel({ options, site, api, settings, state });
|
|
118
|
+
const url = liveTunnelUrl || getProxyUrl(settings);
|
|
119
|
+
process.env.URL = url;
|
|
120
|
+
process.env.DEPLOY_URL = url;
|
|
121
|
+
log(`${NETLIFYDEVWARN} Setting up local development server`);
|
|
122
|
+
const { configPath: configPathOverride } = await runDevTimeline({
|
|
123
|
+
command,
|
|
124
|
+
options,
|
|
125
|
+
settings,
|
|
126
|
+
env: {
|
|
127
|
+
URL: url,
|
|
128
|
+
DEPLOY_URL: url,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
const blobsContext = await getBlobsContext({
|
|
132
|
+
debug: options.debug,
|
|
133
|
+
projectRoot: command.workingDir,
|
|
134
|
+
siteID: site.id ?? 'unknown-site-id',
|
|
135
|
+
});
|
|
136
|
+
const functionsRegistry = await startFunctionsServer({
|
|
137
|
+
api,
|
|
138
|
+
blobsContext,
|
|
139
|
+
command,
|
|
140
|
+
config,
|
|
141
|
+
debug: options.debug,
|
|
142
|
+
settings,
|
|
143
|
+
site,
|
|
144
|
+
siteInfo,
|
|
145
|
+
siteUrl,
|
|
146
|
+
capabilities,
|
|
147
|
+
timeouts,
|
|
148
|
+
geolocationMode: options.geo,
|
|
149
|
+
geoCountry: options.country,
|
|
150
|
+
offline: options.offline,
|
|
151
|
+
state,
|
|
152
|
+
accountId,
|
|
153
|
+
});
|
|
154
|
+
// Try to add `.netlify` to `.gitignore`.
|
|
155
|
+
try {
|
|
156
|
+
await ensureNetlifyIgnore(repositoryRoot);
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
// no-op
|
|
160
|
+
}
|
|
161
|
+
// TODO: We should consolidate this with the existing config watcher.
|
|
162
|
+
const getUpdatedConfig = async () => {
|
|
163
|
+
const { config: newConfig } = await command.getConfig({
|
|
164
|
+
cwd: command.workingDir,
|
|
165
|
+
offline: true,
|
|
166
|
+
state,
|
|
167
|
+
});
|
|
168
|
+
const normalizedNewConfig = normalizeConfig(newConfig);
|
|
169
|
+
return normalizedNewConfig;
|
|
170
|
+
};
|
|
171
|
+
const inspectSettings = generateInspectSettings(options.edgeInspect, options.edgeInspectBrk);
|
|
172
|
+
await startProxyServer({
|
|
173
|
+
addonsUrls,
|
|
174
|
+
blobsContext,
|
|
175
|
+
config,
|
|
176
|
+
configPath: configPathOverride,
|
|
177
|
+
debug: options.debug,
|
|
178
|
+
projectDir: command.workingDir,
|
|
179
|
+
env,
|
|
180
|
+
getUpdatedConfig,
|
|
181
|
+
inspectSettings,
|
|
182
|
+
offline: options.offline,
|
|
183
|
+
settings,
|
|
184
|
+
site,
|
|
185
|
+
siteInfo,
|
|
186
|
+
state,
|
|
187
|
+
geolocationMode: options.geo,
|
|
188
|
+
geoCountry: options.country,
|
|
189
|
+
accountId,
|
|
190
|
+
functionsRegistry,
|
|
191
|
+
repositoryRoot,
|
|
192
|
+
});
|
|
193
|
+
if (devConfig.autoLaunch !== false) {
|
|
194
|
+
await openBrowser({ url, silentBrowserNoneError: true });
|
|
141
195
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
command.setAnalyticsPayload({ live: options.live })
|
|
146
|
-
|
|
147
|
-
const liveTunnelUrl = await handleLiveTunnel({ options, site, api, settings, state })
|
|
148
|
-
const url = liveTunnelUrl || getProxyUrl(settings)
|
|
149
|
-
|
|
150
|
-
process.env.URL = url
|
|
151
|
-
process.env.DEPLOY_URL = url
|
|
152
|
-
|
|
153
|
-
log(`${NETLIFYDEVWARN} Setting up local development server`)
|
|
154
|
-
|
|
155
|
-
const { configPath: configPathOverride } = await runDevTimeline({
|
|
156
|
-
command,
|
|
157
|
-
options,
|
|
158
|
-
settings,
|
|
159
|
-
env: {
|
|
160
|
-
URL: url,
|
|
161
|
-
DEPLOY_URL: url,
|
|
162
|
-
},
|
|
163
|
-
})
|
|
164
|
-
|
|
165
|
-
const blobsContext = await getBlobsContext({
|
|
166
|
-
debug: options.debug,
|
|
167
|
-
projectRoot: command.workingDir,
|
|
168
|
-
siteID: site.id ?? 'unknown-site-id',
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
const functionsRegistry = await startFunctionsServer({
|
|
172
|
-
api,
|
|
173
|
-
blobsContext,
|
|
174
|
-
command,
|
|
175
|
-
config,
|
|
176
|
-
debug: options.debug,
|
|
177
|
-
settings,
|
|
178
|
-
site,
|
|
179
|
-
siteInfo,
|
|
180
|
-
siteUrl,
|
|
181
|
-
capabilities,
|
|
182
|
-
timeouts,
|
|
183
|
-
geolocationMode: options.geo,
|
|
184
|
-
geoCountry: options.country,
|
|
185
|
-
offline: options.offline,
|
|
186
|
-
state,
|
|
187
|
-
accountId,
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
// Try to add `.netlify` to `.gitignore`.
|
|
191
|
-
try {
|
|
192
|
-
await ensureNetlifyIgnore(repositoryRoot)
|
|
193
|
-
} catch {
|
|
194
|
-
// no-op
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// TODO: We should consolidate this with the existing config watcher.
|
|
198
|
-
const getUpdatedConfig = async () => {
|
|
199
|
-
const { config: newConfig } = await command.getConfig({
|
|
200
|
-
cwd: command.workingDir,
|
|
201
|
-
offline: true,
|
|
202
|
-
state,
|
|
203
|
-
})
|
|
204
|
-
const normalizedNewConfig = normalizeConfig(newConfig)
|
|
205
|
-
|
|
206
|
-
return normalizedNewConfig
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const inspectSettings = generateInspectSettings(options.edgeInspect, options.edgeInspectBrk)
|
|
210
|
-
|
|
211
|
-
await startProxyServer({
|
|
212
|
-
addonsUrls,
|
|
213
|
-
blobsContext,
|
|
214
|
-
config,
|
|
215
|
-
configPath: configPathOverride,
|
|
216
|
-
debug: options.debug,
|
|
217
|
-
projectDir: command.workingDir,
|
|
218
|
-
env,
|
|
219
|
-
getUpdatedConfig,
|
|
220
|
-
inspectSettings,
|
|
221
|
-
offline: options.offline,
|
|
222
|
-
settings,
|
|
223
|
-
site,
|
|
224
|
-
siteInfo,
|
|
225
|
-
state,
|
|
226
|
-
geolocationMode: options.geo,
|
|
227
|
-
geoCountry: options.country,
|
|
228
|
-
accountId,
|
|
229
|
-
functionsRegistry,
|
|
230
|
-
repositoryRoot,
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
if (devConfig.autoLaunch !== false) {
|
|
234
|
-
await openBrowser({ url, silentBrowserNoneError: true })
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
printBanner({ url })
|
|
238
|
-
}
|
|
239
|
-
|
|
196
|
+
printBanner({ url });
|
|
197
|
+
};
|
|
240
198
|
/**
|
|
241
199
|
* Creates the `netlify dev` command
|
|
242
200
|
* @param {import('../base-command.mjs').default} program
|
|
243
201
|
* @returns
|
|
244
202
|
*/
|
|
203
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
|
|
245
204
|
export const createDevCommand = (program) => {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
'--context <context>',
|
|
257
|
-
'Specify a deploy context or branch for environment variables (contexts: "production", "deploy-preview", "branch-deploy", "dev")',
|
|
258
|
-
normalizeContext,
|
|
259
|
-
)
|
|
260
|
-
.option('-p ,--port <port>', 'port of netlify dev', (value) => Number.parseInt(value))
|
|
261
|
-
.addOption(
|
|
262
|
-
new Option('--targetPort <port>', 'Old, prefer --target-port. Port of target app server')
|
|
205
|
+
createDevExecCommand(program);
|
|
206
|
+
return program
|
|
207
|
+
.command('dev')
|
|
208
|
+
.alias('develop')
|
|
209
|
+
.description(`Local dev server\nThe dev command will run a local dev server with Netlify's proxy and redirect rules`)
|
|
210
|
+
.option('-c ,--command <command>', 'command to run')
|
|
211
|
+
.option('--context <context>', 'Specify a deploy context or branch for environment variables (contexts: "production", "deploy-preview", "branch-deploy", "dev")', normalizeContext)
|
|
212
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type.
|
|
213
|
+
.option('-p ,--port <port>', 'port of netlify dev', (value) => Number.parseInt(value))
|
|
214
|
+
.addOption(new Option('--targetPort <port>', 'Old, prefer --target-port. Port of target app server')
|
|
263
215
|
.argParser((value) => Number.parseInt(value))
|
|
264
|
-
.hideHelp(true)
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
'start a public live session; optionally, supply a subdomain to generate a custom URL',
|
|
275
|
-
false,
|
|
276
|
-
)
|
|
277
|
-
.addOption(
|
|
278
|
-
new Option('--functionsPort <port>', 'Old, prefer --functions-port. Port of functions server')
|
|
216
|
+
.hideHelp(true))
|
|
217
|
+
.addOption(new Option('--no-open', 'disables the automatic opening of a browser window'))
|
|
218
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type.
|
|
219
|
+
.option('--target-port <port>', 'port of target app server', (value) => Number.parseInt(value))
|
|
220
|
+
.option('--framework <name>', 'framework to use. Defaults to #auto which automatically detects a framework')
|
|
221
|
+
.option('-d ,--dir <path>', 'dir with static files')
|
|
222
|
+
.option('-f ,--functions <folder>', 'specify a functions folder to serve')
|
|
223
|
+
.option('-o ,--offline', 'disables any features that require network access')
|
|
224
|
+
.option('-l, --live [subdomain]', 'start a public live session; optionally, supply a subdomain to generate a custom URL', false)
|
|
225
|
+
.addOption(new Option('--functionsPort <port>', 'Old, prefer --functions-port. Port of functions server')
|
|
279
226
|
.argParser((value) => Number.parseInt(value))
|
|
280
|
-
.hideHelp(true)
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
new Option(
|
|
285
|
-
'--geo <mode>',
|
|
286
|
-
'force geolocation data to be updated, use cached data from the last 24h if found, or use a mock location',
|
|
287
|
-
)
|
|
227
|
+
.hideHelp(true))
|
|
228
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type.
|
|
229
|
+
.option('--functions-port <port>', 'port of functions server', (value) => Number.parseInt(value))
|
|
230
|
+
.addOption(new Option('--geo <mode>', 'force geolocation data to be updated, use cached data from the last 24h if found, or use a mock location')
|
|
288
231
|
.choices(['cache', 'mock', 'update'])
|
|
289
|
-
.default('cache')
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
new Option(
|
|
293
|
-
'--country <geoCountry>',
|
|
294
|
-
'Two-letter country code (https://ntl.fyi/country-codes) to use as mock geolocation (enables --geo=mock automatically)',
|
|
295
|
-
).argParser(getGeoCountryArgParser('netlify dev --geo=mock --country=FR')),
|
|
296
|
-
)
|
|
297
|
-
.addOption(
|
|
298
|
-
new Option('--staticServerPort <port>', 'port of the static app server used when no framework is detected')
|
|
232
|
+
.default('cache'))
|
|
233
|
+
.addOption(new Option('--country <geoCountry>', 'Two-letter country code (https://ntl.fyi/country-codes) to use as mock geolocation (enables --geo=mock automatically)').argParser(getGeoCountryArgParser('netlify dev --geo=mock --country=FR')))
|
|
234
|
+
.addOption(new Option('--staticServerPort <port>', 'port of the static app server used when no framework is detected')
|
|
299
235
|
.argParser((value) => Number.parseInt(value))
|
|
300
|
-
.hideHelp()
|
|
301
|
-
|
|
302
|
-
.addOption(
|
|
303
|
-
new Option(
|
|
304
|
-
'-e, --edgeInspect [address]',
|
|
305
|
-
'Old, prefer --edge-inspect. Enable the V8 Inspector Protocol for Edge Functions, with an optional address in the host:port format',
|
|
306
|
-
)
|
|
236
|
+
.hideHelp())
|
|
237
|
+
.addOption(new Option('-e, --edgeInspect [address]', 'Old, prefer --edge-inspect. Enable the V8 Inspector Protocol for Edge Functions, with an optional address in the host:port format')
|
|
307
238
|
.conflicts('edgeInspectBrk')
|
|
308
239
|
.argParser(validateShortFlagArgs)
|
|
309
|
-
.hideHelp(true)
|
|
310
|
-
|
|
311
|
-
.addOption(
|
|
312
|
-
new Option(
|
|
313
|
-
'-e, --edge-inspect [address]',
|
|
314
|
-
'enable the V8 Inspector Protocol for Edge Functions, with an optional address in the host:port format',
|
|
315
|
-
)
|
|
240
|
+
.hideHelp(true))
|
|
241
|
+
.addOption(new Option('-e, --edge-inspect [address]', 'enable the V8 Inspector Protocol for Edge Functions, with an optional address in the host:port format')
|
|
316
242
|
.conflicts('edgeInspectBrk')
|
|
317
|
-
.argParser(validateShortFlagArgs)
|
|
318
|
-
|
|
319
|
-
.addOption(
|
|
320
|
-
new Option(
|
|
321
|
-
'-E, --edgeInspectBrk [address]',
|
|
322
|
-
'Old, prefer --edge-inspect-brk. Enable the V8 Inspector Protocol for Edge Functions and pause execution on the first line of code, with an optional address in the host:port format',
|
|
323
|
-
)
|
|
243
|
+
.argParser(validateShortFlagArgs))
|
|
244
|
+
.addOption(new Option('-E, --edgeInspectBrk [address]', 'Old, prefer --edge-inspect-brk. Enable the V8 Inspector Protocol for Edge Functions and pause execution on the first line of code, with an optional address in the host:port format')
|
|
324
245
|
.conflicts('edgeInspect')
|
|
325
246
|
.hideHelp(true)
|
|
326
|
-
.argParser(validateShortFlagArgs)
|
|
327
|
-
|
|
328
|
-
.addOption(
|
|
329
|
-
new Option(
|
|
330
|
-
'-E, --edge-inspect-brk [address]',
|
|
331
|
-
'enable the V8 Inspector Protocol for Edge Functions and pause execution on the first line of code, with an optional address in the host:port format',
|
|
332
|
-
)
|
|
247
|
+
.argParser(validateShortFlagArgs))
|
|
248
|
+
.addOption(new Option('-E, --edge-inspect-brk [address]', 'enable the V8 Inspector Protocol for Edge Functions and pause execution on the first line of code, with an optional address in the host:port format')
|
|
333
249
|
.conflicts('edgeInspect')
|
|
334
|
-
.argParser(validateShortFlagArgs)
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
'BROWSER=none netlify dev # disable browser auto opening',
|
|
250
|
+
.argParser(validateShortFlagArgs))
|
|
251
|
+
.addExamples([
|
|
252
|
+
'netlify dev',
|
|
253
|
+
'netlify dev -d public',
|
|
254
|
+
'netlify dev -c "hugo server -w" --target-port 1313',
|
|
255
|
+
'netlify dev --context production',
|
|
256
|
+
'netlify dev --edge-inspect',
|
|
257
|
+
'netlify dev --edge-inspect=127.0.0.1:9229',
|
|
258
|
+
'netlify dev --edge-inspect-brk',
|
|
259
|
+
'netlify dev --edge-inspect-brk=127.0.0.1:9229',
|
|
260
|
+
'BROWSER=none netlify dev # disable browser auto opening',
|
|
346
261
|
])
|
|
347
|
-
|
|
348
|
-
}
|
|
262
|
+
.action(dev);
|
|
263
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createDevCommand } from './dev.mjs'
|
|
1
|
+
export { createDevCommand } from './dev.mjs';
|