@kubb/cli 5.15.1 → 5.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Telemetry-C7Qwy2s7.js → Telemetry-BTeqnqie.js} +2 -2
- package/dist/{Telemetry-C7Qwy2s7.js.map → Telemetry-BTeqnqie.js.map} +1 -1
- package/dist/{Telemetry-B52pKz9i.cjs → Telemetry-DuO34wMx.cjs} +2 -2
- package/dist/{Telemetry-B52pKz9i.cjs.map → Telemetry-DuO34wMx.cjs.map} +1 -1
- package/dist/{background-CK2gQtTU.cjs → background-CdE3TOkv.cjs} +2 -2
- package/dist/{background-CK2gQtTU.cjs.map → background-CdE3TOkv.cjs.map} +1 -1
- package/dist/{background-BJCuXYuB.js → background-DxK8rpi2.js} +2 -2
- package/dist/{background-BJCuXYuB.js.map → background-DxK8rpi2.js.map} +1 -1
- package/dist/{background-D4mZCg-4.js → background-TT-XsxC2.js} +1 -1
- package/dist/{configFile-CoEpHdXG.cjs → configFile-CVfWdtKh.cjs} +4 -40
- package/dist/configFile-CVfWdtKh.cjs.map +1 -0
- package/dist/{configFile-C0DIXNMD.js → configFile-IHj8fRIw.js} +3 -39
- package/dist/configFile-IHj8fRIw.js.map +1 -0
- package/dist/{spinner-BZaln7O8.js → fs-Cf1FSRh9.js} +20 -41
- package/dist/fs-Cf1FSRh9.js.map +1 -0
- package/dist/index.cjs +14 -14
- package/dist/index.js +14 -14
- package/dist/{installWithSpinner-DpnpxHq5.js → installWithSpinner-BAlTSQlE.js} +3 -3
- package/dist/{installWithSpinner-DpnpxHq5.js.map → installWithSpinner-BAlTSQlE.js.map} +1 -1
- package/dist/{installWithSpinner-ONGfIVUJ.cjs → installWithSpinner-X9J7yxiR.cjs} +3 -3
- package/dist/{installWithSpinner-ONGfIVUJ.cjs.map → installWithSpinner-X9J7yxiR.cjs.map} +1 -1
- package/dist/intro-DRl-pwVs.js +72 -0
- package/dist/intro-DRl-pwVs.js.map +1 -0
- package/dist/intro-DuyzJ3Rb.cjs +102 -0
- package/dist/intro-DuyzJ3Rb.cjs.map +1 -0
- package/dist/{intro-9PB8sE8z.js → log-B-1vLxF1.js} +2 -66
- package/dist/log-B-1vLxF1.js.map +1 -0
- package/dist/{intro-YPaf1Imr.cjs → log-wv1OxLiq.cjs} +1 -95
- package/dist/log-wv1OxLiq.cjs.map +1 -0
- package/dist/{mascot-JSA0j3Q_.cjs → mascot-CC-D4ON2.cjs} +2 -2
- package/dist/{mascot-JSA0j3Q_.cjs.map → mascot-CC-D4ON2.cjs.map} +1 -1
- package/dist/{mascot--q1xjKw1.js → mascot-CmUUHLlx.js} +2 -2
- package/dist/{mascot--q1xjKw1.js.map → mascot-CmUUHLlx.js.map} +1 -1
- package/dist/{mcp-CcseJJwh.cjs → mcp-DMCyJrkw.cjs} +2 -2
- package/dist/{mcp-CcseJJwh.cjs.map → mcp-DMCyJrkw.cjs.map} +1 -1
- package/dist/{mcp-DUTsS8tR.js → mcp-DNMDPZOo.js} +2 -2
- package/dist/{mcp-DUTsS8tR.js.map → mcp-DNMDPZOo.js.map} +1 -1
- package/dist/{package-B1hUUjio.cjs → package-Bc9heh-c.cjs} +2 -2
- package/dist/package-Bc9heh-c.cjs.map +1 -0
- package/dist/package-Bm6L1D0Q.js +5 -0
- package/dist/package-Bm6L1D0Q.js.map +1 -0
- package/dist/{registry-B3eYk4LN.js → registry-Cy48PGdh.js} +3 -2
- package/dist/registry-Cy48PGdh.js.map +1 -0
- package/dist/{registry-YE1pFWL-.cjs → registry-Q77p5TZp.cjs} +3 -2
- package/dist/registry-Q77p5TZp.cjs.map +1 -0
- package/dist/reporters-9MqdcKPp.js +1 -0
- package/dist/{reporters-BM430HdQ.js → reporters-B_USHwD6.js} +297 -33
- package/dist/reporters-B_USHwD6.js.map +1 -0
- package/dist/{reporters-2cgjvXwR.cjs → reporters-DyjE3BzZ.cjs} +318 -20
- package/dist/reporters-DyjE3BzZ.cjs.map +1 -0
- package/dist/{run-CXVhxFfC.js → run-B4pveKq5.js} +10 -10
- package/dist/{run-CXVhxFfC.js.map → run-B4pveKq5.js.map} +1 -1
- package/dist/{run-CLiHI99L.js → run-B7p16C0S.js} +4 -4
- package/dist/{run-CLiHI99L.js.map → run-B7p16C0S.js.map} +1 -1
- package/dist/{run-dMTJfs4_.cjs → run-BBzw9B1L.cjs} +4 -4
- package/dist/{run-dMTJfs4_.cjs.map → run-BBzw9B1L.cjs.map} +1 -1
- package/dist/{run-DUwX6Icx.js → run-CBB5Hlgy.js} +10 -9
- package/dist/{run-DUwX6Icx.js.map → run-CBB5Hlgy.js.map} +1 -1
- package/dist/{run-CrM4jsix.cjs → run-CfumUZCl.cjs} +7 -6
- package/dist/{run-CrM4jsix.cjs.map → run-CfumUZCl.cjs.map} +1 -1
- package/dist/{run-D-nn9-Wq.js → run-Cgy4_JPy.js} +14 -18
- package/dist/run-Cgy4_JPy.js.map +1 -0
- package/dist/{run-1H9TGT8v.js → run-Ch7Uuu-u.js} +4 -3
- package/dist/{run-1H9TGT8v.js.map → run-Ch7Uuu-u.js.map} +1 -1
- package/dist/{run-BsrNfFIl.js → run-CkNLuV4M.js} +44 -38
- package/dist/run-CkNLuV4M.js.map +1 -0
- package/dist/{run-CyzKy-0p.cjs → run-CoPzxsoM.cjs} +20 -20
- package/dist/{run-CyzKy-0p.cjs.map → run-CoPzxsoM.cjs.map} +1 -1
- package/dist/{run-DTqMrPS9.js → run-CrDbD50I.js} +2 -2
- package/dist/{run-DTqMrPS9.js.map → run-CrDbD50I.js.map} +1 -1
- package/dist/{run-LY_UAYyM.cjs → run-Cxf3s3Ap.cjs} +48 -42
- package/dist/run-Cxf3s3Ap.cjs.map +1 -0
- package/dist/{run-BYP_t9dR.cjs → run-DCggecSY.cjs} +19 -24
- package/dist/run-DCggecSY.cjs.map +1 -0
- package/dist/{run-BrM7-NSV.js → run-DHfFHNfG.js} +13 -17
- package/dist/run-DHfFHNfG.js.map +1 -0
- package/dist/{run-DBnSbwtU.cjs → run-DQdcGuXL.cjs} +47 -61
- package/dist/run-DQdcGuXL.cjs.map +1 -0
- package/dist/{run-CvFakE3B.cjs → run-DT4hTOR2.cjs} +16 -21
- package/dist/run-DT4hTOR2.cjs.map +1 -0
- package/dist/{run-FEiyv6_U.js → run-DcEE0-8W.js} +40 -53
- package/dist/run-DcEE0-8W.js.map +1 -0
- package/dist/{run-Bq6gcfkS.js → run-MGGga_wU.js} +1 -1
- package/dist/{run-CQORv7Gq.cjs → run-S6Hkmn-h.cjs} +13 -12
- package/dist/{run-CQORv7Gq.cjs.map → run-S6Hkmn-h.cjs.map} +1 -1
- package/dist/{run-uPA5s3rI.cjs → run-UXFhmzzO.cjs} +2 -2
- package/dist/{run-uPA5s3rI.cjs.map → run-UXFhmzzO.cjs.map} +1 -1
- package/dist/shared-DcDHRtZx.js +58 -0
- package/dist/shared-DcDHRtZx.js.map +1 -0
- package/dist/shared-KKRMm1xX.cjs +87 -0
- package/dist/shared-KKRMm1xX.cjs.map +1 -0
- package/dist/{snapshot-CPF9zyZj.cjs → snapshot-BHFRCLgH.cjs} +7 -7
- package/dist/{snapshot-CPF9zyZj.cjs.map → snapshot-BHFRCLgH.cjs.map} +1 -1
- package/dist/{snapshot-CiV08NJr.js → snapshot-NH1AFDwz.js} +6 -6
- package/dist/{snapshot-CiV08NJr.js.map → snapshot-NH1AFDwz.js.map} +1 -1
- package/dist/spinner-DxsAllRI.js +48 -0
- package/dist/spinner-DxsAllRI.js.map +1 -0
- package/dist/{spinner-CfB0sIPy.cjs → spinner-RfMb7fd6.cjs} +50 -21
- package/dist/spinner-RfMb7fd6.cjs.map +1 -0
- package/dist/{status-C066YA-4.cjs → status-3A7fVPqb.cjs} +3 -3
- package/dist/{status-C066YA-4.cjs.map → status-3A7fVPqb.cjs.map} +1 -1
- package/dist/{status-Dj8tivag.js → status-BeJwJ7Xa.js} +3 -3
- package/dist/{status-Dj8tivag.js.map → status-BeJwJ7Xa.js.map} +1 -1
- package/dist/{studio-B4XsXgKj.js → studio-B-1AM1My.js} +12 -12
- package/dist/{studio-B4XsXgKj.js.map → studio-B-1AM1My.js.map} +1 -1
- package/dist/{studio-D9_-mKee.cjs → studio-BUhnJl4S.cjs} +12 -12
- package/dist/{studio-D9_-mKee.cjs.map → studio-BUhnJl4S.cjs.map} +1 -1
- package/dist/studioWorker.js +2 -2
- package/dist/{summary-Clvl5Hxs.cjs → summary-B2Apv5KO.cjs} +17 -2
- package/dist/summary-B2Apv5KO.cjs.map +1 -0
- package/dist/{summary-CbmQKA8l.js → summary-BQWHL_Ca.js} +12 -3
- package/dist/summary-BQWHL_Ca.js.map +1 -0
- package/dist/{text-Ep3AulAS.cjs → text-DMiX2dcG.cjs} +10 -1
- package/dist/text-DMiX2dcG.cjs.map +1 -0
- package/dist/{text-BmiI4s6N.js → text-EoYn04SX.js} +5 -2
- package/dist/text-EoYn04SX.js.map +1 -0
- package/dist/{utils-CbJ6hS_t.js → utils-CeMUE4P0.js} +90 -70
- package/dist/utils-CeMUE4P0.js.map +1 -0
- package/dist/{utils-CO89mxRU.cjs → utils-uSJAZuvP.cjs} +101 -69
- package/dist/utils-uSJAZuvP.cjs.map +1 -0
- package/dist/{validate-C5fyNF4v.js → validate--AEg1yAB.js} +3 -3
- package/dist/{validate-C5fyNF4v.js.map → validate--AEg1yAB.js.map} +1 -1
- package/dist/{validate-B3tLWYJU.cjs → validate-BVNrsXe2.cjs} +3 -3
- package/dist/{validate-B3tLWYJU.cjs.map → validate-BVNrsXe2.cjs.map} +1 -1
- package/package.json +8 -7
- package/dist/configFile-C0DIXNMD.js.map +0 -1
- package/dist/configFile-CoEpHdXG.cjs.map +0 -1
- package/dist/intro-9PB8sE8z.js.map +0 -1
- package/dist/intro-YPaf1Imr.cjs.map +0 -1
- package/dist/package-B1hUUjio.cjs.map +0 -1
- package/dist/package-MYPMnnTX.js +0 -5
- package/dist/package-MYPMnnTX.js.map +0 -1
- package/dist/registry-B3eYk4LN.js.map +0 -1
- package/dist/registry-YE1pFWL-.cjs.map +0 -1
- package/dist/reporters-2cgjvXwR.cjs.map +0 -1
- package/dist/reporters-BM430HdQ.js.map +0 -1
- package/dist/run-BYP_t9dR.cjs.map +0 -1
- package/dist/run-BrM7-NSV.js.map +0 -1
- package/dist/run-BsrNfFIl.js.map +0 -1
- package/dist/run-CvFakE3B.cjs.map +0 -1
- package/dist/run-D-nn9-Wq.js.map +0 -1
- package/dist/run-DBnSbwtU.cjs.map +0 -1
- package/dist/run-FEiyv6_U.js.map +0 -1
- package/dist/run-LY_UAYyM.cjs.map +0 -1
- package/dist/shared-C0EtrdUm.cjs +0 -123
- package/dist/shared-C0EtrdUm.cjs.map +0 -1
- package/dist/shared-Ct9stKpp.js +0 -94
- package/dist/shared-Ct9stKpp.js.map +0 -1
- package/dist/spinner-BZaln7O8.js.map +0 -1
- package/dist/spinner-CfB0sIPy.cjs.map +0 -1
- package/dist/summary-CbmQKA8l.js.map +0 -1
- package/dist/summary-Clvl5Hxs.cjs.map +0 -1
- package/dist/text-BmiI4s6N.js.map +0 -1
- package/dist/text-Ep3AulAS.cjs.map +0 -1
- package/dist/utils-BdibacYq.js +0 -244
- package/dist/utils-BdibacYq.js.map +0 -1
- package/dist/utils-CO89mxRU.cjs.map +0 -1
- package/dist/utils-CbJ6hS_t.js.map +0 -1
- package/dist/utils-CcARPB45.cjs +0 -286
- package/dist/utils-CcARPB45.cjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-DBnSbwtU.cjs","names":["clack","editConfig","ConfigEditOperation","Diagnostics","KUBB_CONFIG_FILENAME","getConfigs","createKubb","process","createSpinner","styleText","isInteractiveRun","fetchRegistryIndex","registryUrl","incompatibility","exists","path","detectPackageManager","initPackageJson","findSpecFiles","readSpecInfo","pluralize","initDefaults","findPlugin","parsePluginsFlag","missingPluginDependencies","KUBB_PACKAGE_NAME","version","installSpec","installPackages","installWithSpinner","write","addGenerateScript","generateScript","formatMs","getElapsedMs","defineWithTypes","dryRunId"],"sources":["../../../internals/shared/src/init.ts","../src/runners/init/run.ts"],"sourcesContent":["/** The `kubb.config.ts` `kubb init` writes before `kubb add` puts each plugin in. */\nexport function generateConfigFile({ inputPath, outputPath }: { inputPath: string; outputPath: string }): string {\n return `import { defineConfig } from 'kubb/config'\n\nexport default defineConfig({\n input: '${inputPath}',\n output: {\n path: '${outputPath}',\n clean: true,\n },\n plugins: [],\n})\n`\n}\n","import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport type { DryRunExtension } from '@gunshi/plugin-dryrun'\nimport { defineWithTypes } from 'gunshi'\nimport { ConfigEditOperation, editConfig, generateConfigFile, initDefaults, KUBB_CONFIG_FILENAME, KUBB_PACKAGE_NAME } from '@internals/shared'\nimport { exists, formatMs, getElapsedMs, write } from '@internals/utils'\nimport { createKubb, Diagnostics, type RegistryEntry } from '@kubb/core'\nimport { dryRunId, type DryRunExtensions } from '../../commands/shared.ts'\nimport { getConfigs } from '../../config.ts'\nimport { pluralize } from '../../ui/text.ts'\nimport { isInteractiveRun, logIntro, logOutro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { createSpinner } from '../../ui/spinner.ts'\nimport { fetchRegistryIndex, incompatibility, installSpec, registryUrl } from '../../utils/registry.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\nimport {\n addGenerateScript,\n detectPackageManager,\n findPlugin,\n findSpecFiles,\n generateScript,\n initPackageJson,\n installPackages,\n missingPluginDependencies,\n type PackageManagerInfo,\n parsePluginsFlag,\n readSpecInfo,\n} from './utils.ts'\nimport { version } from '../../../package.json'\n\nfunction cancelAndExit(message = 'Operation canceled.'): never {\n clack.cancel(message)\n process.exit(0)\n}\n\nfunction unwrap<T>(value: T): Exclude<T, symbol> {\n if (clack.isCancel(value)) cancelAndExit()\n return value as Exclude<T, symbol>\n}\n\ntype InitOptions = {\n /**\n * When `true`, skips all interactive prompts and uses the detected or default values.\n */\n yes: boolean\n /**\n * Input path flag value from `--input`. When provided, skips the input prompt.\n */\n input?: string\n /**\n * Output directory flag value from `--output`. When provided, skips the output prompt.\n */\n output?: string\n /**\n * Comma-separated plugin list from `--plugins`, e.g. `'plugin-ts,zod'`. When provided, skips the plugin selection prompt.\n */\n plugins?: string\n /**\n * Dry-run extension from `@gunshi/plugin-dryrun`. When enabled, package installation, file\n * writes, and the first run are skipped.\n */\n dryRun: DryRunExtension\n}\n\ntype Choices = {\n inputPath: string\n outputPath: string\n plugins: Array<RegistryEntry>\n}\n\n/** The full `kubb.config.ts` for `choices`, with each plugin added the way `kubb add` adds it. */\nfunction buildConfig({ inputPath, outputPath, plugins }: Choices): string {\n const { source, outcomes } = editConfig({\n source: generateConfigFile({ inputPath, outputPath }),\n edits: plugins.map((entry) => ({ operation: ConfigEditOperation.ADD_PLUGIN, plugin: entry.artifact.package })),\n extensions: new Map(plugins.map(({ artifact, manifest }) => [artifact.package, { package: artifact.package, version: artifact.version, manifest }])),\n })\n const failed = outcomes.find((outcome) => !outcome.applied)\n if (failed && failed.edit.operation === ConfigEditOperation.ADD_PLUGIN)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `Could not add ${failed.edit.plugin} to ${KUBB_CONFIG_FILENAME}: ${failed.reason}`,\n help: `Run kubb init without that plugin, then add it with kubb add.`,\n })\n return source\n}\n\n/** Generates from the config at `configPath` without reporters, and returns how many files it wrote. */\nasync function firstRun(configPath: string): Promise<number> {\n const { configs } = await getConfigs({ configPath })\n let files = 0\n for (const config of configs) {\n const result = await createKubb(config).generate()\n if (!result.success) throw new Error(result.diagnostics.flatMap((diagnostic) => (diagnostic.severity === 'error' ? [diagnostic.message] : [])).join('\\n'))\n files += result.files.length\n }\n return files\n}\n\n/** The command that runs `kubb generate`: the `generate` script when it runs Kubb, otherwise `npx kubb generate`. */\nfunction generateCommand({ packageManager, script, watch }: { packageManager: PackageManagerInfo; script: string | undefined; watch: boolean }): string {\n if (script !== 'kubb generate') return `npx kubb generate${watch ? ' --watch' : ''}`\n const run = [packageManager.name, ...packageManager.runCommand, 'generate'].join(' ')\n if (!watch) return run\n return packageManager.name === 'npm' ? `${run} -- --watch` : `${run} --watch`\n}\n\n/**\n * Runs the Kubb setup wizard: detects the package manager and specs, asks for the spec, plugins, and\n * output folder, shows the config for review, then installs, writes `kubb.config.ts`, adds a\n * `generate` script, and runs the first generation.\n * Pass `yes: true` to skip all prompts and print one line per step.\n */\nexport async function run({ yes, input: inputFlag, output: outputFlag, plugins: pluginsFlag, dryRun }: InitOptions): Promise<void> {\n const cwd = process.cwd()\n\n /** Runs `task` behind a spinner, or prints one line when it is done in `--yes` mode. */\n async function step<T>({ start, task, done, failed }: { start: string; task: () => Promise<T>; done: (result: T) => string; failed: string }): Promise<T> {\n const spinner = createSpinner()\n if (!yes) spinner.start(start)\n try {\n const result = await task()\n if (yes) console.log(`${styleText('green', '✓')} ${done(result)}`)\n else spinner.stop(done(result))\n return result\n } catch (error) {\n if (!yes) spinner.error(failed)\n throw error\n }\n }\n\n if (!yes) logIntro({ title: isInteractiveRun({ yes, dryRun: dryRun.enabled }) ? undefined : 'Set up Kubb' })\n\n try {\n // Start the registry fetch now but await it only at the plugin step, so the first prompt never waits on the network\n const registry = fetchRegistryIndex({ registry: registryUrl() }).then((entries) =>\n entries.filter((entry) => entry.kind === 'plugin' && !incompatibility(entry.manifest)),\n )\n registry.catch(() => {})\n\n if (!(await exists(path.join(cwd, 'package.json')))) {\n if (!yes) {\n const shouldInit = unwrap(await clack.confirm({ message: 'No package.json found. Would you like to create one?', initialValue: true }))\n if (!shouldInit) cancelAndExit()\n }\n\n const packageManager = detectPackageManager(cwd)\n await step({\n start: `Initializing package.json with ${packageManager.name}`,\n task: () => initPackageJson(cwd, packageManager),\n done: () => `Created package.json with ${packageManager.name}`,\n failed: 'Could not create package.json',\n })\n }\n\n const packageManager = detectPackageManager(cwd)\n const specs = await findSpecFiles(cwd)\n\n if (!yes) {\n logStep(`Package manager ${packageManager.name}`)\n if (specs[0]) {\n const { version: specVersion, operations } = await readSpecInfo(path.join(cwd, specs[0]))\n const details = [\n specs[0].slice(2),\n specVersion ? `${specVersion.startsWith('2') ? 'Swagger' : 'OpenAPI'} ${specVersion}` : undefined,\n operations === undefined ? undefined : pluralize(operations, 'operation'),\n specs.length > 1 ? `+${specs.length - 1} more` : undefined,\n ]\n logStep(`Found ${details.filter(Boolean).join(' · ')}`)\n }\n }\n\n // `--plugins` and `--yes` need the registry before any prompt; the interactive path reads it at the plugin step\n const plugins = pluginsFlag || yes ? await registry : undefined\n const defaultPlugins = (entries: Array<RegistryEntry>) => initDefaults.plugins.flatMap((id) => findPlugin({ plugins: entries, id }) ?? [])\n\n const flagPlugins = pluginsFlag && plugins ? parsePluginsFlag({ plugins, value: pluginsFlag }) : undefined\n\n let choices: Choices = {\n inputPath: inputFlag ?? specs[0] ?? initDefaults.inputPath,\n outputPath: outputFlag ?? initDefaults.outputPath,\n plugins: flagPlugins ?? (plugins ? defaultPlugins(plugins) : []),\n }\n if (yes && !choices.plugins.length) {\n throw new Error('The registry has no default plugin. Pass --plugins to choose one.')\n }\n\n async function askInput(current: string): Promise<string> {\n const choice = specs.length\n ? unwrap(\n await clack.select({\n message: 'Which spec should Kubb read?',\n options: [\n ...specs.map((spec) => ({ value: spec, label: spec, hint: 'found in this repo' })),\n { value: 'url', label: 'A URL' },\n { value: 'file', label: 'Another file' },\n ],\n initialValue: specs.includes(current) ? current : /^https?:\\/\\//.test(current) ? 'url' : 'file',\n }),\n )\n : /^https?:\\/\\//.test(current)\n ? 'url'\n : 'file'\n if (specs.includes(choice)) return choice\n const isUrl = choice === 'url'\n const initial = isUrl === /^https?:\\/\\//.test(current) && !specs.includes(current) ? current : undefined\n return unwrap(\n await clack.text({\n message: isUrl ? 'Spec URL' : 'Spec path',\n placeholder: isUrl ? 'https://example.com/openapi.yaml' : initDefaults.inputPath,\n initialValue: initial,\n defaultValue: isUrl ? undefined : initDefaults.inputPath,\n validate: (value) => {\n if (isUrl && !/^https?:\\/\\//.test(value ?? '')) return 'Enter an http(s) URL'\n },\n }),\n )\n }\n\n async function askPlugins(previous: Array<RegistryEntry>): Promise<Array<RegistryEntry>> {\n const plugins = await registry\n const current = previous.length ? previous : defaultPlugins(plugins)\n const width = Math.max(...plugins.map((entry) => entry.manifest.displayName.length))\n const nameWidth = Math.max(...plugins.map((entry) => entry.manifest.name.length))\n const values = unwrap(\n await clack.multiselect({\n message: 'What should Kubb generate?',\n options: plugins.map(({ id, manifest }) => ({\n value: id,\n label: `${manifest.displayName.padEnd(width)} ${styleText('dim', manifest.name.padEnd(nameWidth))}`.trimEnd(),\n })),\n initialValues: current.map((entry) => entry.id),\n required: true,\n }),\n )\n return plugins.filter((entry) => values.includes(entry.id))\n }\n\n // Flags for all three choices leave nothing to ask or review, as before the review step existed\n const answered = yes || Boolean(inputFlag && outputFlag && pluginsFlag)\n if (!answered) {\n let firstPass = true\n while (true) {\n // The first pass skips the questions a flag answered; \"Change a choice\" asks them all again.\n choices = {\n inputPath: firstPass && inputFlag ? inputFlag : await askInput(choices.inputPath),\n plugins: firstPass && flagPlugins ? flagPlugins : await askPlugins(choices.plugins),\n outputPath:\n firstPass && outputFlag\n ? outputFlag\n : unwrap(await clack.text({ message: 'Output folder', placeholder: choices.outputPath, defaultValue: choices.outputPath })),\n }\n firstPass = false\n const missing = missingPluginDependencies(choices.plugins.map((entry) => entry.manifest))\n if (missing.length) {\n logWarn(`${missing.join('\\n')}\\nAdd the missing plugins.`)\n continue\n }\n const config = buildConfig(choices)\n const packages = [KUBB_PACKAGE_NAME, ...choices.plugins.map((entry) => entry.artifact.package)]\n logStep(`Review ${KUBB_CONFIG_FILENAME}`)\n logBlock([...config.trimEnd().split('\\n'), '', `${styleText('dim', 'Installs')} ${packages.join(' ')} with ${packageManager.name}`])\n const configExists = await exists(path.join(cwd, KUBB_CONFIG_FILENAME))\n const confirmed = unwrap(\n await clack.select({\n message: configExists ? `${KUBB_CONFIG_FILENAME} exists. Overwrite it?` : 'Create it?',\n options: [\n { value: true, label: 'Yes' },\n { value: false, label: 'Change a choice' },\n ],\n }),\n )\n if (confirmed) break\n }\n }\n\n // Check the selection against the plugins' manifests before installing anything\n const missing = missingPluginDependencies(choices.plugins.map((entry) => entry.manifest))\n if (missing.length) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.missingDependency,\n severity: 'error',\n message: `${missing.join('\\n')}\\nAdd the missing plugins and run kubb init again.`,\n })\n }\n\n const configPath = path.join(cwd, KUBB_CONFIG_FILENAME)\n if (answered && !yes && (await exists(configPath))) {\n const overwrite = unwrap(await clack.confirm({ message: `${KUBB_CONFIG_FILENAME} exists. Overwrite it?`, initialValue: false }))\n if (!overwrite) cancelAndExit('Keeping existing configuration.')\n }\n\n // Install `kubb` at the running CLI's version and each plugin at the version the registry pins\n const packagesToInstall = [`${KUBB_PACKAGE_NAME}@${version}`, ...choices.plugins.map((entry) => installSpec(entry.artifact))]\n const packageNames = [KUBB_PACKAGE_NAME, ...choices.plugins.map((entry) => entry.artifact.package)]\n const dry = { message: `install ${packagesToInstall.length} packages with ${packageManager.name}` }\n if (yes) {\n await step({\n start: '',\n task: async () => void (await dryRun.run(() => installPackages(packagesToInstall, packageManager, cwd), dry)),\n done: () => `Installed ${packageNames.join(' ')} with ${packageManager.name}`,\n failed: 'Installation failed',\n })\n } else {\n await installWithSpinner({\n packages: packagesToInstall,\n names: `${packagesToInstall.length} packages`,\n packageManager,\n cwd,\n install: async (packages, packageManager, cwd, onLine) => void (await dryRun.run(() => installPackages(packages, packageManager, cwd, onLine), dry)),\n })\n }\n\n await step({\n start: `Writing ${KUBB_CONFIG_FILENAME}`,\n task: async () => dryRun.run(async () => void (await write(configPath, buildConfig(choices))), { message: `write ${KUBB_CONFIG_FILENAME}` }),\n done: () => `Wrote ${KUBB_CONFIG_FILENAME}`,\n failed: `Could not write ${KUBB_CONFIG_FILENAME}`,\n })\n\n const scriptAdded = await dryRun.run(() => addGenerateScript(cwd), {\n message: 'add a generate script to package.json',\n resolve: async () => (await generateScript(cwd)) === undefined,\n })\n if (scriptAdded && !yes) logStep('Added \"generate\": \"kubb generate\" to package.json')\n\n const script = scriptAdded ? 'kubb generate' : await generateScript(cwd)\n const runStart = process.hrtime()\n try {\n await dryRun.run(\n () =>\n step({\n start: 'Running the first generation',\n task: () => firstRun(configPath),\n done: (files) =>\n yes\n ? `Generated ${pluralize(files, 'file')} in ${choices.outputPath}`\n : `First run ${pluralize(files, 'file')} in ${choices.outputPath} · ${formatMs(getElapsedMs(runStart))}`,\n failed: 'First run failed',\n }),\n { message: 'run the first generation', resolve: () => 0 },\n )\n } catch (error) {\n logError(error instanceof Error ? error.message : String(error))\n const message = `Kubb is set up, but the first run failed. Fix the error, then run ${generateCommand({ packageManager, script, watch: false })}.`\n if (yes) console.log(message)\n else logOutro(styleText('yellow', message))\n process.exitCode = 1\n return\n }\n\n if (yes) {\n console.log(`Kubb is set up. Run ${generateCommand({ packageManager, script, watch: false })} after changing the spec.`)\n return\n }\n logOutro(`${styleText('green', '✓ Kubb is set up')}\\n ${styleText('dim', 'Next')} ${generateCommand({ packageManager, script, watch: true })}`)\n } catch (error) {\n logError(styleText('red', 'An error occurred during initialization'))\n if (error instanceof Error) {\n logError(error.message)\n }\n process.exit(1)\n }\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'init',\n description: 'Set up a config, install plugins, and run the first generation.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --yes --input ./openapi.yaml --plugins ts,zod --output src/api',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n 'kubb init --yes --dry-run',\n ].join('\\n'),\n toKebab: true,\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use the detected spec, the default plugin, and the default output folder',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated Kubb registry ids of the plugins to add, the same ids `kubb add` takes (plugin-ts, plugin-zod, acme/plugin-x), or short names (ts, zod)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n run: ({ values, extensions }) => run({ yes: values.yes, input: values.input, output: values.output, plugins: values.plugins, dryRun: extensions[dryRunId] }),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAgB,mBAAmB,EAAE,WAAW,cAAiE;CAC/G,OAAO;;;YAGG,UAAU;;aAET,WAAW;;;;;;AAMxB;;ACmBA,SAAS,cAAc,UAAU,uBAA8B;CAC7D,eAAM,OAAO,OAAO;CACpB,aAAA,QAAQ,KAAK,CAAC;AAChB;AAEA,SAAS,OAAU,OAA8B;CAC/C,IAAIA,eAAM,SAAS,KAAK,GAAG,cAAc;CACzC,OAAO;AACT;;AAiCA,SAAS,YAAY,EAAE,WAAW,YAAY,WAA4B;CACxE,MAAM,EAAE,QAAQ,aAAaC,mBAAAA,WAAW;EACtC,QAAQ,mBAAmB;GAAE;GAAW;EAAW,CAAC;EACpD,OAAO,QAAQ,KAAK,WAAW;GAAE,WAAWC,mBAAAA,oBAAoB;GAAY,QAAQ,MAAM,SAAS;EAAQ,EAAE;EAC7G,YAAY,IAAI,IAAI,QAAQ,KAAK,EAAE,UAAU,eAAe,CAAC,SAAS,SAAS;GAAE,SAAS,SAAS;GAAS,SAAS,SAAS;GAAS;EAAS,CAAC,CAAC,CAAC;CACrJ,CAAC;CACD,MAAM,SAAS,SAAS,MAAM,YAAY,CAAC,QAAQ,OAAO;CAC1D,IAAI,UAAU,OAAO,KAAK,cAAcA,mBAAAA,oBAAoB,YAC1D,MAAM,IAAIC,WAAAA,YAAY,MAAM;EAC1B,MAAMA,WAAAA,YAAY,KAAK;EACvB,UAAU;EACV,SAAS,iBAAiB,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,OAAO,yCAAyC,CAAC;EACpE,IAAI,iBAAiB,OACnB,cAAA,SAAS,MAAM,OAAO;EAExB,aAAA,QAAQ,KAAK,CAAC;CAChB;AACF;AAEA,MAAa,WAAA,GAAU0B,OAAAA,gBAAAA,CAAkD,CAAC,CAAC;CACzE,MAAM;CACN,aAAa;CACb,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,SAAS;CACT,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS;EACX;CACF;CACA,MAAM,EAAE,QAAQ,iBAAiB,IAAI;EAAE,KAAK,OAAO;EAAK,OAAO,OAAO;EAAO,QAAQ,OAAO;EAAQ,SAAS,OAAO;EAAS,QAAQ,WAAWC,sBAAAA;CAAU,CAAC;AAC7J,CAAC"}
|
package/dist/run-FEiyv6_U.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-FEiyv6_U.js","names":[],"sources":["../../../internals/shared/src/init.ts","../src/runners/init/run.ts"],"sourcesContent":["/** The `kubb.config.ts` `kubb init` writes before `kubb add` puts each plugin in. */\nexport function generateConfigFile({ inputPath, outputPath }: { inputPath: string; outputPath: string }): string {\n return `import { defineConfig } from 'kubb/config'\n\nexport default defineConfig({\n input: '${inputPath}',\n output: {\n path: '${outputPath}',\n clean: true,\n },\n plugins: [],\n})\n`\n}\n","import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport type { DryRunExtension } from '@gunshi/plugin-dryrun'\nimport { defineWithTypes } from 'gunshi'\nimport { ConfigEditOperation, editConfig, generateConfigFile, initDefaults, KUBB_CONFIG_FILENAME, KUBB_PACKAGE_NAME } from '@internals/shared'\nimport { exists, formatMs, getElapsedMs, write } from '@internals/utils'\nimport { createKubb, Diagnostics, type RegistryEntry } from '@kubb/core'\nimport { dryRunId, type DryRunExtensions } from '../../commands/shared.ts'\nimport { getConfigs } from '../../config.ts'\nimport { pluralize } from '../../ui/text.ts'\nimport { isInteractiveRun, logIntro, logOutro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { createSpinner } from '../../ui/spinner.ts'\nimport { fetchRegistryIndex, incompatibility, installSpec, registryUrl } from '../../utils/registry.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\nimport {\n addGenerateScript,\n detectPackageManager,\n findPlugin,\n findSpecFiles,\n generateScript,\n initPackageJson,\n installPackages,\n missingPluginDependencies,\n type PackageManagerInfo,\n parsePluginsFlag,\n readSpecInfo,\n} from './utils.ts'\nimport { version } from '../../../package.json'\n\nfunction cancelAndExit(message = 'Operation canceled.'): never {\n clack.cancel(message)\n process.exit(0)\n}\n\nfunction unwrap<T>(value: T): Exclude<T, symbol> {\n if (clack.isCancel(value)) cancelAndExit()\n return value as Exclude<T, symbol>\n}\n\ntype InitOptions = {\n /**\n * When `true`, skips all interactive prompts and uses the detected or default values.\n */\n yes: boolean\n /**\n * Input path flag value from `--input`. When provided, skips the input prompt.\n */\n input?: string\n /**\n * Output directory flag value from `--output`. When provided, skips the output prompt.\n */\n output?: string\n /**\n * Comma-separated plugin list from `--plugins`, e.g. `'plugin-ts,zod'`. When provided, skips the plugin selection prompt.\n */\n plugins?: string\n /**\n * Dry-run extension from `@gunshi/plugin-dryrun`. When enabled, package installation, file\n * writes, and the first run are skipped.\n */\n dryRun: DryRunExtension\n}\n\ntype Choices = {\n inputPath: string\n outputPath: string\n plugins: Array<RegistryEntry>\n}\n\n/** The full `kubb.config.ts` for `choices`, with each plugin added the way `kubb add` adds it. */\nfunction buildConfig({ inputPath, outputPath, plugins }: Choices): string {\n const { source, outcomes } = editConfig({\n source: generateConfigFile({ inputPath, outputPath }),\n edits: plugins.map((entry) => ({ operation: ConfigEditOperation.ADD_PLUGIN, plugin: entry.artifact.package })),\n extensions: new Map(plugins.map(({ artifact, manifest }) => [artifact.package, { package: artifact.package, version: artifact.version, manifest }])),\n })\n const failed = outcomes.find((outcome) => !outcome.applied)\n if (failed && failed.edit.operation === ConfigEditOperation.ADD_PLUGIN)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `Could not add ${failed.edit.plugin} to ${KUBB_CONFIG_FILENAME}: ${failed.reason}`,\n help: `Run kubb init without that plugin, then add it with kubb add.`,\n })\n return source\n}\n\n/** Generates from the config at `configPath` without reporters, and returns how many files it wrote. */\nasync function firstRun(configPath: string): Promise<number> {\n const { configs } = await getConfigs({ configPath })\n let files = 0\n for (const config of configs) {\n const result = await createKubb(config).generate()\n if (!result.success) throw new Error(result.diagnostics.flatMap((diagnostic) => (diagnostic.severity === 'error' ? [diagnostic.message] : [])).join('\\n'))\n files += result.files.length\n }\n return files\n}\n\n/** The command that runs `kubb generate`: the `generate` script when it runs Kubb, otherwise `npx kubb generate`. */\nfunction generateCommand({ packageManager, script, watch }: { packageManager: PackageManagerInfo; script: string | undefined; watch: boolean }): string {\n if (script !== 'kubb generate') return `npx kubb generate${watch ? ' --watch' : ''}`\n const run = [packageManager.name, ...packageManager.runCommand, 'generate'].join(' ')\n if (!watch) return run\n return packageManager.name === 'npm' ? `${run} -- --watch` : `${run} --watch`\n}\n\n/**\n * Runs the Kubb setup wizard: detects the package manager and specs, asks for the spec, plugins, and\n * output folder, shows the config for review, then installs, writes `kubb.config.ts`, adds a\n * `generate` script, and runs the first generation.\n * Pass `yes: true` to skip all prompts and print one line per step.\n */\nexport async function run({ yes, input: inputFlag, output: outputFlag, plugins: pluginsFlag, dryRun }: InitOptions): Promise<void> {\n const cwd = process.cwd()\n\n /** Runs `task` behind a spinner, or prints one line when it is done in `--yes` mode. */\n async function step<T>({ start, task, done, failed }: { start: string; task: () => Promise<T>; done: (result: T) => string; failed: string }): Promise<T> {\n const spinner = createSpinner()\n if (!yes) spinner.start(start)\n try {\n const result = await task()\n if (yes) console.log(`${styleText('green', '✓')} ${done(result)}`)\n else spinner.stop(done(result))\n return result\n } catch (error) {\n if (!yes) spinner.error(failed)\n throw error\n }\n }\n\n if (!yes) logIntro({ title: isInteractiveRun({ yes, dryRun: dryRun.enabled }) ? undefined : 'Set up Kubb' })\n\n try {\n // Start the registry fetch now but await it only at the plugin step, so the first prompt never waits on the network\n const registry = fetchRegistryIndex({ registry: registryUrl() }).then((entries) =>\n entries.filter((entry) => entry.kind === 'plugin' && !incompatibility(entry.manifest)),\n )\n registry.catch(() => {})\n\n if (!(await exists(path.join(cwd, 'package.json')))) {\n if (!yes) {\n const shouldInit = unwrap(await clack.confirm({ message: 'No package.json found. Would you like to create one?', initialValue: true }))\n if (!shouldInit) cancelAndExit()\n }\n\n const packageManager = detectPackageManager(cwd)\n await step({\n start: `Initializing package.json with ${packageManager.name}`,\n task: () => initPackageJson(cwd, packageManager),\n done: () => `Created package.json with ${packageManager.name}`,\n failed: 'Could not create package.json',\n })\n }\n\n const packageManager = detectPackageManager(cwd)\n const specs = await findSpecFiles(cwd)\n\n if (!yes) {\n logStep(`Package manager ${packageManager.name}`)\n if (specs[0]) {\n const { version: specVersion, operations } = await readSpecInfo(path.join(cwd, specs[0]))\n const details = [\n specs[0].slice(2),\n specVersion ? `${specVersion.startsWith('2') ? 'Swagger' : 'OpenAPI'} ${specVersion}` : undefined,\n operations === undefined ? undefined : pluralize(operations, 'operation'),\n specs.length > 1 ? `+${specs.length - 1} more` : undefined,\n ]\n logStep(`Found ${details.filter(Boolean).join(' · ')}`)\n }\n }\n\n // `--plugins` and `--yes` need the registry before any prompt; the interactive path reads it at the plugin step\n const plugins = pluginsFlag || yes ? await registry : undefined\n const defaultPlugins = (entries: Array<RegistryEntry>) => initDefaults.plugins.flatMap((id) => findPlugin({ plugins: entries, id }) ?? [])\n\n const flagPlugins = pluginsFlag && plugins ? parsePluginsFlag({ plugins, value: pluginsFlag }) : undefined\n\n let choices: Choices = {\n inputPath: inputFlag ?? specs[0] ?? initDefaults.inputPath,\n outputPath: outputFlag ?? initDefaults.outputPath,\n plugins: flagPlugins ?? (plugins ? defaultPlugins(plugins) : []),\n }\n if (yes && !choices.plugins.length) {\n throw new Error('The registry has no default plugin. Pass --plugins to choose one.')\n }\n\n async function askInput(current: string): Promise<string> {\n const choice = specs.length\n ? unwrap(\n await clack.select({\n message: 'Which spec should Kubb read?',\n options: [\n ...specs.map((spec) => ({ value: spec, label: spec, hint: 'found in this repo' })),\n { value: 'url', label: 'A URL' },\n { value: 'file', label: 'Another file' },\n ],\n initialValue: specs.includes(current) ? current : /^https?:\\/\\//.test(current) ? 'url' : 'file',\n }),\n )\n : /^https?:\\/\\//.test(current)\n ? 'url'\n : 'file'\n if (specs.includes(choice)) return choice\n const isUrl = choice === 'url'\n const initial = isUrl === /^https?:\\/\\//.test(current) && !specs.includes(current) ? current : undefined\n return unwrap(\n await clack.text({\n message: isUrl ? 'Spec URL' : 'Spec path',\n placeholder: isUrl ? 'https://example.com/openapi.yaml' : initDefaults.inputPath,\n initialValue: initial,\n defaultValue: isUrl ? undefined : initDefaults.inputPath,\n validate: (value) => {\n if (isUrl && !/^https?:\\/\\//.test(value ?? '')) return 'Enter an http(s) URL'\n },\n }),\n )\n }\n\n async function askPlugins(previous: Array<RegistryEntry>): Promise<Array<RegistryEntry>> {\n const plugins = await registry\n const current = previous.length ? previous : defaultPlugins(plugins)\n const width = Math.max(...plugins.map((entry) => entry.manifest.displayName.length))\n const nameWidth = Math.max(...plugins.map((entry) => entry.manifest.name.length))\n const values = unwrap(\n await clack.multiselect({\n message: 'What should Kubb generate?',\n options: plugins.map(({ id, manifest }) => ({\n value: id,\n label: `${manifest.displayName.padEnd(width)} ${styleText('dim', manifest.name.padEnd(nameWidth))}`.trimEnd(),\n })),\n initialValues: current.map((entry) => entry.id),\n required: true,\n }),\n )\n return plugins.filter((entry) => values.includes(entry.id))\n }\n\n // Flags for all three choices leave nothing to ask or review, as before the review step existed\n const answered = yes || Boolean(inputFlag && outputFlag && pluginsFlag)\n if (!answered) {\n let firstPass = true\n while (true) {\n // The first pass skips the questions a flag answered; \"Change a choice\" asks them all again.\n choices = {\n inputPath: firstPass && inputFlag ? inputFlag : await askInput(choices.inputPath),\n plugins: firstPass && flagPlugins ? flagPlugins : await askPlugins(choices.plugins),\n outputPath:\n firstPass && outputFlag\n ? outputFlag\n : unwrap(await clack.text({ message: 'Output folder', placeholder: choices.outputPath, defaultValue: choices.outputPath })),\n }\n firstPass = false\n const missing = missingPluginDependencies(choices.plugins.map((entry) => entry.manifest))\n if (missing.length) {\n logWarn(`${missing.join('\\n')}\\nAdd the missing plugins.`)\n continue\n }\n const config = buildConfig(choices)\n const packages = [KUBB_PACKAGE_NAME, ...choices.plugins.map((entry) => entry.artifact.package)]\n logStep(`Review ${KUBB_CONFIG_FILENAME}`)\n logBlock([...config.trimEnd().split('\\n'), '', `${styleText('dim', 'Installs')} ${packages.join(' ')} with ${packageManager.name}`])\n const configExists = await exists(path.join(cwd, KUBB_CONFIG_FILENAME))\n const confirmed = unwrap(\n await clack.select({\n message: configExists ? `${KUBB_CONFIG_FILENAME} exists. Overwrite it?` : 'Create it?',\n options: [\n { value: true, label: 'Yes' },\n { value: false, label: 'Change a choice' },\n ],\n }),\n )\n if (confirmed) break\n }\n }\n\n // Check the selection against the plugins' manifests before installing anything\n const missing = missingPluginDependencies(choices.plugins.map((entry) => entry.manifest))\n if (missing.length) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.missingDependency,\n severity: 'error',\n message: `${missing.join('\\n')}\\nAdd the missing plugins and run kubb init again.`,\n })\n }\n\n const configPath = path.join(cwd, KUBB_CONFIG_FILENAME)\n if (answered && !yes && (await exists(configPath))) {\n const overwrite = unwrap(await clack.confirm({ message: `${KUBB_CONFIG_FILENAME} exists. Overwrite it?`, initialValue: false }))\n if (!overwrite) cancelAndExit('Keeping existing configuration.')\n }\n\n // Install `kubb` at the running CLI's version and each plugin at the version the registry pins\n const packagesToInstall = [`${KUBB_PACKAGE_NAME}@${version}`, ...choices.plugins.map((entry) => installSpec(entry.artifact))]\n const packageNames = [KUBB_PACKAGE_NAME, ...choices.plugins.map((entry) => entry.artifact.package)]\n const dry = { message: `install ${packagesToInstall.length} packages with ${packageManager.name}` }\n if (yes) {\n await step({\n start: '',\n task: async () => void (await dryRun.run(() => installPackages(packagesToInstall, packageManager, cwd), dry)),\n done: () => `Installed ${packageNames.join(' ')} with ${packageManager.name}`,\n failed: 'Installation failed',\n })\n } else {\n await installWithSpinner({\n packages: packagesToInstall,\n names: `${packagesToInstall.length} packages`,\n packageManager,\n cwd,\n install: async (packages, packageManager, cwd, onLine) => void (await dryRun.run(() => installPackages(packages, packageManager, cwd, onLine), dry)),\n })\n }\n\n await step({\n start: `Writing ${KUBB_CONFIG_FILENAME}`,\n task: async () => dryRun.run(async () => void (await write(configPath, buildConfig(choices))), { message: `write ${KUBB_CONFIG_FILENAME}` }),\n done: () => `Wrote ${KUBB_CONFIG_FILENAME}`,\n failed: `Could not write ${KUBB_CONFIG_FILENAME}`,\n })\n\n const scriptAdded = await dryRun.run(() => addGenerateScript(cwd), {\n message: 'add a generate script to package.json',\n resolve: async () => (await generateScript(cwd)) === undefined,\n })\n if (scriptAdded && !yes) logStep('Added \"generate\": \"kubb generate\" to package.json')\n\n const script = scriptAdded ? 'kubb generate' : await generateScript(cwd)\n const runStart = process.hrtime()\n try {\n await dryRun.run(\n () =>\n step({\n start: 'Running the first generation',\n task: () => firstRun(configPath),\n done: (files) =>\n yes\n ? `Generated ${pluralize(files, 'file')} in ${choices.outputPath}`\n : `First run ${pluralize(files, 'file')} in ${choices.outputPath} · ${formatMs(getElapsedMs(runStart))}`,\n failed: 'First run failed',\n }),\n { message: 'run the first generation', resolve: () => 0 },\n )\n } catch (error) {\n logError(error instanceof Error ? error.message : String(error))\n const message = `Kubb is set up, but the first run failed. Fix the error, then run ${generateCommand({ packageManager, script, watch: false })}.`\n if (yes) console.log(message)\n else logOutro(styleText('yellow', message))\n process.exitCode = 1\n return\n }\n\n if (yes) {\n console.log(`Kubb is set up. Run ${generateCommand({ packageManager, script, watch: false })} after changing the spec.`)\n return\n }\n logOutro(`${styleText('green', '✓ Kubb is set up')}\\n ${styleText('dim', 'Next')} ${generateCommand({ packageManager, script, watch: true })}`)\n } catch (error) {\n logError(styleText('red', 'An error occurred during initialization'))\n if (error instanceof Error) {\n logError(error.message)\n }\n process.exit(1)\n }\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'init',\n description: 'Set up a config, install plugins, and run the first generation.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --yes --input ./openapi.yaml --plugins ts,zod --output src/api',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n 'kubb init --yes --dry-run',\n ].join('\\n'),\n toKebab: true,\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use the detected spec, the default plugin, and the default output folder',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated Kubb registry ids of the plugins to add, the same ids `kubb add` takes (plugin-ts, plugin-zod, acme/plugin-x), or short names (ts, zod)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n run: ({ values, extensions }) => run({ yes: values.yes, input: values.input, output: values.output, plugins: values.plugins, dryRun: extensions[dryRunId] }),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,SAAgB,mBAAmB,EAAE,WAAW,cAAiE;CAC/G,OAAO;;;YAGG,UAAU;;aAET,WAAW;;;;;;AAMxB;;AC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AAC;EACpE,IAAI,iBAAiB,OACnB,SAAS,MAAM,OAAO;EAExB,QAAQ,KAAK,CAAC;CAChB;AACF;AAEA,MAAa,UAAU,gBAAkD,CAAC,CAAC;CACzE,MAAM;CACN,aAAa;CACb,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,SAAS;CACT,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS;EACX;CACF;CACA,MAAM,EAAE,QAAQ,iBAAiB,IAAI;EAAE,KAAK,OAAO;EAAK,OAAO,OAAO;EAAO,QAAQ,OAAO;EAAQ,SAAS,OAAO;EAAS,QAAQ,WAAW;CAAU,CAAC;AAC7J,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-LY_UAYyM.cjs","names":["createSpinner","path","readOutputFiles","Hookable","diffFiles","pluralize","getErrorMessage","process","logCommandSummary","isInteractiveRun","styleText","toRegistryId","withSpinner","fetchRegistryIndex","registryUrl","readInstalledPackages","bumpOf","isOutdated","incompatibility","formatTable","clack","toShortId","detectPackageManager","installWithSpinner","installSpec","findConfigFile","defineWithTypes","yesArg","dryRunId"],"sources":["../src/runners/update/run.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { defineWithTypes } from 'gunshi'\nimport { findConfigFile } from '@internals/shared'\nimport { getErrorMessage } from '@internals/utils'\nimport { Hookable, type KubbHooks, readInstalledPackages, type RegistryEntry } from '@kubb/core'\nimport { pluralize } from '../../ui/text.ts'\nimport { dryRunId, type DryRunExtensions, yesArg } from '../../commands/shared.ts'\nimport { isInteractiveRun, logIntro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { createSpinner, withSpinner } from '../../ui/spinner.ts'\nimport { logCommandSummary } from '../../ui/summary.ts'\nimport { formatTable } from '../../ui/table.ts'\nimport { bumpOf, fetchRegistryIndex, incompatibility, installSpec, isOutdated, registryUrl, toRegistryId, toShortId } from '../../utils/registry.ts'\nimport { detectPackageManager } from '../init/utils.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\nimport { diffFiles, type FileChange, readOutputFiles } from '../generate/utils.ts'\n\nexport type UpdateOptions = {\n /**\n * Registry ids to update. Empty updates every installed extension the registry lists.\n */\n ids: Array<string>\n /**\n * List the updates without installing anything.\n */\n dryRun: boolean\n yes: boolean\n}\n\n/**\n * Generates every config in this process, the way `kubb generate` does, and returns the output files\n * it changed. Runs after the install, so the config loads the new versions. `undefined` when the\n * config fails to load or a build fails.\n */\nasync function regenerate({\n cwd,\n configPath,\n}: {\n cwd: string\n configPath: string\n}): Promise<{ files: Array<FileChange>; unchanged: number; output: string } | undefined> {\n const spinner = createSpinner()\n spinner.start('Generating with the new versions')\n try {\n // Imported here, so the config loader and the generate path never slow down `kubb --help`.\n const [{ getConfigs }, { generate }] = await Promise.all([import('../../config.ts'), import('../generate/run.ts')])\n const { configs } = await getConfigs({ configPath })\n const dirs = configs.map((config) => path.resolve(config.root ?? cwd, config.output.path))\n const before = new Map((await Promise.all(dirs.map(readOutputFiles))).flatMap((files) => [...files]))\n const hooks = new Hookable<KubbHooks>()\n for (const config of configs) {\n if (!(await generate({ config, hooks }))) throw new Error('Generation failed')\n }\n const after = new Map((await Promise.all(dirs.map(readOutputFiles))).flatMap((files) => [...files]))\n const diff = diffFiles(before, after)\n spinner.stop(diff.files.length ? `Generated: ${pluralize(diff.files.length, 'file')} changed` : 'Generated: no files changed')\n return { ...diff, output: dirs.map((dir) => path.relative(cwd, dir) || '.').join(', ') }\n } catch (error) {\n spinner.error(`Generation failed: ${getErrorMessage(error)}`)\n return undefined\n }\n}\n\n/**\n * Moves installed extensions to the version the registry pins. Shows each version change with its\n * bump, asks which to install with majors left out, installs them, and regenerates to show which\n * files changed. With `dryRun`, only lists the updates and installs nothing.\n */\nexport async function run({ ids, dryRun, yes }: UpdateOptions): Promise<void> {\n const cwd = process.cwd()\n const hrStart = process.hrtime()\n const installedPackages: Array<string> = []\n const summary = (title: string, status: Parameters<typeof logCommandSummary>[0]['status'], lines: ReadonlyArray<string>) =>\n logCommandSummary({ title, status, hrStart, block: true, lines })\n logIntro({ title: isInteractiveRun({ yes, dryRun }) ? undefined : styleText('bgCyan', styleText('black', ' Kubb Update ')) })\n\n try {\n const wanted = new Set(ids.map(toRegistryId))\n const [entries, installed] = await withSpinner({\n message: 'Checking the registry',\n promise: Promise.all([fetchRegistryIndex({ registry: registryUrl() }), readInstalledPackages({ root: cwd })]),\n })\n const versions = new Map(installed.map((item) => [item.package, item.version]))\n\n const tracked = entries.filter((entry) => versions.has(entry.artifact.package) && (!wanted.size || wanted.has(entry.id)))\n for (const id of wanted) {\n if (tracked.some((entry) => entry.id === id)) continue\n logWarn(`${id} is not installed, or not in the registry.`)\n // A caller that named it, such as Studio, must not read the run as a successful update.\n process.exitCode = 1\n }\n\n const current = ({ artifact }: RegistryEntry) => versions.get(artifact.package)\n const isMajor = (entry: RegistryEntry) => bumpOf({ installed: current(entry), latest: entry.artifact.version }) === 'major'\n const outdated = tracked.filter((entry) => isOutdated({ installed: current(entry), latest: entry.artifact.version }))\n const proposals = outdated.filter((entry) => {\n const problem = incompatibility(entry.manifest)\n if (problem) {\n logWarn(`Skipped ${entry.id}: ${problem}`)\n // Same as a missing id: Studio would report an update that installed nothing.\n if (wanted.has(entry.id)) process.exitCode = 1\n }\n return !problem\n })\n\n if (!proposals.length) {\n const title = outdated.length ? 'No compatible updates available' : 'Already up to date'\n summary(tracked.length ? title : 'No installed extensions to update', outdated.length ? 'warning' : 'success', [\n ` ${tracked.length - outdated.length} of ${tracked.length} up to date`,\n ...(ids.length ? ['', `No updates for ${ids.join(', ')}.`] : []),\n ])\n return\n }\n\n if (tracked.length) {\n const header = ['Extension', 'Current', 'Latest', '']\n const rows = tracked.map((entry) => {\n if (!outdated.includes(entry)) return [entry.artifact.package, current(entry) ?? '-', 'up to date', '']\n const bump = bumpOf({ installed: current(entry), latest: entry.artifact.version }) ?? ''\n return [entry.artifact.package, current(entry) ?? 'not installed', entry.artifact.version, bump === 'major' ? 'major · breaking' : bump]\n })\n const lines = formatTable([header, ...rows])\n logStep(`Checked ${pluralize(tracked.length, 'extension')} against the registry`)\n logBlock([\n styleText('dim', lines[0]!),\n ...lines.slice(1).map((line, index) => {\n if (!outdated.includes(tracked[index]!)) return styleText('dim', line)\n return line.endsWith('major · breaking') ? styleText('yellow', line) : line\n }),\n ])\n }\n\n if (dryRun) {\n summary('Updates available', 'planned', [`Dry run: nothing was installed. Run kubb update to install ${proposals.length === 1 ? 'it' : 'them'}.`])\n return\n }\n\n // A major can break the generated code, so it is only picked for you when you named it.\n const defaults = proposals.filter((entry) => wanted.has(entry.id) || !isMajor(entry))\n const chosen = yes\n ? defaults.map((entry) => entry.id)\n : await clack.multiselect({\n message: 'Select the updates to install',\n options: proposals.map((entry) => ({\n value: entry.id,\n label: entry.artifact.package,\n hint: `${current(entry) ?? 'not installed'} → ${entry.artifact.version}`,\n })),\n initialValues: defaults.map((entry) => entry.id),\n required: false,\n })\n if (clack.isCancel(chosen)) {\n summary('Update canceled', 'canceled', [' No changes made'])\n return\n }\n const selected = proposals.filter((entry) => chosen.includes(entry.id))\n\n const skipped = proposals\n .filter((entry) => !selected.includes(entry))\n .map((entry) => {\n const kind = entry.manifest.kind.charAt(0).toUpperCase() + entry.manifest.kind.slice(1)\n return ` ${styleText('dim', 'Skipped')} ${kind} ${entry.artifact.package} ${entry.artifact.version} ${styleText('dim', `run kubb update ${toShortId(entry.id)} later`)}`\n })\n if (!selected.length) {\n summary('No updates installed', 'canceled', [' No updates selected.', ...skipped])\n return\n }\n\n const packageManager = detectPackageManager(cwd)\n const names = selected.map(({ artifact }) => artifact.package).join(', ')\n await installWithSpinner({\n packages: selected.map(({ artifact }) => installSpec(artifact)),\n names,\n packageManager,\n cwd,\n })\n installedPackages.push(...selected.map((entry) => entry.artifact.package))\n\n // Regenerating rewrites output files, so it is asked for. `--yes` only accepts the install.\n const foundConfig = findConfigFile(cwd)\n const regenerateNow =\n foundConfig && !yes && (await clack.confirm({ message: 'Regenerate now? This rewrites the generated files.', initialValue: true })) === true\n const configPath = regenerateNow ? foundConfig : undefined\n const changed = configPath ? await regenerate({ cwd, configPath }) : undefined\n\n const generationFailed = Boolean(configPath && !changed)\n const fileCounts = { A: 0, M: 0, D: 0 }\n for (const file of changed?.files ?? []) fileCounts[file.status]++\n summary(generationFailed ? 'Extensions updated; generation failed' : 'Update complete', generationFailed ? 'warning' : 'success', [\n ` Packages ${selected.length} installed with ${packageManager.name}${skipped.length ? ` · ${skipped.length} skipped` : ''}`,\n ...skipped,\n ...(changed ? [` Files ${fileCounts.A} added · ${fileCounts.M} modified · ${fileCounts.D} deleted`] : []),\n ...(!configPath ? [' Regeneration not run'] : []),\n ...(generationFailed ? ['', 'Fix the generation error, then run kubb generate.'] : []),\n ])\n } catch (error) {\n logError(getErrorMessage(error))\n summary('Update failed', 'failed', installedPackages.length ? [` Packages ${installedPackages.join(', ')} installed`] : [' No changes made'])\n process.exitCode = 1\n }\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'update',\n description: 'Update installed extensions, regenerate, and summarize file changes.',\n examples: ['kubb update', 'kubb update --dry-run', '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 ...yesArg,\n },\n run: ({ values, extensions }) => run({ ids: values.ids ?? [], dryRun: extensions[dryRunId].enabled, yes: values.yes }),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqC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ChI,eAAe,SAAS,OAAO,kBAAkB,eAAe,OAAO,QAAQ,SAAS,MAAM,QAAQ,OAAO,YAAY;GACzH,GAAG;GACH,GAAI,UAAU,CAAC,eAAe,WAAW,EAAE,WAAW,WAAW,EAAE,cAAc,WAAW,EAAE,SAAS,IAAI,CAAC;GAC5G,GAAI,CAAC,aAAa,CAAC,wBAAwB,IAAI,CAAC;GAChD,GAAI,mBAAmB,CAAC,IAAI,mDAAmD,IAAI,CAAC;EACtF,CAAC;CACH,SAAS,OAAO;EACd,cAAA,SAASd,eAAAA,gBAAgB,KAAK,CAAC;EAC/B,QAAQ,iBAAiB,UAAU,kBAAkB,SAAS,CAAC,eAAe,kBAAkB,KAAK,IAAI,EAAE,WAAW,IAAI,CAAC,mBAAmB,CAAC;EAC/I,aAAA,QAAA,WAAmB;CACrB;AACF;AAEA,MAAa,WAAA,GAAUoB,OAAAA,gBAAAA,CAAkD,CAAC,CAAC;CACzE,MAAM;CACN,aAAa;CACb,UAAU;EAAC;EAAe;EAAyB;CAAwC,CAAC,CAAC,KAAK,IAAI;CACtG,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,UAAU;EACZ;EACA,GAAGC,eAAAA;CACL;CACA,MAAM,EAAE,QAAQ,iBAAiB,IAAI;EAAE,KAAK,OAAO,OAAO,CAAC;EAAG,QAAQ,WAAWC,sBAAAA,SAAS,CAAC;EAAS,KAAK,OAAO;CAAI,CAAC;AACvH,CAAC"}
|
package/dist/shared-C0EtrdUm.cjs
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
require("@gunshi/plugin-dryrun");
|
|
2
|
-
// src/commands/shared.ts
|
|
3
|
-
const configArg = { config: {
|
|
4
|
-
type: "string",
|
|
5
|
-
description: "Path to the Kubb config",
|
|
6
|
-
short: "c"
|
|
7
|
-
} };
|
|
8
|
-
const yesArg = { yes: {
|
|
9
|
-
type: "boolean",
|
|
10
|
-
description: "Skip the confirmation",
|
|
11
|
-
short: "y",
|
|
12
|
-
default: false
|
|
13
|
-
} };
|
|
14
|
-
const logLevelArg = { logLevel: {
|
|
15
|
-
type: "enum",
|
|
16
|
-
choices: [
|
|
17
|
-
"silent",
|
|
18
|
-
"info",
|
|
19
|
-
"verbose"
|
|
20
|
-
],
|
|
21
|
-
description: "Info, silent or verbose",
|
|
22
|
-
short: "l",
|
|
23
|
-
default: "info",
|
|
24
|
-
toKebab: true
|
|
25
|
-
} };
|
|
26
|
-
const studioConnectionArgs = {
|
|
27
|
-
url: {
|
|
28
|
-
type: "string",
|
|
29
|
-
description: "Base URL of the Kubb Studio instance"
|
|
30
|
-
},
|
|
31
|
-
token: {
|
|
32
|
-
type: "string",
|
|
33
|
-
description: "Organization CI API key for `snapshot`. Defaults to KUBB_TOKEN"
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
const studioPermissionArgs = {
|
|
37
|
-
allowRead: {
|
|
38
|
-
type: "boolean",
|
|
39
|
-
description: "Read the source of files a generation produced. Asked for once per project when omitted",
|
|
40
|
-
default: false,
|
|
41
|
-
toKebab: true
|
|
42
|
-
},
|
|
43
|
-
allowReadAst: {
|
|
44
|
-
type: "boolean",
|
|
45
|
-
description: "Read the parsed spec (the Kubb AST). Asked for once per project when omitted",
|
|
46
|
-
default: false,
|
|
47
|
-
toKebab: true
|
|
48
|
-
},
|
|
49
|
-
allowWrite: {
|
|
50
|
-
type: "boolean",
|
|
51
|
-
description: "Write generated files to disk. Asked for once per project when omitted",
|
|
52
|
-
default: false,
|
|
53
|
-
toKebab: true
|
|
54
|
-
},
|
|
55
|
-
allowConfigEdit: {
|
|
56
|
-
type: "boolean",
|
|
57
|
-
description: "Let Studio change plugin options in kubb.config.ts. Asked for once per project when omitted",
|
|
58
|
-
default: false,
|
|
59
|
-
toKebab: true
|
|
60
|
-
},
|
|
61
|
-
allowInstall: {
|
|
62
|
-
type: "boolean",
|
|
63
|
-
description: "Let Studio install extensions from the registry with kubb add; needs --allow-config-edit too. Asked for once per project when omitted",
|
|
64
|
-
default: false,
|
|
65
|
-
toKebab: true
|
|
66
|
-
},
|
|
67
|
-
allowUpdate: {
|
|
68
|
-
type: "boolean",
|
|
69
|
-
description: "Let Studio update installed extensions with kubb update. Asked for once per project when omitted",
|
|
70
|
-
default: false,
|
|
71
|
-
toKebab: true
|
|
72
|
-
},
|
|
73
|
-
allowRemove: {
|
|
74
|
-
type: "boolean",
|
|
75
|
-
description: "Let Studio remove extensions with kubb remove, which edits kubb.config.ts and uninstalls packages; needs --allow-config-edit too. Asked for once per project when omitted",
|
|
76
|
-
default: false,
|
|
77
|
-
toKebab: true
|
|
78
|
-
},
|
|
79
|
-
allowSaveInput: {
|
|
80
|
-
type: "boolean",
|
|
81
|
-
description: "Let Studio save the spec it sends as the input in kubb.config.ts; needs --allow-config-edit too. Asked for once per project when omitted",
|
|
82
|
-
default: false,
|
|
83
|
-
toKebab: true
|
|
84
|
-
},
|
|
85
|
-
allowExec: {
|
|
86
|
-
type: "boolean",
|
|
87
|
-
description: "Run the formatter, the linter, and output.postGenerate after a generation",
|
|
88
|
-
default: false,
|
|
89
|
-
toKebab: true
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
Object.defineProperty(exports, "configArg", {
|
|
93
|
-
enumerable: true,
|
|
94
|
-
get: function() {
|
|
95
|
-
return configArg;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
Object.defineProperty(exports, "logLevelArg", {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
get: function() {
|
|
101
|
-
return logLevelArg;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
Object.defineProperty(exports, "studioConnectionArgs", {
|
|
105
|
-
enumerable: true,
|
|
106
|
-
get: function() {
|
|
107
|
-
return studioConnectionArgs;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
Object.defineProperty(exports, "studioPermissionArgs", {
|
|
111
|
-
enumerable: true,
|
|
112
|
-
get: function() {
|
|
113
|
-
return studioPermissionArgs;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
Object.defineProperty(exports, "yesArg", {
|
|
117
|
-
enumerable: true,
|
|
118
|
-
get: function() {
|
|
119
|
-
return yesArg;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
//# sourceMappingURL=shared-C0EtrdUm.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shared-C0EtrdUm.cjs","names":[],"sources":["../src/commands/shared.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 allowReadAst: {\n type: 'boolean',\n description: 'Read the parsed spec (the Kubb AST). 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 allowInstall: {\n type: 'boolean',\n description: 'Let Studio install extensions from the registry with kubb add; needs --allow-config-edit too. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowUpdate: {\n type: 'boolean',\n description: 'Let Studio update installed extensions with kubb update. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowRemove: {\n type: 'boolean',\n description:\n 'Let Studio remove extensions with kubb remove, which edits kubb.config.ts and uninstalls packages; needs --allow-config-edit too. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowSaveInput: {\n type: 'boolean',\n description: 'Let Studio save the spec it sends as the input in kubb.config.ts; needs --allow-config-edit too. 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"],"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,cAAc;EACZ,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,cAAc;EACZ,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,aAAa;EACX,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,aAAa;EACX,MAAM;EACN,aACE;EACF,SAAS;EACT,SAAS;CACX;CACA,gBAAgB;EACd,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,WAAW;EACT,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;AACF"}
|
package/dist/shared-Ct9stKpp.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { pluginId as dryRunId } from "@gunshi/plugin-dryrun";
|
|
2
|
-
// src/commands/shared.ts
|
|
3
|
-
const configArg = { config: {
|
|
4
|
-
type: "string",
|
|
5
|
-
description: "Path to the Kubb config",
|
|
6
|
-
short: "c"
|
|
7
|
-
} };
|
|
8
|
-
const yesArg = { yes: {
|
|
9
|
-
type: "boolean",
|
|
10
|
-
description: "Skip the confirmation",
|
|
11
|
-
short: "y",
|
|
12
|
-
default: false
|
|
13
|
-
} };
|
|
14
|
-
const logLevelArg = { logLevel: {
|
|
15
|
-
type: "enum",
|
|
16
|
-
choices: [
|
|
17
|
-
"silent",
|
|
18
|
-
"info",
|
|
19
|
-
"verbose"
|
|
20
|
-
],
|
|
21
|
-
description: "Info, silent or verbose",
|
|
22
|
-
short: "l",
|
|
23
|
-
default: "info",
|
|
24
|
-
toKebab: true
|
|
25
|
-
} };
|
|
26
|
-
const studioConnectionArgs = {
|
|
27
|
-
url: {
|
|
28
|
-
type: "string",
|
|
29
|
-
description: "Base URL of the Kubb Studio instance"
|
|
30
|
-
},
|
|
31
|
-
token: {
|
|
32
|
-
type: "string",
|
|
33
|
-
description: "Organization CI API key for `snapshot`. Defaults to KUBB_TOKEN"
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
const studioPermissionArgs = {
|
|
37
|
-
allowRead: {
|
|
38
|
-
type: "boolean",
|
|
39
|
-
description: "Read the source of files a generation produced. Asked for once per project when omitted",
|
|
40
|
-
default: false,
|
|
41
|
-
toKebab: true
|
|
42
|
-
},
|
|
43
|
-
allowReadAst: {
|
|
44
|
-
type: "boolean",
|
|
45
|
-
description: "Read the parsed spec (the Kubb AST). Asked for once per project when omitted",
|
|
46
|
-
default: false,
|
|
47
|
-
toKebab: true
|
|
48
|
-
},
|
|
49
|
-
allowWrite: {
|
|
50
|
-
type: "boolean",
|
|
51
|
-
description: "Write generated files to disk. Asked for once per project when omitted",
|
|
52
|
-
default: false,
|
|
53
|
-
toKebab: true
|
|
54
|
-
},
|
|
55
|
-
allowConfigEdit: {
|
|
56
|
-
type: "boolean",
|
|
57
|
-
description: "Let Studio change plugin options in kubb.config.ts. Asked for once per project when omitted",
|
|
58
|
-
default: false,
|
|
59
|
-
toKebab: true
|
|
60
|
-
},
|
|
61
|
-
allowInstall: {
|
|
62
|
-
type: "boolean",
|
|
63
|
-
description: "Let Studio install extensions from the registry with kubb add; needs --allow-config-edit too. Asked for once per project when omitted",
|
|
64
|
-
default: false,
|
|
65
|
-
toKebab: true
|
|
66
|
-
},
|
|
67
|
-
allowUpdate: {
|
|
68
|
-
type: "boolean",
|
|
69
|
-
description: "Let Studio update installed extensions with kubb update. Asked for once per project when omitted",
|
|
70
|
-
default: false,
|
|
71
|
-
toKebab: true
|
|
72
|
-
},
|
|
73
|
-
allowRemove: {
|
|
74
|
-
type: "boolean",
|
|
75
|
-
description: "Let Studio remove extensions with kubb remove, which edits kubb.config.ts and uninstalls packages; needs --allow-config-edit too. Asked for once per project when omitted",
|
|
76
|
-
default: false,
|
|
77
|
-
toKebab: true
|
|
78
|
-
},
|
|
79
|
-
allowSaveInput: {
|
|
80
|
-
type: "boolean",
|
|
81
|
-
description: "Let Studio save the spec it sends as the input in kubb.config.ts; needs --allow-config-edit too. Asked for once per project when omitted",
|
|
82
|
-
default: false,
|
|
83
|
-
toKebab: true
|
|
84
|
-
},
|
|
85
|
-
allowExec: {
|
|
86
|
-
type: "boolean",
|
|
87
|
-
description: "Run the formatter, the linter, and output.postGenerate after a generation",
|
|
88
|
-
default: false,
|
|
89
|
-
toKebab: true
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
export { studioPermissionArgs as a, studioConnectionArgs as i, dryRunId as n, yesArg as o, logLevelArg as r, configArg as t };
|
|
93
|
-
|
|
94
|
-
//# sourceMappingURL=shared-Ct9stKpp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shared-Ct9stKpp.js","names":[],"sources":["../src/commands/shared.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 allowReadAst: {\n type: 'boolean',\n description: 'Read the parsed spec (the Kubb AST). 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 allowInstall: {\n type: 'boolean',\n description: 'Let Studio install extensions from the registry with kubb add; needs --allow-config-edit too. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowUpdate: {\n type: 'boolean',\n description: 'Let Studio update installed extensions with kubb update. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowRemove: {\n type: 'boolean',\n description:\n 'Let Studio remove extensions with kubb remove, which edits kubb.config.ts and uninstalls packages; needs --allow-config-edit too. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowSaveInput: {\n type: 'boolean',\n description: 'Let Studio save the spec it sends as the input in kubb.config.ts; needs --allow-config-edit too. 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"],"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,cAAc;EACZ,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,cAAc;EACZ,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,aAAa;EACX,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,aAAa;EACX,MAAM;EACN,aACE;EACF,SAAS;EACT,SAAS;CACX;CACA,gBAAgB;EACd,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,WAAW;EACT,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spinner-BZaln7O8.js","names":[],"sources":["../../../internals/utils/src/fs.ts","../src/ui/spinner.ts"],"sourcesContent":["import { access, glob as globNode, mkdir, readFile, writeFile } from 'node:fs/promises'\n\nimport { dirname, isAbsolute, join, relative, resolve } from 'node:path'\nimport { runtime } from './runtime.ts'\n\nexport { existsSync } from 'node:fs'\nexport { mkdir, mkdtemp, rm } from 'node:fs/promises'\n\n/**\n * Resolves to `true` when the file or directory at `path` exists.\n * Uses `Bun.file().exists()` when running under Bun, `fs.access` otherwise.\n *\n * @example\n * ```ts\n * if (await exists('./kubb.config.ts')) {\n * const content = await read('./kubb.config.ts')\n * }\n * ```\n */\nexport async function exists(path: string): Promise<boolean> {\n if (runtime.isBun) {\n return Bun.file(path).exists()\n }\n return access(path).then(\n () => true,\n () => false,\n )\n}\n\n/**\n * Reads the file at `path` as a UTF-8 string.\n * Uses `Bun.file().text()` when running under Bun, `fs.readFile` otherwise.\n *\n * @example\n * ```ts\n * const source = await read('./src/Pet.ts')\n * ```\n */\nexport async function read(path: string): Promise<string> {\n if (runtime.isBun) {\n return Bun.file(path).text()\n }\n return readFile(path, { encoding: 'utf8' })\n}\n\ntype WriteOptions = {\n /**\n * Previously read content, or `null` when the file does not exist.\n * Omitting this value reads the file before writing.\n */\n stored?: string | null\n /**\n * When `true`, re-reads the file immediately after writing and throws if the\n * content does not match — useful for catching write failures on unreliable file systems.\n */\n sanity?: boolean\n}\n\n/**\n * Whether `stored` already holds `source`, comparing on the trimmed text rather than the exact\n * bytes. Surrounding whitespace is what a formatter adds and what editors strip, and neither is a\n * reason to rewrite the file.\n *\n * Both sides are trimmed, so a storage that keeps bytes verbatim settles on the same answer as one\n * that normalizes what it stores. Trimming only `stored` would leave a source with leading\n * whitespace rewritten on every build, since the stored copy keeps the whitespace the comparison\n * has already dropped.\n */\nexport function matchesStored({ stored, source }: { stored: string; source: string }): boolean {\n return stored.trim() === source.trim()\n}\n\n/**\n * Writes `data` to `path`, trimming surrounding whitespace and ending the file with a single newline\n * the way prettier, biome, and oxfmt all do.\n * Skips the write when the trimmed content is empty, or when the file already holds that content.\n * Creates any missing parent directories automatically.\n * When `sanity` is `true`, re-reads the file after writing and throws if the content does not match.\n *\n * @example\n * ```ts\n * await write('./src/Pet.ts', source) // writes and returns the trimmed content plus a newline\n * await write('./src/Pet.ts', source) // null — file unchanged\n * await write('./src/Pet.ts', ' ') // null — empty content skipped\n * ```\n */\nexport async function write(path: string, data: string, options: WriteOptions = {}): Promise<string | null> {\n const trimmed = data.trim()\n if (trimmed === '') return null\n\n const content = `${trimmed}\\n`\n const resolved = resolve(path)\n let stored = options.stored\n\n if (stored === undefined) {\n if (runtime.isBun) {\n const file = Bun.file(resolved)\n stored = (await file.exists()) ? await file.text() : null\n } else {\n try {\n stored = await readFile(resolved, { encoding: 'utf-8' })\n } catch {\n /* file doesn't exist yet */\n stored = null\n }\n }\n }\n if (matchesStored({ stored: stored ?? '', source: trimmed })) return null\n\n await writeRaw(resolved, content)\n\n if (options.sanity) {\n const savedData = await read(resolved)\n if (savedData !== content) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n return savedData\n }\n\n return content\n}\n\n/**\n * Writes UTF-8 content verbatim, including empty files and surrounding whitespace.\n * Uses Bun.write under Bun and creates missing parent directories under either runtime.\n *\n * @example\n * await writeRaw('./cache/output.ts', ' // keep these bytes\\n\\n')\n */\nexport async function writeRaw(path: string, content: string): Promise<void> {\n const resolved = resolve(path)\n if (runtime.isBun) {\n await Bun.write(resolved, content)\n return\n }\n try {\n await writeFile(resolved, content, { encoding: 'utf-8' })\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error\n await mkdir(dirname(resolved), { recursive: true })\n await writeFile(resolved, content, { encoding: 'utf-8' })\n }\n}\n\n/**\n * Lists non-hidden regular files below `directory` as relative POSIX paths, excluding directories and symlinks.\n * Uses Bun.Glob under Bun because its Node glob compatibility API lacks directory-entry support.\n *\n * @example\n * for await (const path of listFiles('./src')) console.log(path)\n */\nexport async function* listFiles(directory: string): AsyncGenerator<string> {\n const cwd = resolve(directory)\n if (runtime.isBun) {\n yield* new Bun.Glob('**/*').scan({ cwd, dot: false, onlyFiles: true, followSymlinks: false })\n return\n }\n for await (const entry of globNode('**/*', { cwd, withFileTypes: true })) {\n if (entry.isFile()) yield toPosixPath(relative(cwd, join(entry.parentPath, entry.name)))\n }\n}\n\n/**\n * Converts a filesystem path to use POSIX (`/`) separators.\n *\n * Most of the codebase compares and composes paths as strings (prefix matching, joining for\n * import specifiers, splitting on `/`). On POSIX `path.resolve` already returns `/`-separated\n * paths, but on Windows it returns `\\`-separated paths, which breaks every such comparison.\n *\n * Routing every path that crosses a module boundary through `toPosixPath` keeps the rest of the\n * code platform-agnostic. The conversion runs unconditionally so Windows-specific behavior is\n * exercisable from POSIX CI.\n *\n * @example\n * toPosixPath('C:\\\\repo\\\\src\\\\pet.ts') // 'C:/repo/src/pet.ts'\n */\nexport function toPosixPath(filePath: string): string {\n return filePath.replaceAll('\\\\', '/')\n}\n\n/**\n * Strips the file extension from a path or file name.\n * Only removes the last `.ext` segment when the dot is not part of a directory name.\n *\n * @example\n * trimExtName('petStore.ts') // 'petStore'\n * trimExtName('/src/models/pet.ts') // '/src/models/pet'\n * trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'\n * trimExtName('noExtension') // 'noExtension'\n */\nexport function trimExtName(text: string): string {\n const dotIndex = text.lastIndexOf('.')\n if (dotIndex > 0 && !text.includes('/', dotIndex)) {\n return text.slice(0, dotIndex)\n }\n return text\n}\n\n/**\n * Resolves to `true` when `path` is `parent` itself or nested inside it. Both sides are resolved\n * to absolute paths first, so relative and `..`-containing inputs compare correctly.\n *\n * Guards a destructive or an out-of-tree operation: before wiping an output directory, check that\n * it does not contain the project root, and before loading a path a caller supplied, check that it\n * did not escape the directory it is allowed to read from.\n *\n * @example\n * isPathInside('./src/gen', '.') // true — nested inside the root\n * isPathInside('.', '.') // true — the same directory counts as inside\n * isPathInside('.', './src/gen') // false — the root is not inside its own output\n * isPathInside('../other', '.') // false — escapes the root\n */\nexport function isPathInside(path: string, parent: string): boolean {\n const resolvedPath = resolve(path)\n const resolvedParent = resolve(parent)\n if (resolvedPath === resolvedParent) {\n return true\n }\n\n const rel = relative(resolvedParent, resolvedPath)\n\n return rel !== '' && !rel.startsWith('..') && !isAbsolute(rel)\n}\n","import type { WriterSpinner } from '../loggers/types.ts'\nimport { writer } from './log.ts'\n\n/**\n * A progress spinner, or a writer that prints each message it is given when the terminal cannot\n * animate one. Callers drive both the same way, including the failure state.\n */\nexport function createSpinner(): WriterSpinner {\n return writer().spinner()\n}\n\n/** How long a wait may run before a spinner shows, so a fast answer draws nothing. */\nconst SPINNER_DELAY_MS = 150\n\n/**\n * Awaits `promise`, showing a spinner with `message` only when it takes longer than 150 ms.\n */\nexport async function withSpinner<T>({ promise, message }: { promise: Promise<T>; message: string }): Promise<T> {\n let spinner: WriterSpinner | undefined\n const timer = setTimeout(() => {\n spinner = createSpinner()\n spinner.start(message)\n }, SPINNER_DELAY_MS)\n try {\n return await promise\n } finally {\n clearTimeout(timer)\n spinner?.clear()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,eAAsB,OAAO,MAAgC;CAC3D,IAAI,QAAQ,O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WAAW,QAAQ,IAAI;CAC7B,IAAI,QAAQ,OAAO;EACjB,MAAM,IAAI,MAAM,UAAU,OAAO;EACjC;CACF;CACA,IAAI;EACF,MAAM,UAAU,UAAU,SAAS,EAAE,UAAU,QAAQ,CAAC;CAC1D,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAAU,MAAM;EAC9D,MAAM,MAAM,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;EAClD,MAAM,UAAU,UAAU,SAAS,EAAE,UAAU,QAAQ,CAAC;CAC1D;AACF;;;;;;;;;;;;;;;AAsEA,SAAgB,aAAa,MAAc,QAAyB;CAClE,MAAM,eAAe,QAAQ,IAAI;CACjC,MAAM,iBAAiB,QAAQ,MAAM;CACrC,IAAI,iBAAiB,gBACnB,OAAO;CAGT,MAAM,MAAM,SAAS,gBAAgB,YAAY;CAEjD,OAAO,QAAQ,MAAM,CAAC,IAAI,WAAW,IAAI,KAAK,CAAC,WAAW,GAAG;AAC/D;;;;;;ACvNA,SAAgB,gBAA+B;CAC7C,OAAO,OAAO,CAAC,CAAC,QAAQ;AAC1B;;AAGA,MAAM,mBAAmB;;;;AAKzB,eAAsB,YAAe,EAAE,SAAS,WAAiE;CAC/G,IAAI;CACJ,MAAM,QAAQ,iBAAiB;EAC7B,UAAU,cAAc;EACxB,QAAQ,MAAM,OAAO;CACvB,GAAG,gBAAgB;CACnB,IAAI;EACF,OAAO,MAAM;CACf,UAAU;EACR,aAAa,KAAK;EAClB,SAAS,MAAM;CACjB;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spinner-CfB0sIPy.cjs","names":["runtime","access","readFile","resolve","writeFile","mkdir","dirname","relative","isAbsolute","writer"],"sources":["../../../internals/utils/src/fs.ts","../src/ui/spinner.ts"],"sourcesContent":["import { access, glob as globNode, mkdir, readFile, writeFile } from 'node:fs/promises'\n\nimport { dirname, isAbsolute, join, relative, resolve } from 'node:path'\nimport { runtime } from './runtime.ts'\n\nexport { existsSync } from 'node:fs'\nexport { mkdir, mkdtemp, rm } from 'node:fs/promises'\n\n/**\n * Resolves to `true` when the file or directory at `path` exists.\n * Uses `Bun.file().exists()` when running under Bun, `fs.access` otherwise.\n *\n * @example\n * ```ts\n * if (await exists('./kubb.config.ts')) {\n * const content = await read('./kubb.config.ts')\n * }\n * ```\n */\nexport async function exists(path: string): Promise<boolean> {\n if (runtime.isBun) {\n return Bun.file(path).exists()\n }\n return access(path).then(\n () => true,\n () => false,\n )\n}\n\n/**\n * Reads the file at `path` as a UTF-8 string.\n * Uses `Bun.file().text()` when running under Bun, `fs.readFile` otherwise.\n *\n * @example\n * ```ts\n * const source = await read('./src/Pet.ts')\n * ```\n */\nexport async function read(path: string): Promise<string> {\n if (runtime.isBun) {\n return Bun.file(path).text()\n }\n return readFile(path, { encoding: 'utf8' })\n}\n\ntype WriteOptions = {\n /**\n * Previously read content, or `null` when the file does not exist.\n * Omitting this value reads the file before writing.\n */\n stored?: string | null\n /**\n * When `true`, re-reads the file immediately after writing and throws if the\n * content does not match — useful for catching write failures on unreliable file systems.\n */\n sanity?: boolean\n}\n\n/**\n * Whether `stored` already holds `source`, comparing on the trimmed text rather than the exact\n * bytes. Surrounding whitespace is what a formatter adds and what editors strip, and neither is a\n * reason to rewrite the file.\n *\n * Both sides are trimmed, so a storage that keeps bytes verbatim settles on the same answer as one\n * that normalizes what it stores. Trimming only `stored` would leave a source with leading\n * whitespace rewritten on every build, since the stored copy keeps the whitespace the comparison\n * has already dropped.\n */\nexport function matchesStored({ stored, source }: { stored: string; source: string }): boolean {\n return stored.trim() === source.trim()\n}\n\n/**\n * Writes `data` to `path`, trimming surrounding whitespace and ending the file with a single newline\n * the way prettier, biome, and oxfmt all do.\n * Skips the write when the trimmed content is empty, or when the file already holds that content.\n * Creates any missing parent directories automatically.\n * When `sanity` is `true`, re-reads the file after writing and throws if the content does not match.\n *\n * @example\n * ```ts\n * await write('./src/Pet.ts', source) // writes and returns the trimmed content plus a newline\n * await write('./src/Pet.ts', source) // null — file unchanged\n * await write('./src/Pet.ts', ' ') // null — empty content skipped\n * ```\n */\nexport async function write(path: string, data: string, options: WriteOptions = {}): Promise<string | null> {\n const trimmed = data.trim()\n if (trimmed === '') return null\n\n const content = `${trimmed}\\n`\n const resolved = resolve(path)\n let stored = options.stored\n\n if (stored === undefined) {\n if (runtime.isBun) {\n const file = Bun.file(resolved)\n stored = (await file.exists()) ? await file.text() : null\n } else {\n try {\n stored = await readFile(resolved, { encoding: 'utf-8' })\n } catch {\n /* file doesn't exist yet */\n stored = null\n }\n }\n }\n if (matchesStored({ stored: stored ?? '', source: trimmed })) return null\n\n await writeRaw(resolved, content)\n\n if (options.sanity) {\n const savedData = await read(resolved)\n if (savedData !== content) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n return savedData\n }\n\n return content\n}\n\n/**\n * Writes UTF-8 content verbatim, including empty files and surrounding whitespace.\n * Uses Bun.write under Bun and creates missing parent directories under either runtime.\n *\n * @example\n * await writeRaw('./cache/output.ts', ' // keep these bytes\\n\\n')\n */\nexport async function writeRaw(path: string, content: string): Promise<void> {\n const resolved = resolve(path)\n if (runtime.isBun) {\n await Bun.write(resolved, content)\n return\n }\n try {\n await writeFile(resolved, content, { encoding: 'utf-8' })\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error\n await mkdir(dirname(resolved), { recursive: true })\n await writeFile(resolved, content, { encoding: 'utf-8' })\n }\n}\n\n/**\n * Lists non-hidden regular files below `directory` as relative POSIX paths, excluding directories and symlinks.\n * Uses Bun.Glob under Bun because its Node glob compatibility API lacks directory-entry support.\n *\n * @example\n * for await (const path of listFiles('./src')) console.log(path)\n */\nexport async function* listFiles(directory: string): AsyncGenerator<string> {\n const cwd = resolve(directory)\n if (runtime.isBun) {\n yield* new Bun.Glob('**/*').scan({ cwd, dot: false, onlyFiles: true, followSymlinks: false })\n return\n }\n for await (const entry of globNode('**/*', { cwd, withFileTypes: true })) {\n if (entry.isFile()) yield toPosixPath(relative(cwd, join(entry.parentPath, entry.name)))\n }\n}\n\n/**\n * Converts a filesystem path to use POSIX (`/`) separators.\n *\n * Most of the codebase compares and composes paths as strings (prefix matching, joining for\n * import specifiers, splitting on `/`). On POSIX `path.resolve` already returns `/`-separated\n * paths, but on Windows it returns `\\`-separated paths, which breaks every such comparison.\n *\n * Routing every path that crosses a module boundary through `toPosixPath` keeps the rest of the\n * code platform-agnostic. The conversion runs unconditionally so Windows-specific behavior is\n * exercisable from POSIX CI.\n *\n * @example\n * toPosixPath('C:\\\\repo\\\\src\\\\pet.ts') // 'C:/repo/src/pet.ts'\n */\nexport function toPosixPath(filePath: string): string {\n return filePath.replaceAll('\\\\', '/')\n}\n\n/**\n * Strips the file extension from a path or file name.\n * Only removes the last `.ext` segment when the dot is not part of a directory name.\n *\n * @example\n * trimExtName('petStore.ts') // 'petStore'\n * trimExtName('/src/models/pet.ts') // '/src/models/pet'\n * trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'\n * trimExtName('noExtension') // 'noExtension'\n */\nexport function trimExtName(text: string): string {\n const dotIndex = text.lastIndexOf('.')\n if (dotIndex > 0 && !text.includes('/', dotIndex)) {\n return text.slice(0, dotIndex)\n }\n return text\n}\n\n/**\n * Resolves to `true` when `path` is `parent` itself or nested inside it. Both sides are resolved\n * to absolute paths first, so relative and `..`-containing inputs compare correctly.\n *\n * Guards a destructive or an out-of-tree operation: before wiping an output directory, check that\n * it does not contain the project root, and before loading a path a caller supplied, check that it\n * did not escape the directory it is allowed to read from.\n *\n * @example\n * isPathInside('./src/gen', '.') // true — nested inside the root\n * isPathInside('.', '.') // true — the same directory counts as inside\n * isPathInside('.', './src/gen') // false — the root is not inside its own output\n * isPathInside('../other', '.') // false — escapes the root\n */\nexport function isPathInside(path: string, parent: string): boolean {\n const resolvedPath = resolve(path)\n const resolvedParent = resolve(parent)\n if (resolvedPath === resolvedParent) {\n return true\n }\n\n const rel = relative(resolvedParent, resolvedPath)\n\n return rel !== '' && !rel.startsWith('..') && !isAbsolute(rel)\n}\n","import type { WriterSpinner } from '../loggers/types.ts'\nimport { writer } from './log.ts'\n\n/**\n * A progress spinner, or a writer that prints each message it is given when the terminal cannot\n * animate one. Callers drive both the same way, including the failure state.\n */\nexport function createSpinner(): WriterSpinner {\n return writer().spinner()\n}\n\n/** How long a wait may run before a spinner shows, so a fast answer draws nothing. */\nconst SPINNER_DELAY_MS = 150\n\n/**\n * Awaits `promise`, showing a spinner with `message` only when it takes longer than 150 ms.\n */\nexport async function withSpinner<T>({ promise, message }: { promise: Promise<T>; message: string }): Promise<T> {\n let spinner: WriterSpinner | undefined\n const timer = setTimeout(() => {\n spinner = createSpinner()\n spinner.start(message)\n }, SPINNER_DELAY_MS)\n try {\n return await promise\n } finally {\n clearTimeout(timer)\n spinner?.clear()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,eAAsB,OAAO,MAAgC;CAC3D,IAAIA,aAAAA,QAAQ,OACV,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,OAAO;CAE/B,QAAA,GAAOC,iBAAAA,OAAAA,CAAO,IAAI,CAAC,CAAC,WACZ,YACA,KACR;AACF;;;;;;;;;;AAWA,eAAsB,KAAK,MAA+B;CACxD,IAAID,aAAAA,QAAQ,OACV,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,KAAK;CAE7B,QAAA,GAAOE,iBAAAA,SAAAA,CAAS,MAAM,EAAE,UAAU,OAAO,CAAC;AAC5C;;;;;;;;;;;AAyBA,SAAgB,cAAc,EAAE,QAAQ,UAAuD;CAC7F,OAAO,OAAO,KAAK,MAAM,OAAO,KAAK;AACvC;;;;;;;;;;;;;;;AAgBA,eAAsB,MAAM,MAAc,MAAc,UAAwB,CAAC,GAA2B;CAC1G,MAAM,UAAU,KAAK,KAAK;CAC1B,IAAI,YAAY,IAAI,OAAO;CAE3B,MAAM,UAAU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;;;;;;;;;;;;;;;AAsEA,SAAgB,aAAa,MAAc,QAAyB;CAClE,MAAM,gBAAA,GAAeD,UAAAA,QAAAA,CAAQ,IAAI;CACjC,MAAM,kBAAA,GAAiBA,UAAAA,QAAAA,CAAQ,MAAM;CACrC,IAAI,iBAAiB,gBACnB,OAAO;CAGT,MAAM,OAAA,GAAMI,UAAAA,SAAAA,CAAS,gBAAgB,YAAY;CAEjD,OAAO,QAAQ,MAAM,CAAC,IAAI,WAAW,IAAI,KAAK,EAAA,GAACC,UAAAA,WAAAA,CAAW,GAAG;AAC/D;;;;;;ACvNA,SAAgB,gBAA+B;CAC7C,OAAOC,cAAAA,OAAO,CAAC,CAAC,QAAQ;AAC1B;;AAGA,MAAM,mBAAmB;;;;AAKzB,eAAsB,YAAe,EAAE,SAAS,WAAiE;CAC/G,IAAI;CACJ,MAAM,QAAQ,iBAAiB;EAC7B,UAAU,cAAc;EACxB,QAAQ,MAAM,OAAO;CACvB,GAAG,gBAAgB;CACnB,IAAI;EACF,OAAO,MAAM;CACf,UAAU;EACR,aAAa,KAAK;EAClB,SAAS,MAAM;CACjB;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"summary-CbmQKA8l.js","names":[],"sources":["../src/ui/summary.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport { formatMs, getElapsedMs } from '@internals/utils'\nimport { logOutro } from './intro.ts'\n\n/**\n * Finishes a command with its outcome and duration before the labeled details.\n * A command with prompts closes its existing block; validation writes a standalone summary.\n */\nexport function logCommandSummary({\n title,\n status,\n hrStart,\n lines,\n block = false,\n}: {\n title: string\n status: 'success' | 'failed' | 'warning' | 'planned' | 'canceled'\n hrStart: [number, number]\n lines: ReadonlyArray<string>\n block?: boolean\n}): void {\n const colors = { success: 'green', failed: 'red', warning: 'yellow', planned: 'cyan', canceled: 'dim' } as const\n const symbols = { success: '✓', failed: '✗', warning: '!', planned: '◇', canceled: '○' } as const\n const summary = [`${styleText(colors[status], `${symbols[status]} ${title}`)} ${styleText('dim', formatMs(getElapsedMs(hrStart)))}`, '', ...lines].join('\\n')\n if (block) {\n logOutro(summary)\n return\n }\n if (status === 'failed') {\n console.error(summary)\n return\n }\n console.log(summary)\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,kBAAkB,EAChC,OACA,QACA,SACA,OACA,QAAQ,SAOD;CAGP,MAAM,UAAU;EAAC,GAAG,UAAU;GAFb,SAAS;GAAS,QAAQ;GAAO,SAAS;GAAU,SAAS;GAAQ,UAAU;EAE7D,EAAE,SAAS,GAAG;GAD/B,SAAS;GAAK,QAAQ;GAAK,SAAS;GAAK,SAAS;GAAK,UAAU;EAC5B,EAAE,QAAQ,GAAG,OAAO,EAAE,IAAI,UAAU,OAAO,SAAS,aAAa,OAAO,CAAC,CAAC;EAAK;EAAI,GAAG;CAAK,CAAC,CAAC,KAAK,IAAI;CAC7J,IAAI,OAAO;EACT,SAAS,OAAO;EAChB;CACF;CACA,IAAI,WAAW,UAAU;EACvB,QAAQ,MAAM,OAAO;EACrB;CACF;CACA,QAAQ,IAAI,OAAO;AACrB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"summary-Clvl5Hxs.cjs","names":["styleText","formatMs","getElapsedMs"],"sources":["../src/ui/summary.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport { formatMs, getElapsedMs } from '@internals/utils'\nimport { logOutro } from './intro.ts'\n\n/**\n * Finishes a command with its outcome and duration before the labeled details.\n * A command with prompts closes its existing block; validation writes a standalone summary.\n */\nexport function logCommandSummary({\n title,\n status,\n hrStart,\n lines,\n block = false,\n}: {\n title: string\n status: 'success' | 'failed' | 'warning' | 'planned' | 'canceled'\n hrStart: [number, number]\n lines: ReadonlyArray<string>\n block?: boolean\n}): void {\n const colors = { success: 'green', failed: 'red', warning: 'yellow', planned: 'cyan', canceled: 'dim' } as const\n const symbols = { success: '✓', failed: '✗', warning: '!', planned: '◇', canceled: '○' } as const\n const summary = [`${styleText(colors[status], `${symbols[status]} ${title}`)} ${styleText('dim', formatMs(getElapsedMs(hrStart)))}`, '', ...lines].join('\\n')\n if (block) {\n logOutro(summary)\n return\n }\n if (status === 'failed') {\n console.error(summary)\n return\n }\n console.log(summary)\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,kBAAkB,EAChC,OACA,QACA,SACA,OACA,QAAQ,SAOD;CAGP,MAAM,UAAU;EAAC,IAAA,GAAGA,UAAAA,UAAAA,CAAU;GAFb,SAAS;GAAS,QAAQ;GAAO,SAAS;GAAU,SAAS;GAAQ,UAAU;EAE7D,EAAE,SAAS,GAAG;GAD/B,SAAS;GAAK,QAAQ;GAAK,SAAS;GAAK,SAAS;GAAK,UAAU;EAC5B,EAAE,QAAQ,GAAG,OAAO,EAAE,KAAA,GAAIA,UAAAA,UAAAA,CAAU,OAAOC,aAAAA,SAASC,aAAAA,aAAa,OAAO,CAAC,CAAC;EAAK;EAAI,GAAG;CAAK,CAAC,CAAC,KAAK,IAAI;CAC7J,IAAI,OAAO;EACT,cAAA,SAAS,OAAO;EAChB;CACF;CACA,IAAI,WAAW,UAAU;EACvB,QAAQ,MAAM,OAAO;EACrB;CACF;CACA,QAAQ,IAAI,OAAO;AACrB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text-BmiI4s6N.js","names":[],"sources":["../src/ui/text.ts"],"sourcesContent":["/** Counts a noun, so a message never reads `1 files`. */\nexport function pluralize(count: number, noun: string): string {\n return `${count} ${count === 1 ? noun : `${noun}s`}`\n}\n\n/** The flag that grants a permission, such as `--allow-read-ast`. */\nexport function toPermissionFlag(key: string): string {\n return `--${key.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)}`\n}\n"],"mappings":";;;AACA,SAAgB,UAAU,OAAe,MAAsB;CAC7D,OAAO,GAAG,MAAM,GAAG,UAAU,IAAI,OAAO,GAAG,KAAK;AAClD;;AAGA,SAAgB,iBAAiB,KAAqB;CACpD,OAAO,KAAK,IAAI,QAAQ,WAAW,SAAS,IAAI,KAAK,YAAY,GAAG;AACtE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text-Ep3AulAS.cjs","names":[],"sources":["../src/ui/text.ts"],"sourcesContent":["/** Counts a noun, so a message never reads `1 files`. */\nexport function pluralize(count: number, noun: string): string {\n return `${count} ${count === 1 ? noun : `${noun}s`}`\n}\n\n/** The flag that grants a permission, such as `--allow-read-ast`. */\nexport function toPermissionFlag(key: string): string {\n return `--${key.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)}`\n}\n"],"mappings":";;;AACA,SAAgB,UAAU,OAAe,MAAsB;CAC7D,OAAO,GAAG,MAAM,GAAG,UAAU,IAAI,OAAO,GAAG,KAAK;AAClD;;AAGA,SAAgB,iBAAiB,KAAqB;CACpD,OAAO,KAAK,IAAI,QAAQ,WAAW,SAAS,IAAI,KAAK,YAAY,GAAG;AACtE"}
|