home-hosted 0.7.5 → 0.7.6

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/cli.js CHANGED
@@ -10300,6 +10300,26 @@ function readJson(file) {
10300
10300
  return null;
10301
10301
  }
10302
10302
  }
10303
+ /**
10304
+ * A legacy file, with "absent" told apart from "present but unreadable".
10305
+ *
10306
+ * `readJson` collapses both into `null`, and a split that is skipped reads exactly like
10307
+ * one with nothing to do — so a corrupt legacy config used to be abandoned silently
10308
+ * while `workspaces.json` was still created, after which `hasLegacyLayout()` is false
10309
+ * and no later run ever looks at that file again. The definitions would sit unread
10310
+ * beside a panel supervising nothing.
10311
+ */
10312
+ function readLegacy(file) {
10313
+ if (!fs.existsSync(file)) return {
10314
+ parsed: null,
10315
+ unreadable: false
10316
+ };
10317
+ const parsed = readJson(file);
10318
+ return {
10319
+ parsed,
10320
+ unreadable: parsed === null
10321
+ };
10322
+ }
10303
10323
  function writeJson(file, value, mode) {
10304
10324
  fs.mkdirSync(path.dirname(file), { recursive: true });
10305
10325
  fs.writeFileSync(file, `${JSON.stringify(value, null, 2)}\n`, mode === void 0 ? {} : { mode });
@@ -10397,10 +10417,11 @@ function migrateLayout() {
10397
10417
  const moved = [];
10398
10418
  const warnings = [];
10399
10419
  fs.mkdirSync(hhDir, { recursive: true });
10400
- const legacyConfig = readJson(legacy.configPath);
10420
+ const legacyConfig = readLegacy(legacy.configPath);
10401
10421
  let configSplit = false;
10402
- if (legacyConfig !== null) {
10403
- const split = splitConfig(legacyConfig);
10422
+ if (legacyConfig.unreadable) warnings.push(`${legacy.configPath} could not be read — it was NOT migrated and is still there; fix or remove it, then move the file in by hand`);
10423
+ if (legacyConfig.parsed !== null) {
10424
+ const split = splitConfig(legacyConfig.parsed);
10404
10425
  const destinations = [
10405
10426
  path.join(hhDir, "settings.json"),
10406
10427
  path.join(hhDir, "default", "settings.json"),
@@ -10417,10 +10438,11 @@ function migrateLayout() {
10417
10438
  configSplit = true;
10418
10439
  }
10419
10440
  }
10420
- const legacySecrets = readJson(legacy.secretsPath);
10441
+ const legacySecrets = readLegacy(legacy.secretsPath);
10421
10442
  let secretsSplit = false;
10422
- if (legacySecrets !== null) {
10423
- const split = splitSecrets(legacySecrets);
10443
+ if (legacySecrets.unreadable) warnings.push(`${legacy.secretsPath} could not be read — it was NOT migrated and is still there; a panel without it starts on the default password`);
10444
+ if (legacySecrets.parsed !== null) {
10445
+ const split = splitSecrets(legacySecrets.parsed);
10424
10446
  const destinations = [path.join(hhDir, ".control-secrets.json"), path.join(hhDir, "default", ".secrets.json")];
10425
10447
  const taken = destinations.filter((file) => fs.existsSync(file));
10426
10448
  if (taken.length > 0) warnings.push(`${legacy.secretsPath} could not be split — ${taken.map((file) => path.relative(hhDir, file)).join(", ")} already exist(s); left it in place`);
@@ -10600,6 +10622,8 @@ function localCall(runtime, path, method, token, timeoutMs) {
10600
10622
  status: response.statusCode ?? 0,
10601
10623
  body
10602
10624
  }));
10625
+ response.once("aborted", () => resolve(null));
10626
+ response.once("error", () => resolve(null));
10603
10627
  });
10604
10628
  request.once("error", () => resolve(null));
10605
10629
  request.once("timeout", () => {
@@ -17087,6 +17111,7 @@ state/.hh/*
17087
17111
  !state/.hh/settings.json
17088
17112
  !state/.hh/workspaces.json
17089
17113
  state/.hh/*/*
17114
+ !state/.hh/*/
17090
17115
  !state/.hh/*/settings.json
17091
17116
  !state/.hh/*/servers.config.json
17092
17117
  data/