neex 0.6.26 → 0.6.28
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:
|
|
45
|
+
printOutput: true,
|
|
46
46
|
color: true,
|
|
47
|
-
showTiming:
|
|
48
|
-
prefix:
|
|
49
|
-
stopOnError:
|
|
50
|
-
minimalOutput:
|
|
47
|
+
showTiming: true,
|
|
48
|
+
prefix: true,
|
|
49
|
+
stopOnError: false,
|
|
50
|
+
minimalOutput: false,
|
|
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}]`);
|
|
99
100
|
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,13 +149,10 @@ class BuildManager {
|
|
|
149
149
|
}
|
|
150
150
|
async runBuild() {
|
|
151
151
|
const buildCommand = this.generateBuildCommand();
|
|
152
|
-
// Create a
|
|
152
|
+
// Create a modified options object for the runner
|
|
153
153
|
const runnerOptions = {
|
|
154
154
|
...this.options,
|
|
155
|
-
|
|
156
|
-
showTiming: Boolean(this.options.showInfo),
|
|
157
|
-
prefix: Boolean(this.options.showInfo),
|
|
158
|
-
customPrefix: this.options.showInfo ? () => `build` : undefined
|
|
155
|
+
customPrefix: () => `build`
|
|
159
156
|
};
|
|
160
157
|
this.runner = new runner_1.Runner(runnerOptions);
|
|
161
158
|
try {
|
|
@@ -172,23 +169,24 @@ class BuildManager {
|
|
|
172
169
|
const results = await this.runner.run([buildCommand]);
|
|
173
170
|
// Handle build results
|
|
174
171
|
const success = results.every(result => result.success);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
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');
|
|
185
181
|
}
|
|
186
|
-
throw new Error('Build failed');
|
|
187
182
|
}
|
|
188
183
|
return results;
|
|
189
184
|
}
|
|
190
185
|
catch (error) {
|
|
191
|
-
|
|
186
|
+
if (this.options.showInfo) {
|
|
187
|
+
logger_1.default.printLine(`Build failed: ${error.message}`, 'error');
|
|
188
|
+
}
|
|
189
|
+
return [];
|
|
192
190
|
}
|
|
193
191
|
finally {
|
|
194
192
|
this.isBuilding = false;
|
|
@@ -237,31 +235,37 @@ class BuildManager {
|
|
|
237
235
|
this.setupFileWatcher();
|
|
238
236
|
}
|
|
239
237
|
// Print build banner only if showInfo is true
|
|
240
|
-
|
|
241
|
-
this.printBuildBanner();
|
|
242
|
-
}
|
|
238
|
+
this.printBuildBanner();
|
|
243
239
|
// Start file watcher if enabled
|
|
244
240
|
if (this.fileWatcher) {
|
|
245
241
|
await this.fileWatcher.start();
|
|
246
242
|
}
|
|
247
243
|
// 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}]`);
|
|
254
253
|
logger_1.default.printLine(`${prefix} Build completed. Watching for changes...`, 'info');
|
|
255
254
|
logger_1.default.printLine(`${prefix} Press ${chalk_1.default.cyan('Ctrl+C')} to stop`, 'info');
|
|
256
255
|
}
|
|
257
256
|
}
|
|
257
|
+
else {
|
|
258
|
+
if (this.options.showInfo) {
|
|
259
|
+
logger_1.default.printLine(`${prefix} Build process completed`, 'info');
|
|
260
|
+
}
|
|
261
|
+
}
|
|
258
262
|
}
|
|
259
263
|
async rebuild() {
|
|
264
|
+
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
260
265
|
if (this.isBuilding) {
|
|
261
266
|
return;
|
|
262
267
|
}
|
|
263
268
|
if (this.options.showInfo) {
|
|
264
|
-
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
265
269
|
logger_1.default.printLine(`${prefix} Rebuilding due to file changes...`, 'info');
|
|
266
270
|
}
|
|
267
271
|
// Stop current processes
|
|
@@ -271,26 +275,19 @@ class BuildManager {
|
|
|
271
275
|
// Wait a moment before rebuilding
|
|
272
276
|
await new Promise(resolve => setTimeout(resolve, 500));
|
|
273
277
|
// Print rebuild banner only if showInfo is true
|
|
274
|
-
|
|
275
|
-
this.printBuildBanner();
|
|
276
|
-
}
|
|
278
|
+
this.printBuildBanner();
|
|
277
279
|
// Run build again
|
|
278
280
|
await this.runBuild();
|
|
279
281
|
if (this.options.showInfo) {
|
|
280
|
-
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
281
282
|
logger_1.default.printLine(`${prefix} Rebuild completed. Watching for changes...`, 'info');
|
|
282
283
|
}
|
|
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
|
-
}
|
|
287
284
|
}
|
|
288
285
|
async stop() {
|
|
286
|
+
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
289
287
|
if (!this.isBuilding && !this.options.watch) {
|
|
290
288
|
return;
|
|
291
289
|
}
|
|
292
290
|
if (this.options.showInfo) {
|
|
293
|
-
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
294
291
|
logger_1.default.printLine(`${prefix} Stopping build process...`, 'info');
|
|
295
292
|
}
|
|
296
293
|
// Stop file watcher
|
|
@@ -301,10 +298,9 @@ class BuildManager {
|
|
|
301
298
|
if (this.runner) {
|
|
302
299
|
this.runner.cleanup('SIGTERM');
|
|
303
300
|
}
|
|
301
|
+
const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
|
|
302
|
+
const uptimeStr = this.formatUptime(uptime);
|
|
304
303
|
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);
|
|
308
304
|
logger_1.default.printLine(`${prefix} Build process stopped after ${uptimeStr}`, 'info');
|
|
309
305
|
if (this.buildCount > 0) {
|
|
310
306
|
logger_1.default.printLine(`${prefix} Total builds: ${this.buildCount}`, 'info');
|
|
@@ -116,7 +116,11 @@ 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 ||
|
|
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
|
+
}
|
|
120
124
|
// Validate file parameter
|
|
121
125
|
if (!file || file.trim() === '') {
|
|
122
126
|
console.error(chalk_1.default.red(`${figures_1.default.cross} neex build: Error - No file specified!`));
|
|
@@ -126,18 +130,18 @@ function addBuildCommands(program) {
|
|
|
126
130
|
}
|
|
127
131
|
// Get build configuration
|
|
128
132
|
const buildConfig = await getBuildConfig(file, options.output, showInfo);
|
|
129
|
-
// Create BuildManager instance with
|
|
130
|
-
buildManager = new build_manager_js_1.BuildManager({
|
|
133
|
+
// Create BuildManager instance with all required options
|
|
134
|
+
const buildManager = new build_manager_js_1.BuildManager({
|
|
131
135
|
runnerName: 'neex build',
|
|
132
136
|
inputFile: file,
|
|
133
137
|
outputDir: options.output,
|
|
134
138
|
buildType: buildConfig.buildType,
|
|
135
139
|
buildCommand: buildConfig.buildCommand,
|
|
136
140
|
showInfo: showInfo,
|
|
137
|
-
color: !options.
|
|
138
|
-
showTiming:
|
|
141
|
+
color: !options.color,
|
|
142
|
+
showTiming: !options.timing,
|
|
139
143
|
watch: options.watch,
|
|
140
|
-
delay: parseInt(options.delay)
|
|
144
|
+
delay: parseInt(options.delay),
|
|
141
145
|
verbose: options.verbose,
|
|
142
146
|
clean: options.clean,
|
|
143
147
|
sourceMap: options.sourceMap,
|
|
@@ -146,19 +150,56 @@ function addBuildCommands(program) {
|
|
|
146
150
|
parallel: false,
|
|
147
151
|
groupOutput: false,
|
|
148
152
|
isServerMode: false,
|
|
149
|
-
printOutput:
|
|
150
|
-
prefix:
|
|
151
|
-
stopOnError:
|
|
152
|
-
minimalOutput:
|
|
153
|
+
printOutput: true,
|
|
154
|
+
prefix: true,
|
|
155
|
+
stopOnError: false,
|
|
156
|
+
minimalOutput: false
|
|
153
157
|
});
|
|
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
|
+
}
|
|
154
189
|
// Start the build process
|
|
155
190
|
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
|
+
}
|
|
156
194
|
await buildManager.start();
|
|
157
|
-
|
|
158
|
-
|
|
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
|
+
}
|
|
159
201
|
}
|
|
160
202
|
catch (error) {
|
|
161
|
-
// Only show error message, no extra logs
|
|
162
203
|
console.error(chalk_1.default.red(`${figures_1.default.cross} Build failed`));
|
|
163
204
|
if (error instanceof Error) {
|
|
164
205
|
console.error(chalk_1.default.red(`Error: ${error.message}`));
|
|
@@ -167,14 +208,17 @@ function addBuildCommands(program) {
|
|
|
167
208
|
}
|
|
168
209
|
}
|
|
169
210
|
catch (error) {
|
|
170
|
-
|
|
171
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} Build failed`));
|
|
211
|
+
console.error(chalk_1.default.red(`${figures_1.default.cross} neex build: Fatal error occurred`));
|
|
172
212
|
if (error instanceof Error) {
|
|
173
|
-
console.error(chalk_1.default.red(
|
|
213
|
+
console.error(chalk_1.default.red(`${figures_1.default.cross} Details: ${error.message}`));
|
|
174
214
|
if (options.verbose && error.stack) {
|
|
175
215
|
console.error(chalk_1.default.gray(`Stack trace:\n${error.stack}`));
|
|
176
216
|
}
|
|
177
217
|
}
|
|
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`));
|
|
178
222
|
process.exit(1);
|
|
179
223
|
}
|
|
180
224
|
});
|
|
@@ -183,7 +227,9 @@ function addBuildCommands(program) {
|
|
|
183
227
|
getBuildManager: () => buildManager,
|
|
184
228
|
cleanupBuild: () => {
|
|
185
229
|
if (buildManager && buildManager.isActive()) {
|
|
230
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} neex build: Stopping build process...`));
|
|
186
231
|
buildManager.stop();
|
|
232
|
+
console.log(chalk_1.default.green(`${figures_1.default.tick} neex build: Build process stopped successfully`));
|
|
187
233
|
}
|
|
188
234
|
}
|
|
189
235
|
};
|
|
@@ -155,13 +155,15 @@ function addStartCommands(program) {
|
|
|
155
155
|
'Thumbs.db'
|
|
156
156
|
];
|
|
157
157
|
const extensions = options.ext || ['js', 'mjs', 'json'];
|
|
158
|
+
// Ensure environment is always set to production unless explicitly overridden
|
|
159
|
+
const environment = options.env === 'development' ? options.env : 'production';
|
|
158
160
|
// Log configuration only if --info flag is set
|
|
159
161
|
if (showInfo) {
|
|
160
162
|
console.log(chalk_1.default.blue(`${figures_1.default.info} neex start: Configuration:`));
|
|
161
163
|
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Target: ${chalk_1.default.cyan(file)}`));
|
|
162
164
|
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Runtime: ${chalk_1.default.cyan(startConfig.runtime)}`));
|
|
163
165
|
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Process name: ${chalk_1.default.cyan(startConfig.processName)}`));
|
|
164
|
-
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Environment: ${chalk_1.default.cyan(
|
|
166
|
+
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Environment: ${chalk_1.default.cyan(environment)}`));
|
|
165
167
|
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Watch mode: ${chalk_1.default.cyan(options.watch ? 'Yes' : 'No')}`));
|
|
166
168
|
console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Cluster mode: ${chalk_1.default.cyan(options.cluster ? 'Yes' : 'No')}`));
|
|
167
169
|
if (options.cluster) {
|
|
@@ -185,7 +187,7 @@ function addStartCommands(program) {
|
|
|
185
187
|
console.log(chalk_1.default.blue(`${figures_1.default.info} neex start: Verbose mode enabled - showing detailed logs`));
|
|
186
188
|
}
|
|
187
189
|
console.log(chalk_1.default.green(`${figures_1.default.tick} neex start: Starting production application server...`));
|
|
188
|
-
console.log(chalk_1.default.green(`${figures_1.default.tick} neex start: Launching ${chalk_1.default.cyan(startConfig.processName)} in ${chalk_1.default.cyan(
|
|
190
|
+
console.log(chalk_1.default.green(`${figures_1.default.tick} neex start: Launching ${chalk_1.default.cyan(startConfig.processName)} in ${chalk_1.default.cyan(environment)} mode...`));
|
|
189
191
|
console.log(chalk_1.default.blue(`${figures_1.default.info} neex start: Press Ctrl+C to stop the application server`));
|
|
190
192
|
console.log(chalk_1.default.gray(`${'='.repeat(60)}`));
|
|
191
193
|
}
|
|
@@ -196,7 +198,7 @@ function addStartCommands(program) {
|
|
|
196
198
|
command: startConfig.command,
|
|
197
199
|
processName: startConfig.processName,
|
|
198
200
|
runtime: startConfig.runtime,
|
|
199
|
-
environment:
|
|
201
|
+
environment: environment,
|
|
200
202
|
parallel: false,
|
|
201
203
|
color: options.color,
|
|
202
204
|
showTiming: options.timing,
|