neex 0.6.2 → 0.6.3
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 +41 -57
- package/dist/src/dev-runner.js +48 -9
- package/package.json +1 -1
|
@@ -98,8 +98,11 @@ function addDevCommands(program) {
|
|
|
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
|
+
// Only show detailed startup logs if --info flag is used
|
|
102
|
+
if (options.info) {
|
|
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,80 +114,61 @@ function addDevCommands(program) {
|
|
|
111
114
|
let commandToExecute;
|
|
112
115
|
let fileExtension;
|
|
113
116
|
try {
|
|
114
|
-
commandToExecute = await getBestCommand(file);
|
|
117
|
+
commandToExecute = await getBestCommand(file, options.info);
|
|
115
118
|
fileExtension = path.extname(file).toLowerCase();
|
|
116
119
|
}
|
|
117
120
|
catch (error) {
|
|
118
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev:
|
|
121
|
+
console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: Error - ${error.message}`));
|
|
119
122
|
process.exit(1);
|
|
120
123
|
}
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
'
|
|
128
|
-
'
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
'*.tmp',
|
|
132
|
-
'*.temp',
|
|
133
|
-
'.DS_Store',
|
|
134
|
-
'Thumbs.db'
|
|
135
|
-
];
|
|
136
|
-
const extensions = options.ext || ['js', 'mjs', 'json', 'ts', 'tsx', 'jsx', 'vue', 'svelte'];
|
|
137
|
-
// Log configuration
|
|
138
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Configuration:`));
|
|
139
|
-
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Target: ${chalk_1.default.cyan(file)}`));
|
|
140
|
-
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Runtime: ${chalk_1.default.cyan(fileExtension === '.ts' || fileExtension === '.mts' || fileExtension === '.cts' ? 'TypeScript' : 'JavaScript')}`));
|
|
141
|
-
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Watch paths: ${chalk_1.default.cyan(watchPaths.join(', '))}`));
|
|
142
|
-
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Extensions: ${chalk_1.default.cyan(extensions.join(', '))}`));
|
|
143
|
-
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Restart delay: ${chalk_1.default.cyan(options.delay || 1000)}ms`));
|
|
144
|
-
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Clear console: ${chalk_1.default.cyan(options.clear ? 'Yes' : 'No')}`));
|
|
145
|
-
if (options.verbose) {
|
|
146
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Verbose mode enabled - showing detailed logs`));
|
|
124
|
+
// Only show detailed configuration if --info flag is used
|
|
125
|
+
if (options.info) {
|
|
126
|
+
console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: ${fileExtension === '.ts' ? 'TypeScript' : 'JavaScript'} detected, ready to run`));
|
|
127
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Configuration:`));
|
|
128
|
+
console.log(` → Target: ${file}`);
|
|
129
|
+
console.log(` → Runtime: ${fileExtension === '.ts' ? 'TypeScript' : 'JavaScript'}`);
|
|
130
|
+
console.log(` → Watch paths: ${options.watch || './'}`);
|
|
131
|
+
console.log(` → Extensions: ${options.ext || 'js, mjs, json, ts, tsx, jsx, vue, svelte'}`);
|
|
132
|
+
console.log(` → Restart delay: ${options.delay || 1000}ms`);
|
|
133
|
+
console.log(` → Clear console: ${options.clear ? 'Yes' : 'No'}`);
|
|
147
134
|
}
|
|
148
135
|
console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Starting file watcher and process manager...`));
|
|
149
|
-
// Create DevRunner instance
|
|
136
|
+
// Create DevRunner instance
|
|
150
137
|
devRunner = new dev_runner_js_1.DevRunner({
|
|
151
138
|
runnerName: 'neex dev',
|
|
152
139
|
parallel: false,
|
|
153
|
-
color: options.color,
|
|
154
|
-
showTiming: options.timing,
|
|
155
|
-
prefix: options.prefix,
|
|
140
|
+
color: !options.color,
|
|
141
|
+
showTiming: !options.timing,
|
|
142
|
+
prefix: !options.prefix,
|
|
156
143
|
stopOnError: options.stopOnError,
|
|
157
|
-
printOutput: options.output,
|
|
158
144
|
minimalOutput: options.minimal,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
delay: options.delay || 1000,
|
|
145
|
+
groupOutput: false,
|
|
146
|
+
isServerMode: true,
|
|
147
|
+
restartOnChange: true,
|
|
163
148
|
clearConsole: options.clear,
|
|
164
|
-
verbose: options.verbose,
|
|
165
149
|
signal: options.signal,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
150
|
+
watch: options.watch || ['./'],
|
|
151
|
+
ignore: options.ignore || [
|
|
152
|
+
'node_modules/**',
|
|
153
|
+
'.git/**',
|
|
154
|
+
'*.log',
|
|
155
|
+
'dist/**',
|
|
156
|
+
'build/**',
|
|
157
|
+
'coverage/**',
|
|
158
|
+
'.nyc_output/**',
|
|
159
|
+
'*.tmp',
|
|
160
|
+
'*.temp'
|
|
161
|
+
],
|
|
162
|
+
ext: options.ext || ['js', 'mjs', 'json', 'ts', 'tsx', 'jsx', 'vue', 'svelte'],
|
|
163
|
+
delay: options.delay || 1000,
|
|
164
|
+
verbose: options.verbose,
|
|
165
|
+
printOutput: true, // Add this required property
|
|
169
166
|
});
|
|
170
167
|
// 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
168
|
await devRunner.start([commandToExecute]);
|
|
175
169
|
}
|
|
176
170
|
catch (error) {
|
|
177
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev:
|
|
178
|
-
if (error instanceof Error) {
|
|
179
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} Details: ${error.message}`));
|
|
180
|
-
if (options.verbose && error.stack) {
|
|
181
|
-
console.error(chalk_1.default.gray(`Stack trace:\n${error.stack}`));
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} Unknown error occurred`));
|
|
186
|
-
}
|
|
187
|
-
console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Try running with --verbose flag for more details`));
|
|
171
|
+
console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: Error - ${error.message}`));
|
|
188
172
|
process.exit(1);
|
|
189
173
|
}
|
|
190
174
|
});
|
package/dist/src/dev-runner.js
CHANGED
|
@@ -16,6 +16,9 @@ class DevRunner {
|
|
|
16
16
|
this.isRunning = false;
|
|
17
17
|
this.restartCount = 0;
|
|
18
18
|
this.startTime = new Date();
|
|
19
|
+
this.serverInfo = new Map();
|
|
20
|
+
this.portRegex = /\bport\s+(\d+)\b/;
|
|
21
|
+
this.urlRegex = /\burl:\s*(https?:\/\/[^\s]+)/;
|
|
19
22
|
const defaultOptions = {
|
|
20
23
|
parallel: false,
|
|
21
24
|
printOutput: true,
|
|
@@ -81,6 +84,13 @@ class DevRunner {
|
|
|
81
84
|
this.runner = new runner_1.Runner(this.options);
|
|
82
85
|
try {
|
|
83
86
|
const results = await this.runner.run(this.commands);
|
|
87
|
+
results.forEach((result, index) => {
|
|
88
|
+
if (result.output) {
|
|
89
|
+
result.output.forEach(output => {
|
|
90
|
+
this.detectServerInfo(this.commands[index], output.data);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
});
|
|
84
94
|
return results;
|
|
85
95
|
}
|
|
86
96
|
catch (error) {
|
|
@@ -88,21 +98,50 @@ class DevRunner {
|
|
|
88
98
|
return [];
|
|
89
99
|
}
|
|
90
100
|
}
|
|
101
|
+
detectServerInfo(command, data) {
|
|
102
|
+
if (!this.options.isServerMode)
|
|
103
|
+
return;
|
|
104
|
+
// Get or create server info
|
|
105
|
+
let serverInfo = this.serverInfo.get(command);
|
|
106
|
+
if (!serverInfo) {
|
|
107
|
+
serverInfo = {
|
|
108
|
+
name: command,
|
|
109
|
+
status: 'starting'
|
|
110
|
+
};
|
|
111
|
+
this.serverInfo.set(command, serverInfo);
|
|
112
|
+
}
|
|
113
|
+
// Try to detect port from output
|
|
114
|
+
const portMatch = data.match(this.portRegex);
|
|
115
|
+
if (portMatch && portMatch[1]) {
|
|
116
|
+
serverInfo.port = parseInt(portMatch[1], 10);
|
|
117
|
+
serverInfo.status = 'running';
|
|
118
|
+
}
|
|
119
|
+
// Try to detect full URL from output
|
|
120
|
+
const urlMatch = data.match(this.urlRegex);
|
|
121
|
+
if (urlMatch && urlMatch[1]) {
|
|
122
|
+
serverInfo.url = urlMatch[1];
|
|
123
|
+
serverInfo.status = 'running';
|
|
124
|
+
}
|
|
125
|
+
// Update server info
|
|
126
|
+
this.serverInfo.set(command, serverInfo);
|
|
127
|
+
}
|
|
91
128
|
printDevBanner() {
|
|
92
129
|
var _a, _b;
|
|
93
130
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
94
131
|
const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
|
|
95
132
|
const uptimeStr = this.formatUptime(uptime);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
133
|
+
if (this.options.verbose) {
|
|
134
|
+
console.log('\n' + chalk_1.default.bgGreen.black(` ${(_a = this.options.runnerName) === null || _a === void 0 ? void 0 : _a.toUpperCase()} MODE `) + '\n');
|
|
135
|
+
if (this.restartCount > 0) {
|
|
136
|
+
console.log(`${prefix} ${chalk_1.default.green(`${figures_1.default.arrowUp} Restarted ${this.restartCount} times`)}`);
|
|
137
|
+
}
|
|
138
|
+
console.log(`${prefix} ${chalk_1.default.blue(`${figures_1.default.info} Uptime: ${uptimeStr}`)}`);
|
|
139
|
+
console.log(`${prefix} ${chalk_1.default.blue(`${figures_1.default.info} Watching: ${((_b = this.options.watch) === null || _b === void 0 ? void 0 : _b.join(', ')) || 'current directory'}`)}`);
|
|
140
|
+
if (this.options.ext && this.options.ext.length > 0) {
|
|
141
|
+
console.log(`${prefix} ${chalk_1.default.blue(`${figures_1.default.info} Extensions: ${this.options.ext.join(', ')}`)}`);
|
|
142
|
+
}
|
|
143
|
+
console.log('');
|
|
104
144
|
}
|
|
105
|
-
console.log('');
|
|
106
145
|
}
|
|
107
146
|
formatUptime(seconds) {
|
|
108
147
|
if (seconds < 60) {
|