@kubb/cli 5.20.0 → 5.20.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-q5YqdKmI.cjs → Telemetry-CZl99KxO.cjs} +2 -2
- package/dist/{Telemetry-q5YqdKmI.cjs.map → Telemetry-CZl99KxO.cjs.map} +1 -1
- package/dist/{Telemetry-4T6PkdJo.js → Telemetry-D-q7d63-.js} +2 -2
- package/dist/{Telemetry-4T6PkdJo.js.map → Telemetry-D-q7d63-.js.map} +1 -1
- package/dist/{background-Bi9AvpqA.js → background-72p1aYFM.js} +1 -1
- package/dist/{background-DtI6vVet.cjs → background-BdeXAlTk.cjs} +3 -3
- package/dist/{background-DtI6vVet.cjs.map → background-BdeXAlTk.cjs.map} +1 -1
- package/dist/{background-Bt-N8p5N.js → background-CwUTDHsy.js} +3 -3
- package/dist/{background-Bt-N8p5N.js.map → background-CwUTDHsy.js.map} +1 -1
- package/dist/{credentials-9OkKaKAr.cjs → credentials-DLDcroAt.cjs} +66 -11
- package/dist/credentials-DLDcroAt.cjs.map +1 -0
- package/dist/{credentials-Bran9lpd.js → credentials-DZH7HT4w.js} +68 -13
- package/dist/credentials-DZH7HT4w.js.map +1 -0
- package/dist/{credentials-XjRyFRWF.js → credentials-DkrM8C9G.js} +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.js +9 -9
- package/dist/{mcp-C26j2VvJ.js → mcp-Czwo61MD.js} +2 -2
- package/dist/{mcp-C26j2VvJ.js.map → mcp-Czwo61MD.js.map} +1 -1
- package/dist/{mcp-C5Qb_3i8.cjs → mcp-Dol0uvD5.cjs} +2 -2
- package/dist/{mcp-C5Qb_3i8.cjs.map → mcp-Dol0uvD5.cjs.map} +1 -1
- package/dist/{package-CsxsJg57.cjs → package-C3QvvKTh.cjs} +2 -2
- package/dist/package-C3QvvKTh.cjs.map +1 -0
- package/dist/package-LSfew-Qt.js +5 -0
- package/dist/package-LSfew-Qt.js.map +1 -0
- package/dist/{run-B6e2p23o.js → run-6KAmg90E.js} +3 -3
- package/dist/{run-B6e2p23o.js.map → run-6KAmg90E.js.map} +1 -1
- package/dist/{run-D5lG3Rv7.cjs → run-9WksWzVa.cjs} +2 -2
- package/dist/{run-D5lG3Rv7.cjs.map → run-9WksWzVa.cjs.map} +1 -1
- package/dist/{run-DeevN1it.js → run-BJhArAVF.js} +2 -2
- package/dist/{run-DeevN1it.js.map → run-BJhArAVF.js.map} +1 -1
- package/dist/{run-6lwgfA_P.js → run-B_NPBulV.js} +2 -2
- package/dist/{run-6lwgfA_P.js.map → run-B_NPBulV.js.map} +1 -1
- package/dist/{run-8gqo-bOB.js → run-CHUNGIji.js} +6 -6
- package/dist/{run-8gqo-bOB.js.map → run-CHUNGIji.js.map} +1 -1
- package/dist/{run-C1JNeHrj.cjs → run-CHzhE8di.cjs} +2 -2
- package/dist/{run-C1JNeHrj.cjs.map → run-CHzhE8di.cjs.map} +1 -1
- package/dist/{run-Dy3EpGtg.cjs → run-Cweae_Wh.cjs} +6 -6
- package/dist/{run-Dy3EpGtg.cjs.map → run-Cweae_Wh.cjs.map} +1 -1
- package/dist/{run-QBGgsQ2B.js → run-CxRPI0ye.js} +2 -2
- package/dist/{run-QBGgsQ2B.js.map → run-CxRPI0ye.js.map} +1 -1
- package/dist/{run-JAYvsn2v.js → run-Cyn4lvz3.js} +1 -1
- package/dist/{run-CYY1iFD_.cjs → run-D0Y8rIEE.cjs} +3 -3
- package/dist/{run-CYY1iFD_.cjs.map → run-D0Y8rIEE.cjs.map} +1 -1
- package/dist/{run-q2tnHViw.cjs → run-D1fxLLXW.cjs} +2 -2
- package/dist/{run-q2tnHViw.cjs.map → run-D1fxLLXW.cjs.map} +1 -1
- package/dist/{run-Dlj-dK7u.cjs → run-D5_WwxCy.cjs} +2 -2
- package/dist/{run-Dlj-dK7u.cjs.map → run-D5_WwxCy.cjs.map} +1 -1
- package/dist/{run-yNWLKHjJ.js → run-gL99a3-0.js} +2 -2
- package/dist/{run-yNWLKHjJ.js.map → run-gL99a3-0.js.map} +1 -1
- package/dist/{snapshot-CRwqhXnu.cjs → snapshot-BtcVhcTJ.cjs} +2 -2
- package/dist/{snapshot-CRwqhXnu.cjs.map → snapshot-BtcVhcTJ.cjs.map} +1 -1
- package/dist/{snapshot-fRVniDRs.js → snapshot-DDTtDiyL.js} +2 -2
- package/dist/{snapshot-fRVniDRs.js.map → snapshot-DDTtDiyL.js.map} +1 -1
- package/dist/{status-W_mU4q9r.cjs → status-Cd_587gI.cjs} +2 -2
- package/dist/{status-W_mU4q9r.cjs.map → status-Cd_587gI.cjs.map} +1 -1
- package/dist/{status-DJryj--a.js → status-JrxZ9APu.js} +2 -2
- package/dist/{status-DJryj--a.js.map → status-JrxZ9APu.js.map} +1 -1
- package/dist/{studio-ncHwqZbW.js → studio-Bv32y8_Y.js} +14 -14
- package/dist/{studio-ncHwqZbW.js.map → studio-Bv32y8_Y.js.map} +1 -1
- package/dist/{studio-KJwsS5S9.cjs → studio-NubH589v.cjs} +14 -14
- package/dist/{studio-KJwsS5S9.cjs.map → studio-NubH589v.cjs.map} +1 -1
- package/dist/studioWorker.js +2 -2
- package/dist/{validate-DQ9Ls3az.js → validate--xnsXlIO.js} +2 -2
- package/dist/{validate-DQ9Ls3az.js.map → validate--xnsXlIO.js.map} +1 -1
- package/dist/{validate-Dz1Kh4xw.cjs → validate-DfZyp9m-.cjs} +2 -2
- package/dist/{validate-Dz1Kh4xw.cjs.map → validate-DfZyp9m-.cjs.map} +1 -1
- package/package.json +8 -7
- package/dist/credentials-9OkKaKAr.cjs.map +0 -1
- package/dist/credentials-Bran9lpd.js.map +0 -1
- package/dist/package-CsxsJg57.cjs.map +0 -1
- package/dist/package-D1ycB0bA.js +0 -5
- package/dist/package-D1ycB0bA.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials-DZH7HT4w.js","names":["sleep"],"sources":["../src/runners/studio/credentials.ts"],"sourcesContent":["import { hash, randomBytes, randomUUID } from 'node:crypto'\nimport { mkdir, readFile, rename, rm, stat, utimes, writeFile } from 'node:fs/promises'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { setTimeout as sleep } from 'node:timers/promises'\nimport { kubbStorage, resolveKubbDir } from '@kubb/core'\n\nconst projectBase = (project = process.cwd()) => path.join('projects', hash('sha256', project))\n\n/**\n * Root for the credential and machine identity of the current project, inside `KUBB_HOME`.\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 return resolveKubbDir(projectBase(project))\n}\n\nconst projectStorage = () => kubbStorage({ base: projectBase() })\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 /**\n * When `token` was issued, as an ISO date.\n */\n issuedAt?: string\n /**\n * The agent key as a PKCS #8 PEM string, absent for an agent paired without one. Kept in the\n * system keychain where there is one, and in the credential file otherwise.\n */\n privateKey?: string\n agentId: string\n agentSlug: string\n /**\n * The organization that approved the pairing, absent when Studio sends none.\n */\n organizationSlug?: 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<\n string,\n {\n allowRead?: boolean\n allowReadAst?: boolean\n allowWrite?: boolean\n allowConfigEdit?: boolean\n allowInstall?: boolean\n allowUpdate?: boolean\n allowRemove?: boolean\n allowSaveInput?: boolean\n allowFileRefs?: boolean\n allowExec?: boolean\n }\n >\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 stored = await projectStorage()\n .getItem<Credentials>(CREDENTIALS_FILENAME)\n .catch(() => null)\n if (typeof stored?.token !== 'string' || stored.token === '') return null\n if (stored.privateKey) return stored\n\n const privateKey = await keychainEntry()\n .then((entry) => entry?.getPassword())\n .catch(() => null)\n\n return privateKey ? { ...stored, privateKey } : stored\n}\n\n/**\n * Writes the credential into the project folder, which only its owner can open. The agent key goes\n * to the system keychain instead when one accepts it, so a copy of the folder does not carry it.\n */\nexport async function writeCredentials(credentials: Credentials): Promise<void> {\n await writeCredentialFile(credentials, await storeKey(credentials.privateKey))\n}\n\n/**\n * Saves the agent key in the keychain. Resolves `false` when there is no key or no keychain takes it,\n * so the key has to go into the credential file.\n */\nfunction storeKey(privateKey: string | undefined): Promise<boolean> {\n if (privateKey === undefined) return Promise.resolve(false)\n return keychainEntry()\n .then(async (entry) => {\n await entry?.setPassword(privateKey)\n return entry !== null\n })\n .catch(() => false)\n}\n\nfunction writeCredentialFile({ privateKey, ...credentials }: Credentials, inKeychain: boolean): Promise<void> {\n return projectStorage().setItem(CREDENTIALS_FILENAME, inKeychain ? credentials : { ...credentials, privateKey })\n}\n\n/**\n * The keychain item for this project: macOS Keychain, Windows Credential Manager, or Secret Service\n * on Linux. Null when the native binding is missing for this platform.\n */\nasync function keychainEntry() {\n const keyring = await import('@napi-rs/keyring').catch(() => null)\n\n // Without Secret Service, Linux would fall back to the kernel keyring, which a reboot empties.\n return keyring ? new keyring.AsyncEntry('kubb-studio', getProjectKubbHome(), { linux: { store: 'secret-service' } }) : null\n}\n\nconst LOCK_STALE_MS = 10_000\nconst LOCK_RETRY_MS = 25\n\n/**\n * Takes the lock and resolves `true`, or resolves `false` while another process holds it. A lock\n * older than {@link LOCK_STALE_MS} was left by a process that died, and is cleared for the next try.\n */\nasync function tryLock(lock: string): Promise<boolean> {\n const taken = await mkdir(lock).then(\n () => true,\n (error: NodeJS.ErrnoException) => {\n if (error.code !== 'EEXIST') throw error\n return false\n },\n )\n if (taken) return true\n\n const isStale = (dir: string) => stat(dir).then(({ mtimeMs }) => Date.now() - mtimeMs > LOCK_STALE_MS)\n if (!(await isStale(lock).catch(() => false))) return false\n // Moving the lock aside is atomic: one contender takes it, and the others find it gone.\n const aside = `${lock}.${randomUUID()}`\n if (\n !(await rename(lock, aside).then(\n () => true,\n () => false,\n ))\n )\n return false\n // A contender that was slower to look may have moved a live lock, which goes back.\n const cleared = (await isStale(aside)) ? rm(aside, { recursive: true, force: true }) : rename(aside, lock)\n await cleared.catch(() => undefined)\n\n return false\n}\n\n/**\n * Applies `update` to the stored credential under a lock that every writer takes, so two processes\n * cannot overwrite each other's change. Returning nothing leaves the file as it is. Resolves what\n * `update` returned.\n */\nexport function updateCredentials<T extends Credentials | null | undefined>(update: (stored: Credentials | null) => T): Promise<T> {\n return withLock(async (assertOwner) => {\n const next = update(await readCredentials())\n if (next) {\n await assertOwner()\n const inKeychain = await storeKey(next.privateKey)\n // The keychain can keep this process waiting on a prompt, so ownership is checked again right before the file write.\n await assertOwner()\n await writeCredentialFile(next, inKeychain)\n }\n return next\n })\n}\n\n/**\n * Runs `run` while holding the credential lock. `assertOwner` throws once another process has taken\n * the lock over, which happens when this one was paused past {@link LOCK_STALE_MS}, so a write made\n * from an older read never lands on top of the newer owner's.\n */\nasync function withLock<T>(run: (assertOwner: () => Promise<void>) => Promise<T>): Promise<T> {\n const home = getProjectKubbHome()\n const lock = path.join(home, 'credentials.lock')\n const ownerFile = path.join(lock, 'owner')\n await mkdir(home, { recursive: true, mode: 0o700 })\n while (!(await tryLock(lock))) await sleep(LOCK_RETRY_MS)\n const owner = randomUUID()\n await writeFile(ownerFile, owner)\n const owns = () =>\n readFile(ownerFile, 'utf8').then(\n (stored) => stored === owner,\n () => false,\n )\n // A keychain prompt can keep the owner waiting past LOCK_STALE_MS, so it keeps the lock fresh.\n const renew = setInterval(() => {\n const now = new Date()\n void utimes(lock, now, now).catch(() => undefined)\n }, LOCK_STALE_MS / 2)\n renew.unref()\n try {\n return await run(async () => {\n if (!(await owns())) throw new Error('Another kubb process took over the Studio credentials while this one was paused. Run the command again.')\n })\n } finally {\n clearInterval(renew)\n // shortcut: the check and the removal are two steps, so a takeover between them is still possible; use an OS file lock if that window matters.\n if (await owns()) await rm(lock, { recursive: true, force: true }).catch(() => undefined)\n }\n}\n\n/**\n * Forgets the stored credential. Succeeds when there was nothing to forget. Given a `token`, a\n * credential another process stored since, with a different token, is kept.\n */\nexport function clearCredentials(token?: string): Promise<void> {\n return withLock(async (assertOwner) => {\n if (token && (await readCredentials())?.token !== token) return\n await assertOwner()\n await projectStorage().removeItem(CREDENTIALS_FILENAME)\n await keychainEntry()\n .then((entry) => entry?.deletePassword())\n .catch(() => undefined)\n })\n}\n\n/**\n * Reads this project's machine secret, creating it on first use. Pairing sends its hash, so pairing\n * the same project again rotates one agent's token instead of creating a second agent. It lives\n * apart from the credential, which {@link clearCredentials} deletes.\n */\nexport async function getMachineId(): Promise<string> {\n const storage = projectStorage()\n const stored = await storage.getItem('machine-secret').catch(() => null)\n if (typeof stored === 'string' && stored.trim()) return stored.trim()\n\n const secret = randomBytes(32).toString('hex')\n await storage.setItem('machine-secret', secret)\n\n return secret\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,eAAe,UAAU,QAAQ,IAAI,MAAM,KAAK,KAAK,YAAY,KAAK,UAAU,OAAO,CAAC;;;;;;;AAQ9F,SAAgB,mBAAmB,UAAU,QAAQ,IAAI,GAAW;CAClE,OAAO,eAAe,YAAY,OAAO,CAAC;AAC5C;AAEA,MAAM,uBAAuB,YAAY,EAAE,MAAM,YAAY,EAAE,CAAC;AAEhE,MAAM,uBAAuB;;;;AAK7B,SAAgB,qBAA6B;CAC3C,OAAO,KAAK,KAAK,mBAAmB,GAAG,oBAAoB;AAC7D;;;;;;AAoDA,eAAsB,kBAA+C;CACnE,MAAM,SAAS,MAAM,eAAe,CAAC,CAClC,QAAqB,oBAAoB,CAAC,CAC1C,YAAY,I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AAK;EAEnB,IAAI,MAAM,KAAK,GAAG,MAAM,GAAG,MAAM;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC,CAAC,CAAC,YAAY,KAAA,CAAS;CAC1F;AACF;;;;;AAMA,SAAgB,iBAAiB,OAA+B;CAC9D,OAAO,SAAS,OAAO,gBAAgB;EACrC,IAAI,UAAU,MAAM,gBAAgB,EAAA,EAAI,UAAU,OAAO;EACzD,MAAM,YAAY;EAClB,MAAM,eAAe,CAAC,CAAC,WAAW,oBAAoB;EACtD,MAAM,cAAc,CAAC,CAClB,MAAM,UAAU,OAAO,eAAe,CAAC,CAAC,CACxC,YAAY,KAAA,CAAS;CAC1B,CAAC;AACH;;;;;;AAOA,eAAsB,eAAgC;CACpD,MAAM,UAAU,eAAe;CAC/B,MAAM,SAAS,MAAM,QAAQ,QAAQ,gBAAgB,CAAC,CAAC,YAAY,IAAI;CACvE,IAAI,OAAO,WAAW,YAAY,OAAO,KAAK,GAAG,OAAO,OAAO,KAAK;CAEpE,MAAM,SAAS,YAAY,EAAE,CAAC,CAAC,SAAS,KAAK;CAC7C,MAAM,QAAQ,QAAQ,kBAAkB,MAAM;CAE9C,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as clearCredentials, a as readCredentials } from "./credentials-
|
|
1
|
+
export { t as clearCredentials, a as readCredentials } from "./credentials-DZH7HT4w.js";
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
|
|
3
|
-
const require_Telemetry = require("./Telemetry-
|
|
4
|
-
const require_package = require("./package-
|
|
3
|
+
const require_Telemetry = require("./Telemetry-CZl99KxO.cjs");
|
|
4
|
+
const require_package = require("./package-C3QvvKTh.cjs");
|
|
5
5
|
const require_mascot = require("./mascot-CLw0Qmln.cjs");
|
|
6
6
|
const require_shared = require("./shared-CK7OtOSX.cjs");
|
|
7
7
|
let node_util = require("node:util");
|
|
@@ -88,7 +88,7 @@ const command = (0, gunshi.defineWithTypes)()({
|
|
|
88
88
|
async run(ctx) {
|
|
89
89
|
const { values } = ctx;
|
|
90
90
|
const logLevel = resolveLogLevel(values);
|
|
91
|
-
const { run } = await Promise.resolve().then(() => require("./run-
|
|
91
|
+
const { run } = await Promise.resolve().then(() => require("./run-D0Y8rIEE.cjs"));
|
|
92
92
|
await run({
|
|
93
93
|
input: values.input,
|
|
94
94
|
configPath: values.config,
|
|
@@ -134,12 +134,12 @@ function resolveDeprecatedFlags(args) {
|
|
|
134
134
|
// src/index.ts
|
|
135
135
|
/** The subcommands besides `generate`, imported only when the run needs them, so `kubb generate` never loads their code. */
|
|
136
136
|
const commandLoaders = {
|
|
137
|
-
init: () => Promise.resolve().then(() => require("./run-
|
|
138
|
-
validate: () => Promise.resolve().then(() => require("./validate-
|
|
139
|
-
mcp: () => Promise.resolve().then(() => require("./mcp-
|
|
140
|
-
studio: () => Promise.resolve().then(() => require("./studio-
|
|
137
|
+
init: () => Promise.resolve().then(() => require("./run-D1fxLLXW.cjs")),
|
|
138
|
+
validate: () => Promise.resolve().then(() => require("./validate-DfZyp9m-.cjs")),
|
|
139
|
+
mcp: () => Promise.resolve().then(() => require("./mcp-Dol0uvD5.cjs")),
|
|
140
|
+
studio: () => Promise.resolve().then(() => require("./studio-NubH589v.cjs")),
|
|
141
141
|
add: () => Promise.resolve().then(() => require("./run-w8oRvtdl.cjs")),
|
|
142
|
-
update: () => Promise.resolve().then(() => require("./run-
|
|
142
|
+
update: () => Promise.resolve().then(() => require("./run-CHzhE8di.cjs")),
|
|
143
143
|
remove: () => Promise.resolve().then(() => require("./run-Cz4jqsVH.cjs")),
|
|
144
144
|
list: () => Promise.resolve().then(() => require("./run-D15oxCOd.cjs"))
|
|
145
145
|
};
|
|
@@ -164,7 +164,7 @@ async function run(argv = process.argv.slice(2)) {
|
|
|
164
164
|
if (Object.hasOwn(commandLoaders, name)) names = [name];
|
|
165
165
|
if (!names.length && resolvedArgs.some((arg) => HELP_FLAGS.has(arg))) names = Object.keys(commandLoaders);
|
|
166
166
|
const modules = Object.fromEntries(await Promise.all(names.map(async (key) => [key, await commandLoaders[key]()])));
|
|
167
|
-
const args = name === "studio" ? (await Promise.resolve().then(() => require("./studio-
|
|
167
|
+
const args = name === "studio" ? (await Promise.resolve().then(() => require("./studio-NubH589v.cjs"))).routeStudioFlags(resolvedArgs) : resolvedArgs;
|
|
168
168
|
const isQuietFlag = args.some((arg) => QUIET_FLAGS.has(arg));
|
|
169
169
|
const isJsonOutput = args.includes("--json") || args.some((arg, index) => /^--reporter=.*\bjson\b/.test(arg) || arg === "--reporter" && /\bjson\b/.test(args[index + 1] ?? ""));
|
|
170
170
|
if (!require_Telemetry.isDisabled() && !isQuietFlag) console.error(`${(0, node_util.styleText)("yellow", "Notice:")} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${(0, node_util.styleText)("cyan", "KUBB_DISABLE_TELEMETRY=1")}.\n`);
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-BowF1xt-.js";
|
|
2
|
-
import { t as isDisabled } from "./Telemetry-
|
|
3
|
-
import { t as version } from "./package-
|
|
2
|
+
import { t as isDisabled } from "./Telemetry-D-q7d63-.js";
|
|
3
|
+
import { t as version } from "./package-LSfew-Qt.js";
|
|
4
4
|
import { r as wantsMascot, t as getBanner } from "./mascot-b4yXsKwl.js";
|
|
5
5
|
import { n as dryRunId, r as logLevelArg, t as configArg } from "./shared-B5nei7B5.js";
|
|
6
6
|
import { styleText } from "node:util";
|
|
@@ -86,7 +86,7 @@ const command = defineWithTypes()({
|
|
|
86
86
|
async run(ctx) {
|
|
87
87
|
const { values } = ctx;
|
|
88
88
|
const logLevel = resolveLogLevel(values);
|
|
89
|
-
const { run } = await import("./run-
|
|
89
|
+
const { run } = await import("./run-6KAmg90E.js");
|
|
90
90
|
await run({
|
|
91
91
|
input: values.input,
|
|
92
92
|
configPath: values.config,
|
|
@@ -132,12 +132,12 @@ function resolveDeprecatedFlags(args) {
|
|
|
132
132
|
// src/index.ts
|
|
133
133
|
/** The subcommands besides `generate`, imported only when the run needs them, so `kubb generate` never loads their code. */
|
|
134
134
|
const commandLoaders = {
|
|
135
|
-
init: () => import("./run-
|
|
136
|
-
validate: () => import("./validate
|
|
137
|
-
mcp: () => import("./mcp-
|
|
138
|
-
studio: () => import("./studio-
|
|
135
|
+
init: () => import("./run-BJhArAVF.js"),
|
|
136
|
+
validate: () => import("./validate--xnsXlIO.js"),
|
|
137
|
+
mcp: () => import("./mcp-Czwo61MD.js"),
|
|
138
|
+
studio: () => import("./studio-Bv32y8_Y.js"),
|
|
139
139
|
add: () => import("./run-Bn5MQwU6.js"),
|
|
140
|
-
update: () => import("./run-
|
|
140
|
+
update: () => import("./run-B_NPBulV.js"),
|
|
141
141
|
remove: () => import("./run-DZF-DqiM.js"),
|
|
142
142
|
list: () => import("./run-C4fd98gp.js")
|
|
143
143
|
};
|
|
@@ -162,7 +162,7 @@ async function run(argv = process.argv.slice(2)) {
|
|
|
162
162
|
if (Object.hasOwn(commandLoaders, name)) names = [name];
|
|
163
163
|
if (!names.length && resolvedArgs.some((arg) => HELP_FLAGS.has(arg))) names = Object.keys(commandLoaders);
|
|
164
164
|
const modules = Object.fromEntries(await Promise.all(names.map(async (key) => [key, await commandLoaders[key]()])));
|
|
165
|
-
const args = name === "studio" ? (await import("./studio-
|
|
165
|
+
const args = name === "studio" ? (await import("./studio-Bv32y8_Y.js")).routeStudioFlags(resolvedArgs) : resolvedArgs;
|
|
166
166
|
const isQuietFlag = args.some((arg) => QUIET_FLAGS.has(arg));
|
|
167
167
|
const isJsonOutput = args.includes("--json") || args.some((arg, index) => /^--reporter=.*\bjson\b/.test(arg) || arg === "--reporter" && /\bjson\b/.test(args[index + 1] ?? ""));
|
|
168
168
|
if (!isDisabled() && !isQuietFlag) console.error(`${styleText("yellow", "Notice:")} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${styleText("cyan", "KUBB_DISABLE_TELEMETRY=1")}.\n`);
|
|
@@ -12,10 +12,10 @@ const command = define({
|
|
|
12
12
|
].join("\n"),
|
|
13
13
|
rendering: { header: null },
|
|
14
14
|
async run() {
|
|
15
|
-
const { run } = await import("./run-
|
|
15
|
+
const { run } = await import("./run-CxRPI0ye.js");
|
|
16
16
|
await run();
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
export { command };
|
|
20
20
|
|
|
21
|
-
//# sourceMappingURL=mcp-
|
|
21
|
+
//# sourceMappingURL=mcp-Czwo61MD.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-
|
|
1
|
+
{"version":3,"file":"mcp-Czwo61MD.js","names":[],"sources":["../src/commands/mcp.ts"],"sourcesContent":["import { define } from 'gunshi'\n\n/** The runner is imported when the command runs, so listing `kubb --help` never loads `@kubb/mcp`. */\nexport const command = define({\n name: 'mcp',\n description: 'Start an MCP server for code generation from an AI assistant.',\n examples: ['kubb mcp', '# Then add to your MCP client config:', '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }'].join('\\n'),\n // gunshi prints the header to stdout, which the MCP stdio transport owns.\n rendering: { header: null },\n async run() {\n const { run } = await import('../runners/mcp/run.ts')\n await run()\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,OAAO;CAC5B,MAAM;CACN,aAAa;CACb,UAAU;EAAC;EAAY;EAAyC;CAA+E,CAAC,CAAC,KAAK,IAAI;CAE1J,WAAW,EAAE,QAAQ,KAAK;CAC1B,MAAM,MAAM;EACV,MAAM,EAAE,QAAQ,MAAM,OAAO;EAC7B,MAAM,IAAI;CACZ;AACF,CAAC"}
|
|
@@ -11,10 +11,10 @@ const command = (0, require("gunshi").define)({
|
|
|
11
11
|
].join("\n"),
|
|
12
12
|
rendering: { header: null },
|
|
13
13
|
async run() {
|
|
14
|
-
const { run } = await Promise.resolve().then(() => require("./run-
|
|
14
|
+
const { run } = await Promise.resolve().then(() => require("./run-9WksWzVa.cjs"));
|
|
15
15
|
await run();
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
exports.command = command;
|
|
19
19
|
|
|
20
|
-
//# sourceMappingURL=mcp-
|
|
20
|
+
//# sourceMappingURL=mcp-Dol0uvD5.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-
|
|
1
|
+
{"version":3,"file":"mcp-Dol0uvD5.cjs","names":["define"],"sources":["../src/commands/mcp.ts"],"sourcesContent":["import { define } from 'gunshi'\n\n/** The runner is imported when the command runs, so listing `kubb --help` never loads `@kubb/mcp`. */\nexport const command = define({\n name: 'mcp',\n description: 'Start an MCP server for code generation from an AI assistant.',\n examples: ['kubb mcp', '# Then add to your MCP client config:', '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }'].join('\\n'),\n // gunshi prints the header to stdout, which the MCP stdio transport owns.\n rendering: { header: null },\n async run() {\n const { run } = await import('../runners/mcp/run.ts')\n await run()\n },\n})\n"],"mappings":";;;AAGA,MAAa,WAAA,G,gBAAUA,CAAAA,CAAAA,OAAAA,CAAO;CAC5B,MAAM;CACN,aAAa;CACb,UAAU;EAAC;EAAY;EAAyC;CAA+E,CAAC,CAAC,KAAK,IAAI;CAE1J,WAAW,EAAE,QAAQ,KAAK;CAC1B,MAAM,MAAM;EACV,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EACtB,MAAM,IAAI;CACZ;AACF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "5.20.
|
|
2
|
+
var version = "5.20.1";
|
|
3
3
|
Object.defineProperty(exports, "version", {
|
|
4
4
|
enumerable: true,
|
|
5
5
|
get: function() {
|
|
@@ -7,4 +7,4 @@ Object.defineProperty(exports, "version", {
|
|
|
7
7
|
}
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
//# sourceMappingURL=package-
|
|
10
|
+
//# sourceMappingURL=package-C3QvvKTh.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-C3QvvKTh.cjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-LSfew-Qt.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./rolldown-runtime-BowF1xt-.js";
|
|
2
2
|
import { n as getElapsedMs, t as formatMs } from "./time-D7ONPPZf.js";
|
|
3
|
-
import { t as version } from "./package-
|
|
4
|
-
import { n as trackRun } from "./Telemetry-
|
|
3
|
+
import { t as version } from "./package-LSfew-Qt.js";
|
|
4
|
+
import { n as trackRun } from "./Telemetry-D-q7d63-.js";
|
|
5
5
|
import { n as pluralize } from "./text-HYWAcipy.js";
|
|
6
6
|
import { a as startWatcher, i as listenForKeys, n as setupReporters, o as trackBuild, r as diffBuilds, t as selectReporters } from "./reporters-B6p0n7s3.js";
|
|
7
7
|
import { a as logWarn, i as logStep, n as logError, r as logInfo, s as createPlainWriter } from "./log-B_uVM704.js";
|
|
@@ -288,4 +288,4 @@ async function run({ input, configPath, logLevel: logLevelKey, watch: watchMode,
|
|
|
288
288
|
}
|
|
289
289
|
export { generate, run };
|
|
290
290
|
|
|
291
|
-
//# sourceMappingURL=run-
|
|
291
|
+
//# sourceMappingURL=run-6KAmg90E.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-B6e2p23o.js","names":["delay","logLevel","logLevelMap"],"sources":["../src/utils/updateCheck.ts","../src/runners/generate/run.ts"],"sourcesContent":["import { isCIEnvironment } from '@internals/utils'\nimport { kubbStorage } from '@kubb/core'\nimport { isValid } from 'verkit'\n\n/** NPM registry endpoint used to check for @kubb/cli updates. */\nconst KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/** Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run. */\nconst UPDATE_CHECK_TIMEOUT_MS = 3_000\n\n/** How long a stored registry answer stays fresh. */\nexport const UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1_000\n\nconst STORE_KEY = 'update-check.json'\n\ntype StoredCheck = {\n version: string\n checkedAt: number\n}\n\nfunction isStoredCheck(value: unknown): value is StoredCheck {\n const check = value as Partial<StoredCheck> | null\n return typeof check?.version === 'string' && isValid(check.version) && typeof check.checkedAt === 'number'\n}\n\n// A timestamp in the future, from a clock set back, counts as stale so it cannot hide updates.\nfunction isFresh(checkedAt: number): boolean {\n const age = Date.now() - checkedAt\n return age >= 0 && age < UPDATE_CHECK_INTERVAL_MS\n}\n\n/** The latest published version, `undefined` when the registry does not answer in time or `signal` aborts. Never rejects. */\nasync function fetchLatestVersion(signal: AbortSignal): Promise<string | undefined> {\n try {\n const res = await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.any([signal, AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS)]) })\n if (!res.ok) return undefined\n const data = (await res.json()) as { version?: unknown }\n return typeof data.version === 'string' && isValid(data.version) ? data.version : undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * The latest published `@kubb/cli` version for the update notice. Skipped in CI. Asks npm at most once per\n * {@link UPDATE_CHECK_INTERVAL_MS} and keeps the answer in `~/.kubb/cache` (or `KUBB_HOME`).\n * Resolves `undefined` when there is nothing to show. Never rejects.\n */\nexport async function getLatestVersion(signal: AbortSignal): Promise<string | undefined> {\n if (isCIEnvironment()) return undefined\n\n const storage = (() => {\n try {\n return kubbStorage({ base: 'cache' })\n } catch {\n return undefined\n }\n })()\n const stored = await storage?.getItem(STORE_KEY).catch(() => null)\n if (isStoredCheck(stored) && isFresh(stored.checkedAt)) return stored.version\n\n const latest = await fetchLatestVersion(signal)\n if (latest) await storage?.setItem(STORE_KEY, { version: latest, checkedAt: Date.now() }).catch(() => undefined)\n return latest\n}\n","import path from 'node:path'\nimport process from 'node:process'\nimport { setTimeout as delay } from 'node:timers/promises'\nimport { styleText } from 'node:util'\nimport { formatMs, formatters, getElapsedMs, linters } from '@internals/utils'\nimport {\n Hookable,\n type CLIOptions,\n cliReporter,\n type Config,\n Diagnostics,\n fileReporter,\n getInputKind,\n htmlReporter,\n jsonReporter,\n Kubb,\n type KubbHooks,\n logLevel as logLevelMap,\n memoryStorage,\n type ReporterName,\n} from '@kubb/core'\nimport { version } from '../../../package.json'\nimport { trackRun } from '../../Telemetry.ts'\nimport { pluralize } from '../../ui/text.ts'\nimport setupReporters, { selectReporters } from '../../loggers/reporters.ts'\nimport { createPlainWriter } from '../../loggers/plainWriter.ts'\nimport { logIntro, logOutro, logSpacer, logTip } from '../../ui/intro.ts'\nimport { logError, logInfo, logStep, logWarn } from '../../ui/log.ts'\nimport { logBanner } from '../../ui/mascot.ts'\nimport { createSpinner } from '../../ui/spinner.ts'\nimport { getConfigs } from '../../config.ts'\nimport { isOutdated } from '../../utils/registry.ts'\nimport { getLatestVersion } from '../../utils/updateCheck.ts'\nimport { type BuildDiff, type BuildSnapshot, diffBuilds, listenForKeys, startWatcher, trackBuild } from './utils.ts'\n\n/** The formatter names from `Config['output'].format`, without `'auto'` (detection, not a tool) and `false` (skip). */\ntype FormatterName = Exclude<NonNullable<Config['output']['format']>, 'auto' | false>\ntype LinterName = Exclude<NonNullable<Config['output']['lint']>, 'auto' | false>\n\n// Pinned here, not in `@internals/utils` (which must not import `@kubb/core`): a tool added to the union without a descriptor fails to compile.\nformatters satisfies Record<FormatterName, unknown>\nlinters satisfies Record<LinterName, unknown>\n\nfunction toRunConfig({ config, input, dryRun }: { config: Config; input?: string; dryRun: boolean }): Config {\n return {\n ...config,\n input: input ?? config.input,\n // Dry-run never touches disk, regardless of the config's own storage driver.\n storage: dryRun ? memoryStorage() : config.storage,\n // Also keeps core's `hasOutputPasses` false, so dry-run skips the output manifest write too.\n output: dryRun ? { ...config.output, format: false, lint: false, postGenerate: [] } : config.output,\n }\n}\n\ntype GenerateProps = {\n configs: Array<Config>\n hooks: Hookable<KubbHooks>\n}\n\n/**\n * Generates the configs and returns whether every build succeeded.\n */\nexport async function generate({ configs, hooks }: GenerateProps): Promise<boolean> {\n // Not awaited: each request finishes in the background, capped by its timeout, so it never delays the summary.\n const untrack = hooks.hook('kubb:generation:end', ({ config, filesCreated = 0, status = 'success', hrStart = process.hrtime() }) => {\n void trackRun({ command: 'generate', hrStart })({\n plugins: config.plugins.flatMap((p) =>\n p && typeof p === 'object' ? [{ name: p.meta?.name ?? p.name ?? '', options: (p.options ?? {}) as Record<string, unknown> }] : [],\n ),\n filesCreated,\n status,\n })\n })\n let succeeded = true\n try {\n for await (const { success, error } of Kubb.generate(configs, { hooks })) {\n if (error) await Diagnostics.emit(hooks, error)\n succeeded &&= success\n }\n } finally {\n untrack()\n }\n return succeeded\n}\n\ntype GenerateCommandOptions = {\n input?: string\n configPath?: string\n logLevel: string\n watch: boolean\n reporters?: Array<ReporterName>\n dryRun?: boolean\n}\n\n/** Upper bound in milliseconds for the update check's cache read or write once generation is done. */\nconst UPDATE_WAIT_MS = 1_000\n\n/** `promise`'s value, or `undefined` when it takes longer than `ms`. */\nasync function withTimeout<T>({ promise, ms }: { promise: Promise<T>; ms: number }): Promise<T | undefined> {\n const timer = new AbortController()\n const timeout = delay(ms, undefined, { signal: timer.signal }).catch(() => undefined)\n return Promise.race([promise, timeout]).finally(() => timer.abort())\n}\n\nasync function checkForUpdate({ hooks, latestVersion }: { hooks: Hookable<KubbHooks>; latestVersion: string | undefined }): Promise<void> {\n if (latestVersion && isOutdated({ installed: version, latest: latestVersion })) {\n await Diagnostics.emit(hooks, Diagnostics.update({ currentVersion: version, latestVersion }))\n }\n}\n\n/** Prints `Rebuilt in 1.2s · +1 schema -2 operations`, without the names part when the spec kept the same names. */\nfunction logRebuild({ diff: { schemas, operations }, durationMs }: { diff: BuildDiff; durationMs: number }): void {\n const specChange = [\n schemas.added && styleText('green', `+${pluralize(schemas.added, 'schema')}`),\n schemas.removed && styleText('red', `-${pluralize(schemas.removed, 'schema')}`),\n operations.added && styleText('green', `+${pluralize(operations.added, 'operation')}`),\n operations.removed && styleText('red', `-${pluralize(operations.removed, 'operation')}`),\n ]\n .filter(Boolean)\n .join(' ')\n logStep([`Rebuilt in ${formatMs(durationMs)}`, specChange].filter(Boolean).join(styleText('dim', ' · ')))\n}\n\n/**\n * Generates the configs, then again whenever a local `input` file changes. Returns whether the build succeeded when there is no file to watch.\n */\nasync function watch({ configs, hooks, quiet }: GenerateProps & { quiet: boolean }): Promise<boolean> {\n const watchPaths = [...new Set(configs.flatMap(({ input }) => (typeof input === 'string' && getInputKind(input) === 'file' ? [input] : [])))]\n if (!watchPaths.length) {\n if (!quiet) logWarn('Watch mode only follows a local `input` file, so the configs are generated once.')\n return generate({ configs, hooks })\n }\n\n const label = styleText('yellow', `Watching ${watchPaths.map((watchPath) => path.relative(process.cwd(), watchPath)).join(', ')}`)\n const tracker = trackBuild(hooks)\n let previous: BuildSnapshot | undefined\n // Don't removeAll() between builds, that would also drop logger and lifecycle\n // listeners. Plugin listeners are already disposed by safeBuild's dispose()\n // in its finally block, so re-running generate() on the same hooks emitter is safe.\n const build = async () => {\n const hrStart = process.hrtime()\n // Every config builds again, since an edited spec can change what the configs share.\n const succeeded = await generate({ configs, hooks })\n const snapshot = tracker.take()\n if (previous) logRebuild({ diff: diffBuilds(previous, snapshot), durationMs: getElapsedMs(hrStart) })\n previous = snapshot\n\n logStep(armKeys ? `${label} ${styleText('dim', 'r rebuild · q quit')}` : label)\n armKeys?.()\n if (succeeded) {\n logSpacer()\n logTip()\n }\n }\n // A trigger that lands while a build is queued joins it. One that lands during the build queues one more. Never rejects.\n let queue = Promise.resolve()\n let pending = false\n const rebuild = (): Promise<void> => {\n if (pending) return queue\n pending = true\n queue = queue\n .then(() => {\n pending = false\n return build()\n })\n .catch((error) => void Diagnostics.emit(hooks, error))\n return queue\n }\n const armKeys = quiet\n ? undefined\n : listenForKeys({\n rebuild: () => void rebuild(),\n quit: (code) => void Promise.resolve(hooks.callHook('kubb:lifecycle:end')).finally(() => process.exit(code)),\n })\n\n // The watcher ignores its startup state, so run the first build here. A failing one keeps watching so the user can fix the input.\n await rebuild()\n await startWatcher(watchPaths, rebuild, { info: logInfo, error: logError })\n return true\n}\n\n/**\n * Runs the full Kubb generation lifecycle for the given CLI options.\n * Loads configs, sets up the reporters (CLI `--reporter` picks which of `config.reporters` to trigger),\n * calls `generate` for each config entry, and prints an update notice when a newer version is known.\n */\nexport async function run({\n input,\n configPath,\n logLevel: logLevelKey,\n watch: watchMode,\n reporters: cliReporters,\n dryRun,\n}: GenerateCommandOptions): Promise<void> {\n // Started first: the notice prints at the end only when the stored answer or the registry is there by then.\n const updateCheck = new AbortController()\n const latestVersion = getLatestVersion(updateCheck.signal)\n const logLevel = logLevelMap[logLevelKey as keyof typeof logLevelMap] ?? logLevelMap.info\n const hooks = new Hookable<KubbHooks>()\n\n // CLI `--reporter` selects which reporters to trigger by name, defaulting to `cli`. `defineConfig`\n // registers the built-in reporters on the config; a config exported without it falls back to them below.\n const requestedNames: Array<ReporterName> = cliReporters?.length ? cliReporters : ['cli']\n\n // The `json` reporter owns stdout, so the command writes nothing of its own around it.\n const json = requestedNames.includes('json')\n const quiet = logLevel <= logLevelMap.silent || json\n\n // The run log goes to stderr in `json` mode, so an error with no report entry is never silent and stdout stays one JSON document.\n if (json) setupReporters(hooks, { logLevel, reporters: [cliReporter], writer: createPlainWriter(console.error) })\n\n // The config loads while the banner plays. Once it settles the banner jumps to its last frame, so\n // the build starts right away and no frame lands between log lines.\n const bannerCut = new AbortController()\n const banner = quiet ? undefined : logBanner({ version, signal: bannerCut.signal })\n const loading = getConfigs({\n configPath,\n input,\n watch: watchMode,\n logLevel: logLevelKey as CLIOptions['logLevel'],\n reporters: cliReporters,\n })\n // A rejection is handled below; this also keeps it from counting as unhandled during the banner.\n void loading.then(\n () => bannerCut.abort(),\n () => bannerCut.abort(),\n )\n await banner\n\n if (!quiet) {\n logIntro({ title: 'Configuration' })\n }\n\n // Load the config first so `config.reporters` can pick the reporters. A failure here has no\n // reporter installed yet, so fall back to the default `cli` reporter to surface it.\n const configSpinner = createSpinner()\n let configs: Array<Config>\n let resolvedConfigPath: string\n try {\n if (!quiet) configSpinner.start('Loading config')\n\n const loaded = await loading\n configs = loaded.configs\n resolvedConfigPath = loaded.configPath\n\n if (!quiet) configSpinner.stop(`Loaded ${styleText('dim', path.relative(process.cwd(), resolvedConfigPath))}`)\n } catch (error) {\n if (!quiet) configSpinner.error('Config failed loading')\n\n if (!json) setupReporters(hooks, { logLevel, reporters: [cliReporter] })\n // A diagnostic thrown while the config file runs, such as invalid extension options, sits in the cause chain.\n await Diagnostics.emit(hooks, error)\n\n if (!quiet) logOutro(styleText('red', '✗ Configuration failed'))\n process.exit(1)\n }\n\n // Without a reporter nothing is printed, not even an error, so a config written without\n // `defineConfig` gets the same built-ins it would have registered.\n const available = configs[0]?.reporters?.length ? configs[0].reporters : [cliReporter, jsonReporter, fileReporter, htmlReporter]\n const reporters = selectReporters(available, requestedNames)\n setupReporters(hooks, { logLevel, reporters, dryRun })\n\n await hooks.callHook('kubb:lifecycle:start', { version })\n\n const runConfigs = configs.map((config) => toRunConfig({ config, input, dryRun: dryRun ?? false }))\n\n if (!quiet) logOutro(`${pluralize(configs.length, 'config')} ready`)\n\n try {\n // One config that fails does not stop the others.\n const succeeded = await (watchMode ? watch({ configs: runConfigs, hooks, quiet }) : generate({ configs: runConfigs, hooks }))\n\n // Aborting settles a request in flight at once; the timeout covers a cache read or write on a stalled disk.\n updateCheck.abort()\n await checkForUpdate({ hooks, latestVersion: await withTimeout({ promise: latestVersion, ms: UPDATE_WAIT_MS }) })\n\n await hooks.callHook('kubb:lifecycle:end')\n\n // Watch mode prints a tip after each successful build. Regular generate commands need to\n // print one explicitly after the lifecycle group has closed so it stays outside the group.\n if (!quiet && !watchMode && succeeded) {\n logTip()\n }\n\n // `exitCode`, not `exit()`, so a telemetry request still in flight can finish within its timeout.\n if (!succeeded) {\n process.exitCode = 1\n }\n } catch (error) {\n await Diagnostics.emit(hooks, error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,uBAAuB;;AAG7B,MAAM,0BAA0B;AAKhC,MAAM,YAAY;AAOlB,SAAS,cAAc,OAAsC;CAC3D,MAAM,QAAQ;CACd,OAAO,OAAO,OAAO,YAAY,YAAY,QAAQ,MAAM,OAAO,KAAK,OAAO,MAAM,cAAc;AACpG;AAGA,SAAS,QAAQ,WAA4B;CAC3C,MAAM,MAAM,KAAK,IAAI,IAAI;CACzB,OAAO,OAAO,KAAK,MAAA;AACrB;;AAGA,eAAe,mBAAmB,QAAkD;CAClF,IAAI;EACF,MAAM,MAAM,MAAM,MAAM,sBAAsB,EAAE,QAAQ,YAAY,IAAI,CAAC,QAAQ,YAAY,QAAQ,uBAAuB,CAAC,CAAC,EAAE,CAAC;EACjI,IAAI,CAAC,IAAI,IAAI,OAAO,KAAA;EACpB,MAAM,OAAQ,MAAM,IAAI,KAAK;EAC7B,OAAO,OAAO,KAAK,YAAY,YAAY,QAAQ,KAAK,OAAO,IAAI,KAAK,UAAU,KAAA;CACpF,QAAQ;EACN;CACF;AACF;;;;;;AAOA,eAAsB,iBAAiB,QAAkD;CACvF,IAAI,gBAAgB,GAAG,OAAO,KAAA;CAE9B,MAAM,iBAAiB;EACrB,IAAI;GACF,OAAO,YAAY,EAAE,MAAM,QAAQ,CAAC;EACtC,QAAQ;GACN;EACF;CACF,EAAA,CAAG;CACH,MAAM,SAAS,MAAM,SAAS,QAAQ,SAAS,CAAC,CAAC,YAAY,IAAI;CACjE,IAAI,cAAc,MAAM,KAAK,QAAQ,OAAO,SAAS,GAAG,O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,YAAY,gBAAgB,WAAW,cAAc;CAC3D,eAAe,OAAO;EAAE,UAAA;EAAU;EAAW;CAAO,CAAC;CAErD,MAAM,MAAM,SAAS,wBAAwB,EAAE,QAAQ,CAAC;CAExD,MAAM,aAAa,QAAQ,KAAK,WAAW,YAAY;EAAE;EAAQ;EAAO,QAAQ,UAAU;CAAM,CAAC,CAAC;CAElG,IAAI,CAAC,OAAO,SAAS,GAAG,UAAU,QAAQ,QAAQ,QAAQ,EAAE,OAAO;CAEnE,IAAI;EAEF,MAAM,YAAY,OAAO,YAAY,MAAM;GAAE,SAAS;GAAY;GAAO;EAAM,CAAC,IAAI,SAAS;GAAE,SAAS;GAAY;EAAM,CAAC;EAG3H,YAAY,MAAM;EAClB,MAAM,eAAe;GAAE;GAAO,eAAe,MAAM,YAAY;IAAE,SAAS;IAAe,IAAI;GAAe,CAAC;EAAE,CAAC;EAEhH,MAAM,MAAM,SAAS,oBAAoB;EAIzC,IAAI,CAAC,SAAS,CAAC,aAAa,WAC1B,OAAO;EAIT,IAAI,CAAC,WACH,QAAQ,WAAW;CAEvB,SAAS,OAAO;EACd,MAAM,YAAY,KAAK,OAAO,KAAK;EACnC,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
1
|
+
{"version":3,"file":"run-6KAmg90E.js","names":["delay","logLevel","logLevelMap"],"sources":["../src/utils/updateCheck.ts","../src/runners/generate/run.ts"],"sourcesContent":["import { isCIEnvironment } from '@internals/utils'\nimport { kubbStorage } from '@kubb/core'\nimport { isValid } from 'verkit'\n\n/** NPM registry endpoint used to check for @kubb/cli updates. */\nconst KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/** Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run. */\nconst UPDATE_CHECK_TIMEOUT_MS = 3_000\n\n/** How long a stored registry answer stays fresh. */\nexport const UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1_000\n\nconst STORE_KEY = 'update-check.json'\n\ntype StoredCheck = {\n version: string\n checkedAt: number\n}\n\nfunction isStoredCheck(value: unknown): value is StoredCheck {\n const check = value as Partial<StoredCheck> | null\n return typeof check?.version === 'string' && isValid(check.version) && typeof check.checkedAt === 'number'\n}\n\n// A timestamp in the future, from a clock set back, counts as stale so it cannot hide updates.\nfunction isFresh(checkedAt: number): boolean {\n const age = Date.now() - checkedAt\n return age >= 0 && age < UPDATE_CHECK_INTERVAL_MS\n}\n\n/** The latest published version, `undefined` when the registry does not answer in time or `signal` aborts. Never rejects. */\nasync function fetchLatestVersion(signal: AbortSignal): Promise<string | undefined> {\n try {\n const res = await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.any([signal, AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS)]) })\n if (!res.ok) return undefined\n const data = (await res.json()) as { version?: unknown }\n return typeof data.version === 'string' && isValid(data.version) ? data.version : undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * The latest published `@kubb/cli` version for the update notice. Skipped in CI. Asks npm at most once per\n * {@link UPDATE_CHECK_INTERVAL_MS} and keeps the answer in `~/.kubb/cache` (or `KUBB_HOME`).\n * Resolves `undefined` when there is nothing to show. Never rejects.\n */\nexport async function getLatestVersion(signal: AbortSignal): Promise<string | undefined> {\n if (isCIEnvironment()) return undefined\n\n const storage = (() => {\n try {\n return kubbStorage({ base: 'cache' })\n } catch {\n return undefined\n }\n })()\n const stored = await storage?.getItem(STORE_KEY).catch(() => null)\n if (isStoredCheck(stored) && isFresh(stored.checkedAt)) return stored.version\n\n const latest = await fetchLatestVersion(signal)\n if (latest) await storage?.setItem(STORE_KEY, { version: latest, checkedAt: Date.now() }).catch(() => undefined)\n return latest\n}\n","import path from 'node:path'\nimport process from 'node:process'\nimport { setTimeout as delay } from 'node:timers/promises'\nimport { styleText } from 'node:util'\nimport { formatMs, formatters, getElapsedMs, linters } from '@internals/utils'\nimport {\n Hookable,\n type CLIOptions,\n cliReporter,\n type Config,\n Diagnostics,\n fileReporter,\n getInputKind,\n htmlReporter,\n jsonReporter,\n Kubb,\n type KubbHooks,\n logLevel as logLevelMap,\n memoryStorage,\n type ReporterName,\n} from '@kubb/core'\nimport { version } from '../../../package.json'\nimport { trackRun } from '../../Telemetry.ts'\nimport { pluralize } from '../../ui/text.ts'\nimport setupReporters, { selectReporters } from '../../loggers/reporters.ts'\nimport { createPlainWriter } from '../../loggers/plainWriter.ts'\nimport { logIntro, logOutro, logSpacer, logTip } from '../../ui/intro.ts'\nimport { logError, logInfo, logStep, logWarn } from '../../ui/log.ts'\nimport { logBanner } from '../../ui/mascot.ts'\nimport { createSpinner } from '../../ui/spinner.ts'\nimport { getConfigs } from '../../config.ts'\nimport { isOutdated } from '../../utils/registry.ts'\nimport { getLatestVersion } from '../../utils/updateCheck.ts'\nimport { type BuildDiff, type BuildSnapshot, diffBuilds, listenForKeys, startWatcher, trackBuild } from './utils.ts'\n\n/** The formatter names from `Config['output'].format`, without `'auto'` (detection, not a tool) and `false` (skip). */\ntype FormatterName = Exclude<NonNullable<Config['output']['format']>, 'auto' | false>\ntype LinterName = Exclude<NonNullable<Config['output']['lint']>, 'auto' | false>\n\n// Pinned here, not in `@internals/utils` (which must not import `@kubb/core`): a tool added to the union without a descriptor fails to compile.\nformatters satisfies Record<FormatterName, unknown>\nlinters satisfies Record<LinterName, unknown>\n\nfunction toRunConfig({ config, input, dryRun }: { config: Config; input?: string; dryRun: boolean }): Config {\n return {\n ...config,\n input: input ?? config.input,\n // Dry-run never touches disk, regardless of the config's own storage driver.\n storage: dryRun ? memoryStorage() : config.storage,\n // Also keeps core's `hasOutputPasses` false, so dry-run skips the output manifest write too.\n output: dryRun ? { ...config.output, format: false, lint: false, postGenerate: [] } : config.output,\n }\n}\n\ntype GenerateProps = {\n configs: Array<Config>\n hooks: Hookable<KubbHooks>\n}\n\n/**\n * Generates the configs and returns whether every build succeeded.\n */\nexport async function generate({ configs, hooks }: GenerateProps): Promise<boolean> {\n // Not awaited: each request finishes in the background, capped by its timeout, so it never delays the summary.\n const untrack = hooks.hook('kubb:generation:end', ({ config, filesCreated = 0, status = 'success', hrStart = process.hrtime() }) => {\n void trackRun({ command: 'generate', hrStart })({\n plugins: config.plugins.flatMap((p) =>\n p && typeof p === 'object' ? [{ name: p.meta?.name ?? p.name ?? '', options: (p.options ?? {}) as Record<string, unknown> }] : [],\n ),\n filesCreated,\n status,\n })\n })\n let succeeded = true\n try {\n for await (const { success, error } of Kubb.generate(configs, { hooks })) {\n if (error) await Diagnostics.emit(hooks, error)\n succeeded &&= success\n }\n } finally {\n untrack()\n }\n return succeeded\n}\n\ntype GenerateCommandOptions = {\n input?: string\n configPath?: string\n logLevel: string\n watch: boolean\n reporters?: Array<ReporterName>\n dryRun?: boolean\n}\n\n/** Upper bound in milliseconds for the update check's cache read or write once generation is done. */\nconst UPDATE_WAIT_MS = 1_000\n\n/** `promise`'s value, or `undefined` when it takes longer than `ms`. */\nasync function withTimeout<T>({ promise, ms }: { promise: Promise<T>; ms: number }): Promise<T | undefined> {\n const timer = new AbortController()\n const timeout = delay(ms, undefined, { signal: timer.signal }).catch(() => undefined)\n return Promise.race([promise, timeout]).finally(() => timer.abort())\n}\n\nasync function checkForUpdate({ hooks, latestVersion }: { hooks: Hookable<KubbHooks>; latestVersion: string | undefined }): Promise<void> {\n if (latestVersion && isOutdated({ installed: version, latest: latestVersion })) {\n await Diagnostics.emit(hooks, Diagnostics.update({ currentVersion: version, latestVersion }))\n }\n}\n\n/** Prints `Rebuilt in 1.2s · +1 schema -2 operations`, without the names part when the spec kept the same names. */\nfunction logRebuild({ diff: { schemas, operations }, durationMs }: { diff: BuildDiff; durationMs: number }): void {\n const specChange = [\n schemas.added && styleText('green', `+${pluralize(schemas.added, 'schema')}`),\n schemas.removed && styleText('red', `-${pluralize(schemas.removed, 'schema')}`),\n operations.added && styleText('green', `+${pluralize(operations.added, 'operation')}`),\n operations.removed && styleText('red', `-${pluralize(operations.removed, 'operation')}`),\n ]\n .filter(Boolean)\n .join(' ')\n logStep([`Rebuilt in ${formatMs(durationMs)}`, specChange].filter(Boolean).join(styleText('dim', ' · ')))\n}\n\n/**\n * Generates the configs, then again whenever a local `input` file changes. Returns whether the build succeeded when there is no file to watch.\n */\nasync function watch({ configs, hooks, quiet }: GenerateProps & { quiet: boolean }): Promise<boolean> {\n const watchPaths = [...new Set(configs.flatMap(({ input }) => (typeof input === 'string' && getInputKind(input) === 'file' ? [input] : [])))]\n if (!watchPaths.length) {\n if (!quiet) logWarn('Watch mode only follows a local `input` file, so the configs are generated once.')\n return generate({ configs, hooks })\n }\n\n const label = styleText('yellow', `Watching ${watchPaths.map((watchPath) => path.relative(process.cwd(), watchPath)).join(', ')}`)\n const tracker = trackBuild(hooks)\n let previous: BuildSnapshot | undefined\n // Don't removeAll() between builds, that would also drop logger and lifecycle\n // listeners. Plugin listeners are already disposed by safeBuild's dispose()\n // in its finally block, so re-running generate() on the same hooks emitter is safe.\n const build = async () => {\n const hrStart = process.hrtime()\n // Every config builds again, since an edited spec can change what the configs share.\n const succeeded = await generate({ configs, hooks })\n const snapshot = tracker.take()\n if (previous) logRebuild({ diff: diffBuilds(previous, snapshot), durationMs: getElapsedMs(hrStart) })\n previous = snapshot\n\n logStep(armKeys ? `${label} ${styleText('dim', 'r rebuild · q quit')}` : label)\n armKeys?.()\n if (succeeded) {\n logSpacer()\n logTip()\n }\n }\n // A trigger that lands while a build is queued joins it. One that lands during the build queues one more. Never rejects.\n let queue = Promise.resolve()\n let pending = false\n const rebuild = (): Promise<void> => {\n if (pending) return queue\n pending = true\n queue = queue\n .then(() => {\n pending = false\n return build()\n })\n .catch((error) => void Diagnostics.emit(hooks, error))\n return queue\n }\n const armKeys = quiet\n ? undefined\n : listenForKeys({\n rebuild: () => void rebuild(),\n quit: (code) => void Promise.resolve(hooks.callHook('kubb:lifecycle:end')).finally(() => process.exit(code)),\n })\n\n // The watcher ignores its startup state, so run the first build here. A failing one keeps watching so the user can fix the input.\n await rebuild()\n await startWatcher(watchPaths, rebuild, { info: logInfo, error: logError })\n return true\n}\n\n/**\n * Runs the full Kubb generation lifecycle for the given CLI options.\n * Loads configs, sets up the reporters (CLI `--reporter` picks which of `config.reporters` to trigger),\n * calls `generate` for each config entry, and prints an update notice when a newer version is known.\n */\nexport async function run({\n input,\n configPath,\n logLevel: logLevelKey,\n watch: watchMode,\n reporters: cliReporters,\n dryRun,\n}: GenerateCommandOptions): Promise<void> {\n // Started first: the notice prints at the end only when the stored answer or the registry is there by then.\n const updateCheck = new AbortController()\n const latestVersion = getLatestVersion(updateCheck.signal)\n const logLevel = logLevelMap[logLevelKey as keyof typeof logLevelMap] ?? logLevelMap.info\n const hooks = new Hookable<KubbHooks>()\n\n // CLI `--reporter` selects which reporters to trigger by name, defaulting to `cli`. `defineConfig`\n // registers the built-in reporters on the config; a config exported without it falls back to them below.\n const requestedNames: Array<ReporterName> = cliReporters?.length ? cliReporters : ['cli']\n\n // The `json` reporter owns stdout, so the command writes nothing of its own around it.\n const json = requestedNames.includes('json')\n const quiet = logLevel <= logLevelMap.silent || json\n\n // The run log goes to stderr in `json` mode, so an error with no report entry is never silent and stdout stays one JSON document.\n if (json) setupReporters(hooks, { logLevel, reporters: [cliReporter], writer: createPlainWriter(console.error) })\n\n // The config loads while the banner plays. Once it settles the banner jumps to its last frame, so\n // the build starts right away and no frame lands between log lines.\n const bannerCut = new AbortController()\n const banner = quiet ? undefined : logBanner({ version, signal: bannerCut.signal })\n const loading = getConfigs({\n configPath,\n input,\n watch: watchMode,\n logLevel: logLevelKey as CLIOptions['logLevel'],\n reporters: cliReporters,\n })\n // A rejection is handled below; this also keeps it from counting as unhandled during the banner.\n void loading.then(\n () => bannerCut.abort(),\n () => bannerCut.abort(),\n )\n await banner\n\n if (!quiet) {\n logIntro({ title: 'Configuration' })\n }\n\n // Load the config first so `config.reporters` can pick the reporters. A failure here has no\n // reporter installed yet, so fall back to the default `cli` reporter to surface it.\n const configSpinner = createSpinner()\n let configs: Array<Config>\n let resolvedConfigPath: string\n try {\n if (!quiet) configSpinner.start('Loading config')\n\n const loaded = await loading\n configs = loaded.configs\n resolvedConfigPath = loaded.configPath\n\n if (!quiet) configSpinner.stop(`Loaded ${styleText('dim', path.relative(process.cwd(), resolvedConfigPath))}`)\n } catch (error) {\n if (!quiet) configSpinner.error('Config failed loading')\n\n if (!json) setupReporters(hooks, { logLevel, reporters: [cliReporter] })\n // A diagnostic thrown while the config file runs, such as invalid extension options, sits in the cause chain.\n await Diagnostics.emit(hooks, error)\n\n if (!quiet) logOutro(styleText('red', '✗ Configuration failed'))\n process.exit(1)\n }\n\n // Without a reporter nothing is printed, not even an error, so a config written without\n // `defineConfig` gets the same built-ins it would have registered.\n const available = configs[0]?.reporters?.length ? configs[0].reporters : [cliReporter, jsonReporter, fileReporter, htmlReporter]\n const reporters = selectReporters(available, requestedNames)\n setupReporters(hooks, { logLevel, reporters, dryRun })\n\n await hooks.callHook('kubb:lifecycle:start', { version })\n\n const runConfigs = configs.map((config) => toRunConfig({ config, input, dryRun: dryRun ?? false }))\n\n if (!quiet) logOutro(`${pluralize(configs.length, 'config')} ready`)\n\n try {\n // One config that fails does not stop the others.\n const succeeded = await (watchMode ? watch({ configs: runConfigs, hooks, quiet }) : generate({ configs: runConfigs, hooks }))\n\n // Aborting settles a request in flight at once; the timeout covers a cache read or write on a stalled disk.\n updateCheck.abort()\n await checkForUpdate({ hooks, latestVersion: await withTimeout({ promise: latestVersion, ms: UPDATE_WAIT_MS }) })\n\n await hooks.callHook('kubb:lifecycle:end')\n\n // Watch mode prints a tip after each successful build. Regular generate commands need to\n // print one explicitly after the lifecycle group has closed so it stays outside the group.\n if (!quiet && !watchMode && succeeded) {\n logTip()\n }\n\n // `exitCode`, not `exit()`, so a telemetry request still in flight can finish within its timeout.\n if (!succeeded) {\n process.exitCode = 1\n }\n } catch (error) {\n await Diagnostics.emit(hooks, error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,uBAAuB;;AAG7B,MAAM,0BAA0B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AEF,MAAM,YAAY,OAAO,YAAY,MAAM;GAAE,SAAS;GAAY;GAAO;EAAM,CAAC,IAAI,SAAS;GAAE,SAAS;GAAY;EAAM,CAAC;EAG3H,YAAY,MAAM;EAClB,MAAM,eAAe;GAAE;GAAO,eAAe,MAAM,YAAY;IAAE,SAAS;IAAe,IAAI;GAAe,CAAC;EAAE,CAAC;EAEhH,MAAM,MAAM,SAAS,oBAAoB;EAIzC,IAAI,CAAC,SAAS,CAAC,aAAa,WAC1B,OAAO;EAIT,IAAI,CAAC,WACH,QAAQ,WAAW;CAEvB,SAAS,OAAO;EACd,MAAM,YAAY,KAAK,OAAO,KAAK;EACnC,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
|
|
2
2
|
const require_errors = require("./errors-Bewwe8mY.cjs");
|
|
3
|
-
const require_Telemetry = require("./Telemetry-
|
|
3
|
+
const require_Telemetry = require("./Telemetry-CZl99KxO.cjs");
|
|
4
4
|
let node_util = require("node:util");
|
|
5
5
|
let node_process = require("node:process");
|
|
6
6
|
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
@@ -29,4 +29,4 @@ async function run() {
|
|
|
29
29
|
}
|
|
30
30
|
exports.run = run;
|
|
31
31
|
|
|
32
|
-
//# sourceMappingURL=run-
|
|
32
|
+
//# sourceMappingURL=run-9WksWzVa.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-
|
|
1
|
+
{"version":3,"file":"run-9WksWzVa.cjs","names":["trackRun","process","styleText","toError"],"sources":["../src/runners/mcp/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { toError } from '@internals/utils'\nimport type * as McpModule from '@kubb/mcp'\nimport { trackRun } from '../../Telemetry.ts'\n\n/**\n * Starts the `@kubb/mcp` server over stdio and reports the outcome to telemetry.\n */\nexport async function run(): Promise<void> {\n const { run: startMcpServer } = (await import('@kubb/mcp')) as typeof McpModule\n\n const report = trackRun({ command: 'mcp', hrStart: process.hrtime() })\n\n try {\n // The MCP stdio transport owns stdout: anything else written there corrupts the JSON-RPC stream.\n console.error(styleText('cyan', '⏳ Starting MCP server...'))\n console.warn(styleText('yellow', 'This feature is still under development, use with caution'))\n const server = startMcpServer()\n // Report once the client introduces itself, so the event names the client (e.g. `claude-code`, `cursor-vscode`).\n server.on('initialize', ({ clientInfo }) => void report({ status: 'success', mcpClient: clientInfo.name }), { once: true })\n } catch (error) {\n await report({ status: 'failed' })\n console.error(toError(error).message)\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;AASA,eAAsB,MAAqB;CACzC,MAAM,EAAE,KAAK,mBAAoB,MAAM,OAAO;CAE9C,MAAM,SAASA,kBAAAA,SAAS;EAAE,SAAS;EAAO,SAASC,aAAAA,QAAQ,OAAO;CAAE,CAAC;CAErE,IAAI;EAEF,QAAQ,OAAA,GAAMC,UAAAA,UAAAA,CAAU,QAAQ,0BAA0B,CAAC;EAC3D,QAAQ,MAAA,GAAKA,UAAAA,UAAAA,CAAU,UAAU,2DAA2D,CAAC;EAG7F,eAAK,CAAC,CAAC,GAAG,eAAe,EAAE,iBAAiB,KAAK,OAAO;GAAE,QAAQ;GAAW,WAAW,WAAW;EAAK,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC;CAC5H,SAAS,OAAO;EACd,MAAM,OAAO,EAAE,QAAQ,SAAS,CAAC;EACjC,QAAQ,MAAMC,eAAAA,QAAQ,KAAK,CAAC,CAAC,OAAO;EACpC,aAAA,QAAA,WAAmB;CACrB;AACF"}
|
|
@@ -12,7 +12,7 @@ import { n as withSpinner } from "./spinner-D5DgYSS5.js";
|
|
|
12
12
|
import { a as installSpec, i as incompatibility, r as fetchRegistryIndex, s as registryUrl } from "./registry-BBJpMlM9.js";
|
|
13
13
|
import { t as installWithSpinner } from "./installWithSpinner-RJhWCsgh.js";
|
|
14
14
|
import { a as generateScript, c as missingPluginDependencies, i as findSpecFiles, l as parsePluginsFlag, n as detectPackageManager, o as initPackageJson, r as findPlugin, s as installPackages, t as addGenerateScript, u as readSpecInfo } from "./utils-DnmjcKb0.js";
|
|
15
|
-
import { t as version } from "./package-
|
|
15
|
+
import { t as version } from "./package-LSfew-Qt.js";
|
|
16
16
|
import { styleText } from "node:util";
|
|
17
17
|
import { defineWithTypes } from "gunshi";
|
|
18
18
|
import process from "node:process";
|
|
@@ -369,4 +369,4 @@ const command = defineWithTypes()({
|
|
|
369
369
|
});
|
|
370
370
|
export { command, run };
|
|
371
371
|
|
|
372
|
-
//# sourceMappingURL=run-
|
|
372
|
+
//# sourceMappingURL=run-BJhArAVF.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-DeevN1it.js","names":[],"sources":["../../../internals/shared/src/init.ts","../src/runners/init/run.ts"],"sourcesContent":["/** The `kubb.config.ts` `kubb init` writes before `kubb add` puts each plugin in. */\nexport function generateConfigFile({ inputPath, outputPath }: { inputPath: string; outputPath: string }): string {\n return `import { defineConfig } from 'kubb/config'\n\nexport default defineConfig({\n input: '${inputPath}',\n output: {\n path: '${outputPath}',\n clean: true,\n },\n plugins: [],\n})\n`\n}\n","import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport type { DryRunExtension } from '@gunshi/plugin-dryrun'\nimport { defineWithTypes } from 'gunshi'\nimport { resolveCommand } from 'package-manager-detector'\nimport { ConfigEditOperation, editConfig, generateConfigFile, initDefaults, KUBB_CONFIG_FILENAME, KUBB_PACKAGE_NAME } from '@internals/shared'\nimport { exists, formatMs, getElapsedMs, write } from '@internals/utils'\nimport { createKubb, Diagnostics, type RegistryEntry } from '@kubb/core'\nimport { dryRunId, type DryRunExtensions } from '../../commands/shared.ts'\nimport { getConfigs } from '../../config.ts'\nimport { isHttpUrl, pluralize } from '../../ui/text.ts'\nimport { isInteractiveRun, logIntro, logOutro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { withSpinner } from '../../ui/spinner.ts'\nimport { fetchRegistryIndex, incompatibility, installSpec, registryUrl } from '../../utils/registry.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\nimport {\n addGenerateScript,\n detectPackageManager,\n findPlugin,\n findSpecFiles,\n generateScript,\n initPackageJson,\n installPackages,\n missingPluginDependencies,\n type PackageManagerInfo,\n parsePluginsFlag,\n readSpecInfo,\n} from './utils.ts'\nimport { version } from '../../../package.json'\n\nfunction cancelAndExit(message = 'Operation canceled.'): never {\n clack.cancel(message)\n process.exit(0)\n}\n\nfunction unwrap<T>(value: T): Exclude<T, symbol> {\n if (clack.isCancel(value)) cancelAndExit()\n return value as Exclude<T, symbol>\n}\n\ntype InitOptions = {\n /**\n * When `true`, skips all interactive prompts and uses the detected or default values.\n */\n yes: boolean\n /**\n * Input path flag value from `--input`. When provided, skips the input prompt.\n */\n input?: string\n /**\n * Output directory flag value from `--output`. When provided, skips the output prompt.\n */\n output?: string\n /**\n * Comma-separated plugin list from `--plugins`, e.g. `'plugin-ts,zod'`. When provided, skips the plugin selection prompt.\n */\n plugins?: string\n /**\n * Dry-run extension from `@gunshi/plugin-dryrun`. When enabled, package installation, file\n * writes, and the first run are skipped.\n */\n dryRun: DryRunExtension\n}\n\ntype Choices = {\n inputPath: string\n outputPath: string\n plugins: Array<RegistryEntry>\n}\n\n/** The full `kubb.config.ts` for `choices`, with each plugin added the way `kubb add` adds it. */\nfunction buildConfig({ inputPath, outputPath, plugins }: Choices): string {\n const { source, outcomes } = editConfig({\n source: generateConfigFile({ inputPath, outputPath }),\n edits: plugins.map((entry) => ({ operation: ConfigEditOperation.ADD_PLUGIN, plugin: entry.artifact.package })),\n extensions: new Map(plugins.map(({ artifact, manifest }) => [artifact.package, { package: artifact.package, version: artifact.version, manifest }])),\n })\n const failed = outcomes.find((outcome) => !outcome.applied)\n if (failed && failed.edit.operation === ConfigEditOperation.ADD_PLUGIN)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `Could not add ${failed.edit.plugin} to ${KUBB_CONFIG_FILENAME}: ${failed.reason}`,\n help: `Run kubb init without that plugin, then add it with kubb add.`,\n })\n return source\n}\n\n/** Generates from the config at `configPath` without reporters, and returns how many files it wrote. */\nasync function firstRun(configPath: string): Promise<number> {\n const { configs } = await getConfigs({ configPath })\n let files = 0\n for (const config of configs) {\n const result = await createKubb(config).generate()\n if (!result.success) throw new Error(result.diagnostics.flatMap((diagnostic) => (diagnostic.severity === 'error' ? [diagnostic.message] : [])).join('\\n'))\n files += result.files.length\n }\n return files\n}\n\n/** The command that runs `kubb generate`: the `generate` script when it runs Kubb, otherwise `npx kubb generate`. */\nfunction generateCommand({ packageManager, script, watch }: { packageManager: PackageManagerInfo; script: string | undefined; watch: boolean }): string {\n if (script !== 'kubb generate') return `npx kubb generate${watch ? ' --watch' : ''}`\n const { command, args } = resolveCommand(packageManager.agent, 'run', watch ? ['generate', '--watch'] : ['generate'])!\n return [command, ...args].join(' ')\n}\n\n/**\n * Runs the Kubb setup wizard: detects the package manager and specs, asks for the spec, plugins, and\n * output folder, shows the config for review, then installs, writes `kubb.config.ts`, adds a\n * `generate` script, and runs the first generation.\n * Pass `yes: true` to skip all prompts and print one line per step.\n */\nexport async function run({ yes, input: inputFlag, output: outputFlag, plugins: pluginsFlag, dryRun }: InitOptions): Promise<void> {\n const cwd = process.cwd()\n\n if (!yes) logIntro({ title: isInteractiveRun({ yes, dryRun: dryRun.enabled }) ? undefined : 'Set up Kubb' })\n\n try {\n // Start the registry fetch now but await it only at the plugin step, so the first prompt never waits on the network\n const registry = fetchRegistryIndex({ registry: registryUrl() }).then((entries) =>\n entries.filter((entry) => entry.kind === 'plugin' && !incompatibility(entry.manifest)),\n )\n registry.catch(() => {})\n\n if (!(await exists(path.join(cwd, 'package.json')))) {\n if (!yes) {\n const shouldInit = unwrap(await clack.confirm({ message: 'No package.json found. Would you like to create one?', initialValue: true }))\n if (!shouldInit) cancelAndExit()\n }\n\n const packageManager = await detectPackageManager(cwd)\n await withSpinner({\n message: `Initializing package.json with ${packageManager.name}`,\n promise: initPackageJson(cwd, packageManager),\n done: () => `Created package.json with ${packageManager.name}`,\n failed: 'Could not create package.json',\n plain: yes,\n })\n }\n\n const packageManager = await detectPackageManager(cwd)\n const specs = await findSpecFiles(cwd)\n\n if (!yes) {\n logStep(`Package manager ${packageManager.name}`)\n if (specs[0]) {\n const { version: specVersion, operations } = await readSpecInfo(path.join(cwd, specs[0]))\n const details = [\n specs[0].slice(2),\n specVersion ? `${specVersion.startsWith('2') ? 'Swagger' : 'OpenAPI'} ${specVersion}` : undefined,\n operations === undefined ? undefined : pluralize(operations, 'operation'),\n specs.length > 1 ? `+${specs.length - 1} more` : undefined,\n ]\n logStep(`Found ${details.filter(Boolean).join(' · ')}`)\n }\n }\n\n // `--plugins` and `--yes` need the registry before any prompt; the interactive path reads it at the plugin step\n const plugins = pluginsFlag || yes ? await registry : undefined\n const defaultPlugins = (entries: Array<RegistryEntry>) => initDefaults.plugins.flatMap((id) => findPlugin({ plugins: entries, id }) ?? [])\n\n const flagPlugins = pluginsFlag && plugins ? parsePluginsFlag({ plugins, value: pluginsFlag }) : undefined\n\n let choices: Choices = {\n inputPath: inputFlag ?? specs[0] ?? initDefaults.inputPath,\n outputPath: outputFlag ?? initDefaults.outputPath,\n plugins: flagPlugins ?? (plugins ? defaultPlugins(plugins) : []),\n }\n if (yes && !choices.plugins.length) {\n throw new Error('The registry has no default plugin. Pass --plugins to choose one.')\n }\n\n async function askInput(current: string): Promise<string> {\n const choice = specs.length\n ? unwrap(\n await clack.select({\n message: 'Which spec should Kubb read?',\n options: [\n ...specs.map((spec) => ({ value: spec, label: spec, hint: 'found in this repo' })),\n { value: 'url', label: 'A URL' },\n { value: 'file', label: 'Another file' },\n ],\n initialValue: specs.includes(current) ? current : isHttpUrl(current) ? 'url' : 'file',\n }),\n )\n : isHttpUrl(current)\n ? 'url'\n : 'file'\n if (specs.includes(choice)) return choice\n const isUrl = choice === 'url'\n const initial = isUrl === isHttpUrl(current) && !specs.includes(current) ? current : undefined\n return unwrap(\n await clack.text({\n message: isUrl ? 'Spec URL' : 'Spec path',\n placeholder: isUrl ? 'https://example.com/openapi.yaml' : initDefaults.inputPath,\n initialValue: initial,\n defaultValue: isUrl ? undefined : initDefaults.inputPath,\n validate: (value) => {\n if (isUrl && !isHttpUrl(value ?? '')) return 'Enter an http(s) URL'\n },\n }),\n )\n }\n\n async function askPlugins(previous: Array<RegistryEntry>): Promise<Array<RegistryEntry>> {\n const plugins = await registry\n const current = previous.length ? previous : defaultPlugins(plugins)\n const width = Math.max(...plugins.map((entry) => entry.manifest.displayName.length))\n const nameWidth = Math.max(...plugins.map((entry) => entry.manifest.name.length))\n const values = unwrap(\n await clack.multiselect({\n message: 'What should Kubb generate?',\n options: plugins.map(({ id, manifest }) => ({\n value: id,\n label: `${manifest.displayName.padEnd(width)} ${styleText('dim', manifest.name.padEnd(nameWidth))}`.trimEnd(),\n })),\n initialValues: current.map((entry) => entry.id),\n required: true,\n }),\n )\n return plugins.filter((entry) => values.includes(entry.id))\n }\n\n // Flags for all three choices leave nothing to ask or review, as before the review step existed\n const answered = yes || Boolean(inputFlag && outputFlag && pluginsFlag)\n if (!answered) {\n let firstPass = true\n while (true) {\n // The first pass skips the questions a flag answered; \"Change a choice\" asks them all again.\n choices = {\n inputPath: firstPass && inputFlag ? inputFlag : await askInput(choices.inputPath),\n plugins: firstPass && flagPlugins ? flagPlugins : await askPlugins(choices.plugins),\n outputPath:\n firstPass && outputFlag\n ? outputFlag\n : unwrap(await clack.text({ message: 'Output folder', placeholder: choices.outputPath, defaultValue: choices.outputPath })),\n }\n firstPass = false\n const missing = missingPluginDependencies(choices.plugins.map((entry) => entry.manifest))\n if (missing.length) {\n logWarn(`${missing.join('\\n')}\\nAdd the missing plugins.`)\n continue\n }\n const config = buildConfig(choices)\n const packages = [KUBB_PACKAGE_NAME, ...choices.plugins.map((entry) => entry.artifact.package)]\n logStep(`Review ${KUBB_CONFIG_FILENAME}`)\n logBlock([...config.trimEnd().split('\\n'), '', `${styleText('dim', 'Installs')} ${packages.join(' ')} with ${packageManager.name}`])\n const configExists = await exists(path.join(cwd, KUBB_CONFIG_FILENAME))\n const confirmed = unwrap(\n await clack.select({\n message: configExists ? `${KUBB_CONFIG_FILENAME} exists. Overwrite it?` : 'Create it?',\n options: [\n { value: true, label: 'Yes' },\n { value: false, label: 'Change a choice' },\n ],\n }),\n )\n if (confirmed) break\n }\n }\n\n // Check the selection against the plugins' manifests before installing anything\n const missing = missingPluginDependencies(choices.plugins.map((entry) => entry.manifest))\n if (missing.length) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.missingDependency,\n severity: 'error',\n message: `${missing.join('\\n')}\\nAdd the missing plugins and run kubb init again.`,\n })\n }\n\n const configPath = path.join(cwd, KUBB_CONFIG_FILENAME)\n if (answered && !yes && (await exists(configPath))) {\n const overwrite = unwrap(await clack.confirm({ message: `${KUBB_CONFIG_FILENAME} exists. Overwrite it?`, initialValue: false }))\n if (!overwrite) cancelAndExit('Keeping existing configuration.')\n }\n\n // Install `kubb` at the running CLI's version and each plugin at the version the registry pins\n const packagesToInstall = [`${KUBB_PACKAGE_NAME}@${version}`, ...choices.plugins.map((entry) => installSpec(entry.artifact))]\n const packageNames = [KUBB_PACKAGE_NAME, ...choices.plugins.map((entry) => entry.artifact.package)]\n const dry = { message: `install ${packagesToInstall.length} packages with ${packageManager.name}` }\n if (yes) {\n await withSpinner({\n message: '',\n promise: dryRun.run(() => installPackages(packagesToInstall, packageManager, cwd), dry),\n done: () => `Installed ${packageNames.join(' ')} with ${packageManager.name}`,\n plain: true,\n })\n } else {\n await installWithSpinner({\n packages: packagesToInstall,\n names: `${packagesToInstall.length} packages`,\n packageManager,\n cwd,\n install: async (packages, packageManager, cwd, onLine) => void (await dryRun.run(() => installPackages(packages, packageManager, cwd, onLine), dry)),\n })\n }\n\n await withSpinner({\n message: `Writing ${KUBB_CONFIG_FILENAME}`,\n promise: dryRun.run(async () => void (await write(configPath, buildConfig(choices))), { message: `write ${KUBB_CONFIG_FILENAME}` }),\n done: () => `Wrote ${KUBB_CONFIG_FILENAME}`,\n failed: `Could not write ${KUBB_CONFIG_FILENAME}`,\n plain: yes,\n })\n\n const scriptAdded = await dryRun.run(() => addGenerateScript(cwd), {\n message: 'add a generate script to package.json',\n resolve: async () => (await generateScript(cwd)) === undefined,\n })\n if (scriptAdded && !yes) logStep('Added \"generate\": \"kubb generate\" to package.json')\n\n const script = scriptAdded ? 'kubb generate' : await generateScript(cwd)\n const runStart = process.hrtime()\n try {\n await dryRun.run(\n () =>\n withSpinner({\n message: 'Running the first generation',\n promise: firstRun(configPath),\n done: (files) =>\n yes\n ? `Generated ${pluralize(files, 'file')} in ${choices.outputPath}`\n : `First run ${pluralize(files, 'file')} in ${choices.outputPath} · ${formatMs(getElapsedMs(runStart))}`,\n failed: 'First run failed',\n plain: yes,\n }),\n { message: 'run the first generation', resolve: () => 0 },\n )\n } catch (error) {\n logError(error instanceof Error ? error.message : String(error))\n const message = `Kubb is set up, but the first run failed. Fix the error, then run ${generateCommand({ packageManager, script, watch: false })}.`\n if (yes) console.log(message)\n else logOutro(styleText('yellow', message))\n process.exitCode = 1\n return\n }\n\n if (yes) {\n console.log(`Kubb is set up. Run ${generateCommand({ packageManager, script, watch: false })} after changing the spec.`)\n return\n }\n logOutro(`${styleText('green', '✓ Kubb is set up')}\\n ${styleText('dim', 'Next')} ${generateCommand({ packageManager, script, watch: true })}`)\n } catch (error) {\n logError(styleText('red', 'An error occurred during initialization'))\n if (error instanceof Error) {\n logError(error.message)\n }\n process.exit(1)\n }\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'init',\n description: 'Set up a config, install plugins, and run the first generation.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --yes --input ./openapi.yaml --plugins ts,zod --output src/api',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n 'kubb init --yes --dry-run',\n ].join('\\n'),\n toKebab: true,\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use the detected spec, the default plugin, and the default output folder',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated Kubb registry ids of the plugins to add, the same ids `kubb add` takes (plugin-ts, plugin-zod, acme/plugin-x), or short names (ts, zod)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n run: ({ values, extensions }) => run({ yes: values.yes, input: values.input, output: values.output, plugins: values.plugins, dryRun: extensions[dryRunId] }),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAgB,mBAAmB,EAAE,WAAW,cAAiE;CAC/G,OAAO;;;YAGG,UAAU;;aAET,WAAW;;;;;;AAMxB;;ACoBA,SAAS,cAAc,UAAU,uBAA8B;CAC7D,MAAM,OAAO,OAAO;CACpB,QAAQ,KAAK,CAAC;AAChB;AAEA,SAAS,OAAU,OAA8B;CAC/C,IAAI,MAAM,SAAS,KAAK,GAAG,cAAc;CACzC,OAAO;AACT;;AAiCA,SAAS,YAAY,EAAE,WAAW,YAAY,WAA4B;CACxE,MAAM,EAAE,QAAQ,aAAa,WAAW;EACtC,QAAQ,mBAAmB;GAAE;GAAW;EAAW,CAAC;EACpD,OAAO,QAAQ,KAAK,WAAW;GAAE,WAAW,oBAAoB;GAAY,QAAQ,MAAM,SAAS;EAAQ,EAAE;EAC7G,YAAY,IAAI,IAAI,QAAQ,KAAK,EAAE,UAAU,eAAe,CAAC,SAAS,SAAS;GAAE,SAAS,SAAS;GAAS,SAAS,SAAS;GAAS;EAAS,CAAC,CAAC,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EAEA,IAAI,KAAK;GACP,QAAQ,IAAI,uBAAuB,gBAAgB;IAAE;IAAgB;IAAQ,OAAO;GAAM,CAAC,EAAE,0BAA0B;GACvH;EACF;EACA,SAAS,GAAG,UAAU,SAAS,kBAAkB,EAAE,OAAO,UAAU,OAAO,MAAM,EAAE,IAAI,gBAAgB;GAAE;GAAgB;GAAQ,OAAO;EAAK,CAAC,GAAG;CACnJ,SAAS,OAAO;EACd,SAAS,UAAU,OAAO,yCAAyC,CAAC;EACpE,IAAI,iBAAiB,OACnB,SAAS,MAAM,OAAO;EAExB,QAAQ,KAAK,CAAC;CAChB;AACF;AAEA,MAAa,UAAU,gBAAkD,CAAC,CAAC;CACzE,MAAM;CACN,aAAa;CACb,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,SAAS;CACT,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS;EACX;CACF;CACA,MAAM,EAAE,QAAQ,iBAAiB,IAAI;EAAE,KAAK,OAAO;EAAK,OAAO,OAAO;EAAO,QAAQ,OAAO;EAAQ,SAAS,OAAO;EAAS,QAAQ,WAAW;CAAU,CAAC;AAC7J,CAAC"}
|
|
1
|
+
{"version":3,"file":"run-BJhArAVF.js","names":[],"sources":["../../../internals/shared/src/init.ts","../src/runners/init/run.ts"],"sourcesContent":["/** The `kubb.config.ts` `kubb init` writes before `kubb add` puts each plugin in. */\nexport function generateConfigFile({ inputPath, outputPath }: { inputPath: string; outputPath: string }): string {\n return `import { defineConfig } from 'kubb/config'\n\nexport default defineConfig({\n input: '${inputPath}',\n output: {\n path: '${outputPath}',\n clean: true,\n },\n plugins: [],\n})\n`\n}\n","import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport type { DryRunExtension } from '@gunshi/plugin-dryrun'\nimport { defineWithTypes } from 'gunshi'\nimport { resolveCommand } from 'package-manager-detector'\nimport { ConfigEditOperation, editConfig, generateConfigFile, initDefaults, KUBB_CONFIG_FILENAME, KUBB_PACKAGE_NAME } from '@internals/shared'\nimport { exists, formatMs, getElapsedMs, write } from '@internals/utils'\nimport { createKubb, Diagnostics, type RegistryEntry } from '@kubb/core'\nimport { dryRunId, type DryRunExtensions } from '../../commands/shared.ts'\nimport { getConfigs } from '../../config.ts'\nimport { isHttpUrl, pluralize } from '../../ui/text.ts'\nimport { isInteractiveRun, logIntro, logOutro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { withSpinner } from '../../ui/spinner.ts'\nimport { fetchRegistryIndex, incompatibility, installSpec, registryUrl } from '../../utils/registry.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\nimport {\n addGenerateScript,\n detectPackageManager,\n findPlugin,\n findSpecFiles,\n generateScript,\n initPackageJson,\n installPackages,\n missingPluginDependencies,\n type PackageManagerInfo,\n parsePluginsFlag,\n readSpecInfo,\n} from './utils.ts'\nimport { version } from '../../../package.json'\n\nfunction cancelAndExit(message = 'Operation canceled.'): never {\n clack.cancel(message)\n process.exit(0)\n}\n\nfunction unwrap<T>(value: T): Exclude<T, symbol> {\n if (clack.isCancel(value)) cancelAndExit()\n return value as Exclude<T, symbol>\n}\n\ntype InitOptions = {\n /**\n * When `true`, skips all interactive prompts and uses the detected or default values.\n */\n yes: boolean\n /**\n * Input path flag value from `--input`. When provided, skips the input prompt.\n */\n input?: string\n /**\n * Output directory flag value from `--output`. When provided, skips the output prompt.\n */\n output?: string\n /**\n * Comma-separated plugin list from `--plugins`, e.g. `'plugin-ts,zod'`. When provided, skips the plugin selection prompt.\n */\n plugins?: string\n /**\n * Dry-run extension from `@gunshi/plugin-dryrun`. When enabled, package installation, file\n * writes, and the first run are skipped.\n */\n dryRun: DryRunExtension\n}\n\ntype Choices = {\n inputPath: string\n outputPath: string\n plugins: Array<RegistryEntry>\n}\n\n/** The full `kubb.config.ts` for `choices`, with each plugin added the way `kubb add` adds it. */\nfunction buildConfig({ inputPath, outputPath, plugins }: Choices): string {\n const { source, outcomes } = editConfig({\n source: generateConfigFile({ inputPath, outputPath }),\n edits: plugins.map((entry) => ({ operation: ConfigEditOperation.ADD_PLUGIN, plugin: entry.artifact.package })),\n extensions: new Map(plugins.map(({ artifact, manifest }) => [artifact.package, { package: artifact.package, version: artifact.version, manifest }])),\n })\n const failed = outcomes.find((outcome) => !outcome.applied)\n if (failed && failed.edit.operation === ConfigEditOperation.ADD_PLUGIN)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `Could not add ${failed.edit.plugin} to ${KUBB_CONFIG_FILENAME}: ${failed.reason}`,\n help: `Run kubb init without that plugin, then add it with kubb add.`,\n })\n return source\n}\n\n/** Generates from the config at `configPath` without reporters, and returns how many files it wrote. */\nasync function firstRun(configPath: string): Promise<number> {\n const { configs } = await getConfigs({ configPath })\n let files = 0\n for (const config of configs) {\n const result = await createKubb(config).generate()\n if (!result.success) throw new Error(result.diagnostics.flatMap((diagnostic) => (diagnostic.severity === 'error' ? [diagnostic.message] : [])).join('\\n'))\n files += result.files.length\n }\n return files\n}\n\n/** The command that runs `kubb generate`: the `generate` script when it runs Kubb, otherwise `npx kubb generate`. */\nfunction generateCommand({ packageManager, script, watch }: { packageManager: PackageManagerInfo; script: string | undefined; watch: boolean }): string {\n if (script !== 'kubb generate') return `npx kubb generate${watch ? ' --watch' : ''}`\n const { command, args } = resolveCommand(packageManager.agent, 'run', watch ? ['generate', '--watch'] : ['generate'])!\n return [command, ...args].join(' ')\n}\n\n/**\n * Runs the Kubb setup wizard: detects the package manager and specs, asks for the spec, plugins, and\n * output folder, shows the config for review, then installs, writes `kubb.config.ts`, adds a\n * `generate` script, and runs the first generation.\n * Pass `yes: true` to skip all prompts and print one line per step.\n */\nexport async function run({ yes, input: inputFlag, output: outputFlag, plugins: pluginsFlag, dryRun }: InitOptions): Promise<void> {\n const cwd = process.cwd()\n\n if (!yes) logIntro({ title: isInteractiveRun({ yes, dryRun: dryRun.enabled }) ? undefined : 'Set up Kubb' })\n\n try {\n // Start the registry fetch now but await it only at the plugin step, so the first prompt never waits on the network\n const registry = fetchRegistryIndex({ registry: registryUrl() }).then((entries) =>\n entries.filter((entry) => entry.kind === 'plugin' && !incompatibility(entry.manifest)),\n )\n registry.catch(() => {})\n\n if (!(await exists(path.join(cwd, 'package.json')))) {\n if (!yes) {\n const shouldInit = unwrap(await clack.confirm({ message: 'No package.json found. Would you like to create one?', initialValue: true }))\n if (!shouldInit) cancelAndExit()\n }\n\n const packageManager = await detectPackageManager(cwd)\n await withSpinner({\n message: `Initializing package.json with ${packageManager.name}`,\n promise: initPackageJson(cwd, packageManager),\n done: () => `Created package.json with ${packageManager.name}`,\n failed: 'Could not create package.json',\n plain: yes,\n })\n }\n\n const packageManager = await detectPackageManager(cwd)\n const specs = await findSpecFiles(cwd)\n\n if (!yes) {\n logStep(`Package manager ${packageManager.name}`)\n if (specs[0]) {\n const { version: specVersion, operations } = await readSpecInfo(path.join(cwd, specs[0]))\n const details = [\n specs[0].slice(2),\n specVersion ? `${specVersion.startsWith('2') ? 'Swagger' : 'OpenAPI'} ${specVersion}` : undefined,\n operations === undefined ? undefined : pluralize(operations, 'operation'),\n specs.length > 1 ? `+${specs.length - 1} more` : undefined,\n ]\n logStep(`Found ${details.filter(Boolean).join(' · ')}`)\n }\n }\n\n // `--plugins` and `--yes` need the registry before any prompt; the interactive path reads it at the plugin step\n const plugins = pluginsFlag || yes ? await registry : undefined\n const defaultPlugins = (entries: Array<RegistryEntry>) => initDefaults.plugins.flatMap((id) => findPlugin({ plugins: entries, id }) ?? [])\n\n const flagPlugins = pluginsFlag && plugins ? parsePluginsFlag({ plugins, value: pluginsFlag }) : undefined\n\n let choices: Choices = {\n inputPath: inputFlag ?? specs[0] ?? initDefaults.inputPath,\n outputPath: outputFlag ?? initDefaults.outputPath,\n plugins: flagPlugins ?? (plugins ? defaultPlugins(plugins) : []),\n }\n if (yes && !choices.plugins.length) {\n throw new Error('The registry has no default plugin. Pass --plugins to choose one.')\n }\n\n async function askInput(current: string): Promise<string> {\n const choice = specs.length\n ? unwrap(\n await clack.select({\n message: 'Which spec should Kubb read?',\n options: [\n ...specs.map((spec) => ({ value: spec, label: spec, hint: 'found in this repo' })),\n { value: 'url', label: 'A URL' },\n { value: 'file', label: 'Another file' },\n ],\n initialValue: specs.includes(current) ? current : isHttpUrl(current) ? 'url' : 'file',\n }),\n )\n : isHttpUrl(current)\n ? 'url'\n : 'file'\n if (specs.includes(choice)) return choice\n const isUrl = choice === 'url'\n const initial = isUrl === isHttpUrl(current) && !specs.includes(current) ? current : undefined\n return unwrap(\n await clack.text({\n message: isUrl ? 'Spec URL' : 'Spec path',\n placeholder: isUrl ? 'https://example.com/openapi.yaml' : initDefaults.inputPath,\n initialValue: initial,\n defaultValue: isUrl ? undefined : initDefaults.inputPath,\n validate: (value) => {\n if (isUrl && !isHttpUrl(value ?? '')) return 'Enter an http(s) URL'\n },\n }),\n )\n }\n\n async function askPlugins(previous: Array<RegistryEntry>): Promise<Array<RegistryEntry>> {\n const plugins = await registry\n const current = previous.length ? previous : defaultPlugins(plugins)\n const width = Math.max(...plugins.map((entry) => entry.manifest.displayName.length))\n const nameWidth = Math.max(...plugins.map((entry) => entry.manifest.name.length))\n const values = unwrap(\n await clack.multiselect({\n message: 'What should Kubb generate?',\n options: plugins.map(({ id, manifest }) => ({\n value: id,\n label: `${manifest.displayName.padEnd(width)} ${styleText('dim', manifest.name.padEnd(nameWidth))}`.trimEnd(),\n })),\n initialValues: current.map((entry) => entry.id),\n required: true,\n }),\n )\n return plugins.filter((entry) => values.includes(entry.id))\n }\n\n // Flags for all three choices leave nothing to ask or review, as before the review step existed\n const answered = yes || Boolean(inputFlag && outputFlag && pluginsFlag)\n if (!answered) {\n let firstPass = true\n while (true) {\n // The first pass skips the questions a flag answered; \"Change a choice\" asks them all again.\n choices = {\n inputPath: firstPass && inputFlag ? inputFlag : await askInput(choices.inputPath),\n plugins: firstPass && flagPlugins ? flagPlugins : await askPlugins(choices.plugins),\n outputPath:\n firstPass && outputFlag\n ? outputFlag\n : unwrap(await clack.text({ message: 'Output folder', placeholder: choices.outputPath, defaultValue: choices.outputPath })),\n }\n firstPass = false\n const missing = missingPluginDependencies(choices.plugins.map((entry) => entry.manifest))\n if (missing.length) {\n logWarn(`${missing.join('\\n')}\\nAdd the missing plugins.`)\n continue\n }\n const config = buildConfig(choices)\n const packages = [KUBB_PACKAGE_NAME, ...choices.plugins.map((entry) => entry.artifact.package)]\n logStep(`Review ${KUBB_CONFIG_FILENAME}`)\n logBlock([...config.trimEnd().split('\\n'), '', `${styleText('dim', 'Installs')} ${packages.join(' ')} with ${packageManager.name}`])\n const configExists = await exists(path.join(cwd, KUBB_CONFIG_FILENAME))\n const confirmed = unwrap(\n await clack.select({\n message: configExists ? `${KUBB_CONFIG_FILENAME} exists. Overwrite it?` : 'Create it?',\n options: [\n { value: true, label: 'Yes' },\n { value: false, label: 'Change a choice' },\n ],\n }),\n )\n if (confirmed) break\n }\n }\n\n // Check the selection against the plugins' manifests before installing anything\n const missing = missingPluginDependencies(choices.plugins.map((entry) => entry.manifest))\n if (missing.length) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.missingDependency,\n severity: 'error',\n message: `${missing.join('\\n')}\\nAdd the missing plugins and run kubb init again.`,\n })\n }\n\n const configPath = path.join(cwd, KUBB_CONFIG_FILENAME)\n if (answered && !yes && (await exists(configPath))) {\n const overwrite = unwrap(await clack.confirm({ message: `${KUBB_CONFIG_FILENAME} exists. Overwrite it?`, initialValue: false }))\n if (!overwrite) cancelAndExit('Keeping existing configuration.')\n }\n\n // Install `kubb` at the running CLI's version and each plugin at the version the registry pins\n const packagesToInstall = [`${KUBB_PACKAGE_NAME}@${version}`, ...choices.plugins.map((entry) => installSpec(entry.artifact))]\n const packageNames = [KUBB_PACKAGE_NAME, ...choices.plugins.map((entry) => entry.artifact.package)]\n const dry = { message: `install ${packagesToInstall.length} packages with ${packageManager.name}` }\n if (yes) {\n await withSpinner({\n message: '',\n promise: dryRun.run(() => installPackages(packagesToInstall, packageManager, cwd), dry),\n done: () => `Installed ${packageNames.join(' ')} with ${packageManager.name}`,\n plain: true,\n })\n } else {\n await installWithSpinner({\n packages: packagesToInstall,\n names: `${packagesToInstall.length} packages`,\n packageManager,\n cwd,\n install: async (packages, packageManager, cwd, onLine) => void (await dryRun.run(() => installPackages(packages, packageManager, cwd, onLine), dry)),\n })\n }\n\n await withSpinner({\n message: `Writing ${KUBB_CONFIG_FILENAME}`,\n promise: dryRun.run(async () => void (await write(configPath, buildConfig(choices))), { message: `write ${KUBB_CONFIG_FILENAME}` }),\n done: () => `Wrote ${KUBB_CONFIG_FILENAME}`,\n failed: `Could not write ${KUBB_CONFIG_FILENAME}`,\n plain: yes,\n })\n\n const scriptAdded = await dryRun.run(() => addGenerateScript(cwd), {\n message: 'add a generate script to package.json',\n resolve: async () => (await generateScript(cwd)) === undefined,\n })\n if (scriptAdded && !yes) logStep('Added \"generate\": \"kubb generate\" to package.json')\n\n const script = scriptAdded ? 'kubb generate' : await generateScript(cwd)\n const runStart = process.hrtime()\n try {\n await dryRun.run(\n () =>\n withSpinner({\n message: 'Running the first generation',\n promise: firstRun(configPath),\n done: (files) =>\n yes\n ? `Generated ${pluralize(files, 'file')} in ${choices.outputPath}`\n : `First run ${pluralize(files, 'file')} in ${choices.outputPath} · ${formatMs(getElapsedMs(runStart))}`,\n failed: 'First run failed',\n plain: yes,\n }),\n { message: 'run the first generation', resolve: () => 0 },\n )\n } catch (error) {\n logError(error instanceof Error ? error.message : String(error))\n const message = `Kubb is set up, but the first run failed. Fix the error, then run ${generateCommand({ packageManager, script, watch: false })}.`\n if (yes) console.log(message)\n else logOutro(styleText('yellow', message))\n process.exitCode = 1\n return\n }\n\n if (yes) {\n console.log(`Kubb is set up. Run ${generateCommand({ packageManager, script, watch: false })} after changing the spec.`)\n return\n }\n logOutro(`${styleText('green', '✓ Kubb is set up')}\\n ${styleText('dim', 'Next')} ${generateCommand({ packageManager, script, watch: true })}`)\n } catch (error) {\n logError(styleText('red', 'An error occurred during initialization'))\n if (error instanceof Error) {\n logError(error.message)\n }\n process.exit(1)\n }\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'init',\n description: 'Set up a config, install plugins, and run the first generation.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --yes --input ./openapi.yaml --plugins ts,zod --output src/api',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n 'kubb init --yes --dry-run',\n ].join('\\n'),\n toKebab: true,\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use the detected spec, the default plugin, and the default output folder',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated Kubb registry ids of the plugins to add, the same ids `kubb add` takes (plugin-ts, plugin-zod, acme/plugin-x), or short names (ts, zod)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n run: ({ values, extensions }) => run({ yes: values.yes, input: values.input, output: values.output, plugins: values.plugins, dryRun: extensions[dryRunId] }),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAgB,mBAAmB,EAAE,WAAW,cAAiE;CAC/G,OAAO;;;YAGG,UAAU;;aAET,WAAW;;;;;;AAMxB;;ACoBA,SAAS,cAAc,UAAU,uBAA8B;CAC7D,MAAM,OAAO,OAAO;CACpB,Q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CACA,MAAM,EAAE,QAAQ,iBAAiB,IAAI;EAAE,KAAK,OAAO;EAAK,OAAO,OAAO;EAAO,QAAQ,OAAO;EAAQ,SAAS,OAAO;EAAS,QAAQ,WAAW;CAAU,CAAC;AAC7J,CAAC"}
|
|
@@ -29,7 +29,7 @@ async function regenerate({ cwd, configPath }) {
|
|
|
29
29
|
try {
|
|
30
30
|
const [{ getConfigs }, { generate }, { default: setupReporters }] = await Promise.all([
|
|
31
31
|
import("./config-BKi_vTvh.js"),
|
|
32
|
-
import("./run-
|
|
32
|
+
import("./run-6KAmg90E.js"),
|
|
33
33
|
import("./reporters-BDzKLpyo.js")
|
|
34
34
|
]);
|
|
35
35
|
const { configs } = await getConfigs({ configPath });
|
|
@@ -231,4 +231,4 @@ const command = defineWithTypes()({
|
|
|
231
231
|
});
|
|
232
232
|
export { command, run };
|
|
233
233
|
|
|
234
|
-
//# sourceMappingURL=run-
|
|
234
|
+
//# sourceMappingURL=run-B_NPBulV.js.map
|