@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/functions_config.js
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
import isPlainObj from 'is-plain-obj'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const bundlers = ['esbuild', 'nft', 'zisi']
|
|
6
|
-
export const WILDCARD_ALL = '*'
|
|
7
|
-
|
|
1
|
+
import isPlainObj from 'is-plain-obj';
|
|
2
|
+
import { isDefined } from './utils/remove_falsy.js';
|
|
3
|
+
export const bundlers = ['esbuild', 'nft', 'zisi'];
|
|
4
|
+
export const WILDCARD_ALL = '*';
|
|
8
5
|
// Removing the legacy `functions` from the `build` block.
|
|
9
6
|
// Looking for a default directory in the `functions` block, separating it
|
|
10
7
|
// from the rest of the configuration if it exists.
|
|
11
|
-
export const normalizeFunctionsProps = function (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const functionsDirectoryProps = getFunctionsDirectoryProps({ functionsDirectory, v1FunctionsDirectory })
|
|
18
|
-
return { build, functions: functionsB, functionsDirectoryProps }
|
|
19
|
-
}
|
|
20
|
-
|
|
8
|
+
export const normalizeFunctionsProps = function ({ functions: v1FunctionsDirectory, ...build }, { [WILDCARD_ALL]: wildcardProps, ...functions }) {
|
|
9
|
+
const functionsA = Object.entries(functions).reduce(normalizeFunctionsProp, { [WILDCARD_ALL]: wildcardProps });
|
|
10
|
+
const { directory: functionsDirectory, functions: functionsB } = extractFunctionsDirectory(functionsA);
|
|
11
|
+
const functionsDirectoryProps = getFunctionsDirectoryProps({ functionsDirectory, v1FunctionsDirectory });
|
|
12
|
+
return { build, functions: functionsB, functionsDirectoryProps };
|
|
13
|
+
};
|
|
21
14
|
// Normalizes a functions configuration object, so that the first level of keys
|
|
22
15
|
// represents function expressions mapped to a configuration object.
|
|
23
16
|
//
|
|
@@ -37,47 +30,38 @@ export const normalizeFunctionsProps = function (
|
|
|
37
30
|
// that to be the case if the value is an object where all keys are also
|
|
38
31
|
// config properties. If not, it's simply a function with the same name
|
|
39
32
|
// as one of the config properties.
|
|
40
|
-
const normalizeFunctionsProp = (functions, [propName, propValue]) =>
|
|
41
|
-
isConfigProperty(propName) && !isConfigLeaf(propValue)
|
|
33
|
+
const normalizeFunctionsProp = (functions, [propName, propValue]) => isConfigProperty(propName) && !isConfigLeaf(propValue)
|
|
42
34
|
? { ...functions, [WILDCARD_ALL]: { [propName]: propValue, ...functions[WILDCARD_ALL] } }
|
|
43
|
-
: { ...functions, [propName]: propValue }
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
isPlainObj(functionConfig) && Object.keys(functionConfig).every(isConfigProperty)
|
|
47
|
-
|
|
48
|
-
const isConfigProperty = (propName) => FUNCTION_CONFIG_PROPERTIES.has(propName)
|
|
49
|
-
|
|
35
|
+
: { ...functions, [propName]: propValue };
|
|
36
|
+
const isConfigLeaf = (functionConfig) => isPlainObj(functionConfig) && Object.keys(functionConfig).every(isConfigProperty);
|
|
37
|
+
const isConfigProperty = (propName) => FUNCTION_CONFIG_PROPERTIES.has(propName);
|
|
50
38
|
export const FUNCTION_CONFIG_PROPERTIES = new Set([
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
])
|
|
58
|
-
|
|
39
|
+
'directory',
|
|
40
|
+
'external_node_modules',
|
|
41
|
+
'ignored_node_modules',
|
|
42
|
+
'included_files',
|
|
43
|
+
'node_bundler',
|
|
44
|
+
'schedule',
|
|
45
|
+
]);
|
|
59
46
|
// Takes a functions configuration object and looks for the functions directory
|
|
60
47
|
// definition, returning it under the `directory` key. The rest of the config
|
|
61
48
|
// object is returned under the `functions` key.
|
|
62
49
|
const extractFunctionsDirectory = ({ [WILDCARD_ALL]: { directory, ...wildcardFunctionsConfig }, ...functions }) => ({
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
})
|
|
66
|
-
|
|
50
|
+
directory,
|
|
51
|
+
functions: { ...functions, [WILDCARD_ALL]: wildcardFunctionsConfig },
|
|
52
|
+
});
|
|
67
53
|
const getFunctionsDirectoryProps = ({ functionsDirectory, v1FunctionsDirectory }) => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
if (isDefined(functionsDirectory)) {
|
|
55
|
+
return {
|
|
56
|
+
functionsDirectory,
|
|
57
|
+
functionsDirectoryOrigin: 'config',
|
|
58
|
+
};
|
|
72
59
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
functionsDirectoryOrigin: 'config-v1',
|
|
60
|
+
if (isDefined(v1FunctionsDirectory)) {
|
|
61
|
+
return {
|
|
62
|
+
functionsDirectory: v1FunctionsDirectory,
|
|
63
|
+
functionsDirectoryOrigin: 'config-v1',
|
|
64
|
+
};
|
|
79
65
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return {}
|
|
83
|
-
}
|
|
66
|
+
return {};
|
|
67
|
+
};
|
package/lib/headers.js
CHANGED
|
@@ -1,30 +1,20 @@
|
|
|
1
|
-
import { resolve } from 'path'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { warnHeadersParsing, warnHeadersCaseSensitivity } from './log/messages.js'
|
|
6
|
-
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { parseAllHeaders } from 'netlify-headers-parser';
|
|
3
|
+
import { warnHeadersParsing, warnHeadersCaseSensitivity } from './log/messages.js';
|
|
7
4
|
// Retrieve path to `_headers` file (even if it does not exist yet)
|
|
8
5
|
export const getHeadersPath = function ({ build: { publish } }) {
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const HEADERS_FILENAME = '_headers'
|
|
13
|
-
|
|
6
|
+
return resolve(publish, HEADERS_FILENAME);
|
|
7
|
+
};
|
|
8
|
+
const HEADERS_FILENAME = '_headers';
|
|
14
9
|
// Add `config.headers`
|
|
15
|
-
export const addHeaders = async function ({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
})
|
|
27
|
-
warnHeadersParsing(logs, errors)
|
|
28
|
-
warnHeadersCaseSensitivity(logs, headers)
|
|
29
|
-
return { ...config, headers }
|
|
30
|
-
}
|
|
10
|
+
export const addHeaders = async function ({ config: { headers: configHeaders, ...config }, headersPath, logs, featureFlags, }) {
|
|
11
|
+
const { headers, errors } = await parseAllHeaders({
|
|
12
|
+
headersFiles: [headersPath],
|
|
13
|
+
configHeaders,
|
|
14
|
+
minimal: true,
|
|
15
|
+
featureFlags,
|
|
16
|
+
});
|
|
17
|
+
warnHeadersParsing(logs, errors);
|
|
18
|
+
warnHeadersCaseSensitivity(logs, headers);
|
|
19
|
+
return { ...config, headers };
|
|
20
|
+
};
|
package/lib/inline_config.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { logInlineConfig } from './log/main.js'
|
|
2
|
-
import { applyMutations } from './mutations/apply.js'
|
|
3
|
-
|
|
1
|
+
import { logInlineConfig } from './log/main.js';
|
|
2
|
+
import { applyMutations } from './mutations/apply.js';
|
|
4
3
|
// Retrieve the `--inlineConfig` CLI flag
|
|
5
4
|
export const getInlineConfig = function ({ inlineConfig, configMutations, logs, debug }) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
5
|
+
const mutatedInlineConfig = applyMutations(inlineConfig, configMutations);
|
|
6
|
+
logInlineConfig(mutatedInlineConfig, { logs, debug });
|
|
7
|
+
return mutatedInlineConfig;
|
|
8
|
+
};
|
package/lib/log/cleanup.js
CHANGED
|
@@ -1,92 +1,64 @@
|
|
|
1
|
-
import filterObj from 'filter-obj'
|
|
2
|
-
|
|
3
|
-
import { simplifyConfig } from '../simplify.js'
|
|
4
|
-
|
|
1
|
+
import filterObj from 'filter-obj';
|
|
2
|
+
import { simplifyConfig } from '../simplify.js';
|
|
5
3
|
// Make sure we are not printing secret values. Use an allow list.
|
|
6
|
-
export const cleanupConfig = function ({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
processing,
|
|
36
|
-
publish,
|
|
37
|
-
publishOrigin,
|
|
38
|
-
}
|
|
39
|
-
const pluginsA = plugins.map(cleanupPlugin)
|
|
40
|
-
const netlifyConfig = simplifyConfig({
|
|
41
|
-
build,
|
|
42
|
-
plugins: pluginsA,
|
|
43
|
-
headers,
|
|
44
|
-
headersOrigin,
|
|
45
|
-
redirects,
|
|
46
|
-
redirectsOrigin,
|
|
47
|
-
baseRelDir,
|
|
48
|
-
functions,
|
|
49
|
-
functionsDirectory,
|
|
50
|
-
})
|
|
51
|
-
const netlifyConfigA = truncateArray(netlifyConfig, 'headers')
|
|
52
|
-
const netlifyConfigB = truncateArray(netlifyConfigA, 'redirects')
|
|
53
|
-
return netlifyConfigB
|
|
54
|
-
}
|
|
55
|
-
|
|
4
|
+
export const cleanupConfig = function ({ build: { base, command, commandOrigin, environment = {}, edge_functions: edgeFunctions, ignore, processing, publish, publishOrigin, } = {}, headers, headersOrigin, plugins = [], redirects, redirectsOrigin, baseRelDir, functions, functionsDirectory, }) {
|
|
5
|
+
const environmentA = cleanupEnvironment(environment);
|
|
6
|
+
const build = {
|
|
7
|
+
base,
|
|
8
|
+
command,
|
|
9
|
+
commandOrigin,
|
|
10
|
+
environment: environmentA,
|
|
11
|
+
edge_functions: edgeFunctions,
|
|
12
|
+
ignore,
|
|
13
|
+
processing,
|
|
14
|
+
publish,
|
|
15
|
+
publishOrigin,
|
|
16
|
+
};
|
|
17
|
+
const pluginsA = plugins.map(cleanupPlugin);
|
|
18
|
+
const netlifyConfig = simplifyConfig({
|
|
19
|
+
build,
|
|
20
|
+
plugins: pluginsA,
|
|
21
|
+
headers,
|
|
22
|
+
headersOrigin,
|
|
23
|
+
redirects,
|
|
24
|
+
redirectsOrigin,
|
|
25
|
+
baseRelDir,
|
|
26
|
+
functions,
|
|
27
|
+
functionsDirectory,
|
|
28
|
+
});
|
|
29
|
+
const netlifyConfigA = truncateArray(netlifyConfig, 'headers');
|
|
30
|
+
const netlifyConfigB = truncateArray(netlifyConfigA, 'redirects');
|
|
31
|
+
return netlifyConfigB;
|
|
32
|
+
};
|
|
56
33
|
export const cleanupEnvironment = function (environment) {
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
34
|
+
return Object.keys(environment).filter((key) => !BUILDBOT_ENVIRONMENT.has(key));
|
|
35
|
+
};
|
|
60
36
|
// Added by the buildbot. We only want to print environment variables specified
|
|
61
37
|
// by the user.
|
|
62
38
|
const BUILDBOT_ENVIRONMENT = new Set([
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
])
|
|
73
|
-
|
|
39
|
+
'BRANCH',
|
|
40
|
+
'CONTEXT',
|
|
41
|
+
'DEPLOY_PRIME_URL',
|
|
42
|
+
'DEPLOY_URL',
|
|
43
|
+
'GO_VERSION',
|
|
44
|
+
'NETLIFY_IMAGES_CDN_DOMAIN',
|
|
45
|
+
'SITE_ID',
|
|
46
|
+
'SITE_NAME',
|
|
47
|
+
'URL',
|
|
48
|
+
]);
|
|
74
49
|
const cleanupPlugin = function ({ package: packageName, origin, inputs = {} }) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
50
|
+
const inputsA = filterObj(inputs, isPublicInput);
|
|
51
|
+
return { package: packageName, origin, inputs: inputsA };
|
|
52
|
+
};
|
|
79
53
|
const isPublicInput = function (key, input) {
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
54
|
+
return typeof input === 'boolean';
|
|
55
|
+
};
|
|
83
56
|
// `headers` and `redirects` can be very long, which can take several minutes
|
|
84
57
|
// to print in the build logs. We truncate them before logging.
|
|
85
58
|
const truncateArray = function (netlifyConfig, propName) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const MAX_ARRAY_LENGTH = 100
|
|
59
|
+
const array = netlifyConfig[propName];
|
|
60
|
+
return Array.isArray(array) && array.length > MAX_ARRAY_LENGTH
|
|
61
|
+
? { ...netlifyConfig, [propName]: array.slice(0, MAX_ARRAY_LENGTH) }
|
|
62
|
+
: netlifyConfig;
|
|
63
|
+
};
|
|
64
|
+
const MAX_ARRAY_LENGTH = 100;
|
package/lib/log/logger.js
CHANGED
|
@@ -1,47 +1,36 @@
|
|
|
1
|
-
import figures from 'figures'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { THEME } from './theme.js'
|
|
5
|
-
|
|
1
|
+
import figures from 'figures';
|
|
2
|
+
import { serializeObject } from './serialize.js';
|
|
3
|
+
import { THEME } from './theme.js';
|
|
6
4
|
// When the `buffer` option is true, we return logs instead of printing them
|
|
7
5
|
// on the console. The logs are accumulated in a `logs` array variable.
|
|
8
6
|
export const getBufferLogs = function ({ buffer }) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
7
|
+
if (!buffer) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
return { stdout: [], stderr: [] };
|
|
11
|
+
};
|
|
16
12
|
// This should be used instead of `console.log()`
|
|
17
13
|
// Printed on stderr because stdout is reserved for the JSON output
|
|
18
14
|
export const log = function (logs, string, { color } = {}) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
console.warn(stringB)
|
|
30
|
-
}
|
|
31
|
-
|
|
15
|
+
const stringA = String(string).replace(EMPTY_LINES_REGEXP, EMPTY_LINE);
|
|
16
|
+
const stringB = color === undefined ? stringA : color(stringA);
|
|
17
|
+
if (logs !== undefined) {
|
|
18
|
+
// `logs` is a stateful variable
|
|
19
|
+
logs.stderr.push(stringB);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
console.warn(stringB);
|
|
23
|
+
};
|
|
32
24
|
// We need to add a zero width space character in empty lines. Otherwise the
|
|
33
25
|
// buildbot removes those due to a bug: https://github.com/netlify/buildbot/issues/595
|
|
34
|
-
const EMPTY_LINES_REGEXP = /^\s*$/gm
|
|
35
|
-
const EMPTY_LINE = '\u{200B}'
|
|
36
|
-
|
|
26
|
+
const EMPTY_LINES_REGEXP = /^\s*$/gm;
|
|
27
|
+
const EMPTY_LINE = '\u{200B}';
|
|
37
28
|
export const logWarning = function (logs, string, opts) {
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
29
|
+
log(logs, string, { color: THEME.warningLine, ...opts });
|
|
30
|
+
};
|
|
41
31
|
export const logObject = function (logs, object, opts) {
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
32
|
+
log(logs, serializeObject(object), opts);
|
|
33
|
+
};
|
|
45
34
|
export const logSubHeader = function (logs, string, opts) {
|
|
46
|
-
|
|
47
|
-
}
|
|
35
|
+
log(logs, `\n${figures.pointer} ${string}`, { color: THEME.subHeader, ...opts });
|
|
36
|
+
};
|
package/lib/log/main.js
CHANGED
|
@@ -1,48 +1,39 @@
|
|
|
1
|
-
import { cleanupConfig, cleanupEnvironment } from './cleanup.js'
|
|
2
|
-
import { logObject, logSubHeader } from './logger.js'
|
|
3
|
-
import { cleanupConfigOpts } from './options.js'
|
|
4
|
-
|
|
1
|
+
import { cleanupConfig, cleanupEnvironment } from './cleanup.js';
|
|
2
|
+
import { logObject, logSubHeader } from './logger.js';
|
|
3
|
+
import { cleanupConfigOpts } from './options.js';
|
|
5
4
|
// Log options in debug mode.
|
|
6
5
|
export const logOpts = function (opts, { logs, debug, cachedConfig, cachedConfigPath }) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
6
|
+
// In production, print those in the first call to `@netlify/config`, not the
|
|
7
|
+
// second one done inside `@netlify/build`
|
|
8
|
+
if (!debug || cachedConfig !== undefined || cachedConfigPath !== undefined) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
logSubHeader(logs, 'Initial build environment');
|
|
12
|
+
logObject(logs, cleanupConfigOpts(opts));
|
|
13
|
+
};
|
|
17
14
|
// Log `defaultConfig` option in debug mode
|
|
18
15
|
export const logDefaultConfig = function (defaultConfig, { logs, debug, baseRelDir }) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
16
|
+
if (!debug || defaultConfig === undefined) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
logSubHeader(logs, 'UI build settings');
|
|
20
|
+
logObject(logs, cleanupConfig({ ...defaultConfig, baseRelDir }));
|
|
21
|
+
};
|
|
27
22
|
// Log `inlineConfig` option in debug mode
|
|
28
23
|
export const logInlineConfig = function (initialConfig, { logs, debug }) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
24
|
+
if (!debug || Object.keys(initialConfig).length === 0) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
logSubHeader(logs, 'Configuration override');
|
|
28
|
+
logObject(logs, cleanupConfig(initialConfig));
|
|
29
|
+
};
|
|
37
30
|
// Log return value of `@netlify/config` in debug mode
|
|
38
31
|
export const logResult = function ({ configPath, buildDir, config, context, branch, env }, { logs, debug }) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
logObject(logs, cleanupConfig(config))
|
|
48
|
-
}
|
|
32
|
+
if (!debug) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
logSubHeader(logs, 'Resolved build environment');
|
|
36
|
+
logObject(logs, { configPath, buildDir, context, branch, env: cleanupEnvironment(env) });
|
|
37
|
+
logSubHeader(logs, 'Resolved config');
|
|
38
|
+
logObject(logs, cleanupConfig(config));
|
|
39
|
+
};
|
package/lib/log/messages.js
CHANGED
|
@@ -1,126 +1,87 @@
|
|
|
1
|
-
import { throwUserError } from '../error.js'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const ERROR_CALL_TO_ACTION = `Double-check your login status with 'netlify status' or contact support with details of your error.`
|
|
6
|
-
|
|
1
|
+
import { throwUserError } from '../error.js';
|
|
2
|
+
import { logWarning } from './logger.js';
|
|
3
|
+
export const ERROR_CALL_TO_ACTION = `Double-check your login status with 'netlify status' or contact support with details of your error.`;
|
|
7
4
|
export const throwOnInvalidTomlSequence = function (invalidSequence) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
)
|
|
12
|
-
}
|
|
13
|
-
|
|
5
|
+
throwUserError(`In netlify.toml, the following backslash should be escaped: ${invalidSequence}
|
|
6
|
+
The following should be used instead: \\${invalidSequence}`);
|
|
7
|
+
};
|
|
14
8
|
export const warnLegacyFunctionsDirectory = ({ config = {}, logs }) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
logWarning(
|
|
22
|
-
logs,
|
|
23
|
-
`
|
|
9
|
+
const { functionsDirectory, functionsDirectoryOrigin } = config;
|
|
10
|
+
if (functionsDirectoryOrigin !== 'config-v1') {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
logWarning(logs, `
|
|
24
14
|
Detected functions directory configuration in netlify.toml under [build] settings.
|
|
25
15
|
We recommend updating netlify.toml to set the functions directory under [functions] settings using the directory property. For example,
|
|
26
16
|
|
|
27
17
|
[functions]
|
|
28
|
-
directory = "${functionsDirectory}"
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
18
|
+
directory = "${functionsDirectory}"`);
|
|
19
|
+
};
|
|
32
20
|
export const warnContextPluginConfig = function (logs, packageName, context) {
|
|
33
|
-
|
|
34
|
-
logs,
|
|
35
|
-
`
|
|
21
|
+
logWarning(logs, `
|
|
36
22
|
"${packageName}" is installed in the UI, which means that it runs in all deploy contexts, regardless of file-based configuration.
|
|
37
|
-
To run "${packageName}" in the ${context} context only, uninstall the plugin from the site plugins list
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
23
|
+
To run "${packageName}" in the ${context} context only, uninstall the plugin from the site plugins list.`);
|
|
24
|
+
};
|
|
41
25
|
export const throwContextPluginsConfig = function (packageName, context) {
|
|
42
|
-
|
|
43
|
-
`
|
|
26
|
+
throwUserError(`
|
|
44
27
|
"${packageName}" is installed in the UI, which means that it runs in all deploy contexts, regardless of file-based configuration.
|
|
45
28
|
To run "${packageName}" in the ${context} context only, uninstall the plugin from the site plugins list.
|
|
46
29
|
To run "${packageName}" in all contexts, please remove the following section from "netlify.toml".
|
|
47
30
|
|
|
48
31
|
[[context.${context}.plugins]]
|
|
49
32
|
package = "${packageName}"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
33
|
+
`);
|
|
34
|
+
};
|
|
54
35
|
export const warnHeadersParsing = function (logs, errors) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
logWarning(
|
|
61
|
-
logs,
|
|
62
|
-
`
|
|
36
|
+
if (errors.length === 0) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const errorMessage = errors.map(getErrorMessage).join('\n\n');
|
|
40
|
+
logWarning(logs, `
|
|
63
41
|
Warning: some headers have syntax errors:
|
|
64
42
|
|
|
65
|
-
${errorMessage}
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
43
|
+
${errorMessage}`);
|
|
44
|
+
};
|
|
69
45
|
// Headers with different cases are not currently the way users probably
|
|
70
46
|
// intend them to be, so we print a warning message.
|
|
71
47
|
// See issue at https://github.com/netlify/build/issues/2290
|
|
72
48
|
export const warnHeadersCaseSensitivity = function (logs, headers) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
`
|
|
84
|
-
Warning: the same header is set twice with different cases${sameForPath}: "${headerName}" and "${differentCaseHeader.headerName}"`,
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
|
|
49
|
+
const headersA = headers.flatMap(getHeaderNames).filter(isNotDuplicateHeaderName).map(addHeaderLowerCase);
|
|
50
|
+
const differentCaseHeader = headersA.find(hasHeaderCaseDuplicate);
|
|
51
|
+
if (differentCaseHeader === undefined) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const { forPath, headerName } = headersA.find((header) => isHeaderCaseDuplicate(header, differentCaseHeader));
|
|
55
|
+
const sameForPath = forPath === differentCaseHeader.forPath ? ` for "${forPath}"` : '';
|
|
56
|
+
logWarning(logs, `
|
|
57
|
+
Warning: the same header is set twice with different cases${sameForPath}: "${headerName}" and "${differentCaseHeader.headerName}"`);
|
|
58
|
+
};
|
|
88
59
|
const getHeaderNames = function ({ for: forPath, values = {} }) {
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
60
|
+
return Object.keys(values).map((headerName) => ({ forPath, headerName }));
|
|
61
|
+
};
|
|
92
62
|
const isNotDuplicateHeaderName = function ({ headerName }, index, headers) {
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
63
|
+
return headers.slice(index + 1).every((header) => header.headerName !== headerName);
|
|
64
|
+
};
|
|
96
65
|
const addHeaderLowerCase = function ({ forPath, headerName }) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
66
|
+
const lowerHeaderName = headerName.toLowerCase();
|
|
67
|
+
return { forPath, headerName, lowerHeaderName };
|
|
68
|
+
};
|
|
101
69
|
const hasHeaderCaseDuplicate = function ({ lowerHeaderName }, index, headers) {
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
70
|
+
return headers.slice(index + 1).some((header) => header.lowerHeaderName === lowerHeaderName);
|
|
71
|
+
};
|
|
105
72
|
const isHeaderCaseDuplicate = function ({ headerName, lowerHeaderName }, differentCaseHeader) {
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
73
|
+
return differentCaseHeader.headerName !== headerName && differentCaseHeader.lowerHeaderName === lowerHeaderName;
|
|
74
|
+
};
|
|
109
75
|
export const warnRedirectsParsing = function (logs, errors) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
logWarning(
|
|
116
|
-
logs,
|
|
117
|
-
`
|
|
76
|
+
if (errors.length === 0) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const errorMessage = errors.map(getErrorMessage).join('\n\n');
|
|
80
|
+
logWarning(logs, `
|
|
118
81
|
Warning: some redirects have syntax errors:
|
|
119
82
|
|
|
120
|
-
${errorMessage}
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
83
|
+
${errorMessage}`);
|
|
84
|
+
};
|
|
124
85
|
const getErrorMessage = function ({ message }) {
|
|
125
|
-
|
|
126
|
-
}
|
|
86
|
+
return message;
|
|
87
|
+
};
|