From 86dcaf6293cf0bd0e59a07ebfb6914bbca6eb255 Mon Sep 17 00:00:00 2001 From: ladeirarodolfo <39910206+ladeirarodolfo@users.noreply.github.com> Date: Thu, 21 Jul 2022 19:42:43 -0300 Subject: [PATCH] fix: ohif-cli cosmetic changes for help description (#2776) * fix ohif-cli cosmetic changes for help description * refact code review fix main command name * fix extension template fix extension-default package version --- platform/cli/src/index.js | 55 +++++++++++-------- .../cli/templates/extension/dependencies.json | 2 +- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/platform/cli/src/index.js b/platform/cli/src/index.js index ffdf5cb7707..9d2f868b0cc 100755 --- a/platform/cli/src/index.js +++ b/platform/cli/src/index.js @@ -1,6 +1,6 @@ #!/usr/bin/env node -import program from 'commander'; +import { Command } from 'commander'; import inquirer from 'inquirer'; import path from 'path'; import fs from 'fs'; @@ -51,7 +51,7 @@ function _createPackage(packageType) { let pathAnswers; const askPathQuestions = () => { - inquirer.prompt(pathQuestions).then((answers) => { + inquirer.prompt(pathQuestions).then(answers => { pathAnswers = answers; if (pathAnswers.confirm) { askRepoQuestions(answers.baseDir, answers.name); @@ -62,7 +62,7 @@ function _createPackage(packageType) { }; const askRepoQuestions = () => { - inquirer.prompt(repoQuestions).then((repoAnswers) => { + inquirer.prompt(repoQuestions).then(repoAnswers => { const answers = { ...pathAnswers, ...repoAnswers, @@ -80,12 +80,19 @@ function _createPackage(packageType) { askPathQuestions(); } +// for now ohif-cli is ran through yarn only. +// see ohif-cli.md section # OHIF Command Line Interface for reference. +const program = new Command('yarn run cli'); // Todo: inject with webpack -program.version('2.0.7').description('OHIF CLI'); +program + .version('2.0.7') + .description('OHIF CLI') + .configureHelp({ sortOptions: true, sortSubcommands: true }) + .showHelpAfterError('(add --help for additional information)'); program .command('create-extension') - .description('Create a new template extension') + .description('Create a new template Extension') .action(() => { _createPackage('extension'); }); @@ -99,7 +106,7 @@ program program .command('add-extension [version]') - .description('Adds an ohif extension') + .description('Adds an OHIF Extension') .action((packageName, version) => { // change directory to viewer process.chdir(viewerDirectory); @@ -108,8 +115,8 @@ program program .command('remove-extension ') - .description('removes an ohif extension') - .action((packageName) => { + .description('Removes an OHIF Extension') + .action(packageName => { // change directory to viewer process.chdir(viewerDirectory); removeExtension(packageName); @@ -117,7 +124,7 @@ program program .command('add-mode [version]') - .description('Removes an ohif mode') + .description('Add an OHIF Mode') .action((packageName, version) => { // change directory to viewer process.chdir(viewerDirectory); @@ -126,8 +133,8 @@ program program .command('remove-mode ') - .description('Removes an ohif mode') - .action((packageName) => { + .description('Removes an OHIF Mode') + .action(packageName => { // change directory to viewer process.chdir(viewerDirectory); removeMode(packageName); @@ -136,13 +143,13 @@ program program .command('link-extension ') .description( - 'Links a local OHIF extension to the Viewer to be used for development' + 'Links a local OHIF Extension to the Viewer to be used for development' ) - .action((packageDir) => { + .action(packageDir => { if (!fs.existsSync(packageDir)) { console.log( chalk.red( - 'The extension directory does not exist, please provide a valid directory' + 'The Extension directory does not exist, please provide a valid directory' ) ); process.exit(1); @@ -152,12 +159,12 @@ program program .command('unlink-extension ') - .description('Unlinks a local OHIF extension from the Viewer') - .action((extensionName) => { + .description('Unlinks a local OHIF Extension from the Viewer') + .action(extensionName => { unlinkExtension(extensionName, { viewerDirectory }); console.log( chalk.green( - `Successfully unlinked extension ${extensionName} from the Viewer, don't forget to run yarn install --force` + `Successfully unlinked Extension ${extensionName} from the Viewer, don't forget to run yarn install --force` ) ); }); @@ -165,13 +172,13 @@ program program .command('link-mode ') .description( - 'Links a local OHIF mode to the Viewer to be used for development' + 'Links a local OHIF Mode to the Viewer to be used for development' ) - .action((packageDir) => { + .action(packageDir => { if (!fs.existsSync(packageDir)) { console.log( chalk.red( - 'The mode directory does not exist, please provide a valid directory' + 'The Mode directory does not exist, please provide a valid directory' ) ); process.exit(1); @@ -181,12 +188,12 @@ program program .command('unlink-mode ') - .description('Unlinks a local OHIF mode from the Viewer') - .action((modeName) => { + .description('Unlinks a local OHIF Mode from the Viewer') + .action(modeName => { unlinkMode(modeName, { viewerDirectory }); console.log( chalk.green( - `Successfully unlinked mode ${modeName} from the Viewer, don't forget to run yarn install --force` + `Successfully unlinked Mode ${modeName} from the Viewer, don't forget to run yarn install --force` ) ); }); @@ -203,7 +210,7 @@ program .command('search') .option('-v, --verbose', 'Verbose output') .description('Search NPM for the list of Modes and Extensions') - .action((options) => { + .action(options => { searchPlugins(options); }); diff --git a/platform/cli/templates/extension/dependencies.json b/platform/cli/templates/extension/dependencies.json index 471d842603c..65b17c9d977 100644 --- a/platform/cli/templates/extension/dependencies.json +++ b/platform/cli/templates/extension/dependencies.json @@ -17,7 +17,7 @@ }, "peerDependencies": { "@ohif/core": "^3.0.0", - "@ohif/extension-default": "^1.0.1", + "@ohif/extension-default": "^3.0.0", "@ohif/extension-cornerstone": "^3.0.0", "@ohif/i18n": "^1.0.0", "prop-types": "^15.6.2",