From 726412a655e5d4ccaf2247c825d2aa7ec0e2867a Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Mon, 16 Dec 2024 10:46:24 +0100 Subject: [PATCH] Add launch tasks for VS Code (#17772) * feat: add two launch tasks to start a vite server and attach to an existing vite server * build(deps-dev): install and use cross-env for vite commands * build: add mocked launch task * build: add prompt to check if msw should be on or off * build: defaults * build: rename launch task * build: add compound to start backend and frontend at the same time --- .vscode/launch.json | 154 +++++++++++++++----- src/Umbraco.Web.UI.Client/package-lock.json | 20 +++ src/Umbraco.Web.UI.Client/package.json | 5 +- 3 files changed, 144 insertions(+), 35 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index f40f2a827070..5f4eb9034512 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,35 +1,123 @@ { - "version": "0.2.0", - "configurations": [ - { - // Use IntelliSense to find out which attributes exist for C# debugging - // Use hover for the description of the existing attributes - // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md - "name": ".NET Core Launch (web)", - "type": "coreclr", - "request": "launch", - "program": "dotnet", - "args": ["run"], - "cwd": "${workspaceFolder}/src/Umbraco.Web.UI", - "stopAtEntry": false, - "requireExactSource": false, - // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser - "serverReadyAction": { - "action": "openExternally", - "pattern": "\\\\bNow listening on:\\\\s+(https?://\\\\S+)" - }, - "env": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "sourceFileMap": { - "/Views": "${workspaceFolder}/Views" - } - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach", - "processId": "${command:pickProcess}" - } - ] + "version": "0.2.0", + "compounds": [ + { + "name": "Backoffice Launch (Vite + .NET Core)", + "configurations": [ + "Backoffice Launch Vite (Chrome)", + ".NET Core Serve with External Auth (web)" + ], + "stopAll": true, + "presentation": { + "group": "1" + } + } + ], + "configurations": [ + { + "name": "Backoffice Launch Vite (Chrome)", + "request": "launch", + "env": { + "VITE_UMBRACO_USE_MSW": "${input:AskForMockServer}" + }, + "runtimeExecutable": "npx", + "runtimeArgs": ["vite"], + "type": "node", + "cwd": "${workspaceFolder}/src/Umbraco.Web.UI.Client", + "skipFiles": ["/**", "node_modules/**"], + "smartStep": true, + "autoAttachChildProcesses": true, + "serverReadyAction": { + "killOnServerStop": true, + "action": "debugWithChrome", + "pattern": "Local: http://localhost:([0-9]+)", + "uriFormat": "http://localhost:%s", + "webRoot": "${workspaceFolder}/src/Umbraco.Web.UI.Client" + }, + "presentation": { + "group": "2" + } + }, + { + "name": "Backoffice Attach Vite (Chrome)", + "request": "launch", + "type": "chrome", + "smartStep": true, + "url": "http://localhost:5173/", + "skipFiles": ["/**", "node_modules/**"], + "webRoot": "${workspaceFolder}/src/Umbraco.Web.UI.Client", + "presentation": { + "group": "2" + } + }, + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "program": "dotnet", + "args": ["run"], + "cwd": "${workspaceFolder}/src/Umbraco.Web.UI", + "stopAtEntry": false, + "requireExactSource": false, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\\\bNow listening on:\\\\s+(https?://\\\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Umbraco.Web.UI/Views" + }, + "presentation": { + "group": "3" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}", + "presentation": { + "group": "3" + } + }, + { + "name": ".NET Core Serve with External Auth (web)", + "type": "coreclr", + "request": "launch", + "program": "dotnet", + "args": ["run"], + "cwd": "${workspaceFolder}/src/Umbraco.Web.UI", + "stopAtEntry": false, + "requireExactSource": false, + "checkForDevCert": true, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "https://localhost:44339", + "UMBRACO__CMS__SECURITY__BACKOFFICEHOST": "http://localhost:5173", + "UMBRACO__CMS__SECURITY__AUTHORIZECALLBACKPATHNAME": "/oauth_complete", + "UMBRACO__CMS__SECURITY__AUTHORIZECALLBACKLOGOUTPATHNAME": "/logout", + "UMBRACO__CMS__SECURITY__AUTHORIZECALLBACKERRORPATHNAME": "/error" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Umbraco.Web.UI/Views" + }, + "presentation": { + "group": "3" + } + } + ], + "inputs": [ + { + "id": "AskForMockServer", + "type": "promptString", + "description": "Use Mock Service Worker (MSW) for Backoffice API calls (off requires a running server)?", + "default": "off" + } + ] } diff --git a/src/Umbraco.Web.UI.Client/package-lock.json b/src/Umbraco.Web.UI.Client/package-lock.json index 720f9f606987..90e4256d2645 100644 --- a/src/Umbraco.Web.UI.Client/package-lock.json +++ b/src/Umbraco.Web.UI.Client/package-lock.json @@ -66,6 +66,7 @@ "@web/test-runner": "^0.19.0", "@web/test-runner-playwright": "^0.11.0", "babel-loader": "^9.2.1", + "cross-env": "7.0.3", "eslint": "^9.15.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.31.0", @@ -7112,6 +7113,25 @@ "integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==", "license": "MIT" }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", diff --git a/src/Umbraco.Web.UI.Client/package.json b/src/Umbraco.Web.UI.Client/package.json index ba5f733c9b70..d36eb74cebd4 100644 --- a/src/Umbraco.Web.UI.Client/package.json +++ b/src/Umbraco.Web.UI.Client/package.json @@ -161,8 +161,8 @@ "check:circular": "madge --circular --warning --extensions ts ./src", "compile": "tsc", "dev": "vite", - "dev:server": "VITE_UMBRACO_USE_MSW=off vite", - "dev:mock": "VITE_UMBRACO_USE_MSW=on vite", + "dev:server": "cross-env VITE_UMBRACO_USE_MSW=off vite", + "dev:mock": "cross-env VITE_UMBRACO_USE_MSW=on vite", "example": "node ./devops/example-runner/index.js", "format:fix": "npm run format -- --write", "format": "prettier 'src/**/*.ts' --check", @@ -253,6 +253,7 @@ "@web/test-runner": "^0.19.0", "@web/test-runner-playwright": "^0.11.0", "babel-loader": "^9.2.1", + "cross-env": "7.0.3", "eslint": "^9.15.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.31.0",