cskit-cli 1.0.33 → 1.0.36
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 +51 -24
- package/src/commands/update.js +24 -9
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -457,15 +457,14 @@ async function initCommand(options) {
|
|
|
457
457
|
process.exit(1);
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
timeline.complete(0, 'OK');
|
|
461
|
-
|
|
462
460
|
// Check existing installation
|
|
463
461
|
const manifest = loadManifest(projectDir);
|
|
464
462
|
const isUpdate = manifest.version !== null;
|
|
465
463
|
|
|
466
464
|
if (isUpdate) {
|
|
467
|
-
|
|
465
|
+
timeline.addChild(0, `Current: ${manifest.version}`, 'info');
|
|
468
466
|
}
|
|
467
|
+
timeline.complete(0, 'OK');
|
|
469
468
|
|
|
470
469
|
// Get available versions
|
|
471
470
|
const releases = await getAllReleases(token);
|
|
@@ -483,6 +482,7 @@ async function initCommand(options) {
|
|
|
483
482
|
choices.push({ name: chalk.dim('main branch (dev)'), value: 'main' });
|
|
484
483
|
|
|
485
484
|
timeline.pause(); // Pause before prompt
|
|
485
|
+
console.log(''); // One blank line before prompt
|
|
486
486
|
const answer = await inquirer.prompt([{
|
|
487
487
|
type: 'list',
|
|
488
488
|
name: 'version',
|
|
@@ -496,7 +496,7 @@ async function initCommand(options) {
|
|
|
496
496
|
selectedVersion = latest.tag;
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
-
console.log(chalk.dim(
|
|
499
|
+
console.log(` ${chalk.dim('Installing:')} ${selectedVersion}\n`);
|
|
500
500
|
|
|
501
501
|
// Step 2: Download zip
|
|
502
502
|
timeline.start(1);
|
|
@@ -551,27 +551,46 @@ async function initCommand(options) {
|
|
|
551
551
|
// Step 5: Confirm changes
|
|
552
552
|
timeline.start(4);
|
|
553
553
|
|
|
554
|
+
// Tree connector symbols
|
|
555
|
+
const pipe = chalk.dim('│');
|
|
556
|
+
const branch = chalk.dim('├──');
|
|
557
|
+
const corner = chalk.dim('└──');
|
|
558
|
+
|
|
554
559
|
// Show files that will be changed
|
|
555
560
|
if (changes.update.length > 0) {
|
|
556
|
-
console.log(
|
|
557
|
-
|
|
558
|
-
|
|
561
|
+
console.log(`\n ${pipe}`);
|
|
562
|
+
console.log(` ${branch} ${chalk.yellow('Files to be updated (will overwrite):')}`);
|
|
563
|
+
|
|
564
|
+
const showFiles = changes.update.slice(0, 15);
|
|
565
|
+
const hasMore = changes.update.length > 15;
|
|
566
|
+
|
|
567
|
+
for (let i = 0; i < showFiles.length; i++) {
|
|
568
|
+
const isLast = i === showFiles.length - 1 && !hasMore;
|
|
569
|
+
const prefix = isLast ? corner : branch;
|
|
570
|
+
console.log(` ${pipe} ${prefix} ${chalk.yellow('!')} ${showFiles[i].target}`);
|
|
559
571
|
}
|
|
560
|
-
if (
|
|
561
|
-
console.log(chalk.dim(
|
|
572
|
+
if (hasMore) {
|
|
573
|
+
console.log(` ${pipe} ${corner} ${chalk.dim(`... and ${changes.update.length - 15} more`)}`);
|
|
562
574
|
}
|
|
563
|
-
console.log(
|
|
575
|
+
console.log(` ${pipe}`);
|
|
564
576
|
}
|
|
565
577
|
|
|
566
578
|
if (changes.new.length > 0) {
|
|
567
|
-
console.log(
|
|
568
|
-
|
|
569
|
-
|
|
579
|
+
console.log(`\n ${pipe}`);
|
|
580
|
+
console.log(` ${branch} ${chalk.green('New files to be created:')}`);
|
|
581
|
+
|
|
582
|
+
const showFiles = changes.new.slice(0, 10);
|
|
583
|
+
const hasMore = changes.new.length > 10;
|
|
584
|
+
|
|
585
|
+
for (let i = 0; i < showFiles.length; i++) {
|
|
586
|
+
const isLast = i === showFiles.length - 1 && !hasMore;
|
|
587
|
+
const prefix = isLast ? corner : branch;
|
|
588
|
+
console.log(` ${pipe} ${prefix} ${chalk.green('+')} ${showFiles[i].target}`);
|
|
570
589
|
}
|
|
571
|
-
if (
|
|
572
|
-
console.log(chalk.dim(
|
|
590
|
+
if (hasMore) {
|
|
591
|
+
console.log(` ${pipe} ${corner} ${chalk.dim(`... and ${changes.new.length - 10} more`)}`);
|
|
573
592
|
}
|
|
574
|
-
console.log(
|
|
593
|
+
console.log(` ${pipe}`);
|
|
575
594
|
}
|
|
576
595
|
|
|
577
596
|
// Confirm
|
|
@@ -694,19 +713,27 @@ async function initCommand(options) {
|
|
|
694
713
|
return;
|
|
695
714
|
}
|
|
696
715
|
|
|
697
|
-
// Show what needs to be installed/updated
|
|
698
|
-
console.log(
|
|
699
|
-
|
|
716
|
+
// Show what needs to be installed/updated with tree connector
|
|
717
|
+
console.log(`\n ${pipe}`);
|
|
718
|
+
console.log(` ${branch} ${chalk.cyan('Packages to install/update:')}`);
|
|
719
|
+
|
|
720
|
+
const showPkgs = allToInstall.slice(0, 10);
|
|
721
|
+
const hasMore = allToInstall.length > 10;
|
|
722
|
+
|
|
723
|
+
for (let i = 0; i < showPkgs.length; i++) {
|
|
724
|
+
const pkg = showPkgs[i];
|
|
725
|
+
const isLast = i === showPkgs.length - 1 && !hasMore;
|
|
726
|
+
const prefix = isLast ? corner : branch;
|
|
700
727
|
if (pkg.current) {
|
|
701
|
-
console.log(`
|
|
728
|
+
console.log(` ${pipe} ${prefix} ${chalk.blue('~')} ${pkg.name}: ${pkg.current} → ${pkg.required}`);
|
|
702
729
|
} else {
|
|
703
|
-
console.log(`
|
|
730
|
+
console.log(` ${pipe} ${prefix} ${chalk.green('+')} ${pkg.name}: ${pkg.required || 'latest'}`);
|
|
704
731
|
}
|
|
705
732
|
}
|
|
706
|
-
if (
|
|
707
|
-
console.log(chalk.dim(
|
|
733
|
+
if (hasMore) {
|
|
734
|
+
console.log(` ${pipe} ${corner} ${chalk.dim(`... and ${allToInstall.length - 10} more`)}`);
|
|
708
735
|
}
|
|
709
|
-
console.log(
|
|
736
|
+
console.log(` ${pipe}`);
|
|
710
737
|
|
|
711
738
|
timeline.pause();
|
|
712
739
|
const { confirmPkgs } = await inquirer.prompt([{
|
package/src/commands/update.js
CHANGED
|
@@ -26,6 +26,16 @@ function compareVersions(a, b) {
|
|
|
26
26
|
return 0;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Pad text to fixed width (ignoring ANSI codes)
|
|
31
|
+
*/
|
|
32
|
+
function padText(text, width) {
|
|
33
|
+
// Strip ANSI codes to get visible length
|
|
34
|
+
const visible = text.replace(/\x1b\[[0-9;]*m/g, '');
|
|
35
|
+
const padding = Math.max(0, width - visible.length);
|
|
36
|
+
return text + ' '.repeat(padding);
|
|
37
|
+
}
|
|
38
|
+
|
|
29
39
|
/**
|
|
30
40
|
* Main update command handler
|
|
31
41
|
*/
|
|
@@ -33,10 +43,12 @@ async function updateCommand() {
|
|
|
33
43
|
console.log(chalk.cyan('\n CSK CLI - Update\n'));
|
|
34
44
|
|
|
35
45
|
const currentVersion = pkg.version;
|
|
46
|
+
const boxWidth = 37; // Inner width between │ and │
|
|
36
47
|
|
|
37
48
|
// Show version info box
|
|
38
|
-
console.log(chalk.dim('
|
|
39
|
-
|
|
49
|
+
console.log(chalk.dim(' ┌' + '─'.repeat(boxWidth) + '┐'));
|
|
50
|
+
const currentLine = ` Current: ${chalk.yellow('v' + currentVersion)}`;
|
|
51
|
+
console.log(chalk.dim(' │') + padText(currentLine, boxWidth) + chalk.dim('│'));
|
|
40
52
|
|
|
41
53
|
const spinner = ora({ text: 'Checking npm registry...', indent: 2 }).start();
|
|
42
54
|
|
|
@@ -48,8 +60,9 @@ async function updateCommand() {
|
|
|
48
60
|
}).trim();
|
|
49
61
|
|
|
50
62
|
spinner.stop();
|
|
51
|
-
|
|
52
|
-
console.log(chalk.dim('
|
|
63
|
+
const latestLine = ` Latest: ${chalk.green('v' + latestVersion)}`;
|
|
64
|
+
console.log(chalk.dim(' │') + padText(latestLine, boxWidth) + chalk.dim('│'));
|
|
65
|
+
console.log(chalk.dim(' └' + '─'.repeat(boxWidth) + '┘\n'));
|
|
53
66
|
|
|
54
67
|
const comparison = compareVersions(currentVersion, latestVersion);
|
|
55
68
|
|
|
@@ -77,15 +90,17 @@ async function updateCommand() {
|
|
|
77
90
|
|
|
78
91
|
// Show summary
|
|
79
92
|
console.log('');
|
|
80
|
-
console.log(chalk.dim('
|
|
81
|
-
|
|
82
|
-
console.log(chalk.dim('
|
|
93
|
+
console.log(chalk.dim(' ┌' + '─'.repeat(boxWidth) + '┐'));
|
|
94
|
+
const summaryLine = ` ${chalk.red('v' + currentVersion)} → ${chalk.green('v' + latestVersion)}`;
|
|
95
|
+
console.log(chalk.dim(' │') + padText(summaryLine, boxWidth) + chalk.dim('│'));
|
|
96
|
+
console.log(chalk.dim(' └' + '─'.repeat(boxWidth) + '┘'));
|
|
83
97
|
console.log(chalk.dim('\n Run `cskit init` to update project files.\n'));
|
|
84
98
|
|
|
85
99
|
} catch (error) {
|
|
86
100
|
spinner.stop();
|
|
87
|
-
|
|
88
|
-
console.log(chalk.dim('
|
|
101
|
+
const errorLine = ` Latest: ${chalk.red('(unavailable)')}`;
|
|
102
|
+
console.log(chalk.dim(' │') + padText(errorLine, boxWidth) + chalk.dim('│'));
|
|
103
|
+
console.log(chalk.dim(' └' + '─'.repeat(boxWidth) + '┘\n'));
|
|
89
104
|
|
|
90
105
|
if (error.message.includes('npm view') || error.message.includes('404')) {
|
|
91
106
|
console.log(chalk.red(' ✗ Could not check for updates'));
|