@eventra_dev/eventra-cli 0.1.12 → 0.1.13
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/dist/commands/watch.js +5 -6
- package/dist/engine/engine.js +6 -3
- package/package.json +1 -1
- package/src/commands/watch.ts +8 -7
- package/src/engine/engine.ts +6 -3
package/dist/commands/watch.js
CHANGED
|
@@ -13,6 +13,7 @@ const config_1 = require("../utils/config");
|
|
|
13
13
|
const engine_1 = require("../engine/engine");
|
|
14
14
|
const processFile_1 = require("../utils/processFile");
|
|
15
15
|
async function watch() {
|
|
16
|
+
process.env.EVENTRA_WATCH = "1";
|
|
16
17
|
const config = await (0, config_1.loadConfig)();
|
|
17
18
|
if (!config)
|
|
18
19
|
return;
|
|
@@ -42,11 +43,9 @@ async function watch() {
|
|
|
42
43
|
config.events = engine.getAllEvents().sort();
|
|
43
44
|
await (0, config_1.saveConfig)(config);
|
|
44
45
|
console.log(chalk_1.default.gray(`Initial: ${config.events.length} events\n`));
|
|
45
|
-
// WATCH STATE
|
|
46
46
|
let locked = false;
|
|
47
47
|
let queued = new Set();
|
|
48
48
|
let timer = null;
|
|
49
|
-
// RUN BATCH
|
|
50
49
|
const run = async () => {
|
|
51
50
|
if (locked)
|
|
52
51
|
return;
|
|
@@ -55,8 +54,10 @@ async function watch() {
|
|
|
55
54
|
queued.clear();
|
|
56
55
|
for (const file of batch) {
|
|
57
56
|
try {
|
|
58
|
-
const
|
|
59
|
-
const
|
|
57
|
+
const abs = path_1.default.resolve(file);
|
|
58
|
+
const raw = await promises_1.default.readFile(abs, "utf-8");
|
|
59
|
+
const { content, virtualFile } = (0, processFile_1.processFile)(abs, raw);
|
|
60
|
+
engine["ts"].updateFile(virtualFile, content);
|
|
60
61
|
engine.updateFile(virtualFile, content, config);
|
|
61
62
|
}
|
|
62
63
|
catch {
|
|
@@ -75,7 +76,6 @@ async function watch() {
|
|
|
75
76
|
}
|
|
76
77
|
locked = false;
|
|
77
78
|
};
|
|
78
|
-
// SCHEDULER
|
|
79
79
|
const schedule = (file) => {
|
|
80
80
|
const abs = path_1.default.resolve(file);
|
|
81
81
|
queued.add(abs);
|
|
@@ -83,7 +83,6 @@ async function watch() {
|
|
|
83
83
|
clearTimeout(timer);
|
|
84
84
|
timer = setTimeout(run, 100);
|
|
85
85
|
};
|
|
86
|
-
// WATCHER
|
|
87
86
|
const watcher = chokidar_1.default.watch(config.sync.include, {
|
|
88
87
|
ignored: config.sync.exclude,
|
|
89
88
|
ignoreInitial: true,
|
package/dist/engine/engine.js
CHANGED
|
@@ -19,8 +19,9 @@ class EventraEngine {
|
|
|
19
19
|
// SCAN FILE
|
|
20
20
|
scanFile(file, content, config) {
|
|
21
21
|
const h = (0, hash_1.hash)(content);
|
|
22
|
+
const isWatch = process.env.EVENTRA_WATCH === "1";
|
|
22
23
|
// skip unchanged
|
|
23
|
-
if (this.fileHash.get(file) === h) {
|
|
24
|
+
if (this.fileHash.get(file) === h && !isWatch) {
|
|
24
25
|
return (this.fileResults.get(file) ?? {
|
|
25
26
|
events: new Set(),
|
|
26
27
|
detectedFunctionWrappers: new Set(),
|
|
@@ -60,8 +61,9 @@ class EventraEngine {
|
|
|
60
61
|
if (!depContent)
|
|
61
62
|
continue;
|
|
62
63
|
const h = (0, hash_1.hash)(depContent);
|
|
64
|
+
const isWatch = process.env.EVENTRA_WATCH === "1";
|
|
63
65
|
// skip unchanged dependents
|
|
64
|
-
if (this.fileHash.get(dep) === h)
|
|
66
|
+
if (this.fileHash.get(dep) === h && !isWatch)
|
|
65
67
|
continue;
|
|
66
68
|
this.fileHash.set(dep, h);
|
|
67
69
|
this.graph.update(dep, source);
|
|
@@ -96,8 +98,9 @@ class EventraEngine {
|
|
|
96
98
|
if (!content)
|
|
97
99
|
continue;
|
|
98
100
|
const h = (0, hash_1.hash)(content);
|
|
101
|
+
const isWatch = process.env.EVENTRA_WATCH === "1";
|
|
99
102
|
// skip unchanged
|
|
100
|
-
if (this.fileHash.get(dep) === h)
|
|
103
|
+
if (this.fileHash.get(dep) === h && !isWatch)
|
|
101
104
|
continue;
|
|
102
105
|
this.fileHash.set(dep, h);
|
|
103
106
|
const r = (0, scanner_1.scanSource)(source, checker, config ?? {
|
package/package.json
CHANGED
package/src/commands/watch.ts
CHANGED
|
@@ -9,6 +9,8 @@ import { EventraEngine } from "../engine/engine";
|
|
|
9
9
|
import { processFile } from "../utils/processFile";
|
|
10
10
|
|
|
11
11
|
export async function watch() {
|
|
12
|
+
process.env.EVENTRA_WATCH = "1";
|
|
13
|
+
|
|
12
14
|
const config = await loadConfig();
|
|
13
15
|
if (!config) return;
|
|
14
16
|
|
|
@@ -50,12 +52,10 @@ export async function watch() {
|
|
|
50
52
|
chalk.gray(`Initial: ${config.events.length} events\n`)
|
|
51
53
|
);
|
|
52
54
|
|
|
53
|
-
// WATCH STATE
|
|
54
55
|
let locked = false;
|
|
55
56
|
let queued = new Set<string>();
|
|
56
57
|
let timer: NodeJS.Timeout | null = null;
|
|
57
58
|
|
|
58
|
-
// RUN BATCH
|
|
59
59
|
const run = async () => {
|
|
60
60
|
if (locked) return;
|
|
61
61
|
locked = true;
|
|
@@ -65,9 +65,13 @@ export async function watch() {
|
|
|
65
65
|
|
|
66
66
|
for (const file of batch) {
|
|
67
67
|
try {
|
|
68
|
-
const
|
|
69
|
-
|
|
68
|
+
const abs = path.resolve(file);
|
|
69
|
+
|
|
70
|
+
const raw = await fs.readFile(abs, "utf-8");
|
|
70
71
|
|
|
72
|
+
const { content, virtualFile } = processFile(abs, raw);
|
|
73
|
+
|
|
74
|
+
engine["ts"].updateFile(virtualFile, content);
|
|
71
75
|
engine.updateFile(virtualFile, content, config);
|
|
72
76
|
|
|
73
77
|
} catch {
|
|
@@ -95,17 +99,14 @@ export async function watch() {
|
|
|
95
99
|
locked = false;
|
|
96
100
|
};
|
|
97
101
|
|
|
98
|
-
// SCHEDULER
|
|
99
102
|
const schedule = (file: string) => {
|
|
100
103
|
const abs = path.resolve(file);
|
|
101
|
-
|
|
102
104
|
queued.add(abs);
|
|
103
105
|
|
|
104
106
|
if (timer) clearTimeout(timer);
|
|
105
107
|
timer = setTimeout(run, 100);
|
|
106
108
|
};
|
|
107
109
|
|
|
108
|
-
// WATCHER
|
|
109
110
|
const watcher = chokidar.watch(config.sync.include, {
|
|
110
111
|
ignored: config.sync.exclude,
|
|
111
112
|
ignoreInitial: true,
|
package/src/engine/engine.ts
CHANGED
|
@@ -26,9 +26,10 @@ export class EventraEngine {
|
|
|
26
26
|
config: EventraConfig
|
|
27
27
|
): ScanResult {
|
|
28
28
|
const h = hash(content);
|
|
29
|
+
const isWatch = process.env.EVENTRA_WATCH === "1";
|
|
29
30
|
|
|
30
31
|
// skip unchanged
|
|
31
|
-
if (this.fileHash.get(file) === h) {
|
|
32
|
+
if (this.fileHash.get(file) === h && !isWatch) {
|
|
32
33
|
return (
|
|
33
34
|
this.fileResults.get(file) ?? {
|
|
34
35
|
events: new Set(),
|
|
@@ -85,9 +86,10 @@ export class EventraEngine {
|
|
|
85
86
|
if (!depContent) continue;
|
|
86
87
|
|
|
87
88
|
const h = hash(depContent);
|
|
89
|
+
const isWatch = process.env.EVENTRA_WATCH === "1";
|
|
88
90
|
|
|
89
91
|
// skip unchanged dependents
|
|
90
|
-
if (this.fileHash.get(dep) === h) continue;
|
|
92
|
+
if (this.fileHash.get(dep) === h && !isWatch) continue;
|
|
91
93
|
|
|
92
94
|
this.fileHash.set(dep, h);
|
|
93
95
|
|
|
@@ -131,9 +133,10 @@ export class EventraEngine {
|
|
|
131
133
|
if (!content) continue;
|
|
132
134
|
|
|
133
135
|
const h = hash(content);
|
|
136
|
+
const isWatch = process.env.EVENTRA_WATCH === "1";
|
|
134
137
|
|
|
135
138
|
// skip unchanged
|
|
136
|
-
if (this.fileHash.get(dep) === h) continue;
|
|
139
|
+
if (this.fileHash.get(dep) === h && !isWatch) continue;
|
|
137
140
|
|
|
138
141
|
this.fileHash.set(dep, h);
|
|
139
142
|
|