@zitadel/cli 0.1.0-alpha.8 → 0.1.0

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 +2758 -210
  2. package/bin/run.js +8 -0
  3. package/dist/index.mjs +25199 -0
  4. package/dist/index.mjs.map +1 -0
  5. package/dist/lib/oclif/help.mjs +71 -0
  6. package/dist/lib/oclif/help.mjs.map +1 -0
  7. package/dist/skills-hint-BSspFzhr.mjs +173 -0
  8. package/dist/skills-hint-BSspFzhr.mjs.map +1 -0
  9. package/oclif.manifest.json +5846 -250
  10. package/package.json +73 -13
  11. package/skills/zitadel-cli/SKILL.md +442 -0
  12. package/skills/zitadel-cli/references/driving-login-ui.md +89 -0
  13. package/SKILLS.md +0 -152
  14. package/dist/commands/apply.mjs +0 -62
  15. package/dist/commands/apply.mjs.map +0 -1
  16. package/dist/commands/doctor.mjs +0 -490
  17. package/dist/commands/doctor.mjs.map +0 -1
  18. package/dist/commands/eject.mjs +0 -145
  19. package/dist/commands/eject.mjs.map +0 -1
  20. package/dist/commands/logs.mjs +0 -58
  21. package/dist/commands/logs.mjs.map +0 -1
  22. package/dist/commands/plan.mjs +0 -52
  23. package/dist/commands/plan.mjs.map +0 -1
  24. package/dist/commands/reset.mjs +0 -71
  25. package/dist/commands/reset.mjs.map +0 -1
  26. package/dist/commands/setup.mjs +0 -916
  27. package/dist/commands/setup.mjs.map +0 -1
  28. package/dist/commands/start.mjs +0 -221
  29. package/dist/commands/start.mjs.map +0 -1
  30. package/dist/commands/status.mjs +0 -112
  31. package/dist/commands/status.mjs.map +0 -1
  32. package/dist/commands/stop.mjs +0 -52
  33. package/dist/commands/stop.mjs.map +0 -1
  34. package/dist/docker-BA78SdC2.mjs +0 -383
  35. package/dist/docker-BA78SdC2.mjs.map +0 -1
  36. package/dist/docker-guidance-BvfpmsDj.mjs +0 -21
  37. package/dist/docker-guidance-BvfpmsDj.mjs.map +0 -1
  38. package/dist/oclif-VkCTGIEk.mjs +0 -818
  39. package/dist/oclif-VkCTGIEk.mjs.map +0 -1
  40. package/dist/orca-CfKDQRop.mjs +0 -2556
  41. package/dist/orca-CfKDQRop.mjs.map +0 -1
  42. package/dist/project-CKAHtHML.mjs +0 -87
  43. package/dist/project-CKAHtHML.mjs.map +0 -1
  44. package/dist/sync-B5lqgQO3.mjs +0 -733
  45. package/dist/sync-B5lqgQO3.mjs.map +0 -1
@@ -1,145 +0,0 @@
1
- import { D as ZitadelError, t as BaseCommand } from "../oclif-VkCTGIEk.mjs";
2
- import { t as createOrca } from "../orca-CfKDQRop.mjs";
3
- import { a as readZitadelConfig, i as readRendererId } from "../project-CKAHtHML.mjs";
4
- import { join } from "node:path";
5
- import { readFile, rename, rm, stat } from "node:fs/promises";
6
- //#region src/commands/eject.ts
7
- /**
8
- * Asks the framework patcher which artifacts it owns. Falls back to the
9
- * framework-agnostic set (`zitadel.json`, `.zitadel/`, `.env.local`) when the
10
- * framework or its patcher cannot be resolved, so an orphaned/partial project
11
- * can still be cleaned up.
12
- */
13
- async function resolveEjectActions(cwd) {
14
- const fallback = {
15
- markedFiles: [],
16
- rootConfigFiles: ["zitadel.json"],
17
- directories: [".zitadel"],
18
- envBackups: [".env.local"],
19
- dependencies: [],
20
- configEdits: []
21
- };
22
- const orca = createOrca();
23
- const framework = await orca.tryDetect(cwd);
24
- if (!framework) return fallback;
25
- try {
26
- const config = await readZitadelConfig(cwd).catch(() => ({}));
27
- return orca.patcherFor(framework.id).artifacts({
28
- framework,
29
- rendererId: readRendererId(config)
30
- });
31
- } catch {
32
- return fallback;
33
- }
34
- }
35
- /**
36
- * Builds the `next_commands` envelope field — manual follow-ups `eject` can't
37
- * safely run itself: deleting the `.env.local.ejected-*` backups it created
38
- * (only when some were made), and uninstalling the SDK packages the patcher
39
- * added (the CLI never modifies the user's `package.json` + lockfile +
40
- * `node_modules` directly; it just suggests the command).
41
- */
42
- function assembleNextCommands(backedUp, dependencies) {
43
- const commands = [];
44
- if (backedUp.length > 0) commands.push("rm -f .env.local.ejected-*");
45
- for (const dep of dependencies) commands.push(`npm uninstall ${dep}`);
46
- return commands;
47
- }
48
- async function pathExists(path) {
49
- try {
50
- await stat(path);
51
- return true;
52
- } catch {
53
- return false;
54
- }
55
- }
56
- /**
57
- * `zitadel eject` — remove managed files and local Zitadel state.
58
- *
59
- * Removes Zitadel-managed files from the project, leaving the remote project
60
- * untouched. The set of files comes from the framework patcher's
61
- * {@link import("../lib/orca/patchers/types").Patcher.artifacts}, so the patcher
62
- * is the single source of truth for what its integration owns.
63
- *
64
- * Marked code files are removed only when they still carry the managed marker
65
- * (user-replaced files are preserved); `zitadel.json` is removed; `.env.local`
66
- * is renamed to a timestamped backup; and `.zitadel/` is removed wholesale.
67
- * `--dry-run` reports without touching the filesystem; non-interactive runs
68
- * require `--force`.
69
- */
70
- var Eject = class Eject extends BaseCommand {
71
- static description = "Remove managed files and local Zitadel state.";
72
- static aliases = ["uninstall"];
73
- async run() {
74
- const { flags } = await this.parse(Eject);
75
- await this.toMeta(flags);
76
- const { cwd, force, nonInteractive, dryRun } = this.meta;
77
- if (!force && nonInteractive) throw new ZitadelError("E_VALIDATION", "Eject requires --force in non-interactive mode", { hint: "Re-run with --force to confirm deletion of managed files." });
78
- const actions = await resolveEjectActions(cwd);
79
- const removed = [];
80
- const preserved = [];
81
- const backedUp = [];
82
- for (const rel of actions.markedFiles) {
83
- const abs = join(cwd, rel);
84
- if (!await pathExists(abs)) continue;
85
- if (!(await readFile(abs, "utf8").catch(() => "")).includes("// zitadel-cli: managed-file v1")) {
86
- preserved.push(rel);
87
- continue;
88
- }
89
- if (!dryRun) await rm(abs, { force: true });
90
- removed.push(rel);
91
- }
92
- for (const rel of actions.rootConfigFiles) {
93
- const abs = join(cwd, rel);
94
- if (!await pathExists(abs)) continue;
95
- if (!dryRun) await rm(abs, { force: true });
96
- removed.push(rel);
97
- }
98
- for (const rel of actions.envBackups) {
99
- const abs = join(cwd, rel);
100
- if (!await pathExists(abs)) continue;
101
- if (dryRun) {
102
- backedUp.push(`${rel} -> ${rel}.ejected-<timestamp>`);
103
- continue;
104
- }
105
- const backup = `${abs}.ejected-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`;
106
- await rename(abs, backup);
107
- backedUp.push(`${rel} -> ${backup.slice(cwd.length + 1)}`);
108
- }
109
- for (const rel of actions.directories) {
110
- const abs = join(cwd, rel);
111
- if (!await pathExists(abs)) continue;
112
- if (!dryRun) await rm(abs, {
113
- recursive: true,
114
- force: true
115
- });
116
- removed.push(rel);
117
- }
118
- const manualSteps = actions.configEdits.map((rel) => {
119
- if (rel === "package.json" || rel.endsWith("/package.json")) return `Remove the "dev" script setup added to ${rel}`;
120
- if (rel === "angular.json" || rel.endsWith("/angular.json")) return `Remove the Zitadel proxyConfig (and dev-server port) from the serve target in ${rel}`;
121
- return `Remove the Zitadel configuration block from ${rel}`;
122
- });
123
- if (removed.length === 0 && backedUp.length === 0 && manualSteps.length === 0) return this.emit({
124
- status: "skipped",
125
- reason: "nothing-to-eject",
126
- data: { cwd }
127
- });
128
- const nextCommands = assembleNextCommands(backedUp, actions.dependencies);
129
- return this.emit({
130
- status: "ok",
131
- data: {
132
- title: "Zitadel ejected. Remote project is untouched.",
133
- files_removed: removed,
134
- files_preserved: preserved,
135
- backed_up: backedUp,
136
- next_commands: nextCommands,
137
- manual_steps: manualSteps
138
- }
139
- });
140
- }
141
- };
142
- //#endregion
143
- export { Eject as default };
144
-
145
- //# sourceMappingURL=eject.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"eject.mjs","names":[],"sources":["../../src/commands/eject.ts"],"sourcesContent":["import { readFile, rename, rm, stat } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport { BaseCommand, type JsonEnvelope } from \"../lib/oclif\";\nimport { ZitadelError } from \"../lib/errors\";\nimport { createOrca } from \"../lib/orca\";\nimport type { EjectActions } from \"../lib/orca/patchers/types\";\nimport { MANAGED_MARKER } from \"../lib/paths\";\nimport { readRendererId, readZitadelConfig } from \"../lib/project\";\n\n/**\n * Asks the framework patcher which artifacts it owns. Falls back to the\n * framework-agnostic set (`zitadel.json`, `.zitadel/`, `.env.local`) when the\n * framework or its patcher cannot be resolved, so an orphaned/partial project\n * can still be cleaned up.\n */\nasync function resolveEjectActions(cwd: string): Promise<EjectActions> {\n const fallback: EjectActions = {\n markedFiles: [],\n rootConfigFiles: [\"zitadel.json\"],\n directories: [\".zitadel\"],\n envBackups: [\".env.local\"],\n dependencies: [],\n configEdits: [],\n };\n const orca = createOrca();\n const framework = await orca.tryDetect(cwd);\n if (!framework) {\n return fallback;\n }\n try {\n const config = await readZitadelConfig(cwd).catch(() => ({}) as Record<string, unknown>);\n return orca.patcherFor(framework.id).artifacts({\n framework,\n rendererId: readRendererId(config),\n });\n } catch {\n return fallback;\n }\n}\n\n/**\n * Builds the `next_commands` envelope field — manual follow-ups `eject` can't\n * safely run itself: deleting the `.env.local.ejected-*` backups it created\n * (only when some were made), and uninstalling the SDK packages the patcher\n * added (the CLI never modifies the user's `package.json` + lockfile +\n * `node_modules` directly; it just suggests the command).\n */\nfunction assembleNextCommands(\n backedUp: ReadonlyArray<unknown>,\n dependencies: ReadonlyArray<string>,\n): ReadonlyArray<string> {\n const commands: string[] = [];\n if (backedUp.length > 0) {\n commands.push(\"rm -f .env.local.ejected-*\");\n }\n for (const dep of dependencies) {\n commands.push(`npm uninstall ${dep}`);\n }\n return commands;\n}\n\nasync function pathExists(path: string): Promise<boolean> {\n try {\n await stat(path);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * `zitadel eject` — remove managed files and local Zitadel state.\n *\n * Removes Zitadel-managed files from the project, leaving the remote project\n * untouched. The set of files comes from the framework patcher's\n * {@link import(\"../lib/orca/patchers/types\").Patcher.artifacts}, so the patcher\n * is the single source of truth for what its integration owns.\n *\n * Marked code files are removed only when they still carry the managed marker\n * (user-replaced files are preserved); `zitadel.json` is removed; `.env.local`\n * is renamed to a timestamped backup; and `.zitadel/` is removed wholesale.\n * `--dry-run` reports without touching the filesystem; non-interactive runs\n * require `--force`.\n */\nexport default class Eject extends BaseCommand {\n static override description = \"Remove managed files and local Zitadel state.\";\n static override aliases = [\"uninstall\"];\n\n async run(): Promise<JsonEnvelope> {\n const { flags } = await this.parse(Eject);\n await this.toMeta(flags);\n const { cwd, force, nonInteractive, dryRun } = this.meta;\n\n if (!force && nonInteractive) {\n throw new ZitadelError(\"E_VALIDATION\", \"Eject requires --force in non-interactive mode\", {\n hint: \"Re-run with --force to confirm deletion of managed files.\",\n });\n }\n\n const actions = await resolveEjectActions(cwd);\n const removed: string[] = [];\n const preserved: string[] = [];\n const backedUp: string[] = [];\n\n for (const rel of actions.markedFiles) {\n const abs = join(cwd, rel);\n if (!(await pathExists(abs))) {\n continue;\n }\n const contents = await readFile(abs, \"utf8\").catch(() => \"\");\n if (!contents.includes(MANAGED_MARKER)) {\n preserved.push(rel);\n continue;\n }\n if (!dryRun) {\n await rm(abs, { force: true });\n }\n removed.push(rel);\n }\n\n for (const rel of actions.rootConfigFiles) {\n const abs = join(cwd, rel);\n if (!(await pathExists(abs))) {\n continue;\n }\n if (!dryRun) {\n await rm(abs, { force: true });\n }\n removed.push(rel);\n }\n\n for (const rel of actions.envBackups) {\n const abs = join(cwd, rel);\n if (!(await pathExists(abs))) {\n continue;\n }\n if (dryRun) {\n backedUp.push(`${rel} -> ${rel}.ejected-<timestamp>`);\n continue;\n }\n const stamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const backup = `${abs}.ejected-${stamp}`;\n await rename(abs, backup);\n backedUp.push(`${rel} -> ${backup.slice(cwd.length + 1)}`);\n }\n\n for (const rel of actions.directories) {\n const abs = join(cwd, rel);\n if (!(await pathExists(abs))) {\n continue;\n }\n if (!dryRun) {\n await rm(abs, { recursive: true, force: true });\n }\n removed.push(rel);\n }\n\n // In-place config merges (vite.config.ts / angular.json / nuxt.config.ts)\n // can't be auto-reverted, so surface them as manual cleanup steps. The\n // Angular patcher also edits package.json (a `dev` script, not a config\n // block), so word that one accurately.\n const manualSteps = actions.configEdits.map((rel) => {\n if (rel === \"package.json\" || rel.endsWith(\"/package.json\")) {\n return `Remove the \"dev\" script setup added to ${rel}`;\n }\n if (rel === \"angular.json\" || rel.endsWith(\"/angular.json\")) {\n return `Remove the Zitadel proxyConfig (and dev-server port) from the serve target in ${rel}`;\n }\n return `Remove the Zitadel configuration block from ${rel}`;\n });\n\n if (removed.length === 0 && backedUp.length === 0 && manualSteps.length === 0) {\n return this.emit({ status: \"skipped\", reason: \"nothing-to-eject\", data: { cwd } });\n }\n\n const nextCommands = assembleNextCommands(backedUp, actions.dependencies);\n\n return this.emit({\n status: \"ok\",\n data: {\n title: \"Zitadel ejected. Remote project is untouched.\",\n files_removed: removed,\n files_preserved: preserved,\n backed_up: backedUp,\n next_commands: nextCommands,\n manual_steps: manualSteps,\n },\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,eAAe,oBAAoB,KAAoC;CACrE,MAAM,WAAyB;EAC7B,aAAa,EAAE;EACf,iBAAiB,CAAC,eAAe;EACjC,aAAa,CAAC,WAAW;EACzB,YAAY,CAAC,aAAa;EAC1B,cAAc,EAAE;EAChB,aAAa,EAAE;EAChB;CACD,MAAM,OAAO,YAAY;CACzB,MAAM,YAAY,MAAM,KAAK,UAAU,IAAI;AAC3C,KAAI,CAAC,UACH,QAAO;AAET,KAAI;EACF,MAAM,SAAS,MAAM,kBAAkB,IAAI,CAAC,aAAa,EAAE,EAA6B;AACxF,SAAO,KAAK,WAAW,UAAU,GAAG,CAAC,UAAU;GAC7C;GACA,YAAY,eAAe,OAAO;GACnC,CAAC;SACI;AACN,SAAO;;;;;;;;;;AAWX,SAAS,qBACP,UACA,cACuB;CACvB,MAAM,WAAqB,EAAE;AAC7B,KAAI,SAAS,SAAS,EACpB,UAAS,KAAK,6BAA6B;AAE7C,MAAK,MAAM,OAAO,aAChB,UAAS,KAAK,iBAAiB,MAAM;AAEvC,QA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AI,QAAQ;AACV,aAAS,KAAK,GAAG,IAAI,MAAM,IAAI,sBAAsB;AACrD;;GAGF,MAAM,SAAS,GAAG,IAAI,4BADR,IAAI,MAAM,EAAC,aAAa,CAAC,QAAQ,SAAS,IAClB;AACtC,SAAM,OAAO,KAAK,OAAO;AACzB,YAAS,KAAK,GAAG,IAAI,MAAM,OAAO,MAAM,IAAI,SAAS,EAAE,GAAG;;AAG5D,OAAK,MAAM,OAAO,QAAQ,aAAa;GACrC,MAAM,MAAM,KAAK,KAAK,IAAI;AAC1B,OAAI,CAAE,MAAM,WAAW,IAAI,CACzB;AAEF,OAAI,CAAC,OACH,OAAM,GAAG,KAAK;IAAE,WAAW;IAAM,OAAO;IAAM,CAAC;AAEjD,WAAQ,KAAK,IAAI;;EAOnB,MAAM,cAAc,QAAQ,YAAY,KAAK,QAAQ;AACnD,OAAI,QAAQ,kBAAkB,IAAI,SAAS,gBAAgB,CACzD,QAAO,0CAA0C;AAEnD,OAAI,QAAQ,kBAAkB,IAAI,SAAS,gBAAgB,CACzD,QAAO,iFAAiF;AAE1F,UAAO,+CAA+C;IACtD;AAEF,MAAI,QAAQ,WAAW,KAAK,SAAS,WAAW,KAAK,YAAY,WAAW,EAC1E,QAAO,KAAK,KAAK;GAAE,QAAQ;GAAW,QAAQ;GAAoB,MAAM,EAAE,KAAK;GAAE,CAAC;EAGpF,MAAM,eAAe,qBAAqB,UAAU,QAAQ,aAAa;AAEzE,SAAO,KAAK,KAAK;GACf,QAAQ;GACR,MAAM;IACJ,OAAO;IACP,eAAe;IACf,iBAAiB;IACjB,WAAW;IACX,eAAe;IACf,cAAc;IACf;GACF,CAAC"}
@@ -1,58 +0,0 @@
1
- import { C as resolveCwd, D as ZitadelError, h as readRuntimeMetadata, t as BaseCommand, x as publicCliCommand } from "../oclif-VkCTGIEk.mjs";
2
- import { a as followContainerLogs, f as binaryLogs, p as followBinaryLogs, t as containerLogs } from "../docker-BA78SdC2.mjs";
3
- import { Flags } from "@oclif/core";
4
- //#region src/commands/logs.ts
5
- var Logs = class Logs extends BaseCommand {
6
- static description = "Show local Zitadel server logs.";
7
- static flags = {
8
- follow: Flags.boolean({ description: "Follow logs." }),
9
- tail: Flags.integer({
10
- description: "Number of lines to show.",
11
- default: 200
12
- })
13
- };
14
- async run() {
15
- const { flags } = await this.parse(Logs);
16
- const runtime = await readRuntimeMetadata(resolveCwd(typeof flags.cwd === "string" ? flags.cwd : void 0));
17
- await this.toMeta(flags, {
18
- resolveServer: false,
19
- source: runtime?.server_url ?? "http://localhost:8080"
20
- });
21
- if (!runtime) throw new ZitadelError("E_VALIDATION", "Local Zitadel runtime has not been started", {
22
- hint: "Run `zitadel start` first.",
23
- nextCommands: [publicCliCommand("start", this.meta.cliVersion)]
24
- });
25
- const tail = flags.tail ?? 200;
26
- if (!Number.isInteger(tail) || tail < 1) throw new ZitadelError("E_VALIDATION", `Invalid tail value ${String(tail)}`, { hint: "Use a positive integer." });
27
- if (flags.follow) {
28
- if (this.jsonEnabled()) throw new ZitadelError("E_VALIDATION", "Cannot stream logs with --json", { hint: "Run without --json, or omit --follow." });
29
- if (runtime.backend === "binary") await followBinaryLogs(runtime.log_path, tail);
30
- else await followContainerLogs(runtime.container_name, tail);
31
- return this.emit({
32
- status: "ok",
33
- data: { title: "Stopped following local Zitadel logs." }
34
- });
35
- }
36
- const logs = runtime.backend === "binary" ? await binaryLogs(runtime.log_path, tail) : await containerLogs(runtime.container_name, tail);
37
- return this.emit({
38
- status: "ok",
39
- pretty: logs.trimEnd(),
40
- data: {
41
- title: "Local Zitadel server logs.",
42
- runtime: runtime.backend === "binary" ? {
43
- backend: runtime.backend,
44
- pid: runtime.pid,
45
- log_path: runtime.log_path
46
- } : {
47
- backend: runtime.backend,
48
- container_name: runtime.container_name
49
- },
50
- logs
51
- }
52
- });
53
- }
54
- };
55
- //#endregion
56
- export { Logs as default };
57
-
58
- //# sourceMappingURL=logs.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logs.mjs","names":[],"sources":["../../src/commands/logs.ts"],"sourcesContent":["import { Flags } from \"@oclif/core\";\n\nimport { ZitadelError } from \"../lib/errors\";\nimport { binaryLogs, followBinaryLogs } from \"../lib/local-server/binary\";\nimport { containerLogs, followContainerLogs } from \"../lib/local-server/docker\";\nimport { DEFAULT_LOCAL_SERVER_URL, readRuntimeMetadata } 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 Logs extends BaseCommand {\n static override description = \"Show local Zitadel server logs.\";\n static override flags = {\n follow: Flags.boolean({ description: \"Follow logs.\" }),\n tail: Flags.integer({ description: \"Number of lines to show.\", default: 200 }),\n };\n\n async run(): Promise<JsonEnvelope> {\n const { flags } = await this.parse(Logs);\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 (!runtime) {\n throw new ZitadelError(\"E_VALIDATION\", \"Local Zitadel runtime has not been started\", {\n hint: \"Run `zitadel start` first.\",\n nextCommands: [publicCliCommand(\"start\", this.meta.cliVersion)],\n });\n }\n\n const tail = flags.tail ?? 200;\n if (!Number.isInteger(tail) || tail < 1) {\n throw new ZitadelError(\"E_VALIDATION\", `Invalid tail value ${String(tail)}`, {\n hint: \"Use a positive integer.\",\n });\n }\n\n if (flags.follow) {\n if (this.jsonEnabled()) {\n throw new ZitadelError(\"E_VALIDATION\", \"Cannot stream logs with --json\", {\n hint: \"Run without --json, or omit --follow.\",\n });\n }\n if (runtime.backend === \"binary\") {\n await followBinaryLogs(runtime.log_path, tail);\n } else {\n await followContainerLogs(runtime.container_name, tail);\n }\n return this.emit({\n status: \"ok\",\n data: { title: \"Stopped following local Zitadel logs.\" },\n });\n }\n\n const logs =\n runtime.backend === \"binary\"\n ? await binaryLogs(runtime.log_path, tail)\n : await containerLogs(runtime.container_name, tail);\n return this.emit({\n status: \"ok\",\n pretty: logs.trimEnd(),\n data: {\n title: \"Local Zitadel server logs.\",\n runtime:\n runtime.backend === \"binary\"\n ? { backend: runtime.backend, pid: runtime.pid, log_path: runtime.log_path }\n : { backend: runtime.backend, container_name: runtime.container_name },\n logs,\n },\n });\n }\n}\n"],"mappings":";;;;AAUA,IAAqB,OAArB,MAAqB,aAAa,YAAY;CAC5C,OAAgB,cAAc;CAC9B,OAAgB,QAAQ;EACtB,QAAQ,MAAM,QAAQ,EAAE,aAAa,gBAAgB,CAAC;EACtD,MAAM,MAAM,QAAQ;GAAE,aAAa;GAA4B,SAAS;GAAK,CAAC;EAC/E;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,SAAS,cAAA;GAClB,CAAC;AAEF,MAAI,CAAC,QACH,OAAM,IAAI,aAAa,gBAAgB,8CAA8C;GACnF,MAAM;GACN,cAAc,CAAC,iBAAiB,SAAS,KAAK,KAAK,WAAW,CAAC;GAChE,CAAC;EAGJ,MAAM,OAAO,MAAM,QAAQ;AAC3B,MAAI,CAAC,OAAO,UAAU,KAAK,IAAI,OAAO,EACpC,OAAM,IAAI,aAAa,gBAAgB,sBAAsB,OAAO,KAAK,IAAI,EAC3E,MAAM,2BACP,CAAC;AAGJ,MAAI,MAAM,QAAQ;AAChB,OAAI,KAAK,aAAa,CACpB,OAAM,IAAI,aAAa,gBAAgB,kCAAkC,EACvE,MAAM,yCACP,CAAC;AAEJ,OAAI,QAAQ,YAAY,SACtB,OAAM,iBAAiB,QAAQ,UAAU,KAAK;OAE9C,OAAM,oBAAoB,QAAQ,gBAAgB,KAAK;AAEzD,UAAO,KAAK,KAAK;IACf,QAAQ;IACR,MAAM,EAAE,OAAO,yCAAyC;IACzD,CAAC;;EAGJ,MAAM,OACJ,QAAQ,YAAY,WAChB,MAAM,WAAW,QAAQ,UAAU,KAAK,GACxC,MAAM,cAAc,QAAQ,gBAAgB,KAAK;AACvD,SAAO,KAAK,KAAK;GACf,QAAQ;GACR,QAAQ,KAAK,SAAS;GACtB,MAAM;IACJ,OAAO;IACP,SACE,QAAQ,YAAY,WAChB;KAAE,SAAS,QAAQ;KAAS,KAAK,QAAQ;KAAK,UAAU,QAAQ;KAAU,GAC1E;KAAE,SAAS,QAAQ;KAAS,gBAAgB,QAAQ;KAAgB;IAC1E;IACD;GACF,CAAC"}
@@ -1,52 +0,0 @@
1
- import { t as BaseCommand } from "../oclif-VkCTGIEk.mjs";
2
- import { o as readZitadelSecret } from "../project-CKAHtHML.mjs";
3
- import { a as makeSyncers, n as summarizePlan, o as environmentSchema, r as buildSyncPlan, t as renderPlan } from "../sync-B5lqgQO3.mjs";
4
- import { Flags } from "@oclif/core";
5
- import { createZitadelClient } from "@zitadel/api/client";
6
- import { consola as consola$1 } from "consola";
7
- //#region src/commands/plan.ts
8
- /**
9
- * `zitadel plan` — validate config and preview the sync diff without mutating.
10
- *
11
- * The read-only counterpart of `apply`: it builds and renders the diff instead
12
- * of running the sync loop. All validation (structural shape and env-ref
13
- * presence) happens in the sync engine, so an invalid file fails the same way
14
- * `apply` would.
15
- */
16
- var Plan = class Plan extends BaseCommand {
17
- static description = "Validate config without mutation and preview the sync diff.";
18
- static flags = { environment: Flags.string({
19
- char: "e",
20
- description: "Target environment (default: development).",
21
- options: [...environmentSchema.options]
22
- }) };
23
- async run() {
24
- const { flags } = await this.parse(Plan);
25
- await this.toMeta(flags);
26
- const { cwd, source, env, isTTY } = this.meta;
27
- const secret = await readZitadelSecret(cwd);
28
- consola$1.info(`Project ${secret.project_id}`);
29
- consola$1.info(`Server ${source}`);
30
- const syncers = makeSyncers({
31
- client: createZitadelClient({
32
- baseUrl: source,
33
- token: secret.project_secret
34
- }),
35
- projectId: secret.project_id,
36
- env
37
- });
38
- consola$1.start("Building plan");
39
- const plan = await buildSyncPlan(cwd, syncers, true);
40
- const summary = summarizePlan(plan);
41
- consola$1.success(`Plan: ${summary.creates} create${summary.creates === 1 ? "" : "s"}, ${summary.updates} update${summary.updates === 1 ? "" : "s"}, ${summary.deletes} delete${summary.deletes === 1 ? "" : "s"}, ${summary.total - summary.creates - summary.updates - summary.deletes} unchanged`);
42
- return this.emit({
43
- status: "ok",
44
- data: summary,
45
- pretty: renderPlan(plan, isTTY)
46
- });
47
- }
48
- };
49
- //#endregion
50
- export { Plan as default };
51
-
52
- //# sourceMappingURL=plan.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plan.mjs","names":[],"sources":["../../src/commands/plan.ts"],"sourcesContent":["import { Flags } from \"@oclif/core\";\nimport { consola } from \"consola\";\n\nimport { createZitadelClient } from \"@zitadel/api/client\";\n\nimport { BaseCommand, type JsonEnvelope } from \"../lib/oclif\";\nimport { environmentSchema } from \"../lib/environment\";\nimport { buildSyncPlan, makeSyncers, renderPlan, summarizePlan } from \"../lib/sync\";\nimport { readZitadelSecret } from \"../lib/project\";\n\n/**\n * `zitadel plan` — validate config and preview the sync diff without mutating.\n *\n * The read-only counterpart of `apply`: it builds and renders the diff instead\n * of running the sync loop. All validation (structural shape and env-ref\n * presence) happens in the sync engine, so an invalid file fails the same way\n * `apply` would.\n */\nexport default class Plan extends BaseCommand {\n static override description = \"Validate config without mutation and preview the sync diff.\";\n static override flags = {\n environment: Flags.string({\n char: \"e\",\n description: \"Target environment (default: development).\",\n options: [...environmentSchema.options],\n }),\n };\n\n async run(): Promise<JsonEnvelope> {\n const { flags } = await this.parse(Plan);\n await this.toMeta(flags);\n const { cwd, source, env, isTTY } = this.meta;\n\n const secret = await readZitadelSecret(cwd);\n consola.info(`Project ${secret.project_id}`);\n consola.info(`Server ${source}`);\n const client = createZitadelClient({\n baseUrl: source,\n token: secret.project_secret,\n });\n const syncers = makeSyncers({ client, projectId: secret.project_id, env });\n\n consola.start(\"Building plan\");\n const plan = await buildSyncPlan(cwd, syncers, true);\n const summary = summarizePlan(plan);\n consola.success(\n `Plan: ${summary.creates} create${summary.creates === 1 ? \"\" : \"s\"}, ` +\n `${summary.updates} update${summary.updates === 1 ? \"\" : \"s\"}, ` +\n `${summary.deletes} delete${summary.deletes === 1 ? \"\" : \"s\"}, ` +\n `${summary.total - summary.creates - summary.updates - summary.deletes} unchanged`,\n );\n return this.emit({\n status: \"ok\",\n data: summary,\n pretty: renderPlan(plan, isTTY),\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,IAAqB,OAArB,MAAqB,aAAa,YAAY;CAC5C,OAAgB,cAAc;CAC9B,OAAgB,QAAQ,EACtB,aAAa,MAAM,OAAO;EACxB,MAAM;EACN,aAAa;EACb,SAAS,CAAC,GAAG,kBAAkB,QAAQ;EACxC,CAAC,EACH;CAED,MAAM,MAA6B;EACjC,MAAM,EAAE,UAAU,MAAM,KAAK,MAAM,KAAK;AACxC,QAAM,KAAK,OAAO,MAAM;EACxB,MAAM,EAAE,KAAK,QAAQ,KAAK,UAAU,KAAK;EAEzC,MAAM,SAAS,MAAM,kBAAkB,IAAI;AAC3C,YAAQ,KAAK,aAAa,OAAO,aAAa;AAC9C,YAAQ,KAAK,aAAa,SAAS;EAKnC,MAAM,UAAU,YAAY;GAAE,QAJf,oBAAoB;IACjC,SAAS;IACT,OAAO,OAAO;IACf,CACmC;GAAE,WAAW,OAAO;GAAY;GAAK,CAAC;AAE1E,YAAQ,MAAM,gBAAgB;EAC9B,MAAM,OAAO,MAAM,cAAc,KAAK,SAAS,KAAK;EACpD,MAAM,UAAU,cAAc,KAAK;AACnC,YAAQ,QACN,SAAS,QAAQ,QAAQ,SAAS,QAAQ,YAAY,IAAI,KAAK,IAAI,IAC9D,QAAQ,QAAQ,SAAS,QAAQ,YAAY,IAAI,KAAK,IAAI,IAC1D,QAAQ,QAAQ,SAAS,QAAQ,YAAY,IAAI,KAAK,IAAI,IAC1D,QAAQ,QAAQ,QAAQ,UAAU,QAAQ,UAAU,QAAQ,QAAQ,YAC1E;AACD,SAAO,KAAK,KAAK;GACf,QAAQ;GACR,MAAM;GACN,QAAQ,WAAW,MAAM,MAAM;GAChC,CAAC"}
@@ -1,71 +0,0 @@
1
- import { C as resolveCwd, D as ZitadelError, _ as removeRuntimeMetadata, g as removeLocalData, h as readRuntimeMetadata, p as localContainerName, t as BaseCommand, x as publicCliCommand } from "../oclif-VkCTGIEk.mjs";
2
- import { g as stopBinaryRuntime, u as stopAndRemoveContainer } from "../docker-BA78SdC2.mjs";
3
- import { cancel, confirm, isCancel } from "@clack/prompts";
4
- //#region src/commands/reset.ts
5
- var Reset = class Reset extends BaseCommand {
6
- static description = "Delete the local Zitadel server runtime and data.";
7
- async run() {
8
- const { flags } = await this.parse(Reset);
9
- const runtime = await readRuntimeMetadata(resolveCwd(typeof flags.cwd === "string" ? flags.cwd : void 0));
10
- await this.toMeta(flags, {
11
- resolveServer: false,
12
- source: runtime?.server_url ?? "http://localhost:8080"
13
- });
14
- const containerName = runtime?.backend === "docker" ? runtime.container_name : localContainerName(this.meta.cwd);
15
- if (this.meta.dryRun) return this.emit({
16
- status: "ok",
17
- data: {
18
- title: "Local Zitadel server runtime reset plan.",
19
- runtime: {
20
- backend: runtime?.backend ?? "missing",
21
- ...runtime?.backend === "binary" ? {
22
- pid: runtime.pid,
23
- log_path: runtime.log_path
24
- } : { container_name: containerName },
25
- data_deleted: true
26
- },
27
- next_commands: [publicCliCommand("reset --force", this.meta.cliVersion)]
28
- }
29
- });
30
- if (!this.meta.force) {
31
- if (this.meta.nonInteractive) throw new ZitadelError("E_VALIDATION", "Reset requires --force in non-interactive mode", {
32
- hint: "Pass --force to delete `.zitadel/local/nextgen-data`.",
33
- nextCommands: [publicCliCommand("reset --force", this.meta.cliVersion)]
34
- });
35
- const answer = await confirm({
36
- message: "Delete the local Zitadel runtime and .zitadel/local/nextgen-data?",
37
- initialValue: false
38
- });
39
- if (isCancel(answer)) {
40
- cancel("Reset cancelled.");
41
- throw new ZitadelError("E_VALIDATION", "Reset cancelled by user");
42
- }
43
- if (!answer) return this.emit({
44
- status: "skipped",
45
- reason: "reset-cancelled"
46
- });
47
- }
48
- if (runtime?.backend === "binary") await stopBinaryRuntime(runtime.pid);
49
- else await stopAndRemoveContainer(containerName);
50
- await removeLocalData(this.meta.cwd);
51
- await removeRuntimeMetadata(this.meta.cwd);
52
- return this.emit({
53
- status: "ok",
54
- data: {
55
- title: "Local Zitadel server runtime reset.",
56
- runtime: {
57
- backend: runtime?.backend ?? "missing",
58
- ...runtime?.backend === "binary" ? {
59
- pid: runtime.pid,
60
- log_path: runtime.log_path
61
- } : { container_name: containerName },
62
- data_deleted: true
63
- }
64
- }
65
- });
66
- }
67
- };
68
- //#endregion
69
- export { Reset as default };
70
-
71
- //# sourceMappingURL=reset.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reset.mjs","names":[],"sources":["../../src/commands/reset.ts"],"sourcesContent":["import { cancel, confirm, isCancel } from \"@clack/prompts\";\n\nimport { ZitadelError } from \"../lib/errors\";\nimport { stopBinaryRuntime } from \"../lib/local-server/binary\";\nimport { stopAndRemoveContainer } from \"../lib/local-server/docker\";\nimport {\n DEFAULT_LOCAL_SERVER_URL,\n localContainerName,\n readRuntimeMetadata,\n removeLocalData,\n removeRuntimeMetadata,\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 Reset extends BaseCommand {\n static override description = \"Delete the local Zitadel server runtime and data.\";\n\n async run(): Promise<JsonEnvelope> {\n const { flags } = await this.parse(Reset);\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 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 runtime reset 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_deleted: true,\n },\n next_commands: [publicCliCommand(\"reset --force\", this.meta.cliVersion)],\n },\n });\n }\n\n if (!this.meta.force) {\n if (this.meta.nonInteractive) {\n throw new ZitadelError(\"E_VALIDATION\", \"Reset requires --force in non-interactive mode\", {\n hint: \"Pass --force to delete `.zitadel/local/nextgen-data`.\",\n nextCommands: [publicCliCommand(\"reset --force\", this.meta.cliVersion)],\n });\n }\n const answer = await confirm({\n message: \"Delete the local Zitadel runtime and .zitadel/local/nextgen-data?\",\n initialValue: false,\n });\n if (isCancel(answer)) {\n cancel(\"Reset cancelled.\");\n throw new ZitadelError(\"E_VALIDATION\", \"Reset cancelled by user\");\n }\n if (!answer) {\n return this.emit({ status: \"skipped\", reason: \"reset-cancelled\" });\n }\n }\n\n if (runtime?.backend === \"binary\") {\n await stopBinaryRuntime(runtime.pid);\n } else {\n await stopAndRemoveContainer(containerName);\n }\n await removeLocalData(this.meta.cwd);\n await removeRuntimeMetadata(this.meta.cwd);\n\n return this.emit({\n status: \"ok\",\n data: {\n title: \"Local Zitadel server runtime reset.\",\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_deleted: true,\n },\n },\n });\n }\n}\n"],"mappings":";;;;AAgBA,IAAqB,QAArB,MAAqB,cAAc,YAAY;CAC7C,OAAgB,cAAc;CAE9B,MAAM,MAA6B;EACjC,MAAM,EAAE,UAAU,MAAM,KAAK,MAAM,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