cskit-cli 1.0.40 → 1.0.43
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/package.json +1 -1
- package/src/commands/init.js +123 -116
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -377,7 +377,8 @@ async function initCommand(options) {
|
|
|
377
377
|
timeline.addStep('Scan changes');
|
|
378
378
|
timeline.addStep('Confirm changes');
|
|
379
379
|
timeline.addStep('Apply changes');
|
|
380
|
-
timeline.addStep('
|
|
380
|
+
timeline.addStep('Check dependencies');
|
|
381
|
+
timeline.addStep('Install packages');
|
|
381
382
|
|
|
382
383
|
// Step 1: Authenticate
|
|
383
384
|
timeline.start(0);
|
|
@@ -546,6 +547,7 @@ async function initCommand(options) {
|
|
|
546
547
|
timeline.skip(4, 'User cancelled');
|
|
547
548
|
timeline.skip(5, 'Skipped');
|
|
548
549
|
timeline.skip(6, 'Skipped');
|
|
550
|
+
timeline.skip(7, 'Skipped');
|
|
549
551
|
|
|
550
552
|
// Cleanup
|
|
551
553
|
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
@@ -607,111 +609,61 @@ async function initCommand(options) {
|
|
|
607
609
|
|
|
608
610
|
timeline.complete(5, `${applied} files`);
|
|
609
611
|
|
|
610
|
-
//
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
// Helper function to install Python packages
|
|
616
|
-
async function handlePythonPackages(pythonCmd) {
|
|
617
|
-
if (!fs.existsSync(libPythonDir)) {
|
|
618
|
-
timeline.skip(6, 'No lib/python folder');
|
|
619
|
-
return;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
timeline.pause();
|
|
623
|
-
const { installAdvanced } = await inquirer.prompt([{
|
|
624
|
-
type: 'confirm',
|
|
625
|
-
name: 'installAdvanced',
|
|
626
|
-
message: 'Install Python dependencies?',
|
|
627
|
-
default: true
|
|
628
|
-
}]);
|
|
629
|
-
|
|
630
|
-
if (!installAdvanced) {
|
|
631
|
-
timeline.resume();
|
|
632
|
-
timeline.skip(6, 'Skipped by user');
|
|
633
|
-
return;
|
|
634
|
-
}
|
|
635
|
-
timeline.resume();
|
|
636
|
-
|
|
637
|
-
const pkgStatus = checkPythonPackages(libPythonDir);
|
|
638
|
-
|
|
639
|
-
// Show Python version in timeline
|
|
640
|
-
timeline.addChild(6, `Python ${pythonCmd === 'python3' ? pythonInfo.version : '3.x'} (${pythonCmd})`, 'update');
|
|
641
|
-
|
|
642
|
-
// Show already installed count
|
|
643
|
-
if (pkgStatus.installed.length > 0) {
|
|
644
|
-
timeline.addChild(6, `${pkgStatus.installed.length} packages already installed`, 'info');
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
const allToInstall = [...pkgStatus.toInstall, ...pkgStatus.toUpdate];
|
|
612
|
+
// Create .env from .env.example if not exists
|
|
613
|
+
const envPath = path.join(projectDir, '.claude', '.env');
|
|
614
|
+
const envExamplePath = path.join(projectDir, '.claude', '.env.example');
|
|
615
|
+
let envCreated = false;
|
|
648
616
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
617
|
+
if (!fs.existsSync(envPath) && fs.existsSync(envExamplePath)) {
|
|
618
|
+
fs.copyFileSync(envExamplePath, envPath);
|
|
619
|
+
envCreated = true;
|
|
620
|
+
}
|
|
653
621
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
console.log(` ${branch} ${chalk.cyan('Packages to install/update:')}`);
|
|
622
|
+
// Step 7: Check dependencies
|
|
623
|
+
timeline.start(6);
|
|
657
624
|
|
|
658
|
-
|
|
659
|
-
const hasMore = allToInstall.length > 10;
|
|
625
|
+
const libPythonDir = path.join(projectDir, 'lib', 'python');
|
|
660
626
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
627
|
+
// Check if lib/python exists
|
|
628
|
+
if (!fs.existsSync(libPythonDir)) {
|
|
629
|
+
timeline.addChild(6, 'No lib/python folder', 'skip');
|
|
630
|
+
timeline.complete(6, 'Skipped');
|
|
631
|
+
timeline.skip(7, 'No dependencies');
|
|
632
|
+
|
|
633
|
+
// Cleanup and finish
|
|
634
|
+
try { fs.rmSync(tempDir, { recursive: true, force: true }); } catch {}
|
|
635
|
+
const ver = selectedVersion.replace(/^v/, '');
|
|
636
|
+
console.log(chalk.green(`\n ✓ CSK v${ver} ${isUpdate ? 'updated' : 'installed'} successfully!\n`));
|
|
637
|
+
|
|
638
|
+
if (envCreated) {
|
|
639
|
+
console.log(chalk.yellow(' ⚠ Configuration needed:\n'));
|
|
640
|
+
console.log(chalk.dim(' Edit .claude/.env and set:'));
|
|
641
|
+
console.log(` ${chalk.white('CSK_OUTPUT_DIR')} - Output folder for reports`);
|
|
642
|
+
console.log(` ${chalk.white('GEMINI_API_KEY')} - For AI features (optional)\n`);
|
|
670
643
|
}
|
|
671
|
-
if (hasMore) {
|
|
672
|
-
console.log(` ${pipe} ${corner} ${chalk.dim(`... and ${allToInstall.length - 10} more`)}`);
|
|
673
|
-
}
|
|
674
|
-
console.log(` ${pipe}`);
|
|
675
|
-
|
|
676
|
-
timeline.pause();
|
|
677
|
-
const { confirmPkgs } = await inquirer.prompt([{
|
|
678
|
-
type: 'confirm',
|
|
679
|
-
name: 'confirmPkgs',
|
|
680
|
-
message: `Install/update ${allToInstall.length} packages?`,
|
|
681
|
-
default: true
|
|
682
|
-
}]);
|
|
683
|
-
timeline.resume();
|
|
684
644
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
645
|
+
console.log(chalk.cyan(' Quick Start\n'));
|
|
646
|
+
console.log(chalk.dim(' 1. Open Claude Code:'));
|
|
647
|
+
console.log(` ${chalk.white('claude')}\n`);
|
|
648
|
+
console.log(chalk.dim(' 2. Start with CSK:'));
|
|
649
|
+
console.log(` ${chalk.white('/csk')}\n`);
|
|
650
|
+
return;
|
|
691
651
|
}
|
|
692
652
|
|
|
693
|
-
// Check Python availability
|
|
653
|
+
// Check Python availability
|
|
694
654
|
let pythonInfo = detectPython();
|
|
695
655
|
let pythonReady = false;
|
|
696
656
|
|
|
697
657
|
if (!pythonInfo.found) {
|
|
698
|
-
|
|
699
|
-
console.log(chalk.yellow(' Python not found on this system.'));
|
|
700
|
-
console.log(chalk.dim(' Python is required for:'));
|
|
701
|
-
console.log(chalk.dim(' - Data fetching and analysis'));
|
|
702
|
-
console.log(chalk.dim(' - Chart generation'));
|
|
703
|
-
console.log(chalk.dim(' - MCP server tools'));
|
|
704
|
-
console.log('');
|
|
658
|
+
timeline.addChild(6, 'Python not found', 'skip');
|
|
705
659
|
|
|
706
660
|
// Check if we can auto-install
|
|
707
661
|
const autoInstall = canAutoInstall();
|
|
708
662
|
|
|
709
663
|
if (autoInstall.canInstall) {
|
|
664
|
+
console.log('');
|
|
665
|
+
console.log(chalk.yellow(' Python not found on this system.'));
|
|
710
666
|
console.log(chalk.cyan(` Auto-install available via ${autoInstall.manager}`));
|
|
711
|
-
if (autoInstall.needsSudo) {
|
|
712
|
-
console.log(chalk.dim(' (requires sudo password)'));
|
|
713
|
-
}
|
|
714
|
-
console.log(chalk.dim(` Command: ${autoInstall.command}`));
|
|
715
667
|
console.log('');
|
|
716
668
|
|
|
717
669
|
timeline.pause();
|
|
@@ -724,11 +676,9 @@ async function initCommand(options) {
|
|
|
724
676
|
timeline.resume();
|
|
725
677
|
|
|
726
678
|
if (doInstall) {
|
|
727
|
-
console.log('');
|
|
728
679
|
timeline.addChild(6, `Installing via ${autoInstall.manager}...`, 'update');
|
|
729
|
-
|
|
730
680
|
const result = await installPython((msg) => {
|
|
731
|
-
console.log(chalk.dim(`
|
|
681
|
+
console.log(chalk.dim(` ${msg}`));
|
|
732
682
|
});
|
|
733
683
|
|
|
734
684
|
if (result.success) {
|
|
@@ -736,43 +686,92 @@ async function initCommand(options) {
|
|
|
736
686
|
timeline.addChild(6, `Python ${result.version} installed`, 'new');
|
|
737
687
|
pythonReady = true;
|
|
738
688
|
} else {
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
console.log('');
|
|
743
|
-
timeline.skip(6, 'Installation failed');
|
|
689
|
+
timeline.addChild(6, 'Installation failed', 'skip');
|
|
690
|
+
timeline.complete(6, 'Failed');
|
|
691
|
+
timeline.skip(7, 'No Python');
|
|
744
692
|
}
|
|
745
693
|
} else {
|
|
746
|
-
timeline.
|
|
694
|
+
timeline.complete(6, 'Skipped');
|
|
695
|
+
timeline.skip(7, 'No Python');
|
|
747
696
|
}
|
|
748
697
|
} else {
|
|
749
|
-
//
|
|
698
|
+
// Show manual instructions
|
|
750
699
|
const instructions = getInstallInstructions();
|
|
751
|
-
console.log(chalk.bold(` Install via ${instructions.method}:\n`));
|
|
752
|
-
for (const cmd of instructions.commands.slice(0, 4)) {
|
|
753
|
-
if (cmd.startsWith('#')) {
|
|
754
|
-
console.log(chalk.dim(` ${cmd}`));
|
|
755
|
-
} else if (cmd !== '') {
|
|
756
|
-
console.log(chalk.cyan(` ${cmd}`));
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
700
|
console.log('');
|
|
760
|
-
|
|
701
|
+
console.log(chalk.yellow(' Python not found. Install via:'));
|
|
702
|
+
console.log(chalk.cyan(` ${instructions.commands[0]}`));
|
|
703
|
+
console.log('');
|
|
704
|
+
timeline.complete(6, 'Python needed');
|
|
705
|
+
timeline.skip(7, 'No Python');
|
|
761
706
|
}
|
|
762
707
|
} else if (!pythonInfo.meetsMinimum) {
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
console.log('');
|
|
767
|
-
timeline.skip(6, `Python ${pythonInfo.version} too old`);
|
|
708
|
+
timeline.addChild(6, `Python ${pythonInfo.version} (need 3.8+)`, 'skip');
|
|
709
|
+
timeline.complete(6, 'Upgrade needed');
|
|
710
|
+
timeline.skip(7, 'Python too old');
|
|
768
711
|
} else {
|
|
769
712
|
pythonReady = true;
|
|
713
|
+
timeline.addChild(6, `Python ${pythonInfo.version}`, 'info');
|
|
770
714
|
}
|
|
771
715
|
|
|
772
|
-
//
|
|
773
|
-
if (pythonReady
|
|
774
|
-
|
|
775
|
-
|
|
716
|
+
// If Python not ready, exit early
|
|
717
|
+
if (!pythonReady) {
|
|
718
|
+
try { fs.rmSync(tempDir, { recursive: true, force: true }); } catch {}
|
|
719
|
+
const ver = selectedVersion.replace(/^v/, '');
|
|
720
|
+
console.log(chalk.green(`\n ✓ CSK v${ver} ${isUpdate ? 'updated' : 'installed'} successfully!\n`));
|
|
721
|
+
console.log(chalk.dim(' Note: Python dependencies not installed.\n'));
|
|
722
|
+
|
|
723
|
+
if (envCreated) {
|
|
724
|
+
console.log(chalk.yellow(' ⚠ Configuration needed:\n'));
|
|
725
|
+
console.log(chalk.dim(' Edit .claude/.env and set:'));
|
|
726
|
+
console.log(` ${chalk.white('CSK_OUTPUT_DIR')} - Output folder for reports`);
|
|
727
|
+
console.log(` ${chalk.white('GEMINI_API_KEY')} - For AI features (optional)\n`);
|
|
728
|
+
}
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
// Check packages
|
|
733
|
+
const pkgStatus = checkPythonPackages(libPythonDir);
|
|
734
|
+
const allToInstall = [...pkgStatus.toInstall, ...pkgStatus.toUpdate];
|
|
735
|
+
|
|
736
|
+
if (pkgStatus.installed.length > 0) {
|
|
737
|
+
timeline.addChild(6, `${pkgStatus.installed.length} packages OK`, 'info');
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
if (allToInstall.length === 0) {
|
|
741
|
+
timeline.complete(6, 'All ready');
|
|
742
|
+
timeline.skip(7, 'Nothing to install');
|
|
743
|
+
} else {
|
|
744
|
+
// Show packages to install/update
|
|
745
|
+
for (const pkg of allToInstall.slice(0, 5)) {
|
|
746
|
+
if (pkg.current) {
|
|
747
|
+
timeline.addChild(6, `${pkg.name}: ${pkg.current} → ${pkg.required}`, 'update');
|
|
748
|
+
} else {
|
|
749
|
+
timeline.addChild(6, `${pkg.name}: ${pkg.required || 'latest'}`, 'new');
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
if (allToInstall.length > 5) {
|
|
753
|
+
timeline.addChild(6, `... and ${allToInstall.length - 5} more`, 'info');
|
|
754
|
+
}
|
|
755
|
+
timeline.complete(6, `${allToInstall.length} to install`);
|
|
756
|
+
|
|
757
|
+
// Step 8: Install packages
|
|
758
|
+
timeline.start(7);
|
|
759
|
+
|
|
760
|
+
timeline.pause();
|
|
761
|
+
const { confirmPkgs } = await inquirer.prompt([{
|
|
762
|
+
type: 'confirm',
|
|
763
|
+
name: 'confirmPkgs',
|
|
764
|
+
message: `Install ${allToInstall.length} packages?`,
|
|
765
|
+
default: true
|
|
766
|
+
}]);
|
|
767
|
+
timeline.resume();
|
|
768
|
+
|
|
769
|
+
if (confirmPkgs) {
|
|
770
|
+
await installPackages(libPythonDir, allToInstall, timeline, 7, pythonInfo.command);
|
|
771
|
+
timeline.complete(7, `${pkgStatus.installed.length + allToInstall.length} packages`);
|
|
772
|
+
} else {
|
|
773
|
+
timeline.skip(7, 'Skipped');
|
|
774
|
+
}
|
|
776
775
|
}
|
|
777
776
|
|
|
778
777
|
// Cleanup temp files
|
|
@@ -784,6 +783,14 @@ async function initCommand(options) {
|
|
|
784
783
|
const ver = selectedVersion.replace(/^v/, '');
|
|
785
784
|
console.log(chalk.green(`\n ✓ CSK v${ver} ${isUpdate ? 'updated' : 'installed'} successfully!\n`));
|
|
786
785
|
|
|
786
|
+
// Show .env reminder if created
|
|
787
|
+
if (envCreated) {
|
|
788
|
+
console.log(chalk.yellow(' ⚠ Configuration needed:\n'));
|
|
789
|
+
console.log(chalk.dim(' Edit .claude/.env and set:'));
|
|
790
|
+
console.log(` ${chalk.white('CSK_OUTPUT_DIR')} - Output folder for reports`);
|
|
791
|
+
console.log(` ${chalk.white('GEMINI_API_KEY')} - For AI features (optional)\n`);
|
|
792
|
+
}
|
|
793
|
+
|
|
787
794
|
console.log(chalk.cyan(' Quick Start\n'));
|
|
788
795
|
console.log(chalk.dim(' 1. Open Claude Code:'));
|
|
789
796
|
console.log(` ${chalk.white('claude')}\n`);
|