mod-build 4.0.95-beta.1 → 4.0.96-beta.1
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 +4 -0
- package/package.json +1 -1
- package/tasks/get-default-trade-questions.js +33 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.0.96
|
|
4
|
+
|
|
5
|
+
- Added `resolveRefs()` to `get-default-trade-questions.js` to resolve JSON `$ref` placeholders, cutting down on repeated content in trade-questions config
|
|
6
|
+
|
|
3
7
|
## 4.0.95
|
|
4
8
|
|
|
5
9
|
- Fix lazy-load HTML transform that treated `data-img-class="lazy"` as a `class="lazy"` match and rewrote `data-img-src` to `data-img-data-src`; now only real `class`, `src`, `srcset`, and `href` attributes are affected
|
package/package.json
CHANGED
|
@@ -2,6 +2,37 @@
|
|
|
2
2
|
import merge from 'lodash.merge';
|
|
3
3
|
import { defaultSettings } from '../src/data/config.js';
|
|
4
4
|
|
|
5
|
+
function resolveRefs(value, root, refChain = new Set()) {
|
|
6
|
+
if (value === null || typeof value !== 'object') {
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (Array.isArray(value)) {
|
|
11
|
+
return value.map((item) => resolveRefs(item, root, refChain));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (typeof value.$ref === 'string') {
|
|
15
|
+
if (refChain.has(value.$ref)) {
|
|
16
|
+
throw new Error(`Circular $ref detected: ${[...refChain, value.$ref].join(' -> ')}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const refValue = root[value.$ref];
|
|
20
|
+
if (!refValue || typeof refValue !== 'object') {
|
|
21
|
+
throw new Error(`Could not resolve $ref: ${value.$ref}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return resolveRefs(refValue, root, new Set(refChain).add(value.$ref));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const resolved = {};
|
|
28
|
+
for (const key in value) {
|
|
29
|
+
if (value.hasOwnProperty(key)) {
|
|
30
|
+
resolved[key] = resolveRefs(value[key], root, refChain);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return resolved;
|
|
34
|
+
}
|
|
35
|
+
|
|
5
36
|
function mergeDefaultTradeQuestionsConfigOnSteps(config, steps) {
|
|
6
37
|
if (!config || typeof config !== 'object') return;
|
|
7
38
|
|
|
@@ -204,7 +235,8 @@ export default async function(config) {
|
|
|
204
235
|
steps.OwnHome = commonQuestions.OwnHome;
|
|
205
236
|
steps.BuyTimeframe = commonQuestions.BuyTimeframe;
|
|
206
237
|
|
|
207
|
-
|
|
238
|
+
const resolvedSteps = resolveRefs(steps, steps);
|
|
239
|
+
mergeDefaultTradeQuestionsConfigOnSteps(config, resolvedSteps);
|
|
208
240
|
resolve();
|
|
209
241
|
})
|
|
210
242
|
.catch(error => {
|