@netlify/config 20.8.0-rc.0 → 20.8.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/lib/base.js +1 -1
- package/lib/edge_functions.js +9 -1
- package/lib/files.js +5 -12
- package/lib/path.js +3 -1
- package/package.json +4 -3
package/lib/base.js
CHANGED
|
@@ -3,7 +3,7 @@ import { resolvePath } from './files.js';
|
|
|
3
3
|
* Retrieve the first `base` directory used to load the first config file.
|
|
4
4
|
*/
|
|
5
5
|
export const getInitialBase = function ({ repositoryRoot,
|
|
6
|
-
// @ts-expect-error TODO: enhance later
|
|
6
|
+
// @ts-expect-error TODO: enhance the types later on, just moved the file to .ts
|
|
7
7
|
defaultConfig: { build: { base: defaultBase } = {} }, inlineConfig: { build: { base: initialBase = defaultBase } = {} }, }) {
|
|
8
8
|
return resolveBase(repositoryRoot, initialBase);
|
|
9
9
|
};
|
package/lib/edge_functions.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { isString, validProperties } from './validate/helpers.js';
|
|
2
2
|
const cacheValues = ['manual', 'off'];
|
|
3
|
+
const methodValues = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'];
|
|
4
|
+
const isMethod = (value) => typeof value === 'string' && methodValues.includes(value.toUpperCase());
|
|
3
5
|
export const validations = [
|
|
4
6
|
{
|
|
5
7
|
property: 'edge_functions.*',
|
|
6
|
-
...validProperties(['path', 'excludedPath', 'pattern', 'excludedPattern', 'function', 'cache'], []),
|
|
8
|
+
...validProperties(['path', 'excludedPath', 'pattern', 'excludedPattern', 'function', 'cache', 'method'], []),
|
|
7
9
|
example: () => ({ edge_functions: [{ path: '/hello', function: 'hello' }] }),
|
|
8
10
|
},
|
|
9
11
|
{
|
|
@@ -76,4 +78,10 @@ export const validations = [
|
|
|
76
78
|
message: `must be one of: ${cacheValues.join(', ')}`,
|
|
77
79
|
example: () => ({ edge_functions: [{ cache: cacheValues[0], path: '/hello', function: 'hello' }] }),
|
|
78
80
|
},
|
|
81
|
+
{
|
|
82
|
+
property: 'edge_functions.*.method',
|
|
83
|
+
check: (value) => isMethod(value) || (Array.isArray(value) && value.length !== 0 && value.every(isMethod)),
|
|
84
|
+
message: `must be one of or array of: ${methodValues.join(', ')}`,
|
|
85
|
+
example: () => ({ edge_functions: [{ method: ['PUT', 'DELETE'], path: '/hello', function: 'hello' }] }),
|
|
86
|
+
},
|
|
79
87
|
];
|
package/lib/files.js
CHANGED
|
@@ -27,7 +27,6 @@ export const resolveConfigPaths = function (options) {
|
|
|
27
27
|
const baseRel = options.baseRelDir ? options.buildDir : options.repositoryRoot;
|
|
28
28
|
const config = resolvePaths({
|
|
29
29
|
config: options.config,
|
|
30
|
-
packagePath: options.packagePath,
|
|
31
30
|
propNames: FILE_PATH_CONFIG_PROPS,
|
|
32
31
|
baseRel,
|
|
33
32
|
repositoryRoot: options.repositoryRoot,
|
|
@@ -39,28 +38,22 @@ export const resolveConfigPaths = function (options) {
|
|
|
39
38
|
packagePath: options.packagePath,
|
|
40
39
|
});
|
|
41
40
|
};
|
|
42
|
-
const resolvePaths = function ({ config, propNames, baseRel,
|
|
43
|
-
return propNames.reduce((configA, propName) => resolvePathProp(configA, propName, baseRel, repositoryRoot
|
|
41
|
+
const resolvePaths = function ({ config, propNames, baseRel, repositoryRoot, }) {
|
|
42
|
+
return propNames.reduce((configA, propName) => resolvePathProp(configA, propName, baseRel, repositoryRoot), config);
|
|
44
43
|
};
|
|
45
|
-
const resolvePathProp = function (config, propName, baseRel, repositoryRoot
|
|
44
|
+
const resolvePathProp = function (config, propName, baseRel, repositoryRoot) {
|
|
46
45
|
const path = getProperty(config, propName);
|
|
47
46
|
if (!isTruthy(path)) {
|
|
48
47
|
deleteProperty(config, propName);
|
|
49
48
|
return config;
|
|
50
49
|
}
|
|
51
|
-
return setProperty(config, propName, resolvePath(repositoryRoot, baseRel, path, propName
|
|
50
|
+
return setProperty(config, propName, resolvePath(repositoryRoot, baseRel, path, propName));
|
|
52
51
|
};
|
|
53
|
-
export const resolvePath = (repositoryRoot, baseRel, originalPath, propName
|
|
54
|
-
// @ts-expect-error depends on the survey outcome see comment below
|
|
55
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
56
|
-
packagePath) => {
|
|
52
|
+
export const resolvePath = (repositoryRoot, baseRel, originalPath, propName) => {
|
|
57
53
|
if (!isTruthy(originalPath)) {
|
|
58
54
|
return;
|
|
59
55
|
}
|
|
60
56
|
const path = originalPath.replace(LEADING_SLASH_REGEXP, '');
|
|
61
|
-
// TODO: Based on survey outcome: https://netlify.slack.com/archives/C05556LEX28/p1691423437855069
|
|
62
|
-
// If we like option B then:
|
|
63
|
-
// const pathA = resolve(baseRel, packagePath || '', path)
|
|
64
57
|
const pathA = resolve(baseRel, path);
|
|
65
58
|
validateInsideRoot(originalPath, pathA, repositoryRoot, propName);
|
|
66
59
|
return pathA;
|
package/lib/path.js
CHANGED
|
@@ -6,6 +6,7 @@ const FILENAME = 'netlify.toml';
|
|
|
6
6
|
/**
|
|
7
7
|
* Configuration location can be:
|
|
8
8
|
* - a local path with the --config CLI flag
|
|
9
|
+
* - a `netlify.*` file in the `repositoryRoot/{base}/{packagePath}`
|
|
9
10
|
* - a `netlify.*` file in the `repositoryRoot/{base}`
|
|
10
11
|
* - a `netlify.*` file in the `repositoryRoot`
|
|
11
12
|
* - a `netlify.*` file in the current directory or any parent
|
|
@@ -33,7 +34,8 @@ const searchBaseConfigFile = function (repoRoot, base, packagePath) {
|
|
|
33
34
|
if (base === undefined && packagePath === undefined) {
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
+
const cwd = join(base ? base : repoRoot, packagePath || '');
|
|
38
|
+
return searchConfigFile(cwd);
|
|
37
39
|
};
|
|
38
40
|
/**
|
|
39
41
|
* Look for several file extensions for `netlify.*`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/config",
|
|
3
|
-
"version": "20.8.
|
|
3
|
+
"version": "20.8.1",
|
|
4
4
|
"description": "Netlify config module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"map-obj": "^5.0.0",
|
|
73
73
|
"netlify": "^13.1.10",
|
|
74
74
|
"netlify-headers-parser": "^7.1.2",
|
|
75
|
+
"netlify-redirect-parser": "^14.2.0",
|
|
75
76
|
"node-fetch": "^3.3.1",
|
|
76
|
-
"netlify-redirect-parser": "^14.1.3",
|
|
77
77
|
"omit.js": "^2.0.2",
|
|
78
78
|
"p-locate": "^6.0.0",
|
|
79
79
|
"path-type": "^5.0.0",
|
|
@@ -93,5 +93,6 @@
|
|
|
93
93
|
},
|
|
94
94
|
"engines": {
|
|
95
95
|
"node": "^14.16.0 || >=16.0.0"
|
|
96
|
-
}
|
|
96
|
+
},
|
|
97
|
+
"gitHead": "0eb6dbbfd00ba11941b1ef638811eded8a030a17"
|
|
97
98
|
}
|