Skip to content
Snippets Groups Projects
Commit 6a8db141 authored by joel.vonderwe's avatar joel.vonderwe Committed by michael.minelli
Browse files

Add sonar option to assignment creation

parent 71567736
Branches
No related tags found
No related merge requests found
import CommanderCommand from '../../CommanderCommand.js'; import CommanderCommand from '../../CommanderCommand.js';
import ora from 'ora'; import ora from 'ora';
import SharedConfig from '../../../shared/config/SharedConfig';
import AccessesHelper from '../../../helpers/AccessesHelper.js'; import AccessesHelper from '../../../helpers/AccessesHelper.js';
import Assignment from '../../../sharedByClients/models/Assignment.js'; import Assignment from '../../../sharedByClients/models/Assignment.js';
import DojoBackendManager from '../../../managers/DojoBackendManager.js'; import DojoBackendManager from '../../../managers/DojoBackendManager.js';
...@@ -9,7 +10,7 @@ import TextStyle from '../../../types/TextStyle.js'; ...@@ -9,7 +10,7 @@ import TextStyle from '../../../types/TextStyle.js';
import Config from '../../../config/Config'; 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 { class AssignmentCreateCommand extends CommanderCommand {
...@@ -28,6 +29,10 @@ class AssignmentCreateCommand extends CommanderCommand { ...@@ -28,6 +29,10 @@ class AssignmentCreateCommand extends CommanderCommand {
.option('-t, --template <string>', 'id or url of the template (http/s and ssh urls are possible)') .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)') .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)); .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) { private async dataRetrieval(options: CommandOptions) {
...@@ -63,7 +68,9 @@ class AssignmentCreateCommand extends CommanderCommand { ...@@ -63,7 +68,9 @@ class AssignmentCreateCommand extends CommanderCommand {
private async createAssignment(options: CommandOptions) { private async createAssignment(options: CommandOptions) {
console.log(TextStyle.BLOCK('Please wait while we are creating the assignment (approximately 10 seconds)...')); 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) => { const oraInfo = (message: string) => {
ora({ ora({
......
...@@ -247,7 +247,7 @@ class DojoBackendManager { ...@@ -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...'); const spinner: ora.Ora = ora('Creating assignment...');
if ( verbose ) { if ( verbose ) {
...@@ -257,7 +257,8 @@ class DojoBackendManager { ...@@ -257,7 +257,8 @@ class DojoBackendManager {
try { try {
const response = await axios.post<DojoBackendResponse<Assignment>>(DojoBackendHelper.getApiUrl(ApiRoute.ASSIGNMENT_CREATE), Object.assign({ const response = await axios.post<DojoBackendResponse<Assignment>>(DojoBackendHelper.getApiUrl(ApiRoute.ASSIGNMENT_CREATE), Object.assign({
name : name, name : name,
members: JSON.stringify(members) members: JSON.stringify(members),
sonar : sonar
}, templateIdOrNamespace ? { template: templateIdOrNamespace } : {})); }, templateIdOrNamespace ? { template: templateIdOrNamespace } : {}));
if ( verbose ) { if ( verbose ) {
......
Subproject commit 92008b25753c96bef9917cd39baab3a4d160cd9c Subproject commit 937081e68f6127b669daca30e57c43e73b9c96c9
Subproject commit 81c1c69cdc9ed0b381c60fe4fd2e4668abe00625 Subproject commit 59308a719fdee1a2025e90a18774d56fc6d11d9b
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment