@netlify/config 18.2.2 → 18.2.4-rc

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 (55) hide show
  1. package/package.json +8 -7
  2. package/src/api/build_settings.js +0 -41
  3. package/src/api/client.js +0 -15
  4. package/src/api/site_info.js +0 -67
  5. package/src/base.js +0 -34
  6. package/src/bin/flags.js +0 -181
  7. package/src/bin/main.js +0 -73
  8. package/src/build_dir.js +0 -26
  9. package/src/cached_config.js +0 -29
  10. package/src/case.js +0 -37
  11. package/src/context.js +0 -108
  12. package/src/default.js +0 -31
  13. package/src/env/envelope.js +0 -24
  14. package/src/env/git.js +0 -23
  15. package/src/env/main.js +0 -202
  16. package/src/error.js +0 -36
  17. package/src/events.js +0 -22
  18. package/src/files.js +0 -107
  19. package/src/functions_config.js +0 -83
  20. package/src/headers.js +0 -30
  21. package/src/inline_config.js +0 -9
  22. package/src/log/cleanup.js +0 -92
  23. package/src/log/logger.js +0 -47
  24. package/src/log/main.js +0 -48
  25. package/src/log/messages.js +0 -126
  26. package/src/log/options.js +0 -43
  27. package/src/log/serialize.js +0 -5
  28. package/src/log/theme.js +0 -14
  29. package/src/main.js +0 -285
  30. package/src/merge.js +0 -53
  31. package/src/merge_normalize.js +0 -31
  32. package/src/mutations/apply.js +0 -78
  33. package/src/mutations/config_prop_name.js +0 -16
  34. package/src/mutations/update.js +0 -117
  35. package/src/normalize.js +0 -36
  36. package/src/options/base.js +0 -66
  37. package/src/options/branch.js +0 -34
  38. package/src/options/feature_flags.js +0 -15
  39. package/src/options/main.js +0 -111
  40. package/src/options/repository_root.js +0 -21
  41. package/src/origin.js +0 -38
  42. package/src/parse.js +0 -69
  43. package/src/path.js +0 -52
  44. package/src/redirects.js +0 -29
  45. package/src/simplify.js +0 -103
  46. package/src/utils/group.js +0 -10
  47. package/src/utils/remove_falsy.js +0 -18
  48. package/src/utils/set.js +0 -33
  49. package/src/utils/toml.js +0 -23
  50. package/src/validate/context.js +0 -57
  51. package/src/validate/example.js +0 -37
  52. package/src/validate/helpers.js +0 -31
  53. package/src/validate/identical.js +0 -20
  54. package/src/validate/main.js +0 -143
  55. package/src/validate/validations.js +0 -289
@@ -1,289 +0,0 @@
1
- import CronParser from 'cron-parser'
2
- import isPlainObj from 'is-plain-obj'
3
- import validateNpmPackageName from 'validate-npm-package-name'
4
-
5
- import { bundlers, WILDCARD_ALL as FUNCTIONS_CONFIG_WILDCARD_ALL } from '../functions_config.js'
6
-
7
- import { functionsDirectoryCheck, isArrayOfObjects, isArrayOfStrings, isString, validProperties } from './helpers.js'
8
-
9
- /**
10
- * @param {string} cron
11
- * @returns {boolean}
12
- */
13
- const isValidCronExpression = (cron) => {
14
- try {
15
- CronParser.parseExpression(cron)
16
- return true
17
- } catch {
18
- return false
19
- }
20
- }
21
-
22
- // List of validations performed on the configuration file.
23
- // Validation are performed in order: parent should be before children.
24
- // Each validation is an object with the following properties:
25
- // - `property` {string}: dot-delimited path to the property.
26
- // Can contain `*` providing a previous check validates the parent is an
27
- // object or an array.
28
- // - `propertyName` {string}: human-friendly property name; overrides the
29
- // value of `property` when displaying an error message
30
- // - `check` {(value, key, prevPath) => boolean}: validation check function
31
- // - `message` {string}: error message
32
- // - `example` {string}: example of correct code
33
- // - `formatInvalid` {(object) => object}: formats the invalid value when
34
- // displaying an error message
35
- // We use this instead of JSON schema (or others) to get nicer error messages.
36
-
37
- // Validations done before case normalization
38
- export const PRE_CASE_NORMALIZE_VALIDATIONS = [
39
- {
40
- property: 'build',
41
- check: isPlainObj,
42
- message: 'must be a plain object.',
43
- example: () => ({ build: { command: 'npm run build' } }),
44
- },
45
- ]
46
-
47
- // Properties with an `origin` property need to be validated twice:
48
- // - Before the `origin` property is added
49
- // - After `context.*` is merged, since they might contain that property
50
- const ORIGIN_VALIDATIONS = [
51
- {
52
- property: 'build.command',
53
- check: isString,
54
- message: 'must be a string',
55
- example: () => ({ build: { command: 'npm run build' } }),
56
- },
57
- {
58
- property: 'plugins',
59
- check: isArrayOfObjects,
60
- message: 'must be an array of objects.',
61
- example: () => ({ plugins: [{ package: 'netlify-plugin-one' }, { package: 'netlify-plugin-two' }] }),
62
- },
63
- ]
64
-
65
- // Validations done before `defaultConfig` merge
66
- export const PRE_MERGE_VALIDATIONS = [...ORIGIN_VALIDATIONS]
67
-
68
- // Validations done before context merge
69
- export const PRE_CONTEXT_VALIDATIONS = [
70
- {
71
- property: 'context',
72
- check: isPlainObj,
73
- message: 'must be a plain object.',
74
- example: () => ({ context: { production: { publish: 'dist' } } }),
75
- },
76
- {
77
- property: 'context.*',
78
- check: isPlainObj,
79
- message: 'must be a plain object.',
80
- example: (contextProps, key) => ({ context: { [key]: { publish: 'dist' } } }),
81
- },
82
- ]
83
-
84
- // Validations done before normalization
85
- export const PRE_NORMALIZE_VALIDATIONS = [
86
- ...ORIGIN_VALIDATIONS,
87
- {
88
- property: 'functions',
89
- check: isPlainObj,
90
- message: 'must be an object.',
91
- example: () => ({
92
- functions: { external_node_modules: ['module-one', 'module-two'] },
93
- }),
94
- },
95
- {
96
- property: 'functions',
97
- check: isPlainObj,
98
- message: 'must be an object.',
99
- example: () => ({
100
- functions: { ignored_node_modules: ['module-one', 'module-two'] },
101
- }),
102
- },
103
- {
104
- property: 'edge_functions',
105
- check: isArrayOfObjects,
106
- message: 'must be an array of objects.',
107
- example: () => ({
108
- edge_functions: [
109
- { path: '/hello', function: 'hello' },
110
- { path: '/auth', function: 'auth' },
111
- ],
112
- }),
113
- },
114
- ]
115
-
116
- const EXAMPLE_PORT = 80
117
-
118
- // Validations done after normalization
119
- export const POST_NORMALIZE_VALIDATIONS = [
120
- {
121
- property: 'plugins.*',
122
- ...validProperties(['package', 'pinned_version', 'inputs'], ['origin']),
123
- example: { plugins: [{ package: 'netlify-plugin-one', inputs: { port: EXAMPLE_PORT } }] },
124
- },
125
-
126
- {
127
- property: 'plugins.*',
128
- check: (plugin) => plugin.package !== undefined,
129
- message: '"package" property is required.',
130
- example: () => ({ plugins: [{ package: 'netlify-plugin-one' }] }),
131
- },
132
-
133
- {
134
- property: 'plugins.*.package',
135
- check: isString,
136
- message: 'must be a string.',
137
- example: () => ({ plugins: [{ package: 'netlify-plugin-one' }] }),
138
- },
139
- // We don't allow `package@tag|version` nor `git:...`, `github:...`,
140
- // `https://...`, etc.
141
- // We skip this validation for local plugins.
142
- // We ensure @scope/plugin still work.
143
- {
144
- property: 'plugins.*.package',
145
- check: (packageName) =>
146
- packageName.startsWith('.') ||
147
- packageName.startsWith('/') ||
148
- validateNpmPackageName(packageName).validForOldPackages,
149
- message: 'must be a npm package name only.',
150
- example: () => ({ plugins: [{ package: 'netlify-plugin-one' }] }),
151
- },
152
-
153
- {
154
- property: 'plugins.*.pinned_version',
155
- check: isString,
156
- message: 'must be a string.',
157
- example: () => ({ plugins: [{ package: 'netlify-plugin-one', pinned_version: '1' }] }),
158
- },
159
- {
160
- property: 'plugins.*.inputs',
161
- check: isPlainObj,
162
- message: 'must be a plain object.',
163
- example: () => ({ plugins: [{ package: 'netlify-plugin-one', inputs: { port: EXAMPLE_PORT } }] }),
164
- },
165
- {
166
- property: 'build.base',
167
- check: isString,
168
- message: 'must be a string.',
169
- example: () => ({ build: { base: 'packages/project' } }),
170
- },
171
- {
172
- property: 'build.publish',
173
- check: isString,
174
- message: 'must be a string.',
175
- example: () => ({ build: { publish: 'dist' } }),
176
- },
177
- {
178
- property: 'build.functions',
179
- check: isString,
180
- message: 'must be a string.',
181
- example: () => ({ build: { functions: 'functions' } }),
182
- },
183
- {
184
- property: 'build.edge_functions',
185
- check: isString,
186
- message: 'must be a string.',
187
- example: () => ({ build: { edge_functions: 'edge-functions' } }),
188
- },
189
- {
190
- property: 'functions.*',
191
- check: isPlainObj,
192
- message: 'must be an object.',
193
- example: (value, key, prevPath) => ({
194
- functions: { [prevPath[1]]: { external_node_modules: ['module-one', 'module-two'] } },
195
- }),
196
- },
197
- {
198
- property: 'functions.*.external_node_modules',
199
- check: isArrayOfStrings,
200
- message: 'must be an array of strings.',
201
- example: (value, key, prevPath) => ({
202
- functions: { [prevPath[1]]: { external_node_modules: ['module-one', 'module-two'] } },
203
- }),
204
- },
205
- {
206
- property: 'functions.*.ignored_node_modules',
207
- check: isArrayOfStrings,
208
- message: 'must be an array of strings.',
209
- example: (value, key, prevPath) => ({
210
- functions: { [prevPath[1]]: { ignored_node_modules: ['module-one', 'module-two'] } },
211
- }),
212
- },
213
- {
214
- property: 'functions.*.included_files',
215
- check: isArrayOfStrings,
216
- message: 'must be an array of strings.',
217
- example: (value, key, prevPath) => ({
218
- functions: { [prevPath[1]]: { included_files: ['directory-one/file1', 'directory-two/**/*.jpg'] } },
219
- }),
220
- },
221
- {
222
- property: 'functions.*.node_bundler',
223
- check: (value) => bundlers.includes(value),
224
- message: `must be one of: ${bundlers.join(', ')}`,
225
- example: (value, key, prevPath) => ({
226
- functions: { [prevPath[1]]: { node_bundler: bundlers[0] } },
227
- }),
228
- },
229
- {
230
- property: 'functions.*.directory',
231
- check: (value, key, prevPath) => prevPath[1] === FUNCTIONS_CONFIG_WILDCARD_ALL,
232
- message: 'must be defined on the main `functions` object.',
233
- example: () => ({
234
- functions: { directory: 'my-functions' },
235
- }),
236
- },
237
- {
238
- property: 'functions.*.schedule',
239
- check: isValidCronExpression,
240
- message: 'must be a valid cron expression (see https://ntl.fyi/cron-syntax).',
241
- example: (value, key, prevPath) => ({
242
- functions: { [prevPath[1]]: { schedule: '5 4 * * *' } },
243
- }),
244
- },
245
- {
246
- property: 'functionsDirectory',
247
- check: isString,
248
- message: 'must be a string.',
249
- ...functionsDirectoryCheck,
250
- example: () => ({
251
- functions: { directory: 'my-functions' },
252
- }),
253
- },
254
- {
255
- property: 'edge_functions.*',
256
- ...validProperties(['path', 'function'], []),
257
- example: () => ({ edge_functions: [{ path: '/hello', function: 'hello' }] }),
258
- },
259
- {
260
- property: 'edge_functions.*',
261
- check: (edgeFunction) => edgeFunction.path !== undefined,
262
- message: '"path" property is required.',
263
- example: () => ({ edge_functions: [{ path: '/hello', function: 'hello' }] }),
264
- },
265
- {
266
- property: 'edge_functions.*',
267
- check: (edgeFunction) => edgeFunction.function !== undefined,
268
- message: '"function" property is required.',
269
- example: () => ({ edge_functions: [{ path: '/hello', function: 'hello' }] }),
270
- },
271
- {
272
- property: 'edge_functions.*.path',
273
- check: isString,
274
- message: 'must be a string.',
275
- example: () => ({ edge_functions: [{ path: '/hello', function: 'hello' }] }),
276
- },
277
- {
278
- property: 'edge_functions.*.function',
279
- check: isString,
280
- message: 'must be a string.',
281
- example: () => ({ edge_functions: [{ path: '/hello', function: 'hello' }] }),
282
- },
283
- {
284
- property: 'edge_functions.*.path',
285
- check: (pathName) => pathName.startsWith('/'),
286
- message: 'must be a valid path.',
287
- example: () => ({ edge_functions: [{ path: '/hello', function: 'hello' }] }),
288
- },
289
- ]