@zitadel/cli 0.1.0-alpha.0 → 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 (43) hide show
  1. package/README.md +227 -18
  2. package/SKILLS.md +104 -11
  3. package/dist/commands/apply.mjs +4 -4
  4. package/dist/commands/apply.mjs.map +1 -1
  5. package/dist/commands/doctor.mjs +291 -17
  6. package/dist/commands/doctor.mjs.map +1 -1
  7. package/dist/commands/eject.mjs +14 -6
  8. package/dist/commands/eject.mjs.map +1 -1
  9. package/dist/commands/logs.mjs +58 -0
  10. package/dist/commands/logs.mjs.map +1 -0
  11. package/dist/commands/plan.mjs +4 -4
  12. package/dist/commands/plan.mjs.map +1 -1
  13. package/dist/commands/reset.mjs +79 -0
  14. package/dist/commands/reset.mjs.map +1 -0
  15. package/dist/commands/setup.mjs +267 -105
  16. package/dist/commands/setup.mjs.map +1 -1
  17. package/dist/commands/start.mjs +288 -0
  18. package/dist/commands/start.mjs.map +1 -0
  19. package/dist/commands/status.mjs +92 -27
  20. package/dist/commands/status.mjs.map +1 -1
  21. package/dist/commands/stop.mjs +105 -0
  22. package/dist/commands/stop.mjs.map +1 -0
  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/{project-C3pSfbao.mjs → oclif-B7lBzh3R.mjs} +339 -119
  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-Cd0L3PtM.mjs +87 -0
  36. package/dist/project-Cd0L3PtM.mjs.map +1 -0
  37. package/dist/{sync-Cuyh-X1J.mjs → sync-BojoQm2P.mjs} +4 -4
  38. package/dist/{sync-Cuyh-X1J.mjs.map → sync-BojoQm2P.mjs.map} +1 -1
  39. package/oclif.manifest.json +399 -7
  40. package/package.json +8 -41
  41. package/dist/orca-COsUnVoz.mjs +0 -1006
  42. package/dist/orca-COsUnVoz.mjs.map +0 -1
  43. package/dist/project-C3pSfbao.mjs.map +0 -1
@@ -1,46 +1,111 @@
1
- import { a as readZitadelConfig, n as hasZitadelSecret, o as readZitadelSecret, r as readDevelopmentIssuer, s as BaseCommand } from "../project-C3pSfbao.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";
2
4
  //#region src/commands/status.ts
3
5
  /**
4
- * `zitadel status` — summarize the local project state.
6
+ * `zitadel status` — summarize the local server and project state.
5
7
  *
6
- * Reads `zitadel.json` and its secret. A present config with a missing secret
7
- * is treated as an "orphaned" install (returned as skipped with recovery
8
- * commands) rather than an error, so status stays informational and safe to
9
- * run on partial or broken setups.
8
+ * This is intentionally informational: a missing `zitadel.json`, stopped
9
+ * local server, or orphaned config should be visible without making `status`
10
+ * itself fail.
10
11
  */
11
12
  var Status = class Status extends BaseCommand {
12
- static description = "Summarize the local project state.";
13
+ static description = "Summarize the local Zitadel server and project state.";
13
14
  async run() {
14
15
  const { flags } = await this.parse(Status);
15
- await this.toMeta(flags);
16
- const { cwd, source } = this.meta;
17
- const config = await readZitadelConfig(cwd);
18
- if (!await hasZitadelSecret(cwd)) return this.emit({
19
- status: "skipped",
20
- reason: "orphaned-config",
21
- data: {
22
- project_id: typeof config.project === "string" ? config.project : void 0,
23
- lifecycle: "orphaned-config",
24
- message: "zitadel.json exists but .zitadel/secret is missing."
25
- },
26
- nextCommands: ["zitadel setup --force", "zitadel doctor --fix"]
16
+ const runtime = await readRuntimeMetadata(resolveCwd(typeof flags.cwd === "string" ? flags.cwd : void 0));
17
+ if (flags.server === "local") await this.toMeta(flags, {
18
+ resolveServer: false,
19
+ source: runtime?.server_url ?? "http://localhost:8080"
20
+ });
21
+ else await this.toMeta(flags);
22
+ let docker;
23
+ let dockerError;
24
+ if (runtime?.backend === "docker") try {
25
+ docker = await inspectContainer(runtime.container_name);
26
+ } catch (error) {
27
+ dockerError = error instanceof Error ? error.message : String(error);
28
+ }
29
+ const healthy = runtime ? await checkLocalServerHealth(runtime.server_url) : false;
30
+ const processRunning = runtime?.backend === "binary" ? isProcessRunning(runtime.pid) : false;
31
+ const serverLifecycle = lifecycleForRuntime({
32
+ docker,
33
+ healthy,
34
+ processRunning,
35
+ runtime
27
36
  });
28
- const secret = await readZitadelSecret(cwd);
37
+ const project = await projectStatus(this.meta.cwd);
38
+ const nextCommands = nextCommandsFor(serverLifecycle, project.lifecycle, this.meta.cliVersion);
39
+ const nextActions = nextActionsFor(project.lifecycle);
29
40
  return this.emit({
30
41
  status: "ok",
31
42
  data: {
32
- title: "Zitadel project detected.",
33
- project: {
34
- project_id: String(config.project ?? secret.project_id ?? ""),
35
- issuer: readDevelopmentIssuer(config)
43
+ title: "Zitadel status.",
44
+ server: {
45
+ lifecycle: serverLifecycle,
46
+ runtime: runtimeSummary(runtime),
47
+ docker: {
48
+ available: dockerError === void 0,
49
+ error: dockerError,
50
+ container_exists: docker?.exists ?? false,
51
+ container_running: docker?.running ?? false
52
+ },
53
+ process: runtime?.backend === "binary" ? {
54
+ pid: runtime.pid,
55
+ running: processRunning
56
+ } : void 0,
57
+ health: {
58
+ healthy,
59
+ url: runtime?.server_url
60
+ }
36
61
  },
37
- server: source,
38
- next_actions: ["Run `zitadel doctor`.", "Run `zitadel apply` after config changes."],
39
- next_commands: ["zitadel doctor", "zitadel apply"]
62
+ project,
63
+ next_actions: nextActions,
64
+ next_commands: nextCommands
40
65
  }
41
66
  });
42
67
  }
43
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
+ }
79
+ async function projectStatus(cwd) {
80
+ if (!await hasZitadelConfig(cwd)) return {
81
+ lifecycle: "not-configured",
82
+ message: "zitadel.json has not been created yet."
83
+ };
84
+ const config = await readZitadelConfig(cwd);
85
+ if (!await hasZitadelSecret(cwd)) return {
86
+ lifecycle: "orphaned-config",
87
+ project_id: typeof config.project === "string" ? config.project : void 0,
88
+ message: "zitadel.json exists but .zitadel/secret is missing."
89
+ };
90
+ const secret = await readZitadelSecret(cwd);
91
+ return {
92
+ lifecycle: "configured",
93
+ project_id: String(config.project ?? secret.project_id ?? ""),
94
+ issuer: readDevelopmentIssuer(config)
95
+ };
96
+ }
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) {
102
+ const commands = [];
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));
107
+ return commands;
108
+ }
44
109
  //#endregion
45
110
  export { Status as default };
46
111
 
@@ -1 +1 @@
1
- {"version":3,"file":"status.mjs","names":[],"sources":["../../src/commands/status.ts"],"sourcesContent":["import { BaseCommand, type JsonEnvelope } from \"../lib/oclif\";\nimport {\n hasZitadelSecret,\n readDevelopmentIssuer,\n readZitadelConfig,\n readZitadelSecret,\n} from \"../lib/project\";\n\n/**\n * `zitadel status` — summarize the local project state.\n *\n * Reads `zitadel.json` and its secret. A present config with a missing secret\n * is treated as an \"orphaned\" install (returned as skipped with recovery\n * commands) rather than an error, so status stays informational and safe to\n * run on partial or broken setups.\n */\nexport default class Status extends BaseCommand {\n static override description = \"Summarize the local project state.\";\n\n async run(): Promise<JsonEnvelope> {\n const { flags } = await this.parse(Status);\n await this.toMeta(flags);\n const { cwd, source } = this.meta;\n\n const config = await readZitadelConfig(cwd);\n\n if (!(await hasZitadelSecret(cwd))) {\n return this.emit({\n status: \"skipped\",\n reason: \"orphaned-config\",\n data: {\n project_id: typeof config.project === \"string\" ? config.project : undefined,\n lifecycle: \"orphaned-config\",\n message: \"zitadel.json exists but .zitadel/secret is missing.\",\n },\n nextCommands: [\"zitadel setup --force\", \"zitadel doctor --fix\"],\n });\n }\n\n const secret = await readZitadelSecret(cwd);\n return this.emit({\n status: \"ok\",\n data: {\n title: \"Zitadel project detected.\",\n project: {\n project_id: String(config.project ?? secret.project_id ?? \"\"),\n issuer: readDevelopmentIssuer(config),\n },\n server: source,\n next_actions: [\"Run `zitadel doctor`.\", \"Run `zitadel apply` after config changes.\"],\n next_commands: [\"zitadel doctor\", \"zitadel apply\"],\n },\n });\n }\n}\n"],"mappings":";;;;;;;;;;AAgBA,IAAqB,SAArB,MAAqB,eAAe,YAAY;CAC9C,OAAgB,cAAc;CAE9B,MAAM,MAA6B;EACjC,MAAM,EAAE,UAAU,MAAM,KAAK,MAAM,OAAO;AAC1C,QAAM,KAAK,OAAO,MAAM;EACxB,MAAM,EAAE,KAAK,WAAW,KAAK;EAE7B,MAAM,SAAS,MAAM,kBAAkB,IAAI;AAE3C,MAAI,CAAE,MAAM,iBAAiB,IAAI,CAC/B,QAAO,KAAK,KAAK;GACf,QAAQ;GACR,QAAQ;GACR,MAAM;IACJ,YAAY,OAAO,OAAO,YAAY,WAAW,OAAO,UAAU,KAAA;IAClE,WAAW;IACX,SAAS;IACV;GACD,cAAc,CAAC,yBAAyB,uBAAuB;GAChE,CAAC;EAGJ,MAAM,SAAS,MAAM,kBAAkB,IAAI;AAC3C,SAAO,KAAK,KAAK;GACf,QAAQ;GACR,MAAM;IACJ,OAAO;IACP,SAAS;KACP,YAAY,OAAO,OAAO,WAAW,OAAO,cAAc,GAAG;KAC7D,QAAQ,sBAAsB,OAAO;KACtC;IACD,QAAQ;IACR,cAAc,CAAC,yBAAyB,4CAA4C;IACpF,eAAe,CAAC,kBAAkB,gBAAgB;IACnD;GACF,CAAC"}
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,W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SAAO,MAAM,iBAAiB,cAAc;;AAE9C,KAAI,MAAM,QAAQ,WAAW,MAAM,QACjC,QAAO;AAET,KAAI,MAAM,QAAQ,OAChB,QAAO;AAET,QAAO;;AAmBT,eAAe,cAAc,KAAqC;AAChE,KAAI,CAAE,MAAM,iBAAiB,IAAI,CAC/B,QAAO;EACL,WAAW;EACX,SAAS;EACV;CAGH,MAAM,SAAS,MAAM,kBAAkB,IAAI;AAC3C,KAAI,CAAE,MAAM,iBAAiB,IAAI,CAC/B,QAAO;EACL,WAAW;EACX,YAAY,OAAO,OAAO,YAAY,WAAW,OAAO,UAAU,KAAA;EAClE,SAAS;EACV;CAGH,MAAM,SAAS,MAAM,kBAAkB,IAAI;AAC3C,QAAO;EACL,WAAW;EACX,YAAY,OAAO,OAAO,WAAW,OAAO,cAAc,GAAG;EAC7D,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"}
@@ -0,0 +1,105 @@
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";
5
+ //#region src/commands/stop.ts
6
+ var Stop = class Stop extends BaseCommand {
7
+ static description = "Stop the local Zitadel server.";
8
+ static flags = { all: Flags.boolean({ description: "Stop all discovered CLI-managed local Zitadel runtime processes." }) };
9
+ async run() {
10
+ const { flags } = await this.parse(Stop);
11
+ const runtime = await readRuntimeMetadata(resolveCwd(typeof flags.cwd === "string" ? flags.cwd : void 0));
12
+ await this.toMeta(flags, {
13
+ resolveServer: false,
14
+ source: runtime?.server_url ?? "http://localhost:8080"
15
+ });
16
+ if (flags.all) return this.stopAllManagedRuntimes();
17
+ const containerName = runtime?.backend === "docker" ? runtime.container_name : localContainerName(this.meta.cwd);
18
+ if (this.meta.dryRun) return this.emit({
19
+ status: "ok",
20
+ data: {
21
+ title: "Local Zitadel server stop plan.",
22
+ runtime: {
23
+ backend: runtime?.backend ?? "missing",
24
+ ...runtime?.backend === "binary" ? {
25
+ pid: runtime.pid,
26
+ log_path: runtime.log_path
27
+ } : { container_name: containerName },
28
+ data_preserved: true,
29
+ data_dir: runtime?.data_dir
30
+ },
31
+ next_commands: [publicCliCommand("stop", this.meta.cliVersion)]
32
+ }
33
+ });
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);
45
+ return this.emit({
46
+ status: "ok",
47
+ data: {
48
+ title: stopResult?.status === "stale" ? "Local Zitadel server was not running." : "Local Zitadel server stopped.",
49
+ runtime: {
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 },
56
+ data_preserved: true,
57
+ data_dir: runtime?.data_dir
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
+ }
98
+ }
99
+ });
100
+ }
101
+ };
102
+ //#endregion
103
+ export { Stop as default };
104
+
105
+ //# sourceMappingURL=stop.mjs.map
@@ -0,0 +1 @@
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,MAAM,KAAK;EAExC,MAAM,UAAU,MAAM,oBADV,WAAW,OAAO,MAAM,QAAQ,WAAW,MAAM,MAAM,KAAA,EACtB,CAAC;AAC9C,QAAM,KAAK,OAAO,OAAO;GACvB,eAAe;GACf,QAAQ,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