blun-king-cli 5.1.0 → 5.1.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/blun-cli.js +13 -3
- package/package.json +1 -1
package/blun-cli.js
CHANGED
|
@@ -2689,13 +2689,23 @@ async function main() {
|
|
|
2689
2689
|
printHeader();
|
|
2690
2690
|
checkForUpdates();
|
|
2691
2691
|
|
|
2692
|
-
// API
|
|
2693
|
-
if (
|
|
2694
|
-
|
|
2692
|
+
// API Key check — prompt if missing
|
|
2693
|
+
if (!config.api.key && !process.argv.includes("--api-key")) {
|
|
2694
|
+
console.log("");
|
|
2695
|
+
console.log(C.yellow + " " + BOX.bot + " No API key configured." + C.reset);
|
|
2696
|
+
console.log(C.gray + " Enter your BLUN King API key (or press Enter to skip):" + C.reset);
|
|
2697
|
+
var apiKeyAnswer = await new Promise(function(resolve) {
|
|
2698
|
+
var rlKey = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
2699
|
+
rlKey.question(C.brightBlue + " API Key: " + C.reset, function(answer) {
|
|
2700
|
+
rlKey.close();
|
|
2701
|
+
resolve(answer.trim());
|
|
2702
|
+
});
|
|
2703
|
+
});
|
|
2695
2704
|
if (apiKeyAnswer) {
|
|
2696
2705
|
config.api.key = apiKeyAnswer;
|
|
2697
2706
|
var cfgFile = path.join(CONFIG_DIR, "config.json");
|
|
2698
2707
|
var cfgData = {};
|
|
2708
|
+
if (fs.existsSync(cfgFile)) { try { cfgData = JSON.parse(fs.readFileSync(cfgFile, "utf8")); } catch(e) {} }
|
|
2699
2709
|
if (!cfgData.api) cfgData.api = {};
|
|
2700
2710
|
cfgData.api.key = apiKeyAnswer;
|
|
2701
2711
|
fs.writeFileSync(cfgFile, JSON.stringify(cfgData, null, 2));
|