neex 0.6.35 → 0.6.37
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.
- package/README.md +1 -1
- package/dist/src/build-manager.js +12 -15
- package/dist/src/commands/build-commands.js +2 -3
- package/dist/src/commands/dev-commands.js +2 -3
- package/dist/src/commands/start-commands.js +2 -2
- package/dist/src/config.js +59 -0
- package/dist/src/dev-runner.js +10 -13
- package/dist/src/logger-process.js +48 -0
- package/dist/src/start-manager.js +15 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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();
|
|
@@ -70,13 +69,11 @@ class BuildManager {
|
|
|
70
69
|
clean: false,
|
|
71
70
|
sourceMap: false,
|
|
72
71
|
target: 'es2020',
|
|
73
|
-
module: 'commonjs'
|
|
74
|
-
silent: false,
|
|
72
|
+
module: 'commonjs'
|
|
75
73
|
};
|
|
76
74
|
this.options = {
|
|
77
75
|
...defaultOptions,
|
|
78
|
-
...options
|
|
79
|
-
silent: (_a = options.silent) !== null && _a !== void 0 ? _a : false,
|
|
76
|
+
...options
|
|
80
77
|
};
|
|
81
78
|
}
|
|
82
79
|
setupFileWatcher() {
|
|
@@ -99,7 +96,7 @@ class BuildManager {
|
|
|
99
96
|
});
|
|
100
97
|
}
|
|
101
98
|
async handleFileChange(event) {
|
|
102
|
-
if (this.options.showInfo
|
|
99
|
+
if (this.options.showInfo) {
|
|
103
100
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
104
101
|
logger_1.default.printLine(`${prefix} File changed: ${chalk_1.default.yellow(event.relativePath)}`, 'info');
|
|
105
102
|
}
|
|
@@ -110,7 +107,7 @@ class BuildManager {
|
|
|
110
107
|
await fs.mkdir(this.options.outputDir, { recursive: true });
|
|
111
108
|
}
|
|
112
109
|
catch (error) {
|
|
113
|
-
if (this.options.showInfo
|
|
110
|
+
if (this.options.showInfo) {
|
|
114
111
|
logger_1.default.printLine(`Failed to create output directory: ${error.message}`, 'error');
|
|
115
112
|
}
|
|
116
113
|
throw error;
|
|
@@ -122,13 +119,13 @@ class BuildManager {
|
|
|
122
119
|
}
|
|
123
120
|
try {
|
|
124
121
|
await fs.rm(this.options.outputDir, { recursive: true, force: true });
|
|
125
|
-
if (this.options.showInfo
|
|
122
|
+
if (this.options.showInfo) {
|
|
126
123
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
127
124
|
logger_1.default.printLine(`${prefix} Cleaned output directory: ${chalk_1.default.yellow(this.options.outputDir)}`, 'info');
|
|
128
125
|
}
|
|
129
126
|
}
|
|
130
127
|
catch (error) {
|
|
131
|
-
if (this.options.showInfo
|
|
128
|
+
if (this.options.showInfo) {
|
|
132
129
|
logger_1.default.printLine(`Failed to clean output directory: ${error.message}`, 'error');
|
|
133
130
|
}
|
|
134
131
|
throw error;
|
|
@@ -253,7 +250,7 @@ class BuildManager {
|
|
|
253
250
|
// Set up graceful shutdown
|
|
254
251
|
this.setupGracefulShutdown();
|
|
255
252
|
if (this.options.watch) {
|
|
256
|
-
if (this.options.showInfo
|
|
253
|
+
if (this.options.showInfo) {
|
|
257
254
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
258
255
|
logger_1.default.printLine(`${prefix} Build completed. Watching for changes...`, 'info');
|
|
259
256
|
logger_1.default.printLine(`${prefix} Press ${chalk_1.default.cyan('Ctrl+C')} to stop`, 'info');
|
|
@@ -264,7 +261,7 @@ class BuildManager {
|
|
|
264
261
|
if (this.isBuilding) {
|
|
265
262
|
return;
|
|
266
263
|
}
|
|
267
|
-
if (this.options.showInfo
|
|
264
|
+
if (this.options.showInfo) {
|
|
268
265
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
269
266
|
logger_1.default.printLine(`${prefix} Rebuilding due to file changes...`, 'info');
|
|
270
267
|
}
|
|
@@ -280,7 +277,7 @@ class BuildManager {
|
|
|
280
277
|
}
|
|
281
278
|
// Run build again
|
|
282
279
|
await this.runBuild();
|
|
283
|
-
if (this.options.showInfo
|
|
280
|
+
if (this.options.showInfo) {
|
|
284
281
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
285
282
|
logger_1.default.printLine(`${prefix} Rebuild completed. Watching for changes...`, 'info');
|
|
286
283
|
}
|
|
@@ -293,7 +290,7 @@ class BuildManager {
|
|
|
293
290
|
if (!this.isBuilding && !this.options.watch) {
|
|
294
291
|
return;
|
|
295
292
|
}
|
|
296
|
-
if (this.options.showInfo
|
|
293
|
+
if (this.options.showInfo) {
|
|
297
294
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
298
295
|
logger_1.default.printLine(`${prefix} Stopping build process...`, 'info');
|
|
299
296
|
}
|
|
@@ -305,7 +302,7 @@ class BuildManager {
|
|
|
305
302
|
if (this.runner) {
|
|
306
303
|
this.runner.cleanup('SIGTERM');
|
|
307
304
|
}
|
|
308
|
-
if (this.options.showInfo
|
|
305
|
+
if (this.options.showInfo) {
|
|
309
306
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
310
307
|
const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
|
|
311
308
|
const uptimeStr = this.formatUptime(uptime);
|
|
@@ -317,7 +314,7 @@ class BuildManager {
|
|
|
317
314
|
}
|
|
318
315
|
setupGracefulShutdown() {
|
|
319
316
|
const handleSignal = (signal) => {
|
|
320
|
-
if (this.options.showInfo
|
|
317
|
+
if (this.options.showInfo) {
|
|
321
318
|
console.log(`\n${chalk_1.default.yellow(`${figures_1.default.warning} Received ${signal}. Shutting down build process...`)}`);
|
|
322
319
|
}
|
|
323
320
|
this.stop().then(() => {
|
|
@@ -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 {
|
|
@@ -170,12 +170,11 @@ function addDevCommands(program) {
|
|
|
170
170
|
delay: options.delay || 1000,
|
|
171
171
|
clearConsole: options.clear,
|
|
172
172
|
verbose: options.verbose,
|
|
173
|
+
showInfo: showInfo,
|
|
173
174
|
signal: options.signal,
|
|
174
175
|
restartOnChange: true,
|
|
175
176
|
groupOutput: false,
|
|
176
|
-
isServerMode: false
|
|
177
|
-
showInfo: true,
|
|
178
|
-
silent: true // Silence the logger
|
|
177
|
+
isServerMode: false
|
|
179
178
|
});
|
|
180
179
|
// Start the development server
|
|
181
180
|
await devRunner.start([commandToExecute]);
|
|
@@ -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;
|
package/dist/src/dev-runner.js
CHANGED
|
@@ -12,7 +12,6 @@ const figures_1 = __importDefault(require("figures"));
|
|
|
12
12
|
const logger_1 = __importDefault(require("./logger"));
|
|
13
13
|
class DevRunner {
|
|
14
14
|
constructor(options) {
|
|
15
|
-
var _a;
|
|
16
15
|
this.commands = [];
|
|
17
16
|
this.isRunning = false;
|
|
18
17
|
this.restartCount = 0;
|
|
@@ -47,12 +46,10 @@ class DevRunner {
|
|
|
47
46
|
verbose: false,
|
|
48
47
|
showInfo: false,
|
|
49
48
|
runnerName: 'neex dev',
|
|
50
|
-
silent: false,
|
|
51
49
|
};
|
|
52
50
|
this.options = {
|
|
53
51
|
...defaultOptions,
|
|
54
|
-
...options
|
|
55
|
-
silent: (_a = options.silent) !== null && _a !== void 0 ? _a : false,
|
|
52
|
+
...options
|
|
56
53
|
};
|
|
57
54
|
}
|
|
58
55
|
setupFileWatcher() {
|
|
@@ -72,7 +69,7 @@ class DevRunner {
|
|
|
72
69
|
}
|
|
73
70
|
async handleFileChange(event) {
|
|
74
71
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
75
|
-
if (this.options.showInfo
|
|
72
|
+
if (this.options.showInfo) {
|
|
76
73
|
logger_1.default.printLine(`${prefix} File changed: ${chalk_1.default.yellow(event.relativePath)}`, 'info');
|
|
77
74
|
}
|
|
78
75
|
if (this.options.clearConsole) {
|
|
@@ -105,7 +102,7 @@ class DevRunner {
|
|
|
105
102
|
return results;
|
|
106
103
|
}
|
|
107
104
|
catch (error) {
|
|
108
|
-
if (this.options.showInfo
|
|
105
|
+
if (this.options.showInfo) {
|
|
109
106
|
logger_1.default.printLine(`Execution failed: ${error.message}`, 'error');
|
|
110
107
|
}
|
|
111
108
|
return [];
|
|
@@ -159,13 +156,13 @@ class DevRunner {
|
|
|
159
156
|
}
|
|
160
157
|
// Run initial commands
|
|
161
158
|
const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
|
|
162
|
-
if (this.options.showInfo
|
|
159
|
+
if (this.options.showInfo) {
|
|
163
160
|
logger_1.default.printLine(`${prefix} Starting development server...`, 'info');
|
|
164
161
|
}
|
|
165
162
|
await this.runCommands();
|
|
166
163
|
// Set up graceful shutdown
|
|
167
164
|
this.setupGracefulShutdown();
|
|
168
|
-
if (this.options.showInfo
|
|
165
|
+
if (this.options.showInfo) {
|
|
169
166
|
logger_1.default.printLine(`${prefix} Development server started. Watching for changes...`, 'info');
|
|
170
167
|
logger_1.default.printLine(`${prefix} Press ${chalk_1.default.cyan('Ctrl+C')} to stop`, 'info');
|
|
171
168
|
}
|
|
@@ -175,7 +172,7 @@ class DevRunner {
|
|
|
175
172
|
if (!this.isRunning) {
|
|
176
173
|
return;
|
|
177
174
|
}
|
|
178
|
-
if (this.options.showInfo
|
|
175
|
+
if (this.options.showInfo) {
|
|
179
176
|
logger_1.default.printLine(`${prefix} Restarting due to file changes...`, 'info');
|
|
180
177
|
}
|
|
181
178
|
this.restartCount++;
|
|
@@ -189,7 +186,7 @@ class DevRunner {
|
|
|
189
186
|
this.printDevBanner();
|
|
190
187
|
// Run commands again
|
|
191
188
|
await this.runCommands();
|
|
192
|
-
if (this.options.showInfo
|
|
189
|
+
if (this.options.showInfo) {
|
|
193
190
|
logger_1.default.printLine(`${prefix} Restart completed. Watching for changes...`, 'info');
|
|
194
191
|
}
|
|
195
192
|
}
|
|
@@ -198,7 +195,7 @@ class DevRunner {
|
|
|
198
195
|
if (!this.isRunning) {
|
|
199
196
|
return;
|
|
200
197
|
}
|
|
201
|
-
if (this.options.showInfo
|
|
198
|
+
if (this.options.showInfo) {
|
|
202
199
|
logger_1.default.printLine(`${prefix} Stopping development server...`, 'info');
|
|
203
200
|
}
|
|
204
201
|
this.isRunning = false;
|
|
@@ -212,7 +209,7 @@ class DevRunner {
|
|
|
212
209
|
}
|
|
213
210
|
const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
|
|
214
211
|
const uptimeStr = this.formatUptime(uptime);
|
|
215
|
-
if (this.options.showInfo
|
|
212
|
+
if (this.options.showInfo) {
|
|
216
213
|
logger_1.default.printLine(`${prefix} ${this.options.runnerName} development server stopped after ${uptimeStr}`, 'info');
|
|
217
214
|
if (this.restartCount > 0) {
|
|
218
215
|
logger_1.default.printLine(`${prefix} Total restarts: ${this.restartCount}`, 'info');
|
|
@@ -221,7 +218,7 @@ class DevRunner {
|
|
|
221
218
|
}
|
|
222
219
|
setupGracefulShutdown() {
|
|
223
220
|
const handleSignal = (signal) => {
|
|
224
|
-
if (this.options.showInfo
|
|
221
|
+
if (this.options.showInfo) {
|
|
225
222
|
console.log(`\n${chalk_1.default.yellow(`${figures_1.default.warning} Received ${signal}. Shutting down development server...`)}`);
|
|
226
223
|
}
|
|
227
224
|
this.stop().then(() => {
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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(() => {
|