@kubb/cli 5.8.4 → 5.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/dist/{Telemetry-Ci7sRy6A.js → Telemetry-BivZAaw9.js} +2 -2
- package/dist/{Telemetry-Ci7sRy6A.js.map → Telemetry-BivZAaw9.js.map} +1 -1
- package/dist/{Telemetry-DKccmt8g.cjs → Telemetry-D1jiXfo2.cjs} +2 -2
- package/dist/{Telemetry-DKccmt8g.cjs.map → Telemetry-D1jiXfo2.cjs.map} +1 -1
- package/dist/{background-B7VAPM7b.cjs → background-Cd2TGkLg.cjs} +2 -2
- package/dist/{background-B7VAPM7b.cjs.map → background-Cd2TGkLg.cjs.map} +1 -1
- package/dist/background-D0UaV1ZP.js +1 -0
- package/dist/{background-CnSPyAn7.js → background-uIIElWXl.js} +2 -2
- package/dist/{background-CnSPyAn7.js.map → background-uIIElWXl.js.map} +1 -1
- package/dist/{commands-Cgmj9PsM.js → commands-BlNFxWKB.js} +3 -3
- package/dist/{commands-Cgmj9PsM.js.map → commands-BlNFxWKB.js.map} +1 -1
- package/dist/{commands-CLUcjHHU.cjs → commands-ID-cYLXW.cjs} +3 -3
- package/dist/{commands-CLUcjHHU.cjs.map → commands-ID-cYLXW.cjs.map} +1 -1
- package/dist/index.cjs +13 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -12
- package/dist/index.js.map +1 -1
- package/dist/{run-9oIapU5y.js → run-BF2Wq1Io.js} +3 -3
- package/dist/{run-9oIapU5y.js.map → run-BF2Wq1Io.js.map} +1 -1
- package/dist/{run-CMkKa1rU.cjs → run-CNXBX4kr.cjs} +2 -2
- package/dist/{run-CMkKa1rU.cjs.map → run-CNXBX4kr.cjs.map} +1 -1
- package/dist/{run-CQKXIa2D.cjs → run-D4cZ-1zg.cjs} +2 -2
- package/dist/{run-CQKXIa2D.cjs.map → run-D4cZ-1zg.cjs.map} +1 -1
- package/dist/{run-BnCdDjXH.cjs → run-DSeEZTnT.cjs} +3 -3
- package/dist/{run-BnCdDjXH.cjs.map → run-DSeEZTnT.cjs.map} +1 -1
- package/dist/{run-ClLBHOpl.cjs → run-DfkvTomI.cjs} +2 -2
- package/dist/{run-ClLBHOpl.cjs.map → run-DfkvTomI.cjs.map} +1 -1
- package/dist/{run-IkpyXtut.js → run-DnXUzX34.js} +2 -2
- package/dist/{run-IkpyXtut.js.map → run-DnXUzX34.js.map} +1 -1
- package/dist/{run-99Go42ib.js → run-ajUuT3vK.js} +2 -2
- package/dist/{run-99Go42ib.js.map → run-ajUuT3vK.js.map} +1 -1
- package/dist/{run-BSQJrncc.js → run-mx0KM8y5.js} +2 -2
- package/dist/{run-BSQJrncc.js.map → run-mx0KM8y5.js.map} +1 -1
- package/dist/{snapshot-2q9d9Dqg.js → snapshot-CHKxNlYg.js} +3 -3
- package/dist/{snapshot-2q9d9Dqg.js.map → snapshot-CHKxNlYg.js.map} +1 -1
- package/dist/{snapshot-CXplfGXC.cjs → snapshot-D5OaRDf9.cjs} +3 -3
- package/dist/{snapshot-CXplfGXC.cjs.map → snapshot-D5OaRDf9.cjs.map} +1 -1
- package/dist/studioWorker.js +2 -2
- package/package.json +7 -7
- package/dist/background-CATamspG.js +0 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["command","define","command","defineWithTypes","dryRunId","command","defineWithTypes","dryRunId","command","define","command","define","command","define","command","define","connectCommand","command","define","command","define","command","define","connectCommand","command","define","command","define","connectCommand","startCommand","loginCommand","logoutCommand","statusCommand","snapshotCommand","command","define","define","styleText","isTelemetryDisabled","styleText","cli","generateCommand","initCommand","validateCommand","mcpCommand","studioCommand","addCommand","updateCommand","listCommand","dryrun"],"sources":["../src/commands/shared.ts","../src/commands/add.ts","../src/commands/generate.ts","../src/commands/init.ts","../src/commands/list.ts","../src/commands/mcp.ts","../src/commands/studio/connect.ts","../src/commands/studio/login.ts","../src/commands/studio/logout.ts","../src/commands/studio/snapshot.ts","../src/commands/studio/background.ts","../src/commands/studio/status.ts","../src/commands/studio/index.ts","../src/commands/update.ts","../src/commands/validate.ts","../src/deprecatedFlags.ts","../src/index.ts"],"sourcesContent":["import { pluginId as dryRunId } from '@gunshi/plugin-dryrun'\nimport type { DryRunExtension } from '@gunshi/plugin-dryrun'\n\nexport { dryRunId }\n\n/** Extension shape gunshi's command context carries with `@gunshi/plugin-dryrun`; the `extensions` type parameter of `defineWithTypes`. */\nexport type DryRunExtensions = {\n [dryRunId]: DryRunExtension\n}\n\nexport const configArg = {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n} as const\n\nexport const yesArg = {\n yes: {\n type: 'boolean',\n description: 'Skip the confirmation',\n short: 'y',\n default: false,\n },\n} as const\n\nexport const logLevelArg = {\n logLevel: {\n type: 'enum',\n choices: ['silent', 'info', 'verbose'] as const,\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n toKebab: true,\n },\n} as const\n\nexport const studioConnectionArgs = {\n url: {\n type: 'string',\n description: 'Base URL of the Kubb Studio instance',\n },\n token: {\n type: 'string',\n description: 'Organization CI API key for `snapshot`. Defaults to KUBB_TOKEN',\n },\n} as const\n\nexport const studioPermissionArgs = {\n allowRead: {\n type: 'boolean',\n description: 'Read the source of files a generation produced. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowWrite: {\n type: 'boolean',\n description: 'Write generated files to disk. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowConfigEdit: {\n type: 'boolean',\n description: 'Let Studio change plugin options in kubb.config.ts. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowExec: {\n type: 'boolean',\n description: 'Run the formatter, the linter, and output.postGenerate after a generation',\n default: false,\n toKebab: true,\n },\n} as const\n","import { define } from 'gunshi'\nimport { configArg, yesArg } from './shared.ts'\n\nexport const command = define({\n name: 'add',\n description:\n 'Install a plugin, adapter, or parser from the Kubb registry at its reviewed version. A plugin is added to kubb.config.ts, an adapter or parser prints the code to add. Reads KUBB_REGISTRY to use another registry.',\n examples: ['kubb add plugin-zod', 'kubb add kubb-labs/plugin-react-query', 'kubb add acme/plugin-x --yes', 'kubb add plugin-zod --no-install'].join('\\n'),\n toKebab: true,\n args: {\n id: {\n type: 'positional',\n description: 'Registry id: owner/slug, or a slug for an official extension',\n required: true,\n },\n ...configArg,\n ...yesArg,\n install: {\n type: 'boolean',\n description: 'Install the package. Pass --no-install to only edit the config',\n negatable: true,\n default: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/add/run.ts')\n await run({ id: values.id, configPath: values.config, yes: values.yes, install: values.install })\n },\n})\n","import { defineWithTypes } from 'gunshi'\nimport type { ReporterName } from '@kubb/core'\nimport { configArg, dryRunId, type DryRunExtensions, logLevelArg } from './shared.ts'\n\nconst REPORTER_NAMES: Array<ReporterName> = ['cli', 'json', 'file', 'html']\n\n/**\n * Splits and validates the comma-separated `--reporter` value against the known reporter names.\n */\nfunction parseReporters(value: string): Array<ReporterName> {\n const names = value\n .split(',')\n .map((name) => name.trim())\n .filter(Boolean)\n\n for (const name of names) {\n if (!REPORTER_NAMES.includes(name as ReporterName)) {\n throw new Error(`must be one of cli, json, file, html (got \"${name}\")`)\n }\n }\n\n return names as Array<ReporterName>\n}\n\n/**\n * Resolves the effective log level, letting the `--verbose` and `--silent` flags win over `--log-level`.\n */\nfunction resolveLogLevel({ verbose, silent, logLevel }: { verbose: boolean; silent: boolean; logLevel: string }): string {\n if (verbose) return 'verbose'\n if (silent) return 'silent'\n return logLevel\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'generate',\n description:\n 'Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.',\n examples: [\n 'kubb generate # generate from kubb.config.ts',\n 'kubb generate ./openapi.yaml # generate from this spec instead of the config input',\n 'kubb generate --config kubb.config.ts',\n 'kubb generate --watch # regenerate whenever the spec changes',\n 'kubb generate --dry-run # preview the run without writing files',\n 'kubb generate --reporter html # write an HTML run report',\n 'kubb studio # connect this project to Kubb Studio and generate from the browser',\n 'kubb studio --allow-write # let Studio write the generated files to disk',\n 'kubb studio login # pair this machine with Studio without connecting',\n ].join('\\n'),\n toKebab: true,\n args: {\n input: {\n type: 'positional',\n required: false,\n description: 'Path to the OpenAPI specification, overriding the config',\n },\n ...configArg,\n ...logLevelArg,\n watch: {\n type: 'boolean',\n description: 'Watch mode: watches an input file for changes, or polls an input URL',\n short: 'w',\n default: false,\n },\n verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\n default: false,\n },\n silent: {\n type: 'boolean',\n description: 'Override logLevel to silent',\n short: 's',\n default: false,\n },\n reporter: {\n type: 'custom',\n description: 'Reporters that render the run: cli, json, file, html. Comma-separated. Overrides config.reporters',\n metavar: 'cli|json|file|html',\n parse: parseReporters,\n },\n },\n async run(ctx) {\n const { values } = ctx\n const logLevel = resolveLogLevel(values)\n const { run } = await import('../runners/generate/run.ts')\n\n await run({\n input: values.input,\n configPath: values.config,\n logLevel,\n watch: values.watch,\n reporters: values.reporter,\n dryRun: ctx.extensions[dryRunId].enabled,\n })\n },\n})\n","import { defineWithTypes } from 'gunshi'\nimport { dryRunId, type DryRunExtensions } from './shared.ts'\nimport { version } from '../../package.json'\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'init',\n description:\n 'Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n 'kubb init --yes --dry-run',\n ].join('\\n'),\n toKebab: true,\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use default options',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n async run(ctx) {\n const { values } = ctx\n const { run } = await import('../runners/init/run.ts')\n\n await run({\n yes: values.yes,\n version,\n input: values.input,\n output: values.output,\n plugins: values.plugins,\n dryRun: ctx.extensions[dryRunId],\n })\n },\n})\n","import { define } from 'gunshi'\n\nexport const command = define({\n name: 'list',\n description:\n 'List the installed Kubb extensions: their registry id, package, installed version, the version the Kubb registry pins, and whether an update exists.',\n examples: 'kubb list',\n async run() {\n const { run } = await import('../runners/list/run.ts')\n await run()\n },\n})\n","import { define } from 'gunshi'\n\n/** The runner is imported when the command runs, so listing `kubb --help` never loads `@kubb/mcp`. */\nexport const command = define({\n name: 'mcp',\n description:\n 'Start a Model Context Protocol (MCP) server that exposes Kubb code generation as tools for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect to it — the assistant can then call kubb generate directly without leaving the chat.',\n examples: ['kubb mcp', '# Then add to your MCP client config:', '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }'].join('\\n'),\n async run() {\n const { run } = await import('../runners/mcp/run.ts')\n await run()\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const command = define({\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 toKebab: true,\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 async run(ctx) {\n const { connectRunner } = await import('../../runners/studio/commands.ts')\n await connectRunner(ctx)\n },\n})\n","import { define } from 'gunshi'\nimport { command as connectCommand } from './connect.ts'\n\nexport const command = define({\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 toKebab: true,\n args: connectCommand.args,\n async run(ctx) {\n const { loginRunner } = await import('../../runners/studio/commands.ts')\n await loginRunner(ctx)\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const command = define({\n name: 'logout',\n description: 'Forget the stored Kubb Studio token.',\n examples: ['kubb studio logout'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n ...logLevelArg,\n },\n async run(ctx) {\n const { logoutRunner } = await import('../../runners/studio/commands.ts')\n await logoutRunner(ctx)\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'\n\nexport const command = define({\n name: 'start',\n description: 'Keep this project connected to Kubb Studio in the background.',\n toKebab: true,\n args: connectCommand.args,\n async run(ctx) {\n const { startRunner } = await import('../../runners/studio/commands.ts')\n await startRunner(ctx)\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 { stopRunner } = await import('../../runners/studio/commands.ts')\n await stopRunner()\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const command = define({\n name: 'status',\n description: 'Show the project worker, Kubb Studio pairing, and saved permissions.',\n examples: ['kubb studio status'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n ...logLevelArg,\n },\n async run(ctx) {\n const { statusRunner } = await import('../../runners/studio/commands.ts')\n await statusRunner(ctx)\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 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 name: 'studio',\n description: 'Connect this project to Kubb Studio, or manage its pairing and snapshots.',\n examples: ['kubb studio', 'kubb studio --allow-read', 'kubb studio login', 'kubb studio status', 'kubb studio logout', 'kubb studio snapshot'].join('\\n'),\n toKebab: true,\n args: connectCommand.args,\n async run(ctx) {\n const { connectRunner } = await import('../../runners/studio/commands.ts')\n await connectRunner(ctx)\n },\n subCommands: {\n start: startCommand,\n stop: stopCommand,\n connect: connectCommand,\n login: loginCommand,\n logout: logoutCommand,\n status: statusCommand,\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","import { define } from 'gunshi'\nimport { yesArg } from './shared.ts'\n\nexport const command = define({\n name: 'update',\n description:\n 'Update installed extensions to the version the Kubb registry pins. Pass ids to update only those, or --check to list the updates without installing.',\n examples: ['kubb update', 'kubb update --check', 'kubb update plugin-zod plugin-ts --yes'].join('\\n'),\n args: {\n ids: {\n type: 'positional',\n description: 'Registry ids to update, all installed extensions when omitted',\n multiple: true,\n },\n check: {\n type: 'boolean',\n description: 'List the available updates without installing them',\n default: false,\n },\n ...yesArg,\n },\n async run({ values }) {\n const { run } = await import('../runners/update/run.ts')\n await run({ ids: values.ids ?? [], check: values.check, yes: values.yes })\n },\n})\n","import { define } from 'gunshi'\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:\n 'Parse and validate an OpenAPI/Swagger file for structural correctness. Reports schema errors, missing required fields, and malformed references. Use this before running generate to catch spec issues early.',\n examples: ['kubb validate ./openapi.yaml', 'kubb validate https://petstore3.swagger.io/api/v3/openapi.json'].join('\\n'),\n args: {\n input: {\n type: 'positional',\n description: 'Path or URL to the OpenAPI/Swagger file 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 })\n },\n})\n","import { styleText } from 'node:util'\n\n/**\n * Maps each camelCase flag removed in favor of kebab-case (kubb-labs/kubb#4046) to its\n * replacement. Drop this table, and the rewrite it drives, once the deprecation window ends.\n */\nconst DEPRECATED_FLAGS: Record<string, string> = {\n allowWrite: 'allow-write',\n allowConfigEdit: 'allow-config-edit',\n allowExec: 'allow-exec',\n logLevel: 'log-level',\n dryRun: 'dry-run',\n packageVersion: 'package-version',\n}\n\nconst FLAG_PATTERN = /^--([a-zA-Z][\\w-]*)(=.*)?$/\n\n/**\n * Rewrites a deprecated camelCase flag to its kebab-case replacement and warns on stderr, so a\n * script written against the old flag names keeps working during the deprecation window instead\n * of failing with an unknown-option error.\n */\nexport function resolveDeprecatedFlags(args: Array<string>): Array<string> {\n return args.map((arg) => {\n const match = FLAG_PATTERN.exec(arg)\n const name = match?.[1]\n const replacement = name ? DEPRECATED_FLAGS[name] : undefined\n\n if (!name || !replacement) {\n return arg\n }\n\n console.error(\n `${styleText('yellow', 'Warning:')} --${name} is deprecated, use --${replacement} instead. --${name} will be removed in a future major version.`,\n )\n\n return `--${replacement}${match?.[2] ?? ''}`\n })\n}\n","import { styleText } from 'node:util'\nimport dryrun from '@gunshi/plugin-dryrun'\nimport { cli } from 'gunshi'\nimport { isDisabled as isTelemetryDisabled } from './Telemetry.ts'\nimport { version } from '../package.json'\nimport { command as addCommand } from './commands/add.ts'\nimport { command as generateCommand } from './commands/generate.ts'\nimport { command as initCommand } from './commands/init.ts'\nimport { command as listCommand } from './commands/list.ts'\nimport { command as mcpCommand } from './commands/mcp.ts'\nimport { command as studioCommand, routeStudioFlags } from './commands/studio/index.ts'\nimport { command as updateCommand } from './commands/update.ts'\nimport { command as validateCommand } from './commands/validate.ts'\nimport { resolveDeprecatedFlags } from './deprecatedFlags.ts'\n\n/** Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these. */\nconst QUIET_FLAGS = new Set<string>(['--help', '-h', '--version', '-v', '--json'])\n\n/**\n * Strips the leading executable + script entries when `process.argv` is passed directly.\n * Handles Node.js (`/usr/bin/node`), Bun (`/usr/local/bin/bun`), Deno, tsx, etc. All runtime\n * executable paths contain a path separator; bare command names do not.\n */\nfunction stripExecArgs(argv: Array<string>): Array<string> {\n const firstArgIsExecutablePath = (argv[0]?.includes('/') || argv[0]?.includes('\\\\')) ?? false\n return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv\n}\n\n/**\n * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a\n * quiet flag is passed, then runs the given command, or `generate` when none is given.\n */\nexport async function run(argv: Array<string> = process.argv): Promise<void> {\n const args = routeStudioFlags(resolveDeprecatedFlags(stripExecArgs(argv)))\n const isQuietFlag = args.some((arg) => QUIET_FLAGS.has(arg))\n\n // stderr, so the notice never lands in a stream a client parses, such as `kubb mcp` stdio.\n if (!isTelemetryDisabled() && !isQuietFlag) {\n console.error(\n `${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \\nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\\n`,\n )\n }\n\n // Each command's `run` imports its runner, so an optional peer (@kubb/adapter-oas, @kubb/mcp, @kubb/studio) loads only when it runs.\n await cli(args, generateCommand, {\n name: 'kubb',\n version,\n // Not `generateCommand.description`: gunshi prints this on every subcommand's help too, so\n // `kubb studio --help` would open with a paragraph about generating types.\n description: 'Generate code from an OpenAPI specification, manage Kubb extensions, or connect the project to Kubb Studio.',\n subCommands: {\n generate: generateCommand,\n init: initCommand,\n validate: validateCommand,\n mcp: mcpCommand,\n studio: studioCommand,\n add: addCommand,\n update: updateCommand,\n list: listCommand,\n },\n fallbackToEntry: true,\n strict: true,\n plugins: [dryrun({ name: 'dry-run' })],\n onErrorCommand: async (_ctx, error) => {\n process.exitCode = 1\n console.error(error)\n },\n })\n}\n"],"mappings":";;;;;;;;AAUA,MAAa,YAAY,EACvB,QAAQ;CACN,MAAM;CACN,aAAa;CACb,OAAO;AACT,EACF;AAEA,MAAa,SAAS,EACpB,KAAK;CACH,MAAM;CACN,aAAa;CACb,OAAO;CACP,SAAS;AACX,EACF;AAEA,MAAa,cA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,aAAa;GACX,UAAUA;GACV,MAAMC;GACN,UAAUC;GACV,KAAKC;GACL,QAAQC;GACR,KAAKC;GACL,QAAQC;GACR,MAAMC;EACR;EACA,iBAAiB;EACjB,QAAQ;EACR,SAAS,EAAA,GAACC,sBAAAA,QAAAA,CAAO,EAAE,MAAM,UAAU,CAAC,CAAC;EACrC,gBAAgB,OAAO,MAAM,UAAU;GACrC,QAAQ,WAAW;GACnB,QAAQ,MAAM,KAAK;EACrB;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["command","define","command","defineWithTypes","dryRunId","command","defineWithTypes","dryRunId","command","define","command","define","command","define","command","define","connectCommand","command","define","command","define","command","define","connectCommand","command","define","command","define","connectCommand","startCommand","loginCommand","logoutCommand","statusCommand","snapshotCommand","command","define","define","styleText","isTelemetryDisabled","styleText","cli","generateCommand","initCommand","validateCommand","mcpCommand","studioCommand","addCommand","updateCommand","listCommand","dryrun"],"sources":["../src/commands/shared.ts","../src/commands/add.ts","../src/commands/generate.ts","../src/commands/init.ts","../src/commands/list.ts","../src/commands/mcp.ts","../src/commands/studio/connect.ts","../src/commands/studio/login.ts","../src/commands/studio/logout.ts","../src/commands/studio/snapshot.ts","../src/commands/studio/background.ts","../src/commands/studio/status.ts","../src/commands/studio/index.ts","../src/commands/update.ts","../src/commands/validate.ts","../src/deprecatedFlags.ts","../src/index.ts"],"sourcesContent":["import { pluginId as dryRunId } from '@gunshi/plugin-dryrun'\nimport type { DryRunExtension } from '@gunshi/plugin-dryrun'\n\nexport { dryRunId }\n\n/** Extension shape gunshi's command context carries with `@gunshi/plugin-dryrun`; the `extensions` type parameter of `defineWithTypes`. */\nexport type DryRunExtensions = {\n [dryRunId]: DryRunExtension\n}\n\nexport const configArg = {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n} as const\n\nexport const yesArg = {\n yes: {\n type: 'boolean',\n description: 'Skip the confirmation',\n short: 'y',\n default: false,\n },\n} as const\n\nexport const logLevelArg = {\n logLevel: {\n type: 'enum',\n choices: ['silent', 'info', 'verbose'] as const,\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n toKebab: true,\n },\n} as const\n\nexport const studioConnectionArgs = {\n url: {\n type: 'string',\n description: 'Base URL of the Kubb Studio instance',\n },\n token: {\n type: 'string',\n description: 'Organization CI API key for `snapshot`. Defaults to KUBB_TOKEN',\n },\n} as const\n\nexport const studioPermissionArgs = {\n allowRead: {\n type: 'boolean',\n description: 'Read the source of files a generation produced. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowWrite: {\n type: 'boolean',\n description: 'Write generated files to disk. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowConfigEdit: {\n type: 'boolean',\n description: 'Let Studio change plugin options in kubb.config.ts. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowExec: {\n type: 'boolean',\n description: 'Run the formatter, the linter, and output.postGenerate after a generation',\n default: false,\n toKebab: true,\n },\n} as const\n","import { define } from 'gunshi'\nimport { configArg, yesArg } from './shared.ts'\n\nexport const command = define({\n name: 'add',\n description:\n 'Install a plugin, adapter, or parser from the Kubb registry at its reviewed version. A plugin is added to kubb.config.ts, an adapter or parser prints the code to add. Reads KUBB_REGISTRY to use another registry.',\n examples: ['kubb add plugin-zod', 'kubb add kubb-labs/plugin-react-query', 'kubb add acme/plugin-x --yes', 'kubb add plugin-zod --no-install'].join('\\n'),\n toKebab: true,\n args: {\n id: {\n type: 'positional',\n description: 'Registry id: owner/slug, or a slug for an official extension',\n required: true,\n },\n ...configArg,\n ...yesArg,\n install: {\n type: 'boolean',\n description: 'Install the package. Pass --no-install to only edit the config',\n negatable: true,\n default: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/add/run.ts')\n await run({ id: values.id, configPath: values.config, yes: values.yes, install: values.install })\n },\n})\n","import { defineWithTypes } from 'gunshi'\nimport type { ReporterName } from '@kubb/core'\nimport { configArg, dryRunId, type DryRunExtensions, logLevelArg } from './shared.ts'\n\nconst REPORTER_NAMES: Array<ReporterName> = ['cli', 'json', 'file', 'html']\n\n/**\n * Splits and validates the comma-separated `--reporter` value against the known reporter names.\n */\nfunction parseReporters(value: string): Array<ReporterName> {\n const names = value\n .split(',')\n .map((name) => name.trim())\n .filter(Boolean)\n\n for (const name of names) {\n if (!REPORTER_NAMES.includes(name as ReporterName)) {\n throw new Error(`must be one of cli, json, file, html (got \"${name}\")`)\n }\n }\n\n return names as Array<ReporterName>\n}\n\n/**\n * Resolves the effective log level, letting the `--verbose` and `--silent` flags win over `--log-level`.\n */\nfunction resolveLogLevel({ verbose, silent, logLevel }: { verbose: boolean; silent: boolean; logLevel: string }): string {\n if (verbose) return 'verbose'\n if (silent) return 'silent'\n return logLevel\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'generate',\n description:\n 'Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.',\n examples: [\n 'kubb generate # generate from kubb.config.ts',\n 'kubb generate ./openapi.yaml # generate from this spec instead of the config input',\n 'kubb generate --config kubb.config.ts',\n 'kubb generate --watch # regenerate whenever the spec changes',\n 'kubb generate --dry-run # preview the run without writing files',\n 'kubb generate --reporter html # write an HTML run report',\n 'kubb studio # connect this project to Kubb Studio and generate from the browser',\n 'kubb studio --allow-write # let Studio write the generated files to disk',\n 'kubb studio login # pair this machine with Studio without connecting',\n ].join('\\n'),\n toKebab: true,\n args: {\n input: {\n type: 'positional',\n required: false,\n description: 'Path to the OpenAPI specification, overriding the config',\n },\n ...configArg,\n ...logLevelArg,\n watch: {\n type: 'boolean',\n description: 'Watch mode: watches an input file for changes, or polls an input URL',\n short: 'w',\n default: false,\n },\n verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\n default: false,\n },\n silent: {\n type: 'boolean',\n description: 'Override logLevel to silent',\n short: 's',\n default: false,\n },\n reporter: {\n type: 'custom',\n description: 'Reporters that render the run: cli, json, file, html. Comma-separated. Overrides config.reporters',\n metavar: 'cli|json|file|html',\n parse: parseReporters,\n },\n },\n async run(ctx) {\n const { values } = ctx\n const logLevel = resolveLogLevel(values)\n const { run } = await import('../runners/generate/run.ts')\n\n await run({\n input: values.input,\n configPath: values.config,\n logLevel,\n watch: values.watch,\n reporters: values.reporter,\n dryRun: ctx.extensions[dryRunId].enabled,\n })\n },\n})\n","import { defineWithTypes } from 'gunshi'\nimport { dryRunId, type DryRunExtensions } from './shared.ts'\nimport { version } from '../../package.json'\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'init',\n description:\n 'Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n 'kubb init --yes --dry-run',\n ].join('\\n'),\n toKebab: true,\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use default options',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n async run(ctx) {\n const { values } = ctx\n const { run } = await import('../runners/init/run.ts')\n\n await run({\n yes: values.yes,\n version,\n input: values.input,\n output: values.output,\n plugins: values.plugins,\n dryRun: ctx.extensions[dryRunId],\n })\n },\n})\n","import { define } from 'gunshi'\n\nexport const command = define({\n name: 'list',\n description:\n 'List the installed Kubb extensions: their registry id, package, installed version, the version the Kubb registry pins, and whether an update exists.',\n examples: 'kubb list',\n async run() {\n const { run } = await import('../runners/list/run.ts')\n await run()\n },\n})\n","import { define } from 'gunshi'\n\n/** The runner is imported when the command runs, so listing `kubb --help` never loads `@kubb/mcp`. */\nexport const command = define({\n name: 'mcp',\n description:\n 'Start a Model Context Protocol (MCP) server that exposes Kubb code generation as tools for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect to it — the assistant can then call kubb generate directly without leaving the chat.',\n examples: ['kubb mcp', '# Then add to your MCP client config:', '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }'].join('\\n'),\n // gunshi prints the header to stdout, which the MCP stdio transport owns.\n rendering: { header: null },\n async run() {\n const { run } = await import('../runners/mcp/run.ts')\n await run()\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const command = define({\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 toKebab: true,\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 async run(ctx) {\n const { connectRunner } = await import('../../runners/studio/commands.ts')\n await connectRunner(ctx)\n },\n})\n","import { define } from 'gunshi'\nimport { command as connectCommand } from './connect.ts'\n\nexport const command = define({\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 toKebab: true,\n args: connectCommand.args,\n async run(ctx) {\n const { loginRunner } = await import('../../runners/studio/commands.ts')\n await loginRunner(ctx)\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const command = define({\n name: 'logout',\n description: 'Forget the stored Kubb Studio token.',\n examples: ['kubb studio logout'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n ...logLevelArg,\n },\n async run(ctx) {\n const { logoutRunner } = await import('../../runners/studio/commands.ts')\n await logoutRunner(ctx)\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'\n\nexport const command = define({\n name: 'start',\n description: 'Keep this project connected to Kubb Studio in the background.',\n toKebab: true,\n args: connectCommand.args,\n async run(ctx) {\n const { startRunner } = await import('../../runners/studio/commands.ts')\n await startRunner(ctx)\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 { stopRunner } = await import('../../runners/studio/commands.ts')\n await stopRunner()\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const command = define({\n name: 'status',\n description: 'Show the project worker, Kubb Studio pairing, and saved permissions.',\n examples: ['kubb studio status'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n ...logLevelArg,\n },\n async run(ctx) {\n const { statusRunner } = await import('../../runners/studio/commands.ts')\n await statusRunner(ctx)\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 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 name: 'studio',\n description: 'Connect this project to Kubb Studio, or manage its pairing and snapshots.',\n examples: ['kubb studio', 'kubb studio --allow-read', 'kubb studio login', 'kubb studio status', 'kubb studio logout', 'kubb studio snapshot'].join('\\n'),\n toKebab: true,\n args: connectCommand.args,\n async run(ctx) {\n const { connectRunner } = await import('../../runners/studio/commands.ts')\n await connectRunner(ctx)\n },\n subCommands: {\n start: startCommand,\n stop: stopCommand,\n connect: connectCommand,\n login: loginCommand,\n logout: logoutCommand,\n status: statusCommand,\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","import { define } from 'gunshi'\nimport { yesArg } from './shared.ts'\n\nexport const command = define({\n name: 'update',\n description:\n 'Update installed extensions to the version the Kubb registry pins. Pass ids to update only those, or --check to list the updates without installing.',\n examples: ['kubb update', 'kubb update --check', 'kubb update plugin-zod plugin-ts --yes'].join('\\n'),\n args: {\n ids: {\n type: 'positional',\n description: 'Registry ids to update, all installed extensions when omitted',\n multiple: true,\n },\n check: {\n type: 'boolean',\n description: 'List the available updates without installing them',\n default: false,\n },\n ...yesArg,\n },\n async run({ values }) {\n const { run } = await import('../runners/update/run.ts')\n await run({ ids: values.ids ?? [], check: values.check, yes: values.yes })\n },\n})\n","import { define } from 'gunshi'\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:\n 'Parse and validate an OpenAPI/Swagger file for structural correctness. Reports schema errors, missing required fields, and malformed references. Use this before running generate to catch spec issues early.',\n examples: ['kubb validate ./openapi.yaml', 'kubb validate https://petstore3.swagger.io/api/v3/openapi.json'].join('\\n'),\n args: {\n input: {\n type: 'positional',\n description: 'Path or URL to the OpenAPI/Swagger file 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 })\n },\n})\n","import { styleText } from 'node:util'\n\n/**\n * Maps each camelCase flag removed in favor of kebab-case (kubb-labs/kubb#4046) to its\n * replacement. Drop this table, and the rewrite it drives, once the deprecation window ends.\n */\nconst DEPRECATED_FLAGS: Record<string, string> = {\n allowWrite: 'allow-write',\n allowConfigEdit: 'allow-config-edit',\n allowExec: 'allow-exec',\n logLevel: 'log-level',\n dryRun: 'dry-run',\n packageVersion: 'package-version',\n}\n\nconst FLAG_PATTERN = /^--([a-zA-Z][\\w-]*)(=.*)?$/\n\n/**\n * Rewrites a deprecated camelCase flag to its kebab-case replacement and warns on stderr, so a\n * script written against the old flag names keeps working during the deprecation window instead\n * of failing with an unknown-option error.\n */\nexport function resolveDeprecatedFlags(args: Array<string>): Array<string> {\n return args.map((arg) => {\n const match = FLAG_PATTERN.exec(arg)\n const name = match?.[1]\n const replacement = name ? DEPRECATED_FLAGS[name] : undefined\n\n if (!name || !replacement) {\n return arg\n }\n\n console.error(\n `${styleText('yellow', 'Warning:')} --${name} is deprecated, use --${replacement} instead. --${name} will be removed in a future major version.`,\n )\n\n return `--${replacement}${match?.[2] ?? ''}`\n })\n}\n","import { styleText } from 'node:util'\nimport dryrun from '@gunshi/plugin-dryrun'\nimport { cli } from 'gunshi'\nimport { isDisabled as isTelemetryDisabled } from './Telemetry.ts'\nimport { version } from '../package.json'\nimport { command as addCommand } from './commands/add.ts'\nimport { command as generateCommand } from './commands/generate.ts'\nimport { command as initCommand } from './commands/init.ts'\nimport { command as listCommand } from './commands/list.ts'\nimport { command as mcpCommand } from './commands/mcp.ts'\nimport { command as studioCommand, routeStudioFlags } from './commands/studio/index.ts'\nimport { command as updateCommand } from './commands/update.ts'\nimport { command as validateCommand } from './commands/validate.ts'\nimport { resolveDeprecatedFlags } from './deprecatedFlags.ts'\n\n/** Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these. */\nconst QUIET_FLAGS = new Set<string>(['--help', '-h', '--version', '-v', '--json'])\n\n/**\n * Strips the leading executable + script entries when `process.argv` is passed directly.\n * Handles Node.js (`/usr/bin/node`), Bun (`/usr/local/bin/bun`), Deno, tsx, etc. All runtime\n * executable paths contain a path separator; bare command names do not.\n */\nfunction stripExecArgs(argv: Array<string>): Array<string> {\n const firstArgIsExecutablePath = (argv[0]?.includes('/') || argv[0]?.includes('\\\\')) ?? false\n return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv\n}\n\n/**\n * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a\n * quiet flag is passed, then runs the given command, or `generate` when none is given.\n */\nexport async function run(argv: Array<string> = process.argv): Promise<void> {\n const args = routeStudioFlags(resolveDeprecatedFlags(stripExecArgs(argv)))\n const isQuietFlag = args.some((arg) => QUIET_FLAGS.has(arg))\n\n // stderr, so the notice never lands in a stream a client parses, such as `kubb mcp` stdio.\n if (!isTelemetryDisabled() && !isQuietFlag) {\n console.error(\n `${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \\nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\\n`,\n )\n }\n\n // Each command's `run` imports its runner, so an optional peer (@kubb/adapter-oas, @kubb/mcp, @kubb/studio) loads only when it runs.\n await cli(args, generateCommand, {\n name: 'kubb',\n version,\n // Not `generateCommand.description`: gunshi prints this on every subcommand's help too, so\n // `kubb studio --help` would open with a paragraph about generating types.\n description: 'Generate code from an OpenAPI specification, manage Kubb extensions, or connect the project to Kubb Studio.',\n subCommands: {\n generate: generateCommand,\n init: initCommand,\n validate: validateCommand,\n mcp: mcpCommand,\n studio: studioCommand,\n add: addCommand,\n update: updateCommand,\n list: listCommand,\n },\n fallbackToEntry: true,\n strict: true,\n plugins: [dryrun({ name: 'dry-run' })],\n onErrorCommand: async (_ctx, error) => {\n process.exitCode = 1\n console.error(error)\n },\n })\n}\n"],"mappings":";;;;;;;;AAUA,MAAa,YAAY,EACvB,QAAQ;CACN,MAAM;CACN,aAAa;CACb,OAAO;AACT,EACF;AAEA,MAAa,SAAS,EACpB,KAAK;CACH,MAAM;CACN,aAAa;CACb,OAAO;CACP,SAAS;AACX,EACF;AAEA,MAAa,cAAc,EACzB,UAAU;CACR,MAAM;CACN,SAAS;EAAC;EAAU;EAAQ;CAAS;CACrC,aAAa;CACb,OAAO;CACP,SAAS;CACT,SAAS;AACX,EACF;AAEA,MAAa,uBAAuB;CAClC,KAAK;EACH,MAAM;EACN,aAAa;CACf;CACA,OAAO;EACL,MAAM;EACN,aAAa;CACf;AACF;AAEA,MAAa,uBAAuB;CAClC,WAAW;EACT,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,YAAY;EACV,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,iBAAiB;EACf,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,WAAW;EACT,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAA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
|
2
|
+
import { r as version, t as isDisabled } from "./Telemetry-BivZAaw9.js";
|
|
3
3
|
import { styleText } from "node:util";
|
|
4
4
|
import dryrun, { pluginId as dryRunId } from "@gunshi/plugin-dryrun";
|
|
5
5
|
import { cli, define, defineWithTypes } from "gunshi";
|
|
@@ -174,7 +174,7 @@ const command$12 = defineWithTypes()({
|
|
|
174
174
|
async run(ctx) {
|
|
175
175
|
const { values } = ctx;
|
|
176
176
|
const logLevel = resolveLogLevel(values);
|
|
177
|
-
const { run } = await import("./run-
|
|
177
|
+
const { run } = await import("./run-mx0KM8y5.js");
|
|
178
178
|
await run({
|
|
179
179
|
input: values.input,
|
|
180
180
|
configPath: values.config,
|
|
@@ -258,8 +258,9 @@ const command$9 = define({
|
|
|
258
258
|
"# Then add to your MCP client config:",
|
|
259
259
|
"# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }"
|
|
260
260
|
].join("\n"),
|
|
261
|
+
rendering: { header: null },
|
|
261
262
|
async run() {
|
|
262
|
-
const { run } = await import("./run-
|
|
263
|
+
const { run } = await import("./run-ajUuT3vK.js");
|
|
263
264
|
await run();
|
|
264
265
|
}
|
|
265
266
|
});
|
|
@@ -288,7 +289,7 @@ const command$8 = define({
|
|
|
288
289
|
...logLevelArg
|
|
289
290
|
},
|
|
290
291
|
async run(ctx) {
|
|
291
|
-
const { connectRunner } = await import("./commands-
|
|
292
|
+
const { connectRunner } = await import("./commands-BlNFxWKB.js");
|
|
292
293
|
await connectRunner(ctx);
|
|
293
294
|
}
|
|
294
295
|
});
|
|
@@ -301,7 +302,7 @@ const command$7 = define({
|
|
|
301
302
|
toKebab: true,
|
|
302
303
|
args: command$8.args,
|
|
303
304
|
async run(ctx) {
|
|
304
|
-
const { loginRunner } = await import("./commands-
|
|
305
|
+
const { loginRunner } = await import("./commands-BlNFxWKB.js");
|
|
305
306
|
await loginRunner(ctx);
|
|
306
307
|
}
|
|
307
308
|
});
|
|
@@ -319,7 +320,7 @@ const command$6 = define({
|
|
|
319
320
|
...logLevelArg
|
|
320
321
|
},
|
|
321
322
|
async run(ctx) {
|
|
322
|
-
const { logoutRunner } = await import("./commands-
|
|
323
|
+
const { logoutRunner } = await import("./commands-BlNFxWKB.js");
|
|
323
324
|
await logoutRunner(ctx);
|
|
324
325
|
}
|
|
325
326
|
});
|
|
@@ -359,7 +360,7 @@ const command$5 = define({
|
|
|
359
360
|
...logLevelArg
|
|
360
361
|
},
|
|
361
362
|
async run(ctx) {
|
|
362
|
-
const { runner } = await import("./snapshot-
|
|
363
|
+
const { runner } = await import("./snapshot-CHKxNlYg.js");
|
|
363
364
|
await runner(ctx);
|
|
364
365
|
}
|
|
365
366
|
});
|
|
@@ -371,7 +372,7 @@ const command$4 = define({
|
|
|
371
372
|
toKebab: true,
|
|
372
373
|
args: command$8.args,
|
|
373
374
|
async run(ctx) {
|
|
374
|
-
const { startRunner } = await import("./commands-
|
|
375
|
+
const { startRunner } = await import("./commands-BlNFxWKB.js");
|
|
375
376
|
await startRunner(ctx);
|
|
376
377
|
}
|
|
377
378
|
});
|
|
@@ -379,7 +380,7 @@ const stopCommand = define({
|
|
|
379
380
|
name: "stop",
|
|
380
381
|
description: "Stop this project's background connection and keep its pairing.",
|
|
381
382
|
async run() {
|
|
382
|
-
const { stopRunner } = await import("./commands-
|
|
383
|
+
const { stopRunner } = await import("./commands-BlNFxWKB.js");
|
|
383
384
|
await stopRunner();
|
|
384
385
|
}
|
|
385
386
|
});
|
|
@@ -397,7 +398,7 @@ const command$3 = define({
|
|
|
397
398
|
...logLevelArg
|
|
398
399
|
},
|
|
399
400
|
async run(ctx) {
|
|
400
|
-
const { statusRunner } = await import("./commands-
|
|
401
|
+
const { statusRunner } = await import("./commands-BlNFxWKB.js");
|
|
401
402
|
await statusRunner(ctx);
|
|
402
403
|
}
|
|
403
404
|
});
|
|
@@ -417,7 +418,7 @@ const command$2 = define({
|
|
|
417
418
|
toKebab: true,
|
|
418
419
|
args: command$8.args,
|
|
419
420
|
async run(ctx) {
|
|
420
|
-
const { connectRunner } = await import("./commands-
|
|
421
|
+
const { connectRunner } = await import("./commands-BlNFxWKB.js");
|
|
421
422
|
await connectRunner(ctx);
|
|
422
423
|
},
|
|
423
424
|
subCommands: {
|
|
@@ -488,7 +489,7 @@ const command = define({
|
|
|
488
489
|
required: true
|
|
489
490
|
} },
|
|
490
491
|
async run({ values }) {
|
|
491
|
-
const { run } = await import("./run-
|
|
492
|
+
const { run } = await import("./run-DnXUzX34.js");
|
|
492
493
|
await run({ input: values.input });
|
|
493
494
|
}
|
|
494
495
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["command","command","command","command","command","command","command","connectCommand","command","command","command","connectCommand","command","command","connectCommand","startCommand","loginCommand","logoutCommand","statusCommand","snapshotCommand","command","isTelemetryDisabled","generateCommand","initCommand","validateCommand","mcpCommand","studioCommand","addCommand","updateCommand","listCommand"],"sources":["../src/commands/shared.ts","../src/commands/add.ts","../src/commands/generate.ts","../src/commands/init.ts","../src/commands/list.ts","../src/commands/mcp.ts","../src/commands/studio/connect.ts","../src/commands/studio/login.ts","../src/commands/studio/logout.ts","../src/commands/studio/snapshot.ts","../src/commands/studio/background.ts","../src/commands/studio/status.ts","../src/commands/studio/index.ts","../src/commands/update.ts","../src/commands/validate.ts","../src/deprecatedFlags.ts","../src/index.ts"],"sourcesContent":["import { pluginId as dryRunId } from '@gunshi/plugin-dryrun'\nimport type { DryRunExtension } from '@gunshi/plugin-dryrun'\n\nexport { dryRunId }\n\n/** Extension shape gunshi's command context carries with `@gunshi/plugin-dryrun`; the `extensions` type parameter of `defineWithTypes`. */\nexport type DryRunExtensions = {\n [dryRunId]: DryRunExtension\n}\n\nexport const configArg = {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n} as const\n\nexport const yesArg = {\n yes: {\n type: 'boolean',\n description: 'Skip the confirmation',\n short: 'y',\n default: false,\n },\n} as const\n\nexport const logLevelArg = {\n logLevel: {\n type: 'enum',\n choices: ['silent', 'info', 'verbose'] as const,\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n toKebab: true,\n },\n} as const\n\nexport const studioConnectionArgs = {\n url: {\n type: 'string',\n description: 'Base URL of the Kubb Studio instance',\n },\n token: {\n type: 'string',\n description: 'Organization CI API key for `snapshot`. Defaults to KUBB_TOKEN',\n },\n} as const\n\nexport const studioPermissionArgs = {\n allowRead: {\n type: 'boolean',\n description: 'Read the source of files a generation produced. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowWrite: {\n type: 'boolean',\n description: 'Write generated files to disk. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowConfigEdit: {\n type: 'boolean',\n description: 'Let Studio change plugin options in kubb.config.ts. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowExec: {\n type: 'boolean',\n description: 'Run the formatter, the linter, and output.postGenerate after a generation',\n default: false,\n toKebab: true,\n },\n} as const\n","import { define } from 'gunshi'\nimport { configArg, yesArg } from './shared.ts'\n\nexport const command = define({\n name: 'add',\n description:\n 'Install a plugin, adapter, or parser from the Kubb registry at its reviewed version. A plugin is added to kubb.config.ts, an adapter or parser prints the code to add. Reads KUBB_REGISTRY to use another registry.',\n examples: ['kubb add plugin-zod', 'kubb add kubb-labs/plugin-react-query', 'kubb add acme/plugin-x --yes', 'kubb add plugin-zod --no-install'].join('\\n'),\n toKebab: true,\n args: {\n id: {\n type: 'positional',\n description: 'Registry id: owner/slug, or a slug for an official extension',\n required: true,\n },\n ...configArg,\n ...yesArg,\n install: {\n type: 'boolean',\n description: 'Install the package. Pass --no-install to only edit the config',\n negatable: true,\n default: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/add/run.ts')\n await run({ id: values.id, configPath: values.config, yes: values.yes, install: values.install })\n },\n})\n","import { defineWithTypes } from 'gunshi'\nimport type { ReporterName } from '@kubb/core'\nimport { configArg, dryRunId, type DryRunExtensions, logLevelArg } from './shared.ts'\n\nconst REPORTER_NAMES: Array<ReporterName> = ['cli', 'json', 'file', 'html']\n\n/**\n * Splits and validates the comma-separated `--reporter` value against the known reporter names.\n */\nfunction parseReporters(value: string): Array<ReporterName> {\n const names = value\n .split(',')\n .map((name) => name.trim())\n .filter(Boolean)\n\n for (const name of names) {\n if (!REPORTER_NAMES.includes(name as ReporterName)) {\n throw new Error(`must be one of cli, json, file, html (got \"${name}\")`)\n }\n }\n\n return names as Array<ReporterName>\n}\n\n/**\n * Resolves the effective log level, letting the `--verbose` and `--silent` flags win over `--log-level`.\n */\nfunction resolveLogLevel({ verbose, silent, logLevel }: { verbose: boolean; silent: boolean; logLevel: string }): string {\n if (verbose) return 'verbose'\n if (silent) return 'silent'\n return logLevel\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'generate',\n description:\n 'Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.',\n examples: [\n 'kubb generate # generate from kubb.config.ts',\n 'kubb generate ./openapi.yaml # generate from this spec instead of the config input',\n 'kubb generate --config kubb.config.ts',\n 'kubb generate --watch # regenerate whenever the spec changes',\n 'kubb generate --dry-run # preview the run without writing files',\n 'kubb generate --reporter html # write an HTML run report',\n 'kubb studio # connect this project to Kubb Studio and generate from the browser',\n 'kubb studio --allow-write # let Studio write the generated files to disk',\n 'kubb studio login # pair this machine with Studio without connecting',\n ].join('\\n'),\n toKebab: true,\n args: {\n input: {\n type: 'positional',\n required: false,\n description: 'Path to the OpenAPI specification, overriding the config',\n },\n ...configArg,\n ...logLevelArg,\n watch: {\n type: 'boolean',\n description: 'Watch mode: watches an input file for changes, or polls an input URL',\n short: 'w',\n default: false,\n },\n verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\n default: false,\n },\n silent: {\n type: 'boolean',\n description: 'Override logLevel to silent',\n short: 's',\n default: false,\n },\n reporter: {\n type: 'custom',\n description: 'Reporters that render the run: cli, json, file, html. Comma-separated. Overrides config.reporters',\n metavar: 'cli|json|file|html',\n parse: parseReporters,\n },\n },\n async run(ctx) {\n const { values } = ctx\n const logLevel = resolveLogLevel(values)\n const { run } = await import('../runners/generate/run.ts')\n\n await run({\n input: values.input,\n configPath: values.config,\n logLevel,\n watch: values.watch,\n reporters: values.reporter,\n dryRun: ctx.extensions[dryRunId].enabled,\n })\n },\n})\n","import { defineWithTypes } from 'gunshi'\nimport { dryRunId, type DryRunExtensions } from './shared.ts'\nimport { version } from '../../package.json'\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'init',\n description:\n 'Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n 'kubb init --yes --dry-run',\n ].join('\\n'),\n toKebab: true,\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use default options',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n async run(ctx) {\n const { values } = ctx\n const { run } = await import('../runners/init/run.ts')\n\n await run({\n yes: values.yes,\n version,\n input: values.input,\n output: values.output,\n plugins: values.plugins,\n dryRun: ctx.extensions[dryRunId],\n })\n },\n})\n","import { define } from 'gunshi'\n\nexport const command = define({\n name: 'list',\n description:\n 'List the installed Kubb extensions: their registry id, package, installed version, the version the Kubb registry pins, and whether an update exists.',\n examples: 'kubb list',\n async run() {\n const { run } = await import('../runners/list/run.ts')\n await run()\n },\n})\n","import { define } from 'gunshi'\n\n/** The runner is imported when the command runs, so listing `kubb --help` never loads `@kubb/mcp`. */\nexport const command = define({\n name: 'mcp',\n description:\n 'Start a Model Context Protocol (MCP) server that exposes Kubb code generation as tools for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect to it — the assistant can then call kubb generate directly without leaving the chat.',\n examples: ['kubb mcp', '# Then add to your MCP client config:', '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }'].join('\\n'),\n async run() {\n const { run } = await import('../runners/mcp/run.ts')\n await run()\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const command = define({\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 toKebab: true,\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 async run(ctx) {\n const { connectRunner } = await import('../../runners/studio/commands.ts')\n await connectRunner(ctx)\n },\n})\n","import { define } from 'gunshi'\nimport { command as connectCommand } from './connect.ts'\n\nexport const command = define({\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 toKebab: true,\n args: connectCommand.args,\n async run(ctx) {\n const { loginRunner } = await import('../../runners/studio/commands.ts')\n await loginRunner(ctx)\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const command = define({\n name: 'logout',\n description: 'Forget the stored Kubb Studio token.',\n examples: ['kubb studio logout'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n ...logLevelArg,\n },\n async run(ctx) {\n const { logoutRunner } = await import('../../runners/studio/commands.ts')\n await logoutRunner(ctx)\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'\n\nexport const command = define({\n name: 'start',\n description: 'Keep this project connected to Kubb Studio in the background.',\n toKebab: true,\n args: connectCommand.args,\n async run(ctx) {\n const { startRunner } = await import('../../runners/studio/commands.ts')\n await startRunner(ctx)\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 { stopRunner } = await import('../../runners/studio/commands.ts')\n await stopRunner()\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const command = define({\n name: 'status',\n description: 'Show the project worker, Kubb Studio pairing, and saved permissions.',\n examples: ['kubb studio status'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n ...logLevelArg,\n },\n async run(ctx) {\n const { statusRunner } = await import('../../runners/studio/commands.ts')\n await statusRunner(ctx)\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 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 name: 'studio',\n description: 'Connect this project to Kubb Studio, or manage its pairing and snapshots.',\n examples: ['kubb studio', 'kubb studio --allow-read', 'kubb studio login', 'kubb studio status', 'kubb studio logout', 'kubb studio snapshot'].join('\\n'),\n toKebab: true,\n args: connectCommand.args,\n async run(ctx) {\n const { connectRunner } = await import('../../runners/studio/commands.ts')\n await connectRunner(ctx)\n },\n subCommands: {\n start: startCommand,\n stop: stopCommand,\n connect: connectCommand,\n login: loginCommand,\n logout: logoutCommand,\n status: statusCommand,\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","import { define } from 'gunshi'\nimport { yesArg } from './shared.ts'\n\nexport const command = define({\n name: 'update',\n description:\n 'Update installed extensions to the version the Kubb registry pins. Pass ids to update only those, or --check to list the updates without installing.',\n examples: ['kubb update', 'kubb update --check', 'kubb update plugin-zod plugin-ts --yes'].join('\\n'),\n args: {\n ids: {\n type: 'positional',\n description: 'Registry ids to update, all installed extensions when omitted',\n multiple: true,\n },\n check: {\n type: 'boolean',\n description: 'List the available updates without installing them',\n default: false,\n },\n ...yesArg,\n },\n async run({ values }) {\n const { run } = await import('../runners/update/run.ts')\n await run({ ids: values.ids ?? [], check: values.check, yes: values.yes })\n },\n})\n","import { define } from 'gunshi'\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:\n 'Parse and validate an OpenAPI/Swagger file for structural correctness. Reports schema errors, missing required fields, and malformed references. Use this before running generate to catch spec issues early.',\n examples: ['kubb validate ./openapi.yaml', 'kubb validate https://petstore3.swagger.io/api/v3/openapi.json'].join('\\n'),\n args: {\n input: {\n type: 'positional',\n description: 'Path or URL to the OpenAPI/Swagger file 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 })\n },\n})\n","import { styleText } from 'node:util'\n\n/**\n * Maps each camelCase flag removed in favor of kebab-case (kubb-labs/kubb#4046) to its\n * replacement. Drop this table, and the rewrite it drives, once the deprecation window ends.\n */\nconst DEPRECATED_FLAGS: Record<string, string> = {\n allowWrite: 'allow-write',\n allowConfigEdit: 'allow-config-edit',\n allowExec: 'allow-exec',\n logLevel: 'log-level',\n dryRun: 'dry-run',\n packageVersion: 'package-version',\n}\n\nconst FLAG_PATTERN = /^--([a-zA-Z][\\w-]*)(=.*)?$/\n\n/**\n * Rewrites a deprecated camelCase flag to its kebab-case replacement and warns on stderr, so a\n * script written against the old flag names keeps working during the deprecation window instead\n * of failing with an unknown-option error.\n */\nexport function resolveDeprecatedFlags(args: Array<string>): Array<string> {\n return args.map((arg) => {\n const match = FLAG_PATTERN.exec(arg)\n const name = match?.[1]\n const replacement = name ? DEPRECATED_FLAGS[name] : undefined\n\n if (!name || !replacement) {\n return arg\n }\n\n console.error(\n `${styleText('yellow', 'Warning:')} --${name} is deprecated, use --${replacement} instead. --${name} will be removed in a future major version.`,\n )\n\n return `--${replacement}${match?.[2] ?? ''}`\n })\n}\n","import { styleText } from 'node:util'\nimport dryrun from '@gunshi/plugin-dryrun'\nimport { cli } from 'gunshi'\nimport { isDisabled as isTelemetryDisabled } from './Telemetry.ts'\nimport { version } from '../package.json'\nimport { command as addCommand } from './commands/add.ts'\nimport { command as generateCommand } from './commands/generate.ts'\nimport { command as initCommand } from './commands/init.ts'\nimport { command as listCommand } from './commands/list.ts'\nimport { command as mcpCommand } from './commands/mcp.ts'\nimport { command as studioCommand, routeStudioFlags } from './commands/studio/index.ts'\nimport { command as updateCommand } from './commands/update.ts'\nimport { command as validateCommand } from './commands/validate.ts'\nimport { resolveDeprecatedFlags } from './deprecatedFlags.ts'\n\n/** Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these. */\nconst QUIET_FLAGS = new Set<string>(['--help', '-h', '--version', '-v', '--json'])\n\n/**\n * Strips the leading executable + script entries when `process.argv` is passed directly.\n * Handles Node.js (`/usr/bin/node`), Bun (`/usr/local/bin/bun`), Deno, tsx, etc. All runtime\n * executable paths contain a path separator; bare command names do not.\n */\nfunction stripExecArgs(argv: Array<string>): Array<string> {\n const firstArgIsExecutablePath = (argv[0]?.includes('/') || argv[0]?.includes('\\\\')) ?? false\n return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv\n}\n\n/**\n * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a\n * quiet flag is passed, then runs the given command, or `generate` when none is given.\n */\nexport async function run(argv: Array<string> = process.argv): Promise<void> {\n const args = routeStudioFlags(resolveDeprecatedFlags(stripExecArgs(argv)))\n const isQuietFlag = args.some((arg) => QUIET_FLAGS.has(arg))\n\n // stderr, so the notice never lands in a stream a client parses, such as `kubb mcp` stdio.\n if (!isTelemetryDisabled() && !isQuietFlag) {\n console.error(\n `${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \\nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\\n`,\n )\n }\n\n // Each command's `run` imports its runner, so an optional peer (@kubb/adapter-oas, @kubb/mcp, @kubb/studio) loads only when it runs.\n await cli(args, generateCommand, {\n name: 'kubb',\n version,\n // Not `generateCommand.description`: gunshi prints this on every subcommand's help too, so\n // `kubb studio --help` would open with a paragraph about generating types.\n description: 'Generate code from an OpenAPI specification, manage Kubb extensions, or connect the project to Kubb Studio.',\n subCommands: {\n generate: generateCommand,\n init: initCommand,\n validate: validateCommand,\n mcp: mcpCommand,\n studio: studioCommand,\n add: addCommand,\n update: updateCommand,\n list: listCommand,\n },\n fallbackToEntry: true,\n strict: true,\n plugins: [dryrun({ name: 'dry-run' })],\n onErrorCommand: async (_ctx, error) => {\n process.exitCode = 1\n console.error(error)\n },\n })\n}\n"],"mappings":";;;;;;AAUA,MAAa,YAAY,EACvB,QAAQ;CACN,MAAM;CACN,aAAa;CACb,OAAO;AACT,EACF;AAEA,MAAa,SAAS,EACpB,KAAK;CACH,MAAM;CACN,aAAa;CACb,OAAO;CACP,SAAS;AACX,EACF;AAEA,MAAa,cAAc,EACzB,UAAU;CACR,MAAM;CACN,SAAS;EAAC;EAAU;EAAQ;CAAS;CACrC,aAAa;CACb,OAAO;CACP,SAAS;CACT,SAAS;AACX,EACF;AAEA,MAAa,uBAAuB;CAClC,KAAK;EACH,MAAM;EACN,aAAa;CACf;CACA,OAAO;EACL,MAAM;EACN,aAAa;CACf;AACF;AAEA,MAAa,uBAAuB;CAClC,WAAW;EACT,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,YAAY;EACV,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,iBAAiB;EACf,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,WAAW;EACT,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;AACF;;;ACvEA,MAAaA,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AA;EAEpD,IAAI,CAAC,QAAQ,CAAC,aACZ,OAAO;EAGT,QAAQ,MACN,GAAG,UAAU,UAAU,UAAU,EAAE,KAAK,KAAK,wBAAwB,YAAY,cAAc,KAAK,4CACtG;EAEA,OAAO,KAAK,cAAc,QAAQ,MAAM;CAC1C,CAAC;AACH;;;;ACtBA,MAAM,8BAAc,IAAI,IAAY;CAAC;CAAU;CAAM;CAAa;CAAM;AAAQ,CAAC;;;;;;AAOjF,SAAS,cAAc,MAAoC;CACzD,MAAM,4BAA4B,KAAK,EAAE,EAAE,SAAS,GAAG,KAAK,KAAK,EAAE,EAAE,SAAS,IAAI,MAAM;CACxF,OAAO,KAAK,UAAU,KAAK,2BAA2B,KAAK,MAAM,CAAC,IAAI;AACxE;;;;;AAMA,eAAsB,IAAI,OAAsB,QAAQ,MAAqB;CAC3E,MAAM,OAAO,iBAAiB,uBAAuB,cAAc,IAAI,CAAC,CAAC;CACzE,MAAM,cAAc,KAAK,MAAM,QAAQ,YAAY,IAAI,GAAG,CAAC;CAG3D,IAAI,CAACC,WAAoB,KAAK,CAAC,aAC7B,QAAQ,MACN,GAAG,UAAU,UAAU,SAAS,EAAE,uIAAuI,UAAU,QAAQ,0BAA0B,EAAE,IACzN;CAIF,MAAM,IAAI,MAAMC,YAAiB;EAC/B,MAAM;EACN;EAGA,aAAa;EACb,aAAa;GACX,UAAUA;GACV,MAAMC;GACN,UAAUC;GACV,KAAKC;GACL,QAAQC;GACR,KAAKC;GACL,QAAQC;GACR,MAAMC;EACR;EACA,iBAAiB;EACjB,QAAQ;EACR,SAAS,CAAC,OAAO,EAAE,MAAM,UAAU,CAAC,CAAC;EACrC,gBAAgB,OAAO,MAAM,UAAU;GACrC,QAAQ,WAAW;GACnB,QAAQ,MAAM,KAAK;EACrB;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["command","command","command","command","command","command","command","connectCommand","command","command","command","connectCommand","command","command","connectCommand","startCommand","loginCommand","logoutCommand","statusCommand","snapshotCommand","command","isTelemetryDisabled","generateCommand","initCommand","validateCommand","mcpCommand","studioCommand","addCommand","updateCommand","listCommand"],"sources":["../src/commands/shared.ts","../src/commands/add.ts","../src/commands/generate.ts","../src/commands/init.ts","../src/commands/list.ts","../src/commands/mcp.ts","../src/commands/studio/connect.ts","../src/commands/studio/login.ts","../src/commands/studio/logout.ts","../src/commands/studio/snapshot.ts","../src/commands/studio/background.ts","../src/commands/studio/status.ts","../src/commands/studio/index.ts","../src/commands/update.ts","../src/commands/validate.ts","../src/deprecatedFlags.ts","../src/index.ts"],"sourcesContent":["import { pluginId as dryRunId } from '@gunshi/plugin-dryrun'\nimport type { DryRunExtension } from '@gunshi/plugin-dryrun'\n\nexport { dryRunId }\n\n/** Extension shape gunshi's command context carries with `@gunshi/plugin-dryrun`; the `extensions` type parameter of `defineWithTypes`. */\nexport type DryRunExtensions = {\n [dryRunId]: DryRunExtension\n}\n\nexport const configArg = {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n} as const\n\nexport const yesArg = {\n yes: {\n type: 'boolean',\n description: 'Skip the confirmation',\n short: 'y',\n default: false,\n },\n} as const\n\nexport const logLevelArg = {\n logLevel: {\n type: 'enum',\n choices: ['silent', 'info', 'verbose'] as const,\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n toKebab: true,\n },\n} as const\n\nexport const studioConnectionArgs = {\n url: {\n type: 'string',\n description: 'Base URL of the Kubb Studio instance',\n },\n token: {\n type: 'string',\n description: 'Organization CI API key for `snapshot`. Defaults to KUBB_TOKEN',\n },\n} as const\n\nexport const studioPermissionArgs = {\n allowRead: {\n type: 'boolean',\n description: 'Read the source of files a generation produced. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowWrite: {\n type: 'boolean',\n description: 'Write generated files to disk. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowConfigEdit: {\n type: 'boolean',\n description: 'Let Studio change plugin options in kubb.config.ts. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowExec: {\n type: 'boolean',\n description: 'Run the formatter, the linter, and output.postGenerate after a generation',\n default: false,\n toKebab: true,\n },\n} as const\n","import { define } from 'gunshi'\nimport { configArg, yesArg } from './shared.ts'\n\nexport const command = define({\n name: 'add',\n description:\n 'Install a plugin, adapter, or parser from the Kubb registry at its reviewed version. A plugin is added to kubb.config.ts, an adapter or parser prints the code to add. Reads KUBB_REGISTRY to use another registry.',\n examples: ['kubb add plugin-zod', 'kubb add kubb-labs/plugin-react-query', 'kubb add acme/plugin-x --yes', 'kubb add plugin-zod --no-install'].join('\\n'),\n toKebab: true,\n args: {\n id: {\n type: 'positional',\n description: 'Registry id: owner/slug, or a slug for an official extension',\n required: true,\n },\n ...configArg,\n ...yesArg,\n install: {\n type: 'boolean',\n description: 'Install the package. Pass --no-install to only edit the config',\n negatable: true,\n default: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/add/run.ts')\n await run({ id: values.id, configPath: values.config, yes: values.yes, install: values.install })\n },\n})\n","import { defineWithTypes } from 'gunshi'\nimport type { ReporterName } from '@kubb/core'\nimport { configArg, dryRunId, type DryRunExtensions, logLevelArg } from './shared.ts'\n\nconst REPORTER_NAMES: Array<ReporterName> = ['cli', 'json', 'file', 'html']\n\n/**\n * Splits and validates the comma-separated `--reporter` value against the known reporter names.\n */\nfunction parseReporters(value: string): Array<ReporterName> {\n const names = value\n .split(',')\n .map((name) => name.trim())\n .filter(Boolean)\n\n for (const name of names) {\n if (!REPORTER_NAMES.includes(name as ReporterName)) {\n throw new Error(`must be one of cli, json, file, html (got \"${name}\")`)\n }\n }\n\n return names as Array<ReporterName>\n}\n\n/**\n * Resolves the effective log level, letting the `--verbose` and `--silent` flags win over `--log-level`.\n */\nfunction resolveLogLevel({ verbose, silent, logLevel }: { verbose: boolean; silent: boolean; logLevel: string }): string {\n if (verbose) return 'verbose'\n if (silent) return 'silent'\n return logLevel\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'generate',\n description:\n 'Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.',\n examples: [\n 'kubb generate # generate from kubb.config.ts',\n 'kubb generate ./openapi.yaml # generate from this spec instead of the config input',\n 'kubb generate --config kubb.config.ts',\n 'kubb generate --watch # regenerate whenever the spec changes',\n 'kubb generate --dry-run # preview the run without writing files',\n 'kubb generate --reporter html # write an HTML run report',\n 'kubb studio # connect this project to Kubb Studio and generate from the browser',\n 'kubb studio --allow-write # let Studio write the generated files to disk',\n 'kubb studio login # pair this machine with Studio without connecting',\n ].join('\\n'),\n toKebab: true,\n args: {\n input: {\n type: 'positional',\n required: false,\n description: 'Path to the OpenAPI specification, overriding the config',\n },\n ...configArg,\n ...logLevelArg,\n watch: {\n type: 'boolean',\n description: 'Watch mode: watches an input file for changes, or polls an input URL',\n short: 'w',\n default: false,\n },\n verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\n default: false,\n },\n silent: {\n type: 'boolean',\n description: 'Override logLevel to silent',\n short: 's',\n default: false,\n },\n reporter: {\n type: 'custom',\n description: 'Reporters that render the run: cli, json, file, html. Comma-separated. Overrides config.reporters',\n metavar: 'cli|json|file|html',\n parse: parseReporters,\n },\n },\n async run(ctx) {\n const { values } = ctx\n const logLevel = resolveLogLevel(values)\n const { run } = await import('../runners/generate/run.ts')\n\n await run({\n input: values.input,\n configPath: values.config,\n logLevel,\n watch: values.watch,\n reporters: values.reporter,\n dryRun: ctx.extensions[dryRunId].enabled,\n })\n },\n})\n","import { defineWithTypes } from 'gunshi'\nimport { dryRunId, type DryRunExtensions } from './shared.ts'\nimport { version } from '../../package.json'\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'init',\n description:\n 'Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n 'kubb init --yes --dry-run',\n ].join('\\n'),\n toKebab: true,\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use default options',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n async run(ctx) {\n const { values } = ctx\n const { run } = await import('../runners/init/run.ts')\n\n await run({\n yes: values.yes,\n version,\n input: values.input,\n output: values.output,\n plugins: values.plugins,\n dryRun: ctx.extensions[dryRunId],\n })\n },\n})\n","import { define } from 'gunshi'\n\nexport const command = define({\n name: 'list',\n description:\n 'List the installed Kubb extensions: their registry id, package, installed version, the version the Kubb registry pins, and whether an update exists.',\n examples: 'kubb list',\n async run() {\n const { run } = await import('../runners/list/run.ts')\n await run()\n },\n})\n","import { define } from 'gunshi'\n\n/** The runner is imported when the command runs, so listing `kubb --help` never loads `@kubb/mcp`. */\nexport const command = define({\n name: 'mcp',\n description:\n 'Start a Model Context Protocol (MCP) server that exposes Kubb code generation as tools for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect to it — the assistant can then call kubb generate directly without leaving the chat.',\n examples: ['kubb mcp', '# Then add to your MCP client config:', '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }'].join('\\n'),\n // gunshi prints the header to stdout, which the MCP stdio transport owns.\n rendering: { header: null },\n async run() {\n const { run } = await import('../runners/mcp/run.ts')\n await run()\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const command = define({\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 toKebab: true,\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 async run(ctx) {\n const { connectRunner } = await import('../../runners/studio/commands.ts')\n await connectRunner(ctx)\n },\n})\n","import { define } from 'gunshi'\nimport { command as connectCommand } from './connect.ts'\n\nexport const command = define({\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 toKebab: true,\n args: connectCommand.args,\n async run(ctx) {\n const { loginRunner } = await import('../../runners/studio/commands.ts')\n await loginRunner(ctx)\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const command = define({\n name: 'logout',\n description: 'Forget the stored Kubb Studio token.',\n examples: ['kubb studio logout'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n ...logLevelArg,\n },\n async run(ctx) {\n const { logoutRunner } = await import('../../runners/studio/commands.ts')\n await logoutRunner(ctx)\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'\n\nexport const command = define({\n name: 'start',\n description: 'Keep this project connected to Kubb Studio in the background.',\n toKebab: true,\n args: connectCommand.args,\n async run(ctx) {\n const { startRunner } = await import('../../runners/studio/commands.ts')\n await startRunner(ctx)\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 { stopRunner } = await import('../../runners/studio/commands.ts')\n await stopRunner()\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const command = define({\n name: 'status',\n description: 'Show the project worker, Kubb Studio pairing, and saved permissions.',\n examples: ['kubb studio status'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n ...logLevelArg,\n },\n async run(ctx) {\n const { statusRunner } = await import('../../runners/studio/commands.ts')\n await statusRunner(ctx)\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 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 name: 'studio',\n description: 'Connect this project to Kubb Studio, or manage its pairing and snapshots.',\n examples: ['kubb studio', 'kubb studio --allow-read', 'kubb studio login', 'kubb studio status', 'kubb studio logout', 'kubb studio snapshot'].join('\\n'),\n toKebab: true,\n args: connectCommand.args,\n async run(ctx) {\n const { connectRunner } = await import('../../runners/studio/commands.ts')\n await connectRunner(ctx)\n },\n subCommands: {\n start: startCommand,\n stop: stopCommand,\n connect: connectCommand,\n login: loginCommand,\n logout: logoutCommand,\n status: statusCommand,\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","import { define } from 'gunshi'\nimport { yesArg } from './shared.ts'\n\nexport const command = define({\n name: 'update',\n description:\n 'Update installed extensions to the version the Kubb registry pins. Pass ids to update only those, or --check to list the updates without installing.',\n examples: ['kubb update', 'kubb update --check', 'kubb update plugin-zod plugin-ts --yes'].join('\\n'),\n args: {\n ids: {\n type: 'positional',\n description: 'Registry ids to update, all installed extensions when omitted',\n multiple: true,\n },\n check: {\n type: 'boolean',\n description: 'List the available updates without installing them',\n default: false,\n },\n ...yesArg,\n },\n async run({ values }) {\n const { run } = await import('../runners/update/run.ts')\n await run({ ids: values.ids ?? [], check: values.check, yes: values.yes })\n },\n})\n","import { define } from 'gunshi'\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:\n 'Parse and validate an OpenAPI/Swagger file for structural correctness. Reports schema errors, missing required fields, and malformed references. Use this before running generate to catch spec issues early.',\n examples: ['kubb validate ./openapi.yaml', 'kubb validate https://petstore3.swagger.io/api/v3/openapi.json'].join('\\n'),\n args: {\n input: {\n type: 'positional',\n description: 'Path or URL to the OpenAPI/Swagger file 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 })\n },\n})\n","import { styleText } from 'node:util'\n\n/**\n * Maps each camelCase flag removed in favor of kebab-case (kubb-labs/kubb#4046) to its\n * replacement. Drop this table, and the rewrite it drives, once the deprecation window ends.\n */\nconst DEPRECATED_FLAGS: Record<string, string> = {\n allowWrite: 'allow-write',\n allowConfigEdit: 'allow-config-edit',\n allowExec: 'allow-exec',\n logLevel: 'log-level',\n dryRun: 'dry-run',\n packageVersion: 'package-version',\n}\n\nconst FLAG_PATTERN = /^--([a-zA-Z][\\w-]*)(=.*)?$/\n\n/**\n * Rewrites a deprecated camelCase flag to its kebab-case replacement and warns on stderr, so a\n * script written against the old flag names keeps working during the deprecation window instead\n * of failing with an unknown-option error.\n */\nexport function resolveDeprecatedFlags(args: Array<string>): Array<string> {\n return args.map((arg) => {\n const match = FLAG_PATTERN.exec(arg)\n const name = match?.[1]\n const replacement = name ? DEPRECATED_FLAGS[name] : undefined\n\n if (!name || !replacement) {\n return arg\n }\n\n console.error(\n `${styleText('yellow', 'Warning:')} --${name} is deprecated, use --${replacement} instead. --${name} will be removed in a future major version.`,\n )\n\n return `--${replacement}${match?.[2] ?? ''}`\n })\n}\n","import { styleText } from 'node:util'\nimport dryrun from '@gunshi/plugin-dryrun'\nimport { cli } from 'gunshi'\nimport { isDisabled as isTelemetryDisabled } from './Telemetry.ts'\nimport { version } from '../package.json'\nimport { command as addCommand } from './commands/add.ts'\nimport { command as generateCommand } from './commands/generate.ts'\nimport { command as initCommand } from './commands/init.ts'\nimport { command as listCommand } from './commands/list.ts'\nimport { command as mcpCommand } from './commands/mcp.ts'\nimport { command as studioCommand, routeStudioFlags } from './commands/studio/index.ts'\nimport { command as updateCommand } from './commands/update.ts'\nimport { command as validateCommand } from './commands/validate.ts'\nimport { resolveDeprecatedFlags } from './deprecatedFlags.ts'\n\n/** Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these. */\nconst QUIET_FLAGS = new Set<string>(['--help', '-h', '--version', '-v', '--json'])\n\n/**\n * Strips the leading executable + script entries when `process.argv` is passed directly.\n * Handles Node.js (`/usr/bin/node`), Bun (`/usr/local/bin/bun`), Deno, tsx, etc. All runtime\n * executable paths contain a path separator; bare command names do not.\n */\nfunction stripExecArgs(argv: Array<string>): Array<string> {\n const firstArgIsExecutablePath = (argv[0]?.includes('/') || argv[0]?.includes('\\\\')) ?? false\n return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv\n}\n\n/**\n * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a\n * quiet flag is passed, then runs the given command, or `generate` when none is given.\n */\nexport async function run(argv: Array<string> = process.argv): Promise<void> {\n const args = routeStudioFlags(resolveDeprecatedFlags(stripExecArgs(argv)))\n const isQuietFlag = args.some((arg) => QUIET_FLAGS.has(arg))\n\n // stderr, so the notice never lands in a stream a client parses, such as `kubb mcp` stdio.\n if (!isTelemetryDisabled() && !isQuietFlag) {\n console.error(\n `${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \\nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\\n`,\n )\n }\n\n // Each command's `run` imports its runner, so an optional peer (@kubb/adapter-oas, @kubb/mcp, @kubb/studio) loads only when it runs.\n await cli(args, generateCommand, {\n name: 'kubb',\n version,\n // Not `generateCommand.description`: gunshi prints this on every subcommand's help too, so\n // `kubb studio --help` would open with a paragraph about generating types.\n description: 'Generate code from an OpenAPI specification, manage Kubb extensions, or connect the project to Kubb Studio.',\n subCommands: {\n generate: generateCommand,\n init: initCommand,\n validate: validateCommand,\n mcp: mcpCommand,\n studio: studioCommand,\n add: addCommand,\n update: updateCommand,\n list: listCommand,\n },\n fallbackToEntry: true,\n strict: true,\n plugins: [dryrun({ name: 'dry-run' })],\n onErrorCommand: async (_ctx, error) => {\n process.exitCode = 1\n console.error(error)\n },\n })\n}\n"],"mappings":";;;;;;AAUA,MAAa,YAAY,EACvB,QAAQ;CACN,MAAM;CACN,aAAa;CACb,OAAO;AACT,EACF;AAEA,MAAa,SAAS,EACpB,KAAK;CACH,MAAM;CACN,aAAa;CACb,OAAO;CACP,SAAS;AACX,EACF;AAEA,MAAa,cAAc,EACzB,UAAU;CACR,MAAM;CACN,SAAS;EAAC;EAAU;EAAQ;CAAS;CACrC,aAAa;CACb,OAAO;CACP,SAAS;CACT,SAAS;AACX,EACF;AAEA,MAAa,uBAAuB;CAClC,KAAK;EACH,MAAM;EACN,aAAa;CACf;CACA,OAAO;EACL,MAAM;EACN,aAAa;CACf;AACF;AAEA,MAAa,uBAAuB;CAClC,WAAW;EACT,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,YAAY;EACV,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,iBAAiB;EACf,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,WAAW;EACT,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;AACF;;;ACvEA,MAAaA,aAAU,OAAO;CAC5B,MAAM;CACN,aACE;CACF,UAAU;EAAC;EAAuB;EAAyC;EAAgC;CAAkC,CAAC,CAAC,KAAK,IAAI;CACxJ,SAAS;CACT,MAAM;EACJ,IAAI;GACF,MAAM;GACN,aAAa;GACb,UAAU;EACZ;EACA,GAAG;EACH,GAAG;EACH,SAAS;GACP,MAAM;GACN,aAAa;GACb,WAAW;GACX,SAAS;EACX;CACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAC7B,MAAM,IAAI;GAAE,IAAI,OAAO;GAAI,YAAY,OAAO;GAAQ,KAAK,OAAO;GAAK,SAAS,OAAO;EAAQ,CAAC;CAClG;AACF,CAAC;;;ACxBD,MAAM,iBAAsC;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,MAAM,CAAC,IAAI;AACxE;;;;;AAMA,eAAsB,IAAI,OAAsB,QAAQ,MAAqB;CAC3E,MAAM,OAAO,iBAAiB,uBAAuB,cAAc,IAAI,CAAC,CAAC;CACzE,MAAM,cAAc,KAAK,MAAM,QAAQ,YAAY,IAAI,GAAG,CAAC;CAG3D,IAAI,CAACC,WAAoB,KAAK,CAAC,aAC7B,QAAQ,MACN,GAAG,UAAU,UAAU,SAAS,EAAE,uIAAuI,UAAU,QAAQ,0BAA0B,EAAE,IACzN;CAIF,MAAM,IAAI,MAAMC,YAAiB;EAC/B,MAAM;EACN;EAGA,aAAa;EACb,aAAa;GACX,UAAUA;GACV,MAAMC;GACN,UAAUC;GACV,KAAKC;GACL,QAAQC;GACR,KAAKC;GACL,QAAQC;GACR,MAAMC;EACR;EACA,iBAAiB;EACjB,QAAQ;EACR,SAAS,CAAC,OAAO,EAAE,MAAM,UAAU,CAAC,CAAC;EACrC,gBAAgB,OAAO,MAAM,UAAU;GACrC,QAAQ,WAAW;GACnB,QAAQ,MAAM,KAAK;EACrB;CACF,CAAC;AACH"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./rolldown-runtime-CRm0XQPb.js";
|
|
2
2
|
import { n as toError } from "./errors-DmC83ALX.js";
|
|
3
3
|
import { i as isCIEnvironment } from "./agent-BPIqnEl2.js";
|
|
4
|
-
import { n as trackRun, r as version } from "./Telemetry-
|
|
4
|
+
import { n as trackRun, r as version } from "./Telemetry-BivZAaw9.js";
|
|
5
5
|
import { t as KUBB_CONFIG_FILENAME } from "./constants-DHRspBTo.js";
|
|
6
6
|
import { n as getConfigs } from "./config-DAdYwK_D.js";
|
|
7
7
|
import { g as plainLogger, o as logIntro, p as canUseTTY, r as logBlock, s as logOutro, t as createSpinner, u as logTip } from "./output-B9Yw7vL0.js";
|
|
@@ -280,7 +280,7 @@ async function connect(options, context = {}) {
|
|
|
280
280
|
}
|
|
281
281
|
try {
|
|
282
282
|
if (!context.prepared) {
|
|
283
|
-
const { getWorkerStatus } = await import("./background-
|
|
283
|
+
const { getWorkerStatus } = await import("./background-D0UaV1ZP.js");
|
|
284
284
|
if ((await getWorkerStatus()).running) throw new Error("This project is running in the background. Run `kubb studio stop` first.");
|
|
285
285
|
}
|
|
286
286
|
const prepared = context.prepared ?? await prepareConnection(options, signal);
|
|
@@ -363,4 +363,4 @@ async function run({ options, action, block = false, json = false }) {
|
|
|
363
363
|
//#endregion
|
|
364
364
|
export { login as a, clearCredentials as c, loadConfigs as i, getProjectKubbHome as l, createStudioOptions as n, prepareConnection as o, formatPermissionRows as r, run as s, connect as t, readCredentials as u };
|
|
365
365
|
|
|
366
|
-
//# sourceMappingURL=run-
|
|
366
|
+
//# sourceMappingURL=run-BF2Wq1Io.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-9oIapU5y.js","names":["logLevelMap"],"sources":["../../../internals/utils/src/openInBrowser.ts","../src/runners/studio/credentials.ts","../src/runners/studio/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { x } from 'tinyexec'\nimport { isCIEnvironment } from './isCIEnvironment.ts'\n\nconst ignore = () => {}\n\n/**\n * Opens a URL or local file in the default browser, unless running in CI.\n */\nexport function openInBrowser(target: string): void {\n if (isCIEnvironment()) return\n\n if (process.platform === 'win32') {\n x('cmd', ['/c', 'start', '', target]).then(ignore, ignore)\n return\n }\n x(process.platform === 'darwin' ? 'open' : 'xdg-open', [target]).then(ignore, ignore)\n}\n","import { hash, randomBytes } from 'node:crypto'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { kubbStorage, resolveKubbDir } from '@kubb/core'\n\nconst projectBase = (project = process.cwd()) => path.join('projects', hash('sha256', project))\n\n/**\n * Root for the credential and machine identity of the current project, inside `KUBB_HOME`.\n *\n * Studio agents are project connections, so two projects on one machine must not share the same\n * persisted token or machine secret.\n */\nexport function getProjectKubbHome(project = process.cwd()): string {\n return resolveKubbDir(projectBase(project))\n}\n\nconst projectStorage = () => kubbStorage({ base: projectBase() })\n\nconst CREDENTIALS_FILENAME = 'credentials.json'\n\n/**\n * Absolute path of the stored credential, so callers can name it in output without rebuilding it.\n */\nexport function getCredentialsPath(): string {\n return path.join(getProjectKubbHome(), CREDENTIALS_FILENAME)\n}\n\nexport type Credentials = {\n /**\n * The Studio instance this machine paired with. A different `--url` means re-pairing.\n */\n studioUrl: string\n /**\n * Bearer token for this machine. Never logged, never printed.\n */\n token: string\n agentId: string\n agentSlug: string\n /**\n * Permissions the user has already granted, keyed by absolute project path, so the CLI asks\n * once per project instead of on every run.\n */\n projects?: Record<string, { allowRead?: boolean; allowWrite?: boolean; allowConfigEdit?: boolean; allowExec?: boolean }>\n}\n\n/**\n * Reads the stored credential, or null when this machine has not paired yet or the file is\n * unreadable or corrupt. A bad file is treated as \"not paired\" so `kubb studio login` can\n * overwrite it rather than the CLI dying on it.\n */\nexport async function readCredentials(): Promise<Credentials | null> {\n const stored = await projectStorage()\n .getItem<Credentials>(CREDENTIALS_FILENAME)\n .catch(() => null)\n\n return typeof stored?.token === 'string' && stored.token !== '' ? stored : null\n}\n\n/**\n * Writes the credential into the project folder, which only its owner can open.\n */\nexport async function writeCredentials(credentials: Credentials): Promise<void> {\n await projectStorage().setItem(CREDENTIALS_FILENAME, credentials)\n}\n\n/**\n * Forgets the stored credential. Succeeds when there was nothing to forget.\n */\nexport async function clearCredentials(): Promise<void> {\n await projectStorage().removeItem(CREDENTIALS_FILENAME)\n}\n\n/**\n * Reads this project's machine secret, creating it on first use. Pairing sends its hash, so pairing\n * the same project again rotates one agent's token instead of creating a second agent. It lives\n * apart from the credential, which {@link clearCredentials} deletes.\n */\nexport async function getMachineId(): Promise<string> {\n const storage = projectStorage()\n const stored = await storage.getItem('machine-secret').catch(() => null)\n if (typeof stored === 'string' && stored.trim()) return stored.trim()\n\n const secret = randomBytes(32).toString('hex')\n await storage.setItem('machine-secret', secret)\n\n return secret\n}\n","import { hostname } from 'node:os'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as prompts from '@clack/prompts'\nimport { KUBB_CONFIG_FILENAME } from '@internals/shared'\nimport { isCIEnvironment, openInBrowser, toError } from '@internals/utils'\nimport type { CLIOptions, Config } from '@kubb/core'\nimport { cliReporter, Hookable, type KubbHooks, logLevel as logLevelMap } from '@kubb/core'\nimport { connectAgent, defaultStudioUrl, InvalidAgentTokenError, pairAgent, PairingCanceledError } from '@kubb/studio'\nimport { trackRun } from '../../Telemetry.ts'\nimport { plainLogger } from '../../loggers/plainLogger.ts'\nimport setupReporters from '../../loggers/reporters.ts'\nimport { createSpinner, logBlock, logIntro, logOutro, logTip } from '../../loggers/output.ts'\nimport { canUseTTY } from '../../utils/env.ts'\nimport { getConfigs } from '../../config.ts'\nimport { clearCredentials, type Credentials, getCredentialsPath, getMachineId, readCredentials, writeCredentials } from './credentials.ts'\nimport { version } from '../../../package.json'\n\ntype Permission = 'allowRead' | 'allowWrite' | 'allowConfigEdit' | 'allowExec'\n\nexport type StudioOptions = {\n /**\n * Current `@kubb/cli` version, reported to Studio and used for the telemetry payload.\n */\n version: string\n configPath?: string\n /**\n * Base URL of the Studio instance, for a self-hosted deployment. Resolved before it reaches here,\n * since stored credentials are bound to it.\n */\n studioUrl: string\n /**\n * What Studio may do in this project. Each flag grants outright; the rest are asked once per\n * project through {@link resolvePermissions}.\n */\n permission: Record<Permission, boolean>\n /**\n * Whether to open the approval page in a browser during pairing.\n */\n autoOpen: boolean\n logLevel?: CLIOptions['logLevel']\n}\n\nexport type SnapshotOptions = Pick<StudioOptions, 'configPath' | 'studioUrl' | 'logLevel'> & {\n /**\n * Organization CI API key. Falls back to `KUBB_TOKEN`.\n */\n token?: string\n /**\n * Stable identity for the CI agent. Falls back to CI auto-detection.\n */\n id?: string\n /** Identity of another CI agent to also compare with. Falls back to CI auto-detection. */\n baseId?: string\n /**\n * Package name for the generated tarball. Falls back to the nearest package.json.\n */\n name?: string\n /**\n * Package version for the generated tarball. Falls back to the nearest package.json.\n */\n packageVersion?: string\n /**\n * Print the result as one JSON object instead of a summary.\n */\n json?: boolean\n}\n\ntype StudioValues = {\n config?: string\n url?: string\n allowRead: boolean\n allowWrite: boolean\n allowConfigEdit: boolean\n allowExec: boolean\n open?: boolean\n logLevel?: CLIOptions['logLevel']\n}\n\nexport function createStudioOptions(values: StudioValues): StudioOptions {\n return {\n version,\n configPath: values.config,\n studioUrl: values.url ?? defaultStudioUrl,\n permission: {\n allowRead: values.allowRead,\n allowWrite: values.allowWrite,\n allowConfigEdit: values.allowConfigEdit,\n allowExec: values.allowExec,\n },\n autoOpen: values.open ?? true,\n logLevel: values.logLevel,\n }\n}\n\ntype LoginOptions = {\n /**\n * Aborting this cancels an in-flight pairing request or poll and rejects with\n * {@link PairingCanceledError}. Wired to `kubb studio`'s shutdown signal, so Ctrl+C during\n * pairing cancels it instead of leaving the poll running.\n */\n signal?: AbortSignal\n /**\n * Credentials from before this login. When the fresh pairing resolves to the same agent on the\n * same Studio, its saved project permissions carry forward instead of being asked again.\n * Left out for an explicitly requested `kubb studio login`, which always starts clean.\n */\n previousCredentials?: Credentials | null\n}\n\n/**\n * Pairs this machine with Studio and stores the resulting token.\n *\n * The CLI holds a code and the browser approves it, rather than the user copying a token out of\n * the UI. The token comes back over the CLI's own HTTPS POST, so it never lands in a URL, a\n * server log, or a `Referer` header.\n */\nexport async function login({ studioUrl, autoOpen }: StudioOptions, { signal, previousCredentials }: LoginOptions = {}): Promise<Credentials> {\n const spinner = createSpinner()\n // The spinner only starts once a code is shown.\n let waiting = false\n\n try {\n const { token, agent } = await pairAgent({\n studioUrl,\n type: 'cli',\n name: path.basename(process.cwd()),\n hostname: hostname(),\n machineId: await getMachineId(),\n signal,\n onCode: (session) => {\n console.log(`\\nOpen ${styleText('cyan', session.verification_uri)} and approve the code ${styleText('bold', session.user_code)}`)\n\n if (autoOpen) {\n openInBrowser(session.verification_uri_complete)\n }\n\n spinner.start('Waiting for approval')\n waiting = true\n },\n onRetry: (error) => spinner.message(`Could not reach Kubb Studio, retrying: ${error.message}`),\n })\n spinner.stop(`Paired as ${agent.name}`)\n\n const keepsIdentity = previousCredentials?.studioUrl === studioUrl && previousCredentials.agentId === agent.id\n const credentials: Credentials = {\n studioUrl,\n token,\n agentId: agent.id,\n agentSlug: agent.slug,\n ...(keepsIdentity && previousCredentials?.projects ? { projects: previousCredentials.projects } : {}),\n }\n await writeCredentials(credentials)\n\n console.log(`Credentials stored in ${getCredentialsPath()}`)\n\n return credentials\n } catch (error) {\n if (waiting) {\n spinner.stop(error instanceof PairingCanceledError ? 'Pairing canceled' : 'Pairing failed')\n }\n throw error\n }\n}\n\n/**\n * What each permission is asked as, in the order the questions appear.\n */\nconst PERMISSIONS: ReadonlyArray<{\n key: Permission\n /**\n * Short label for status output and the connect summary.\n */\n label: string\n question: (project: string, configPath: string) => string\n}> = [\n {\n key: 'allowRead',\n label: 'read generated files',\n question: () => 'Let Kubb Studio read the files a generation produced?',\n },\n { key: 'allowWrite', label: 'write generated files', question: (project) => `Let Kubb Studio write generated files into ${project}?` },\n {\n key: 'allowConfigEdit',\n label: 'edit kubb.config.ts',\n question: (_project, configPath) => `Let Kubb Studio change plugin options in ${configPath}?`,\n },\n {\n key: 'allowExec',\n label: 'run formatter, linter, postGenerate',\n question: () => 'Let Kubb Studio run the formatter, the linter, and output.postGenerate?',\n },\n]\n\n/**\n * One row per permission, for the connect banner and `kubb studio status`. A list rather than a\n * joined line: four labels this long read as one run-on sentence side by side.\n */\nexport function formatPermissionRows(granted: Record<Permission, boolean>): Array<string> {\n return PERMISSIONS.map(({ key, label }) => `${granted[key] ? styleText('green', '✔') : styleText('red', '✘')} ${label}`)\n}\n\n/**\n * Resolves Studio permissions for the current project.\n * Flags win, saved answers are reused, and new answers are stored unless `persist` is false.\n */\nexport async function resolvePermissions(\n options: StudioOptions,\n credentials: Credentials,\n configPath: string = KUBB_CONFIG_FILENAME,\n /**\n * Stores new answers in `~/.kubb/credentials.json`.\n * Pass `false` for `KUBB_AGENT_TOKEN` sessions so a temporary token is not written back to disk.\n */\n persist = true,\n): Promise<Record<Permission, boolean>> {\n const project = process.cwd()\n const remembered = credentials.projects?.[project]\n const granted: Record<Permission, boolean> = { allowRead: false, allowWrite: false, allowConfigEdit: false, allowExec: false }\n const answers: Partial<Record<Permission, boolean>> = {}\n prompts.updateSettings({ withGuide: true })\n\n for (const { key, question } of PERMISSIONS) {\n if (options.permission[key] || typeof remembered?.[key] === 'boolean') {\n granted[key] = options.permission[key] || remembered?.[key] === true\n continue\n }\n\n if (isCIEnvironment() || !canUseTTY()) {\n granted[key] = false\n continue\n }\n\n granted[key] = (await prompts.confirm({ message: question(project, configPath), initialValue: false })) === true\n answers[key] = granted[key]\n }\n if (persist && Object.keys(answers).length) {\n await writeCredentials({\n ...credentials,\n projects: { ...credentials.projects, [project]: { ...remembered, ...answers } },\n })\n }\n\n return granted\n}\n\n/**\n * Loads the project's Kubb config the same way `kubb generate` does.\n * Returns the first config.\n */\nexport async function loadConfigs(options: Pick<StudioOptions, 'configPath' | 'logLevel'>): Promise<{ configPath: string; config: Config }> {\n const { configPath, configs } = await getConfigs({ configPath: options.configPath, logLevel: options.logLevel })\n const [config] = configs\n\n if (!config) {\n throw new Error('Config not defined, create a kubb.config.ts or pass it with --config')\n }\n\n // `getConfigs` resolves this to an absolute path. Relativized here, once, so the permission\n // prompt and the path Studio receives over the wire both show the project-relative form instead\n // of leaking the local filesystem layout.\n return { configPath: path.relative(process.cwd(), configPath) || configPath, config }\n}\n\n/**\n * Why a rejected token could not be recovered automatically: it came from `KUBB_AGENT_TOKEN`, no\n * browser is available to re-pair with, or the token this run already re-paired for was rejected\n * again.\n */\ntype RejectedTokenReason = 'envToken' | 'nonInteractive' | 'reauthExhausted'\n\n/**\n * Explains a rejected token to the operator. Builds the error and nothing else, so each caller\n * decides what happens to the credentials.\n */\nfunction explainRejectedToken(error: InvalidAgentTokenError, reason: RejectedTokenReason): Error {\n if (reason === 'envToken') {\n return new Error(`${error.message} Pair again and update KUBB_AGENT_TOKEN.`)\n }\n\n if (reason === 'reauthExhausted') {\n return new Error(`${error.message} Studio rejected the newly approved token too. Run \\`kubb studio login\\` and try again.`)\n }\n\n return new Error(`${error.message} Run \\`kubb studio login\\` to pair again.`)\n}\n\nexport type PreparedConnection = {\n configPath: string\n credentials: Credentials\n permissions: StudioOptions['permission']\n}\n\n/** Validates the project and resolves pairing and permissions before starting its worker. */\nexport async function prepareConnection(options: StudioOptions, signal?: AbortSignal): Promise<PreparedConnection> {\n const { configPath } = await loadConfigs(options)\n const envToken = process.env.KUBB_AGENT_TOKEN\n const stored = envToken ? null : await readCredentials()\n const credentials = await (async () => {\n if (envToken) return { studioUrl: options.studioUrl, token: envToken, agentId: '', agentSlug: '' }\n if (stored?.studioUrl === options.studioUrl) return stored\n if (isCIEnvironment()) {\n throw new Error(`Not paired with ${options.studioUrl}. Set KUBB_AGENT_TOKEN, or run \\`kubb studio login\\` on a machine with a browser.`)\n }\n return login(options, { signal })\n })()\n const permissions = await resolvePermissions(options, credentials, configPath, !envToken)\n return { configPath, credentials, permissions }\n}\n\nexport type WorkerState = 'starting' | 'connected' | 'reconnecting' | 'authentication required' | 'stopped'\n\n/** Runs the same project connection in the foreground or in a background worker. */\nexport async function connect(\n options: StudioOptions,\n context: {\n prepared?: PreparedConnection\n signal?: AbortSignal\n onState?: (state: WorkerState) => void | Promise<void>\n } = {},\n): Promise<void> {\n const shutdown = new AbortController()\n const signal = context.signal ?? shutdown.signal\n const stop = () => shutdown.abort()\n const events = process as unknown as NodeJS.EventEmitter\n if (!context.signal) {\n events.once('SIGINT', stop)\n events.once('SIGTERM', stop)\n }\n try {\n if (!context.prepared) {\n const { getWorkerStatus } = await import('./background.ts')\n const worker = await getWorkerStatus()\n if (worker.running) throw new Error('This project is running in the background. Run `kubb studio stop` first.')\n }\n const prepared = context.prepared ?? (await prepareConnection(options, signal))\n let { credentials, permissions } = prepared\n const { configPath } = prepared\n let hinted = false\n // Set by a fresh pairing until it connects, so a token rejected right after approval fails the run instead of looping.\n let pairedAgain = false\n\n // The background worker writes to a log file, so it gets the plain logger rather than the\n // animated one. The logger also covers the `studio:*` events and each generation run.\n const hooks = new Hookable<KubbHooks>()\n setupReporters(hooks, {\n logLevel: logLevelMap[options.logLevel ?? 'info'],\n reporters: [cliReporter],\n ...(context.onState ? { logger: plainLogger } : {}),\n })\n hooks.hook('studio:connected', async () => {\n pairedAgain = false\n await context.onState?.('connected')\n if (hinted || context.onState || options.logLevel === 'silent') return\n hinted = true\n logBlock(styleText('dim', 'Press Ctrl+C to disconnect'))\n logTip()\n })\n hooks.hook('studio:reconnecting', () => context.onState?.('reconnecting'))\n\n for (;;) {\n try {\n await connectAgent({\n token: credentials.token,\n studioUrl: options.studioUrl,\n configPath,\n version: options.version,\n root: process.cwd(),\n permissions,\n loadConfig: async () => (await loadConfigs(options)).config,\n hooks,\n signal,\n })\n break\n } catch (error) {\n if (!(error instanceof InvalidAgentTokenError)) throw error\n await context.onState?.('authentication required')\n if (process.env.KUBB_AGENT_TOKEN) throw explainRejectedToken(error, 'envToken')\n await clearCredentials()\n if (pairedAgain) throw explainRejectedToken(error, 'reauthExhausted')\n if (context.onState || isCIEnvironment() || !canUseTTY()) throw explainRejectedToken(error, 'nonInteractive')\n\n console.log(styleText('yellow', `${error.message} Pairing again...`))\n credentials = await login(options, { signal, previousCredentials: credentials })\n pairedAgain = true\n permissions = await resolvePermissions(options, credentials, configPath)\n }\n }\n if (!context.onState && signal.aborted && options.logLevel !== 'silent') logOutro('Disconnected')\n } catch (error) {\n if (!(error instanceof PairingCanceledError)) throw error\n } finally {\n events.off('SIGINT', stop)\n events.off('SIGTERM', stop)\n }\n}\n\n/**\n * Runs a Studio command with shared setup and telemetry reporting.\n */\nexport async function run({\n options,\n action,\n block = false,\n json = false,\n}: {\n options: Pick<StudioOptions, 'logLevel'>\n action: () => Promise<unknown>\n block?: boolean\n json?: boolean\n}): Promise<void> {\n const report = trackRun({ command: 'studio', hrStart: process.hrtime() })\n\n try {\n if (options.logLevel !== 'silent' && !json) {\n logIntro({\n warning: styleText('yellow', 'This feature is still under development, use with caution'),\n block,\n })\n }\n\n await action()\n\n await report({ status: 'success' })\n } catch (error) {\n await report({ status: 'failed' })\n console.error(toError(error).message)\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAIA,MAAM,eAAe,CAAC;;;;AAKtB,SAAgB,cAAc,QAAsB;CAClD,IAAI,gBAAgB,GAAG;CAEvB,IAAI,QAAQ,aAAa,SAAS;EAChC,EAAE,OAAO;GAAC;GAAM;GAAS;GAAI;EAAM,CAAC,CAAC,CAAC,KAAK,QAAQ,MAAM;EACzD;CACF;CACA,EAAE,QAAQ,aAAa,WAAW,SAAS,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,QAAQ,MAAM;AACtF;;;ACZA,MAAM,eAAe,UAAU,QAAQ,IAAI,MAAM,KAAK,KAAK,YAAY,KAAK,UAAU,OAAO,CAAC;;;;;;;AAQ9F,SAAgB,mBAAmB,UAAU,QAAQ,IAAI,GAAW;CAClE,OAAO,eAAe,YAAY,OAAO,CAAC;AAC5C;AAEA,MAAM,uBAAuB,YAAY,EAAE,MAAM,YAAY,EAAE,CAAC;AAEhE,MAAM,uBAAuB;;;;AAK7B,SAAgB,qBAA6B;CAC3C,OAAO,KAAK,KAAK,mBAAmB,GAAG,oBAAoB;AAC7D;;;;;;AAyBA,eAAsB,kBAA+C;CACnE,MAAM,SAAS,MAAM,eAAe,CAAC,CAClC,QAAqB,oBAAoB,CAAC,CAC1C,YAAY,IAAI;CAEnB,OAAO,OAAO,QAAQ,UAAU,YAAY,OAAO,UAAU,KAAK,SAAS;AAC7E;;;;AAKA,eAAsB,iBAAiB,aAAyC;CAC9E,MAAM,eAAe,CAAC,CAAC,QAAQ,sBAAsB,WAAW;AAClE;;;;AAKA,eAAsB,mBAAkC;CACtD,MAAM,eAAe,CAAC,CAAC,WAAW,oBAAoB;AACxD;;;;;;AAOA,eAAsB,eAAgC;CAC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WAAW;CACrB;AACF"}
|
|
1
|
+
{"version":3,"file":"run-BF2Wq1Io.js","names":["logLevelMap"],"sources":["../../../internals/utils/src/openInBrowser.ts","../src/runners/studio/credentials.ts","../src/runners/studio/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { x } from 'tinyexec'\nimport { isCIEnvironment } from './isCIEnvironment.ts'\n\nconst ignore = () => {}\n\n/**\n * Opens a URL or local file in the default browser, unless running in CI.\n */\nexport function openInBrowser(target: string): void {\n if (isCIEnvironment()) return\n\n if (process.platform === 'win32') {\n x('cmd', ['/c', 'start', '', target]).then(ignore, ignore)\n return\n }\n x(process.platform === 'darwin' ? 'open' : 'xdg-open', [target]).then(ignore, ignore)\n}\n","import { hash, randomBytes } from 'node:crypto'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { kubbStorage, resolveKubbDir } from '@kubb/core'\n\nconst projectBase = (project = process.cwd()) => path.join('projects', hash('sha256', project))\n\n/**\n * Root for the credential and machine identity of the current project, inside `KUBB_HOME`.\n *\n * Studio agents are project connections, so two projects on one machine must not share the same\n * persisted token or machine secret.\n */\nexport function getProjectKubbHome(project = process.cwd()): string {\n return resolveKubbDir(projectBase(project))\n}\n\nconst projectStorage = () => kubbStorage({ base: projectBase() })\n\nconst CREDENTIALS_FILENAME = 'credentials.json'\n\n/**\n * Absolute path of the stored credential, so callers can name it in output without rebuilding it.\n */\nexport function getCredentialsPath(): string {\n return path.join(getProjectKubbHome(), CREDENTIALS_FILENAME)\n}\n\nexport type Credentials = {\n /**\n * The Studio instance this machine paired with. A different `--url` means re-pairing.\n */\n studioUrl: string\n /**\n * Bearer token for this machine. Never logged, never printed.\n */\n token: string\n agentId: string\n agentSlug: string\n /**\n * Permissions the user has already granted, keyed by absolute project path, so the CLI asks\n * once per project instead of on every run.\n */\n projects?: Record<string, { allowRead?: boolean; allowWrite?: boolean; allowConfigEdit?: boolean; allowExec?: boolean }>\n}\n\n/**\n * Reads the stored credential, or null when this machine has not paired yet or the file is\n * unreadable or corrupt. A bad file is treated as \"not paired\" so `kubb studio login` can\n * overwrite it rather than the CLI dying on it.\n */\nexport async function readCredentials(): Promise<Credentials | null> {\n const stored = await projectStorage()\n .getItem<Credentials>(CREDENTIALS_FILENAME)\n .catch(() => null)\n\n return typeof stored?.token === 'string' && stored.token !== '' ? stored : null\n}\n\n/**\n * Writes the credential into the project folder, which only its owner can open.\n */\nexport async function writeCredentials(credentials: Credentials): Promise<void> {\n await projectStorage().setItem(CREDENTIALS_FILENAME, credentials)\n}\n\n/**\n * Forgets the stored credential. Succeeds when there was nothing to forget.\n */\nexport async function clearCredentials(): Promise<void> {\n await projectStorage().removeItem(CREDENTIALS_FILENAME)\n}\n\n/**\n * Reads this project's machine secret, creating it on first use. Pairing sends its hash, so pairing\n * the same project again rotates one agent's token instead of creating a second agent. It lives\n * apart from the credential, which {@link clearCredentials} deletes.\n */\nexport async function getMachineId(): Promise<string> {\n const storage = projectStorage()\n const stored = await storage.getItem('machine-secret').catch(() => null)\n if (typeof stored === 'string' && stored.trim()) return stored.trim()\n\n const secret = randomBytes(32).toString('hex')\n await storage.setItem('machine-secret', secret)\n\n return secret\n}\n","import { hostname } from 'node:os'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as prompts from '@clack/prompts'\nimport { KUBB_CONFIG_FILENAME } from '@internals/shared'\nimport { isCIEnvironment, openInBrowser, toError } from '@internals/utils'\nimport type { CLIOptions, Config } from '@kubb/core'\nimport { cliReporter, Hookable, type KubbHooks, logLevel as logLevelMap } from '@kubb/core'\nimport { connectAgent, defaultStudioUrl, InvalidAgentTokenError, pairAgent, PairingCanceledError } from '@kubb/studio'\nimport { trackRun } from '../../Telemetry.ts'\nimport { plainLogger } from '../../loggers/plainLogger.ts'\nimport setupReporters from '../../loggers/reporters.ts'\nimport { createSpinner, logBlock, logIntro, logOutro, logTip } from '../../loggers/output.ts'\nimport { canUseTTY } from '../../utils/env.ts'\nimport { getConfigs } from '../../config.ts'\nimport { clearCredentials, type Credentials, getCredentialsPath, getMachineId, readCredentials, writeCredentials } from './credentials.ts'\nimport { version } from '../../../package.json'\n\ntype Permission = 'allowRead' | 'allowWrite' | 'allowConfigEdit' | 'allowExec'\n\nexport type StudioOptions = {\n /**\n * Current `@kubb/cli` version, reported to Studio and used for the telemetry payload.\n */\n version: string\n configPath?: string\n /**\n * Base URL of the Studio instance, for a self-hosted deployment. Resolved before it reaches here,\n * since stored credentials are bound to it.\n */\n studioUrl: string\n /**\n * What Studio may do in this project. Each flag grants outright; the rest are asked once per\n * project through {@link resolvePermissions}.\n */\n permission: Record<Permission, boolean>\n /**\n * Whether to open the approval page in a browser during pairing.\n */\n autoOpen: boolean\n logLevel?: CLIOptions['logLevel']\n}\n\nexport type SnapshotOptions = Pick<StudioOptions, 'configPath' | 'studioUrl' | 'logLevel'> & {\n /**\n * Organization CI API key. Falls back to `KUBB_TOKEN`.\n */\n token?: string\n /**\n * Stable identity for the CI agent. Falls back to CI auto-detection.\n */\n id?: string\n /** Identity of another CI agent to also compare with. Falls back to CI auto-detection. */\n baseId?: string\n /**\n * Package name for the generated tarball. Falls back to the nearest package.json.\n */\n name?: string\n /**\n * Package version for the generated tarball. Falls back to the nearest package.json.\n */\n packageVersion?: string\n /**\n * Print the result as one JSON object instead of a summary.\n */\n json?: boolean\n}\n\ntype StudioValues = {\n config?: string\n url?: string\n allowRead: boolean\n allowWrite: boolean\n allowConfigEdit: boolean\n allowExec: boolean\n open?: boolean\n logLevel?: CLIOptions['logLevel']\n}\n\nexport function createStudioOptions(values: StudioValues): StudioOptions {\n return {\n version,\n configPath: values.config,\n studioUrl: values.url ?? defaultStudioUrl,\n permission: {\n allowRead: values.allowRead,\n allowWrite: values.allowWrite,\n allowConfigEdit: values.allowConfigEdit,\n allowExec: values.allowExec,\n },\n autoOpen: values.open ?? true,\n logLevel: values.logLevel,\n }\n}\n\ntype LoginOptions = {\n /**\n * Aborting this cancels an in-flight pairing request or poll and rejects with\n * {@link PairingCanceledError}. Wired to `kubb studio`'s shutdown signal, so Ctrl+C during\n * pairing cancels it instead of leaving the poll running.\n */\n signal?: AbortSignal\n /**\n * Credentials from before this login. When the fresh pairing resolves to the same agent on the\n * same Studio, its saved project permissions carry forward instead of being asked again.\n * Left out for an explicitly requested `kubb studio login`, which always starts clean.\n */\n previousCredentials?: Credentials | null\n}\n\n/**\n * Pairs this machine with Studio and stores the resulting token.\n *\n * The CLI holds a code and the browser approves it, rather than the user copying a token out of\n * the UI. The token comes back over the CLI's own HTTPS POST, so it never lands in a URL, a\n * server log, or a `Referer` header.\n */\nexport async function login({ studioUrl, autoOpen }: StudioOptions, { signal, previousCredentials }: LoginOptions = {}): Promise<Credentials> {\n const spinner = createSpinner()\n // The spinner only starts once a code is shown.\n let waiting = false\n\n try {\n const { token, agent } = await pairAgent({\n studioUrl,\n type: 'cli',\n name: path.basename(process.cwd()),\n hostname: hostname(),\n machineId: await getMachineId(),\n signal,\n onCode: (session) => {\n console.log(`\\nOpen ${styleText('cyan', session.verification_uri)} and approve the code ${styleText('bold', session.user_code)}`)\n\n if (autoOpen) {\n openInBrowser(session.verification_uri_complete)\n }\n\n spinner.start('Waiting for approval')\n waiting = true\n },\n onRetry: (error) => spinner.message(`Could not reach Kubb Studio, retrying: ${error.message}`),\n })\n spinner.stop(`Paired as ${agent.name}`)\n\n const keepsIdentity = previousCredentials?.studioUrl === studioUrl && previousCredentials.agentId === agent.id\n const credentials: Credentials = {\n studioUrl,\n token,\n agentId: agent.id,\n agentSlug: agent.slug,\n ...(keepsIdentity && previousCredentials?.projects ? { projects: previousCredentials.projects } : {}),\n }\n await writeCredentials(credentials)\n\n console.log(`Credentials stored in ${getCredentialsPath()}`)\n\n return credentials\n } catch (error) {\n if (waiting) {\n spinner.stop(error instanceof PairingCanceledError ? 'Pairing canceled' : 'Pairing failed')\n }\n throw error\n }\n}\n\n/**\n * What each permission is asked as, in the order the questions appear.\n */\nconst PERMISSIONS: ReadonlyArray<{\n key: Permission\n /**\n * Short label for status output and the connect summary.\n */\n label: string\n question: (project: string, configPath: string) => string\n}> = [\n {\n key: 'allowRead',\n label: 'read generated files',\n question: () => 'Let Kubb Studio read the files a generation produced?',\n },\n { key: 'allowWrite', label: 'write generated files', question: (project) => `Let Kubb Studio write generated files into ${project}?` },\n {\n key: 'allowConfigEdit',\n label: 'edit kubb.config.ts',\n question: (_project, configPath) => `Let Kubb Studio change plugin options in ${configPath}?`,\n },\n {\n key: 'allowExec',\n label: 'run formatter, linter, postGenerate',\n question: () => 'Let Kubb Studio run the formatter, the linter, and output.postGenerate?',\n },\n]\n\n/**\n * One row per permission, for the connect banner and `kubb studio status`. A list rather than a\n * joined line: four labels this long read as one run-on sentence side by side.\n */\nexport function formatPermissionRows(granted: Record<Permission, boolean>): Array<string> {\n return PERMISSIONS.map(({ key, label }) => `${granted[key] ? styleText('green', '✔') : styleText('red', '✘')} ${label}`)\n}\n\n/**\n * Resolves Studio permissions for the current project.\n * Flags win, saved answers are reused, and new answers are stored unless `persist` is false.\n */\nexport async function resolvePermissions(\n options: StudioOptions,\n credentials: Credentials,\n configPath: string = KUBB_CONFIG_FILENAME,\n /**\n * Stores new answers in `~/.kubb/credentials.json`.\n * Pass `false` for `KUBB_AGENT_TOKEN` sessions so a temporary token is not written back to disk.\n */\n persist = true,\n): Promise<Record<Permission, boolean>> {\n const project = process.cwd()\n const remembered = credentials.projects?.[project]\n const granted: Record<Permission, boolean> = { allowRead: false, allowWrite: false, allowConfigEdit: false, allowExec: false }\n const answers: Partial<Record<Permission, boolean>> = {}\n prompts.updateSettings({ withGuide: true })\n\n for (const { key, question } of PERMISSIONS) {\n if (options.permission[key] || typeof remembered?.[key] === 'boolean') {\n granted[key] = options.permission[key] || remembered?.[key] === true\n continue\n }\n\n if (isCIEnvironment() || !canUseTTY()) {\n granted[key] = false\n continue\n }\n\n granted[key] = (await prompts.confirm({ message: question(project, configPath), initialValue: false })) === true\n answers[key] = granted[key]\n }\n if (persist && Object.keys(answers).length) {\n await writeCredentials({\n ...credentials,\n projects: { ...credentials.projects, [project]: { ...remembered, ...answers } },\n })\n }\n\n return granted\n}\n\n/**\n * Loads the project's Kubb config the same way `kubb generate` does.\n * Returns the first config.\n */\nexport async function loadConfigs(options: Pick<StudioOptions, 'configPath' | 'logLevel'>): Promise<{ configPath: string; config: Config }> {\n const { configPath, configs } = await getConfigs({ configPath: options.configPath, logLevel: options.logLevel })\n const [config] = configs\n\n if (!config) {\n throw new Error('Config not defined, create a kubb.config.ts or pass it with --config')\n }\n\n // `getConfigs` resolves this to an absolute path. Relativized here, once, so the permission\n // prompt and the path Studio receives over the wire both show the project-relative form instead\n // of leaking the local filesystem layout.\n return { configPath: path.relative(process.cwd(), configPath) || configPath, config }\n}\n\n/**\n * Why a rejected token could not be recovered automatically: it came from `KUBB_AGENT_TOKEN`, no\n * browser is available to re-pair with, or the token this run already re-paired for was rejected\n * again.\n */\ntype RejectedTokenReason = 'envToken' | 'nonInteractive' | 'reauthExhausted'\n\n/**\n * Explains a rejected token to the operator. Builds the error and nothing else, so each caller\n * decides what happens to the credentials.\n */\nfunction explainRejectedToken(error: InvalidAgentTokenError, reason: RejectedTokenReason): Error {\n if (reason === 'envToken') {\n return new Error(`${error.message} Pair again and update KUBB_AGENT_TOKEN.`)\n }\n\n if (reason === 'reauthExhausted') {\n return new Error(`${error.message} Studio rejected the newly approved token too. Run \\`kubb studio login\\` and try again.`)\n }\n\n return new Error(`${error.message} Run \\`kubb studio login\\` to pair again.`)\n}\n\nexport type PreparedConnection = {\n configPath: string\n credentials: Credentials\n permissions: StudioOptions['permission']\n}\n\n/** Validates the project and resolves pairing and permissions before starting its worker. */\nexport async function prepareConnection(options: StudioOptions, signal?: AbortSignal): Promise<PreparedConnection> {\n const { configPath } = await loadConfigs(options)\n const envToken = process.env.KUBB_AGENT_TOKEN\n const stored = envToken ? null : await readCredentials()\n const credentials = await (async () => {\n if (envToken) return { studioUrl: options.studioUrl, token: envToken, agentId: '', agentSlug: '' }\n if (stored?.studioUrl === options.studioUrl) return stored\n if (isCIEnvironment()) {\n throw new Error(`Not paired with ${options.studioUrl}. Set KUBB_AGENT_TOKEN, or run \\`kubb studio login\\` on a machine with a browser.`)\n }\n return login(options, { signal })\n })()\n const permissions = await resolvePermissions(options, credentials, configPath, !envToken)\n return { configPath, credentials, permissions }\n}\n\nexport type WorkerState = 'starting' | 'connected' | 'reconnecting' | 'authentication required' | 'stopped'\n\n/** Runs the same project connection in the foreground or in a background worker. */\nexport async function connect(\n options: StudioOptions,\n context: {\n prepared?: PreparedConnection\n signal?: AbortSignal\n onState?: (state: WorkerState) => void | Promise<void>\n } = {},\n): Promise<void> {\n const shutdown = new AbortController()\n const signal = context.signal ?? shutdown.signal\n const stop = () => shutdown.abort()\n const events = process as unknown as NodeJS.EventEmitter\n if (!context.signal) {\n events.once('SIGINT', stop)\n events.once('SIGTERM', stop)\n }\n try {\n if (!context.prepared) {\n const { getWorkerStatus } = await import('./background.ts')\n const worker = await getWorkerStatus()\n if (worker.running) throw new Error('This project is running in the background. Run `kubb studio stop` first.')\n }\n const prepared = context.prepared ?? (await prepareConnection(options, signal))\n let { credentials, permissions } = prepared\n const { configPath } = prepared\n let hinted = false\n // Set by a fresh pairing until it connects, so a token rejected right after approval fails the run instead of looping.\n let pairedAgain = false\n\n // The background worker writes to a log file, so it gets the plain logger rather than the\n // animated one. The logger also covers the `studio:*` events and each generation run.\n const hooks = new Hookable<KubbHooks>()\n setupReporters(hooks, {\n logLevel: logLevelMap[options.logLevel ?? 'info'],\n reporters: [cliReporter],\n ...(context.onState ? { logger: plainLogger } : {}),\n })\n hooks.hook('studio:connected', async () => {\n pairedAgain = false\n await context.onState?.('connected')\n if (hinted || context.onState || options.logLevel === 'silent') return\n hinted = true\n logBlock(styleText('dim', 'Press Ctrl+C to disconnect'))\n logTip()\n })\n hooks.hook('studio:reconnecting', () => context.onState?.('reconnecting'))\n\n for (;;) {\n try {\n await connectAgent({\n token: credentials.token,\n studioUrl: options.studioUrl,\n configPath,\n version: options.version,\n root: process.cwd(),\n permissions,\n loadConfig: async () => (await loadConfigs(options)).config,\n hooks,\n signal,\n })\n break\n } catch (error) {\n if (!(error instanceof InvalidAgentTokenError)) throw error\n await context.onState?.('authentication required')\n if (process.env.KUBB_AGENT_TOKEN) throw explainRejectedToken(error, 'envToken')\n await clearCredentials()\n if (pairedAgain) throw explainRejectedToken(error, 'reauthExhausted')\n if (context.onState || isCIEnvironment() || !canUseTTY()) throw explainRejectedToken(error, 'nonInteractive')\n\n console.log(styleText('yellow', `${error.message} Pairing again...`))\n credentials = await login(options, { signal, previousCredentials: credentials })\n pairedAgain = true\n permissions = await resolvePermissions(options, credentials, configPath)\n }\n }\n if (!context.onState && signal.aborted && options.logLevel !== 'silent') logOutro('Disconnected')\n } catch (error) {\n if (!(error instanceof PairingCanceledError)) throw error\n } finally {\n events.off('SIGINT', stop)\n events.off('SIGTERM', stop)\n }\n}\n\n/**\n * Runs a Studio command with shared setup and telemetry reporting.\n */\nexport async function run({\n options,\n action,\n block = false,\n json = false,\n}: {\n options: Pick<StudioOptions, 'logLevel'>\n action: () => Promise<unknown>\n block?: boolean\n json?: boolean\n}): Promise<void> {\n const report = trackRun({ command: 'studio', hrStart: process.hrtime() })\n\n try {\n if (options.logLevel !== 'silent' && !json) {\n logIntro({\n warning: styleText('yellow', 'This feature is still under development, use with caution'),\n block,\n })\n }\n\n await action()\n\n await report({ status: 'success' })\n } catch (error) {\n await report({ status: 'failed' })\n console.error(toError(error).message)\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAIA,MAAM,eAAe,CAAC;;;;AAKtB,SAAgB,cAAc,QAAsB;CAClD,IAAI,gBAAgB,GAAG;CAEvB,IAAI,QAAQ,aAAa,SAAS;EAChC,EAAE,OAAO;GAAC;GAAM;GAAS;GAAI;EAAM,CAAC,CAAC,CAAC,KAAK,QAAQ,MAAM;EACzD;CACF;CACA,EAAE,QAAQ,aAAa,WAAW,SAAS,YAAY,CAAC,MAAM,CAAC,CA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,MAAM,MAAM,SAAS;IAAE;IAAQ,qBAAqB;GAAY,CAAC;GAC/E,cAAc;GACd,cAAc,MAAM,mBAAmB,SAAS,aAAa,UAAU;EACzE;EAEF,IAAI,CAAC,QAAQ,WAAW,OAAO,WAAW,QAAQ,aAAa,UAAU,SAAS,cAAc;CAClG,SAAS,OAAO;EACd,IAAI,EAAE,iBAAiB,uBAAuB,MAAM;CACtD,UAAU;EACR,OAAO,IAAI,UAAU,IAAI;EACzB,OAAO,IAAI,WAAW,IAAI;CAC5B;AACF;;;;AAKA,eAAsB,IAAI,EACxB,SACA,QACA,QAAQ,OACR,OAAO,SAMS;CAChB,MAAM,SAAS,SAAS;EAAE,SAAS;EAAU,SAAS,QAAQ,OAAO;CAAE,CAAC;CAExE,IAAI;EACF,IAAI,QAAQ,aAAa,YAAY,CAAC,MACpC,SAAS;GACP,SAAS,UAAU,UAAU,2DAA2D;GACxF;EACF,CAAC;EAGH,MAAM,OAAO;EAEb,MAAM,OAAO,EAAE,QAAQ,UAAU,CAAC;CACpC,SAAS,OAAO;EACd,MAAM,OAAO,EAAE,QAAQ,SAAS,CAAC;EACjC,QAAQ,MAAM,QAAQ,KAAK,CAAC,CAAC,OAAO;EACpC,QAAQ,WAAW;CACrB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_agent = require("./agent-DElUuYuy.cjs");
|
|
2
2
|
const require_errors = require("./errors-BdA8M78q.cjs");
|
|
3
|
-
const require_Telemetry = require("./Telemetry-
|
|
3
|
+
const require_Telemetry = require("./Telemetry-D1jiXfo2.cjs");
|
|
4
4
|
const require_config = require("./config-CRBZcWwg.cjs");
|
|
5
5
|
const require_output = require("./output-CWupdozw.cjs");
|
|
6
6
|
const require_reporters = require("./reporters-C5HAypFq.cjs");
|
|
@@ -350,4 +350,4 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
|
|
|
350
350
|
//#endregion
|
|
351
351
|
exports.run = run;
|
|
352
352
|
|
|
353
|
-
//# sourceMappingURL=run-
|
|
353
|
+
//# sourceMappingURL=run-CNXBX4kr.cjs.map
|