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,44 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { sortOptions, warn } from '../../utils/command-helpers.mjs'
|
|
6
|
-
|
|
7
|
-
import { AUTOCOMPLETION_FILE } from './constants.mjs'
|
|
8
|
-
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
import { sortOptions, warn } from '../../utils/command-helpers.mjs';
|
|
4
|
+
import { AUTOCOMPLETION_FILE } from './constants.mjs';
|
|
9
5
|
/**
|
|
10
6
|
* Create or updates the autocompletion information for the CLI
|
|
11
7
|
* @param {import('../../commands/base-command.mjs').default} program
|
|
12
8
|
* @returns {void}
|
|
13
9
|
*/
|
|
10
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type.
|
|
14
11
|
const generateAutocompletion = (program) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
12
|
+
try {
|
|
13
|
+
const autocomplete = program.commands.reduce(
|
|
14
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'prev' implicitly has an 'any' type.
|
|
15
|
+
(prev, cmd) => ({
|
|
16
|
+
...prev,
|
|
17
|
+
[cmd.name()]: {
|
|
18
|
+
name: cmd.name(),
|
|
19
|
+
description: cmd.description().split('\n')[0],
|
|
20
|
+
options: cmd.options
|
|
21
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'option' implicitly has an 'any' type.
|
|
22
|
+
.filter((option) => !option.hidden)
|
|
23
|
+
.sort(sortOptions)
|
|
24
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'opt' implicitly has an 'any' type.
|
|
25
|
+
.map((opt) => ({ name: `--${opt.name()}`, description: opt.description })),
|
|
26
|
+
},
|
|
27
|
+
}), {});
|
|
28
|
+
if (!fs.existsSync(dirname(AUTOCOMPLETION_FILE))) {
|
|
29
|
+
fs.mkdirSync(dirname(AUTOCOMPLETION_FILE), { recursive: true });
|
|
30
|
+
}
|
|
31
|
+
fs.writeFileSync(AUTOCOMPLETION_FILE, JSON.stringify(autocomplete), 'utf-8');
|
|
33
32
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
catch (error_) {
|
|
34
|
+
// Sometimes it can happen that the autocomplete generation in the postinstall script lacks permissions
|
|
35
|
+
// to write files to the home directory of the user. Therefore just warn with the error and don't break install.
|
|
36
|
+
if (error_ instanceof Error) {
|
|
37
|
+
warn(`could not create autocompletion.\n${error_.message}`);
|
|
38
|
+
}
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export default generateAutocompletion
|
|
40
|
+
};
|
|
41
|
+
export default generateAutocompletion;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* @typedef CompletionItem
|
|
5
3
|
* @type import('tabtab').CompletionItem
|
|
@@ -10,39 +8,37 @@
|
|
|
10
8
|
* @param {Record<string, CompletionItem & {options: CompletionItem[]}>} program
|
|
11
9
|
* @returns {CompletionItem[]|void}
|
|
12
10
|
*/
|
|
11
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'env' implicitly has an 'any' type.
|
|
13
12
|
const getAutocompletion = function (env, program) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
// means that we are currently in the first command (the root command)
|
|
18
|
-
if (env.words === 1) {
|
|
19
|
-
const rootCommands = Object.values(program).map(({ description, name }) => ({ name, description }))
|
|
20
|
-
|
|
21
|
-
// suggest all commands
|
|
22
|
-
// $ netlify <cursor>
|
|
23
|
-
if (env.lastPartial.length === 0) {
|
|
24
|
-
return rootCommands
|
|
13
|
+
if (!env.complete) {
|
|
14
|
+
return;
|
|
25
15
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return unusedOptions.filter(({ name }) => name.startsWith(env.lastPartial))
|
|
16
|
+
// means that we are currently in the first command (the root command)
|
|
17
|
+
if (env.words === 1) {
|
|
18
|
+
// @ts-expect-error TS(2345) FIXME: Argument of type '({ description, name }: { descri... Remove this comment to see the full error message
|
|
19
|
+
const rootCommands = Object.values(program).map(({ description, name }) => ({ name, description }));
|
|
20
|
+
// suggest all commands
|
|
21
|
+
// $ netlify <cursor>
|
|
22
|
+
if (env.lastPartial.length === 0) {
|
|
23
|
+
return rootCommands;
|
|
24
|
+
}
|
|
25
|
+
// $ netlify add<cursor>
|
|
26
|
+
// we can now check if a command starts with the last partial
|
|
27
|
+
// @ts-expect-error TS(2769) FIXME: No overload matches this call.
|
|
28
|
+
const autocomplete = rootCommands.filter(({ name }) => name.startsWith(env.lastPartial));
|
|
29
|
+
return autocomplete;
|
|
41
30
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
31
|
+
const [, command, ...args] = env.line.split(' ');
|
|
32
|
+
if (program[command]) {
|
|
33
|
+
const usedArgs = new Set(args);
|
|
34
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'name' implicitly has an 'any' typ... Remove this comment to see the full error message
|
|
35
|
+
const unusedOptions = program[command].options.filter(({ name }) => !usedArgs.has(name));
|
|
36
|
+
if (env.lastPartial.length !== 0) {
|
|
37
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'name' implicitly has an 'any' typ... Remove this comment to see the full error message
|
|
38
|
+
return unusedOptions.filter(({ name }) => name.startsWith(env.lastPartial));
|
|
39
|
+
}
|
|
40
|
+
// suggest options that are not used
|
|
41
|
+
return unusedOptions;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
export default getAutocompletion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as generateAutocompletion } from './generate-autocompletion.mjs'
|
|
1
|
+
export { default as generateAutocompletion } from './generate-autocompletion.mjs';
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// @ts-check
|
|
3
|
-
|
|
4
2
|
// This script is run by the completion (every log output will be displayed on tab)
|
|
5
3
|
// src/commands/completion/completion.mjs -> dynamically references this file
|
|
6
4
|
// if this file is renamed or moved then it needs to be adapted there
|
|
7
|
-
import { existsSync, readFileSync } from 'fs'
|
|
8
|
-
import process from 'process'
|
|
9
|
-
|
|
10
|
-
import { log, parseEnv } from 'tabtab'
|
|
11
|
-
|
|
12
|
-
import
|
|
13
|
-
import getAutocompletion from './get-autocompletion.mjs'
|
|
14
|
-
|
|
5
|
+
import { existsSync, readFileSync } from 'fs';
|
|
6
|
+
import process from 'process';
|
|
7
|
+
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'tabt... Remove this comment to see the full error message
|
|
8
|
+
import { log, parseEnv } from 'tabtab';
|
|
9
|
+
import { AUTOCOMPLETION_FILE } from './constants.mjs';
|
|
10
|
+
import getAutocompletion from './get-autocompletion.mjs';
|
|
15
11
|
/**
|
|
16
12
|
* @typedef CompletionItem
|
|
17
13
|
* @type import('tabtab').CompletionItem
|
|
@@ -22,14 +18,11 @@ import getAutocompletion from './get-autocompletion.mjs'
|
|
|
22
18
|
* @param {Record<string, CompletionItem & {options: CompletionItem[]}>} program
|
|
23
19
|
* @returns {CompletionItem[]|void}
|
|
24
20
|
*/
|
|
25
|
-
|
|
26
|
-
const env = parseEnv(process.env)
|
|
27
|
-
|
|
21
|
+
const env = parseEnv(process.env);
|
|
28
22
|
if (existsSync(AUTOCOMPLETION_FILE)) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
23
|
+
const program = JSON.parse(readFileSync(AUTOCOMPLETION_FILE, 'utf-8'));
|
|
24
|
+
const autocomplete = getAutocompletion(env, program);
|
|
25
|
+
if (autocomplete && autocomplete.length !== 0) {
|
|
26
|
+
log(autocomplete);
|
|
27
|
+
}
|
|
35
28
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { env } from 'process'
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
export const getBootstrapURL = () => env.NETLIFY_EDGE_BOOTSTRAP || latestBootstrapURL
|
|
1
|
+
import { env } from 'process';
|
|
2
|
+
const latestBootstrapURL = 'https://65437779a0c9990008b54abe--edge.netlify.com/bootstrap/index-combined.ts';
|
|
3
|
+
export const getBootstrapURL = () => env.NETLIFY_EDGE_BOOTSTRAP || latestBootstrapURL;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
export const DIST_IMPORT_MAP_PATH = 'edge-functions-import-map.json'
|
|
2
|
-
export const INTERNAL_EDGE_FUNCTIONS_FOLDER = 'edge-functions'
|
|
3
|
-
export const EDGE_FUNCTIONS_FOLDER = 'edge-functions-dist'
|
|
4
|
-
export const EDGE_FUNCTIONS_SERVE_FOLDER = 'edge-functions-serve'
|
|
5
|
-
export const PUBLIC_URL_PATH = '.netlify/internal/edge-functions'
|
|
6
|
-
|
|
1
|
+
export const DIST_IMPORT_MAP_PATH = 'edge-functions-import-map.json';
|
|
2
|
+
export const INTERNAL_EDGE_FUNCTIONS_FOLDER = 'edge-functions';
|
|
3
|
+
export const EDGE_FUNCTIONS_FOLDER = 'edge-functions-dist';
|
|
4
|
+
export const EDGE_FUNCTIONS_SERVE_FOLDER = 'edge-functions-serve';
|
|
5
|
+
export const PUBLIC_URL_PATH = '.netlify/internal/edge-functions';
|
|
7
6
|
// Feature flags related to Edge Functions that should be passed along to
|
|
8
7
|
// Netlify Build.
|
|
9
8
|
export const featureFlags = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
9
|
+
edge_functions_config_export: true,
|
|
10
|
+
edge_functions_npm_modules: true,
|
|
11
|
+
edge_functions_read_deno_config: true,
|
|
12
|
+
};
|
|
@@ -1,44 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { EDGE_FUNCTIONS_FOLDER, PUBLIC_URL_PATH } from './consts.mjs'
|
|
8
|
-
|
|
9
|
-
const distPath = getPathInProject([EDGE_FUNCTIONS_FOLDER])
|
|
10
|
-
|
|
1
|
+
import { stat } from 'fs/promises';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { getPathInProject } from '../settings.mjs';
|
|
4
|
+
import { EDGE_FUNCTIONS_FOLDER, PUBLIC_URL_PATH } from './consts.mjs';
|
|
5
|
+
const distPath = getPathInProject([EDGE_FUNCTIONS_FOLDER]);
|
|
11
6
|
/**
|
|
12
7
|
* @param {string} workingDir
|
|
13
8
|
* @param {*} file
|
|
14
9
|
*/
|
|
10
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'workingDir' implicitly has an 'any' typ... Remove this comment to see the full error message
|
|
15
11
|
export const deployFileNormalizer = (workingDir, file) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
12
|
+
const absoluteDistPath = join(workingDir, distPath);
|
|
13
|
+
const isEdgeFunction = file.root === absoluteDistPath;
|
|
14
|
+
const normalizedPath = isEdgeFunction ? `${PUBLIC_URL_PATH}/${file.normalizedPath}` : file.normalizedPath;
|
|
15
|
+
return {
|
|
16
|
+
...file,
|
|
17
|
+
normalizedPath,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
26
20
|
/**
|
|
27
21
|
* @param {string} workingDir
|
|
28
22
|
*/
|
|
23
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'workingDir' implicitly has an 'any' typ... Remove this comment to see the full error message
|
|
29
24
|
export const getDistPathIfExists = async (workingDir) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
try {
|
|
26
|
+
const absoluteDistPath = join(workingDir, distPath);
|
|
27
|
+
const stats = await stat(absoluteDistPath);
|
|
28
|
+
if (!stats.isDirectory()) {
|
|
29
|
+
throw new Error(`Path ${absoluteDistPath} must be a directory.`);
|
|
30
|
+
}
|
|
31
|
+
return absoluteDistPath;
|
|
36
32
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const isEdgeFunctionFile = (filePath) => filePath.startsWith(`${PUBLIC_URL_PATH}/`)
|
|
33
|
+
catch {
|
|
34
|
+
// no-op
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'filePath' implicitly has an 'any' type.
|
|
38
|
+
export const isEdgeFunctionFile = (filePath) => filePath.startsWith(`${PUBLIC_URL_PATH}/`);
|
|
@@ -1,43 +1,30 @@
|
|
|
1
|
-
import { env } from 'process'
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const STATE_PROMPT_PROPERTY = 'promptVSCodeSettings'
|
|
8
|
-
|
|
1
|
+
import { env } from 'process';
|
|
2
|
+
import inquirer from 'inquirer';
|
|
3
|
+
import { runRecipe } from '../../commands/recipes/index.mjs';
|
|
4
|
+
const STATE_PROMPT_PROPERTY = 'promptVSCodeSettings';
|
|
5
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'NETLIFYDEVLOG' implicitly has an ... Remove this comment to see the full error message
|
|
9
6
|
export const promptEditorHelper = async ({ NETLIFYDEVLOG, chalk, config, log, repositoryRoot, state }) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
`${NETLIFYDEVLOG} You can start this configuration manually by running ${chalk.magenta.bold(
|
|
35
|
-
'netlify recipes vscode',
|
|
36
|
-
)}.`,
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
await runRecipe({ config, recipeName: 'vscode', repositoryRoot })
|
|
43
|
-
}
|
|
7
|
+
// This prevents tests from hanging when running them inside the VS Code
|
|
8
|
+
// terminal, as otherwise we'll show the prompt and wait for a response.
|
|
9
|
+
if (env.NODE_ENV === 'test')
|
|
10
|
+
return;
|
|
11
|
+
const isVSCode = env.TERM_PROGRAM === 'vscode';
|
|
12
|
+
const hasShownPrompt = Boolean(state.get(STATE_PROMPT_PROPERTY));
|
|
13
|
+
const hasEdgeFunctions = Boolean(config.edge_functions && config.edge_functions.length !== 0);
|
|
14
|
+
if (!isVSCode || hasShownPrompt || !hasEdgeFunctions) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
state.set(STATE_PROMPT_PROPERTY, true);
|
|
18
|
+
const message = 'Would you like to configure VS Code to use Edge Functions?';
|
|
19
|
+
const { confirm } = await inquirer.prompt({
|
|
20
|
+
type: 'confirm',
|
|
21
|
+
name: 'confirm',
|
|
22
|
+
message,
|
|
23
|
+
default: true,
|
|
24
|
+
});
|
|
25
|
+
if (!confirm) {
|
|
26
|
+
log(`${NETLIFYDEVLOG} You can start this configuration manually by running ${chalk.magenta.bold('netlify recipes vscode')}.`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
await runRecipe({ config, recipeName: 'vscode', repositoryRoot });
|
|
30
|
+
};
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
import { Buffer } from 'buffer'
|
|
3
|
-
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
4
2
|
export const headers = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
3
|
+
BlobsInfo: 'x-nf-blobs-info',
|
|
4
|
+
DeployID: 'x-nf-deploy-id',
|
|
5
|
+
FeatureFlags: 'x-nf-feature-flags',
|
|
6
|
+
ForwardedHost: 'x-forwarded-host',
|
|
7
|
+
ForwardedProtocol: 'x-forwarded-proto',
|
|
8
|
+
Functions: 'x-nf-edge-functions',
|
|
9
|
+
InvocationMetadata: 'x-nf-edge-functions-metadata',
|
|
10
|
+
Geo: 'x-nf-geo',
|
|
11
|
+
Passthrough: 'x-nf-passthrough',
|
|
12
|
+
PassthroughHost: 'x-nf-passthrough-host',
|
|
13
|
+
PassthroughProtocol: 'x-nf-passthrough-proto',
|
|
14
|
+
IP: 'x-nf-client-connection-ip',
|
|
15
|
+
Site: 'X-NF-Site-Info',
|
|
16
|
+
DebugLogging: 'x-nf-debug-logging',
|
|
17
|
+
Account: 'x-nf-account-info',
|
|
18
|
+
};
|
|
22
19
|
/**
|
|
23
20
|
* Takes an array of feature flags and produces a Base64-encoded JSON object
|
|
24
21
|
* that the bootstrap layer can understand.
|
|
@@ -26,12 +23,12 @@ export const headers = {
|
|
|
26
23
|
* @param {Array<string>} featureFlags
|
|
27
24
|
* @returns {string}
|
|
28
25
|
*/
|
|
26
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'featureFlags' implicitly has an 'any' t... Remove this comment to see the full error message
|
|
29
27
|
export const getFeatureFlagsHeader = (featureFlags) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
28
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'acc' implicitly has an 'any' type.
|
|
29
|
+
const featureFlagsObject = featureFlags.reduce((acc, flagName) => ({ ...acc, [flagName]: true }), {});
|
|
30
|
+
return Buffer.from(JSON.stringify(featureFlagsObject)).toString('base64');
|
|
31
|
+
};
|
|
35
32
|
/**
|
|
36
33
|
* Takes the invocation metadata object and produces a Base64-encoded JSON
|
|
37
34
|
* object that the bootstrap layer can understand.
|
|
@@ -39,4 +36,5 @@ export const getFeatureFlagsHeader = (featureFlags) => {
|
|
|
39
36
|
* @param {object} metadata
|
|
40
37
|
* @returns {string}
|
|
41
38
|
*/
|
|
42
|
-
|
|
39
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'metadata' implicitly has an 'any' type.
|
|
40
|
+
export const getInvocationMetadataHeader = (metadata) => Buffer.from(JSON.stringify(metadata)).toString('base64');
|
|
@@ -1,52 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { getPathInProject } from '../settings.mjs'
|
|
6
|
-
|
|
7
|
-
import { INTERNAL_EDGE_FUNCTIONS_FOLDER } from './consts.mjs'
|
|
8
|
-
|
|
1
|
+
import { readFile, stat } from 'fs/promises';
|
|
2
|
+
import { dirname, join, resolve } from 'path';
|
|
3
|
+
import { getPathInProject } from '../settings.mjs';
|
|
4
|
+
import { INTERNAL_EDGE_FUNCTIONS_FOLDER } from './consts.mjs';
|
|
9
5
|
/**
|
|
10
6
|
* @param {string} workingDir
|
|
11
7
|
*/
|
|
8
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'workingDir' implicitly has an 'any' typ... Remove this comment to see the full error message
|
|
12
9
|
export const getInternalFunctions = async (workingDir) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
throw new Error('Internal edge functions directory expected')
|
|
10
|
+
const path = join(workingDir, getPathInProject([INTERNAL_EDGE_FUNCTIONS_FOLDER]));
|
|
11
|
+
try {
|
|
12
|
+
const stats = await stat(path);
|
|
13
|
+
if (!stats.isDirectory()) {
|
|
14
|
+
throw new Error('Internal edge functions directory expected');
|
|
15
|
+
}
|
|
20
16
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
catch {
|
|
18
|
+
return {
|
|
19
|
+
functions: [],
|
|
20
|
+
path: null,
|
|
21
|
+
};
|
|
25
22
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
try {
|
|
24
|
+
const manifestPath = join(path, 'manifest.json');
|
|
25
|
+
// @ts-expect-error TS(2345) FIXME: Argument of type 'Buffer' is not assignable to par... Remove this comment to see the full error message
|
|
26
|
+
const manifest = JSON.parse(await readFile(manifestPath));
|
|
27
|
+
if (manifest.version !== 1) {
|
|
28
|
+
throw new Error('Unsupported manifest format');
|
|
29
|
+
}
|
|
30
|
+
const data = {
|
|
31
|
+
functions: manifest.functions || [],
|
|
32
|
+
path,
|
|
33
|
+
};
|
|
34
|
+
if (manifest.import_map) {
|
|
35
|
+
// @ts-expect-error TS(2339) FIXME: Property 'importMap' does not exist on type '{ fun... Remove this comment to see the full error message
|
|
36
|
+
data.importMap = resolve(dirname(manifestPath), manifest.import_map);
|
|
37
|
+
}
|
|
38
|
+
return data;
|
|
34
39
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
catch {
|
|
41
|
+
return {
|
|
42
|
+
functions: [],
|
|
43
|
+
path,
|
|
44
|
+
};
|
|
39
45
|
}
|
|
40
|
-
|
|
41
|
-
if (manifest.import_map) {
|
|
42
|
-
data.importMap = resolve(dirname(manifestPath), manifest.import_map)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return data
|
|
46
|
-
} catch {
|
|
47
|
-
return {
|
|
48
|
-
functions: [],
|
|
49
|
-
path,
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
46
|
+
};
|