From d5ad8cd4efb971779122c15f5a24e375dcf7717e Mon Sep 17 00:00:00 2001 From: Matt Seddon <37993418+mattseddon@users.noreply.github.com> Date: Tue, 2 May 2023 07:08:52 +1000 Subject: [PATCH 1/2] Display progress errors to users (#3791) --- extension/src/setup/autoInstall.ts | 42 +++++++------ .../src/test/suite/setup/autoInstall.test.ts | 60 +++++++++++++++++++ extension/src/vscode/toast.ts | 16 +++++ 3 files changed, 101 insertions(+), 17 deletions(-) diff --git a/extension/src/setup/autoInstall.ts b/extension/src/setup/autoInstall.ts index 49b4b43421..b38480e43a 100644 --- a/extension/src/setup/autoInstall.ts +++ b/extension/src/setup/autoInstall.ts @@ -23,25 +23,33 @@ const showInstallProgress = ( Toast.showProgress('Installing packages', async progress => { progress.report({ increment: 0 }) - await Toast.runCommandAndIncrementProgress( - async () => { - await installPackages(root, pythonBinPath, 'dvclive') - return 'DVCLive Installed' - }, - progress, - 25 - ) + try { + await Toast.runCommandAndIncrementProgress( + async () => { + await installPackages(root, pythonBinPath, 'dvclive') + return 'DVCLive Installed' + }, + progress, + 25 + ) + } catch (error: unknown) { + return Toast.reportProgressError(error, progress) + } - await Toast.runCommandAndIncrementProgress( - async () => { - await installPackages(root, pythonBinPath, 'dvc') - return 'DVC Installed' - }, - progress, - 75 - ) + try { + await Toast.runCommandAndIncrementProgress( + async () => { + await installPackages(root, pythonBinPath, 'dvc') + return 'DVC Installed' + }, + progress, + 75 + ) - return Toast.delayProgressClosing() + return Toast.delayProgressClosing() + } catch (error: unknown) { + return Toast.reportProgressError(error, progress) + } }) export const autoInstallDvc = async (): Promise => { diff --git a/extension/src/test/suite/setup/autoInstall.test.ts b/extension/src/test/suite/setup/autoInstall.test.ts index 44276f5dfd..775a75fb32 100644 --- a/extension/src/test/suite/setup/autoInstall.test.ts +++ b/extension/src/test/suite/setup/autoInstall.test.ts @@ -8,6 +8,7 @@ import * as Python from '../../../python' import { autoInstallDvc } from '../../../setup/autoInstall' import * as WorkspaceFolders from '../../../vscode/workspaceFolders' import { bypassProgressCloseDelay } from '../util' +import { Toast } from '../../../vscode/toast' const { getDefaultPython } = Python @@ -89,5 +90,64 @@ suite('Auto Install Test Suite', () => { 'dvclive' ) }) + + it('should show an error message and exit early if DVCLive fails to install', async () => { + bypassProgressCloseDelay() + const cwd = __dirname + stub(PythonExtension, 'getPythonExecutionDetails').resolves(undefined) + stub(Python, 'findPythonBin').resolves(defaultPython) + const mockInstallPackages = stub(Python, 'installPackages').rejects( + new Error('Failed to install DVCLive') + ) + stub(WorkspaceFolders, 'getFirstWorkspaceFolder').returns(cwd) + + const showProgressSpy = spy(window, 'withProgress') + const showErrorSpy = spy(window, 'showErrorMessage') + + await autoInstallDvc() + + expect(showProgressSpy).to.be.called + expect(showErrorSpy).not.to.be.called + expect(mockInstallPackages).to.be.calledOnce + expect(mockInstallPackages).to.be.calledWithExactly( + cwd, + defaultPython, + 'dvclive' + ) + }) + + it('should show an error message if DVC fails to install', async () => { + bypassProgressCloseDelay() + const cwd = __dirname + stub(PythonExtension, 'getPythonExecutionDetails').resolves(undefined) + stub(Python, 'findPythonBin').resolves(defaultPython) + const mockInstallPackages = stub(Python, 'installPackages') + .onFirstCall() + .resolves(undefined) + .onSecondCall() + .rejects(new Error('Network error')) + stub(WorkspaceFolders, 'getFirstWorkspaceFolder').returns(cwd) + + const showProgressSpy = spy(window, 'withProgress') + const showErrorSpy = spy(window, 'showErrorMessage') + const reportProgressErrorSpy = spy(Toast, 'reportProgressError') + + await autoInstallDvc() + + expect(showProgressSpy).to.be.called + expect(showErrorSpy).not.to.be.called + expect(reportProgressErrorSpy).to.be.calledOnce + expect(mockInstallPackages).to.be.calledTwice + expect(mockInstallPackages).to.be.calledWithExactly( + cwd, + defaultPython, + 'dvclive' + ) + expect(mockInstallPackages).to.be.calledWithExactly( + cwd, + defaultPython, + 'dvc' + ) + }) }) }) diff --git a/extension/src/vscode/toast.ts b/extension/src/vscode/toast.ts index d8006950a2..cd4c81579e 100644 --- a/extension/src/vscode/toast.ts +++ b/extension/src/vscode/toast.ts @@ -75,6 +75,22 @@ export class Toast { }) } + static reportProgressError( + error: unknown, + progress: Progress<{ + message?: string | undefined + increment?: number | undefined + }> + ) { + const message = (error as Error)?.message || 'an unexpected error occurred' + + progress.report({ + increment: 0, + message + }) + return Toast.delayProgressClosing(60000) + } + static delayProgressClosing(ms = 5000) { return delay(ms) } From 03019fbbe6a643908e0dfc8ebff9645610d5712b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 1 May 2023 21:54:01 +0000 Subject: [PATCH 2/2] chore(deps): update typescript-eslint monorepo to v5.59.1 (#3795) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 4 +- yarn.lock | 102 +++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 77 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index 5a52863fa9..322bfb42f9 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,8 @@ "svgr": "yarn workspace dvc-vscode-webview svgr" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "5.59.0", - "@typescript-eslint/parser": "5.59.0", + "@typescript-eslint/eslint-plugin": "5.59.1", + "@typescript-eslint/parser": "5.59.1", "@vscode/codicons": "0.0.32", "eslint": "8.39.0", "eslint-config-prettier": "8.8.0", diff --git a/yarn.lock b/yarn.lock index 0f482d7dcc..46820f1e67 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5513,15 +5513,15 @@ dependencies: "@types/node" "*" -"@typescript-eslint/eslint-plugin@5.59.0": - version "5.59.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.0.tgz#c0e10eeb936debe5d1c3433cf36206a95befefd0" - integrity sha512-p0QgrEyrxAWBecR56gyn3wkG15TJdI//eetInP3zYRewDh0XS+DhB3VUAd3QqvziFsfaQIoIuZMxZRB7vXYaYw== +"@typescript-eslint/eslint-plugin@5.59.1": + version "5.59.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.1.tgz#9b09ee1541bff1d2cebdcb87e7ce4a4003acde08" + integrity sha512-AVi0uazY5quFB9hlp2Xv+ogpfpk77xzsgsIEWyVS7uK/c7MZ5tw7ZPbapa0SbfkqE0fsAMkz5UwtgMLVk2BQAg== dependencies: "@eslint-community/regexpp" "^4.4.0" - "@typescript-eslint/scope-manager" "5.59.0" - "@typescript-eslint/type-utils" "5.59.0" - "@typescript-eslint/utils" "5.59.0" + "@typescript-eslint/scope-manager" "5.59.1" + "@typescript-eslint/type-utils" "5.59.1" + "@typescript-eslint/utils" "5.59.1" debug "^4.3.4" grapheme-splitter "^1.0.4" ignore "^5.2.0" @@ -5536,14 +5536,14 @@ dependencies: "@typescript-eslint/utils" "5.25.0" -"@typescript-eslint/parser@5.59.0": - version "5.59.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.59.0.tgz#0ad7cd019346cc5d150363f64869eca10ca9977c" - integrity sha512-qK9TZ70eJtjojSUMrrEwA9ZDQ4N0e/AuoOIgXuNBorXYcBDk397D2r5MIe1B3cok/oCtdNC5j+lUUpVB+Dpb+w== +"@typescript-eslint/parser@5.59.1": + version "5.59.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.59.1.tgz#73c2c12127c5c1182d2e5b71a8fa2a85d215cbb4" + integrity sha512-nzjFAN8WEu6yPRDizIFyzAfgK7nybPodMNFGNH0M9tei2gYnYszRDqVA0xlnRjkl7Hkx2vYrEdb6fP2a21cG1g== dependencies: - "@typescript-eslint/scope-manager" "5.59.0" - "@typescript-eslint/types" "5.59.0" - "@typescript-eslint/typescript-estree" "5.59.0" + "@typescript-eslint/scope-manager" "5.59.1" + "@typescript-eslint/types" "5.59.1" + "@typescript-eslint/typescript-estree" "5.59.1" debug "^4.3.4" "@typescript-eslint/scope-manager@5.17.0": @@ -5570,13 +5570,21 @@ "@typescript-eslint/types" "5.59.0" "@typescript-eslint/visitor-keys" "5.59.0" -"@typescript-eslint/type-utils@5.59.0": - version "5.59.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.59.0.tgz#8e8d1420fc2265989fa3a0d897bde37f3851e8c9" - integrity sha512-d/B6VSWnZwu70kcKQSCqjcXpVH+7ABKH8P1KNn4K7j5PXXuycZTPXF44Nui0TEm6rbWGi8kc78xRgOC4n7xFgA== +"@typescript-eslint/scope-manager@5.59.1": + version "5.59.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.59.1.tgz#8a20222719cebc5198618a5d44113705b51fd7fe" + integrity sha512-mau0waO5frJctPuAzcxiNWqJR5Z8V0190FTSqRw1Q4Euop6+zTwHAf8YIXNwDOT29tyUDrQ65jSg9aTU/H0omA== dependencies: - "@typescript-eslint/typescript-estree" "5.59.0" - "@typescript-eslint/utils" "5.59.0" + "@typescript-eslint/types" "5.59.1" + "@typescript-eslint/visitor-keys" "5.59.1" + +"@typescript-eslint/type-utils@5.59.1": + version "5.59.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.59.1.tgz#63981d61684fd24eda2f9f08c0a47ecb000a2111" + integrity sha512-ZMWQ+Oh82jWqWzvM3xU+9y5U7MEMVv6GLioM3R5NJk6uvP47kZ7YvlgSHJ7ERD6bOY7Q4uxWm25c76HKEwIjZw== + dependencies: + "@typescript-eslint/typescript-estree" "5.59.1" + "@typescript-eslint/utils" "5.59.1" debug "^4.3.4" tsutils "^3.21.0" @@ -5595,6 +5603,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.59.0.tgz#3fcdac7dbf923ec5251545acdd9f1d42d7c4fe32" integrity sha512-yR2h1NotF23xFFYKHZs17QJnB51J/s+ud4PYU4MqdZbzeNxpgUr05+dNeCN/bb6raslHvGdd6BFCkVhpPk/ZeA== +"@typescript-eslint/types@5.59.1": + version "5.59.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.59.1.tgz#03f3fedd1c044cb336ebc34cc7855f121991f41d" + integrity sha512-dg0ICB+RZwHlysIy/Dh1SP+gnXNzwd/KS0JprD3Lmgmdq+dJAJnUPe1gNG34p0U19HvRlGX733d/KqscrGC1Pg== + "@typescript-eslint/typescript-estree@5.17.0": version "5.17.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.17.0.tgz#a7cba7dfc8f9cc2ac78c18584e684507df4f2488" @@ -5634,6 +5647,19 @@ semver "^7.3.7" tsutils "^3.21.0" +"@typescript-eslint/typescript-estree@5.59.1": + version "5.59.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.1.tgz#4aa546d27fd0d477c618f0ca00b483f0ec84c43c" + integrity sha512-lYLBBOCsFltFy7XVqzX0Ju+Lh3WPIAWxYpmH/Q7ZoqzbscLiCW00LeYCdsUnnfnj29/s1WovXKh2gwCoinHNGA== + dependencies: + "@typescript-eslint/types" "5.59.1" + "@typescript-eslint/visitor-keys" "5.59.1" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + semver "^7.3.7" + tsutils "^3.21.0" + "@typescript-eslint/utils@5.25.0": version "5.25.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.25.0.tgz#272751fd737733294b4ab95e16c7f2d4a75c2049" @@ -5646,17 +5672,17 @@ eslint-scope "^5.1.1" eslint-utils "^3.0.0" -"@typescript-eslint/utils@5.59.0", "@typescript-eslint/utils@^5.58.0": - version "5.59.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.59.0.tgz#063d066b3bc4850c18872649ed0da9ee72d833d5" - integrity sha512-GGLFd+86drlHSvPgN/el6dRQNYYGOvRSDVydsUaQluwIW3HvbXuxyuD5JETvBt/9qGYe+lOrDk6gRrWOHb/FvA== +"@typescript-eslint/utils@5.59.1": + version "5.59.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.59.1.tgz#d89fc758ad23d2157cfae53f0b429bdf15db9473" + integrity sha512-MkTe7FE+K1/GxZkP5gRj3rCztg45bEhsd8HYjczBuYm+qFHP5vtZmjx3B0yUCDotceQ4sHgTyz60Ycl225njmA== dependencies: "@eslint-community/eslint-utils" "^4.2.0" "@types/json-schema" "^7.0.9" "@types/semver" "^7.3.12" - "@typescript-eslint/scope-manager" "5.59.0" - "@typescript-eslint/types" "5.59.0" - "@typescript-eslint/typescript-estree" "5.59.0" + "@typescript-eslint/scope-manager" "5.59.1" + "@typescript-eslint/types" "5.59.1" + "@typescript-eslint/typescript-estree" "5.59.1" eslint-scope "^5.1.1" semver "^7.3.7" @@ -5672,6 +5698,20 @@ eslint-scope "^5.1.1" eslint-utils "^3.0.0" +"@typescript-eslint/utils@^5.58.0": + version "5.59.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.59.0.tgz#063d066b3bc4850c18872649ed0da9ee72d833d5" + integrity sha512-GGLFd+86drlHSvPgN/el6dRQNYYGOvRSDVydsUaQluwIW3HvbXuxyuD5JETvBt/9qGYe+lOrDk6gRrWOHb/FvA== + dependencies: + "@eslint-community/eslint-utils" "^4.2.0" + "@types/json-schema" "^7.0.9" + "@types/semver" "^7.3.12" + "@typescript-eslint/scope-manager" "5.59.0" + "@typescript-eslint/types" "5.59.0" + "@typescript-eslint/typescript-estree" "5.59.0" + eslint-scope "^5.1.1" + semver "^7.3.7" + "@typescript-eslint/visitor-keys@5.17.0": version "5.17.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.17.0.tgz#52daae45c61b0211b4c81b53a71841911e479128" @@ -5696,6 +5736,14 @@ "@typescript-eslint/types" "5.59.0" eslint-visitor-keys "^3.3.0" +"@typescript-eslint/visitor-keys@5.59.1": + version "5.59.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.1.tgz#0d96c36efb6560d7fb8eb85de10442c10d8f6058" + integrity sha512-6waEYwBTCWryx0VJmP7JaM4FpipLsFl9CvYf2foAE8Qh/Y0s+bxWysciwOs0LTBED4JCaNxTZ5rGadB14M6dwA== + dependencies: + "@typescript-eslint/types" "5.59.1" + eslint-visitor-keys "^3.3.0" + "@ungap/promise-all-settled@1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44"