netlify-cli 17.3.2 → 17.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/README.md +2 -138
  2. package/npm-shrinkwrap.json +76 -76
  3. package/package.json +16 -15
  4. package/src/commands/addons/addons-auth.mjs +27 -30
  5. package/src/commands/addons/addons-config.mjs +145 -154
  6. package/src/commands/addons/addons-create.mjs +94 -108
  7. package/src/commands/addons/addons-delete.mjs +36 -41
  8. package/src/commands/addons/addons-list.mjs +38 -42
  9. package/src/commands/addons/addons.mjs +26 -28
  10. package/src/commands/addons/index.mjs +1 -1
  11. package/src/commands/api/api.mjs +45 -53
  12. package/src/commands/api/index.mjs +1 -1
  13. package/src/commands/base-command.mjs +597 -684
  14. package/src/commands/blobs/blobs-delete.mjs +35 -0
  15. package/src/commands/blobs/blobs-get.mjs +44 -0
  16. package/src/commands/blobs/blobs-list.mjs +48 -0
  17. package/src/commands/blobs/blobs-set.mjs +54 -0
  18. package/src/commands/blobs/blobs.mjs +32 -0
  19. package/src/commands/blobs/index.mjs +1 -0
  20. package/src/commands/build/build.mjs +55 -67
  21. package/src/commands/build/index.mjs +1 -1
  22. package/src/commands/completion/completion.mjs +41 -46
  23. package/src/commands/completion/index.mjs +1 -1
  24. package/src/commands/deploy/deploy.mjs +675 -710
  25. package/src/commands/deploy/index.mjs +1 -1
  26. package/src/commands/dev/dev-exec.mjs +20 -32
  27. package/src/commands/dev/dev.mjs +217 -302
  28. package/src/commands/dev/index.mjs +1 -1
  29. package/src/commands/dev/types.d.ts +30 -0
  30. package/src/commands/env/env-clone.mjs +157 -184
  31. package/src/commands/env/env-get.mjs +49 -68
  32. package/src/commands/env/env-import.mjs +100 -119
  33. package/src/commands/env/env-list.mjs +104 -129
  34. package/src/commands/env/env-set.mjs +160 -185
  35. package/src/commands/env/env-unset.mjs +104 -122
  36. package/src/commands/env/env.mjs +28 -30
  37. package/src/commands/env/index.mjs +1 -1
  38. package/src/commands/functions/functions-build.mjs +29 -41
  39. package/src/commands/functions/functions-create.mjs +533 -601
  40. package/src/commands/functions/functions-invoke.mjs +193 -216
  41. package/src/commands/functions/functions-list.mjs +45 -55
  42. package/src/commands/functions/functions-serve.mjs +51 -61
  43. package/src/commands/functions/functions.mjs +26 -32
  44. package/src/commands/functions/index.mjs +1 -1
  45. package/src/commands/index.mjs +2 -2
  46. package/src/commands/init/index.mjs +1 -1
  47. package/src/commands/init/init.mjs +138 -167
  48. package/src/commands/integration/deploy.mjs +337 -399
  49. package/src/commands/integration/index.mjs +12 -13
  50. package/src/commands/link/index.mjs +1 -1
  51. package/src/commands/link/link.mjs +298 -317
  52. package/src/commands/lm/index.mjs +1 -1
  53. package/src/commands/lm/lm-info.mjs +23 -31
  54. package/src/commands/lm/lm-install.mjs +13 -17
  55. package/src/commands/lm/lm-setup.mjs +80 -84
  56. package/src/commands/lm/lm-uninstall.mjs +7 -12
  57. package/src/commands/lm/lm.mjs +18 -22
  58. package/src/commands/login/index.mjs +1 -1
  59. package/src/commands/login/login.mjs +35 -41
  60. package/src/commands/logout/index.mjs +1 -1
  61. package/src/commands/logout/logout.mjs +25 -31
  62. package/src/commands/main.mjs +166 -201
  63. package/src/commands/open/index.mjs +1 -1
  64. package/src/commands/open/open-admin.mjs +15 -18
  65. package/src/commands/open/open-site.mjs +16 -19
  66. package/src/commands/open/open.mjs +24 -27
  67. package/src/commands/recipes/common.mjs +23 -34
  68. package/src/commands/recipes/index.mjs +1 -1
  69. package/src/commands/recipes/recipes-list.mjs +13 -20
  70. package/src/commands/recipes/recipes.mjs +59 -72
  71. package/src/commands/serve/index.mjs +1 -1
  72. package/src/commands/serve/serve.mjs +142 -189
  73. package/src/commands/sites/index.mjs +2 -2
  74. package/src/commands/sites/sites-create-template.mjs +214 -236
  75. package/src/commands/sites/sites-create.mjs +145 -157
  76. package/src/commands/sites/sites-delete.mjs +75 -81
  77. package/src/commands/sites/sites-list.mjs +63 -66
  78. package/src/commands/sites/sites.mjs +18 -20
  79. package/src/commands/status/index.mjs +1 -1
  80. package/src/commands/status/status-hooks.mjs +32 -34
  81. package/src/commands/status/status.mjs +99 -106
  82. package/src/commands/switch/index.mjs +1 -1
  83. package/src/commands/switch/switch.mjs +32 -37
  84. package/src/commands/types.d.ts +31 -0
  85. package/src/commands/unlink/index.mjs +1 -1
  86. package/src/commands/unlink/unlink.mjs +23 -29
  87. package/src/commands/watch/index.mjs +1 -1
  88. package/src/commands/watch/watch.mjs +91 -105
  89. package/src/functions-templates/javascript/hello/{{name}}.js +2 -3
  90. package/src/lib/account.mjs +4 -5
  91. package/src/lib/api.mjs +22 -20
  92. package/src/lib/blobs/blobs.mjs +36 -45
  93. package/src/lib/build.mjs +82 -85
  94. package/src/lib/completion/constants.mjs +2 -4
  95. package/src/lib/completion/generate-autocompletion.mjs +33 -36
  96. package/src/lib/completion/get-autocompletion.mjs +31 -35
  97. package/src/lib/completion/index.mjs +1 -1
  98. package/src/lib/completion/script.mjs +12 -19
  99. package/src/lib/edge-functions/bootstrap.mjs +3 -5
  100. package/src/lib/edge-functions/consts.mjs +9 -10
  101. package/src/lib/edge-functions/deploy.mjs +28 -34
  102. package/src/lib/edge-functions/editor-helper.mjs +29 -42
  103. package/src/lib/edge-functions/headers.mjs +24 -26
  104. package/src/lib/edge-functions/internal.mjs +38 -44
  105. package/src/lib/edge-functions/proxy.mjs +229 -228
  106. package/src/lib/edge-functions/registry.mjs +473 -574
  107. package/src/lib/exec-fetcher.mjs +115 -122
  108. package/src/lib/fs.mjs +28 -27
  109. package/src/lib/functions/background.mjs +16 -20
  110. package/src/lib/functions/config.mjs +12 -9
  111. package/src/lib/functions/form-submissions-handler.mjs +143 -149
  112. package/src/lib/functions/local-proxy.mjs +40 -44
  113. package/src/lib/functions/memoized-build.mjs +19 -21
  114. package/src/lib/functions/netlify-function.mjs +269 -249
  115. package/src/lib/functions/registry.mjs +509 -568
  116. package/src/lib/functions/runtimes/go/index.mjs +62 -71
  117. package/src/lib/functions/runtimes/index.mjs +8 -15
  118. package/src/lib/functions/runtimes/js/builders/netlify-lambda.mjs +55 -64
  119. package/src/lib/functions/runtimes/js/builders/zisi.mjs +135 -154
  120. package/src/lib/functions/runtimes/js/constants.mjs +1 -1
  121. package/src/lib/functions/runtimes/js/index.mjs +92 -109
  122. package/src/lib/functions/runtimes/js/worker.mjs +43 -45
  123. package/src/lib/functions/runtimes/rust/index.mjs +64 -73
  124. package/src/lib/functions/scheduled.mjs +70 -88
  125. package/src/lib/functions/server.mjs +269 -327
  126. package/src/lib/functions/synchronous.mjs +118 -147
  127. package/src/lib/functions/utils.mjs +38 -46
  128. package/src/lib/geo-location.mjs +69 -81
  129. package/src/lib/http-agent.mjs +87 -90
  130. package/src/lib/images/proxy.mjs +97 -99
  131. package/src/lib/log.mjs +6 -9
  132. package/src/lib/path.mjs +2 -1
  133. package/src/lib/render-error-template.mjs +19 -20
  134. package/src/lib/settings.mjs +17 -19
  135. package/src/lib/spinner.mjs +21 -23
  136. package/src/lib/string.mjs +4 -2
  137. package/src/recipes/vscode/index.mjs +69 -85
  138. package/src/recipes/vscode/settings.mjs +53 -58
  139. package/src/utils/addons/compare.mjs +31 -32
  140. package/src/utils/addons/diffs/index.mjs +16 -17
  141. package/src/utils/addons/diffs/options.mjs +99 -101
  142. package/src/utils/addons/prepare.mjs +100 -97
  143. package/src/utils/addons/prompts.mjs +73 -76
  144. package/src/utils/addons/render.mjs +33 -36
  145. package/src/utils/addons/validation.mjs +19 -15
  146. package/src/utils/banner.mjs +11 -16
  147. package/src/utils/build-info.mjs +65 -66
  148. package/src/utils/command-helpers.mjs +185 -199
  149. package/src/utils/create-deferred.mjs +9 -12
  150. package/src/utils/create-stream-promise.mjs +54 -47
  151. package/src/utils/deploy/constants.mjs +9 -11
  152. package/src/utils/deploy/deploy-site.mjs +162 -182
  153. package/src/utils/deploy/hash-config.mjs +21 -21
  154. package/src/utils/deploy/hash-files.mjs +34 -38
  155. package/src/utils/deploy/hash-fns.mjs +149 -154
  156. package/src/utils/deploy/hasher-segments.mjs +58 -52
  157. package/src/utils/deploy/upload-files.mjs +99 -113
  158. package/src/utils/deploy/util.mjs +85 -91
  159. package/src/utils/detect-server-settings.mjs +236 -268
  160. package/src/utils/dev.mjs +163 -178
  161. package/src/utils/dot-env.mjs +37 -42
  162. package/src/utils/env/index.mjs +148 -148
  163. package/src/utils/execa.mjs +9 -13
  164. package/src/utils/feature-flags.mjs +6 -5
  165. package/src/utils/framework-server.mjs +43 -52
  166. package/src/utils/functions/constants.mjs +1 -1
  167. package/src/utils/functions/functions.mjs +30 -40
  168. package/src/utils/functions/get-functions.mjs +28 -29
  169. package/src/utils/functions/index.mjs +3 -3
  170. package/src/utils/get-global-config.mjs +33 -36
  171. package/src/utils/get-package-json.mjs +14 -15
  172. package/src/utils/get-repo-data.mjs +54 -64
  173. package/src/utils/get-site.mjs +14 -14
  174. package/src/utils/gh-auth.mjs +79 -100
  175. package/src/utils/gitignore.mjs +37 -40
  176. package/src/utils/headers.mjs +33 -35
  177. package/src/utils/hooks/requires-site-info.mjs +26 -22
  178. package/src/utils/init/config-github.mjs +207 -219
  179. package/src/utils/init/config-manual.mjs +83 -100
  180. package/src/utils/init/config.mjs +25 -26
  181. package/src/utils/init/node-version.mjs +23 -30
  182. package/src/utils/init/plugins.mjs +12 -8
  183. package/src/utils/init/utils.mjs +152 -172
  184. package/src/utils/live-tunnel.mjs +118 -141
  185. package/src/utils/lm/install.mjs +220 -259
  186. package/src/utils/lm/requirements.mjs +54 -63
  187. package/src/utils/lm/steps.mjs +31 -31
  188. package/src/utils/lm/ui.mjs +13 -20
  189. package/src/utils/open-browser.mjs +31 -32
  190. package/src/utils/parse-raw-flags.mjs +39 -35
  191. package/src/utils/proxy-server.mjs +84 -71
  192. package/src/utils/proxy.mjs +696 -750
  193. package/src/utils/read-repo-url.mjs +48 -47
  194. package/src/utils/redirects.mjs +49 -49
  195. package/src/utils/request-id.mjs +2 -4
  196. package/src/utils/rules-proxy.mjs +96 -100
  197. package/src/utils/run-build.mjs +109 -132
  198. package/src/utils/shell.mjs +99 -106
  199. package/src/utils/sign-redirect.mjs +14 -14
  200. package/src/utils/sites/utils.mjs +48 -55
  201. package/src/utils/state-config.mjs +101 -101
  202. package/src/utils/static-server.mjs +28 -34
  203. package/src/utils/telemetry/index.mjs +2 -2
  204. package/src/utils/telemetry/report-error.mjs +45 -49
  205. package/src/utils/telemetry/request.mjs +36 -43
  206. package/src/utils/telemetry/telemetry.mjs +90 -105
  207. package/src/utils/telemetry/utils.mjs +5 -6
  208. package/src/utils/telemetry/validation.mjs +55 -53
  209. package/src/utils/types.d.ts +46 -0
  210. package/src/utils/validation.mjs +10 -13
@@ -1,44 +1,41 @@
1
- // @ts-check
2
- import fs from 'fs'
3
- import { dirname } from 'path'
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
- try {
16
- const autocomplete = program.commands.reduce(
17
- (prev, cmd) => ({
18
- ...prev,
19
- [cmd.name()]: {
20
- name: cmd.name(),
21
- description: cmd.description().split('\n')[0],
22
- options: cmd.options
23
- .filter((option) => !option.hidden)
24
- .sort(sortOptions)
25
- .map((opt) => ({ name: `--${opt.name()}`, description: opt.description })),
26
- },
27
- }),
28
- {},
29
- )
30
-
31
- if (!fs.existsSync(dirname(AUTOCOMPLETION_FILE))) {
32
- fs.mkdirSync(dirname(AUTOCOMPLETION_FILE), { recursive: true })
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
- fs.writeFileSync(AUTOCOMPLETION_FILE, JSON.stringify(autocomplete), 'utf-8')
35
- } catch (error_) {
36
- // Sometimes it can happen that the autocomplete generation in the postinstall script lacks permissions
37
- // to write files to the home directory of the user. Therefore just warn with the error and don't break install.
38
- if (error_ instanceof Error) {
39
- warn(`could not create autocompletion.\n${error_.message}`)
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
- if (!env.complete) {
15
- return
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
- // $ netlify add<cursor>
28
- // we can now check if a command starts with the last partial
29
- const autocomplete = rootCommands.filter(({ name }) => name.startsWith(env.lastPartial))
30
- return autocomplete
31
- }
32
-
33
- const [, command, ...args] = env.line.split(' ')
34
-
35
- if (program[command]) {
36
- const usedArgs = new Set(args)
37
- const unusedOptions = program[command].options.filter(({ name }) => !usedArgs.has(name))
38
-
39
- if (env.lastPartial.length !== 0) {
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
- // suggest options that are not used
44
- return unusedOptions
45
- }
46
- }
47
-
48
- export default getAutocompletion
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 { AUTOCOMPLETION_FILE } from './constants.mjs'
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
- const program = JSON.parse(readFileSync(AUTOCOMPLETION_FILE, 'utf-8'))
30
- const autocomplete = getAutocompletion(env, program)
31
-
32
- if (autocomplete && autocomplete.length !== 0) {
33
- log(autocomplete)
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 latestBootstrapURL = 'https://65437779a0c9990008b54abe--edge.netlify.com/bootstrap/index-combined.ts'
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
- edge_functions_config_export: true,
11
- edge_functions_npm_modules: true,
12
- edge_functions_read_deno_config: true,
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
- // @ts-check
2
- import { stat } from 'fs/promises'
3
- import { join } from 'path'
4
-
5
- import { getPathInProject } from '../settings.mjs'
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
- const absoluteDistPath = join(workingDir, distPath)
17
- const isEdgeFunction = file.root === absoluteDistPath
18
- const normalizedPath = isEdgeFunction ? `${PUBLIC_URL_PATH}/${file.normalizedPath}` : file.normalizedPath
19
-
20
- return {
21
- ...file,
22
- normalizedPath,
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
- try {
31
- const absoluteDistPath = join(workingDir, distPath)
32
- const stats = await stat(absoluteDistPath)
33
-
34
- if (!stats.isDirectory()) {
35
- throw new Error(`Path ${absoluteDistPath} must be a directory.`)
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
- return absoluteDistPath
39
- } catch {
40
- // no-op
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 inquirer from 'inquirer'
4
-
5
- import { runRecipe } from '../../commands/recipes/index.mjs'
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
- // This prevents tests from hanging when running them inside the VS Code
11
- // terminal, as otherwise we'll show the prompt and wait for a response.
12
- if (env.NODE_ENV === 'test') return
13
-
14
- const isVSCode = env.TERM_PROGRAM === 'vscode'
15
- const hasShownPrompt = Boolean(state.get(STATE_PROMPT_PROPERTY))
16
- const hasEdgeFunctions = Boolean(config.edge_functions && config.edge_functions.length !== 0)
17
-
18
- if (!isVSCode || hasShownPrompt || !hasEdgeFunctions) {
19
- return
20
- }
21
-
22
- state.set(STATE_PROMPT_PROPERTY, true)
23
-
24
- const message = 'Would you like to configure VS Code to use Edge Functions?'
25
- const { confirm } = await inquirer.prompt({
26
- type: 'confirm',
27
- name: 'confirm',
28
- message,
29
- default: true,
30
- })
31
-
32
- if (!confirm) {
33
- log(
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
- // @ts-check
2
- import { Buffer } from 'buffer'
3
-
1
+ import { Buffer } from 'buffer';
4
2
  export const headers = {
5
- BlobsInfo: 'x-nf-blobs-info',
6
- DeployID: 'x-nf-deploy-id',
7
- FeatureFlags: 'x-nf-feature-flags',
8
- ForwardedHost: 'x-forwarded-host',
9
- ForwardedProtocol: 'x-forwarded-proto',
10
- Functions: 'x-nf-edge-functions',
11
- InvocationMetadata: 'x-nf-edge-functions-metadata',
12
- Geo: 'x-nf-geo',
13
- Passthrough: 'x-nf-passthrough',
14
- PassthroughHost: 'x-nf-passthrough-host',
15
- PassthroughProtocol: 'x-nf-passthrough-proto',
16
- IP: 'x-nf-client-connection-ip',
17
- Site: 'X-NF-Site-Info',
18
- DebugLogging: 'x-nf-debug-logging',
19
- Account: 'x-nf-account-info',
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
- const featureFlagsObject = featureFlags.reduce((acc, flagName) => ({ ...acc, [flagName]: true }), {})
31
-
32
- return Buffer.from(JSON.stringify(featureFlagsObject)).toString('base64')
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
- export const getInvocationMetadataHeader = (metadata) => Buffer.from(JSON.stringify(metadata)).toString('base64')
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
- // @ts-check
2
- import { readFile, stat } from 'fs/promises'
3
- import { dirname, join, resolve } from 'path'
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
- const path = join(workingDir, getPathInProject([INTERNAL_EDGE_FUNCTIONS_FOLDER]))
14
-
15
- try {
16
- const stats = await stat(path)
17
-
18
- if (!stats.isDirectory()) {
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
- } catch {
22
- return {
23
- functions: [],
24
- path: null,
17
+ catch {
18
+ return {
19
+ functions: [],
20
+ path: null,
21
+ };
25
22
  }
26
- }
27
-
28
- try {
29
- const manifestPath = join(path, 'manifest.json')
30
- const manifest = JSON.parse(await readFile(manifestPath))
31
-
32
- if (manifest.version !== 1) {
33
- throw new Error('Unsupported manifest format')
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
- const data = {
37
- functions: manifest.functions || [],
38
- path,
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
+ };