neex 0.6.35 → 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.
@@ -37,7 +37,6 @@ const path = __importStar(require("path"));
37
37
  const fs = __importStar(require("fs/promises"));
38
38
  class BuildManager {
39
39
  constructor(options) {
40
- var _a;
41
40
  this.isBuilding = false;
42
41
  this.buildCount = 0;
43
42
  this.startTime = new Date();
@@ -76,7 +75,6 @@ class BuildManager {
76
75
  this.options = {
77
76
  ...defaultOptions,
78
77
  ...options,
79
- silent: (_a = options.silent) !== null && _a !== void 0 ? _a : false,
80
78
  };
81
79
  }
82
80
  setupFileWatcher() {
@@ -159,7 +157,8 @@ class BuildManager {
159
157
  printOutput: (_a = this.options.showInfo) !== null && _a !== void 0 ? _a : false,
160
158
  showTiming: (_b = this.options.showInfo) !== null && _b !== void 0 ? _b : false,
161
159
  prefix: (_c = this.options.showInfo) !== null && _c !== void 0 ? _c : false,
162
- customPrefix: this.options.showInfo ? () => `build` : undefined
160
+ customPrefix: this.options.showInfo ? () => `build` : undefined,
161
+ silent: this.options.silent, // Pass silent option to the runner
163
162
  };
164
163
  this.runner = new runner_1.Runner(runnerOptions);
165
164
  try {
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);
@@ -133,6 +133,7 @@ function addBuildCommands(program) {
133
133
  outputDir: options.output,
134
134
  buildType: buildConfig.buildType,
135
135
  buildCommand: buildConfig.buildCommand,
136
+ showInfo: showInfo,
136
137
  color: !options.noColor,
137
138
  showTiming: false,
138
139
  watch: options.watch,
@@ -148,9 +149,7 @@ function addBuildCommands(program) {
148
149
  printOutput: false,
149
150
  prefix: false,
150
151
  stopOnError: true,
151
- minimalOutput: true,
152
- showInfo: true,
153
- silent: true, // Silence the logger
152
+ minimalOutput: true // Use minimal output
154
153
  });
155
154
  // Start the build process
156
155
  try {
@@ -1,210 +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
- signal: options.signal,
174
- restartOnChange: true,
175
- groupOutput: false,
176
- isServerMode: false,
177
- showInfo: true,
178
- silent: true // Silence the logger
179
- });
180
- // Start the development server
181
- 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);
182
29
  }
183
30
  catch (error) {
184
- console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: Fatal error occurred`));
185
- if (error instanceof Error) {
186
- console.error(chalk_1.default.red(`${figures_1.default.cross} Details: ${error.message}`));
187
- if (options.verbose && error.stack) {
188
- console.error(chalk_1.default.gray(`Stack trace:\n${error.stack}`));
189
- }
190
- }
191
- else {
192
- console.error(chalk_1.default.red(`${figures_1.default.cross} Unknown error occurred`));
193
- }
194
- 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}`));
195
32
  process.exit(1);
196
33
  }
197
34
  });
198
- // Return cleanup function for dev runner
199
35
  return {
200
- getDevRunner: () => devRunner,
201
36
  cleanupDev: () => {
202
- if (devRunner && devRunner.isActive()) {
203
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Stopping development server...`));
204
- devRunner.stop();
205
- console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Development server stopped successfully`));
206
- }
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.
207
39
  }
208
40
  };
209
41
  }
210
- 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; } });
@@ -213,6 +213,7 @@ function addStartCommands(program) {
213
213
  maxRestarts: options.maxRestarts,
214
214
  restartDelay: options.restartDelay || 3000,
215
215
  verbose: options.verbose,
216
+ showInfo: showInfo,
216
217
  signal: options.signal,
217
218
  cluster: options.cluster,
218
219
  clusterInstances: options.clusterInstances,
@@ -220,8 +221,7 @@ function addStartCommands(program) {
220
221
  cpuLimit: options.cpuLimit,
221
222
  groupOutput: false,
222
223
  isServerMode: true,
223
- stopOnError: false,
224
- silent: true // Silence the logger
224
+ stopOnError: false
225
225
  });
226
226
  // Start the application server
227
227
  await startManager.start();
@@ -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,16 +3,17 @@ 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
- var _a;
16
17
  this.commands = [];
17
18
  this.isRunning = false;
18
19
  this.restartCount = 0;
@@ -47,12 +48,10 @@ class DevRunner {
47
48
  verbose: false,
48
49
  showInfo: false,
49
50
  runnerName: 'neex dev',
50
- silent: false,
51
51
  };
52
52
  this.options = {
53
53
  ...defaultOptions,
54
- ...options,
55
- silent: (_a = options.silent) !== null && _a !== void 0 ? _a : false,
54
+ ...options
56
55
  };
57
56
  }
58
57
  setupFileWatcher() {
@@ -72,7 +71,7 @@ class DevRunner {
72
71
  }
73
72
  async handleFileChange(event) {
74
73
  const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
75
- if (this.options.showInfo && !this.options.silent) {
74
+ if (this.options.showInfo) {
76
75
  logger_1.default.printLine(`${prefix} File changed: ${chalk_1.default.yellow(event.relativePath)}`, 'info');
77
76
  }
78
77
  if (this.options.clearConsole) {
@@ -101,11 +100,12 @@ class DevRunner {
101
100
  };
102
101
  this.runner = new runner_1.Runner(runnerOptions);
103
102
  try {
104
- 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);
105
105
  return results;
106
106
  }
107
107
  catch (error) {
108
- if (this.options.showInfo && !this.options.silent) {
108
+ if (this.options.showInfo) {
109
109
  logger_1.default.printLine(`Execution failed: ${error.message}`, 'error');
110
110
  }
111
111
  return [];
@@ -159,13 +159,13 @@ class DevRunner {
159
159
  }
160
160
  // Run initial commands
161
161
  const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
162
- if (this.options.showInfo && !this.options.silent) {
162
+ if (this.options.showInfo) {
163
163
  logger_1.default.printLine(`${prefix} Starting development server...`, 'info');
164
164
  }
165
165
  await this.runCommands();
166
166
  // Set up graceful shutdown
167
167
  this.setupGracefulShutdown();
168
- if (this.options.showInfo && !this.options.silent) {
168
+ if (this.options.showInfo) {
169
169
  logger_1.default.printLine(`${prefix} Development server started. Watching for changes...`, 'info');
170
170
  logger_1.default.printLine(`${prefix} Press ${chalk_1.default.cyan('Ctrl+C')} to stop`, 'info');
171
171
  }
@@ -175,7 +175,7 @@ class DevRunner {
175
175
  if (!this.isRunning) {
176
176
  return;
177
177
  }
178
- if (this.options.showInfo && !this.options.silent) {
178
+ if (this.options.showInfo) {
179
179
  logger_1.default.printLine(`${prefix} Restarting due to file changes...`, 'info');
180
180
  }
181
181
  this.restartCount++;
@@ -189,7 +189,7 @@ class DevRunner {
189
189
  this.printDevBanner();
190
190
  // Run commands again
191
191
  await this.runCommands();
192
- if (this.options.showInfo && !this.options.silent) {
192
+ if (this.options.showInfo) {
193
193
  logger_1.default.printLine(`${prefix} Restart completed. Watching for changes...`, 'info');
194
194
  }
195
195
  }
@@ -198,7 +198,7 @@ class DevRunner {
198
198
  if (!this.isRunning) {
199
199
  return;
200
200
  }
201
- if (this.options.showInfo && !this.options.silent) {
201
+ if (this.options.showInfo) {
202
202
  logger_1.default.printLine(`${prefix} Stopping development server...`, 'info');
203
203
  }
204
204
  this.isRunning = false;
@@ -212,7 +212,7 @@ class DevRunner {
212
212
  }
213
213
  const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
214
214
  const uptimeStr = this.formatUptime(uptime);
215
- if (this.options.showInfo && !this.options.silent) {
215
+ if (this.options.showInfo) {
216
216
  logger_1.default.printLine(`${prefix} ${this.options.runnerName} development server stopped after ${uptimeStr}`, 'info');
217
217
  if (this.restartCount > 0) {
218
218
  logger_1.default.printLine(`${prefix} Total restarts: ${this.restartCount}`, 'info');
@@ -221,7 +221,7 @@ class DevRunner {
221
221
  }
222
222
  setupGracefulShutdown() {
223
223
  const handleSignal = (signal) => {
224
- if (this.options.showInfo && !this.options.silent) {
224
+ if (this.options.showInfo) {
225
225
  console.log(`\n${chalk_1.default.yellow(`${figures_1.default.warning} Received ${signal}. Shutting down development server...`)}`);
226
226
  }
227
227
  this.stop().then(() => {
@@ -247,3 +247,41 @@ class DevRunner {
247
247
  }
248
248
  }
249
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;
@@ -36,7 +36,6 @@ const logger_1 = __importDefault(require("./logger"));
36
36
  const os = __importStar(require("os"));
37
37
  class StartManager {
38
38
  constructor(options) {
39
- var _a;
40
39
  this.isRunning = false;
41
40
  this.restartCount = 0;
42
41
  this.crashCount = 0;
@@ -80,13 +79,11 @@ class StartManager {
80
79
  restartDelay: 3000,
81
80
  signal: 'SIGTERM',
82
81
  cluster: false,
83
- clusterInstances: os.cpus().length,
84
- silent: false,
82
+ clusterInstances: os.cpus().length
85
83
  };
86
84
  this.options = {
87
85
  ...defaultOptions,
88
- ...options,
89
- silent: (_a = options.silent) !== null && _a !== void 0 ? _a : false,
86
+ ...options
90
87
  };
91
88
  }
92
89
  setupFileWatcher() {
@@ -110,7 +107,7 @@ class StartManager {
110
107
  }
111
108
  async handleFileChange(event) {
112
109
  const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
113
- if (this.options.showInfo && !this.options.silent) {
110
+ if (this.options.showInfo) {
114
111
  logger_1.default.printLine(`${prefix} File changed: ${chalk_1.default.yellow(event.relativePath)}`, 'info');
115
112
  }
116
113
  await this.gracefulRestart();
@@ -167,7 +164,7 @@ class StartManager {
167
164
  }
168
165
  catch (error) {
169
166
  this.crashCount++;
170
- if (this.options.showInfo && !this.options.silent) {
167
+ if (this.options.showInfo) {
171
168
  logger_1.default.printLine(`Application crashed: ${error.message}`, 'error');
172
169
  }
173
170
  // Check if we should restart
@@ -185,7 +182,7 @@ class StartManager {
185
182
  }
186
183
  async handleCrash() {
187
184
  const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
188
- if (this.options.showInfo && !this.options.silent) {
185
+ if (this.options.showInfo) {
189
186
  logger_1.default.printLine(`${prefix} ${chalk_1.default.red(`${figures_1.default.cross} Application crashed`)}`, 'error');
190
187
  logger_1.default.printLine(`${prefix} ${chalk_1.default.yellow(`${figures_1.default.warning} Attempting restart in ${this.options.restartDelay}ms...`)}`, 'info');
191
188
  }
@@ -266,14 +263,12 @@ class StartManager {
266
263
  // Check memory limit
267
264
  if (this.options.memoryLimit && this.processStats.memoryUsage > this.options.memoryLimit) {
268
265
  const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
269
- if (!this.options.silent)
270
- logger_1.default.printLine(`${prefix} ${chalk_1.default.red(`${figures_1.default.warning} Memory limit exceeded: ${this.processStats.memoryUsage}MB > ${this.options.memoryLimit}MB`)}`, 'warn');
266
+ logger_1.default.printLine(`${prefix} ${chalk_1.default.red(`${figures_1.default.warning} Memory limit exceeded: ${this.processStats.memoryUsage}MB > ${this.options.memoryLimit}MB`)}`, 'warn');
271
267
  }
272
268
  // Log stats every 30 seconds in verbose mode
273
269
  if (this.options.verbose && this.processStats.uptime % 30 === 0) {
274
270
  const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
275
- if (!this.options.silent)
276
- logger_1.default.printLine(`${prefix} ${chalk_1.default.gray(`Stats: ${this.processStats.memoryUsage}MB memory, ${this.formatUptime(this.processStats.uptime)} uptime`)}`, 'info');
271
+ logger_1.default.printLine(`${prefix} ${chalk_1.default.gray(`Stats: ${this.processStats.memoryUsage}MB memory, ${this.formatUptime(this.processStats.uptime)} uptime`)}`, 'info');
277
272
  }
278
273
  }, 1000);
279
274
  }
@@ -294,13 +289,13 @@ class StartManager {
294
289
  this.monitorResources();
295
290
  // Start application
296
291
  const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
297
- if (this.options.showInfo && !this.options.silent) {
292
+ if (this.options.showInfo) {
298
293
  logger_1.default.printLine(`${prefix} Starting ${this.options.processName}...`, 'info');
299
294
  }
300
295
  await this.startApplication();
301
296
  // Set up graceful shutdown
302
297
  this.setupGracefulShutdown();
303
- if (this.options.showInfo && !this.options.silent) {
298
+ if (this.options.showInfo) {
304
299
  logger_1.default.printLine(`${prefix} ${this.options.processName} is running in ${this.options.environment} mode`, 'info');
305
300
  if (this.options.watch) {
306
301
  logger_1.default.printLine(`${prefix} Watching for changes...`, 'info');
@@ -314,13 +309,13 @@ class StartManager {
314
309
  return;
315
310
  }
316
311
  if (!this.shouldRestart()) {
317
- if (this.options.showInfo && !this.options.silent) {
312
+ if (this.options.showInfo) {
318
313
  logger_1.default.printLine(`${prefix} ${chalk_1.default.red(`${figures_1.default.cross} Max restarts reached (${this.options.maxRestarts}). Stopping application.`)}`, 'error');
319
314
  }
320
315
  await this.stop();
321
316
  return;
322
317
  }
323
- if (this.options.showInfo && !this.options.silent) {
318
+ if (this.options.showInfo) {
324
319
  logger_1.default.printLine(`${prefix} ${chalk_1.default.yellow(`${figures_1.default.warning} Gracefully restarting ${this.options.processName}...`)}`, 'info');
325
320
  }
326
321
  this.restartCount++;
@@ -335,7 +330,7 @@ class StartManager {
335
330
  this.printStartBanner();
336
331
  // Start application again
337
332
  await this.startApplication();
338
- if (this.options.showInfo && !this.options.silent) {
333
+ if (this.options.showInfo) {
339
334
  logger_1.default.printLine(`${prefix} ${chalk_1.default.green(`${figures_1.default.tick} ${this.options.processName} restarted successfully`)}`, 'info');
340
335
  }
341
336
  }
@@ -344,7 +339,7 @@ class StartManager {
344
339
  if (!this.isRunning) {
345
340
  return;
346
341
  }
347
- if (this.options.showInfo && !this.options.silent) {
342
+ if (this.options.showInfo) {
348
343
  logger_1.default.printLine(`${prefix} ${chalk_1.default.yellow(`${figures_1.default.warning} Stopping ${this.options.processName}...`)}`, 'info');
349
344
  }
350
345
  this.isRunning = false;
@@ -359,14 +354,14 @@ class StartManager {
359
354
  // Calculate final stats
360
355
  const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
361
356
  const uptimeStr = this.formatUptime(uptime);
362
- if (this.options.showInfo && !this.options.silent) {
357
+ if (this.options.showInfo) {
363
358
  logger_1.default.printLine(`${prefix} ${chalk_1.default.green(`${figures_1.default.tick} ${this.options.processName} stopped successfully`)}`, 'info');
364
359
  logger_1.default.printLine(`${prefix} Final stats: ${uptimeStr} uptime, ${this.restartCount} restarts, ${this.crashCount} crashes`, 'info');
365
360
  }
366
361
  }
367
362
  setupGracefulShutdown() {
368
363
  const handleSignal = (signal) => {
369
- if (this.options.showInfo && !this.options.silent) {
364
+ if (this.options.showInfo) {
370
365
  console.log(`\n${chalk_1.default.yellow(`${figures_1.default.warning} Received ${signal}. Gracefully shutting down ${this.options.processName}...`)}`);
371
366
  }
372
367
  this.stop().then(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neex",
3
- "version": "0.6.35",
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",