neex 0.7.20 → 0.7.31

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.
Files changed (58) hide show
  1. package/README.md +13 -31
  2. package/dist/bin/neex.d.ts +26 -0
  3. package/dist/bin/neex.d.ts.map +1 -0
  4. package/dist/src/build-manager.d.ts +41 -0
  5. package/dist/src/build-manager.d.ts.map +1 -0
  6. package/dist/src/build-manager.js +26 -24
  7. package/dist/src/cli.d.ts +2 -0
  8. package/dist/src/cli.d.ts.map +1 -0
  9. package/dist/src/commands/build-commands.d.ts +5 -0
  10. package/dist/src/commands/build-commands.d.ts.map +1 -0
  11. package/dist/src/commands/build-commands.js +2 -2
  12. package/dist/src/commands/dev-commands.d.ts +5 -0
  13. package/dist/src/commands/dev-commands.d.ts.map +1 -0
  14. package/dist/src/commands/dev-commands.js +5 -3
  15. package/dist/src/commands/index.d.ts +7 -0
  16. package/dist/src/commands/index.d.ts.map +1 -0
  17. package/dist/src/commands/init-commands.d.ts +2 -0
  18. package/dist/src/commands/init-commands.d.ts.map +1 -0
  19. package/dist/src/commands/init-commands.js +4 -4
  20. package/dist/src/commands/run-commands.d.ts +3 -0
  21. package/dist/src/commands/run-commands.d.ts.map +1 -0
  22. package/dist/src/commands/run-commands.js +26 -26
  23. package/dist/src/commands/server-commands.d.ts +3 -0
  24. package/dist/src/commands/server-commands.d.ts.map +1 -0
  25. package/dist/src/commands/server-commands.js +4 -2
  26. package/dist/src/commands/start-commands.d.ts +5 -0
  27. package/dist/src/commands/start-commands.d.ts.map +1 -0
  28. package/dist/src/commands/start-commands.js +2 -2
  29. package/dist/src/dev-manager.d.ts +51 -0
  30. package/dist/src/dev-manager.d.ts.map +1 -0
  31. package/dist/src/dev-manager.js +29 -21
  32. package/dist/src/index.d.ts +41 -0
  33. package/dist/src/index.d.ts.map +1 -0
  34. package/dist/src/index.js +15 -16
  35. package/dist/src/logger-manager.d.ts +4 -0
  36. package/dist/src/logger-manager.d.ts.map +1 -0
  37. package/dist/src/logger-manager.js +4 -4
  38. package/dist/src/logger.d.ts +34 -0
  39. package/dist/src/logger.d.ts.map +1 -0
  40. package/dist/src/logger.js +21 -15
  41. package/dist/src/runner.d.ts +21 -0
  42. package/dist/src/runner.d.ts.map +1 -0
  43. package/dist/src/runner.js +38 -25
  44. package/dist/src/start-manager.d.ts +49 -0
  45. package/dist/src/start-manager.d.ts.map +1 -0
  46. package/dist/src/start-manager.js +34 -29
  47. package/dist/src/types.d.ts +41 -0
  48. package/dist/src/types.d.ts.map +1 -0
  49. package/dist/src/utils.d.ts +2 -0
  50. package/dist/src/utils.d.ts.map +1 -0
  51. package/package.json +14 -9
  52. package/dist/src/cli-init.js +0 -1
  53. package/dist/src/commands/process-commands.js +0 -759
  54. package/dist/src/config.js +0 -59
  55. package/dist/src/dev-runner.js +0 -234
  56. package/dist/src/logger-process.js +0 -17
  57. package/dist/src/process-manager.js +0 -669
  58. package/dist/src/watcher.js +0 -245
@@ -0,0 +1,49 @@
1
+ export interface StartOptions {
2
+ file: string;
3
+ workingDir: string;
4
+ envFile: string;
5
+ port?: number;
6
+ workers: number;
7
+ memoryLimit?: string;
8
+ logLevel: string;
9
+ color: boolean;
10
+ verbose: boolean;
11
+ watch: boolean;
12
+ maxMemory?: string;
13
+ maxCrashes: number;
14
+ restartDelay: number;
15
+ healthCheck: boolean;
16
+ healthPort: number;
17
+ gracefulTimeout: number;
18
+ inspect: boolean;
19
+ inspectBrk: boolean;
20
+ nodeArgs?: string;
21
+ }
22
+ export declare class StartManager {
23
+ private options;
24
+ private workers;
25
+ private watcher;
26
+ private healthServer;
27
+ private isShuttingDown;
28
+ private debouncedRestart;
29
+ private startTime;
30
+ private totalRestarts;
31
+ private envLoaded;
32
+ private masterProcess;
33
+ constructor(options: StartOptions);
34
+ private log;
35
+ private loadEnvFile;
36
+ private parseMemoryLimit;
37
+ private getNodeArgs;
38
+ private startSingleProcess;
39
+ private startWorker;
40
+ private restartWorker;
41
+ private waitForProcessExit;
42
+ private startCluster;
43
+ private setupHealthCheck;
44
+ private setupWatcher;
45
+ private restartAll;
46
+ start(): Promise<void>;
47
+ stop(): Promise<void>;
48
+ }
49
+ //# sourceMappingURL=start-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-manager.d.ts","sourceRoot":"","sources":["../../src/start-manager.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAWD,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,OAAO,CAAsC;IACrD,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,gBAAgB,CAAa;IACrC,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,aAAa,CAA6B;gBAEtC,OAAO,EAAE,YAAY;IASjC,OAAO,CAAC,GAAG;IAOX,OAAO,CAAC,WAAW;IA0CnB,OAAO,CAAC,gBAAgB;IAkBxB,OAAO,CAAC,WAAW;YA0BL,kBAAkB;IA4EhC,OAAO,CAAC,WAAW;YAiHL,aAAa;YAiCb,kBAAkB;YAqBlB,YAAY;IAoC1B,OAAO,CAAC,gBAAgB;IAgDxB,OAAO,CAAC,YAAY;YAqCN,UAAU;IA0CX,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAiDnC"}
@@ -16,14 +16,17 @@ const http_1 = __importDefault(require("http"));
16
16
  const lodash_1 = require("lodash");
17
17
  const os_1 = __importDefault(require("os"));
18
18
  class StartManager {
19
+ options;
20
+ workers = new Map();
21
+ watcher = null;
22
+ healthServer = null;
23
+ isShuttingDown = false;
24
+ debouncedRestart;
25
+ startTime;
26
+ totalRestarts = 0;
27
+ envLoaded = false;
28
+ masterProcess = null;
19
29
  constructor(options) {
20
- this.workers = new Map();
21
- this.watcher = null;
22
- this.healthServer = null;
23
- this.isShuttingDown = false;
24
- this.totalRestarts = 0;
25
- this.envLoaded = false;
26
- this.masterProcess = null;
27
30
  this.options = options;
28
31
  this.startTime = new Date();
29
32
  this.debouncedRestart = (0, lodash_1.debounce)(this.restartAll.bind(this), options.restartDelay);
@@ -66,15 +69,19 @@ class StartManager {
66
69
  }
67
70
  }
68
71
  parseMemoryLimit(limit) {
69
- var _a;
70
72
  if (!limit)
71
73
  return undefined;
72
74
  const match = limit.match(/^(\d+)([KMGT]?)$/i);
73
75
  if (!match)
74
76
  return undefined;
75
77
  const value = parseInt(match[1]);
76
- const unit = ((_a = match[2]) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || '';
77
- const multipliers = { K: 1024, M: 1024 * 1024, G: 1024 * 1024 * 1024, T: 1024 * 1024 * 1024 * 1024 };
78
+ const unit = match[2]?.toUpperCase() || '';
79
+ const multipliers = {
80
+ K: 1024,
81
+ M: 1024 * 1024,
82
+ G: 1024 * 1024 * 1024,
83
+ T: 1024 * 1024 * 1024 * 1024,
84
+ };
78
85
  return value * (multipliers[unit] || 1);
79
86
  }
80
87
  getNodeArgs() {
@@ -105,15 +112,15 @@ class StartManager {
105
112
  NODE_ENV: process.env.NODE_ENV || 'production',
106
113
  PORT: port.toString(),
107
114
  FORCE_COLOR: this.options.color ? '1' : '0',
108
- NODE_OPTIONS: '--no-deprecation'
115
+ NODE_OPTIONS: '--no-deprecation',
109
116
  };
110
117
  this.masterProcess = (0, child_process_1.fork)(this.options.file, [], {
111
118
  cwd: this.options.workingDir,
112
119
  env,
113
120
  execArgv: nodeArgs,
114
- silent: false // Let the process handle its own output
121
+ silent: false, // Let the process handle its own output
115
122
  });
116
- this.masterProcess.on('error', (error) => {
123
+ this.masterProcess.on('error', error => {
117
124
  this.log(`Process error: ${error.message}`, 'error');
118
125
  });
119
126
  this.masterProcess.on('exit', (code, signal) => {
@@ -141,11 +148,11 @@ class StartManager {
141
148
  resolve();
142
149
  }
143
150
  });
144
- this.masterProcess.on('error', (error) => {
151
+ this.masterProcess.on('error', error => {
145
152
  clearTimeout(timeout);
146
153
  reject(error);
147
154
  });
148
- this.masterProcess.on('exit', (code) => {
155
+ this.masterProcess.on('exit', code => {
149
156
  clearTimeout(timeout);
150
157
  if (code !== 0) {
151
158
  reject(new Error(`Process exited with code ${code}`));
@@ -161,7 +168,6 @@ class StartManager {
161
168
  }
162
169
  startWorker(workerId) {
163
170
  return new Promise((resolve, reject) => {
164
- var _a, _b;
165
171
  const nodeArgs = this.getNodeArgs();
166
172
  const port = this.options.port || 8000;
167
173
  const env = {
@@ -171,13 +177,13 @@ class StartManager {
171
177
  PORT: port.toString(),
172
178
  CLUSTER_WORKER: 'true',
173
179
  FORCE_COLOR: this.options.color ? '1' : '0',
174
- NODE_OPTIONS: '--no-deprecation'
180
+ NODE_OPTIONS: '--no-deprecation',
175
181
  };
176
182
  const workerProcess = (0, child_process_1.fork)(this.options.file, [], {
177
183
  cwd: this.options.workingDir,
178
184
  env,
179
185
  execArgv: nodeArgs,
180
- silent: true
186
+ silent: true,
181
187
  });
182
188
  const workerInfo = {
183
189
  process: workerProcess,
@@ -185,7 +191,7 @@ class StartManager {
185
191
  restarts: 0,
186
192
  startTime: new Date(),
187
193
  id: workerId,
188
- port: port
194
+ port: port,
189
195
  };
190
196
  this.workers.set(workerId, workerInfo);
191
197
  let isReady = false;
@@ -196,9 +202,8 @@ class StartManager {
196
202
  }
197
203
  }, 15000);
198
204
  const cleanupReadinessListeners = () => {
199
- var _a;
200
205
  clearTimeout(readinessTimeout);
201
- (_a = workerProcess.stdout) === null || _a === void 0 ? void 0 : _a.removeListener('data', onDataForReady);
206
+ workerProcess.stdout?.removeListener('data', onDataForReady);
202
207
  workerProcess.removeListener('message', onMessageForReady);
203
208
  };
204
209
  const onReady = () => {
@@ -224,13 +229,13 @@ class StartManager {
224
229
  onReady();
225
230
  }
226
231
  };
227
- (_a = workerProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', onDataForReady);
228
- (_b = workerProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => {
232
+ workerProcess.stdout?.on('data', onDataForReady);
233
+ workerProcess.stderr?.on('data', data => {
229
234
  const prefix = chalk_1.default.red.dim(`[Worker ${workerId}] `);
230
235
  process.stderr.write(prefix + data.toString());
231
236
  });
232
237
  workerProcess.on('message', onMessageForReady);
233
- workerProcess.on('error', (error) => {
238
+ workerProcess.on('error', error => {
234
239
  if (!isReady) {
235
240
  cleanupReadinessListeners();
236
241
  reject(error);
@@ -335,12 +340,12 @@ class StartManager {
335
340
  id: w.id,
336
341
  pid: w.pid,
337
342
  restarts: w.restarts,
338
- uptime: Date.now() - w.startTime.getTime()
343
+ uptime: Date.now() - w.startTime.getTime(),
339
344
  })),
340
345
  totalRestarts: this.totalRestarts,
341
346
  memory: process.memoryUsage(),
342
347
  cpu: os_1.default.loadavg(),
343
- port: this.options.port || 8000
348
+ port: this.options.port || 8000,
344
349
  };
345
350
  res.writeHead(200, { 'Content-Type': 'application/json' });
346
351
  res.end(JSON.stringify(stats, null, 2));
@@ -362,7 +367,7 @@ class StartManager {
362
367
  const watchPatterns = [
363
368
  `${this.options.workingDir}/**/*.js`,
364
369
  `${this.options.workingDir}/**/*.json`,
365
- `${this.options.workingDir}/**/*.env*`
370
+ `${this.options.workingDir}/**/*.env*`,
366
371
  ];
367
372
  this.watcher = (0, chokidar_1.watch)(watchPatterns, {
368
373
  ignored: ['**/node_modules/**', '**/.git/**', '**/logs/**', '**/tmp/**'],
@@ -370,8 +375,8 @@ class StartManager {
370
375
  atomic: 300,
371
376
  awaitWriteFinish: {
372
377
  stabilityThreshold: 2000,
373
- pollInterval: 100
374
- }
378
+ pollInterval: 100,
379
+ },
375
380
  });
376
381
  this.watcher.on('change', (filePath) => {
377
382
  if (this.options.verbose) {
@@ -0,0 +1,41 @@
1
+ export interface RunOptions {
2
+ parallel: boolean;
3
+ maxParallel?: number;
4
+ printOutput: boolean;
5
+ color: boolean;
6
+ showTiming: boolean;
7
+ prefix: boolean;
8
+ stopOnError: boolean;
9
+ minimalOutput: boolean;
10
+ groupOutput: boolean;
11
+ isServerMode: boolean;
12
+ retry?: number;
13
+ retryDelay?: number;
14
+ }
15
+ export interface RunResult {
16
+ stderr: any;
17
+ command: string;
18
+ success: boolean;
19
+ code: number | null;
20
+ startTime: Date;
21
+ endTime: Date | null;
22
+ duration?: number;
23
+ error?: Error;
24
+ output?: CommandOutput[];
25
+ }
26
+ export interface CommandOutput {
27
+ command: string;
28
+ type: 'stdout' | 'stderr';
29
+ data: string;
30
+ timestamp: Date;
31
+ }
32
+ export interface ServerInfo {
33
+ name: string;
34
+ url?: string;
35
+ status: 'starting' | 'running' | 'error' | 'stopped';
36
+ pid?: number;
37
+ port?: number;
38
+ startTime?: Date;
39
+ }
40
+ export type LogLevel = 'info' | 'warn' | 'error' | 'debug' | 'success';
41
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version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IAAI,CAAC;CAClB;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function formatDuration(ms: number): string;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAKjD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neex",
3
- "version": "0.7.20",
3
+ "version": "0.7.31",
4
4
  "description": "Neex - Modern Fullstack Framework Built on Express and Next.js. Fast to Start, Easy to Build, Ready to Deploy",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -9,13 +9,16 @@
9
9
  },
10
10
  "scripts": {
11
11
  "build": "tsc",
12
+ "dev": "tsc --watch",
12
13
  "start": "node dist/bin/neex.js",
13
- "prepublishOnly": "npm run build",
14
+ "clean": "rm -rf dist",
15
+ "lint": "eslint .",
16
+ "lint:fix": "eslint . --fix",
17
+ "prepublishOnly": "npm run clean && npm run build",
14
18
  "test": "jest",
15
- "dev": "neex w \"ts-node src/server.ts\"",
16
19
  "test:dev": "node ./dist/bin/neex.js px \"echo Starting frontend\" \"echo Starting backend\"",
17
- "test:parallel": "node ./dist/src/cli.js parallel \"echo Building frontend\" \"echo Building backend\"",
18
- "test:sequence": "node ./dist/src/cli.js run \"echo Step 1\" \"echo Step 2\" \"echo Step 3\""
20
+ "test:parallel": "node ./dist/bin/neex.js parallel \"echo Building frontend\" \"echo Building backend\"",
21
+ "test:sequence": "node ./dist/bin/neex.js run \"echo Step 1\" \"echo Step 2\" \"echo Step 3\""
19
22
  },
20
23
  "keywords": [
21
24
  "fullstack-framework",
@@ -38,10 +41,10 @@
38
41
  "author": "foshati",
39
42
  "license": "MIT",
40
43
  "dependencies": {
41
- "chalk": "^4.1.2",
44
+ "chalk": "^5.6.2",
42
45
  "chokidar": "^4.0.3",
43
- "commander": "14.0.0",
44
- "figlet": "^1.8.1",
46
+ "commander": "14.0.2",
47
+ "figlet": "^1.9.3",
45
48
  "figures": "^6.1.0",
46
49
  "gradient-string": "^3.0.0",
47
50
  "lodash": "^4.17.21",
@@ -50,11 +53,13 @@
50
53
  "string-width": "^7.2.0",
51
54
  "typescript": "^5.8.3"
52
55
  },
56
+
53
57
  "devDependencies": {
54
58
  "@types/figlet": "^1.7.0",
55
59
  "@types/jest": "^29.2.3",
56
60
  "@types/lodash": "^4.17.20",
57
61
  "@types/node": "^20.14.10",
62
+ "eslint": "^9.38.0",
58
63
  "jest": "^29.3.1",
59
64
  "ts-jest": "^29.0.3",
60
65
  "ts-node": "^10.9.2"
@@ -66,4 +71,4 @@
66
71
  "type": "git",
67
72
  "url": "https://github.com/Neexjs"
68
73
  }
69
- }
74
+ }
@@ -1 +0,0 @@
1
- "use strict";