Skip to content
Snippets Groups Projects
Commit eaf6bb41 authored by michael.minelli's avatar michael.minelli
Browse files

Sonar => Minimize code duplication

parent 7cdf0f9d
No related branches found
No related tags found
1 merge request!10Resolve "Add sonar integration"
Pipeline #29975 failed
......@@ -8,6 +8,9 @@ NodeApp/src/config/Version.ts
dojo_bash_completion.sh
dojo.fish
sonarlint.xml
sonarlint/
############################ MacOS
# General
.DS_Store
......
......@@ -12,4 +12,7 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="SonarLintModuleSettings">
<option name="uniqueId" value="7e31b6fd-1f86-4d26-8c50-c9ab6530f54e" />
</component>
</module>
\ No newline at end of file
......@@ -4,20 +4,16 @@ import ora from 'ora';
import chalk from 'chalk';
import AssignmentValidator from '../../../sharedByClients/helpers/Dojo/AssignmentValidator';
import ClientsSharedAssignmentHelper from '../../../sharedByClients/helpers/Dojo/ClientsSharedAssignmentHelper';
import { Option } from 'commander';
import SharedConfig from '../../../shared/config/SharedConfig';
import GlobalHelper from '../../../helpers/GlobalHelper';
class AssignmentCheckCommand extends CommanderCommand {
protected commandName: string = 'check';
protected defineCommand() {
this.command
GlobalHelper.runCommandDefinition(this.command)
.description('locally run a check of an assignment')
.option('-p, --path <value>', 'assignment path', Config.folders.defaultLocalExercise)
.option('-v, --verbose', 'verbose mode - display principal container output in live')
.addOption(new Option('-w, --super-verbose', 'verbose mode - display all docker compose logs (build included) in live').conflicts('verbose'))
.addOption(new Option('--verbose-ssj2').hideHelp().implies({ superVerbose: true }))
.action(this.commandAction.bind(this));
}
......
import CommanderCommand from '../../CommanderCommand';
import Config from '../../../config/Config';
import { Option } from 'commander';
import ExerciseRunHelper from '../../../helpers/Dojo/ExerciseRunHelper';
import GlobalHelper from '../../../helpers/GlobalHelper';
class AssignmentRunCommand extends CommanderCommand {
protected commandName: string = 'run';
protected defineCommand() {
// This command is synced with the "exercise run" command
this.command
GlobalHelper.runCommandDefinition(this.command)
.description('locally run the assignment as an exercise')
.option('-p, --path <value>', 'exercise path', Config.folders.defaultLocalExercise)
.option('-v, --verbose', 'verbose mode - display principal container output in live')
.addOption(new Option('-w, --super-verbose', 'verbose mode - display all docker compose logs (build included) in live').conflicts('verbose'))
.addOption(new Option('--verbose-ssj2').hideHelp().implies({ superVerbose: true }))
.action(this.commandAction.bind(this));
}
......
......@@ -5,6 +5,7 @@ import TextStyle from '../../../types/T
import fs from 'fs-extra';
import path from 'path';
import os from 'os';
import GlobalHelper from '../../../helpers/GlobalHelper';
class CompletionBashCommand extends CommanderCommand {
......@@ -13,10 +14,8 @@ class CompletionBashCommand extends CommanderCommand {
private installPath = path.join(os.homedir(), '.bash_completion');
protected defineCommand() {
this.command
GlobalHelper.completionCommandDefinition(this.command)
.description('generate bash completion')
.option('-f, --file <filename>')
.option('-y, --force', 'don\'t ask for file overwrite confirmation')
.action(this.commandAction.bind(this));
}
......
......@@ -5,6 +5,7 @@ import TextStyle from '../../../types/T
import path from 'path';
import os from 'os';
import fs from 'fs-extra';
import GlobalHelper from '../../../helpers/GlobalHelper';
class CompletionFishCommand extends CommanderCommand {
......@@ -13,15 +14,14 @@ class CompletionFishCommand extends CommanderCommand {
private installPath = path.join(os.homedir(), '.config/fish/completions/dojo.fish');
protected defineCommand() {
this.command
GlobalHelper.completionCommandDefinition(this.command)
.description('generate fish completion')
.option('-f, --file <filename>', `filename where the bash completion will be stored`)
.option('-y, --force', 'don\'t ask for file overwrite confirmation')
.action(this.commandAction.bind(this));
}
private writeFile(filename: string, showInstructions: boolean) {
const spinner: ora.Ora = ora(`Writing fish completion in ${ filename }...`).start();
try {
fs.mkdirsSync(path.dirname(filename));
......@@ -29,7 +29,6 @@ class CompletionFishCommand extends CommanderCommand {
spinner.succeed(`Fish completion successfully written in ${ filename }.`);
if ( showInstructions ) {
console.log(`
The easiest way to install the completion is to copy the ${ TextStyle.CODE(filename) } into the ${ TextStyle.CODE('~/.config/fish/completions') } directory.
......
......@@ -5,6 +5,7 @@ import TextStyle from '../../../types/T
import path from 'path';
import { homedir } from 'os';
import fs from 'fs-extra';
import GlobalHelper from '../../../helpers/GlobalHelper';
class CompletionZshCommand extends CommanderCommand {
......@@ -21,10 +22,8 @@ source ${ this.bash_completion }
protected defineCommand() {
this.command
GlobalHelper.completionCommandDefinition(this.command)
.description('generate zsh completion, which is derived from the bash completion')
.option('-f, --file <filename>', 'bash completion filename')
.option('-y, --force', 'don\'t ask for file overwrite confirmation')
.action(this.commandAction.bind(this));
}
......
import CommanderCommand from '../../CommanderCommand';
import Config from '../../../config/Config';
import ExerciseRunHelper from '../../../helpers/Dojo/ExerciseRunHelper';
import { Option } from 'commander';
import GlobalHelper from '../../../helpers/GlobalHelper';
class ExerciseRunCommand extends CommanderCommand {
protected commandName: string = 'run';
protected defineCommand() {
// This command is synced with the "assignment run" command
this.command
GlobalHelper.runCommandDefinition(this.command)
.description('locally run an exercise')
.option('-p, --path <value>', 'exercise path', Config.folders.defaultLocalExercise)
.option('-v, --verbose', 'verbose mode - display principal container output in live')
.addOption(new Option('-w, --super-verbose', 'verbose mode - display all docker compose logs (build included) in live').conflicts('verbose'))
.addOption(new Option('--verbose-ssj2').hideHelp().implies({ superVerbose: true }))
.action(this.commandAction.bind(this));
}
......
import { Command, Option } from 'commander';
import Config from '../config/Config';
class GlobalHelper {
public runCommandDefinition(command: Command) {
command
.option('-p, --path <value>', 'assignment path', Config.folders.defaultLocalExercise)
.option('-v, --verbose', 'verbose mode - display principal container output in live')
.addOption(new Option('-w, --super-verbose', 'verbose mode - display all docker compose logs (build included) in live').conflicts('verbose'))
.addOption(new Option('--verbose-ssj2').hideHelp().implies({ superVerbose: true }));
return command;
}
public completionCommandDefinition(command: Command) {
command
.option('-f, --file <filename>')
.option('-y, --force', 'don\'t ask for file overwrite confirmation');
return command;
}
}
export default new GlobalHelper();
\ No newline at end of file
Subproject commit 9e3f29d2f313ef96944a199da0db39f1827c496a
Subproject commit 6214acbd799d9eed3f5b6840858f8d5ecda82c86
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment