netlify-cli 12.12.0 → 12.12.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "netlify-cli",
3
3
  "description": "Netlify command line tool",
4
- "version": "12.12.0",
4
+ "version": "12.12.1",
5
5
  "author": "Netlify Inc.",
6
6
  "type": "module",
7
7
  "engines": {
@@ -71,17 +71,17 @@
71
71
  "certs": "openssl req -x509 -out localhost.crt -keyout localhost.key -newkey rsa:2048 -nodes -sha256 -subj \"/CN=localhost\" -extensions EXT -config certconf"
72
72
  },
73
73
  "config": {
74
- "eslint": "--ignore-path .gitignore --cache --format=codeframe --max-warnings=0 \"{src,scripts,site,tests,.github}/**/*.{mjs,cjs,js,md,html}\" \"*.{mjs,cjs,js,md,html}\" \".*.{mjs,cjs,js,md,html}\"",
75
- "prettier": "--ignore-path .gitignore --loglevel=warn \"{src,tools,scripts,site,tests,.github}/**/*.{mjs,cjs,js,md,yml,json,html}\" \"*.{mjs,cjs,js,yml,json,html}\" \".*.{mjs,cjs,js,yml,json,html}\" \"!CHANGELOG.md\" \"!npm-shrinkwrap.json\" \"!**/*/package-lock.json\" \"!.github/**/*.md\""
74
+ "eslint": "--cache --format=codeframe --max-warnings=0 \"{src,scripts,site,tests,.github}/**/*.{mjs,cjs,js,md,html}\" \"*.{mjs,cjs,js,md,html}\" \".*.{mjs,cjs,js,md,html}\"",
75
+ "prettier": "--ignore-path .eslintignore --loglevel=warn \"{src,tools,scripts,site,tests,.github}/**/*.{mjs,cjs,js,md,yml,json,html}\" \"*.{mjs,cjs,js,yml,json,html}\" \".*.{mjs,cjs,js,yml,json,html}\" \"!CHANGELOG.md\" \"!npm-shrinkwrap.json\" \"!**/*/package-lock.json\" \"!.github/**/*.md\""
76
76
  },
77
77
  "dependencies": {
78
78
  "@fastify/static": "^6.6.0",
79
- "@netlify/build": "^29.5.5",
79
+ "@netlify/build": "^29.5.7",
80
80
  "@netlify/config": "^20.3.3",
81
- "@netlify/edge-bundler": "^8.4.0",
81
+ "@netlify/edge-bundler": "^8.6.0",
82
82
  "@netlify/framework-info": "^9.8.1",
83
83
  "@netlify/local-functions-proxy": "^1.1.1",
84
- "@netlify/zip-it-and-ship-it": "^8.5.0",
84
+ "@netlify/zip-it-and-ship-it": "^8.6.0",
85
85
  "@octokit/rest": "^19.0.0",
86
86
  "ansi-escapes": "^5.0.0",
87
87
  "ansi-styles": "^5.0.0",
@@ -94,7 +94,7 @@
94
94
  "chokidar": "^3.0.2",
95
95
  "ci-info": "^3.0.0",
96
96
  "clean-deep": "^3.0.2",
97
- "commander": "^9.2.0",
97
+ "commander": "^10.0.0",
98
98
  "comment-json": "^4.2.3",
99
99
  "concordance": "^5.0.0",
100
100
  "configstore": "^5.0.0",
@@ -187,6 +187,7 @@
187
187
  "@vitest/coverage-c8": "^0.28.0",
188
188
  "ava": "^4.0.0",
189
189
  "c8": "^7.11.0",
190
+ "cpy": "^9.0.1",
190
191
  "eslint-plugin-sort-destructure-keys": "^1.3.5",
191
192
  "fast-glob": "^3.2.7",
192
193
  "form-data": "^4.0.0",
@@ -19,9 +19,9 @@
19
19
  "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
20
20
  },
21
21
  "node_modules/axios": {
22
- "version": "1.2.6",
23
- "resolved": "https://registry.npmjs.org/axios/-/axios-1.2.6.tgz",
24
- "integrity": "sha512-rC/7F08XxZwjMV4iuWv+JpD3E0Ksqg9nac4IIg6RwNuF0JTeWoCo/mBNG54+tNhhI11G3/VDRbdDQTs9hGp4pQ==",
22
+ "version": "1.3.3",
23
+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.3.tgz",
24
+ "integrity": "sha512-eYq77dYIFS77AQlhzEL937yUBSepBfPIe8FcgEDN35vMNZKMrs81pgnyrQpwfy4NF4b4XWX1Zgx7yX+25w8QJA==",
25
25
  "dependencies": {
26
26
  "follow-redirects": "^1.15.0",
27
27
  "form-data": "^4.0.0",
@@ -198,9 +198,9 @@
198
198
  "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
199
199
  },
200
200
  "axios": {
201
- "version": "1.2.6",
202
- "resolved": "https://registry.npmjs.org/axios/-/axios-1.2.6.tgz",
203
- "integrity": "sha512-rC/7F08XxZwjMV4iuWv+JpD3E0Ksqg9nac4IIg6RwNuF0JTeWoCo/mBNG54+tNhhI11G3/VDRbdDQTs9hGp4pQ==",
201
+ "version": "1.3.3",
202
+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.3.tgz",
203
+ "integrity": "sha512-eYq77dYIFS77AQlhzEL937yUBSepBfPIe8FcgEDN35vMNZKMrs81pgnyrQpwfy4NF4b4XWX1Zgx7yX+25w8QJA==",
204
204
  "requires": {
205
205
  "follow-redirects": "^1.15.0",
206
206
  "form-data": "^4.0.0",
@@ -11,4 +11,4 @@ http = "0.2.8"
11
11
  lambda_runtime = "0.7.3"
12
12
  log = "0.4.17"
13
13
  simple_logger = "1.16.0"
14
- tokio = "1.24.2"
14
+ tokio = "1.25.0"
@@ -3,6 +3,16 @@ import { fileURLToPath } from 'url'
3
3
 
4
4
  import { NETLIFYDEVERR, NETLIFYDEVLOG, chalk, log, warn, watchDebounced } from '../../utils/command-helpers.mjs'
5
5
 
6
+ // TODO: Import from `@netlify/edge-bundler` once it exports this type.
7
+ /**
8
+ * @typedef InSourceDeclaration
9
+ * @type {object}
10
+ * @property {string} [cache]
11
+ * @property {string} function
12
+ * @property {string | string[]} [path]
13
+ * @property {string | string[]} [excludedPath]
14
+ */
15
+
6
16
  /**
7
17
  * @typedef EdgeFunction
8
18
  * @type {object}
@@ -21,10 +31,11 @@ import { NETLIFYDEVERR, NETLIFYDEVLOG, chalk, log, warn, watchDebounced } from '
21
31
  * @typedef EdgeFunctionDeclarationWithPattern
22
32
  * @type {object}
23
33
  * @property {string} function
24
- * @property {RegExp} pattern
34
+ * @property {string} pattern
25
35
  */
26
36
 
27
- /** @typedef {(EdgeFunctionDeclarationWithPath | EdgeFunctionDeclarationWithPattern) } EdgeFunctionDeclaration */
37
+ /** @typedef {(EdgeFunctionDeclarationWithPath | EdgeFunctionDeclarationWithPattern)} EdgeFunctionDeclaration */
38
+ /** @typedef {Awaited<ReturnType<typeof import('@netlify/edge-bundler').serve>>} RunIsolate */
28
39
 
29
40
  export class EdgeFunctionsRegistry {
30
41
  /**
@@ -37,7 +48,7 @@ export class EdgeFunctionsRegistry {
37
48
  * @param {() => Promise<object>} opts.getUpdatedConfig
38
49
  * @param {EdgeFunction[]} opts.internalFunctions
39
50
  * @param {string} opts.projectDir
40
- * @param {(functions: EdgeFunction[], env?: NodeJS.ProcessEnv) => Promise<object>} opts.runIsolate
51
+ * @param {RunIsolate} opts.runIsolate
41
52
  */
42
53
  constructor({
43
54
  bundler,
@@ -50,9 +61,6 @@ export class EdgeFunctionsRegistry {
50
61
  projectDir,
51
62
  runIsolate,
52
63
  }) {
53
- /**
54
- * @type {import('@netlify/edge-bundler')}
55
- */
56
64
  this.bundler = bundler
57
65
 
58
66
  /**
@@ -76,7 +84,7 @@ export class EdgeFunctionsRegistry {
76
84
  this.internalFunctions = internalFunctions
77
85
 
78
86
  /**
79
- * @type {(functions: EdgeFunction[], env?: NodeJS.ProcessEnv) => Promise<object>}
87
+ * @type {RunIsolate}
80
88
  */
81
89
  this.runIsolate = runIsolate
82
90
 
@@ -91,7 +99,7 @@ export class EdgeFunctionsRegistry {
91
99
  this.declarationsFromConfig = this.getDeclarationsFromConfig(config)
92
100
 
93
101
  /**
94
- * @type {EdgeFunctionDeclaration[]}
102
+ * @type {InSourceDeclaration[]}
95
103
  */
96
104
  this.declarationsFromSource = []
97
105
 
@@ -287,7 +295,7 @@ export class EdgeFunctionsRegistry {
287
295
  */
288
296
  async matchURLPath(urlPath) {
289
297
  const declarations = this.mergeDeclarations()
290
- const manifest = await this.bundler.generateManifest({
298
+ const manifest = this.bundler.generateManifest({
291
299
  declarations,
292
300
  functions: this.functions,
293
301
  })
@@ -309,14 +317,14 @@ export class EdgeFunctionsRegistry {
309
317
  return { functionNames, orphanedDeclarations }
310
318
  }
311
319
 
312
- async matchURLPathAgainstOrphanedDeclarations(urlPath) {
320
+ matchURLPathAgainstOrphanedDeclarations(urlPath) {
313
321
  // `generateManifest` will only include functions for which there is both a
314
322
  // function file and a config declaration, but we want to catch cases where
315
323
  // a config declaration exists without a matching function file. To do that
316
324
  // we compute a list of functions from the declarations (the `path` doesn't
317
325
  // really matter).
318
326
  const functions = this.declarationsFromConfig.map((declaration) => ({ name: declaration.function, path: '' }))
319
- const manifest = await this.bundler.generateManifest({
327
+ const manifest = this.bundler.generateManifest({
320
328
  declarations: this.declarationsFromConfig,
321
329
  functions,
322
330
  })
@@ -346,12 +354,33 @@ export class EdgeFunctionsRegistry {
346
354
  const declarations = [...this.declarationsFromConfig]
347
355
 
348
356
  this.declarationsFromSource.forEach((declarationFromSource) => {
349
- const index = declarations.findIndex(({ function: func }) => func === declarationFromSource.function)
350
-
351
- if (index === -1) {
352
- declarations.push(declarationFromSource)
357
+ const { path: pathOrPaths, ...configProps } = declarationFromSource
358
+
359
+ // Find any declarations in the config for the function.
360
+ const indexes = declarations
361
+ .filter(({ function: func }) => func === declarationFromSource.function)
362
+ .map((_, index) => index)
363
+
364
+ // If the in-source declaration doesn't have a path, add its properties
365
+ // to any existing declarations for the function.
366
+ if (pathOrPaths === undefined) {
367
+ indexes.forEach((index) => {
368
+ declarations[index] = { ...declarations[index], ...configProps }
369
+ })
353
370
  } else {
354
- declarations[index] = { ...declarations[index], ...declarationFromSource }
371
+ // The in-source declaration has a path, and those take precedence.
372
+ // Discard any config declarations first.
373
+ indexes.forEach((index) => {
374
+ declarations.splice(index, 1)
375
+ })
376
+
377
+ // The path may be an array or a string, so let's normalize that first.
378
+ const paths = Array.isArray(pathOrPaths) ? pathOrPaths : [pathOrPaths]
379
+
380
+ // Create a new declaration for each path.
381
+ paths.forEach((path) => {
382
+ declarations.push({ ...configProps, path })
383
+ })
355
384
  }
356
385
  })
357
386