neex 0.6.34 → 0.6.36

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.
@@ -69,11 +69,12 @@ class BuildManager {
69
69
  clean: false,
70
70
  sourceMap: false,
71
71
  target: 'es2020',
72
- module: 'commonjs'
72
+ module: 'commonjs',
73
+ silent: false,
73
74
  };
74
75
  this.options = {
75
76
  ...defaultOptions,
76
- ...options
77
+ ...options,
77
78
  };
78
79
  }
79
80
  setupFileWatcher() {
@@ -96,7 +97,7 @@ class BuildManager {
96
97
  });
97
98
  }
98
99
  async handleFileChange(event) {
99
- if (this.options.showInfo) {
100
+ if (this.options.showInfo && !this.options.silent) {
100
101
  const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
101
102
  logger_1.default.printLine(`${prefix} File changed: ${chalk_1.default.yellow(event.relativePath)}`, 'info');
102
103
  }
@@ -107,7 +108,7 @@ class BuildManager {
107
108
  await fs.mkdir(this.options.outputDir, { recursive: true });
108
109
  }
109
110
  catch (error) {
110
- if (this.options.showInfo) {
111
+ if (this.options.showInfo && !this.options.silent) {
111
112
  logger_1.default.printLine(`Failed to create output directory: ${error.message}`, 'error');
112
113
  }
113
114
  throw error;
@@ -119,13 +120,13 @@ class BuildManager {
119
120
  }
120
121
  try {
121
122
  await fs.rm(this.options.outputDir, { recursive: true, force: true });
122
- if (this.options.showInfo) {
123
+ if (this.options.showInfo && !this.options.silent) {
123
124
  const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
124
125
  logger_1.default.printLine(`${prefix} Cleaned output directory: ${chalk_1.default.yellow(this.options.outputDir)}`, 'info');
125
126
  }
126
127
  }
127
128
  catch (error) {
128
- if (this.options.showInfo) {
129
+ if (this.options.showInfo && !this.options.silent) {
129
130
  logger_1.default.printLine(`Failed to clean output directory: ${error.message}`, 'error');
130
131
  }
131
132
  throw error;
@@ -156,7 +157,8 @@ class BuildManager {
156
157
  printOutput: (_a = this.options.showInfo) !== null && _a !== void 0 ? _a : false,
157
158
  showTiming: (_b = this.options.showInfo) !== null && _b !== void 0 ? _b : false,
158
159
  prefix: (_c = this.options.showInfo) !== null && _c !== void 0 ? _c : false,
159
- customPrefix: this.options.showInfo ? () => `build` : undefined
160
+ customPrefix: this.options.showInfo ? () => `build` : undefined,
161
+ silent: this.options.silent, // Pass silent option to the runner
160
162
  };
161
163
  this.runner = new runner_1.Runner(runnerOptions);
162
164
  try {
@@ -250,7 +252,7 @@ class BuildManager {
250
252
  // Set up graceful shutdown
251
253
  this.setupGracefulShutdown();
252
254
  if (this.options.watch) {
253
- if (this.options.showInfo) {
255
+ if (this.options.showInfo && !this.options.silent) {
254
256
  const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
255
257
  logger_1.default.printLine(`${prefix} Build completed. Watching for changes...`, 'info');
256
258
  logger_1.default.printLine(`${prefix} Press ${chalk_1.default.cyan('Ctrl+C')} to stop`, 'info');
@@ -261,7 +263,7 @@ class BuildManager {
261
263
  if (this.isBuilding) {
262
264
  return;
263
265
  }
264
- if (this.options.showInfo) {
266
+ if (this.options.showInfo && !this.options.silent) {
265
267
  const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
266
268
  logger_1.default.printLine(`${prefix} Rebuilding due to file changes...`, 'info');
267
269
  }
@@ -277,7 +279,7 @@ class BuildManager {
277
279
  }
278
280
  // Run build again
279
281
  await this.runBuild();
280
- if (this.options.showInfo) {
282
+ if (this.options.showInfo && !this.options.silent) {
281
283
  const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
282
284
  logger_1.default.printLine(`${prefix} Rebuild completed. Watching for changes...`, 'info');
283
285
  }
@@ -290,7 +292,7 @@ class BuildManager {
290
292
  if (!this.isBuilding && !this.options.watch) {
291
293
  return;
292
294
  }
293
- if (this.options.showInfo) {
295
+ if (this.options.showInfo && !this.options.silent) {
294
296
  const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
295
297
  logger_1.default.printLine(`${prefix} Stopping build process...`, 'info');
296
298
  }
@@ -302,7 +304,7 @@ class BuildManager {
302
304
  if (this.runner) {
303
305
  this.runner.cleanup('SIGTERM');
304
306
  }
305
- if (this.options.showInfo) {
307
+ if (this.options.showInfo && !this.options.silent) {
306
308
  const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
307
309
  const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
308
310
  const uptimeStr = this.formatUptime(uptime);
@@ -314,7 +316,7 @@ class BuildManager {
314
316
  }
315
317
  setupGracefulShutdown() {
316
318
  const handleSignal = (signal) => {
317
- if (this.options.showInfo) {
319
+ if (this.options.showInfo && !this.options.silent) {
318
320
  console.log(`\n${chalk_1.default.yellow(`${figures_1.default.warning} Received ${signal}. Shutting down build process...`)}`);
319
321
  }
320
322
  this.stop().then(() => {
package/dist/src/cli.js CHANGED
@@ -20,8 +20,8 @@ function cli() {
20
20
  // Add all command groups
21
21
  (0, index_js_1.addRunCommands)(program);
22
22
  (0, index_js_1.addServerCommands)(program);
23
- const devCommands = (0, index_js_1.addDevCommands)(program);
24
- cleanupHandlers.push(devCommands.cleanupDev);
23
+ const devCmds = (0, index_js_1.devCommands)(program);
24
+ cleanupHandlers.push(devCmds.cleanupDev);
25
25
  const buildCommands = (0, index_js_1.addBuildCommands)(program);
26
26
  cleanupHandlers.push(buildCommands.cleanupBuild);
27
27
  const startCommands = (0, index_js_1.addStartCommands)(program);
@@ -1,209 +1,42 @@
1
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
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
28
5
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.addDevCommands = void 0;
6
+ exports.devCommands = void 0;
30
7
  const dev_runner_js_1 = require("../dev-runner.js");
31
8
  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 check if file exists
36
- async function fileExists(filePath) {
37
- try {
38
- await fs.access(filePath);
39
- return true;
40
- }
41
- catch (_a) {
42
- return false;
43
- }
44
- }
45
- // Helper function to determine the best command to run the file
46
- async function getBestCommand(filePath, showInfo) {
47
- const ext = path.extname(filePath).toLowerCase();
48
- const absolutePath = path.resolve(process.cwd(), filePath);
49
- // Check if file exists
50
- if (!(await fileExists(absolutePath))) {
51
- throw new Error(`File not found: ${filePath}`);
52
- }
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
- }
56
- switch (ext) {
57
- case '.ts':
58
- case '.mts':
59
- case '.cts':
60
- if (showInfo) {
61
- console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: TypeScript detected, ready to run`));
62
- }
63
- return `npx ts-node ${filePath}`;
64
- case '.js':
65
- case '.mjs':
66
- case '.cjs':
67
- if (showInfo) {
68
- console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: JavaScript detected, ready to run`));
69
- }
70
- return `node ${filePath}`;
71
- default:
72
- if (showInfo) {
73
- console.log(chalk_1.default.yellow(`${figures_1.default.warning} neex dev: Unknown file type, using Node.js`));
74
- }
75
- return `node ${filePath}`;
76
- }
77
- }
78
- function addDevCommands(program) {
79
- let devRunner = null;
80
- // Dev command - file watching and auto-restart like nodemon/ts-node-dev
9
+ const config_js_1 = require("../config.js");
10
+ function devCommands(program) {
81
11
  program
82
- .command('dev <file>') // Made file mandatory
83
- .alias('d')
84
- .description('Run TypeScript/JavaScript files with file watching and auto-restart (like nodemon/ts-node-dev but better)')
85
- .option('-c, --no-color', 'Disable colored output')
86
- .option('-t, --no-timing', 'Hide timing information')
87
- .option('-p, --no-prefix', 'Hide command prefix')
88
- .option('-s, --stop-on-error', 'Stop on first error')
89
- .option('-o, --no-output', 'Hide command output')
90
- .option('-m, --minimal', 'Use minimal output format')
91
- .option('-w, --watch <paths...>', 'Additional paths to watch (default: current directory)')
92
- .option('-i, --ignore <patterns...>', 'Patterns to ignore')
93
- .option('-e, --ext <extensions...>', 'File extensions to watch (default: js,mjs,json,ts,tsx,jsx)')
94
- .option('-d, --delay <ms>', 'Delay before restart in milliseconds', parseInt)
95
- .option('--clear', 'Clear console on restart')
96
- .option('--verbose', 'Verbose output')
97
- .option('--info', 'Show detailed information during startup')
98
- .option('--signal <signal>', 'Signal to send to processes on restart', 'SIGTERM')
99
- .action(async (file, options) => {
12
+ .command('dev')
13
+ .description('Run commands in development mode')
14
+ .option('-c, --config <path>', 'Path to the neex.config.js file')
15
+ .action(async (options) => {
100
16
  try {
101
- const showInfo = options.info || false;
102
- if (showInfo) {
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
- }
106
- // Validate file parameter
107
- if (!file || file.trim() === '') {
108
- console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: Error - No file specified!`));
109
- console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Usage: neex dev <file>`));
110
- console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Example: neex dev src/server.ts`));
17
+ const config = await (0, config_js_1.loadConfig)(options.config);
18
+ if (!config.commands || config.commands.length === 0) {
19
+ console.error(chalk_1.default.red('No commands found in the configuration file.'));
111
20
  process.exit(1);
112
21
  }
113
- // Get the best command to run the file
114
- let commandToExecute;
115
- let fileExtension;
116
- try {
117
- commandToExecute = await getBestCommand(file, showInfo);
118
- fileExtension = path.extname(file).toLowerCase();
119
- }
120
- catch (error) {
121
- console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: ${error instanceof Error ? error.message : 'Unknown error occurred'}`));
122
- process.exit(1);
123
- }
124
- // Setup watch configuration
125
- const watchPaths = options.watch ? [...options.watch, './'] : ['./'];
126
- const ignorePatterns = options.ignore || [
127
- 'node_modules/**',
128
- '.git/**',
129
- '*.log',
130
- 'dist/**',
131
- 'build/**',
132
- 'coverage/**',
133
- '.nyc_output/**',
134
- '*.tmp',
135
- '*.temp',
136
- '.DS_Store',
137
- 'Thumbs.db'
138
- ];
139
- const extensions = options.ext || ['js', 'mjs', 'json', 'ts', 'tsx', 'jsx', 'vue', 'svelte'];
140
- // Log configuration only if --info flag is set
141
- if (showInfo) {
142
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Configuration:`));
143
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Target: ${chalk_1.default.cyan(file)}`));
144
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Runtime: ${chalk_1.default.cyan(fileExtension === '.ts' || fileExtension === '.mts' || fileExtension === '.cts' ? 'TypeScript' : 'JavaScript')}`));
145
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Watch paths: ${chalk_1.default.cyan(watchPaths.join(', '))}`));
146
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Extensions: ${chalk_1.default.cyan(extensions.join(', '))}`));
147
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Restart delay: ${chalk_1.default.cyan(options.delay || 1000)}ms`));
148
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Clear console: ${chalk_1.default.cyan(options.clear ? 'Yes' : 'No')}`));
149
- if (options.verbose) {
150
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Verbose mode enabled - showing detailed logs`));
151
- }
152
- console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Starting file watcher and process manager...`));
153
- console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Launching ${chalk_1.default.cyan(path.basename(file))} with auto-restart capability...`));
154
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Press Ctrl+C to stop the development server`));
155
- console.log(chalk_1.default.gray(`${'='.repeat(60)}`));
156
- }
157
- // Create DevRunner instance
158
- devRunner = new dev_runner_js_1.DevRunner({
159
- runnerName: 'neex dev',
160
- parallel: false,
161
- color: options.color,
162
- showTiming: options.timing,
163
- prefix: options.prefix,
164
- stopOnError: options.stopOnError,
165
- printOutput: options.output,
166
- minimalOutput: options.minimal,
167
- watch: watchPaths,
168
- ignore: ignorePatterns,
169
- ext: extensions,
170
- delay: options.delay || 1000,
171
- clearConsole: options.clear,
172
- verbose: options.verbose,
173
- showInfo: showInfo,
174
- signal: options.signal,
175
- restartOnChange: true,
176
- groupOutput: false,
177
- isServerMode: false
178
- });
179
- // Start the development server
180
- await devRunner.start([commandToExecute]);
22
+ const commandsToRun = config.commands.map((cmd) => ({
23
+ name: cmd.name,
24
+ command: cmd.command,
25
+ cwd: cmd.cwd,
26
+ }));
27
+ console.log(chalk_1.default.blue('Starting development mode...'));
28
+ (0, dev_runner_js_1.runDev)(commandsToRun);
181
29
  }
182
30
  catch (error) {
183
- console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: Fatal error occurred`));
184
- if (error instanceof Error) {
185
- console.error(chalk_1.default.red(`${figures_1.default.cross} Details: ${error.message}`));
186
- if (options.verbose && error.stack) {
187
- console.error(chalk_1.default.gray(`Stack trace:\n${error.stack}`));
188
- }
189
- }
190
- else {
191
- console.error(chalk_1.default.red(`${figures_1.default.cross} Unknown error occurred`));
192
- }
193
- console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Try running with --verbose flag for more details`));
31
+ console.error(chalk_1.default.red(`Error during dev command: ${error.message}`));
194
32
  process.exit(1);
195
33
  }
196
34
  });
197
- // Return cleanup function for dev runner
198
35
  return {
199
- getDevRunner: () => devRunner,
200
36
  cleanupDev: () => {
201
- if (devRunner && devRunner.isActive()) {
202
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Stopping development server...`));
203
- devRunner.stop();
204
- console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Development server stopped successfully`));
205
- }
37
+ // In the new model, cleanup is handled by runDev itself via process signals.
38
+ // This function can be used for any additional cleanup if needed in the future.
206
39
  }
207
40
  };
208
41
  }
209
- exports.addDevCommands = addDevCommands;
42
+ exports.devCommands = devCommands;
@@ -1,22 +1,14 @@
1
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
- };
2
+ // src/commands/index.ts
16
3
  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("./server-commands.js"), exports);
21
- __exportStar(require("./start-commands.js"), exports);
22
- __exportStar(require("./build-commands"), exports);
4
+ exports.addStartCommands = exports.addBuildCommands = exports.devCommands = exports.addServerCommands = exports.addRunCommands = void 0;
5
+ var run_commands_js_1 = require("./run-commands.js");
6
+ Object.defineProperty(exports, "addRunCommands", { enumerable: true, get: function () { return run_commands_js_1.addRunCommands; } });
7
+ var server_commands_js_1 = require("./server-commands.js");
8
+ Object.defineProperty(exports, "addServerCommands", { enumerable: true, get: function () { return server_commands_js_1.addServerCommands; } });
9
+ var dev_commands_js_1 = require("./dev-commands.js");
10
+ Object.defineProperty(exports, "devCommands", { enumerable: true, get: function () { return dev_commands_js_1.devCommands; } });
11
+ var build_commands_js_1 = require("./build-commands.js");
12
+ Object.defineProperty(exports, "addBuildCommands", { enumerable: true, get: function () { return build_commands_js_1.addBuildCommands; } });
13
+ var start_commands_js_1 = require("./start-commands.js");
14
+ Object.defineProperty(exports, "addStartCommands", { enumerable: true, get: function () { return start_commands_js_1.addStartCommands; } });
@@ -0,0 +1,59 @@
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
+ var _a;
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.loadConfig = void 0;
31
+ const path_1 = __importDefault(require("path"));
32
+ const fs_1 = __importDefault(require("fs"));
33
+ const chalk_1 = __importDefault(require("chalk"));
34
+ async function loadConfig(configPath) {
35
+ const defaultConfigPath = path_1.default.resolve(process.cwd(), 'neex.config.js');
36
+ const finalConfigPath = configPath ? path_1.default.resolve(process.cwd(), configPath) : defaultConfigPath;
37
+ if (!fs_1.default.existsSync(finalConfigPath)) {
38
+ console.error(chalk_1.default.red(`Configuration file not found at: ${finalConfigPath}`));
39
+ process.exit(1);
40
+ }
41
+ try {
42
+ // Use a dynamic import to load the config file.
43
+ // The 'file://' protocol is important for ensuring correct module resolution on all platforms.
44
+ const configModule = await (_a = `file://${finalConfigPath}`, Promise.resolve().then(() => __importStar(require(_a))));
45
+ // The config can be the default export or the entire module.
46
+ const config = configModule.default || configModule;
47
+ // Basic validation to ensure the config has the expected structure.
48
+ if (!config.commands || !Array.isArray(config.commands)) {
49
+ console.error(chalk_1.default.red('Invalid configuration: \'commands\' array is missing or not an array.'));
50
+ process.exit(1);
51
+ }
52
+ return config;
53
+ }
54
+ catch (error) {
55
+ console.error(chalk_1.default.red(`Error loading configuration file: ${error.message}`));
56
+ process.exit(1);
57
+ }
58
+ }
59
+ exports.loadConfig = loadConfig;
@@ -3,13 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DevRunner = void 0;
6
+ exports.runDev = exports.DevRunner = void 0;
7
7
  // src/dev-runner.ts - Development runner with file watching (nodemon functionality)
8
8
  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
  const logger_1 = __importDefault(require("./logger"));
13
+ const logger_process_1 = require("./logger-process");
14
+ const child_process_1 = require("child_process");
13
15
  class DevRunner {
14
16
  constructor(options) {
15
17
  this.commands = [];
@@ -98,7 +100,8 @@ class DevRunner {
98
100
  };
99
101
  this.runner = new runner_1.Runner(runnerOptions);
100
102
  try {
101
- const results = await this.runner.run(this.commands);
103
+ const commandStrings = this.commands.map(c => c.command);
104
+ const results = await this.runner.run(commandStrings);
102
105
  return results;
103
106
  }
104
107
  catch (error) {
@@ -244,3 +247,41 @@ class DevRunner {
244
247
  }
245
248
  }
246
249
  exports.DevRunner = DevRunner;
250
+ function runDev(commands) {
251
+ const processes = [];
252
+ commands.forEach(cmd => {
253
+ const logger = new logger_process_1.LoggerProcess(cmd.name);
254
+ logger.info(`Starting command: ${cmd.command}`);
255
+ const child = (0, child_process_1.spawn)(cmd.command, {
256
+ shell: true,
257
+ stdio: 'pipe',
258
+ cwd: cmd.cwd || process.cwd(),
259
+ });
260
+ child.stdout.on('data', (data) => {
261
+ logger.log(data);
262
+ });
263
+ child.stderr.on('data', (data) => {
264
+ logger.error(data);
265
+ });
266
+ child.on('close', (code) => {
267
+ if (code === 0) {
268
+ logger.info(`Command finished successfully.`);
269
+ }
270
+ else {
271
+ logger.error(`Command failed with code ${code}.`);
272
+ }
273
+ });
274
+ child.on('error', (err) => {
275
+ logger.error(`Failed to start command: ${err.message}`);
276
+ });
277
+ processes.push(child);
278
+ });
279
+ function cleanup() {
280
+ console.log('\nShutting down dev processes...');
281
+ processes.forEach(p => p.kill());
282
+ process.exit();
283
+ }
284
+ process.on('SIGINT', cleanup);
285
+ process.on('SIGTERM', cleanup);
286
+ }
287
+ exports.runDev = runDev;
@@ -0,0 +1,48 @@
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.LoggerProcess = void 0;
7
+ // src/.logger-process.ts
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ class LoggerProcess {
10
+ constructor(command) {
11
+ this.command = command;
12
+ this.color = this.generateColor(command);
13
+ this.prefix = `${this.color(command)}: `;
14
+ }
15
+ generateColor(command) {
16
+ const colors = [
17
+ chalk_1.default.cyan,
18
+ chalk_1.default.magenta,
19
+ chalk_1.default.blue,
20
+ chalk_1.default.yellow,
21
+ chalk_1.default.green,
22
+ chalk_1.default.red
23
+ ];
24
+ let hash = 0;
25
+ for (let i = 0; i < command.length; i++) {
26
+ hash = (hash << 5) - hash + command.charCodeAt(i);
27
+ hash |= 0;
28
+ }
29
+ return colors[Math.abs(hash) % colors.length];
30
+ }
31
+ log(data) {
32
+ this.print(data.toString(), process.stdout);
33
+ }
34
+ error(data) {
35
+ this.print(data.toString(), process.stderr, chalk_1.default.red);
36
+ }
37
+ print(data, stream, colorizer) {
38
+ const lines = data.split('\n').filter(line => line.trim().length > 0);
39
+ for (const line of lines) {
40
+ const coloredLine = colorizer ? colorizer(line) : line;
41
+ stream.write(`${this.prefix}${coloredLine}\n`);
42
+ }
43
+ }
44
+ info(message) {
45
+ console.log(`${this.prefix}${chalk_1.default.blue(message)}`);
46
+ }
47
+ }
48
+ exports.LoggerProcess = LoggerProcess;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neex",
3
- "version": "0.6.34",
3
+ "version": "0.6.36",
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",