neex 0.6.1 → 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/README.md +1 -1
- package/dist/src/commands/dev-commands.js +55 -62
- package/dist/src/dev-runner.js +48 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,27 +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 = false) {
|
|
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
|
-
|
|
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
|
+
}
|
|
54
56
|
switch (ext) {
|
|
55
57
|
case '.ts':
|
|
56
58
|
case '.mts':
|
|
57
59
|
case '.cts':
|
|
58
|
-
|
|
60
|
+
if (showInfo) {
|
|
61
|
+
console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: TypeScript detected, ready to run`));
|
|
62
|
+
}
|
|
59
63
|
return `npx ts-node ${filePath}`;
|
|
60
64
|
case '.js':
|
|
61
65
|
case '.mjs':
|
|
62
66
|
case '.cjs':
|
|
63
|
-
|
|
67
|
+
if (showInfo) {
|
|
68
|
+
console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: JavaScript detected, ready to run`));
|
|
69
|
+
}
|
|
64
70
|
return `node ${filePath}`;
|
|
65
71
|
default:
|
|
66
|
-
|
|
72
|
+
if (showInfo) {
|
|
73
|
+
console.log(chalk_1.default.yellow(`${figures_1.default.warning} neex dev: Unknown file type, using Node.js`));
|
|
74
|
+
}
|
|
67
75
|
return `node ${filePath}`;
|
|
68
76
|
}
|
|
69
77
|
}
|
|
@@ -86,11 +94,15 @@ function addDevCommands(program) {
|
|
|
86
94
|
.option('-d, --delay <ms>', 'Delay before restart in milliseconds', parseInt)
|
|
87
95
|
.option('--clear', 'Clear console on restart')
|
|
88
96
|
.option('--verbose', 'Verbose output')
|
|
97
|
+
.option('--info', 'Show detailed information and logs')
|
|
89
98
|
.option('--signal <signal>', 'Signal to send to processes on restart', 'SIGTERM')
|
|
90
99
|
.action(async (file, options) => {
|
|
91
100
|
try {
|
|
92
|
-
|
|
93
|
-
|
|
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
|
+
}
|
|
94
106
|
// Validate file parameter
|
|
95
107
|
if (!file || file.trim() === '') {
|
|
96
108
|
console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: Error - No file specified!`));
|
|
@@ -102,80 +114,61 @@ function addDevCommands(program) {
|
|
|
102
114
|
let commandToExecute;
|
|
103
115
|
let fileExtension;
|
|
104
116
|
try {
|
|
105
|
-
commandToExecute = await getBestCommand(file);
|
|
117
|
+
commandToExecute = await getBestCommand(file, options.info);
|
|
106
118
|
fileExtension = path.extname(file).toLowerCase();
|
|
107
119
|
}
|
|
108
120
|
catch (error) {
|
|
109
|
-
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}`));
|
|
110
122
|
process.exit(1);
|
|
111
123
|
}
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
'
|
|
119
|
-
'
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
'*.tmp',
|
|
123
|
-
'*.temp',
|
|
124
|
-
'.DS_Store',
|
|
125
|
-
'Thumbs.db'
|
|
126
|
-
];
|
|
127
|
-
const extensions = options.ext || ['js', 'mjs', 'json', 'ts', 'tsx', 'jsx', 'vue', 'svelte'];
|
|
128
|
-
// Log configuration
|
|
129
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Configuration:`));
|
|
130
|
-
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Target: ${chalk_1.default.cyan(file)}`));
|
|
131
|
-
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Runtime: ${chalk_1.default.cyan(fileExtension === '.ts' || fileExtension === '.mts' || fileExtension === '.cts' ? 'TypeScript' : 'JavaScript')}`));
|
|
132
|
-
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Watch paths: ${chalk_1.default.cyan(watchPaths.join(', '))}`));
|
|
133
|
-
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Extensions: ${chalk_1.default.cyan(extensions.join(', '))}`));
|
|
134
|
-
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Restart delay: ${chalk_1.default.cyan(options.delay || 1000)}ms`));
|
|
135
|
-
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Clear console: ${chalk_1.default.cyan(options.clear ? 'Yes' : 'No')}`));
|
|
136
|
-
if (options.verbose) {
|
|
137
|
-
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'}`);
|
|
138
134
|
}
|
|
139
135
|
console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Starting file watcher and process manager...`));
|
|
140
|
-
// Create DevRunner instance
|
|
136
|
+
// Create DevRunner instance
|
|
141
137
|
devRunner = new dev_runner_js_1.DevRunner({
|
|
142
138
|
runnerName: 'neex dev',
|
|
143
139
|
parallel: false,
|
|
144
|
-
color: options.color,
|
|
145
|
-
showTiming: options.timing,
|
|
146
|
-
prefix: options.prefix,
|
|
140
|
+
color: !options.color,
|
|
141
|
+
showTiming: !options.timing,
|
|
142
|
+
prefix: !options.prefix,
|
|
147
143
|
stopOnError: options.stopOnError,
|
|
148
|
-
printOutput: options.output,
|
|
149
144
|
minimalOutput: options.minimal,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
delay: options.delay || 1000,
|
|
145
|
+
groupOutput: false,
|
|
146
|
+
isServerMode: true,
|
|
147
|
+
restartOnChange: true,
|
|
154
148
|
clearConsole: options.clear,
|
|
155
|
-
verbose: options.verbose,
|
|
156
149
|
signal: options.signal,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
|
160
166
|
});
|
|
161
167
|
// Start the development server
|
|
162
|
-
console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Launching ${chalk_1.default.cyan(path.basename(file))} with auto-restart capability...`));
|
|
163
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Press Ctrl+C to stop the development server`));
|
|
164
|
-
console.log(chalk_1.default.gray(`${'='.repeat(60)}`));
|
|
165
168
|
await devRunner.start([commandToExecute]);
|
|
166
169
|
}
|
|
167
170
|
catch (error) {
|
|
168
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev:
|
|
169
|
-
if (error instanceof Error) {
|
|
170
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} Details: ${error.message}`));
|
|
171
|
-
if (options.verbose && error.stack) {
|
|
172
|
-
console.error(chalk_1.default.gray(`Stack trace:\n${error.stack}`));
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} Unknown error occurred`));
|
|
177
|
-
}
|
|
178
|
-
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}`));
|
|
179
172
|
process.exit(1);
|
|
180
173
|
}
|
|
181
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) {
|