sarangai-cli 1.0.0 → 1.0.3
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.cjs +16 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -35,23 +35,24 @@ var import_path2 = __toESM(require("path"));
|
|
|
35
35
|
var import_fs = __toESM(require("fs"));
|
|
36
36
|
var import_path = __toESM(require("path"));
|
|
37
37
|
var import_os = __toESM(require("os"));
|
|
38
|
-
var
|
|
38
|
+
var CONFIG_FILE = import_path.default.join(import_os.default.homedir(), ".sarangairc");
|
|
39
39
|
function getConfig() {
|
|
40
40
|
try {
|
|
41
|
-
if (import_fs.default.existsSync(
|
|
42
|
-
|
|
41
|
+
if (import_fs.default.existsSync(CONFIG_FILE)) {
|
|
42
|
+
const raw = import_fs.default.readFileSync(CONFIG_FILE, "utf-8");
|
|
43
|
+
return JSON.parse(raw);
|
|
43
44
|
}
|
|
44
45
|
} catch {
|
|
45
46
|
}
|
|
46
47
|
return {
|
|
47
|
-
baseUrl: "https://
|
|
48
|
-
defaultModel: "
|
|
48
|
+
baseUrl: "https://idshop.or.id",
|
|
49
|
+
defaultModel: "minimax/minimax-m2.7"
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
|
-
function saveConfig(
|
|
52
|
+
function saveConfig(newConfig) {
|
|
52
53
|
const current = getConfig();
|
|
53
|
-
const
|
|
54
|
-
import_fs.default.writeFileSync(
|
|
54
|
+
const merged = { ...current, ...newConfig };
|
|
55
|
+
import_fs.default.writeFileSync(CONFIG_FILE, JSON.stringify(merged, null, 2), "utf-8");
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
// src/index.ts
|
|
@@ -204,17 +205,21 @@ program.name("sarang").description(import_chalk.default.cyanBright("SarangAI CLI
|
|
|
204
205
|
startInteractiveSession();
|
|
205
206
|
});
|
|
206
207
|
program.command("login").description("Hubungkan API Key SarangAI akun Anda").action(async () => {
|
|
208
|
+
const baseUrl = resolveBaseUrl();
|
|
209
|
+
console.log(import_chalk.default.cyanBright("\n\u{1F510} Autentikasi SarangAI CLI"));
|
|
210
|
+
console.log(import_chalk.default.gray("Dapatkan API Key Anda di: ") + import_chalk.default.underline.cyan(`${baseUrl}/dashboard`));
|
|
211
|
+
console.log(import_chalk.default.gray("--------------------------------------------------\n"));
|
|
207
212
|
const res = await (0, import_prompts.default)({
|
|
208
213
|
type: "password",
|
|
209
214
|
name: "key",
|
|
210
|
-
message: "Masukkan SarangAI API Key Anda
|
|
215
|
+
message: "Masukkan SarangAI API Key Anda:"
|
|
211
216
|
});
|
|
212
217
|
if (!res.key) {
|
|
213
|
-
console.log(import_chalk.default.red("
|
|
218
|
+
console.log(import_chalk.default.red("\nLogin dibatalkan.\n"));
|
|
214
219
|
return;
|
|
215
220
|
}
|
|
216
221
|
saveConfig({ apiKey: res.key.trim() });
|
|
217
|
-
console.log(import_chalk.default.green("\u2714 API Key
|
|
222
|
+
console.log(import_chalk.default.green("\n\u2714 Berhasil terhubung! API Key tersimpan di ~/.sarangairc\n"));
|
|
218
223
|
});
|
|
219
224
|
program.command("balance").description("Cek sisa saldo kredit akun SarangAI Anda").action(async () => {
|
|
220
225
|
const cfg = getConfig();
|