diff --git a/NodeApp/package-lock.json b/NodeApp/package-lock.json index f971eb6179b3ab26a8212b4d1feca408ddb586fc..6077bca055b5e5bb8c3622a189c73fc1434d8b60 100644 --- a/NodeApp/package-lock.json +++ b/NodeApp/package-lock.json @@ -14,6 +14,7 @@ "axios": "^1.6.5", "boxen": "^5.1.2", "chalk": "^4.1.2", + "cli-table3": "^0.6.3", "commander": "^11.1.0", "dotenv": "^16.3.1", "dotenv-expand": "^10.0.0", @@ -1588,6 +1589,29 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/cli-table3": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.3.tgz", + "integrity": "sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg==", + "dependencies": { + "string-width": "^4.2.0" + }, + "engines": { + "node": "10.* || >= 12.*" + }, + "optionalDependencies": { + "@colors/colors": "1.5.0" + } + }, + "node_modules/cli-table3/node_modules/@colors/colors": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", + "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", + "optional": true, + "engines": { + "node": ">=0.1.90" + } + }, "node_modules/cli-width": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", diff --git a/NodeApp/package.json b/NodeApp/package.json index cea130b65abd9cad9e60bdc1f1afc9c6ccdc1a94..993e25e400ae21949c85e8479d41fd6778c94c66 100644 --- a/NodeApp/package.json +++ b/NodeApp/package.json @@ -1,16 +1,16 @@ { - "name" : "dojo_cli", - "description" : "CLI of the Dojo project", - "version" : "3.5.0", - "license" : "AGPLv3", - "author" : "Michaël Minelli <dojo@minelli.me>", - "main" : "dist/app.js", - "bin" : { + "name": "dojo_cli", + "description": "CLI of the Dojo project", + "version": "3.5.0", + "license": "AGPLv3", + "author": "Michaël Minelli <dojo@minelli.me>", + "main": "dist/app.js", + "bin": { "dojo": "./dist/app.js" }, - "pkg" : { + "pkg": { "scripts": [], - "assets" : [ + "assets": [ "node_modules/axios/dist/node/axios.cjs", ".env", "assets/**/*" @@ -24,51 +24,52 @@ "node18-win-x86" ] }, - "scripts" : { + "scripts": { "dotenv:build": "npx dotenv-vault local build", - "lint" : "npx eslint .", - "genversion" : "npx genversion -s -e src/config/Version.ts", - "build" : "npm run genversion; npx tsc", - "start:dev" : "npm run genversion; npm run lint; npx ts-node src/app.ts", - "test" : "echo \"Error: no test specified\" && exit 1" + "lint": "npx eslint .", + "genversion": "npx genversion -s -e src/config/Version.ts", + "build": "npm run genversion; npx tsc", + "start:dev": "npm run genversion; npm run lint; npx ts-node src/app.ts", + "test": "echo \"Error: no test specified\" && exit 1" }, - "dependencies" : { - "@gitbeaker/rest" : "^39.34.3", - "appdata-path" : "^1.0.0", - "axios" : "^1.6.5", - "boxen" : "^5.1.2", - "chalk" : "^4.1.2", - "commander" : "^11.1.0", - "dotenv" : "^16.3.1", - "dotenv-expand" : "^10.0.0", - "fs-extra" : "^11.2.0", - "http-status-codes" : "^2.3.0", - "inquirer" : "^8.2.6", - "json5" : "^2.2.3", - "jsonwebtoken" : "^8.5.1", - "open" : "^8.4.2", - "ora" : "^5.4.1", - "semver" : "^7.5.4", - "tar-stream" : "^3.1.6", - "winston" : "^3.11.0", - "yaml" : "^2.3.4", - "zod" : "^3.22.4", + "dependencies": { + "@gitbeaker/rest": "^39.34.3", + "appdata-path": "^1.0.0", + "axios": "^1.6.5", + "boxen": "^5.1.2", + "chalk": "^4.1.2", + "cli-table3": "^0.6.3", + "commander": "^11.1.0", + "dotenv": "^16.3.1", + "dotenv-expand": "^10.0.0", + "fs-extra": "^11.2.0", + "http-status-codes": "^2.3.0", + "inquirer": "^8.2.6", + "json5": "^2.2.3", + "jsonwebtoken": "^8.5.1", + "open": "^8.4.2", + "ora": "^5.4.1", + "semver": "^7.5.4", + "tar-stream": "^3.1.6", + "winston": "^3.11.0", + "yaml": "^2.3.4", + "zod": "^3.22.4", "zod-validation-error": "^3.0.0" }, "devDependencies": { - "@types/fs-extra" : "^11.0.4", - "@types/inquirer" : "^8.2.10", - "@types/jsonwebtoken" : "^8.5.9", - "@types/node" : "^18.19.2", - "@types/semver" : "^7.5.6", - "@types/tar-stream" : "^3.1.3", + "@types/fs-extra": "^11.0.4", + "@types/inquirer": "^8.2.10", + "@types/jsonwebtoken": "^8.5.9", + "@types/node": "^18.19.2", + "@types/semver": "^7.5.6", + "@types/tar-stream": "^3.1.3", "@typescript-eslint/eslint-plugin": "^6.18.1", - "@typescript-eslint/parser" : "^6.18.1", - "dotenv-vault" : "^1.25.0", - "genversion" : "^3.2.0", - "pkg" : "^5.8.1", - "tiny-typed-emitter" : "^2.1.0", - "ts-node" : "^10.9.2", - "typescript" : "^5.3.3" + "@typescript-eslint/parser": "^6.18.1", + "dotenv-vault": "^1.25.0", + "genversion": "^3.2.0", + "pkg": "^5.8.1", + "tiny-typed-emitter": "^2.1.0", + "ts-node": "^10.9.2", + "typescript": "^5.3.3" } } diff --git a/NodeApp/src/commander/assignment/subcommands/AssignmentDeleteCommand.ts b/NodeApp/src/commander/assignment/subcommands/AssignmentDeleteCommand.ts index 12a58ba8180b99071c4d78ec1b1bba0b05bec014..60eda55dbdf9bd1235af5bdd1d43d604e62fbcc7 100644 --- a/NodeApp/src/commander/assignment/subcommands/AssignmentDeleteCommand.ts +++ b/NodeApp/src/commander/assignment/subcommands/AssignmentDeleteCommand.ts @@ -21,12 +21,12 @@ class AssignmentDeleteCommand extends CommanderCommand { { console.log(chalk.cyan('Please wait while we are retrieving the users...')); assign = await DojoBackendManager.delAssignment(assignmentName); - const oraInfo = (message: string) => { - ora({ - text: message, - indent: 4 - }).start().info(); - }; + // const oraInfo = (message: string) => { + // ora({ + // text: message, + // indent: 4 + // }).start().info(); + // }; console.log(assign) // assign.forEach(a => { // oraInfo(`${chalk.magenta('ID :')} ${a.gitlabId}`); diff --git a/NodeApp/src/commander/assignment/subcommands/AssignmentListCommand.ts b/NodeApp/src/commander/assignment/subcommands/AssignmentListCommand.ts index 9867e02ff7544ef5495cd2cbce8e736c9fcd7dee..6aee3f0df2249e21b3a688797dfaa579d53f5dd0 100644 --- a/NodeApp/src/commander/assignment/subcommands/AssignmentListCommand.ts +++ b/NodeApp/src/commander/assignment/subcommands/AssignmentListCommand.ts @@ -4,6 +4,8 @@ import DojoBackendManager from "../../../managers/DojoBackendManager"; import ora from "ora"; import User from "../../../sharedByClients/models/User"; import SessionManager from "../../../managers/SessionManager"; +import Table from 'cli-table3'; +import Assignment from "../../../sharedByClients/models/Assignment"; class AssignmentListCommand extends CommanderCommand { protected commandName : string = 'list'; @@ -40,15 +42,22 @@ class AssignmentListCommand extends CommanderCommand { oraInfo(`${chalk.magenta('Name :')} ${user.gitlabUsername}`); oraInfo(`${chalk.magenta('Role :')} ${user.role}`); console.log(); - user.assignments?.forEach(assign => { - const d = new Date(assign.gitlabCreationInfo.last_activity_at).toDateString(); - - oraInfo(`${chalk.magenta(`Assignment ${assign.gitlabId}: `)} ${assign.name}`); - oraInfo(`${chalk.magenta(`Last Activity : `)} ${d}`); - oraInfo(`${chalk.magenta(`Link :`)} ${assign.gitlabLink}`); - }); + this.display(user.assignments); } } + + private display(assign: Assignment[] | undefined) { + const table = new Table({ + head: ['#', 'Assignment', 'Last Activity', 'Link'] + }); + + assign?.forEach((a, index) => { + const d = new Date(a.gitlabCreationInfo.last_activity_at).toDateString(); + table.push([index + 1, a.name, d, a.gitlabLink]) + }) + + console.log(table.toString()); + } } export default new AssignmentListCommand(); \ No newline at end of file