diff --git a/NodeApp/src/commander/CommanderApp.ts b/NodeApp/src/commander/CommanderApp.ts index 17d435aa912cca9aacb35893db6252ac97ad2a8b..96127df535f6b529cd6618404fddb46a620431c4 100644 --- a/NodeApp/src/commander/CommanderApp.ts +++ b/NodeApp/src/commander/CommanderApp.ts @@ -1,15 +1,15 @@ import { Command, Option } from 'commander'; -import SessionCommand from './session/SessionCommand'; +import SessionCommand from './session/SessionCommand'; import ClientsSharedConfig from '../sharedByClients/config/ClientsSharedConfig'; -import AssignmentCommand from './assignment/AssignmentCommand'; -import ExerciseCommand from './exercise/ExerciseCommand'; -import SharedConfig from '../shared/config/SharedConfig'; -import boxen from 'boxen'; +import AssignmentCommand from './assignment/AssignmentCommand'; +import ExerciseCommand from './exercise/ExerciseCommand'; +import SharedConfig from '../shared/config/SharedConfig'; +import boxen from 'boxen'; import { stateConfigFile } from '../config/ConfigFiles'; -import semver from 'semver/preload'; -import { version } from '../config/Version'; -import Config from '../config/Config'; -import {getBashCompletion} from '../helpers/AutoCompletionHelper'; +import semver from 'semver/preload'; +import { version } from '../config/Version'; +import Config from '../config/Config'; +import { getBashCompletion } from '../helpers/AutoCompletionHelper'; class CommanderApp { @@ -17,22 +17,22 @@ class CommanderApp { constructor() { this.program - .name('dojo') - .description('CLI of the Dojo application') - .version('{{VERSION}}') - .showHelpAfterError() - .configureHelp({ - showGlobalOptions: true, - sortOptions : true, - sortSubcommands : true - }) - .option('-H, --host <string>', 'override the Dojo API endpoint', ClientsSharedConfig.apiURL) - .addOption(new Option('--debug').hideHelp()) - .hook('preAction', () => { - this.warnDevelopmentVersion(); - }).hook('postAction', () => { - this.informNewVersion(); - }); + .name('dojo') + .description('CLI of the Dojo application') + .version('{{VERSION}}') + .showHelpAfterError() + .configureHelp({ + showGlobalOptions: true, + sortOptions: true, + sortSubcommands: true + }) + .option('-H, --host <string>', 'override the Dojo API endpoint', ClientsSharedConfig.apiURL) + .addOption(new Option('--debug').hideHelp()) + .hook('preAction', () => { + this.warnDevelopmentVersion(); + }).hook('postAction', () => { + this.informNewVersion(); + }); this.program.on('option:host', () => { ClientsSharedConfig.apiURL = this.program.opts().host; @@ -45,42 +45,41 @@ class CommanderApp { this.registerCommands(); getBashCompletion(this.program) - // AutoCompletionHelper.getCommands(this.program) this.program.parse(); } private warnDevelopmentVersion() { - if ( !SharedConfig.production ) { + if (!SharedConfig.production) { console.log(boxen(`This is a development (unstable) version of the DojoCLI. If you want to use the stable version, please install the package from the following url: https://gitedu.hesge.ch/dojo_project/projects/ui/dojocli/-/releases/Latest`, { - title : 'Warning', + title: 'Warning', titleAlignment: 'center', - borderColor : 'red', - borderStyle : 'bold', - margin : 1, - padding : 1, - textAlignment : 'left' + borderColor: 'red', + borderStyle: 'bold', + margin: 1, + padding: 1, + textAlignment: 'left' })); } } private informNewVersion() { - if ( SharedConfig.production ) { + if (SharedConfig.production) { const latestDojoCliVersion = stateConfigFile.getParam('latestDojoCliVersion') as string | null || '0.0.0'; const latestDojoCliVersionNotification = stateConfigFile.getParam('latestDojoCliVersionNotification') as number | null || 0; - if ( semver.lt(version, latestDojoCliVersion) ) { - if ( (new Date()).getTime() - latestDojoCliVersionNotification >= Config.versionUpdateInformationPeriodHours * 60 * 60 * 1000 ) { - console.log(boxen(`The ${ latestDojoCliVersion } version of the DojoCLI is available: + if (semver.lt(version, latestDojoCliVersion)) { + if ((new Date()).getTime() - latestDojoCliVersionNotification >= Config.versionUpdateInformationPeriodHours * 60 * 60 * 1000) { + console.log(boxen(`The ${latestDojoCliVersion} version of the DojoCLI is available: https://gitedu.hesge.ch/dojo_project/projects/ui/dojocli/-/releases/Latest`, { - title : 'Information', + title: 'Information', titleAlignment: 'center', - borderColor : 'blue', - borderStyle : 'bold', - margin : 1, - padding : 1, - textAlignment : 'left' + borderColor: 'blue', + borderStyle: 'bold', + margin: 1, + padding: 1, + textAlignment: 'left' })); stateConfigFile.setParam('latestDojoCliVersionNotification', (new Date()).getTime()); }