Skip to content
Snippets Groups Projects
Commit a5a10430 authored by Lansana DIOMANDE's avatar Lansana DIOMANDE Committed by Guillaume WEBER
Browse files

refactor(deadlock-extension): migration de l'extension de esbuild vers webpack

parent 48f942e1
Branches
No related tags found
2 merge requests!14feat: added mounted, .bashrc, .zshrc, added tests, added keycloak tests,!8feat(extension): login, open in devcontainer, automaticly save code, open briefing, publish extension
Showing
with 1739 additions and 188 deletions
...@@ -7,10 +7,11 @@ module.exports = { ...@@ -7,10 +7,11 @@ module.exports = {
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
rules: { rules: {
semi: [2, 'always'], semi: [2, 'always'],
quotes: [2, 'single' | 'backtick', 'avoid-escape'], '@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-unused-vars': 0,
'@typescript-eslint/no-explicit-any': 0, '@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/explicit-module-boundary-types': 0, '@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/no-non-null-assertion': 0, '@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-this-alias': 0,
}, },
}; };
{ {
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. // See http://go.microsoft.com/fwlink/?LinkId=827846
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp // for the documentation about the extensions.json format
"recommendations": ["dbaeumer.vscode-eslint", "amodio.tsl-problem-matcher"]
// List of extensions which should be recommended for users of this workspace.
"recommendations": ["dbaeumer.vscode-eslint"]
} }
...@@ -9,10 +9,20 @@ ...@@ -9,10 +9,20 @@
"name": "Run Extension", "name": "Run Extension",
"type": "extensionHost", "type": "extensionHost",
"request": "launch", "request": "launch",
"runtimeExecutable": "${execPath}", "args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"args": ["--extensionDevelopmentPath=${workspaceRoot}"], "outFiles": ["${workspaceFolder}/dist/**/*.js"],
"outFiles": ["${workspaceFolder}/out/**/*.js"], "preLaunchTask": "${defaultBuildTask}"
"preLaunchTask": "npm: watch" },
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": ["${workspaceFolder}/out/**/*.js", "${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "tasks: watch-tests"
} }
] ]
} }
// Place your settings in this file to overwrite default and user settings.
{ {
"editor.insertSpaces": false "files.exclude": {
"out": false, // set this to true to hide the "out" folder with the compiled JS files
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
},
"search.exclude": {
"out": true, // set this to false to include "out" folder in search results
"dist": true // set this to false to include "dist" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
} }
...@@ -6,15 +6,32 @@ ...@@ -6,15 +6,32 @@
{ {
"type": "npm", "type": "npm",
"script": "watch", "script": "watch",
"problemMatcher": "$tsc-watch", "problemMatcher": ["$ts-webpack-watch", "$tslint-webpack-watch"],
"isBackground": true, "isBackground": true,
"presentation": { "presentation": {
"reveal": "never" "reveal": "never",
"group": "watchers"
}, },
"group": { "group": {
"kind": "build", "kind": "build",
"isDefault": true "isDefault": true
} }
},
{
"type": "npm",
"script": "watch-tests",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never",
"group": "watchers"
},
"group": "build"
},
{
"label": "tasks: watch-tests",
"dependsOn": ["npm: watch", "npm: watch-tests"],
"problemMatcher": []
} }
] ]
} }
...@@ -7,10 +7,10 @@ VSCode extension to show a panel with : ...@@ -7,10 +7,10 @@ VSCode extension to show a panel with :
## Quick start ## Quick start
- Open `deadlock-extension` folder in Vscode
- Run `setup-dev-env.sh` to mock mission configuration - Run `setup-dev-env.sh` to mock mission configuration
- Run `install.sh` - Run `install.sh`
- Run `build.sh` - Inside the editor, press `F5` (or use `Run and Debug` tab).
- Press `F5` (or use `Run and Debug` tab).
If something goes wrong, you may need to kill watch Task terminal between restarts. If something goes wrong, you may need to kill watch Task terminal between restarts.
......
This diff is collapsed.
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
"onWebviewPanel:deadlockHelp", "onWebviewPanel:deadlockHelp",
"onStartupFinished" "onStartupFinished"
], ],
"main": "out/main.js", "main": "./dist/extension.js",
"contributes": { "contributes": {
"commands": [ "commands": [
{ {
...@@ -84,14 +84,18 @@ ...@@ -84,14 +84,18 @@
"scripts": { "scripts": {
"vsce-package": "vsce package --allow-missing-repository", "vsce-package": "vsce package --allow-missing-repository",
"vsce-publish": "vsce publish --allow-missing-repository", "vsce-publish": "vsce publish --allow-missing-repository",
"vscode:prepublish": "npm run build-extension",
"compile": "webpack",
"esbuild-base": "esbuild --bundle --format=cjs --platform=node", "esbuild-base": "esbuild --bundle --format=cjs --platform=node",
"build-extension": "npm run esbuild-base -- --external:vscode ./src/extension.ts --outfile=out/main.js --minify",
"build-recorder": "npm run esbuild-base -- ./src/recorder/index.ts --outfile=out/recorder.js --minify", "build-recorder": "npm run esbuild-base -- ./src/recorder/index.ts --outfile=out/recorder.js --minify",
"build-preStop": "npm run esbuild-base -- ./src/recorder/preStop.ts --outfile=out/preStop.js --minify",
"esbuild": "npm run esbuild-base -- --sourcemap", "esbuild": "npm run esbuild-base -- --sourcemap",
"esbuild-watch": "npm run esbuild-base -- --sourcemap --watch", "watch": "webpack --watch",
"lint": "eslint . --ext .ts,.tsx", "build-extension": "webpack --mode production --devtool hidden-source-map",
"watch": "tsc -w -p ./", "compile-tests": "tsc -p . --outDir out",
"watch-tests": "tsc -p . -w --outDir out",
"pretest": "npm run compile-tests && npm run compile && npm run lint",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js",
"postversion": "git add package*.json && auto-changelog -p && git add CHANGELOG.md && git commit -m \"build: $npm_package_version\" && git tag $npm_package_version && echo \" \\033[31m Don't forget to publish tags (exemple: git push origin $npm_package_version) \\033[0m\"" "postversion": "git add package*.json && auto-changelog -p && git add CHANGELOG.md && git commit -m \"build: $npm_package_version\" && git tag $npm_package_version && echo \" \\033[31m Don't forget to publish tags (exemple: git push origin $npm_package_version) \\033[0m\""
}, },
"dependencies": { "dependencies": {
...@@ -105,26 +109,32 @@ ...@@ -105,26 +109,32 @@
"marked": "^4.0.6", "marked": "^4.0.6",
"node-fetch": "^3.2.3", "node-fetch": "^3.2.3",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"simple-git": "^2.48.0" "simple-git": "^3.7.0"
}, },
"devDependencies": { "devDependencies": {
"@types/glob": "^7.2.0",
"@types/mocha": "^9.1.0",
"@types/crypto-js": "^4.1.1", "@types/crypto-js": "^4.1.1",
"@types/marked": "^4.0.1", "@types/marked": "^4.0.1",
"@types/node": "^12.20.47", "@types/node": "14.x",
"@types/node-fetch": "^2.6.1", "@types/node-fetch": "^2.6.1",
"@types/vscode": "^1.51.0", "@types/vscode": "^1.66.0",
"@typescript-eslint/eslint-plugin": "^3.10.1",
"@typescript-eslint/parser": "^3.10.1",
"auto-changelog": "^2.4.0", "auto-changelog": "^2.4.0",
"esbuild": "^0.14.2", "esbuild": "^0.14.2",
"eslint": "^7.32.0",
"prettier": "2.6.2", "prettier": "2.6.2",
"terser-webpack-plugin": "^5.2.5", "terser-webpack-plugin": "^5.2.5",
"ts-node": "^9.1.1", "ts-node": "^9.1.1",
"typescript": "^3.9.10",
"vsce": "^2.7.0", "vsce": "^2.7.0",
"webpack": "^5.65.0", "typescript": "^3.9.10",
"webpack-cli": "^4.9.1" "ts-loader": "^9.2.8",
"webpack": "^5.70.0",
"webpack-cli": "^4.9.2",
"@typescript-eslint/eslint-plugin": "^3.10.1",
"@typescript-eslint/parser": "^3.10.1",
"eslint": "^7.32.0",
"glob": "^7.2.0",
"mocha": "^9.2.2",
"@vscode/test-electron": "^2.1.3"
}, },
"extensionPack": [ "extensionPack": [
"ms-vscode-remote.remote-containers" "ms-vscode-remote.remote-containers"
......
...@@ -6,4 +6,4 @@ ...@@ -6,4 +6,4 @@
mkdir -p /home/$USER/deadlock-extension/project mkdir -p /home/$USER/deadlock-extension/project
mkdir -p /home/$USER/deadlock-extension/project-theia mkdir -p /home/$USER/deadlock-extension/project-theia
cp -R ./dev/* /home/$USER/deadlock-extension cp -R ./dev/ressources/* /home/$USER/deadlock-extension
...@@ -46,12 +46,13 @@ export default class Controller { ...@@ -46,12 +46,13 @@ export default class Controller {
handleUri(uri: vscode.Uri) { handleUri(uri: vscode.Uri) {
const queryParams = new URLSearchParams(uri.query); const queryParams = new URLSearchParams(uri.query);
const action = queryParams.get('action'); const action = queryParams.get('action');
// TODO: Should we follow eslint no-case-declarations ?
const missionId = queryParams.get('missionId');
const missionVersion = queryParams.get('missionVersion');
log('Opening link', uri); log('Opening link', uri);
switch (action) { switch (action) {
case 'open-mission': case 'open-mission':
const missionId = queryParams.get('missionId');
const missionVersion = queryParams.get('missionVersion');
if (!missionId || !missionVersion) { if (!missionId || !missionVersion) {
vscode.window.showErrorMessage('Identifiant ou version de la mission incorrect'); vscode.window.showErrorMessage('Identifiant ou version de la mission incorrect');
} else { } else {
...@@ -89,11 +90,8 @@ export default class Controller { ...@@ -89,11 +90,8 @@ export default class Controller {
} }
public async clear() { public async clear() {
console.log('CLEAR');
await this.extensionStore.clear(); await this.extensionStore.clear();
console.log('CLEAR2');
this.quickSetupView.isAlreadyConnected = false; this.quickSetupView.isAlreadyConnected = false;
console.log('CLEAR3');
} }
public async createSshKeyPairIfNotExist() { public async createSshKeyPairIfNotExist() {
......
...@@ -16,7 +16,7 @@ export default class ExtensionStore { ...@@ -16,7 +16,7 @@ export default class ExtensionStore {
public async clear() { public async clear() {
if (this.globalStorage.keys()) { if (this.globalStorage.keys()) {
for (let key of this.globalStorage.keys()) { for (const key of this.globalStorage.keys()) {
this.globalStorage.update(key, undefined); this.globalStorage.update(key, undefined);
} }
} }
......
...@@ -27,14 +27,14 @@ export default class KeycloakOAuth2DeviceFlowConnectionTest { ...@@ -27,14 +27,14 @@ export default class KeycloakOAuth2DeviceFlowConnectionTest {
log(`click here: ${link}`); log(`click here: ${link}`);
}; };
let tokens = await this.connection.getToken({ openLink: openLinkPlaceholder }); const tokens = await this.connection.getToken({ openLink: openLinkPlaceholder });
log('tokens', tokens); log('tokens', tokens);
if (!tokens?.refreshToken) { if (!tokens?.refreshToken) {
log("refresh token doesn't exist"); log("refresh token doesn't exist");
return; return;
} }
let refreshedTokens = await this.connection.getToken({ const refreshedTokens = await this.connection.getToken({
refreshToken: tokens.refreshToken, refreshToken: tokens.refreshToken,
openLink: openLinkPlaceholder, openLink: openLinkPlaceholder,
}); });
......
...@@ -67,7 +67,7 @@ export default class KeycloakOAuth2DeviceFlowConnection { ...@@ -67,7 +67,7 @@ export default class KeycloakOAuth2DeviceFlowConnection {
public async getToken(args: { refreshToken?: string; openLink?: (link: string) => void }) { public async getToken(args: { refreshToken?: string; openLink?: (link: string) => void }) {
const { refreshToken, openLink } = args; const { refreshToken, openLink } = args;
if (!!refreshToken) { if (refreshToken !== undefined) {
await this.createUserAuthentication({ await this.createUserAuthentication({
url: this.tokenUrl, url: this.tokenUrl,
body: (() => { body: (() => {
......
...@@ -29,7 +29,7 @@ export interface Base { ...@@ -29,7 +29,7 @@ export interface Base {
export interface VSCodespecific { export interface VSCodespecific {
extensions?: string[]; extensions?: string[];
settings?: object; settings?: Record<string, unknown>;
devPort?: string; devPort?: string;
} }
......
...@@ -2,8 +2,6 @@ import * as fs from 'fs'; ...@@ -2,8 +2,6 @@ import * as fs from 'fs';
import { userSshKeyFolderPath } from './config'; import { userSshKeyFolderPath } from './config';
export default class SshKeyManager { export default class SshKeyManager {
constructor() {}
public isSshKeyPairExist(): boolean { public isSshKeyPairExist(): boolean {
return this.isPrivateKeyExist() && this.isPublicKeyExist(); return this.isPrivateKeyExist() && this.isPublicKeyExist();
} }
......
import * as path from 'path';
import { runTests } from '@vscode/test-electron';
async function main() {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
// The path to test runner
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './suite/index');
// Download VS Code, unzip it and run the integration test
await runTests({ extensionDevelopmentPath, extensionTestsPath });
} catch (err) {
console.error('Failed to run tests');
process.exit(1);
}
}
main();
import * as assert from 'assert';
// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import * as vscode from 'vscode';
// import * as myExtension from '../../extension';
suite('Extension Test Suite', () => {
vscode.window.showInformationMessage('Start all tests.');
test('Sample test', () => {
assert.strictEqual(-1, [1, 2, 3].indexOf(5));
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment