cskit-cli 1.0.28 → 1.0.30

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,13 +1,14 @@
1
1
  {
2
2
  "name": "cskit-cli",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "description": "Content Suite Kit CLI - Download and manage CSK skills from private repository",
5
5
  "main": "src/index.js",
6
6
  "bin": {
7
7
  "cskit": "bin/csk.js"
8
8
  },
9
9
  "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1"
10
+ "test": "echo \"Error: no test specified\" && exit 1",
11
+ "postinstall": "node src/postinstall.js"
11
12
  },
12
13
  "keywords": [
13
14
  "claude",
@@ -45,6 +46,7 @@
45
46
  "files": [
46
47
  "bin",
47
48
  "src",
48
- "README.md"
49
+ "README.md",
50
+ "postinstall.js"
49
51
  ]
50
52
  }
@@ -66,8 +66,7 @@ class Timeline {
66
66
  this.steps = [];
67
67
  this.currentStep = -1;
68
68
  this.lastLineCount = 0;
69
- this.isFirstRender = true;
70
- this.isPaused = false;
69
+ this.inPlaceEnabled = true; // Disable after any prompt
71
70
  }
72
71
 
73
72
  addStep(name) {
@@ -102,44 +101,39 @@ class Timeline {
102
101
  this.steps[stepIndex].children.push({ text, type });
103
102
  }
104
103
 
105
- // Call before any external output (prompts, logs, etc.)
104
+ // Call before any prompt - disables in-place updates for rest of session
106
105
  pause() {
107
- // Don't update in-place after external output - just continue below
106
+ this.inPlaceEnabled = false;
108
107
  this.lastLineCount = 0;
109
- this.isPaused = true;
110
108
  }
111
109
 
112
- // Re-render timeline after external output
110
+ // Re-render after prompt (just prints fresh, no in-place)
113
111
  resume() {
114
- if (this.isPaused) {
115
- // Print separator and continue fresh (no in-place update)
116
- console.log(chalk.dim(' ─'.repeat(20)));
117
- this.isPaused = false;
118
- }
119
- this.isFirstRender = true;
120
- this.render();
112
+ console.log(chalk.dim('\n ─'.repeat(20) + '\n'));
113
+ this.renderFresh();
121
114
  }
122
115
 
123
- // Print final summary (no in-place update)
124
- printSummary() {
125
- this.lastLineCount = 0; // Disable in-place update
126
- this.render();
116
+ // Print without in-place update
117
+ renderFresh() {
118
+ const lines = this.buildLines();
119
+ console.log('');
120
+ for (const line of lines) {
121
+ console.log(line);
122
+ }
123
+ console.log('');
127
124
  }
128
125
 
129
- render() {
130
- // Build output lines
126
+ buildLines() {
131
127
  const lines = [];
132
-
133
128
  for (let i = 0; i < this.steps.length; i++) {
134
129
  const step = this.steps[i];
135
130
  const symbol = SYMBOLS[step.status];
136
131
  const num = chalk.dim(`${i + 1}.`);
137
132
  const name = step.status === 'active' ? chalk.cyan(step.name) : step.name;
138
133
  const msg = step.message ? chalk.dim(` (${step.message})`) : '';
139
-
140
134
  lines.push(` ${symbol} ${num} ${name}${msg}`);
141
135
 
142
- // Show children only for active or done steps (not pending)
136
+ // Children for non-pending steps
143
137
  if (step.status !== 'pending') {
144
138
  for (let j = 0; j < step.children.length; j++) {
145
139
  const child = step.children[j];
@@ -149,35 +143,37 @@ class Timeline {
149
143
  child.type === 'update' ? chalk.blue('~') :
150
144
  child.type === 'skip' ? chalk.yellow('!') :
151
145
  child.type === 'delete' ? chalk.red('-') :
146
+ child.type === 'info' ? chalk.cyan('i') :
152
147
  chalk.dim('•');
153
148
  lines.push(` ${SYMBOLS.indent}${branch} ${prefix} ${child.text}`);
154
149
  }
155
150
  }
156
151
  }
152
+ return lines;
153
+ }
157
154
 
158
- // Clear previous output (move cursor up and clear lines)
159
- // Only do in-place update when not paused and have previous output
160
- if (!this.isFirstRender && this.lastLineCount > 0 && !this.isPaused) {
161
- // Move cursor up and clear each line
155
+ render() {
156
+ const lines = this.buildLines();
157
+
158
+ // In-place update only if enabled and have previous output
159
+ if (this.inPlaceEnabled && this.lastLineCount > 0) {
162
160
  process.stdout.write(`\x1b[${this.lastLineCount}A`);
163
161
  for (let i = 0; i < this.lastLineCount; i++) {
164
- process.stdout.write('\x1b[2K\n'); // Clear line
162
+ process.stdout.write('\x1b[2K\n');
165
163
  }
166
- process.stdout.write(`\x1b[${this.lastLineCount}A`); // Move back up
167
- }
168
-
169
- // Print new output
170
- if (this.isFirstRender) {
171
- console.log(''); // Initial blank line
172
- this.isFirstRender = false;
164
+ process.stdout.write(`\x1b[${this.lastLineCount}A`);
165
+ } else if (this.lastLineCount === 0) {
166
+ // First render
167
+ console.log('');
173
168
  }
174
169
 
170
+ // If in-place disabled, just print below (no cursor movement)
175
171
  for (const line of lines) {
176
172
  console.log(line);
177
173
  }
178
- console.log(''); // Trailing blank line
174
+ console.log('');
179
175
 
180
- this.lastLineCount = lines.length + 1; // +1 for trailing blank
176
+ this.lastLineCount = this.inPlaceEnabled ? lines.length + 1 : 0;
181
177
  }
182
178
  }
183
179
 
@@ -4,6 +4,7 @@
4
4
  * Update Command
5
5
  *
6
6
  * Updates the CSK CLI tool itself to latest version.
7
+ * Shows clear version comparison before and after update.
7
8
  */
8
9
 
9
10
  const chalk = require('chalk');
@@ -11,15 +12,33 @@ const ora = require('ora');
11
12
  const { execSync } = require('child_process');
12
13
  const pkg = require('../../package.json');
13
14
 
15
+ /**
16
+ * Compare semantic versions
17
+ * @returns -1 if a < b, 0 if equal, 1 if a > b
18
+ */
19
+ function compareVersions(a, b) {
20
+ const partsA = a.replace(/^v/, '').split('.').map(Number);
21
+ const partsB = b.replace(/^v/, '').split('.').map(Number);
22
+ for (let i = 0; i < 3; i++) {
23
+ if (partsA[i] > partsB[i]) return 1;
24
+ if (partsA[i] < partsB[i]) return -1;
25
+ }
26
+ return 0;
27
+ }
28
+
14
29
  /**
15
30
  * Main update command handler
16
31
  */
17
32
  async function updateCommand() {
18
33
  console.log(chalk.cyan('\n CSK CLI - Update\n'));
19
34
 
20
- console.log(chalk.dim(` Current version: v${pkg.version}\n`));
35
+ const currentVersion = pkg.version;
36
+
37
+ // Show version info box
38
+ console.log(chalk.dim(' ┌─────────────────────────────────────┐'));
39
+ console.log(chalk.dim(' │') + ` Current version: ${chalk.yellow('v' + currentVersion)}`.padEnd(46) + chalk.dim('│'));
21
40
 
22
- const spinner = ora('Checking for updates...').start();
41
+ const spinner = ora({ text: 'Checking npm registry...', indent: 2 }).start();
23
42
 
24
43
  try {
25
44
  // Get latest version from npm
@@ -28,29 +47,53 @@ async function updateCommand() {
28
47
  stdio: ['pipe', 'pipe', 'pipe']
29
48
  }).trim();
30
49
 
31
- if (latestVersion === pkg.version) {
32
- spinner.succeed(chalk.green('Already on latest version'));
50
+ spinner.stop();
51
+ console.log(chalk.dim(' │') + ` Latest version: ${chalk.green('v' + latestVersion)}`.padEnd(46) + chalk.dim('│'));
52
+ console.log(chalk.dim(' └─────────────────────────────────────┘\n'));
53
+
54
+ const comparison = compareVersions(currentVersion, latestVersion);
55
+
56
+ if (comparison === 0) {
57
+ console.log(chalk.green(' ✓ Already on latest version\n'));
33
58
  return;
34
59
  }
35
60
 
36
- spinner.text = `Updating to v${latestVersion}...`;
61
+ if (comparison > 0) {
62
+ console.log(chalk.yellow(' ⚠ Local version is newer than npm (dev build?)\n'));
63
+ return;
64
+ }
65
+
66
+ // Need update
67
+ console.log(chalk.cyan(` Updating v${currentVersion} → v${latestVersion}...\n`));
68
+
69
+ const updateSpinner = ora({ text: 'Installing update...', indent: 2 }).start();
37
70
 
38
- // Run npm update
71
+ // Run npm update (hide npm output)
39
72
  execSync('npm install -g cskit-cli@latest', {
40
- stdio: ['pipe', 'pipe', 'pipe']
73
+ stdio: 'ignore' // Hide npm noise
41
74
  });
42
75
 
43
- spinner.succeed(chalk.green(`Updated to v${latestVersion}`));
76
+ updateSpinner.succeed(chalk.green('Update complete'));
77
+
78
+ // Show summary
79
+ console.log('');
80
+ console.log(chalk.dim(' ┌─────────────────────────────────────┐'));
81
+ console.log(chalk.dim(' │') + ` ${chalk.red('v' + currentVersion)} → ${chalk.green('v' + latestVersion)}`.padEnd(55) + chalk.dim('│'));
82
+ console.log(chalk.dim(' └─────────────────────────────────────┘'));
83
+ console.log(chalk.dim('\n Run `cskit init` to update project files.\n'));
44
84
 
45
- console.log(chalk.dim('\n Run `csk init` to update project files.\n'));
46
85
  } catch (error) {
47
- if (error.message.includes('npm view')) {
48
- spinner.fail(chalk.red('Could not check for updates'));
49
- console.log(chalk.dim('\n Package may not be published yet.\n'));
86
+ spinner.stop();
87
+ console.log(chalk.dim(' │') + ` Latest version: ${chalk.red('(unavailable)')}`.padEnd(46) + chalk.dim('│'));
88
+ console.log(chalk.dim(' └─────────────────────────────────────┘\n'));
89
+
90
+ if (error.message.includes('npm view') || error.message.includes('404')) {
91
+ console.log(chalk.red(' ✗ Could not check for updates'));
92
+ console.log(chalk.dim(' Package may not be published yet.\n'));
50
93
  } else {
51
- spinner.fail(chalk.red('Update failed'));
52
- console.log(chalk.dim(`\n ${error.message}`));
53
- console.log(chalk.dim('\n Try manually: npm install -g cskit-cli@latest\n'));
94
+ console.log(chalk.red('Update failed'));
95
+ console.log(chalk.dim(` ${error.message}`));
96
+ console.log(chalk.dim('\n Try manually: npm install -g cskit-cli@latest\n'));
54
97
  }
55
98
  }
56
99
  }
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /**
5
+ * Postinstall script - shows welcome message after npm install
6
+ */
7
+
8
+ const pkg = require('../package.json');
9
+
10
+ // Simple colors without requiring chalk (postinstall runs before deps ready)
11
+ const cyan = (s) => `\x1b[36m${s}\x1b[0m`;
12
+ const green = (s) => `\x1b[32m${s}\x1b[0m`;
13
+ const dim = (s) => `\x1b[2m${s}\x1b[0m`;
14
+ const bold = (s) => `\x1b[1m${s}\x1b[0m`;
15
+
16
+ console.log('');
17
+ console.log(cyan(' ┌─────────────────────────────────────────────────┐'));
18
+ console.log(cyan(' │') + bold(' CSK CLI - Content Suite Kit ') + cyan('│'));
19
+ console.log(cyan(' └─────────────────────────────────────────────────┘'));
20
+ console.log('');
21
+ console.log(` ${green('✓')} Installed ${bold('cskit-cli')} v${pkg.version}`);
22
+ console.log('');
23
+ console.log(dim(' Quick Start:'));
24
+ console.log(` ${bold('cskit auth')} - Login with GitHub`);
25
+ console.log(` ${bold('cskit init')} - Initialize project with skills`);
26
+ console.log(` ${bold('cskit update')} - Update CLI to latest version`);
27
+ console.log('');
28
+ console.log(dim(` Docs: ${pkg.homepage}`));
29
+ console.log('');