diff --git a/NodeApp/src/commander/assignment/subcommands/AssignmentCreateCommand.ts b/NodeApp/src/commander/assignment/subcommands/AssignmentCreateCommand.ts index d5cab1979c72b38b08b4ce6e6e0e2c64e7ca879a..fcf8a53eafd7b6231c5f25555b80e4ceb2380363 100644 --- a/NodeApp/src/commander/assignment/subcommands/AssignmentCreateCommand.ts +++ b/NodeApp/src/commander/assignment/subcommands/AssignmentCreateCommand.ts @@ -1,5 +1,6 @@ import CommanderCommand from '../../CommanderCommand.js'; import ora from 'ora'; +import SharedConfig from '../../../shared/config/SharedConfig'; import AccessesHelper from '../../../helpers/AccessesHelper.js'; import Assignment from '../../../sharedByClients/models/Assignment.js'; import DojoBackendManager from '../../../managers/DojoBackendManager.js'; @@ -9,7 +10,7 @@ import TextStyle from '../../../types/TextStyle.js'; import Config from '../../../config/Config'; -type CommandOptions = { name: string, template?: string, members_id?: Array<number>, members_username?: Array<string>, clone?: string | boolean } +type CommandOptions = { name: string, template?: string, members_id?: Array<number>, members_username?: Array<string>, clone?: string | boolean, sonar?: boolean } class AssignmentCreateCommand extends CommanderCommand { @@ -21,13 +22,17 @@ class AssignmentCreateCommand extends CommanderCommand { protected defineCommand() { this.command - .description('create a new repository for an assignment') - .requiredOption('-n, --name <name>', 'name of the assignment') - .option('-i, --members_id <ids...>', 'list of gitlab members ids (teaching staff) to add to the repository') - .option('-u, --members_username <usernames...>', 'list of gitlab members username (teaching staff) to add to the repository') - .option('-t, --template <string>', 'id or url of the template (http/s and ssh urls are possible)') - .option('-c, --clone [string]', 'automatically clone the repository (SSH required) in the specified directory (this will create a subdirectory with the assignment name)') - .action(this.commandAction.bind(this)); + .description('create a new repository for an assignment') + .requiredOption('-n, --name <name>', 'name of the assignment') + .option('-i, --members_id <ids...>', 'list of gitlab members ids (teaching staff) to add to the repository') + .option('-u, --members_username <usernames...>', 'list of gitlab members username (teaching staff) to add to the repository') + .option('-t, --template <string>', 'id or url of the template (http/s and ssh urls are possible)') + .option('-c, --clone [string]', 'automatically clone the repository (SSH required) in the specified directory (this will create a subdirectory with the assignment name)') + .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'); + } } private async dataRetrieval(options: CommandOptions) { @@ -63,7 +68,9 @@ class AssignmentCreateCommand extends CommanderCommand { private async createAssignment(options: CommandOptions) { console.log(TextStyle.BLOCK('Please wait while we are creating the assignment (approximately 10 seconds)...')); - this.assignment = await DojoBackendManager.createAssignment(options.name, this.members!, this.templateIdOrNamespace); + const sonar = (SharedConfig.sonar.enabled ? options.sonar ?? false : false); + + this.assignment = await DojoBackendManager.createAssignment(options.name, this.members!, this.templateIdOrNamespace, sonar); const oraInfo = (message: string) => { ora({ diff --git a/NodeApp/src/managers/DojoBackendManager.ts b/NodeApp/src/managers/DojoBackendManager.ts index f885205140af602eb2c3207a6d9d5b5b34060fee..4d1fe1d5e172acc4b366244db7a134825362ae5b 100644 --- a/NodeApp/src/managers/DojoBackendManager.ts +++ b/NodeApp/src/managers/DojoBackendManager.ts @@ -247,7 +247,7 @@ class DojoBackendManager { } } - public async createAssignment(name: string, members: Array<Gitlab.UserSchema>, templateIdOrNamespace: string | null, verbose: boolean = true): Promise<Assignment> { + public async createAssignment(name: string, members: Array<Gitlab.UserSchema>, templateIdOrNamespace: string | null, sonar: boolean = false, verbose: boolean = true): Promise<Assignment> { const spinner: ora.Ora = ora('Creating assignment...'); if ( verbose ) { @@ -257,7 +257,8 @@ class DojoBackendManager { try { const response = await axios.post<DojoBackendResponse<Assignment>>(DojoBackendHelper.getApiUrl(ApiRoute.ASSIGNMENT_CREATE), Object.assign({ name : name, - members: JSON.stringify(members) + members: JSON.stringify(members), + sonar : sonar }, templateIdOrNamespace ? { template: templateIdOrNamespace } : {})); if ( verbose ) { diff --git a/NodeApp/src/shared b/NodeApp/src/shared index 92008b25753c96bef9917cd39baab3a4d160cd9c..937081e68f6127b669daca30e57c43e73b9c96c9 160000 --- a/NodeApp/src/shared +++ b/NodeApp/src/shared @@ -1 +1 @@ -Subproject commit 92008b25753c96bef9917cd39baab3a4d160cd9c +Subproject commit 937081e68f6127b669daca30e57c43e73b9c96c9 diff --git a/NodeApp/src/sharedByClients b/NodeApp/src/sharedByClients index 81c1c69cdc9ed0b381c60fe4fd2e4668abe00625..59308a719fdee1a2025e90a18774d56fc6d11d9b 160000 --- a/NodeApp/src/sharedByClients +++ b/NodeApp/src/sharedByClients @@ -1 +1 @@ -Subproject commit 81c1c69cdc9ed0b381c60fe4fd2e4668abe00625 +Subproject commit 59308a719fdee1a2025e90a18774d56fc6d11d9b