@kubb/cli 5.0.0-alpha.42 → 5.0.0-alpha.43
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/agent-CWitLsL9.cjs.map +1 -1
- package/dist/{agent-B_YiHpAa.cjs → agent-dAvD6Qlt.cjs} +2 -2
- package/dist/{agent-B_YiHpAa.cjs.map → agent-dAvD6Qlt.cjs.map} +1 -1
- package/dist/{agent-DiqRXCW7.js → agent-gIWBobyC.js} +2 -2
- package/dist/{agent-DiqRXCW7.js.map → agent-gIWBobyC.js.map} +1 -1
- package/dist/agent-poGbscec.js.map +1 -1
- package/dist/{generate-Dcok8KLN.js → generate-BuOyrlAd.js} +127 -127
- package/dist/generate-BuOyrlAd.js.map +1 -0
- package/dist/{generate-CtTiY1xz.js → generate-ByuXn3l6.js} +2 -2
- package/dist/{generate-CtTiY1xz.js.map → generate-ByuXn3l6.js.map} +1 -1
- package/dist/{generate-zQOqOI9F.cjs → generate-CTa0WBEL.cjs} +127 -127
- package/dist/generate-CTa0WBEL.cjs.map +1 -0
- package/dist/{generate-0fN4XGCH.cjs → generate-Cot9oHPK.cjs} +2 -2
- package/dist/{generate-0fN4XGCH.cjs.map → generate-Cot9oHPK.cjs.map} +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.js +6 -6
- package/dist/{init-DLSNDwle.js → init-Lixf1A0k.js} +2 -2
- package/dist/{init-DLSNDwle.js.map → init-Lixf1A0k.js.map} +1 -1
- package/dist/{init-B9SY8ZAs.cjs → init-d5UWmNrP.cjs} +2 -2
- package/dist/{init-B9SY8ZAs.cjs.map → init-d5UWmNrP.cjs.map} +1 -1
- package/dist/{mcp-Oi4H6gBV.js → mcp-BRsYx5qz.js} +2 -2
- package/dist/{mcp-Oi4H6gBV.js.map → mcp-BRsYx5qz.js.map} +1 -1
- package/dist/{mcp-B8ILzKI6.cjs → mcp-RN0WsHq_.cjs} +2 -2
- package/dist/{mcp-B8ILzKI6.cjs.map → mcp-RN0WsHq_.cjs.map} +1 -1
- package/dist/{package-AfsVioCi.cjs → package-CFbqPfx6.cjs} +2 -2
- package/dist/package-CFbqPfx6.cjs.map +1 -0
- package/dist/package-KJfRdbQA.js +6 -0
- package/dist/package-KJfRdbQA.js.map +1 -0
- package/dist/{validate-CT9wggjq.js → validate--Somzrer.js} +2 -2
- package/dist/{validate-CT9wggjq.js.map → validate--Somzrer.js.map} +1 -1
- package/dist/{validate-UHKme1dS.cjs → validate-ipF21nm2.cjs} +2 -2
- package/dist/{validate-UHKme1dS.cjs.map → validate-ipF21nm2.cjs.map} +1 -1
- package/package.json +6 -6
- package/src/runners/agent.ts +1 -3
- package/src/runners/generate.ts +1 -8
- package/dist/generate-Dcok8KLN.js.map +0 -1
- package/dist/generate-zQOqOI9F.cjs.map +0 -1
- package/dist/package-4BsY_J5b.js +0 -6
- package/dist/package-4BsY_J5b.js.map +0 -1
- package/dist/package-AfsVioCi.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-CWitLsL9.cjs","names":["process","agentDefaults","path","net","spawnAsync","sendTelemetry","buildTelemetryEvent"],"sources":["../src/runners/agent.ts"],"sourcesContent":["import net from 'node:net'\nimport path from 'node:path'\nimport * as process from 'node:process'\nimport { fileURLToPath } from 'node:url'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { spawnAsync } from '@internals/utils'\nimport { agentDefaults } from '../constants.ts'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\ntype AgentStartOptions = {\n port: string | undefined\n host: string\n configPath: string | undefined\n allowWrite: boolean\n allowAll: boolean\n version: string\n}\n\ntype ResolvedAgentStartEnvironment = {\n port: string\n host: string\n allowWrite: boolean\n allowAll: boolean\n agentConfigPath: string\n env: NodeJS.ProcessEnv\n}\n\n/**\n * Resolves the environment passed to the detached agent process using CLI values first, then environment values, then CLI defaults.\n */\nfunction resolveAgentStartEnvironment({ port, host, configPath, allowWrite, allowAll }: Omit<AgentStartOptions, 'version'>): ResolvedAgentStartEnvironment {\n const resolvedPort = port ?? process.env.PORT ?? agentDefaults.port\n const resolvedHost = host !== agentDefaults.host ? host : (process.env.HOST ?? agentDefaults.host)\n const resolvedAllowAll = allowAll || process.env.KUBB_AGENT_ALLOW_ALL === 'true'\n const resolvedAllowWrite = resolvedAllowAll || allowWrite || process.env.KUBB_AGENT_ALLOW_WRITE === 'true'\n const agentRoot = process.env.KUBB_AGENT_ROOT ?? process.cwd()\n const agentConfigPath = path.resolve(process.cwd(), configPath || process.env.KUBB_AGENT_CONFIG || agentDefaults.configFile)\n\n return {\n port: resolvedPort,\n host: resolvedHost,\n allowWrite: resolvedAllowWrite,\n allowAll: resolvedAllowAll,\n agentConfigPath,\n env: {\n ...process.env,\n PORT: resolvedPort,\n HOST: resolvedHost,\n KUBB_AGENT_ROOT: agentRoot,\n KUBB_AGENT_CONFIG: agentConfigPath,\n KUBB_AGENT_ALLOW_WRITE: String(resolvedAllowWrite),\n KUBB_AGENT_ALLOW_ALL: String(resolvedAllowAll),\n KUBB_AGENT_TOKEN: process.env.KUBB_AGENT_TOKEN,\n KUBB_AGENT_RETRY_TIMEOUT: process.env.KUBB_AGENT_RETRY_TIMEOUT ?? agentDefaults.retryTimeout,\n KUBB_STUDIO_URL: process.env.KUBB_STUDIO_URL ?? agentDefaults.studioUrl,\n },\n }\n}\n\nfunction isPortAvailable(port: number, host: string): Promise<boolean> {\n return new Promise((resolve) => {\n const server = net.createServer()\n server.once('error', () => resolve(false))\n server.once('listening', () => {\n server.close()\n resolve(true)\n })\n server.listen(port, host)\n })\n}\n\nexport async function runAgentStart({ port, host, configPath, allowWrite, allowAll, version }: AgentStartOptions): Promise<void> {\n const hrStart = process.hrtime()\n\n try {\n // Load .env file into process.env using Node.js built-in (v20.12.0+)\n try {\n process.loadEnvFile()\n } catch {\n // .env file may not exist; ignore\n }\n\n // Resolve the @kubb/agent package path\n const agentPkgUrl = import.meta.resolve('@kubb/agent/package.json')\n const agentPkgPath = fileURLToPath(agentPkgUrl)\n const agentDir = path.dirname(agentPkgPath)\n const serverPath = path.join(agentDir, agentDefaults.serverEntryPath)\n\n const resolvedEnv = resolveAgentStartEnvironment({ port, host, configPath, allowWrite, allowAll })\n const numericPort = Number(resolvedEnv.port)\n\n if (!Number.isInteger(numericPort) || numericPort <= 0) {\n throw new Error(`Invalid port \"${resolvedEnv.port}\". Provide a positive integer with --port or PORT.`)\n }\n\n clack.log.step(styleText('cyan', 'Starting agent server...'))\n clack.log.info(styleText('dim', `Config: ${resolvedEnv.agentConfigPath}`))\n clack.log.info(styleText('dim', `Host: ${resolvedEnv.host}`))\n clack.log.info(styleText('dim', `Port: ${resolvedEnv.port}`))\n if (!resolvedEnv.allowWrite && !resolvedEnv.allowAll) {\n clack.log.warn(styleText('yellow', 'Filesystem writes disabled. Use --allow-write or --allow-all to enable.'))\n }\n\n if (!(await isPortAvailable(numericPort, resolvedEnv.host))) {\n clack.log.error(
|
|
1
|
+
{"version":3,"file":"agent-CWitLsL9.cjs","names":["process","agentDefaults","path","net","spawnAsync","sendTelemetry","buildTelemetryEvent"],"sources":["../src/runners/agent.ts"],"sourcesContent":["import net from 'node:net'\nimport path from 'node:path'\nimport * as process from 'node:process'\nimport { fileURLToPath } from 'node:url'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { spawnAsync } from '@internals/utils'\nimport { agentDefaults } from '../constants.ts'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\ntype AgentStartOptions = {\n port: string | undefined\n host: string\n configPath: string | undefined\n allowWrite: boolean\n allowAll: boolean\n version: string\n}\n\ntype ResolvedAgentStartEnvironment = {\n port: string\n host: string\n allowWrite: boolean\n allowAll: boolean\n agentConfigPath: string\n env: NodeJS.ProcessEnv\n}\n\n/**\n * Resolves the environment passed to the detached agent process using CLI values first, then environment values, then CLI defaults.\n */\nfunction resolveAgentStartEnvironment({ port, host, configPath, allowWrite, allowAll }: Omit<AgentStartOptions, 'version'>): ResolvedAgentStartEnvironment {\n const resolvedPort = port ?? process.env.PORT ?? agentDefaults.port\n const resolvedHost = host !== agentDefaults.host ? host : (process.env.HOST ?? agentDefaults.host)\n const resolvedAllowAll = allowAll || process.env.KUBB_AGENT_ALLOW_ALL === 'true'\n const resolvedAllowWrite = resolvedAllowAll || allowWrite || process.env.KUBB_AGENT_ALLOW_WRITE === 'true'\n const agentRoot = process.env.KUBB_AGENT_ROOT ?? process.cwd()\n const agentConfigPath = path.resolve(process.cwd(), configPath || process.env.KUBB_AGENT_CONFIG || agentDefaults.configFile)\n\n return {\n port: resolvedPort,\n host: resolvedHost,\n allowWrite: resolvedAllowWrite,\n allowAll: resolvedAllowAll,\n agentConfigPath,\n env: {\n ...process.env,\n PORT: resolvedPort,\n HOST: resolvedHost,\n KUBB_AGENT_ROOT: agentRoot,\n KUBB_AGENT_CONFIG: agentConfigPath,\n KUBB_AGENT_ALLOW_WRITE: String(resolvedAllowWrite),\n KUBB_AGENT_ALLOW_ALL: String(resolvedAllowAll),\n KUBB_AGENT_TOKEN: process.env.KUBB_AGENT_TOKEN,\n KUBB_AGENT_RETRY_TIMEOUT: process.env.KUBB_AGENT_RETRY_TIMEOUT ?? agentDefaults.retryTimeout,\n KUBB_STUDIO_URL: process.env.KUBB_STUDIO_URL ?? agentDefaults.studioUrl,\n },\n }\n}\n\nfunction isPortAvailable(port: number, host: string): Promise<boolean> {\n return new Promise((resolve) => {\n const server = net.createServer()\n server.once('error', () => resolve(false))\n server.once('listening', () => {\n server.close()\n resolve(true)\n })\n server.listen(port, host)\n })\n}\n\nexport async function runAgentStart({ port, host, configPath, allowWrite, allowAll, version }: AgentStartOptions): Promise<void> {\n const hrStart = process.hrtime()\n\n try {\n // Load .env file into process.env using Node.js built-in (v20.12.0+)\n try {\n process.loadEnvFile()\n } catch {\n // .env file may not exist; ignore\n }\n\n // Resolve the @kubb/agent package path\n const agentPkgUrl = import.meta.resolve('@kubb/agent/package.json')\n const agentPkgPath = fileURLToPath(agentPkgUrl)\n const agentDir = path.dirname(agentPkgPath)\n const serverPath = path.join(agentDir, agentDefaults.serverEntryPath)\n\n const resolvedEnv = resolveAgentStartEnvironment({ port, host, configPath, allowWrite, allowAll })\n const numericPort = Number(resolvedEnv.port)\n\n if (!Number.isInteger(numericPort) || numericPort <= 0) {\n throw new Error(`Invalid port \"${resolvedEnv.port}\". Provide a positive integer with --port or PORT.`)\n }\n\n clack.log.step(styleText('cyan', 'Starting agent server...'))\n clack.log.info(styleText('dim', `Config: ${resolvedEnv.agentConfigPath}`))\n clack.log.info(styleText('dim', `Host: ${resolvedEnv.host}`))\n clack.log.info(styleText('dim', `Port: ${resolvedEnv.port}`))\n if (!resolvedEnv.allowWrite && !resolvedEnv.allowAll) {\n clack.log.warn(styleText('yellow', 'Filesystem writes disabled. Use --allow-write or --allow-all to enable.'))\n }\n\n if (!(await isPortAvailable(numericPort, resolvedEnv.host))) {\n clack.log.error(styleText('red', `Port ${resolvedEnv.port} is already in use. Stop the existing process or choose a different port with --port.`))\n process.exit(1)\n }\n\n // Spawns the server as a detached background process so the CLI can exit independently.\n await spawnAsync('node', [serverPath], {\n env: resolvedEnv.env,\n cwd: process.cwd(),\n })\n\n await sendTelemetry(buildTelemetryEvent({ command: 'agent', kubbVersion: version, hrStart, status: 'success' }))\n } catch (error) {\n await sendTelemetry(buildTelemetryEvent({ command: 'agent', kubbVersion: version, hrStart, status: 'failed' }))\n clack.log.error(styleText('red', 'Failed to start agent server'))\n console.error(error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,SAAS,6BAA6B,EAAE,MAAM,MAAM,YAAY,YAAY,YAA+E;CACzJ,MAAM,eAAe,QAAQA,aAAQ,IAAI,QAAQC,kBAAAA,cAAc;CAC/D,MAAM,eAAe,SAASA,kBAAAA,cAAc,OAAO,OAAQD,aAAQ,IAAI,QAAQC,kBAAAA,cAAc;CAC7F,MAAM,mBAAmB,YAAYD,aAAQ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ByKO4r7w.cjs");
|
|
2
2
|
const require_define = require("./define-Bdn8j5VM.cjs");
|
|
3
|
-
const require_package = require("./package-
|
|
3
|
+
const require_package = require("./package-CFbqPfx6.cjs");
|
|
4
4
|
const require_constants = require("./constants-D0XHAHeZ.cjs");
|
|
5
5
|
//#region src/commands/agent/start.ts
|
|
6
6
|
const command$1 = require_define.defineCommand({
|
|
@@ -55,4 +55,4 @@ const command = require_define.defineCommand({
|
|
|
55
55
|
//#endregion
|
|
56
56
|
exports.command = command;
|
|
57
57
|
|
|
58
|
-
//# sourceMappingURL=agent-
|
|
58
|
+
//# sourceMappingURL=agent-dAvD6Qlt.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-
|
|
1
|
+
{"version":3,"file":"agent-dAvD6Qlt.cjs","names":["command","defineCommand","agentDefaults","defineCommand","startCommand"],"sources":["../src/commands/agent/start.ts","../src/commands/agent.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../../package.json'\nimport { agentDefaults } from '../../constants.ts'\n\nexport const command = defineCommand({\n name: 'start',\n description: 'Start the Agent server',\n options: {\n config: { type: 'string', description: 'Path to the Kubb config', short: 'c' },\n port: { type: 'string', description: `Port for the server (default: ${agentDefaults.port})`, short: 'p' },\n host: { type: 'string', description: 'Host for the server', default: agentDefaults.host },\n 'allow-write': {\n type: 'boolean',\n description: 'Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.',\n default: false,\n },\n 'allow-all': { type: 'boolean', description: 'Grant all permissions (implies --allow-write).', default: false },\n },\n async run({ values }) {\n const { runAgentStart } = await import('../../runners/agent.ts')\n\n await runAgentStart({\n port: values.port !== undefined ? values.port : undefined,\n host: values.host,\n configPath: values.config,\n allowWrite: values['allow-write'],\n allowAll: values['allow-all'],\n version,\n })\n },\n})\n","import { defineCommand } from '@internals/utils'\nimport { command as startCommand } from './agent/start.ts'\n\nexport const command = defineCommand({\n name: 'agent',\n description: 'Manage the Kubb Agent server',\n subCommands: [startCommand],\n})\n"],"mappings":";;;;;AAIA,MAAaA,YAAUC,eAAAA,cAAc;CACnC,MAAM;CACN,aAAa;CACb,SAAS;EACP,QAAQ;GAAE,MAAM;GAAU,aAAa;GAA2B,OAAO;GAAK;EAC9E,MAAM;GAAE,MAAM;GAAU,aAAa,iCAAiCC,kBAAAA,cAAc,KAAK;GAAI,OAAO;GAAK;EACzG,MAAM;GAAE,MAAM;GAAU,aAAa;GAAuB,SAASA,kBAAAA,cAAc;GAAM;EACzF,eAAe;GACb,MAAM;GACN,aAAa;GACb,SAAS;GACV;EACD,aAAa;GAAE,MAAM;GAAW,aAAa;GAAkD,SAAS;GAAO;EAChH;CACD,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,kBAAkB,MAAA,QAAA,SAAA,CAAA,WAAA,QAAM,uBAAA,CAAA;AAEhC,QAAM,cAAc;GAClB,MAAM,OAAO,SAAS,KAAA,IAAY,OAAO,OAAO,KAAA;GAChD,MAAM,OAAO;GACb,YAAY,OAAO;GACnB,YAAY,OAAO;GACnB,UAAU,OAAO;GACjB,SAAA,gBAAA;GACD,CAAC;;CAEL,CAAC;;;AC3BF,MAAa,UAAUC,eAAAA,cAAc;CACnC,MAAM;CACN,aAAa;CACb,aAAa,CAACC,UAAa;CAC5B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
2
|
import { n as defineCommand } from "./define-Ctii4bel.js";
|
|
3
|
-
import { t as version } from "./package-
|
|
3
|
+
import { t as version } from "./package-KJfRdbQA.js";
|
|
4
4
|
import { o as agentDefaults } from "./constants-DJM9zCXm.js";
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/commands/agent.ts
|
|
@@ -53,4 +53,4 @@ const command = defineCommand({
|
|
|
53
53
|
//#endregion
|
|
54
54
|
export { command };
|
|
55
55
|
|
|
56
|
-
//# sourceMappingURL=agent-
|
|
56
|
+
//# sourceMappingURL=agent-gIWBobyC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-
|
|
1
|
+
{"version":3,"file":"agent-gIWBobyC.js","names":["command","startCommand"],"sources":["../src/commands/agent/start.ts","../src/commands/agent.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../../package.json'\nimport { agentDefaults } from '../../constants.ts'\n\nexport const command = defineCommand({\n name: 'start',\n description: 'Start the Agent server',\n options: {\n config: { type: 'string', description: 'Path to the Kubb config', short: 'c' },\n port: { type: 'string', description: `Port for the server (default: ${agentDefaults.port})`, short: 'p' },\n host: { type: 'string', description: 'Host for the server', default: agentDefaults.host },\n 'allow-write': {\n type: 'boolean',\n description: 'Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.',\n default: false,\n },\n 'allow-all': { type: 'boolean', description: 'Grant all permissions (implies --allow-write).', default: false },\n },\n async run({ values }) {\n const { runAgentStart } = await import('../../runners/agent.ts')\n\n await runAgentStart({\n port: values.port !== undefined ? values.port : undefined,\n host: values.host,\n configPath: values.config,\n allowWrite: values['allow-write'],\n allowAll: values['allow-all'],\n version,\n })\n },\n})\n","import { defineCommand } from '@internals/utils'\nimport { command as startCommand } from './agent/start.ts'\n\nexport const command = defineCommand({\n name: 'agent',\n description: 'Manage the Kubb Agent server',\n subCommands: [startCommand],\n})\n"],"mappings":";;;;;;ACGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,aAAa,CDFQ,cAAc;EACnC,MAAM;EACN,aAAa;EACb,SAAS;GACP,QAAQ;IAAE,MAAM;IAAU,aAAa;IAA2B,OAAO;IAAK;GAC9E,MAAM;IAAE,MAAM;IAAU,aAAa,iCAAiC,cAAc,KAAK;IAAI,OAAO;IAAK;GACzG,MAAM;IAAE,MAAM;IAAU,aAAa;IAAuB,SAAS,cAAc;IAAM;GACzF,eAAe;IACb,MAAM;IACN,aAAa;IACb,SAAS;IACV;GACD,aAAa;IAAE,MAAM;IAAW,aAAa;IAAkD,SAAS;IAAO;GAChH;EACD,MAAM,IAAI,EAAE,UAAU;GACpB,MAAM,EAAE,kBAAkB,MAAM,OAAO;AAEvC,SAAM,cAAc;IAClB,MAAM,OAAO,SAAS,KAAA,IAAY,OAAO,OAAO,KAAA;IAChD,MAAM,OAAO;IACb,YAAY,OAAO;IACnB,YAAY,OAAO;IACnB,UAAU,OAAO;IACjB;IACD,CAAC;;EAEL,CAAC,CCxB2B;CAC5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-poGbscec.js","names":["process"],"sources":["../src/runners/agent.ts"],"sourcesContent":["import net from 'node:net'\nimport path from 'node:path'\nimport * as process from 'node:process'\nimport { fileURLToPath } from 'node:url'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { spawnAsync } from '@internals/utils'\nimport { agentDefaults } from '../constants.ts'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\ntype AgentStartOptions = {\n port: string | undefined\n host: string\n configPath: string | undefined\n allowWrite: boolean\n allowAll: boolean\n version: string\n}\n\ntype ResolvedAgentStartEnvironment = {\n port: string\n host: string\n allowWrite: boolean\n allowAll: boolean\n agentConfigPath: string\n env: NodeJS.ProcessEnv\n}\n\n/**\n * Resolves the environment passed to the detached agent process using CLI values first, then environment values, then CLI defaults.\n */\nfunction resolveAgentStartEnvironment({ port, host, configPath, allowWrite, allowAll }: Omit<AgentStartOptions, 'version'>): ResolvedAgentStartEnvironment {\n const resolvedPort = port ?? process.env.PORT ?? agentDefaults.port\n const resolvedHost = host !== agentDefaults.host ? host : (process.env.HOST ?? agentDefaults.host)\n const resolvedAllowAll = allowAll || process.env.KUBB_AGENT_ALLOW_ALL === 'true'\n const resolvedAllowWrite = resolvedAllowAll || allowWrite || process.env.KUBB_AGENT_ALLOW_WRITE === 'true'\n const agentRoot = process.env.KUBB_AGENT_ROOT ?? process.cwd()\n const agentConfigPath = path.resolve(process.cwd(), configPath || process.env.KUBB_AGENT_CONFIG || agentDefaults.configFile)\n\n return {\n port: resolvedPort,\n host: resolvedHost,\n allowWrite: resolvedAllowWrite,\n allowAll: resolvedAllowAll,\n agentConfigPath,\n env: {\n ...process.env,\n PORT: resolvedPort,\n HOST: resolvedHost,\n KUBB_AGENT_ROOT: agentRoot,\n KUBB_AGENT_CONFIG: agentConfigPath,\n KUBB_AGENT_ALLOW_WRITE: String(resolvedAllowWrite),\n KUBB_AGENT_ALLOW_ALL: String(resolvedAllowAll),\n KUBB_AGENT_TOKEN: process.env.KUBB_AGENT_TOKEN,\n KUBB_AGENT_RETRY_TIMEOUT: process.env.KUBB_AGENT_RETRY_TIMEOUT ?? agentDefaults.retryTimeout,\n KUBB_STUDIO_URL: process.env.KUBB_STUDIO_URL ?? agentDefaults.studioUrl,\n },\n }\n}\n\nfunction isPortAvailable(port: number, host: string): Promise<boolean> {\n return new Promise((resolve) => {\n const server = net.createServer()\n server.once('error', () => resolve(false))\n server.once('listening', () => {\n server.close()\n resolve(true)\n })\n server.listen(port, host)\n })\n}\n\nexport async function runAgentStart({ port, host, configPath, allowWrite, allowAll, version }: AgentStartOptions): Promise<void> {\n const hrStart = process.hrtime()\n\n try {\n // Load .env file into process.env using Node.js built-in (v20.12.0+)\n try {\n process.loadEnvFile()\n } catch {\n // .env file may not exist; ignore\n }\n\n // Resolve the @kubb/agent package path\n const agentPkgUrl = import.meta.resolve('@kubb/agent/package.json')\n const agentPkgPath = fileURLToPath(agentPkgUrl)\n const agentDir = path.dirname(agentPkgPath)\n const serverPath = path.join(agentDir, agentDefaults.serverEntryPath)\n\n const resolvedEnv = resolveAgentStartEnvironment({ port, host, configPath, allowWrite, allowAll })\n const numericPort = Number(resolvedEnv.port)\n\n if (!Number.isInteger(numericPort) || numericPort <= 0) {\n throw new Error(`Invalid port \"${resolvedEnv.port}\". Provide a positive integer with --port or PORT.`)\n }\n\n clack.log.step(styleText('cyan', 'Starting agent server...'))\n clack.log.info(styleText('dim', `Config: ${resolvedEnv.agentConfigPath}`))\n clack.log.info(styleText('dim', `Host: ${resolvedEnv.host}`))\n clack.log.info(styleText('dim', `Port: ${resolvedEnv.port}`))\n if (!resolvedEnv.allowWrite && !resolvedEnv.allowAll) {\n clack.log.warn(styleText('yellow', 'Filesystem writes disabled. Use --allow-write or --allow-all to enable.'))\n }\n\n if (!(await isPortAvailable(numericPort, resolvedEnv.host))) {\n clack.log.error(
|
|
1
|
+
{"version":3,"file":"agent-poGbscec.js","names":["process"],"sources":["../src/runners/agent.ts"],"sourcesContent":["import net from 'node:net'\nimport path from 'node:path'\nimport * as process from 'node:process'\nimport { fileURLToPath } from 'node:url'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { spawnAsync } from '@internals/utils'\nimport { agentDefaults } from '../constants.ts'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\ntype AgentStartOptions = {\n port: string | undefined\n host: string\n configPath: string | undefined\n allowWrite: boolean\n allowAll: boolean\n version: string\n}\n\ntype ResolvedAgentStartEnvironment = {\n port: string\n host: string\n allowWrite: boolean\n allowAll: boolean\n agentConfigPath: string\n env: NodeJS.ProcessEnv\n}\n\n/**\n * Resolves the environment passed to the detached agent process using CLI values first, then environment values, then CLI defaults.\n */\nfunction resolveAgentStartEnvironment({ port, host, configPath, allowWrite, allowAll }: Omit<AgentStartOptions, 'version'>): ResolvedAgentStartEnvironment {\n const resolvedPort = port ?? process.env.PORT ?? agentDefaults.port\n const resolvedHost = host !== agentDefaults.host ? host : (process.env.HOST ?? agentDefaults.host)\n const resolvedAllowAll = allowAll || process.env.KUBB_AGENT_ALLOW_ALL === 'true'\n const resolvedAllowWrite = resolvedAllowAll || allowWrite || process.env.KUBB_AGENT_ALLOW_WRITE === 'true'\n const agentRoot = process.env.KUBB_AGENT_ROOT ?? process.cwd()\n const agentConfigPath = path.resolve(process.cwd(), configPath || process.env.KUBB_AGENT_CONFIG || agentDefaults.configFile)\n\n return {\n port: resolvedPort,\n host: resolvedHost,\n allowWrite: resolvedAllowWrite,\n allowAll: resolvedAllowAll,\n agentConfigPath,\n env: {\n ...process.env,\n PORT: resolvedPort,\n HOST: resolvedHost,\n KUBB_AGENT_ROOT: agentRoot,\n KUBB_AGENT_CONFIG: agentConfigPath,\n KUBB_AGENT_ALLOW_WRITE: String(resolvedAllowWrite),\n KUBB_AGENT_ALLOW_ALL: String(resolvedAllowAll),\n KUBB_AGENT_TOKEN: process.env.KUBB_AGENT_TOKEN,\n KUBB_AGENT_RETRY_TIMEOUT: process.env.KUBB_AGENT_RETRY_TIMEOUT ?? agentDefaults.retryTimeout,\n KUBB_STUDIO_URL: process.env.KUBB_STUDIO_URL ?? agentDefaults.studioUrl,\n },\n }\n}\n\nfunction isPortAvailable(port: number, host: string): Promise<boolean> {\n return new Promise((resolve) => {\n const server = net.createServer()\n server.once('error', () => resolve(false))\n server.once('listening', () => {\n server.close()\n resolve(true)\n })\n server.listen(port, host)\n })\n}\n\nexport async function runAgentStart({ port, host, configPath, allowWrite, allowAll, version }: AgentStartOptions): Promise<void> {\n const hrStart = process.hrtime()\n\n try {\n // Load .env file into process.env using Node.js built-in (v20.12.0+)\n try {\n process.loadEnvFile()\n } catch {\n // .env file may not exist; ignore\n }\n\n // Resolve the @kubb/agent package path\n const agentPkgUrl = import.meta.resolve('@kubb/agent/package.json')\n const agentPkgPath = fileURLToPath(agentPkgUrl)\n const agentDir = path.dirname(agentPkgPath)\n const serverPath = path.join(agentDir, agentDefaults.serverEntryPath)\n\n const resolvedEnv = resolveAgentStartEnvironment({ port, host, configPath, allowWrite, allowAll })\n const numericPort = Number(resolvedEnv.port)\n\n if (!Number.isInteger(numericPort) || numericPort <= 0) {\n throw new Error(`Invalid port \"${resolvedEnv.port}\". Provide a positive integer with --port or PORT.`)\n }\n\n clack.log.step(styleText('cyan', 'Starting agent server...'))\n clack.log.info(styleText('dim', `Config: ${resolvedEnv.agentConfigPath}`))\n clack.log.info(styleText('dim', `Host: ${resolvedEnv.host}`))\n clack.log.info(styleText('dim', `Port: ${resolvedEnv.port}`))\n if (!resolvedEnv.allowWrite && !resolvedEnv.allowAll) {\n clack.log.warn(styleText('yellow', 'Filesystem writes disabled. Use --allow-write or --allow-all to enable.'))\n }\n\n if (!(await isPortAvailable(numericPort, resolvedEnv.host))) {\n clack.log.error(styleText('red', `Port ${resolvedEnv.port} is already in use. Stop the existing process or choose a different port with --port.`))\n process.exit(1)\n }\n\n // Spawns the server as a detached background process so the CLI can exit independently.\n await spawnAsync('node', [serverPath], {\n env: resolvedEnv.env,\n cwd: process.cwd(),\n })\n\n await sendTelemetry(buildTelemetryEvent({ command: 'agent', kubbVersion: version, hrStart, status: 'success' }))\n } catch (error) {\n await sendTelemetry(buildTelemetryEvent({ command: 'agent', kubbVersion: version, hrStart, status: 'failed' }))\n clack.log.error(styleText('red', 'Failed to start agent server'))\n console.error(error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA+BA,SAAS,6BAA6B,EAAE,MAAM,MAAM,YAAY,YAAY,YAA+E;CACzJ,MAAM,eAAe,QAAQA,UAAQ,IAAI,QAAQ,cAAc;CAC/D,MAAM,eAAe,SAAS,cAAc,OAAO,OAAQA,UAAQ,IAAI,QAAQ,cAAc;CAC7F,MAAM,mBAAmB,YAAYA,UAAQ,IAAI,yBAAyB;CAC1E,MAAM,qBAAqB,oBAAoB,cAAcA,UAAQ,IAAI,2BAA2B;CACpG,MAAM,YAAYA,UAAQ,IAAI,mBAAmBA,UAAQ,KAAK;CAC9D,MAAM,kBAAkB,KAAK,QAAQA,UAAQ,KAAK,EAAE,cAAcA,UAAQ,IAAI,qBAAqB,cAAc,WAAW;AAE5H,QAAO;EACL,MAAM;EACN,MAAM;EACN,YAAY;EACZ,UAAU;EACV;EACA,KAAK;GACH,GAAGA,UAAQ;GACX,MAAM;GACN,MAAM;GACN,iBAAiB;GACjB,mBAAmB;GACnB,wBAAwB,OAAO,mBAAmB;GAClD,sBAAsB,OAAO,iBAAiB;GAC9C,kBAAkBA,U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YAAY,KAAK,EAAG;AAC3D,SAAM,IAAI,MAAM,UAAU,OAAO,QAAQ,YAAY,KAAK,uFAAuF,CAAC;AAClJ,aAAQ,KAAK,EAAE;;AAIjB,QAAM,WAAW,QAAQ,CAAC,WAAW,EAAE;GACrC,KAAK,YAAY;GACjB,KAAKA,UAAQ,KAAK;GACnB,CAAC;AAEF,QAAM,cAAc,oBAAoB;GAAE,SAAS;GAAS,aAAa;GAAS;GAAS,QAAQ;GAAW,CAAC,CAAC;UACzG,OAAO;AACd,QAAM,cAAc,oBAAoB;GAAE,SAAS;GAAS,aAAa;GAAS;GAAS,QAAQ;GAAU,CAAC,CAAC;AAC/G,QAAM,IAAI,MAAM,UAAU,OAAO,+BAA+B,CAAC;AACjE,UAAQ,MAAM,MAAM;AACpB,YAAQ,KAAK,EAAE"}
|
|
@@ -2,12 +2,12 @@ import "./chunk--u3MIqq1.js";
|
|
|
2
2
|
import { n as toCause, r as toError } from "./errors-CjPmyZHy.js";
|
|
3
3
|
import { a as canUseTTY, i as executeIfOnline, o as isGitHubActions, r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-CBISr5w4.js";
|
|
4
4
|
import { n as tokenize } from "./shell-DLzN4fRo.js";
|
|
5
|
-
import { t as version } from "./package-
|
|
5
|
+
import { t as version } from "./package-KJfRdbQA.js";
|
|
6
6
|
import { a as WATCHER_IGNORED_PATHS, i as SUMMARY_SEPARATOR, t as KUBB_NPM_PACKAGE_URL } from "./constants-DJM9zCXm.js";
|
|
7
7
|
import { styleText } from "node:util";
|
|
8
8
|
import { EventEmitter } from "node:events";
|
|
9
|
-
import { spawn } from "node:child_process";
|
|
10
9
|
import { createHash } from "node:crypto";
|
|
10
|
+
import { spawn } from "node:child_process";
|
|
11
11
|
import "node:fs";
|
|
12
12
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
13
13
|
import path, { dirname, relative, resolve } from "node:path";
|
|
@@ -125,130 +125,6 @@ var AsyncEventEmitter = class {
|
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
127
|
//#endregion
|
|
128
|
-
//#region ../../internals/utils/src/formatters.ts
|
|
129
|
-
/**
|
|
130
|
-
* CLI command descriptors for each supported code formatter.
|
|
131
|
-
*
|
|
132
|
-
* Each entry contains the executable `command`, an `args` factory that maps an
|
|
133
|
-
* output path to the correct argument list, and an `errorMessage` shown when
|
|
134
|
-
* the formatter is not found.
|
|
135
|
-
*/
|
|
136
|
-
const formatters = {
|
|
137
|
-
prettier: {
|
|
138
|
-
command: "prettier",
|
|
139
|
-
args: (outputPath) => [
|
|
140
|
-
"--ignore-unknown",
|
|
141
|
-
"--write",
|
|
142
|
-
outputPath
|
|
143
|
-
],
|
|
144
|
-
errorMessage: "Prettier not found"
|
|
145
|
-
},
|
|
146
|
-
biome: {
|
|
147
|
-
command: "biome",
|
|
148
|
-
args: (outputPath) => [
|
|
149
|
-
"format",
|
|
150
|
-
"--write",
|
|
151
|
-
outputPath
|
|
152
|
-
],
|
|
153
|
-
errorMessage: "Biome not found"
|
|
154
|
-
},
|
|
155
|
-
oxfmt: {
|
|
156
|
-
command: "oxfmt",
|
|
157
|
-
args: (outputPath) => [outputPath],
|
|
158
|
-
errorMessage: "Oxfmt not found"
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
async function isFormatterAvailable(formatter) {
|
|
162
|
-
return new Promise((resolve) => {
|
|
163
|
-
const child = spawn(formatter, ["--version"], { stdio: "ignore" });
|
|
164
|
-
child.on("close", (code) => resolve(code === 0));
|
|
165
|
-
child.on("error", () => resolve(false));
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Detects the first available code formatter on the current system.
|
|
170
|
-
*
|
|
171
|
-
* - Checks in preference order: `biome`, `oxfmt`, `prettier`.
|
|
172
|
-
* - Returns `null` when none are found.
|
|
173
|
-
*
|
|
174
|
-
* @example
|
|
175
|
-
* ```ts
|
|
176
|
-
* const formatter = await detectFormatter()
|
|
177
|
-
* if (formatter) {
|
|
178
|
-
* console.log(`Using ${formatter} for formatting`)
|
|
179
|
-
* }
|
|
180
|
-
* ```
|
|
181
|
-
*/
|
|
182
|
-
async function detectFormatter() {
|
|
183
|
-
const formatterNames = new Set([
|
|
184
|
-
"biome",
|
|
185
|
-
"oxfmt",
|
|
186
|
-
"prettier"
|
|
187
|
-
]);
|
|
188
|
-
for (const formatter of formatterNames) if (await isFormatterAvailable(formatter)) return formatter;
|
|
189
|
-
return null;
|
|
190
|
-
}
|
|
191
|
-
//#endregion
|
|
192
|
-
//#region ../../internals/utils/src/linters.ts
|
|
193
|
-
/**
|
|
194
|
-
* CLI command descriptors for each supported linter.
|
|
195
|
-
*
|
|
196
|
-
* Each entry contains the executable `command`, an `args` factory that maps an
|
|
197
|
-
* output path to the correct argument list, and an `errorMessage` shown when
|
|
198
|
-
* the linter is not found.
|
|
199
|
-
*/
|
|
200
|
-
const linters = {
|
|
201
|
-
eslint: {
|
|
202
|
-
command: "eslint",
|
|
203
|
-
args: (outputPath) => [outputPath, "--fix"],
|
|
204
|
-
errorMessage: "Eslint not found"
|
|
205
|
-
},
|
|
206
|
-
biome: {
|
|
207
|
-
command: "biome",
|
|
208
|
-
args: (outputPath) => [
|
|
209
|
-
"lint",
|
|
210
|
-
"--fix",
|
|
211
|
-
outputPath
|
|
212
|
-
],
|
|
213
|
-
errorMessage: "Biome not found"
|
|
214
|
-
},
|
|
215
|
-
oxlint: {
|
|
216
|
-
command: "oxlint",
|
|
217
|
-
args: (outputPath) => ["--fix", outputPath],
|
|
218
|
-
errorMessage: "Oxlint not found"
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
async function isLinterAvailable(linter) {
|
|
222
|
-
return new Promise((resolve) => {
|
|
223
|
-
const child = spawn(linter, ["--version"], { stdio: "ignore" });
|
|
224
|
-
child.on("close", (code) => resolve(code === 0));
|
|
225
|
-
child.on("error", () => resolve(false));
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Detects the first available linter on the current system.
|
|
230
|
-
*
|
|
231
|
-
* - Checks in preference order: `biome`, `oxlint`, `eslint`.
|
|
232
|
-
* - Returns `null` when none are found.
|
|
233
|
-
*
|
|
234
|
-
* @example
|
|
235
|
-
* ```ts
|
|
236
|
-
* const linter = await detectLinter()
|
|
237
|
-
* if (linter) {
|
|
238
|
-
* console.log(`Using ${linter} for linting`)
|
|
239
|
-
* }
|
|
240
|
-
* ```
|
|
241
|
-
*/
|
|
242
|
-
async function detectLinter() {
|
|
243
|
-
const linterNames = new Set([
|
|
244
|
-
"biome",
|
|
245
|
-
"oxlint",
|
|
246
|
-
"eslint"
|
|
247
|
-
]);
|
|
248
|
-
for (const linter of linterNames) if (await isLinterAvailable(linter)) return linter;
|
|
249
|
-
return null;
|
|
250
|
-
}
|
|
251
|
-
//#endregion
|
|
252
128
|
//#region ../../internals/utils/src/time.ts
|
|
253
129
|
/**
|
|
254
130
|
* Calculates elapsed time in milliseconds from a high-resolution `process.hrtime` start time.
|
|
@@ -415,6 +291,70 @@ function formatMsWithColor(ms) {
|
|
|
415
291
|
return styleText("red", formatted);
|
|
416
292
|
}
|
|
417
293
|
//#endregion
|
|
294
|
+
//#region ../../internals/utils/src/formatters.ts
|
|
295
|
+
/**
|
|
296
|
+
* CLI command descriptors for each supported code formatter.
|
|
297
|
+
*
|
|
298
|
+
* Each entry contains the executable `command`, an `args` factory that maps an
|
|
299
|
+
* output path to the correct argument list, and an `errorMessage` shown when
|
|
300
|
+
* the formatter is not found.
|
|
301
|
+
*/
|
|
302
|
+
const formatters = {
|
|
303
|
+
prettier: {
|
|
304
|
+
command: "prettier",
|
|
305
|
+
args: (outputPath) => [
|
|
306
|
+
"--ignore-unknown",
|
|
307
|
+
"--write",
|
|
308
|
+
outputPath
|
|
309
|
+
],
|
|
310
|
+
errorMessage: "Prettier not found"
|
|
311
|
+
},
|
|
312
|
+
biome: {
|
|
313
|
+
command: "biome",
|
|
314
|
+
args: (outputPath) => [
|
|
315
|
+
"format",
|
|
316
|
+
"--write",
|
|
317
|
+
outputPath
|
|
318
|
+
],
|
|
319
|
+
errorMessage: "Biome not found"
|
|
320
|
+
},
|
|
321
|
+
oxfmt: {
|
|
322
|
+
command: "oxfmt",
|
|
323
|
+
args: (outputPath) => [outputPath],
|
|
324
|
+
errorMessage: "Oxfmt not found"
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
async function isFormatterAvailable(formatter) {
|
|
328
|
+
return new Promise((resolve) => {
|
|
329
|
+
const child = spawn(formatter, ["--version"], { stdio: "ignore" });
|
|
330
|
+
child.on("close", (code) => resolve(code === 0));
|
|
331
|
+
child.on("error", () => resolve(false));
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Detects the first available code formatter on the current system.
|
|
336
|
+
*
|
|
337
|
+
* - Checks in preference order: `biome`, `oxfmt`, `prettier`.
|
|
338
|
+
* - Returns `null` when none are found.
|
|
339
|
+
*
|
|
340
|
+
* @example
|
|
341
|
+
* ```ts
|
|
342
|
+
* const formatter = await detectFormatter()
|
|
343
|
+
* if (formatter) {
|
|
344
|
+
* console.log(`Using ${formatter} for formatting`)
|
|
345
|
+
* }
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
async function detectFormatter() {
|
|
349
|
+
const formatterNames = new Set([
|
|
350
|
+
"biome",
|
|
351
|
+
"oxfmt",
|
|
352
|
+
"prettier"
|
|
353
|
+
]);
|
|
354
|
+
for (const formatter of formatterNames) if (await isFormatterAvailable(formatter)) return formatter;
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
//#endregion
|
|
418
358
|
//#region ../../internals/utils/src/fs.ts
|
|
419
359
|
/**
|
|
420
360
|
* Writes `data` to `path`, trimming leading/trailing whitespace before saving.
|
|
@@ -452,6 +392,66 @@ async function write(path, data, options = {}) {
|
|
|
452
392
|
return trimmed;
|
|
453
393
|
}
|
|
454
394
|
//#endregion
|
|
395
|
+
//#region ../../internals/utils/src/linters.ts
|
|
396
|
+
/**
|
|
397
|
+
* CLI command descriptors for each supported linter.
|
|
398
|
+
*
|
|
399
|
+
* Each entry contains the executable `command`, an `args` factory that maps an
|
|
400
|
+
* output path to the correct argument list, and an `errorMessage` shown when
|
|
401
|
+
* the linter is not found.
|
|
402
|
+
*/
|
|
403
|
+
const linters = {
|
|
404
|
+
eslint: {
|
|
405
|
+
command: "eslint",
|
|
406
|
+
args: (outputPath) => [outputPath, "--fix"],
|
|
407
|
+
errorMessage: "Eslint not found"
|
|
408
|
+
},
|
|
409
|
+
biome: {
|
|
410
|
+
command: "biome",
|
|
411
|
+
args: (outputPath) => [
|
|
412
|
+
"lint",
|
|
413
|
+
"--fix",
|
|
414
|
+
outputPath
|
|
415
|
+
],
|
|
416
|
+
errorMessage: "Biome not found"
|
|
417
|
+
},
|
|
418
|
+
oxlint: {
|
|
419
|
+
command: "oxlint",
|
|
420
|
+
args: (outputPath) => ["--fix", outputPath],
|
|
421
|
+
errorMessage: "Oxlint not found"
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
async function isLinterAvailable(linter) {
|
|
425
|
+
return new Promise((resolve) => {
|
|
426
|
+
const child = spawn(linter, ["--version"], { stdio: "ignore" });
|
|
427
|
+
child.on("close", (code) => resolve(code === 0));
|
|
428
|
+
child.on("error", () => resolve(false));
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Detects the first available linter on the current system.
|
|
433
|
+
*
|
|
434
|
+
* - Checks in preference order: `biome`, `oxlint`, `eslint`.
|
|
435
|
+
* - Returns `null` when none are found.
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```ts
|
|
439
|
+
* const linter = await detectLinter()
|
|
440
|
+
* if (linter) {
|
|
441
|
+
* console.log(`Using ${linter} for linting`)
|
|
442
|
+
* }
|
|
443
|
+
* ```
|
|
444
|
+
*/
|
|
445
|
+
async function detectLinter() {
|
|
446
|
+
const linterNames = new Set([
|
|
447
|
+
"biome",
|
|
448
|
+
"oxlint",
|
|
449
|
+
"eslint"
|
|
450
|
+
]);
|
|
451
|
+
for (const linter of linterNames) if (await isLinterAvailable(linter)) return linter;
|
|
452
|
+
return null;
|
|
453
|
+
}
|
|
454
|
+
//#endregion
|
|
455
455
|
//#region src/utils/getSummary.ts
|
|
456
456
|
function getSummary({ failedPlugins, filesCreated, status, hrStart, config, pluginTimings }) {
|
|
457
457
|
const duration = formatHrtime(hrStart);
|
|
@@ -1694,4 +1694,4 @@ async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, wa
|
|
|
1694
1694
|
//#endregion
|
|
1695
1695
|
export { runGenerateCommand };
|
|
1696
1696
|
|
|
1697
|
-
//# sourceMappingURL=generate-
|
|
1697
|
+
//# sourceMappingURL=generate-BuOyrlAd.js.map
|