gut-cli 0.1.15 → 0.1.17
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/index.js +37 -22
- package/dist/index.js.map +1 -1
- package/dist/lib/index.js +14 -2
- package/dist/lib/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -108,7 +108,8 @@ var FALLBACK_ENV_MAP = {
|
|
|
108
108
|
};
|
|
109
109
|
async function getKeytar() {
|
|
110
110
|
try {
|
|
111
|
-
|
|
111
|
+
const keytar = await import("keytar");
|
|
112
|
+
return keytar.default || keytar;
|
|
112
113
|
} catch {
|
|
113
114
|
return null;
|
|
114
115
|
}
|
|
@@ -176,27 +177,30 @@ async function readSecretInput(prompt) {
|
|
|
176
177
|
stdin.setRawMode(true);
|
|
177
178
|
stdin.resume();
|
|
178
179
|
stdin.setEncoding("utf8");
|
|
179
|
-
const onData = (
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
180
|
+
const onData = (data) => {
|
|
181
|
+
for (const char of data) {
|
|
182
|
+
const charCode = char.charCodeAt(0);
|
|
183
|
+
if (charCode === 13 || charCode === 10) {
|
|
184
|
+
stdin.setRawMode(false);
|
|
185
|
+
stdin.pause();
|
|
186
|
+
stdin.removeListener("data", onData);
|
|
187
|
+
console.log();
|
|
188
|
+
resolve(input);
|
|
189
|
+
return;
|
|
190
|
+
} else if (charCode === 127 || charCode === 8) {
|
|
191
|
+
if (input.length > 0) {
|
|
192
|
+
input = input.slice(0, -1);
|
|
193
|
+
process.stdout.write("\b \b");
|
|
194
|
+
}
|
|
195
|
+
} else if (charCode === 3) {
|
|
196
|
+
stdin.setRawMode(false);
|
|
197
|
+
stdin.pause();
|
|
198
|
+
console.log();
|
|
199
|
+
process.exit(0);
|
|
200
|
+
} else if (charCode >= 32) {
|
|
201
|
+
input += char;
|
|
202
|
+
process.stdout.write("*");
|
|
191
203
|
}
|
|
192
|
-
} else if (charCode === 3) {
|
|
193
|
-
stdin.setRawMode(false);
|
|
194
|
-
stdin.pause();
|
|
195
|
-
console.log();
|
|
196
|
-
process.exit(0);
|
|
197
|
-
} else if (charCode >= 32) {
|
|
198
|
-
input += char;
|
|
199
|
-
process.stdout.write("*");
|
|
200
204
|
}
|
|
201
205
|
};
|
|
202
206
|
stdin.on("data", onData);
|
|
@@ -390,7 +394,18 @@ function isValidLanguage(lang) {
|
|
|
390
394
|
// src/lib/ai.ts
|
|
391
395
|
var __filename = fileURLToPath(import.meta.url);
|
|
392
396
|
var __dirname = dirname(__filename);
|
|
393
|
-
|
|
397
|
+
function findGutRoot() {
|
|
398
|
+
let current = __dirname;
|
|
399
|
+
for (let i = 0; i < 5; i++) {
|
|
400
|
+
const gutPath = join2(current, ".gut");
|
|
401
|
+
if (existsSync2(gutPath)) {
|
|
402
|
+
return current;
|
|
403
|
+
}
|
|
404
|
+
current = dirname(current);
|
|
405
|
+
}
|
|
406
|
+
return join2(__dirname, "..");
|
|
407
|
+
}
|
|
408
|
+
var GUT_ROOT = findGutRoot();
|
|
394
409
|
function loadTemplate(name) {
|
|
395
410
|
const templatePath = join2(GUT_ROOT, ".gut", `${name}.md`);
|
|
396
411
|
if (existsSync2(templatePath)) {
|