Skip to content

Commit

Permalink
refactor: Use cli version from package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
pawanpaudel93 committed Mar 17, 2024
1 parent 8bc0c24 commit 649cd55
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
@@ -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('<contractPath>', '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')
Expand Down

0 comments on commit 649cd55

Please sign in to comment.