webide-cli 0.0.1-alpha.9 → 0.0.1-beta.1
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/index.js +28 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4,6 +4,7 @@ const { version } = require('./package.json');
|
|
|
4
4
|
const { createClient } = require('@supabase/supabase-js');
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const path = require('path');
|
|
7
|
+
const readline = require('readline');
|
|
7
8
|
|
|
8
9
|
const termCols = process.stdout.columns;
|
|
9
10
|
|
|
@@ -134,7 +135,7 @@ function loading(msg) {
|
|
|
134
135
|
const terminalWidth = process.stdout.columns;
|
|
135
136
|
let i = 0;
|
|
136
137
|
let linesUsed = Math.ceil((spinnerChars[0].length + msg.length + 1) / terminalWidth);
|
|
137
|
-
if (termCols < msg.
|
|
138
|
+
if (termCols < msg.length + 14 + workdir.length) process.stdout.write('\n');
|
|
138
139
|
const interval = setInterval(() => {
|
|
139
140
|
const displayText = `${spinnerChars[i++]} ${msg}`;
|
|
140
141
|
linesUsed = Math.ceil(displayText.length / terminalWidth);
|
|
@@ -181,4 +182,30 @@ async function search(keyword) {
|
|
|
181
182
|
const { data, error } = await bucket.list('');
|
|
182
183
|
if (error) throw error;
|
|
183
184
|
return data.filter(file => file.name.includes(keyword));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function getCursorPosition() {
|
|
188
|
+
return new Promise((resolve) => {
|
|
189
|
+
const rl = readline.createInterface({
|
|
190
|
+
input: process.stdin,
|
|
191
|
+
output: process.stdout
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// 发送查询光标位置的ANSI序列
|
|
195
|
+
process.stdout.write('\x1B[6n');
|
|
196
|
+
|
|
197
|
+
process.stdin.once('data', (data) => {
|
|
198
|
+
// 解析响应 \x1B[row;colR
|
|
199
|
+
const match = data.toString().match(/\[(\d+);(\d+)R/);
|
|
200
|
+
if (match) {
|
|
201
|
+
const row = parseInt(match[1]);
|
|
202
|
+
const col = parseInt(match[2]);
|
|
203
|
+
resolve({ row, col });
|
|
204
|
+
} else {
|
|
205
|
+
resolve(null);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
rl.close();
|
|
209
|
+
});
|
|
210
|
+
});
|
|
184
211
|
}
|