neex 0.6.2 → 0.6.4
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/README.md +1 -1
- package/dist/src/commands/dev-commands.js +26 -20
- package/dist/src/dev-runner.js +54 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ async function fileExists(filePath) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
// Helper function to determine the best command to run the file
|
|
46
|
-
async function getBestCommand(filePath, showInfo
|
|
46
|
+
async function getBestCommand(filePath, showInfo) {
|
|
47
47
|
const ext = path.extname(filePath).toLowerCase();
|
|
48
48
|
const absolutePath = path.resolve(process.cwd(), filePath);
|
|
49
49
|
// Check if file exists
|
|
@@ -94,12 +94,15 @@ function addDevCommands(program) {
|
|
|
94
94
|
.option('-d, --delay <ms>', 'Delay before restart in milliseconds', parseInt)
|
|
95
95
|
.option('--clear', 'Clear console on restart')
|
|
96
96
|
.option('--verbose', 'Verbose output')
|
|
97
|
-
.option('--info', 'Show detailed information
|
|
97
|
+
.option('--info', 'Show detailed information during startup')
|
|
98
98
|
.option('--signal <signal>', 'Signal to send to processes on restart', 'SIGTERM')
|
|
99
99
|
.action(async (file, options) => {
|
|
100
100
|
try {
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
const showInfo = options.info || false;
|
|
102
|
+
if (showInfo) {
|
|
103
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Starting enhanced development server...`));
|
|
104
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Target file: ${chalk_1.default.cyan(file)}`));
|
|
105
|
+
}
|
|
103
106
|
// Validate file parameter
|
|
104
107
|
if (!file || file.trim() === '') {
|
|
105
108
|
console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: Error - No file specified!`));
|
|
@@ -111,7 +114,7 @@ function addDevCommands(program) {
|
|
|
111
114
|
let commandToExecute;
|
|
112
115
|
let fileExtension;
|
|
113
116
|
try {
|
|
114
|
-
commandToExecute = await getBestCommand(file);
|
|
117
|
+
commandToExecute = await getBestCommand(file, showInfo);
|
|
115
118
|
fileExtension = path.extname(file).toLowerCase();
|
|
116
119
|
}
|
|
117
120
|
catch (error) {
|
|
@@ -134,19 +137,24 @@ function addDevCommands(program) {
|
|
|
134
137
|
'Thumbs.db'
|
|
135
138
|
];
|
|
136
139
|
const extensions = options.ext || ['js', 'mjs', 'json', 'ts', 'tsx', 'jsx', 'vue', 'svelte'];
|
|
137
|
-
// Log configuration
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
140
|
+
// Log configuration only if --info flag is set
|
|
141
|
+
if (showInfo) {
|
|
142
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Configuration:`));
|
|
143
|
+
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Target: ${chalk_1.default.cyan(file)}`));
|
|
144
|
+
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Runtime: ${chalk_1.default.cyan(fileExtension === '.ts' || fileExtension === '.mts' || fileExtension === '.cts' ? 'TypeScript' : 'JavaScript')}`));
|
|
145
|
+
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Watch paths: ${chalk_1.default.cyan(watchPaths.join(', '))}`));
|
|
146
|
+
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Extensions: ${chalk_1.default.cyan(extensions.join(', '))}`));
|
|
147
|
+
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Restart delay: ${chalk_1.default.cyan(options.delay || 1000)}ms`));
|
|
148
|
+
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Clear console: ${chalk_1.default.cyan(options.clear ? 'Yes' : 'No')}`));
|
|
149
|
+
if (options.verbose) {
|
|
150
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Verbose mode enabled - showing detailed logs`));
|
|
151
|
+
}
|
|
152
|
+
console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Starting file watcher and process manager...`));
|
|
153
|
+
console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Launching ${chalk_1.default.cyan(path.basename(file))} with auto-restart capability...`));
|
|
154
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Press Ctrl+C to stop the development server`));
|
|
155
|
+
console.log(chalk_1.default.gray(`${'='.repeat(60)}`));
|
|
147
156
|
}
|
|
148
|
-
|
|
149
|
-
// Create DevRunner instance - remove customPrefix since it doesn't exist
|
|
157
|
+
// Create DevRunner instance
|
|
150
158
|
devRunner = new dev_runner_js_1.DevRunner({
|
|
151
159
|
runnerName: 'neex dev',
|
|
152
160
|
parallel: false,
|
|
@@ -162,15 +170,13 @@ function addDevCommands(program) {
|
|
|
162
170
|
delay: options.delay || 1000,
|
|
163
171
|
clearConsole: options.clear,
|
|
164
172
|
verbose: options.verbose,
|
|
173
|
+
showInfo: showInfo,
|
|
165
174
|
signal: options.signal,
|
|
166
175
|
restartOnChange: true,
|
|
167
176
|
groupOutput: false,
|
|
168
177
|
isServerMode: false
|
|
169
178
|
});
|
|
170
179
|
// Start the development server
|
|
171
|
-
console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Launching ${chalk_1.default.cyan(path.basename(file))} with auto-restart capability...`));
|
|
172
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Press Ctrl+C to stop the development server`));
|
|
173
|
-
console.log(chalk_1.default.gray(`${'='.repeat(60)}`));
|
|
174
180
|
await devRunner.start([commandToExecute]);
|
|
175
181
|
}
|
|
176
182
|
catch (error) {
|
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: this.options.verbose
|
|
61
|
+
verbose: this.options.verbose && this.options.showInfo // Only show verbose watcher logs if both verbose and showInfo are true
|
|
61
62
|
};
|
|
62
63
|
this.fileWatcher = new watcher_1.FileWatcher(watchOptions);
|
|
63
64
|
this.fileWatcher.on('change', (event) => {
|
|
@@ -68,7 +69,9 @@ class DevRunner {
|
|
|
68
69
|
}
|
|
69
70
|
async handleFileChange(event) {
|
|
70
71
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
71
|
-
|
|
72
|
+
if (this.options.showInfo) {
|
|
73
|
+
logger_1.default.printLine(`${prefix} File changed: ${chalk_1.default.yellow(event.relativePath)}`, 'info');
|
|
74
|
+
}
|
|
72
75
|
if (this.options.clearConsole) {
|
|
73
76
|
console.clear();
|
|
74
77
|
}
|
|
@@ -78,18 +81,38 @@ class DevRunner {
|
|
|
78
81
|
if (this.commands.length === 0) {
|
|
79
82
|
return [];
|
|
80
83
|
}
|
|
81
|
-
|
|
84
|
+
// Create a modified options object for the runner to clean up output
|
|
85
|
+
const runnerOptions = {
|
|
86
|
+
...this.options,
|
|
87
|
+
// Override prefix behavior to show clean command name
|
|
88
|
+
customPrefix: (command) => {
|
|
89
|
+
// Extract just the filename from the command
|
|
90
|
+
const match = command.match(/(?:npx ts-node|node)\s+(.+)/);
|
|
91
|
+
if (match) {
|
|
92
|
+
const filePath = match[1];
|
|
93
|
+
const fileName = filePath.split('/').pop() || filePath;
|
|
94
|
+
return `${fileName}`;
|
|
95
|
+
}
|
|
96
|
+
return command;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
this.runner = new runner_1.Runner(runnerOptions);
|
|
82
100
|
try {
|
|
83
101
|
const results = await this.runner.run(this.commands);
|
|
84
102
|
return results;
|
|
85
103
|
}
|
|
86
104
|
catch (error) {
|
|
87
|
-
|
|
105
|
+
if (this.options.showInfo) {
|
|
106
|
+
logger_1.default.printLine(`Execution failed: ${error.message}`, 'error');
|
|
107
|
+
}
|
|
88
108
|
return [];
|
|
89
109
|
}
|
|
90
110
|
}
|
|
91
111
|
printDevBanner() {
|
|
92
112
|
var _a, _b;
|
|
113
|
+
if (!this.options.showInfo) {
|
|
114
|
+
return; // Don't show banner if showInfo is false
|
|
115
|
+
}
|
|
93
116
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
94
117
|
const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
|
|
95
118
|
const uptimeStr = this.formatUptime(uptime);
|
|
@@ -125,7 +148,7 @@ class DevRunner {
|
|
|
125
148
|
this.startTime = new Date();
|
|
126
149
|
// Setup file watcher
|
|
127
150
|
this.setupFileWatcher();
|
|
128
|
-
// Print development banner
|
|
151
|
+
// Print development banner only if showInfo is true
|
|
129
152
|
this.printDevBanner();
|
|
130
153
|
// Start file watcher
|
|
131
154
|
if (this.fileWatcher) {
|
|
@@ -133,19 +156,25 @@ class DevRunner {
|
|
|
133
156
|
}
|
|
134
157
|
// Run initial commands
|
|
135
158
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
136
|
-
|
|
159
|
+
if (this.options.showInfo) {
|
|
160
|
+
logger_1.default.printLine(`${prefix} Starting development server...`, 'info');
|
|
161
|
+
}
|
|
137
162
|
await this.runCommands();
|
|
138
163
|
// Set up graceful shutdown
|
|
139
164
|
this.setupGracefulShutdown();
|
|
140
|
-
|
|
141
|
-
|
|
165
|
+
if (this.options.showInfo) {
|
|
166
|
+
logger_1.default.printLine(`${prefix} Development server started. Watching for changes...`, 'info');
|
|
167
|
+
logger_1.default.printLine(`${prefix} Press ${chalk_1.default.cyan('Ctrl+C')} to stop`, 'info');
|
|
168
|
+
}
|
|
142
169
|
}
|
|
143
170
|
async restart() {
|
|
144
171
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
145
172
|
if (!this.isRunning) {
|
|
146
173
|
return;
|
|
147
174
|
}
|
|
148
|
-
|
|
175
|
+
if (this.options.showInfo) {
|
|
176
|
+
logger_1.default.printLine(`${prefix} Restarting due to file changes...`, 'info');
|
|
177
|
+
}
|
|
149
178
|
this.restartCount++;
|
|
150
179
|
// Stop current processes
|
|
151
180
|
if (this.runner) {
|
|
@@ -153,18 +182,22 @@ class DevRunner {
|
|
|
153
182
|
}
|
|
154
183
|
// Wait a moment before restarting
|
|
155
184
|
await new Promise(resolve => setTimeout(resolve, 500));
|
|
156
|
-
// Print restart banner
|
|
185
|
+
// Print restart banner only if showInfo is true
|
|
157
186
|
this.printDevBanner();
|
|
158
187
|
// Run commands again
|
|
159
188
|
await this.runCommands();
|
|
160
|
-
|
|
189
|
+
if (this.options.showInfo) {
|
|
190
|
+
logger_1.default.printLine(`${prefix} Restart completed. Watching for changes...`, 'info');
|
|
191
|
+
}
|
|
161
192
|
}
|
|
162
193
|
async stop() {
|
|
163
194
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
164
195
|
if (!this.isRunning) {
|
|
165
196
|
return;
|
|
166
197
|
}
|
|
167
|
-
|
|
198
|
+
if (this.options.showInfo) {
|
|
199
|
+
logger_1.default.printLine(`${prefix} Stopping development server...`, 'info');
|
|
200
|
+
}
|
|
168
201
|
this.isRunning = false;
|
|
169
202
|
// Stop file watcher
|
|
170
203
|
if (this.fileWatcher) {
|
|
@@ -176,14 +209,18 @@ class DevRunner {
|
|
|
176
209
|
}
|
|
177
210
|
const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
|
|
178
211
|
const uptimeStr = this.formatUptime(uptime);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
+
}
|
|
182
217
|
}
|
|
183
218
|
}
|
|
184
219
|
setupGracefulShutdown() {
|
|
185
220
|
const handleSignal = (signal) => {
|
|
186
|
-
|
|
221
|
+
if (this.options.showInfo) {
|
|
222
|
+
console.log(`\n${chalk_1.default.yellow(`${figures_1.default.warning} Received ${signal}. Shutting down development server...`)}`);
|
|
223
|
+
}
|
|
187
224
|
this.stop().then(() => {
|
|
188
225
|
process.exit(0);
|
|
189
226
|
});
|