netlify-cli 12.2.8 → 12.2.10
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 +1465 -104
- package/package.json +10 -5
- package/src/commands/dev/dev.mjs +1 -1
- package/src/functions-templates/javascript/graphql-gateway/example-sibling-function-graphql-1.js +0 -2
- package/src/functions-templates/javascript/graphql-gateway/example-sibling-function-graphql-2.js +0 -2
- package/src/functions-templates/typescript/hello-world/package-lock.json +6 -6
- package/src/lib/edge-functions/consts.cjs +0 -10
- package/src/lib/edge-functions/internal.cjs +7 -7
- package/src/lib/edge-functions/registry.cjs +13 -2
- package/src/lib/functions/server.mjs +16 -5
- package/src/utils/command-helpers.cjs +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netlify-cli",
|
|
3
3
|
"description": "Netlify command line tool",
|
|
4
|
-
"version": "12.2.
|
|
4
|
+
"version": "12.2.10",
|
|
5
5
|
"author": "Netlify Inc.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"contributors": [
|
|
@@ -211,8 +211,11 @@
|
|
|
211
211
|
"test:init:eleventy-deps": "npm ci --prefix tests/integration/eleventy-site --no-audit",
|
|
212
212
|
"test:init:hugo-deps": "npm ci --prefix tests/integration/hugo-site --no-audit",
|
|
213
213
|
"test:dev:ava": "ava --verbose",
|
|
214
|
+
"test:dev:vitest": "vitest run",
|
|
214
215
|
"test:ci:ava:unit": "c8 -r json ava --no-worker-threads tests/unit/ tools/",
|
|
215
216
|
"test:ci:ava:integration": "c8 -r json ava --concurrency 1 --no-worker-threads tests/integration/",
|
|
217
|
+
"test:ci:vitest:unit": "vitest run --coverage tests/unit/",
|
|
218
|
+
"test:ci:vitest:integration": "vitest run --coverage --no-threads tests/integration/",
|
|
216
219
|
"test:affected": "node ./tools/affected-test.mjs",
|
|
217
220
|
"e2e": "node ./tools/e2e/run.mjs",
|
|
218
221
|
"docs": "node ./site/scripts/docs.mjs",
|
|
@@ -230,7 +233,7 @@
|
|
|
230
233
|
"dependencies": {
|
|
231
234
|
"@netlify/build": "^28.4.5",
|
|
232
235
|
"@netlify/config": "^20.0.2",
|
|
233
|
-
"@netlify/edge-bundler": "^5.
|
|
236
|
+
"@netlify/edge-bundler": "^5.3.1",
|
|
234
237
|
"@netlify/framework-info": "^9.5.2",
|
|
235
238
|
"@netlify/local-functions-proxy": "^1.1.1",
|
|
236
239
|
"@netlify/zip-it-and-ship-it": "^8.1.0",
|
|
@@ -337,6 +340,7 @@
|
|
|
337
340
|
"devDependencies": {
|
|
338
341
|
"@babel/preset-react": "^7.12.13",
|
|
339
342
|
"@netlify/eslint-config-node": "^7.0.0",
|
|
343
|
+
"@vitest/coverage-c8": "^0.25.3",
|
|
340
344
|
"ava": "^4.0.0",
|
|
341
345
|
"c8": "^7.11.0",
|
|
342
346
|
"eslint-plugin-sort-destructure-keys": "^1.3.5",
|
|
@@ -352,19 +356,20 @@
|
|
|
352
356
|
"rewiremock": "^3.14.3",
|
|
353
357
|
"serialize-javascript": "^6.0.0",
|
|
354
358
|
"sinon": "^14.0.0",
|
|
355
|
-
"sort-on": "^4.1.0",
|
|
356
359
|
"strip-ansi": "^6.0.0",
|
|
357
360
|
"supertest": "^6.1.6",
|
|
358
361
|
"temp-dir": "^2.0.0",
|
|
359
362
|
"tomlify-j0.4": "^3.0.0",
|
|
360
363
|
"tree-kill": "^1.2.2",
|
|
361
364
|
"typescript": "^4.4.4",
|
|
362
|
-
"verdaccio": "^5.10.2"
|
|
365
|
+
"verdaccio": "^5.10.2",
|
|
366
|
+
"vite": "^3.2.4",
|
|
367
|
+
"vitest": "^0.25.3"
|
|
363
368
|
},
|
|
364
369
|
"ava": {
|
|
365
370
|
"files": [
|
|
366
371
|
"tools/**/*.test.mjs",
|
|
367
|
-
"tests/**/*.test
|
|
372
|
+
"tests/**/*.test.cjs"
|
|
368
373
|
],
|
|
369
374
|
"cache": true,
|
|
370
375
|
"concurrency": 5,
|
package/src/commands/dev/dev.mjs
CHANGED
|
@@ -516,7 +516,7 @@ const dev = async (options, command) => {
|
|
|
516
516
|
|
|
517
517
|
const devCommand = async () => {
|
|
518
518
|
const { ipVersion } = await startFrameworkServer({ settings })
|
|
519
|
-
|
|
519
|
+
|
|
520
520
|
settings.frameworkHost = ipVersion === 6 ? '::1' : '127.0.0.1'
|
|
521
521
|
}
|
|
522
522
|
const startDevOptions = getBuildOptions({
|
package/src/functions-templates/javascript/graphql-gateway/example-sibling-function-graphql-1.js
CHANGED
|
@@ -17,13 +17,11 @@ const typeDefs = gql`
|
|
|
17
17
|
}
|
|
18
18
|
`
|
|
19
19
|
|
|
20
|
-
/* eslint-disable no-magic-numbers */
|
|
21
20
|
const authors = [
|
|
22
21
|
{ id: 1, name: 'Terry Pratchett', age: 67 },
|
|
23
22
|
{ id: 2, name: 'Stephen King', age: 71 },
|
|
24
23
|
{ id: 3, name: 'JK Rowling', age: 53 },
|
|
25
24
|
]
|
|
26
|
-
/* eslint-enable no-magic-numbers */
|
|
27
25
|
|
|
28
26
|
const resolvers = {
|
|
29
27
|
Query: {
|
package/src/functions-templates/javascript/graphql-gateway/example-sibling-function-graphql-2.js
CHANGED
|
@@ -17,7 +17,6 @@ const typeDefs = gql`
|
|
|
17
17
|
}
|
|
18
18
|
`
|
|
19
19
|
|
|
20
|
-
/* eslint-disable no-magic-numbers */
|
|
21
20
|
const books = [
|
|
22
21
|
{
|
|
23
22
|
id: 1,
|
|
@@ -62,7 +61,6 @@ const books = [
|
|
|
62
61
|
authorName: 'JK Rowling',
|
|
63
62
|
},
|
|
64
63
|
]
|
|
65
|
-
/* eslint-enable no-magic-numbers */
|
|
66
64
|
|
|
67
65
|
const resolvers = {
|
|
68
66
|
Query: {
|
|
@@ -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.34",
|
|
30
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.34.tgz",
|
|
31
|
+
"integrity": "sha512-hcU9AIQVHmPnmjRK+XUUYlILlr9pQrsqSrwov/JK1pnf3GTQowVBhx54FbvM0AU/VXGH4i3+vgXS5EguR7fysA=="
|
|
32
32
|
},
|
|
33
33
|
"node_modules/is-promise": {
|
|
34
34
|
"version": "4.0.0",
|
|
@@ -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.34",
|
|
62
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.34.tgz",
|
|
63
|
+
"integrity": "sha512-hcU9AIQVHmPnmjRK+XUUYlILlr9pQrsqSrwov/JK1pnf3GTQowVBhx54FbvM0AU/VXGH4i3+vgXS5EguR7fysA=="
|
|
64
64
|
},
|
|
65
65
|
"is-promise": {
|
|
66
66
|
"version": "4.0.0",
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
const DEFAULT_SRC_DIR = 'netlify/edge-functions'
|
|
2
1
|
const DIST_IMPORT_MAP_PATH = 'edge-functions-import-map.json'
|
|
3
2
|
const INTERNAL_EDGE_FUNCTIONS_FOLDER = 'edge-functions'
|
|
4
3
|
const EDGE_FUNCTIONS_FOLDER = 'edge-functions-dist'
|
|
5
4
|
const PUBLIC_URL_PATH = '.netlify/internal/edge-functions'
|
|
6
5
|
|
|
7
|
-
// 1 second
|
|
8
|
-
const SERVER_POLL_INTERNAL = 1e3
|
|
9
|
-
|
|
10
|
-
// 10 seconds
|
|
11
|
-
const SERVER_POLL_TIMEOUT = 1e4
|
|
12
|
-
|
|
13
6
|
module.exports = {
|
|
14
|
-
DEFAULT_SRC_DIR,
|
|
15
7
|
DIST_IMPORT_MAP_PATH,
|
|
16
8
|
INTERNAL_EDGE_FUNCTIONS_FOLDER,
|
|
17
9
|
EDGE_FUNCTIONS_FOLDER,
|
|
18
10
|
PUBLIC_URL_PATH,
|
|
19
|
-
SERVER_POLL_INTERNAL,
|
|
20
|
-
SERVER_POLL_TIMEOUT,
|
|
21
11
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
const { promises: fs } = require('fs')
|
|
3
|
-
const
|
|
3
|
+
const { dirname, join, resolve } = require('path')
|
|
4
4
|
const { cwd } = require('process')
|
|
5
5
|
const { pathToFileURL } = require('url')
|
|
6
6
|
|
|
@@ -30,16 +30,16 @@ const getImportMap = async (importMapPath) => {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
const getInternalFunctions = async () => {
|
|
33
|
-
const
|
|
33
|
+
const path = join(cwd(), getPathInProject([INTERNAL_EDGE_FUNCTIONS_FOLDER]))
|
|
34
34
|
|
|
35
35
|
try {
|
|
36
|
-
const stats = await fs.stat(
|
|
36
|
+
const stats = await fs.stat(path)
|
|
37
37
|
|
|
38
38
|
if (!stats.isDirectory()) {
|
|
39
39
|
throw new Error('Path is not a directory')
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const manifestPath =
|
|
42
|
+
const manifestPath = join(path, 'manifest.json')
|
|
43
43
|
// eslint-disable-next-line import/no-dynamic-require, n/global-require
|
|
44
44
|
const manifest = require(manifestPath)
|
|
45
45
|
|
|
@@ -49,11 +49,11 @@ const getInternalFunctions = async () => {
|
|
|
49
49
|
|
|
50
50
|
const data = {
|
|
51
51
|
functions: manifest.functions,
|
|
52
|
-
path
|
|
52
|
+
path,
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
if (manifest.import_map) {
|
|
56
|
-
const importMapPath =
|
|
56
|
+
const importMapPath = resolve(dirname(manifestPath), manifest.import_map)
|
|
57
57
|
const importMap = await getImportMap(importMapPath)
|
|
58
58
|
|
|
59
59
|
if (importMap !== null) {
|
|
@@ -71,7 +71,7 @@ const getInternalFunctions = async () => {
|
|
|
71
71
|
} catch {
|
|
72
72
|
return {
|
|
73
73
|
functions: [],
|
|
74
|
-
path
|
|
74
|
+
path,
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}
|
|
@@ -11,12 +11,21 @@ const { NETLIFYDEVERR, NETLIFYDEVLOG, chalk, log, warn, watchDebounced } = requi
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* @typedef
|
|
14
|
+
* @typedef EdgeFunctionDeclarationWithPath
|
|
15
15
|
* @type {object}
|
|
16
16
|
* @property {string} function
|
|
17
17
|
* @property {string} path
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* @typedef EdgeFunctionDeclarationWithPattern
|
|
22
|
+
* @type {object}
|
|
23
|
+
* @property {string} function
|
|
24
|
+
* @property {RegExp} pattern
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** @typedef {(EdgeFunctionDeclarationWithPath | EdgeFunctionDeclarationWithPattern) } EdgeFunctionDeclaration */
|
|
28
|
+
|
|
20
29
|
class EdgeFunctionsRegistry {
|
|
21
30
|
/**
|
|
22
31
|
* @param {Object} opts
|
|
@@ -341,7 +350,9 @@ class EdgeFunctionsRegistry {
|
|
|
341
350
|
}
|
|
342
351
|
})
|
|
343
352
|
|
|
344
|
-
|
|
353
|
+
const filteredDeclarations = declarations.filter((declaration) => 'path' in declaration || 'pattern' in declaration)
|
|
354
|
+
|
|
355
|
+
return filteredDeclarations
|
|
345
356
|
}
|
|
346
357
|
|
|
347
358
|
processGraph(graph) {
|
|
@@ -41,6 +41,14 @@ const buildClientContext = function (headers) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
const hasBody = (req) =>
|
|
45
|
+
// copied from is-type package
|
|
46
|
+
// eslint-disable-next-line unicorn/prefer-number-properties
|
|
47
|
+
(req.header('transfer-encoding') !== undefined || !isNaN(req.header('content-length'))) &&
|
|
48
|
+
// we expect a string or a buffer, because we use the two bodyParsers(text, raw) from express
|
|
49
|
+
// eslint-disable-next-line n/prefer-global/buffer
|
|
50
|
+
(typeof req.body === 'string' || Buffer.isBuffer(req.body))
|
|
51
|
+
|
|
44
52
|
export const createHandler = function (options) {
|
|
45
53
|
const { config, functionsRegistry } = options
|
|
46
54
|
|
|
@@ -62,18 +70,21 @@ export const createHandler = function (options) {
|
|
|
62
70
|
return
|
|
63
71
|
}
|
|
64
72
|
|
|
65
|
-
const isBase64Encoded = shouldBase64Encode(request.
|
|
66
|
-
|
|
73
|
+
const isBase64Encoded = shouldBase64Encode(request.header('content-type'))
|
|
74
|
+
let body
|
|
75
|
+
if (hasBody(request)) {
|
|
76
|
+
body = request.body.toString(isBase64Encoded ? 'base64' : 'utf8')
|
|
77
|
+
}
|
|
67
78
|
|
|
68
|
-
let remoteAddress = request.
|
|
79
|
+
let remoteAddress = request.header('x-forwarded-for') || request.connection.remoteAddress || ''
|
|
69
80
|
remoteAddress = remoteAddress
|
|
70
81
|
.split(remoteAddress.includes('.') ? ':' : ',')
|
|
71
82
|
.pop()
|
|
72
83
|
.trim()
|
|
73
84
|
|
|
74
85
|
let requestPath = request.path
|
|
75
|
-
if (request.
|
|
76
|
-
requestPath = request.
|
|
86
|
+
if (request.header('x-netlify-original-pathname')) {
|
|
87
|
+
requestPath = request.header('x-netlify-original-pathname')
|
|
77
88
|
delete request.headers['x-netlify-original-pathname']
|
|
78
89
|
}
|
|
79
90
|
const queryParams = Object.entries(request.query).reduce(
|
|
@@ -53,7 +53,6 @@ const USER_AGENT = `${name}/${version} ${platform}-${arch} node-${process.versio
|
|
|
53
53
|
/** A list of base command flags that needs to be sorted down on documentation and on help pages */
|
|
54
54
|
const BASE_FLAGS = new Set(['--debug', '--httpProxy', '--httpProxyCertificateFilename'])
|
|
55
55
|
|
|
56
|
-
// eslint-disable-next-line no-magic-numbers
|
|
57
56
|
const NETLIFY_CYAN = chalk.rgb(40, 180, 170)
|
|
58
57
|
|
|
59
58
|
const NETLIFYDEV = `${chalk.greenBright('◈')} ${NETLIFY_CYAN('Netlify Dev')} ${chalk.greenBright('◈')}`
|