@zitadel/cli 0.1.0-alpha.1 → 0.1.0-alpha.10

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.
Files changed (45) hide show
  1. package/README.md +116 -26
  2. package/SKILLS.md +102 -24
  3. package/dist/commands/apply.mjs +4 -5
  4. package/dist/commands/apply.mjs.map +1 -1
  5. package/dist/commands/doctor.mjs +214 -50
  6. package/dist/commands/doctor.mjs.map +1 -1
  7. package/dist/commands/eject.mjs +14 -7
  8. package/dist/commands/eject.mjs.map +1 -1
  9. package/dist/commands/logs.mjs +15 -7
  10. package/dist/commands/logs.mjs.map +1 -1
  11. package/dist/commands/plan.mjs +4 -5
  12. package/dist/commands/plan.mjs.map +1 -1
  13. package/dist/commands/reset.mjs +28 -12
  14. package/dist/commands/reset.mjs.map +1 -1
  15. package/dist/commands/setup.mjs +266 -106
  16. package/dist/commands/setup.mjs.map +1 -1
  17. package/dist/commands/start.mjs +180 -24
  18. package/dist/commands/start.mjs.map +1 -1
  19. package/dist/commands/status.mjs +40 -16
  20. package/dist/commands/status.mjs.map +1 -1
  21. package/dist/commands/stop.mjs +72 -11
  22. package/dist/commands/stop.mjs.map +1 -1
  23. package/dist/docker-CnGQK3ZK.mjs +432 -0
  24. package/dist/docker-CnGQK3ZK.mjs.map +1 -0
  25. package/dist/docker-guidance-ypN3IM3o.mjs +21 -0
  26. package/dist/docker-guidance-ypN3IM3o.mjs.map +1 -0
  27. package/dist/{oclif-DSPO9Sck.mjs → oclif-B7lBzh3R.mjs} +158 -63
  28. package/dist/oclif-B7lBzh3R.mjs.map +1 -0
  29. package/dist/orca-BoTFU8SI.mjs +2581 -0
  30. package/dist/orca-BoTFU8SI.mjs.map +1 -0
  31. package/dist/ports-B09RjuHx.mjs +111 -0
  32. package/dist/ports-B09RjuHx.mjs.map +1 -0
  33. package/dist/processes-Cw8TO1SY.mjs +120 -0
  34. package/dist/processes-Cw8TO1SY.mjs.map +1 -0
  35. package/dist/{project-Dwb9WVAT.mjs → project-Cd0L3PtM.mjs} +3 -3
  36. package/dist/{project-Dwb9WVAT.mjs.map → project-Cd0L3PtM.mjs.map} +1 -1
  37. package/dist/{sync-DmtTYNmq.mjs → sync-BojoQm2P.mjs} +3 -3
  38. package/dist/{sync-DmtTYNmq.mjs.map → sync-BojoQm2P.mjs.map} +1 -1
  39. package/oclif.manifest.json +49 -5
  40. package/package.json +8 -41
  41. package/dist/docker-C0aVpJqm.mjs +0 -209
  42. package/dist/docker-C0aVpJqm.mjs.map +0 -1
  43. package/dist/oclif-DSPO9Sck.mjs.map +0 -1
  44. package/dist/orca-DOxshV9n.mjs +0 -1009
  45. package/dist/orca-DOxshV9n.mjs.map +0 -1
@@ -1,6 +1,6 @@
1
- import { _ as readRuntimeMetadata, b as runtimeSummary, m as localContainerName, t as BaseCommand, u as checkLocalServerHealth } from "../oclif-DSPO9Sck.mjs";
2
- import { a as readZitadelConfig, n as hasZitadelSecret, o as readZitadelSecret, r as readDevelopmentIssuer, t as hasZitadelConfig } from "../project-Dwb9WVAT.mjs";
3
- import { s as inspectContainer } from "../docker-C0aVpJqm.mjs";
1
+ import { S as resolveCwd, _ as runtimeSummary, b as publicCliCommand, c as checkLocalServerHealth, m as readRuntimeMetadata, t as BaseCommand } from "../oclif-B7lBzh3R.mjs";
2
+ import { a as readZitadelConfig, n as hasZitadelSecret, o as readZitadelSecret, r as readDevelopmentIssuer, t as hasZitadelConfig } from "../project-Cd0L3PtM.mjs";
3
+ import { m as isProcessRunning, s as inspectContainer } from "../docker-CnGQK3ZK.mjs";
4
4
  //#region src/commands/status.ts
5
5
  /**
6
6
  * `zitadel status` — summarize the local server and project state.
@@ -13,25 +13,30 @@ var Status = class Status extends BaseCommand {
13
13
  static description = "Summarize the local Zitadel server and project state.";
14
14
  async run() {
15
15
  const { flags } = await this.parse(Status);
16
- const runtime = await readRuntimeMetadata(flags.cwd ? String(flags.cwd) : process.cwd());
16
+ const runtime = await readRuntimeMetadata(resolveCwd(typeof flags.cwd === "string" ? flags.cwd : void 0));
17
17
  if (flags.server === "local") await this.toMeta(flags, {
18
18
  resolveServer: false,
19
19
  source: runtime?.server_url ?? "http://localhost:8080"
20
20
  });
21
21
  else await this.toMeta(flags);
22
- const { cwd } = this.meta;
23
- const containerName = runtime?.container_name ?? localContainerName(cwd);
24
22
  let docker;
25
23
  let dockerError;
26
- try {
27
- docker = await inspectContainer(containerName);
24
+ if (runtime?.backend === "docker") try {
25
+ docker = await inspectContainer(runtime.container_name);
28
26
  } catch (error) {
29
27
  dockerError = error instanceof Error ? error.message : String(error);
30
28
  }
31
29
  const healthy = runtime ? await checkLocalServerHealth(runtime.server_url) : false;
32
- const serverLifecycle = runtime ? docker?.running && healthy ? "running" : docker?.exists ? "unhealthy" : "stopped" : "missing";
33
- const project = await projectStatus(cwd);
34
- const nextCommands = nextCommandsFor(serverLifecycle, project.lifecycle);
30
+ const processRunning = runtime?.backend === "binary" ? isProcessRunning(runtime.pid) : false;
31
+ const serverLifecycle = lifecycleForRuntime({
32
+ docker,
33
+ healthy,
34
+ processRunning,
35
+ runtime
36
+ });
37
+ const project = await projectStatus(this.meta.cwd);
38
+ const nextCommands = nextCommandsFor(serverLifecycle, project.lifecycle, this.meta.cliVersion);
39
+ const nextActions = nextActionsFor(project.lifecycle);
35
40
  return this.emit({
36
41
  status: "ok",
37
42
  data: {
@@ -45,17 +50,32 @@ var Status = class Status extends BaseCommand {
45
50
  container_exists: docker?.exists ?? false,
46
51
  container_running: docker?.running ?? false
47
52
  },
53
+ process: runtime?.backend === "binary" ? {
54
+ pid: runtime.pid,
55
+ running: processRunning
56
+ } : void 0,
48
57
  health: {
49
58
  healthy,
50
59
  url: runtime?.server_url
51
60
  }
52
61
  },
53
62
  project,
63
+ next_actions: nextActions,
54
64
  next_commands: nextCommands
55
65
  }
56
66
  });
57
67
  }
58
68
  };
69
+ function lifecycleForRuntime(input) {
70
+ if (!input.runtime) return "missing";
71
+ if (input.runtime.backend === "binary") {
72
+ if (input.processRunning && input.healthy) return "running";
73
+ return input.processRunning ? "unhealthy" : "stopped";
74
+ }
75
+ if (input.docker?.running && input.healthy) return "running";
76
+ if (input.docker?.exists) return "unhealthy";
77
+ return "stopped";
78
+ }
59
79
  async function projectStatus(cwd) {
60
80
  if (!await hasZitadelConfig(cwd)) return {
61
81
  lifecycle: "not-configured",
@@ -74,12 +94,16 @@ async function projectStatus(cwd) {
74
94
  issuer: readDevelopmentIssuer(config)
75
95
  };
76
96
  }
77
- function nextCommandsFor(serverLifecycle, projectLifecycle) {
97
+ function nextActionsFor(projectLifecycle) {
98
+ if (projectLifecycle === "not-configured") return ["From your app directory, run setup; the CLI will detect the framework or ask in an empty directory."];
99
+ return [];
100
+ }
101
+ function nextCommandsFor(serverLifecycle, projectLifecycle, cliVersion) {
78
102
  const commands = [];
79
- if (serverLifecycle !== "running") commands.push("zitadel start");
80
- if (projectLifecycle === "not-configured") commands.push("zitadel setup --framework next --server local");
81
- else if (projectLifecycle === "orphaned-config") commands.push("zitadel setup --force", "zitadel doctor --fix");
82
- else commands.push("zitadel doctor", "zitadel apply");
103
+ if (serverLifecycle !== "running") commands.push(publicCliCommand("start", cliVersion));
104
+ if (projectLifecycle === "not-configured") commands.push(publicCliCommand("setup --server local", cliVersion));
105
+ else if (projectLifecycle === "orphaned-config") commands.push(publicCliCommand("setup --force", cliVersion), publicCliCommand("doctor --fix", cliVersion));
106
+ else commands.push(publicCliCommand("doctor", cliVersion), publicCliCommand("apply", cliVersion));
83
107
  return commands;
84
108
  }
85
109
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"status.mjs","names":[],"sources":["../../src/commands/status.ts"],"sourcesContent":["import { BaseCommand, type JsonEnvelope } from \"../lib/oclif\";\nimport { inspectContainer } from \"../lib/local-server/docker\";\nimport {\n DEFAULT_LOCAL_SERVER_URL,\n checkLocalServerHealth,\n localContainerName,\n readRuntimeMetadata,\n runtimeSummary,\n} from \"../lib/local-server/runtime\";\nimport {\n hasZitadelConfig,\n hasZitadelSecret,\n readDevelopmentIssuer,\n readZitadelConfig,\n readZitadelSecret,\n} from \"../lib/project\";\n\n/**\n * `zitadel status` — summarize the local server and project state.\n *\n * This is intentionally informational: a missing `zitadel.json`, stopped\n * local server, or orphaned config should be visible without making `status`\n * itself fail.\n */\nexport default class Status extends BaseCommand {\n static override description = \"Summarize the local Zitadel server and project state.\";\n\n async run(): Promise<JsonEnvelope> {\n const { flags } = await this.parse(Status);\n const runtime = await readRuntimeMetadata(flags.cwd ? String(flags.cwd) : process.cwd());\n if (flags.server === \"local\") {\n await this.toMeta(flags, {\n resolveServer: false,\n source: runtime?.server_url ?? DEFAULT_LOCAL_SERVER_URL,\n });\n } else {\n await this.toMeta(flags);\n }\n const { cwd } = this.meta;\n\n const containerName = runtime?.container_name ?? localContainerName(cwd);\n let docker: Awaited<ReturnType<typeof inspectContainer>> | undefined;\n let dockerError: string | undefined;\n try {\n docker = await inspectContainer(containerName);\n } catch (error) {\n dockerError = error instanceof Error ? error.message : String(error);\n }\n const healthy = runtime ? await checkLocalServerHealth(runtime.server_url) : false;\n const serverLifecycle = runtime\n ? docker?.running && healthy\n ? \"running\"\n : docker?.exists\n ? \"unhealthy\"\n : \"stopped\"\n : \"missing\";\n\n const project = await projectStatus(cwd);\n const nextCommands = nextCommandsFor(serverLifecycle, project.lifecycle);\n\n return this.emit({\n status: \"ok\",\n data: {\n title: \"Zitadel status.\",\n server: {\n lifecycle: serverLifecycle,\n runtime: runtimeSummary(runtime),\n docker: {\n available: dockerError === undefined,\n error: dockerError,\n container_exists: docker?.exists ?? false,\n container_running: docker?.running ?? false,\n },\n health: {\n healthy,\n url: runtime?.server_url,\n },\n },\n project,\n next_commands: nextCommands,\n },\n });\n }\n}\n\ntype ProjectStatus =\n | {\n lifecycle: \"not-configured\";\n message: string;\n }\n | {\n lifecycle: \"orphaned-config\";\n project_id?: string;\n message: string;\n }\n | {\n lifecycle: \"configured\";\n project_id: string;\n issuer?: string;\n };\n\nasync function projectStatus(cwd: string): Promise<ProjectStatus> {\n if (!(await hasZitadelConfig(cwd))) {\n return {\n lifecycle: \"not-configured\",\n message: \"zitadel.json has not been created yet.\",\n };\n }\n\n const config = await readZitadelConfig(cwd);\n if (!(await hasZitadelSecret(cwd))) {\n return {\n lifecycle: \"orphaned-config\",\n project_id: typeof config.project === \"string\" ? config.project : undefined,\n message: \"zitadel.json exists but .zitadel/secret is missing.\",\n };\n }\n\n const secret = await readZitadelSecret(cwd);\n return {\n lifecycle: \"configured\",\n project_id: String(config.project ?? secret.project_id ?? \"\"),\n issuer: readDevelopmentIssuer(config),\n };\n}\n\nfunction nextCommandsFor(serverLifecycle: string, projectLifecycle: ProjectStatus[\"lifecycle\"]): string[] {\n const commands: string[] = [];\n if (serverLifecycle !== \"running\") {\n commands.push(\"zitadel start\");\n }\n if (projectLifecycle === \"not-configured\") {\n commands.push(\"zitadel setup --framework next --server local\");\n } else if (projectLifecycle === \"orphaned-config\") {\n commands.push(\"zitadel setup --force\", \"zitadel doctor --fix\");\n } else {\n commands.push(\"zitadel doctor\", \"zitadel apply\");\n }\n return commands;\n}\n"],"mappings":";;;;;;;;;;;AAwBA,IAAqB,SAArB,MAAqB,eAAe,YAAY;CAC9C,OAAgB,cAAc;CAE9B,MAAM,MAA6B;EACjC,MAAM,EAAE,UAAU,MAAM,KAAK,MAAM,OAAO;EAC1C,MAAM,UAAU,MAAM,oBAAoB,MAAM,MAAM,OAAO,MAAM,IAAI,GAAG,QAAQ,KAAK,CAAC;AACxF,MAAI,MAAM,WAAW,QACnB,OAAM,KAAK,OAAO,OAAO;GACvB,eAAe;GACf,QAAQ,SAAS,cAAA;GAClB,CAAC;MAEF,OAAM,KAAK,OAAO,MAAM;EAE1B,MAAM,EAAE,QAAQ,KAAK;EAErB,MAAM,gBAAgB,SAAS,kBAAkB,mBAAmB,IAAI;EACxE,IAAI;EACJ,IAAI;AACJ,MAAI;AACF,YAAS,MAAM,iBAAiB,cAAc;WACvC,OAAO;AACd,iBAAc,iBA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O"}
1
+ {"version":3,"file":"status.mjs","names":[],"sources":["../../src/commands/status.ts"],"sourcesContent":["import { isProcessRunning } from \"../lib/local-server/binary\";\nimport { inspectContainer } from \"../lib/local-server/docker\";\nimport {\n DEFAULT_LOCAL_SERVER_URL,\n checkLocalServerHealth,\n readRuntimeMetadata,\n runtimeSummary,\n} from \"../lib/local-server/runtime\";\nimport { BaseCommand, type JsonEnvelope } from \"../lib/oclif\";\nimport { resolveCwd } from \"../lib/paths\";\nimport {\n hasZitadelConfig,\n hasZitadelSecret,\n readDevelopmentIssuer,\n readZitadelConfig,\n readZitadelSecret,\n} from \"../lib/project\";\nimport { publicCliCommand } from \"../lib/public-cli\";\n\n/**\n * `zitadel status` — summarize the local server and project state.\n *\n * This is intentionally informational: a missing `zitadel.json`, stopped\n * local server, or orphaned config should be visible without making `status`\n * itself fail.\n */\nexport default class Status extends BaseCommand {\n static override description = \"Summarize the local Zitadel server and project state.\";\n\n async run(): Promise<JsonEnvelope> {\n const { flags } = await this.parse(Status);\n const cwd = resolveCwd(typeof flags.cwd === \"string\" ? flags.cwd : undefined);\n const runtime = await readRuntimeMetadata(cwd);\n if (flags.server === \"local\") {\n await this.toMeta(flags, {\n resolveServer: false,\n source: runtime?.server_url ?? DEFAULT_LOCAL_SERVER_URL,\n });\n } else {\n await this.toMeta(flags);\n }\n let docker: Awaited<ReturnType<typeof inspectContainer>> | undefined;\n let dockerError: string | undefined;\n if (runtime?.backend === \"docker\") {\n try {\n docker = await inspectContainer(runtime.container_name);\n } catch (error) {\n dockerError = error instanceof Error ? error.message : String(error);\n }\n }\n const healthy = runtime ? await checkLocalServerHealth(runtime.server_url) : false;\n const processRunning = runtime?.backend === \"binary\" ? isProcessRunning(runtime.pid) : false;\n const serverLifecycle = lifecycleForRuntime({ docker, healthy, processRunning, runtime });\n\n const project = await projectStatus(this.meta.cwd);\n const nextCommands = nextCommandsFor(serverLifecycle, project.lifecycle, this.meta.cliVersion);\n const nextActions = nextActionsFor(project.lifecycle);\n\n return this.emit({\n status: \"ok\",\n data: {\n title: \"Zitadel status.\",\n server: {\n lifecycle: serverLifecycle,\n runtime: runtimeSummary(runtime),\n docker: {\n available: dockerError === undefined,\n error: dockerError,\n container_exists: docker?.exists ?? false,\n container_running: docker?.running ?? false,\n },\n process:\n runtime?.backend === \"binary\"\n ? {\n pid: runtime.pid,\n running: processRunning,\n }\n : undefined,\n health: {\n healthy,\n url: runtime?.server_url,\n },\n },\n project,\n next_actions: nextActions,\n next_commands: nextCommands,\n },\n });\n }\n}\n\nfunction lifecycleForRuntime(input: {\n docker: Awaited<ReturnType<typeof inspectContainer>> | undefined;\n healthy: boolean;\n processRunning: boolean;\n runtime: Awaited<ReturnType<typeof readRuntimeMetadata>>;\n}): string {\n if (!input.runtime) {\n return \"missing\";\n }\n if (input.runtime.backend === \"binary\") {\n if (input.processRunning && input.healthy) {\n return \"running\";\n }\n return input.processRunning ? \"unhealthy\" : \"stopped\";\n }\n if (input.docker?.running && input.healthy) {\n return \"running\";\n }\n if (input.docker?.exists) {\n return \"unhealthy\";\n }\n return \"stopped\";\n}\n\ntype ProjectStatus =\n | {\n lifecycle: \"not-configured\";\n message: string;\n }\n | {\n lifecycle: \"orphaned-config\";\n project_id?: string;\n message: string;\n }\n | {\n lifecycle: \"configured\";\n project_id: string;\n issuer?: string;\n };\n\nasync function projectStatus(cwd: string): Promise<ProjectStatus> {\n if (!(await hasZitadelConfig(cwd))) {\n return {\n lifecycle: \"not-configured\",\n message: \"zitadel.json has not been created yet.\",\n };\n }\n\n const config = await readZitadelConfig(cwd);\n if (!(await hasZitadelSecret(cwd))) {\n return {\n lifecycle: \"orphaned-config\",\n project_id: typeof config.project === \"string\" ? config.project : undefined,\n message: \"zitadel.json exists but .zitadel/secret is missing.\",\n };\n }\n\n const secret = await readZitadelSecret(cwd);\n return {\n lifecycle: \"configured\",\n project_id: String(config.project ?? secret.project_id ?? \"\"),\n issuer: readDevelopmentIssuer(config),\n };\n}\n\nfunction nextActionsFor(projectLifecycle: ProjectStatus[\"lifecycle\"]): string[] {\n if (projectLifecycle === \"not-configured\") {\n return [\n \"From your app directory, run setup; the CLI will detect the framework or ask in an empty directory.\",\n ];\n }\n return [];\n}\n\nfunction nextCommandsFor(\n serverLifecycle: string,\n projectLifecycle: ProjectStatus[\"lifecycle\"],\n cliVersion: string,\n): string[] {\n const commands: string[] = [];\n if (serverLifecycle !== \"running\") {\n commands.push(publicCliCommand(\"start\", cliVersion));\n }\n if (projectLifecycle === \"not-configured\") {\n commands.push(publicCliCommand(\"setup --server local\", cliVersion));\n } else if (projectLifecycle === \"orphaned-config\") {\n commands.push(\n publicCliCommand(\"setup --force\", cliVersion),\n publicCliCommand(\"doctor --fix\", cliVersion),\n );\n } else {\n commands.push(publicCliCommand(\"doctor\", cliVersion), publicCliCommand(\"apply\", cliVersion));\n }\n return commands;\n}\n"],"mappings":";;;;;;;;;;;AA0BA,IAAqB,SAArB,MAAqB,eAAe,YAAY;CAC9C,OAAgB,cAAc;CAE9B,MAAM,MAA6B;EACjC,MAAM,EAAE,UAAU,MAAM,KAAK,MAAM,OAAO;EAE1C,MAAM,UAAU,MAAM,oBADV,WAAW,OAAO,MAAM,QAAQ,WAAW,MAAM,MAAM,KAAA,EACtB,CAAC;AAC9C,MAAI,MAAM,WAAW,QACnB,OAAM,KAAK,OAAO,OAAO;GACvB,eAAe;GACf,QAAQ,SAAS,cAAA;GAClB,CAAC;MAEF,OAAM,KAAK,OAAO,MAAM;EAE1B,IAAI;EACJ,IAAI;AACJ,MAAI,SAAS,YAAY,SACvB,KAAI;AACF,YAAS,MAAM,iBAAiB,QAAQ,eAAe;WAChD,OAAO;AACd,iBAAc,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;;EAGxE,MAAM,UAAU,UAAU,MAAM,uBAAuB,QAAQ,WAAW,GAAG;EAC7E,MAAM,iBAAiB,SAAS,YAAY,WAAW,iBAAiB,QAAQ,IAAI,GAAG;EACvF,MAAM,kBAAkB,oBAAoB;GAAE;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QAAQ,sBAAsB,OAAO;EACtC;;AAGH,SAAS,eAAe,kBAAwD;AAC9E,KAAI,qBAAqB,iBACvB,QAAO,CACL,sGACD;AAEH,QAAO,EAAE;;AAGX,SAAS,gBACP,iBACA,kBACA,YACU;CACV,MAAM,WAAqB,EAAE;AAC7B,KAAI,oBAAoB,UACtB,UAAS,KAAK,iBAAiB,SAAS,WAAW,CAAC;AAEtD,KAAI,qBAAqB,iBACvB,UAAS,KAAK,iBAAiB,wBAAwB,WAAW,CAAC;UAC1D,qBAAqB,kBAC9B,UAAS,KACP,iBAAiB,iBAAiB,WAAW,EAC7C,iBAAiB,gBAAgB,WAAW,CAC7C;KAED,UAAS,KAAK,iBAAiB,UAAU,WAAW,EAAE,iBAAiB,SAAS,WAAW,CAAC;AAE9F,QAAO"}
@@ -1,39 +1,100 @@
1
- import { _ as readRuntimeMetadata, m as localContainerName, t as BaseCommand } from "../oclif-DSPO9Sck.mjs";
2
- import { u as stopAndRemoveContainer } from "../docker-C0aVpJqm.mjs";
1
+ import { E as ZitadelError, S as resolveCwd, b as publicCliCommand, f as localContainerName, m as readRuntimeMetadata, t as BaseCommand } from "../oclif-B7lBzh3R.mjs";
2
+ import { g as stopBinaryRuntime, u as stopAndRemoveContainer } from "../docker-CnGQK3ZK.mjs";
3
+ import { t as discoverManagedRuntimeProcesses } from "../processes-Cw8TO1SY.mjs";
4
+ import { Flags } from "@oclif/core";
3
5
  //#region src/commands/stop.ts
4
6
  var Stop = class Stop extends BaseCommand {
5
7
  static description = "Stop the local Zitadel server.";
8
+ static flags = { all: Flags.boolean({ description: "Stop all discovered CLI-managed local Zitadel runtime processes." }) };
6
9
  async run() {
7
10
  const { flags } = await this.parse(Stop);
8
- const runtime = await readRuntimeMetadata(flags.cwd ? String(flags.cwd) : process.cwd());
11
+ const runtime = await readRuntimeMetadata(resolveCwd(typeof flags.cwd === "string" ? flags.cwd : void 0));
9
12
  await this.toMeta(flags, {
10
13
  resolveServer: false,
11
14
  source: runtime?.server_url ?? "http://localhost:8080"
12
15
  });
13
- const containerName = runtime?.container_name ?? localContainerName(this.meta.cwd);
16
+ if (flags.all) return this.stopAllManagedRuntimes();
17
+ const containerName = runtime?.backend === "docker" ? runtime.container_name : localContainerName(this.meta.cwd);
14
18
  if (this.meta.dryRun) return this.emit({
15
19
  status: "ok",
16
20
  data: {
17
21
  title: "Local Zitadel server stop plan.",
18
22
  runtime: {
19
- container_name: containerName,
23
+ backend: runtime?.backend ?? "missing",
24
+ ...runtime?.backend === "binary" ? {
25
+ pid: runtime.pid,
26
+ log_path: runtime.log_path
27
+ } : { container_name: containerName },
20
28
  data_preserved: true,
21
29
  data_dir: runtime?.data_dir
22
30
  },
23
- next_commands: ["zitadel stop"]
31
+ next_commands: [publicCliCommand("stop", this.meta.cliVersion)]
24
32
  }
25
33
  });
26
- await stopAndRemoveContainer(containerName);
34
+ let stopResult;
35
+ if (runtime?.backend === "binary") {
36
+ stopResult = await stopBinaryRuntime(runtime.pid);
37
+ if (stopResult.status === "failed") throw new ZitadelError("E_VALIDATION", "Local Zitadel server did not stop", {
38
+ hint: "Inspect the local runtime process and stop it manually, then rerun `zitadel stop`.",
39
+ details: {
40
+ runtime,
41
+ stop_result: stopResult
42
+ }
43
+ });
44
+ } else await stopAndRemoveContainer(containerName);
27
45
  return this.emit({
28
46
  status: "ok",
29
47
  data: {
30
- title: "Local Zitadel server stopped.",
48
+ title: stopResult?.status === "stale" ? "Local Zitadel server was not running." : "Local Zitadel server stopped.",
31
49
  runtime: {
32
- container_name: containerName,
50
+ backend: runtime?.backend ?? "missing",
51
+ ...runtime?.backend === "binary" ? {
52
+ pid: runtime.pid,
53
+ log_path: runtime.log_path,
54
+ stop_result: stopResult
55
+ } : { container_name: containerName },
33
56
  data_preserved: true,
34
57
  data_dir: runtime?.data_dir
35
- },
36
- next_commands: ["zitadel start", "zitadel reset --force"]
58
+ }
59
+ }
60
+ });
61
+ }
62
+ async stopAllManagedRuntimes() {
63
+ const discovery = await discoverManagedRuntimeProcesses();
64
+ if (!discovery.supported) return this.emit({
65
+ status: "ok",
66
+ data: {
67
+ title: "Managed local runtime process discovery is unavailable.",
68
+ sweep: {
69
+ supported: false,
70
+ error: discovery.error,
71
+ stopped: []
72
+ }
73
+ },
74
+ warnings: ["managed-runtime-processes: discovery unavailable"]
75
+ });
76
+ const results = [];
77
+ for (const processInfo of discovery.processes) results.push({
78
+ process: processInfo,
79
+ stop_result: await stopBinaryRuntime(processInfo.pid)
80
+ });
81
+ if (results.filter((result) => result.stop_result.status === "failed").length > 0) throw new ZitadelError("E_VALIDATION", "Some managed local runtime processes did not stop", {
82
+ hint: "Inspect the failed process IDs and stop them manually, then rerun `zitadel stop --all`.",
83
+ details: {
84
+ supported: true,
85
+ results
86
+ }
87
+ });
88
+ return this.emit({
89
+ status: "ok",
90
+ data: {
91
+ title: results.length === 0 ? "No host-wide managed local runtime processes found." : "Host-wide managed local runtime processes stopped.",
92
+ sweep: {
93
+ supported: true,
94
+ scope: "host",
95
+ count: results.length,
96
+ results
97
+ }
37
98
  }
38
99
  });
39
100
  }
@@ -1 +1 @@
1
- {"version":3,"file":"stop.mjs","names":[],"sources":["../../src/commands/stop.ts"],"sourcesContent":["import { BaseCommand, type JsonEnvelope } from \"../lib/oclif\";\nimport { stopAndRemoveContainer } from \"../lib/local-server/docker\";\nimport {\n DEFAULT_LOCAL_SERVER_URL,\n localContainerName,\n readRuntimeMetadata,\n} from \"../lib/local-server/runtime\";\n\nexport default class Stop extends BaseCommand {\n static override description = \"Stop the local Zitadel server.\";\n\n async run(): Promise<JsonEnvelope> {\n const { flags } = await this.parse(Stop);\n const runtime = await readRuntimeMetadata(flags.cwd ? String(flags.cwd) : process.cwd());\n await this.toMeta(flags, {\n resolveServer: false,\n source: runtime?.server_url ?? DEFAULT_LOCAL_SERVER_URL,\n });\n\n const containerName = runtime?.container_name ?? localContainerName(this.meta.cwd);\n if (this.meta.dryRun) {\n return this.emit({\n status: \"ok\",\n data: {\n title: \"Local Zitadel server stop plan.\",\n runtime: {\n container_name: containerName,\n data_preserved: true,\n data_dir: runtime?.data_dir,\n },\n next_commands: [\"zitadel stop\"],\n },\n });\n }\n\n await stopAndRemoveContainer(containerName);\n\n return this.emit({\n status: \"ok\",\n data: {\n title: \"Local Zitadel server stopped.\",\n runtime: {\n container_name: containerName,\n data_preserved: true,\n data_dir: runtime?.data_dir,\n },\n next_commands: [\"zitadel start\", \"zitadel reset --force\"],\n },\n });\n }\n}\n"],"mappings":";;;AAQA,IAAqB,OAArB,MAAqB,aAAa,YAAY;CAC5C,OAAgB,cAAc;CAE9B,MAAM,MAA6B;EACjC,MAAM,EAAE,UAAU,MAAM,KAAK,MAAM,KAAK;EACxC,MAAM,UAAU,MAAM,oBAAoB,MAAM,MAAM,OAAO,MAAM,IAAI,GAAG,QAAQ,KAAK,CAAC;AACxF,QAAM,KAAK,OAAO,OAAO;GACvB,eAAe;GACf,QAAQ,SAAS,cAAA;GAClB,CAAC;EAEF,MAAM,gBAAgB,SAAS,kBAAkB,mBAAmB,KAAK,KAAK,IAAI;AAClF,MAAI,KAAK,KAAK,OACZ,QAAO,KAAK,KAAK;GACf,QAAQ;GACR,MAAM;IACJ,OAAO;IACP,SAAS;KACP,gBAAgB;KAChB,gBAAgB;KAChB,UAAU,SAAS;KACpB;IACD,eAAe,CAAC,eAAe;IAChC;GACF,CAAC;AAGJ,QAAM,uBAAuB,cAAc;AAE3C,SAAO,KAAK,KAAK;GACf,QAAQ;GACR,MAAM;IACJ,OAAO;IACP,SAAS;KACP,gBAAgB;KAChB,gBAAgB;KAChB,UAAU,SAAS;KACpB;IACD,eAAe,CAAC,iBAAiB,wBAAwB;IAC1D;GACF,CAAC"}
1
+ {"version":3,"file":"stop.mjs","names":[],"sources":["../../src/commands/stop.ts"],"sourcesContent":["import { Flags } from \"@oclif/core\";\n\nimport { ZitadelError } from \"../lib/errors\";\nimport { stopBinaryRuntime, type StopBinaryRuntimeResult } from \"../lib/local-server/binary\";\nimport { stopAndRemoveContainer } from \"../lib/local-server/docker\";\nimport {\n discoverManagedRuntimeProcesses,\n type ManagedRuntimeProcess,\n} from \"../lib/local-server/processes\";\nimport {\n DEFAULT_LOCAL_SERVER_URL,\n localContainerName,\n readRuntimeMetadata,\n} from \"../lib/local-server/runtime\";\nimport { BaseCommand, type JsonEnvelope } from \"../lib/oclif\";\nimport { resolveCwd } from \"../lib/paths\";\nimport { publicCliCommand } from \"../lib/public-cli\";\n\nexport default class Stop extends BaseCommand {\n static override description = \"Stop the local Zitadel server.\";\n static override flags = {\n all: Flags.boolean({\n description: \"Stop all discovered CLI-managed local Zitadel runtime processes.\",\n }),\n };\n\n async run(): Promise<JsonEnvelope> {\n const { flags } = await this.parse(Stop);\n const cwd = resolveCwd(typeof flags.cwd === \"string\" ? flags.cwd : undefined);\n const runtime = await readRuntimeMetadata(cwd);\n await this.toMeta(flags, {\n resolveServer: false,\n source: runtime?.server_url ?? DEFAULT_LOCAL_SERVER_URL,\n });\n\n if (flags.all) {\n return this.stopAllManagedRuntimes();\n }\n\n const containerName =\n runtime?.backend === \"docker\" ? runtime.container_name : localContainerName(this.meta.cwd);\n if (this.meta.dryRun) {\n return this.emit({\n status: \"ok\",\n data: {\n title: \"Local Zitadel server stop plan.\",\n runtime: {\n backend: runtime?.backend ?? \"missing\",\n ...(runtime?.backend === \"binary\"\n ? { pid: runtime.pid, log_path: runtime.log_path }\n : { container_name: containerName }),\n data_preserved: true,\n data_dir: runtime?.data_dir,\n },\n next_commands: [publicCliCommand(\"stop\", this.meta.cliVersion)],\n },\n });\n }\n\n let stopResult: Awaited<ReturnType<typeof stopBinaryRuntime>> | undefined;\n if (runtime?.backend === \"binary\") {\n stopResult = await stopBinaryRuntime(runtime.pid);\n if (stopResult.status === \"failed\") {\n throw new ZitadelError(\"E_VALIDATION\", \"Local Zitadel server did not stop\", {\n hint: \"Inspect the local runtime process and stop it manually, then rerun `zitadel stop`.\",\n details: { runtime, stop_result: stopResult },\n });\n }\n } else {\n await stopAndRemoveContainer(containerName);\n }\n\n return this.emit({\n status: \"ok\",\n data: {\n title:\n stopResult?.status === \"stale\"\n ? \"Local Zitadel server was not running.\"\n : \"Local Zitadel server stopped.\",\n runtime: {\n backend: runtime?.backend ?? \"missing\",\n ...(runtime?.backend === \"binary\"\n ? { pid: runtime.pid, log_path: runtime.log_path, stop_result: stopResult }\n : { container_name: containerName }),\n data_preserved: true,\n data_dir: runtime?.data_dir,\n },\n },\n });\n }\n\n private async stopAllManagedRuntimes(): Promise<JsonEnvelope> {\n const discovery = await discoverManagedRuntimeProcesses();\n if (!discovery.supported) {\n return this.emit({\n status: \"ok\",\n data: {\n title: \"Managed local runtime process discovery is unavailable.\",\n sweep: { supported: false, error: discovery.error, stopped: [] },\n },\n warnings: [\"managed-runtime-processes: discovery unavailable\"],\n });\n }\n\n const results: ManagedRuntimeSweepResult[] = [];\n for (const processInfo of discovery.processes) {\n results.push({\n process: processInfo,\n stop_result: await stopBinaryRuntime(processInfo.pid),\n });\n }\n const failed = results.filter((result) => result.stop_result.status === \"failed\");\n if (failed.length > 0) {\n throw new ZitadelError(\"E_VALIDATION\", \"Some managed local runtime processes did not stop\", {\n hint: \"Inspect the failed process IDs and stop them manually, then rerun `zitadel stop --all`.\",\n details: { supported: true, results },\n });\n }\n\n return this.emit({\n status: \"ok\",\n data: {\n title:\n results.length === 0\n ? \"No host-wide managed local runtime processes found.\"\n : \"Host-wide managed local runtime processes stopped.\",\n sweep: {\n supported: true,\n scope: \"host\",\n count: results.length,\n results,\n },\n },\n });\n }\n}\n\ntype ManagedRuntimeSweepResult = Readonly<{\n process: ManagedRuntimeProcess;\n stop_result: StopBinaryRuntimeResult;\n}>;\n"],"mappings":";;;;;AAkBA,IAAqB,OAArB,MAAqB,aAAa,YAAY;CAC5C,OAAgB,cAAc;CAC9B,OAAgB,QAAQ,EACtB,KAAK,MAAM,QAAQ,EACjB,aAAa,oEACd,CAAC,EACH;CAED,MAAM,MAA6B;EACjC,MAAM,EAAE,UAAU,MAAM,KAAK,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