@netlify/config 25.2.4 → 25.2.6
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/main.js +11 -4
- package/lib/validate/validations.d.ts +1 -1
- package/lib/validate/validations.js +24 -2
- package/package.json +2 -2
package/lib/main.js
CHANGED
|
@@ -39,7 +39,7 @@ export const resolveConfig = async function (opts) {
|
|
|
39
39
|
const extensionApiBaseUrl = host?.includes(NETLIFY_API_STAGING_HOSTNAME)
|
|
40
40
|
? EXTENSION_API_STAGING_BASE_URL
|
|
41
41
|
: EXTENSION_API_BASE_URL;
|
|
42
|
-
const { config: configOpt, defaultConfig, inlineConfig, configMutations, cwd, context, repositoryRoot, base, branch, siteId, accountId, deployId, skewProtectionToken, buildId, baseRelDir, mode, debug, logs, featureFlags, } = await normalizeOpts(optsA);
|
|
42
|
+
const { config: configOpt, defaultConfig, inlineConfig, configMutations, configMutationsOrigin, cwd, context, repositoryRoot, base, branch, siteId, accountId, deployId, skewProtectionToken, buildId, baseRelDir, mode, debug, logs, featureFlags, } = await normalizeOpts(optsA);
|
|
43
43
|
let { siteInfo, accounts, integrations: extensions } = parsedCachedConfig || {};
|
|
44
44
|
// If we have cached site info, we don't need to fetch it again
|
|
45
45
|
const useCachedSiteInfo = Boolean(featureFlags?.use_cached_site_info && siteInfo && accounts && extensions);
|
|
@@ -83,6 +83,7 @@ export const resolveConfig = async function (opts) {
|
|
|
83
83
|
branch,
|
|
84
84
|
defaultConfig: defaultConfigA,
|
|
85
85
|
inlineConfig: inlineConfigA,
|
|
86
|
+
configMutationsOrigin,
|
|
86
87
|
baseRelDir: baseRelDirA,
|
|
87
88
|
logs,
|
|
88
89
|
featureFlags,
|
|
@@ -157,7 +158,7 @@ const addLegacyFunctionsDirectory = (config) => {
|
|
|
157
158
|
* The first pass uses the `defaultConfig`'s `build.base` (if defined).
|
|
158
159
|
* The second pass uses the `build.base` from the first pass (if defined).
|
|
159
160
|
*/
|
|
160
|
-
const loadConfig = async function ({ configOpt, cwd, context, repositoryRoot, packagePath, branch, defaultConfig, inlineConfig, baseRelDir, logs, featureFlags, }) {
|
|
161
|
+
const loadConfig = async function ({ configOpt, cwd, context, repositoryRoot, packagePath, branch, defaultConfig, inlineConfig, configMutationsOrigin, baseRelDir, logs, featureFlags, }) {
|
|
161
162
|
const initialBase = getInitialBase({ repositoryRoot, defaultConfig, inlineConfig });
|
|
162
163
|
const { configPath, config, buildDir, base, redirectsPath, headersPath } = await getFullConfig({
|
|
163
164
|
configOpt,
|
|
@@ -167,6 +168,7 @@ const loadConfig = async function ({ configOpt, cwd, context, repositoryRoot, pa
|
|
|
167
168
|
branch,
|
|
168
169
|
defaultConfig,
|
|
169
170
|
inlineConfig,
|
|
171
|
+
configMutationsOrigin,
|
|
170
172
|
baseRelDir,
|
|
171
173
|
packagePath,
|
|
172
174
|
configBase: initialBase,
|
|
@@ -190,6 +192,7 @@ const loadConfig = async function ({ configOpt, cwd, context, repositoryRoot, pa
|
|
|
190
192
|
branch,
|
|
191
193
|
defaultConfig,
|
|
192
194
|
inlineConfig,
|
|
195
|
+
configMutationsOrigin,
|
|
193
196
|
baseRelDir,
|
|
194
197
|
configBase: base,
|
|
195
198
|
base,
|
|
@@ -207,7 +210,7 @@ const loadConfig = async function ({ configOpt, cwd, context, repositoryRoot, pa
|
|
|
207
210
|
/**
|
|
208
211
|
* Load configuration file and normalize it, merge contexts, etc.
|
|
209
212
|
*/
|
|
210
|
-
const getFullConfig = async function ({ configOpt, cwd, context, repositoryRoot, packagePath, branch, defaultConfig, inlineConfig, baseRelDir, configBase, base, logs, featureFlags, }) {
|
|
213
|
+
const getFullConfig = async function ({ configOpt, cwd, context, repositoryRoot, packagePath, branch, defaultConfig, inlineConfig, configMutationsOrigin, baseRelDir, configBase, base, logs, featureFlags, }) {
|
|
211
214
|
const configPath = await getConfigPath({ configOpt, cwd, repositoryRoot, packagePath, configBase });
|
|
212
215
|
try {
|
|
213
216
|
const config = await parseConfig(configPath);
|
|
@@ -221,7 +224,11 @@ const getFullConfig = async function ({ configOpt, cwd, context, repositoryRoot,
|
|
|
221
224
|
}
|
|
222
225
|
catch (error) {
|
|
223
226
|
const configName = configPath === undefined ? '' : ` file ${configPath}`;
|
|
224
|
-
|
|
227
|
+
// The invalid value is not in the config file when it came from a mutation.
|
|
228
|
+
const stage = configMutationsOrigin === undefined
|
|
229
|
+
? `resolving config${configName}`
|
|
230
|
+
: `applying configuration from ${configMutationsOrigin}`;
|
|
231
|
+
error.message = `When ${stage}:\n${error.message}`;
|
|
225
232
|
throw error;
|
|
226
233
|
}
|
|
227
234
|
};
|
|
@@ -299,7 +299,7 @@ export const POST_NORMALIZE_VALIDATIONS: ({
|
|
|
299
299
|
};
|
|
300
300
|
} | {
|
|
301
301
|
property: string;
|
|
302
|
-
check: (value: any) =>
|
|
302
|
+
check: (value: any) => boolean;
|
|
303
303
|
message: string;
|
|
304
304
|
example: (value: any, key: any, prevPath: any) => {
|
|
305
305
|
functions: {
|
|
@@ -17,6 +17,20 @@ const isValidCronExpression = (cron) => {
|
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
+
const FUNCTION_MEMORY_PATTERN = /^(\d+(?:\.\d+)?)\s*(mb|gb)?$/i;
|
|
21
|
+
const FUNCTION_MEMORY_MIN_MB = 1024;
|
|
22
|
+
const FUNCTION_MEMORY_MAX_MB = 4096;
|
|
23
|
+
const isValidFunctionMemory = (value) => {
|
|
24
|
+
let megabytes = value;
|
|
25
|
+
if (isString(value)) {
|
|
26
|
+
const match = FUNCTION_MEMORY_PATTERN.exec(value.trim());
|
|
27
|
+
if (!match) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
megabytes = Number.parseFloat(match[1]) * (match[2]?.toLowerCase() === 'gb' ? 1024 : 1);
|
|
31
|
+
}
|
|
32
|
+
return Number.isInteger(megabytes) && megabytes >= FUNCTION_MEMORY_MIN_MB && megabytes <= FUNCTION_MEMORY_MAX_MB;
|
|
33
|
+
};
|
|
20
34
|
// List of validations performed on the configuration file.
|
|
21
35
|
// Validation are performed in order: parent should be before children.
|
|
22
36
|
// Each validation is an object with the following properties:
|
|
@@ -273,8 +287,8 @@ export const POST_NORMALIZE_VALIDATIONS = [
|
|
|
273
287
|
},
|
|
274
288
|
{
|
|
275
289
|
property: 'functions.*.memory',
|
|
276
|
-
check:
|
|
277
|
-
message: 'must be a number (in MB) or a string with a unit (e.g. "2gb").',
|
|
290
|
+
check: isValidFunctionMemory,
|
|
291
|
+
message: 'must be between 1024 and 4096 MB, as a number (in MB) or a string with a unit (e.g. "2gb").',
|
|
278
292
|
example: (value, key, prevPath) => ({
|
|
279
293
|
functions: { [prevPath[1]]: { memory: '2gb' } },
|
|
280
294
|
}),
|
|
@@ -295,6 +309,14 @@ export const POST_NORMALIZE_VALIDATIONS = [
|
|
|
295
309
|
functions: { [prevPath[1]]: { vcpu: 1.5 } },
|
|
296
310
|
}),
|
|
297
311
|
},
|
|
312
|
+
{
|
|
313
|
+
property: 'functions.*',
|
|
314
|
+
check: (functionConfig) => !(functionConfig.memory !== undefined && functionConfig.vcpu !== undefined),
|
|
315
|
+
message: '"memory" and "vcpu" are mutually exclusive.',
|
|
316
|
+
example: (value, key, prevPath) => ({
|
|
317
|
+
functions: { [prevPath[1]]: { memory: '2gb' } },
|
|
318
|
+
}),
|
|
319
|
+
},
|
|
298
320
|
{
|
|
299
321
|
property: 'functions.*.schedule',
|
|
300
322
|
check: isValidCronExpression,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/config",
|
|
3
|
-
"version": "25.2.
|
|
3
|
+
"version": "25.2.6",
|
|
4
4
|
"description": "Netlify config module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"engines": {
|
|
95
95
|
"node": ">=22.12.0"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "227492a17c9821682390f6b7554bd69dfa282d9e"
|
|
98
98
|
}
|