@netlify/config 17.0.20 → 18.0.2
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 +2 -2
- package/src/case.js +3 -3
- package/src/context.js +6 -6
- package/src/files.js +4 -4
- package/src/log/cleanup.js +2 -2
- package/src/mutations/apply.js +2 -2
- package/src/options/base.js +1 -1
- package/src/validate/validations.js +48 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.2",
|
|
4
4
|
"description": "Netlify config module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./src/main.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"is-plain-obj": "^4.0.0",
|
|
65
65
|
"js-yaml": "^4.0.0",
|
|
66
66
|
"map-obj": "^5.0.0",
|
|
67
|
-
"netlify": "^11.0.
|
|
67
|
+
"netlify": "^11.0.2",
|
|
68
68
|
"netlify-headers-parser": "^6.0.2",
|
|
69
69
|
"netlify-redirect-parser": "13.0.5",
|
|
70
70
|
"omit.js": "^2.0.2",
|
package/src/case.js
CHANGED
|
@@ -9,8 +9,8 @@ const normalizeBuildCase = function ({
|
|
|
9
9
|
base = Base,
|
|
10
10
|
Command,
|
|
11
11
|
command = Command,
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
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) && !
|
|
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
|
-
'
|
|
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.
|
|
79
|
-
// `config.build.
|
|
80
|
-
const
|
|
81
|
-
return key === '
|
|
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.
|
|
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: {
|
|
94
|
-
defaultPath: 'netlify/edge-
|
|
95
|
-
propName: 'build.
|
|
93
|
+
getConfig: (directory) => ({ build: { edge_functions: directory } }),
|
|
94
|
+
defaultPath: 'netlify/edge-functions',
|
|
95
|
+
propName: 'build.edge_functions',
|
|
96
96
|
},
|
|
97
97
|
]
|
|
98
98
|
|
package/src/log/cleanup.js
CHANGED
|
@@ -9,7 +9,7 @@ export const cleanupConfig = function ({
|
|
|
9
9
|
command,
|
|
10
10
|
commandOrigin,
|
|
11
11
|
environment = {},
|
|
12
|
-
|
|
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
|
-
|
|
33
|
+
edge_functions: edgeFunctions,
|
|
34
34
|
ignore,
|
|
35
35
|
processing,
|
|
36
36
|
publish,
|
package/src/mutations/apply.js
CHANGED
|
@@ -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.
|
|
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
|
-
|
|
73
|
+
edge_functions: { lastEvent: 'onPostBuild' },
|
|
74
74
|
'functions.*': { lastEvent: 'onBuild', denormalize: denormalizeFunctionsTopProps },
|
|
75
75
|
'functions.*.*': { lastEvent: 'onBuild' },
|
|
76
76
|
headers: { lastEvent: 'onPostBuild' },
|
package/src/options/base.js
CHANGED
|
@@ -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 `
|
|
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.
|
|
186
|
+
property: 'build.edge_functions',
|
|
176
187
|
check: isString,
|
|
177
188
|
message: 'must be a string.',
|
|
178
|
-
example: () => ({ build: {
|
|
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 */
|