cskit-cli 1.0.29 → 1.0.31
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 +30 -41
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -66,8 +66,7 @@ class Timeline {
|
|
|
66
66
|
this.steps = [];
|
|
67
67
|
this.currentStep = -1;
|
|
68
68
|
this.lastLineCount = 0;
|
|
69
|
-
this.
|
|
70
|
-
this.isPaused = false;
|
|
69
|
+
this.paused = false; // After prompt, stop full re-renders
|
|
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
|
|
104
|
+
// Call before any prompt - stops full re-renders
|
|
106
105
|
pause() {
|
|
107
|
-
|
|
106
|
+
this.paused = true;
|
|
108
107
|
this.lastLineCount = 0;
|
|
109
|
-
this.isPaused = true;
|
|
110
108
|
}
|
|
111
109
|
|
|
112
|
-
//
|
|
110
|
+
// Print separator after prompt
|
|
113
111
|
resume() {
|
|
114
|
-
|
|
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'));
|
|
121
113
|
}
|
|
122
114
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
115
|
+
buildStatusLine(stepIndex) {
|
|
116
|
+
const step = this.steps[stepIndex];
|
|
117
|
+
const symbol = SYMBOLS[step.status];
|
|
118
|
+
const num = chalk.dim(`${stepIndex + 1}.`);
|
|
119
|
+
const name = step.status === 'active' ? chalk.cyan(step.name) : step.name;
|
|
120
|
+
const msg = step.message ? chalk.dim(` (${step.message})`) : '';
|
|
121
|
+
return ` ${symbol} ${num} ${name}${msg}`;
|
|
127
122
|
}
|
|
128
123
|
|
|
129
124
|
render() {
|
|
130
|
-
//
|
|
131
|
-
|
|
125
|
+
// After pause, only print current step status (no full timeline)
|
|
126
|
+
if (this.paused) {
|
|
127
|
+
console.log(this.buildStatusLine(this.currentStep));
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
132
130
|
|
|
131
|
+
const lines = [];
|
|
133
132
|
for (let i = 0; i < this.steps.length; i++) {
|
|
134
|
-
|
|
135
|
-
const symbol = SYMBOLS[step.status];
|
|
136
|
-
const num = chalk.dim(`${i + 1}.`);
|
|
137
|
-
const name = step.status === 'active' ? chalk.cyan(step.name) : step.name;
|
|
138
|
-
const msg = step.message ? chalk.dim(` (${step.message})`) : '';
|
|
133
|
+
lines.push(this.buildStatusLine(i));
|
|
139
134
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
// Show children only for active or done steps (not pending)
|
|
135
|
+
const step = this.steps[i];
|
|
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,30 @@ 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
|
}
|
|
157
152
|
|
|
158
|
-
//
|
|
159
|
-
|
|
160
|
-
if (!this.isFirstRender && this.lastLineCount > 0 && !this.isPaused) {
|
|
161
|
-
// Move cursor up and clear each line
|
|
153
|
+
// In-place update if have previous output
|
|
154
|
+
if (this.lastLineCount > 0) {
|
|
162
155
|
process.stdout.write(`\x1b[${this.lastLineCount}A`);
|
|
163
156
|
for (let i = 0; i < this.lastLineCount; i++) {
|
|
164
|
-
process.stdout.write('\x1b[2K\n');
|
|
157
|
+
process.stdout.write('\x1b[2K\n');
|
|
165
158
|
}
|
|
166
|
-
process.stdout.write(`\x1b[${this.lastLineCount}A`);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Print new output
|
|
170
|
-
if (this.isFirstRender) {
|
|
171
|
-
console.log(''); // Initial blank line
|
|
172
|
-
this.isFirstRender = false;
|
|
159
|
+
process.stdout.write(`\x1b[${this.lastLineCount}A`);
|
|
160
|
+
} else {
|
|
161
|
+
console.log('');
|
|
173
162
|
}
|
|
174
163
|
|
|
175
164
|
for (const line of lines) {
|
|
176
165
|
console.log(line);
|
|
177
166
|
}
|
|
178
|
-
console.log('');
|
|
167
|
+
console.log('');
|
|
179
168
|
|
|
180
|
-
this.lastLineCount = lines.length + 1;
|
|
169
|
+
this.lastLineCount = lines.length + 1;
|
|
181
170
|
}
|
|
182
171
|
}
|
|
183
172
|
|