neex 0.7.45 → 0.8.3
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 +50 -326
- package/bin/neex +31 -0
- package/install.js +94 -0
- package/package.json +30 -63
- package/dist/bin/neex.d.ts +0 -26
- package/dist/bin/neex.d.ts.map +0 -1
- package/dist/bin/neex.js +0 -8
- package/dist/src/build-manager.d.ts +0 -41
- package/dist/src/build-manager.d.ts.map +0 -1
- package/dist/src/build-manager.js +0 -369
- package/dist/src/cli.d.ts +0 -2
- package/dist/src/cli.d.ts.map +0 -1
- package/dist/src/cli.js +0 -67
- package/dist/src/commands/add-commands.d.ts +0 -4
- package/dist/src/commands/add-commands.d.ts.map +0 -1
- package/dist/src/commands/add-commands.js +0 -83
- package/dist/src/commands/build-commands.d.ts +0 -5
- package/dist/src/commands/build-commands.d.ts.map +0 -1
- package/dist/src/commands/build-commands.js +0 -123
- package/dist/src/commands/dev-commands.d.ts +0 -5
- package/dist/src/commands/dev-commands.d.ts.map +0 -1
- package/dist/src/commands/dev-commands.js +0 -198
- package/dist/src/commands/index.d.ts +0 -8
- package/dist/src/commands/index.d.ts.map +0 -1
- package/dist/src/commands/index.js +0 -27
- package/dist/src/commands/init-commands.d.ts +0 -2
- package/dist/src/commands/init-commands.d.ts.map +0 -1
- package/dist/src/commands/init-commands.js +0 -20
- package/dist/src/commands/run-commands.d.ts +0 -3
- package/dist/src/commands/run-commands.d.ts.map +0 -1
- package/dist/src/commands/run-commands.js +0 -93
- package/dist/src/commands/server-commands.d.ts +0 -3
- package/dist/src/commands/server-commands.d.ts.map +0 -1
- package/dist/src/commands/server-commands.js +0 -51
- package/dist/src/commands/start-commands.d.ts +0 -5
- package/dist/src/commands/start-commands.d.ts.map +0 -1
- package/dist/src/commands/start-commands.js +0 -162
- package/dist/src/dev-manager.d.ts +0 -51
- package/dist/src/dev-manager.d.ts.map +0 -1
- package/dist/src/dev-manager.js +0 -471
- package/dist/src/index.d.ts +0 -41
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -70
- package/dist/src/logger-manager.d.ts +0 -4
- package/dist/src/logger-manager.d.ts.map +0 -1
- package/dist/src/logger-manager.js +0 -17
- package/dist/src/logger.d.ts +0 -34
- package/dist/src/logger.d.ts.map +0 -1
- package/dist/src/logger.js +0 -279
- package/dist/src/runner.d.ts +0 -21
- package/dist/src/runner.d.ts.map +0 -1
- package/dist/src/runner.js +0 -414
- package/dist/src/start-manager.d.ts +0 -49
- package/dist/src/start-manager.d.ts.map +0 -1
- package/dist/src/start-manager.js +0 -484
- package/dist/src/types.d.ts +0 -41
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -2
- package/dist/src/utils.d.ts +0 -2
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -9
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export interface BuildOptions {
|
|
2
|
-
source: string;
|
|
3
|
-
output: string;
|
|
4
|
-
watch: boolean;
|
|
5
|
-
clean: boolean;
|
|
6
|
-
minify: boolean;
|
|
7
|
-
sourcemap: boolean;
|
|
8
|
-
target: string;
|
|
9
|
-
format: string;
|
|
10
|
-
bundle: boolean;
|
|
11
|
-
external: string[];
|
|
12
|
-
tsconfig: string;
|
|
13
|
-
verbose: boolean;
|
|
14
|
-
quiet: boolean;
|
|
15
|
-
color: boolean;
|
|
16
|
-
analyze: boolean;
|
|
17
|
-
}
|
|
18
|
-
export declare class BuildManager {
|
|
19
|
-
private options;
|
|
20
|
-
private watcher;
|
|
21
|
-
private buildProcess;
|
|
22
|
-
private isBuilding;
|
|
23
|
-
private buildCount;
|
|
24
|
-
constructor(options: BuildOptions);
|
|
25
|
-
private cleanOutputDirectory;
|
|
26
|
-
private ensureOutputDirectory;
|
|
27
|
-
private validateTsConfig;
|
|
28
|
-
private copyPackageJson;
|
|
29
|
-
private getTscCommand;
|
|
30
|
-
private runBuild;
|
|
31
|
-
private filterTscErrors;
|
|
32
|
-
private analyzeBuild;
|
|
33
|
-
private stopProcess;
|
|
34
|
-
private formatBytes;
|
|
35
|
-
private setupWatcher;
|
|
36
|
-
private debouncedBuild;
|
|
37
|
-
private debounce;
|
|
38
|
-
build(): Promise<void>;
|
|
39
|
-
stop(): Promise<void>;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=build-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-manager.d.ts","sourceRoot":"","sources":["../../src/build-manager.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,UAAU,CAAK;gBAEX,OAAO,EAAE,YAAY;YAInB,oBAAoB;YAmBpB,qBAAqB;YAUrB,gBAAgB;YAQhB,eAAe;IA4C7B,OAAO,CAAC,aAAa;YA+BP,QAAQ;IAwGtB,OAAO,CAAC,eAAe;YAmBT,YAAY;YAmDZ,WAAW;IAkDzB,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,YAAY;IA8DpB,OAAO,CAAC,cAAc,CAAgD;IAEtE,OAAO,CAAC,QAAQ;IAYH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA4BtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAsBnC"}
|
|
@@ -1,369 +0,0 @@
|
|
|
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.BuildManager = void 0;
|
|
7
|
-
// src/build-manager.ts - Build manager for TypeScript projects using tsc
|
|
8
|
-
const child_process_1 = require("child_process");
|
|
9
|
-
const chokidar_1 = require("chokidar");
|
|
10
|
-
const logger_manager_js_1 = require("./logger-manager.js");
|
|
11
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
12
|
-
const figures_1 = __importDefault(require("figures"));
|
|
13
|
-
const path_1 = __importDefault(require("path"));
|
|
14
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
15
|
-
const fs_1 = require("fs");
|
|
16
|
-
class BuildManager {
|
|
17
|
-
options;
|
|
18
|
-
watcher = null;
|
|
19
|
-
buildProcess = null;
|
|
20
|
-
isBuilding = false;
|
|
21
|
-
buildCount = 0;
|
|
22
|
-
constructor(options) {
|
|
23
|
-
this.options = options;
|
|
24
|
-
}
|
|
25
|
-
async cleanOutputDirectory() {
|
|
26
|
-
if (this.options.clean && (0, fs_1.existsSync)(this.options.output)) {
|
|
27
|
-
try {
|
|
28
|
-
await promises_1.default.rm(this.options.output, { recursive: true, force: true });
|
|
29
|
-
if (this.options.verbose) {
|
|
30
|
-
logger_manager_js_1.loggerManager.printLine(`Cleaned output directory: ${this.options.output}`, 'info');
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
logger_manager_js_1.loggerManager.printLine(`Failed to clean output directory: ${error.message}`, 'warn');
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async ensureOutputDirectory() {
|
|
39
|
-
try {
|
|
40
|
-
await promises_1.default.mkdir(this.options.output, { recursive: true });
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
throw new Error(`Failed to create output directory: ${error.message}`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
async validateTsConfig() {
|
|
47
|
-
if (!(0, fs_1.existsSync)(this.options.tsconfig)) {
|
|
48
|
-
throw new Error(`TypeScript config file not found: ${this.options.tsconfig}`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
async copyPackageJson() {
|
|
52
|
-
const packageJsonPath = path_1.default.join(process.cwd(), 'package.json');
|
|
53
|
-
const outputPackageJsonPath = path_1.default.join(this.options.output, 'package.json');
|
|
54
|
-
if ((0, fs_1.existsSync)(packageJsonPath)) {
|
|
55
|
-
try {
|
|
56
|
-
const packageJson = JSON.parse(await promises_1.default.readFile(packageJsonPath, 'utf8'));
|
|
57
|
-
// Create production package.json
|
|
58
|
-
const prodPackageJson = {
|
|
59
|
-
name: packageJson.name,
|
|
60
|
-
version: packageJson.version,
|
|
61
|
-
description: packageJson.description,
|
|
62
|
-
main: packageJson.main?.replace(/^src\//, '') || 'index.js',
|
|
63
|
-
type: this.options.format === 'esm' ? 'module' : 'commonjs',
|
|
64
|
-
scripts: {
|
|
65
|
-
start: 'node index.js',
|
|
66
|
-
},
|
|
67
|
-
dependencies: packageJson.dependencies || {},
|
|
68
|
-
engines: packageJson.engines,
|
|
69
|
-
};
|
|
70
|
-
await promises_1.default.writeFile(outputPackageJsonPath, JSON.stringify(prodPackageJson, null, 2));
|
|
71
|
-
if (this.options.verbose) {
|
|
72
|
-
logger_manager_js_1.loggerManager.printLine('Generated production package.json', 'info');
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
logger_manager_js_1.loggerManager.printLine(`Failed to copy package.json: ${error.message}`, 'warn');
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
getTscCommand() {
|
|
81
|
-
const args = [
|
|
82
|
-
'--project',
|
|
83
|
-
this.options.tsconfig,
|
|
84
|
-
'--outDir',
|
|
85
|
-
this.options.output,
|
|
86
|
-
'--target',
|
|
87
|
-
this.options.target,
|
|
88
|
-
'--declaration',
|
|
89
|
-
];
|
|
90
|
-
if (this.options.sourcemap) {
|
|
91
|
-
args.push('--sourceMap');
|
|
92
|
-
}
|
|
93
|
-
if (this.options.format === 'esm') {
|
|
94
|
-
args.push('--module', 'es2020', '--moduleResolution', 'node');
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
args.push('--module', 'commonjs');
|
|
98
|
-
}
|
|
99
|
-
// Always include these for better compatibility
|
|
100
|
-
args.push('--esModuleInterop', '--allowSyntheticDefaultImports', '--strict');
|
|
101
|
-
return { command: 'tsc', args };
|
|
102
|
-
}
|
|
103
|
-
async runBuild() {
|
|
104
|
-
if (this.isBuilding) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
this.isBuilding = true;
|
|
108
|
-
this.buildCount++;
|
|
109
|
-
const startTime = Date.now();
|
|
110
|
-
if (!this.options.quiet) {
|
|
111
|
-
const buildNumber = this.options.watch ? ` #${this.buildCount}` : '';
|
|
112
|
-
logger_manager_js_1.loggerManager.printLine(`${chalk_1.default.green(figures_1.default.play)} Building${buildNumber}...`, 'info');
|
|
113
|
-
}
|
|
114
|
-
try {
|
|
115
|
-
await this.ensureOutputDirectory();
|
|
116
|
-
const { command, args } = this.getTscCommand();
|
|
117
|
-
if (this.options.verbose) {
|
|
118
|
-
logger_manager_js_1.loggerManager.printLine(`Executing: ${command} ${args.join(' ')}`, 'info');
|
|
119
|
-
}
|
|
120
|
-
return new Promise((resolve, reject) => {
|
|
121
|
-
this.buildProcess = (0, child_process_1.spawn)(command, args, {
|
|
122
|
-
stdio: ['ignore', 'pipe', 'pipe'], // Capture stdout and stderr
|
|
123
|
-
shell: false,
|
|
124
|
-
env: {
|
|
125
|
-
...process.env,
|
|
126
|
-
FORCE_COLOR: '0', // Disable TSC colors to avoid log pollution
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
let stdout = '';
|
|
130
|
-
let stderr = '';
|
|
131
|
-
// Capture all output but don't display TSC logs
|
|
132
|
-
this.buildProcess.stdout?.on('data', data => {
|
|
133
|
-
stdout += data.toString();
|
|
134
|
-
});
|
|
135
|
-
this.buildProcess.stderr?.on('data', data => {
|
|
136
|
-
stderr += data.toString();
|
|
137
|
-
});
|
|
138
|
-
this.buildProcess.on('error', error => {
|
|
139
|
-
this.buildProcess = null;
|
|
140
|
-
this.isBuilding = false;
|
|
141
|
-
reject(new Error(`Build process error: ${error.message}`));
|
|
142
|
-
});
|
|
143
|
-
this.buildProcess.on('exit', async (code) => {
|
|
144
|
-
this.buildProcess = null;
|
|
145
|
-
this.isBuilding = false;
|
|
146
|
-
const duration = Date.now() - startTime;
|
|
147
|
-
if (code === 0) {
|
|
148
|
-
// Copy package.json after successful build
|
|
149
|
-
await this.copyPackageJson();
|
|
150
|
-
if (!this.options.quiet) {
|
|
151
|
-
logger_manager_js_1.loggerManager.printLine(`${chalk_1.default.green(figures_1.default.tick)} Build completed in ${duration}ms`, 'info');
|
|
152
|
-
}
|
|
153
|
-
if (this.options.analyze) {
|
|
154
|
-
await this.analyzeBuild();
|
|
155
|
-
}
|
|
156
|
-
resolve();
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
// Only show meaningful errors, filter out TSC verbosity
|
|
160
|
-
const meaningfulErrors = this.filterTscErrors(stderr);
|
|
161
|
-
if (meaningfulErrors) {
|
|
162
|
-
logger_manager_js_1.loggerManager.printLine(`Build failed:\n${meaningfulErrors}`, 'error');
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
logger_manager_js_1.loggerManager.printLine(`Build failed with code ${code}`, 'error');
|
|
166
|
-
}
|
|
167
|
-
reject(new Error(`Build failed with code ${code}`));
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
catch (error) {
|
|
173
|
-
this.isBuilding = false;
|
|
174
|
-
throw error;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
filterTscErrors(stderr) {
|
|
178
|
-
if (!stderr)
|
|
179
|
-
return '';
|
|
180
|
-
const lines = stderr.split('\n');
|
|
181
|
-
const meaningfulLines = lines.filter(line => {
|
|
182
|
-
const trimmed = line.trim();
|
|
183
|
-
// Filter out TSC verbose output, keep only actual errors
|
|
184
|
-
return (trimmed &&
|
|
185
|
-
!trimmed.includes('message TS') &&
|
|
186
|
-
!trimmed.includes('Found 0 errors') &&
|
|
187
|
-
!trimmed.match(/^\s*\d+\s*$/) && // Filter line numbers
|
|
188
|
-
!trimmed.includes('Watching for file changes'));
|
|
189
|
-
});
|
|
190
|
-
return meaningfulLines.join('\n').trim();
|
|
191
|
-
}
|
|
192
|
-
async analyzeBuild() {
|
|
193
|
-
try {
|
|
194
|
-
const files = await promises_1.default.readdir(this.options.output, {
|
|
195
|
-
withFileTypes: true,
|
|
196
|
-
});
|
|
197
|
-
let totalSize = 0;
|
|
198
|
-
const fileStats = [];
|
|
199
|
-
for (const file of files) {
|
|
200
|
-
if (file.isFile() &&
|
|
201
|
-
(file.name.endsWith('.js') || file.name.endsWith('.d.ts'))) {
|
|
202
|
-
const filePath = path_1.default.join(this.options.output, file.name);
|
|
203
|
-
const stat = await promises_1.default.stat(filePath);
|
|
204
|
-
totalSize += stat.size;
|
|
205
|
-
fileStats.push({ name: file.name, size: stat.size });
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
fileStats.sort((a, b) => b.size - a.size);
|
|
209
|
-
logger_manager_js_1.loggerManager.printLine(`${chalk_1.default.blue(figures_1.default.info)} Build Analysis:`, 'info');
|
|
210
|
-
logger_manager_js_1.loggerManager.printLine(`Total size: ${chalk_1.default.cyan(this.formatBytes(totalSize))}`, 'info');
|
|
211
|
-
logger_manager_js_1.loggerManager.printLine(`Generated files: ${fileStats.length}`, 'info');
|
|
212
|
-
if (this.options.verbose && fileStats.length > 0) {
|
|
213
|
-
const topFiles = fileStats.slice(0, 5);
|
|
214
|
-
logger_manager_js_1.loggerManager.printLine('Largest files:', 'info');
|
|
215
|
-
topFiles.forEach(file => {
|
|
216
|
-
logger_manager_js_1.loggerManager.printLine(` ${file.name}: ${this.formatBytes(file.size)}`, 'info');
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
catch (error) {
|
|
221
|
-
logger_manager_js_1.loggerManager.printLine(`Failed to analyze build: ${error.message}`, 'warn');
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
async stopProcess() {
|
|
225
|
-
if (!this.buildProcess) {
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
return new Promise(resolve => {
|
|
229
|
-
if (!this.buildProcess) {
|
|
230
|
-
resolve();
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
const proc = this.buildProcess;
|
|
234
|
-
this.buildProcess = null;
|
|
235
|
-
const cleanup = () => {
|
|
236
|
-
if (!this.options.quiet) {
|
|
237
|
-
logger_manager_js_1.loggerManager.printLine(`${chalk_1.default.yellow(figures_1.default.square)} Build process stopped`, 'info');
|
|
238
|
-
}
|
|
239
|
-
resolve();
|
|
240
|
-
};
|
|
241
|
-
proc.on('exit', cleanup);
|
|
242
|
-
proc.on('error', cleanup);
|
|
243
|
-
try {
|
|
244
|
-
if (proc.pid) {
|
|
245
|
-
// Kill process group
|
|
246
|
-
process.kill(-proc.pid, 'SIGTERM');
|
|
247
|
-
// Fallback after timeout
|
|
248
|
-
setTimeout(() => {
|
|
249
|
-
if (proc.pid && !proc.killed) {
|
|
250
|
-
try {
|
|
251
|
-
process.kill(-proc.pid, 'SIGKILL');
|
|
252
|
-
}
|
|
253
|
-
catch (e) {
|
|
254
|
-
// Ignore
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}, 3000);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
catch (error) {
|
|
261
|
-
// Process might already be dead
|
|
262
|
-
cleanup();
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
formatBytes(bytes) {
|
|
267
|
-
if (bytes === 0)
|
|
268
|
-
return '0 Bytes';
|
|
269
|
-
const k = 1024;
|
|
270
|
-
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
271
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
272
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
|
273
|
-
}
|
|
274
|
-
setupWatcher() {
|
|
275
|
-
const watchPatterns = [
|
|
276
|
-
`${this.options.source}/**/*.ts`,
|
|
277
|
-
`${this.options.source}/**/*.tsx`,
|
|
278
|
-
`${this.options.source}/**/*.js`,
|
|
279
|
-
`${this.options.source}/**/*.jsx`,
|
|
280
|
-
this.options.tsconfig,
|
|
281
|
-
];
|
|
282
|
-
this.watcher = (0, chokidar_1.watch)(watchPatterns, {
|
|
283
|
-
ignoreInitial: true,
|
|
284
|
-
followSymlinks: false,
|
|
285
|
-
usePolling: false,
|
|
286
|
-
atomic: 200,
|
|
287
|
-
ignored: [
|
|
288
|
-
'**/node_modules/**',
|
|
289
|
-
'**/.git/**',
|
|
290
|
-
`**/${this.options.output}/**`,
|
|
291
|
-
'**/*.log',
|
|
292
|
-
'**/*.map',
|
|
293
|
-
],
|
|
294
|
-
});
|
|
295
|
-
this.watcher.on('change', (filePath) => {
|
|
296
|
-
if (this.options.verbose) {
|
|
297
|
-
logger_manager_js_1.loggerManager.printLine(`File changed: ${path_1.default.relative(process.cwd(), filePath)}`, 'info');
|
|
298
|
-
}
|
|
299
|
-
this.debouncedBuild();
|
|
300
|
-
});
|
|
301
|
-
this.watcher.on('add', (filePath) => {
|
|
302
|
-
if (this.options.verbose) {
|
|
303
|
-
logger_manager_js_1.loggerManager.printLine(`File added: ${path_1.default.relative(process.cwd(), filePath)}`, 'info');
|
|
304
|
-
}
|
|
305
|
-
this.debouncedBuild();
|
|
306
|
-
});
|
|
307
|
-
this.watcher.on('unlink', (filePath) => {
|
|
308
|
-
if (this.options.verbose) {
|
|
309
|
-
logger_manager_js_1.loggerManager.printLine(`File removed: ${path_1.default.relative(process.cwd(), filePath)}`, 'info');
|
|
310
|
-
}
|
|
311
|
-
this.debouncedBuild();
|
|
312
|
-
});
|
|
313
|
-
this.watcher.on('error', (error) => {
|
|
314
|
-
logger_manager_js_1.loggerManager.printLine(`Watcher error: ${error.message}`, 'error');
|
|
315
|
-
});
|
|
316
|
-
if (this.options.verbose) {
|
|
317
|
-
logger_manager_js_1.loggerManager.printLine(`Watching: ${watchPatterns.join(', ')}`, 'info');
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
debouncedBuild = this.debounce(this.runBuild.bind(this), 300);
|
|
321
|
-
debounce(func, wait) {
|
|
322
|
-
let timeout;
|
|
323
|
-
return function executedFunction(...args) {
|
|
324
|
-
const later = () => {
|
|
325
|
-
clearTimeout(timeout);
|
|
326
|
-
func(...args);
|
|
327
|
-
};
|
|
328
|
-
clearTimeout(timeout);
|
|
329
|
-
timeout = setTimeout(later, wait);
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
async build() {
|
|
333
|
-
// Check if source directory exists
|
|
334
|
-
if (!(0, fs_1.existsSync)(this.options.source)) {
|
|
335
|
-
throw new Error(`Source directory not found: ${this.options.source}`);
|
|
336
|
-
}
|
|
337
|
-
try {
|
|
338
|
-
await this.validateTsConfig();
|
|
339
|
-
await this.cleanOutputDirectory();
|
|
340
|
-
await this.runBuild();
|
|
341
|
-
if (this.options.watch) {
|
|
342
|
-
this.setupWatcher();
|
|
343
|
-
if (!this.options.quiet) {
|
|
344
|
-
logger_manager_js_1.loggerManager.printLine(`${chalk_1.default.blue(figures_1.default.info)} Watching for changes...`, 'info');
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
catch (error) {
|
|
349
|
-
logger_manager_js_1.loggerManager.printLine(error.message, 'error');
|
|
350
|
-
if (!this.options.watch) {
|
|
351
|
-
process.exit(1);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
async stop() {
|
|
356
|
-
if (!this.options.quiet) {
|
|
357
|
-
logger_manager_js_1.loggerManager.printLine(`${chalk_1.default.yellow('⏹')} Stopping build process...`, 'info');
|
|
358
|
-
}
|
|
359
|
-
if (this.watcher) {
|
|
360
|
-
await this.watcher.close();
|
|
361
|
-
this.watcher = null;
|
|
362
|
-
}
|
|
363
|
-
await this.stopProcess();
|
|
364
|
-
if (this.buildCount > 0 && !this.options.quiet) {
|
|
365
|
-
logger_manager_js_1.loggerManager.printLine(`${chalk_1.default.blue('ℹ')} Build process stopped after ${this.buildCount} build(s).`, 'info');
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
exports.BuildManager = BuildManager;
|
package/dist/src/cli.d.ts
DELETED
package/dist/src/cli.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAgBA,MAAM,CAAC,OAAO,UAAU,GAAG,IAAI,IAAI,CAoFlC"}
|
package/dist/src/cli.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
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.default = cli;
|
|
7
|
-
// src/cli.ts - Main CLI file (refactored)
|
|
8
|
-
const commander_1 = require("commander");
|
|
9
|
-
const index_js_1 = require("./commands/index.js");
|
|
10
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
-
const figures_1 = __importDefault(require("figures"));
|
|
12
|
-
const { version } = require('../../package.json');
|
|
13
|
-
function cli() {
|
|
14
|
-
const args = process.argv.slice(2);
|
|
15
|
-
// Handle the 'init' command as a special case before anything else.
|
|
16
|
-
// This makes 'neex' and 'neex init' act as aliases for 'npx create-neex'.
|
|
17
|
-
if (args.length === 0 || args[0] === 'init') {
|
|
18
|
-
const initArgs = args.slice(1); // Get all arguments after 'init'
|
|
19
|
-
(0, index_js_1.runInit)(initArgs);
|
|
20
|
-
return; // Exit early, do not proceed with the rest of the CLI
|
|
21
|
-
}
|
|
22
|
-
const program = new commander_1.Command();
|
|
23
|
-
// Initialize cleanup handlers
|
|
24
|
-
const cleanupHandlers = [];
|
|
25
|
-
program
|
|
26
|
-
.name('neex')
|
|
27
|
-
.description('Professional script runner with nodemon and PM2 functionality')
|
|
28
|
-
.version(version);
|
|
29
|
-
// Add plugin command
|
|
30
|
-
program
|
|
31
|
-
.command('add <plugin>')
|
|
32
|
-
.description('Add a plugin to the project')
|
|
33
|
-
.action(async (plugin) => {
|
|
34
|
-
await (0, index_js_1.addPlugin)(plugin);
|
|
35
|
-
});
|
|
36
|
-
// Add all other command groups
|
|
37
|
-
(0, index_js_1.addRunCommands)(program);
|
|
38
|
-
(0, index_js_1.addServerCommands)(program);
|
|
39
|
-
const devCommands = (0, index_js_1.addDevCommands)(program);
|
|
40
|
-
cleanupHandlers.push(devCommands.cleanupDev);
|
|
41
|
-
const buildCommands = (0, index_js_1.addBuildCommands)(program);
|
|
42
|
-
cleanupHandlers.push(buildCommands.cleanupBuild);
|
|
43
|
-
const startCommands = (0, index_js_1.addStartCommands)(program);
|
|
44
|
-
cleanupHandlers.push(startCommands.cleanupStart);
|
|
45
|
-
program.parse(process.argv);
|
|
46
|
-
// Show help if no commands specified
|
|
47
|
-
if (program.args.length === 0) {
|
|
48
|
-
program.help();
|
|
49
|
-
}
|
|
50
|
-
// Graceful shutdown handling
|
|
51
|
-
const handleSignal = async (signal) => {
|
|
52
|
-
console.log(`\n${chalk_1.default.yellow(`${figures_1.default.warning} Received ${signal}. Cleaning up...`)}`);
|
|
53
|
-
// Run all cleanup handlers
|
|
54
|
-
for (const cleanup of cleanupHandlers) {
|
|
55
|
-
try {
|
|
56
|
-
await cleanup();
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
console.error(`Cleanup error:`, error);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
setTimeout(() => process.exit(0), 500);
|
|
63
|
-
};
|
|
64
|
-
process.on('SIGINT', () => handleSignal('SIGINT').catch(err => console.error('SIGINT handler error:', err)));
|
|
65
|
-
process.on('SIGTERM', () => handleSignal('SIGTERM').catch(err => console.error('SIGTERM handler error:', err)));
|
|
66
|
-
process.on('SIGQUIT', () => handleSignal('SIGQUIT').catch(err => console.error('SIGQUIT handler error:', err)));
|
|
67
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"add-commands.d.ts","sourceRoot":"","sources":["../../../src/commands/add-commands.ts"],"names":[],"mappings":"AAKA,wBAAsB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,iBA6EjF"}
|
|
@@ -1,83 +0,0 @@
|
|
|
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.addPlugin = addPlugin;
|
|
7
|
-
const child_process_1 = require("child_process");
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const fs_1 = __importDefault(require("fs"));
|
|
11
|
-
async function addPlugin(pluginName, options = {}) {
|
|
12
|
-
const projectPath = options.cwd || process.cwd();
|
|
13
|
-
console.log(chalk_1.default.blue(`📦 Installing ${pluginName}...`));
|
|
14
|
-
try {
|
|
15
|
-
// Check if package.json exists
|
|
16
|
-
const packageJsonPath = path_1.default.join(projectPath, 'package.json');
|
|
17
|
-
if (!fs_1.default.existsSync(packageJsonPath)) {
|
|
18
|
-
throw new Error('package.json not found. Make sure you are in a valid project directory.');
|
|
19
|
-
}
|
|
20
|
-
// Detect package manager and install
|
|
21
|
-
let installCommand = `npm install ${pluginName}`;
|
|
22
|
-
// Check if bun.lock exists (prefer bun)
|
|
23
|
-
if (fs_1.default.existsSync(path_1.default.join(projectPath, 'bun.lock'))) {
|
|
24
|
-
installCommand = `bun add ${pluginName}`;
|
|
25
|
-
}
|
|
26
|
-
else if (fs_1.default.existsSync(path_1.default.join(projectPath, 'pnpm-lock.yaml'))) {
|
|
27
|
-
installCommand = `pnpm add ${pluginName}`;
|
|
28
|
-
}
|
|
29
|
-
else if (fs_1.default.existsSync(path_1.default.join(projectPath, 'yarn.lock'))) {
|
|
30
|
-
installCommand = `yarn add ${pluginName}`;
|
|
31
|
-
}
|
|
32
|
-
console.log(chalk_1.default.dim(`Running: ${installCommand}`));
|
|
33
|
-
(0, child_process_1.execSync)(installCommand, {
|
|
34
|
-
stdio: 'inherit',
|
|
35
|
-
cwd: projectPath
|
|
36
|
-
});
|
|
37
|
-
// Handle specific plugins
|
|
38
|
-
if (pluginName === 'neex-admin') {
|
|
39
|
-
console.log(chalk_1.default.blue('🔧 Initializing admin panel...'));
|
|
40
|
-
try {
|
|
41
|
-
// Import and run the admin init function
|
|
42
|
-
const adminModule = require('neex-admin');
|
|
43
|
-
if (adminModule.initAdmin) {
|
|
44
|
-
await adminModule.initAdmin(projectPath);
|
|
45
|
-
}
|
|
46
|
-
console.log(chalk_1.default.green('✅ Admin panel added successfully!'));
|
|
47
|
-
console.log(chalk_1.default.yellow('💡 Run "npm run admin:dev" to start the admin panel'));
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
console.log(chalk_1.default.yellow('⚠️ Admin plugin installed, manual setup required'));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
// Try to find and run plugin's init function
|
|
55
|
-
try {
|
|
56
|
-
const pluginPath = path_1.default.join(projectPath, 'node_modules', pluginName);
|
|
57
|
-
const plugin = require(pluginPath);
|
|
58
|
-
if (plugin.init && typeof plugin.init === 'function') {
|
|
59
|
-
await plugin.init(projectPath);
|
|
60
|
-
console.log(chalk_1.default.green(`✅ ${pluginName} initialized successfully!`));
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
console.log(chalk_1.default.green(`✅ ${pluginName} installed successfully!`));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
console.log(chalk_1.default.green(`✅ ${pluginName} installed successfully!`));
|
|
68
|
-
console.log(chalk_1.default.yellow('⚠️ No initialization function found'));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
console.error(chalk_1.default.red(`❌ Failed to install ${pluginName}`));
|
|
74
|
-
if (error instanceof Error) {
|
|
75
|
-
console.error(chalk_1.default.red(error.message));
|
|
76
|
-
}
|
|
77
|
-
// Try manual installation suggestion
|
|
78
|
-
console.log(chalk_1.default.yellow('💡 Try manual installation:'));
|
|
79
|
-
console.log(chalk_1.default.dim(` bun add ${pluginName}`));
|
|
80
|
-
console.log(chalk_1.default.dim(` # or npm install ${pluginName}`));
|
|
81
|
-
process.exit(1);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-commands.d.ts","sourceRoot":"","sources":["../../../src/commands/build-commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG;IAClD,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B,CAwJA"}
|