@netlify/config 17.0.11 → 17.0.14

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/config",
3
- "version": "17.0.11",
3
+ "version": "17.0.14",
4
4
  "description": "Netlify config module",
5
5
  "type": "module",
6
6
  "exports": "./src/main.js",
@@ -19,8 +19,8 @@
19
19
  "prepublishOnly": "cd ../../ && npm run prepublishOnly"
20
20
  },
21
21
  "keywords": [
22
- "nodejs",
23
22
  "javascript",
23
+ "nodejs",
24
24
  "windows",
25
25
  "macos",
26
26
  "linux",
@@ -66,7 +66,7 @@
66
66
  "map-obj": "^5.0.0",
67
67
  "netlify": "^11.0.0",
68
68
  "netlify-headers-parser": "^6.0.2",
69
- "netlify-redirect-parser": "^13.0.3",
69
+ "netlify-redirect-parser": "13.0.2",
70
70
  "omit.js": "^2.0.2",
71
71
  "p-locate": "^6.0.0",
72
72
  "path-exists": "^5.0.0",
package/src/headers.js CHANGED
@@ -12,11 +12,17 @@ export const getHeadersPath = function ({ build: { publish } }) {
12
12
  const HEADERS_FILENAME = '_headers'
13
13
 
14
14
  // Add `config.headers`
15
- export const addHeaders = async function ({ headers: configHeaders, ...config }, headersPath, logs) {
15
+ export const addHeaders = async function ({
16
+ config: { headers: configHeaders, ...config },
17
+ headersPath,
18
+ logs,
19
+ featureFlags,
20
+ }) {
16
21
  const { headers, errors } = await parseAllHeaders({
17
22
  headersFiles: [headersPath],
18
23
  configHeaders,
19
24
  minimal: true,
25
+ featureFlags,
20
26
  })
21
27
  warnHeadersParsing(logs, errors)
22
28
  warnHeadersCaseSensitivity(logs, headers)
@@ -48,7 +48,9 @@ export const cleanupConfig = function ({
48
48
  functions,
49
49
  functionsDirectory,
50
50
  })
51
- return netlifyConfig
51
+ const netlifyConfigA = truncateArray(netlifyConfig, 'headers')
52
+ const netlifyConfigB = truncateArray(netlifyConfigA, 'redirects')
53
+ return netlifyConfigB
52
54
  }
53
55
 
54
56
  export const cleanupEnvironment = function (environment) {
@@ -77,3 +79,14 @@ const cleanupPlugin = function ({ package: packageName, origin, inputs = {} }) {
77
79
  const isPublicInput = function (key, input) {
78
80
  return typeof input === 'boolean'
79
81
  }
82
+
83
+ // `headers` and `redirects` can be very long, which can take several minutes
84
+ // to print in the build logs. We truncate them before logging.
85
+ const truncateArray = function (netlifyConfig, propName) {
86
+ const array = netlifyConfig[propName]
87
+ return Array.isArray(array) && array.length > MAX_ARRAY_LENGTH
88
+ ? { ...netlifyConfig, [propName]: array.slice(0, MAX_ARRAY_LENGTH) }
89
+ : netlifyConfig
90
+ }
91
+
92
+ const MAX_ARRAY_LENGTH = 100
package/src/main.js CHANGED
@@ -55,6 +55,7 @@ export const resolveConfig = async function (opts) {
55
55
  mode,
56
56
  debug,
57
57
  logs,
58
+ featureFlags,
58
59
  } = await normalizeOpts(optsA)
59
60
 
60
61
  const { siteInfo, accounts, addons } = await getSiteInfo({ api, siteId, mode, testOpts })
@@ -79,6 +80,7 @@ export const resolveConfig = async function (opts) {
79
80
  inlineConfig: inlineConfigA,
80
81
  baseRelDir: baseRelDirA,
81
82
  logs,
83
+ featureFlags,
82
84
  })
83
85
 
84
86
  const env = await getEnv({
@@ -147,6 +149,7 @@ const loadConfig = async function ({
147
149
  inlineConfig,
148
150
  baseRelDir,
149
151
  logs,
152
+ featureFlags,
150
153
  }) {
151
154
  const initialBase = getInitialBase({ repositoryRoot, defaultConfig, inlineConfig })
152
155
  const { configPath, config, buildDir, base, redirectsPath, headersPath } = await getFullConfig({
@@ -160,6 +163,7 @@ const loadConfig = async function ({
160
163
  baseRelDir,
161
164
  configBase: initialBase,
162
165
  logs,
166
+ featureFlags,
163
167
  })
164
168
 
165
169
  // No second pass needed if:
@@ -190,6 +194,7 @@ const loadConfig = async function ({
190
194
  configBase: base,
191
195
  base,
192
196
  logs,
197
+ featureFlags,
193
198
  })
194
199
  return {
195
200
  configPath: configPathA,
@@ -213,6 +218,7 @@ const getFullConfig = async function ({
213
218
  configBase,
214
219
  base,
215
220
  logs,
221
+ featureFlags,
216
222
  }) {
217
223
  const configPath = await getConfigPath({ configOpt, cwd, repositoryRoot, configBase })
218
224
 
@@ -232,9 +238,9 @@ const getFullConfig = async function ({
232
238
  base: baseA,
233
239
  } = await resolveFiles({ config: configA, repositoryRoot, base, baseRelDir })
234
240
  const headersPath = getHeadersPath(configB)
235
- const configC = await addHeaders(configB, headersPath, logs)
241
+ const configC = await addHeaders({ config: configB, headersPath, logs, featureFlags })
236
242
  const redirectsPath = getRedirectsPath(configC)
237
- const configD = await addRedirects(configC, redirectsPath, logs)
243
+ const configD = await addRedirects({ config: configC, redirectsPath, logs, featureFlags })
238
244
  return { configPath, config: configD, buildDir, base: baseA, redirectsPath, headersPath }
239
245
  } catch (error) {
240
246
  const configName = configPath === undefined ? '' : ` file ${configPath}`
@@ -16,7 +16,7 @@ import { applyMutations } from './apply.js'
16
16
  // If `netlify.toml` does not exist, creates it. Otherwise, merges the changes.
17
17
  export const updateConfig = async function (
18
18
  configMutations,
19
- { buildDir, configPath, headersPath, redirectsPath, context, branch, logs },
19
+ { buildDir, configPath, headersPath, redirectsPath, context, branch, logs, featureFlags },
20
20
  ) {
21
21
  if (configMutations.length === 0) {
22
22
  return
@@ -25,8 +25,8 @@ export const updateConfig = async function (
25
25
  const inlineConfig = applyMutations({}, configMutations)
26
26
  const normalizedInlineConfig = ensureConfigPriority(inlineConfig, context, branch)
27
27
  const updatedConfig = await mergeWithConfig(normalizedInlineConfig, configPath)
28
- const configWithHeaders = await addHeaders(updatedConfig, headersPath, logs)
29
- const finalConfig = await addRedirects(configWithHeaders, redirectsPath, logs)
28
+ const configWithHeaders = await addHeaders({ config: updatedConfig, headersPath, logs, featureFlags })
29
+ const finalConfig = await addRedirects({ config: configWithHeaders, redirectsPath, logs, featureFlags })
30
30
  const simplifiedConfig = simplifyConfig(finalConfig)
31
31
  await backupConfig({ buildDir, configPath, headersPath, redirectsPath })
32
32
  await Promise.all([
package/src/redirects.js CHANGED
@@ -12,11 +12,17 @@ export const getRedirectsPath = function ({ build: { publish } }) {
12
12
  const REDIRECTS_FILENAME = '_redirects'
13
13
 
14
14
  // Add `config.redirects`
15
- export const addRedirects = async function ({ redirects: configRedirects, ...config }, redirectsPath, logs) {
15
+ export const addRedirects = async function ({
16
+ config: { redirects: configRedirects, ...config },
17
+ redirectsPath,
18
+ logs,
19
+ featureFlags,
20
+ }) {
16
21
  const { redirects, errors } = await parseAllRedirects({
17
22
  redirectsFiles: [redirectsPath],
18
23
  configRedirects,
19
24
  minimal: true,
25
+ featureFlags,
20
26
  })
21
27
  warnRedirectsParsing(logs, errors)
22
28
  return { ...config, redirects }
package/src/simplify.js CHANGED
@@ -33,8 +33,8 @@ export const simplifyConfig = function ({
33
33
  ...removeEmptyObject(simplifyFunctions(functions), 'functions'),
34
34
  ...removeEmptyObject(buildA, 'build'),
35
35
  ...removeEmptyArray(plugins, 'plugins'),
36
- ...removeEmptyArray(truncateArray(headers), 'headers'),
37
- ...removeEmptyArray(simplifyRedirects(truncateArray(redirects)), 'redirects'),
36
+ ...removeEmptyArray(headers, 'headers'),
37
+ ...removeEmptyArray(simplifyRedirects(redirects), 'redirects'),
38
38
  ...removeEmptyObject(simplifyContexts(context), 'context'),
39
39
  })
40
40
  }
@@ -85,14 +85,6 @@ const removeDefaultValue = function (value, propName, defaultValue) {
85
85
  return value === defaultValue ? {} : { [propName]: value }
86
86
  }
87
87
 
88
- // `headers` and `redirects` can be very long, which can take several minutes
89
- // to print in the build logs. We truncate them before logging.
90
- const truncateArray = function (array) {
91
- return !Array.isArray(array) || array.length < MAX_ARRAY_LENGTH ? array : array.slice(0, MAX_ARRAY_LENGTH)
92
- }
93
-
94
- const MAX_ARRAY_LENGTH = 100
95
-
96
88
  export const removeEmptyObject = function (object, propName) {
97
89
  if (!isPlainObj(object)) {
98
90
  return {}