Skip to content

Commit

Permalink
fix(help): show version info with --version
Browse files Browse the repository at this point in the history
  • Loading branch information
blackfalcon committed Jun 11, 2021
1 parent bb4ffb0 commit 23d8bc6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
8 changes: 7 additions & 1 deletion bin/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ const parseArgs = () => {
const args = arg({
// Types
'--help': Boolean,
'--version': Boolean,
'--test': Boolean,
'--name': String,
'--npm': String,
'--dir': String,
'--verbose': Boolean,
// Aliases
'-h': '--help',
'-v': '--version',
'-t': '--test',
'-n': '--name',
'-P': '--npm',
Expand All @@ -56,6 +58,11 @@ const parseArgs = () => {
process.exit(0);
}

if (args['--version']) {
log(require('../util/version-outputs').generate);
process.exit(0);
}

const nameErrorMessage = `'${args[`--name`]}' does not follow the correct name format.\nPlease include a single '-'; [namespace]-[element name]\n`

// if ends with "-" or has too many, stop process.
Expand All @@ -77,7 +84,6 @@ const parseArgs = () => {

npm = args['--npm'] || '@aurodesignsystem';
const test = args['--test'];
const version = args['--version'];
const name = args['--name'].split('-')[1];
const namespace = args['--name'].split('-')[0];
const dir = path.resolve(
Expand Down
3 changes: 2 additions & 1 deletion util/help-outputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const generate = `
${chalk.gray('More help:')}
For more help with building an Auro Web Component,
be sure to see ${chalk.blue('https://bit.ly/3cqTsp5')}
be sure to see ${chalk.blue('https://auro.alaskaair.com/generator')}
${chalk.gray('Installed version:')}
v${pjson.version}
Expand All @@ -24,6 +24,7 @@ const generate = `
${chalk.gray('Options:')}
-h, --help Get help info about WC generator
-v, --version Return installed WC generator version
-t, --test Test repo generation without installing dependencies
-n, --name [name] Name of the web component to build, must follow format [namespace]-[name]
-P, --npm [npm] Choose npm namespace
Expand Down
26 changes: 26 additions & 0 deletions util/version-outputs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const chalk = require('chalk');
const pjson = require('../package.json');

const generate = `
${chalk.gray('Installed version:')}
v${pjson.version}
${chalk.gray('Upgrade to latest version:')}
$ npm i @aurodesignsystem/wc-generator@latest -g
${chalk.gray('More help:')}
For more help with building an Auro Web Component,
be sure to see ${chalk.blue('https://auro.alaskaair.com/generator')}
${chalk.gray('Options:')}
-h, --help Get help info about WC generator
-v, --version Return installed WC generator version
-t, --test Test repo generation without installing dependencies
-n, --name [name] Name of the web component to build, must follow format [namespace]-[name]
-P, --npm [npm] Choose npm namespace
-d, --dir [directory] Directory where the new custom element will be created
--verbose Verbose command line feedback
`;

module.exports = { generate };

0 comments on commit 23d8bc6

Please sign in to comment.