Skip to content

Commit 67670a6

Browse files
nprijicveredcon
andauthored
feat: migrating to Vue3 (#280)
* feat: migrating to Vue3 * fix: removing unnecessary code from Vite config * fix: removing unnecessary css style * fix: adding folder browser to test case * fix: proxy objects --------- Co-authored-by: Vered Constantin1 <[email protected]>
1 parent f68b953 commit 67670a6

29 files changed

+4568
-6400
lines changed

.eslintrc.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
node: true,
88
jest: true,
99
es6: true,
10+
es2020: true,
1011
},
1112
rules: {
1213
"eslint-comments/require-description": ["error", { ignore: [] }],
@@ -19,7 +20,7 @@ module.exports = {
1920
parserOptions: {
2021
// The `ecmaVersion` should align to the supported features of our target runtimes (browsers / nodejs / others)
2122
// Consult with: https://kangax.github.io/compat-table/es2016plus/
22-
ecmaVersion: 2017,
23+
ecmaVersion: 2020,
2324
},
2425
},
2526
{
@@ -30,7 +31,7 @@ module.exports = {
3031
sourceType: "module",
3132
// The `ecmaVersion` should align to the supported features of our target runtimes (browsers / nodejs / others)
3233
// Consult with: https://kangax.github.io/compat-table/es2016plus/
33-
ecmaVersion: 2018,
34+
ecmaVersion: 2020,
3435
},
3536
},
3637
{

.github/workflows/ci.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
node_version:
18-
- 14.x
19-
# Build fails on node versions 16 and 18
20-
# - 16.x
21-
# - 18.x
18+
- 20.x
2219
# https://stackoverflow.com/questions/61070925/github-actions-disable-auto-cancel-when-job-fails
2320
fail-fast: false
2421

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v1
1212
- uses: actions/setup-node@v3
1313
with:
14-
node-version: '14.x'
14+
node-version: '20.x'
1515
registry-url: 'https://registry.npmjs.org'
1616
cache: 'yarn'
1717

examples/vscode-snippet-contrib/src/configHelper.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class ConfigHelper {
1313
}
1414
try {
1515
return _.merge(parse(content), ConfigHelper.getDefaultContent());
16-
} catch (e) {
16+
} catch (e: any) {
1717
vscode.window.showErrorMessage(e.message);
1818
return Promise.reject();
1919
}

examples/vscode-snippet-contrib/src/extension.ts

+17
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,23 @@ function createCodeSnippetQuestions(): any[] {
142142
default: "",
143143
message: "Program",
144144
},
145+
{
146+
guiOptions: {
147+
hint: "Select the folder you want to run.",
148+
type: "folder-browser",
149+
link: {
150+
text: "Open Settings",
151+
command: {
152+
id: "workbench.action.openSettings",
153+
params: ["Typescript.Format"],
154+
},
155+
},
156+
},
157+
type: "input",
158+
name: "folder",
159+
default: "",
160+
message: "Select folder",
161+
},
145162
{
146163
type: "input",
147164
guiOptions: {

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
"@commitlint/config-conventional": "11.0.0",
3535
"@types/chai": "4.2.16",
3636
"@types/mocha": "7.0.2",
37-
"@typescript-eslint/eslint-plugin": "4.15.0",
38-
"@typescript-eslint/parser": "4.20.0",
37+
"@typescript-eslint/eslint-plugin": "5.28.0",
38+
"@typescript-eslint/parser": "5.28.0",
3939
"chai": "4.3.4",
4040
"coveralls": "2.11.16",
4141
"cz-conventional-changelog": "3.3.0",
@@ -53,7 +53,7 @@
5353
"prettier": "2.2.1",
5454
"rimraf": "3.0.2",
5555
"shx": "0.3.3",
56-
"typescript": "^3.9.7"
56+
"typescript": "~4.5.0"
5757
},
5858
"husky": {
5959
"hooks": {

packages/backend/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@
121121
"lodash": "4.17.21",
122122
"strip-ansi": "6.0.0",
123123
"ws": "7.4.4",
124-
"yeoman-environment": "2.10.3"
124+
"yeoman-environment": "2.10.3",
125+
"jsdom": "23.2.0"
125126
},
126127
"devDependencies": {
127128
"@types/fs-extra": "^9.0.4",
@@ -136,7 +137,7 @@
136137
"ts-loader": "^8.0.14",
137138
"ts-node": "^9.1.1",
138139
"vsce": "^1.73.0",
139-
"webpack": "^4.43.0",
140-
"webpack-cli": "^3.3.11"
140+
"webpack": "^5.89.0",
141+
"webpack-cli": "5.1.4"
141142
}
142143
}

packages/backend/src/extension.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function activate(context: vscode.ExtensionContext): void {
1616
try {
1717
createExtensionLoggerAndSubscribeToLogSettingsChanges(context);
1818
SWA.createSWATracker(getLogger());
19-
} catch (error) {
19+
} catch (error: any) {
2020
console.error(
2121
"Extension activation failed due to Logger configuration failure:",
2222
error.message

packages/backend/src/panels/AbstractWebviewPanel.ts

+21-14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as fsextra from "fs-extra";
55
import { IChildLogger } from "@vscode-logging/logger";
66
import { getClassLogger } from "../logger/logger-wrapper";
77
import { createFlowPromise, FlowPromise } from "../utils";
8+
import { JSDOM } from "jsdom";
89

910
export abstract class AbstractWebviewPanel {
1011
public viewType: string;
@@ -147,20 +148,26 @@ export abstract class AbstractWebviewPanel {
147148
scriptPathOnDisk
148149
);
149150

150-
// TODO: very fragile: assuming double quotes and src is first attribute
151-
// specifically, doesn't work when building vue for development (vue-cli-service build --mode development)
152-
indexHtml = indexHtml.replace(
153-
/<link href=/g,
154-
`<link href=${scriptUri.toString()}`
155-
);
156-
indexHtml = indexHtml.replace(
157-
/<script src=/g,
158-
`<script src=${scriptUri.toString()}`
159-
);
160-
indexHtml = indexHtml.replace(
161-
/<img src=/g,
162-
`<img src=${scriptUri.toString()}`
163-
);
151+
const baseUrl = scriptUri.toString();
152+
const dom = new JSDOM(indexHtml);
153+
const { document } = dom.window;
154+
155+
function replaceAttributePaths(elements: any, attributeName: string) {
156+
elements.forEach((element: any) => {
157+
const currentAttr = element.getAttribute(attributeName);
158+
if (currentAttr) {
159+
element.setAttribute(attributeName, `${baseUrl}/${currentAttr}`);
160+
}
161+
});
162+
}
163+
164+
const srcElements = document.querySelectorAll("[src]");
165+
const hrefElements = document.querySelectorAll("[href]");
166+
167+
replaceAttributePaths(srcElements, "src");
168+
replaceAttributePaths(hrefElements, "href");
169+
170+
indexHtml = dom.serialize();
164171
}
165172
this.webViewPanel.webview.html = indexHtml;
166173
}

packages/backend/src/swa-tracker/swa-tracker-wrapper.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class SWA {
7979
`SAP Web Analytics tracker was created for ${SWA.CODE_SNIPPET}`
8080
);
8181
}
82-
} catch (error) {
82+
} catch (error: any) {
8383
logger.error(error);
8484
}
8585
}
@@ -106,7 +106,7 @@ export class SWA {
106106
);
107107
}
108108
}
109-
} catch (error) {
109+
} catch (error: any) {
110110
logger.error(error);
111111
}
112112
}
@@ -144,7 +144,7 @@ export class SWA {
144144
});
145145
}
146146
}
147-
} catch (error) {
147+
} catch (error: any) {
148148
logger.error(error);
149149
}
150150
}

packages/backend/test/code-snippet.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ describe("codeSnippet unit test", () => {
557557
"question1",
558558
"method1"
559559
);
560-
} catch (e) {
560+
} catch (e: any) {
561561
expect(e.stack).to.contain("method1");
562562
}
563563
});

packages/backend/webpack.config.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ const config = {
1818
vscode: "commonjs vscode", // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/
1919
},
2020
resolve: {
21-
modules: ["node_modules"],
22-
// support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
2321
extensions: [".ts", ".js"],
22+
alias: {},
2423
},
2524
module: {
2625
rules: [
@@ -30,10 +29,14 @@ const config = {
3029
use: [
3130
{
3231
loader: "ts-loader",
32+
options: {},
3333
},
3434
],
3535
},
3636
],
3737
},
38+
optimization: {},
39+
plugins: [],
3840
};
41+
3942
module.exports = config;

packages/frontend/babel.config.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
module.exports = {
2-
presets: ["@vue/app", ["@babel/preset-env", { modules: false }]],
3-
env: {
4-
test: {
5-
presets: [["@babel/preset-env", { targets: { node: "current" } }]],
6-
},
7-
},
2+
presets: ["@babel/preset-env", "@babel/preset-typescript"],
3+
plugins: [
4+
"@babel/plugin-transform-modules-commonjs",
5+
"@babel/plugin-transform-runtime",
6+
],
87
};

packages/frontend/index.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
8+
<title>Code-snippet</title>
9+
</head>
10+
<body >
11+
<div id="app"></div>
12+
<script type="module" src="/src/main.js"></script>
13+
</body>
14+
</html>

packages/frontend/jest.config.js

+17-12
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,36 @@ module.exports = {
22
verbose: true,
33
testRegex: "(/test/(.*).(test|spec)).[jt]sx?$",
44
collectCoverage: true,
5+
coverageProvider: "v8",
56
collectCoverageFrom: [
67
"src/**/*.{js,vue}",
78
"!**/node_modules/**",
89
"!<rootDir>/src/main.js",
10+
"!<rootDir>/src/assets/**",
911
"!<rootDir>/src/plugins/**",
1012
],
11-
coverageReporters: ["lcov", "html", "text-summary"],
13+
moduleNameMapper: {
14+
"^@/(.*)$": "<rootDir>/src/$1",
15+
},
1216
moduleFileExtensions: ["js", "vue", "json"],
13-
transformIgnorePatterns: ["<rootDir>/node_modules/(?!(@sap-devx)/)"],
17+
transformIgnorePatterns: ["<rootDir>/node_modules/(?!(.+)/)"],
1418
modulePaths: ["<rootDir>/src", "<rootDir>/node_modules"],
1519
transform: {
16-
".*\\.(vue)$": "vue-jest",
17-
"^.+\\.vue$": "vue-jest",
18-
".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$":
19-
"jest-transform-stub",
20+
"^.+\\.vue$": "@vue/vue3-jest",
2021
"^.+\\.tsx?$": "ts-jest",
21-
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
22+
"^.+\\.js$": "babel-jest",
23+
"^.+\\.jsx?$": "babel-jest",
24+
},
25+
testEnvironmentOptions: {
26+
customExportConditions: ["node", "node-addons"],
2227
},
23-
snapshotSerializers: ["<rootDir>/node_modules/jest-serializer-vue"],
28+
testEnvironment: "jsdom",
2429
coverageThreshold: {
2530
global: {
26-
branches: 85,
27-
functions: 96.9,
28-
lines: 95.5,
29-
statements: 95.5,
31+
branches: 89,
32+
functions: 78,
33+
lines: 89,
34+
statements: 89,
3035
},
3136
},
3237
};

0 commit comments

Comments
 (0)