xcraft-core-utils 4.1.0 → 4.3.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/lib/modules.js +14 -3
- package/package.json +1 -1
package/lib/modules.js
CHANGED
|
@@ -5,6 +5,12 @@ const fse = require('fs-extra');
|
|
|
5
5
|
const xFs = require('xcraft-core-fs');
|
|
6
6
|
const _ = require('lodash');
|
|
7
7
|
|
|
8
|
+
function merge(obj, overloads) {
|
|
9
|
+
_.mergeWith(obj, overloads, (_, src) =>
|
|
10
|
+
Array.isArray(src) && src.length === 0 ? [] : undefined
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
function applyOverloads(appDir, appId, variantId, app) {
|
|
9
15
|
if (!variantId) {
|
|
10
16
|
return;
|
|
@@ -14,7 +20,7 @@ function applyOverloads(appDir, appId, variantId, app) {
|
|
|
14
20
|
const overloads = JSON.parse(
|
|
15
21
|
fse.readFileSync(path.join(appDir, appId, `app.${variantId}.json`))
|
|
16
22
|
);
|
|
17
|
-
|
|
23
|
+
merge(app.xcraft, overloads);
|
|
18
24
|
} catch (ex) {
|
|
19
25
|
if (ex.code !== 'ENOENT') {
|
|
20
26
|
throw ex;
|
|
@@ -22,6 +28,8 @@ function applyOverloads(appDir, appId, variantId, app) {
|
|
|
22
28
|
}
|
|
23
29
|
}
|
|
24
30
|
|
|
31
|
+
exports.mergeOverloads = merge;
|
|
32
|
+
|
|
25
33
|
exports.extractForEtc = (appDir, appId, variantId) => {
|
|
26
34
|
const app = JSON.parse(
|
|
27
35
|
fse.readFileSync(path.join(appDir, appId, 'app.json'))
|
|
@@ -47,10 +55,10 @@ exports.extractForEtc = (appDir, appId, variantId) => {
|
|
|
47
55
|
fse.readFileSync(path.join(appDir, appId, 'app.json'))
|
|
48
56
|
);
|
|
49
57
|
applyOverloads(appDir, appId, variantId, appConfig);
|
|
50
|
-
|
|
58
|
+
merge(app.xcraft[mod.moduleName], appConfig.xcraft[mod.moduleName]);
|
|
51
59
|
});
|
|
52
60
|
|
|
53
|
-
|
|
61
|
+
merge(app.xcraft[mod.moduleName], userOverloads);
|
|
54
62
|
delete app.xcraft[`${mod.moduleName}@${mod.fullAppId}`];
|
|
55
63
|
});
|
|
56
64
|
|
|
@@ -161,6 +169,9 @@ exports.extractAllJs = (libDir, modules) => {
|
|
|
161
169
|
const location = path.join(libDir, mod);
|
|
162
170
|
const files = xFs
|
|
163
171
|
.lsall(location, true)
|
|
172
|
+
.filter(
|
|
173
|
+
(file) => !/node_modules/.test(file.substring(location.length + 1))
|
|
174
|
+
)
|
|
164
175
|
.filter((file) => /\.js$/.test(file));
|
|
165
176
|
list = list.concat(files);
|
|
166
177
|
});
|