Add name and version to main

This commit is contained in:
Marcus Eide
2020-03-03 10:13:59 +01:00
parent 39cd481040
commit 2c9db37275
+10
View File
@@ -1,5 +1,6 @@
import program from 'commander';
import chalk from 'chalk';
import fs from 'fs';
import createPluginCommand from './commands/createPlugin';
import watch from './commands/watch-deps';
import serve from './commands/serve';
@@ -9,6 +10,15 @@ process.on('unhandledRejection', err => {
});
const main = (argv: string[]) => {
const version = fs
.readFileSync('package.json', 'utf-8')
.split('\n')
.filter(row => row.match(/"version":/))
.join()
.match(/"version":\s"(?<version>\d\.\d\.\d)"/)?.groups?.version;
program.name('backstage-cli').version(version ?? '0.0.0');
program
.command('create-plugin')
.description('Creates a new plugin in the current repository')