neex 0.6.13 → 0.6.14
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/dev-runner.js +62 -28
- package/package.json +1 -1
package/dist/src/dev-runner.js
CHANGED
|
@@ -44,7 +44,8 @@ class DevRunner {
|
|
|
44
44
|
ext: ['js', 'mjs', 'json', 'ts', 'tsx', 'jsx'],
|
|
45
45
|
delay: 1000,
|
|
46
46
|
verbose: false,
|
|
47
|
-
|
|
47
|
+
showInfo: false,
|
|
48
|
+
runnerName: 'neex dev',
|
|
48
49
|
};
|
|
49
50
|
this.options = {
|
|
50
51
|
...defaultOptions,
|
|
@@ -57,7 +58,7 @@ class DevRunner {
|
|
|
57
58
|
ignore: this.options.ignore,
|
|
58
59
|
ext: this.options.ext,
|
|
59
60
|
delay: this.options.delay,
|
|
60
|
-
verbose:
|
|
61
|
+
verbose: false // Always set to false to hide watcher logs
|
|
61
62
|
};
|
|
62
63
|
this.fileWatcher = new watcher_1.FileWatcher(watchOptions);
|
|
63
64
|
this.fileWatcher.on('change', (event) => {
|
|
@@ -67,8 +68,6 @@ class DevRunner {
|
|
|
67
68
|
});
|
|
68
69
|
}
|
|
69
70
|
async handleFileChange(event) {
|
|
70
|
-
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
71
|
-
logger_1.default.printLine(`${prefix} File changed: ${chalk_1.default.yellow(event.relativePath)}`, 'info');
|
|
72
71
|
if (this.options.clearConsole) {
|
|
73
72
|
console.clear();
|
|
74
73
|
}
|
|
@@ -78,31 +77,52 @@ class DevRunner {
|
|
|
78
77
|
if (this.commands.length === 0) {
|
|
79
78
|
return [];
|
|
80
79
|
}
|
|
81
|
-
|
|
80
|
+
// Create a modified options object for the runner to clean up output
|
|
81
|
+
const runnerOptions = {
|
|
82
|
+
...this.options,
|
|
83
|
+
// Override prefix behavior to show clean command name
|
|
84
|
+
customPrefix: (command) => {
|
|
85
|
+
// Extract just the filename from the command
|
|
86
|
+
const match = command.match(/(?:npx ts-node|node)\s+(.+)/);
|
|
87
|
+
if (match) {
|
|
88
|
+
const filePath = match[1];
|
|
89
|
+
const fileName = filePath.split('/').pop() || filePath;
|
|
90
|
+
return `${fileName}`;
|
|
91
|
+
}
|
|
92
|
+
return command;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
this.runner = new runner_1.Runner(runnerOptions);
|
|
82
96
|
try {
|
|
83
97
|
const results = await this.runner.run(this.commands);
|
|
84
98
|
return results;
|
|
85
99
|
}
|
|
86
100
|
catch (error) {
|
|
87
|
-
|
|
101
|
+
if (this.options.showInfo) {
|
|
102
|
+
logger_1.default.printLine(`Execution failed: ${error.message}`, 'error');
|
|
103
|
+
}
|
|
88
104
|
return [];
|
|
89
105
|
}
|
|
90
106
|
}
|
|
91
107
|
printDevBanner() {
|
|
92
|
-
var _a, _b;
|
|
108
|
+
var _a, _b, _c;
|
|
109
|
+
if (!this.options.showInfo) {
|
|
110
|
+
return; // Don't show banner if showInfo is false
|
|
111
|
+
}
|
|
93
112
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
94
113
|
const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
|
|
95
114
|
const uptimeStr = this.formatUptime(uptime);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
console.log(`${prefix} ${
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
115
|
+
if (this.options.showInfo) {
|
|
116
|
+
console.log(chalk_1.default.blue(`${prefix} ${figures_1.default.info} Starting file watcher...`));
|
|
117
|
+
console.log(chalk_1.default.blue(`${prefix} ${figures_1.default.info} File watcher started. Monitoring ${((_a = this.options.watch) === null || _a === void 0 ? void 0 : _a.length) || 1} locations`));
|
|
118
|
+
console.log(chalk_1.default.blue(`${prefix} ${figures_1.default.info} Watching extensions: ${((_b = this.options.ext) === null || _b === void 0 ? void 0 : _b.join(', ')) || 'js, mjs, json, ts, tsx, jsx, vue, svelte'}`));
|
|
119
|
+
console.log(chalk_1.default.blue(`${prefix} ${figures_1.default.info} Uptime: ${uptimeStr}`));
|
|
120
|
+
console.log(chalk_1.default.blue(`${prefix} ${figures_1.default.info} Watching: ${((_c = this.options.watch) === null || _c === void 0 ? void 0 : _c.join(', ')) || 'current directory'}`));
|
|
121
|
+
if (this.restartCount > 0) {
|
|
122
|
+
console.log(chalk_1.default.blue(`${prefix} ${figures_1.default.info} Restarted ${this.restartCount} times`));
|
|
123
|
+
}
|
|
124
|
+
console.log('');
|
|
104
125
|
}
|
|
105
|
-
console.log('');
|
|
106
126
|
}
|
|
107
127
|
formatUptime(seconds) {
|
|
108
128
|
if (seconds < 60) {
|
|
@@ -125,7 +145,7 @@ class DevRunner {
|
|
|
125
145
|
this.startTime = new Date();
|
|
126
146
|
// Setup file watcher
|
|
127
147
|
this.setupFileWatcher();
|
|
128
|
-
// Print development banner
|
|
148
|
+
// Print development banner only if showInfo is true
|
|
129
149
|
this.printDevBanner();
|
|
130
150
|
// Start file watcher
|
|
131
151
|
if (this.fileWatcher) {
|
|
@@ -133,19 +153,25 @@ class DevRunner {
|
|
|
133
153
|
}
|
|
134
154
|
// Run initial commands
|
|
135
155
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
136
|
-
|
|
156
|
+
if (this.options.showInfo) {
|
|
157
|
+
logger_1.default.printLine(`${prefix} Starting development server...`, 'info');
|
|
158
|
+
}
|
|
137
159
|
await this.runCommands();
|
|
138
160
|
// Set up graceful shutdown
|
|
139
161
|
this.setupGracefulShutdown();
|
|
140
|
-
|
|
141
|
-
|
|
162
|
+
if (this.options.showInfo) {
|
|
163
|
+
logger_1.default.printLine(`${prefix} Development server started. Watching for changes...`, 'info');
|
|
164
|
+
logger_1.default.printLine(`${prefix} Press ${chalk_1.default.cyan('Ctrl+C')} to stop`, 'info');
|
|
165
|
+
}
|
|
142
166
|
}
|
|
143
167
|
async restart() {
|
|
144
168
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
145
169
|
if (!this.isRunning) {
|
|
146
170
|
return;
|
|
147
171
|
}
|
|
148
|
-
|
|
172
|
+
if (this.options.showInfo) {
|
|
173
|
+
logger_1.default.printLine(`${prefix} Restarting due to file changes...`, 'info');
|
|
174
|
+
}
|
|
149
175
|
this.restartCount++;
|
|
150
176
|
// Stop current processes
|
|
151
177
|
if (this.runner) {
|
|
@@ -153,18 +179,22 @@ class DevRunner {
|
|
|
153
179
|
}
|
|
154
180
|
// Wait a moment before restarting
|
|
155
181
|
await new Promise(resolve => setTimeout(resolve, 500));
|
|
156
|
-
// Print restart banner
|
|
182
|
+
// Print restart banner only if showInfo is true
|
|
157
183
|
this.printDevBanner();
|
|
158
184
|
// Run commands again
|
|
159
185
|
await this.runCommands();
|
|
160
|
-
|
|
186
|
+
if (this.options.showInfo) {
|
|
187
|
+
logger_1.default.printLine(`${prefix} Restart completed. Watching for changes...`, 'info');
|
|
188
|
+
}
|
|
161
189
|
}
|
|
162
190
|
async stop() {
|
|
163
191
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
164
192
|
if (!this.isRunning) {
|
|
165
193
|
return;
|
|
166
194
|
}
|
|
167
|
-
|
|
195
|
+
if (this.options.showInfo) {
|
|
196
|
+
logger_1.default.printLine(`${prefix} Stopping development server...`, 'info');
|
|
197
|
+
}
|
|
168
198
|
this.isRunning = false;
|
|
169
199
|
// Stop file watcher
|
|
170
200
|
if (this.fileWatcher) {
|
|
@@ -176,14 +206,18 @@ class DevRunner {
|
|
|
176
206
|
}
|
|
177
207
|
const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
|
|
178
208
|
const uptimeStr = this.formatUptime(uptime);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
209
|
+
if (this.options.showInfo) {
|
|
210
|
+
logger_1.default.printLine(`${prefix} ${this.options.runnerName} development server stopped after ${uptimeStr}`, 'info');
|
|
211
|
+
if (this.restartCount > 0) {
|
|
212
|
+
logger_1.default.printLine(`${prefix} Total restarts: ${this.restartCount}`, 'info');
|
|
213
|
+
}
|
|
182
214
|
}
|
|
183
215
|
}
|
|
184
216
|
setupGracefulShutdown() {
|
|
185
217
|
const handleSignal = (signal) => {
|
|
186
|
-
|
|
218
|
+
if (this.options.showInfo) {
|
|
219
|
+
console.log(`\n${chalk_1.default.yellow(`${figures_1.default.warning} Received ${signal}. Shutting down development server...`)}`);
|
|
220
|
+
}
|
|
187
221
|
this.stop().then(() => {
|
|
188
222
|
process.exit(0);
|
|
189
223
|
});
|