neex 0.6.22 → 0.6.23

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.
@@ -42,12 +42,12 @@ class BuildManager {
42
42
  this.startTime = new Date();
43
43
  const defaultOptions = {
44
44
  parallel: false,
45
- printOutput: true,
45
+ printOutput: false,
46
46
  color: true,
47
- showTiming: true,
48
- prefix: true,
49
- stopOnError: false,
50
- minimalOutput: false,
47
+ showTiming: false,
48
+ prefix: false,
49
+ stopOnError: true,
50
+ minimalOutput: true,
51
51
  groupOutput: false,
52
52
  isServerMode: false,
53
53
  watch: false,
@@ -96,8 +96,8 @@ class BuildManager {
96
96
  });
97
97
  }
98
98
  async handleFileChange(event) {
99
- const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
100
99
  if (this.options.showInfo) {
100
+ const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
101
101
  logger_1.default.printLine(`${prefix} File changed: ${chalk_1.default.yellow(event.relativePath)}`, 'info');
102
102
  }
103
103
  await this.rebuild();
@@ -149,10 +149,13 @@ class BuildManager {
149
149
  }
150
150
  async runBuild() {
151
151
  const buildCommand = this.generateBuildCommand();
152
- // Create a modified options object for the runner
152
+ // Create a runner with clean output settings
153
153
  const runnerOptions = {
154
154
  ...this.options,
155
- customPrefix: () => `build`
155
+ printOutput: Boolean(this.options.showInfo),
156
+ showTiming: Boolean(this.options.showInfo),
157
+ prefix: Boolean(this.options.showInfo),
158
+ customPrefix: this.options.showInfo ? () => `build` : undefined
156
159
  };
157
160
  this.runner = new runner_1.Runner(runnerOptions);
158
161
  try {
@@ -169,24 +172,23 @@ class BuildManager {
169
172
  const results = await this.runner.run([buildCommand]);
170
173
  // Handle build results
171
174
  const success = results.every(result => result.success);
172
- const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
173
- if (success) {
174
- if (this.options.showInfo) {
175
- logger_1.default.printLine(`${prefix} ${chalk_1.default.green(`${figures_1.default.tick} Build completed successfully`)}`, 'info');
176
- }
177
- }
178
- else {
179
- if (this.options.showInfo) {
180
- logger_1.default.printLine(`${prefix} ${chalk_1.default.red(`${figures_1.default.cross} Build failed`)}`, 'error');
175
+ if (!success) {
176
+ // Only show errors, let the caller handle success message
177
+ const failedResults = results.filter(result => !result.success);
178
+ for (const result of failedResults) {
179
+ if (result.stderr) {
180
+ console.error(chalk_1.default.red(result.stderr));
181
+ }
182
+ if (result.error) {
183
+ console.error(chalk_1.default.red(result.error));
184
+ }
181
185
  }
186
+ throw new Error('Build failed');
182
187
  }
183
188
  return results;
184
189
  }
185
190
  catch (error) {
186
- if (this.options.showInfo) {
187
- logger_1.default.printLine(`Build failed: ${error.message}`, 'error');
188
- }
189
- return [];
191
+ throw error;
190
192
  }
191
193
  finally {
192
194
  this.isBuilding = false;
@@ -235,37 +237,31 @@ class BuildManager {
235
237
  this.setupFileWatcher();
236
238
  }
237
239
  // Print build banner only if showInfo is true
238
- this.printBuildBanner();
240
+ if (this.options.showInfo) {
241
+ this.printBuildBanner();
242
+ }
239
243
  // Start file watcher if enabled
240
244
  if (this.fileWatcher) {
241
245
  await this.fileWatcher.start();
242
246
  }
243
247
  // Run initial build
244
- const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
245
- if (this.options.showInfo) {
246
- logger_1.default.printLine(`${prefix} Starting build process...`, 'info');
247
- }
248
248
  await this.runBuild();
249
249
  // Set up graceful shutdown
250
250
  this.setupGracefulShutdown();
251
251
  if (this.options.watch) {
252
252
  if (this.options.showInfo) {
253
+ const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
253
254
  logger_1.default.printLine(`${prefix} Build completed. Watching for changes...`, 'info');
254
255
  logger_1.default.printLine(`${prefix} Press ${chalk_1.default.cyan('Ctrl+C')} to stop`, 'info');
255
256
  }
256
257
  }
257
- else {
258
- if (this.options.showInfo) {
259
- logger_1.default.printLine(`${prefix} Build process completed`, 'info');
260
- }
261
- }
262
258
  }
263
259
  async rebuild() {
264
- const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
265
260
  if (this.isBuilding) {
266
261
  return;
267
262
  }
268
263
  if (this.options.showInfo) {
264
+ const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
269
265
  logger_1.default.printLine(`${prefix} Rebuilding due to file changes...`, 'info');
270
266
  }
271
267
  // Stop current processes
@@ -275,19 +271,26 @@ class BuildManager {
275
271
  // Wait a moment before rebuilding
276
272
  await new Promise(resolve => setTimeout(resolve, 500));
277
273
  // Print rebuild banner only if showInfo is true
278
- this.printBuildBanner();
274
+ if (this.options.showInfo) {
275
+ this.printBuildBanner();
276
+ }
279
277
  // Run build again
280
278
  await this.runBuild();
281
279
  if (this.options.showInfo) {
280
+ const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
282
281
  logger_1.default.printLine(`${prefix} Rebuild completed. Watching for changes...`, 'info');
283
282
  }
283
+ else {
284
+ // Show rebuild completion even without showInfo for watch mode
285
+ console.log(chalk_1.default.green(`${figures_1.default.tick} Rebuild completed`));
286
+ }
284
287
  }
285
288
  async stop() {
286
- const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
287
289
  if (!this.isBuilding && !this.options.watch) {
288
290
  return;
289
291
  }
290
292
  if (this.options.showInfo) {
293
+ const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
291
294
  logger_1.default.printLine(`${prefix} Stopping build process...`, 'info');
292
295
  }
293
296
  // Stop file watcher
@@ -298,9 +301,10 @@ class BuildManager {
298
301
  if (this.runner) {
299
302
  this.runner.cleanup('SIGTERM');
300
303
  }
301
- const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
302
- const uptimeStr = this.formatUptime(uptime);
303
304
  if (this.options.showInfo) {
305
+ const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
306
+ const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
307
+ const uptimeStr = this.formatUptime(uptime);
304
308
  logger_1.default.printLine(`${prefix} Build process stopped after ${uptimeStr}`, 'info');
305
309
  if (this.buildCount > 0) {
306
310
  logger_1.default.printLine(`${prefix} Total builds: ${this.buildCount}`, 'info');
@@ -116,11 +116,7 @@ function addBuildCommands(program) {
116
116
  .option('--module <module>', 'Module system', 'commonjs')
117
117
  .action(async (file, options) => {
118
118
  try {
119
- const showInfo = options.info || false;
120
- if (showInfo) {
121
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex build: Starting build process...`));
122
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex build: Target file: ${chalk_1.default.cyan(file)}`));
123
- }
119
+ const showInfo = options.info || options.verbose || false;
124
120
  // Validate file parameter
125
121
  if (!file || file.trim() === '') {
126
122
  console.error(chalk_1.default.red(`${figures_1.default.cross} neex build: Error - No file specified!`));
@@ -130,18 +126,18 @@ function addBuildCommands(program) {
130
126
  }
131
127
  // Get build configuration
132
128
  const buildConfig = await getBuildConfig(file, options.output, showInfo);
133
- // Create BuildManager instance with all required options
134
- const buildManager = new build_manager_js_1.BuildManager({
129
+ // Create BuildManager instance with clean output settings
130
+ buildManager = new build_manager_js_1.BuildManager({
135
131
  runnerName: 'neex build',
136
132
  inputFile: file,
137
133
  outputDir: options.output,
138
134
  buildType: buildConfig.buildType,
139
135
  buildCommand: buildConfig.buildCommand,
140
136
  showInfo: showInfo,
141
- color: !options.color,
142
- showTiming: !options.timing,
137
+ color: !options.noColor,
138
+ showTiming: false,
143
139
  watch: options.watch,
144
- delay: parseInt(options.delay),
140
+ delay: parseInt(options.delay) || 1000,
145
141
  verbose: options.verbose,
146
142
  clean: options.clean,
147
143
  sourceMap: options.sourceMap,
@@ -150,56 +146,19 @@ function addBuildCommands(program) {
150
146
  parallel: false,
151
147
  groupOutput: false,
152
148
  isServerMode: false,
153
- printOutput: true,
154
- prefix: true,
155
- stopOnError: false,
156
- minimalOutput: false
149
+ printOutput: false,
150
+ prefix: false,
151
+ stopOnError: true,
152
+ minimalOutput: true // Use minimal output
157
153
  });
158
- // Setup ignore patterns for watch mode
159
- const ignorePatterns = options.ignore || [
160
- 'node_modules/**',
161
- '.git/**',
162
- '*.log',
163
- 'dist/**',
164
- 'build/**',
165
- 'coverage/**',
166
- '.nyc_output/**',
167
- '*.tmp',
168
- '*.temp',
169
- '.DS_Store',
170
- 'Thumbs.db'
171
- ];
172
- // Log configuration only if --info flag is set
173
- if (showInfo) {
174
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex build: Configuration:`));
175
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Input: ${chalk_1.default.cyan(file)}`));
176
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Output: ${chalk_1.default.cyan(options.output)}`));
177
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Build type: ${chalk_1.default.cyan(buildConfig.buildType)}`));
178
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Target: ${chalk_1.default.cyan(options.target)}`));
179
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Module: ${chalk_1.default.cyan(options.module)}`));
180
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Watch mode: ${chalk_1.default.cyan(options.watch ? 'Yes' : 'No')}`));
181
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Clean before build: ${chalk_1.default.cyan(options.clean ? 'Yes' : 'No')}`));
182
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Source maps: ${chalk_1.default.cyan(options.sourceMap ? 'Yes' : 'No')}`));
183
- if (options.verbose) {
184
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex build: Verbose mode enabled - showing detailed logs`));
185
- }
186
- console.log(chalk_1.default.green(`${figures_1.default.tick} neex build: Starting build process...`));
187
- console.log(chalk_1.default.gray(`${'='.repeat(60)}`));
188
- }
189
154
  // Start the build process
190
155
  try {
191
- if (showInfo) {
192
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex build: Analyzing ${chalk_1.default.cyan(path.basename(file))}`));
193
- }
194
156
  await buildManager.start();
195
- if (showInfo) {
196
- console.log(chalk_1.default.green(`${figures_1.default.tick} Build completed successfully`));
197
- }
198
- else {
199
- console.log(chalk_1.default.green(`${figures_1.default.tick} Build completed`));
200
- }
157
+ // Only show success message, no extra logs
158
+ console.log(chalk_1.default.green(`${figures_1.default.tick} Build completed`));
201
159
  }
202
160
  catch (error) {
161
+ // Only show error message, no extra logs
203
162
  console.error(chalk_1.default.red(`${figures_1.default.cross} Build failed`));
204
163
  if (error instanceof Error) {
205
164
  console.error(chalk_1.default.red(`Error: ${error.message}`));
@@ -208,17 +167,14 @@ function addBuildCommands(program) {
208
167
  }
209
168
  }
210
169
  catch (error) {
211
- console.error(chalk_1.default.red(`${figures_1.default.cross} neex build: Fatal error occurred`));
170
+ // Only show fatal error, no extra logs
171
+ console.error(chalk_1.default.red(`${figures_1.default.cross} Build failed`));
212
172
  if (error instanceof Error) {
213
- console.error(chalk_1.default.red(`${figures_1.default.cross} Details: ${error.message}`));
173
+ console.error(chalk_1.default.red(`Error: ${error.message}`));
214
174
  if (options.verbose && error.stack) {
215
175
  console.error(chalk_1.default.gray(`Stack trace:\n${error.stack}`));
216
176
  }
217
177
  }
218
- else {
219
- console.error(chalk_1.default.red(`${figures_1.default.cross} Unknown error occurred`));
220
- }
221
- console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Try running with --verbose flag for more details`));
222
178
  process.exit(1);
223
179
  }
224
180
  });
@@ -227,9 +183,7 @@ function addBuildCommands(program) {
227
183
  getBuildManager: () => buildManager,
228
184
  cleanupBuild: () => {
229
185
  if (buildManager && buildManager.isActive()) {
230
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex build: Stopping build process...`));
231
186
  buildManager.stop();
232
- console.log(chalk_1.default.green(`${figures_1.default.tick} neex build: Build process stopped successfully`));
233
187
  }
234
188
  }
235
189
  };
@@ -27,7 +27,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.addStartCommands = void 0;
30
- const start_manager_js_1 = require("../start-manager.js");
31
30
  const chalk_1 = __importDefault(require("chalk"));
32
31
  const figures_1 = __importDefault(require("figures"));
33
32
  const path = __importStar(require("path"));
@@ -100,75 +99,74 @@ function addStartCommands(program) {
100
99
  program
101
100
  .command('start <file>')
102
101
  .alias('s')
103
- .description('Start a production application')
102
+ .description('Start JavaScript/TypeScript applications in production mode')
104
103
  .option('-c, --no-color', 'Disable colored output')
105
104
  .option('-t, --no-timing', 'Hide timing information')
106
- .option('-v, --verbose', 'Show detailed logs')
107
- .option('-w, --watch', 'Watch for file changes')
108
- .option('--delay <ms>', 'Delay between file changes (ms)', '1000')
109
- .option('--environment <env>', 'Application environment', 'production')
110
- .option('--cluster', 'Enable cluster mode')
111
- .option('--instances <num>', 'Number of cluster instances', '1')
112
- .option('--memory <mb>', 'Memory limit (MB)', '0')
113
- .option('--cpu <percent>', 'CPU limit (%)', '0')
114
- .option('--info', 'Show detailed start information')
105
+ .option('-p, --no-prefix', 'Hide command prefix')
106
+ .option('-o, --no-output', 'Hide command output')
107
+ .option('-m, --minimal', 'Use minimal output format')
108
+ .option('-w, --watch', 'Watch for changes and restart (production hot-reload)')
109
+ .option('-i, --ignore <patterns...>', 'Patterns to ignore when watching')
110
+ .option('-e, --ext <extensions...>', 'File extensions to watch (default: js,mjs,json)')
111
+ .option('-d, --delay <ms>', 'Delay before restart in milliseconds', parseInt)
112
+ .option('--max-restarts <number>', 'Maximum number of restarts', parseInt)
113
+ .option('--restart-delay <ms>', 'Delay between restarts in milliseconds', parseInt)
114
+ .option('--verbose', 'Verbose output')
115
+ .option('--info', 'Show detailed information during startup')
116
+ .option('--signal <signal>', 'Signal to send to processes on restart', 'SIGTERM')
117
+ .option('--env <env>', 'Environment mode', 'production')
118
+ .option('--cluster', 'Enable cluster mode (spawn multiple processes)')
119
+ .option('--cluster-instances <number>', 'Number of cluster instances', parseInt)
120
+ .option('--memory-limit <mb>', 'Memory limit in MB', parseInt)
121
+ .option('--cpu-limit <percent>', 'CPU limit percentage', parseInt)
115
122
  .action(async (file, options) => {
116
123
  try {
117
- // Get start command configuration
118
- const startConfig = await getStartCommand(file, options.info);
119
- // Create StartManager instance
120
- const startManager = new start_manager_js_1.StartManager({
121
- runnerName: 'neex start',
122
- targetFile: file,
123
- command: startConfig.command,
124
- processName: startConfig.processName,
125
- runtime: startConfig.runtime,
126
- environment: options.environment,
127
- showInfo: options.info,
128
- color: !options.color,
129
- showTiming: !options.timing,
130
- watch: options.watch,
131
- delay: parseInt(options.delay),
132
- verbose: options.verbose,
133
- cluster: options.cluster,
134
- clusterInstances: parseInt(options.instances),
135
- memoryLimit: parseInt(options.memory),
136
- cpuLimit: parseInt(options.cpu),
137
- parallel: false,
138
- printOutput: true,
139
- prefix: true,
140
- stopOnError: false,
141
- minimalOutput: false,
142
- groupOutput: false,
143
- isServerMode: true
144
- });
145
- // Start the application
124
+ const showInfo = options.info || false;
125
+ if (showInfo) {
126
+ console.log(chalk_1.default.blue(`${figures_1.default.info} neex start: Starting production application server...`));
127
+ console.log(chalk_1.default.blue(`${figures_1.default.info} neex start: Target file: ${chalk_1.default.cyan(file)}`));
128
+ }
129
+ // Validate file parameter
130
+ if (!file || file.trim() === '') {
131
+ console.error(chalk_1.default.red(`${figures_1.default.cross} neex start: Error - No file specified!`));
132
+ console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Usage: neex start <file>`));
133
+ console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Example: neex start dist/server.js`));
134
+ process.exit(1);
135
+ }
136
+ // Get the start command configuration
137
+ let startConfig;
146
138
  try {
147
- if (options.info) {
148
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex start: Analyzing ${chalk_1.default.cyan(path.basename(file))}`));
149
- console.log(chalk_1.default.green(`${figures_1.default.tick} neex start: ${startConfig.runtime} detected, using ${startConfig.runtime} runtime`));
150
- }
151
- await startManager.start();
152
- if (options.info) {
153
- console.log(chalk_1.default.green(`${figures_1.default.tick} Application started successfully`));
154
- }
155
- else {
156
- console.log(chalk_1.default.green(`${figures_1.default.tick} Application started`));
157
- }
139
+ startConfig = await getStartCommand(file, showInfo);
158
140
  }
159
141
  catch (error) {
160
- console.error(chalk_1.default.red(`${figures_1.default.cross} Failed to start application`));
161
- if (error instanceof Error) {
162
- console.error(chalk_1.default.red(`Error: ${error.message}`));
163
- }
142
+ console.error(chalk_1.default.red(`${figures_1.default.cross} neex start: ${error instanceof Error ? error.message : 'Unknown error occurred'}`));
164
143
  process.exit(1);
165
144
  }
145
+ // Setup watch configuration if enabled
146
+ const watchPaths = options.watch ? [path.dirname(file)] : [];
147
+ const ignorePatterns = options.ignore || [
148
+ 'node_modules/**',
149
+ '.git/**',
150
+ '*.log',
151
+ 'src/**',
152
+ 'test/**',
153
+ 'tests/**',
154
+ 'coverage/**',
155
+ '.nyc_output/**',
156
+ '*.tmp',
157
+ '*.temp',
158
+ '.DS_Store',
159
+ 'Thumbs.db'
160
+ ];
161
+ const extensions = options.ext || ['js', 'mjs', 'json'];
162
+ // Log configuration only if --info flag is set
163
+ if (showInfo) {
164
+ console.log(chalk_1.default.blue(`${figures_1.default.info} neex start: Configuration:`));
165
+ console;
166
+ }
166
167
  }
167
168
  catch (error) {
168
- console.error(chalk_1.default.red(`${figures_1.default.cross} Failed to start application`));
169
- if (error instanceof Error) {
170
- console.error(chalk_1.default.red(`Error: ${error.message}`));
171
- }
169
+ console.error(chalk_1.default.red(`${figures_1.default.cross} neex start: ${error instanceof Error ? error.message : 'Unknown error occurred'}`));
172
170
  process.exit(1);
173
171
  }
174
172
  });
@@ -148,7 +148,8 @@ class Runner {
148
148
  code: null,
149
149
  startTime,
150
150
  endTime: null,
151
- output: []
151
+ output: [],
152
+ stderr: []
152
153
  };
153
154
  if (this.options.printOutput) {
154
155
  logger_1.default.printStart(originalCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neex",
3
- "version": "0.6.22",
3
+ "version": "0.6.23",
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",