From dccbd8398480bf9945c5bff7402672f926073f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <michael@minelli.me> Date: Thu, 12 Oct 2023 21:48:05 +0200 Subject: [PATCH] App => Run the validation --- AssignmentChecker/src/app.ts | 55 ++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/AssignmentChecker/src/app.ts b/AssignmentChecker/src/app.ts index bb70d03..1299507 100644 --- a/AssignmentChecker/src/app.ts +++ b/AssignmentChecker/src/app.ts @@ -1,17 +1,20 @@ // Read from the .env file // ATTENTION : This lines MUST be the first of this file (except for the path import) const path = require('node:path'); -require('dotenv').config({ - path : path.join(__dirname, '../.env'), - DOTENV_KEY: 'dotenv://:key_f1778b6998874f6fd78c716ccef982c5595fa300f174b129eafc88ba7044d69b@dotenv.local/vault/.env.vault?environment=development' - }); +const myEnv = require('dotenv').config({ + path : path.join(__dirname, '../.env'), + DOTENV_KEY: 'dotenv://:key_f1778b6998874f6fd78c716ccef982c5595fa300f174b129eafc88ba7044d69b@dotenv.local/vault/.env.vault?environment=development' + }); +require('dotenv-expand').expand(myEnv); require('./shared/helpers/TypeScriptExtensions'); // ATTENTION : This line MUST be the second of this file -import Styles from './types/Style'; -import { exec } from 'child_process'; -import util from 'util'; -import HttpManager from './managers/HttpManager'; -import Config from './config/Config'; +import AssignmentValidator from './sharedByClients/helpers/Dojo/AssignmentValidator'; +import Styles from './types/Style'; +import { exec } from 'child_process'; +import util from 'util'; +import HttpManager from './managers/HttpManager'; +import Config from './config/Config'; +import Icon from './sharedByClients/types/Icon'; (async () => { @@ -20,4 +23,38 @@ import Config from './config/Config'; HttpManager.registerAxiosInterceptor(); console.log(Styles.APP_NAME(`${ Config.appName } (version {{VERSION}})`)); + + const assignmentValidator = new AssignmentValidator(Config.folders.project); + + try { + await new Promise<void>((resolve, reject) => { + assignmentValidator.events.on('step', (name: string, message: string) => { + console.log(Styles.CAT_INFO(`${ Icon.CAT_INFO } ${ message }`)); + }); + + assignmentValidator.events.on('subStep', (name: string, message: string) => { + console.log(Styles.INFO(`\t${ Icon.INFO } ${ message }`)); + }); + + assignmentValidator.events.on('endSubStep', (stepName: string, message: string, error: boolean) => { + if ( error ) { + console.error(Styles.ERROR(`\t${ Icon.ERROR } ${ message }`)); + } + }); + + assignmentValidator.events.on('endStep', (stepName: string, message: string, error: boolean) => { + if ( error ) { + console.error(Styles.ERROR(`${ Icon.ERROR } ${ message }`)); + } + }); + + assignmentValidator.events.on('finished', (success: boolean, exitCode: number) => { + success ? resolve() : reject(); + }); + + assignmentValidator.run(); + }); + } catch ( error ) { } + + process.exit(assignmentValidator.exitCode); })(); \ No newline at end of file -- GitLab