From b071a32ed4cdaee5469f533e745b87e9baca7ea4 Mon Sep 17 00:00:00 2001 From: Kelvin Schoofs Date: Sat, 16 Jan 2021 16:08:51 +0100 Subject: [PATCH] Update webview create-react-app framework and IDE support --- .vscode/tasks.json | 66 +- src/fileSystemConfig.ts | 2 +- src/webview.ts | 1 + webview/.env | 4 + webview/.gitignore | 1 + webview/package.json | 26 +- webview/public/index.html | 2 +- webview/src/ConfigList/index.tsx | 2 +- webview/src/FieldTypes/base.tsx | 2 +- webview/src/FieldTypes/dropdown.tsx | 8 +- webview/src/FieldTypes/dropdownwithinput.tsx | 2 +- webview/src/FieldTypes/string.tsx | 3 - webview/src/Startscreen.tsx | 5 +- webview/src/react-app-env.d.ts | 1 + webview/src/types/fileSystemConfig.ts | 2 +- webview/src/vscode.ts | 2 +- webview/tsconfig.json | 26 +- webview/tsconfig.prod.json | 3 - webview/tsconfig.test.json | 6 - webview/yarn.lock | 11765 ++++++++++------- 20 files changed, 7247 insertions(+), 4682 deletions(-) create mode 100644 webview/.env create mode 100644 webview/src/react-app-env.d.ts delete mode 100644 webview/tsconfig.prod.json delete mode 100644 webview/tsconfig.test.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json index d82a55b..7e7c648 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -37,30 +37,52 @@ "cwd": "./webview" }, "group": "build", - "problemMatcher": { - "source": "react-dev-utils", - "severity": "error", - "fileLocation": "absolute", - "applyTo": "closedDocuments", - "background": { - "activeOnStart": true, - "beginsPattern": "Compiling.*?|Compilation .*?starting", - "endsPattern": "Compiled .*?successfully|Failed .*?to.*?compile.*?" + "problemMatcher": [ + { + "source": "parser", + "owner": "react", + "fileLocation": "absolute", + "applyTo": "allDocuments", + "pattern": [ + { + "regexp": "^SyntaxError: (.*): (.+) \\((\\d+):(\\d+)\\)$", + "file": 1, + "message": 2, + "line": 3, + "column": 4 + } + ], + "background": { + "activeOnStart": true, + "beginsPattern": "^Compiling.*", + "endsPattern": "^(Compiled successfully|Failed to compile)" + } }, - "pattern": [ - { - "regexp": "^(.+)$", - "file": 1 - }, - { - "regexp": "\\((\\d+),(\\d+)\\):\\s*(.+)", - "line": 1, - "column": 2, - "message": 3, - "loop": true + { + "source": "typescript", + "owner": "react", + "fileLocation": "absolute", + "applyTo": "allDocuments", + "pattern": [ + { + "regexp": "^TypeScript error in (.*)\\((\\d+),(\\d+)\\):", + "file": 1, + "line": 2, + "column": 3 + }, + { + "regexp": "^(.{5,})$", + "message": 1, + "loop": true + } + ], + "background": { + "activeOnStart": true, + "beginsPattern": "^Compiling.*", + "endsPattern": "^(Compiled successfully|Failed to compile)" } - ] - }, + } + ], "isBackground": true } ] diff --git a/src/fileSystemConfig.ts b/src/fileSystemConfig.ts index 35b5dfd..4ea92d6 100644 --- a/src/fileSystemConfig.ts +++ b/src/fileSystemConfig.ts @@ -110,6 +110,6 @@ export interface FileSystemConfig extends ConnectConfig { export function invalidConfigName(name: string) { if (!name) return 'Missing a name for this SSH FS'; - if (name.match(/^[\w_\\\/\.@\-+]+$/)) return null; + if (name.match(/^[\w_\\/.@\-+]+$/)) return null; return `A SSH FS name can only exists of lowercase alphanumeric characters, slashes and any of these: _.+-@`; } diff --git a/src/webview.ts b/src/webview.ts index d8e959a..014664b 100644 --- a/src/webview.ts +++ b/src/webview.ts @@ -31,6 +31,7 @@ async function getDebugContent(): Promise { // Make sure the CSP meta tag also includes the React dev server (including connect-src for the socket, which uses both http:// and ws://) body = body.replace(/\$WEBVIEW_CSPSOURCE/g, `$WEBVIEW_CSPSOURCE ${URL}`); body = body.replace(/\$WEBVIEW_CSPEXTRA/g, `connect-src ${URL} ${URL.replace('http://', 'ws://')};`); + body = body.replace(/src="\/static\//g, `src="${URL}/static/`); cb(null, body); }).on('error', err => { Logging.warning(`Error connecting to React dev server: ${err}`); diff --git a/webview/.env b/webview/.env new file mode 100644 index 0000000..38ad0f3 --- /dev/null +++ b/webview/.env @@ -0,0 +1,4 @@ +WDS_SOCKET_HOST=localhost +WDS_SOCKET_PORT=3000 +BROWSER=none +SKIP_PREFLIGHT_CHECK=true diff --git a/webview/.gitignore b/webview/.gitignore index 4db5f33..d73532b 100644 --- a/webview/.gitignore +++ b/webview/.gitignore @@ -15,6 +15,7 @@ build .env.development.local .env.test.local .env.production.local +.eslintcache npm-debug.log* yarn-debug.log* diff --git a/webview/package.json b/webview/package.json index 06734e1..03e2255 100644 --- a/webview/package.json +++ b/webview/package.json @@ -9,18 +9,30 @@ "redux": "^4.0.5" }, "scripts": { - "start": "cross-env BROWSER=none react-scripts-ts start", - "build": "react-scripts-ts build", - "test": "react-scripts-ts test --env=jsdom", - "eject": "react-scripts-ts eject" + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test", + "eject": "react-scripts eject" }, "devDependencies": { "@types/jest": "^25.1.4", "@types/react": "^16.9.23", "@types/react-dom": "^16.9.5", "@types/react-redux": "^7.1.7", - "cross-env": "^7.0.3", - "react-scripts-ts": "^3.1.0", + "react-scripts": "^4.0.1", "typescript": "^4.0.2" + }, + "browserslist": [ + "Electron >= 9.0.0" + ], + "eslintConfig": { + "extends": [ + "react-app", + "react-app/jest" + ], + "rules": { + "no-sparse-arrays": 0, + "no-sequences": 0 + } } -} +} \ No newline at end of file diff --git a/webview/public/index.html b/webview/public/index.html index 2eb8536..940102b 100644 --- a/webview/public/index.html +++ b/webview/public/index.html @@ -2,7 +2,7 @@ - +