@zitadel/cli 1.0.0-alpha.22 → 1.0.0-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2248 -227
- package/SKILLS.md +237 -65
- package/dist/groups-CMB0fMzE.mjs +22 -0
- package/dist/groups-CMB0fMzE.mjs.map +1 -0
- package/dist/index.mjs +16027 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/oclif/help.mjs +67 -0
- package/dist/lib/oclif/help.mjs.map +1 -0
- package/oclif.manifest.json +4577 -185
- package/package.json +40 -8
- package/dist/box-B_mwKole.mjs +0 -35
- package/dist/box-B_mwKole.mjs.map +0 -1
- package/dist/branding-DvoH8e0D.mjs +0 -79
- package/dist/branding-DvoH8e0D.mjs.map +0 -1
- package/dist/claim-state-B6ZSKmhW.mjs +0 -125
- package/dist/claim-state-B6ZSKmhW.mjs.map +0 -1
- package/dist/commands/apply.mjs +0 -81
- package/dist/commands/apply.mjs.map +0 -1
- package/dist/commands/branding/eject.mjs +0 -104
- package/dist/commands/branding/eject.mjs.map +0 -1
- package/dist/commands/claim.mjs +0 -445
- package/dist/commands/claim.mjs.map +0 -1
- package/dist/commands/doctor.mjs +0 -1138
- package/dist/commands/doctor.mjs.map +0 -1
- package/dist/commands/eject.mjs +0 -157
- package/dist/commands/eject.mjs.map +0 -1
- package/dist/commands/logs.mjs +0 -58
- package/dist/commands/logs.mjs.map +0 -1
- package/dist/commands/plan.mjs +0 -65
- package/dist/commands/plan.mjs.map +0 -1
- package/dist/commands/reset.mjs +0 -79
- package/dist/commands/reset.mjs.map +0 -1
- package/dist/commands/schemas/list.mjs +0 -146
- package/dist/commands/schemas/list.mjs.map +0 -1
- package/dist/commands/setup.mjs +0 -1309
- package/dist/commands/setup.mjs.map +0 -1
- package/dist/commands/start.mjs +0 -288
- package/dist/commands/start.mjs.map +0 -1
- package/dist/commands/status.mjs +0 -151
- package/dist/commands/status.mjs.map +0 -1
- package/dist/commands/stop.mjs +0 -105
- package/dist/commands/stop.mjs.map +0 -1
- package/dist/designs-Ckz18Dpo.mjs +0 -38
- package/dist/designs-Ckz18Dpo.mjs.map +0 -1
- package/dist/docker-B1MjOMFo.mjs +0 -436
- package/dist/docker-B1MjOMFo.mjs.map +0 -1
- package/dist/environment-fibXmzM8.mjs +0 -17
- package/dist/environment-fibXmzM8.mjs.map +0 -1
- package/dist/journey-guidance-C9MxJNTg.mjs +0 -40
- package/dist/journey-guidance-C9MxJNTg.mjs.map +0 -1
- package/dist/oclif-JlsN1lfO.mjs +0 -1769
- package/dist/oclif-JlsN1lfO.mjs.map +0 -1
- package/dist/orca-CPMHzmg3.mjs +0 -3917
- package/dist/orca-CPMHzmg3.mjs.map +0 -1
- package/dist/package-manager-CDUsoGBy.mjs +0 -194
- package/dist/package-manager-CDUsoGBy.mjs.map +0 -1
- package/dist/ports-hidBnSW-.mjs +0 -116
- package/dist/ports-hidBnSW-.mjs.map +0 -1
- package/dist/processes-Cv19mJ2I.mjs +0 -120
- package/dist/processes-Cv19mJ2I.mjs.map +0 -1
- package/dist/project-Ba0nriNm.mjs +0 -140
- package/dist/project-Ba0nriNm.mjs.map +0 -1
- package/dist/sync-ChlLQ4vZ.mjs +0 -1633
- package/dist/sync-ChlLQ4vZ.mjs.map +0 -1
- package/dist/user-schema-C2mC-JTN.mjs +0 -91
- package/dist/user-schema-C2mC-JTN.mjs.map +0 -1
package/dist/docker-B1MjOMFo.mjs
DELETED
|
@@ -1,436 +0,0 @@
|
|
|
1
|
-
import { E as ZitadelError, i as CONTAINER_HTTP_PORT, r as CONTAINER_DATA_DIR } from "./oclif-JlsN1lfO.mjs";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
import { mkdir, open, readFile, stat } from "node:fs/promises";
|
|
4
|
-
import { dirname, join } from "node:path";
|
|
5
|
-
import { createReadStream } from "node:fs";
|
|
6
|
-
import { spawn } from "node:child_process";
|
|
7
|
-
//#region src/lib/local-server/binary.ts
|
|
8
|
-
const SERVER_NPM_PACKAGE = "@zitadel/server";
|
|
9
|
-
const START_COMMAND_ENV = "ZITADEL_SERVER_BINARY";
|
|
10
|
-
const START_COMMAND_VERSION_ENV = "ZITADEL_SERVER_BINARY_VERSION";
|
|
11
|
-
const STOP_TIMEOUT_MS = 1e4;
|
|
12
|
-
const STOP_KILL_TIMEOUT_MS = 2e3;
|
|
13
|
-
const require = createRequire(import.meta.url);
|
|
14
|
-
function resolveServerCommand(env = process.env) {
|
|
15
|
-
if (env[START_COMMAND_ENV]) return {
|
|
16
|
-
command: env[START_COMMAND_ENV],
|
|
17
|
-
args: [],
|
|
18
|
-
serverPackage: SERVER_NPM_PACKAGE,
|
|
19
|
-
serverVersion: env[START_COMMAND_VERSION_ENV]?.trim() || "override"
|
|
20
|
-
};
|
|
21
|
-
const manifestPath = resolveServerPackageManifest();
|
|
22
|
-
const manifest = require(manifestPath);
|
|
23
|
-
return {
|
|
24
|
-
command: process.execPath,
|
|
25
|
-
args: [join(dirname(manifestPath), "bin", "zitadel-server.js")],
|
|
26
|
-
serverPackage: SERVER_NPM_PACKAGE,
|
|
27
|
-
serverVersion: typeof manifest.version === "string" ? manifest.version : "unknown"
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
async function startBinaryRuntime(spec) {
|
|
31
|
-
const command = resolveServerCommand();
|
|
32
|
-
await mkdir(dirname(spec.logPath), {
|
|
33
|
-
recursive: true,
|
|
34
|
-
mode: 448
|
|
35
|
-
});
|
|
36
|
-
const log = await open(spec.logPath, "a", 384);
|
|
37
|
-
try {
|
|
38
|
-
const child = spawn(command.command, command.args, {
|
|
39
|
-
detached: true,
|
|
40
|
-
env: {
|
|
41
|
-
...process.env,
|
|
42
|
-
NEXTGEN_SERVER_ADDRESS: `:${String(spec.port)}`,
|
|
43
|
-
NEXTGEN_SERVER_DATA_DIR: spec.dataDir,
|
|
44
|
-
NEXTGEN_SERVER_PUBLIC_BASE: spec.serverUrl
|
|
45
|
-
},
|
|
46
|
-
stdio: [
|
|
47
|
-
"ignore",
|
|
48
|
-
log.fd,
|
|
49
|
-
log.fd
|
|
50
|
-
]
|
|
51
|
-
});
|
|
52
|
-
child.unref();
|
|
53
|
-
if (!child.pid) throw new Error("server process did not expose a pid");
|
|
54
|
-
return {
|
|
55
|
-
schema_version: 1,
|
|
56
|
-
backend: "binary",
|
|
57
|
-
pid: child.pid,
|
|
58
|
-
command: [command.command, ...command.args].join(" "),
|
|
59
|
-
log_path: spec.logPath,
|
|
60
|
-
server_package: command.serverPackage,
|
|
61
|
-
server_version: command.serverVersion,
|
|
62
|
-
port: spec.port,
|
|
63
|
-
server_url: spec.serverUrl,
|
|
64
|
-
data_dir: spec.dataDir,
|
|
65
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
66
|
-
cli_version: spec.cliVersion
|
|
67
|
-
};
|
|
68
|
-
} finally {
|
|
69
|
-
await log.close();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
async function stopBinaryRuntime(pid) {
|
|
73
|
-
if (!isProcessRunning(pid)) return {
|
|
74
|
-
pid,
|
|
75
|
-
status: "stale",
|
|
76
|
-
target: "process"
|
|
77
|
-
};
|
|
78
|
-
const term = signalRuntime(pid, "SIGTERM");
|
|
79
|
-
if (!term.sent) return {
|
|
80
|
-
pid,
|
|
81
|
-
status: "stale",
|
|
82
|
-
target: term.target
|
|
83
|
-
};
|
|
84
|
-
if (await waitForExit(pid, STOP_TIMEOUT_MS)) return {
|
|
85
|
-
pid,
|
|
86
|
-
status: "stopped",
|
|
87
|
-
target: term.target,
|
|
88
|
-
signal: "SIGTERM"
|
|
89
|
-
};
|
|
90
|
-
if (isProcessRunning(pid)) {
|
|
91
|
-
const kill = signalRuntime(pid, "SIGKILL");
|
|
92
|
-
if (kill.sent && await waitForExit(pid, STOP_KILL_TIMEOUT_MS)) return {
|
|
93
|
-
pid,
|
|
94
|
-
status: "stopped",
|
|
95
|
-
target: kill.target,
|
|
96
|
-
signal: "SIGKILL"
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
return {
|
|
100
|
-
pid,
|
|
101
|
-
status: "failed",
|
|
102
|
-
target: term.target,
|
|
103
|
-
signal: "SIGKILL"
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function isProcessRunning(pid) {
|
|
107
|
-
try {
|
|
108
|
-
process.kill(pid, 0);
|
|
109
|
-
return true;
|
|
110
|
-
} catch (error) {
|
|
111
|
-
return isErrno(error, "EPERM");
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
async function binaryLogs(logPath, tail) {
|
|
115
|
-
let content = "";
|
|
116
|
-
try {
|
|
117
|
-
content = await readFile(logPath, "utf8");
|
|
118
|
-
} catch (error) {
|
|
119
|
-
if (isErrno(error, "ENOENT")) return "";
|
|
120
|
-
throw error;
|
|
121
|
-
}
|
|
122
|
-
const lines = content.split(/\r?\n/);
|
|
123
|
-
const hasTrailingNewline = lines.at(-1) === "";
|
|
124
|
-
const selected = (hasTrailingNewline ? lines.slice(0, -1) : lines).slice(-tail).join("\n");
|
|
125
|
-
return selected.length === 0 ? "" : `${selected}${hasTrailingNewline ? "\n" : ""}`;
|
|
126
|
-
}
|
|
127
|
-
async function followBinaryLogs(logPath, tail) {
|
|
128
|
-
process.stdout.write(await binaryLogs(logPath, tail));
|
|
129
|
-
let offset = await fileSize(logPath);
|
|
130
|
-
await new Promise((resolveFollow, reject) => {
|
|
131
|
-
const interval = setInterval(() => {
|
|
132
|
-
(async () => {
|
|
133
|
-
try {
|
|
134
|
-
const size = await fileSize(logPath);
|
|
135
|
-
if (size > offset) {
|
|
136
|
-
createReadStream(logPath, {
|
|
137
|
-
start: offset,
|
|
138
|
-
end: size - 1
|
|
139
|
-
}).pipe(process.stdout, { end: false });
|
|
140
|
-
offset = size;
|
|
141
|
-
}
|
|
142
|
-
} catch (error) {
|
|
143
|
-
reject(error);
|
|
144
|
-
}
|
|
145
|
-
})();
|
|
146
|
-
}, 1e3);
|
|
147
|
-
const stop = () => {
|
|
148
|
-
clearInterval(interval);
|
|
149
|
-
resolveFollow();
|
|
150
|
-
};
|
|
151
|
-
process.once("SIGINT", stop);
|
|
152
|
-
process.once("SIGTERM", stop);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
async function assertServerPackageAvailable() {
|
|
156
|
-
try {
|
|
157
|
-
return resolveServerCommand().serverVersion;
|
|
158
|
-
} catch (error) {
|
|
159
|
-
throw new ZitadelError("E_VALIDATION", "Zitadel server npm package is not available", {
|
|
160
|
-
hint: "Reinstall @zitadel/cli so npm can install @zitadel/server and its platform package.",
|
|
161
|
-
nextCommands: ["npm install @zitadel/cli@alpha"],
|
|
162
|
-
details: {
|
|
163
|
-
package: SERVER_NPM_PACKAGE,
|
|
164
|
-
message: errorMessage(error)
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
function resolveServerPackageManifest() {
|
|
170
|
-
try {
|
|
171
|
-
return require.resolve(`${SERVER_NPM_PACKAGE}/package.json`);
|
|
172
|
-
} catch (error) {
|
|
173
|
-
throw new Error(`Missing ${SERVER_NPM_PACKAGE}. Reinstall @zitadel/cli.`, { cause: error });
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
async function fileSize(path) {
|
|
177
|
-
try {
|
|
178
|
-
return (await stat(path)).size;
|
|
179
|
-
} catch (error) {
|
|
180
|
-
if (isErrno(error, "ENOENT")) return 0;
|
|
181
|
-
throw error;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
function isErrno(error, code) {
|
|
185
|
-
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
186
|
-
}
|
|
187
|
-
function signalProcess(pid, signal) {
|
|
188
|
-
try {
|
|
189
|
-
process.kill(pid, signal);
|
|
190
|
-
return true;
|
|
191
|
-
} catch (error) {
|
|
192
|
-
if (isErrno(error, "ESRCH")) return false;
|
|
193
|
-
throw error;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
function signalRuntime(pid, signal) {
|
|
197
|
-
if (process.platform !== "win32") try {
|
|
198
|
-
process.kill(-pid, signal);
|
|
199
|
-
return {
|
|
200
|
-
sent: true,
|
|
201
|
-
target: "process-group"
|
|
202
|
-
};
|
|
203
|
-
} catch (error) {
|
|
204
|
-
if (!isErrno(error, "ESRCH")) throw error;
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
sent: signalProcess(pid, signal),
|
|
208
|
-
target: "process"
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
async function waitForExit(pid, timeoutMs) {
|
|
212
|
-
const deadline = Date.now() + timeoutMs;
|
|
213
|
-
while (Date.now() < deadline) {
|
|
214
|
-
if (!isProcessRunning(pid)) return true;
|
|
215
|
-
await delay(200);
|
|
216
|
-
}
|
|
217
|
-
return !isProcessRunning(pid);
|
|
218
|
-
}
|
|
219
|
-
function errorMessage(error) {
|
|
220
|
-
return error instanceof Error ? error.message : String(error);
|
|
221
|
-
}
|
|
222
|
-
function delay(ms) {
|
|
223
|
-
return new Promise((resolveDelay) => setTimeout(resolveDelay, ms));
|
|
224
|
-
}
|
|
225
|
-
//#endregion
|
|
226
|
-
//#region src/lib/local-server/docker.ts
|
|
227
|
-
function dockerRunArgs(spec) {
|
|
228
|
-
const args = [
|
|
229
|
-
"run",
|
|
230
|
-
"--detach",
|
|
231
|
-
"--name",
|
|
232
|
-
spec.containerName,
|
|
233
|
-
"--publish",
|
|
234
|
-
`127.0.0.1:${spec.port}:${CONTAINER_HTTP_PORT}`,
|
|
235
|
-
"--volume",
|
|
236
|
-
`${spec.dataDir}:${CONTAINER_DATA_DIR}`,
|
|
237
|
-
"--env",
|
|
238
|
-
`NEXTGEN_SERVER_ADDRESS=:${CONTAINER_HTTP_PORT}`,
|
|
239
|
-
"--env",
|
|
240
|
-
`NEXTGEN_SERVER_DATA_DIR=${CONTAINER_DATA_DIR}`,
|
|
241
|
-
"--env",
|
|
242
|
-
`NEXTGEN_SERVER_PUBLIC_BASE=http://localhost:${spec.port}`
|
|
243
|
-
];
|
|
244
|
-
if (spec.identity) args.push("--volume", `${spec.identity.passwdFile}:/etc/passwd:ro`, "--volume", `${spec.identity.groupFile}:/etc/group:ro`, "--user", `${spec.identity.uid}:${spec.identity.gid}`);
|
|
245
|
-
args.push(spec.image);
|
|
246
|
-
return args;
|
|
247
|
-
}
|
|
248
|
-
async function runDocker(args) {
|
|
249
|
-
return new Promise((resolve, reject) => {
|
|
250
|
-
const child = spawn("docker", args, {
|
|
251
|
-
stdio: [
|
|
252
|
-
"ignore",
|
|
253
|
-
"pipe",
|
|
254
|
-
"pipe"
|
|
255
|
-
],
|
|
256
|
-
env: process.env
|
|
257
|
-
});
|
|
258
|
-
let stdout = "";
|
|
259
|
-
let stderr = "";
|
|
260
|
-
child.stdout?.setEncoding("utf8");
|
|
261
|
-
child.stderr?.setEncoding("utf8");
|
|
262
|
-
child.stdout?.on("data", (chunk) => {
|
|
263
|
-
stdout += chunk;
|
|
264
|
-
});
|
|
265
|
-
child.stderr?.on("data", (chunk) => {
|
|
266
|
-
stderr += chunk;
|
|
267
|
-
});
|
|
268
|
-
child.on("error", reject);
|
|
269
|
-
child.on("close", (code) => {
|
|
270
|
-
resolve({
|
|
271
|
-
status: code ?? 1,
|
|
272
|
-
stdout,
|
|
273
|
-
stderr
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
async function streamDocker(args) {
|
|
279
|
-
await new Promise((resolve, reject) => {
|
|
280
|
-
const child = spawn("docker", args, {
|
|
281
|
-
stdio: "inherit",
|
|
282
|
-
env: process.env
|
|
283
|
-
});
|
|
284
|
-
child.on("error", reject);
|
|
285
|
-
child.on("close", (code) => {
|
|
286
|
-
if (code === 0) resolve();
|
|
287
|
-
else reject(/* @__PURE__ */ new Error(`docker ${args.join(" ")} exited with status ${code ?? 1}`));
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
async function dockerAvailable() {
|
|
292
|
-
return runDocker([
|
|
293
|
-
"version",
|
|
294
|
-
"--format",
|
|
295
|
-
"{{.Server.Version}}"
|
|
296
|
-
]);
|
|
297
|
-
}
|
|
298
|
-
async function pullImage(image) {
|
|
299
|
-
await requireDocker([
|
|
300
|
-
"pull",
|
|
301
|
-
"--quiet",
|
|
302
|
-
image
|
|
303
|
-
], `Pull Docker image ${image}`);
|
|
304
|
-
}
|
|
305
|
-
async function imageExists(image) {
|
|
306
|
-
let result;
|
|
307
|
-
const args = [
|
|
308
|
-
"image",
|
|
309
|
-
"inspect",
|
|
310
|
-
image
|
|
311
|
-
];
|
|
312
|
-
try {
|
|
313
|
-
result = await runDocker(args);
|
|
314
|
-
} catch (error) {
|
|
315
|
-
throw dockerError(`Inspect Docker image ${image}`, args, error);
|
|
316
|
-
}
|
|
317
|
-
return result.status === 0;
|
|
318
|
-
}
|
|
319
|
-
async function imageAvailable(image) {
|
|
320
|
-
if (await imageExists(image)) return "local";
|
|
321
|
-
const args = [
|
|
322
|
-
"manifest",
|
|
323
|
-
"inspect",
|
|
324
|
-
image
|
|
325
|
-
];
|
|
326
|
-
let result;
|
|
327
|
-
try {
|
|
328
|
-
result = await runDocker(args);
|
|
329
|
-
} catch (error) {
|
|
330
|
-
throw dockerError(`Inspect Docker image ${image}`, args, error);
|
|
331
|
-
}
|
|
332
|
-
if (result.status === 0) return "remote";
|
|
333
|
-
throw dockerError(`Inspect Docker image ${image}`, args, result);
|
|
334
|
-
}
|
|
335
|
-
async function ensureImage(image) {
|
|
336
|
-
if (await imageExists(image)) return "local";
|
|
337
|
-
await pullImage(image);
|
|
338
|
-
return "pulled";
|
|
339
|
-
}
|
|
340
|
-
async function inspectContainer(containerName) {
|
|
341
|
-
const result = await runDocker([
|
|
342
|
-
"inspect",
|
|
343
|
-
"--format",
|
|
344
|
-
"{{.Id}} {{.State.Running}} {{.Config.Image}}",
|
|
345
|
-
containerName
|
|
346
|
-
]);
|
|
347
|
-
if (result.status !== 0) return {
|
|
348
|
-
exists: false,
|
|
349
|
-
running: false
|
|
350
|
-
};
|
|
351
|
-
const [id, running, ...imageParts] = result.stdout.trim().split(/\s+/);
|
|
352
|
-
return {
|
|
353
|
-
exists: true,
|
|
354
|
-
running: running === "true",
|
|
355
|
-
id,
|
|
356
|
-
image: imageParts.join(" ")
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
async function startContainer(spec) {
|
|
360
|
-
return (await requireDocker(dockerRunArgs(spec), "Start local Zitadel container")).stdout.trim();
|
|
361
|
-
}
|
|
362
|
-
async function stopAndRemoveContainer(containerName) {
|
|
363
|
-
const inspect = await inspectContainer(containerName);
|
|
364
|
-
if (!inspect.exists) return;
|
|
365
|
-
if (inspect.running) await requireDocker(["stop", containerName], `Stop ${containerName}`);
|
|
366
|
-
await requireDocker(["rm", containerName], `Remove ${containerName}`);
|
|
367
|
-
}
|
|
368
|
-
async function containerLogs(containerName, tail) {
|
|
369
|
-
return (await requireDocker([
|
|
370
|
-
"logs",
|
|
371
|
-
"--tail",
|
|
372
|
-
String(tail),
|
|
373
|
-
containerName
|
|
374
|
-
], "Read logs")).stdout;
|
|
375
|
-
}
|
|
376
|
-
async function followContainerLogs(containerName, tail) {
|
|
377
|
-
await streamDocker([
|
|
378
|
-
"logs",
|
|
379
|
-
"--tail",
|
|
380
|
-
String(tail),
|
|
381
|
-
"--follow",
|
|
382
|
-
containerName
|
|
383
|
-
]);
|
|
384
|
-
}
|
|
385
|
-
function currentUser() {
|
|
386
|
-
const getuid = process.getuid;
|
|
387
|
-
const getgid = process.getgid;
|
|
388
|
-
if (typeof getuid !== "function") return {};
|
|
389
|
-
const uid = getuid();
|
|
390
|
-
return {
|
|
391
|
-
uid,
|
|
392
|
-
gid: typeof getgid === "function" ? getgid() : uid
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
function metadataFromStart(input) {
|
|
396
|
-
return {
|
|
397
|
-
schema_version: 1,
|
|
398
|
-
backend: "docker",
|
|
399
|
-
container_name: input.containerName,
|
|
400
|
-
container_id: input.containerId,
|
|
401
|
-
image: input.image,
|
|
402
|
-
port: input.port,
|
|
403
|
-
server_url: input.serverUrl,
|
|
404
|
-
data_dir: input.cwdDataDir,
|
|
405
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
406
|
-
cli_version: input.cliVersion
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
async function requireDocker(args, action) {
|
|
410
|
-
let result;
|
|
411
|
-
try {
|
|
412
|
-
result = await runDocker(args);
|
|
413
|
-
} catch (error) {
|
|
414
|
-
throw dockerError(action, args, error);
|
|
415
|
-
}
|
|
416
|
-
if (result.status !== 0) throw dockerError(action, args, result);
|
|
417
|
-
return result;
|
|
418
|
-
}
|
|
419
|
-
function dockerError(action, args, cause) {
|
|
420
|
-
const details = cause && typeof cause === "object" && "stderr" in cause ? {
|
|
421
|
-
command: ["docker", ...args],
|
|
422
|
-
stderr: String(cause.stderr)
|
|
423
|
-
} : {
|
|
424
|
-
command: ["docker", ...args],
|
|
425
|
-
cause
|
|
426
|
-
};
|
|
427
|
-
return new ZitadelError("E_VALIDATION", `${action} failed`, {
|
|
428
|
-
hint: "Check that Docker is installed, running, and reachable from this shell.",
|
|
429
|
-
nextCommands: ["zitadel doctor"],
|
|
430
|
-
details
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
//#endregion
|
|
434
|
-
export { followContainerLogs as a, metadataFromStart as c, assertServerPackageAvailable as d, binaryLogs as f, stopBinaryRuntime as g, startBinaryRuntime as h, ensureImage as i, startContainer as l, isProcessRunning as m, currentUser as n, imageAvailable as o, followBinaryLogs as p, dockerAvailable as r, inspectContainer as s, containerLogs as t, stopAndRemoveContainer as u };
|
|
435
|
-
|
|
436
|
-
//# sourceMappingURL=docker-B1MjOMFo.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"docker-B1MjOMFo.mjs","names":[],"sources":["../src/lib/local-server/binary.ts","../src/lib/local-server/docker.ts"],"sourcesContent":["import { spawn } from \"node:child_process\";\nimport { createReadStream } from \"node:fs\";\nimport { mkdir, open, readFile, stat } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\n\nimport { ZitadelError } from \"../errors\";\nimport {\n type BinaryRuntimeMetadata,\n type RuntimeMetadata,\n checkLocalServerHealth,\n} from \"./runtime\";\n\nexport const SERVER_NPM_PACKAGE = \"@zitadel/server\";\nconst START_COMMAND_ENV = \"ZITADEL_SERVER_BINARY\";\nconst START_COMMAND_VERSION_ENV = \"ZITADEL_SERVER_BINARY_VERSION\";\nconst STOP_TIMEOUT_MS = 10_000;\nconst STOP_KILL_TIMEOUT_MS = 2_000;\n\nconst require = createRequire(import.meta.url);\n\nexport type BinaryRunSpec = {\n cliVersion: string;\n dataDir: string;\n logPath: string;\n port: number;\n serverUrl: string;\n};\n\nexport type StopBinaryRuntimeResult = Readonly<{\n pid: number;\n signal?: NodeJS.Signals;\n status: \"failed\" | \"stale\" | \"stopped\";\n target: \"process\" | \"process-group\";\n}>;\n\nexport function resolveServerCommand(env: NodeJS.ProcessEnv = process.env): {\n command: string;\n args: string[];\n serverPackage: string;\n serverVersion: string;\n} {\n if (env[START_COMMAND_ENV]) {\n return {\n command: env[START_COMMAND_ENV],\n args: [],\n serverPackage: SERVER_NPM_PACKAGE,\n serverVersion: env[START_COMMAND_VERSION_ENV]?.trim() || \"override\",\n };\n }\n\n const manifestPath = resolveServerPackageManifest();\n const manifest = require(manifestPath) as { version?: unknown };\n return {\n command: process.execPath,\n args: [join(dirname(manifestPath), \"bin\", \"zitadel-server.js\")],\n serverPackage: SERVER_NPM_PACKAGE,\n serverVersion: typeof manifest.version === \"string\" ? manifest.version : \"unknown\",\n };\n}\n\nexport async function startBinaryRuntime(spec: BinaryRunSpec): Promise<BinaryRuntimeMetadata> {\n const command = resolveServerCommand();\n await mkdir(dirname(spec.logPath), { recursive: true, mode: 0o700 });\n const log = await open(spec.logPath, \"a\", 0o600);\n try {\n const child = spawn(command.command, command.args, {\n detached: true,\n env: {\n ...process.env,\n NEXTGEN_SERVER_ADDRESS: `:${String(spec.port)}`,\n NEXTGEN_SERVER_DATA_DIR: spec.dataDir,\n // Browser-facing URLs (claim, dashboard) must point at this local\n // server, not the cloud default the server config falls back to.\n NEXTGEN_SERVER_PUBLIC_BASE: spec.serverUrl,\n },\n stdio: [\"ignore\", log.fd, log.fd],\n });\n child.unref();\n if (!child.pid) {\n throw new Error(\"server process did not expose a pid\");\n }\n return {\n schema_version: 1,\n backend: \"binary\",\n pid: child.pid,\n command: [command.command, ...command.args].join(\" \"),\n log_path: spec.logPath,\n server_package: command.serverPackage,\n server_version: command.serverVersion,\n port: spec.port,\n server_url: spec.serverUrl,\n data_dir: spec.dataDir,\n created_at: new Date().toISOString(),\n cli_version: spec.cliVersion,\n };\n } finally {\n await log.close();\n }\n}\n\nexport async function stopBinaryRuntime(pid: number): Promise<StopBinaryRuntimeResult> {\n if (!isProcessRunning(pid)) {\n return { pid, status: \"stale\", target: \"process\" };\n }\n const term = signalRuntime(pid, \"SIGTERM\");\n if (!term.sent) {\n return { pid, status: \"stale\", target: term.target };\n }\n if (await waitForExit(pid, STOP_TIMEOUT_MS)) {\n return { pid, status: \"stopped\", target: term.target, signal: \"SIGTERM\" };\n }\n\n if (isProcessRunning(pid)) {\n const kill = signalRuntime(pid, \"SIGKILL\");\n if (kill.sent && (await waitForExit(pid, STOP_KILL_TIMEOUT_MS))) {\n return { pid, status: \"stopped\", target: kill.target, signal: \"SIGKILL\" };\n }\n }\n return { pid, status: \"failed\", target: term.target, signal: \"SIGKILL\" };\n}\n\nexport function isProcessRunning(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return isErrno(error, \"EPERM\");\n }\n}\n\nexport async function binaryLogs(logPath: string, tail: number): Promise<string> {\n let content = \"\";\n try {\n content = await readFile(logPath, \"utf8\");\n } catch (error) {\n if (isErrno(error, \"ENOENT\")) {\n return \"\";\n }\n throw error;\n }\n const lines = content.split(/\\r?\\n/);\n const hasTrailingNewline = lines.at(-1) === \"\";\n const body = hasTrailingNewline ? lines.slice(0, -1) : lines;\n const selected = body.slice(-tail).join(\"\\n\");\n return selected.length === 0 ? \"\" : `${selected}${hasTrailingNewline ? \"\\n\" : \"\"}`;\n}\n\nexport async function followBinaryLogs(logPath: string, tail: number): Promise<void> {\n process.stdout.write(await binaryLogs(logPath, tail));\n let offset = await fileSize(logPath);\n await new Promise<void>((resolveFollow, reject) => {\n const interval = setInterval(() => {\n void (async () => {\n try {\n const size = await fileSize(logPath);\n if (size > offset) {\n const stream = createReadStream(logPath, { start: offset, end: size - 1 });\n stream.pipe(process.stdout, { end: false });\n offset = size;\n }\n } catch (error) {\n reject(error);\n }\n })();\n }, 1000);\n const stop = () => {\n clearInterval(interval);\n resolveFollow();\n };\n process.once(\"SIGINT\", stop);\n process.once(\"SIGTERM\", stop);\n });\n}\n\nexport async function assertServerPackageAvailable(): Promise<string> {\n try {\n const command = resolveServerCommand();\n return command.serverVersion;\n } catch (error) {\n throw new ZitadelError(\"E_VALIDATION\", \"Zitadel server npm package is not available\", {\n hint: \"Reinstall @zitadel/cli so npm can install @zitadel/server and its platform package.\",\n nextCommands: [\"npm install @zitadel/cli@alpha\"],\n details: { package: SERVER_NPM_PACKAGE, message: errorMessage(error) },\n });\n }\n}\n\nexport async function binaryRuntimeHealthy(runtime: RuntimeMetadata): Promise<boolean> {\n return (\n runtime.backend === \"binary\" &&\n isProcessRunning(runtime.pid) &&\n (await checkLocalServerHealth(runtime.server_url))\n );\n}\n\nfunction resolveServerPackageManifest(): string {\n try {\n return require.resolve(`${SERVER_NPM_PACKAGE}/package.json`);\n } catch (error) {\n throw new Error(`Missing ${SERVER_NPM_PACKAGE}. Reinstall @zitadel/cli.`, { cause: error });\n }\n}\n\nasync function fileSize(path: string): Promise<number> {\n try {\n return (await stat(path)).size;\n } catch (error) {\n if (isErrno(error, \"ENOENT\")) {\n return 0;\n }\n throw error;\n }\n}\n\nfunction isErrno(error: unknown, code: string): boolean {\n return (\n typeof error === \"object\" &&\n error !== null &&\n \"code\" in error &&\n (error as { code?: unknown }).code === code\n );\n}\n\nfunction signalProcess(pid: number, signal: NodeJS.Signals): boolean {\n try {\n process.kill(pid, signal);\n return true;\n } catch (error) {\n if (isErrno(error, \"ESRCH\")) {\n return false;\n }\n throw error;\n }\n}\n\nfunction signalRuntime(\n pid: number,\n signal: NodeJS.Signals,\n): { sent: boolean; target: \"process\" | \"process-group\" } {\n if (process.platform !== \"win32\") {\n try {\n process.kill(-pid, signal);\n return { sent: true, target: \"process-group\" };\n } catch (error) {\n if (!isErrno(error, \"ESRCH\")) {\n throw error;\n }\n }\n }\n return { sent: signalProcess(pid, signal), target: \"process\" };\n}\n\nasync function waitForExit(pid: number, timeoutMs: number): Promise<boolean> {\n const deadline = Date.now() + timeoutMs;\n while (Date.now() < deadline) {\n if (!isProcessRunning(pid)) {\n return true;\n }\n await delay(200);\n }\n return !isProcessRunning(pid);\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolveDelay) => setTimeout(resolveDelay, ms));\n}\n","import { spawn } from \"node:child_process\";\n\nimport { ZitadelError } from \"../errors\";\nimport {\n CONTAINER_DATA_DIR,\n CONTAINER_HTTP_PORT,\n type ContainerIdentity,\n type RuntimeMetadata,\n} from \"./runtime\";\n\nexport type DockerResult = {\n status: number;\n stdout: string;\n stderr: string;\n};\n\nexport type DockerRunSpec = {\n containerName: string;\n image: string;\n port: number;\n dataDir: string;\n identity?: ContainerIdentity;\n};\n\nexport function dockerRunArgs(spec: DockerRunSpec): string[] {\n const args = [\n \"run\",\n \"--detach\",\n \"--name\",\n spec.containerName,\n \"--publish\",\n `127.0.0.1:${spec.port}:${CONTAINER_HTTP_PORT}`,\n \"--volume\",\n `${spec.dataDir}:${CONTAINER_DATA_DIR}`,\n \"--env\",\n `NEXTGEN_SERVER_ADDRESS=:${CONTAINER_HTTP_PORT}`,\n \"--env\",\n `NEXTGEN_SERVER_DATA_DIR=${CONTAINER_DATA_DIR}`,\n // Browser-facing URLs (claim, dashboard) must use the host-visible port\n // published above, not the cloud default the server config falls back to.\n \"--env\",\n `NEXTGEN_SERVER_PUBLIC_BASE=http://localhost:${spec.port}`,\n ];\n\n if (spec.identity) {\n args.push(\n \"--volume\",\n `${spec.identity.passwdFile}:/etc/passwd:ro`,\n \"--volume\",\n `${spec.identity.groupFile}:/etc/group:ro`,\n \"--user\",\n `${spec.identity.uid}:${spec.identity.gid}`,\n );\n }\n\n args.push(spec.image);\n return args;\n}\n\nexport async function runDocker(args: string[]): Promise<DockerResult> {\n return new Promise((resolve, reject) => {\n const child = spawn(\"docker\", args, {\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n env: process.env,\n });\n let stdout = \"\";\n let stderr = \"\";\n child.stdout?.setEncoding(\"utf8\");\n child.stderr?.setEncoding(\"utf8\");\n child.stdout?.on(\"data\", (chunk: string) => {\n stdout += chunk;\n });\n child.stderr?.on(\"data\", (chunk: string) => {\n stderr += chunk;\n });\n child.on(\"error\", reject);\n child.on(\"close\", (code) => {\n resolve({ status: code ?? 1, stdout, stderr });\n });\n });\n}\n\nexport async function streamDocker(args: string[]): Promise<void> {\n await new Promise<void>((resolve, reject) => {\n const child = spawn(\"docker\", args, {\n stdio: \"inherit\",\n env: process.env,\n });\n child.on(\"error\", reject);\n child.on(\"close\", (code) => {\n if (code === 0) {\n resolve();\n } else {\n reject(new Error(`docker ${args.join(\" \")} exited with status ${code ?? 1}`));\n }\n });\n });\n}\n\nexport async function dockerAvailable(): Promise<DockerResult> {\n return runDocker([\"version\", \"--format\", \"{{.Server.Version}}\"]);\n}\n\nexport async function pullImage(image: string): Promise<void> {\n await requireDocker([\"pull\", \"--quiet\", image], `Pull Docker image ${image}`);\n}\n\nexport async function imageExists(image: string): Promise<boolean> {\n let result: DockerResult;\n const args = [\"image\", \"inspect\", image];\n try {\n result = await runDocker(args);\n } catch (error) {\n throw dockerError(`Inspect Docker image ${image}`, args, error);\n }\n return result.status === 0;\n}\n\nexport async function imageAvailable(image: string): Promise<\"local\" | \"remote\"> {\n if (await imageExists(image)) {\n return \"local\";\n }\n\n const args = [\"manifest\", \"inspect\", image];\n let result: DockerResult;\n try {\n result = await runDocker(args);\n } catch (error) {\n throw dockerError(`Inspect Docker image ${image}`, args, error);\n }\n if (result.status === 0) {\n return \"remote\";\n }\n throw dockerError(`Inspect Docker image ${image}`, args, result);\n}\n\nexport async function ensureImage(image: string): Promise<\"local\" | \"pulled\"> {\n if (await imageExists(image)) {\n return \"local\";\n }\n await pullImage(image);\n return \"pulled\";\n}\n\nexport async function inspectContainer(containerName: string): Promise<{\n exists: boolean;\n running: boolean;\n id?: string;\n image?: string;\n}> {\n const result = await runDocker([\n \"inspect\",\n \"--format\",\n \"{{.Id}} {{.State.Running}} {{.Config.Image}}\",\n containerName,\n ]);\n if (result.status !== 0) {\n return { exists: false, running: false };\n }\n const [id, running, ...imageParts] = result.stdout.trim().split(/\\s+/);\n return { exists: true, running: running === \"true\", id, image: imageParts.join(\" \") };\n}\n\nexport async function startContainer(spec: DockerRunSpec): Promise<string> {\n const args = dockerRunArgs(spec);\n const result = await requireDocker(args, \"Start local Zitadel container\");\n return result.stdout.trim();\n}\n\nexport async function stopAndRemoveContainer(containerName: string): Promise<void> {\n const inspect = await inspectContainer(containerName);\n if (!inspect.exists) {\n return;\n }\n if (inspect.running) {\n await requireDocker([\"stop\", containerName], `Stop ${containerName}`);\n }\n await requireDocker([\"rm\", containerName], `Remove ${containerName}`);\n}\n\nexport async function containerLogs(containerName: string, tail: number): Promise<string> {\n const result = await requireDocker([\"logs\", \"--tail\", String(tail), containerName], \"Read logs\");\n return result.stdout;\n}\n\nexport async function followContainerLogs(containerName: string, tail: number): Promise<void> {\n await streamDocker([\"logs\", \"--tail\", String(tail), \"--follow\", containerName]);\n}\n\nexport function currentUser(): { uid?: number; gid?: number } {\n const getuid = process.getuid;\n const getgid = process.getgid;\n if (typeof getuid !== \"function\") {\n return {};\n }\n const uid = getuid();\n const gid = typeof getgid === \"function\" ? getgid() : uid;\n return { uid, gid };\n}\n\nexport function metadataFromStart(input: {\n cwdDataDir: string;\n cliVersion: string;\n containerName: string;\n containerId: string;\n image: string;\n port: number;\n serverUrl: string;\n}): RuntimeMetadata {\n return {\n schema_version: 1,\n backend: \"docker\",\n container_name: input.containerName,\n container_id: input.containerId,\n image: input.image,\n port: input.port,\n server_url: input.serverUrl,\n data_dir: input.cwdDataDir,\n created_at: new Date().toISOString(),\n cli_version: input.cliVersion,\n };\n}\n\nexport async function requireDocker(args: string[], action: string): Promise<DockerResult> {\n let result: DockerResult;\n try {\n result = await runDocker(args);\n } catch (error) {\n throw dockerError(action, args, error);\n }\n if (result.status !== 0) {\n throw dockerError(action, args, result);\n }\n return result;\n}\n\nfunction dockerError(action: string, args: string[], cause: unknown): ZitadelError {\n const details =\n cause && typeof cause === \"object\" && \"stderr\" in cause\n ? { command: [\"docker\", ...args], stderr: String((cause as { stderr?: unknown }).stderr) }\n : { command: [\"docker\", ...args], cause };\n return new ZitadelError(\"E_VALIDATION\", `${action} failed`, {\n hint: \"Check that Docker is installed, running, and reachable from this shell.\",\n nextCommands: [\"zitadel doctor\"],\n details,\n });\n}\n"],"mappings":";;;;;;;AAaA,MAAa,qBAAqB;AAClC,MAAM,oBAAoB;AAC1B,MAAM,4BAA4B;AAClC,MAAM,kBAAkB;AACxB,MAAM,uBAAuB;AAE7B,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAiB9C,SAAgB,qBAAqB,MAAyB,QAAQ,KAKpE;AACA,KAAI,IAAI,mBACN,QAAO;EACL,SAAS,IAAI;EACb,MAAM,EAAE;EACR,eAAe;EACf,eAAe,IAAI,4BAA4B,MAAM,IAAI;EAC1D;CAGH,MAAM,eAAe,8BAA8B;CACnD,MAAM,WAAW,QAAQ,aAAa;AACtC,QAAO;EACL,SAAS,QAAQ;EACjB,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EACb,MAAM,MAAM;EACZ,YAAY,MAAM;EAClB,UAAU,MAAM;EAChB,6BAAY,IAAI,MAAM,EAAC,aAAa;EACpC,aAAa,MAAM;EACpB;;AAGH,eAAsB,cAAc,MAAgB,QAAuC;CACzF,IAAI;AACJ,KAAI;AACF,WAAS,MAAM,UAAU,KAAK;UACvB,OAAO;AACd,QAAM,YAAY,QAAQ,MAAM,MAAM;;AAExC,KAAI,OAAO,WAAW,EACpB,OAAM,YAAY,QAAQ,MAAM,OAAO;AAEzC,QAAO;;AAGT,SAAS,YAAY,QAAgB,MAAgB,OAA8B;CACjF,MAAM,UACJ,SAAS,OAAO,UAAU,YAAY,YAAY,QAC9C;EAAE,SAAS,CAAC,UAAU,GAAG,KAAK;EAAE,QAAQ,OAAQ,MAA+B,OAAO;EAAE,GACxF;EAAE,SAAS,CAAC,UAAU,GAAG,KAAK;EAAE;EAAO;AAC7C,QAAO,IAAI,aAAa,gBAAgB,GAAG,OAAO,UAAU;EAC1D,MAAM;EACN,cAAc,CAAC,iBAAiB;EAChC;EACD,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
//#region src/lib/environment.ts
|
|
3
|
-
/**
|
|
4
|
-
* CLI-side deployment environment. Not an API model — it gates which
|
|
5
|
-
* `zitadel.json` environment block and server the commands target.
|
|
6
|
-
* Project request/response shapes live in `@zitadel/api`
|
|
7
|
-
* (generated from the OpenAPI spec).
|
|
8
|
-
*/
|
|
9
|
-
const environmentSchema = z.enum([
|
|
10
|
-
"development",
|
|
11
|
-
"preview",
|
|
12
|
-
"production"
|
|
13
|
-
]);
|
|
14
|
-
//#endregion
|
|
15
|
-
export { environmentSchema as t };
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=environment-fibXmzM8.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"environment-fibXmzM8.mjs","names":[],"sources":["../src/lib/environment.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/**\n * CLI-side deployment environment. Not an API model — it gates which\n * `zitadel.json` environment block and server the commands target.\n * Project request/response shapes live in `@zitadel/api`\n * (generated from the OpenAPI spec).\n */\nexport const environmentSchema = z.enum([\"development\", \"preview\", \"production\"]);\n"],"mappings":";;;;;;;;AAQA,MAAa,oBAAoB,EAAE,KAAK;CAAC;CAAe;CAAW;CAAa,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { j as publicCliCommand } from "./oclif-JlsN1lfO.mjs";
|
|
2
|
-
//#region src/lib/journey-guidance.ts
|
|
3
|
-
/**
|
|
4
|
-
* Journey-staged guidance copy shared by `setup` and `status`.
|
|
5
|
-
*
|
|
6
|
-
* The staging exists because of alpha tester feedback (Elina, alpha.15):
|
|
7
|
-
* printing customize/publish steps before the user has logged in once reads
|
|
8
|
-
* as noise, but dropping them entirely recreates the round-1 dead end where
|
|
9
|
-
* nothing pointed to the next step. So the guidance tracks journey position —
|
|
10
|
-
* verify first, customize/publish once login demonstrably works — and both
|
|
11
|
-
* commands quote the same copy so the story doesn't fork.
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* The verify mission: prove the scaffolded auth round-trips before touching
|
|
15
|
-
* config. `openUrl` prefixes the browser destination for callers that have
|
|
16
|
-
* not already narrated it (setup's box has a separate "Start your project"
|
|
17
|
-
* line; status has only the issuer).
|
|
18
|
-
*/
|
|
19
|
-
function verifyLoginAction(openUrl) {
|
|
20
|
-
return `Verify auth in the browser: ${openUrl ? `open ${openUrl}, ` : ""}register a user, log out, log in again with the same user, and confirm /profile shows Signed in.`;
|
|
21
|
-
}
|
|
22
|
-
/** The customize/publish pair, in Elina's tested wording. */
|
|
23
|
-
function customizeAndPublishActions(cliVersion) {
|
|
24
|
-
return ["Customize what you ask for and how people sign in: edit .zitadel/schemas/ to change the information you collect, and .zitadel/flows/ to change the sign-up/sign-in experience. Each folder has a README with examples.", `See your changes before they go live: ${publicCliCommand("plan", cliVersion)} to preview, then ${publicCliCommand("apply", cliVersion)} to publish.`];
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* How to change the login's look, depending on whether setup already ejected
|
|
28
|
-
* a starter design. With a design, revision 1 is already live and the
|
|
29
|
-
* template is repo-owned — point at the files and the plan/apply loop.
|
|
30
|
-
* Without one, point at `branding eject` so the built-in template's
|
|
31
|
-
* customization path stays discoverable after setup.
|
|
32
|
-
*/
|
|
33
|
-
function brandingGuidanceAction(design, cliVersion) {
|
|
34
|
-
if (design) return `Make the login yours: the ${design} design is live as branding revision 1. Edit .zitadel/branding/login.liquid (logo and hero image URLs live in branding.json), then ${publicCliCommand("plan", cliVersion)} and ${publicCliCommand("apply", cliVersion)} to publish the next revision.`;
|
|
35
|
-
return `Change how the login looks: ${publicCliCommand("branding eject", cliVersion)} scaffolds .zitadel/branding/ from a starter design (centered, split, split-right, hero, minimal) for you to edit.`;
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
|
-
export { customizeAndPublishActions as n, verifyLoginAction as r, brandingGuidanceAction as t };
|
|
39
|
-
|
|
40
|
-
//# sourceMappingURL=journey-guidance-C9MxJNTg.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"journey-guidance-C9MxJNTg.mjs","names":[],"sources":["../src/lib/journey-guidance.ts"],"sourcesContent":["import { publicCliCommand } from \"./public-cli\";\n\n/**\n * Journey-staged guidance copy shared by `setup` and `status`.\n *\n * The staging exists because of alpha tester feedback (Elina, alpha.15):\n * printing customize/publish steps before the user has logged in once reads\n * as noise, but dropping them entirely recreates the round-1 dead end where\n * nothing pointed to the next step. So the guidance tracks journey position —\n * verify first, customize/publish once login demonstrably works — and both\n * commands quote the same copy so the story doesn't fork.\n */\n\n/**\n * The verify mission: prove the scaffolded auth round-trips before touching\n * config. `openUrl` prefixes the browser destination for callers that have\n * not already narrated it (setup's box has a separate \"Start your project\"\n * line; status has only the issuer).\n */\nexport function verifyLoginAction(openUrl?: string): string {\n const open = openUrl ? `open ${openUrl}, ` : \"\";\n return (\n `Verify auth in the browser: ${open}register a user, log out, ` +\n \"log in again with the same user, and confirm /profile shows Signed in.\"\n );\n}\n\n/** The customize/publish pair, in Elina's tested wording. */\nexport function customizeAndPublishActions(cliVersion: string): string[] {\n return [\n \"Customize what you ask for and how people sign in: edit .zitadel/schemas/ to change \" +\n \"the information you collect, and .zitadel/flows/ to change the sign-up/sign-in \" +\n \"experience. Each folder has a README with examples.\",\n `See your changes before they go live: ${publicCliCommand(\"plan\", cliVersion)} to preview, ` +\n `then ${publicCliCommand(\"apply\", cliVersion)} to publish.`,\n ];\n}\n\n/**\n * How to change the login's look, depending on whether setup already ejected\n * a starter design. With a design, revision 1 is already live and the\n * template is repo-owned — point at the files and the plan/apply loop.\n * Without one, point at `branding eject` so the built-in template's\n * customization path stays discoverable after setup.\n */\nexport function brandingGuidanceAction(\n design: string | undefined,\n cliVersion: string,\n): string {\n if (design) {\n return (\n `Make the login yours: the ${design} design is live as branding revision 1. ` +\n \"Edit .zitadel/branding/login.liquid (logo and hero image URLs live in \" +\n `branding.json), then ${publicCliCommand(\"plan\", cliVersion)} and ` +\n `${publicCliCommand(\"apply\", cliVersion)} to publish the next revision.`\n );\n }\n return (\n \"Change how the login looks: \" +\n `${publicCliCommand(\"branding eject\", cliVersion)} scaffolds .zitadel/branding/ ` +\n \"from a starter design (centered, split, split-right, hero, minimal) for you to edit.\"\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,SAAgB,kBAAkB,SAA0B;AAE1D,QACE,+BAFW,UAAU,QAAQ,QAAQ,MAAM,GAEP;;;AAMxC,SAAgB,2BAA2B,YAA8B;AACvE,QAAO,CACL,0NAGA,yCAAyC,iBAAiB,QAAQ,WAAW,CAAC,oBACpE,iBAAiB,SAAS,WAAW,CAAC,cACjD;;;;;;;;;AAUH,SAAgB,uBACd,QACA,YACQ;AACR,KAAI,OACF,QACE,6BAA6B,OAAO,qIAEZ,iBAAiB,QAAQ,WAAW,CAAC,OAC1D,iBAAiB,SAAS,WAAW,CAAC;AAG7C,QACE,+BACG,iBAAiB,kBAAkB,WAAW,CAAC"}
|