@adobe/helix-config 4.5.2 → 4.5.3
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/CHANGELOG.md +7 -0
- package/package.json +3 -3
- package/src/config-merge.js +19 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [4.5.3](https://github.com/adobe/helix-config/compare/v4.5.2...v4.5.3) (2024-09-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* dedupe sidekick plugins when merging site with profile ([#189](https://github.com/adobe/helix-config/issues/189)) ([69d32da](https://github.com/adobe/helix-config/commit/69d32da8c771f37b77cbc9047b45160d547e3b6d)), closes [#188](https://github.com/adobe/helix-config/issues/188)
|
|
7
|
+
|
|
1
8
|
## [4.5.2](https://github.com/adobe/helix-config/compare/v4.5.1...v4.5.2) (2024-09-13)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-config",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.3",
|
|
4
4
|
"description": "Helix Config",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"@semantic-release/npm": "12.0.1",
|
|
42
42
|
"c8": "10.1.2",
|
|
43
43
|
"eslint": "8.57.0",
|
|
44
|
-
"husky": "9.1.
|
|
44
|
+
"husky": "9.1.6",
|
|
45
45
|
"junit-report-builder": "5.0.0",
|
|
46
46
|
"lint-staged": "15.2.10",
|
|
47
47
|
"mocha": "10.7.3",
|
|
48
48
|
"mocha-multi-reporters": "1.5.1",
|
|
49
49
|
"mocha-suppress-logs": "0.5.1",
|
|
50
50
|
"nock": "13.5.5",
|
|
51
|
-
"semantic-release": "24.1.
|
|
51
|
+
"semantic-release": "24.1.1"
|
|
52
52
|
},
|
|
53
53
|
"lint-staged": {
|
|
54
54
|
"*.js": "eslint",
|
package/src/config-merge.js
CHANGED
|
@@ -38,6 +38,9 @@ const ROOT_PROPERTIES = {
|
|
|
38
38
|
|
|
39
39
|
const FORCED_TYPES = {
|
|
40
40
|
'.cdn.prod.route': 'array',
|
|
41
|
+
'.sidekick.plugins': 'id-array',
|
|
42
|
+
'.headers': 'modifier',
|
|
43
|
+
'.metadata': 'modifier',
|
|
41
44
|
};
|
|
42
45
|
|
|
43
46
|
/**
|
|
@@ -48,10 +51,9 @@ const FORCED_TYPES = {
|
|
|
48
51
|
* - some well known paths are forced to be arrays
|
|
49
52
|
* @param {object} dst
|
|
50
53
|
* @param {object} src
|
|
51
|
-
* @param {
|
|
52
|
-
* merging
|
|
54
|
+
* @param {string} [path]
|
|
53
55
|
*/
|
|
54
|
-
function merge(dst, src, path
|
|
56
|
+
function merge(dst, src, path) {
|
|
55
57
|
for (const [key, value] of Object.entries(src)) {
|
|
56
58
|
const itemPath = `${path}.${key}`;
|
|
57
59
|
if (value === '') {
|
|
@@ -88,7 +90,7 @@ function merge(dst, src, path, isModifier) {
|
|
|
88
90
|
if (typeof item === 'object') {
|
|
89
91
|
// todo: handle arrays in arrays eventually
|
|
90
92
|
// special case for modifier sheets
|
|
91
|
-
if (
|
|
93
|
+
if (FORCED_TYPES[path] === 'modifier' && item.key) {
|
|
92
94
|
const idx = dstArray.findIndex((i) => i.key === item.key);
|
|
93
95
|
if (idx >= 0) {
|
|
94
96
|
dstArray.splice(idx, 1);
|
|
@@ -98,9 +100,16 @@ function merge(dst, src, path, isModifier) {
|
|
|
98
100
|
continue;
|
|
99
101
|
}
|
|
100
102
|
}
|
|
103
|
+
if (FORCED_TYPES[itemPath] === 'id-array' && item.id !== undefined) {
|
|
104
|
+
// special case for id arrays
|
|
105
|
+
const idx = dstArray.findIndex((i) => i.id === item.id);
|
|
106
|
+
if (idx >= 0) {
|
|
107
|
+
dstArray.splice(idx, 1);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
101
110
|
const dstObj = Object.create(null);
|
|
102
111
|
dstArray.push(dstObj);
|
|
103
|
-
merge(dstObj, item, itemPath
|
|
112
|
+
merge(dstObj, item, itemPath);
|
|
104
113
|
} else if (!dstArray.includes(item)) {
|
|
105
114
|
dstArray.push(item);
|
|
106
115
|
}
|
|
@@ -108,26 +117,26 @@ function merge(dst, src, path, isModifier) {
|
|
|
108
117
|
} else {
|
|
109
118
|
// handle plain object
|
|
110
119
|
// eslint-disable-next-line no-use-before-define
|
|
111
|
-
mergeObject(dst, key, value, `${path}.${key}
|
|
120
|
+
mergeObject(dst, key, value, `${path}.${key}`);
|
|
112
121
|
}
|
|
113
122
|
}
|
|
114
123
|
}
|
|
115
124
|
|
|
116
|
-
function mergeObject(dst, key, value, path
|
|
125
|
+
function mergeObject(dst, key, value, path) {
|
|
117
126
|
const dstObj = dst[key] ?? Object.create(null);
|
|
118
127
|
if (!dst[key]) {
|
|
119
128
|
dst[key] = dstObj;
|
|
120
129
|
}
|
|
121
|
-
merge(dstObj, value, path
|
|
130
|
+
merge(dstObj, value, path);
|
|
122
131
|
}
|
|
123
132
|
|
|
124
133
|
function mergeConfig(dst, src) {
|
|
125
|
-
Object.entries(ROOT_PROPERTIES).forEach(([key, { atomic
|
|
134
|
+
Object.entries(ROOT_PROPERTIES).forEach(([key, { atomic }]) => {
|
|
126
135
|
if (src[key]) {
|
|
127
136
|
if (atomic) {
|
|
128
137
|
dst[key] = src[key];
|
|
129
138
|
} else {
|
|
130
|
-
mergeObject(dst, key, src[key], `.${key}
|
|
139
|
+
mergeObject(dst, key, src[key], `.${key}`);
|
|
131
140
|
}
|
|
132
141
|
}
|
|
133
142
|
});
|