@kubb/cli 5.3.19 → 5.4.1
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/dist/{Telemetry-Dw5s6abr.js → Telemetry-cHHOzBW8.js} +3 -3
- package/dist/{Telemetry-Dw5s6abr.js.map → Telemetry-cHHOzBW8.js.map} +1 -1
- package/dist/{agent-3JmkMghp.js → agent-w0Hlq4mG.js} +2 -2
- package/dist/{agent-3JmkMghp.js.map → agent-w0Hlq4mG.js.map} +1 -1
- package/dist/background-BDZa6MJS.js +252 -0
- package/dist/background-BDZa6MJS.js.map +1 -0
- package/dist/background-CNHhnQ5M.cjs +171 -0
- package/dist/background-CNHhnQ5M.cjs.map +1 -0
- package/dist/background-CS7jIBAY.js +2 -0
- package/dist/{connect-BjIZWrx8.js → connect-CIVmP_6l.js} +3 -3
- package/dist/{connect-BjIZWrx8.js.map → connect-CIVmP_6l.js.map} +1 -1
- package/dist/{connect-D9g-WltE.cjs → connect-DLbFBfoV.cjs} +2 -2
- package/dist/{connect-D9g-WltE.cjs.map → connect-DLbFBfoV.cjs.map} +1 -1
- package/dist/{errors-C8yNfV7w.js → errors-BQJzaUwP.js} +2 -2
- package/dist/{errors-C8yNfV7w.js.map → errors-BQJzaUwP.js.map} +1 -1
- package/dist/{generate-DhMzVV6l.cjs → generate-BWwjYxN5.cjs} +2 -2
- package/dist/{generate-DhMzVV6l.cjs.map → generate-BWwjYxN5.cjs.map} +1 -1
- package/dist/{generate-D0Zx0PDk.js → generate-BY_PbRPu.js} +3 -3
- package/dist/{generate-D0Zx0PDk.js.map → generate-BY_PbRPu.js.map} +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -9
- package/dist/{init-Bbz6UeBl.js → init-Dpa1wuah.js} +4 -4
- package/dist/{init-Bbz6UeBl.js.map → init-Dpa1wuah.js.map} +1 -1
- package/dist/{init-nHruRHSm.cjs → init-yb2ZIQwp.cjs} +2 -2
- package/dist/{init-nHruRHSm.cjs.map → init-yb2ZIQwp.cjs.map} +1 -1
- package/dist/{login-DFda5soT.js → login-Di6_DU_V.js} +3 -3
- package/dist/{login-DFda5soT.js.map → login-Di6_DU_V.js.map} +1 -1
- package/dist/{login-BG7t5rN5.cjs → login-LVIZdclC.cjs} +2 -2
- package/dist/{login-BG7t5rN5.cjs.map → login-LVIZdclC.cjs.map} +1 -1
- package/dist/{logout-B_uyXcH1.cjs → logout-B8L-Jb8P.cjs} +4 -2
- package/dist/logout-B8L-Jb8P.cjs.map +1 -0
- package/dist/{logout-1AnE6Wgf.js → logout-BOhSROh8.js} +5 -3
- package/dist/logout-BOhSROh8.js.map +1 -0
- package/dist/{output-C_Gk4p-8.js → output-C5h3LBgQ.js} +3 -3
- package/dist/{output-C_Gk4p-8.js.map → output-C5h3LBgQ.js.map} +1 -1
- package/dist/{package-Dg6ALxDA.cjs → package-DjS7Xk-S.cjs} +2 -2
- package/dist/package-DjS7Xk-S.cjs.map +1 -0
- package/dist/package-IY922xjh.js +6 -0
- package/dist/package-IY922xjh.js.map +1 -0
- package/dist/{rolldown-runtime-C0LytTxp.js → rolldown-runtime-CRm0XQPb.js} +1 -0
- package/dist/{run-BGhKiO9F.cjs → run-0k75--OI.cjs} +2 -2
- package/dist/{run-BGhKiO9F.cjs.map → run-0k75--OI.cjs.map} +1 -1
- package/dist/{run-WTZgnA65.cjs → run-BNQt-kUj.cjs} +2 -2
- package/dist/{run-WTZgnA65.cjs.map → run-BNQt-kUj.cjs.map} +1 -1
- package/dist/{run-CJmvvmr6.js → run-BaqE5cze.js} +5 -5
- package/dist/{run-CJmvvmr6.js.map → run-BaqE5cze.js.map} +1 -1
- package/dist/{run-DgWNV5Z5.js → run-BsP5syy1.js} +107 -156
- package/dist/{run-DgWNV5Z5.js.map → run-BsP5syy1.js.map} +1 -1
- package/dist/{run-cx-6U2Rq.js → run-DQNoMoHW.js} +7 -7
- package/dist/{run-cx-6U2Rq.js.map → run-DQNoMoHW.js.map} +1 -1
- package/dist/{run-CXYrjM2-.js → run-Drf9rg9j.js} +5 -5
- package/dist/{run-CXYrjM2-.js.map → run-Drf9rg9j.js.map} +1 -1
- package/dist/{run-BEZhsX-8.js → run-G2lUygYI.js} +3 -3
- package/dist/{run-BEZhsX-8.js.map → run-G2lUygYI.js.map} +1 -1
- package/dist/{run-CTu2E3vp.cjs → run-GGJ4QLsg.cjs} +2 -2
- package/dist/{run-CTu2E3vp.cjs.map → run-GGJ4QLsg.cjs.map} +1 -1
- package/dist/{run-yGsAbOqK.cjs → run-_hE0GAWu.cjs} +110 -147
- package/dist/{run-yGsAbOqK.cjs.map → run-_hE0GAWu.cjs.map} +1 -1
- package/dist/{snapshot-DmmO5Ymq.cjs → snapshot-DndnZx5y.cjs} +2 -2
- package/dist/{snapshot-DmmO5Ymq.cjs.map → snapshot-DndnZx5y.cjs.map} +1 -1
- package/dist/{snapshot-BBU1-wmn.js → snapshot-ZY24CtRk.js} +6 -6
- package/dist/{snapshot-BBU1-wmn.js.map → snapshot-ZY24CtRk.js.map} +1 -1
- package/dist/start-BlwmWZDb.js +12 -0
- package/dist/start-BlwmWZDb.js.map +1 -0
- package/dist/start-Bu5xpzix.cjs +12 -0
- package/dist/start-Bu5xpzix.cjs.map +1 -0
- package/dist/status-5UqQP9WB.js +17 -0
- package/dist/status-5UqQP9WB.js.map +1 -0
- package/dist/status-L4I8buia.cjs +17 -0
- package/dist/status-L4I8buia.cjs.map +1 -0
- package/dist/stop-BQkjAPNH.cjs +11 -0
- package/dist/stop-BQkjAPNH.cjs.map +1 -0
- package/dist/stop-mqUTbxMO.js +11 -0
- package/dist/stop-mqUTbxMO.js.map +1 -0
- package/dist/{studio-2iNLigEg.js → studio-BBnIuXst.js} +27 -13
- package/dist/studio-BBnIuXst.js.map +1 -0
- package/dist/{studio-Dz9XBEp6.cjs → studio-BFy085ae.cjs} +26 -12
- package/dist/studio-BFy085ae.cjs.map +1 -0
- package/dist/studioWorker.d.ts +1 -0
- package/dist/studioWorker.js +62 -0
- package/dist/studioWorker.js.map +1 -0
- package/dist/{utils-TpILNAy7.js → utils-BWksgOYQ.js} +36 -36
- package/dist/utils-BWksgOYQ.js.map +1 -0
- package/package.json +7 -7
- package/dist/logout-1AnE6Wgf.js.map +0 -1
- package/dist/logout-B_uyXcH1.cjs.map +0 -1
- package/dist/package-B1pE4gUR.js +0 -6
- package/dist/package-B1pE4gUR.js.map +0 -1
- package/dist/package-Dg6ALxDA.cjs.map +0 -1
- package/dist/status-B88gFiy4.cjs +0 -11
- package/dist/status-B88gFiy4.cjs.map +0 -1
- package/dist/status-BRdnIBoM.js +0 -11
- package/dist/status-BRdnIBoM.js.map +0 -1
- package/dist/studio-2iNLigEg.js.map +0 -1
- package/dist/studio-Dz9XBEp6.cjs.map +0 -1
- package/dist/utils-TpILNAy7.js.map +0 -1
|
@@ -4,7 +4,7 @@ const require_agent = require("./agent-BPqs9VRj.cjs");
|
|
|
4
4
|
const require_Telemetry = require("./Telemetry-B3kc9gFh.cjs");
|
|
5
5
|
const require_utils = require("./utils-DqUNntyL.cjs");
|
|
6
6
|
const require_output = require("./output-D-9bGS7y.cjs");
|
|
7
|
-
const require_package = require("./package-
|
|
7
|
+
const require_package = require("./package-DjS7Xk-S.cjs");
|
|
8
8
|
const require_constants = require("./constants-CdxpgX3_.cjs");
|
|
9
9
|
let node_util = require("node:util");
|
|
10
10
|
let node_crypto = require("node:crypto");
|
|
@@ -294,158 +294,109 @@ function explainRejectedToken(error, reason) {
|
|
|
294
294
|
if (reason === "reauthExhausted") return /* @__PURE__ */ new Error(`${error.message} Studio rejected the newly approved token too. Run \`kubb studio login\` and try again.`);
|
|
295
295
|
return /* @__PURE__ */ new Error(`${error.message} Run \`kubb studio login\` to pair again.`);
|
|
296
296
|
}
|
|
297
|
-
/**
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
#requestShutdown = () => this.#shutdown.abort();
|
|
306
|
-
#processEvents = node_process.default;
|
|
307
|
-
#credentials;
|
|
308
|
-
#hinted = false;
|
|
309
|
-
#hasReauthenticated = false;
|
|
310
|
-
#granted;
|
|
311
|
-
constructor(options, configPath) {
|
|
312
|
-
this.#options = options;
|
|
313
|
-
this.#configPath = configPath;
|
|
314
|
-
}
|
|
315
|
-
#reportDisconnected() {
|
|
316
|
-
if (this.#options.logLevel === "silent") return;
|
|
317
|
-
require_output.logOutro("Disconnected");
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Connects and streams generation events until the process is stopped or Studio rejects the
|
|
321
|
-
* token.
|
|
322
|
-
*
|
|
323
|
-
* One `AbortController` covers the whole run: it cancels an in-flight pairing poll on Ctrl+C and
|
|
324
|
-
* ends the wait in `#connectAndWait`. Its signal listeners are armed once here, so a retried
|
|
325
|
-
* pairing cannot leave a duplicate behind.
|
|
326
|
-
*/
|
|
327
|
-
async run() {
|
|
328
|
-
this.#processEvents.once("SIGINT", this.#requestShutdown);
|
|
329
|
-
this.#processEvents.once("SIGTERM", this.#requestShutdown);
|
|
330
|
-
try {
|
|
331
|
-
this.#credentials = await this.#resolveInitialCredentials();
|
|
332
|
-
this.#granted = await resolvePermissions(this.#options, this.#credentials, this.#configPath, !node_process.default.env.KUBB_AGENT_TOKEN);
|
|
333
|
-
this.#printBanner();
|
|
334
|
-
if (await (0, _kubb_studio.runConnection)({
|
|
335
|
-
credentials: this.#credentials,
|
|
336
|
-
signal: this.#shutdown.signal,
|
|
337
|
-
clientOptions: () => this.#clientOptions(),
|
|
338
|
-
onTokenRejected: ({ error, live }) => this.#handleRejection(error, live)
|
|
339
|
-
}) === "shutdown") this.#reportDisconnected();
|
|
340
|
-
} catch (error) {
|
|
341
|
-
if (error instanceof _kubb_studio.PairingCanceledError) return;
|
|
342
|
-
throw error;
|
|
343
|
-
} finally {
|
|
344
|
-
this.#processEvents.off("SIGINT", this.#requestShutdown);
|
|
345
|
-
this.#processEvents.off("SIGTERM", this.#requestShutdown);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
async #resolveInitialCredentials() {
|
|
349
|
-
const envToken = node_process.default.env.KUBB_AGENT_TOKEN;
|
|
350
|
-
const stored = envToken ? null : await readCredentials();
|
|
351
|
-
const resolved = envToken ? {
|
|
352
|
-
studioUrl: this.#options.studioUrl,
|
|
297
|
+
/** Validates the project and resolves pairing and permissions before starting its worker. */
|
|
298
|
+
async function prepareConnection(options, signal) {
|
|
299
|
+
const { configPath } = await loadConfigs(options);
|
|
300
|
+
const envToken = node_process.default.env.KUBB_AGENT_TOKEN;
|
|
301
|
+
const stored = envToken ? null : await readCredentials();
|
|
302
|
+
const credentials = await (async () => {
|
|
303
|
+
if (envToken) return {
|
|
304
|
+
studioUrl: options.studioUrl,
|
|
353
305
|
token: envToken,
|
|
354
306
|
agentId: "",
|
|
355
307
|
agentSlug: ""
|
|
356
|
-
} : stored?.studioUrl === this.#options.studioUrl ? stored : null;
|
|
357
|
-
if (resolved) return resolved;
|
|
358
|
-
if (require_agent.isCIEnvironment()) throw new Error(`Not paired with ${this.#options.studioUrl}. Set KUBB_AGENT_TOKEN, or run \`kubb studio login\` on a machine with a browser.`);
|
|
359
|
-
return login(this.#options, { signal: this.#shutdown.signal });
|
|
360
|
-
}
|
|
361
|
-
#printBanner() {
|
|
362
|
-
if (this.#options.logLevel === "silent") return;
|
|
363
|
-
const detail = (label, value) => `${(0, node_util.styleText)("dim", label.padEnd(7))} ${value}`;
|
|
364
|
-
require_output.logBlock([
|
|
365
|
-
detail("Studio", (0, node_util.styleText)("cyan", this.#options.studioUrl)),
|
|
366
|
-
detail("Project", node_path.default.basename(node_process.default.cwd())),
|
|
367
|
-
detail("Config", node_path.default.relative(node_process.default.cwd(), this.#configPath) || this.#configPath),
|
|
368
|
-
"",
|
|
369
|
-
(0, node_util.styleText)("dim", "Permissions"),
|
|
370
|
-
...formatPermissionRows(this.#granted)
|
|
371
|
-
]);
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* What every connection attempt opens with. Rebuilt per attempt, so a re-pair that changed the
|
|
375
|
-
* granted permissions takes effect on the next one.
|
|
376
|
-
*/
|
|
377
|
-
#clientOptions() {
|
|
378
|
-
return {
|
|
379
|
-
studioUrl: this.#options.studioUrl,
|
|
380
|
-
configPath: this.#configPath,
|
|
381
|
-
version: this.#options.version,
|
|
382
|
-
loadConfig: async () => (await loadConfigs(this.#options)).config,
|
|
383
|
-
root: node_process.default.cwd(),
|
|
384
|
-
permissions: this.#granted,
|
|
385
|
-
installLogger: async (hooks) => {
|
|
386
|
-
await require_utils.setupReporters(hooks, {
|
|
387
|
-
logLevel: _kubb_core.logLevel[this.#options.logLevel ?? "info"],
|
|
388
|
-
reporters: [_kubb_core.cliReporter]
|
|
389
|
-
});
|
|
390
|
-
hooks.hook("studio:connected", () => {
|
|
391
|
-
if (this.#hinted || this.#options.logLevel === "silent") return;
|
|
392
|
-
this.#hinted = true;
|
|
393
|
-
require_output.logBlock((0, node_util.styleText)("dim", "Press Ctrl+C to disconnect"));
|
|
394
|
-
});
|
|
395
|
-
hooks.hook("studio:ready", () => {
|
|
396
|
-
require_output.logTip();
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
308
|
};
|
|
309
|
+
if (stored?.studioUrl === options.studioUrl) return stored;
|
|
310
|
+
if (require_agent.isCIEnvironment()) throw new Error(`Not paired with ${options.studioUrl}. Set KUBB_AGENT_TOKEN, or run \`kubb studio login\` on a machine with a browser.`);
|
|
311
|
+
return login(options, { signal });
|
|
312
|
+
})();
|
|
313
|
+
return {
|
|
314
|
+
configPath,
|
|
315
|
+
credentials,
|
|
316
|
+
permissions: await resolvePermissions(options, credentials, configPath, !envToken)
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
/** Runs the same project connection in the foreground or in a background worker. */
|
|
320
|
+
async function connect(options, context = {}) {
|
|
321
|
+
const shutdown = new AbortController();
|
|
322
|
+
const signal = context.signal ?? shutdown.signal;
|
|
323
|
+
const stop = () => shutdown.abort();
|
|
324
|
+
const events = node_process.default;
|
|
325
|
+
if (!context.signal) {
|
|
326
|
+
events.once("SIGINT", stop);
|
|
327
|
+
events.once("SIGTERM", stop);
|
|
400
328
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
if (require_agent.isCIEnvironment() || !require_output.canUseTTY()) throw explainRejectedToken(error, "nonInteractive");
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Studio rejected the token, either before a session ever opened or once one was already live.
|
|
411
|
-
* Keeping a rejected token only produces 401s on every run, so it is forgotten and paired again.
|
|
412
|
-
* Returns the credential to reconnect with, or null when the run is over.
|
|
413
|
-
*/
|
|
414
|
-
async #handleRejection(error, live) {
|
|
415
|
-
if (node_process.default.env.KUBB_AGENT_TOKEN) throw explainRejectedToken(error, "envToken");
|
|
416
|
-
if (!live) await clearCredentials();
|
|
417
|
-
this.#assertCanReauthenticate(error);
|
|
418
|
-
console.log((0, node_util.styleText)("yellow", live ? `${error.message} Studio needs you to approve access again.` : `${error.message} Pairing again...`));
|
|
419
|
-
if (live) await clearCredentials();
|
|
420
|
-
const credentials = await this.#reauthenticate();
|
|
421
|
-
if (!credentials && live) this.#reportDisconnected();
|
|
422
|
-
return credentials;
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* Re-pairs and stores the resulting credentials. Returns null when the operator canceled it.
|
|
426
|
-
*/
|
|
427
|
-
async #reauthenticate() {
|
|
428
|
-
try {
|
|
429
|
-
this.#credentials = await login(this.#options, {
|
|
430
|
-
signal: this.#shutdown.signal,
|
|
431
|
-
previousCredentials: this.#credentials
|
|
432
|
-
});
|
|
433
|
-
} catch (loginError) {
|
|
434
|
-
if (loginError instanceof _kubb_studio.PairingCanceledError) return null;
|
|
435
|
-
throw loginError;
|
|
329
|
+
let hinted = false;
|
|
330
|
+
let reauthenticated = false;
|
|
331
|
+
try {
|
|
332
|
+
if (!context.prepared) {
|
|
333
|
+
const { getWorkerStatus } = await Promise.resolve().then(() => require("./background-CNHhnQ5M.cjs"));
|
|
334
|
+
if ((await getWorkerStatus()).running) throw new Error("This project is running in the background. Run `kubb studio stop` first.");
|
|
436
335
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
336
|
+
const prepared = context.prepared ?? await prepareConnection(options, signal);
|
|
337
|
+
let { credentials, permissions } = prepared;
|
|
338
|
+
const { configPath } = prepared;
|
|
339
|
+
await (0, _kubb_studio.runConnection)({
|
|
340
|
+
credentials,
|
|
341
|
+
signal,
|
|
342
|
+
clientOptions: () => ({
|
|
343
|
+
studioUrl: options.studioUrl,
|
|
344
|
+
configPath,
|
|
345
|
+
version: options.version,
|
|
346
|
+
root: node_process.default.cwd(),
|
|
347
|
+
permissions,
|
|
348
|
+
loadConfig: async () => (await loadConfigs(options)).config,
|
|
349
|
+
installLogger: async (hooks) => {
|
|
350
|
+
if (!context.onState) await require_utils.setupReporters(hooks, {
|
|
351
|
+
logLevel: _kubb_core.logLevel[options.logLevel ?? "info"],
|
|
352
|
+
reporters: [_kubb_core.cliReporter]
|
|
353
|
+
});
|
|
354
|
+
hooks.hook("studio:connected", () => {
|
|
355
|
+
if (!hinted && !context.onState && options.logLevel !== "silent") require_output.logBlock((0, node_util.styleText)("dim", "Press Ctrl+C to disconnect"));
|
|
356
|
+
hinted = true;
|
|
357
|
+
});
|
|
358
|
+
hooks.hook("studio:ready", async () => {
|
|
359
|
+
await context.onState?.("connected");
|
|
360
|
+
if (!context.onState) require_output.logTip();
|
|
361
|
+
});
|
|
362
|
+
hooks.hook("studio:reconnecting", () => context.onState?.("reconnecting"));
|
|
363
|
+
hooks.hook("studio:error", ({ error }) => {
|
|
364
|
+
if (context.onState) console.error(error.message);
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}),
|
|
368
|
+
onTokenRejected: async ({ error, live }) => {
|
|
369
|
+
await context.onState?.("authentication required");
|
|
370
|
+
if (node_process.default.env.KUBB_AGENT_TOKEN) throw explainRejectedToken(error, "envToken");
|
|
371
|
+
if (!live) await clearCredentials();
|
|
372
|
+
if (reauthenticated) throw explainRejectedToken(error, "reauthExhausted");
|
|
373
|
+
if (context.onState || require_agent.isCIEnvironment() || !require_output.canUseTTY()) throw explainRejectedToken(error, "nonInteractive");
|
|
374
|
+
console.log((0, node_util.styleText)("yellow", live ? `${error.message} Studio needs you to approve access again.` : `${error.message} Pairing again...`));
|
|
375
|
+
if (live) await clearCredentials();
|
|
376
|
+
try {
|
|
377
|
+
credentials = await login(options, {
|
|
378
|
+
signal,
|
|
379
|
+
previousCredentials: credentials
|
|
380
|
+
});
|
|
381
|
+
} catch (error) {
|
|
382
|
+
if (error instanceof _kubb_studio.PairingCanceledError) {
|
|
383
|
+
if (live && options.logLevel !== "silent") require_output.logOutro("Disconnected");
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
throw error;
|
|
387
|
+
}
|
|
388
|
+
reauthenticated = true;
|
|
389
|
+
permissions = await resolvePermissions(options, credentials, configPath, !node_process.default.env.KUBB_AGENT_TOKEN);
|
|
390
|
+
return credentials;
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
if (!context.onState && signal.aborted && options.logLevel !== "silent") require_output.logOutro("Disconnected");
|
|
394
|
+
} catch (error) {
|
|
395
|
+
if (!(error instanceof _kubb_studio.PairingCanceledError)) throw error;
|
|
396
|
+
} finally {
|
|
397
|
+
events.off("SIGINT", stop);
|
|
398
|
+
events.off("SIGTERM", stop);
|
|
440
399
|
}
|
|
441
|
-
};
|
|
442
|
-
/**
|
|
443
|
-
* Connects this project to Studio and streams generation events until the process is stopped or
|
|
444
|
-
* Studio rejects the token.
|
|
445
|
-
*/
|
|
446
|
-
async function connect(options) {
|
|
447
|
-
const { configPath } = await loadConfigs(options);
|
|
448
|
-
await new StudioConnection(options, configPath).run();
|
|
449
400
|
}
|
|
450
401
|
/**
|
|
451
402
|
* Reports the paired agent and any saved permissions for the current project.
|
|
@@ -521,6 +472,12 @@ Object.defineProperty(exports, "exists", {
|
|
|
521
472
|
return exists;
|
|
522
473
|
}
|
|
523
474
|
});
|
|
475
|
+
Object.defineProperty(exports, "getProjectKubbHome", {
|
|
476
|
+
enumerable: true,
|
|
477
|
+
get: function() {
|
|
478
|
+
return getProjectKubbHome;
|
|
479
|
+
}
|
|
480
|
+
});
|
|
524
481
|
Object.defineProperty(exports, "loadConfigs", {
|
|
525
482
|
enumerable: true,
|
|
526
483
|
get: function() {
|
|
@@ -533,6 +490,12 @@ Object.defineProperty(exports, "login", {
|
|
|
533
490
|
return login;
|
|
534
491
|
}
|
|
535
492
|
});
|
|
493
|
+
Object.defineProperty(exports, "prepareConnection", {
|
|
494
|
+
enumerable: true,
|
|
495
|
+
get: function() {
|
|
496
|
+
return prepareConnection;
|
|
497
|
+
}
|
|
498
|
+
});
|
|
536
499
|
Object.defineProperty(exports, "read", {
|
|
537
500
|
enumerable: true,
|
|
538
501
|
get: function() {
|
|
@@ -552,4 +515,4 @@ Object.defineProperty(exports, "status", {
|
|
|
552
515
|
}
|
|
553
516
|
});
|
|
554
517
|
|
|
555
|
-
//# sourceMappingURL=run-
|
|
518
|
+
//# sourceMappingURL=run-_hE0GAWu.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-yGsAbOqK.cjs","names":["isCIEnvironment","process","runtime","access","readFile","rm","process","path","homedir","hash","mkdir","writeFile","defaultStudioUrl","createSpinner","pairAgent","path","process","hostname","styleText","PairingCanceledError","KUBB_CONFIG_FILENAME","isCIEnvironment","canUseTTY","prompts","getConfigs","runConnection","setupReporters","logLevelMap","cliReporter","createFileStorage","sendTelemetry","buildTelemetryEvent","toError"],"sources":["../../../internals/utils/src/openInBrowser.ts","../../../internals/utils/src/fs.ts","../src/runners/studio/credentials.ts","../src/runners/studio/run.ts"],"sourcesContent":["import { execFile } from 'node:child_process'\nimport process from 'node:process'\nimport { isCIEnvironment } from './isCIEnvironment.ts'\n\n/**\n * Opens a URL or local file in the default browser, unless running in CI.\n */\nexport function openInBrowser(target: string): void {\n if (isCIEnvironment()) return\n\n if (process.platform === 'win32') {\n execFile('cmd', ['/c', 'start', '', target], () => {})\n } else {\n execFile(process.platform === 'darwin' ? 'open' : 'xdg-open', [target], () => {})\n }\n}\n","import { access, mkdir, readFile, rm, writeFile } from 'node:fs/promises'\nimport { dirname, isAbsolute, relative, resolve } from 'node:path'\nimport { runtime } from './runtime.ts'\n\n/**\n * Resolves to `true` when the file or directory at `path` exists.\n * Uses `Bun.file().exists()` when running under Bun, `fs.access` otherwise.\n *\n * @example\n * ```ts\n * if (await exists('./kubb.config.ts')) {\n * const content = await read('./kubb.config.ts')\n * }\n * ```\n */\nexport async function exists(path: string): Promise<boolean> {\n if (runtime.isBun) {\n return Bun.file(path).exists()\n }\n return access(path).then(\n () => true,\n () => false,\n )\n}\n\n/**\n * Reads the file at `path` as a UTF-8 string.\n * Uses `Bun.file().text()` when running under Bun, `fs.readFile` otherwise.\n *\n * @example\n * ```ts\n * const source = await read('./src/Pet.ts')\n * ```\n */\nexport async function read(path: string): Promise<string> {\n if (runtime.isBun) {\n return Bun.file(path).text()\n }\n return readFile(path, { encoding: 'utf8' })\n}\n\ntype WriteOptions = {\n /**\n * Previously read content, or `null` when the file does not exist.\n * Omitting this value reads the file before writing.\n */\n stored?: string | null\n /**\n * When `true`, re-reads the file immediately after writing and throws if the\n * content does not match — useful for catching write failures on unreliable file systems.\n */\n sanity?: boolean\n}\n\n/**\n * Whether `stored` already holds `source`, comparing on the trimmed text rather than the exact\n * bytes. Surrounding whitespace is what a formatter adds and what editors strip, and neither is a\n * reason to rewrite the file.\n *\n * Both sides are trimmed, so a storage that keeps bytes verbatim settles on the same answer as one\n * that normalizes what it stores. Trimming only `stored` would leave a source with leading\n * whitespace rewritten on every build, since the stored copy keeps the whitespace the comparison\n * has already dropped.\n */\nexport function matchesStored({ stored, source }: { stored: string; source: string }): boolean {\n return stored.trim() === source.trim()\n}\n\n/**\n * Writes `data` to `path`, trimming surrounding whitespace and ending the file with a single newline\n * the way prettier, biome, and oxfmt all do.\n * Skips the write when the trimmed content is empty, or when the file already holds that content.\n * Creates any missing parent directories automatically.\n * When `sanity` is `true`, re-reads the file after writing and throws if the content does not match.\n *\n * @example\n * ```ts\n * await write('./src/Pet.ts', source) // writes and returns the trimmed content plus a newline\n * await write('./src/Pet.ts', source) // null — file unchanged\n * await write('./src/Pet.ts', ' ') // null — empty content skipped\n * ```\n */\nexport async function write(path: string, data: string, options: WriteOptions = {}): Promise<string | null> {\n const trimmed = data.trim()\n if (trimmed === '') return null\n\n const content = `${trimmed}\\n`\n const resolved = resolve(path)\n let stored = options.stored\n\n if (stored === undefined) {\n if (runtime.isBun) {\n const file = Bun.file(resolved)\n stored = (await file.exists()) ? await file.text() : null\n } else {\n try {\n stored = await readFile(resolved, { encoding: 'utf-8' })\n } catch {\n /* file doesn't exist yet */\n stored = null\n }\n }\n }\n if (matchesStored({ stored: stored ?? '', source: trimmed })) return null\n\n if (runtime.isBun) {\n await Bun.write(resolved, content)\n return content\n }\n\n // Creating the directory up front costs a syscall per file, and every file after the first in a\n // directory pays it for nothing. Write first and only fall back when the directory is missing,\n // which also stays correct when something removed it mid-run.\n try {\n await writeFile(resolved, content, { encoding: 'utf-8' })\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error\n\n await mkdir(dirname(resolved), { recursive: true })\n await writeFile(resolved, content, { encoding: 'utf-8' })\n }\n\n if (options.sanity) {\n const savedData = await readFile(resolved, { encoding: 'utf-8' })\n if (savedData !== content) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n return savedData\n }\n\n return content\n}\n\n/**\n * Recursively removes `path`. Silently succeeds when `path` does not exist.\n *\n * @example\n * ```ts\n * await clean('./dist')\n * ```\n */\nexport async function clean(path: string): Promise<void> {\n return rm(path, { recursive: true, force: true })\n}\n\n/**\n * Converts a filesystem path to use POSIX (`/`) separators.\n *\n * Most of the codebase compares and composes paths as strings (prefix matching, joining for\n * import specifiers, splitting on `/`). On POSIX `path.resolve` already returns `/`-separated\n * paths, but on Windows it returns `\\`-separated paths, which breaks every such comparison.\n *\n * Routing every path that crosses a module boundary through `toPosixPath` keeps the rest of the\n * code platform-agnostic. The conversion runs unconditionally so Windows-specific behavior is\n * exercisable from POSIX CI.\n *\n * @example\n * toPosixPath('C:\\\\repo\\\\src\\\\pet.ts') // 'C:/repo/src/pet.ts'\n */\nexport function toPosixPath(filePath: string): string {\n return filePath.replaceAll('\\\\', '/')\n}\n\n/**\n * Strips the file extension from a path or file name.\n * Only removes the last `.ext` segment when the dot is not part of a directory name.\n *\n * @example\n * trimExtName('petStore.ts') // 'petStore'\n * trimExtName('/src/models/pet.ts') // '/src/models/pet'\n * trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'\n * trimExtName('noExtension') // 'noExtension'\n */\nexport function trimExtName(text: string): string {\n const dotIndex = text.lastIndexOf('.')\n if (dotIndex > 0 && !text.includes('/', dotIndex)) {\n return text.slice(0, dotIndex)\n }\n return text\n}\n\n/**\n * Resolves to `true` when `path` is `parent` itself or nested inside it. Both sides are resolved\n * to absolute paths first, so relative and `..`-containing inputs compare correctly.\n *\n * Guards a destructive or an out-of-tree operation: before wiping an output directory, check that\n * it does not contain the project root, and before loading a path a caller supplied, check that it\n * did not escape the directory it is allowed to read from.\n *\n * @example\n * isPathInside('./src/gen', '.') // true — nested inside the root\n * isPathInside('.', '.') // true — the same directory counts as inside\n * isPathInside('.', './src/gen') // false — the root is not inside its own output\n * isPathInside('../other', '.') // false — escapes the root\n */\nexport function isPathInside(path: string, parent: string): boolean {\n const resolvedPath = resolve(path)\n const resolvedParent = resolve(parent)\n if (resolvedPath === resolvedParent) {\n return true\n }\n\n const rel = relative(resolvedParent, resolvedPath)\n\n return rel !== '' && !rel.startsWith('..') && !isAbsolute(rel)\n}\n","import { hash } from 'node:crypto'\nimport { mkdir, writeFile } from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { clean, read } from '@internals/utils'\n\n/**\n * Root for everything the CLI persists between runs: the paired credential, the machine secret,\n * the last Studio config, and the live-session registry. `KUBB_HOME` relocates all of it.\n */\nfunction getKubbHome(): string {\n return process.env.KUBB_HOME ?? path.join(homedir(), '.kubb')\n}\n\n/**\n * Root for the credential and machine identity of the current project.\n *\n * Studio agents are project connections, so two projects on one machine must not share the same\n * persisted token or machine secret.\n */\nexport function getProjectKubbHome(project = process.cwd()): string {\n const projectId = hash('sha256', project)\n return path.join(getKubbHome(), 'projects', projectId)\n}\n\nconst CREDENTIALS_FILENAME = 'credentials.json'\n\n/**\n * Absolute path of the stored credential, so callers can name it in output without rebuilding it.\n */\nexport function getCredentialsPath(): string {\n return path.join(getProjectKubbHome(), CREDENTIALS_FILENAME)\n}\n\nexport type Credentials = {\n /**\n * The Studio instance this machine paired with. A different `--url` means re-pairing.\n */\n studioUrl: string\n /**\n * Bearer token for this machine. Never logged, never printed.\n */\n token: string\n agentId: string\n agentSlug: string\n /**\n * Permissions the user has already granted, keyed by absolute project path, so the CLI asks\n * once per project instead of on every run.\n */\n projects?: Record<string, { allowRead?: boolean; allowWrite?: boolean; allowConfigEdit?: boolean; allowExec?: boolean }>\n}\n\n/**\n * Reads the stored credential, or null when this machine has not paired yet or the file is\n * unreadable or corrupt. A bad file is treated as \"not paired\" so `kubb studio login` can\n * overwrite it rather than the CLI dying on it.\n */\nexport async function readCredentials(): Promise<Credentials | null> {\n const raw = await read(getCredentialsPath()).catch(() => null)\n if (!raw) {\n return null\n }\n\n try {\n return JSON.parse(raw) as Credentials\n } catch {\n return null\n }\n}\n\n/**\n * Writes the credential with owner-only permissions. The file holds a bearer token, so the mode\n * is set at creation time rather than left to the process umask or fixed up afterward, which\n * would leave the token briefly readable under the umask's default mode.\n */\nexport async function writeCredentials(credentials: Credentials): Promise<void> {\n const file = getCredentialsPath()\n\n await mkdir(path.dirname(file), { recursive: true, mode: 0o700 })\n await writeFile(file, JSON.stringify(credentials, null, 2), { mode: 0o600 })\n}\n\n/**\n * Forgets the stored credential. Succeeds when there was nothing to forget.\n */\nexport async function clearCredentials(): Promise<void> {\n await clean(getCredentialsPath())\n}\n","import { hostname } from 'node:os'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as prompts from '@clack/prompts'\nimport { KUBB_CONFIG_FILENAME } from '@internals/shared'\nimport { isCIEnvironment, openInBrowser, toError } from '@internals/utils'\nimport type { CLIOptions, Config } from '@kubb/core'\nimport { cliReporter, logLevel as logLevelMap } from '@kubb/core'\nimport {\n createFileStorage,\n type ClientOptions,\n defaultStudioUrl,\n type InvalidAgentTokenError,\n pairAgent,\n PairingCanceledError,\n runConnection,\n setStorage,\n} from '@kubb/studio'\nimport { buildTelemetryEvent, sendTelemetry } from '../../Telemetry.ts'\nimport setupReporters from '../../loggers/utils.ts'\nimport { createSpinner, logBlock, logIntro, logOutro, logTip } from '../../loggers/output.ts'\nimport { canUseTTY } from '../../utils/env.ts'\nimport { getConfigs } from '../generate/utils.ts'\nimport { clearCredentials, type Credentials, getCredentialsPath, getProjectKubbHome, readCredentials, writeCredentials } from './credentials.ts'\nimport { version } from '../../../package.json'\n\ntype Permission = 'allowRead' | 'allowWrite' | 'allowConfigEdit' | 'allowExec'\n\nexport type StudioOptions = {\n /**\n * Current `@kubb/cli` version, reported to Studio and used for the telemetry payload.\n */\n version: string\n configPath?: string\n /**\n * Base URL of the Studio instance, for a self-hosted deployment. Resolved before it reaches here,\n * since stored credentials are bound to it.\n */\n studioUrl: string\n /**\n * What Studio may do in this project. Each flag grants outright; the rest are asked once per\n * project through {@link resolvePermissions}.\n */\n permission: Record<Permission, boolean>\n /**\n * Whether to open the approval page in a browser during pairing.\n */\n autoOpen: boolean\n logLevel?: CLIOptions['logLevel']\n}\n\nexport type SnapshotOptions = StudioOptions & {\n /**\n * Organization CI API key. Falls back to `KUBB_TOKEN`.\n */\n token?: string\n /**\n * Stable identity for the CI agent. Falls back to CI auto-detection.\n */\n id?: string\n /** Identity of another CI agent to also compare with. Falls back to CI auto-detection. */\n baseId?: string\n /**\n * Package name for the generated tarball. Falls back to the nearest package.json.\n */\n name?: string\n /**\n * Package version for the generated tarball. Falls back to the nearest package.json.\n */\n packageVersion?: string\n /**\n * Seconds to wait for the job to finish.\n */\n timeout?: number\n /**\n * Print the result as one JSON object instead of a summary.\n */\n json?: boolean\n}\n\ntype StudioValues = {\n config?: string\n url?: string\n allowRead: boolean\n allowWrite: boolean\n allowConfigEdit: boolean\n allowExec: boolean\n open?: boolean\n logLevel?: CLIOptions['logLevel']\n}\n\nexport function createStudioOptions(values: StudioValues): StudioOptions {\n return {\n version,\n configPath: values.config,\n studioUrl: values.url ?? defaultStudioUrl,\n permission: {\n allowRead: values.allowRead,\n allowWrite: values.allowWrite,\n allowConfigEdit: values.allowConfigEdit,\n allowExec: values.allowExec,\n },\n autoOpen: values.open ?? true,\n logLevel: values.logLevel,\n }\n}\n\ntype LoginOptions = {\n /**\n * Aborting this cancels an in-flight pairing request or poll and rejects with\n * {@link PairingCanceledError}. Wired to `kubb studio`'s shutdown signal, so Ctrl+C during\n * pairing cancels it instead of leaving the poll running.\n */\n signal?: AbortSignal\n /**\n * Credentials from before this login. When the fresh pairing resolves to the same agent on the\n * same Studio, its saved project permissions carry forward instead of being asked again.\n * Left out for an explicitly requested `kubb studio login`, which always starts clean.\n */\n previousCredentials?: Credentials | null\n}\n\n/**\n * Pairs this machine with Studio and stores the resulting token.\n *\n * The CLI holds a code and the browser approves it, rather than the user copying a token out of\n * the UI. The token comes back over the CLI's own HTTPS POST, so it never lands in a URL, a\n * server log, or a `Referer` header.\n */\nexport async function login({ studioUrl, autoOpen }: StudioOptions, { signal, previousCredentials }: LoginOptions = {}): Promise<Credentials> {\n const spinner = createSpinner()\n // The spinner only starts once a code is shown.\n let waiting = false\n\n try {\n const { token, agent } = await pairAgent({\n studioUrl,\n type: 'cli',\n name: path.basename(process.cwd()),\n hostname: hostname(),\n signal,\n onCode: (session) => {\n console.log(`\\nOpen ${styleText('cyan', session.verification_uri)} and approve the code ${styleText('bold', session.user_code)}`)\n\n if (autoOpen) {\n openInBrowser(session.verification_uri_complete)\n }\n\n spinner.start('Waiting for approval')\n waiting = true\n },\n onRetry: (error) => spinner.message(`Could not reach Kubb Studio, retrying: ${error.message}`),\n })\n spinner.stop(`Paired as ${agent.name}`)\n\n const keepsIdentity = previousCredentials?.studioUrl === studioUrl && previousCredentials.agentId === agent.id\n const credentials: Credentials = {\n studioUrl,\n token,\n agentId: agent.id,\n agentSlug: agent.slug,\n ...(keepsIdentity && previousCredentials?.projects ? { projects: previousCredentials.projects } : {}),\n }\n await writeCredentials(credentials)\n\n console.log(`Credentials stored in ${getCredentialsPath()}`)\n\n return credentials\n } catch (error) {\n if (waiting) {\n spinner.stop(error instanceof PairingCanceledError ? 'Pairing canceled' : 'Pairing failed')\n }\n throw error\n }\n}\n\n/**\n * What each permission is asked as, in the order the questions appear.\n */\nconst PERMISSIONS: ReadonlyArray<{\n key: Permission\n /**\n * Short label for status output and the connect summary.\n */\n label: string\n question: (project: string, configPath: string) => string\n}> = [\n {\n key: 'allowRead',\n label: 'read generated files',\n question: () => 'Let Kubb Studio read the files a generation produced?',\n },\n { key: 'allowWrite', label: 'write generated files', question: (project) => `Let Kubb Studio write generated files into ${project}?` },\n {\n key: 'allowConfigEdit',\n label: 'edit kubb.config.ts',\n question: (_project, configPath) => `Let Kubb Studio change plugin options in ${configPath}?`,\n },\n {\n key: 'allowExec',\n label: 'run formatter, linter, postGenerate',\n question: () => 'Let Kubb Studio run the formatter, the linter, and output.postGenerate?',\n },\n]\n\n/**\n * One row per permission, for the connect banner and `kubb studio status`. A list rather than a\n * joined line: four labels this long read as one run-on sentence side by side.\n */\nexport function formatPermissionRows(granted: Record<Permission, boolean>): Array<string> {\n return PERMISSIONS.map(({ key, label }) => `${granted[key] ? styleText('green', '✔') : styleText('red', '✘')} ${label}`)\n}\n\n/**\n * Resolves Studio permissions for the current project.\n * Flags win, saved answers are reused, and new answers are stored unless `persist` is false.\n */\nexport async function resolvePermissions(\n options: StudioOptions,\n credentials: Credentials,\n configPath: string = KUBB_CONFIG_FILENAME,\n /**\n * Stores new answers in `~/.kubb/credentials.json`.\n * Pass `false` for `KUBB_AGENT_TOKEN` sessions so a temporary token is not written back to disk.\n */\n persist = true,\n): Promise<Record<Permission, boolean>> {\n const project = process.cwd()\n const remembered = credentials.projects?.[project]\n const granted: Record<Permission, boolean> = { allowRead: false, allowWrite: false, allowConfigEdit: false, allowExec: false }\n const answers: Partial<Record<Permission, boolean>> = {}\n prompts.updateSettings({ withGuide: true })\n\n for (const { key, question } of PERMISSIONS) {\n if (options.permission[key] || typeof remembered?.[key] === 'boolean') {\n granted[key] = options.permission[key] || remembered?.[key] === true\n continue\n }\n\n if (isCIEnvironment() || !canUseTTY()) {\n granted[key] = false\n continue\n }\n\n granted[key] = (await prompts.confirm({ message: question(project, configPath), initialValue: false })) === true\n answers[key] = granted[key]\n }\n if (persist && Object.keys(answers).length) {\n await writeCredentials({\n ...credentials,\n projects: { ...credentials.projects, [project]: { ...remembered, ...answers } },\n })\n }\n\n return granted\n}\n\n/**\n * Loads the project's Kubb config the same way `kubb generate` does.\n * Returns the first config.\n */\nexport async function loadConfigs(options: StudioOptions): Promise<{ configPath: string; config: Config }> {\n const { configPath, configs } = await getConfigs({ configPath: options.configPath, logLevel: options.logLevel })\n const [config] = configs\n\n if (!config) {\n throw new Error('Config not defined, create a kubb.config.ts or pass it with --config')\n }\n\n // `getConfigs` resolves this to an absolute path. Relativized here, once, so the permission\n // prompt and the path Studio receives over the wire both show the project-relative form instead\n // of leaking the local filesystem layout.\n return { configPath: path.relative(process.cwd(), configPath) || configPath, config }\n}\n\n/**\n * Why a rejected token could not be recovered automatically: it came from `KUBB_AGENT_TOKEN`, no\n * browser is available to re-pair with, or the token this run already re-paired for was rejected\n * again.\n */\ntype RejectedTokenReason = 'envToken' | 'nonInteractive' | 'reauthExhausted'\n\n/**\n * Explains a rejected token to the operator. Builds the error and nothing else, so each caller\n * decides what happens to the credentials.\n */\nfunction explainRejectedToken(error: InvalidAgentTokenError, reason: RejectedTokenReason): Error {\n if (reason === 'envToken') {\n return new Error(`${error.message} Pair again and update KUBB_AGENT_TOKEN.`)\n }\n\n if (reason === 'reauthExhausted') {\n return new Error(`${error.message} Studio rejected the newly approved token too. Run \\`kubb studio login\\` and try again.`)\n }\n\n return new Error(`${error.message} Run \\`kubb studio login\\` to pair again.`)\n}\n\n/**\n * One `kubb studio` connect run: pairing if needed, connecting, and pairing again whenever Studio\n * rejects the token. Reached through `connect()`, which is what the command runs.\n */\nclass StudioConnection {\n readonly #options: StudioOptions\n readonly #configPath: string\n readonly #shutdown = new AbortController()\n readonly #requestShutdown = (): void => this.#shutdown.abort()\n // `bun-types` narrows `process.on`/`process.off` to its own event union, which omits Node's\n // process signal events, so the listener is installed and removed through the plain emitter API.\n readonly #processEvents = process as unknown as NodeJS.EventEmitter\n\n // Known once `run()` resolves the initial credentials, before anything else reads this field.\n #credentials!: Credentials\n // Whether the \"Press Ctrl+C\" hint already printed, so a reconnect never repeats it.\n #hinted = false\n // One automatic re-pair per run, whether the rejection lands at startup or once the session is\n // live. A token rejected right after a fresh login is a hard failure, not a reason to keep\n // pairing.\n #hasReauthenticated = false\n // Resolved by `run()` from the flags and the project's saved answers, before anything reads it.\n #granted!: Record<Permission, boolean>\n\n constructor(options: StudioOptions, configPath: string) {\n this.#options = options\n this.#configPath = configPath\n }\n\n #reportDisconnected(): void {\n if (this.#options.logLevel === 'silent') {\n return\n }\n\n logOutro('Disconnected')\n }\n\n /**\n * Connects and streams generation events until the process is stopped or Studio rejects the\n * token.\n *\n * One `AbortController` covers the whole run: it cancels an in-flight pairing poll on Ctrl+C and\n * ends the wait in `#connectAndWait`. Its signal listeners are armed once here, so a retried\n * pairing cannot leave a duplicate behind.\n */\n async run(): Promise<void> {\n this.#processEvents.once('SIGINT', this.#requestShutdown)\n this.#processEvents.once('SIGTERM', this.#requestShutdown)\n\n try {\n this.#credentials = await this.#resolveInitialCredentials()\n\n this.#granted = await resolvePermissions(this.#options, this.#credentials, this.#configPath, !process.env.KUBB_AGENT_TOKEN)\n\n this.#printBanner()\n\n const outcome = await runConnection({\n credentials: this.#credentials,\n signal: this.#shutdown.signal,\n clientOptions: () => this.#clientOptions(),\n onTokenRejected: ({ error, live }) => this.#handleRejection(error, live),\n })\n\n if (outcome === 'shutdown') {\n this.#reportDisconnected()\n }\n } catch (error) {\n // Canceling the very first pairing (before anything was ever connected) is Ctrl+C working as\n // intended, not a failure to report.\n if (error instanceof PairingCanceledError) {\n return\n }\n\n throw error\n } finally {\n this.#processEvents.off('SIGINT', this.#requestShutdown)\n this.#processEvents.off('SIGTERM', this.#requestShutdown)\n }\n }\n\n async #resolveInitialCredentials(): Promise<Credentials> {\n const envToken = process.env.KUBB_AGENT_TOKEN\n const stored = envToken ? null : await readCredentials()\n\n // A credential is only reused for the Studio it was issued by, so switching `--url` re-pairs\n // instead of sending one instance's token to another.\n const resolved = envToken\n ? { studioUrl: this.#options.studioUrl, token: envToken, agentId: '', agentSlug: '' }\n : stored?.studioUrl === this.#options.studioUrl\n ? stored\n : null\n\n if (resolved) {\n return resolved\n }\n\n if (isCIEnvironment()) {\n throw new Error(`Not paired with ${this.#options.studioUrl}. Set KUBB_AGENT_TOKEN, or run \\`kubb studio login\\` on a machine with a browser.`)\n }\n\n return login(this.#options, { signal: this.#shutdown.signal })\n }\n\n #printBanner(): void {\n if (this.#options.logLevel === 'silent') {\n return\n }\n\n const detail = (label: string, value: string) => `${styleText('dim', label.padEnd(7))} ${value}`\n\n logBlock([\n detail('Studio', styleText('cyan', this.#options.studioUrl)),\n detail('Project', path.basename(process.cwd())),\n detail('Config', path.relative(process.cwd(), this.#configPath) || this.#configPath),\n '',\n styleText('dim', 'Permissions'),\n ...formatPermissionRows(this.#granted),\n ])\n }\n\n /**\n * What every connection attempt opens with. Rebuilt per attempt, so a re-pair that changed the\n * granted permissions takes effect on the next one.\n */\n #clientOptions(): Omit<ClientOptions, 'token' | 'onAuthRequired'> {\n return {\n studioUrl: this.#options.studioUrl,\n configPath: this.#configPath,\n version: this.#options.version,\n // Reloaded on every generate, so an edit to kubb.config.ts is picked up without reconnecting.\n loadConfig: async () => (await loadConfigs(this.#options)).config,\n root: process.cwd(),\n permissions: this.#granted,\n // The loggers `kubb generate` installs, so one place renders the session events and the\n // generations it drives.\n installLogger: async (hooks) => {\n await setupReporters(hooks, { logLevel: logLevelMap[this.#options.logLevel ?? 'info'], reporters: [cliReporter] })\n\n // `client.connect()` resolves once the agent is registered, not once a session is open, so\n // this is the only point that knows the connection is live. Registered after the loggers so\n // it lands under their \"Connected to ...\" line, and once, since every reconnect fires again.\n hooks.hook('studio:connected', () => {\n if (this.#hinted || this.#options.logLevel === 'silent') {\n return\n }\n this.#hinted = true\n\n logBlock(styleText('dim', 'Press Ctrl+C to disconnect'))\n })\n // Registered after the CLI reporter so the tip is printed immediately before its\n // \"Ready to receive jobs\" spinner when the Studio session becomes ready.\n hooks.hook('studio:ready', () => {\n logTip()\n })\n },\n }\n }\n\n /**\n * Throws when a rejected token cannot be replaced by pairing again: this run already paired once\n * and was rejected anyway, or there is no browser to approve a new pairing.\n */\n #assertCanReauthenticate(error: InvalidAgentTokenError): void {\n if (this.#hasReauthenticated) {\n throw explainRejectedToken(error, 'reauthExhausted')\n }\n\n if (isCIEnvironment() || !canUseTTY()) {\n throw explainRejectedToken(error, 'nonInteractive')\n }\n }\n\n /**\n * Studio rejected the token, either before a session ever opened or once one was already live.\n * Keeping a rejected token only produces 401s on every run, so it is forgotten and paired again.\n * Returns the credential to reconnect with, or null when the run is over.\n */\n async #handleRejection(error: InvalidAgentTokenError, live: boolean): Promise<Credentials | null> {\n // An operator-supplied token is never replaced automatically.\n if (process.env.KUBB_AGENT_TOKEN) {\n throw explainRejectedToken(error, 'envToken')\n }\n\n // A token dead at startup is forgotten either way. A live one is only forgotten once this run\n // knows it can pair again, so a CI run keeps the credential it could not replace.\n if (!live) {\n await clearCredentials()\n }\n\n this.#assertCanReauthenticate(error)\n\n console.log(styleText('yellow', live ? `${error.message} Studio needs you to approve access again.` : `${error.message} Pairing again...`))\n\n if (live) {\n await clearCredentials()\n }\n\n const credentials = await this.#reauthenticate()\n\n // Nothing was ever connected at startup, so there is no session to report the end of.\n if (!credentials && live) {\n this.#reportDisconnected()\n }\n\n return credentials\n }\n\n /**\n * Re-pairs and stores the resulting credentials. Returns null when the operator canceled it.\n */\n async #reauthenticate(): Promise<Credentials | null> {\n try {\n this.#credentials = await login(this.#options, { signal: this.#shutdown.signal, previousCredentials: this.#credentials })\n } catch (loginError) {\n if (loginError instanceof PairingCanceledError) {\n return null\n }\n throw loginError\n }\n\n this.#hasReauthenticated = true\n\n // The approved agent may be a different identity, whose saved permissions did not carry\n // forward. Resolving again asks for whatever this credential does not already hold, instead\n // of handing the new agent what the previous one was granted.\n this.#granted = await resolvePermissions(this.#options, this.#credentials, this.#configPath, !process.env.KUBB_AGENT_TOKEN)\n\n return this.#credentials\n }\n}\n\n/**\n * Connects this project to Studio and streams generation events until the process is stopped or\n * Studio rejects the token.\n */\nexport async function connect(options: StudioOptions): Promise<void> {\n // Resolved before any network call to Studio (pairing included), so a project with no config\n // fails fast instead of starting a device-authorization flow it can never use.\n const { configPath } = await loadConfigs(options)\n\n await new StudioConnection(options, configPath).run()\n}\n\n/**\n * Reports the paired agent and any saved permissions for the current project.\n */\nexport async function status(options: StudioOptions): Promise<void> {\n const credentials = await readCredentials()\n\n if (!credentials) {\n console.log('Not paired. Run `kubb studio login`.')\n\n return\n }\n\n console.log(`Paired with ${credentials.studioUrl} as ${styleText('cyan', credentials.agentSlug || credentials.agentId)}`)\n\n if (credentials.studioUrl !== options.studioUrl) {\n console.log(styleText('yellow', `Connecting to ${options.studioUrl} needs pairing again.`))\n }\n\n const remembered = credentials.projects?.[process.cwd()]\n\n if (!remembered) {\n console.log(styleText('dim', 'No saved permissions for this project. Run `kubb studio` to connect and choose.'))\n\n return\n }\n\n console.log(styleText('dim', 'Saved permissions'))\n\n for (const row of formatPermissionRows({\n allowRead: remembered.allowRead === true,\n allowWrite: remembered.allowWrite === true,\n allowConfigEdit: remembered.allowConfigEdit === true,\n allowExec: remembered.allowExec === true,\n })) {\n console.log(row)\n }\n}\n\n/**\n * Runs a Studio command with shared setup and telemetry reporting.\n */\nexport async function run(options: StudioOptions, action: () => Promise<unknown>, { block = false, json = false } = {}): Promise<void> {\n // The machine secret lives here and pairing binds it, so storage is installed before anything\n // reads `getMachineToken()`, which `startPairing` does, before any client exists.\n setStorage(createFileStorage(getProjectKubbHome()))\n\n const hrStart = process.hrtime()\n const report = (status: 'success' | 'failed') => sendTelemetry(buildTelemetryEvent({ command: 'studio', kubbVersion: options.version, hrStart, status }))\n\n try {\n if (options.logLevel !== 'silent' && !json) {\n logIntro({\n warning: styleText('yellow', 'This feature is still under development, use with caution'),\n block,\n })\n }\n\n await action()\n\n await report('success')\n } catch (error) {\n await report('failed')\n console.error(toError(error).message)\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAOA,SAAgB,cAAc,QAAsB;CAClD,IAAIA,cAAAA,gBAAgB,GAAG;CAEvB,IAAIC,aAAAA,QAAQ,aAAa,SACvB,CAAA,GAAA,mBAAA,SAAA,CAAS,OAAO;EAAC;EAAM;EAAS;EAAI;CAAM,SAAS,CAAC,CAAC;MAErD,CAAA,GAAA,mBAAA,SAAA,CAASA,aAAAA,QAAQ,aAAa,WAAW,SAAS,YAAY,CAAC,MAAM,SAAS,CAAC,CAAC;AAEpF;;;;;;;;;;;;;;ACAA,eAAsB,OAAO,MAAgC;CAC3D,IAAIC,kBAAAA,QAAQ,OACV,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,OAAO;CAE/B,QAAA,GAAOC,iBAAAA,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aAAAA,QAAQ,IAAI;CAEtD,IAAI,CAAC,YAAY;EACf,QAAQ,KAAA,GAAIE,UAAAA,UAAAA,CAAU,OAAO,iFAAiF,CAAC;EAE/G;CACF;CAEA,QAAQ,KAAA,GAAIA,UAAAA,UAAAA,CAAU,OAAO,mBAAmB,CAAC;CAEjD,KAAK,MAAM,OAAO,qBAAqB;EACrC,WAAW,WAAW,cAAc;EACpC,YAAY,WAAW,eAAe;EACtC,iBAAiB,WAAW,oBAAoB;EAChD,WAAW,WAAW,cAAc;CACtC,CAAC,GACC,QAAQ,IAAI,GAAG;AAEnB;;;;AAKA,eAAsB,IAAI,SAAwB,QAAgC,EAAE,QAAQ,OAAO,OAAO,UAAU,CAAC,GAAkB;CAGrI,CAAA,GAAA,aAAA,WAAA,EAAA,GAAWW,aAAAA,kBAAAA,CAAkB,mBAAmB,CAAC,CAAC;CAElD,MAAM,UAAUb,aAAAA,QAAQ,OAAO;CAC/B,MAAM,UAAU,WAAiCc,kBAAAA,cAAcC,kBAAAA,oBAAoB;EAAE,SAAS;EAAU,aAAa,QAAQ;EAAS;EAAS;CAAO,CAAC,CAAC;CAExJ,IAAI;EACF,IAAI,QAAQ,aAAa,YAAY,CAAC,MACpC,eAAA,SAAS;GACP,UAAA,GAASb,UAAAA,UAAAA,CAAU,UAAU,2DAA2D;GACxF;EACF,CAAC;EAGH,MAAM,OAAO;EAEb,MAAM,OAAO,SAAS;CACxB,SAAS,OAAO;EACd,MAAM,OAAO,QAAQ;EACrB,QAAQ,MAAMc,eAAAA,QAAQ,KAAK,CAAC,CAAC,OAAO;EACpC,aAAA,QAAA,WAAmB;CACrB;AACF"}
|
|
1
|
+
{"version":3,"file":"run-_hE0GAWu.cjs","names":["isCIEnvironment","process","runtime","access","readFile","rm","process","path","homedir","hash","mkdir","writeFile","defaultStudioUrl","createSpinner","pairAgent","path","process","hostname","styleText","PairingCanceledError","KUBB_CONFIG_FILENAME","isCIEnvironment","canUseTTY","prompts","getConfigs","runConnection","setupReporters","logLevelMap","cliReporter","createFileStorage","sendTelemetry","buildTelemetryEvent","toError"],"sources":["../../../internals/utils/src/openInBrowser.ts","../../../internals/utils/src/fs.ts","../src/runners/studio/credentials.ts","../src/runners/studio/run.ts"],"sourcesContent":["import { execFile } from 'node:child_process'\nimport process from 'node:process'\nimport { isCIEnvironment } from './isCIEnvironment.ts'\n\n/**\n * Opens a URL or local file in the default browser, unless running in CI.\n */\nexport function openInBrowser(target: string): void {\n if (isCIEnvironment()) return\n\n if (process.platform === 'win32') {\n execFile('cmd', ['/c', 'start', '', target], () => {})\n } else {\n execFile(process.platform === 'darwin' ? 'open' : 'xdg-open', [target], () => {})\n }\n}\n","import { access, mkdir, readFile, rm, writeFile } from 'node:fs/promises'\nimport { dirname, isAbsolute, relative, resolve } from 'node:path'\nimport { runtime } from './runtime.ts'\n\n/**\n * Resolves to `true` when the file or directory at `path` exists.\n * Uses `Bun.file().exists()` when running under Bun, `fs.access` otherwise.\n *\n * @example\n * ```ts\n * if (await exists('./kubb.config.ts')) {\n * const content = await read('./kubb.config.ts')\n * }\n * ```\n */\nexport async function exists(path: string): Promise<boolean> {\n if (runtime.isBun) {\n return Bun.file(path).exists()\n }\n return access(path).then(\n () => true,\n () => false,\n )\n}\n\n/**\n * Reads the file at `path` as a UTF-8 string.\n * Uses `Bun.file().text()` when running under Bun, `fs.readFile` otherwise.\n *\n * @example\n * ```ts\n * const source = await read('./src/Pet.ts')\n * ```\n */\nexport async function read(path: string): Promise<string> {\n if (runtime.isBun) {\n return Bun.file(path).text()\n }\n return readFile(path, { encoding: 'utf8' })\n}\n\ntype WriteOptions = {\n /**\n * Previously read content, or `null` when the file does not exist.\n * Omitting this value reads the file before writing.\n */\n stored?: string | null\n /**\n * When `true`, re-reads the file immediately after writing and throws if the\n * content does not match — useful for catching write failures on unreliable file systems.\n */\n sanity?: boolean\n}\n\n/**\n * Whether `stored` already holds `source`, comparing on the trimmed text rather than the exact\n * bytes. Surrounding whitespace is what a formatter adds and what editors strip, and neither is a\n * reason to rewrite the file.\n *\n * Both sides are trimmed, so a storage that keeps bytes verbatim settles on the same answer as one\n * that normalizes what it stores. Trimming only `stored` would leave a source with leading\n * whitespace rewritten on every build, since the stored copy keeps the whitespace the comparison\n * has already dropped.\n */\nexport function matchesStored({ stored, source }: { stored: string; source: string }): boolean {\n return stored.trim() === source.trim()\n}\n\n/**\n * Writes `data` to `path`, trimming surrounding whitespace and ending the file with a single newline\n * the way prettier, biome, and oxfmt all do.\n * Skips the write when the trimmed content is empty, or when the file already holds that content.\n * Creates any missing parent directories automatically.\n * When `sanity` is `true`, re-reads the file after writing and throws if the content does not match.\n *\n * @example\n * ```ts\n * await write('./src/Pet.ts', source) // writes and returns the trimmed content plus a newline\n * await write('./src/Pet.ts', source) // null — file unchanged\n * await write('./src/Pet.ts', ' ') // null — empty content skipped\n * ```\n */\nexport async function write(path: string, data: string, options: WriteOptions = {}): Promise<string | null> {\n const trimmed = data.trim()\n if (trimmed === '') return null\n\n const content = `${trimmed}\\n`\n const resolved = resolve(path)\n let stored = options.stored\n\n if (stored === undefined) {\n if (runtime.isBun) {\n const file = Bun.file(resolved)\n stored = (await file.exists()) ? await file.text() : null\n } else {\n try {\n stored = await readFile(resolved, { encoding: 'utf-8' })\n } catch {\n /* file doesn't exist yet */\n stored = null\n }\n }\n }\n if (matchesStored({ stored: stored ?? '', source: trimmed })) return null\n\n if (runtime.isBun) {\n await Bun.write(resolved, content)\n return content\n }\n\n // Creating the directory up front costs a syscall per file, and every file after the first in a\n // directory pays it for nothing. Write first and only fall back when the directory is missing,\n // which also stays correct when something removed it mid-run.\n try {\n await writeFile(resolved, content, { encoding: 'utf-8' })\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error\n\n await mkdir(dirname(resolved), { recursive: true })\n await writeFile(resolved, content, { encoding: 'utf-8' })\n }\n\n if (options.sanity) {\n const savedData = await readFile(resolved, { encoding: 'utf-8' })\n if (savedData !== content) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n return savedData\n }\n\n return content\n}\n\n/**\n * Recursively removes `path`. Silently succeeds when `path` does not exist.\n *\n * @example\n * ```ts\n * await clean('./dist')\n * ```\n */\nexport async function clean(path: string): Promise<void> {\n return rm(path, { recursive: true, force: true })\n}\n\n/**\n * Converts a filesystem path to use POSIX (`/`) separators.\n *\n * Most of the codebase compares and composes paths as strings (prefix matching, joining for\n * import specifiers, splitting on `/`). On POSIX `path.resolve` already returns `/`-separated\n * paths, but on Windows it returns `\\`-separated paths, which breaks every such comparison.\n *\n * Routing every path that crosses a module boundary through `toPosixPath` keeps the rest of the\n * code platform-agnostic. The conversion runs unconditionally so Windows-specific behavior is\n * exercisable from POSIX CI.\n *\n * @example\n * toPosixPath('C:\\\\repo\\\\src\\\\pet.ts') // 'C:/repo/src/pet.ts'\n */\nexport function toPosixPath(filePath: string): string {\n return filePath.replaceAll('\\\\', '/')\n}\n\n/**\n * Strips the file extension from a path or file name.\n * Only removes the last `.ext` segment when the dot is not part of a directory name.\n *\n * @example\n * trimExtName('petStore.ts') // 'petStore'\n * trimExtName('/src/models/pet.ts') // '/src/models/pet'\n * trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'\n * trimExtName('noExtension') // 'noExtension'\n */\nexport function trimExtName(text: string): string {\n const dotIndex = text.lastIndexOf('.')\n if (dotIndex > 0 && !text.includes('/', dotIndex)) {\n return text.slice(0, dotIndex)\n }\n return text\n}\n\n/**\n * Resolves to `true` when `path` is `parent` itself or nested inside it. Both sides are resolved\n * to absolute paths first, so relative and `..`-containing inputs compare correctly.\n *\n * Guards a destructive or an out-of-tree operation: before wiping an output directory, check that\n * it does not contain the project root, and before loading a path a caller supplied, check that it\n * did not escape the directory it is allowed to read from.\n *\n * @example\n * isPathInside('./src/gen', '.') // true — nested inside the root\n * isPathInside('.', '.') // true — the same directory counts as inside\n * isPathInside('.', './src/gen') // false — the root is not inside its own output\n * isPathInside('../other', '.') // false — escapes the root\n */\nexport function isPathInside(path: string, parent: string): boolean {\n const resolvedPath = resolve(path)\n const resolvedParent = resolve(parent)\n if (resolvedPath === resolvedParent) {\n return true\n }\n\n const rel = relative(resolvedParent, resolvedPath)\n\n return rel !== '' && !rel.startsWith('..') && !isAbsolute(rel)\n}\n","import { hash } from 'node:crypto'\nimport { mkdir, writeFile } from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { clean, read } from '@internals/utils'\n\n/**\n * Root for everything the CLI persists between runs: the paired credential, the machine secret,\n * the last Studio config, and the live-session registry. `KUBB_HOME` relocates all of it.\n */\nfunction getKubbHome(): string {\n return process.env.KUBB_HOME ?? path.join(homedir(), '.kubb')\n}\n\n/**\n * Root for the credential and machine identity of the current project.\n *\n * Studio agents are project connections, so two projects on one machine must not share the same\n * persisted token or machine secret.\n */\nexport function getProjectKubbHome(project = process.cwd()): string {\n const projectId = hash('sha256', project)\n return path.join(getKubbHome(), 'projects', projectId)\n}\n\nconst CREDENTIALS_FILENAME = 'credentials.json'\n\n/**\n * Absolute path of the stored credential, so callers can name it in output without rebuilding it.\n */\nexport function getCredentialsPath(): string {\n return path.join(getProjectKubbHome(), CREDENTIALS_FILENAME)\n}\n\nexport type Credentials = {\n /**\n * The Studio instance this machine paired with. A different `--url` means re-pairing.\n */\n studioUrl: string\n /**\n * Bearer token for this machine. Never logged, never printed.\n */\n token: string\n agentId: string\n agentSlug: string\n /**\n * Permissions the user has already granted, keyed by absolute project path, so the CLI asks\n * once per project instead of on every run.\n */\n projects?: Record<string, { allowRead?: boolean; allowWrite?: boolean; allowConfigEdit?: boolean; allowExec?: boolean }>\n}\n\n/**\n * Reads the stored credential, or null when this machine has not paired yet or the file is\n * unreadable or corrupt. A bad file is treated as \"not paired\" so `kubb studio login` can\n * overwrite it rather than the CLI dying on it.\n */\nexport async function readCredentials(): Promise<Credentials | null> {\n const raw = await read(getCredentialsPath()).catch(() => null)\n if (!raw) {\n return null\n }\n\n try {\n return JSON.parse(raw) as Credentials\n } catch {\n return null\n }\n}\n\n/**\n * Writes the credential with owner-only permissions. The file holds a bearer token, so the mode\n * is set at creation time rather than left to the process umask or fixed up afterward, which\n * would leave the token briefly readable under the umask's default mode.\n */\nexport async function writeCredentials(credentials: Credentials): Promise<void> {\n const file = getCredentialsPath()\n\n await mkdir(path.dirname(file), { recursive: true, mode: 0o700 })\n await writeFile(file, JSON.stringify(credentials, null, 2), { mode: 0o600 })\n}\n\n/**\n * Forgets the stored credential. Succeeds when there was nothing to forget.\n */\nexport async function clearCredentials(): Promise<void> {\n await clean(getCredentialsPath())\n}\n","import { hostname } from 'node:os'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as prompts from '@clack/prompts'\nimport { KUBB_CONFIG_FILENAME } from '@internals/shared'\nimport { isCIEnvironment, openInBrowser, toError } from '@internals/utils'\nimport type { CLIOptions, Config } from '@kubb/core'\nimport { cliReporter, logLevel as logLevelMap } from '@kubb/core'\nimport {\n createFileStorage,\n type ClientOptions,\n defaultStudioUrl,\n type InvalidAgentTokenError,\n pairAgent,\n PairingCanceledError,\n runConnection,\n setStorage,\n} from '@kubb/studio'\nimport { buildTelemetryEvent, sendTelemetry } from '../../Telemetry.ts'\nimport setupReporters from '../../loggers/utils.ts'\nimport { createSpinner, logBlock, logIntro, logOutro, logTip } from '../../loggers/output.ts'\nimport { canUseTTY } from '../../utils/env.ts'\nimport { getConfigs } from '../generate/utils.ts'\nimport { clearCredentials, type Credentials, getCredentialsPath, getProjectKubbHome, readCredentials, writeCredentials } from './credentials.ts'\nimport { version } from '../../../package.json'\n\ntype Permission = 'allowRead' | 'allowWrite' | 'allowConfigEdit' | 'allowExec'\n\nexport type StudioOptions = {\n /**\n * Current `@kubb/cli` version, reported to Studio and used for the telemetry payload.\n */\n version: string\n configPath?: string\n /**\n * Base URL of the Studio instance, for a self-hosted deployment. Resolved before it reaches here,\n * since stored credentials are bound to it.\n */\n studioUrl: string\n /**\n * What Studio may do in this project. Each flag grants outright; the rest are asked once per\n * project through {@link resolvePermissions}.\n */\n permission: Record<Permission, boolean>\n /**\n * Whether to open the approval page in a browser during pairing.\n */\n autoOpen: boolean\n logLevel?: CLIOptions['logLevel']\n}\n\nexport type SnapshotOptions = StudioOptions & {\n /**\n * Organization CI API key. Falls back to `KUBB_TOKEN`.\n */\n token?: string\n /**\n * Stable identity for the CI agent. Falls back to CI auto-detection.\n */\n id?: string\n /** Identity of another CI agent to also compare with. Falls back to CI auto-detection. */\n baseId?: string\n /**\n * Package name for the generated tarball. Falls back to the nearest package.json.\n */\n name?: string\n /**\n * Package version for the generated tarball. Falls back to the nearest package.json.\n */\n packageVersion?: string\n /**\n * Seconds to wait for the job to finish.\n */\n timeout?: number\n /**\n * Print the result as one JSON object instead of a summary.\n */\n json?: boolean\n}\n\ntype StudioValues = {\n config?: string\n url?: string\n allowRead: boolean\n allowWrite: boolean\n allowConfigEdit: boolean\n allowExec: boolean\n open?: boolean\n logLevel?: CLIOptions['logLevel']\n}\n\nexport function createStudioOptions(values: StudioValues): StudioOptions {\n return {\n version,\n configPath: values.config,\n studioUrl: values.url ?? defaultStudioUrl,\n permission: {\n allowRead: values.allowRead,\n allowWrite: values.allowWrite,\n allowConfigEdit: values.allowConfigEdit,\n allowExec: values.allowExec,\n },\n autoOpen: values.open ?? true,\n logLevel: values.logLevel,\n }\n}\n\ntype LoginOptions = {\n /**\n * Aborting this cancels an in-flight pairing request or poll and rejects with\n * {@link PairingCanceledError}. Wired to `kubb studio`'s shutdown signal, so Ctrl+C during\n * pairing cancels it instead of leaving the poll running.\n */\n signal?: AbortSignal\n /**\n * Credentials from before this login. When the fresh pairing resolves to the same agent on the\n * same Studio, its saved project permissions carry forward instead of being asked again.\n * Left out for an explicitly requested `kubb studio login`, which always starts clean.\n */\n previousCredentials?: Credentials | null\n}\n\n/**\n * Pairs this machine with Studio and stores the resulting token.\n *\n * The CLI holds a code and the browser approves it, rather than the user copying a token out of\n * the UI. The token comes back over the CLI's own HTTPS POST, so it never lands in a URL, a\n * server log, or a `Referer` header.\n */\nexport async function login({ studioUrl, autoOpen }: StudioOptions, { signal, previousCredentials }: LoginOptions = {}): Promise<Credentials> {\n const spinner = createSpinner()\n // The spinner only starts once a code is shown.\n let waiting = false\n\n try {\n const { token, agent } = await pairAgent({\n studioUrl,\n type: 'cli',\n name: path.basename(process.cwd()),\n hostname: hostname(),\n signal,\n onCode: (session) => {\n console.log(`\\nOpen ${styleText('cyan', session.verification_uri)} and approve the code ${styleText('bold', session.user_code)}`)\n\n if (autoOpen) {\n openInBrowser(session.verification_uri_complete)\n }\n\n spinner.start('Waiting for approval')\n waiting = true\n },\n onRetry: (error) => spinner.message(`Could not reach Kubb Studio, retrying: ${error.message}`),\n })\n spinner.stop(`Paired as ${agent.name}`)\n\n const keepsIdentity = previousCredentials?.studioUrl === studioUrl && previousCredentials.agentId === agent.id\n const credentials: Credentials = {\n studioUrl,\n token,\n agentId: agent.id,\n agentSlug: agent.slug,\n ...(keepsIdentity && previousCredentials?.projects ? { projects: previousCredentials.projects } : {}),\n }\n await writeCredentials(credentials)\n\n console.log(`Credentials stored in ${getCredentialsPath()}`)\n\n return credentials\n } catch (error) {\n if (waiting) {\n spinner.stop(error instanceof PairingCanceledError ? 'Pairing canceled' : 'Pairing failed')\n }\n throw error\n }\n}\n\n/**\n * What each permission is asked as, in the order the questions appear.\n */\nconst PERMISSIONS: ReadonlyArray<{\n key: Permission\n /**\n * Short label for status output and the connect summary.\n */\n label: string\n question: (project: string, configPath: string) => string\n}> = [\n {\n key: 'allowRead',\n label: 'read generated files',\n question: () => 'Let Kubb Studio read the files a generation produced?',\n },\n { key: 'allowWrite', label: 'write generated files', question: (project) => `Let Kubb Studio write generated files into ${project}?` },\n {\n key: 'allowConfigEdit',\n label: 'edit kubb.config.ts',\n question: (_project, configPath) => `Let Kubb Studio change plugin options in ${configPath}?`,\n },\n {\n key: 'allowExec',\n label: 'run formatter, linter, postGenerate',\n question: () => 'Let Kubb Studio run the formatter, the linter, and output.postGenerate?',\n },\n]\n\n/**\n * One row per permission, for the connect banner and `kubb studio status`. A list rather than a\n * joined line: four labels this long read as one run-on sentence side by side.\n */\nexport function formatPermissionRows(granted: Record<Permission, boolean>): Array<string> {\n return PERMISSIONS.map(({ key, label }) => `${granted[key] ? styleText('green', '✔') : styleText('red', '✘')} ${label}`)\n}\n\n/**\n * Resolves Studio permissions for the current project.\n * Flags win, saved answers are reused, and new answers are stored unless `persist` is false.\n */\nexport async function resolvePermissions(\n options: StudioOptions,\n credentials: Credentials,\n configPath: string = KUBB_CONFIG_FILENAME,\n /**\n * Stores new answers in `~/.kubb/credentials.json`.\n * Pass `false` for `KUBB_AGENT_TOKEN` sessions so a temporary token is not written back to disk.\n */\n persist = true,\n): Promise<Record<Permission, boolean>> {\n const project = process.cwd()\n const remembered = credentials.projects?.[project]\n const granted: Record<Permission, boolean> = { allowRead: false, allowWrite: false, allowConfigEdit: false, allowExec: false }\n const answers: Partial<Record<Permission, boolean>> = {}\n prompts.updateSettings({ withGuide: true })\n\n for (const { key, question } of PERMISSIONS) {\n if (options.permission[key] || typeof remembered?.[key] === 'boolean') {\n granted[key] = options.permission[key] || remembered?.[key] === true\n continue\n }\n\n if (isCIEnvironment() || !canUseTTY()) {\n granted[key] = false\n continue\n }\n\n granted[key] = (await prompts.confirm({ message: question(project, configPath), initialValue: false })) === true\n answers[key] = granted[key]\n }\n if (persist && Object.keys(answers).length) {\n await writeCredentials({\n ...credentials,\n projects: { ...credentials.projects, [project]: { ...remembered, ...answers } },\n })\n }\n\n return granted\n}\n\n/**\n * Loads the project's Kubb config the same way `kubb generate` does.\n * Returns the first config.\n */\nexport async function loadConfigs(options: StudioOptions): Promise<{ configPath: string; config: Config }> {\n const { configPath, configs } = await getConfigs({ configPath: options.configPath, logLevel: options.logLevel })\n const [config] = configs\n\n if (!config) {\n throw new Error('Config not defined, create a kubb.config.ts or pass it with --config')\n }\n\n // `getConfigs` resolves this to an absolute path. Relativized here, once, so the permission\n // prompt and the path Studio receives over the wire both show the project-relative form instead\n // of leaking the local filesystem layout.\n return { configPath: path.relative(process.cwd(), configPath) || configPath, config }\n}\n\n/**\n * Why a rejected token could not be recovered automatically: it came from `KUBB_AGENT_TOKEN`, no\n * browser is available to re-pair with, or the token this run already re-paired for was rejected\n * again.\n */\ntype RejectedTokenReason = 'envToken' | 'nonInteractive' | 'reauthExhausted'\n\n/**\n * Explains a rejected token to the operator. Builds the error and nothing else, so each caller\n * decides what happens to the credentials.\n */\nfunction explainRejectedToken(error: InvalidAgentTokenError, reason: RejectedTokenReason): Error {\n if (reason === 'envToken') {\n return new Error(`${error.message} Pair again and update KUBB_AGENT_TOKEN.`)\n }\n\n if (reason === 'reauthExhausted') {\n return new Error(`${error.message} Studio rejected the newly approved token too. Run \\`kubb studio login\\` and try again.`)\n }\n\n return new Error(`${error.message} Run \\`kubb studio login\\` to pair again.`)\n}\n\nexport type PreparedConnection = {\n configPath: string\n credentials: Credentials\n permissions: StudioOptions['permission']\n}\n\n/** Validates the project and resolves pairing and permissions before starting its worker. */\nexport async function prepareConnection(options: StudioOptions, signal?: AbortSignal): Promise<PreparedConnection> {\n const { configPath } = await loadConfigs(options)\n const envToken = process.env.KUBB_AGENT_TOKEN\n const stored = envToken ? null : await readCredentials()\n const credentials = await (async () => {\n if (envToken) return { studioUrl: options.studioUrl, token: envToken, agentId: '', agentSlug: '' }\n if (stored?.studioUrl === options.studioUrl) return stored\n if (isCIEnvironment()) {\n throw new Error(`Not paired with ${options.studioUrl}. Set KUBB_AGENT_TOKEN, or run \\`kubb studio login\\` on a machine with a browser.`)\n }\n return login(options, { signal })\n })()\n const permissions = await resolvePermissions(options, credentials, configPath, !envToken)\n return { configPath, credentials, permissions }\n}\n\nexport type WorkerState = 'starting' | 'connected' | 'reconnecting' | 'authentication required' | 'stopped'\n\n/** Runs the same project connection in the foreground or in a background worker. */\nexport async function connect(\n options: StudioOptions,\n context: {\n prepared?: PreparedConnection\n signal?: AbortSignal\n onState?: (state: WorkerState) => void | Promise<void>\n } = {},\n): Promise<void> {\n const shutdown = new AbortController()\n const signal = context.signal ?? shutdown.signal\n const stop = () => shutdown.abort()\n const events = process as unknown as NodeJS.EventEmitter\n if (!context.signal) {\n events.once('SIGINT', stop)\n events.once('SIGTERM', stop)\n }\n let hinted = false\n let reauthenticated = false\n try {\n if (!context.prepared) {\n const { getWorkerStatus } = await import('./background.ts')\n const worker = await getWorkerStatus()\n if (worker.running) throw new Error('This project is running in the background. Run `kubb studio stop` first.')\n }\n const prepared = context.prepared ?? (await prepareConnection(options, signal))\n let { credentials, permissions } = prepared\n const { configPath } = prepared\n await runConnection({\n credentials,\n signal,\n clientOptions: (): Omit<ClientOptions, 'token' | 'onAuthRequired'> => ({\n studioUrl: options.studioUrl,\n configPath,\n version: options.version,\n root: process.cwd(),\n permissions,\n loadConfig: async () => (await loadConfigs(options)).config,\n installLogger: async (hooks) => {\n if (!context.onState) await setupReporters(hooks, { logLevel: logLevelMap[options.logLevel ?? 'info'], reporters: [cliReporter] })\n hooks.hook('studio:connected', () => {\n if (!hinted && !context.onState && options.logLevel !== 'silent') logBlock(styleText('dim', 'Press Ctrl+C to disconnect'))\n hinted = true\n })\n hooks.hook('studio:ready', async () => {\n await context.onState?.('connected')\n if (!context.onState) logTip()\n })\n hooks.hook('studio:reconnecting', () => context.onState?.('reconnecting'))\n hooks.hook('studio:error', ({ error }) => {\n if (context.onState) console.error(error.message)\n })\n },\n }),\n onTokenRejected: async ({ error, live }) => {\n await context.onState?.('authentication required')\n if (process.env.KUBB_AGENT_TOKEN) throw explainRejectedToken(error, 'envToken')\n if (!live) await clearCredentials()\n if (reauthenticated) throw explainRejectedToken(error, 'reauthExhausted')\n if (context.onState || isCIEnvironment() || !canUseTTY()) throw explainRejectedToken(error, 'nonInteractive')\n console.log(styleText('yellow', live ? `${error.message} Studio needs you to approve access again.` : `${error.message} Pairing again...`))\n if (live) await clearCredentials()\n try {\n credentials = await login(options, { signal, previousCredentials: credentials })\n } catch (error) {\n if (error instanceof PairingCanceledError) {\n if (live && options.logLevel !== 'silent') logOutro('Disconnected')\n return null\n }\n throw error\n }\n reauthenticated = true\n permissions = await resolvePermissions(options, credentials, configPath, !process.env.KUBB_AGENT_TOKEN)\n return credentials\n },\n })\n if (!context.onState && signal.aborted && options.logLevel !== 'silent') logOutro('Disconnected')\n } catch (error) {\n if (!(error instanceof PairingCanceledError)) throw error\n } finally {\n events.off('SIGINT', stop)\n events.off('SIGTERM', stop)\n }\n}\n\n/**\n * Reports the paired agent and any saved permissions for the current project.\n */\nexport async function status(options: StudioOptions): Promise<void> {\n const credentials = await readCredentials()\n\n if (!credentials) {\n console.log('Not paired. Run `kubb studio login`.')\n\n return\n }\n\n console.log(`Paired with ${credentials.studioUrl} as ${styleText('cyan', credentials.agentSlug || credentials.agentId)}`)\n\n if (credentials.studioUrl !== options.studioUrl) {\n console.log(styleText('yellow', `Connecting to ${options.studioUrl} needs pairing again.`))\n }\n\n const remembered = credentials.projects?.[process.cwd()]\n\n if (!remembered) {\n console.log(styleText('dim', 'No saved permissions for this project. Run `kubb studio` to connect and choose.'))\n\n return\n }\n\n console.log(styleText('dim', 'Saved permissions'))\n\n for (const row of formatPermissionRows({\n allowRead: remembered.allowRead === true,\n allowWrite: remembered.allowWrite === true,\n allowConfigEdit: remembered.allowConfigEdit === true,\n allowExec: remembered.allowExec === true,\n })) {\n console.log(row)\n }\n}\n\n/**\n * Runs a Studio command with shared setup and telemetry reporting.\n */\nexport async function run(options: StudioOptions, action: () => Promise<unknown>, { block = false, json = false } = {}): Promise<void> {\n // The machine secret lives here and pairing binds it, so storage is installed before anything\n // reads `getMachineToken()`, which `startPairing` does, before any client exists.\n setStorage(createFileStorage(getProjectKubbHome()))\n\n const hrStart = process.hrtime()\n const report = (status: 'success' | 'failed') => sendTelemetry(buildTelemetryEvent({ command: 'studio', kubbVersion: options.version, hrStart, status }))\n\n try {\n if (options.logLevel !== 'silent' && !json) {\n logIntro({\n warning: styleText('yellow', 'This feature is still under development, use with caution'),\n block,\n })\n }\n\n await action()\n\n await report('success')\n } catch (error) {\n await report('failed')\n console.error(toError(error).message)\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAOA,SAAgB,cAAc,QAAsB;CAClD,IAAIA,cAAAA,gBAAgB,GAAG;CAEvB,IAAIC,aAAAA,QAAQ,aAAa,SACvB,CAAA,GAAA,mBAAA,SAAA,CAAS,OAAO;EAAC;EAAM;EAAS;EAAI;CAAM,SAAS,CAAC,CAAC;MAErD,CAAA,GAAA,mBAAA,SAAA,CAASA,aAAAA,QAAQ,aAAa,WAAW,SAAS,YAAY,CAAC,MAAM,SAAS,CAAC,CAAC;AAEpF;;;;;;;;;;;;;;ACAA,eAAsB,OAAO,MAAgC;CAC3D,IAAIC,kBAAAA,QAAQ,OACV,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,OAAO;CAE/B,QAAA,GAAOC,iBAAAA,OAAAA,CAAO,IAAI,CAAC,CAAC,WACZ,YACA,KACR;AACF;;;;;;;;;;AAWA,eAAsB,KAAK,MAA+B;CACxD,IAAID,kBAAAA,QAAQ,OACV,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,KAAK;CAE7B,QAAA,GAAOE,iBAAAA,SAAAA,CAAS,MAAM,EAAE,UAAU,OAAO,CAAC;AAC5C;;;;;;;;;AAsGA,eAAsB,MAAM,MAA6B;CACvD,QAAA,GAAOC,iBAAAA,GAAAA,CAAG,MAAM;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;AAClD;;;;;;;ACpIA,SAAS,cAAsB;CAC7B,OAAOC,aAAAA,QAAQ,IAAI,aAAaC,UAAAA,QAAK,MAAA,GAAKC,QAAAA,QAAAA,CAAQ,GAAG,OAAO;AAC9D;;;;;;;AAQA,SAAgB,mBAAmB,UAAUF,aAAAA,QAAQ,IAAI,GAAW;CAClE,MAAM,aAAA,GAAY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MAAM,aAAa,YAAY,WAAWF,aAAAA,QAAQ,IAAI;CAEtD,IAAI,CAAC,YAAY;EACf,QAAQ,KAAA,GAAIE,UAAAA,UAAAA,CAAU,OAAO,iFAAiF,CAAC;EAE/G;CACF;CAEA,QAAQ,KAAA,GAAIA,UAAAA,UAAAA,CAAU,OAAO,mBAAmB,CAAC;CAEjD,KAAK,MAAM,OAAO,qBAAqB;EACrC,WAAW,WAAW,cAAc;EACpC,YAAY,WAAW,eAAe;EACtC,iBAAiB,WAAW,oBAAoB;EAChD,WAAW,WAAW,cAAc;CACtC,CAAC,GACC,QAAQ,IAAI,GAAG;AAEnB;;;;AAKA,eAAsB,IAAI,SAAwB,QAAgC,EAAE,QAAQ,OAAO,OAAO,UAAU,CAAC,GAAkB;CAGrI,CAAA,GAAA,aAAA,WAAA,EAAA,GAAWW,aAAAA,kBAAAA,CAAkB,mBAAmB,CAAC,CAAC;CAElD,MAAM,UAAUb,aAAAA,QAAQ,OAAO;CAC/B,MAAM,UAAU,WAAiCc,kBAAAA,cAAcC,kBAAAA,oBAAoB;EAAE,SAAS;EAAU,aAAa,QAAQ;EAAS;EAAS;CAAO,CAAC,CAAC;CAExJ,IAAI;EACF,IAAI,QAAQ,aAAa,YAAY,CAAC,MACpC,eAAA,SAAS;GACP,UAAA,GAASb,UAAAA,UAAAA,CAAU,UAAU,2DAA2D;GACxF;EACF,CAAC;EAGH,MAAM,OAAO;EAEb,MAAM,OAAO,SAAS;CACxB,SAAS,OAAO;EACd,MAAM,OAAO,QAAQ;EACrB,QAAQ,MAAMc,eAAAA,QAAQ,KAAK,CAAC,CAAC,OAAO;EACpC,aAAA,QAAA,WAAmB;CACrB;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-qbf5tadS.cjs");
|
|
2
|
-
const require_run = require("./run-
|
|
2
|
+
const require_run = require("./run-_hE0GAWu.cjs");
|
|
3
3
|
const require_utils = require("./utils-DqUNntyL.cjs");
|
|
4
4
|
const require_output = require("./output-D-9bGS7y.cjs");
|
|
5
5
|
let node_util = require("node:util");
|
|
@@ -325,4 +325,4 @@ const runner = async ({ values }) => {
|
|
|
325
325
|
//#endregion
|
|
326
326
|
exports.runner = runner;
|
|
327
327
|
|
|
328
|
-
//# sourceMappingURL=snapshot-
|
|
328
|
+
//# sourceMappingURL=snapshot-DndnZx5y.cjs.map
|