From 192be3bf061a208572d1dbf06288828aa76f805c Mon Sep 17 00:00:00 2001
From: Lansana DIOMANDE <ldiomande@takima.fr>
Date: Mon, 23 May 2022 18:19:18 +0200
Subject: [PATCH] refactor: improve source code

---
 .../deadlock-extension/dev/README.md          | 67 ++++++++-----------
 .../src/core/api.service.ts                   |  2 +-
 .../deadlock-extension/src/recorder/utils.ts  |  4 +-
 start.desktop.sh                              |  2 -
 4 files changed, 32 insertions(+), 43 deletions(-)

diff --git a/deadlock-plugins/deadlock-extension/dev/README.md b/deadlock-plugins/deadlock-extension/dev/README.md
index a723e2f9..e34ff205 100644
--- a/deadlock-plugins/deadlock-extension/dev/README.md
+++ b/deadlock-plugins/deadlock-extension/dev/README.md
@@ -7,67 +7,58 @@ VSCode extension to show a panel with :
 
 ## Quick start
 
-- Open `deadlock-extension` folder in Vscode
-- Run `setup-dev-env.sh` to mock mission configuration
-- Run `install.sh`
-- Inside the editor, press `F5` (or use `Run and Debug` tab).
+- Ouvrir le dossier `deadlock-extension` dans Vscode
+- Lancer le script `setup-dev-env.sh` pour simuler la configuration d'une mission
+- Lancer le script `install.sh`
+- Dans l'éditeur, appuyer sur `F5` (ou utiliser l'onglet `Run and Debug`).
 
-If something goes wrong, you may need to kill watch Task terminal between restarts.
+## Gitlab CI pour publier l'extension
 
-## Build a prod version
+Le pipeline a besoin d'un token provenant de la marketplace pour y publier l'extension.
 
-1. Upgrade the version with `npm version`. You can see how to use the command [here](https://docs.npmjs.com/cli/v8/commands/npm-version)
+- La méthode pour obtenir le token est décrite [ici](https://code.visualstudio.com/api/working-with-extensions/publishing-extension#get-a-personal-access-token)
+- Le token doit être inséré en tant que valeur de la variable `VSCODE_EXTENSION_MARKET_PLACE_ACCESS_TOKEN`
 
-2. Push
+**Le token a une durée de vie maximale de 1 an**
 
-```shell
-git push origin X.Y.Z --tags
-```
-
-## Release/pre-release management
-
-For the moment, the vscode marketplace does not fully support semver ([especially the suffixes](https://github.com/microsoft/vsmarketplace/issues/50#issuecomment-990764201)). It is therefore not possible to create an `0.0.1-alpha` version of the extension for example.
-
-### Publish a pre-release version
+## Gestion de la production et de la pré-production
 
-When you push a tag that have a version like X.Y.Z and `Z` is **odd**, a `pre-release` version of the extension is published.
+Pour le moment, la marketplace de Vscode ne supporte pas totalement le `semver`([spécialement les suffixes](https://github.com/microsoft/vsmarketplace/issues/50#issuecomment-990764201)). Il n'est pas possible de créer une version `0.0.1-alpha` de l'extension par example.
 
-### Publish a release version
+### Construire une version de pré-production
 
-When you push a tag that have a version like X.Y.Z and `Z` is **even**, a `release` version of the extension is published.
+Lorsque le travail est poussé sur la branche `master`, une version de l'extension est poussé en `pre-release` sur la marketplace.
 
-[More detail on how publish an extension on marketplace](https://code.visualstudio.com/api/working-with-extensions/publishing-extension)
+### Constuire une version de production
 
-### Gitlab pipeline to pusblish extension
+1. Monter la version de l'extension avec`npm version`. Vous pouvez voir comment utiliser la commande [ici](https://docs.npmjs.com/cli/v8/commands/npm-version).
 
-The pipeline needs a token from the marketplace in order to publish the extension.
+2. Pousser le code source et le tag
 
-- The method describing how to retrieve the token is described [here](https://code.visualstudio.com/api/working-with-extensions/publishing-extension#get-a-personal-access-token)
-- Then the token must be inserted as the value of the CI/CD variables `VSCODE_EXTENSION_MARKET_PLACE_ACCESS_TOKEN`
-
-**This token has a maximum lifetime of 1 year**
-
----
+```shell
+git push origin taBranch --tags
+```
 
-## Details on the use case to be tested
+## Le cas d'usage à essayer
 
 The use case to be tested to validate a US Deadlock Desktop corresponds to a use scenario. De facto, this scenario should be updated after each release of features.
+Le cas d'usage à essayer pour valider une US Deadlock Desktop correspond à un scénario utilisateur. Ce scénario doit être mis à jour à chaque mise à jour.
 
-Initial configuration:
+Configuration de base :
 
 - OS: Ubuntu 20.04.4 LTS
-- Browser: Mozilla Firefox (v99.0+), Google Chrome (v101.0+)
+- Navigateur: Mozilla Firefox (v99.0+), Google Chrome (v101.0+)
 - Docker version 20.10.14, build a224086
 - Visual Studio Code (v1.66.2+)
 
 Steps:
 
-1. Go to https://www.dev.deadlock.io/. The Keycloak authentication home page should appear.
-2. Log in via the Google Identity Provider. The user should be authenticated and redirected to the home page.
-3. Select and launch a desktop mission. Instructions specific to this type should be displayed on the mission overview page.
-4. All links on the mission page should work: dependencies installation, extension page on the Store, and xdg-open link opening VS Code.
-5. Once VS Code is open, a popup window should appear, suggesting the installation of the extension. Accept the installation. The installation should be successful, and the welcome to Deadlock notification should appear.
-6. Uninstall the extension, restart the IDE, and search for `deadlock` in the `marketplace` search bar. The extension should immediately appear in the first 3 results. Reinstall the extension.
+1. Aller sur https://www.dev.deadlock.io/. La page d'authentification doit apparaitre.
+2. Se connecter via Google. The user should be authenticated and redirected to the home page.
+3. Sélectionner et lancer une mission du type `desktop`. Les instructions de la mission doivent apparaître sur la page.
+4. Tous les liens sur la page de la mission doivent fonctionnés : installation de dépendances, la page de l'extension sur la marketplace, et le lien xdg-open permettant d'ouvrir Vscode.
+5. Lorsque VS Code est ouvert, une fenêtre doit apparaitre et suggérer l'installation de l'extension. Accepter l'installation. L'installation doit fonctionner et une notification de bienvenue doit apparaître.
+6. Désinstaller l'extension, relancer l'IDE, et chercher `deadlock` dans la barre de recherche de la `marketplace`. The extension should immediately appear in the first 3 results. Reinstall the extension.
 7. Re-click on the xdg-open link. A popup asking for the parent working folder should open.
 8. Select a directory that does not pose any access rights problems for the current user. A page on the default browser should open, allowing access to an OAuth Device Flow 2.0 authentication page.
 9. Validate the authentication using the Google provider and return to the extension. A login confirmation notification should be visible.
diff --git a/deadlock-plugins/deadlock-extension/src/core/api.service.ts b/deadlock-plugins/deadlock-extension/src/core/api.service.ts
index 9583bdc3..be281fc0 100644
--- a/deadlock-plugins/deadlock-extension/src/core/api.service.ts
+++ b/deadlock-plugins/deadlock-extension/src/core/api.service.ts
@@ -89,7 +89,7 @@ export default class ApiService {
 
       this.axiosInstance.defaults.headers.common['authorization'] = `BEARER ${accessToken}`;
       return this.axiosInstance(originalConfig);
-    } catch (_error: any) {
+    } catch (_error) {
       if (_error.response && _error.response.data) {
         return Promise.reject(_error.response.data);
       } else {
diff --git a/deadlock-plugins/deadlock-extension/src/recorder/utils.ts b/deadlock-plugins/deadlock-extension/src/recorder/utils.ts
index f3737fdc..aad779a4 100644
--- a/deadlock-plugins/deadlock-extension/src/recorder/utils.ts
+++ b/deadlock-plugins/deadlock-extension/src/recorder/utils.ts
@@ -138,7 +138,7 @@ async function commitAndPushCode(gitMission: GitMission) {
     await gitMission.commit(currentDate);
     await gitMission.push();
     log('Commit & push done.');
-  } catch (e: any) {
+  } catch (e) {
     error(`[${e.status}] cannot commitAndPush code: ${e.stderr}`);
     error(e.message);
     throw new Error(e);
@@ -157,7 +157,7 @@ async function mergeMaster(gitMission: GitMission) {
     await gitMission.push();
     log('Merge to master done');
     await gitMission.checkout(Branch.LIVE);
-  } catch (e: any) {
+  } catch (e) {
     error(`[${e.status}] cannot commitAndPush code: ${e.stderr}`);
     error(e.message);
     throw new Error(e);
diff --git a/start.desktop.sh b/start.desktop.sh
index e211e094..21d28863 100644
--- a/start.desktop.sh
+++ b/start.desktop.sh
@@ -25,8 +25,6 @@ fi
 
 
 su deadlock -c "sudo python /setup_trace.py"
-rm setup_trace.py
-
 
 
 # start command recorder
-- 
GitLab