Skip to content
Snippets Groups Projects
Commit dbad7c3f authored by joel.vonderwe's avatar joel.vonderwe
Browse files

Add sonar option to assignment creation

parent d4dd88c0
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ import GitlabUser from '../../../shared/types/Gitlab/GitlabUser';
import GitlabManager from '../../../managers/GitlabManager';
import DojoBackendManager from '../../../managers/DojoBackendManager';
import Toolbox from '../../../shared/helpers/Toolbox';
import SharedConfig from '../../../shared/config/SharedConfig';
class AssignmentCreateCommand extends CommanderCommand {
......@@ -21,9 +22,13 @@ class AssignmentCreateCommand extends CommanderCommand {
.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.useSonar) {
this.command.requiredOption('-s, --sonar', 'add sonar to the code checking process for exercises derived from the assignment');
}
}
protected async commandAction(options: { name: string, template?: string, members_id?: Array<number>, members_username?: Array<string>, clone?: string | boolean }): Promise<void> {
protected async commandAction(options: { name: string, template?: string, members_id?: Array<number>, members_username?: Array<string>, clone?: string | boolean, sonar?: boolean}): Promise<void> {
let members!: Array<GitlabUser> | false;
let templateIdOrNamespace: string | null = null;
let assignment!: Assignment;
......@@ -66,7 +71,9 @@ class AssignmentCreateCommand extends CommanderCommand {
console.log(chalk.cyan('Please wait while we are creating the assignment (approximately 10 seconds)...'));
try {
assignment = await DojoBackendManager.createAssignment(options.name, members, templateIdOrNamespace);
const sonar = (SharedConfig.useSonar ? options.sonar ?? false : false);
assignment = await DojoBackendManager.createAssignment(options.name, members, templateIdOrNamespace, sonar);
const oraInfo = (message: string) => {
ora({
......
......@@ -82,7 +82,7 @@ class DojoBackendManager {
}
}
public async createAssignment(name: string, members: Array<GitlabUser>, templateIdOrNamespace: string | null, verbose: boolean = true): Promise<Assignment> {
public async createAssignment(name: string, members: Array<GitlabUser>, templateIdOrNamespace: string | null, sonar: boolean = false, verbose: boolean = true): Promise<Assignment> {
const spinner: ora.Ora = ora('Creating assignment...');
if ( verbose ) {
......@@ -92,7 +92,8 @@ class DojoBackendManager {
try {
const response = await axios.post<DojoBackendResponse<Assignment>>(this.getApiUrl(ApiRoute.ASSIGNMENT_CREATE), Object.assign({
name : name,
members: JSON.stringify(members)
members: JSON.stringify(members),
sonar : sonar
}, templateIdOrNamespace ? { template: templateIdOrNamespace } : {}));
if ( verbose ) {
......
Subproject commit 9e3f29d2f313ef96944a199da0db39f1827c496a
Subproject commit d509efa1b35e100446ace49d8e665ca72e5a7afe
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment