From 3a29dec81fda62478c3d3d65853dae450fbbdd9a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <michael@minelli.me>
Date: Sun, 14 Jan 2024 22:55:44 +0100
Subject: [PATCH] AssignmentCheckCommand => Add two levels of verbose

---
 .../subcommands/AssignmentCheckCommand.ts     | 30 +++++++++++++------
 NodeApp/src/sharedByClients                   |  2 +-
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/NodeApp/src/commander/assignment/subcommands/AssignmentCheckCommand.ts b/NodeApp/src/commander/assignment/subcommands/AssignmentCheckCommand.ts
index 718b7b9..8201f3a 100644
--- a/NodeApp/src/commander/assignment/subcommands/AssignmentCheckCommand.ts
+++ b/NodeApp/src/commander/assignment/subcommands/AssignmentCheckCommand.ts
@@ -4,6 +4,7 @@ import ora                           from 'ora';
 import chalk                         from 'chalk';
 import AssignmentValidator           from '../../../sharedByClients/helpers/Dojo/AssignmentValidator';
 import ClientsSharedAssignmentHelper from '../../../sharedByClients/helpers/Dojo/ClientsSharedAssignmentHelper';
+import { Option }                    from 'commander';
 
 
 class AssignmentCheckCommand extends CommanderCommand {
@@ -13,11 +14,15 @@ class AssignmentCheckCommand extends CommanderCommand {
         this.command
         .description('locally run a check of an assignment')
         .option('-p, --path <value>', 'assignment path', Config.folders.defaultLocalExercise)
-        .option('-v, --verbose', 'verbose mode (display docker compose logs in live)')
+        .option('-v, --verbose', 'verbose mode - display principal container output in live')
+        .addOption(new Option('-w, --super-verbose', 'verbose mode - display all docker compose logs (build included) in live').conflicts('verbose'))
+        .addOption(new Option('--verbose-ssj2').hideHelp().implies({ superVerbose: true }))
         .action(this.commandAction.bind(this));
     }
 
-    protected async commandAction(options: { path: string, verbose: boolean }): Promise<void> {
+    protected async commandAction(options: { path: string, verbose: boolean, superVerbose: boolean }): Promise<void> {
+        const verbose: boolean = options.verbose || options.superVerbose;
+
         const localExercisePath: string = options.path ?? Config.folders.defaultLocalExercise;
 
         const assignmentValidator = new AssignmentValidator(localExercisePath);
@@ -26,10 +31,17 @@ class AssignmentCheckCommand extends CommanderCommand {
             await new Promise<void>((resolve, reject) => {
                 let spinner: ora.Ora;
 
-                if ( options.verbose ) {
-                    assignmentValidator.events.on('logs', (log: string, _error: boolean, displayable: boolean) => {
-                        if ( displayable ) {
-                            console.log(log);
+                if ( verbose ) {
+                    let buildPhase: boolean = true;
+                    assignmentValidator.events.on('logs', (log: string, _error: boolean, displayable: boolean, _currentStep: string, currentSubStep: string) => {
+                        for ( const line of log.split('\n') ) {
+                            if ( currentSubStep == 'COMPOSE_RUN' && buildPhase && line != '' && !line.startsWith('#') ) {
+                                buildPhase = false;
+                            }
+
+                            if ( displayable && (options.superVerbose || !buildPhase) ) {
+                                console.log(line);
+                            }
                         }
                     });
                 }
@@ -44,14 +56,14 @@ class AssignmentCheckCommand extends CommanderCommand {
                                       indent: 4
                                   }).start();
 
-                    if ( options.verbose && name == 'COMPOSE_RUN' ) {
+                    if ( verbose && name == 'COMPOSE_RUN' ) {
                         spinner.info();
                     }
                 });
 
                 assignmentValidator.events.on('endSubStep', (stepName: string, message: string, error: boolean) => {
                     if ( error ) {
-                        if ( options.verbose && stepName == 'COMPOSE_RUN' ) {
+                        if ( verbose && stepName == 'COMPOSE_RUN' ) {
                             ora({
                                     text  : message,
                                     indent: 4
@@ -60,7 +72,7 @@ class AssignmentCheckCommand extends CommanderCommand {
                             spinner.fail(message);
                         }
                     } else {
-                        if ( options.verbose && stepName == 'COMPOSE_RUN' ) {
+                        if ( verbose && stepName == 'COMPOSE_RUN' ) {
                             ora({
                                     text  : message,
                                     indent: 4
diff --git a/NodeApp/src/sharedByClients b/NodeApp/src/sharedByClients
index 04e9ad7..68f6ffc 160000
--- a/NodeApp/src/sharedByClients
+++ b/NodeApp/src/sharedByClients
@@ -1 +1 @@
-Subproject commit 04e9ad7c9f53fe47ffb2ef6f2c0266e28c1c963b
+Subproject commit 68f6ffc241fabf4fd288871713419aab1d2d9f50
-- 
GitLab