@voxgig/model 2.2.0 → 2.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.
|
@@ -5,8 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.local_builder = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
// import fresh from 'import-fresh'
|
|
9
|
-
const clear_module_1 = __importDefault(require("clear-module"));
|
|
10
8
|
// Runs any builders local to the repo.
|
|
11
9
|
const local_builder = async (build) => {
|
|
12
10
|
try {
|
|
@@ -26,11 +24,8 @@ const local_builder = async (build) => {
|
|
|
26
24
|
// console.log('LOCAL BUILDER', name)
|
|
27
25
|
let builder = builders[name];
|
|
28
26
|
let action_path = path_1.default.join(root, builder.load);
|
|
29
|
-
|
|
30
|
-
// console.log('ACTION PATH', name, action_path)
|
|
31
|
-
(0, clear_module_1.default)(action_path);
|
|
27
|
+
clear(action_path);
|
|
32
28
|
let action = require(action_path);
|
|
33
|
-
// let action: any = fresh(action_path)
|
|
34
29
|
let br = await action(build.model, build);
|
|
35
30
|
ok = ok && null != br && br.ok;
|
|
36
31
|
brlog.push(br);
|
|
@@ -43,4 +38,27 @@ const local_builder = async (build) => {
|
|
|
43
38
|
}
|
|
44
39
|
};
|
|
45
40
|
exports.local_builder = local_builder;
|
|
41
|
+
// Adapted from https://github.com/sindresorhus/import-fresh - Thanks!
|
|
42
|
+
function clear(path) {
|
|
43
|
+
let filePath = require.resolve(path);
|
|
44
|
+
// console.log('CM fp', filePath)
|
|
45
|
+
if (require.cache[filePath]) {
|
|
46
|
+
const children = require.cache[filePath].children.map(child => child.id);
|
|
47
|
+
// console.log('CM-B', filePath, children)
|
|
48
|
+
// Delete module from cache
|
|
49
|
+
delete require.cache[filePath];
|
|
50
|
+
for (const id of children) {
|
|
51
|
+
clear(id);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (require.cache[filePath] && require.cache[filePath].parent) {
|
|
55
|
+
let i = require.cache[filePath].parent.children.length;
|
|
56
|
+
// console.log('CM-A', filePath, require.cache[filePath].parent.children)
|
|
57
|
+
while (i--) {
|
|
58
|
+
if (require.cache[filePath].parent.children[i].id === filePath) {
|
|
59
|
+
require.cache[filePath].parent.children.splice(i, 1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
46
64
|
//# sourceMappingURL=local.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../../lib/builder/local.ts"],"names":[],"mappings":";;;;;;AACA,gDAAuB;
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../../lib/builder/local.ts"],"names":[],"mappings":";;;;;;AACA,gDAAuB;AAKvB,uCAAuC;AACvC,MAAM,aAAa,GAAY,KAAK,EAAE,KAAY,EAAE,EAAE;IACpD,IAAI,CAAC;QACH,+CAA+C;QAC/C,IAAI,IAAI,GAAG,cAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;QAE/C,6BAA6B;QAC7B,mCAAmC;QACnC,IAAI,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAA;QAElC,IAAI,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAA;QAC/C,8BAA8B;QAC9B,uCAAuC;QAEvC,IAAI,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAA;QAExC,IAAI,EAAE,GAAG,IAAI,CAAA;QACb,IAAI,KAAK,GAAG,EAAE,CAAA;QAEd,kCAAkC;QAClC,KAAK,IAAI,IAAI,IAAI,QAAQ,EAAE,CAAC;YAC1B,qCAAqC;YAErC,IAAI,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA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AAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;QAC9D,IAAI,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAA;QAEtD,yEAAyE;QAEzE,OAAO,CAAC,EAAE,EAAE,CAAC;YACX,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;gBAC/D,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YACtD,CAAC;QACH,CAAC;IACH,CAAC;AAEH,CAAC"}
|
package/lib/builder/local.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import Path from 'path'
|
|
3
3
|
|
|
4
|
-
// import fresh from 'import-fresh'
|
|
5
|
-
import clear from 'clear-module'
|
|
6
|
-
|
|
7
4
|
import { Build, Builder } from '../build'
|
|
8
5
|
|
|
9
6
|
|
|
@@ -33,12 +30,8 @@ const local_builder: Builder = async (build: Build) => {
|
|
|
33
30
|
let builder = builders[name]
|
|
34
31
|
let action_path = Path.join(root, builder.load)
|
|
35
32
|
|
|
36
|
-
// TODO: need to watch these files too, and their deps!
|
|
37
|
-
// console.log('ACTION PATH', name, action_path)
|
|
38
|
-
|
|
39
33
|
clear(action_path)
|
|
40
34
|
let action = require(action_path)
|
|
41
|
-
// let action: any = fresh(action_path)
|
|
42
35
|
let br = await action(build.model, build)
|
|
43
36
|
ok = ok && null != br && br.ok
|
|
44
37
|
brlog.push(br)
|
|
@@ -52,6 +45,41 @@ const local_builder: Builder = async (build: Build) => {
|
|
|
52
45
|
|
|
53
46
|
}
|
|
54
47
|
|
|
48
|
+
|
|
49
|
+
// Adapted from https://github.com/sindresorhus/import-fresh - Thanks!
|
|
50
|
+
function clear(path: string) {
|
|
51
|
+
let filePath = require.resolve(path)
|
|
52
|
+
// console.log('CM fp', filePath)
|
|
53
|
+
|
|
54
|
+
if (require.cache[filePath]) {
|
|
55
|
+
const children = require.cache[filePath].children.map(child => child.id)
|
|
56
|
+
|
|
57
|
+
// console.log('CM-B', filePath, children)
|
|
58
|
+
|
|
59
|
+
// Delete module from cache
|
|
60
|
+
delete require.cache[filePath]
|
|
61
|
+
|
|
62
|
+
for (const id of children) {
|
|
63
|
+
clear(id)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
if (require.cache[filePath] && require.cache[filePath].parent) {
|
|
69
|
+
let i = require.cache[filePath].parent.children.length
|
|
70
|
+
|
|
71
|
+
// console.log('CM-A', filePath, require.cache[filePath].parent.children)
|
|
72
|
+
|
|
73
|
+
while (i--) {
|
|
74
|
+
if (require.cache[filePath].parent.children[i].id === filePath) {
|
|
75
|
+
require.cache[filePath].parent.children.splice(i, 1)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
55
83
|
export {
|
|
56
84
|
local_builder
|
|
57
85
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voxgig/model",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"main": "dist/model.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"types": "dist/model.d.ts",
|
|
@@ -46,13 +46,11 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@voxgig/util": "^0.0.3",
|
|
48
48
|
"aontu": "0.21.1",
|
|
49
|
-
"chokidar": "3.6.0"
|
|
50
|
-
"clear-module": "^4.1.2",
|
|
51
|
-
"import-fresh": "^3.3.0"
|
|
49
|
+
"chokidar": "3.6.0"
|
|
52
50
|
},
|
|
53
51
|
"devDependencies": {
|
|
54
52
|
"@types/jest": "^29.5.12",
|
|
55
|
-
"@types/node": "22.
|
|
53
|
+
"@types/node": "22.3.0",
|
|
56
54
|
"es-jest": "^2.1.0",
|
|
57
55
|
"esbuild": "^0.23.0",
|
|
58
56
|
"esbuild-jest": "^0.5.0",
|