neex 0.3.7 → 0.3.8

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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"dev-manager.js","sourceRoot":"","sources":["../src/dev-manager.ts"],"names":[],"mappings":";;;;;;AAAA,qCAA8C;AAC9C,uCAA4C;AAC5C,iDAAoD;AACpD,+BAAkD;AAClD,2BAA2C;AAC3C,kDAA0B;AAC1B,sDAA8B;AAC9B,mCAAsC;AAoBtC,MAAM,UAAW,SAAQ,qBAAY;IAQjC;QACI,KAAK,EAAE,CAAC;QARJ,YAAO,GAAqB,IAAI,CAAC;QACjC,YAAO,GAAwB,IAAI,CAAC;QACpC,iBAAY,GAAG,KAAK,CAAC;QACrB,iBAAY,GAA0B,IAAI,CAAC;QAC3C,kBAAa,GAAG,MAAM,CAAC;QACvB,gBAAW,GAAG,IAAI,CAAC;IAI3B,CAAC;IAEM,KAAK,CAAC,KAAK,CAAC,OAAmB;QAClC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,aAAa,CAAC;QACpD,MAAM,OAAO,GAAG,IAAA,cAAO,EAAC,MAAM,EAAE,GAAG,IAAA,eAAQ,EAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QAExE,IAAI;YACA,IAAI,CAAC,IAAA,eAAU,EAAC,MAAM,CAAC,EAAE;gBACrB,IAAA,cAAS,EAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;aAC1C;YAED,MAAM,YAAY,GAAiB;gBAC/B,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;gBAC5B,OAAO;gBACP,MAAM,EAAE,IAAI;gBACZ,QAAQ,EAAE,MAAM;gBAChB,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC;gBACpC,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,KAAK;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AE,CAAC;YACrB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACvB;QAED,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAChC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;SAC5B;QAED,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;CACJ;AAEY,QAAA,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC"}
package/dist/src/cli.js DELETED
@@ -1,519 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- // src/cli.ts - Updated version
7
- const commander_1 = require("commander");
8
- const index_js_1 = require("./index.js");
9
- const chalk_1 = __importDefault(require("chalk"));
10
- const figures_1 = __importDefault(require("figures"));
11
- const chokidar_1 = require("chokidar");
12
- const child_process_1 = require("child_process");
13
- const path_1 = require("path");
14
- const fs_1 = require("fs");
15
- const process_manager_js_1 = require("./process-manager.js");
16
- const { version } = require('../../package.json');
17
- function cli() {
18
- const program = new commander_1.Command();
19
- let cleanupRunner = null;
20
- program
21
- .name('neex')
22
- .description('Professional script runner with beautiful colored output')
23
- .version(version);
24
- // Development command for Express.js projects
25
- program
26
- .command('dev <entry>')
27
- .description('Run Express.js project in development mode with TypeScript support')
28
- .option('-p, --port <number>', 'Port to run the server on', '3000')
29
- .option('-w, --watch <paths...>', 'Paths to watch for changes', ['src'])
30
- .option('-i, --ignore <paths...>', 'Paths to ignore', ['node_modules', 'dist', '.git'])
31
- .option('-e, --ext <extensions...>', 'File extensions to watch', ['ts', 'js', 'json'])
32
- .option('-d, --delay <number>', 'Delay before restarting in milliseconds', '1000')
33
- .option('-c, --no-color', 'Disable colored output')
34
- .option('--no-clear', 'Disable screen clearing on restart')
35
- .action(async (entry, options) => {
36
- try {
37
- const entryPath = (0, path_1.resolve)(process.cwd(), entry);
38
- if (!(0, fs_1.existsSync)(entryPath)) {
39
- throw new Error(`Entry file ${entry} not found`);
40
- }
41
- console.log(chalk_1.default.blue(`${figures_1.default.info} Starting development server...`));
42
- let server = null;
43
- let isRestarting = false;
44
- let restartTimer = null;
45
- const startServer = () => {
46
- if (server) {
47
- server.kill();
48
- }
49
- server = (0, child_process_1.spawn)('ts-node', [
50
- '-r', 'tsconfig-paths/register',
51
- entryPath
52
- ], {
53
- stdio: 'inherit',
54
- env: {
55
- ...process.env,
56
- PORT: options.port,
57
- NODE_ENV: 'development'
58
- }
59
- });
60
- server.on('error', (err) => {
61
- console.error(chalk_1.default.red(`${figures_1.default.cross} Server error: ${err.message}`));
62
- });
63
- server.on('exit', (code) => {
64
- if (code !== 0 && !isRestarting) {
65
- console.error(chalk_1.default.red(`${figures_1.default.cross} Server crashed with code ${code}`));
66
- }
67
- });
68
- };
69
- // Initial server start
70
- startServer();
71
- // Setup file watching with chokidar
72
- const watcher = (0, chokidar_1.watch)(options.watch, {
73
- ignored: [
74
- ...options.ignore,
75
- /(^|[\/\\])\../,
76
- '**/*.map' // Ignore source maps
77
- ],
78
- persistent: true,
79
- ignoreInitial: true,
80
- awaitWriteFinish: {
81
- stabilityThreshold: 300,
82
- pollInterval: 100
83
- }
84
- });
85
- // Handle file changes
86
- watcher.on('change', (path) => {
87
- var _a;
88
- const ext = (_a = path.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
89
- if (!ext || !options.ext.includes(ext)) {
90
- return;
91
- }
92
- if (restartTimer) {
93
- clearTimeout(restartTimer);
94
- }
95
- isRestarting = true;
96
- restartTimer = setTimeout(() => {
97
- if (options.clear) {
98
- process.stdout.write('\x1Bc'); // Clear screen
99
- }
100
- console.log(chalk_1.default.yellow(`${figures_1.default.info} File ${path} changed. Restarting...`));
101
- startServer();
102
- isRestarting = false;
103
- }, parseInt(options.delay));
104
- });
105
- // Handle cleanup
106
- cleanupRunner = () => {
107
- if (server) {
108
- server.kill();
109
- }
110
- if (restartTimer) {
111
- clearTimeout(restartTimer);
112
- }
113
- watcher.close();
114
- };
115
- // Handle process signals
116
- process.on('SIGINT', () => {
117
- cleanupRunner === null || cleanupRunner === void 0 ? void 0 : cleanupRunner();
118
- process.exit(0);
119
- });
120
- process.on('SIGTERM', () => {
121
- cleanupRunner === null || cleanupRunner === void 0 ? void 0 : cleanupRunner();
122
- process.exit(0);
123
- });
124
- }
125
- catch (error) {
126
- if (error instanceof Error) {
127
- console.error(chalk_1.default.red(`${figures_1.default.cross} Error: ${error.message}`));
128
- }
129
- else {
130
- console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown error occurred`));
131
- }
132
- process.exit(1);
133
- }
134
- });
135
- // Build command for TypeScript compilation
136
- program
137
- .command('build')
138
- .description('Build TypeScript project')
139
- .option('-o, --outDir <dir>', 'Output directory', 'dist')
140
- .action(async (options) => {
141
- try {
142
- console.log(chalk_1.default.blue(`${figures_1.default.info} Building project...`));
143
- const build = (0, child_process_1.spawn)('tsc', [
144
- '--outDir', options.outDir
145
- ], {
146
- stdio: 'inherit'
147
- });
148
- build.on('close', (code) => {
149
- if (code === 0) {
150
- console.log(chalk_1.default.green(`${figures_1.default.tick} Build completed successfully`));
151
- }
152
- else {
153
- console.error(chalk_1.default.red(`${figures_1.default.cross} Build failed with code ${code}`));
154
- process.exit(code !== null && code !== void 0 ? code : 1);
155
- }
156
- });
157
- }
158
- catch (error) {
159
- if (error instanceof Error) {
160
- console.error(chalk_1.default.red(`${figures_1.default.cross} Error: ${error.message}`));
161
- }
162
- else {
163
- console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown error occurred`));
164
- }
165
- process.exit(1);
166
- }
167
- });
168
- // Start command for production
169
- program
170
- .command('start')
171
- .description('Start the built application in production mode')
172
- .option('-p, --port <number>', 'Port to run the server on', '3000')
173
- .option('-o, --outDir <dir>', 'Output directory', 'dist')
174
- .option('-e, --entry <file>', 'Entry file name', 'index.js')
175
- .action(async (options) => {
176
- try {
177
- const outDir = options.outDir;
178
- const entryFile = options.entry;
179
- const entryPath = (0, path_1.resolve)(process.cwd(), outDir, entryFile);
180
- if (!(0, fs_1.existsSync)(entryPath)) {
181
- console.log(chalk_1.default.yellow(`${figures_1.default.warning} Build not found. Building project first...`));
182
- // Run build command first
183
- const build = (0, child_process_1.spawn)('tsc', [
184
- '--outDir', outDir
185
- ], {
186
- stdio: 'inherit'
187
- });
188
- build.on('close', (code) => {
189
- if (code === 0) {
190
- console.log(chalk_1.default.green(`${figures_1.default.tick} Build completed successfully`));
191
- startServer();
192
- }
193
- else {
194
- console.error(chalk_1.default.red(`${figures_1.default.cross} Build failed with code ${code}`));
195
- process.exit(code !== null && code !== void 0 ? code : 1);
196
- }
197
- });
198
- }
199
- else {
200
- startServer();
201
- }
202
- function startServer() {
203
- console.log(chalk_1.default.blue(`${figures_1.default.info} Starting production server...`));
204
- const server = (0, child_process_1.spawn)('node', [entryPath], {
205
- stdio: 'inherit',
206
- env: {
207
- ...process.env,
208
- PORT: options.port,
209
- NODE_ENV: 'production'
210
- }
211
- });
212
- cleanupRunner = () => {
213
- server.kill();
214
- };
215
- server.on('error', (err) => {
216
- console.error(chalk_1.default.red(`${figures_1.default.cross} Server error: ${err.message}`));
217
- process.exit(1);
218
- });
219
- }
220
- }
221
- catch (error) {
222
- if (error instanceof Error) {
223
- console.error(chalk_1.default.red(`${figures_1.default.cross} Error: ${error.message}`));
224
- }
225
- else {
226
- console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown error occurred`));
227
- }
228
- process.exit(1);
229
- }
230
- });
231
- // Main command for sequential execution (similar to )
232
- program
233
- .command('sequential <commands...>')
234
- .alias('s')
235
- .description('Run commands sequentially')
236
- .option('-c, --no-color', 'Disable colored output')
237
- .option('-t, --no-timing', 'Hide timing information')
238
- .option('-p, --no-prefix', 'Hide command prefix')
239
- .option('-s, --stop-on-error', 'Stop on first error')
240
- .option('-o, --no-output', 'Hide command output')
241
- .option('-m, --minimal', 'Use minimal output format')
242
- .action(async (commands, options) => {
243
- try {
244
- await (0, index_js_1.run)(commands, {
245
- parallel: false,
246
- color: options.color,
247
- showTiming: options.timing,
248
- prefix: options.prefix,
249
- stopOnError: options.stopOnError,
250
- printOutput: options.output,
251
- minimalOutput: options.minimal,
252
- registerCleanup: (cleanup) => { cleanupRunner = cleanup; }
253
- });
254
- }
255
- catch (error) {
256
- if (error instanceof Error) {
257
- console.error(chalk_1.default.red(`${figures_1.default.cross} Error: ${error.message}`));
258
- }
259
- else {
260
- console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown error occurred`));
261
- }
262
- process.exit(1);
263
- }
264
- });
265
- // runx command: parallel execution by default (with alias 'p'), can run sequentially with -q
266
- program
267
- .command('parallel <commands...>', { isDefault: true })
268
- .alias('p')
269
- .description('Run commands in parallel (default) or sequentially with -q. Alias: p')
270
- .option('-c, --no-color', 'Disable colored output')
271
- .option('-t, --no-timing', 'Hide timing information')
272
- .option('-p, --no-prefix', 'Hide command prefix')
273
- .option('-s, --stop-on-error', 'Stop on first error')
274
- .option('-o, --no-output', 'Hide command output')
275
- .option('-m, --minimal', 'Use minimal output format')
276
- .option('-x, --max-parallel <number>', 'Maximum number of parallel processes', parseInt)
277
- .option('-q, --sequential', 'Run commands sequentially instead of in parallel')
278
- .action(async (commands, options) => {
279
- try {
280
- await (0, index_js_1.run)(commands, {
281
- parallel: !options.sequential,
282
- maxParallel: options.maxParallel,
283
- color: options.color,
284
- showTiming: options.timing,
285
- prefix: options.prefix,
286
- stopOnError: options.stopOnError,
287
- printOutput: options.output,
288
- minimalOutput: options.minimal,
289
- registerCleanup: (cleanup) => { cleanupRunner = cleanup; }
290
- });
291
- }
292
- catch (error) {
293
- if (error instanceof Error) {
294
- console.error(chalk_1.default.red(`${figures_1.default.cross} Error: ${error.message}`));
295
- }
296
- else {
297
- console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown error occurred`));
298
- }
299
- process.exit(1);
300
- }
301
- });
302
- // Process Management Commands
303
- program
304
- .command('startx <command>')
305
- .description('Start a process with monitoring and auto-restart')
306
- .option('-n, --name <name>', 'Process name')
307
- .option('-w, --watch', 'Watch for file changes and auto-restart')
308
- .option('-r, --max-restarts <number>', 'Maximum number of restart attempts', '5')
309
- .option('-d, --restart-delay <number>', 'Delay between restarts in milliseconds', '1000')
310
- .option('-c, --cwd <path>', 'Working directory for the process')
311
- .action(async (command, options) => {
312
- try {
313
- const process = await process_manager_js_1.processManager.startx(command, {
314
- name: options.name,
315
- watch: options.watch,
316
- maxRestarts: parseInt(options.maxRestarts),
317
- restartDelay: parseInt(options.restartDelay),
318
- cwd: options.cwd
319
- });
320
- console.log(chalk_1.default.green(`${figures_1.default.tick} Process started successfully`));
321
- console.log(chalk_1.default.blue(`Name: ${process.name}`));
322
- console.log(chalk_1.default.blue(`PID: ${process.pid}`));
323
- console.log(chalk_1.default.blue(`Command: ${process.command}`));
324
- console.log(chalk_1.default.blue(`Max Restarts: ${process.maxRestarts}`));
325
- console.log(chalk_1.default.blue(`Restart Delay: ${process.restartDelay}ms`));
326
- }
327
- catch (error) {
328
- if (error instanceof Error) {
329
- console.error(chalk_1.default.red(`${figures_1.default.cross} Error: ${error.message}`));
330
- }
331
- else {
332
- console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown error occurred`));
333
- }
334
- process.exit(1);
335
- }
336
- });
337
- program
338
- .command('stopx <name>')
339
- .description('Stop a running process')
340
- .option('-f, --force', 'Force stop the process')
341
- .action(async (name, options) => {
342
- try {
343
- await process_manager_js_1.processManager.stopx(name);
344
- console.log(chalk_1.default.green(`${figures_1.default.tick} Process stopped successfully`));
345
- }
346
- catch (error) {
347
- if (error instanceof Error) {
348
- console.error(chalk_1.default.red(`${figures_1.default.cross} Error: ${error.message}`));
349
- }
350
- else {
351
- console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown error occurred`));
352
- }
353
- process.exit(1);
354
- }
355
- });
356
- program
357
- .command('list')
358
- .description('List all running processes')
359
- .option('-a, --all', 'Show all processes including stopped ones')
360
- .option('-j, --json', 'Output in JSON format')
361
- .action((options) => {
362
- try {
363
- if (options.json) {
364
- const processes = Array.from(process_manager_js_1.processManager.list());
365
- console.log(JSON.stringify(processes, null, 2));
366
- return;
367
- }
368
- console.log(process_manager_js_1.processManager.list());
369
- }
370
- catch (error) {
371
- if (error instanceof Error) {
372
- console.error(chalk_1.default.red(`${figures_1.default.cross} Error: ${error.message}`));
373
- }
374
- else {
375
- console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown error occurred`));
376
- }
377
- process.exit(1);
378
- }
379
- });
380
- program
381
- .command('monit <name>')
382
- .description('Monitor a process in real-time')
383
- .option('-i, --interval <number>', 'Update interval in milliseconds', '1000')
384
- .action((name, options) => {
385
- try {
386
- const interval = parseInt(options.interval);
387
- if (isNaN(interval) || interval < 100) {
388
- throw new Error('Interval must be a number greater than 100ms');
389
- }
390
- // Start real-time monitoring
391
- const updateDisplay = () => {
392
- try {
393
- const { table, logs } = process_manager_js_1.processManager.monit(name);
394
- process.stdout.write('\x1Bc'); // Clear screen
395
- console.log(table);
396
- console.log(chalk_1.default.blue('\nRecent Logs:'));
397
- logs.forEach(log => {
398
- if (log.includes('error') || log.includes('Error')) {
399
- console.log(chalk_1.default.red(log));
400
- }
401
- else if (log.includes('warn') || log.includes('Warn')) {
402
- console.log(chalk_1.default.yellow(log));
403
- }
404
- else {
405
- console.log(log);
406
- }
407
- });
408
- }
409
- catch (error) {
410
- clearInterval(monitorInterval);
411
- console.error(chalk_1.default.red(`${figures_1.default.cross} Error monitoring process: ${error}`));
412
- process.exit(1);
413
- }
414
- };
415
- const monitorInterval = setInterval(updateDisplay, interval);
416
- updateDisplay(); // Initial display
417
- process.on('SIGINT', () => {
418
- clearInterval(monitorInterval);
419
- process.exit(0);
420
- });
421
- }
422
- catch (error) {
423
- if (error instanceof Error) {
424
- console.error(chalk_1.default.red(`${figures_1.default.cross} Error: ${error.message}`));
425
- }
426
- else {
427
- console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown error occurred`));
428
- }
429
- process.exit(1);
430
- }
431
- });
432
- program
433
- .command('log <name>')
434
- .description('View process logs')
435
- .option('-f, --follow', 'Follow log output')
436
- .option('-e, --errors', 'Show only errors')
437
- .option('-w, --warnings', 'Show only warnings')
438
- .option('-l, --lines <number>', 'Number of lines to show', '100')
439
- .action((name, options) => {
440
- try {
441
- const lines = parseInt(options.lines);
442
- if (isNaN(lines) || lines < 1) {
443
- throw new Error('Lines must be a positive number');
444
- }
445
- const logs = process_manager_js_1.processManager.log(name, lines);
446
- let filteredLogs = logs;
447
- if (options.errors) {
448
- filteredLogs = logs.filter(log => log.toLowerCase().includes('error') ||
449
- log.toLowerCase().includes('exception'));
450
- }
451
- else if (options.warnings) {
452
- filteredLogs = logs.filter(log => log.toLowerCase().includes('warn') ||
453
- log.toLowerCase().includes('warning'));
454
- }
455
- filteredLogs.forEach(log => {
456
- if (log.includes('error') || log.includes('Error')) {
457
- console.log(chalk_1.default.red(log));
458
- }
459
- else if (log.includes('warn') || log.includes('Warn')) {
460
- console.log(chalk_1.default.yellow(log));
461
- }
462
- else {
463
- console.log(log);
464
- }
465
- });
466
- if (options.follow) {
467
- const watcher = (0, chokidar_1.watch)(process_manager_js_1.processManager.getLogPath(name), {
468
- persistent: true
469
- });
470
- watcher.on('change', () => {
471
- const newLogs = process_manager_js_1.processManager.log(name, 1);
472
- if (newLogs.length > 0) {
473
- const log = newLogs[0];
474
- if (log.includes('error') || log.includes('Error')) {
475
- console.log(chalk_1.default.red(log));
476
- }
477
- else if (log.includes('warn') || log.includes('Warn')) {
478
- console.log(chalk_1.default.yellow(log));
479
- }
480
- else {
481
- console.log(log);
482
- }
483
- }
484
- });
485
- process.on('SIGINT', () => {
486
- watcher.close();
487
- process.exit(0);
488
- });
489
- }
490
- }
491
- catch (error) {
492
- if (error instanceof Error) {
493
- console.error(chalk_1.default.red(`${figures_1.default.cross} Error: ${error.message}`));
494
- }
495
- else {
496
- console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown error occurred`));
497
- }
498
- process.exit(1);
499
- }
500
- });
501
- program.parse(process.argv);
502
- // Show help if no commands specified
503
- if (program.args.length === 0) {
504
- program.help();
505
- }
506
- // Graceful shutdown handling
507
- const handleSignal = (signal) => {
508
- console.log(`\n${chalk_1.default.yellow(`${figures_1.default.warning} Received ${signal}. Cleaning up...`)}`);
509
- if (cleanupRunner) {
510
- cleanupRunner();
511
- }
512
- // Give cleanup a moment, then exit
513
- setTimeout(() => process.exit(0), 500);
514
- };
515
- process.on('SIGINT', () => handleSignal('SIGINT')); // Ctrl+C
516
- process.on('SIGTERM', () => handleSignal('SIGTERM'));
517
- process.on('SIGQUIT', () => handleSignal('SIGQUIT'));
518
- }
519
- exports.default = cli;
package/dist/src/index.js DELETED
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.runServers = exports.runSequential = exports.runParallel = exports.run = void 0;
7
- // src/index.ts - Updated version
8
- const runner_1 = require("./runner");
9
- const logger_1 = __importDefault(require("./logger"));
10
- /**
11
- * Run one or more commands in parallel or sequentially
12
- */
13
- async function run(commands, options) {
14
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
15
- const cmdArray = Array.isArray(commands) ? commands : [commands];
16
- const runOptions = {
17
- parallel: (_a = options === null || options === void 0 ? void 0 : options.parallel) !== null && _a !== void 0 ? _a : false,
18
- maxParallel: options === null || options === void 0 ? void 0 : options.maxParallel,
19
- printOutput: (_b = options === null || options === void 0 ? void 0 : options.printOutput) !== null && _b !== void 0 ? _b : true,
20
- color: (_c = options === null || options === void 0 ? void 0 : options.color) !== null && _c !== void 0 ? _c : true,
21
- showTiming: (_d = options === null || options === void 0 ? void 0 : options.showTiming) !== null && _d !== void 0 ? _d : true,
22
- prefix: (_e = options === null || options === void 0 ? void 0 : options.prefix) !== null && _e !== void 0 ? _e : true,
23
- stopOnError: (_f = options === null || options === void 0 ? void 0 : options.stopOnError) !== null && _f !== void 0 ? _f : false,
24
- minimalOutput: (_g = options === null || options === void 0 ? void 0 : options.minimalOutput) !== null && _g !== void 0 ? _g : false,
25
- groupOutput: (_h = options === null || options === void 0 ? void 0 : options.groupOutput) !== null && _h !== void 0 ? _h : false,
26
- isServerMode: (_j = options === null || options === void 0 ? void 0 : options.isServerMode) !== null && _j !== void 0 ? _j : false
27
- };
28
- const runner = new runner_1.Runner(runOptions);
29
- if (options === null || options === void 0 ? void 0 : options.registerCleanup) {
30
- options.registerCleanup(() => runner.cleanup());
31
- }
32
- const results = await runner.run(cmdArray);
33
- if (runOptions.printOutput && cmdArray.length > 1) {
34
- logger_1.default.printSummary(results);
35
- }
36
- return results;
37
- }
38
- exports.run = run;
39
- /**
40
- * Run multiple commands in parallel
41
- */
42
- async function runParallel(commands, options) {
43
- return run(commands, { ...options, parallel: true });
44
- }
45
- exports.runParallel = runParallel;
46
- /**
47
- * Run multiple commands sequentially
48
- */
49
- async function runSequential(commands, options) {
50
- return run(commands, { ...options, parallel: false });
51
- }
52
- exports.runSequential = runSequential;
53
- /**
54
- * Run multiple servers with optimized output
55
- */
56
- async function runServers(commands, options) {
57
- return run(commands, {
58
- ...options,
59
- parallel: true,
60
- isServerMode: true,
61
- printOutput: true
62
- });
63
- }
64
- exports.runServers = runServers;
65
- exports.default = {
66
- run,
67
- runParallel,
68
- runSequential,
69
- runServers
70
- };