netlify-cli 13.1.7 → 13.2.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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "netlify-cli",
3
- "version": "13.1.7",
3
+ "version": "13.2.1",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "netlify-cli",
9
- "version": "13.1.7",
9
+ "version": "13.2.1",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "netlify-cli",
3
3
  "description": "Netlify command line tool",
4
- "version": "13.1.7",
4
+ "version": "13.2.1",
5
5
  "author": "Netlify Inc.",
6
6
  "type": "module",
7
7
  "engines": {
@@ -26,9 +26,9 @@
26
26
  }
27
27
  },
28
28
  "node_modules/@types/node": {
29
- "version": "14.18.38",
30
- "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.38.tgz",
31
- "integrity": "sha512-zMRIidN2Huikv/+/U7gRPFYsXDR/7IGqFZzTLnCEj5+gkrQjsowfamaxEnyvArct5hxGA3bTxMXlYhH78V6Cew=="
29
+ "version": "14.18.40",
30
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.40.tgz",
31
+ "integrity": "sha512-pGteXO/JQX7wPxGR8lyT+doqjMa7XvlVowwrDwLfX92k5SdLkk4cwC7CYSLBxrenw/R5oQwKioVIak7ZgplM3g=="
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.38",
62
- "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.38.tgz",
63
- "integrity": "sha512-zMRIidN2Huikv/+/U7gRPFYsXDR/7IGqFZzTLnCEj5+gkrQjsowfamaxEnyvArct5hxGA3bTxMXlYhH78V6Cew=="
61
+ "version": "14.18.40",
62
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.40.tgz",
63
+ "integrity": "sha512-pGteXO/JQX7wPxGR8lyT+doqjMa7XvlVowwrDwLfX92k5SdLkk4cwC7CYSLBxrenw/R5oQwKioVIak7ZgplM3g=="
64
64
  },
65
65
  "is-promise": {
66
66
  "version": "4.0.0",
@@ -1,5 +1,5 @@
1
1
  import { env } from 'process'
2
2
 
3
- const latestBootstrapURL = 'https://64109c4552d9020008b9dadc--edge.netlify.com/bootstrap/index-combined.ts'
3
+ const latestBootstrapURL = 'https://6419767d9dc968000848742a--edge.netlify.com/bootstrap/index-combined.ts'
4
4
 
5
5
  export const getBootstrapURL = () => env.NETLIFY_EDGE_BOOTSTRAP || latestBootstrapURL
@@ -1,6 +1,11 @@
1
- const headers = {
1
+ // @ts-check
2
+ import { Buffer } from 'buffer'
3
+
4
+ export const headers = {
5
+ FeatureFlags: 'x-nf-feature-flags',
2
6
  ForwardedHost: 'x-forwarded-host',
3
7
  Functions: 'x-nf-edge-functions',
8
+ InvocationMetadata: 'x-nf-edge-functions-metadata',
4
9
  Geo: 'x-nf-geo',
5
10
  Passthrough: 'x-nf-passthrough',
6
11
  IP: 'x-nf-client-connection-ip',
@@ -8,4 +13,24 @@ const headers = {
8
13
  DebugLogging: 'x-nf-debug-logging',
9
14
  }
10
15
 
11
- export default headers
16
+ /**
17
+ * Takes an array of feature flags and produces a Base64-encoded JSON object
18
+ * that the bootstrap layer can understand.
19
+ *
20
+ * @param {Array<string>} featureFlags
21
+ * @returns {string}
22
+ */
23
+ export const getFeatureFlagsHeader = (featureFlags) => {
24
+ const featureFlagsObject = featureFlags.reduce((acc, flagName) => ({ ...acc, [flagName]: true }), {})
25
+
26
+ return Buffer.from(JSON.stringify(featureFlagsObject)).toString('base64')
27
+ }
28
+
29
+ /**
30
+ * Takes the invocation metadata object and produces a Base64-encoded JSON
31
+ * object that the bootstrap layer can understand.
32
+ *
33
+ * @param {object} metadata
34
+ * @returns {string}
35
+ */
36
+ export const getInvocationMetadataHeader = (metadata) => Buffer.from(JSON.stringify(metadata)).toString('base64')
@@ -12,7 +12,7 @@ import { startSpinner, stopSpinner } from '../spinner.mjs'
12
12
 
13
13
  import { getBootstrapURL } from './bootstrap.mjs'
14
14
  import { DIST_IMPORT_MAP_PATH } from './consts.mjs'
15
- import headers from './headers.mjs'
15
+ import { headers, getFeatureFlagsHeader, getInvocationMetadataHeader } from './headers.mjs'
16
16
  import { getInternalFunctions } from './internal.mjs'
17
17
  import { EdgeFunctionsRegistry } from './registry.mjs'
18
18
 
@@ -109,7 +109,7 @@ export const initializeProxy = async ({
109
109
  await registry.initialize()
110
110
 
111
111
  const url = new URL(req.url, `http://${LOCAL_HOST}:${mainPort}`)
112
- const { functionNames, orphanedDeclarations } = registry.matchURLPath(url.pathname)
112
+ const { functionNames, invocationMetadata, orphanedDeclarations } = registry.matchURLPath(url.pathname)
113
113
 
114
114
  // If the request matches a config declaration for an Edge Function without
115
115
  // a matching function file, we warn the user.
@@ -129,11 +129,15 @@ export const initializeProxy = async ({
129
129
  return
130
130
  }
131
131
 
132
+ const featureFlags = ['edge_functions_bootstrap_failure_mode']
133
+
132
134
  req[headersSymbol] = {
133
- [headers.Functions]: functionNames.join(','),
135
+ [headers.FeatureFlags]: getFeatureFlagsHeader(featureFlags),
134
136
  [headers.ForwardedHost]: `localhost:${passthroughPort}`,
135
- [headers.Passthrough]: 'passthrough',
137
+ [headers.Functions]: functionNames.join(','),
138
+ [headers.InvocationMetadata]: getInvocationMetadataHeader(invocationMetadata),
136
139
  [headers.IP]: LOCAL_HOST,
140
+ [headers.Passthrough]: 'passthrough',
137
141
  }
138
142
 
139
143
  if (debug) {
@@ -268,6 +268,10 @@ export class EdgeFunctionsRegistry {
268
268
  functionConfig: this.declarationsFromSource,
269
269
  functions: this.functions,
270
270
  })
271
+ const invocationMetadata = {
272
+ function_config: manifest.function_config,
273
+ routes: manifest.routes.map((route) => ({ function: route.function, pattern: route.pattern })),
274
+ }
271
275
  const routes = [...manifest.routes, ...manifest.post_cache_routes].map((route) => ({
272
276
  ...route,
273
277
  pattern: new RegExp(route.pattern),
@@ -283,7 +287,7 @@ export class EdgeFunctionsRegistry {
283
287
  .map((route) => route.function)
284
288
  const orphanedDeclarations = this.matchURLPathAgainstOrphanedDeclarations(urlPath)
285
289
 
286
- return { functionNames, orphanedDeclarations }
290
+ return { functionNames, invocationMetadata, orphanedDeclarations }
287
291
  }
288
292
 
289
293
  matchURLPathAgainstOrphanedDeclarations(urlPath) {
@@ -1,15 +1,18 @@
1
1
  // @ts-check
2
2
  import { dirname, join } from 'path'
3
- import process from 'process'
3
+ import process, { version as nodejsVersion } from 'process'
4
4
  import { fileURLToPath } from 'url'
5
5
 
6
6
  import { isCI } from 'ci-info'
7
7
 
8
8
  import execa from '../execa.mjs'
9
9
  import getGlobalConfig from '../get-global-config.mjs'
10
+ import getPackageJson from '../get-package-json.mjs'
10
11
 
11
12
  import isValidEventName from './validation.mjs'
12
13
 
14
+ const { version: cliVersion } = await getPackageJson()
15
+
13
16
  const isTelemetryDisabled = function (config) {
14
17
  return config.get('telemetryDisabled')
15
18
  }
@@ -80,7 +83,7 @@ export const track = async function (eventName, payload = {}) {
80
83
  anonymousId: cliId,
81
84
  duration,
82
85
  status,
83
- properties,
86
+ properties: { ...properties, nodejsVersion, cliVersion },
84
87
  }
85
88
 
86
89
  return send('track', defaultData)