diff --git a/.changeset/smart-pugs-occur.md b/.changeset/smart-pugs-occur.md new file mode 100644 index 0000000000..1adcd3f75c --- /dev/null +++ b/.changeset/smart-pugs-occur.md @@ -0,0 +1,5 @@ +--- +"@wagmi/cli": minor +--- + +Updated CLI to use Incur. diff --git a/packages/cli/package.json b/packages/cli/package.json index 5bf0cd5ab9..7a7ad00cf0 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -69,7 +69,6 @@ "dependencies": { "abitype": "^1.1.1", "bundle-require": "^5.1.0", - "cac": "^6.7.14", "change-case": "^5.4.4", "chokidar": "4.0.1", "dedent": "^0.7.0", @@ -78,6 +77,7 @@ "esbuild": "~0.28.1", "escalade": "3.2.0", "fdir": "^6.1.1", + "incur": "^0.5.1", "nanospinner": "1.2.2", "pathe": "^1.1.2", "picocolors": "^1.0.0", diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 551543bb2b..ba3e264d70 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -1,53 +1,41 @@ #!/usr/bin/env node -import { cac } from 'cac' +import { Cli, z } from 'incur' -import { type Generate, generate } from './commands/generate.js' -import { type Init, init } from './commands/init.js' -import * as logger from './logger.js' +import { generate } from './commands/generate.js' +import { init } from './commands/init.js' import { version } from './version.js' -const cli = cac('wagmi') +try { + process.title = 'node (wagmi)' +} catch {} -cli - .command('generate', 'generate code based on configuration') - .option('-c, --config ', '[string] path to config file') - .option('-r, --root ', '[string] root path to resolve config from') - .option('-w, --watch', '[boolean] watch for changes') - .example((name) => `${name} generate`) - .action(async (options: Generate) => { - await generate(options) - if (!options.watch) process.exit(0) - }) +const commonOptions = { + config: z.string().optional().describe('Path to config file'), + root: z.string().optional().describe('Root path to resolve config from'), +} -cli - .command('init', 'create configuration file') - .option('-c, --config ', '[string] path to config file') - .option('-r, --root ', '[string] root path to resolve config from') - .example((name) => `${name} init`) - .action(async (options: Init) => { - await init(options) - process.exit(0) +const cli = Cli.create('wagmi', { + description: 'Manage and generate code from Ethereum ABIs', + version, +}) + .command('generate', { + alias: { config: 'c', root: 'r', watch: 'w' }, + description: 'Generate code based on configuration', + options: z.object({ + ...commonOptions, + watch: z.boolean().optional().describe('Watch for changes'), + }), + async run({ options }) { + await generate(options) + }, + }) + .command('init', { + alias: { config: 'c', root: 'r' }, + description: 'Create configuration file', + options: z.object(commonOptions), + async run({ options }) { + await init(options) + }, }) -cli.help() -cli.version(version) - -void (async () => { - try { - process.title = 'node (wagmi)' - } catch {} - - try { - // Parse CLI args without running command - cli.parse(process.argv, { run: false }) - if (!cli.matchedCommand) { - if (cli.args.length === 0) { - if (!cli.options.help && !cli.options.version) cli.outputHelp() - } else throw new Error(`Unknown command: ${cli.args.join(' ')}`) - } - await cli.runMatchedCommand() - } catch (error) { - logger.error(`\n${(error as Error).message}`) - process.exit(1) - } -})() +await cli.serve() diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3ad057fc08..1e44734f2c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -259,9 +259,6 @@ importers: bundle-require: specifier: ^5.1.0 version: 5.1.0(esbuild@0.28.1) - cac: - specifier: ^6.7.14 - version: 6.7.14 change-case: specifier: ^5.4.4 version: 5.4.4 @@ -286,6 +283,9 @@ importers: fdir: specifier: ^6.1.1 version: 6.1.1(picomatch@4.0.4) + incur: + specifier: ^0.5.1 + version: 0.5.1 nanospinner: specifier: 1.2.2 version: 1.2.2 @@ -2764,6 +2764,10 @@ packages: '@cfworker/json-schema': optional: true + '@modelcontextprotocol/server@2.0.0-alpha.4': + resolution: {integrity: sha512-/KEo3ZJ50HlagHp0lz2vPgfBZFtXHu6zTBXT9XqPc+4O9i4+IbBVWKq/a9yAfv/ifp0u3+mRo8SUk5kMKzhN8A==} + engines: {node: '>=20'} + '@mswjs/interceptors@0.35.9': resolution: {integrity: sha512-SSnyl/4ni/2ViHKkiZb8eajA/eN1DNFaHjhGiLUdZvDz6PKF4COSf/17xqSz64nOo2Ia29SA6B2KNCsyCbVmaQ==} engines: {node: '>=18'} @@ -4785,6 +4789,10 @@ packages: resolution: {integrity: sha512-CiGWIHgIaOdICpDxp05Jw3OPslWTu8AnL0PhrCT1xZgIO86NlMMLzkGbeycJ4FHpTjA999O791Oxp4bZPIjgHA==} deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info. + '@scalar/openapi-types@0.8.0': + resolution: {integrity: sha512-WmaxVSfvY5K/TwcG2B2TU1WOe1As1uc2s7myswtP6dBlcjU3hM08SApxv/jmyGaCE8t4gO5BBhmHY4pDUfmr2g==} + engines: {node: '>=22'} + '@scure/base@1.1.9': resolution: {integrity: sha512-8YKhl8GHiNI/pU2VMaofa2Tor7PJRAjwQLBBuilkJ9L5+13yVbC7JO/wS7piioAvPSwR3JKM1IJ/u4xQzbcXKg==} @@ -7975,6 +7983,11 @@ packages: engines: {node: '>=22'} hasBin: true + incur@0.5.1: + resolution: {integrity: sha512-gEwPg0Rwf+Oi8pwySLumYgWk//Xiv2wRJhwsOwVskt7ZHrfwFTR7oQmANnyDqudRYhqK3I5/dp489kPehPjIww==} + engines: {node: '>=22'} + hasBin: true + inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} @@ -13530,6 +13543,10 @@ snapshots: optionalDependencies: '@cfworker/json-schema': 4.1.1 + '@modelcontextprotocol/server@2.0.0-alpha.4': + dependencies: + zod: 4.3.6 + '@mswjs/interceptors@0.35.9': dependencies: '@open-draft/deferred-promise': 2.2.0 @@ -15444,6 +15461,8 @@ snapshots: transitivePeerDependencies: - encoding + '@scalar/openapi-types@0.8.0': {} + '@scure/base@1.1.9': {} '@scure/base@1.2.6': {} @@ -19860,6 +19879,16 @@ snapshots: yaml: 2.9.0 zod: 4.3.6 + incur@0.5.1: + dependencies: + '@cfworker/json-schema': 4.1.1 + '@modelcontextprotocol/server': 2.0.0-alpha.4 + '@scalar/openapi-types': 0.8.0 + '@toon-format/toon': 2.1.0 + tokenx: 1.3.0 + yaml: 2.9.0 + zod: 4.3.6 + inherits@2.0.4: {} ini@1.3.8: {}