@netlify/config 18.2.4 → 18.2.5
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/bin.js +5 -0
- package/lib/api/build_settings.js +20 -33
- package/lib/api/client.js +10 -13
- package/lib/api/site_info.js +48 -56
- package/lib/base.js +10 -18
- package/lib/bin/flags.js +134 -142
- package/lib/bin/main.js +49 -63
- package/lib/build_dir.js +11 -15
- package/lib/cached_config.js +14 -17
- package/lib/case.js +16 -35
- package/lib/context.js +62 -84
- package/lib/default.js +18 -22
- package/lib/env/envelope.js +23 -23
- package/lib/env/git.js +18 -18
- package/lib/env/main.js +127 -179
- package/lib/error.js +19 -27
- package/lib/events.js +18 -19
- package/lib/files.js +63 -87
- package/lib/functions_config.js +36 -52
- package/lib/headers.js +17 -27
- package/lib/inline_config.js +6 -7
- package/lib/log/cleanup.js +54 -82
- package/lib/log/logger.js +25 -36
- package/lib/log/main.js +31 -40
- package/lib/log/messages.js +56 -95
- package/lib/log/options.js +24 -38
- package/lib/log/serialize.js +3 -4
- package/lib/log/theme.js +10 -11
- package/lib/main.js +188 -263
- package/lib/merge.js +25 -35
- package/lib/merge_normalize.js +17 -24
- package/lib/mutations/apply.js +53 -65
- package/lib/mutations/config_prop_name.js +6 -8
- package/lib/mutations/update.js +79 -98
- package/lib/normalize.js +24 -28
- package/lib/options/base.js +39 -51
- package/lib/options/branch.js +23 -26
- package/lib/options/feature_flags.js +7 -10
- package/lib/options/main.js +76 -96
- package/lib/options/repository_root.js +11 -16
- package/lib/origin.js +22 -29
- package/lib/parse.js +42 -55
- package/lib/path.js +29 -40
- package/lib/redirects.js +16 -26
- package/lib/simplify.js +66 -92
- package/lib/utils/group.js +5 -6
- package/lib/utils/remove_falsy.js +9 -13
- package/lib/utils/set.js +19 -25
- package/lib/utils/toml.js +13 -16
- package/lib/validate/context.js +24 -43
- package/lib/validate/example.js +20 -27
- package/lib/validate/helpers.js +17 -23
- package/lib/validate/identical.js +8 -12
- package/lib/validate/main.js +83 -127
- package/lib/validate/validations.js +243 -257
- package/package.json +13 -8
package/lib/validate/main.js
CHANGED
|
@@ -1,143 +1,99 @@
|
|
|
1
|
-
import { throwUserError } from '../error.js'
|
|
2
|
-
import { THEME } from '../log/theme.js'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
PRE_CASE_NORMALIZE_VALIDATIONS,
|
|
7
|
-
PRE_MERGE_VALIDATIONS,
|
|
8
|
-
PRE_CONTEXT_VALIDATIONS,
|
|
9
|
-
PRE_NORMALIZE_VALIDATIONS,
|
|
10
|
-
POST_NORMALIZE_VALIDATIONS,
|
|
11
|
-
} from './validations.js'
|
|
12
|
-
|
|
1
|
+
import { throwUserError } from '../error.js';
|
|
2
|
+
import { THEME } from '../log/theme.js';
|
|
3
|
+
import { getExample } from './example.js';
|
|
4
|
+
import { PRE_CASE_NORMALIZE_VALIDATIONS, PRE_MERGE_VALIDATIONS, PRE_CONTEXT_VALIDATIONS, PRE_NORMALIZE_VALIDATIONS, POST_NORMALIZE_VALIDATIONS, } from './validations.js';
|
|
13
5
|
// Validate the configuration file, before case normalization.
|
|
14
6
|
export const validatePreCaseNormalize = function (config) {
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
7
|
+
validateConfig(config, PRE_CASE_NORMALIZE_VALIDATIONS);
|
|
8
|
+
};
|
|
18
9
|
// Validate the configuration file, before `defaultConfig` merge.
|
|
19
10
|
export const validatePreMergeConfig = function (config) {
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
11
|
+
validateConfig(config, PRE_MERGE_VALIDATIONS);
|
|
12
|
+
};
|
|
23
13
|
// Validate the configuration file, before context merge.
|
|
24
14
|
export const validatePreContextConfig = function (config) {
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
15
|
+
validateConfig(config, PRE_CONTEXT_VALIDATIONS);
|
|
16
|
+
};
|
|
28
17
|
// Validate the configuration file, before normalization.
|
|
29
18
|
export const validatePreNormalizeConfig = function (config) {
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
19
|
+
validateConfig(config, PRE_NORMALIZE_VALIDATIONS);
|
|
20
|
+
};
|
|
33
21
|
// Validate the configuration file, after normalization.
|
|
34
22
|
export const validatePostNormalizeConfig = function (config) {
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
23
|
+
validateConfig(config, POST_NORMALIZE_VALIDATIONS);
|
|
24
|
+
};
|
|
38
25
|
const validateConfig = function (config, validations) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
26
|
+
try {
|
|
27
|
+
validations.forEach(({ property, ...validation }) => {
|
|
28
|
+
validateProperty(config, { ...validation, nextPath: property.split('.') });
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
throwUserError(error);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
48
35
|
// Validate a single property in the configuration file.
|
|
49
|
-
const validateProperty = function (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
example,
|
|
76
|
-
formatInvalid,
|
|
77
|
-
propertyName,
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (value === undefined || (check !== undefined && check(value, key, prevPath))) {
|
|
82
|
-
return
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
reportError({ prevPath, propPath, message, example, value, key, formatInvalid, propertyName })
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const reportError = function ({
|
|
89
|
-
prevPath,
|
|
90
|
-
propPath,
|
|
91
|
-
message,
|
|
92
|
-
example,
|
|
93
|
-
value,
|
|
94
|
-
key,
|
|
95
|
-
formatInvalid,
|
|
96
|
-
propertyName = propPath,
|
|
97
|
-
}) {
|
|
98
|
-
throwUserError(`${THEME.highlightWords('Configuration property')} ${propertyName} ${message}
|
|
99
|
-
${getExample({ value, key, prevPath, example, formatInvalid })}`)
|
|
100
|
-
}
|
|
101
|
-
|
|
36
|
+
const validateProperty = function (parent, { nextPath: [propName, nextPropName, ...nextPath], prevPath = [propName], propPath = propName, key = propName, check, message, example, formatInvalid, propertyName, }) {
|
|
37
|
+
const value = parent[propName];
|
|
38
|
+
if (nextPropName !== undefined) {
|
|
39
|
+
return validateChild({
|
|
40
|
+
value,
|
|
41
|
+
nextPropName,
|
|
42
|
+
prevPath,
|
|
43
|
+
nextPath,
|
|
44
|
+
propPath,
|
|
45
|
+
key,
|
|
46
|
+
check,
|
|
47
|
+
message,
|
|
48
|
+
example,
|
|
49
|
+
formatInvalid,
|
|
50
|
+
propertyName,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (value === undefined || (check !== undefined && check(value, key, prevPath))) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
reportError({ prevPath, propPath, message, example, value, key, formatInvalid, propertyName });
|
|
57
|
+
};
|
|
58
|
+
const reportError = function ({ prevPath, propPath, message, example, value, key, formatInvalid, propertyName = propPath, }) {
|
|
59
|
+
throwUserError(`${THEME.highlightWords('Configuration property')} ${propertyName} ${message}
|
|
60
|
+
${getExample({ value, key, prevPath, example, formatInvalid })}`);
|
|
61
|
+
};
|
|
102
62
|
// Recurse over children (each part of the `property` array).
|
|
103
63
|
const validateChild = function ({ value, nextPropName, prevPath, nextPath, propPath, ...rest }) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
})
|
|
121
|
-
}
|
|
122
|
-
|
|
64
|
+
if (value === undefined) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (nextPropName !== '*') {
|
|
68
|
+
return validateProperty(value, {
|
|
69
|
+
...rest,
|
|
70
|
+
prevPath: [...prevPath, nextPropName],
|
|
71
|
+
nextPath: [nextPropName, ...nextPath],
|
|
72
|
+
propPath: `${propPath}.${nextPropName}`,
|
|
73
|
+
key: nextPropName,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return Object.keys(value).forEach((childProp) => {
|
|
77
|
+
validateChildProp({ childProp, value, nextPath, propPath, prevPath, ...rest });
|
|
78
|
+
});
|
|
79
|
+
};
|
|
123
80
|
// Can use * to recurse over array|object elements.
|
|
124
81
|
const validateChildProp = function ({ childProp, value, nextPath, propPath, prevPath, ...rest }) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
82
|
+
if (Array.isArray(value)) {
|
|
83
|
+
const key = Number(childProp);
|
|
84
|
+
return validateProperty(value, {
|
|
85
|
+
...rest,
|
|
86
|
+
prevPath: [...prevPath, key],
|
|
87
|
+
nextPath: [key, ...nextPath],
|
|
88
|
+
propPath: `${propPath}[${childProp}]`,
|
|
89
|
+
key,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
validateProperty(value, {
|
|
93
|
+
...rest,
|
|
94
|
+
prevPath: [...prevPath, childProp],
|
|
95
|
+
nextPath: [childProp, ...nextPath],
|
|
96
|
+
propPath: `${propPath}.${childProp}`,
|
|
97
|
+
key: childProp,
|
|
98
|
+
});
|
|
99
|
+
};
|