neex 0.1.8 → 0.2.6
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 +72 -238
- package/bun.lock +669 -0
- package/dist/src/cli.js +457 -24
- package/dist/src/index.js +1 -3
- package/dist/src/logger.js +0 -36
- package/dist/src/process-manager.js +146 -607
- package/dist/src/runner.js +78 -112
- package/package.json +7 -5
- package/dist/src/commands/dev-commands.js +0 -190
- package/dist/src/commands/index.js +0 -21
- package/dist/src/commands/process-commands.js +0 -679
- package/dist/src/commands/run-commands.js +0 -87
- package/dist/src/commands/server-commands.js +0 -50
- package/dist/src/dev-runner.js +0 -209
- package/dist/src/utils.js +0 -10
- package/dist/src/watcher.js +0 -245
- package/feet.txt +0 -16
package/dist/src/runner.js
CHANGED
|
@@ -35,7 +35,6 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
35
35
|
const logger_1 = __importDefault(require("./logger"));
|
|
36
36
|
const p_map_1 = __importDefault(require("p-map"));
|
|
37
37
|
const npm_run_path_1 = __importDefault(require("npm-run-path"));
|
|
38
|
-
const fs = __importStar(require("fs"));
|
|
39
38
|
class Runner {
|
|
40
39
|
constructor(options) {
|
|
41
40
|
this.activeProcesses = new Map();
|
|
@@ -45,41 +44,6 @@ class Runner {
|
|
|
45
44
|
this.options = options;
|
|
46
45
|
this.activeProcesses = new Map();
|
|
47
46
|
}
|
|
48
|
-
async expandWildcardCommands(commands) {
|
|
49
|
-
const expandedCommands = [];
|
|
50
|
-
let packageJson;
|
|
51
|
-
try {
|
|
52
|
-
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
53
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
54
|
-
const packageJsonContent = await fsPromises.readFile(packageJsonPath, 'utf-8');
|
|
55
|
-
packageJson = JSON.parse(packageJsonContent);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
logger_1.default.printLine(`Could not read or parse package.json: ${error.message}`, 'warn');
|
|
60
|
-
packageJson = { scripts: {} };
|
|
61
|
-
}
|
|
62
|
-
for (const command of commands) {
|
|
63
|
-
if (command.includes('*') && packageJson && packageJson.scripts) {
|
|
64
|
-
const pattern = new RegExp(`^${command.replace(/\*/g, '.*')}$`);
|
|
65
|
-
let foundMatch = false;
|
|
66
|
-
for (const scriptName in packageJson.scripts) {
|
|
67
|
-
if (pattern.test(scriptName)) {
|
|
68
|
-
expandedCommands.push(scriptName); // Or packageJson.scripts[scriptName] if you want the script value
|
|
69
|
-
foundMatch = true;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (!foundMatch) {
|
|
73
|
-
logger_1.default.printLine(`No scripts found in package.json matching wildcard: ${command}`, 'warn');
|
|
74
|
-
expandedCommands.push(command); // Add original command if no match
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
expandedCommands.push(command);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return expandedCommands;
|
|
82
|
-
}
|
|
83
47
|
async resolveScriptAndCwd(scriptNameOrCommand, baseDir) {
|
|
84
48
|
try {
|
|
85
49
|
const packageJsonPath = path.join(baseDir, 'package.json');
|
|
@@ -139,7 +103,7 @@ class Runner {
|
|
|
139
103
|
// Update server info
|
|
140
104
|
this.serverInfo.set(command, serverInfo);
|
|
141
105
|
}
|
|
142
|
-
async runCommand(originalCommand
|
|
106
|
+
async runCommand(originalCommand) {
|
|
143
107
|
const { executableCommand: command, executionCwd: cwd } = await this.resolveScriptAndCwd(originalCommand, process.cwd());
|
|
144
108
|
const startTime = new Date();
|
|
145
109
|
const result = {
|
|
@@ -153,8 +117,7 @@ class Runner {
|
|
|
153
117
|
if (this.options.printOutput) {
|
|
154
118
|
logger_1.default.printStart(originalCommand);
|
|
155
119
|
}
|
|
156
|
-
return new Promise(
|
|
157
|
-
var _a, _b;
|
|
120
|
+
return new Promise((resolve) => {
|
|
158
121
|
const [cmd, ...args] = command.split(' ');
|
|
159
122
|
const env = {
|
|
160
123
|
...process.env,
|
|
@@ -177,93 +140,96 @@ class Runner {
|
|
|
177
140
|
startTime: new Date()
|
|
178
141
|
});
|
|
179
142
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
143
|
+
// Capture and display output
|
|
144
|
+
if (this.options.printOutput) {
|
|
145
|
+
proc.stdout.on('data', (data) => {
|
|
146
|
+
const output = {
|
|
147
|
+
command: originalCommand,
|
|
148
|
+
type: 'stdout',
|
|
149
|
+
data: data.toString(),
|
|
150
|
+
timestamp: new Date()
|
|
151
|
+
};
|
|
152
|
+
if (this.options.isServerMode) {
|
|
153
|
+
this.detectServerInfo(originalCommand, data.toString());
|
|
154
|
+
}
|
|
155
|
+
// Store output for logging
|
|
156
|
+
if (result.output)
|
|
157
|
+
result.output.push(output);
|
|
158
|
+
logger_1.default.bufferOutput(output);
|
|
159
|
+
// Print immediately unless we're in group mode
|
|
160
|
+
if (!this.options.groupOutput) {
|
|
161
|
+
logger_1.default.printBuffer(originalCommand);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
proc.stderr.on('data', (data) => {
|
|
165
|
+
const output = {
|
|
166
|
+
command: originalCommand,
|
|
167
|
+
type: 'stderr',
|
|
168
|
+
data: data.toString(),
|
|
169
|
+
timestamp: new Date()
|
|
170
|
+
};
|
|
171
|
+
// Store output for logging
|
|
172
|
+
if (result.output)
|
|
173
|
+
result.output.push(output);
|
|
174
|
+
logger_1.default.bufferOutput(output);
|
|
175
|
+
// Print immediately unless we're in group mode
|
|
176
|
+
if (!this.options.groupOutput) {
|
|
177
|
+
logger_1.default.printBuffer(originalCommand);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
proc.on('close', (code) => {
|
|
182
|
+
const endTime = new Date();
|
|
183
|
+
const duration = endTime.getTime() - startTime.getTime();
|
|
184
|
+
result.endTime = endTime;
|
|
185
|
+
result.duration = duration;
|
|
186
|
+
result.code = code;
|
|
187
|
+
result.success = code === 0;
|
|
213
188
|
this.activeProcesses.delete(originalCommand);
|
|
214
189
|
if (this.options.isServerMode) {
|
|
215
190
|
const serverInfo = this.serverInfo.get(originalCommand);
|
|
216
191
|
if (serverInfo) {
|
|
217
|
-
serverInfo.status = 'error';
|
|
192
|
+
serverInfo.status = code === 0 ? 'stopped' : 'error';
|
|
218
193
|
this.serverInfo.set(originalCommand, serverInfo);
|
|
219
194
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if (this.options.printOutput)
|
|
224
|
-
logger_1.default.printEnd(result, this.options.minimalOutput);
|
|
225
|
-
if (this.options.retry && this.options.retry > 0 && currentRetry < this.options.retry) {
|
|
226
|
-
logger_1.default.printLine(`Command "${originalCommand}" failed with error. Retrying (${currentRetry + 1}/${this.options.retry})...`, 'warn');
|
|
227
|
-
if (this.options.retryDelay && this.options.retryDelay > 0) {
|
|
228
|
-
await new Promise(res => setTimeout(res, this.options.retryDelay));
|
|
195
|
+
// If this is server mode and a server failed, print prominent error
|
|
196
|
+
if (code !== 0) {
|
|
197
|
+
logger_1.default.printLine(`Server ${originalCommand} crashed with code ${code}`, 'error');
|
|
229
198
|
}
|
|
230
|
-
logger_1.default.clearBuffer(originalCommand);
|
|
231
|
-
resolve(this.runCommand(originalCommand, currentRetry + 1));
|
|
232
199
|
}
|
|
233
|
-
|
|
234
|
-
|
|
200
|
+
// Print grouped output at the end if enabled
|
|
201
|
+
if (this.options.groupOutput && result.output && result.output.length > 0) {
|
|
202
|
+
logger_1.default.printBuffer(originalCommand);
|
|
203
|
+
}
|
|
204
|
+
if (this.options.printOutput) {
|
|
205
|
+
if (result.success) {
|
|
206
|
+
logger_1.default.printSuccess(result);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
logger_1.default.printError(result);
|
|
210
|
+
}
|
|
235
211
|
}
|
|
212
|
+
resolve(result);
|
|
236
213
|
});
|
|
237
|
-
proc.on('
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
result.endTime =
|
|
241
|
-
result.duration =
|
|
214
|
+
proc.on('error', (error) => {
|
|
215
|
+
const endTime = new Date();
|
|
216
|
+
const duration = endTime.getTime() - startTime.getTime();
|
|
217
|
+
result.endTime = endTime;
|
|
218
|
+
result.duration = duration;
|
|
219
|
+
result.error = error;
|
|
220
|
+
result.success = false;
|
|
242
221
|
this.activeProcesses.delete(originalCommand);
|
|
243
222
|
if (this.options.isServerMode) {
|
|
244
223
|
const serverInfo = this.serverInfo.get(originalCommand);
|
|
245
224
|
if (serverInfo) {
|
|
246
|
-
serverInfo.status =
|
|
225
|
+
serverInfo.status = 'error';
|
|
247
226
|
this.serverInfo.set(originalCommand, serverInfo);
|
|
248
227
|
}
|
|
249
|
-
if (code !== 0) {
|
|
250
|
-
logger_1.default.printLine(`Server "${originalCommand}" exited with code ${code}`, 'error');
|
|
251
|
-
}
|
|
252
228
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
logger_1.default.printEnd(result, this.options.minimalOutput);
|
|
256
|
-
if (!result.success && this.options.retry && this.options.retry > 0 && currentRetry < this.options.retry) {
|
|
257
|
-
logger_1.default.printLine(`Command "${originalCommand}" failed with code ${code}. Retrying (${currentRetry + 1}/${this.options.retry})...`, 'warn');
|
|
258
|
-
if (this.options.retryDelay && this.options.retryDelay > 0) {
|
|
259
|
-
await new Promise(res => setTimeout(res, this.options.retryDelay));
|
|
260
|
-
}
|
|
261
|
-
logger_1.default.clearBuffer(originalCommand);
|
|
262
|
-
resolve(this.runCommand(originalCommand, currentRetry + 1));
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
resolve(result);
|
|
229
|
+
if (this.options.printOutput) {
|
|
230
|
+
logger_1.default.printError(result);
|
|
266
231
|
}
|
|
232
|
+
resolve(result);
|
|
267
233
|
});
|
|
268
234
|
});
|
|
269
235
|
}
|
|
@@ -272,6 +238,7 @@ class Runner {
|
|
|
272
238
|
for (const cmd of commands) {
|
|
273
239
|
const result = await this.runCommand(cmd);
|
|
274
240
|
results.push(result);
|
|
241
|
+
// Stop on error if enabled
|
|
275
242
|
if (!result.success && this.options.stopOnError) {
|
|
276
243
|
break;
|
|
277
244
|
}
|
|
@@ -290,19 +257,18 @@ class Runner {
|
|
|
290
257
|
});
|
|
291
258
|
}
|
|
292
259
|
catch (error) {
|
|
260
|
+
// If pMap stops due to stopOnError
|
|
293
261
|
if (this.options.isServerMode) {
|
|
294
262
|
logger_1.default.printLine('One or more servers failed to start. Stopping all servers.', 'error');
|
|
295
263
|
}
|
|
296
264
|
return [];
|
|
297
265
|
}
|
|
298
266
|
}
|
|
299
|
-
async run(
|
|
300
|
-
const commands = await this.expandWildcardCommands(initialCommands);
|
|
267
|
+
async run(commands) {
|
|
301
268
|
if (commands.length === 0) {
|
|
302
|
-
logger_1.default.printLine('No commands to run after wildcard expansion.', 'warn');
|
|
303
269
|
return [];
|
|
304
270
|
}
|
|
305
|
-
//
|
|
271
|
+
// Set up logger with commands
|
|
306
272
|
logger_1.default.setCommands(commands);
|
|
307
273
|
// Run in parallel or sequential mode
|
|
308
274
|
if (this.options.parallel) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "The Modern Build System for Polyrepo-in-Monorepo Architecture",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -12,9 +12,7 @@
|
|
|
12
12
|
"start": "node dist/bin/neex.js",
|
|
13
13
|
"prepublishOnly": "npm run build",
|
|
14
14
|
"test": "jest",
|
|
15
|
-
"dev": "neex
|
|
16
|
-
"w": "neex w \"ts-node src/server.ts\"",
|
|
17
|
-
"test:dev": "node ./dist/bin/neex.js px \"echo Starting frontend\" \"echo Starting backend\"",
|
|
15
|
+
"test:dev": "node ./dist/bin/neex.js runx \"echo Starting frontend\" \"echo Starting backend\"",
|
|
18
16
|
"test:parallel": "node ./dist/src/cli.js parallel \"echo Building frontend\" \"echo Building backend\"",
|
|
19
17
|
"test:sequence": "node ./dist/src/cli.js run \"echo Step 1\" \"echo Step 2\" \"echo Step 3\""
|
|
20
18
|
},
|
|
@@ -31,15 +29,19 @@
|
|
|
31
29
|
"license": "MIT",
|
|
32
30
|
"dependencies": {
|
|
33
31
|
"chalk": "^4.1.2",
|
|
32
|
+
"chokidar": "^3.5.3",
|
|
34
33
|
"commander": "^9.4.0",
|
|
35
34
|
"figlet": "^1.8.1",
|
|
36
35
|
"figures": "^3.2.0",
|
|
37
36
|
"gradient-string": "^3.0.0",
|
|
38
37
|
"npm-run-path": "^4.0.1",
|
|
39
38
|
"p-map": "^4.0.0",
|
|
40
|
-
"string-width": "^4.2.3"
|
|
39
|
+
"string-width": "^4.2.3",
|
|
40
|
+
"ts-node": "^10.9.1",
|
|
41
|
+
"tsconfig-paths": "^4.2.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
44
|
+
"@types/chokidar": "^2.1.7",
|
|
43
45
|
"@types/figlet": "^1.7.0",
|
|
44
46
|
"@types/jest": "^29.2.3",
|
|
45
47
|
"@types/node": "^18.11.9",
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.addDevCommands = void 0;
|
|
30
|
-
const dev_runner_js_1 = require("../dev-runner.js");
|
|
31
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
32
|
-
const figures_1 = __importDefault(require("figures"));
|
|
33
|
-
const path = __importStar(require("path"));
|
|
34
|
-
const fs = __importStar(require("fs/promises"));
|
|
35
|
-
// Helper function to find default command from package.json
|
|
36
|
-
async function findDefaultCommand() {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
try {
|
|
39
|
-
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
40
|
-
await fs.access(packageJsonPath);
|
|
41
|
-
const packageJsonContent = await fs.readFile(packageJsonPath, 'utf-8');
|
|
42
|
-
const packageJson = JSON.parse(packageJsonContent);
|
|
43
|
-
if ((_a = packageJson.scripts) === null || _a === void 0 ? void 0 : _a.dev) {
|
|
44
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} No command provided. Using "dev" script from package.json: npm run dev`));
|
|
45
|
-
return 'npm run dev';
|
|
46
|
-
}
|
|
47
|
-
if ((_b = packageJson.scripts) === null || _b === void 0 ? void 0 : _b.start) {
|
|
48
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} No command provided. Using "start" script from package.json: npm run start`));
|
|
49
|
-
return 'npm run start';
|
|
50
|
-
}
|
|
51
|
-
if (packageJson.main) {
|
|
52
|
-
const mainFile = packageJson.main;
|
|
53
|
-
const mainFilePath = path.resolve(process.cwd(), mainFile);
|
|
54
|
-
try {
|
|
55
|
-
await fs.access(mainFilePath);
|
|
56
|
-
if (mainFile.endsWith('.ts') || mainFile.endsWith('.mts') || mainFile.endsWith('.cts')) {
|
|
57
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} No command or script found. Using "main" field (TypeScript): npx ts-node ${mainFile}`));
|
|
58
|
-
return `npx ts-node ${mainFile}`;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} No command or script found. Using "main" field (JavaScript): node ${mainFile}`));
|
|
62
|
-
return `node ${mainFile}`;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
// Main file doesn't exist, do nothing, will fall through to return null
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
// package.json doesn't exist or other error, do nothing
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function addDevCommands(program) {
|
|
77
|
-
let devRunner = null;
|
|
78
|
-
// Dev command (Nodemon functionality - formerly watch)
|
|
79
|
-
program
|
|
80
|
-
.command('dev [commands...]') // Made commands optional
|
|
81
|
-
.alias('d')
|
|
82
|
-
.description('Run commands with file watching and auto-restart (nodemon functionality)')
|
|
83
|
-
.option('-c, --no-color', 'Disable colored output')
|
|
84
|
-
.option('-t, --no-timing', 'Hide timing information')
|
|
85
|
-
.option('-p, --no-prefix', 'Hide command prefix')
|
|
86
|
-
.option('-s, --stop-on-error', 'Stop on first error')
|
|
87
|
-
.option('-o, --no-output', 'Hide command output')
|
|
88
|
-
.option('-m, --minimal', 'Use minimal output format')
|
|
89
|
-
.option('-w, --watch <paths...>', 'Paths to watch (default: current directory)')
|
|
90
|
-
.option('-i, --ignore <patterns...>', 'Patterns to ignore')
|
|
91
|
-
.option('-e, --ext <extensions...>', 'File extensions to watch (default: js,mjs,json,ts,tsx,jsx)')
|
|
92
|
-
.option('-d, --delay <ms>', 'Delay before restart in milliseconds', parseInt)
|
|
93
|
-
.option('--clear', 'Clear console on restart')
|
|
94
|
-
.option('--verbose', 'Verbose output')
|
|
95
|
-
.option('--signal <signal>', 'Signal to send to processes on restart', 'SIGTERM')
|
|
96
|
-
.action(async (commands, options) => {
|
|
97
|
-
try {
|
|
98
|
-
let effectiveCommands = commands;
|
|
99
|
-
if (!effectiveCommands || effectiveCommands.length === 0) {
|
|
100
|
-
const foundCommand = await findDefaultCommand();
|
|
101
|
-
if (foundCommand) {
|
|
102
|
-
effectiveCommands = [foundCommand];
|
|
103
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} No command specified for 'neex dev', using default: "${foundCommand}"`));
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} No command specified for 'neex dev' and no default script (dev, start) or main file found in package.json.`));
|
|
107
|
-
console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Please specify a command to run (e.g., neex dev "npm run dev") or define a "dev" or "start" script in your package.json.`));
|
|
108
|
-
process.exit(1);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
else { // At least one command/argument is provided
|
|
112
|
-
const firstArg = effectiveCommands[0];
|
|
113
|
-
const remainingArgs = effectiveCommands.slice(1);
|
|
114
|
-
const isLikelyCommandOrScript = firstArg.includes(' ') || firstArg.startsWith('npm') || firstArg.startsWith('yarn') || firstArg.startsWith('pnpm');
|
|
115
|
-
if (!isLikelyCommandOrScript) {
|
|
116
|
-
const filePath = path.resolve(process.cwd(), firstArg);
|
|
117
|
-
try {
|
|
118
|
-
await fs.access(filePath); // Check if file exists
|
|
119
|
-
let commandToExecute = '';
|
|
120
|
-
if (firstArg.endsWith('.js') || firstArg.endsWith('.mjs') || firstArg.endsWith('.cjs')) {
|
|
121
|
-
commandToExecute = `node ${firstArg}`;
|
|
122
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} Detected .js file, prepending with node.`));
|
|
123
|
-
}
|
|
124
|
-
else if (firstArg.endsWith('.ts') || firstArg.endsWith('.mts') || firstArg.endsWith('.cts')) {
|
|
125
|
-
commandToExecute = `npx ts-node ${firstArg}`;
|
|
126
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} Detected .ts file, prepending with npx ts-node.`));
|
|
127
|
-
}
|
|
128
|
-
if (commandToExecute) {
|
|
129
|
-
effectiveCommands = [commandToExecute, ...remainingArgs];
|
|
130
|
-
console.log(chalk_1.default.cyan(`${figures_1.default.pointer} Executing: ${effectiveCommands.join(' ')}`));
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
console.log(chalk_1.default.yellow(`${figures_1.default.warning} First argument "${firstArg}" is not a recognized .js/.ts file and doesn't look like a script. Attempting to run as is.`));
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
catch (e) {
|
|
137
|
-
console.log(chalk_1.default.yellow(`${figures_1.default.warning} File "${firstArg}" not found. Attempting to run as command.`));
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} Starting development server with file watching (neex dev) for command(s): ${effectiveCommands.map(cmd => `"${cmd}"`).join(' && ')}...`));
|
|
142
|
-
const watchPaths = options.watch || ['./'];
|
|
143
|
-
const ignorePatterns = options.ignore || [
|
|
144
|
-
'node_modules/**', '.git/**', '*.log', 'dist/**', 'build/**',
|
|
145
|
-
'coverage/**', '.nyc_output/**', '*.tmp', '*.temp'
|
|
146
|
-
];
|
|
147
|
-
const extensions = options.ext || ['js', 'mjs', 'json', 'ts', 'tsx', 'jsx'];
|
|
148
|
-
devRunner = new dev_runner_js_1.DevRunner({
|
|
149
|
-
runnerName: 'neex dev',
|
|
150
|
-
parallel: false,
|
|
151
|
-
color: options.color,
|
|
152
|
-
showTiming: options.timing,
|
|
153
|
-
prefix: options.prefix,
|
|
154
|
-
stopOnError: options.stopOnError,
|
|
155
|
-
printOutput: options.output,
|
|
156
|
-
minimalOutput: options.minimal,
|
|
157
|
-
watch: watchPaths,
|
|
158
|
-
ignore: ignorePatterns,
|
|
159
|
-
ext: extensions,
|
|
160
|
-
delay: options.delay || 1000,
|
|
161
|
-
clearConsole: options.clear,
|
|
162
|
-
verbose: options.verbose,
|
|
163
|
-
signal: options.signal,
|
|
164
|
-
restartOnChange: true,
|
|
165
|
-
groupOutput: false,
|
|
166
|
-
isServerMode: false
|
|
167
|
-
});
|
|
168
|
-
await devRunner.start(effectiveCommands);
|
|
169
|
-
}
|
|
170
|
-
catch (error) {
|
|
171
|
-
if (error instanceof Error) {
|
|
172
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} Dev Error: ${error.message}`));
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown dev error occurred`));
|
|
176
|
-
}
|
|
177
|
-
process.exit(1);
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
// Return cleanup function for dev runner
|
|
181
|
-
return {
|
|
182
|
-
getDevRunner: () => devRunner,
|
|
183
|
-
cleanupDev: () => {
|
|
184
|
-
if (devRunner && devRunner.isActive()) {
|
|
185
|
-
devRunner.stop();
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
exports.addDevCommands = addDevCommands;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
// src/commands/index.ts - Export all commands
|
|
18
|
-
__exportStar(require("./run-commands.js"), exports);
|
|
19
|
-
__exportStar(require("./dev-commands.js"), exports);
|
|
20
|
-
__exportStar(require("./process-commands"), exports);
|
|
21
|
-
__exportStar(require("./server-commands.js"), exports);
|