@netlify/config 17.0.19 → 18.0.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/config",
3
- "version": "17.0.19",
3
+ "version": "18.0.1",
4
4
  "description": "Netlify config module",
5
5
  "type": "module",
6
6
  "exports": "./src/main.js",
@@ -73,7 +73,7 @@
73
73
  "path-type": "^5.0.0",
74
74
  "toml": "^3.0.0",
75
75
  "tomlify-j0.4": "^3.0.0",
76
- "validate-npm-package-name": "^3.0.0",
76
+ "validate-npm-package-name": "^4.0.0",
77
77
  "yargs": "^17.3.1"
78
78
  },
79
79
  "devDependencies": {
package/src/case.js CHANGED
@@ -9,8 +9,8 @@ const normalizeBuildCase = function ({
9
9
  base = Base,
10
10
  Command,
11
11
  command = Command,
12
- Edge_handlers: EdgeHandlers,
13
- edge_handlers: edgeHandlers = EdgeHandlers,
12
+ Edge_functions: EdgeFunctions,
13
+ edge_functions: edgeFunctions = EdgeFunctions,
14
14
  Environment,
15
15
  environment = Environment,
16
16
  Functions,
@@ -27,7 +27,7 @@ const normalizeBuildCase = function ({
27
27
  ...build,
28
28
  base,
29
29
  command,
30
- edge_handlers: edgeHandlers,
30
+ edge_functions: edgeFunctions,
31
31
  environment,
32
32
  functions,
33
33
  ignore,
package/src/context.js CHANGED
@@ -54,14 +54,14 @@ const addNamespacedProperty = function (contextConfig, [key, value]) {
54
54
  }
55
55
 
56
56
  const isBuildProperty = function (key, value) {
57
- return BUILD_PROPERTIES.has(key) && !isFunctionsConfig(key, value) && !isEdgeHandlersConfig(key, value)
57
+ return BUILD_PROPERTIES.has(key) && !isFunctionsConfig(key, value) && !isEdgeFunctionsConfig(key, value)
58
58
  }
59
59
 
60
60
  // All properties in `config.build.*`
61
61
  const BUILD_PROPERTIES = new Set([
62
62
  'base',
63
63
  'command',
64
- 'edge_handlers',
64
+ 'edge_functions',
65
65
  'environment',
66
66
  'functions',
67
67
  'ignore',
@@ -75,10 +75,10 @@ const isFunctionsConfig = function (key, value) {
75
75
  return key === 'functions' && isPlainObj(value)
76
76
  }
77
77
 
78
- // `config.edge_handlers` is an array of objects while
79
- // `config.build.edge_handlers` is a string.
80
- const isEdgeHandlersConfig = function (key, value) {
81
- return key === 'edge_handlers' && Array.isArray(value)
78
+ // `config.edge_functions` is an array of objects while
79
+ // `config.build.edge_functions` is a string.
80
+ const isEdgeFunctionsConfig = function (key, value) {
81
+ return key === 'edge_functions' && Array.isArray(value)
82
82
  }
83
83
 
84
84
  // Ensure that `inlineConfig` has higher priority than context properties by
package/src/files.js CHANGED
@@ -18,7 +18,7 @@ export const resolveConfigPaths = async function ({ config, repositoryRoot, buil
18
18
 
19
19
  // All file paths in the configuration file are are relative to `buildDir`
20
20
  // (if `baseRelDir` is `true`).
21
- const FILE_PATH_CONFIG_PROPS = ['functionsDirectory', 'build.publish', 'build.edge_handlers']
21
+ const FILE_PATH_CONFIG_PROPS = ['functionsDirectory', 'build.publish', 'build.edge_functions']
22
22
 
23
23
  const resolvePaths = function (config, propNames, baseRel, repositoryRoot) {
24
24
  return propNames.reduce((configA, propName) => resolvePathProp(configA, propName, baseRel, repositoryRoot), config)
@@ -90,9 +90,9 @@ const DEFAULT_PATHS = [
90
90
  propName: 'functions.directory',
91
91
  },
92
92
  {
93
- getConfig: (directory) => ({ build: { edge_handlers: directory } }),
94
- defaultPath: 'netlify/edge-handlers',
95
- propName: 'build.edge_handlers',
93
+ getConfig: (directory) => ({ build: { edge_functions: directory } }),
94
+ defaultPath: 'netlify/edge-functions',
95
+ propName: 'build.edge_functions',
96
96
  },
97
97
  ]
98
98
 
@@ -9,7 +9,7 @@ export const cleanupConfig = function ({
9
9
  command,
10
10
  commandOrigin,
11
11
  environment = {},
12
- edge_handlers: edgeHandlers,
12
+ edge_functions: edgeFunctions,
13
13
  ignore,
14
14
  processing,
15
15
  publish,
@@ -30,7 +30,7 @@ export const cleanupConfig = function ({
30
30
  command,
31
31
  commandOrigin,
32
32
  environment: environmentA,
33
- edge_handlers: edgeHandlers,
33
+ edge_functions: edgeFunctions,
34
34
  ignore,
35
35
  processing,
36
36
  publish,
@@ -51,7 +51,7 @@ const denormalizeFunctionsTopProps = function (
51
51
  // List of properties that are not read-only.
52
52
  const MUTABLE_PROPS = {
53
53
  'build.command': { lastEvent: 'onPreBuild' },
54
- 'build.edge_handlers': { lastEvent: 'onPostBuild' },
54
+ 'build.edge_functions': { lastEvent: 'onPostBuild' },
55
55
  'build.environment': { lastEvent: 'onPostBuild' },
56
56
  'build.environment.*': { lastEvent: 'onPostBuild' },
57
57
  'build.functions': { lastEvent: 'onBuild' },
@@ -70,7 +70,7 @@ const MUTABLE_PROPS = {
70
70
  'build.publish': { lastEvent: 'onPostBuild' },
71
71
  'build.services': { lastEvent: 'onPostBuild' },
72
72
  'build.services.*': { lastEvent: 'onPostBuild' },
73
- edge_handlers: { lastEvent: 'onPostBuild' },
73
+ edge_functions: { lastEvent: 'onPostBuild' },
74
74
  'functions.*': { lastEvent: 'onBuild', denormalize: denormalizeFunctionsTopProps },
75
75
  'functions.*.*': { lastEvent: 'onBuild' },
76
76
  headers: { lastEvent: 'onPostBuild' },
@@ -26,7 +26,7 @@ export const getBaseOverride = async function ({ repositoryRoot, cwd }) {
26
26
  // return an absolute path
27
27
  const base = relative(repositoryRoot, dirname(basePath))
28
28
  // When `base` is explicitely overridden, `baseRelDir: true` makes more sense
29
- // since we want `publish`, `functions` and `edge_handlers` to be relative to it.
29
+ // since we want `publish`, `functions` and `edge_functions` to be relative to it.
30
30
  return { base, baseRelDir: true }
31
31
  }
32
32
 
@@ -102,6 +102,17 @@ export const PRE_NORMALIZE_VALIDATIONS = [
102
102
  functions: { ignored_node_modules: ['module-one', 'module-two'] },
103
103
  }),
104
104
  },
105
+ {
106
+ property: 'edge_functions',
107
+ check: isArrayOfObjects,
108
+ message: 'must be an array of objects.',
109
+ example: () => ({
110
+ edge_functions: [
111
+ { path: '/hello', function: 'hello' },
112
+ { path: '/auth', function: 'auth' },
113
+ ],
114
+ }),
115
+ },
105
116
  ]
106
117
 
107
118
  const EXAMPLE_PORT = 80
@@ -172,10 +183,10 @@ export const POST_NORMALIZE_VALIDATIONS = [
172
183
  example: () => ({ build: { functions: 'functions' } }),
173
184
  },
174
185
  {
175
- property: 'build.edge_handlers',
186
+ property: 'build.edge_functions',
176
187
  check: isString,
177
188
  message: 'must be a string.',
178
- example: () => ({ build: { edge_handlers: 'edge-handlers' } }),
189
+ example: () => ({ build: { edge_functions: 'edge-functions' } }),
179
190
  },
180
191
  {
181
192
  property: 'functions.*',
@@ -242,5 +253,40 @@ export const POST_NORMALIZE_VALIDATIONS = [
242
253
  functions: { directory: 'my-functions' },
243
254
  }),
244
255
  },
256
+ {
257
+ property: 'edge_functions.*',
258
+ ...validProperties(['path', 'function'], []),
259
+ example: () => ({ edge_functions: [{ path: '/hello', function: 'hello' }] }),
260
+ },
261
+ {
262
+ property: 'edge_functions.*',
263
+ check: (edgeFunction) => edgeFunction.path !== undefined,
264
+ message: '"path" property is required.',
265
+ example: () => ({ edge_functions: [{ path: '/hello', function: 'hello' }] }),
266
+ },
267
+ {
268
+ property: 'edge_functions.*',
269
+ check: (edgeFunction) => edgeFunction.function !== undefined,
270
+ message: '"function" property is required.',
271
+ example: () => ({ edge_functions: [{ path: '/hello', function: 'hello' }] }),
272
+ },
273
+ {
274
+ property: 'edge_functions.*.path',
275
+ check: isString,
276
+ message: 'must be a string.',
277
+ example: () => ({ edge_functions: [{ path: '/hello', function: 'hello' }] }),
278
+ },
279
+ {
280
+ property: 'edge_functions.*.function',
281
+ check: isString,
282
+ message: 'must be a string.',
283
+ example: () => ({ edge_functions: [{ path: '/hello', function: 'hello' }] }),
284
+ },
285
+ {
286
+ property: 'edge_functions.*.path',
287
+ check: (pathName) => pathName.startsWith('/'),
288
+ message: 'must be a valid path.',
289
+ example: () => ({ edge_functions: [{ path: '/hello', function: 'hello' }] }),
290
+ },
245
291
  ]
246
292
  /* eslint-enable max-lines */