netlify-cli 12.7.2 → 12.8.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/npm-shrinkwrap.json +560 -624
- package/package.json +11 -11
- package/src/commands/addons/addons.mjs +0 -1
- package/src/commands/base-command.mjs +18 -2
- package/src/commands/deploy/deploy.mjs +11 -2
- package/src/commands/dev/dev.mjs +43 -8
- package/src/commands/env/env-import.mjs +10 -1
- package/src/commands/init/init.mjs +8 -1
- package/src/commands/link/link.mjs +8 -1
- package/src/commands/serve/index.mjs +1 -0
- package/src/commands/serve/serve.mjs +6 -1
- package/src/functions-templates/go/hello-world/go.mod +1 -1
- package/src/functions-templates/javascript/auth-fetch/package-lock.json +7 -7
- package/src/functions-templates/javascript/google-analytics/package-lock.json +6 -6
- package/src/functions-templates/javascript/token-hider/package-lock.json +6 -6
- package/src/functions-templates/rust/hello-world/Cargo.lock +571 -135
- package/src/functions-templates/rust/hello-world/Cargo.toml +3 -3
- package/src/functions-templates/typescript/hello-world/package-lock.json +12 -12
- package/src/lib/edge-functions/headers.mjs +3 -3
- package/src/lib/edge-functions/proxy.mjs +6 -8
- package/src/lib/edge-functions/registry.mjs +9 -1
- package/src/utils/get-repo-data.mjs +1 -1
- package/src/utils/proxy-server.mjs +3 -0
- package/src/utils/proxy.mjs +28 -7
|
@@ -6,9 +6,9 @@ version = "0.1.0"
|
|
|
6
6
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
7
7
|
|
|
8
8
|
[dependencies]
|
|
9
|
-
aws_lambda_events = "0.7.
|
|
9
|
+
aws_lambda_events = "0.7.3"
|
|
10
10
|
http = "0.2.8"
|
|
11
|
-
lambda_runtime = "0.7.
|
|
11
|
+
lambda_runtime = "0.7.3"
|
|
12
12
|
log = "0.4.17"
|
|
13
13
|
simple_logger = "1.16.0"
|
|
14
|
-
tokio = "1.
|
|
14
|
+
tokio = "1.24.1"
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"node_modules/@types/node": {
|
|
29
|
-
"version": "14.18.
|
|
30
|
-
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.
|
|
31
|
-
"integrity": "sha512-
|
|
29
|
+
"version": "14.18.36",
|
|
30
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.36.tgz",
|
|
31
|
+
"integrity": "sha512-FXKWbsJ6a1hIrRxv+FoukuHnGTgEzKYGi7kilfMae96AL9UNkPFNWJEEYWzdRI9ooIkbr4AKldyuSTLql06vLQ=="
|
|
32
32
|
},
|
|
33
33
|
"node_modules/is-promise": {
|
|
34
34
|
"version": "4.0.0",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ=="
|
|
37
37
|
},
|
|
38
38
|
"node_modules/typescript": {
|
|
39
|
-
"version": "4.9.
|
|
40
|
-
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.
|
|
41
|
-
"integrity": "sha512-
|
|
39
|
+
"version": "4.9.4",
|
|
40
|
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz",
|
|
41
|
+
"integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==",
|
|
42
42
|
"bin": {
|
|
43
43
|
"tsc": "bin/tsc",
|
|
44
44
|
"tsserver": "bin/tsserver"
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
"@types/node": {
|
|
61
|
-
"version": "14.18.
|
|
62
|
-
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.
|
|
63
|
-
"integrity": "sha512-
|
|
61
|
+
"version": "14.18.36",
|
|
62
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.36.tgz",
|
|
63
|
+
"integrity": "sha512-FXKWbsJ6a1hIrRxv+FoukuHnGTgEzKYGi7kilfMae96AL9UNkPFNWJEEYWzdRI9ooIkbr4AKldyuSTLql06vLQ=="
|
|
64
64
|
},
|
|
65
65
|
"is-promise": {
|
|
66
66
|
"version": "4.0.0",
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ=="
|
|
69
69
|
},
|
|
70
70
|
"typescript": {
|
|
71
|
-
"version": "4.9.
|
|
72
|
-
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.
|
|
73
|
-
"integrity": "sha512-
|
|
71
|
+
"version": "4.9.4",
|
|
72
|
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz",
|
|
73
|
+
"integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg=="
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const headers = {
|
|
2
2
|
ForwardedHost: 'x-forwarded-host',
|
|
3
|
-
|
|
4
|
-
Functions: 'x-deno-functions',
|
|
3
|
+
Functions: 'x-nf-edge-functions',
|
|
5
4
|
Geo: 'x-nf-geo',
|
|
6
|
-
Passthrough: 'x-
|
|
5
|
+
Passthrough: 'x-nf-passthrough',
|
|
7
6
|
RequestID: 'X-NF-Request-ID',
|
|
8
7
|
IP: 'x-nf-client-connection-ip',
|
|
9
8
|
Site: 'X-NF-Site-Info',
|
|
9
|
+
DebugLogging: 'x-nf-debug-logging',
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export default headers
|
|
@@ -56,19 +56,20 @@ export const createSiteInfoHeader = (siteInfo = {}) => {
|
|
|
56
56
|
export const initializeProxy = async ({
|
|
57
57
|
config,
|
|
58
58
|
configPath,
|
|
59
|
+
debug,
|
|
59
60
|
env: configEnv,
|
|
60
61
|
geoCountry,
|
|
61
62
|
geolocationMode,
|
|
62
63
|
getUpdatedConfig,
|
|
63
64
|
inspectSettings,
|
|
65
|
+
mainPort,
|
|
64
66
|
offline,
|
|
67
|
+
passthroughPort,
|
|
65
68
|
projectDir,
|
|
66
|
-
settings,
|
|
67
69
|
siteInfo,
|
|
68
70
|
state,
|
|
69
71
|
}) => {
|
|
70
72
|
const { functions: internalFunctions, importMap, path: internalFunctionsPath } = await getInternalFunctions()
|
|
71
|
-
const { port: mainPort } = settings
|
|
72
73
|
const userFunctionsPath = config.build.edge_functions
|
|
73
74
|
const isolatePort = await getAvailablePort()
|
|
74
75
|
|
|
@@ -76,7 +77,6 @@ export const initializeProxy = async ({
|
|
|
76
77
|
// the network if needed. We don't want to wait for that to be completed, or
|
|
77
78
|
// the command will be left hanging.
|
|
78
79
|
const server = prepareServer({
|
|
79
|
-
certificatePath: settings.https ? settings.https.certFilePath : undefined,
|
|
80
80
|
config,
|
|
81
81
|
configPath,
|
|
82
82
|
directories: [internalFunctionsPath, userFunctionsPath].filter(Boolean),
|
|
@@ -131,14 +131,14 @@ export const initializeProxy = async ({
|
|
|
131
131
|
|
|
132
132
|
req[headersSymbol] = {
|
|
133
133
|
[headers.Functions]: functionNames.join(','),
|
|
134
|
-
[headers.ForwardedHost]: `localhost:${
|
|
134
|
+
[headers.ForwardedHost]: `localhost:${passthroughPort}`,
|
|
135
135
|
[headers.Passthrough]: 'passthrough',
|
|
136
136
|
[headers.RequestID]: generateUUID(),
|
|
137
137
|
[headers.IP]: LOCAL_HOST,
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
if (
|
|
141
|
-
req[headersSymbol][headers.
|
|
140
|
+
if (debug) {
|
|
141
|
+
req[headersSymbol][headers.DebugLogging] = '1'
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
return `http://${LOCAL_HOST}:${isolatePort}`
|
|
@@ -148,7 +148,6 @@ export const initializeProxy = async ({
|
|
|
148
148
|
export const isEdgeFunctionsRequest = (req) => req[headersSymbol] !== undefined
|
|
149
149
|
|
|
150
150
|
const prepareServer = async ({
|
|
151
|
-
certificatePath,
|
|
152
151
|
config,
|
|
153
152
|
configPath,
|
|
154
153
|
directories,
|
|
@@ -168,7 +167,6 @@ const prepareServer = async ({
|
|
|
168
167
|
const distImportMapPath = getPathInProject([DIST_IMPORT_MAP_PATH])
|
|
169
168
|
const runIsolate = await bundler.serve({
|
|
170
169
|
...getDownloadUpdateFunctions(),
|
|
171
|
-
certificatePath,
|
|
172
170
|
debug: env.NETLIFY_DENO_DEBUG === 'true',
|
|
173
171
|
distImportMapPath,
|
|
174
172
|
formatExportTypeError: (name) =>
|
|
@@ -295,7 +295,15 @@ export class EdgeFunctionsRegistry {
|
|
|
295
295
|
...route,
|
|
296
296
|
pattern: new RegExp(route.pattern),
|
|
297
297
|
}))
|
|
298
|
-
const functionNames = routes
|
|
298
|
+
const functionNames = routes
|
|
299
|
+
.filter(({ pattern }) => pattern.test(urlPath))
|
|
300
|
+
.filter(({ function: name }) => {
|
|
301
|
+
const isExcluded = manifest.function_config[name]?.excluded_patterns.some((pattern) =>
|
|
302
|
+
new RegExp(pattern).test(urlPath),
|
|
303
|
+
)
|
|
304
|
+
return !isExcluded
|
|
305
|
+
})
|
|
306
|
+
.map((route) => route.function)
|
|
299
307
|
const orphanedDeclarations = await this.matchURLPathAgainstOrphanedDeclarations(urlPath)
|
|
300
308
|
|
|
301
309
|
return { functionNames, orphanedDeclarations }
|
|
@@ -44,7 +44,7 @@ const getRepoData = async function ({ remoteName } = {}) {
|
|
|
44
44
|
Object.keys(gitConfig.remote[remoteName]).length === 0
|
|
45
45
|
) {
|
|
46
46
|
throw new Error(
|
|
47
|
-
`The specified remote "${remoteName}" is not defined in Git repo. Please use --
|
|
47
|
+
`The specified remote "${remoteName}" is not defined in Git repo. Please use --git-remote-name flag to specify a remote.`,
|
|
48
48
|
)
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -39,6 +39,7 @@ export const generateInspectSettings = (edgeInspect, edgeInspectBrk) => {
|
|
|
39
39
|
* @param {*} params.addonsUrls
|
|
40
40
|
* @param {import('../commands/base-command.mjs').NetlifyOptions["config"]} params.config
|
|
41
41
|
* @param {string} [params.configPath] An override for the Netlify config path
|
|
42
|
+
* @param {boolean} params.debug
|
|
42
43
|
* @param {import('../commands/base-command.mjs').NetlifyOptions["cachedConfig"]['env']} params.env
|
|
43
44
|
* @param {InspectSettings} params.inspectSettings
|
|
44
45
|
* @param {() => Promise<object>} params.getUpdatedConfig
|
|
@@ -55,6 +56,7 @@ export const startProxyServer = async ({
|
|
|
55
56
|
addonsUrls,
|
|
56
57
|
config,
|
|
57
58
|
configPath,
|
|
59
|
+
debug,
|
|
58
60
|
env,
|
|
59
61
|
geoCountry,
|
|
60
62
|
geolocationMode,
|
|
@@ -70,6 +72,7 @@ export const startProxyServer = async ({
|
|
|
70
72
|
addonsUrls,
|
|
71
73
|
config,
|
|
72
74
|
configPath: configPath || site.configPath,
|
|
75
|
+
debug,
|
|
73
76
|
env,
|
|
74
77
|
geolocationMode,
|
|
75
78
|
geoCountry,
|
package/src/utils/proxy.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import contentType from 'content-type'
|
|
|
13
13
|
import cookie from 'cookie'
|
|
14
14
|
import { get } from 'dot-prop'
|
|
15
15
|
import generateETag from 'etag'
|
|
16
|
+
import getAvailablePort from 'get-port'
|
|
16
17
|
import httpProxy from 'http-proxy'
|
|
17
18
|
import { createProxyMiddleware } from 'http-proxy-middleware'
|
|
18
19
|
import jwtDecode from 'jwt-decode'
|
|
@@ -533,6 +534,7 @@ export const startProxy = async function ({
|
|
|
533
534
|
addonsUrls,
|
|
534
535
|
config,
|
|
535
536
|
configPath,
|
|
537
|
+
debug,
|
|
536
538
|
env,
|
|
537
539
|
geoCountry,
|
|
538
540
|
geolocationMode,
|
|
@@ -544,18 +546,21 @@ export const startProxy = async function ({
|
|
|
544
546
|
siteInfo,
|
|
545
547
|
state,
|
|
546
548
|
}) {
|
|
549
|
+
const secondaryServerPort = settings.https ? await getAvailablePort() : null
|
|
547
550
|
const functionsServer = settings.functionsPort ? `http://127.0.0.1:${settings.functionsPort}` : null
|
|
548
551
|
const edgeFunctionsProxy = await initializeEdgeFunctionsProxy({
|
|
549
552
|
config,
|
|
550
553
|
configPath,
|
|
554
|
+
debug,
|
|
551
555
|
env,
|
|
552
556
|
geolocationMode,
|
|
553
557
|
geoCountry,
|
|
554
558
|
getUpdatedConfig,
|
|
555
559
|
inspectSettings,
|
|
560
|
+
mainPort: settings.port,
|
|
556
561
|
offline,
|
|
562
|
+
passthroughPort: secondaryServerPort || settings.port,
|
|
557
563
|
projectDir,
|
|
558
|
-
settings,
|
|
559
564
|
siteInfo,
|
|
560
565
|
state,
|
|
561
566
|
})
|
|
@@ -584,16 +589,32 @@ export const startProxy = async function ({
|
|
|
584
589
|
functionsServer,
|
|
585
590
|
edgeFunctionsProxy,
|
|
586
591
|
})
|
|
587
|
-
const
|
|
592
|
+
const primaryServer = settings.https
|
|
588
593
|
? https.createServer({ cert: settings.https.cert, key: settings.https.key }, onRequestWithOptions)
|
|
589
594
|
: http.createServer(onRequestWithOptions)
|
|
590
|
-
|
|
591
|
-
server.on('upgrade', function onUpgrade(req, socket, head) {
|
|
595
|
+
const onUpgrade = function onUpgrade(req, socket, head) {
|
|
592
596
|
proxy.ws(req, socket, head)
|
|
593
|
-
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
primaryServer.on('upgrade', onUpgrade)
|
|
600
|
+
primaryServer.listen({ port: settings.port })
|
|
601
|
+
|
|
602
|
+
const eventQueue = [once(primaryServer, 'listening')]
|
|
603
|
+
|
|
604
|
+
// If we're running the main server on HTTPS, we need to start a secondary
|
|
605
|
+
// server on HTTP for receiving passthrough requests from edge functions.
|
|
606
|
+
// This lets us run the Deno server on HTTP and avoid the complications of
|
|
607
|
+
// Deno talking to Node on HTTPS with potentially untrusted certificates.
|
|
608
|
+
if (secondaryServerPort) {
|
|
609
|
+
const secondaryServer = http.createServer(onRequestWithOptions)
|
|
610
|
+
|
|
611
|
+
secondaryServer.on('upgrade', onUpgrade)
|
|
612
|
+
secondaryServer.listen({ port: secondaryServerPort })
|
|
613
|
+
|
|
614
|
+
eventQueue.push(once(secondaryServer, 'listening'))
|
|
615
|
+
}
|
|
594
616
|
|
|
595
|
-
|
|
596
|
-
await once(server, 'listening')
|
|
617
|
+
await Promise.all(eventQueue)
|
|
597
618
|
|
|
598
619
|
const scheme = settings.https ? 'https' : 'http'
|
|
599
620
|
return `${scheme}://localhost:${settings.port}`
|