diff --git a/NodeApp/src/commander/assignment/subcommands/AssignmentCreateCommand.ts b/NodeApp/src/commander/assignment/subcommands/AssignmentCreateCommand.ts index 79fd5e41c3499773aa64acd9440785d96ba22c77..4d5e781f61ee50584fcf28db104bd0af9ea358d9 100644 --- a/NodeApp/src/commander/assignment/subcommands/AssignmentCreateCommand.ts +++ b/NodeApp/src/commander/assignment/subcommands/AssignmentCreateCommand.ts @@ -27,7 +27,8 @@ class AssignmentCreateCommand extends CommanderCommand { .action(this.commandAction.bind(this)); if (SharedConfig.sonar.enabled) { - this.command.requiredOption('-s, --sonar', 'add sonar to the code checking process for exercises derived from the assignment') + this.command.requiredOption('-s, --sonar', 'add sonar to the code checking process for assignment and exercises') + .requiredOption('-d, --no-sonar', 'disable sonar for the code checking process for assignment and exercises') .addOption(new Option('-g, --gate <gate>', 'quality gate for sonar').implies({sonar: true})) .addOption(new Option('-p, --profile <profile...>', 'quality profiles for sonar').default([]).implies({sonar: true})); } @@ -141,6 +142,9 @@ class AssignmentCreateCommand extends CommanderCommand { oraInfo(`${ chalk.magenta('Web URL:') } ${ assignment.gitlabCreationInfo.web_url }`); oraInfo(`${ chalk.magenta('HTTP Repo:') } ${ assignment.gitlabCreationInfo.http_url_to_repo }`); oraInfo(`${ chalk.magenta('SSH Repo:') } ${ assignment.gitlabCreationInfo.ssh_url_to_repo }`); + if (assignment.useSonar) { + oraInfo(`${ chalk.magenta('Sonar project:') } ${SharedConfig.sonar.url}/dashboard?id=${ assignment.sonarKey }`); + } } catch ( error ) { return; } diff --git a/NodeApp/src/commander/exercise/subcommands/ExerciseCreateCommand.ts b/NodeApp/src/commander/exercise/subcommands/ExerciseCreateCommand.ts index 00215301ae2cac6352adb41a152f64fcceeea91f..e7d79723390f6972de592760b95a19c8976a67bb 100644 --- a/NodeApp/src/commander/exercise/subcommands/ExerciseCreateCommand.ts +++ b/NodeApp/src/commander/exercise/subcommands/ExerciseCreateCommand.ts @@ -7,6 +7,7 @@ import DojoBackendManager from '../../../managers/DojoBackendManager'; import AccessesHelper from '../../../helpers/AccessesHelper'; import Assignment from '../../../sharedByClients/models/Assignment'; import Exercise from '../../../sharedByClients/models/Exercise'; +import SharedConfig from '../../../shared/config/SharedConfig'; class ExerciseCreateCommand extends CommanderCommand { @@ -82,6 +83,9 @@ class ExerciseCreateCommand extends CommanderCommand { oraInfo(`${ chalk.magenta('Web URL:') } ${ exercise.gitlabCreationInfo.web_url }`); oraInfo(`${ chalk.magenta('HTTP Repo:') } ${ exercise.gitlabCreationInfo.http_url_to_repo }`); oraInfo(`${ chalk.magenta('SSH Repo:') } ${ exercise.gitlabCreationInfo.ssh_url_to_repo }`); + if (assignment.useSonar) { + oraInfo(`${ chalk.magenta('Sonar project:') } ${SharedConfig.sonar.url}/dashboard?id=${ exercise.sonarKey }`); + } } catch ( error ) { return; } diff --git a/NodeApp/src/managers/DojoBackendManager.ts b/NodeApp/src/managers/DojoBackendManager.ts index 46e7c6a6ef0ddc6338000db2d32de6633e1e9af4..441f249f31133909a455ef922f8f45f39ba21ec0 100644 --- a/NodeApp/src/managers/DojoBackendManager.ts +++ b/NodeApp/src/managers/DojoBackendManager.ts @@ -10,6 +10,7 @@ import Exercise from '../sharedByClients/models/Exercise'; import GitlabToken from '../shared/types/Gitlab/GitlabToken'; import User from '../sharedByClients/models/User'; import DojoStatusCode from '../shared/types/Dojo/DojoStatusCode'; +import SharedConfig from '../shared/config/SharedConfig'; class DojoBackendManager { @@ -113,6 +114,8 @@ class DojoBackendManager { } else { if ( (error.response.data as DojoBackendResponse<unknown>).code === DojoStatusCode.ASSIGNMENT_CREATION_GITLAB_ERROR ) { spinner.fail(`Assignment creation error: An unknown error occurred while creating the assignment on Gitlab. Please try again later or contact an administrator.`); + } else if ( (error.response.data as DojoBackendResponse<unknown>).code === DojoStatusCode.ASSIGNMENT_CREATION_SONAR_MEMBER ) { + spinner.fail(`Tous les membres du projet doivent s'être connectés une première fois à SonarQube avec leurs identifiants Gitlab pour pouvoir créer le projet.\nURL: ${SharedConfig.sonar.url}/`); } else { spinner.fail(`Assignment creation error: An unknown error occurred while creating the assignment on Dojo server. Please try again later or contact an administrator.`); } @@ -155,6 +158,8 @@ class DojoBackendManager { } else { if ( (error.response.data as DojoBackendResponse<unknown>).code === DojoStatusCode.EXERCISE_CREATION_GITLAB_ERROR ) { spinner.fail(`Exercise creation error: An unknown error occurred while creating the exercise on Gitlab. Please try again later or contact an administrator.`); + } else if ( (error.response.data as DojoBackendResponse<unknown>).code === DojoStatusCode.ASSIGNMENT_CREATION_SONAR_MEMBER ) { + spinner.fail(`Tous les membres du projet doivent s'être connectés une première fois à SonarQube avec leurs identifiants Gitlab pour pouvoir créer le projet.\nURL: ${SharedConfig.sonar.url}/`); } else { spinner.fail(`Exercise creation error: An unknown error occurred while creating the exercise on Dojo server. Please try again later or contact an administrator.`); } diff --git a/NodeApp/src/shared b/NodeApp/src/shared index bd29fe76fdb1b124e3fe2f23e995a2b3b70694a7..8efab438a60569011f2757c803a89c81bc46a174 160000 --- a/NodeApp/src/shared +++ b/NodeApp/src/shared @@ -1 +1 @@ -Subproject commit bd29fe76fdb1b124e3fe2f23e995a2b3b70694a7 +Subproject commit 8efab438a60569011f2757c803a89c81bc46a174 diff --git a/NodeApp/src/sharedByClients b/NodeApp/src/sharedByClients index 41b3d88544eb46171acf36b4fd61332c33db5bf8..d15be9b16181f5f172d51b13966e0e44bd34f55d 160000 --- a/NodeApp/src/sharedByClients +++ b/NodeApp/src/sharedByClients @@ -1 +1 @@ -Subproject commit 41b3d88544eb46171acf36b4fd61332c33db5bf8 +Subproject commit d15be9b16181f5f172d51b13966e0e44bd34f55d