@geekmidas/cli 10.0.0-alpha.49 → 10.0.0-alpha.50

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.
@@ -215,6 +215,20 @@ async function prepareEntryCredentials(options) {
215
215
  workspace = await require_config.loadWorkspaceConfig(cwd).then((loaded) => loaded.workspace).catch(() => void 0);
216
216
  secretsRoot = workspace?.root ?? findSecretsRoot(cwd);
217
217
  }
218
+ if (appName && workspace && options.explicitPort === void 0) {
219
+ const { assignAppPorts, describeHolder, holderOf, withAppPorts } = await Promise.resolve().then(() => require("./index.cjs")).then((n) => n.appPorts_exports);
220
+ const assigned = await assignAppPorts(workspace, [appName], {
221
+ free: isPortAvailable,
222
+ holder: holderOf
223
+ });
224
+ for (const { app, from, to, holder } of assigned.moved) logger.log(`↪️ ${app}: ${from} is held by ${describeHolder(holder)}, which is not this workspace's — using ${to}`);
225
+ workspace = withAppPorts(workspace, assigned.ports);
226
+ workspaceAppPort = assigned.ports[appName] ?? workspaceAppPort;
227
+ }
228
+ if (appName) {
229
+ const { APP_TAG_ENV, appTag } = await Promise.resolve().then(() => require("./index.cjs")).then((n) => n.appPorts_exports);
230
+ process.env[APP_TAG_ENV] = appTag(secretsRoot, appName);
231
+ }
218
232
  const resolvedPort = options.explicitPort ?? workspaceAppPort ?? 3e3;
219
233
  const stage = options.stage ?? workspace?.stages.local;
220
234
  const store = stage ? workspace ? await require_store.secretsStoreFor(workspace, stage) : new require_store.FileSecretsStore(secretsRoot) : void 0;
@@ -1972,6 +1986,29 @@ function composeFiles(composePath) {
1972
1986
  }
1973
1987
  /** How long to wait for containers to pass their health checks. */
1974
1988
  const HEALTH_TIMEOUT_MS = 12e4;
1989
+ /** `docker compose up` exited unsuccessfully; its own output said why. */
1990
+ var ComposeUpFailed = class extends Error {
1991
+ services;
1992
+ code;
1993
+ constructor(services, code) {
1994
+ super(`docker compose could not start ${services.join(", ")} (exit ${code ?? "signal"}). Its output above names the container; \`docker compose logs <service>\` shows why it stopped.`);
1995
+ this.services = services;
1996
+ this.code = code;
1997
+ this.name = "ComposeUpFailed";
1998
+ }
1999
+ };
2000
+ /** Run compose with its output on this terminal rather than captured. */
2001
+ function shown(args, services) {
2002
+ return new Promise((resolve, reject) => {
2003
+ const child = (0, node_child_process.spawn)("docker", args, { stdio: [
2004
+ "ignore",
2005
+ "inherit",
2006
+ "inherit"
2007
+ ] });
2008
+ child.on("error", reject);
2009
+ child.on("close", (code) => code === 0 ? resolve() : reject(new ComposeUpFailed(services, code)));
2010
+ });
2011
+ }
1975
2012
  const dockerCli = {
1976
2013
  async publishedPort(composePath, service, inside) {
1977
2014
  try {
@@ -1988,8 +2025,8 @@ const dockerCli = {
1988
2025
  return;
1989
2026
  }
1990
2027
  },
1991
- async up(composePath, services) {
1992
- await run("docker", [
2028
+ async up(composePath, services, options = {}) {
2029
+ const args = [
1993
2030
  "compose",
1994
2031
  ...composeFiles(composePath),
1995
2032
  "up",
@@ -1998,7 +2035,9 @@ const dockerCli = {
1998
2035
  "--wait",
1999
2036
  `--wait-timeout=${Math.floor(HEALTH_TIMEOUT_MS / 1e3)}`,
2000
2037
  ...services
2001
- ]);
2038
+ ];
2039
+ if (options.show) return shown(args, services);
2040
+ await run("docker", args);
2002
2041
  },
2003
2042
  async copyOut(composePath, service, from, to) {
2004
2043
  await (0, node_fs_promises.mkdir)((0, node_path.dirname)(to), { recursive: true });
@@ -2746,9 +2785,13 @@ async function reconcile(options) {
2746
2785
  require_workspace.TEST_STAGE
2747
2786
  ]);
2748
2787
  }
2749
- if (start && plan.containers.length > 0) await docker.up(composePath, plan.containers);
2788
+ if (start && plan.containers.length > 0) {
2789
+ options.progress?.(`🐳 Starting ${plan.containers.join(", ")} — the first start pulls each image, which can take a few minutes`);
2790
+ await docker.up(composePath, plan.containers, options.progress ? { show: true } : {});
2791
+ }
2750
2792
  if (start && plan.containers.includes("caddy")) await docker.reload(composePath, "caddy").catch(() => {});
2751
2793
  if (start && plan.containers.includes("caddy")) await docker.copyOut(composePath, "caddy", CADDY_ROOT_IN_CONTAINER, (0, node_path.join)(root, LOCAL_CA_PATH)).catch(() => {});
2794
+ if (start && provision) options.progress?.("🗄️ Creating what the constructs declare — databases, roles, buckets, topics");
2752
2795
  const provisioned = start && provision ? await create(plan, ports, sql, buckets, carriers, project) : [];
2753
2796
  await saveState(root, {
2754
2797
  hash,
@@ -2920,7 +2963,8 @@ async function reconcileWorkspace(workspace, options) {
2920
2963
  metroPorts: metroPorts(workspace, manifest),
2921
2964
  fakes,
2922
2965
  apps: (containers) => appServices(workspace, manifest, containers, runnables, fakes),
2923
- ...options.start === void 0 ? {} : { start: options.start }
2966
+ ...options.start === void 0 ? {} : { start: options.start },
2967
+ ...options.progress ? { progress: options.progress } : {}
2924
2968
  });
2925
2969
  await savePortState(workspace.root, { ...result.ports });
2926
2970
  return result;
@@ -3121,4 +3165,4 @@ Object.defineProperty(exports, "workspace_exports", {
3121
3165
  }
3122
3166
  });
3123
3167
 
3124
- //# sourceMappingURL=workspace-vafrzZTC.cjs.map
3168
+ //# sourceMappingURL=workspace-j6ZxvJqq.cjs.map