apero-kit-cli 2.4.6 → 2.4.8

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 CHANGED
@@ -1315,6 +1315,26 @@ function isOpenClawInstalled() {
1315
1315
  return false;
1316
1316
  }
1317
1317
  }
1318
+ function isDiscordConfigured() {
1319
+ try {
1320
+ const { execSync: execSync3 } = __require("child_process");
1321
+ const result = execSync3("openclaw config get channels.discord.token 2>/dev/null", { encoding: "utf-8" });
1322
+ return result && result.trim().length > 10;
1323
+ } catch {
1324
+ return false;
1325
+ }
1326
+ }
1327
+ function restartGateway() {
1328
+ try {
1329
+ const { execSync: execSync3 } = __require("child_process");
1330
+ execSync3("openclaw config set gateway.mode local", { stdio: "ignore" });
1331
+ console.log(pc.cyan("Starting OpenClaw gateway..."));
1332
+ execSync3("openclaw gateway", { stdio: "inherit" });
1333
+ return true;
1334
+ } catch {
1335
+ return false;
1336
+ }
1337
+ }
1318
1338
  async function installOpenClaw() {
1319
1339
  const { execSync: execSync3 } = __require("child_process");
1320
1340
  try {
@@ -1346,6 +1366,36 @@ async function promptDiscordSetup() {
1346
1366
  openclawInstalled = await installOpenClaw();
1347
1367
  }
1348
1368
  }
1369
+ if (openclawInstalled && isDiscordConfigured()) {
1370
+ console.log(pc.green("\u2713 Discord bot token already configured."));
1371
+ console.log("");
1372
+ const action = await p.select({
1373
+ message: "What do you want to do?",
1374
+ options: [
1375
+ { value: "restart", label: "Restart gateway", hint: "Use existing config" },
1376
+ { value: "reconfigure", label: "Reconfigure", hint: "Enter new token" },
1377
+ { value: "skip", label: "Skip setup", hint: "Continue without changes" }
1378
+ ]
1379
+ });
1380
+ if (p.isCancel(action)) process.exit(0);
1381
+ if (action === "restart") {
1382
+ restartGateway();
1383
+ return {
1384
+ token: "",
1385
+ autoSetup: false,
1386
+ openclawInstalled: true,
1387
+ restartOnly: true
1388
+ };
1389
+ }
1390
+ if (action === "skip") {
1391
+ return {
1392
+ token: "",
1393
+ autoSetup: false,
1394
+ openclawInstalled: true,
1395
+ restartOnly: true
1396
+ };
1397
+ }
1398
+ }
1349
1399
  console.log(pc.gray("Get your bot token from: https://discord.com/developers/applications"));
1350
1400
  console.log("");
1351
1401
  const token = await p.password({
@@ -1664,7 +1714,7 @@ async function initCommand(projectName, options) {
1664
1714
  } else if (target === "discord") {
1665
1715
  spinner.text = mergeMode ? `Merging config (${targetLabel})...` : `Copying config (${targetLabel})...`;
1666
1716
  await copyDiscordBaseFiles(targetDir, mergeMode);
1667
- if (discordConfig) {
1717
+ if (discordConfig && !discordConfig.restartOnly) {
1668
1718
  spinner.text = "Configuring Discord bot...";
1669
1719
  await updateDiscordConfig(targetDir, discordConfig.token, discordConfig.guildId);
1670
1720
  if (discordConfig.autoSetup) {
@@ -1676,6 +1726,8 @@ async function initCommand(projectName, options) {
1676
1726
  Note: ${result.message}`));
1677
1727
  }
1678
1728
  }
1729
+ } else if (discordConfig?.restartOnly) {
1730
+ openclawSetupSuccess = true;
1679
1731
  }
1680
1732
  }
1681
1733
  }