@netlify/config 24.2.1 → 24.3.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/context.js +21 -1
- package/package.json +2 -2
package/lib/context.js
CHANGED
|
@@ -26,9 +26,29 @@ export const mergeContext = function ({ config: { context: contextProps, ...conf
|
|
|
26
26
|
}
|
|
27
27
|
const contexts = [context, branch];
|
|
28
28
|
validateContextsPluginsConfig({ contextProps, plugins, contexts, logs });
|
|
29
|
-
const filteredContextProps = contexts.
|
|
29
|
+
const filteredContextProps = contexts.flatMap((key) => findMatchingContextProps(contextProps, key)).filter(Boolean);
|
|
30
30
|
return mergeConfigs([config, ...filteredContextProps]);
|
|
31
31
|
};
|
|
32
|
+
// Find matching context properties for a given key.
|
|
33
|
+
// First tries exact match, then falls back to wildcard pattern matching.
|
|
34
|
+
// Wildcard patterns use prefix matching with '*' suffix (e.g., "feat/*" matches "feat/my-branch").
|
|
35
|
+
const findMatchingContextProps = function (contextProps, key) {
|
|
36
|
+
if (!key) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
// Exact match takes precedence
|
|
40
|
+
if (contextProps[key]) {
|
|
41
|
+
return [contextProps[key]];
|
|
42
|
+
}
|
|
43
|
+
// Fall back to wildcard pattern matching
|
|
44
|
+
const matchingProps = [];
|
|
45
|
+
for (const [pattern, value] of Object.entries(contextProps)) {
|
|
46
|
+
if (pattern.endsWith('*') && key.startsWith(pattern.slice(0, -1))) {
|
|
47
|
+
matchingProps.push(value);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return matchingProps;
|
|
51
|
+
};
|
|
32
52
|
// `config.context.{context}.*` properties are merged either to `config.*` or
|
|
33
53
|
// to `config.build.*`. We distinguish between both by checking the property
|
|
34
54
|
// name.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/config",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.3.0",
|
|
4
4
|
"description": "Netlify config module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"engines": {
|
|
97
97
|
"node": ">=18.14.0"
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "b361a613025153da728f16946fb3e2f784127d1a"
|
|
100
100
|
}
|