neex 0.6.42 → 0.6.44
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/src/commands/dev-commands.js +0 -2
- package/dist/src/dev-runner.js +0 -12
- package/dist/src/watcher.js +25 -10
- package/package.json +1 -1
|
@@ -199,9 +199,7 @@ function addDevCommands(program) {
|
|
|
199
199
|
getDevRunner: () => devRunner,
|
|
200
200
|
cleanupDev: () => {
|
|
201
201
|
if (devRunner && devRunner.isActive()) {
|
|
202
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Stopping development server...`));
|
|
203
202
|
devRunner.stop();
|
|
204
|
-
console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Development server stopped successfully`));
|
|
205
203
|
}
|
|
206
204
|
}
|
|
207
205
|
};
|
package/dist/src/dev-runner.js
CHANGED
|
@@ -195,9 +195,6 @@ class DevRunner {
|
|
|
195
195
|
if (!this.isRunning) {
|
|
196
196
|
return;
|
|
197
197
|
}
|
|
198
|
-
if (this.options.showInfo) {
|
|
199
|
-
logger_1.default.printLine(`${prefix} Stopping development server...`, 'info');
|
|
200
|
-
}
|
|
201
198
|
this.isRunning = false;
|
|
202
199
|
// Stop file watcher
|
|
203
200
|
if (this.fileWatcher) {
|
|
@@ -209,18 +206,9 @@ class DevRunner {
|
|
|
209
206
|
}
|
|
210
207
|
const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
|
|
211
208
|
const uptimeStr = this.formatUptime(uptime);
|
|
212
|
-
if (this.options.showInfo) {
|
|
213
|
-
logger_1.default.printLine(`${prefix} ${this.options.runnerName} development server stopped after ${uptimeStr}`, 'info');
|
|
214
|
-
if (this.restartCount > 0) {
|
|
215
|
-
logger_1.default.printLine(`${prefix} Total restarts: ${this.restartCount}`, 'info');
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
209
|
}
|
|
219
210
|
setupGracefulShutdown() {
|
|
220
211
|
const handleSignal = (signal) => {
|
|
221
|
-
if (this.options.showInfo) {
|
|
222
|
-
console.log(`\n${chalk_1.default.yellow(`${figures_1.default.warning} Received ${signal}. Shutting down development server...`)}`);
|
|
223
|
-
}
|
|
224
212
|
this.stop().then(() => {
|
|
225
213
|
process.exit(0);
|
|
226
214
|
});
|
package/dist/src/watcher.js
CHANGED
|
@@ -32,7 +32,17 @@ const fs = __importStar(require("fs"));
|
|
|
32
32
|
const path = __importStar(require("path"));
|
|
33
33
|
const events_1 = require("events");
|
|
34
34
|
const chalk_1 = __importDefault(require("chalk"));
|
|
35
|
-
|
|
35
|
+
// A simple, self-contained logger for this module.
|
|
36
|
+
const logger = {
|
|
37
|
+
printLine: (message, level = 'info') => {
|
|
38
|
+
const prefix = {
|
|
39
|
+
info: chalk_1.default.blue('i'),
|
|
40
|
+
warn: chalk_1.default.yellow('!'),
|
|
41
|
+
error: chalk_1.default.red('x'),
|
|
42
|
+
}[level];
|
|
43
|
+
console.log(`${prefix} ${message}`);
|
|
44
|
+
},
|
|
45
|
+
};
|
|
36
46
|
class FileWatcher extends events_1.EventEmitter {
|
|
37
47
|
constructor(options) {
|
|
38
48
|
super();
|
|
@@ -121,7 +131,7 @@ class FileWatcher extends events_1.EventEmitter {
|
|
|
121
131
|
try {
|
|
122
132
|
const absolutePath = path.resolve(dirPath);
|
|
123
133
|
if (this.options.verbose) {
|
|
124
|
-
|
|
134
|
+
logger.printLine(`Watching directory: ${chalk_1.default.cyan(absolutePath)}`, 'info');
|
|
125
135
|
}
|
|
126
136
|
const watcher = fs.watch(absolutePath, { recursive: true }, async (eventType, filename) => {
|
|
127
137
|
if (!filename)
|
|
@@ -139,7 +149,7 @@ class FileWatcher extends events_1.EventEmitter {
|
|
|
139
149
|
}
|
|
140
150
|
catch (error) {
|
|
141
151
|
if (this.options.verbose) {
|
|
142
|
-
|
|
152
|
+
logger.printLine(`Failed to watch directory ${dirPath}: ${error.message}`, 'warn');
|
|
143
153
|
}
|
|
144
154
|
}
|
|
145
155
|
}
|
|
@@ -153,7 +163,7 @@ class FileWatcher extends events_1.EventEmitter {
|
|
|
153
163
|
return;
|
|
154
164
|
}
|
|
155
165
|
if (this.options.verbose) {
|
|
156
|
-
|
|
166
|
+
logger.printLine(`Watching file: ${chalk_1.default.cyan(absolutePath)}`, 'info');
|
|
157
167
|
}
|
|
158
168
|
const watcher = fs.watch(absolutePath, (eventType) => {
|
|
159
169
|
this.handleFileChange(absolutePath, eventType);
|
|
@@ -163,13 +173,13 @@ class FileWatcher extends events_1.EventEmitter {
|
|
|
163
173
|
}
|
|
164
174
|
catch (error) {
|
|
165
175
|
if (this.options.verbose) {
|
|
166
|
-
|
|
176
|
+
logger.printLine(`Failed to watch file ${filePath}: ${error.message}`, 'warn');
|
|
167
177
|
}
|
|
168
178
|
}
|
|
169
179
|
}
|
|
170
180
|
handleFileChange(filePath, eventType) {
|
|
171
181
|
if (this.options.verbose) {
|
|
172
|
-
|
|
182
|
+
logger.printLine(`File ${eventType}: ${chalk_1.default.yellow(path.relative(process.cwd(), filePath))}`, 'info');
|
|
173
183
|
}
|
|
174
184
|
// Debounce file changes
|
|
175
185
|
if (this.debounceTimer) {
|
|
@@ -188,7 +198,7 @@ class FileWatcher extends events_1.EventEmitter {
|
|
|
188
198
|
return;
|
|
189
199
|
}
|
|
190
200
|
this.isWatching = true;
|
|
191
|
-
|
|
201
|
+
logger.printLine('Starting file watcher...', 'info');
|
|
192
202
|
for (const watchPath of this.options.watch) {
|
|
193
203
|
const absolutePath = path.resolve(watchPath);
|
|
194
204
|
try {
|
|
@@ -201,15 +211,20 @@ class FileWatcher extends events_1.EventEmitter {
|
|
|
201
211
|
}
|
|
202
212
|
}
|
|
203
213
|
catch (error) {
|
|
204
|
-
|
|
214
|
+
logger.printLine(`Cannot watch ${watchPath}: ${error.message}`, 'warn');
|
|
205
215
|
}
|
|
206
216
|
}
|
|
217
|
+
const watchedCount = this.watchers.length;
|
|
218
|
+
logger.printLine(`File watcher started. Monitoring ${chalk_1.default.green(watchedCount)} locations`, 'info');
|
|
219
|
+
if (this.options.ext && this.options.ext.length > 0) {
|
|
220
|
+
logger.printLine(`Watching extensions: ${chalk_1.default.cyan(this.options.ext.join(', '))}`, 'info');
|
|
221
|
+
}
|
|
207
222
|
}
|
|
208
223
|
stop() {
|
|
209
224
|
if (!this.isWatching) {
|
|
210
225
|
return;
|
|
211
226
|
}
|
|
212
|
-
|
|
227
|
+
logger.printLine('Stopping file watcher...', 'info');
|
|
213
228
|
this.watchers.forEach(watcher => {
|
|
214
229
|
try {
|
|
215
230
|
watcher.close();
|
|
@@ -225,7 +240,7 @@ class FileWatcher extends events_1.EventEmitter {
|
|
|
225
240
|
clearTimeout(this.debounceTimer);
|
|
226
241
|
this.debounceTimer = null;
|
|
227
242
|
}
|
|
228
|
-
|
|
243
|
+
logger.printLine('File watcher stopped', 'info');
|
|
229
244
|
}
|
|
230
245
|
isActive() {
|
|
231
246
|
return this.isWatching;
|