cskit-cli 1.0.23 → 1.0.26

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cskit-cli",
3
- "version": "1.0.23",
3
+ "version": "1.0.26",
4
4
  "description": "Content Suite Kit CLI - Download and manage CSK skills from private repository",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -65,6 +65,8 @@ class Timeline {
65
65
  constructor() {
66
66
  this.steps = [];
67
67
  this.currentStep = -1;
68
+ this.lastLineCount = 0;
69
+ this.isFirstRender = true;
68
70
  }
69
71
 
70
72
  addStep(name) {
@@ -99,9 +101,21 @@ class Timeline {
99
101
  this.steps[stepIndex].children.push({ text, type });
100
102
  }
101
103
 
104
+ // Call before any external output (prompts, logs, etc.)
105
+ pause() {
106
+ this.lastLineCount = 0;
107
+ }
108
+
109
+ // Re-render timeline after external output
110
+ resume() {
111
+ this.isFirstRender = true;
112
+ this.render();
113
+ }
114
+
102
115
  render() {
103
- // Clear and redraw (simple version)
104
- console.log('');
116
+ // Build output lines
117
+ const lines = [];
118
+
105
119
  for (let i = 0; i < this.steps.length; i++) {
106
120
  const step = this.steps[i];
107
121
  const symbol = SYMBOLS[step.status];
@@ -109,7 +123,7 @@ class Timeline {
109
123
  const name = step.status === 'active' ? chalk.cyan(step.name) : step.name;
110
124
  const msg = step.message ? chalk.dim(` (${step.message})`) : '';
111
125
 
112
- console.log(` ${symbol} ${num} ${name}${msg}`);
126
+ lines.push(` ${symbol} ${num} ${name}${msg}`);
113
127
 
114
128
  // Show children (files, etc.)
115
129
  for (let j = 0; j < step.children.length; j++) {
@@ -121,10 +135,32 @@ class Timeline {
121
135
  child.type === 'skip' ? chalk.yellow('!') :
122
136
  child.type === 'delete' ? chalk.red('-') :
123
137
  chalk.dim('•');
124
- console.log(` ${SYMBOLS.indent}${branch} ${prefix} ${child.text}`);
138
+ lines.push(` ${SYMBOLS.indent}${branch} ${prefix} ${child.text}`);
125
139
  }
126
140
  }
127
- console.log('');
141
+
142
+ // Clear previous output (move cursor up and clear lines)
143
+ if (!this.isFirstRender && this.lastLineCount > 0) {
144
+ // Move cursor up and clear each line
145
+ process.stdout.write(`\x1b[${this.lastLineCount}A`);
146
+ for (let i = 0; i < this.lastLineCount; i++) {
147
+ process.stdout.write('\x1b[2K\n'); // Clear line
148
+ }
149
+ process.stdout.write(`\x1b[${this.lastLineCount}A`); // Move back up
150
+ }
151
+
152
+ // Print new output
153
+ if (this.isFirstRender) {
154
+ console.log(''); // Initial blank line
155
+ this.isFirstRender = false;
156
+ }
157
+
158
+ for (const line of lines) {
159
+ console.log(line);
160
+ }
161
+ console.log(''); // Trailing blank line
162
+
163
+ this.lastLineCount = lines.length + 1; // +1 for trailing blank
128
164
  }
129
165
  }
130
166
 
@@ -406,6 +442,7 @@ async function initCommand(options) {
406
442
  }));
407
443
  choices.push({ name: chalk.dim('main branch (dev)'), value: 'main' });
408
444
 
445
+ timeline.pause(); // Pause before prompt
409
446
  const answer = await inquirer.prompt([{
410
447
  type: 'list',
411
448
  name: 'version',
@@ -414,11 +451,12 @@ async function initCommand(options) {
414
451
  default: releases[0]?.tag || 'main'
415
452
  }]);
416
453
  selectedVersion = answer.version;
454
+ timeline.resume(); // Resume after prompt
417
455
  } else if (latest) {
418
456
  selectedVersion = latest.tag;
419
457
  }
420
458
 
421
- console.log(chalk.dim(`\n Installing: ${selectedVersion}\n`));
459
+ console.log(chalk.dim(` Installing: ${selectedVersion}\n`));
422
460
 
423
461
  // Step 2: Download zip
424
462
  timeline.start(1);
@@ -498,6 +536,7 @@ async function initCommand(options) {
498
536
 
499
537
  // Confirm
500
538
  if (changes.update.length > 0 && !options.force) {
539
+ timeline.pause();
501
540
  const { confirm } = await inquirer.prompt([{
502
541
  type: 'confirm',
503
542
  name: 'confirm',
@@ -506,6 +545,7 @@ async function initCommand(options) {
506
545
  }]);
507
546
 
508
547
  if (!confirm) {
548
+ timeline.resume();
509
549
  timeline.skip(4, 'User cancelled');
510
550
  timeline.skip(5, 'Skipped');
511
551
  timeline.skip(6, 'Skipped');
@@ -516,6 +556,7 @@ async function initCommand(options) {
516
556
  console.log(chalk.yellow('\n Installation cancelled.\n'));
517
557
  process.exit(0);
518
558
  }
559
+ timeline.resume();
519
560
  }
520
561
 
521
562
  timeline.complete(4, 'Confirmed');
@@ -581,6 +622,7 @@ async function initCommand(options) {
581
622
  return;
582
623
  }
583
624
 
625
+ timeline.pause();
584
626
  const { installAdvanced } = await inquirer.prompt([{
585
627
  type: 'confirm',
586
628
  name: 'installAdvanced',
@@ -589,9 +631,11 @@ async function initCommand(options) {
589
631
  }]);
590
632
 
591
633
  if (!installAdvanced) {
634
+ timeline.resume();
592
635
  timeline.skip(6, 'Skipped by user');
593
636
  return;
594
637
  }
638
+ timeline.resume();
595
639
 
596
640
  const pkgStatus = checkPythonPackages(libPythonDir);
597
641
 
@@ -622,12 +666,14 @@ async function initCommand(options) {
622
666
  }
623
667
  console.log('');
624
668
 
669
+ timeline.pause();
625
670
  const { confirmPkgs } = await inquirer.prompt([{
626
671
  type: 'confirm',
627
672
  name: 'confirmPkgs',
628
673
  message: `Install ${allToInstall.length} packages?`,
629
674
  default: true
630
675
  }]);
676
+ timeline.resume();
631
677
 
632
678
  if (confirmPkgs) {
633
679
  await installPackages(libPythonDir, allToInstall, timeline, 6, pythonCmd);
@@ -661,12 +707,14 @@ async function initCommand(options) {
661
707
  console.log(chalk.dim(` Command: ${autoInstall.command}`));
662
708
  console.log('');
663
709
 
710
+ timeline.pause();
664
711
  const { doInstall } = await inquirer.prompt([{
665
712
  type: 'confirm',
666
713
  name: 'doInstall',
667
714
  message: `Install Python now via ${autoInstall.manager}?`,
668
715
  default: true
669
716
  }]);
717
+ timeline.resume();
670
718
 
671
719
  if (doInstall) {
672
720
  console.log('');