xcraft-core-utils 4.0.0 → 4.2.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/index.js +1 -0
- package/lib/modules.js +9 -3
- package/lib/whereIs.js +13 -0
- package/package.json +7 -2
package/index.js
CHANGED
|
@@ -16,6 +16,7 @@ exports.propTypes = require('./lib/prop-types.js');
|
|
|
16
16
|
exports.reflect = require('./lib/reflect.js');
|
|
17
17
|
exports.regex = require('./lib/regex.js');
|
|
18
18
|
exports.string = require('./lib/string.js');
|
|
19
|
+
exports.whereIs = require('./lib/whereIs.js');
|
|
19
20
|
exports.yaml = require('./lib/yaml.js');
|
|
20
21
|
|
|
21
22
|
exports.RankedCache = require('./lib/ranked-cache.js');
|
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;
|
|
@@ -47,10 +53,10 @@ exports.extractForEtc = (appDir, appId, variantId) => {
|
|
|
47
53
|
fse.readFileSync(path.join(appDir, appId, 'app.json'))
|
|
48
54
|
);
|
|
49
55
|
applyOverloads(appDir, appId, variantId, appConfig);
|
|
50
|
-
|
|
56
|
+
merge(app.xcraft[mod.moduleName], appConfig.xcraft[mod.moduleName]);
|
|
51
57
|
});
|
|
52
58
|
|
|
53
|
-
|
|
59
|
+
merge(app.xcraft[mod.moduleName], userOverloads);
|
|
54
60
|
delete app.xcraft[`${mod.moduleName}@${mod.fullAppId}`];
|
|
55
61
|
});
|
|
56
62
|
|
package/lib/whereIs.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fse = require('fs-extra');
|
|
3
|
+
|
|
4
|
+
module.exports = function whereIs(bin) {
|
|
5
|
+
var fullLocation = null;
|
|
6
|
+
|
|
7
|
+
var exists = process.env.PATH.split(path.delimiter).some(function (location) {
|
|
8
|
+
fullLocation = path.join(location, bin);
|
|
9
|
+
return fse.existsSync(fullLocation);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
return exists ? fullLocation : null;
|
|
13
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xcraft-core-utils",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Xcraft utils",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"escape-regexp": "0.0.1",
|
|
27
27
|
"escape-string-regexp": "^1.0.5",
|
|
28
28
|
"figlet": "^1.2.1",
|
|
29
|
+
"fs-extra": "^9.1.0",
|
|
29
30
|
"gigawatts": "^4.0.1",
|
|
30
31
|
"js-yaml": "^3.9.0",
|
|
31
32
|
"linked-list": "^1.0.4",
|
|
@@ -33,13 +34,17 @@
|
|
|
33
34
|
"locks": "^0.2.2",
|
|
34
35
|
"prop-types": "^15.7.2",
|
|
35
36
|
"uuid": "^8.3.2",
|
|
36
|
-
"xcraft-core-
|
|
37
|
+
"xcraft-core-busclient": "^5.0.0",
|
|
38
|
+
"xcraft-core-fs": "^2.0.0",
|
|
39
|
+
"xcraft-core-log": "^2.0.0",
|
|
40
|
+
"xcraft-core-utils": "^4.0.0"
|
|
37
41
|
},
|
|
38
42
|
"bugs": {
|
|
39
43
|
"url": "https://github.com/Xcraft-Inc/xcraft-core-utils/issues"
|
|
40
44
|
},
|
|
41
45
|
"homepage": "https://github.com/Xcraft-Inc/xcraft-core-utils#readme",
|
|
42
46
|
"devDependencies": {
|
|
47
|
+
"should": "^11.2.1",
|
|
43
48
|
"prettier": "2.0.4",
|
|
44
49
|
"xcraft-dev-prettier": "^2.0.0",
|
|
45
50
|
"xcraft-dev-rules": "^2.0.0"
|