From dd373ae301c9762020837ed247703732008bc84b Mon Sep 17 00:00:00 2001 From: Noah Litvin <335975+noahlitvin@users.noreply.github.com> Date: Fri, 27 Dec 2024 10:01:18 -0500 Subject: [PATCH] fix(cli): lint fix (#1605) --- packages/cli/src/index.ts | 135 ++++++++++++++++++++------------------ 1 file changed, 71 insertions(+), 64 deletions(-) diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 938a798f5..6cadd75be 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -101,7 +101,7 @@ function configureRun(program: Command) { return applyCommandsConfig(program, commandsConfig.run).action(async function ( packages: PackageSpecification[], options, - program, + program ) { log(bold('Starting local node...\n')); @@ -258,67 +258,74 @@ applyCommandsConfig(program.command('verify'), commandsConfig.verify).action(asy await verify(fullPackageRef, cliSettings, chainId); }); -applyCommandsConfig(program.command('diff'), commandsConfig.diff).action( - async function (packageRef, projectDirectory, options) { - const { diff } = await import('./commands/diff'); +applyCommandsConfig(program.command('diff'), commandsConfig.diff).action(async function ( + packageRef, + projectDirectory, + options +) { + const { diff } = await import('./commands/diff'); - const cliSettings = resolveCliSettings(options); - const { fullPackageRef, chainId } = await getPackageInfo(packageRef, options.chainId, cliSettings.rpcUrl); - - const foundDiffs = await diff( - fullPackageRef, - cliSettings, - chainId, - projectDirectory, - options.matchContract, - options.matchSource, - ); + const cliSettings = resolveCliSettings(options); + const { fullPackageRef, chainId } = await getPackageInfo(packageRef, options.chainId, cliSettings.rpcUrl); - // exit code is the number of differences found--useful for CI checks - process.exit(foundDiffs); - }, -); + const foundDiffs = await diff( + fullPackageRef, + cliSettings, + chainId, + projectDirectory, + options.matchContract, + options.matchSource + ); -applyCommandsConfig(program.command('alter'), commandsConfig.alter).action( - async function (packageName, command, options, flags) { - const { alter } = await import('./commands/alter'); + // exit code is the number of differences found--useful for CI checks + process.exit(foundDiffs); +}); - const cliSettings = resolveCliSettings(flags); +applyCommandsConfig(program.command('alter'), commandsConfig.alter).action(async function ( + packageName, + command, + options, + flags +) { + const { alter } = await import('./commands/alter'); - // throw an error if the chainId is not consistent with the provider's chainId - await ensureChainIdConsistency(cliSettings.rpcUrl, flags.chainId); - - // note: for command below, pkgInfo is empty because forge currently supplies no package.json or anything similar - const newUrl = await alter( - packageName, - flags.subpkg ? flags.subpkg.split(',') : [], - parseInt(flags.chainId), - cliSettings, - {}, - command, - options, - {}, - ); + const cliSettings = resolveCliSettings(flags); - log(newUrl); - }, -); + // throw an error if the chainId is not consistent with the provider's chainId + await ensureChainIdConsistency(cliSettings.rpcUrl, flags.chainId); -applyCommandsConfig(program.command('fetch'), commandsConfig.fetch).action( - async function (packageRef, givenIpfsUrl, options) { - const { fetch } = await import('./commands/fetch'); + // note: for command below, pkgInfo is empty because forge currently supplies no package.json or anything similar + const newUrl = await alter( + packageName, + flags.subpkg ? flags.subpkg.split(',') : [], + parseInt(flags.chainId), + cliSettings, + {}, + command, + options, + {} + ); - const { fullPackageRef, chainId } = await getPackageReference(packageRef, options.chainId); - const ipfsUrl = getIpfsUrl(givenIpfsUrl); - const metaIpfsUrl = getIpfsUrl(options.metaHash) || undefined; + log(newUrl); +}); - if (!ipfsUrl) { - throw new Error('IPFS URL is required.'); - } +applyCommandsConfig(program.command('fetch'), commandsConfig.fetch).action(async function ( + packageRef, + givenIpfsUrl, + options +) { + const { fetch } = await import('./commands/fetch'); + + const { fullPackageRef, chainId } = await getPackageReference(packageRef, options.chainId); + const ipfsUrl = getIpfsUrl(givenIpfsUrl); + const metaIpfsUrl = getIpfsUrl(options.metaHash) || undefined; - await fetch(fullPackageRef, chainId, ipfsUrl, metaIpfsUrl); - }, -); + if (!ipfsUrl) { + throw new Error('IPFS URL is required.'); + } + + await fetch(fullPackageRef, chainId, ipfsUrl, metaIpfsUrl); +}); applyCommandsConfig(program.command('pin'), commandsConfig.pin).action(async function (packageRef, options) { const cliSettings = resolveCliSettings(options); @@ -344,7 +351,7 @@ applyCommandsConfig(program.command('pin'), commandsConfig.pin).action(async fun applyCommandsConfig(program.command('publish'), commandsConfig.publish).action(async function ( packageRef, - options: { [opt: string]: string }, + options: { [opt: string]: string } ) { const { publish } = await import('./commands/publish'); @@ -421,8 +428,8 @@ applyCommandsConfig(program.command('publish'), commandsConfig.publish).action(a log(); log( gray( - `Package "${pkgRef.name}" not yet registered, please use "cannon register" to register your package first.\nYou need enough gas on Ethereum Mainnet to register the package on Cannon Registry`, - ), + `Package "${pkgRef.name}" not yet registered, please use "cannon register" to register your package first.\nYou need enough gas on Ethereum Mainnet to register the package on Cannon Registry` + ) ); log(); @@ -475,7 +482,7 @@ applyCommandsConfig(program.command('publish'), commandsConfig.publish).action(a }\n - Max Priority Fee Per Gas: ${ overrides.maxPriorityFeePerGas ? overrides.maxPriorityFeePerGas.toString() : 'default' }\n - Gas Limit: ${overrides.gasLimit ? overrides.gasLimit : 'default'}\n` + - " - To alter these settings use the parameters '--max-fee-per-gas', '--max-priority-fee-per-gas', '--gas-limit'.\n", + " - To alter these settings use the parameters '--max-fee-per-gas', '--max-priority-fee-per-gas', '--gas-limit'.\n" ); await publish({ @@ -527,7 +534,7 @@ applyCommandsConfig(program.command('inspect'), commandsConfig.inspect).action(a chainId, options.json ? 'json' : options.out, options.writeDeployments, - options.sources, + options.sources ); }); @@ -548,7 +555,7 @@ applyCommandsConfig(program.command('prune'), commandsConfig.prune).action(async storage, options.filterPackage?.split(',') || '', options.filterVariant?.split(',') || '', - options.keepAge, + options.keepAge ); if (pruneUrls.length) { @@ -635,9 +642,9 @@ applyCommandsConfig(program.command('test'), commandsConfig.test).action(async f warn( yellowBright( bold( - '⚠️ The `--` syntax for passing options to forge or anvil is deprecated. Please use `--forge.*` or `--anvil.*` instead.', - ), - ), + '⚠️ The `--` syntax for passing options to forge or anvil is deprecated. Please use `--forge.*` or `--anvil.*` instead.' + ) + ) ); log(); } @@ -702,14 +709,14 @@ applyCommandsConfig(program.command('interact'), commandsConfig.interact).action priorityGasFee: options.maxPriorityFee, }, resolver, - getMainLoader(cliSettings), + getMainLoader(cliSettings) ); const deployData = await runtime.readDeploy(fullPackageRef, runtime.chainId); if (!deployData) { throw new Error( - `deployment not found for package: ${fullPackageRef} with chaindId ${chainId}. please make sure it exists for the given preset and current network.`, + `deployment not found for package: ${fullPackageRef} with chaindId ${chainId}. please make sure it exists for the given preset and current network.` ); } @@ -717,7 +724,7 @@ applyCommandsConfig(program.command('interact'), commandsConfig.interact).action if (!outputs) { throw new Error( - `no cannon build found for ${fullPackageRef} with chaindId ${chainId}. Did you mean to run the package instead?`, + `no cannon build found for ${fullPackageRef} with chaindId ${chainId}. Did you mean to run the package instead?` ); }