@netlify/config 25.6.1 → 25.7.0
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/lib/bin/flags.d.ts +3 -156
- package/lib/bin/flags.js +1 -2
- package/lib/bin/main.js +2 -2
- package/lib/build_dir.js +1 -1
- package/lib/context.js +4 -5
- package/lib/env/git.d.ts +7 -1
- package/lib/env/main.js +3 -3
- package/lib/functions_config.js +1 -1
- package/lib/log/cleanup.js +2 -3
- package/lib/log/options.d.ts +11 -1
- package/lib/log/theme.d.ts +4 -4
- package/lib/log/theme.js +6 -6
- package/lib/merge.js +1 -1
- package/lib/mutations/apply.js +9 -0
- package/lib/options/main.d.ts +41 -0
- package/lib/options/main.js +1 -1
- package/lib/path.js +10 -4
- package/lib/simplify.d.ts +3 -1
- package/lib/simplify.js +2 -3
- package/lib/utils/fs.d.ts +5 -0
- package/lib/utils/fs.js +16 -0
- package/lib/utils/is_plain_obj.d.ts +1 -0
- package/lib/utils/is_plain_obj.js +7 -0
- package/lib/utils/remove_falsy.d.ts +4 -1
- package/lib/utils/remove_falsy.js +2 -5
- package/lib/utils/set.js +1 -1
- package/lib/validate/helpers.d.ts +1 -1
- package/lib/validate/helpers.js +1 -1
- package/lib/validate/validations.d.ts +11 -12
- package/lib/validate/validations.js +1 -1
- package/package.json +2 -9
package/lib/bin/flags.d.ts
CHANGED
|
@@ -1,156 +1,3 @@
|
|
|
1
|
-
export declare const parseFlags: () =>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
defaultConfig: any;
|
|
5
|
-
cachedConfig: any;
|
|
6
|
-
cachedConfigPath: unknown;
|
|
7
|
-
inlineConfig: any;
|
|
8
|
-
configMutations: any;
|
|
9
|
-
cwd: unknown;
|
|
10
|
-
packagePath: unknown;
|
|
11
|
-
repositoryRoot: unknown;
|
|
12
|
-
output: unknown;
|
|
13
|
-
stable: boolean;
|
|
14
|
-
token: unknown;
|
|
15
|
-
host: unknown;
|
|
16
|
-
scheme: unknown;
|
|
17
|
-
pathPrefix: unknown;
|
|
18
|
-
siteId: unknown;
|
|
19
|
-
accountId: unknown;
|
|
20
|
-
context: unknown;
|
|
21
|
-
branch: unknown;
|
|
22
|
-
baseRelDir: unknown;
|
|
23
|
-
mode: unknown;
|
|
24
|
-
debug: unknown;
|
|
25
|
-
testOpts: unknown;
|
|
26
|
-
offline: unknown;
|
|
27
|
-
buffer: unknown;
|
|
28
|
-
_: (string | number)[];
|
|
29
|
-
$0: string;
|
|
30
|
-
} | {
|
|
31
|
-
featureFlags: any;
|
|
32
|
-
then<TResult1 = {
|
|
33
|
-
[x: string]: unknown;
|
|
34
|
-
config: unknown;
|
|
35
|
-
defaultConfig: any;
|
|
36
|
-
cachedConfig: any;
|
|
37
|
-
cachedConfigPath: unknown;
|
|
38
|
-
inlineConfig: any;
|
|
39
|
-
configMutations: any;
|
|
40
|
-
cwd: unknown;
|
|
41
|
-
packagePath: unknown;
|
|
42
|
-
repositoryRoot: unknown;
|
|
43
|
-
output: unknown;
|
|
44
|
-
stable: boolean;
|
|
45
|
-
token: unknown;
|
|
46
|
-
host: unknown;
|
|
47
|
-
scheme: unknown;
|
|
48
|
-
pathPrefix: unknown;
|
|
49
|
-
siteId: unknown;
|
|
50
|
-
accountId: unknown;
|
|
51
|
-
context: unknown;
|
|
52
|
-
branch: unknown;
|
|
53
|
-
baseRelDir: unknown;
|
|
54
|
-
mode: unknown;
|
|
55
|
-
debug: unknown;
|
|
56
|
-
testOpts: unknown;
|
|
57
|
-
featureFlags: unknown;
|
|
58
|
-
offline: unknown;
|
|
59
|
-
buffer: unknown;
|
|
60
|
-
_: (string | number)[];
|
|
61
|
-
$0: string;
|
|
62
|
-
}, TResult2 = never>(onfulfilled?: ((value: {
|
|
63
|
-
[x: string]: unknown;
|
|
64
|
-
config: unknown;
|
|
65
|
-
defaultConfig: any;
|
|
66
|
-
cachedConfig: any;
|
|
67
|
-
cachedConfigPath: unknown;
|
|
68
|
-
inlineConfig: any;
|
|
69
|
-
configMutations: any;
|
|
70
|
-
cwd: unknown;
|
|
71
|
-
packagePath: unknown;
|
|
72
|
-
repositoryRoot: unknown;
|
|
73
|
-
output: unknown;
|
|
74
|
-
stable: boolean;
|
|
75
|
-
token: unknown;
|
|
76
|
-
host: unknown;
|
|
77
|
-
scheme: unknown;
|
|
78
|
-
pathPrefix: unknown;
|
|
79
|
-
siteId: unknown;
|
|
80
|
-
accountId: unknown;
|
|
81
|
-
context: unknown;
|
|
82
|
-
branch: unknown;
|
|
83
|
-
baseRelDir: unknown;
|
|
84
|
-
mode: unknown;
|
|
85
|
-
debug: unknown;
|
|
86
|
-
testOpts: unknown;
|
|
87
|
-
featureFlags: unknown;
|
|
88
|
-
offline: unknown;
|
|
89
|
-
buffer: unknown;
|
|
90
|
-
_: (string | number)[];
|
|
91
|
-
$0: string;
|
|
92
|
-
}) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
|
|
93
|
-
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<{
|
|
94
|
-
[x: string]: unknown;
|
|
95
|
-
config: unknown;
|
|
96
|
-
defaultConfig: any;
|
|
97
|
-
cachedConfig: any;
|
|
98
|
-
cachedConfigPath: unknown;
|
|
99
|
-
inlineConfig: any;
|
|
100
|
-
configMutations: any;
|
|
101
|
-
cwd: unknown;
|
|
102
|
-
packagePath: unknown;
|
|
103
|
-
repositoryRoot: unknown;
|
|
104
|
-
output: unknown;
|
|
105
|
-
stable: boolean;
|
|
106
|
-
token: unknown;
|
|
107
|
-
host: unknown;
|
|
108
|
-
scheme: unknown;
|
|
109
|
-
pathPrefix: unknown;
|
|
110
|
-
siteId: unknown;
|
|
111
|
-
accountId: unknown;
|
|
112
|
-
context: unknown;
|
|
113
|
-
branch: unknown;
|
|
114
|
-
baseRelDir: unknown;
|
|
115
|
-
mode: unknown;
|
|
116
|
-
debug: unknown;
|
|
117
|
-
testOpts: unknown;
|
|
118
|
-
featureFlags: unknown;
|
|
119
|
-
offline: unknown;
|
|
120
|
-
buffer: unknown;
|
|
121
|
-
_: (string | number)[];
|
|
122
|
-
$0: string;
|
|
123
|
-
} | TResult>;
|
|
124
|
-
finally(onfinally?: (() => void) | null | undefined): Promise<{
|
|
125
|
-
[x: string]: unknown;
|
|
126
|
-
config: unknown;
|
|
127
|
-
defaultConfig: any;
|
|
128
|
-
cachedConfig: any;
|
|
129
|
-
cachedConfigPath: unknown;
|
|
130
|
-
inlineConfig: any;
|
|
131
|
-
configMutations: any;
|
|
132
|
-
cwd: unknown;
|
|
133
|
-
packagePath: unknown;
|
|
134
|
-
repositoryRoot: unknown;
|
|
135
|
-
output: unknown;
|
|
136
|
-
stable: boolean;
|
|
137
|
-
token: unknown;
|
|
138
|
-
host: unknown;
|
|
139
|
-
scheme: unknown;
|
|
140
|
-
pathPrefix: unknown;
|
|
141
|
-
siteId: unknown;
|
|
142
|
-
accountId: unknown;
|
|
143
|
-
context: unknown;
|
|
144
|
-
branch: unknown;
|
|
145
|
-
baseRelDir: unknown;
|
|
146
|
-
mode: unknown;
|
|
147
|
-
debug: unknown;
|
|
148
|
-
testOpts: unknown;
|
|
149
|
-
featureFlags: unknown;
|
|
150
|
-
offline: unknown;
|
|
151
|
-
buffer: unknown;
|
|
152
|
-
_: (string | number)[];
|
|
153
|
-
$0: string;
|
|
154
|
-
}>;
|
|
155
|
-
[Symbol.toStringTag]: string;
|
|
156
|
-
}>;
|
|
1
|
+
export declare const parseFlags: () => {
|
|
2
|
+
[k: string]: any;
|
|
3
|
+
};
|
package/lib/bin/flags.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import process from 'process';
|
|
2
|
-
import { includeKeys } from 'filter-obj';
|
|
3
2
|
import yargs from 'yargs';
|
|
4
3
|
import { hideBin } from 'yargs/helpers';
|
|
5
4
|
import { normalizeCliFeatureFlags } from '../options/feature_flags.js';
|
|
@@ -13,7 +12,7 @@ export const parseFlags = function () {
|
|
|
13
12
|
.parse();
|
|
14
13
|
const featureFlags = normalizeCliFeatureFlags(cliFeatureFlags);
|
|
15
14
|
const flagsA = { ...flags, featureFlags };
|
|
16
|
-
const flagsB =
|
|
15
|
+
const flagsB = Object.fromEntries(Object.entries(flagsA).filter(([key, value]) => isUserFlag(key, value)));
|
|
17
16
|
return flagsB;
|
|
18
17
|
};
|
|
19
18
|
const jsonParse = function (value) {
|
package/lib/bin/main.js
CHANGED
|
@@ -21,7 +21,7 @@ const DEFAULT_OUTPUT = '-';
|
|
|
21
21
|
// The result is output as JSON on success (exit code 0)
|
|
22
22
|
const handleCliSuccess = async function (result, stable, output) {
|
|
23
23
|
const resultA = serializeApi(result);
|
|
24
|
-
const resultB = Object.fromEntries(Object.entries(resultA).filter(([key]) => !SECRET_PROPERTIES.
|
|
24
|
+
const resultB = Object.fromEntries(Object.entries(resultA).filter(([key]) => !SECRET_PROPERTIES.has(key)));
|
|
25
25
|
const stringifyFunc = stable ? fastSafeStringify.stableStringify : JSON.stringify;
|
|
26
26
|
const resultJson = stringifyFunc(resultB, null, 2);
|
|
27
27
|
await outputResult(resultJson, output);
|
|
@@ -43,7 +43,7 @@ const serializeApi = function ({ api, ...result }) {
|
|
|
43
43
|
}
|
|
44
44
|
return { ...result, hasApi: true };
|
|
45
45
|
};
|
|
46
|
-
const SECRET_PROPERTIES = ['token'];
|
|
46
|
+
const SECRET_PROPERTIES = new Set(['token']);
|
|
47
47
|
const handleCliError = function (error) {
|
|
48
48
|
// Errors caused by users do not show stack traces and have exit code 1
|
|
49
49
|
if (isUserError(error)) {
|
package/lib/build_dir.js
CHANGED
package/lib/context.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import isPlainObj from 'is-plain-obj';
|
|
2
|
-
import mapObj from 'map-obj';
|
|
3
1
|
import { mergeConfigs } from './merge.js';
|
|
4
2
|
import { normalizeBeforeConfigMerge } from './merge_normalize.js';
|
|
3
|
+
import { isPlainObj } from './utils/is_plain_obj.js';
|
|
5
4
|
import { validateContextsPluginsConfig } from './validate/context.js';
|
|
6
5
|
import { validatePreContextConfig } from './validate/main.js';
|
|
7
6
|
// Validate and normalize `config.context.*`
|
|
@@ -10,11 +9,11 @@ export const normalizeContextProps = function ({ config, config: { context: cont
|
|
|
10
9
|
return config;
|
|
11
10
|
}
|
|
12
11
|
validatePreContextConfig(config);
|
|
13
|
-
const allContextProps =
|
|
14
|
-
const normalizedContextProps =
|
|
12
|
+
const allContextProps = Object.fromEntries(Object.entries(contextProps).map(([key, contextConfig]) => [key, addNamespace(contextConfig)]));
|
|
13
|
+
const normalizedContextProps = Object.fromEntries(Object.entries(allContextProps).map(([key, contextConfig]) => [
|
|
15
14
|
key,
|
|
16
15
|
normalizeBeforeConfigMerge(contextConfig, origin),
|
|
17
|
-
]);
|
|
16
|
+
]));
|
|
18
17
|
return { ...config, context: normalizedContextProps };
|
|
19
18
|
};
|
|
20
19
|
// Merge `config.context.{CONTEXT|BRANCH}.*` to `config.build.*` or `config.*`
|
package/lib/env/git.d.ts
CHANGED
package/lib/env/main.js
CHANGED
|
@@ -143,9 +143,9 @@ const getConfigFileEnv = function ({ config: { build: { environment = {} }, }, }
|
|
|
143
143
|
};
|
|
144
144
|
// Some environment variables cannot be overridden by configuration
|
|
145
145
|
const cleanUserEnv = function (userEnv) {
|
|
146
|
-
return Object.fromEntries(Object.entries(userEnv ?? {}).filter(([key]) => !READONLY_ENV.
|
|
146
|
+
return Object.fromEntries(Object.entries(userEnv ?? {}).filter(([key]) => !READONLY_ENV.has(key)));
|
|
147
147
|
};
|
|
148
|
-
const READONLY_ENV = [
|
|
148
|
+
const READONLY_ENV = new Set([
|
|
149
149
|
// Set in local builds
|
|
150
150
|
'BRANCH',
|
|
151
151
|
'CACHED_COMMIT_REF',
|
|
@@ -167,4 +167,4 @@ const READONLY_ENV = [
|
|
|
167
167
|
'NETLIFY_IMAGES_CDN_DOMAIN',
|
|
168
168
|
'PULL_REQUEST',
|
|
169
169
|
'REVIEW_ID',
|
|
170
|
-
];
|
|
170
|
+
]);
|
package/lib/functions_config.js
CHANGED
package/lib/log/cleanup.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { includeKeys } from 'filter-obj';
|
|
2
1
|
import { simplifyConfig } from '../simplify.js';
|
|
3
2
|
// Make sure we are not printing secret values. Use an allow list.
|
|
4
3
|
export const cleanupConfig = function ({ build: { base, command, commandOrigin, environment = {}, edge_functions: edgeFunctions, ignore, processing, publish, publishOrigin, } = {}, headers, headersOrigin, plugins = [], redirects, redirectsOrigin, baseRelDir, functions, functionsDirectory, }) {
|
|
@@ -47,10 +46,10 @@ const BUILDBOT_ENVIRONMENT = new Set([
|
|
|
47
46
|
'URL',
|
|
48
47
|
]);
|
|
49
48
|
const cleanupPlugin = function ({ package: packageName, origin, inputs = {} }) {
|
|
50
|
-
const inputsA =
|
|
49
|
+
const inputsA = Object.fromEntries(Object.entries(inputs).filter(([, input]) => isPublicInput(input)));
|
|
51
50
|
return { package: packageName, origin, inputs: inputsA };
|
|
52
51
|
};
|
|
53
|
-
const isPublicInput = function (
|
|
52
|
+
const isPublicInput = function (input) {
|
|
54
53
|
return typeof input === 'boolean';
|
|
55
54
|
};
|
|
56
55
|
// `headers` and `redirects` can be very long, which can take several minutes
|
package/lib/log/options.d.ts
CHANGED
|
@@ -9,4 +9,14 @@ export function cleanupConfigOpts({ config, cwd, context, branch, mode, reposito
|
|
|
9
9
|
baseRelDir: any;
|
|
10
10
|
env?: {} | undefined;
|
|
11
11
|
featureFlags?: {} | undefined;
|
|
12
|
-
}):
|
|
12
|
+
}): {
|
|
13
|
+
featureFlags: string[];
|
|
14
|
+
config: any;
|
|
15
|
+
cwd: any;
|
|
16
|
+
context: any;
|
|
17
|
+
branch: any;
|
|
18
|
+
mode: any;
|
|
19
|
+
repositoryRoot: any;
|
|
20
|
+
siteId: any;
|
|
21
|
+
baseRelDir: any;
|
|
22
|
+
};
|
package/lib/log/theme.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export namespace THEME {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
function subHeader(string: any): string;
|
|
3
|
+
function errorSubHeader(string: any): string;
|
|
4
|
+
function warningLine(string: any): string;
|
|
5
|
+
function highlightWords(string: any): string;
|
|
6
6
|
}
|
package/lib/log/theme.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
// Color theme. Please use this instead of requiring
|
|
1
|
+
import { styleText } from 'node:util';
|
|
2
|
+
// Color theme. Please use this instead of requiring styleText directly, to ensure
|
|
3
3
|
// consistent colors.
|
|
4
4
|
export const THEME = {
|
|
5
5
|
// Single lines used as subheaders
|
|
6
|
-
subHeader:
|
|
6
|
+
subHeader: (string) => styleText(['cyan', 'bold'], string),
|
|
7
7
|
// Single lines used as subheaders indicating an error
|
|
8
|
-
errorSubHeader:
|
|
8
|
+
errorSubHeader: (string) => styleText(['red', 'bold'], string),
|
|
9
9
|
// Same for warnings
|
|
10
|
-
warningLine:
|
|
10
|
+
warningLine: (string) => styleText('yellowBright', string),
|
|
11
11
|
// One of several words that should be highlighted inside a line
|
|
12
|
-
highlightWords:
|
|
12
|
+
highlightWords: (string) => styleText('cyan', string),
|
|
13
13
|
};
|
package/lib/merge.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import deepmerge from 'deepmerge';
|
|
2
|
-
import isPlainObj from 'is-plain-obj';
|
|
3
2
|
import { groupBy } from './utils/group.js';
|
|
3
|
+
import { isPlainObj } from './utils/is_plain_obj.js';
|
|
4
4
|
import { removeUndefined } from './utils/remove_falsy.js';
|
|
5
5
|
// Merge an array of configuration objects.
|
|
6
6
|
// Last items have higher priority.
|
package/lib/mutations/apply.js
CHANGED
|
@@ -65,6 +65,15 @@ const MUTABLE_PROPS = {
|
|
|
65
65
|
images: { lastEvent: 'onPostBuild' },
|
|
66
66
|
'images.remote_images': { lastEvent: 'onPostBuild' },
|
|
67
67
|
redirects: { lastEvent: 'onPostBuild' },
|
|
68
|
+
server: { lastEvent: 'onBuild' },
|
|
69
|
+
'server.excludedPath': { lastEvent: 'onBuild' },
|
|
70
|
+
'server.includedFiles': { lastEvent: 'onBuild' },
|
|
71
|
+
'server.path': { lastEvent: 'onBuild' },
|
|
72
|
+
'server.region': { lastEvent: 'onBuild' },
|
|
73
|
+
'server.scale': { lastEvent: 'onBuild' },
|
|
74
|
+
'server.scale.max': { lastEvent: 'onBuild' },
|
|
75
|
+
'server.scale.min': { lastEvent: 'onBuild' },
|
|
76
|
+
'server.size': { lastEvent: 'onBuild' },
|
|
68
77
|
spa_fallback: { lastEvent: 'onPostBuild' },
|
|
69
78
|
dev: { lastEvent: 'onPreDev' },
|
|
70
79
|
'dev.processing': { lastEvent: 'onPreDev' },
|
package/lib/options/main.d.ts
CHANGED
|
@@ -3,5 +3,46 @@ export function addDefaultOpts(opts?: {}): {
|
|
|
3
3
|
stdout: never[];
|
|
4
4
|
stderr: never[];
|
|
5
5
|
} | undefined;
|
|
6
|
+
featureFlags: any;
|
|
7
|
+
env: {};
|
|
8
|
+
context: any;
|
|
9
|
+
branch: any;
|
|
10
|
+
host: any;
|
|
11
|
+
token: any;
|
|
12
|
+
siteId: any;
|
|
13
|
+
deployId: any;
|
|
14
|
+
skewProtectionToken: any;
|
|
15
|
+
buildId: any;
|
|
16
|
+
mode: string;
|
|
17
|
+
offline: boolean;
|
|
18
|
+
debug: boolean;
|
|
19
|
+
buffer: boolean;
|
|
20
|
+
inlineConfig: {};
|
|
21
|
+
configMutations: never[];
|
|
22
|
+
cwd?: undefined;
|
|
23
|
+
defaultConfig: {};
|
|
24
|
+
} | {
|
|
25
|
+
logs: {
|
|
26
|
+
stdout: never[];
|
|
27
|
+
stderr: never[];
|
|
28
|
+
} | undefined;
|
|
29
|
+
featureFlags: any;
|
|
30
|
+
env: {};
|
|
31
|
+
context: any;
|
|
32
|
+
branch: any;
|
|
33
|
+
host: any;
|
|
34
|
+
token: any;
|
|
35
|
+
siteId: any;
|
|
36
|
+
deployId: any;
|
|
37
|
+
skewProtectionToken: any;
|
|
38
|
+
buildId: any;
|
|
39
|
+
mode: string;
|
|
40
|
+
offline: boolean;
|
|
41
|
+
debug: boolean;
|
|
42
|
+
buffer: boolean;
|
|
43
|
+
inlineConfig: {};
|
|
44
|
+
configMutations: never[];
|
|
45
|
+
cwd: string;
|
|
46
|
+
defaultConfig: {};
|
|
6
47
|
};
|
|
7
48
|
export function normalizeOpts(opts: any): Promise<any>;
|
package/lib/options/main.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
2
|
import process from 'process';
|
|
3
|
-
import { isDirectory } from 'path-type';
|
|
4
3
|
import { throwUserError } from '../error.js';
|
|
5
4
|
import { getBufferLogs } from '../log/logger.js';
|
|
6
5
|
import { logOpts } from '../log/main.js';
|
|
6
|
+
import { isDirectory } from '../utils/fs.js';
|
|
7
7
|
import { removeFalsy } from '../utils/remove_falsy.js';
|
|
8
8
|
import { getBaseOverride } from './base.js';
|
|
9
9
|
import { getBranch } from './branch.js';
|
package/lib/path.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { existsSync } from 'fs';
|
|
2
2
|
import { join, resolve } from 'path';
|
|
3
3
|
import { findUp } from 'find-up';
|
|
4
|
-
import pLocate from 'p-locate';
|
|
5
4
|
const FILENAME = 'netlify.toml';
|
|
6
5
|
/**
|
|
7
6
|
* Configuration location can be:
|
|
@@ -12,13 +11,20 @@ const FILENAME = 'netlify.toml';
|
|
|
12
11
|
* - a `netlify.*` file in the current directory or any parent
|
|
13
12
|
*/
|
|
14
13
|
export const getConfigPath = async function ({ configOpt, cwd, repositoryRoot, configBase, packagePath, }) {
|
|
15
|
-
|
|
14
|
+
// Returns the first path that exists, preserving the priority order above.
|
|
15
|
+
const candidates = [
|
|
16
16
|
searchConfigOpt(cwd, configOpt),
|
|
17
17
|
searchBaseConfigFile(repositoryRoot, configBase, packagePath),
|
|
18
18
|
searchConfigFile(repositoryRoot),
|
|
19
19
|
findUp(FILENAME, { cwd }),
|
|
20
|
-
]
|
|
21
|
-
|
|
20
|
+
];
|
|
21
|
+
for (const candidate of candidates) {
|
|
22
|
+
const configPath = await candidate;
|
|
23
|
+
if (configPath) {
|
|
24
|
+
return configPath;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
22
28
|
};
|
|
23
29
|
/** --config CLI flag */
|
|
24
30
|
const searchConfigOpt = function (cwd, configOpt) {
|
package/lib/simplify.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ export function simplifyConfig({ build: { environment, processing: { css, html,
|
|
|
10
10
|
context?: {} | undefined;
|
|
11
11
|
}): any;
|
|
12
12
|
export function removeEmptyObject(object: any, propName: any): {
|
|
13
|
-
[x: number]:
|
|
13
|
+
[x: number]: {
|
|
14
|
+
[x: string]: unknown;
|
|
15
|
+
};
|
|
14
16
|
};
|
|
15
17
|
export function removeEmptyArray(array: any, propName: any): {
|
|
16
18
|
[x: number]: any[];
|
package/lib/simplify.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import isPlainObj from '
|
|
2
|
-
import mapObj from 'map-obj';
|
|
1
|
+
import { isPlainObj } from './utils/is_plain_obj.js';
|
|
3
2
|
import { removeFalsy } from './utils/remove_falsy.js';
|
|
4
3
|
// Removes default values (empty objects and arrays) from the configuration.
|
|
5
4
|
export const simplifyConfig = function ({ build: { environment, processing: { css, html, images, js, ...processing } = {}, services, ...build } = {}, functions, plugins, headers, redirects, context = {}, ...config }) {
|
|
@@ -31,7 +30,7 @@ const simplifyEnvironment = function (environment) {
|
|
|
31
30
|
: removeEmptyObject(environment, 'environment');
|
|
32
31
|
};
|
|
33
32
|
const simplifyContexts = function (contextProps) {
|
|
34
|
-
return
|
|
33
|
+
return Object.fromEntries(Object.entries(contextProps).map(([context, contextConfig]) => simplifyContextProps(context, contextConfig)));
|
|
35
34
|
};
|
|
36
35
|
const simplifyContextProps = function (context, contextConfig) {
|
|
37
36
|
return [context, simplifyConfig(contextConfig)];
|
package/lib/utils/fs.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { stat } from 'node:fs/promises';
|
|
2
|
+
/**
|
|
3
|
+
* Whether `path` exists and is a directory. Returns `false` when the path does
|
|
4
|
+
* not exist, but re-throws any other error (e.g. permission issues).
|
|
5
|
+
*/
|
|
6
|
+
export const isDirectory = async function (path) {
|
|
7
|
+
try {
|
|
8
|
+
return (await stat(path)).isDirectory();
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
if (error.code === 'ENOENT') {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isPlainObj: (value: unknown) => value is Record<string, unknown>;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Remove falsy values from object
|
|
3
3
|
*/
|
|
4
|
-
export declare const removeFalsy: (obj:
|
|
4
|
+
export declare const removeFalsy: <T extends object>(obj: T) => NoFalsyField<T>;
|
|
5
|
+
type NoFalsyField<T> = {
|
|
6
|
+
[P in keyof T]: Exclude<T[P], null | undefined | ''>;
|
|
7
|
+
};
|
|
5
8
|
type NoUndefinedField<T> = {
|
|
6
9
|
[P in keyof T]: Exclude<T[P], null | undefined>;
|
|
7
10
|
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { includeKeys } from 'filter-obj';
|
|
2
1
|
/**
|
|
3
2
|
* Remove falsy values from object
|
|
4
3
|
*/
|
|
5
|
-
export const removeFalsy =
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
export const removeUndefined = (obj) => includeKeys(obj, (_key, value) => isDefined(value));
|
|
4
|
+
export const removeFalsy = (obj) => Object.fromEntries(Object.entries(obj).filter(([, value]) => isTruthy(value)));
|
|
5
|
+
export const removeUndefined = (obj) => Object.fromEntries(Object.entries(obj).filter(([, value]) => isDefined(value)));
|
|
9
6
|
export const isTruthy = (value) => isDefined(value) && (typeof value !== 'string' || value.trim() !== '');
|
|
10
7
|
export const isDefined = (value) => value !== undefined && value !== null;
|
package/lib/utils/set.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import isPlainObj from '
|
|
1
|
+
import { isPlainObj } from './is_plain_obj.js';
|
|
2
2
|
// Set a property deeply using an array of `keys` which can be either strings
|
|
3
3
|
// (object properties) or integers (array indices).
|
|
4
4
|
// Adds default values when intermediary properties are undefined or have the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function isArrayOfObjects(value: any): value is Record<
|
|
1
|
+
export function isArrayOfObjects(value: any): value is Record<string, unknown>[];
|
|
2
2
|
export function isArrayOfStrings(value: any): value is string[];
|
|
3
3
|
export function isString(value: any): value is string;
|
|
4
4
|
export function isBoolean(value: any): value is boolean;
|
package/lib/validate/helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const PRE_CASE_NORMALIZE_VALIDATIONS: {
|
|
2
2
|
property: string;
|
|
3
|
-
check:
|
|
3
|
+
check: (value: unknown) => value is Record<string, unknown>;
|
|
4
4
|
message: string;
|
|
5
5
|
example: () => {
|
|
6
6
|
build: {
|
|
@@ -30,7 +30,7 @@ export const PRE_MERGE_VALIDATIONS: ({
|
|
|
30
30
|
};
|
|
31
31
|
} | {
|
|
32
32
|
property: string;
|
|
33
|
-
check: (value: any) => value is Record<
|
|
33
|
+
check: (value: any) => value is Record<string, unknown>[];
|
|
34
34
|
message: string;
|
|
35
35
|
example: () => {
|
|
36
36
|
plugins: {
|
|
@@ -40,7 +40,7 @@ export const PRE_MERGE_VALIDATIONS: ({
|
|
|
40
40
|
})[];
|
|
41
41
|
export const PRE_CONTEXT_VALIDATIONS: ({
|
|
42
42
|
property: string;
|
|
43
|
-
check:
|
|
43
|
+
check: (value: unknown) => value is Record<string, unknown>;
|
|
44
44
|
message: string;
|
|
45
45
|
example: () => {
|
|
46
46
|
context: {
|
|
@@ -51,7 +51,7 @@ export const PRE_CONTEXT_VALIDATIONS: ({
|
|
|
51
51
|
};
|
|
52
52
|
} | {
|
|
53
53
|
property: string;
|
|
54
|
-
check:
|
|
54
|
+
check: (value: unknown) => value is Record<string, unknown>;
|
|
55
55
|
message: string;
|
|
56
56
|
example: (contextProps: any, key: any) => {
|
|
57
57
|
context: {
|
|
@@ -72,7 +72,7 @@ export const PRE_NORMALIZE_VALIDATIONS: ({
|
|
|
72
72
|
};
|
|
73
73
|
} | {
|
|
74
74
|
property: string;
|
|
75
|
-
check: (value: any) => value is Record<
|
|
75
|
+
check: (value: any) => value is Record<string, unknown>[];
|
|
76
76
|
message: string;
|
|
77
77
|
example: () => {
|
|
78
78
|
plugins: {
|
|
@@ -81,7 +81,7 @@ export const PRE_NORMALIZE_VALIDATIONS: ({
|
|
|
81
81
|
};
|
|
82
82
|
} | {
|
|
83
83
|
property: string;
|
|
84
|
-
check:
|
|
84
|
+
check: (value: unknown) => value is Record<string, unknown>;
|
|
85
85
|
message: string;
|
|
86
86
|
example: () => {
|
|
87
87
|
functions: {
|
|
@@ -90,7 +90,7 @@ export const PRE_NORMALIZE_VALIDATIONS: ({
|
|
|
90
90
|
};
|
|
91
91
|
} | {
|
|
92
92
|
property: string;
|
|
93
|
-
check:
|
|
93
|
+
check: (value: unknown) => value is Record<string, unknown>;
|
|
94
94
|
message: string;
|
|
95
95
|
example: () => {
|
|
96
96
|
functions: {
|
|
@@ -99,7 +99,7 @@ export const PRE_NORMALIZE_VALIDATIONS: ({
|
|
|
99
99
|
};
|
|
100
100
|
} | {
|
|
101
101
|
property: string;
|
|
102
|
-
check: (value: any) => value is Record<
|
|
102
|
+
check: (value: any) => value is Record<string, unknown>[];
|
|
103
103
|
message: string;
|
|
104
104
|
example: () => {
|
|
105
105
|
edge_functions: {
|
|
@@ -109,7 +109,7 @@ export const PRE_NORMALIZE_VALIDATIONS: ({
|
|
|
109
109
|
};
|
|
110
110
|
} | {
|
|
111
111
|
property: string;
|
|
112
|
-
check:
|
|
112
|
+
check: (value: unknown) => value is Record<string, unknown>;
|
|
113
113
|
message: string;
|
|
114
114
|
example: () => {
|
|
115
115
|
database: {
|
|
@@ -120,7 +120,7 @@ export const PRE_NORMALIZE_VALIDATIONS: ({
|
|
|
120
120
|
};
|
|
121
121
|
} | {
|
|
122
122
|
property: string;
|
|
123
|
-
check:
|
|
123
|
+
check: (value: unknown) => value is Record<string, unknown>;
|
|
124
124
|
message: string;
|
|
125
125
|
example: () => {
|
|
126
126
|
server: {
|
|
@@ -234,7 +234,7 @@ export const POST_NORMALIZE_VALIDATIONS: ({
|
|
|
234
234
|
};
|
|
235
235
|
} | {
|
|
236
236
|
property: string;
|
|
237
|
-
check:
|
|
237
|
+
check: (value: unknown) => value is Record<string, unknown>;
|
|
238
238
|
message: string;
|
|
239
239
|
example: (value: any, key: any, prevPath: any) => {
|
|
240
240
|
functions: {
|
|
@@ -446,4 +446,3 @@ export const POST_NORMALIZE_VALIDATIONS: ({
|
|
|
446
446
|
};
|
|
447
447
|
};
|
|
448
448
|
})[];
|
|
449
|
-
import isPlainObj from 'is-plain-obj';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CronExpressionParser } from 'cron-parser';
|
|
2
|
-
import isPlainObj from 'is-plain-obj';
|
|
3
2
|
import validateNpmPackageName from 'validate-npm-package-name';
|
|
4
3
|
import { validations as edgeFunctionValidations, EDGE_FUNCTIONS_PROPERTIES } from '../edge_functions.js';
|
|
5
4
|
import { bundlers, WILDCARD_ALL as FUNCTIONS_CONFIG_WILDCARD_ALL } from '../functions_config.js';
|
|
5
|
+
import { isPlainObj } from '../utils/is_plain_obj.js';
|
|
6
6
|
import { functionsDirectoryCheck, isArrayOfObjects, isArrayOfStrings, isBoolean, isString, validProperties, } from './helpers.js';
|
|
7
7
|
/**
|
|
8
8
|
* @param {string} cron
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/config",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.7.0",
|
|
4
4
|
"description": "Netlify config module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -65,20 +65,14 @@
|
|
|
65
65
|
"@netlify/api": "^15.1.6",
|
|
66
66
|
"@netlify/headers-parser": "^10.1.1",
|
|
67
67
|
"@netlify/redirect-parser": "^16.1.1",
|
|
68
|
-
"chalk": "^6.0.0",
|
|
69
68
|
"cron-parser": "^5.0.0",
|
|
70
69
|
"deepmerge": "^4.2.2",
|
|
71
70
|
"dot-prop": "^9.0.0",
|
|
72
71
|
"execa": "^8.0.0",
|
|
73
72
|
"fast-safe-stringify": "^2.0.7",
|
|
74
73
|
"figures": "^6.0.0",
|
|
75
|
-
"filter-obj": "^6.0.0",
|
|
76
74
|
"find-up": "^7.0.0",
|
|
77
75
|
"indent-string": "^5.0.0",
|
|
78
|
-
"is-plain-obj": "^4.0.0",
|
|
79
|
-
"map-obj": "^5.0.0",
|
|
80
|
-
"p-locate": "^6.0.0",
|
|
81
|
-
"path-type": "^6.0.0",
|
|
82
76
|
"read-package-up": "^11.0.0",
|
|
83
77
|
"smol-toml": "^1.5.2",
|
|
84
78
|
"tomlify-j0.4": "^3.0.0",
|
|
@@ -93,11 +87,10 @@
|
|
|
93
87
|
"ajv": "^8.20.0",
|
|
94
88
|
"has-ansi": "^6.0.0",
|
|
95
89
|
"is-ci": "^4.0.0",
|
|
96
|
-
"tmp-promise": "^3.0.2",
|
|
97
90
|
"vitest": "^3.0.0"
|
|
98
91
|
},
|
|
99
92
|
"engines": {
|
|
100
93
|
"node": ">=22.12.0"
|
|
101
94
|
},
|
|
102
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "d5f4f4b6b9dc08bb3b9641b0e547c46d9c045662"
|
|
103
96
|
}
|