@toon-protocol/townhouse 0.1.2 → 0.1.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/cli.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  serviceFromContainerName,
28
28
  tailContainerLogs,
29
29
  writeHsConnectorConfig
30
- } from "./chunk-W33MEOPM.js";
30
+ } from "./chunk-QHFUIWEN.js";
31
31
  import "./chunk-5O4SBV5O.js";
32
32
  import {
33
33
  CONTAINER_PREFIX
@@ -3029,8 +3029,52 @@ function isAnonBootstrapTimeout(err) {
3029
3029
  ${err.stderr ?? ""}`;
3030
3030
  return /connector.*unhealthy|dependency.*connector.*fail/i.test(text);
3031
3031
  }
3032
+ async function attachDashboard(hostname) {
3033
+ if (!shouldRenderInk()) return;
3034
+ try {
3035
+ const { mountTui } = await import("./tui-QE3ZRZO3.js");
3036
+ const apiUrlOverride = process.env["HS_TOWNHOUSE_API_URL"];
3037
+ const mountOpts = apiUrlOverride !== void 0 ? { apiUrl: apiUrlOverride } : {};
3038
+ const instance = mountTui(mountOpts);
3039
+ await instance.waitUntilExit();
3040
+ } catch (tuiErr) {
3041
+ const detail = tuiErr instanceof Error ? tuiErr.message : String(tuiErr);
3042
+ console.error("");
3043
+ console.error(`Your node is live at ${hostname}.`);
3044
+ console.error(
3045
+ `The live dashboard could not open (${detail}) \u2014 this is a display issue, not a node issue. Your node keeps running.`
3046
+ );
3047
+ console.error(
3048
+ "Stop it anytime with: npx @toon-protocol/townhouse hs down"
3049
+ );
3050
+ }
3051
+ }
3032
3052
  async function handleHsUp(_configPath, configDir, config, docker, options) {
3033
3053
  const { password, force, skipPreflight, hsOverrides } = options;
3054
+ if (!force) {
3055
+ const adminClientFactory = hsOverrides?.createAdminClient ?? ((url, t) => new ConnectorAdminClient(url, t));
3056
+ const probe = adminClientFactory(HS_CONNECTOR_ADMIN_URL, 3e3);
3057
+ try {
3058
+ const existing = await probe.getHsHostname();
3059
+ if (existing.hostname !== null) {
3060
+ console.log(`Apex live at ${existing.hostname}`);
3061
+ _writeHostJson(configDir, {
3062
+ hostname: existing.hostname,
3063
+ publishedAt: existing.publishedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
3064
+ writtenAt: (/* @__PURE__ */ new Date()).toISOString()
3065
+ });
3066
+ await attachDashboard(existing.hostname);
3067
+ return;
3068
+ }
3069
+ } catch (probeErr) {
3070
+ const msg = probeErr instanceof Error ? probeErr.message : String(probeErr);
3071
+ if (msg.includes("anon-disabled")) {
3072
+ const { exitCode } = renderFailure(probeErr);
3073
+ process.exitCode = exitCode;
3074
+ return;
3075
+ }
3076
+ }
3077
+ }
3034
3078
  if (!skipPreflight) {
3035
3079
  const preflight = hsOverrides?.checkPortCollisions ?? ((d) => checkHsPortCollisions(d));
3036
3080
  try {
@@ -3089,29 +3133,6 @@ async function handleHsUp(_configPath, configDir, config, docker, options) {
3089
3133
  }
3090
3134
  const ribbon = new OnboardingRibbon();
3091
3135
  try {
3092
- if (!force) {
3093
- const adminClientFactory = hsOverrides?.createAdminClient ?? ((url, t) => new ConnectorAdminClient(url, t));
3094
- const probe = adminClientFactory(HS_CONNECTOR_ADMIN_URL, 3e3);
3095
- try {
3096
- const existing = await probe.getHsHostname();
3097
- if (existing.hostname !== null) {
3098
- console.log(`Apex live at ${existing.hostname}`);
3099
- _writeHostJson(configDir, {
3100
- hostname: existing.hostname,
3101
- publishedAt: existing.publishedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
3102
- writtenAt: (/* @__PURE__ */ new Date()).toISOString()
3103
- });
3104
- return;
3105
- }
3106
- } catch (probeErr) {
3107
- const msg = probeErr instanceof Error ? probeErr.message : String(probeErr);
3108
- if (msg.includes("anon-disabled")) {
3109
- const { exitCode } = renderFailure(probeErr);
3110
- process.exitCode = exitCode;
3111
- return;
3112
- }
3113
- }
3114
- }
3115
3136
  writeHsConnectorConfig(configDir, config, { force });
3116
3137
  const materialize = hsOverrides?.materializeComposeTemplate ?? materializeComposeTemplate;
3117
3138
  const { composePath } = materialize("hs", { townhouseHome: configDir });
@@ -3141,6 +3162,7 @@ async function handleHsUp(_configPath, configDir, config, docker, options) {
3141
3162
  ribbon.start("bootstrap");
3142
3163
  }
3143
3164
  });
3165
+ ribbon.stop();
3144
3166
  if (typeof orch.pullImage === "function") {
3145
3167
  try {
3146
3168
  const apexImages = await collectApexImageRefs(configDir);
@@ -3263,25 +3285,7 @@ async function handleHsUp(_configPath, configDir, config, docker, options) {
3263
3285
  writtenAt: (/* @__PURE__ */ new Date()).toISOString()
3264
3286
  });
3265
3287
  ribbon.start("live", hostname);
3266
- if (shouldRenderInk()) {
3267
- try {
3268
- const { mountTui } = await import("./tui-OIFXGBTL.js");
3269
- const apiUrlOverride = process.env["HS_TOWNHOUSE_API_URL"];
3270
- const mountOpts = apiUrlOverride !== void 0 ? { apiUrl: apiUrlOverride } : {};
3271
- const instance = mountTui(mountOpts);
3272
- await instance.waitUntilExit();
3273
- } catch (tuiErr) {
3274
- const detail = tuiErr instanceof Error ? tuiErr.message : String(tuiErr);
3275
- console.error("");
3276
- console.error(`Your node is live at ${hostname}.`);
3277
- console.error(
3278
- `The live dashboard could not open (${detail}) \u2014 this is a display issue, not a node issue. Your node keeps running.`
3279
- );
3280
- console.error(
3281
- "Stop it anytime with: npx @toon-protocol/townhouse hs down"
3282
- );
3283
- }
3284
- }
3288
+ await attachDashboard(hostname);
3285
3289
  } catch (err) {
3286
3290
  const { exitCode } = renderFailure(err);
3287
3291
  process.exitCode = exitCode;