Skip to content

Commit

Permalink
fix: ohif-cli cosmetic changes for help description (#2776)
Browse files Browse the repository at this point in the history
* fix ohif-cli cosmetic changes for help description

* refact code review fix main command name

* fix extension template fix extension-default package version
  • Loading branch information
ladeirarodolfo authored Jul 21, 2022
1 parent cfcf5e4 commit 86dcaf6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 25 deletions.
55 changes: 31 additions & 24 deletions platform/cli/src/index.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand All @@ -62,7 +62,7 @@ function _createPackage(packageType) {
};

const askRepoQuestions = () => {
inquirer.prompt(repoQuestions).then((repoAnswers) => {
inquirer.prompt(repoQuestions).then(repoAnswers => {
const answers = {
...pathAnswers,
...repoAnswers,
Expand All @@ -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');
});
Expand All @@ -99,7 +106,7 @@ program

program
.command('add-extension <packageName> [version]')
.description('Adds an ohif extension')
.description('Adds an OHIF Extension')
.action((packageName, version) => {
// change directory to viewer
process.chdir(viewerDirectory);
Expand All @@ -108,16 +115,16 @@ program

program
.command('remove-extension <packageName>')
.description('removes an ohif extension')
.action((packageName) => {
.description('Removes an OHIF Extension')
.action(packageName => {
// change directory to viewer
process.chdir(viewerDirectory);
removeExtension(packageName);
});

program
.command('add-mode <packageName> [version]')
.description('Removes an ohif mode')
.description('Add an OHIF Mode')
.action((packageName, version) => {
// change directory to viewer
process.chdir(viewerDirectory);
Expand All @@ -126,8 +133,8 @@ program

program
.command('remove-mode <packageName>')
.description('Removes an ohif mode')
.action((packageName) => {
.description('Removes an OHIF Mode')
.action(packageName => {
// change directory to viewer
process.chdir(viewerDirectory);
removeMode(packageName);
Expand All @@ -136,13 +143,13 @@ program
program
.command('link-extension <packageDir>')
.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);
Expand All @@ -152,26 +159,26 @@ program

program
.command('unlink-extension <extensionName>')
.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`
)
);
});

program
.command('link-mode <packageDir>')
.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);
Expand All @@ -181,12 +188,12 @@ program

program
.command('unlink-mode <modeName>')
.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`
)
);
});
Expand All @@ -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);
});

Expand Down
2 changes: 1 addition & 1 deletion platform/cli/templates/extension/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 86dcaf6

Please sign in to comment.