/* eslint-disable no-console */ import {Command} from 'commander' import {version} from '../package.json' // Check if running via npx (not allowed - must be installed globally) function isRunningViaNpx(): boolean { const execPath = process.env.npm_execpath || '' const npmConfigPrefix = process.env.npm_config_prefix || '' const scriptPath = process.argv[1] || '' // Check for npx in the npm_execpath if (execPath.includes('npx')) { return true } // Check for npx cache directory patterns in the script path if ( scriptPath.includes('_npx') || scriptPath.includes('.npm/_npx') || scriptPath.includes('.pnpm') ) { return true } // Check if npm_config_prefix suggests a temporary npx installation if (npmConfigPrefix.includes('_npx')) { return true } return false } if (isRunningViaNpx()) { console.error('Error: antelope-cli must be installed globally.') console.error('') console.error('Please install it with:') console.error(' npm install -g @greymass/antelope-cli') console.error(' # or') console.error(' bun install -g @greymass/antelope-cli') console.error('') console.error('Then run it with:') console.error(' antelope-cli ') process.exit(1) } import {createContractCommand, generateContractFromCommand} from './commands/contract' import {generateKeysFromCommand} from './commands/keys/index' import {createChainCommand} from './commands/chain/index' import {createCompileCommand} from './commands/compile' import {createDevCommand} from './commands/dev' import {createWalletCommand} from './commands/wallet/index' import {createAccountCommand} from './commands/account' import {createTableCommand} from './commands/table' import {createSignCommand} from './commands/action' const program = new Command() program.version(version).name('antelope-cli').description('Antelope Command Line Utilities') // 1. Command to generate keys program .command('keys') .description('Generate a new set of public and private keys') .action(generateKeysFromCommand) // 2. Existing command to generate a contract program .command('generate') .description('Generate Contract Kit code for the named smart contract') .argument('[account]', 'The account name of the contract (e.g. "eosio.token")') .option('-f, --file [filename]', 'The path where the generated file will be saved') .option('-j, --json [json]', 'The path to a JSON file containing the contract ABI') .option('-e, --eslintrc [eslintrc]', 'The eslintrc file to use') .option( '-u, --url ', 'The URL of the API to connect with (e.g. "https://jungle4.greymass.com")', process.env.WHARFKIT_URL ) .action(generateContractFromCommand) // 3. Command to manage local blockchain program.addCommand(createChainCommand()) // 4. Command to compile contracts program.addCommand(createCompileCommand()) // 5. Command to manage contracts (deploy, etc) program.addCommand(createContractCommand()) // 6. Command for development mode program.addCommand(createDevCommand()) // 7. Command to manage wallet (includes account creation) program.addCommand(createWalletCommand()) // 8. Command to lookup account data program.addCommand(createAccountCommand()) // 9. Command to lookup table data (uses default chain) program.addCommand(createTableCommand()) // 10. Command to create signing requests program.addCommand(createSignCommand()) program.parse(process.argv)