wormclaude 1.0.3 → 1.0.4
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/dist/auth.js +70 -9
- package/dist/theme.js +1 -1
- package/package.json +1 -1
package/dist/auth.js
CHANGED
|
@@ -95,17 +95,78 @@ export function runUpdate() {
|
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
// Giriş yapılmamışken `wormclaude` çalışınca gösterilen menü.
|
|
98
|
-
//
|
|
98
|
+
// ↑/↓ ok tuşlarıyla gezin, Enter ile seç. (1/2 tuşları da çalışır.)
|
|
99
99
|
export function promptLoginMenu() {
|
|
100
|
+
const items = [
|
|
101
|
+
{ label: 'Giriş yap', value: 'login' },
|
|
102
|
+
{ label: 'Çıkış', value: 'exit' },
|
|
103
|
+
];
|
|
100
104
|
return new Promise((resolve) => {
|
|
101
|
-
process.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
const stdin = process.stdin;
|
|
106
|
+
// TTY yoksa (pipe/otomasyon): tek satır oku — '2' → çıkış, aksi → giriş.
|
|
107
|
+
if (!stdin.isTTY) {
|
|
108
|
+
const rl = readline.createInterface({ input: process.stdin });
|
|
109
|
+
rl.once('line', (line) => { rl.close(); resolve(line.trim() === '2' ? 'exit' : 'login'); });
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
let idx = 0;
|
|
113
|
+
process.stdout.write('\n \x1b[1mWormClaude\x1b[0m\n');
|
|
114
|
+
process.stdout.write(' \x1b[2m↑/↓ ile seç · Enter ile onayla\x1b[0m\n\n');
|
|
115
|
+
const draw = (first) => {
|
|
116
|
+
if (!first)
|
|
117
|
+
process.stdout.write(`\x1b[${items.length}A`); // imleci listenin başına al
|
|
118
|
+
items.forEach((it, i) => {
|
|
119
|
+
const line = i === idx
|
|
120
|
+
? ` \x1b[36m❯ ${it.label}\x1b[0m`
|
|
121
|
+
: ` \x1b[2m${it.label}\x1b[0m`;
|
|
122
|
+
process.stdout.write('\x1b[2K' + line + '\n'); // satırı temizle + yaz
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
draw(true);
|
|
126
|
+
readline.emitKeypressEvents(process.stdin);
|
|
127
|
+
try {
|
|
128
|
+
stdin.setRawMode(true);
|
|
129
|
+
}
|
|
130
|
+
catch { }
|
|
131
|
+
stdin.resume();
|
|
132
|
+
const cleanup = () => {
|
|
133
|
+
process.stdin.off('keypress', onKey);
|
|
134
|
+
try {
|
|
135
|
+
stdin.setRawMode(false);
|
|
136
|
+
}
|
|
137
|
+
catch { }
|
|
138
|
+
stdin.pause();
|
|
139
|
+
process.stdout.write('\x1b[2K\n');
|
|
140
|
+
};
|
|
141
|
+
const onKey = (str, key) => {
|
|
142
|
+
if (!key)
|
|
143
|
+
return;
|
|
144
|
+
if (key.name === 'up' || key.name === 'k') {
|
|
145
|
+
idx = (idx - 1 + items.length) % items.length;
|
|
146
|
+
draw(false);
|
|
147
|
+
}
|
|
148
|
+
else if (key.name === 'down' || key.name === 'j' || key.name === 'tab') {
|
|
149
|
+
idx = (idx + 1) % items.length;
|
|
150
|
+
draw(false);
|
|
151
|
+
}
|
|
152
|
+
else if (str === '1') {
|
|
153
|
+
idx = 0;
|
|
154
|
+
draw(false);
|
|
155
|
+
}
|
|
156
|
+
else if (str === '2') {
|
|
157
|
+
idx = 1;
|
|
158
|
+
draw(false);
|
|
159
|
+
}
|
|
160
|
+
else if (key.name === 'return' || key.name === 'enter') {
|
|
161
|
+
cleanup();
|
|
162
|
+
resolve(items[idx].value);
|
|
163
|
+
}
|
|
164
|
+
else if (key.name === 'escape' || (key.ctrl && key.name === 'c')) {
|
|
165
|
+
cleanup();
|
|
166
|
+
resolve('exit');
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
process.stdin.on('keypress', onKey);
|
|
109
170
|
});
|
|
110
171
|
}
|
|
111
172
|
export async function deviceLogin() {
|
package/dist/theme.js
CHANGED