@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.
Files changed (56) hide show
  1. package/bin.js +5 -0
  2. package/lib/api/build_settings.js +20 -33
  3. package/lib/api/client.js +10 -13
  4. package/lib/api/site_info.js +48 -56
  5. package/lib/base.js +10 -18
  6. package/lib/bin/flags.js +134 -142
  7. package/lib/bin/main.js +49 -63
  8. package/lib/build_dir.js +11 -15
  9. package/lib/cached_config.js +14 -17
  10. package/lib/case.js +16 -35
  11. package/lib/context.js +62 -84
  12. package/lib/default.js +18 -22
  13. package/lib/env/envelope.js +23 -23
  14. package/lib/env/git.js +18 -18
  15. package/lib/env/main.js +127 -179
  16. package/lib/error.js +19 -27
  17. package/lib/events.js +18 -19
  18. package/lib/files.js +63 -87
  19. package/lib/functions_config.js +36 -52
  20. package/lib/headers.js +17 -27
  21. package/lib/inline_config.js +6 -7
  22. package/lib/log/cleanup.js +54 -82
  23. package/lib/log/logger.js +25 -36
  24. package/lib/log/main.js +31 -40
  25. package/lib/log/messages.js +56 -95
  26. package/lib/log/options.js +24 -38
  27. package/lib/log/serialize.js +3 -4
  28. package/lib/log/theme.js +10 -11
  29. package/lib/main.js +188 -263
  30. package/lib/merge.js +25 -35
  31. package/lib/merge_normalize.js +17 -24
  32. package/lib/mutations/apply.js +53 -65
  33. package/lib/mutations/config_prop_name.js +6 -8
  34. package/lib/mutations/update.js +79 -98
  35. package/lib/normalize.js +24 -28
  36. package/lib/options/base.js +39 -51
  37. package/lib/options/branch.js +23 -26
  38. package/lib/options/feature_flags.js +7 -10
  39. package/lib/options/main.js +76 -96
  40. package/lib/options/repository_root.js +11 -16
  41. package/lib/origin.js +22 -29
  42. package/lib/parse.js +42 -55
  43. package/lib/path.js +29 -40
  44. package/lib/redirects.js +16 -26
  45. package/lib/simplify.js +66 -92
  46. package/lib/utils/group.js +5 -6
  47. package/lib/utils/remove_falsy.js +9 -13
  48. package/lib/utils/set.js +19 -25
  49. package/lib/utils/toml.js +13 -16
  50. package/lib/validate/context.js +24 -43
  51. package/lib/validate/example.js +20 -27
  52. package/lib/validate/helpers.js +17 -23
  53. package/lib/validate/identical.js +8 -12
  54. package/lib/validate/main.js +83 -127
  55. package/lib/validate/validations.js +243 -257
  56. package/package.json +13 -8
@@ -1,143 +1,99 @@
1
- import { throwUserError } from '../error.js'
2
- import { THEME } from '../log/theme.js'
3
-
4
- import { getExample } from './example.js'
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
- validateConfig(config, PRE_CASE_NORMALIZE_VALIDATIONS)
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
- validateConfig(config, PRE_MERGE_VALIDATIONS)
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
- validateConfig(config, PRE_CONTEXT_VALIDATIONS)
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
- validateConfig(config, PRE_NORMALIZE_VALIDATIONS)
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
- validateConfig(config, POST_NORMALIZE_VALIDATIONS)
36
- }
37
-
23
+ validateConfig(config, POST_NORMALIZE_VALIDATIONS);
24
+ };
38
25
  const validateConfig = function (config, validations) {
39
- try {
40
- validations.forEach(({ property, ...validation }) => {
41
- validateProperty(config, { ...validation, nextPath: property.split('.') })
42
- })
43
- } catch (error) {
44
- throwUserError(error)
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
- parent,
51
- {
52
- nextPath: [propName, nextPropName, ...nextPath],
53
- prevPath = [propName],
54
- propPath = propName,
55
- key = propName,
56
- check,
57
- message,
58
- example,
59
- formatInvalid,
60
- propertyName,
61
- },
62
- ) {
63
- const value = parent[propName]
64
-
65
- if (nextPropName !== undefined) {
66
- return validateChild({
67
- value,
68
- nextPropName,
69
- prevPath,
70
- nextPath,
71
- propPath,
72
- key,
73
- check,
74
- message,
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
- if (value === undefined) {
105
- return
106
- }
107
-
108
- if (nextPropName !== '*') {
109
- return validateProperty(value, {
110
- ...rest,
111
- prevPath: [...prevPath, nextPropName],
112
- nextPath: [nextPropName, ...nextPath],
113
- propPath: `${propPath}.${nextPropName}`,
114
- key: nextPropName,
115
- })
116
- }
117
-
118
- return Object.keys(value).forEach((childProp) => {
119
- validateChildProp({ childProp, value, nextPath, propPath, prevPath, ...rest })
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
- if (Array.isArray(value)) {
126
- const key = Number(childProp)
127
- return validateProperty(value, {
128
- ...rest,
129
- prevPath: [...prevPath, key],
130
- nextPath: [key, ...nextPath],
131
- propPath: `${propPath}[${childProp}]`,
132
- key,
133
- })
134
- }
135
-
136
- validateProperty(value, {
137
- ...rest,
138
- prevPath: [...prevPath, childProp],
139
- nextPath: [childProp, ...nextPath],
140
- propPath: `${propPath}.${childProp}`,
141
- key: childProp,
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
+ };