neex 0.6.71 → 0.6.72
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/dist/src/cli.js +2 -7
- package/dist/src/commands/init-commands.js +54 -23
- package/package.json +1 -1
package/dist/src/cli.js
CHANGED
|
@@ -11,12 +11,6 @@ const figures_1 = __importDefault(require("figures"));
|
|
|
11
11
|
const { version } = require('../../package.json');
|
|
12
12
|
function cli() {
|
|
13
13
|
const program = new commander_1.Command();
|
|
14
|
-
// Special handling for the 'init' command to avoid conflicts
|
|
15
|
-
if (process.argv[2] === 'init') {
|
|
16
|
-
(0, index_js_1.addInitCommand)(program);
|
|
17
|
-
program.parse(process.argv);
|
|
18
|
-
return; // Exit early
|
|
19
|
-
}
|
|
20
14
|
// Initialize cleanup handlers
|
|
21
15
|
const cleanupHandlers = [];
|
|
22
16
|
program
|
|
@@ -24,7 +18,7 @@ function cli() {
|
|
|
24
18
|
.description('Professional script runner with nodemon and PM2 functionality')
|
|
25
19
|
.version(version);
|
|
26
20
|
// Add all command groups
|
|
27
|
-
(0, index_js_1.addInitCommand)(program);
|
|
21
|
+
(0, index_js_1.addInitCommand)(program);
|
|
28
22
|
(0, index_js_1.addRunCommands)(program);
|
|
29
23
|
(0, index_js_1.addServerCommands)(program);
|
|
30
24
|
const devCommands = (0, index_js_1.addDevCommands)(program);
|
|
@@ -33,6 +27,7 @@ function cli() {
|
|
|
33
27
|
cleanupHandlers.push(buildCommands.cleanupBuild);
|
|
34
28
|
const startCommands = (0, index_js_1.addStartCommands)(program);
|
|
35
29
|
cleanupHandlers.push(startCommands.cleanupStart);
|
|
30
|
+
// Parse arguments
|
|
36
31
|
program.parse(process.argv);
|
|
37
32
|
// Show help if no commands specified
|
|
38
33
|
if (program.args.length === 0) {
|
|
@@ -9,30 +9,61 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
9
9
|
const figures_1 = __importDefault(require("figures"));
|
|
10
10
|
function addInitCommand(program) {
|
|
11
11
|
program
|
|
12
|
-
.command('init [
|
|
13
|
-
.description('Initialize a new neex project
|
|
14
|
-
.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
12
|
+
.command('init [project-name]')
|
|
13
|
+
.description('Initialize a new neex project (alias for npx create-neex)')
|
|
14
|
+
.option('-d, --debug', 'Enable debug mode to see detailed logs')
|
|
15
|
+
.option('--version', 'Check CLI version')
|
|
16
|
+
.action((projectName, options) => {
|
|
17
|
+
try {
|
|
18
|
+
console.log(chalk_1.default.green(`${figures_1.default.pointer} Running npx create-neex...`));
|
|
19
|
+
const args = ['create-neex@latest'];
|
|
20
|
+
// Add project name if provided
|
|
21
|
+
if (projectName) {
|
|
22
|
+
args.push(projectName);
|
|
23
|
+
}
|
|
24
|
+
// Add debug flag if specified
|
|
25
|
+
if (options === null || options === void 0 ? void 0 : options.debug) {
|
|
26
|
+
args.push('--debug');
|
|
27
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} Debug: Running command: npx ${args.join(' ')}`));
|
|
28
|
+
}
|
|
29
|
+
// Add version flag if specified
|
|
30
|
+
if (options === null || options === void 0 ? void 0 : options.version) {
|
|
31
|
+
args.push('--version');
|
|
30
32
|
}
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
// Use spawn to execute the command and stream the output
|
|
34
|
+
const child = (0, child_process_1.spawn)('npx', args, {
|
|
35
|
+
stdio: 'inherit',
|
|
36
|
+
shell: true,
|
|
37
|
+
cwd: process.cwd() // Use current working directory
|
|
38
|
+
});
|
|
39
|
+
child.on('close', (code) => {
|
|
40
|
+
if (code !== 0) {
|
|
41
|
+
console.error(chalk_1.default.red(`${figures_1.default.cross} Error initializing project. 'npx create-neex' exited with code ${code}`));
|
|
42
|
+
process.exit(code !== null && code !== void 0 ? code : 1);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
console.log(chalk_1.default.green(`${figures_1.default.tick} Project initialized successfully!`));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
child.on('error', (error) => {
|
|
49
|
+
console.error(chalk_1.default.red(`${figures_1.default.cross} Failed to start command: ${error.message}`));
|
|
50
|
+
console.error(chalk_1.default.yellow(`${figures_1.default.warning} Make sure you have npm/npx installed and accessible`));
|
|
51
|
+
process.exit(1);
|
|
52
|
+
});
|
|
53
|
+
// Handle process termination
|
|
54
|
+
process.on('SIGINT', () => {
|
|
55
|
+
console.log(chalk_1.default.yellow(`\n${figures_1.default.warning} Interrupting initialization...`));
|
|
56
|
+
child.kill('SIGINT');
|
|
57
|
+
});
|
|
58
|
+
process.on('SIGTERM', () => {
|
|
59
|
+
console.log(chalk_1.default.yellow(`\n${figures_1.default.warning} Terminating initialization...`));
|
|
60
|
+
child.kill('SIGTERM');
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
console.error(chalk_1.default.red(`${figures_1.default.cross} Unexpected error: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
36
67
|
});
|
|
37
68
|
}
|
|
38
69
|
exports.addInitCommand = addInitCommand;
|