cskit-cli 1.0.29 → 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 +1 -1
- package/src/commands/init.js +32 -36
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.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
|
|
104
|
+
// Call before any prompt - disables in-place updates for rest of session
|
|
106
105
|
pause() {
|
|
107
|
-
|
|
106
|
+
this.inPlaceEnabled = false;
|
|
108
107
|
this.lastLineCount = 0;
|
|
109
|
-
this.isPaused = true;
|
|
110
108
|
}
|
|
111
109
|
|
|
112
|
-
// Re-render
|
|
110
|
+
// Re-render after prompt (just prints fresh, no in-place)
|
|
113
111
|
resume() {
|
|
114
|
-
|
|
115
|
-
|
|
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
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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');
|
|
162
|
+
process.stdout.write('\x1b[2K\n');
|
|
165
163
|
}
|
|
166
|
-
process.stdout.write(`\x1b[${this.lastLineCount}A`);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
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('');
|
|
174
|
+
console.log('');
|
|
179
175
|
|
|
180
|
-
this.lastLineCount = lines.length + 1
|
|
176
|
+
this.lastLineCount = this.inPlaceEnabled ? lines.length + 1 : 0;
|
|
181
177
|
}
|
|
182
178
|
}
|
|
183
179
|
|