circomkit
circomkit copied to clipboard
feat: add `version` command
This can be used at the top:
import {version, name} from '../package.json';
Then, at the bottom:
new Command()
.name(name)
.version(version)
// ...
Not sure if that package.json can cause any trouble though, mixed comments on the web.
I don't know if the typescript compiler handles importing jsons differently than normal node.js but I did this on the circuitscan cli:
import {readFileSync} from 'node:fs';
import {dirname, join} from 'node:path';
import {fileURLToPath} from 'node:url';
// Recreate old common.js __dirname global
const __dirname = dirname(fileURLToPath(import.meta.url));
function getPackageJson() {
return JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf8'));
}
program
.version(getPackageJson().version);
hmm, also people on the web (stackoverflow) advise against this (i.e. readFile to JSON.parse), thanks for the suggestion though! I will try a few things 🙏🏻