neex 0.6.9 → 0.6.11
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 +15 -77
- package/dist/src/dev-runner.js +7 -52
- package/package.json +1 -1
|
@@ -93,91 +93,29 @@ function addDevCommands(program) {
|
|
|
93
93
|
.option('-e, --ext <extensions...>', 'File extensions to watch (default: js,mjs,json,ts,tsx,jsx)')
|
|
94
94
|
.option('-d, --delay <ms>', 'Delay before restart in milliseconds', parseInt)
|
|
95
95
|
.option('--clear', 'Clear console on restart')
|
|
96
|
-
.option('--verbose', 'Verbose output')
|
|
97
|
-
.option('--info', 'Show detailed information during startup')
|
|
98
96
|
.option('--signal <signal>', 'Signal to send to processes on restart', 'SIGTERM')
|
|
99
97
|
.action(async (file, options) => {
|
|
100
98
|
try {
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (!file || file.trim() === '') {
|
|
108
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: Error - No file specified!`));
|
|
109
|
-
console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Usage: neex dev <file>`));
|
|
110
|
-
console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Example: neex dev src/server.ts`));
|
|
111
|
-
process.exit(1);
|
|
112
|
-
}
|
|
113
|
-
// Get the best command to run the file
|
|
114
|
-
let commandToExecute;
|
|
115
|
-
let fileExtension;
|
|
116
|
-
try {
|
|
117
|
-
commandToExecute = await getBestCommand(file, showInfo);
|
|
118
|
-
fileExtension = path.extname(file).toLowerCase();
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: ${error instanceof Error ? error.message : 'Unknown error occurred'}`));
|
|
122
|
-
process.exit(1);
|
|
123
|
-
}
|
|
124
|
-
// Setup watch configuration
|
|
125
|
-
const watchPaths = options.watch ? [...options.watch, './'] : ['./'];
|
|
126
|
-
const ignorePatterns = options.ignore || [
|
|
127
|
-
'node_modules/**',
|
|
128
|
-
'.git/**',
|
|
129
|
-
'*.log',
|
|
130
|
-
'dist/**',
|
|
131
|
-
'build/**',
|
|
132
|
-
'coverage/**',
|
|
133
|
-
'.nyc_output/**',
|
|
134
|
-
'*.tmp',
|
|
135
|
-
'*.temp',
|
|
136
|
-
'.DS_Store',
|
|
137
|
-
'Thumbs.db'
|
|
138
|
-
];
|
|
139
|
-
const extensions = options.ext || ['js', 'mjs', 'json', 'ts', 'tsx', 'jsx', 'vue', 'svelte'];
|
|
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)}`));
|
|
156
|
-
}
|
|
157
|
-
// Create DevRunner instance
|
|
158
|
-
devRunner = new dev_runner_js_1.DevRunner({
|
|
159
|
-
runnerName: 'neex dev',
|
|
160
|
-
parallel: false,
|
|
161
|
-
color: options.color,
|
|
162
|
-
showTiming: options.timing,
|
|
163
|
-
prefix: options.prefix,
|
|
164
|
-
stopOnError: options.stopOnError,
|
|
165
|
-
printOutput: options.output,
|
|
166
|
-
minimalOutput: options.minimal,
|
|
167
|
-
watch: watchPaths,
|
|
168
|
-
ignore: ignorePatterns,
|
|
169
|
-
ext: extensions,
|
|
170
|
-
delay: options.delay || 1000,
|
|
99
|
+
const devRunner = new dev_runner_js_1.DevRunner({
|
|
100
|
+
showInfo: false,
|
|
101
|
+
watch: options.watch,
|
|
102
|
+
ignore: options.ignore,
|
|
103
|
+
ext: options.ext,
|
|
104
|
+
delay: options.delay,
|
|
171
105
|
clearConsole: options.clear,
|
|
172
|
-
verbose: options.verbose,
|
|
173
|
-
showInfo: showInfo,
|
|
174
106
|
signal: options.signal,
|
|
175
|
-
|
|
107
|
+
runnerName: 'neex dev',
|
|
108
|
+
parallel: false,
|
|
109
|
+
printOutput: true,
|
|
110
|
+
color: true,
|
|
111
|
+
showTiming: true,
|
|
112
|
+
prefix: true,
|
|
113
|
+
stopOnError: false,
|
|
114
|
+
minimalOutput: false,
|
|
176
115
|
groupOutput: false,
|
|
177
116
|
isServerMode: false
|
|
178
117
|
});
|
|
179
|
-
|
|
180
|
-
await devRunner.start([commandToExecute]);
|
|
118
|
+
devRunner.start([await getBestCommand(file, false)]);
|
|
181
119
|
}
|
|
182
120
|
catch (error) {
|
|
183
121
|
console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: Fatal error occurred`));
|
package/dist/src/dev-runner.js
CHANGED
|
@@ -80,16 +80,9 @@ class DevRunner {
|
|
|
80
80
|
// Create a modified options object for the runner to clean up output
|
|
81
81
|
const runnerOptions = {
|
|
82
82
|
...this.options,
|
|
83
|
-
// Override prefix behavior to show
|
|
83
|
+
// Override prefix behavior to show "neex dev" instead of full command
|
|
84
84
|
customPrefix: (command) => {
|
|
85
|
-
//
|
|
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;
|
|
85
|
+
return 'neex dev'; // Always show "neex dev" as prefix
|
|
93
86
|
}
|
|
94
87
|
};
|
|
95
88
|
this.runner = new runner_1.Runner(runnerOptions);
|
|
@@ -105,24 +98,8 @@ class DevRunner {
|
|
|
105
98
|
}
|
|
106
99
|
}
|
|
107
100
|
printDevBanner() {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return; // Don't show banner if showInfo is false
|
|
111
|
-
}
|
|
112
|
-
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
113
|
-
const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
|
|
114
|
-
const uptimeStr = this.formatUptime(uptime);
|
|
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('');
|
|
125
|
-
}
|
|
101
|
+
// Don't show any banner info - keep it completely clean
|
|
102
|
+
return;
|
|
126
103
|
}
|
|
127
104
|
formatUptime(seconds) {
|
|
128
105
|
if (seconds < 60) {
|
|
@@ -145,33 +122,20 @@ class DevRunner {
|
|
|
145
122
|
this.startTime = new Date();
|
|
146
123
|
// Setup file watcher
|
|
147
124
|
this.setupFileWatcher();
|
|
148
|
-
//
|
|
149
|
-
this.printDevBanner();
|
|
125
|
+
// Don't print any development banner
|
|
150
126
|
// Start file watcher
|
|
151
127
|
if (this.fileWatcher) {
|
|
152
128
|
await this.fileWatcher.start();
|
|
153
129
|
}
|
|
154
130
|
// Run initial commands
|
|
155
|
-
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
156
|
-
if (this.options.showInfo) {
|
|
157
|
-
logger_1.default.printLine(`${prefix} Starting development server...`, 'info');
|
|
158
|
-
}
|
|
159
131
|
await this.runCommands();
|
|
160
132
|
// Set up graceful shutdown
|
|
161
133
|
this.setupGracefulShutdown();
|
|
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
|
-
}
|
|
166
134
|
}
|
|
167
135
|
async restart() {
|
|
168
|
-
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
169
136
|
if (!this.isRunning) {
|
|
170
137
|
return;
|
|
171
138
|
}
|
|
172
|
-
if (this.options.showInfo) {
|
|
173
|
-
logger_1.default.printLine(`${prefix} Restarting due to file changes...`, 'info');
|
|
174
|
-
}
|
|
175
139
|
this.restartCount++;
|
|
176
140
|
// Stop current processes
|
|
177
141
|
if (this.runner) {
|
|
@@ -179,22 +143,13 @@ class DevRunner {
|
|
|
179
143
|
}
|
|
180
144
|
// Wait a moment before restarting
|
|
181
145
|
await new Promise(resolve => setTimeout(resolve, 500));
|
|
182
|
-
// Print restart banner only if showInfo is true
|
|
183
|
-
this.printDevBanner();
|
|
184
146
|
// Run commands again
|
|
185
147
|
await this.runCommands();
|
|
186
|
-
if (this.options.showInfo) {
|
|
187
|
-
logger_1.default.printLine(`${prefix} Restart completed. Watching for changes...`, 'info');
|
|
188
|
-
}
|
|
189
148
|
}
|
|
190
149
|
async stop() {
|
|
191
|
-
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
192
150
|
if (!this.isRunning) {
|
|
193
151
|
return;
|
|
194
152
|
}
|
|
195
|
-
if (this.options.showInfo) {
|
|
196
|
-
logger_1.default.printLine(`${prefix} Stopping development server...`, 'info');
|
|
197
|
-
}
|
|
198
153
|
this.isRunning = false;
|
|
199
154
|
// Stop file watcher
|
|
200
155
|
if (this.fileWatcher) {
|
|
@@ -207,9 +162,9 @@ class DevRunner {
|
|
|
207
162
|
const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
|
|
208
163
|
const uptimeStr = this.formatUptime(uptime);
|
|
209
164
|
if (this.options.showInfo) {
|
|
210
|
-
logger_1.default.printLine(`${
|
|
165
|
+
logger_1.default.printLine(`${this.options.runnerName} development server stopped after ${uptimeStr}`, 'info');
|
|
211
166
|
if (this.restartCount > 0) {
|
|
212
|
-
logger_1.default.printLine(
|
|
167
|
+
logger_1.default.printLine(`Total restarts: ${this.restartCount}`, 'info');
|
|
213
168
|
}
|
|
214
169
|
}
|
|
215
170
|
}
|