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.
Files changed (210) hide show
  1. package/README.md +3 -139
  2. package/npm-shrinkwrap.json +82 -82
  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 -89
  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,99 +1,96 @@
1
- // @ts-check
2
- import { readFile } from 'fs/promises'
3
-
4
- import HttpsProxyAgent from 'https-proxy-agent'
5
- import waitPort from 'wait-port'
6
-
7
- import { NETLIFYDEVERR, NETLIFYDEVWARN, exit, log } from '../utils/command-helpers.mjs'
8
-
1
+ import { readFile } from 'fs/promises';
2
+ import HttpsProxyAgent from 'https-proxy-agent';
3
+ import waitPort from 'wait-port';
4
+ import { NETLIFYDEVERR, NETLIFYDEVWARN, exit, log } from '../utils/command-helpers.mjs';
9
5
  // https://github.com/TooTallNate/node-https-proxy-agent/issues/89
10
6
  // Maybe replace with https://github.com/delvedor/hpagent
7
+ // @ts-expect-error TS(2507) FIXME: Type 'typeof createHttpsProxyAgent' is not a const... Remove this comment to see the full error message
11
8
  class HttpsProxyAgentWithCA extends HttpsProxyAgent {
12
- constructor(opts) {
13
- super(opts)
14
- this.ca = opts.ca
15
- }
16
-
17
- callback(req, opts) {
18
- return super.callback(req, {
19
- ...opts,
20
- ...(this.ca && { ca: this.ca }),
21
- })
22
- }
9
+ // @ts-expect-error TS(7006) FIXME: Parameter 'opts' implicitly has an 'any' type.
10
+ constructor(opts) {
11
+ super(opts);
12
+ // @ts-expect-error TS(2339) FIXME: Property 'ca' does not exist on type 'HttpsProxyAg... Remove this comment to see the full error message
13
+ this.ca = opts.ca;
14
+ }
15
+ // @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type.
16
+ callback(req, opts) {
17
+ return super.callback(req, {
18
+ ...opts,
19
+ // @ts-expect-error TS(2339) FIXME: Property 'ca' does not exist on type 'HttpsProxyAg... Remove this comment to see the full error message
20
+ ...(this.ca && { ca: this.ca }),
21
+ });
22
+ }
23
23
  }
24
-
25
- const DEFAULT_HTTP_PORT = 80
26
- const DEFAULT_HTTPS_PORT = 443
24
+ const DEFAULT_HTTP_PORT = 80;
25
+ const DEFAULT_HTTPS_PORT = 443;
27
26
  // 50 seconds
28
- const AGENT_PORT_TIMEOUT = 50
29
-
27
+ const AGENT_PORT_TIMEOUT = 50;
28
+ // @ts-expect-error TS(7031) FIXME: Binding element 'certificateFile' implicitly has a... Remove this comment to see the full error message
30
29
  export const tryGetAgent = async ({ certificateFile, httpProxy }) => {
31
- if (!httpProxy) {
32
- return {}
33
- }
34
-
35
- let proxyUrl
36
- try {
37
- proxyUrl = new URL(httpProxy)
38
- } catch {
39
- return { error: `${httpProxy} is not a valid URL` }
40
- }
41
-
42
- const scheme = proxyUrl.protocol.slice(0, -1)
43
- if (!['http', 'https'].includes(scheme)) {
44
- return { error: `${httpProxy} must have a scheme of http or https` }
45
- }
46
-
47
- let port
48
- try {
49
- port = await waitPort({
50
- port: Number.parseInt(proxyUrl.port) || (scheme === 'http' ? DEFAULT_HTTP_PORT : DEFAULT_HTTPS_PORT),
51
- host: proxyUrl.hostname,
52
- timeout: AGENT_PORT_TIMEOUT,
53
- output: 'silent',
54
- })
55
- } catch (error) {
56
- // unknown error
57
- return { error: `${httpProxy} is not available.`, message: error.message }
58
- }
59
-
60
- if (!port.open) {
61
- // timeout error
62
- return { error: `Could not connect to '${httpProxy}'` }
63
- }
64
-
65
- let response = {}
66
-
67
- let certificate
68
- if (certificateFile) {
30
+ if (!httpProxy) {
31
+ return {};
32
+ }
33
+ let proxyUrl;
69
34
  try {
70
- certificate = await readFile(certificateFile)
71
- } catch (error) {
72
- response = { warning: `Could not read certificate file '${certificateFile}'.`, message: error.message }
35
+ proxyUrl = new URL(httpProxy);
73
36
  }
74
- }
75
-
76
- const opts = {
77
- port: proxyUrl.port,
78
- host: proxyUrl.host,
79
- hostname: proxyUrl.hostname,
80
- protocol: proxyUrl.protocol,
81
- ca: certificate,
82
- }
83
-
84
- const agent = new HttpsProxyAgentWithCA(opts)
85
- response = { ...response, agent }
86
- return response
87
- }
88
-
37
+ catch {
38
+ return { error: `${httpProxy} is not a valid URL` };
39
+ }
40
+ const scheme = proxyUrl.protocol.slice(0, -1);
41
+ if (!['http', 'https'].includes(scheme)) {
42
+ return { error: `${httpProxy} must have a scheme of http or https` };
43
+ }
44
+ let port;
45
+ try {
46
+ port = await waitPort({
47
+ port: Number.parseInt(proxyUrl.port) || (scheme === 'http' ? DEFAULT_HTTP_PORT : DEFAULT_HTTPS_PORT),
48
+ host: proxyUrl.hostname,
49
+ timeout: AGENT_PORT_TIMEOUT,
50
+ output: 'silent',
51
+ });
52
+ }
53
+ catch (error) {
54
+ // unknown error
55
+ // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
56
+ return { error: `${httpProxy} is not available.`, message: error.message };
57
+ }
58
+ if (!port.open) {
59
+ // timeout error
60
+ return { error: `Could not connect to '${httpProxy}'` };
61
+ }
62
+ let response = {};
63
+ let certificate;
64
+ if (certificateFile) {
65
+ try {
66
+ certificate = await readFile(certificateFile);
67
+ }
68
+ catch (error) {
69
+ // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
70
+ response = { warning: `Could not read certificate file '${certificateFile}'.`, message: error.message };
71
+ }
72
+ }
73
+ const opts = {
74
+ port: proxyUrl.port,
75
+ host: proxyUrl.host,
76
+ hostname: proxyUrl.hostname,
77
+ protocol: proxyUrl.protocol,
78
+ ca: certificate,
79
+ };
80
+ const agent = new HttpsProxyAgentWithCA(opts);
81
+ response = { ...response, agent };
82
+ return response;
83
+ };
84
+ // @ts-expect-error TS(7031) FIXME: Binding element 'certificateFile' implicitly has a... Remove this comment to see the full error message
89
85
  export const getAgent = async ({ certificateFile, httpProxy }) => {
90
- const { agent, error, message, warning } = await tryGetAgent({ httpProxy, certificateFile })
91
- if (error) {
92
- log(NETLIFYDEVERR, error, message || '')
93
- exit(1)
94
- }
95
- if (warning) {
96
- log(NETLIFYDEVWARN, warning, message || '')
97
- }
98
- return agent
99
- }
86
+ // @ts-expect-error TS(2339) FIXME: Property 'agent' does not exist on type '{ error?:... Remove this comment to see the full error message
87
+ const { agent, error, message, warning } = await tryGetAgent({ httpProxy, certificateFile });
88
+ if (error) {
89
+ log(NETLIFYDEVERR, error, message || '');
90
+ exit(1);
91
+ }
92
+ if (warning) {
93
+ log(NETLIFYDEVWARN, warning, message || '');
94
+ }
95
+ return agent;
96
+ };
@@ -1,97 +1,105 @@
1
- import express from 'express'
2
- import { createIPX, ipxFSStorage, ipxHttpStorage, createIPXNodeServer } from 'ipx'
3
-
4
- import { log, NETLIFYDEVERR } from '../../utils/command-helpers.mjs'
5
-
6
- export const IMAGE_URL_PATTERN = '/.netlify/images'
7
-
1
+ import express from 'express';
2
+ import { createIPX, ipxFSStorage, ipxHttpStorage, createIPXNodeServer } from 'ipx';
3
+ import { log, NETLIFYDEVERR } from '../../utils/command-helpers.mjs';
4
+ export const IMAGE_URL_PATTERN = '/.netlify/images';
5
+ // @ts-expect-error TS(7006) FIXME: Parameter 'config' implicitly has an 'any' type.
8
6
  export const parseAllDomains = function (config) {
9
- const domains = config?.images?.remote_images
10
- if (!domains) {
11
- return { errors: [], remoteDomains: [] }
12
- }
13
-
14
- const remoteDomains = []
15
- const errors = []
16
-
17
- for (const patternString of domains) {
18
- try {
19
- const url = new URL(patternString)
20
- if (url.hostname) {
21
- remoteDomains.push(url.hostname)
22
- } else {
23
- errors.push(`The URL '${patternString}' does not have a valid hostname.`)
24
- }
25
- } catch (error) {
26
- errors.push(`Invalid URL '${patternString}': ${error.message}`)
7
+ const domains = config?.images?.remote_images;
8
+ if (!domains) {
9
+ return { errors: [], remoteDomains: [] };
27
10
  }
28
- }
29
-
30
- return { errors, remoteDomains }
31
- }
32
-
11
+ const remoteDomains = [];
12
+ const errors = [];
13
+ for (const patternString of domains) {
14
+ try {
15
+ const url = new URL(patternString);
16
+ if (url.hostname) {
17
+ remoteDomains.push(url.hostname);
18
+ }
19
+ else {
20
+ errors.push(`The URL '${patternString}' does not have a valid hostname.`);
21
+ }
22
+ }
23
+ catch (error) {
24
+ // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
25
+ errors.push(`Invalid URL '${patternString}': ${error.message}`);
26
+ }
27
+ }
28
+ return { errors, remoteDomains };
29
+ };
30
+ // @ts-expect-error TS(7031) FIXME: Binding element 'message' implicitly has an 'any' ... Remove this comment to see the full error message
33
31
  const getErrorMessage = function ({ message }) {
34
- return message
35
- }
36
-
32
+ return message;
33
+ };
34
+ // @ts-expect-error TS(7006) FIXME: Parameter 'errors' implicitly has an 'any' type.
37
35
  export const handleImageDomainsErrors = async function (errors) {
38
- if (errors.length === 0) {
39
- return
40
- }
41
-
42
- const errorMessage = await errors.map(getErrorMessage).join('\n\n')
43
- log(NETLIFYDEVERR, `Image domains syntax errors:\n${errorMessage}`)
44
- }
45
-
36
+ if (errors.length === 0) {
37
+ return;
38
+ }
39
+ const errorMessage = await errors.map(getErrorMessage).join('\n\n');
40
+ log(NETLIFYDEVERR, `Image domains syntax errors:\n${errorMessage}`);
41
+ };
42
+ // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message
46
43
  export const parseRemoteImageDomains = async function ({ config }) {
47
- if (!config) {
48
- return []
49
- }
50
-
51
- const { errors, remoteDomains } = await parseAllDomains(config)
52
- await handleImageDomainsErrors(errors)
53
-
54
- return remoteDomains
55
- }
44
+ if (!config) {
45
+ return [];
46
+ }
47
+ const { errors, remoteDomains } = await parseAllDomains(config);
48
+ await handleImageDomainsErrors(errors);
49
+ return remoteDomains;
50
+ };
51
+ // @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type.
56
52
  export const isImageRequest = function (req) {
57
- return req.url.startsWith(IMAGE_URL_PATTERN)
58
- }
59
-
53
+ return req.url.startsWith(IMAGE_URL_PATTERN);
54
+ };
55
+ // @ts-expect-error TS(7006) FIXME: Parameter 'query' implicitly has an 'any' type.
60
56
  export const transformImageParams = function (query) {
61
- const params = {}
62
- // eslint-disable-next-line id-length
63
- params.w = query.w || query.width || null
64
- // eslint-disable-next-line id-length
65
- params.h = query.h || query.height || null
66
- params.quality = query.q || query.quality || null
67
- params.format = query.fm || null
68
- params.fit = query.fit || null
69
- params.position = query.position || null
70
-
71
- return Object.entries(params)
72
- .filter(([, value]) => value !== null)
73
- .map(([key, value]) => `${key}_${value}`)
74
- .join(',')
75
- }
76
-
57
+ const params = {};
58
+ const width = query.w || query.width || null;
59
+ const height = query.h || query.height || null;
60
+ if (width && height) {
61
+ // @ts-expect-error TS(2339) FIXME: Property 's' does not exist on type '{}'.
62
+ // eslint-disable-next-line id-length
63
+ params.s = `${width}x${height}`;
64
+ }
65
+ else {
66
+ // @ts-expect-error TS(2339) FIXME: Property 'w' does not exist on type '{}'.
67
+ // eslint-disable-next-line id-length
68
+ params.w = width;
69
+ // @ts-expect-error TS(2339) FIXME: Property 'j' does not exist on type '{}'.
70
+ // eslint-disable-next-line id-length
71
+ params.h = height;
72
+ }
73
+ // @ts-expect-error TS(2339) FIXME: Property 'quality' does not exist on type '{}'.
74
+ params.quality = query.q || query.quality || null;
75
+ // @ts-expect-error TS(2339) FIXME: Property 'format' does not exist on type '{}'.
76
+ params.format = query.fm || null;
77
+ const fit = query.fit || null;
78
+ // @ts-expect-error TS(2339) FIXME: Property 'fit' does not exist on type '{}'.
79
+ params.fit = fit === 'contain' ? 'inside' : fit;
80
+ // @ts-expect-error TS(2339) FIXME: Property 'position' does not exist on type '{}'.
81
+ params.position = query.position || null;
82
+ return Object.entries(params)
83
+ .filter(([, value]) => value !== null)
84
+ .map(([key, value]) => `${key}_${value}`)
85
+ .join(',');
86
+ };
87
+ // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message
77
88
  export const initializeProxy = async function ({ config }) {
78
- const remoteDomains = await parseRemoteImageDomains({ config })
79
-
80
- const ipx = createIPX({
81
- storage: ipxFSStorage({ dir: config?.build?.publish ?? './public' }),
82
- httpStorage: ipxHttpStorage({ domains: remoteDomains }),
83
- })
84
-
85
- const handler = createIPXNodeServer(ipx)
86
- const app = express()
87
-
88
- app.use(IMAGE_URL_PATTERN, async (req, res) => {
89
- const { url, ...query } = req.query
90
- const modifiers = await transformImageParams(query)
91
- const path = `/${modifiers}/${encodeURIComponent(url)}`
92
- req.url = path
93
- handler(req, res)
94
- })
95
-
96
- return app
97
- }
89
+ const remoteDomains = await parseRemoteImageDomains({ config });
90
+ const ipx = createIPX({
91
+ storage: ipxFSStorage({ dir: config?.build?.publish ?? './public' }),
92
+ httpStorage: ipxHttpStorage({ domains: remoteDomains }),
93
+ });
94
+ const handler = createIPXNodeServer(ipx);
95
+ const app = express();
96
+ app.use(IMAGE_URL_PATTERN, async (req, res) => {
97
+ const { url, ...query } = req.query;
98
+ const modifiers = await transformImageParams(query);
99
+ // @ts-expect-error TS(2345) FIXME: Argument of type 'string | string[] | ParsedQs | P... Remove this comment to see the full error message
100
+ const path = `/${modifiers}/${encodeURIComponent(url)}`;
101
+ req.url = path;
102
+ handler(req, res);
103
+ });
104
+ return app;
105
+ };
package/src/lib/log.mjs CHANGED
@@ -1,18 +1,15 @@
1
- import { chalk } from '../utils/command-helpers.mjs'
2
-
3
- const RED_BACKGROUND = chalk.red('-background')
4
- const [PRO, BUSINESS, ENTERPRISE] = ['Pro', 'Business', 'Enterprise'].map((plan) => chalk.magenta(plan))
1
+ import { chalk } from '../utils/command-helpers.mjs';
2
+ const RED_BACKGROUND = chalk.red('-background');
3
+ const [PRO, BUSINESS, ENTERPRISE] = ['Pro', 'Business', 'Enterprise'].map((plan) => chalk.magenta(plan));
5
4
  export const BACKGROUND_FUNCTIONS_WARNING = `A serverless function ending in \`${RED_BACKGROUND}\` was detected.
6
5
  Your team’s current plan doesn’t support Background Functions, which have names ending in \`${RED_BACKGROUND}\`.
7
6
  To be able to deploy this function successfully either:
8
7
  - change the function name to remove \`${RED_BACKGROUND}\` and execute it synchronously
9
8
  - upgrade your team plan to a level that supports Background Functions (${PRO}, ${BUSINESS}, or ${ENTERPRISE})
10
- `
11
- export const MISSING_AWS_SDK_WARNING = `A function has thrown an error due to a missing dependency: ${chalk.yellow(
12
- 'aws-sdk',
13
- )}.
9
+ `;
10
+ export const MISSING_AWS_SDK_WARNING = `A function has thrown an error due to a missing dependency: ${chalk.yellow('aws-sdk')}.
14
11
  You should add this module to the project's dependencies, using your package manager of choice:
15
12
 
16
13
  ${chalk.yellow('npm install aws-sdk --save')} or ${chalk.yellow('yarn add aws-sdk')}
17
14
 
18
- For more information, see https://ntl.fyi/cli-aws-sdk.`
15
+ For more information, see https://ntl.fyi/cli-aws-sdk.`;
package/src/lib/path.mjs CHANGED
@@ -1 +1,2 @@
1
- export const normalizeBackslash = (path) => path.replace(/\\/g, '/')
1
+ // @ts-expect-error TS(7006) FIXME: Parameter 'path' implicitly has an 'any' type.
2
+ export const normalizeBackslash = (path) => path.replace(/\\/g, '/');
@@ -1,21 +1,20 @@
1
- import { readFile } from 'fs/promises'
2
- import { dirname, join } from 'path'
3
- import { fileURLToPath } from 'url'
4
-
5
- let errorTemplateFile
6
- const dir = dirname(fileURLToPath(import.meta.url))
7
-
1
+ import { readFile } from 'fs/promises';
2
+ import { dirname, join } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ // @ts-expect-error TS(7034) FIXME: Variable 'errorTemplateFile' implicitly has type '... Remove this comment to see the full error message
5
+ let errorTemplateFile;
6
+ const dir = dirname(fileURLToPath(import.meta.url));
7
+ // @ts-expect-error TS(7006) FIXME: Parameter 'errString' implicitly has an 'any' type... Remove this comment to see the full error message
8
8
  const renderErrorTemplate = async (errString, templatePath, functionType) => {
9
- const errorDetailsRegex = /<!--@ERROR-DETAILS-->/g
10
- const functionTypeRegex = /<!--@FUNCTION-TYPE-->/g
11
-
12
- try {
13
- errorTemplateFile = errorTemplateFile || (await readFile(join(dir, templatePath), 'utf-8'))
14
-
15
- return errorTemplateFile.replace(errorDetailsRegex, errString).replace(functionTypeRegex, functionType)
16
- } catch {
17
- return errString
18
- }
19
- }
20
-
21
- export default renderErrorTemplate
9
+ const errorDetailsRegex = /<!--@ERROR-DETAILS-->/g;
10
+ const functionTypeRegex = /<!--@FUNCTION-TYPE-->/g;
11
+ try {
12
+ // @ts-expect-error TS(7005) FIXME: Variable 'errorTemplateFile' implicitly has an 'an... Remove this comment to see the full error message
13
+ errorTemplateFile = errorTemplateFile || (await readFile(join(dir, templatePath), 'utf-8'));
14
+ return errorTemplateFile.replace(errorDetailsRegex, errString).replace(functionTypeRegex, functionType);
15
+ }
16
+ catch {
17
+ return errString;
18
+ }
19
+ };
20
+ export default renderErrorTemplate;
@@ -1,38 +1,36 @@
1
- import os from 'os'
2
- import path from 'path'
3
-
4
- import envPaths from 'env-paths'
5
-
6
- const OSBasedPaths = envPaths('netlify', { suffix: '' })
7
- const NETLIFY_HOME = '.netlify'
8
-
1
+ import os from 'os';
2
+ import path from 'path';
3
+ import envPaths from 'env-paths';
4
+ const OSBasedPaths = envPaths('netlify', { suffix: '' });
5
+ const NETLIFY_HOME = '.netlify';
9
6
  /**
10
7
  * Deprecated method to get netlify's home config - ~/.netlify/...
11
8
  * @deprecated
12
9
  * @param {string[]} paths
13
10
  * @returns {string}
14
11
  */
12
+ // @ts-expect-error TS(7006) FIXME: Parameter 'paths' implicitly has an 'any' type.
15
13
  export const getLegacyPathInHome = (paths) => {
16
- const pathInHome = path.join(os.homedir(), NETLIFY_HOME, ...paths)
17
- return pathInHome
18
- }
19
-
14
+ const pathInHome = path.join(os.homedir(), NETLIFY_HOME, ...paths);
15
+ return pathInHome;
16
+ };
20
17
  /**
21
18
  * get a global path on the os base path
22
19
  * @param {string[]} paths
23
20
  * @returns {string}
24
21
  */
22
+ // @ts-expect-error TS(7006) FIXME: Parameter 'paths' implicitly has an 'any' type.
25
23
  export const getPathInHome = (paths) => {
26
- const pathInHome = path.join(OSBasedPaths.config, ...paths)
27
- return pathInHome
28
- }
29
-
24
+ const pathInHome = path.join(OSBasedPaths.config, ...paths);
25
+ return pathInHome;
26
+ };
30
27
  /**
31
28
  * get a path inside the project folder
32
29
  * @param {string[]} paths
33
30
  * @returns {string}
34
31
  */
32
+ // @ts-expect-error TS(7006) FIXME: Parameter 'paths' implicitly has an 'any' type.
35
33
  export const getPathInProject = (paths) => {
36
- const pathInProject = path.join(NETLIFY_HOME, ...paths)
37
- return pathInProject
38
- }
34
+ const pathInProject = path.join(NETLIFY_HOME, ...paths);
35
+ return pathInProject;
36
+ };
@@ -1,18 +1,15 @@
1
- // @ts-check
2
- import logSymbols from 'log-symbols'
3
- import ora from 'ora'
4
-
1
+ import logSymbols from 'log-symbols';
2
+ import ora from 'ora';
5
3
  /**
6
4
  * Creates a spinner with the following text
7
5
  * @param {object} config
8
6
  * @param {string} config.text
9
7
  * @returns {ora.Ora}
10
8
  */
11
- export const startSpinner = ({ text }) =>
12
- ora({
9
+ // @ts-expect-error TS(7031) FIXME: Binding element 'text' implicitly has an 'any' typ... Remove this comment to see the full error message
10
+ export const startSpinner = ({ text }) => ora({
13
11
  text,
14
- }).start()
15
-
12
+ }).start();
16
13
  /**
17
14
  * Stops the spinner with the following text
18
15
  * @param {object} config
@@ -21,26 +18,27 @@ export const startSpinner = ({ text }) =>
21
18
  * @param {string} [config.text]
22
19
  * @returns {void}
23
20
  */
21
+ // @ts-expect-error TS(7031) FIXME: Binding element 'error' implicitly has an 'any' ty... Remove this comment to see the full error message
24
22
  export const stopSpinner = ({ error, spinner, text }) => {
25
- if (!spinner) {
26
- return
27
- }
28
- // TODO: refactor no package needed `log-symbols` for that
29
- const symbol = error ? logSymbols.error : logSymbols.success
30
- spinner.stopAndPersist({
31
- text,
32
- symbol,
33
- })
34
- }
35
-
23
+ if (!spinner) {
24
+ return;
25
+ }
26
+ // TODO: refactor no package needed `log-symbols` for that
27
+ const symbol = error ? logSymbols.error : logSymbols.success;
28
+ spinner.stopAndPersist({
29
+ text,
30
+ symbol,
31
+ });
32
+ };
36
33
  /**
37
34
  * Clears the spinner
38
35
  * @param {object} config
39
36
  * @param {ora.Ora} config.spinner
40
37
  * @returns {void}
41
38
  */
39
+ // @ts-expect-error TS(7031) FIXME: Binding element 'spinner' implicitly has an 'any' ... Remove this comment to see the full error message
42
40
  export const clearSpinner = ({ spinner }) => {
43
- if (spinner) {
44
- spinner.stop()
45
- }
46
- }
41
+ if (spinner) {
42
+ spinner.stop();
43
+ }
44
+ };
@@ -1,3 +1,5 @@
1
+ // @ts-expect-error TS(7006) FIXME: Parameter 't' implicitly has an 'any' type.
1
2
  export const capitalize = function (t) {
2
- return t.replace(/(^\w|\s\w)/g, (string) => string.toUpperCase())
3
- }
3
+ // @ts-expect-error TS(7006) FIXME: Parameter 'string' implicitly has an 'any' type.
4
+ return t.replace(/(^\w|\s\w)/g, (string) => string.toUpperCase());
5
+ };