From e3e14141b964d267c6e4a3bc31114d53ffeee8bc Mon Sep 17 00:00:00 2001 From: "kelly.nguyen" <kelly.nguyen@etu.hesge.ch> Date: Tue, 20 Aug 2024 20:46:40 +0200 Subject: [PATCH] remove test option --- .../subcommands/UserCreateResumeCommand.ts | 88 +++++++++---------- 1 file changed, 41 insertions(+), 47 deletions(-) diff --git a/NodeApp/src/commander/user/subcommands/UserCreateResumeCommand.ts b/NodeApp/src/commander/user/subcommands/UserCreateResumeCommand.ts index 2126278..928d170 100644 --- a/NodeApp/src/commander/user/subcommands/UserCreateResumeCommand.ts +++ b/NodeApp/src/commander/user/subcommands/UserCreateResumeCommand.ts @@ -20,10 +20,9 @@ class UserCreateResumeCommand extends CommanderCommand { .requiredOption('-u, --id <id>', 'id of the user') .requiredOption('-n, --nameFile <string>', 'path of the file') .option('--full', 'full export') - .option('--test', 'test command') .action(this.commandAction.bind(this)); } - + protected async commandAction(options : CommandOptions): Promise<void> { // check privileges console.log(chalk.cyan('Please wait while we are exporting the resume...')); @@ -41,55 +40,50 @@ class UserCreateResumeCommand extends CommanderCommand { }).start(); try { - if (options.test) { - const res = await DojoBackendManager.createStaticPage(options.id); - console.log(res); - } else { - const resumeCreated = await DojoBackendManager.createResumeUser(options.id); - - if (!resumeCreated) { - resumeSpinner.fail('Failed to create resume'); + const resumeCreated = await DojoBackendManager.createResumeUser(options.id); + + if (!resumeCreated) { + resumeSpinner.fail('Failed to create resume'); + return; + } + + // START LIGHT EXPORT + if (!options.full) { + const portfolioCreated = await DojoBackendManager.createPortfolio(options.id); + + if (!portfolioCreated) { + resumeSpinner.fail('Failed to create portfolio'); return; } - // START LIGHT EXPORT - if (!options.full) { - const portfolioCreated = await DojoBackendManager.createPortfolio(options.id); - - if (!portfolioCreated) { - resumeSpinner.fail('Failed to create portfolio'); - return; - } - - await this.sleep(2000); - // END LIGHT EXPORT - } else { - // START COMPLET EXPORT - const userDataAssignment : User = await DojoBackendManager.getUserAssignments(options.id); - const userDataExercise : User = await DojoBackendManager.getUserExercises(options.id); - - if (!userDataAssignment) { - resumeSpinner.fail('Failed to create portfolio'); - return; - } - if (!userDataExercise) { - resumeSpinner.fail('Failed to create portfolio'); - return; - } - const pathAssignments = userDataAssignment.gitlabUsername + '/assignments' - const pathExercises = userDataAssignment.gitlabUsername + '/exercises' - - userDataAssignment.assignments?.forEach(el => { - this.cloneRepository(pathAssignments, el.gitlabCreationInfo.ssh_url_to_repo, el.name); - }); - - userDataExercise.exercises?.forEach(el => { - this.cloneRepository(pathExercises, el.gitlabCreationInfo.ssh_url_to_repo, el.name); - }); - - // END COMPLET EXPORT - await this.sleep(2000); + await this.sleep(2000); + // END LIGHT EXPORT + } else { + // START COMPLET EXPORT + const userDataAssignment : User = await DojoBackendManager.getUserAssignments(options.id); + const userDataExercise : User = await DojoBackendManager.getUserExercises(options.id); + + if (!userDataAssignment) { + resumeSpinner.fail('Failed to create portfolio'); + return; } + if (!userDataExercise) { + resumeSpinner.fail('Failed to create portfolio'); + return; + } + const pathAssignments = userDataAssignment.gitlabUsername + '/assignments' + const pathExercises = userDataAssignment.gitlabUsername + '/exercises' + + userDataAssignment.assignments?.forEach(el => { + this.cloneRepository(pathAssignments, el.gitlabCreationInfo.ssh_url_to_repo, el.name); + }); + + userDataExercise.exercises?.forEach(el => { + this.cloneRepository(pathExercises, el.gitlabCreationInfo.ssh_url_to_repo, el.name); + }); + + // END COMPLET EXPORT + await this.sleep(2000); this.downloadFile(options).then(() => { resumeSpinner.succeed('File downloaded and saved successfully.'); -- GitLab