vg-coder-cli 2.0.0 → 2.0.1

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +56 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vg-coder-cli",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "🚀 CLI tool to analyze projects, concatenate source files, count tokens, and export HTML with syntax highlighting. Now with modern NestJS API and Angular dashboard!",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -66,6 +66,7 @@ class VGCoderCLI {
66
66
  .alias('s')
67
67
  .description('Khởi động API server')
68
68
  .option('-p, --port <port>', 'Port cho server', '6868')
69
+ .option('--new', 'Khởi động NestJS/Angular stack (modern)')
69
70
  .action(this.handleStart.bind(this));
70
71
  }
71
72
 
@@ -372,6 +373,61 @@ class VGCoderCLI {
372
373
  */
373
374
  async handleStart(options) {
374
375
  try {
376
+ // Check if --new flag is set
377
+ if (options.new) {
378
+ console.log(chalk.blue('🚀 Starting NestJS/Angular stack...'));
379
+ console.log(chalk.yellow('This will start both API (port 3000) and Angular (port 4200)'));
380
+ console.log('');
381
+
382
+ // Check if vg directory exists
383
+ const vgPath = path.join(__dirname, '..', 'vg');
384
+ if (!await fs.pathExists(vgPath)) {
385
+ throw new Error('VG workspace not found. Make sure you have the complete package installed.');
386
+ }
387
+
388
+ // Check if start-dev.sh exists
389
+ const startScript = path.join(vgPath, 'start-dev.sh');
390
+ if (!await fs.pathExists(startScript)) {
391
+ throw new Error('start-dev.sh not found in vg directory.');
392
+ }
393
+
394
+ // Execute start-dev.sh
395
+ const { spawn } = require('child_process');
396
+ const child = spawn('bash', [startScript], {
397
+ cwd: vgPath,
398
+ stdio: 'inherit'
399
+ });
400
+
401
+ child.on('error', (error) => {
402
+ console.error(chalk.red('Failed to start:'), error.message);
403
+ process.exit(1);
404
+ });
405
+
406
+ child.on('exit', (code) => {
407
+ if (code !== 0) {
408
+ console.error(chalk.red(`Process exited with code ${code}`));
409
+ process.exit(code);
410
+ }
411
+ });
412
+
413
+ // Handle graceful shutdown
414
+ const shutdown = () => {
415
+ console.log(chalk.yellow('\n\nShutting down...'));
416
+ child.kill('SIGTERM');
417
+ process.exit(0);
418
+ };
419
+
420
+ process.on('SIGINT', shutdown);
421
+ process.on('SIGTERM', shutdown);
422
+
423
+ return;
424
+ }
425
+
426
+ // Legacy Express server
427
+ console.log(chalk.blue('🚀 Starting Express server (legacy)...'));
428
+ console.log(chalk.yellow('💡 Tip: Use --new flag to start the modern NestJS/Angular stack'));
429
+ console.log('');
430
+
375
431
  const port = parseInt(options.port);
376
432
  const server = new ApiServer(port);
377
433