neex 0.6.37 → 0.6.38
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 +54 -29
- package/dist/src/dev-runner.js +35 -11
- package/package.json +1 -1
|
@@ -32,6 +32,31 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
32
32
|
const figures_1 = __importDefault(require("figures"));
|
|
33
33
|
const path = __importStar(require("path"));
|
|
34
34
|
const fs = __importStar(require("fs/promises"));
|
|
35
|
+
// Simple logger class - no spinners, no complex features
|
|
36
|
+
class SimpleLogger {
|
|
37
|
+
info(message) {
|
|
38
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} ${message}`));
|
|
39
|
+
}
|
|
40
|
+
success(message) {
|
|
41
|
+
console.log(chalk_1.default.green(`${figures_1.default.tick} ${message}`));
|
|
42
|
+
}
|
|
43
|
+
warning(message) {
|
|
44
|
+
console.log(chalk_1.default.yellow(`${figures_1.default.warning} ${message}`));
|
|
45
|
+
}
|
|
46
|
+
error(message) {
|
|
47
|
+
console.log(chalk_1.default.red(`${figures_1.default.cross} ${message}`));
|
|
48
|
+
}
|
|
49
|
+
gray(message) {
|
|
50
|
+
console.log(chalk_1.default.gray(message));
|
|
51
|
+
}
|
|
52
|
+
cyan(message) {
|
|
53
|
+
console.log(chalk_1.default.cyan(message));
|
|
54
|
+
}
|
|
55
|
+
log(message) {
|
|
56
|
+
console.log(message);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const logger = new SimpleLogger();
|
|
35
60
|
// Helper function to check if file exists
|
|
36
61
|
async function fileExists(filePath) {
|
|
37
62
|
try {
|
|
@@ -51,26 +76,26 @@ async function getBestCommand(filePath, showInfo) {
|
|
|
51
76
|
throw new Error(`File not found: ${filePath}`);
|
|
52
77
|
}
|
|
53
78
|
if (showInfo) {
|
|
54
|
-
|
|
79
|
+
logger.info(`neex dev: Analyzing ${chalk_1.default.cyan(path.basename(filePath))}`);
|
|
55
80
|
}
|
|
56
81
|
switch (ext) {
|
|
57
82
|
case '.ts':
|
|
58
83
|
case '.mts':
|
|
59
84
|
case '.cts':
|
|
60
85
|
if (showInfo) {
|
|
61
|
-
|
|
86
|
+
logger.success(`neex dev: TypeScript detected, ready to run`);
|
|
62
87
|
}
|
|
63
88
|
return `npx ts-node ${filePath}`;
|
|
64
89
|
case '.js':
|
|
65
90
|
case '.mjs':
|
|
66
91
|
case '.cjs':
|
|
67
92
|
if (showInfo) {
|
|
68
|
-
|
|
93
|
+
logger.success(`neex dev: JavaScript detected, ready to run`);
|
|
69
94
|
}
|
|
70
95
|
return `node ${filePath}`;
|
|
71
96
|
default:
|
|
72
97
|
if (showInfo) {
|
|
73
|
-
|
|
98
|
+
logger.warning(`neex dev: Unknown file type, using Node.js`);
|
|
74
99
|
}
|
|
75
100
|
return `node ${filePath}`;
|
|
76
101
|
}
|
|
@@ -100,14 +125,14 @@ function addDevCommands(program) {
|
|
|
100
125
|
try {
|
|
101
126
|
const showInfo = options.info || false;
|
|
102
127
|
if (showInfo) {
|
|
103
|
-
|
|
104
|
-
|
|
128
|
+
logger.info(`neex dev: Starting enhanced development server...`);
|
|
129
|
+
logger.info(`neex dev: Target file: ${chalk_1.default.cyan(file)}`);
|
|
105
130
|
}
|
|
106
131
|
// Validate file parameter
|
|
107
132
|
if (!file || file.trim() === '') {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
133
|
+
logger.error(`neex dev: Error - No file specified!`);
|
|
134
|
+
logger.log(chalk_1.default.yellow(`${figures_1.default.pointer} Usage: neex dev <file>`));
|
|
135
|
+
logger.log(chalk_1.default.yellow(`${figures_1.default.pointer} Example: neex dev src/server.ts`));
|
|
111
136
|
process.exit(1);
|
|
112
137
|
}
|
|
113
138
|
// Get the best command to run the file
|
|
@@ -118,7 +143,7 @@ function addDevCommands(program) {
|
|
|
118
143
|
fileExtension = path.extname(file).toLowerCase();
|
|
119
144
|
}
|
|
120
145
|
catch (error) {
|
|
121
|
-
|
|
146
|
+
logger.error(`neex dev: ${error instanceof Error ? error.message : 'Unknown error occurred'}`);
|
|
122
147
|
process.exit(1);
|
|
123
148
|
}
|
|
124
149
|
// Setup watch configuration
|
|
@@ -139,20 +164,20 @@ function addDevCommands(program) {
|
|
|
139
164
|
const extensions = options.ext || ['js', 'mjs', 'json', 'ts', 'tsx', 'jsx', 'vue', 'svelte'];
|
|
140
165
|
// Log configuration only if --info flag is set
|
|
141
166
|
if (showInfo) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
167
|
+
logger.info(`neex dev: Configuration:`);
|
|
168
|
+
logger.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Target: ${chalk_1.default.cyan(file)}`));
|
|
169
|
+
logger.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Runtime: ${chalk_1.default.cyan(fileExtension === '.ts' || fileExtension === '.mts' || fileExtension === '.cts' ? 'TypeScript' : 'JavaScript')}`));
|
|
170
|
+
logger.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Watch paths: ${chalk_1.default.cyan(watchPaths.join(', '))}`));
|
|
171
|
+
logger.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Extensions: ${chalk_1.default.cyan(extensions.join(', '))}`));
|
|
172
|
+
logger.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Restart delay: ${chalk_1.default.cyan(options.delay || 1000)}ms`));
|
|
173
|
+
logger.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Clear console: ${chalk_1.default.cyan(options.clear ? 'Yes' : 'No')}`));
|
|
149
174
|
if (options.verbose) {
|
|
150
|
-
|
|
175
|
+
logger.info(`neex dev: Verbose mode enabled - showing detailed logs`);
|
|
151
176
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
177
|
+
logger.success(`neex dev: Starting file watcher and process manager...`);
|
|
178
|
+
logger.success(`neex dev: Launching ${chalk_1.default.cyan(path.basename(file))} with auto-restart capability...`);
|
|
179
|
+
logger.info(`neex dev: Press Ctrl+C to stop the development server`);
|
|
180
|
+
logger.gray(`${'='.repeat(60)}`);
|
|
156
181
|
}
|
|
157
182
|
// Create DevRunner instance
|
|
158
183
|
devRunner = new dev_runner_js_1.DevRunner({
|
|
@@ -180,17 +205,17 @@ function addDevCommands(program) {
|
|
|
180
205
|
await devRunner.start([commandToExecute]);
|
|
181
206
|
}
|
|
182
207
|
catch (error) {
|
|
183
|
-
|
|
208
|
+
logger.error(`neex dev: Fatal error occurred`);
|
|
184
209
|
if (error instanceof Error) {
|
|
185
|
-
|
|
210
|
+
logger.error(`Details: ${error.message}`);
|
|
186
211
|
if (options.verbose && error.stack) {
|
|
187
|
-
|
|
212
|
+
logger.gray(`Stack trace:\n${error.stack}`);
|
|
188
213
|
}
|
|
189
214
|
}
|
|
190
215
|
else {
|
|
191
|
-
|
|
216
|
+
logger.error(`Unknown error occurred`);
|
|
192
217
|
}
|
|
193
|
-
|
|
218
|
+
logger.log(chalk_1.default.yellow(`${figures_1.default.pointer} Try running with --verbose flag for more details`));
|
|
194
219
|
process.exit(1);
|
|
195
220
|
}
|
|
196
221
|
});
|
|
@@ -199,9 +224,9 @@ function addDevCommands(program) {
|
|
|
199
224
|
getDevRunner: () => devRunner,
|
|
200
225
|
cleanupDev: () => {
|
|
201
226
|
if (devRunner && devRunner.isActive()) {
|
|
202
|
-
|
|
227
|
+
logger.info(`neex dev: Stopping development server...`);
|
|
203
228
|
devRunner.stop();
|
|
204
|
-
|
|
229
|
+
logger.success(`neex dev: Development server stopped successfully`);
|
|
205
230
|
}
|
|
206
231
|
}
|
|
207
232
|
};
|
package/dist/src/dev-runner.js
CHANGED
|
@@ -9,7 +9,31 @@ const watcher_1 = require("./watcher");
|
|
|
9
9
|
const runner_1 = require("./runner");
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
11
|
const figures_1 = __importDefault(require("figures"));
|
|
12
|
-
|
|
12
|
+
// Simple logger class - no spinners, no complex features
|
|
13
|
+
class SimpleLogger {
|
|
14
|
+
info(message) {
|
|
15
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} ${message}`));
|
|
16
|
+
}
|
|
17
|
+
success(message) {
|
|
18
|
+
console.log(chalk_1.default.green(`${figures_1.default.tick} ${message}`));
|
|
19
|
+
}
|
|
20
|
+
warning(message) {
|
|
21
|
+
console.log(chalk_1.default.yellow(`${figures_1.default.warning} ${message}`));
|
|
22
|
+
}
|
|
23
|
+
error(message) {
|
|
24
|
+
console.log(chalk_1.default.red(`${figures_1.default.cross} ${message}`));
|
|
25
|
+
}
|
|
26
|
+
gray(message) {
|
|
27
|
+
console.log(chalk_1.default.gray(message));
|
|
28
|
+
}
|
|
29
|
+
cyan(message) {
|
|
30
|
+
console.log(chalk_1.default.cyan(message));
|
|
31
|
+
}
|
|
32
|
+
log(message) {
|
|
33
|
+
console.log(message);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const logger = new SimpleLogger();
|
|
13
37
|
class DevRunner {
|
|
14
38
|
constructor(options) {
|
|
15
39
|
this.commands = [];
|
|
@@ -70,7 +94,7 @@ class DevRunner {
|
|
|
70
94
|
async handleFileChange(event) {
|
|
71
95
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
72
96
|
if (this.options.showInfo) {
|
|
73
|
-
|
|
97
|
+
logger.log(`${prefix} File changed: ${chalk_1.default.yellow(event.relativePath)}`);
|
|
74
98
|
}
|
|
75
99
|
if (this.options.clearConsole) {
|
|
76
100
|
console.clear();
|
|
@@ -103,7 +127,7 @@ class DevRunner {
|
|
|
103
127
|
}
|
|
104
128
|
catch (error) {
|
|
105
129
|
if (this.options.showInfo) {
|
|
106
|
-
|
|
130
|
+
logger.error(`Execution failed: ${error.message}`);
|
|
107
131
|
}
|
|
108
132
|
return [];
|
|
109
133
|
}
|
|
@@ -157,14 +181,14 @@ class DevRunner {
|
|
|
157
181
|
// Run initial commands
|
|
158
182
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
159
183
|
if (this.options.showInfo) {
|
|
160
|
-
|
|
184
|
+
logger.log(`${prefix} Starting development server...`);
|
|
161
185
|
}
|
|
162
186
|
await this.runCommands();
|
|
163
187
|
// Set up graceful shutdown
|
|
164
188
|
this.setupGracefulShutdown();
|
|
165
189
|
if (this.options.showInfo) {
|
|
166
|
-
|
|
167
|
-
|
|
190
|
+
logger.log(`${prefix} Development server started. Watching for changes...`);
|
|
191
|
+
logger.log(`${prefix} Press ${chalk_1.default.cyan('Ctrl+C')} to stop`);
|
|
168
192
|
}
|
|
169
193
|
}
|
|
170
194
|
async restart() {
|
|
@@ -173,7 +197,7 @@ class DevRunner {
|
|
|
173
197
|
return;
|
|
174
198
|
}
|
|
175
199
|
if (this.options.showInfo) {
|
|
176
|
-
|
|
200
|
+
logger.log(`${prefix} Restarting due to file changes...`);
|
|
177
201
|
}
|
|
178
202
|
this.restartCount++;
|
|
179
203
|
// Stop current processes
|
|
@@ -187,7 +211,7 @@ class DevRunner {
|
|
|
187
211
|
// Run commands again
|
|
188
212
|
await this.runCommands();
|
|
189
213
|
if (this.options.showInfo) {
|
|
190
|
-
|
|
214
|
+
logger.log(`${prefix} Restart completed. Watching for changes...`);
|
|
191
215
|
}
|
|
192
216
|
}
|
|
193
217
|
async stop() {
|
|
@@ -196,7 +220,7 @@ class DevRunner {
|
|
|
196
220
|
return;
|
|
197
221
|
}
|
|
198
222
|
if (this.options.showInfo) {
|
|
199
|
-
|
|
223
|
+
logger.log(`${prefix} Stopping development server...`);
|
|
200
224
|
}
|
|
201
225
|
this.isRunning = false;
|
|
202
226
|
// Stop file watcher
|
|
@@ -210,9 +234,9 @@ class DevRunner {
|
|
|
210
234
|
const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
|
|
211
235
|
const uptimeStr = this.formatUptime(uptime);
|
|
212
236
|
if (this.options.showInfo) {
|
|
213
|
-
|
|
237
|
+
logger.log(`${prefix} ${this.options.runnerName} development server stopped after ${uptimeStr}`);
|
|
214
238
|
if (this.restartCount > 0) {
|
|
215
|
-
|
|
239
|
+
logger.log(`${prefix} Total restarts: ${this.restartCount}`);
|
|
216
240
|
}
|
|
217
241
|
}
|
|
218
242
|
}
|