neex 0.6.16 → 0.6.18
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 +31 -13
- package/dist/src/dev-runner.js +54 -17
- package/package.json +1 -1
|
@@ -43,23 +43,35 @@ 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) {
|
|
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
|
|
50
50
|
if (!(await fileExists(absolutePath))) {
|
|
51
51
|
throw new Error(`File not found: ${filePath}`);
|
|
52
52
|
}
|
|
53
|
+
if (showInfo) {
|
|
54
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Analyzing ${chalk_1.default.cyan(path.basename(filePath))}`));
|
|
55
|
+
}
|
|
53
56
|
switch (ext) {
|
|
54
57
|
case '.ts':
|
|
55
58
|
case '.mts':
|
|
56
59
|
case '.cts':
|
|
60
|
+
if (showInfo) {
|
|
61
|
+
console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: TypeScript detected, ready to run`));
|
|
62
|
+
}
|
|
57
63
|
return `npx ts-node ${filePath}`;
|
|
58
64
|
case '.js':
|
|
59
65
|
case '.mjs':
|
|
60
66
|
case '.cjs':
|
|
67
|
+
if (showInfo) {
|
|
68
|
+
console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: JavaScript detected, ready to run`));
|
|
69
|
+
}
|
|
61
70
|
return `node ${filePath}`;
|
|
62
71
|
default:
|
|
72
|
+
if (showInfo) {
|
|
73
|
+
console.log(chalk_1.default.yellow(`${figures_1.default.warning} neex dev: Unknown file type, using Node.js`));
|
|
74
|
+
}
|
|
63
75
|
return `node ${filePath}`;
|
|
64
76
|
}
|
|
65
77
|
}
|
|
@@ -82,9 +94,15 @@ function addDevCommands(program) {
|
|
|
82
94
|
.option('-d, --delay <ms>', 'Delay before restart in milliseconds', parseInt)
|
|
83
95
|
.option('--clear', 'Clear console on restart')
|
|
84
96
|
.option('--verbose', 'Verbose output')
|
|
97
|
+
.option('--info', 'Show detailed information during startup')
|
|
85
98
|
.option('--signal <signal>', 'Signal to send to processes on restart', 'SIGTERM')
|
|
86
99
|
.action(async (file, options) => {
|
|
87
100
|
try {
|
|
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
|
+
}
|
|
88
106
|
// Validate file parameter
|
|
89
107
|
if (!file || file.trim() === '') {
|
|
90
108
|
console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: Error - No file specified!`));
|
|
@@ -94,8 +112,10 @@ function addDevCommands(program) {
|
|
|
94
112
|
}
|
|
95
113
|
// Get the best command to run the file
|
|
96
114
|
let commandToExecute;
|
|
115
|
+
let fileExtension;
|
|
97
116
|
try {
|
|
98
|
-
commandToExecute = await getBestCommand(file);
|
|
117
|
+
commandToExecute = await getBestCommand(file, showInfo);
|
|
118
|
+
fileExtension = path.extname(file).toLowerCase();
|
|
99
119
|
}
|
|
100
120
|
catch (error) {
|
|
101
121
|
console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: ${error instanceof Error ? error.message : 'Unknown error occurred'}`));
|
|
@@ -117,20 +137,18 @@ function addDevCommands(program) {
|
|
|
117
137
|
'Thumbs.db'
|
|
118
138
|
];
|
|
119
139
|
const extensions = options.ext || ['js', 'mjs', 'json', 'ts', 'tsx', 'jsx', 'vue', 'svelte'];
|
|
120
|
-
//
|
|
121
|
-
if (
|
|
122
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Starting enhanced development server...`));
|
|
123
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Target file: ${chalk_1.default.cyan(file)}`));
|
|
124
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Analyzing file type for ${chalk_1.default.cyan(file)}`));
|
|
125
|
-
console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Detected ${path.extname(file)} file, using appropriate execution method`));
|
|
140
|
+
// Log configuration only if --info flag is set
|
|
141
|
+
if (showInfo) {
|
|
126
142
|
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Configuration:`));
|
|
127
|
-
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight}
|
|
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')}`));
|
|
128
145
|
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Watch paths: ${chalk_1.default.cyan(watchPaths.join(', '))}`));
|
|
129
146
|
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Extensions: ${chalk_1.default.cyan(extensions.join(', '))}`));
|
|
130
|
-
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Ignore patterns: ${chalk_1.default.cyan(ignorePatterns.length)} patterns`));
|
|
131
147
|
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Restart delay: ${chalk_1.default.cyan(options.delay || 1000)}ms`));
|
|
132
148
|
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Clear console: ${chalk_1.default.cyan(options.clear ? 'Yes' : 'No')}`));
|
|
133
|
-
|
|
149
|
+
if (options.verbose) {
|
|
150
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Verbose mode enabled - showing detailed logs`));
|
|
151
|
+
}
|
|
134
152
|
console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Starting file watcher and process manager...`));
|
|
135
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...`));
|
|
136
154
|
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Press Ctrl+C to stop the development server`));
|
|
@@ -152,13 +170,13 @@ function addDevCommands(program) {
|
|
|
152
170
|
delay: options.delay || 1000,
|
|
153
171
|
clearConsole: options.clear,
|
|
154
172
|
verbose: options.verbose,
|
|
173
|
+
showInfo: showInfo,
|
|
155
174
|
signal: options.signal,
|
|
156
175
|
restartOnChange: true,
|
|
157
176
|
groupOutput: false,
|
|
158
177
|
isServerMode: false
|
|
159
178
|
});
|
|
160
|
-
//
|
|
161
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} [neex dev] Starting development server...`));
|
|
179
|
+
// Start the development server
|
|
162
180
|
await devRunner.start([commandToExecute]);
|
|
163
181
|
}
|
|
164
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
|
});
|