diff --git a/src/cli.ts b/src/cli.ts index c945197..064818e 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,15 +1,26 @@ #!/usr/bin/env node import process from 'node:process' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import fs from 'node:fs' import chalk from 'chalk' import { Command } from 'commander' import { deployContract } from './lib/deploy' +const PKG_ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), '../') + +export function getVersion() { + const packageJsonPath = path.join(PKG_ROOT, 'package.json') + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString()) + return packageJson.version || '1.0.0' +} + const program = new Command() program .name('ao-deploy') .description('A CLI tool to deploy AO contracts') - .version('1.0.0') + .version(getVersion()) .argument('', 'Contract main file path to deploy') .option('-n, --name [name]', 'Name of contract to deploy', 'default') .option('-w, --wallet-path [walletPath]', 'Wallet JWK file path')