From 23d8bc6e71e0bf89702c626dc1a907162e793848 Mon Sep 17 00:00:00 2001 From: Dale Sande Date: Fri, 11 Jun 2021 16:00:02 -0700 Subject: [PATCH] fix(help): show version info with --version --- bin/generate.js | 8 +++++++- util/help-outputs.js | 3 ++- util/version-outputs.js | 26 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 util/version-outputs.js diff --git a/bin/generate.js b/bin/generate.js index c13b75c7..7268f0ca 100755 --- a/bin/generate.js +++ b/bin/generate.js @@ -38,6 +38,7 @@ const parseArgs = () => { const args = arg({ // Types '--help': Boolean, + '--version': Boolean, '--test': Boolean, '--name': String, '--npm': String, @@ -45,6 +46,7 @@ const parseArgs = () => { '--verbose': Boolean, // Aliases '-h': '--help', + '-v': '--version', '-t': '--test', '-n': '--name', '-P': '--npm', @@ -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. @@ -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( diff --git a/util/help-outputs.js b/util/help-outputs.js index 9141c1b6..86ff9577 100644 --- a/util/help-outputs.js +++ b/util/help-outputs.js @@ -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} @@ -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 diff --git a/util/version-outputs.js b/util/version-outputs.js new file mode 100644 index 00000000..f6a1c216 --- /dev/null +++ b/util/version-outputs.js @@ -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 };