@kubb/cli 5.18.7 → 5.18.8
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-Cbt_dJE6.cjs → Telemetry-CBzCK4kO.cjs} +2 -2
- package/dist/{Telemetry-Cbt_dJE6.cjs.map → Telemetry-CBzCK4kO.cjs.map} +1 -1
- package/dist/{Telemetry-Bf16psPO.js → Telemetry-DUl_hxVn.js} +2 -2
- package/dist/{Telemetry-Bf16psPO.js.map → Telemetry-DUl_hxVn.js.map} +1 -1
- package/dist/{background-Cvoxk_DQ.js → background-CA9lRKAK.js} +2 -2
- package/dist/{background-Cvoxk_DQ.js.map → background-CA9lRKAK.js.map} +1 -1
- package/dist/{background-JyYJdws1.js → background-DK3HLyNk.js} +1 -1
- package/dist/{background-3TB5Cgkv.cjs → background-fhpYDuSs.cjs} +2 -2
- package/dist/{background-3TB5Cgkv.cjs.map → background-fhpYDuSs.cjs.map} +1 -1
- package/dist/config-BKi_vTvh.js +1 -0
- package/dist/{config-DJtqFNG2.cjs → config-BU9xeaGq.cjs} +2 -2
- package/dist/{config-DJtqFNG2.cjs.map → config-BU9xeaGq.cjs.map} +1 -1
- package/dist/{config-BL4UlCHs.js → config-CGcQTdZV.js} +2 -2
- package/dist/{config-BL4UlCHs.js.map → config-CGcQTdZV.js.map} +1 -1
- package/dist/{config-BIv45u1Z.cjs → config-CkTrJD0E.cjs} +2 -2
- package/dist/{config-BIv45u1Z.cjs.map → config-CkTrJD0E.cjs.map} +1 -1
- package/dist/{config-BqDpLCPu.js → config-re864UnO.js} +4 -4
- package/dist/config-re864UnO.js.map +1 -0
- package/dist/{configFile-C_7uzuGV.cjs → configFile-BQ-Pp7i_.cjs} +3 -3
- package/dist/{configFile-C_7uzuGV.cjs.map → configFile-BQ-Pp7i_.cjs.map} +1 -1
- package/dist/{configFile-B2EIouxg.js → configFile-CPXDgTC2.js} +3 -3
- package/dist/{configFile-B2EIouxg.js.map → configFile-CPXDgTC2.js.map} +1 -1
- package/dist/{fs-j84Tqpbx.js → fs-CmODfKN-.js} +25 -6
- package/dist/fs-CmODfKN-.js.map +1 -0
- package/dist/index.cjs +12 -12
- package/dist/index.js +12 -12
- package/dist/{installWithSpinner-YEtb8cNf.cjs → installWithSpinner-DZDlVp1J.cjs} +3 -3
- package/dist/{installWithSpinner-YEtb8cNf.cjs.map → installWithSpinner-DZDlVp1J.cjs.map} +1 -1
- package/dist/{installWithSpinner-C4gKZ7r5.js → installWithSpinner-gv_OWgww.js} +2 -2
- package/dist/{installWithSpinner-C4gKZ7r5.js.map → installWithSpinner-gv_OWgww.js.map} +1 -1
- package/dist/{mascot-ZEiXQ_LT.cjs → mascot-CLw0Qmln.cjs} +10 -6
- package/dist/{mascot-ZEiXQ_LT.cjs.map → mascot-CLw0Qmln.cjs.map} +1 -1
- package/dist/{mascot-kx6WDntR.js → mascot-b4yXsKwl.js} +10 -6
- package/dist/mascot-b4yXsKwl.js.map +1 -0
- package/dist/{mcp-CIMQ8g_J.cjs → mcp-BBD4kdKF.cjs} +2 -2
- package/dist/{mcp-CIMQ8g_J.cjs.map → mcp-BBD4kdKF.cjs.map} +1 -1
- package/dist/{mcp-DFPXRd6M.js → mcp-CQXp9pcW.js} +2 -2
- package/dist/{mcp-DFPXRd6M.js.map → mcp-CQXp9pcW.js.map} +1 -1
- package/dist/package-CdMFA8OG.js +5 -0
- package/dist/package-CdMFA8OG.js.map +1 -0
- package/dist/{package-C482iN7Y.cjs → package-DXNoJQYa.cjs} +2 -2
- package/dist/package-DXNoJQYa.cjs.map +1 -0
- package/dist/{reporters-yVmLpEoU.cjs → reporters-CaJ8brYA.cjs} +253 -101
- package/dist/reporters-CaJ8brYA.cjs.map +1 -0
- package/dist/{reporters-DJPMb1-j.js → reporters-CzxaQ_bD.js} +1 -1
- package/dist/{reporters-De3ynr5a.js → reporters-DeruUk9K.js} +255 -103
- package/dist/reporters-DeruUk9K.js.map +1 -0
- package/dist/{run-jGpJxxmr.js → run-96_svbr3.js} +5 -5
- package/dist/{run-jGpJxxmr.js.map → run-96_svbr3.js.map} +1 -1
- package/dist/{run-BGkdpZwR.cjs → run-BIgV2zvB.cjs} +2 -2
- package/dist/{run-BGkdpZwR.cjs.map → run-BIgV2zvB.cjs.map} +1 -1
- package/dist/{run-hqWFyi0N.cjs → run-BSA2x4iE.cjs} +8 -8
- package/dist/{run-hqWFyi0N.cjs.map → run-BSA2x4iE.cjs.map} +1 -1
- package/dist/{run-DYr--XFw.js → run-Bi8hhAzv.js} +1 -1
- package/dist/{run-D-3F2mhJ.cjs → run-Bxqg0GuI.cjs} +4 -4
- package/dist/{run-D-3F2mhJ.cjs.map → run-Bxqg0GuI.cjs.map} +1 -1
- package/dist/{run-DD1VdcpX.cjs → run-CIEKCdM-.cjs} +8 -8
- package/dist/{run-DD1VdcpX.cjs.map → run-CIEKCdM-.cjs.map} +1 -1
- package/dist/{run-BVz9vmbt.js → run-CYdKWpyH.js} +6 -6
- package/dist/{run-BVz9vmbt.js.map → run-CYdKWpyH.js.map} +1 -1
- package/dist/{run-B-PAQSVx.js → run-CmHjIMpd.js} +7 -7
- package/dist/{run-B-PAQSVx.js.map → run-CmHjIMpd.js.map} +1 -1
- package/dist/{run-nSTiS72Z.js → run-CpyFU0RM.js} +8 -8
- package/dist/{run-nSTiS72Z.js.map → run-CpyFU0RM.js.map} +1 -1
- package/dist/{run-DwPkySke.cjs → run-DLRu4z5Z.cjs} +5 -5
- package/dist/{run-DwPkySke.cjs.map → run-DLRu4z5Z.cjs.map} +1 -1
- package/dist/{run-DVbHd7qm.js → run-Df4PGOFX.js} +74 -23
- package/dist/run-Df4PGOFX.js.map +1 -0
- package/dist/{run-D7AQwBWZ.cjs → run-GdctJlXN.cjs} +6 -6
- package/dist/{run-D7AQwBWZ.cjs.map → run-GdctJlXN.cjs.map} +1 -1
- package/dist/{run-BjWqOCAj.js → run-ORjkOWFp.js} +2 -2
- package/dist/{run-BjWqOCAj.js.map → run-ORjkOWFp.js.map} +1 -1
- package/dist/{run-w0kr76jl.cjs → run-OqiJknWr.cjs} +9 -9
- package/dist/{run-w0kr76jl.cjs.map → run-OqiJknWr.cjs.map} +1 -1
- package/dist/{run-Bc34cwzh.js → run-U2Ze_QP4.js} +8 -8
- package/dist/{run-Bc34cwzh.js.map → run-U2Ze_QP4.js.map} +1 -1
- package/dist/{run-D1hHaTDJ.js → run-ixh050Ip.js} +4 -4
- package/dist/{run-D1hHaTDJ.js.map → run-ixh050Ip.js.map} +1 -1
- package/dist/{run-puNdxNuf.cjs → run-k-LqKkgU.cjs} +74 -23
- package/dist/run-k-LqKkgU.cjs.map +1 -0
- package/dist/{snapshot-DRyGykFq.cjs → snapshot-C-ge8g3_.cjs} +5 -5
- package/dist/{snapshot-DRyGykFq.cjs.map → snapshot-C-ge8g3_.cjs.map} +1 -1
- package/dist/{snapshot-eO0_VdUy.js → snapshot-CSacL1qI.js} +5 -5
- package/dist/{snapshot-eO0_VdUy.js.map → snapshot-CSacL1qI.js.map} +1 -1
- package/dist/{spinner-CdX9Noe9.cjs → spinner-D584jFAz.cjs} +24 -6
- package/dist/spinner-D584jFAz.cjs.map +1 -0
- package/dist/{status-NqYVjTY8.js → status-Bq-Bjo2n.js} +3 -3
- package/dist/{status-NqYVjTY8.js.map → status-Bq-Bjo2n.js.map} +1 -1
- package/dist/{status-DICY3TJQ.cjs → status-D-Osmkhr.cjs} +3 -3
- package/dist/{status-DICY3TJQ.cjs.map → status-D-Osmkhr.cjs.map} +1 -1
- package/dist/{studio-gu56JqH0.js → studio-BBXKjMN-.js} +12 -12
- package/dist/{studio-gu56JqH0.js.map → studio-BBXKjMN-.js.map} +1 -1
- package/dist/{studio-BfR2KY0b.cjs → studio-BZ53idqa.cjs} +12 -12
- package/dist/{studio-BfR2KY0b.cjs.map → studio-BZ53idqa.cjs.map} +1 -1
- package/dist/studioWorker.js +2 -2
- package/dist/{utils-DGopc0Bo.js → utils-BVccq6W0.js} +3 -3
- package/dist/{utils-DGopc0Bo.js.map → utils-BVccq6W0.js.map} +1 -1
- package/dist/{utils-D19HX-lE.cjs → utils-C9fYoqP2.cjs} +4 -4
- package/dist/{utils-D19HX-lE.cjs.map → utils-C9fYoqP2.cjs.map} +1 -1
- package/dist/{validate-DoSQad-i.js → validate-BuStuH_z.js} +2 -2
- package/dist/{validate-DoSQad-i.js.map → validate-BuStuH_z.js.map} +1 -1
- package/dist/{validate-BXSS6BSO.cjs → validate-rr0LpFhN.cjs} +2 -2
- package/dist/{validate-BXSS6BSO.cjs.map → validate-rr0LpFhN.cjs.map} +1 -1
- package/package.json +7 -7
- package/dist/config-BqDpLCPu.js.map +0 -1
- package/dist/config-CGpzjjPV.js +0 -1
- package/dist/fs-j84Tqpbx.js.map +0 -1
- package/dist/mascot-kx6WDntR.js.map +0 -1
- package/dist/package-C482iN7Y.cjs.map +0 -1
- package/dist/package-DqSfSjr4.js +0 -5
- package/dist/package-DqSfSjr4.js.map +0 -1
- package/dist/reporters-De3ynr5a.js.map +0 -1
- package/dist/reporters-yVmLpEoU.cjs.map +0 -1
- package/dist/run-DVbHd7qm.js.map +0 -1
- package/dist/run-puNdxNuf.cjs.map +0 -1
- package/dist/spinner-CdX9Noe9.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studio-gu56JqH0.js","names":["command","command","connectCommand","command","command","command","command","connectCommand","command","connectCommand","startCommand","loginCommand","logoutCommand","statusCommand","permissionsCommand","snapshotCommand"],"sources":["../src/commands/studio/studioCommand.ts","../src/commands/studio/connect.ts","../src/commands/studio/login.ts","../src/commands/studio/logout.ts","../src/commands/studio/permissions.ts","../src/commands/studio/snapshot.ts","../src/commands/studio/background.ts","../src/commands/studio/status.ts","../src/commands/studio/index.ts"],"sourcesContent":["import { type Args, define } from 'gunshi'\nimport type { StudioOptions, StudioValues } from '../../runners/studio/run.ts'\n\n/**\n * Defines a `kubb studio` subcommand. The runner, and with it `@kubb/studio`, loads only when the\n * command runs, so `kubb --help` never does.\n */\nexport function studioCommand({\n action,\n block,\n ...definition\n}: {\n name: string\n description: string\n examples?: string\n args?: Args\n /** Opens a block a later `logOutro` closes, for a command that keeps running. */\n block?: boolean\n /** The command body, given the options built from its flags. */\n action: (options: StudioOptions) => Promise<unknown>\n}) {\n return define({\n ...definition,\n toKebab: true,\n async run({ values }) {\n const { runStudio } = await import('../../runners/studio/run.ts')\n await runStudio(values as StudioValues, action, { block })\n },\n })\n}\n","import { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'connect',\n description: 'Connect this project to Kubb Studio and generate from the browser.',\n examples: [\n 'kubb studio connect',\n 'kubb studio connect --allow-read',\n 'kubb studio connect --allow-write --allow-exec',\n 'kubb studio connect --url http://localhost:3000',\n ].join('\\n'),\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n open: {\n type: 'boolean',\n description: 'Open the approval page in a browser while pairing',\n default: true,\n negatable: true,\n },\n ...logLevelArg,\n },\n block: true,\n async action(options) {\n const { connect } = await import('../../runners/studio/run.ts')\n await connect(options)\n },\n})\n","import { command as connectCommand } from './connect.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'login',\n description: 'Pair this machine with Kubb Studio without connecting.',\n examples: ['kubb studio login', 'kubb studio login --url http://localhost:3000'].join('\\n'),\n args: connectCommand.args,\n async action(options) {\n const { login } = await import('../../runners/studio/run.ts')\n await login(options)\n },\n})\n","import { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'logout',\n description: 'Forget the stored Kubb Studio token.',\n examples: 'kubb studio logout',\n args: {},\n async action() {\n const { stopWorker } = await import('../../runners/studio/background.ts')\n const { clearCredentials } = await import('../../runners/studio/credentials.ts')\n await stopWorker()\n await clearCredentials()\n console.log('Signed out of Kubb Studio.')\n },\n})\n","import path from 'node:path'\nimport process from 'node:process'\nimport { findConfigFile } from '@internals/shared'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'permissions',\n description: 'Change what Kubb Studio may do in this project.',\n examples: 'kubb studio permissions',\n args: {},\n async action(options) {\n const { readCredentials } = await import('../../runners/studio/credentials.ts')\n const { resolvePermissions } = await import('../../runners/studio/run.ts')\n const { canUseTTY } = await import('../../utils/env.ts')\n\n const credentials = await readCredentials()\n if (!credentials) throw new Error('This project is not paired with Kubb Studio. Run `kubb studio` first.')\n if (!canUseTTY()) throw new Error('Changing permissions needs an interactive terminal.')\n\n const configFile = findConfigFile()\n await resolvePermissions(options, credentials, configFile && path.relative(process.cwd(), configFile), { edit: true })\n console.log(\n 'Permissions saved. A running connection keeps the old ones until you restart it: press Ctrl+C and run `kubb studio` again, or run `kubb studio stop`, then `kubb studio start`. Keep `--url` and `--config`, and leave out the `--allow-*` flag of any permission you turned off, since a flag grants it anyway.',\n )\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs } from '../shared.ts'\n\nexport const command = define({\n name: 'snapshot',\n description: 'Generate and publish a Kubb Studio snapshot from CI.',\n examples: ['kubb studio snapshot', 'kubb studio snapshot --json'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n id: {\n type: 'string',\n description: 'Stable identity for the CI agent, such as a pull request. Auto-detected on GitHub Actions, GitLab CI, Bitbucket Pipelines and CircleCI',\n },\n baseId: {\n type: 'string',\n description:\n \"Identity of another CI agent, such as the base branch's, to also compare this snapshot with. Auto-detected on GitHub pull requests and GitLab merge requests\",\n toKebab: true,\n },\n name: {\n type: 'string',\n description: 'Package name for the generated tarball. Defaults to the name in package.json',\n },\n packageVersion: {\n type: 'string',\n description: 'Package version for the generated tarball. Defaults to the version in package.json',\n toKebab: true,\n },\n json: {\n type: 'boolean',\n description: 'Print the result as one JSON object instead of a summary',\n default: false,\n },\n ...logLevelArg,\n },\n async run(ctx) {\n const { runner } = await import('../../runners/studio/snapshot.ts')\n await runner(ctx)\n },\n})\n","import { define } from 'gunshi'\nimport { command as connectCommand } from './connect.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'start',\n description: 'Keep this project connected to Kubb Studio in the background.',\n args: connectCommand.args,\n async action(options) {\n const { startWorker } = await import('../../runners/studio/background.ts')\n await startWorker(options)\n },\n})\n\nexport const stopCommand = define({\n name: 'stop',\n description: \"Stop this project's background connection and keep its pairing.\",\n async run() {\n const { stopWorker } = await import('../../runners/studio/background.ts')\n await stopWorker()\n console.log('Background connection stopped.')\n },\n})\n","import process from 'node:process'\nimport { studioConnectionArgs } from '../shared.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'status',\n description: 'Show the project worker, Kubb Studio pairing, and saved permissions.',\n examples: 'kubb studio status',\n args: { url: studioConnectionArgs.url },\n async action(options) {\n const { getWorkerLogPath, getWorkerStatus } = await import('../../runners/studio/background.ts')\n const { readCredentials } = await import('../../runners/studio/credentials.ts')\n const { formatStatus } = await import('../../runners/studio/status.ts')\n\n const [worker, credentials] = await Promise.all([getWorkerStatus(), readCredentials()])\n console.log(\n ['', ...formatStatus({ studioUrl: options.studioUrl, credentials, worker, project: process.cwd(), logPath: getWorkerLogPath() }), ''].join('\\n'),\n )\n },\n})\n","import { define } from 'gunshi'\nimport { command as connectCommand } from './connect.ts'\nimport { command as loginCommand } from './login.ts'\nimport { command as logoutCommand } from './logout.ts'\nimport { command as permissionsCommand } from './permissions.ts'\nimport { command as snapshotCommand } from './snapshot.ts'\nimport { command as startCommand, stopCommand } from './background.ts'\nimport { command as statusCommand } from './status.ts'\n\nexport const command = define({\n ...connectCommand,\n name: 'studio',\n description: 'Connect this project to Kubb Studio, or manage its pairing and snapshots.',\n examples: [\n 'kubb studio',\n 'kubb studio --allow-read',\n 'kubb studio login',\n 'kubb studio status',\n 'kubb studio permissions',\n 'kubb studio logout',\n 'kubb studio snapshot',\n ].join('\\n'),\n subCommands: {\n start: startCommand,\n stop: stopCommand,\n connect: connectCommand,\n login: loginCommand,\n logout: logoutCommand,\n status: statusCommand,\n permissions: permissionsCommand,\n snapshot: snapshotCommand,\n },\n})\n\n/**\n * Sends `kubb studio --flag value` to `kubb studio connect`, the same runner. gunshi picks a\n * subcommand from the first token that is not a flag, so `--url http://…` would read the URL as one.\n */\nexport function routeStudioFlags(args: Array<string>): Array<string> {\n const [name, next] = args\n if (name !== 'studio' || !next?.startsWith('-') || next === '--help' || next === '-h') return args\n\n return ['studio', 'connect', ...args.slice(1)]\n}\n"],"mappings":";;;;;;;;;;;AAOA,SAAgB,cAAc,EAC5B,QACA,OACA,GAAG,cAUF;CACD,OAAO,OAAO;EACZ,GAAG;EACH,SAAS;EACT,MAAM,IAAI,EAAE,UAAU;GACpB,MAAM,EAAE,cAAc,MAAM,OAAO;GACnC,MAAM,UAAU,QAAwB,QAAQ,EAAE,MAAM,CAAC;EAC3D;CACF,CAAC;AACH;;AC1BA,MAAaA,YAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,UAAU;EACR;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,MAAM;EACJ,GAAG;EACH,GAAG;EACH,GAAG;EACH,MAAM;GACJ,MAAM;GACN,aAAa;GACb,SAAS;GACT,WAAW;EACb;EACA,GAAG;CACL;CACA,OAAO;CACP,MAAM,OAAO,SAAS;EACpB,MAAM,EAAE,YAAY,MAAM,OAAO;EACjC,MAAM,QAAQ,OAAO;CACvB;AACF,CAAC;;AC1BD,MAAaC,YAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,UAAU,CAAC,qBAAqB,+CAA+C,CAAC,CAAC,KAAK,IAAI;CAC1F,MAAMC,UAAe;CACrB,MAAM,OAAO,SAAS;EACpB,MAAM,EAAE,UAAU,MAAM,OAAO;EAC/B,MAAM,MAAM,OAAO;CACrB;AACF,CAAC;;ACVD,MAAaC,YAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,UAAU;CACV,MAAM,CA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,OAAO;CAE9F,OAAO;EAAC;EAAU;EAAW,GAAG,KAAK,MAAM,CAAC;CAAC;AAC/C"}
|
|
1
|
+
{"version":3,"file":"studio-BBXKjMN-.js","names":["command","command","connectCommand","command","command","command","command","connectCommand","command","connectCommand","startCommand","loginCommand","logoutCommand","statusCommand","permissionsCommand","snapshotCommand"],"sources":["../src/commands/studio/studioCommand.ts","../src/commands/studio/connect.ts","../src/commands/studio/login.ts","../src/commands/studio/logout.ts","../src/commands/studio/permissions.ts","../src/commands/studio/snapshot.ts","../src/commands/studio/background.ts","../src/commands/studio/status.ts","../src/commands/studio/index.ts"],"sourcesContent":["import { type Args, define } from 'gunshi'\nimport type { StudioOptions, StudioValues } from '../../runners/studio/run.ts'\n\n/**\n * Defines a `kubb studio` subcommand. The runner, and with it `@kubb/studio`, loads only when the\n * command runs, so `kubb --help` never does.\n */\nexport function studioCommand({\n action,\n block,\n ...definition\n}: {\n name: string\n description: string\n examples?: string\n args?: Args\n /** Opens a block a later `logOutro` closes, for a command that keeps running. */\n block?: boolean\n /** The command body, given the options built from its flags. */\n action: (options: StudioOptions) => Promise<unknown>\n}) {\n return define({\n ...definition,\n toKebab: true,\n async run({ values }) {\n const { runStudio } = await import('../../runners/studio/run.ts')\n await runStudio(values as StudioValues, action, { block })\n },\n })\n}\n","import { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'connect',\n description: 'Connect this project to Kubb Studio and generate from the browser.',\n examples: [\n 'kubb studio connect',\n 'kubb studio connect --allow-read',\n 'kubb studio connect --allow-write --allow-exec',\n 'kubb studio connect --url http://localhost:3000',\n ].join('\\n'),\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n open: {\n type: 'boolean',\n description: 'Open the approval page in a browser while pairing',\n default: true,\n negatable: true,\n },\n ...logLevelArg,\n },\n block: true,\n async action(options) {\n const { connect } = await import('../../runners/studio/run.ts')\n await connect(options)\n },\n})\n","import { command as connectCommand } from './connect.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'login',\n description: 'Pair this machine with Kubb Studio without connecting.',\n examples: ['kubb studio login', 'kubb studio login --url http://localhost:3000'].join('\\n'),\n args: connectCommand.args,\n async action(options) {\n const { login } = await import('../../runners/studio/run.ts')\n await login(options)\n },\n})\n","import { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'logout',\n description: 'Forget the stored Kubb Studio token.',\n examples: 'kubb studio logout',\n args: {},\n async action() {\n const { stopWorker } = await import('../../runners/studio/background.ts')\n const { clearCredentials } = await import('../../runners/studio/credentials.ts')\n await stopWorker()\n await clearCredentials()\n console.log('Signed out of Kubb Studio.')\n },\n})\n","import path from 'node:path'\nimport process from 'node:process'\nimport { findConfigFile } from '@internals/shared'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'permissions',\n description: 'Change what Kubb Studio may do in this project.',\n examples: 'kubb studio permissions',\n args: {},\n async action(options) {\n const { readCredentials } = await import('../../runners/studio/credentials.ts')\n const { resolvePermissions } = await import('../../runners/studio/run.ts')\n const { canUseTTY } = await import('../../utils/env.ts')\n\n const credentials = await readCredentials()\n if (!credentials) throw new Error('This project is not paired with Kubb Studio. Run `kubb studio` first.')\n if (!canUseTTY()) throw new Error('Changing permissions needs an interactive terminal.')\n\n const configFile = findConfigFile()\n await resolvePermissions(options, credentials, configFile && path.relative(process.cwd(), configFile), { edit: true })\n console.log(\n 'Permissions saved. A running connection keeps the old ones until you restart it: press Ctrl+C and run `kubb studio` again, or run `kubb studio stop`, then `kubb studio start`. Keep `--url` and `--config`, and leave out the `--allow-*` flag of any permission you turned off, since a flag grants it anyway.',\n )\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs } from '../shared.ts'\n\nexport const command = define({\n name: 'snapshot',\n description: 'Generate and publish a Kubb Studio snapshot from CI.',\n examples: ['kubb studio snapshot', 'kubb studio snapshot --json'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n id: {\n type: 'string',\n description: 'Stable identity for the CI agent, such as a pull request. Auto-detected on GitHub Actions, GitLab CI, Bitbucket Pipelines and CircleCI',\n },\n baseId: {\n type: 'string',\n description:\n \"Identity of another CI agent, such as the base branch's, to also compare this snapshot with. Auto-detected on GitHub pull requests and GitLab merge requests\",\n toKebab: true,\n },\n name: {\n type: 'string',\n description: 'Package name for the generated tarball. Defaults to the name in package.json',\n },\n packageVersion: {\n type: 'string',\n description: 'Package version for the generated tarball. Defaults to the version in package.json',\n toKebab: true,\n },\n json: {\n type: 'boolean',\n description: 'Print the result as one JSON object instead of a summary',\n default: false,\n },\n ...logLevelArg,\n },\n async run(ctx) {\n const { runner } = await import('../../runners/studio/snapshot.ts')\n await runner(ctx)\n },\n})\n","import { define } from 'gunshi'\nimport { command as connectCommand } from './connect.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'start',\n description: 'Keep this project connected to Kubb Studio in the background.',\n args: connectCommand.args,\n async action(options) {\n const { startWorker } = await import('../../runners/studio/background.ts')\n await startWorker(options)\n },\n})\n\nexport const stopCommand = define({\n name: 'stop',\n description: \"Stop this project's background connection and keep its pairing.\",\n async run() {\n const { stopWorker } = await import('../../runners/studio/background.ts')\n await stopWorker()\n console.log('Background connection stopped.')\n },\n})\n","import process from 'node:process'\nimport { studioConnectionArgs } from '../shared.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'status',\n description: 'Show the project worker, Kubb Studio pairing, and saved permissions.',\n examples: 'kubb studio status',\n args: { url: studioConnectionArgs.url },\n async action(options) {\n const { getWorkerLogPath, getWorkerStatus } = await import('../../runners/studio/background.ts')\n const { readCredentials } = await import('../../runners/studio/credentials.ts')\n const { formatStatus } = await import('../../runners/studio/status.ts')\n\n const [worker, credentials] = await Promise.all([getWorkerStatus(), readCredentials()])\n console.log(\n ['', ...formatStatus({ studioUrl: options.studioUrl, credentials, worker, project: process.cwd(), logPath: getWorkerLogPath() }), ''].join('\\n'),\n )\n },\n})\n","import { define } from 'gunshi'\nimport { command as connectCommand } from './connect.ts'\nimport { command as loginCommand } from './login.ts'\nimport { command as logoutCommand } from './logout.ts'\nimport { command as permissionsCommand } from './permissions.ts'\nimport { command as snapshotCommand } from './snapshot.ts'\nimport { command as startCommand, stopCommand } from './background.ts'\nimport { command as statusCommand } from './status.ts'\n\nexport const command = define({\n ...connectCommand,\n name: 'studio',\n description: 'Connect this project to Kubb Studio, or manage its pairing and snapshots.',\n examples: [\n 'kubb studio',\n 'kubb studio --allow-read',\n 'kubb studio login',\n 'kubb studio status',\n 'kubb studio permissions',\n 'kubb studio logout',\n 'kubb studio snapshot',\n ].join('\\n'),\n subCommands: {\n start: startCommand,\n stop: stopCommand,\n connect: connectCommand,\n login: loginCommand,\n logout: logoutCommand,\n status: statusCommand,\n permissions: permissionsCommand,\n snapshot: snapshotCommand,\n },\n})\n\n/**\n * Sends `kubb studio --flag value` to `kubb studio connect`, the same runner. gunshi picks a\n * subcommand from the first token that is not a flag, so `--url http://…` would read the URL as one.\n */\nexport function routeStudioFlags(args: Array<string>): Array<string> {\n const [name, next] = args\n if (name !== 'studio' || !next?.startsWith('-') || next === '--help' || next === '-h') return args\n\n return ['studio', 'connect', ...args.slice(1)]\n}\n"],"mappings":";;;;;;;;;;;AAOA,SAAgB,cAAc,EAC5B,QACA,OACA,GAAG,cAUF;CACD,OAAO,OAAO;EACZ,GAAG;EACH,SAAS;EACT,MAAM,IAAI,EAAE,UAAU;GACpB,MAAM,EAAE,cAAc,MAAM,OAAO;GACnC,MAAM,UAAU,QAAwB,QAAQ,EAAE,MAAM,CAAC;EAC3D;CACF,CAAC;AACH;;AC1BA,MAAaA,YAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,UAAU;EACR;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,MA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;IAAW;IAAa;IAAQ,SAAS,QAAQ,IAAI;IAAG,SAAS,iBAAiB;GAAE,CAAC;GAAG;EAAE,CAAC,CAAC,KAAK,IAAI,CACjJ;CACF;AACF,CAAC;;ACVD,MAAa,UAAU,OAAO;CAC5B,GAAGC;CACH,MAAM;CACN,aAAa;CACb,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,aAAa;EACX,OAAOC;EACP,MAAM;EACN,SAASD;EACT,OAAOE;EACP,QAAQC;EACR,QAAQC;EACR,aAAaC;EACb,UAAUC;CACZ;AACF,CAAC;;;;;AAMD,SAAgB,iBAAiB,MAAoC;CACnE,MAAM,CAAC,MAAM,QAAQ;CACrB,IAAI,SAAS,YAAY,CAAC,MAAM,WAAW,GAAG,KAAK,SAAS,YAAY,SAAS,MAAM,OAAO;CAE9F,OAAO;EAAC;EAAU;EAAW,GAAG,KAAK,MAAM,CAAC;CAAC;AAC/C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
|
|
2
2
|
const require_shared = require("./shared-DoD3p_X8.cjs");
|
|
3
|
-
const require_config = require("./config-
|
|
3
|
+
const require_config = require("./config-BU9xeaGq.cjs");
|
|
4
4
|
let gunshi = require("gunshi");
|
|
5
5
|
let node_process = require("node:process");
|
|
6
6
|
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
@@ -16,7 +16,7 @@ function studioCommand({ action, block, ...definition }) {
|
|
|
16
16
|
...definition,
|
|
17
17
|
toKebab: true,
|
|
18
18
|
async run({ values }) {
|
|
19
|
-
const { runStudio } = await Promise.resolve().then(() => require("./run-
|
|
19
|
+
const { runStudio } = await Promise.resolve().then(() => require("./run-OqiJknWr.cjs"));
|
|
20
20
|
await runStudio(values, action, { block });
|
|
21
21
|
}
|
|
22
22
|
});
|
|
@@ -45,7 +45,7 @@ const command$7 = studioCommand({
|
|
|
45
45
|
},
|
|
46
46
|
block: true,
|
|
47
47
|
async action(options) {
|
|
48
|
-
const { connect } = await Promise.resolve().then(() => require("./run-
|
|
48
|
+
const { connect } = await Promise.resolve().then(() => require("./run-OqiJknWr.cjs"));
|
|
49
49
|
await connect(options);
|
|
50
50
|
}
|
|
51
51
|
});
|
|
@@ -56,7 +56,7 @@ const command$6 = studioCommand({
|
|
|
56
56
|
examples: ["kubb studio login", "kubb studio login --url http://localhost:3000"].join("\n"),
|
|
57
57
|
args: command$7.args,
|
|
58
58
|
async action(options) {
|
|
59
|
-
const { login } = await Promise.resolve().then(() => require("./run-
|
|
59
|
+
const { login } = await Promise.resolve().then(() => require("./run-OqiJknWr.cjs"));
|
|
60
60
|
await login(options);
|
|
61
61
|
}
|
|
62
62
|
});
|
|
@@ -67,7 +67,7 @@ const command$5 = studioCommand({
|
|
|
67
67
|
examples: "kubb studio logout",
|
|
68
68
|
args: {},
|
|
69
69
|
async action() {
|
|
70
|
-
const { stopWorker } = await Promise.resolve().then(() => require("./background-
|
|
70
|
+
const { stopWorker } = await Promise.resolve().then(() => require("./background-fhpYDuSs.cjs"));
|
|
71
71
|
const { clearCredentials } = await Promise.resolve().then(() => require("./credentials-Cl3eOa8G.cjs")).then((n) => n.credentials_exports);
|
|
72
72
|
await stopWorker();
|
|
73
73
|
await clearCredentials();
|
|
@@ -82,7 +82,7 @@ const command$4 = studioCommand({
|
|
|
82
82
|
args: {},
|
|
83
83
|
async action(options) {
|
|
84
84
|
const { readCredentials } = await Promise.resolve().then(() => require("./credentials-Cl3eOa8G.cjs")).then((n) => n.credentials_exports);
|
|
85
|
-
const { resolvePermissions } = await Promise.resolve().then(() => require("./run-
|
|
85
|
+
const { resolvePermissions } = await Promise.resolve().then(() => require("./run-OqiJknWr.cjs"));
|
|
86
86
|
const { canUseTTY } = await Promise.resolve().then(() => require("./env-Bi4GXVdd.cjs")).then((n) => n.env_exports);
|
|
87
87
|
const credentials = await readCredentials();
|
|
88
88
|
if (!credentials) throw new Error("This project is not paired with Kubb Studio. Run `kubb studio` first.");
|
|
@@ -127,7 +127,7 @@ const command$3 = (0, gunshi.define)({
|
|
|
127
127
|
...require_shared.logLevelArg
|
|
128
128
|
},
|
|
129
129
|
async run(ctx) {
|
|
130
|
-
const { runner } = await Promise.resolve().then(() => require("./snapshot-
|
|
130
|
+
const { runner } = await Promise.resolve().then(() => require("./snapshot-C-ge8g3_.cjs"));
|
|
131
131
|
await runner(ctx);
|
|
132
132
|
}
|
|
133
133
|
});
|
|
@@ -137,7 +137,7 @@ const command$2 = studioCommand({
|
|
|
137
137
|
description: "Keep this project connected to Kubb Studio in the background.",
|
|
138
138
|
args: command$7.args,
|
|
139
139
|
async action(options) {
|
|
140
|
-
const { startWorker } = await Promise.resolve().then(() => require("./background-
|
|
140
|
+
const { startWorker } = await Promise.resolve().then(() => require("./background-fhpYDuSs.cjs"));
|
|
141
141
|
await startWorker(options);
|
|
142
142
|
}
|
|
143
143
|
});
|
|
@@ -145,7 +145,7 @@ const stopCommand = (0, gunshi.define)({
|
|
|
145
145
|
name: "stop",
|
|
146
146
|
description: "Stop this project's background connection and keep its pairing.",
|
|
147
147
|
async run() {
|
|
148
|
-
const { stopWorker } = await Promise.resolve().then(() => require("./background-
|
|
148
|
+
const { stopWorker } = await Promise.resolve().then(() => require("./background-fhpYDuSs.cjs"));
|
|
149
149
|
await stopWorker();
|
|
150
150
|
console.log("Background connection stopped.");
|
|
151
151
|
}
|
|
@@ -157,9 +157,9 @@ const command$1 = studioCommand({
|
|
|
157
157
|
examples: "kubb studio status",
|
|
158
158
|
args: { url: require_shared.studioConnectionArgs.url },
|
|
159
159
|
async action(options) {
|
|
160
|
-
const { getWorkerLogPath, getWorkerStatus } = await Promise.resolve().then(() => require("./background-
|
|
160
|
+
const { getWorkerLogPath, getWorkerStatus } = await Promise.resolve().then(() => require("./background-fhpYDuSs.cjs"));
|
|
161
161
|
const { readCredentials } = await Promise.resolve().then(() => require("./credentials-Cl3eOa8G.cjs")).then((n) => n.credentials_exports);
|
|
162
|
-
const { formatStatus } = await Promise.resolve().then(() => require("./status-
|
|
162
|
+
const { formatStatus } = await Promise.resolve().then(() => require("./status-D-Osmkhr.cjs"));
|
|
163
163
|
const [worker, credentials] = await Promise.all([getWorkerStatus(), readCredentials()]);
|
|
164
164
|
console.log([
|
|
165
165
|
"",
|
|
@@ -215,4 +215,4 @@ function routeStudioFlags(args) {
|
|
|
215
215
|
exports.command = command;
|
|
216
216
|
exports.routeStudioFlags = routeStudioFlags;
|
|
217
217
|
|
|
218
|
-
//# sourceMappingURL=studio-
|
|
218
|
+
//# sourceMappingURL=studio-BZ53idqa.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studio-BfR2KY0b.cjs","names":["define","command","configArg","studioConnectionArgs","studioPermissionArgs","logLevelArg","command","connectCommand","command","command","findConfigFile","path","process","command","define","configArg","studioConnectionArgs","logLevelArg","command","connectCommand","define","command","studioConnectionArgs","process","define","connectCommand","startCommand","loginCommand","logoutCommand","statusCommand","permissionsCommand","snapshotCommand"],"sources":["../src/commands/studio/studioCommand.ts","../src/commands/studio/connect.ts","../src/commands/studio/login.ts","../src/commands/studio/logout.ts","../src/commands/studio/permissions.ts","../src/commands/studio/snapshot.ts","../src/commands/studio/background.ts","../src/commands/studio/status.ts","../src/commands/studio/index.ts"],"sourcesContent":["import { type Args, define } from 'gunshi'\nimport type { StudioOptions, StudioValues } from '../../runners/studio/run.ts'\n\n/**\n * Defines a `kubb studio` subcommand. The runner, and with it `@kubb/studio`, loads only when the\n * command runs, so `kubb --help` never does.\n */\nexport function studioCommand({\n action,\n block,\n ...definition\n}: {\n name: string\n description: string\n examples?: string\n args?: Args\n /** Opens a block a later `logOutro` closes, for a command that keeps running. */\n block?: boolean\n /** The command body, given the options built from its flags. */\n action: (options: StudioOptions) => Promise<unknown>\n}) {\n return define({\n ...definition,\n toKebab: true,\n async run({ values }) {\n const { runStudio } = await import('../../runners/studio/run.ts')\n await runStudio(values as StudioValues, action, { block })\n },\n })\n}\n","import { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'connect',\n description: 'Connect this project to Kubb Studio and generate from the browser.',\n examples: [\n 'kubb studio connect',\n 'kubb studio connect --allow-read',\n 'kubb studio connect --allow-write --allow-exec',\n 'kubb studio connect --url http://localhost:3000',\n ].join('\\n'),\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n open: {\n type: 'boolean',\n description: 'Open the approval page in a browser while pairing',\n default: true,\n negatable: true,\n },\n ...logLevelArg,\n },\n block: true,\n async action(options) {\n const { connect } = await import('../../runners/studio/run.ts')\n await connect(options)\n },\n})\n","import { command as connectCommand } from './connect.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'login',\n description: 'Pair this machine with Kubb Studio without connecting.',\n examples: ['kubb studio login', 'kubb studio login --url http://localhost:3000'].join('\\n'),\n args: connectCommand.args,\n async action(options) {\n const { login } = await import('../../runners/studio/run.ts')\n await login(options)\n },\n})\n","import { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'logout',\n description: 'Forget the stored Kubb Studio token.',\n examples: 'kubb studio logout',\n args: {},\n async action() {\n const { stopWorker } = await import('../../runners/studio/background.ts')\n const { clearCredentials } = await import('../../runners/studio/credentials.ts')\n await stopWorker()\n await clearCredentials()\n console.log('Signed out of Kubb Studio.')\n },\n})\n","import path from 'node:path'\nimport process from 'node:process'\nimport { findConfigFile } from '@internals/shared'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'permissions',\n description: 'Change what Kubb Studio may do in this project.',\n examples: 'kubb studio permissions',\n args: {},\n async action(options) {\n const { readCredentials } = await import('../../runners/studio/credentials.ts')\n const { resolvePermissions } = await import('../../runners/studio/run.ts')\n const { canUseTTY } = await import('../../utils/env.ts')\n\n const credentials = await readCredentials()\n if (!credentials) throw new Error('This project is not paired with Kubb Studio. Run `kubb studio` first.')\n if (!canUseTTY()) throw new Error('Changing permissions needs an interactive terminal.')\n\n const configFile = findConfigFile()\n await resolvePermissions(options, credentials, configFile && path.relative(process.cwd(), configFile), { edit: true })\n console.log(\n 'Permissions saved. A running connection keeps the old ones until you restart it: press Ctrl+C and run `kubb studio` again, or run `kubb studio stop`, then `kubb studio start`. Keep `--url` and `--config`, and leave out the `--allow-*` flag of any permission you turned off, since a flag grants it anyway.',\n )\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs } from '../shared.ts'\n\nexport const command = define({\n name: 'snapshot',\n description: 'Generate and publish a Kubb Studio snapshot from CI.',\n examples: ['kubb studio snapshot', 'kubb studio snapshot --json'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n id: {\n type: 'string',\n description: 'Stable identity for the CI agent, such as a pull request. Auto-detected on GitHub Actions, GitLab CI, Bitbucket Pipelines and CircleCI',\n },\n baseId: {\n type: 'string',\n description:\n \"Identity of another CI agent, such as the base branch's, to also compare this snapshot with. Auto-detected on GitHub pull requests and GitLab merge requests\",\n toKebab: true,\n },\n name: {\n type: 'string',\n description: 'Package name for the generated tarball. Defaults to the name in package.json',\n },\n packageVersion: {\n type: 'string',\n description: 'Package version for the generated tarball. Defaults to the version in package.json',\n toKebab: true,\n },\n json: {\n type: 'boolean',\n description: 'Print the result as one JSON object instead of a summary',\n default: false,\n },\n ...logLevelArg,\n },\n async run(ctx) {\n const { runner } = await import('../../runners/studio/snapshot.ts')\n await runner(ctx)\n },\n})\n","import { define } from 'gunshi'\nimport { command as connectCommand } from './connect.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'start',\n description: 'Keep this project connected to Kubb Studio in the background.',\n args: connectCommand.args,\n async action(options) {\n const { startWorker } = await import('../../runners/studio/background.ts')\n await startWorker(options)\n },\n})\n\nexport const stopCommand = define({\n name: 'stop',\n description: \"Stop this project's background connection and keep its pairing.\",\n async run() {\n const { stopWorker } = await import('../../runners/studio/background.ts')\n await stopWorker()\n console.log('Background connection stopped.')\n },\n})\n","import process from 'node:process'\nimport { studioConnectionArgs } from '../shared.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'status',\n description: 'Show the project worker, Kubb Studio pairing, and saved permissions.',\n examples: 'kubb studio status',\n args: { url: studioConnectionArgs.url },\n async action(options) {\n const { getWorkerLogPath, getWorkerStatus } = await import('../../runners/studio/background.ts')\n const { readCredentials } = await import('../../runners/studio/credentials.ts')\n const { formatStatus } = await import('../../runners/studio/status.ts')\n\n const [worker, credentials] = await Promise.all([getWorkerStatus(), readCredentials()])\n console.log(\n ['', ...formatStatus({ studioUrl: options.studioUrl, credentials, worker, project: process.cwd(), logPath: getWorkerLogPath() }), ''].join('\\n'),\n )\n },\n})\n","import { define } from 'gunshi'\nimport { command as connectCommand } from './connect.ts'\nimport { command as loginCommand } from './login.ts'\nimport { command as logoutCommand } from './logout.ts'\nimport { command as permissionsCommand } from './permissions.ts'\nimport { command as snapshotCommand } from './snapshot.ts'\nimport { command as startCommand, stopCommand } from './background.ts'\nimport { command as statusCommand } from './status.ts'\n\nexport const command = define({\n ...connectCommand,\n name: 'studio',\n description: 'Connect this project to Kubb Studio, or manage its pairing and snapshots.',\n examples: [\n 'kubb studio',\n 'kubb studio --allow-read',\n 'kubb studio login',\n 'kubb studio status',\n 'kubb studio permissions',\n 'kubb studio logout',\n 'kubb studio snapshot',\n ].join('\\n'),\n subCommands: {\n start: startCommand,\n stop: stopCommand,\n connect: connectCommand,\n login: loginCommand,\n logout: logoutCommand,\n status: statusCommand,\n permissions: permissionsCommand,\n snapshot: snapshotCommand,\n },\n})\n\n/**\n * Sends `kubb studio --flag value` to `kubb studio connect`, the same runner. gunshi picks a\n * subcommand from the first token that is not a flag, so `--url http://…` would read the URL as one.\n */\nexport function routeStudioFlags(args: Array<string>): Array<string> {\n const [name, next] = args\n if (name !== 'studio' || !next?.startsWith('-') || next === '--help' || next === '-h') return args\n\n return ['studio', 'connect', ...args.slice(1)]\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,SAAgB,cAAc,EAC5B,QACA,OACA,GAAG,cAUF;CACD,QAAA,GAAOA,OAAAA,OAAAA,CAAO;EACZ,GAAG;EACH,SAAS;EACT,MAAM,IAAI,EAAE,UAAU;GACpB,MAAM,EAAE,cAAc,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;GAC5B,MAAM,UAAU,QAAwB,QAAQ,EAAE,MAAM,CAAC;EAC3D;CACF,CAAC;AACH;;AC1BA,MAAaC,YAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,UAAU;EACR;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,MAAM;EACJ,GAAGC,eAAAA;EACH,GAAGC,eAAAA;EACH,GAAGC,eAAAA;EACH,MAAM;GACJ,MAAM;GACN,aAAa;GACb,SAAS;GACT,WAAW;EACb;EACA,GAAGC,eAAAA;CACL;CACA,OAAO;CACP,MAAM,OAAO,SAAS;EACpB,MAAM,EAAE,YAAY,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAC1B,MAAM,QAAQ,OAAO;CACvB;AACF,CAAC;;AC1BD,MAAaC,YAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,UAAU,CAAC,qBAAqB,+CAA+C,CAAC,CAAC,KAAK,IAAI;CAC1F,MAAMC,UAAe;CACrB,MAAM,OAAO,SAAS;EACpB,MAAM,EAAE,UAAU,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EACxB,MAAM,MAAM,OAAO;CACrB;AACF,CAAC;;ACVD,MAAaC,YAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,UAAU;CACV,MAAM,CAAC;CACP,MAAM,SAAS;EACb,MAAM,EAAE,eAAe,MAAA,QAAA,QAAA,CAAA,CA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,eAAe,MAAM,QAAQ,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC,CAAC;EACtF,QAAQ,IACN;GAAC;GAAI,GAAG,aAAa;IAAE,WAAW,QAAQ;IAAW;IAAa;IAAQ,SAASC,aAAAA,QAAQ,IAAI;IAAG,SAAS,iBAAiB;GAAE,CAAC;GAAG;EAAE,CAAC,CAAC,KAAK,IAAI,CACjJ;CACF;AACF,CAAC;;ACVD,MAAa,WAAA,GAAUC,OAAAA,OAAAA,CAAO;CAC5B,GAAGC;CACH,MAAM;CACN,aAAa;CACb,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,aAAa;EACX,OAAOC;EACP,MAAM;EACN,SAASD;EACT,OAAOE;EACP,QAAQC;EACR,QAAQC;EACR,aAAaC;EACb,UAAUC;CACZ;AACF,CAAC;;;;;AAMD,SAAgB,iBAAiB,MAAoC;CACnE,MAAM,CAAC,MAAM,QAAQ;CACrB,IAAI,SAAS,YAAY,CAAC,MAAM,WAAW,GAAG,KAAK,SAAS,YAAY,SAAS,MAAM,OAAO;CAE9F,OAAO;EAAC;EAAU;EAAW,GAAG,KAAK,MAAM,CAAC;CAAC;AAC/C"}
|
|
1
|
+
{"version":3,"file":"studio-BZ53idqa.cjs","names":["define","command","configArg","studioConnectionArgs","studioPermissionArgs","logLevelArg","command","connectCommand","command","command","findConfigFile","path","process","command","define","configArg","studioConnectionArgs","logLevelArg","command","connectCommand","define","command","studioConnectionArgs","process","define","connectCommand","startCommand","loginCommand","logoutCommand","statusCommand","permissionsCommand","snapshotCommand"],"sources":["../src/commands/studio/studioCommand.ts","../src/commands/studio/connect.ts","../src/commands/studio/login.ts","../src/commands/studio/logout.ts","../src/commands/studio/permissions.ts","../src/commands/studio/snapshot.ts","../src/commands/studio/background.ts","../src/commands/studio/status.ts","../src/commands/studio/index.ts"],"sourcesContent":["import { type Args, define } from 'gunshi'\nimport type { StudioOptions, StudioValues } from '../../runners/studio/run.ts'\n\n/**\n * Defines a `kubb studio` subcommand. The runner, and with it `@kubb/studio`, loads only when the\n * command runs, so `kubb --help` never does.\n */\nexport function studioCommand({\n action,\n block,\n ...definition\n}: {\n name: string\n description: string\n examples?: string\n args?: Args\n /** Opens a block a later `logOutro` closes, for a command that keeps running. */\n block?: boolean\n /** The command body, given the options built from its flags. */\n action: (options: StudioOptions) => Promise<unknown>\n}) {\n return define({\n ...definition,\n toKebab: true,\n async run({ values }) {\n const { runStudio } = await import('../../runners/studio/run.ts')\n await runStudio(values as StudioValues, action, { block })\n },\n })\n}\n","import { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'connect',\n description: 'Connect this project to Kubb Studio and generate from the browser.',\n examples: [\n 'kubb studio connect',\n 'kubb studio connect --allow-read',\n 'kubb studio connect --allow-write --allow-exec',\n 'kubb studio connect --url http://localhost:3000',\n ].join('\\n'),\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n open: {\n type: 'boolean',\n description: 'Open the approval page in a browser while pairing',\n default: true,\n negatable: true,\n },\n ...logLevelArg,\n },\n block: true,\n async action(options) {\n const { connect } = await import('../../runners/studio/run.ts')\n await connect(options)\n },\n})\n","import { command as connectCommand } from './connect.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'login',\n description: 'Pair this machine with Kubb Studio without connecting.',\n examples: ['kubb studio login', 'kubb studio login --url http://localhost:3000'].join('\\n'),\n args: connectCommand.args,\n async action(options) {\n const { login } = await import('../../runners/studio/run.ts')\n await login(options)\n },\n})\n","import { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'logout',\n description: 'Forget the stored Kubb Studio token.',\n examples: 'kubb studio logout',\n args: {},\n async action() {\n const { stopWorker } = await import('../../runners/studio/background.ts')\n const { clearCredentials } = await import('../../runners/studio/credentials.ts')\n await stopWorker()\n await clearCredentials()\n console.log('Signed out of Kubb Studio.')\n },\n})\n","import path from 'node:path'\nimport process from 'node:process'\nimport { findConfigFile } from '@internals/shared'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'permissions',\n description: 'Change what Kubb Studio may do in this project.',\n examples: 'kubb studio permissions',\n args: {},\n async action(options) {\n const { readCredentials } = await import('../../runners/studio/credentials.ts')\n const { resolvePermissions } = await import('../../runners/studio/run.ts')\n const { canUseTTY } = await import('../../utils/env.ts')\n\n const credentials = await readCredentials()\n if (!credentials) throw new Error('This project is not paired with Kubb Studio. Run `kubb studio` first.')\n if (!canUseTTY()) throw new Error('Changing permissions needs an interactive terminal.')\n\n const configFile = findConfigFile()\n await resolvePermissions(options, credentials, configFile && path.relative(process.cwd(), configFile), { edit: true })\n console.log(\n 'Permissions saved. A running connection keeps the old ones until you restart it: press Ctrl+C and run `kubb studio` again, or run `kubb studio stop`, then `kubb studio start`. Keep `--url` and `--config`, and leave out the `--allow-*` flag of any permission you turned off, since a flag grants it anyway.',\n )\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs } from '../shared.ts'\n\nexport const command = define({\n name: 'snapshot',\n description: 'Generate and publish a Kubb Studio snapshot from CI.',\n examples: ['kubb studio snapshot', 'kubb studio snapshot --json'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n id: {\n type: 'string',\n description: 'Stable identity for the CI agent, such as a pull request. Auto-detected on GitHub Actions, GitLab CI, Bitbucket Pipelines and CircleCI',\n },\n baseId: {\n type: 'string',\n description:\n \"Identity of another CI agent, such as the base branch's, to also compare this snapshot with. Auto-detected on GitHub pull requests and GitLab merge requests\",\n toKebab: true,\n },\n name: {\n type: 'string',\n description: 'Package name for the generated tarball. Defaults to the name in package.json',\n },\n packageVersion: {\n type: 'string',\n description: 'Package version for the generated tarball. Defaults to the version in package.json',\n toKebab: true,\n },\n json: {\n type: 'boolean',\n description: 'Print the result as one JSON object instead of a summary',\n default: false,\n },\n ...logLevelArg,\n },\n async run(ctx) {\n const { runner } = await import('../../runners/studio/snapshot.ts')\n await runner(ctx)\n },\n})\n","import { define } from 'gunshi'\nimport { command as connectCommand } from './connect.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'start',\n description: 'Keep this project connected to Kubb Studio in the background.',\n args: connectCommand.args,\n async action(options) {\n const { startWorker } = await import('../../runners/studio/background.ts')\n await startWorker(options)\n },\n})\n\nexport const stopCommand = define({\n name: 'stop',\n description: \"Stop this project's background connection and keep its pairing.\",\n async run() {\n const { stopWorker } = await import('../../runners/studio/background.ts')\n await stopWorker()\n console.log('Background connection stopped.')\n },\n})\n","import process from 'node:process'\nimport { studioConnectionArgs } from '../shared.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'status',\n description: 'Show the project worker, Kubb Studio pairing, and saved permissions.',\n examples: 'kubb studio status',\n args: { url: studioConnectionArgs.url },\n async action(options) {\n const { getWorkerLogPath, getWorkerStatus } = await import('../../runners/studio/background.ts')\n const { readCredentials } = await import('../../runners/studio/credentials.ts')\n const { formatStatus } = await import('../../runners/studio/status.ts')\n\n const [worker, credentials] = await Promise.all([getWorkerStatus(), readCredentials()])\n console.log(\n ['', ...formatStatus({ studioUrl: options.studioUrl, credentials, worker, project: process.cwd(), logPath: getWorkerLogPath() }), ''].join('\\n'),\n )\n },\n})\n","import { define } from 'gunshi'\nimport { command as connectCommand } from './connect.ts'\nimport { command as loginCommand } from './login.ts'\nimport { command as logoutCommand } from './logout.ts'\nimport { command as permissionsCommand } from './permissions.ts'\nimport { command as snapshotCommand } from './snapshot.ts'\nimport { command as startCommand, stopCommand } from './background.ts'\nimport { command as statusCommand } from './status.ts'\n\nexport const command = define({\n ...connectCommand,\n name: 'studio',\n description: 'Connect this project to Kubb Studio, or manage its pairing and snapshots.',\n examples: [\n 'kubb studio',\n 'kubb studio --allow-read',\n 'kubb studio login',\n 'kubb studio status',\n 'kubb studio permissions',\n 'kubb studio logout',\n 'kubb studio snapshot',\n ].join('\\n'),\n subCommands: {\n start: startCommand,\n stop: stopCommand,\n connect: connectCommand,\n login: loginCommand,\n logout: logoutCommand,\n status: statusCommand,\n permissions: permissionsCommand,\n snapshot: snapshotCommand,\n },\n})\n\n/**\n * Sends `kubb studio --flag value` to `kubb studio connect`, the same runner. gunshi picks a\n * subcommand from the first token that is not a flag, so `--url http://…` would read the URL as one.\n */\nexport function routeStudioFlags(args: Array<string>): Array<string> {\n const [name, next] = args\n if (name !== 'studio' || !next?.startsWith('-') || next === '--help' || next === '-h') return args\n\n return ['studio', 'connect', ...args.slice(1)]\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,SAAgB,cAAc,EAC5B,QACA,OACA,GAAG,cAUF;CACD,QAAA,GAAOA,OAAAA,OAAAA,CAAO;EACZ,GAAG;EACH,SAAS;EACT,MAAM,IAAI,EAAE,UAAU;GACpB,MAAM,EAAE,cAAc,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;GAC5B,MAAM,UAAU,QAAwB,QAAQ,EAAE,MAAM,CAAC;EAC3D;CACF,CAAC;AACH;;AC1BA,MAAaC,YAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,UAAU;EACR;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,MAAM;EACJ,GAAGC,eAAAA;EACH,GAAGC,eAAAA;EACH,GAAGC,eAAAA;EACH,MAAM;GACJ,MAAM;GACN,aAAa;GACb,SAAS;GACT,WAAW;EACb;EACA,GAAGC,eAAAA;CACL;CACA,OAAO;CACP,MAAM,OAAO,SAAS;EACpB,MAAM,EAAE,YAAY,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAC1B,MAAM,QAAQ,OAAO;CACvB;AACF,CAAC;;AC1BD,MAAaC,YAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,UAAU,CAAC,qBAAq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ath } from "./background-
|
|
3
|
-
import { t as connect } from "./run-
|
|
2
|
+
import { r as serveWorker, t as getWorkerLogPath } from "./background-CA9lRKAK.js";
|
|
3
|
+
import { t as connect } from "./run-U2Ze_QP4.js";
|
|
4
4
|
import { format } from "node:util";
|
|
5
5
|
import { appendFileSync, statSync, writeFileSync } from "node:fs";
|
|
6
6
|
// src/runners/studio/worker.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "./rolldown-runtime-BowF1xt-.js";
|
|
2
|
-
import { a as toPosixPath, i as read, o as write } from "./fs-
|
|
2
|
+
import { a as toPosixPath, i as read, o as write } from "./fs-CmODfKN-.js";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { x } from "tinyexec";
|
|
5
|
+
import fs from "node:fs";
|
|
5
6
|
import { glob } from "node:fs/promises";
|
|
6
7
|
import path from "node:path";
|
|
7
|
-
import fs from "node:fs";
|
|
8
8
|
import { Diagnostics } from "@kubb/core";
|
|
9
9
|
import { detect, resolveCommand } from "package-manager-detector";
|
|
10
10
|
// ../../internals/utils/src/casing.ts
|
|
@@ -239,4 +239,4 @@ async function generateScript(cwd) {
|
|
|
239
239
|
}
|
|
240
240
|
export { generateScript as a, missingPluginDependencies as c, uninstallPackages as d, camelCase as f, findSpecFiles as i, parsePluginsFlag as l, detectPackageManager as n, initPackageJson as o, pascalCase as p, findPlugin as r, installPackages as s, addGenerateScript as t, readSpecInfo as u };
|
|
241
241
|
|
|
242
|
-
//# sourceMappingURL=utils-
|
|
242
|
+
//# sourceMappingURL=utils-BVccq6W0.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-DGopc0Bo.js","names":[],"sources":["../../../internals/utils/src/casing.ts","../src/runners/init/utils.ts"],"sourcesContent":["type Options = {\n /** Text prepended before casing is applied. */\n prefix?: string\n /** Text appended before casing is applied. */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction convert(text: string, pascal: boolean): string {\n return (\n text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n // A status range such as `2xx` stays one word.\n .replace(/(\\d)(?!xx(?![a-z]))([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n )\n}\n\n// Plugins case the same names on every visit. Clearing at the limit bounds a long-running host.\nconst cache = new Map<string, string>()\nconst cacheLimit = 100_000\n\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const key = `${pascal ? 'P' : 'c'}${text}`\n const cached = cache.get(key)\n if (cached !== undefined) return cached\n\n const result = convert(text, pascal)\n if (cache.size >= cacheLimit) cache.clear()\n cache.set(key, result)\n return result\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n// A word starts at `petType`, `sensor2Reading`, and `HTTPResponse`, while `IDs` and `OAuth` stay whole\nconst wordStart = /(?<=[a-z\\d])(?=[A-Z])|(?<=[A-Z]{2})(?=[A-Z][a-z]{2})/\n\n// A segment without lowercase letters, such as `COOL` or `2D`, stays one word, so a snake_case name is left unchanged.\nfunction words(text: string): Array<string> {\n return text\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .flatMap((segment) => (segment === segment.toUpperCase() ? segment : segment.split(wordStart)))\n}\n\n/**\n * Uppercases only the first character of `text`. Unlike `pascalCase` it never splits words or strips characters.\n *\n * @example\n * `capitalize('getPetById') // 'GetPetById'`\n */\nexport function capitalize(text: string): string {\n return `${text.charAt(0).toUpperCase()}${text.slice(1)}`\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example\n * `snakeCase('helloWorld') // 'hello_world'`\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return words(`${prefix} ${text} ${suffix}`)\n .map((word) => word.replace(/[^a-zA-Z0-9]/g, '').toLowerCase())\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example\n * `screamingSnakeCase('helloWorld') // 'HELLO_WORLD'`\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","import fs from 'node:fs'\nimport { glob } from 'node:fs/promises'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { read, toPosixPath, write } from '@internals/utils'\nimport { Diagnostics, type ExtensionManifest, type RegistryEntry } from '@kubb/core'\nimport { type Agent, type AgentName, detect, resolveCommand } from 'package-manager-detector'\nimport { x } from 'tinyexec'\n\nexport type PackageManagerName = Extract<AgentName, 'npm' | 'pnpm' | 'yarn' | 'bun'>\n\n/**\n * A project's package manager: `name` for messages, `agent` for `resolveCommand`.\n */\nexport type PackageManagerInfo = { name: PackageManagerName; agent: Agent }\n\n/**\n * Subcommands that create a `package.json`; `package-manager-detector` has no `init` command.\n */\nconst initCommands: Record<PackageManagerName, ReadonlyArray<string>> = { npm: ['init', '-y'], pnpm: ['init'], yarn: ['init', '-y'], bun: ['init', '-y'] }\n\n/** Minimal shape of `package.json` fields read during detection. */\ntype PackageJson = {\n /** The `packageManager` field from `package.json` (e.g. `\"pnpm@9.0.0\"`). */\n packageManager?: string\n scripts?: Record<string, string>\n}\n\n/**\n * Detects the package manager in `cwd`: the `packageManager` field in `package.json`, then a lock file, then `npm`. Parent folders are not searched.\n */\nexport async function detectPackageManager(cwd: string = process.cwd()): Promise<PackageManagerInfo> {\n const found = await detect({ cwd, stopDir: cwd, strategies: ['packageManager-field', 'lockfile'] })\n return found && found.name in initCommands ? (found as PackageManagerInfo) : { name: 'npm', agent: 'npm' }\n}\n\n/**\n * Initializes a new `package.json` at `cwd` using the detected package manager.\n */\nexport async function initPackageJson(cwd: string, packageManager: PackageManagerInfo): Promise<void> {\n await x(packageManager.name, [...initCommands[packageManager.name]], {\n nodeOptions: { cwd, stdio: 'inherit' },\n throwOnError: true,\n })\n}\n\n/** How many trailing lines of a failed install's output the error keeps. */\nconst INSTALL_OUTPUT_LINES = 20\nconst INSTALL_TIMEOUT_MS = 5 * 60_000\n\n/**\n * Installs the given packages at `cwd` using the detected package manager. Each output line goes\n * to `onLine`, so the caller can show it while the install runs; a failed install also keeps the\n * end of the output in the error.\n */\nexport async function installPackages(\n packages: Array<string>,\n packageManager: PackageManagerInfo,\n cwd: string = process.cwd(),\n onLine?: (line: string) => void,\n command: 'add' | 'uninstall' = 'add',\n): Promise<void> {\n const { command: bin, args } = resolveCommand(packageManager.agent, command, command === 'add' ? ['-D', ...packages] : packages)!\n // No stdin, so a package manager that wants input fails instead of waiting. The timeout ends a stalled install.\n const result = x(bin, args, {\n nodeOptions: { cwd, stdio: ['ignore', 'pipe', 'pipe'] },\n timeout: INSTALL_TIMEOUT_MS,\n throwOnError: false,\n })\n const lines: Array<string> = []\n for await (const line of result) {\n lines.push(line)\n onLine?.(line)\n }\n if (result.exitCode === 0) return\n if (result.exitCode === undefined) throw new Error(`\\`${bin} ${args.join(' ')}\\` timed out after ${INSTALL_TIMEOUT_MS / 60_000} minutes`)\n\n const output = lines.slice(-INSTALL_OUTPUT_LINES).join('\\n')\n throw new Error(`\\`${bin} ${args.join(' ')}\\` failed with exit code ${result.exitCode}${output ? `:\\n${output}` : ''}`)\n}\n\n/**\n * Uninstalls the given packages at `cwd` with the package manager's remove command, like {@link installPackages}.\n */\nexport function uninstallPackages(packages: Array<string>, packageManager: PackageManagerInfo, cwd: string = process.cwd()): Promise<void> {\n return installPackages(packages, packageManager, cwd, undefined, 'uninstall')\n}\n\n/**\n * What the selected plugins' `manifests` say is missing from the selection: a `dependencies`\n * entry, or a `client` plugin next to a `consumer`. Empty when nothing is missing.\n * `optionalDependencies` are skipped, since `kubb init` writes the default options.\n */\nexport function missingPluginDependencies(manifests: Array<ExtensionManifest>): Array<string> {\n const selected = manifests.map((manifest) => manifest.name)\n const hasClient = manifests.some((manifest) => manifest.role === 'client')\n return manifests.flatMap((manifest) => [\n ...(manifest.dependencies ?? []).filter((name) => !selected.includes(name)).map((name) => `${manifest.name} needs ${name}.`),\n ...(manifest.role === 'consumer' && !hasClient ? [`${manifest.name} needs a client plugin, such as plugin-axios or plugin-fetch.`] : []),\n ])\n}\n\nasync function readPackageJson(cwd: string): Promise<PackageJson> {\n try {\n return JSON.parse(await read(path.join(cwd, 'package.json'))) as PackageJson\n } catch {\n return {}\n }\n}\n\nconst SPEC_FILE = /^(openapi|swagger)[\\w.-]*\\.(ya?ml|json)$/i\nconst SKIPPED_DIRS = new Set(['node_modules', 'dist', 'build', 'coverage'])\n\n/**\n * Finds OpenAPI spec files up to `depth` folders below `cwd`, shallowest first, as `./`-relative\n * paths. Skips hidden and build folders without walking them and returns at most `limit` files.\n */\nexport async function findSpecFiles(cwd: string, { depth = 3, limit = 20 }: { depth?: number; limit?: number } = {}): Promise<Array<string>> {\n const found: Array<string> = []\n const pattern = `{${Array.from({ length: depth + 1 }, (_, level) => '*/'.repeat(level)).join(',')}}*`\n // The extension stays out of the pattern so SPEC_FILE matches it case-insensitively. Dot folders are skipped by default.\n const files = glob(pattern, { cwd, exclude: (file) => file.split(path.sep).some((segment) => SKIPPED_DIRS.has(segment)) })\n for await (const file of files) if (SPEC_FILE.test(path.basename(file))) found.push(toPosixPath(file))\n return found\n .toSorted((a, b) => a.split('/').length - b.split('/').length || a.localeCompare(b))\n .slice(0, limit)\n .map((file) => `./${file}`)\n}\n\n/** The spec version and operation count, when the file states them. */\nexport type SpecInfo = { version?: string; operations?: number }\n\nconst SPEC_HEAD_BYTES = 256 * 1024\nconst METHOD = '(?:get|put|post|delete|options|head|patch|trace)'\n\n/**\n * Reads the OpenAPI or Swagger version and counts the operations from the first 256 KB of the\n * file, so a large spec is never parsed. The count is left out when the file is longer.\n */\nexport async function readSpecInfo(file: string): Promise<SpecInfo> {\n const handle = await fs.promises.open(file)\n try {\n const buffer = Buffer.alloc(SPEC_HEAD_BYTES)\n const { bytesRead } = await handle.read(buffer, 0, SPEC_HEAD_BYTES, 0)\n const head = buffer.toString('utf-8', 0, bytesRead)\n const complete = bytesRead < SPEC_HEAD_BYTES\n const version = head.match(/^\\s*[\"']?(?:openapi|swagger)[\"']?\\s*:\\s*[\"']?(\\d[\\d.]*)/m)?.[1]\n // shortcut: counts method keys at any depth, so a schema property named `get` counts too; use the adapter when that matters.\n const methods = new RegExp(`^\\\\s*[\"']?${METHOD}[\"']?\\\\s*:\\\\s*(?:\\\\{|$)`, 'gm')\n return { version, operations: complete ? (head.match(methods)?.length ?? 0) : undefined }\n } finally {\n await handle.close()\n }\n}\n\n/** Finds a plugin by registry id, slug, or short name, so `ts`, `plugin-ts`, and `kubb-labs/plugin-ts` all match. */\nexport function findPlugin({ plugins, id }: { plugins: Array<RegistryEntry>; id: string }): RegistryEntry | undefined {\n const ids = id.includes('/') ? [id] : [`kubb-labs/${id}`, `kubb-labs/plugin-${id}`]\n return plugins.find((entry) => ids.includes(entry.id))\n}\n\n/**\n * Turns the comma-separated `--plugins` value into registry entries.\n *\n * @throws when an id is not in `plugins`.\n */\nexport function parsePluginsFlag({ plugins, value }: { plugins: Array<RegistryEntry>; value: string }): Array<RegistryEntry> {\n const ids = value\n .split(',')\n .map((id) => id.trim())\n .filter(Boolean)\n const unknown = ids.filter((id) => !findPlugin({ plugins, id }))\n if (unknown.length)\n throw new Diagnostics.Error({\n code: Diagnostics.code.pluginNotFound,\n severity: 'error',\n message: `Not in the Kubb registry: ${unknown.join(', ')}. Browse the plugins at https://kubb.dev/extensions.`,\n help: 'Use plugin ids from https://kubb.dev/extensions, such as plugin-ts or ts.',\n })\n return ids.map((id) => findPlugin({ plugins, id })!)\n}\n\n/** Adds `\"generate\": \"kubb generate\"` to the `package.json` scripts at `cwd`. Returns `false`, and changes nothing, when a `generate` script exists. */\nexport async function addGenerateScript(cwd: string): Promise<boolean> {\n const file = path.join(cwd, 'package.json')\n const source = await read(file)\n const packageJson = JSON.parse(source) as PackageJson\n if (packageJson.scripts?.generate !== undefined) return false\n const indent = source.match(/^[ \\t]+/m)?.[0] ?? ' '\n const updated = { ...packageJson, scripts: { ...packageJson.scripts, generate: 'kubb generate' } }\n await write(file, JSON.stringify(updated, null, indent))\n return true\n}\n\n/** Reads the `generate` script from the `package.json` at `cwd`. */\nexport async function generateScript(cwd: string): Promise<string | undefined> {\n return (await readPackageJson(cwd)).scripts?.generate\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAcA,SAAS,QAAQ,MAAc,QAAyB;CACtD,OACE,KACG,KAAK,CAAC,CACN,QAAQ,qBAAqB,OAAO,CAAC,CACrC,QAAQ,yBAAyB,OAAO,CAAC,CAEzC,QAAQ,+BAA+B,OAAO,CAAC,CAC/C,MAAM,eAAe,CAAC,CACtB,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,MAAM;EAChB,IAAI,KAAK,SAAS,KAAK,SAAS,KAAK,YAAY,GAAG,OAAO;EAE3D,QADa,MAAM,KAAK,CAAC,SAAS,KAA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AAM,SAAS,MAAM,KAAK,IAAI;CAC9B,MAAM,cAAc,KAAK,MAAM,MAAM;CACrC,IAAI,YAAY,SAAS,aAAa,KAAA,GAAW,OAAO;CACxD,MAAM,SAAS,OAAO,MAAM,UAAU,CAAC,GAAG,MAAM;CAChD,MAAM,UAAU;EAAE,GAAG;EAAa,SAAS;GAAE,GAAG,YAAY;GAAS,UAAU;EAAgB;CAAE;CACjG,MAAM,MAAM,MAAM,KAAK,UAAU,SAAS,MAAM,MAAM,CAAC;CACvD,OAAO;AACT;;AAGA,eAAsB,eAAe,KAA0C;CAC7E,QAAQ,MAAM,gBAAgB,GAAG,EAAA,CAAG,SAAS;AAC/C"}
|
|
1
|
+
{"version":3,"file":"utils-BVccq6W0.js","names":[],"sources":["../../../internals/utils/src/casing.ts","../src/runners/init/utils.ts"],"sourcesContent":["type Options = {\n /** Text prepended before casing is applied. */\n prefix?: string\n /** Text appended before casing is applied. */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction convert(text: string, pascal: boolean): string {\n return (\n text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n // A status range such as `2xx` stays one word.\n .replace(/(\\d)(?!xx(?![a-z]))([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n )\n}\n\n// Plugins case the same names on every visit. Clearing at the limit bounds a long-running host.\nconst cache = new Map<string, string>()\nconst cacheLimit = 100_000\n\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const key = `${pascal ? 'P' : 'c'}${text}`\n const cached = cache.get(key)\n if (cached !== undefined) return cached\n\n const result = convert(text, pascal)\n if (cache.size >= cacheLimit) cache.clear()\n cache.set(key, result)\n return result\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n// A word starts at `petType`, `sensor2Reading`, and `HTTPResponse`, while `IDs` and `OAuth` stay whole\nconst wordStart = /(?<=[a-z\\d])(?=[A-Z])|(?<=[A-Z]{2})(?=[A-Z][a-z]{2})/\n\n// A segment without lowercase letters, such as `COOL` or `2D`, stays one word, so a snake_case name is left unchanged.\nfunction words(text: string): Array<string> {\n return text\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .flatMap((segment) => (segment === segment.toUpperCase() ? segment : segment.split(wordStart)))\n}\n\n/**\n * Uppercases only the first character of `text`. Unlike `pascalCase` it never splits words or strips characters.\n *\n * @example\n * `capitalize('getPetById') // 'GetPetById'`\n */\nexport function capitalize(text: string): string {\n return `${text.charAt(0).toUpperCase()}${text.slice(1)}`\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example\n * `snakeCase('helloWorld') // 'hello_world'`\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return words(`${prefix} ${text} ${suffix}`)\n .map((word) => word.replace(/[^a-zA-Z0-9]/g, '').toLowerCase())\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example\n * `screamingSnakeCase('helloWorld') // 'HELLO_WORLD'`\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","import fs from 'node:fs'\nimport { glob } from 'node:fs/promises'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { read, toPosixPath, write } from '@internals/utils'\nimport { Diagnostics, type ExtensionManifest, type RegistryEntry } from '@kubb/core'\nimport { type Agent, type AgentName, detect, resolveCommand } from 'package-manager-detector'\nimport { x } from 'tinyexec'\n\nexport type PackageManagerName = Extract<AgentName, 'npm' | 'pnpm' | 'yarn' | 'bun'>\n\n/**\n * A project's package manager: `name` for messages, `agent` for `resolveCommand`.\n */\nexport type PackageManagerInfo = { name: PackageManagerName; agent: Agent }\n\n/**\n * Subcommands that create a `package.json`; `package-manager-detector` has no `init` command.\n */\nconst initCommands: Record<PackageManagerName, ReadonlyArray<string>> = { npm: ['init', '-y'], pnpm: ['init'], yarn: ['init', '-y'], bun: ['init', '-y'] }\n\n/** Minimal shape of `package.json` fields read during detection. */\ntype PackageJson = {\n /** The `packageManager` field from `package.json` (e.g. `\"pnpm@9.0.0\"`). */\n packageManager?: string\n scripts?: Record<string, string>\n}\n\n/**\n * Detects the package manager in `cwd`: the `packageManager` field in `package.json`, then a lock file, then `npm`. Parent folders are not searched.\n */\nexport async function detectPackageManager(cwd: string = process.cwd()): Promise<PackageManagerInfo> {\n const found = await detect({ cwd, stopDir: cwd, strategies: ['packageManager-field', 'lockfile'] })\n return found && found.name in initCommands ? (found as PackageManagerInfo) : { name: 'npm', agent: 'npm' }\n}\n\n/**\n * Initializes a new `package.json` at `cwd` using the detected package manager.\n */\nexport async function initPackageJson(cwd: string, packageManager: PackageManagerInfo): Promise<void> {\n await x(packageManager.name, [...initCommands[packageManager.name]], {\n nodeOptions: { cwd, stdio: 'inherit' },\n throwOnError: true,\n })\n}\n\n/** How many trailing lines of a failed install's output the error keeps. */\nconst INSTALL_OUTPUT_LINES = 20\nconst INSTALL_TIMEOUT_MS = 5 * 60_000\n\n/**\n * Installs the given packages at `cwd` using the detected package manager. Each output line goes\n * to `onLine`, so the caller can show it while the install runs; a failed install also keeps the\n * end of the output in the error.\n */\nexport async function installPackages(\n packages: Array<string>,\n packageManager: PackageManagerInfo,\n cwd: string = process.cwd(),\n onLine?: (line: string) => void,\n command: 'add' | 'uninstall' = 'add',\n): Promise<void> {\n const { command: bin, args } = resolveCommand(packageManager.agent, command, command === 'add' ? ['-D', ...packages] : packages)!\n // No stdin, so a package manager that wants input fails instead of waiting. The timeout ends a stalled install.\n const result = x(bin, args, {\n nodeOptions: { cwd, stdio: ['ignore', 'pipe', 'pipe'] },\n timeout: INSTALL_TIMEOUT_MS,\n throwOnError: false,\n })\n const lines: Array<string> = []\n for await (const line of result) {\n lines.push(line)\n onLine?.(line)\n }\n if (result.exitCode === 0) return\n if (result.exitCode === undefined) throw new Error(`\\`${bin} ${args.join(' ')}\\` timed out after ${INSTALL_TIMEOUT_MS / 60_000} minutes`)\n\n const output = lines.slice(-INSTALL_OUTPUT_LINES).join('\\n')\n throw new Error(`\\`${bin} ${args.join(' ')}\\` failed with exit code ${result.exitCode}${output ? `:\\n${output}` : ''}`)\n}\n\n/**\n * Uninstalls the given packages at `cwd` with the package manager's remove command, like {@link installPackages}.\n */\nexport function uninstallPackages(packages: Array<string>, packageManager: PackageManagerInfo, cwd: string = process.cwd()): Promise<void> {\n return installPackages(packages, packageManager, cwd, undefined, 'uninstall')\n}\n\n/**\n * What the selected plugins' `manifests` say is missing from the selection: a `dependencies`\n * entry, or a `client` plugin next to a `consumer`. Empty when nothing is missing.\n * `optionalDependencies` are skipped, since `kubb init` writes the default options.\n */\nexport function missingPluginDependencies(manifests: Array<ExtensionManifest>): Array<string> {\n const selected = manifests.map((manifest) => manifest.name)\n const hasClient = manifests.some((manifest) => manifest.role === 'client')\n return manifests.flatMap((manifest) => [\n ...(manifest.dependencies ?? []).filter((name) => !selected.includes(name)).map((name) => `${manifest.name} needs ${name}.`),\n ...(manifest.role === 'consumer' && !hasClient ? [`${manifest.name} needs a client plugin, such as plugin-axios or plugin-fetch.`] : []),\n ])\n}\n\nasync function readPackageJson(cwd: string): Promise<PackageJson> {\n try {\n return JSON.parse(await read(path.join(cwd, 'package.json'))) as PackageJson\n } catch {\n return {}\n }\n}\n\nconst SPEC_FILE = /^(openapi|swagger)[\\w.-]*\\.(ya?ml|json)$/i\nconst SKIPPED_DIRS = new Set(['node_modules', 'dist', 'build', 'coverage'])\n\n/**\n * Finds OpenAPI spec files up to `depth` folders below `cwd`, shallowest first, as `./`-relative\n * paths. Skips hidden and build folders without walking them and returns at most `limit` files.\n */\nexport async function findSpecFiles(cwd: string, { depth = 3, limit = 20 }: { depth?: number; limit?: number } = {}): Promise<Array<string>> {\n const found: Array<string> = []\n const pattern = `{${Array.from({ length: depth + 1 }, (_, level) => '*/'.repeat(level)).join(',')}}*`\n // The extension stays out of the pattern so SPEC_FILE matches it case-insensitively. Dot folders are skipped by default.\n const files = glob(pattern, { cwd, exclude: (file) => file.split(path.sep).some((segment) => SKIPPED_DIRS.has(segment)) })\n for await (const file of files) if (SPEC_FILE.test(path.basename(file))) found.push(toPosixPath(file))\n return found\n .toSorted((a, b) => a.split('/').length - b.split('/').length || a.localeCompare(b))\n .slice(0, limit)\n .map((file) => `./${file}`)\n}\n\n/** The spec version and operation count, when the file states them. */\nexport type SpecInfo = { version?: string; operations?: number }\n\nconst SPEC_HEAD_BYTES = 256 * 1024\nconst METHOD = '(?:get|put|post|delete|options|head|patch|trace)'\n\n/**\n * Reads the OpenAPI or Swagger version and counts the operations from the first 256 KB of the\n * file, so a large spec is never parsed. The count is left out when the file is longer.\n */\nexport async function readSpecInfo(file: string): Promise<SpecInfo> {\n const handle = await fs.promises.open(file)\n try {\n const buffer = Buffer.alloc(SPEC_HEAD_BYTES)\n const { bytesRead } = await handle.read(buffer, 0, SPEC_HEAD_BYTES, 0)\n const head = buffer.toString('utf-8', 0, bytesRead)\n const complete = bytesRead < SPEC_HEAD_BYTES\n const version = head.match(/^\\s*[\"']?(?:openapi|swagger)[\"']?\\s*:\\s*[\"']?(\\d[\\d.]*)/m)?.[1]\n // shortcut: counts method keys at any depth, so a schema property named `get` counts too; use the adapter when that matters.\n const methods = new RegExp(`^\\\\s*[\"']?${METHOD}[\"']?\\\\s*:\\\\s*(?:\\\\{|$)`, 'gm')\n return { version, operations: complete ? (head.match(methods)?.length ?? 0) : undefined }\n } finally {\n await handle.close()\n }\n}\n\n/** Finds a plugin by registry id, slug, or short name, so `ts`, `plugin-ts`, and `kubb-labs/plugin-ts` all match. */\nexport function findPlugin({ plugins, id }: { plugins: Array<RegistryEntry>; id: string }): RegistryEntry | undefined {\n const ids = id.includes('/') ? [id] : [`kubb-labs/${id}`, `kubb-labs/plugin-${id}`]\n return plugins.find((entry) => ids.includes(entry.id))\n}\n\n/**\n * Turns the comma-separated `--plugins` value into registry entries.\n *\n * @throws when an id is not in `plugins`.\n */\nexport function parsePluginsFlag({ plugins, value }: { plugins: Array<RegistryEntry>; value: string }): Array<RegistryEntry> {\n const ids = value\n .split(',')\n .map((id) => id.trim())\n .filter(Boolean)\n const unknown = ids.filter((id) => !findPlugin({ plugins, id }))\n if (unknown.length)\n throw new Diagnostics.Error({\n code: Diagnostics.code.pluginNotFound,\n severity: 'error',\n message: `Not in the Kubb registry: ${unknown.join(', ')}. Browse the plugins at https://kubb.dev/extensions.`,\n help: 'Use plugin ids from https://kubb.dev/extensions, such as plugin-ts or ts.',\n })\n return ids.map((id) => findPlugin({ plugins, id })!)\n}\n\n/** Adds `\"generate\": \"kubb generate\"` to the `package.json` scripts at `cwd`. Returns `false`, and changes nothing, when a `generate` script exists. */\nexport async function addGenerateScript(cwd: string): Promise<boolean> {\n const file = path.join(cwd, 'package.json')\n const source = await read(file)\n const packageJson = JSON.parse(source) as PackageJson\n if (packageJson.scripts?.generate !== undefined) return false\n const indent = source.match(/^[ \\t]+/m)?.[0] ?? ' '\n const updated = { ...packageJson, scripts: { ...packageJson.scripts, generate: 'kubb generate' } }\n await write(file, JSON.stringify(updated, null, indent))\n return true\n}\n\n/** Reads the `generate` script from the `package.json` at `cwd`. */\nexport async function generateScript(cwd: string): Promise<string | undefined> {\n return (await readPackageJson(cwd)).scripts?.generate\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAcA,SAAS,QAAQ,MAAc,QAAyB;CACtD,OACE,KACG,KAAK,CAAC,CACN,QAAQ,qBAAqB,OAAO,CAAC,CACrC,QAAQ,yBAAyB,OAAO,CAAC,CAEzC,QAAQ,+BAA+B,OAAO,CAAC,CAC/C,MAAM,eAAe,CAAC,CACtB,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,MAAM;EAChB,IAAI,KAAK,SAAS,KAAK,SAAS,KAAK,YAAY,GAAG,OAAO;EAE3D,QADa,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,KAC9E,KAAK,MAAM,CAAC;CAC5B,CAAC,CAAC,CACD,KAAK,EAAE,CAAC,CACR,QAAQ,iBAAiB,EAAE;AAElC;AAGA,MAAM,wBAAQ,IAAI,IAAoB;AACtC,MAAM,aAAa;AAEnB,SAAS,gBAAgB,MAAc,QAAyB;CAC9D,MAAM,MAAM,GAAG,SAAS,MAAM,MAAM;CACpC,MAAM,SAAS,MAAM,IAAI,GAAG;CAC5B,IAAI,WAAW,KAAA,GAAW,OAAO;CAEjC,MAAM,SAAS,QAAQ,MAAM,MAAM;CACnC,IAAI,MAAM,QAAQ,YAAY,MAAM,MAAM;CAC1C,MAAM,IAAI,KAAK,MAAM;CACrB,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,UAAU,MAAc,EAAE,SAAS,IAAI,SAAS,OAA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AG,IAAI,CAAC,EAAE,IAAI,CAAC,aAAa,MAAM,oBAAoB,IAAI;CAClF,OAAO,QAAQ,MAAM,UAAU,IAAI,SAAS,MAAM,EAAE,CAAC;AACvD;;;;;;AAOA,SAAgB,iBAAiB,EAAE,SAAS,SAAiF;CAC3H,MAAM,MAAM,MACT,MAAM,GAAG,CAAC,CACV,KAAK,OAAO,GAAG,KAAK,CAAC,CAAC,CACtB,OAAO,OAAO;CACjB,MAAM,UAAU,IAAI,QAAQ,OAAO,CAAC,WAAW;EAAE;EAAS;CAAG,CAAC,CAAC;CAC/D,IAAI,QAAQ,QACV,MAAM,IAAI,YAAY,MAAM;EAC1B,MAAM,YAAY,KAAK;EACvB,UAAU;EACV,SAAS,6BAA6B,QAAQ,KAAK,IAAI,EAAE;EACzD,MAAM;CACR,CAAC;CACH,OAAO,IAAI,KAAK,OAAO,WAAW;EAAE;EAAS;CAAG,CAAC,CAAE;AACrD;;AAGA,eAAsB,kBAAkB,KAA+B;CACrE,MAAM,OAAO,KAAK,KAAK,KAAK,cAAc;CAC1C,MAAM,SAAS,MAAM,KAAK,IAAI;CAC9B,MAAM,cAAc,KAAK,MAAM,MAAM;CACrC,IAAI,YAAY,SAAS,aAAa,KAAA,GAAW,OAAO;CACxD,MAAM,SAAS,OAAO,MAAM,UAAU,CAAC,GAAG,MAAM;CAChD,MAAM,UAAU;EAAE,GAAG;EAAa,SAAS;GAAE,GAAG,YAAY;GAAS,UAAU;EAAgB;CAAE;CACjG,MAAM,MAAM,MAAM,KAAK,UAAU,SAAS,MAAM,MAAM,CAAC;CACvD,OAAO;AACT;;AAGA,eAAsB,eAAe,KAA0C;CAC7E,QAAQ,MAAM,gBAAgB,GAAG,EAAA,CAAG,SAAS;AAC/C"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
|
|
2
|
-
const require_spinner = require("./spinner-
|
|
2
|
+
const require_spinner = require("./spinner-D584jFAz.cjs");
|
|
3
3
|
let node_process = require("node:process");
|
|
4
4
|
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
5
5
|
let tinyexec = require("tinyexec");
|
|
6
|
+
let node_fs = require("node:fs");
|
|
7
|
+
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
6
8
|
let node_fs_promises = require("node:fs/promises");
|
|
7
9
|
let node_path = require("node:path");
|
|
8
10
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
9
|
-
let node_fs = require("node:fs");
|
|
10
|
-
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
11
11
|
let _kubb_core = require("@kubb/core");
|
|
12
12
|
let package_manager_detector = require("package-manager-detector");
|
|
13
13
|
// ../../internals/utils/src/casing.ts
|
|
@@ -319,4 +319,4 @@ Object.defineProperty(exports, "uninstallPackages", {
|
|
|
319
319
|
}
|
|
320
320
|
});
|
|
321
321
|
|
|
322
|
-
//# sourceMappingURL=utils-
|
|
322
|
+
//# sourceMappingURL=utils-C9fYoqP2.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-D19HX-lE.cjs","names":["process","detect","x","resolveCommand","read","path","glob","toPosixPath","fs","Diagnostics","write"],"sources":["../../../internals/utils/src/casing.ts","../src/runners/init/utils.ts"],"sourcesContent":["type Options = {\n /** Text prepended before casing is applied. */\n prefix?: string\n /** Text appended before casing is applied. */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction convert(text: string, pascal: boolean): string {\n return (\n text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n // A status range such as `2xx` stays one word.\n .replace(/(\\d)(?!xx(?![a-z]))([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n )\n}\n\n// Plugins case the same names on every visit. Clearing at the limit bounds a long-running host.\nconst cache = new Map<string, string>()\nconst cacheLimit = 100_000\n\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const key = `${pascal ? 'P' : 'c'}${text}`\n const cached = cache.get(key)\n if (cached !== undefined) return cached\n\n const result = convert(text, pascal)\n if (cache.size >= cacheLimit) cache.clear()\n cache.set(key, result)\n return result\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n// A word starts at `petType`, `sensor2Reading`, and `HTTPResponse`, while `IDs` and `OAuth` stay whole\nconst wordStart = /(?<=[a-z\\d])(?=[A-Z])|(?<=[A-Z]{2})(?=[A-Z][a-z]{2})/\n\n// A segment without lowercase letters, such as `COOL` or `2D`, stays one word, so a snake_case name is left unchanged.\nfunction words(text: string): Array<string> {\n return text\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .flatMap((segment) => (segment === segment.toUpperCase() ? segment : segment.split(wordStart)))\n}\n\n/**\n * Uppercases only the first character of `text`. Unlike `pascalCase` it never splits words or strips characters.\n *\n * @example\n * `capitalize('getPetById') // 'GetPetById'`\n */\nexport function capitalize(text: string): string {\n return `${text.charAt(0).toUpperCase()}${text.slice(1)}`\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example\n * `snakeCase('helloWorld') // 'hello_world'`\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return words(`${prefix} ${text} ${suffix}`)\n .map((word) => word.replace(/[^a-zA-Z0-9]/g, '').toLowerCase())\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example\n * `screamingSnakeCase('helloWorld') // 'HELLO_WORLD'`\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","import fs from 'node:fs'\nimport { glob } from 'node:fs/promises'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { read, toPosixPath, write } from '@internals/utils'\nimport { Diagnostics, type ExtensionManifest, type RegistryEntry } from '@kubb/core'\nimport { type Agent, type AgentName, detect, resolveCommand } from 'package-manager-detector'\nimport { x } from 'tinyexec'\n\nexport type PackageManagerName = Extract<AgentName, 'npm' | 'pnpm' | 'yarn' | 'bun'>\n\n/**\n * A project's package manager: `name` for messages, `agent` for `resolveCommand`.\n */\nexport type PackageManagerInfo = { name: PackageManagerName; agent: Agent }\n\n/**\n * Subcommands that create a `package.json`; `package-manager-detector` has no `init` command.\n */\nconst initCommands: Record<PackageManagerName, ReadonlyArray<string>> = { npm: ['init', '-y'], pnpm: ['init'], yarn: ['init', '-y'], bun: ['init', '-y'] }\n\n/** Minimal shape of `package.json` fields read during detection. */\ntype PackageJson = {\n /** The `packageManager` field from `package.json` (e.g. `\"pnpm@9.0.0\"`). */\n packageManager?: string\n scripts?: Record<string, string>\n}\n\n/**\n * Detects the package manager in `cwd`: the `packageManager` field in `package.json`, then a lock file, then `npm`. Parent folders are not searched.\n */\nexport async function detectPackageManager(cwd: string = process.cwd()): Promise<PackageManagerInfo> {\n const found = await detect({ cwd, stopDir: cwd, strategies: ['packageManager-field', 'lockfile'] })\n return found && found.name in initCommands ? (found as PackageManagerInfo) : { name: 'npm', agent: 'npm' }\n}\n\n/**\n * Initializes a new `package.json` at `cwd` using the detected package manager.\n */\nexport async function initPackageJson(cwd: string, packageManager: PackageManagerInfo): Promise<void> {\n await x(packageManager.name, [...initCommands[packageManager.name]], {\n nodeOptions: { cwd, stdio: 'inherit' },\n throwOnError: true,\n })\n}\n\n/** How many trailing lines of a failed install's output the error keeps. */\nconst INSTALL_OUTPUT_LINES = 20\nconst INSTALL_TIMEOUT_MS = 5 * 60_000\n\n/**\n * Installs the given packages at `cwd` using the detected package manager. Each output line goes\n * to `onLine`, so the caller can show it while the install runs; a failed install also keeps the\n * end of the output in the error.\n */\nexport async function installPackages(\n packages: Array<string>,\n packageManager: PackageManagerInfo,\n cwd: string = process.cwd(),\n onLine?: (line: string) => void,\n command: 'add' | 'uninstall' = 'add',\n): Promise<void> {\n const { command: bin, args } = resolveCommand(packageManager.agent, command, command === 'add' ? ['-D', ...packages] : packages)!\n // No stdin, so a package manager that wants input fails instead of waiting. The timeout ends a stalled install.\n const result = x(bin, args, {\n nodeOptions: { cwd, stdio: ['ignore', 'pipe', 'pipe'] },\n timeout: INSTALL_TIMEOUT_MS,\n throwOnError: false,\n })\n const lines: Array<string> = []\n for await (const line of result) {\n lines.push(line)\n onLine?.(line)\n }\n if (result.exitCode === 0) return\n if (result.exitCode === undefined) throw new Error(`\\`${bin} ${args.join(' ')}\\` timed out after ${INSTALL_TIMEOUT_MS / 60_000} minutes`)\n\n const output = lines.slice(-INSTALL_OUTPUT_LINES).join('\\n')\n throw new Error(`\\`${bin} ${args.join(' ')}\\` failed with exit code ${result.exitCode}${output ? `:\\n${output}` : ''}`)\n}\n\n/**\n * Uninstalls the given packages at `cwd` with the package manager's remove command, like {@link installPackages}.\n */\nexport function uninstallPackages(packages: Array<string>, packageManager: PackageManagerInfo, cwd: string = process.cwd()): Promise<void> {\n return installPackages(packages, packageManager, cwd, undefined, 'uninstall')\n}\n\n/**\n * What the selected plugins' `manifests` say is missing from the selection: a `dependencies`\n * entry, or a `client` plugin next to a `consumer`. Empty when nothing is missing.\n * `optionalDependencies` are skipped, since `kubb init` writes the default options.\n */\nexport function missingPluginDependencies(manifests: Array<ExtensionManifest>): Array<string> {\n const selected = manifests.map((manifest) => manifest.name)\n const hasClient = manifests.some((manifest) => manifest.role === 'client')\n return manifests.flatMap((manifest) => [\n ...(manifest.dependencies ?? []).filter((name) => !selected.includes(name)).map((name) => `${manifest.name} needs ${name}.`),\n ...(manifest.role === 'consumer' && !hasClient ? [`${manifest.name} needs a client plugin, such as plugin-axios or plugin-fetch.`] : []),\n ])\n}\n\nasync function readPackageJson(cwd: string): Promise<PackageJson> {\n try {\n return JSON.parse(await read(path.join(cwd, 'package.json'))) as PackageJson\n } catch {\n return {}\n }\n}\n\nconst SPEC_FILE = /^(openapi|swagger)[\\w.-]*\\.(ya?ml|json)$/i\nconst SKIPPED_DIRS = new Set(['node_modules', 'dist', 'build', 'coverage'])\n\n/**\n * Finds OpenAPI spec files up to `depth` folders below `cwd`, shallowest first, as `./`-relative\n * paths. Skips hidden and build folders without walking them and returns at most `limit` files.\n */\nexport async function findSpecFiles(cwd: string, { depth = 3, limit = 20 }: { depth?: number; limit?: number } = {}): Promise<Array<string>> {\n const found: Array<string> = []\n const pattern = `{${Array.from({ length: depth + 1 }, (_, level) => '*/'.repeat(level)).join(',')}}*`\n // The extension stays out of the pattern so SPEC_FILE matches it case-insensitively. Dot folders are skipped by default.\n const files = glob(pattern, { cwd, exclude: (file) => file.split(path.sep).some((segment) => SKIPPED_DIRS.has(segment)) })\n for await (const file of files) if (SPEC_FILE.test(path.basename(file))) found.push(toPosixPath(file))\n return found\n .toSorted((a, b) => a.split('/').length - b.split('/').length || a.localeCompare(b))\n .slice(0, limit)\n .map((file) => `./${file}`)\n}\n\n/** The spec version and operation count, when the file states them. */\nexport type SpecInfo = { version?: string; operations?: number }\n\nconst SPEC_HEAD_BYTES = 256 * 1024\nconst METHOD = '(?:get|put|post|delete|options|head|patch|trace)'\n\n/**\n * Reads the OpenAPI or Swagger version and counts the operations from the first 256 KB of the\n * file, so a large spec is never parsed. The count is left out when the file is longer.\n */\nexport async function readSpecInfo(file: string): Promise<SpecInfo> {\n const handle = await fs.promises.open(file)\n try {\n const buffer = Buffer.alloc(SPEC_HEAD_BYTES)\n const { bytesRead } = await handle.read(buffer, 0, SPEC_HEAD_BYTES, 0)\n const head = buffer.toString('utf-8', 0, bytesRead)\n const complete = bytesRead < SPEC_HEAD_BYTES\n const version = head.match(/^\\s*[\"']?(?:openapi|swagger)[\"']?\\s*:\\s*[\"']?(\\d[\\d.]*)/m)?.[1]\n // shortcut: counts method keys at any depth, so a schema property named `get` counts too; use the adapter when that matters.\n const methods = new RegExp(`^\\\\s*[\"']?${METHOD}[\"']?\\\\s*:\\\\s*(?:\\\\{|$)`, 'gm')\n return { version, operations: complete ? (head.match(methods)?.length ?? 0) : undefined }\n } finally {\n await handle.close()\n }\n}\n\n/** Finds a plugin by registry id, slug, or short name, so `ts`, `plugin-ts`, and `kubb-labs/plugin-ts` all match. */\nexport function findPlugin({ plugins, id }: { plugins: Array<RegistryEntry>; id: string }): RegistryEntry | undefined {\n const ids = id.includes('/') ? [id] : [`kubb-labs/${id}`, `kubb-labs/plugin-${id}`]\n return plugins.find((entry) => ids.includes(entry.id))\n}\n\n/**\n * Turns the comma-separated `--plugins` value into registry entries.\n *\n * @throws when an id is not in `plugins`.\n */\nexport function parsePluginsFlag({ plugins, value }: { plugins: Array<RegistryEntry>; value: string }): Array<RegistryEntry> {\n const ids = value\n .split(',')\n .map((id) => id.trim())\n .filter(Boolean)\n const unknown = ids.filter((id) => !findPlugin({ plugins, id }))\n if (unknown.length)\n throw new Diagnostics.Error({\n code: Diagnostics.code.pluginNotFound,\n severity: 'error',\n message: `Not in the Kubb registry: ${unknown.join(', ')}. Browse the plugins at https://kubb.dev/extensions.`,\n help: 'Use plugin ids from https://kubb.dev/extensions, such as plugin-ts or ts.',\n })\n return ids.map((id) => findPlugin({ plugins, id })!)\n}\n\n/** Adds `\"generate\": \"kubb generate\"` to the `package.json` scripts at `cwd`. Returns `false`, and changes nothing, when a `generate` script exists. */\nexport async function addGenerateScript(cwd: string): Promise<boolean> {\n const file = path.join(cwd, 'package.json')\n const source = await read(file)\n const packageJson = JSON.parse(source) as PackageJson\n if (packageJson.scripts?.generate !== undefined) return false\n const indent = source.match(/^[ \\t]+/m)?.[0] ?? ' '\n const updated = { ...packageJson, scripts: { ...packageJson.scripts, generate: 'kubb generate' } }\n await write(file, JSON.stringify(updated, null, indent))\n return true\n}\n\n/** Reads the `generate` script from the `package.json` at `cwd`. */\nexport async function generateScript(cwd: string): Promise<string | undefined> {\n return (await readPackageJson(cwd)).scripts?.generate\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAcA,SAAS,QAAQ,MAAc,QAAyB;CACtD,OACE,KACG,KAAK,CAAC,CACN,QAAQ,qBAAqB,OAAO,CAAC,CACrC,QAAQ,yBAAyB,OAAO,CAAC,CAEzC,QAAQ,+BAA+B,OAAO,CAAC,CAC/C,MAAM,eAAe,CAAC,CACtB,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,MAAM;EAChB,IAAI,KAAK,SAAS,KAAK,SAAS,KAAK,YAAY,GAAG,OAAO;EAE3D,QADa,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,KAC9E,KAAK,MAAM,CAAC;CAC5B,CAAC,CAAC,CACD,KAAK,EAAE,CAAC,CACR,QAAQ,iBAAiB,EAAE;AAElC;AAGA,MAAM,wBAAQ,IAAI,IAAoB;AACtC,MAAM,aAAa;AAEnB,SAAS,gBAAgB,MAAc,QAAyB;CAC9D,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c,KAAK,MAAM,MAAM;CACrC,IAAI,YAAY,SAAS,aAAa,KAAA,GAAW,OAAO;CACxD,MAAM,SAAS,OAAO,MAAM,UAAU,CAAC,GAAG,MAAM;CAChD,MAAM,UAAU;EAAE,GAAG;EAAa,SAAS;GAAE,GAAG,YAAY;GAAS,UAAU;EAAgB;CAAE;CACjG,MAAMM,gBAAAA,MAAM,MAAM,KAAK,UAAU,SAAS,MAAM,MAAM,CAAC;CACvD,OAAO;AACT;;AAGA,eAAsB,eAAe,KAA0C;CAC7E,QAAQ,MAAM,gBAAgB,GAAG,EAAA,CAAG,SAAS;AAC/C"}
|
|
1
|
+
{"version":3,"file":"utils-C9fYoqP2.cjs","names":["process","detect","x","resolveCommand","read","path","glob","toPosixPath","fs","Diagnostics","write"],"sources":["../../../internals/utils/src/casing.ts","../src/runners/init/utils.ts"],"sourcesContent":["type Options = {\n /** Text prepended before casing is applied. */\n prefix?: string\n /** Text appended before casing is applied. */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction convert(text: string, pascal: boolean): string {\n return (\n text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n // A status range such as `2xx` stays one word.\n .replace(/(\\d)(?!xx(?![a-z]))([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n )\n}\n\n// Plugins case the same names on every visit. Clearing at the limit bounds a long-running host.\nconst cache = new Map<string, string>()\nconst cacheLimit = 100_000\n\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const key = `${pascal ? 'P' : 'c'}${text}`\n const cached = cache.get(key)\n if (cached !== undefined) return cached\n\n const result = convert(text, pascal)\n if (cache.size >= cacheLimit) cache.clear()\n cache.set(key, result)\n return result\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n// A word starts at `petType`, `sensor2Reading`, and `HTTPResponse`, while `IDs` and `OAuth` stay whole\nconst wordStart = /(?<=[a-z\\d])(?=[A-Z])|(?<=[A-Z]{2})(?=[A-Z][a-z]{2})/\n\n// A segment without lowercase letters, such as `COOL` or `2D`, stays one word, so a snake_case name is left unchanged.\nfunction words(text: string): Array<string> {\n return text\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .flatMap((segment) => (segment === segment.toUpperCase() ? segment : segment.split(wordStart)))\n}\n\n/**\n * Uppercases only the first character of `text`. Unlike `pascalCase` it never splits words or strips characters.\n *\n * @example\n * `capitalize('getPetById') // 'GetPetById'`\n */\nexport function capitalize(text: string): string {\n return `${text.charAt(0).toUpperCase()}${text.slice(1)}`\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example\n * `snakeCase('helloWorld') // 'hello_world'`\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return words(`${prefix} ${text} ${suffix}`)\n .map((word) => word.replace(/[^a-zA-Z0-9]/g, '').toLowerCase())\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example\n * `screamingSnakeCase('helloWorld') // 'HELLO_WORLD'`\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","import fs from 'node:fs'\nimport { glob } from 'node:fs/promises'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { read, toPosixPath, write } from '@internals/utils'\nimport { Diagnostics, type ExtensionManifest, type RegistryEntry } from '@kubb/core'\nimport { type Agent, type AgentName, detect, resolveCommand } from 'package-manager-detector'\nimport { x } from 'tinyexec'\n\nexport type PackageManagerName = Extract<AgentName, 'npm' | 'pnpm' | 'yarn' | 'bun'>\n\n/**\n * A project's package manager: `name` for messages, `agent` for `resolveCommand`.\n */\nexport type PackageManagerInfo = { name: PackageManagerName; agent: Agent }\n\n/**\n * Subcommands that create a `package.json`; `package-manager-detector` has no `init` command.\n */\nconst initCommands: Record<PackageManagerName, ReadonlyArray<string>> = { npm: ['init', '-y'], pnpm: ['init'], yarn: ['init', '-y'], bun: ['init', '-y'] }\n\n/** Minimal shape of `package.json` fields read during detection. */\ntype PackageJson = {\n /** The `packageManager` field from `package.json` (e.g. `\"pnpm@9.0.0\"`). */\n packageManager?: string\n scripts?: Record<string, string>\n}\n\n/**\n * Detects the package manager in `cwd`: the `packageManager` field in `package.json`, then a lock file, then `npm`. Parent folders are not searched.\n */\nexport async function detectPackageManager(cwd: string = process.cwd()): Promise<PackageManagerInfo> {\n const found = await detect({ cwd, stopDir: cwd, strategies: ['packageManager-field', 'lockfile'] })\n return found && found.name in initCommands ? (found as PackageManagerInfo) : { name: 'npm', agent: 'npm' }\n}\n\n/**\n * Initializes a new `package.json` at `cwd` using the detected package manager.\n */\nexport async function initPackageJson(cwd: string, packageManager: PackageManagerInfo): Promise<void> {\n await x(packageManager.name, [...initCommands[packageManager.name]], {\n nodeOptions: { cwd, stdio: 'inherit' },\n throwOnError: true,\n })\n}\n\n/** How many trailing lines of a failed install's output the error keeps. */\nconst INSTALL_OUTPUT_LINES = 20\nconst INSTALL_TIMEOUT_MS = 5 * 60_000\n\n/**\n * Installs the given packages at `cwd` using the detected package manager. Each output line goes\n * to `onLine`, so the caller can show it while the install runs; a failed install also keeps the\n * end of the output in the error.\n */\nexport async function installPackages(\n packages: Array<string>,\n packageManager: PackageManagerInfo,\n cwd: string = process.cwd(),\n onLine?: (line: string) => void,\n command: 'add' | 'uninstall' = 'add',\n): Promise<void> {\n const { command: bin, args } = resolveCommand(packageManager.agent, command, command === 'add' ? ['-D', ...packages] : packages)!\n // No stdin, so a package manager that wants input fails instead of waiting. The timeout ends a stalled install.\n const result = x(bin, args, {\n nodeOptions: { cwd, stdio: ['ignore', 'pipe', 'pipe'] },\n timeout: INSTALL_TIMEOUT_MS,\n throwOnError: false,\n })\n const lines: Array<string> = []\n for await (const line of result) {\n lines.push(line)\n onLine?.(line)\n }\n if (result.exitCode === 0) return\n if (result.exitCode === undefined) throw new Error(`\\`${bin} ${args.join(' ')}\\` timed out after ${INSTALL_TIMEOUT_MS / 60_000} minutes`)\n\n const output = lines.slice(-INSTALL_OUTPUT_LINES).join('\\n')\n throw new Error(`\\`${bin} ${args.join(' ')}\\` failed with exit code ${result.exitCode}${output ? `:\\n${output}` : ''}`)\n}\n\n/**\n * Uninstalls the given packages at `cwd` with the package manager's remove command, like {@link installPackages}.\n */\nexport function uninstallPackages(packages: Array<string>, packageManager: PackageManagerInfo, cwd: string = process.cwd()): Promise<void> {\n return installPackages(packages, packageManager, cwd, undefined, 'uninstall')\n}\n\n/**\n * What the selected plugins' `manifests` say is missing from the selection: a `dependencies`\n * entry, or a `client` plugin next to a `consumer`. Empty when nothing is missing.\n * `optionalDependencies` are skipped, since `kubb init` writes the default options.\n */\nexport function missingPluginDependencies(manifests: Array<ExtensionManifest>): Array<string> {\n const selected = manifests.map((manifest) => manifest.name)\n const hasClient = manifests.some((manifest) => manifest.role === 'client')\n return manifests.flatMap((manifest) => [\n ...(manifest.dependencies ?? []).filter((name) => !selected.includes(name)).map((name) => `${manifest.name} needs ${name}.`),\n ...(manifest.role === 'consumer' && !hasClient ? [`${manifest.name} needs a client plugin, such as plugin-axios or plugin-fetch.`] : []),\n ])\n}\n\nasync function readPackageJson(cwd: string): Promise<PackageJson> {\n try {\n return JSON.parse(await read(path.join(cwd, 'package.json'))) as PackageJson\n } catch {\n return {}\n }\n}\n\nconst SPEC_FILE = /^(openapi|swagger)[\\w.-]*\\.(ya?ml|json)$/i\nconst SKIPPED_DIRS = new Set(['node_modules', 'dist', 'build', 'coverage'])\n\n/**\n * Finds OpenAPI spec files up to `depth` folders below `cwd`, shallowest first, as `./`-relative\n * paths. Skips hidden and build folders without walking them and returns at most `limit` files.\n */\nexport async function findSpecFiles(cwd: string, { depth = 3, limit = 20 }: { depth?: number; limit?: number } = {}): Promise<Array<string>> {\n const found: Array<string> = []\n const pattern = `{${Array.from({ length: depth + 1 }, (_, level) => '*/'.repeat(level)).join(',')}}*`\n // The extension stays out of the pattern so SPEC_FILE matches it case-insensitively. Dot folders are skipped by default.\n const files = glob(pattern, { cwd, exclude: (file) => file.split(path.sep).some((segment) => SKIPPED_DIRS.has(segment)) })\n for await (const file of files) if (SPEC_FILE.test(path.basename(file))) found.push(toPosixPath(file))\n return found\n .toSorted((a, b) => a.split('/').length - b.split('/').length || a.localeCompare(b))\n .slice(0, limit)\n .map((file) => `./${file}`)\n}\n\n/** The spec version and operation count, when the file states them. */\nexport type SpecInfo = { version?: string; operations?: number }\n\nconst SPEC_HEAD_BYTES = 256 * 1024\nconst METHOD = '(?:get|put|post|delete|options|head|patch|trace)'\n\n/**\n * Reads the OpenAPI or Swagger version and counts the operations from the first 256 KB of the\n * file, so a large spec is never parsed. The count is left out when the file is longer.\n */\nexport async function readSpecInfo(file: string): Promise<SpecInfo> {\n const handle = await fs.promises.open(file)\n try {\n const buffer = Buffer.alloc(SPEC_HEAD_BYTES)\n const { bytesRead } = await handle.read(buffer, 0, SPEC_HEAD_BYTES, 0)\n const head = buffer.toString('utf-8', 0, bytesRead)\n const complete = bytesRead < SPEC_HEAD_BYTES\n const version = head.match(/^\\s*[\"']?(?:openapi|swagger)[\"']?\\s*:\\s*[\"']?(\\d[\\d.]*)/m)?.[1]\n // shortcut: counts method keys at any depth, so a schema property named `get` counts too; use the adapter when that matters.\n const methods = new RegExp(`^\\\\s*[\"']?${METHOD}[\"']?\\\\s*:\\\\s*(?:\\\\{|$)`, 'gm')\n return { version, operations: complete ? (head.match(methods)?.length ?? 0) : undefined }\n } finally {\n await handle.close()\n }\n}\n\n/** Finds a plugin by registry id, slug, or short name, so `ts`, `plugin-ts`, and `kubb-labs/plugin-ts` all match. */\nexport function findPlugin({ plugins, id }: { plugins: Array<RegistryEntry>; id: string }): RegistryEntry | undefined {\n const ids = id.includes('/') ? [id] : [`kubb-labs/${id}`, `kubb-labs/plugin-${id}`]\n return plugins.find((entry) => ids.includes(entry.id))\n}\n\n/**\n * Turns the comma-separated `--plugins` value into registry entries.\n *\n * @throws when an id is not in `plugins`.\n */\nexport function parsePluginsFlag({ plugins, value }: { plugins: Array<RegistryEntry>; value: string }): Array<RegistryEntry> {\n const ids = value\n .split(',')\n .map((id) => id.trim())\n .filter(Boolean)\n const unknown = ids.filter((id) => !findPlugin({ plugins, id }))\n if (unknown.length)\n throw new Diagnostics.Error({\n code: Diagnostics.code.pluginNotFound,\n severity: 'error',\n message: `Not in the Kubb registry: ${unknown.join(', ')}. Browse the plugins at https://kubb.dev/extensions.`,\n help: 'Use plugin ids from https://kubb.dev/extensions, such as plugin-ts or ts.',\n })\n return ids.map((id) => findPlugin({ plugins, id })!)\n}\n\n/** Adds `\"generate\": \"kubb generate\"` to the `package.json` scripts at `cwd`. Returns `false`, and changes nothing, when a `generate` script exists. */\nexport async function addGenerateScript(cwd: string): Promise<boolean> {\n const file = path.join(cwd, 'package.json')\n const source = await read(file)\n const packageJson = JSON.parse(source) as PackageJson\n if (packageJson.scripts?.generate !== undefined) return false\n const indent = source.match(/^[ \\t]+/m)?.[0] ?? ' '\n const updated = { ...packageJson, scripts: { ...packageJson.scripts, generate: 'kubb generate' } }\n await write(file, JSON.stringify(updated, null, indent))\n return true\n}\n\n/** Reads the `generate` script from the `package.json` at `cwd`. */\nexport async function generateScript(cwd: string): Promise<string | undefined> {\n return (await readPackageJson(cwd)).scripts?.generate\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAcA,SAAS,QAAQ,MAAc,QAAyB;CACtD,OACE,KACG,KAAK,CAAC,CACN,QAAQ,qBAAqB,OAAO,CAAC,CACrC,QAAQ,yBAAyB,OAAO,CAAC,CAEzC,QAAQ,+BAA+B,OAAO,CAAC,CAC/C,MAAM,eAAe,CAAC,CACtB,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,MAAM;EAChB,IAAI,KAAK,SAAS,KAAK,SAAS,KAAK,YAAY,GAAG,OAAO;EAE3D,QADa,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,KAC9E,KAAK,MAAM,CAAC;CAC5B,CAAC,CAAC,CACD,KAAK,EAAE,CAAC,CACR,QAAQ,iBAAiB,EAAE;AAElC;AAGA,MAAM,wBAAQ,IAAI,IAAoB;AACtC,MAAM,aAAa;AAEnB,SAAS,gBAAgB,MAAc,QAAyB;CAC9D,MAAM,MAAM,GAAG,SAAS,MAAM,MAAM;CACpC,MAAM,SAAS,MAAM,IAAI,GAAG;CAC5B,IAAI,WAAW,KAAA,GAAW,OAAO;CAEjC,MAAM,SAAS,QAAQ,MAAM,MAAM;CACnC,IAAI,MAAM,QAAQ,YAAY,MAAM,MAAM;CAC1C,MAAM,IAAI,KAAK,MAAM;CACrB,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,UAAU,MAAc,EAAE,SA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OAAO;AACT;;AAGA,eAAsB,eAAe,KAA0C;CAC7E,QAAQ,MAAM,gBAAgB,GAAG,EAAA,CAAG,SAAS;AAC/C"}
|
|
@@ -16,7 +16,7 @@ const command = define({
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
async run({ values }) {
|
|
19
|
-
const { run } = await import("./run-
|
|
19
|
+
const { run } = await import("./run-ixh050Ip.js");
|
|
20
20
|
await run({
|
|
21
21
|
input: values.input,
|
|
22
22
|
configPath: values.config
|
|
@@ -25,4 +25,4 @@ const command = define({
|
|
|
25
25
|
});
|
|
26
26
|
export { command };
|
|
27
27
|
|
|
28
|
-
//# sourceMappingURL=validate-
|
|
28
|
+
//# sourceMappingURL=validate-BuStuH_z.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-
|
|
1
|
+
{"version":3,"file":"validate-BuStuH_z.js","names":[],"sources":["../src/commands/validate.ts"],"sourcesContent":["import { define } from 'gunshi'\nimport { configArg } from './shared.ts'\n\n/** The runner is imported when the command runs, so listing `kubb --help` never loads `@kubb/adapter-oas`. */\nexport const command = define({\n name: 'validate',\n description: 'Check a specification with the configured adapter before generating.',\n examples: ['kubb validate ./openapi.yaml', 'kubb validate https://petstore3.swagger.io/api/v3/openapi.json'].join('\\n'),\n args: {\n ...configArg,\n input: {\n type: 'positional',\n description: 'Path or URL to the specification to validate',\n required: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/validate/run.ts')\n await run({ input: values.input, configPath: values.config })\n },\n})\n"],"mappings":";;;;;AAIA,MAAa,UAAU,OAAO;CAC5B,MAAM;CACN,aAAa;CACb,UAAU,CAAC,gCAAgC,gEAAgE,CAAC,CAAC,KAAK,IAAI;CACtH,MAAM;EACJ,GAAG;EACH,OAAO;GACL,MAAM;GACN,aAAa;GACb,UAAU;EACZ;CACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAC7B,MAAM,IAAI;GAAE,OAAO,OAAO;GAAO,YAAY,OAAO;EAAO,CAAC;CAC9D;AACF,CAAC"}
|
|
@@ -15,7 +15,7 @@ const command = (0, require("gunshi").define)({
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
async run({ values }) {
|
|
18
|
-
const { run } = await Promise.resolve().then(() => require("./run-
|
|
18
|
+
const { run } = await Promise.resolve().then(() => require("./run-Bxqg0GuI.cjs"));
|
|
19
19
|
await run({
|
|
20
20
|
input: values.input,
|
|
21
21
|
configPath: values.config
|
|
@@ -24,4 +24,4 @@ const command = (0, require("gunshi").define)({
|
|
|
24
24
|
});
|
|
25
25
|
exports.command = command;
|
|
26
26
|
|
|
27
|
-
//# sourceMappingURL=validate-
|
|
27
|
+
//# sourceMappingURL=validate-rr0LpFhN.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-
|
|
1
|
+
{"version":3,"file":"validate-rr0LpFhN.cjs","names":["define","configArg"],"sources":["../src/commands/validate.ts"],"sourcesContent":["import { define } from 'gunshi'\nimport { configArg } from './shared.ts'\n\n/** The runner is imported when the command runs, so listing `kubb --help` never loads `@kubb/adapter-oas`. */\nexport const command = define({\n name: 'validate',\n description: 'Check a specification with the configured adapter before generating.',\n examples: ['kubb validate ./openapi.yaml', 'kubb validate https://petstore3.swagger.io/api/v3/openapi.json'].join('\\n'),\n args: {\n ...configArg,\n input: {\n type: 'positional',\n description: 'Path or URL to the specification to validate',\n required: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/validate/run.ts')\n await run({ input: values.input, configPath: values.config })\n },\n})\n"],"mappings":";;;;AAIA,MAAa,WAAA,G,gBAAUA,CAAAA,CAAAA,OAAAA,CAAO;CAC5B,MAAM;CACN,aAAa;CACb,UAAU,CAAC,gCAAgC,gEAAgE,CAAC,CAAC,KAAK,IAAI;CACtH,MAAM;EACJ,GAAGC,eAAAA;EACH,OAAO;GACL,MAAM;GACN,aAAa;GACb,UAAU;EACZ;CACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EACtB,MAAM,IAAI;GAAE,OAAO,OAAO;GAAO,YAAY,OAAO;EAAO,CAAC;CAC9D;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/cli",
|
|
3
|
-
"version": "5.18.
|
|
3
|
+
"version": "5.18.8",
|
|
4
4
|
"description": "Official CLI for Kubb. Run kubb generate, kubb init, kubb validate, kubb studio, and kubb mcp to manage the full code generation lifecycle.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@clack/prompts": "^1.9.0",
|
|
70
70
|
"@gunshi/plugin-dryrun": "^0.37.3",
|
|
71
|
-
"@kubb/core": "^5.18.
|
|
71
|
+
"@kubb/core": "^5.18.8",
|
|
72
72
|
"chokidar": "^6.0.0",
|
|
73
73
|
"gunshi": "^0.37.3",
|
|
74
74
|
"jiti": "^2.7.0",
|
|
@@ -80,13 +80,13 @@
|
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@internals/shared": "0.0.1",
|
|
82
82
|
"@internals/utils": "0.0.1",
|
|
83
|
-
"@kubb/adapter-oas": "5.18.
|
|
84
|
-
"@kubb/studio": "5.18.
|
|
83
|
+
"@kubb/adapter-oas": "5.18.8",
|
|
84
|
+
"@kubb/studio": "5.18.8"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
|
-
"@kubb/adapter-oas": "5.18.
|
|
88
|
-
"@kubb/mcp": "5.18.
|
|
89
|
-
"@kubb/studio": "5.18.
|
|
87
|
+
"@kubb/adapter-oas": "5.18.8",
|
|
88
|
+
"@kubb/mcp": "5.18.8",
|
|
89
|
+
"@kubb/studio": "5.18.8"
|
|
90
90
|
},
|
|
91
91
|
"peerDependenciesMeta": {
|
|
92
92
|
"@kubb/adapter-oas": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-BqDpLCPu.js","names":[],"sources":["../../../internals/shared/src/constants.ts","../../../internals/shared/src/loader.ts","../../../internals/shared/src/config.ts"],"sourcesContent":["export const KUBB_CONFIG_FILENAME = 'kubb.config.ts' as const\n\n/** File extensions a Kubb config file may use. */\nexport const CONFIG_EXTENSIONS = ['.ts', '.mts', '.cts', '.js', '.mjs', '.cjs'] as const\n\nexport const KUBB_PACKAGE_NAME = 'kubb' as const\n\n/**\n * Extensions `kubb` ships at its own version, so they count as installed without being a direct\n * dependency. `constants.test.ts` checks it against the `kubb` package's dependencies.\n */\nexport const BUNDLED_PACKAGES: ReadonlyArray<string> = ['@kubb/adapter-oas', '@kubb/parser-ts', '@kubb/parser-md', '@kubb/plugin-barrel']\n\nexport const initDefaults = {\n inputPath: './openapi.yaml',\n outputPath: './src/gen',\n plugins: ['plugin-ts'],\n} as const\n","import { readFile } from 'node:fs/promises'\nimport { createJiti } from 'jiti'\n\n/**\n * jiti options for loading Kubb config modules: the automatic JSX runtime pointed at\n * `@kubb/renderer-jsx`, and `moduleCache` off so a re-load re-evaluates the file.\n */\nconst JITI_OPTIONS = {\n jsx: { runtime: 'automatic', importSource: '@kubb/renderer-jsx' },\n moduleCache: false,\n} satisfies Parameters<typeof createJiti>[1]\n\n/**\n * Plain JavaScript files. jiti hands these to Node's native `import()`, whose module cache never\n * lets go of a file, so `moduleCache: false` alone would keep returning the first version of it.\n */\nconst JAVASCRIPT_EXTENSION = /\\.[cm]?jsx?$/\n\n/**\n * Per-call options for {@link loadModule}.\n */\ntype LoadModuleOptions = {\n /**\n * Return the module's default export instead of the full namespace.\n */\n default?: boolean\n}\n\nconst jiti = createJiti(import.meta.url, JITI_OPTIONS)\n\n/**\n * Loads a Kubb TypeScript or JavaScript config module via jiti.\n *\n * jiti transpiles TypeScript and the `@kubb/renderer-jsx` JSX runtime on the fly. Every load\n * re-evaluates the file, so a config edited on disk is picked up by the next load.\n *\n * @example\n * ```ts\n * const config = await loadModule('/abs/kubb.config.ts', { default: true })\n * ```\n */\nexport async function loadModule<T = unknown>(filePath: string, options?: LoadModuleOptions): Promise<T> {\n if (!JAVASCRIPT_EXTENSION.test(filePath)) {\n return (options?.default ? jiti.import(filePath, { default: true }) : jiti.import(filePath)) as Promise<T>\n }\n\n // Transpiled through jiti instead, so every load re-evaluates the file as it is on disk now.\n // A TypeScript file it imports reloads too. A plain JavaScript file it imports still goes\n // through Node's `import()` and stays cached until the process restarts.\n const mod = (await jiti.evalModule(await readFile(filePath, 'utf8'), { filename: filePath, async: true, forceTranspile: true })) as\n | { default?: unknown }\n | undefined\n return (options?.default ? (mod?.default ?? mod) : mod) as T\n}\n","import { existsSync } from 'node:fs'\nimport { basename, dirname, join, resolve } from 'node:path'\nimport process from 'node:process'\nimport { CONFIG_EXTENSIONS } from './constants.ts'\nimport { loadModule } from './loader.ts'\n\n// A config in one of these folders belongs to the folder above it.\nconst CONFIG_FOLDERS = ['.config', 'configs']\nconst SEARCH_FILES = ['', ...CONFIG_FOLDERS.map((folder) => `${folder}/`)].flatMap((prefix) => [`${prefix}.kubbrc`, `${prefix}kubb.config`])\n\n/**\n * Every config file path the Kubb CLI checks in `dir`, in the order it checks them.\n */\nexport function configFileCandidates(dir: string): Array<string> {\n return SEARCH_FILES.flatMap((file) => CONFIG_EXTENSIONS.map((extension) => join(dir, `${file}${extension}`)))\n}\n\n/**\n * The first Kubb config file in `cwd` or the nearest parent folder that has one: `.kubbrc` before\n * `kubb.config`, the folder itself before its `.config/` and `configs/`, and {@link CONFIG_EXTENSIONS} in order.\n */\nexport function findConfigFile(cwd: string = process.cwd()): string | undefined {\n for (let dir = resolve(cwd); ; dir = dirname(dir)) {\n const found = configFileCandidates(dir).find((file) => existsSync(file))\n if (found || dirname(dir) === dir) return found\n }\n}\n\n/**\n * Loads a Kubb config module, calls it with `cli` when it exports a function, and returns its\n * configs as a list, so a single config and a `defineConfig([...])` array read the same. Each\n * `root` resolves from the folder the config belongs to: the file's folder, or the folder above\n * `.config/` and `configs/`. A missing `root` becomes that folder, so the CLI, the bundler, and\n * an editor read the same paths wherever they run.\n */\nexport async function loadConfigFile<T extends { root?: string }>({ file, cli }: { file: string; cli: unknown }): Promise<Array<T>> {\n const loaded = await loadModule<unknown>(file, { default: true })\n const resolved = (await (typeof loaded === 'function' ? loaded(cli) : loaded)) as T | Array<T>\n const dir = CONFIG_FOLDERS.includes(basename(dirname(file))) ? dirname(dirname(file)) : dirname(file)\n return (Array.isArray(resolved) ? resolved : [resolved]).map((config) => ({ ...config, root: resolve(dir, config.root ?? '.') }))\n}\n"],"mappings":";;;;;;;AAAA,MAAa,uBAAuB;;AAGpC,MAAa,oBAAoB;CAAC;CAAO;CAAQ;CAAQ;CAAO;CAAQ;AAAM;AAE9E,MAAa,oBAAoB;;;;;AAMjC,MAAa,mBAA0C;CAAC;CAAqB;CAAmB;CAAmB;AAAqB;AAExI,MAAa,eAAe;CAC1B,WAAW;CACX,YAAY;CACZ,SAAS,CAAC,WAAW;AACvB;;;;;;ACVA,MAAM,eAAe;CACnB,KAAK;EAAE,SAAS;EAAa,cAAc;CAAqB;CAChE,aAAa;AACf;;;;;AAMA,MAAM,uBAAuB;AAY7B,MAAM,OAAO,WAAW,YAAY,KAAK,YAAY;;;;;;;;;;;;AAarD,eAAsB,WAAwB,UAAkB,SAAyC;CACvG,IAAI,CAAC,qBAAqB,KAAK,QAAQ,GACrC,OAAQ,SAAS,UAAU,KAAK,OAAO,UAAU,EAAE,SAAS,KAAK,CAAC,IAAI,KAAK,OAAO,QAAQ;CAM5F,MAAM,MAAO,MAAM,KAAK,WAAW,MAAM,SAAS,UAAU,MAAM,GAAG;EAAE,UAAU;EAAU,OAAO;EAAM,gBAAgB;CAAK,CAAC;CAG9H,OAAQ,SAAS,UAAW,KAAK,WAAW,MAAO;AACrD;;AC9CA,MAAM,iBAAiB,CAAC,WAA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