From 2507cbe8c4bfc73d833f519351df764849bdb2ef Mon Sep 17 00:00:00 2001 From: Ahnaf An Nafee Date: Wed, 17 Dec 2025 16:34:08 -0500 Subject: [PATCH 1/2] Fix glob dependency issue and improve activation logging --- .github/ISSUE_TEMPLATE/bug-report.md | 19 ++++++++++-- CHANGELOG.md | 5 ++++ package.json | 11 ++++--- src/extension.ts | 10 ++++++- src/test/runTest.ts | 6 +++- src/test/suite/extension.test.ts | 16 ++++++++++ src/test/suite/index.ts | 45 +++++++++++++++++----------- src/whats-new.ts | 8 +++-- tsconfig.json | 5 ++-- yarn.lock | 44 ++++++++++----------------- 10 files changed, 107 insertions(+), 62 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 7532f89..981cbab 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -4,7 +4,6 @@ about: Create a report to help us improve title: "[BUG] " labels: bug assignees: ahnafnafee - --- **Describe the bug** @@ -12,6 +11,7 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: + 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' @@ -24,8 +24,21 @@ A clear and concise description of what you expected to happen. If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - - OS: [e.g. Windows] - - Version [e.g. 0.3.0] + +- OS: [e.g. Windows] +- Version [e.g. 0.3.0] + +**Extension Host Logs** +Please provide logs to help us debug the issue: + +1. Open VS Code Command Palette (`Ctrl+Shift+P` / `Cmd+Shift+P`) +2. Run `Developer: Show Logs...` +3. Select `Extension Host` +4. Copy lines starting with `PostScript Preview:` or any errors that occurred around the time of the bug. + +```text +Paste logs here +``` **Additional context** Add any other context about the problem here. diff --git a/CHANGELOG.md b/CHANGELOG.md index 370756a..e108e60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## [0.5.2] - 2025-12-17 + +- Fixed `Cannot find module 'path-scurry'` runtime error by downgrading `glob` dependency. +- Fixed "Command not found" error during extension activation on Windows (caused by `showWhatsNew` crash). + ## [0.5.0] - 2025-12-15 ### New Features diff --git a/package.json b/package.json index b0be863..7e61121 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "postscript-preview", "displayName": "PostScript Preview", "description": "PostScript Preview is an extension that helps to preview EPS and PS files in Visual Studio Code.", - "version": "0.5.1", + "version": "0.5.2", "icon": "images/logo.png", "publisher": "ahnafnafee", "engines": { @@ -26,7 +26,6 @@ "preview" ], "activationEvents": [ - "onCommand:postscript-preview.sidePreview", "onLanguage:postscript" ], "main": "./out/extension.js", @@ -77,21 +76,21 @@ "test": "node ./out/test/runTest.js" }, "devDependencies": { - "@types/glob": "^9.0.0", + "@types/glob": "^7.2.0", "@types/mocha": "^10.0.10", "@types/node": "^25.0.2", "@types/vscode": "^1.46.0", "@typescript-eslint/eslint-plugin": "^8.50.0", "@typescript-eslint/parser": "^8.50.0", + "@vscode/test-electron": "^2.4.1", "eslint": "^9.39.2", - "glob": "^13.0.0", "lodash": "^4.17.21", "mocha": "^11.7.5", - "typescript": "^5.9.3", - "@vscode/test-electron": "^2.4.1" + "typescript": "^5.9.3" }, "dependencies": { "@types/temp": "^0.9.4", + "glob": "^7.2.3", "temp": "^0.9.1" }, "repository": { diff --git a/src/extension.ts b/src/extension.ts index 2c62bb3..5d1b605 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -13,10 +13,17 @@ import { showWhatsNew } from "./whats-new"; * Called when the extension is activated */ export function activate(context: vscode.ExtensionContext): void { + console.log("PostScript Preview: Activating extension..."); const isWindows = process.platform === "win32"; if (isWindows) { - showWhatsNew(context); // show notification in case of a minor release + console.log("PostScript Preview: Checking for updates (Windows)..."); + showWhatsNew(context).catch((error) => { + console.error( + "PostScript Preview: Failed to show whats new notification:", + error + ); + }); } const channel = vscode.window.createOutputChannel("PostScript-Preview"); @@ -120,6 +127,7 @@ export function activate(context: vscode.ExtensionContext): void { ); context.subscriptions.push(disposable); + console.log("PostScript Preview: Activation complete. Command registered."); } /** diff --git a/src/test/runTest.ts b/src/test/runTest.ts index 079585e..81ceb16 100644 --- a/src/test/runTest.ts +++ b/src/test/runTest.ts @@ -12,7 +12,11 @@ async function main() { const extensionTestsPath = path.resolve(__dirname, "./suite/index"); // Download VS Code, unzip it and run the integration test - await runTests({ extensionDevelopmentPath, extensionTestsPath }); + await runTests({ + extensionDevelopmentPath, + extensionTestsPath, + launchArgs: [extensionDevelopmentPath], + }); } catch (err) { console.error("Failed to run tests"); process.exit(1); diff --git a/src/test/suite/extension.test.ts b/src/test/suite/extension.test.ts index f698541..3132889 100644 --- a/src/test/suite/extension.test.ts +++ b/src/test/suite/extension.test.ts @@ -28,4 +28,20 @@ suite("Extension Test Suite", () => { const commands = await vscode.commands.getCommands(true); assert.ok(commands.includes("postscript-preview.sidePreview")); }); + + test("Preview command should execute without error", async () => { + // Ensure workspace is open + assert.ok(vscode.workspace.workspaceFolders, "No workspace is open"); + + const workspaceRoot = vscode.workspace.workspaceFolders[0].uri.fsPath; + const filePath = vscode.Uri.file( + workspaceRoot + "/examples/basic_shapes.ps" + ); + + const doc = await vscode.workspace.openTextDocument(filePath); + await vscode.window.showTextDocument(doc); + + // Execute the command - validation fails if this throws + await vscode.commands.executeCommand("postscript-preview.sidePreview"); + }); }); diff --git a/src/test/suite/index.ts b/src/test/suite/index.ts index 361d2c2..f224369 100644 --- a/src/test/suite/index.ts +++ b/src/test/suite/index.ts @@ -1,6 +1,6 @@ import * as path from "path"; import * as Mocha from "mocha"; -import { glob } from "glob"; +const glob = require("glob"); export async function run(): Promise { // Create the mocha test @@ -11,25 +11,34 @@ export async function run(): Promise { const testsRoot = path.resolve(__dirname, ".."); - // Use glob to find all files ending in .test.js - const files = await glob("**/**.test.js", { cwd: testsRoot }); + return new Promise((resolve, reject) => { + glob( + "**/**.test.js", + { cwd: testsRoot }, + (err: any, files: string[]) => { + if (err) { + return reject(err); + } - // Add files to the test suite - files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); + // Add files to the test suite + files.forEach((f: string) => + mocha.addFile(path.resolve(testsRoot, f)) + ); - return new Promise((resolve, reject) => { - try { - // Run the mocha test - mocha.run((failures) => { - if (failures > 0) { - reject(new Error(`${failures} tests failed.`)); - } else { - resolve(); + try { + // Run the mocha test + mocha.run((failures) => { + if (failures > 0) { + reject(new Error(`${failures} tests failed.`)); + } else { + resolve(); + } + }); + } catch (err) { + console.error(err); + reject(err); } - }); - } catch (err) { - console.error(err); - reject(err); - } + } + ); }); } diff --git a/src/whats-new.ts b/src/whats-new.ts index 55389b3..eeed9c4 100644 --- a/src/whats-new.ts +++ b/src/whats-new.ts @@ -36,8 +36,12 @@ function isMajorUpdate( */ export async function showWhatsNew(context: ExtensionContext): Promise { const previousVersion = context.globalState.get(extensionId); - const currentVersion = - extensions.getExtension(extensionId)?.packageJSON.version; + const extension = extensions.getExtension(extensionId); + const currentVersion = extension?.packageJSON?.version; + + if (!currentVersion) { + return; + } // store latest version context.globalState.update(extensionId, currentVersion); diff --git a/tsconfig.json b/tsconfig.json index b65c745..70851c0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,8 @@ ], "sourceMap": true, "rootDir": "src", - "strict": true /* enable all strict type-checking options */ + "strict": true, /* enable all strict type-checking options */ + "skipLibCheck": true, /* Additional Checks */ // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ @@ -18,4 +19,4 @@ "node_modules", ".vscode-test" ] -} +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index c2afcc6..c491c69 100644 --- a/yarn.lock +++ b/yarn.lock @@ -127,18 +127,26 @@ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.8.tgz#958b91c991b1867ced318bedea0e215ee050726e" integrity sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w== -"@types/glob@^9.0.0": - version "9.0.0" - resolved "https://registry.yarnpkg.com/@types/glob/-/glob-9.0.0.tgz#7b942fafe09c55671912b34f04e8e4676faf32b1" - integrity sha512-00UxlRaIUvYm4R4W9WYkN8/J+kV8fmOQ7okeH6YFtGWFMt3odD45tpG5yA5wnL7HE6lLgjaTW5n14ju2hl2NNA== +"@types/glob@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb" + integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA== dependencies: - glob "*" + "@types/minimatch" "*" + "@types/node" "*" "@types/json-schema@^7.0.15": version "7.0.15" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== +"@types/minimatch@*": + version "6.0.0" + resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-6.0.0.tgz#4d207b1cc941367bdcd195a3a781a7e4fc3b1e03" + integrity sha512-zmPitbQ8+6zNutpwgcQuLcsEpn/Cj54Kbn7L5pX0Os5kdWplB7xPgEh/g+SWOB/qmows2gpuCaPyduq8ZZRnxA== + dependencies: + minimatch "*" + "@types/mocha@^10.0.10": version "10.0.10" resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-10.0.10.tgz#91f62905e8d23cbd66225312f239454a23bebfa0" @@ -655,15 +663,6 @@ glob-parent@^6.0.2: dependencies: is-glob "^4.0.3" -glob@*, glob@^13.0.0: - version "13.0.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-13.0.0.tgz#9d9233a4a274fc28ef7adce5508b7ef6237a1be3" - integrity sha512-tvZgpqk6fz4BaNZ66ZsRaZnbHvP/jG3uKJvAZOwEVUL4RTA5nJeeLYfyN9/VA8NX/V3IBG+hkeuGpKjvELkVhA== - dependencies: - minimatch "^10.1.1" - minipass "^7.1.2" - path-scurry "^2.0.0" - glob@^10.4.5: version "10.5.0" resolved "https://registry.yarnpkg.com/glob/-/glob-10.5.0.tgz#8ec0355919cd3338c28428a23d4f24ecc5fe738c" @@ -676,7 +675,7 @@ glob@^10.4.5: package-json-from-dist "^1.0.0" path-scurry "^1.11.1" -glob@^7.1.3: +glob@^7.1.3, glob@^7.2.3: version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== @@ -918,17 +917,12 @@ lru-cache@^10.2.0: resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119" integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ== -lru-cache@^11.0.0: - version "11.2.4" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-11.2.4.tgz#ecb523ebb0e6f4d837c807ad1abaea8e0619770d" - integrity sha512-B5Y16Jr9LB9dHVkh6ZevG+vAbOsNOYCX+sXvFWFu7B3Iz5mijW3zdbMyhsh8ANd2mSWBYdJgnqi+mL7/LrOPYg== - mimic-function@^5.0.0: version "5.0.1" resolved "https://registry.yarnpkg.com/mimic-function/-/mimic-function-5.0.1.tgz#acbe2b3349f99b9deaca7fb70e48b83e94e67076" integrity sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA== -minimatch@^10.1.1: +minimatch@*: version "10.1.1" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.1.1.tgz#e6e61b9b0c1dcab116b5a7d1458e8b6ae9e73a55" integrity sha512-enIvLvRAFZYXJzkCYG5RKmPfrFArdLv+R+lbQ53BmIMLIry74bjKzX6iHAm8WYamJkhSSEabrWN5D97XnKObjQ== @@ -1098,14 +1092,6 @@ path-scurry@^1.11.1: lru-cache "^10.2.0" minipass "^5.0.0 || ^6.0.2 || ^7.0.0" -path-scurry@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-2.0.1.tgz#4b6572376cfd8b811fca9cd1f5c24b3cbac0fe10" - integrity sha512-oWyT4gICAu+kaA7QWk/jvCHWarMKNs6pXOGWKDTr7cw4IGcUbW+PeTfbaQiLGheFRpjo6O9J0PmyMfQPjH71oA== - dependencies: - lru-cache "^11.0.0" - minipass "^7.1.2" - picocolors@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b" From c3976e6c97c00ad1bbbff6a0d7e936045d2fbb29 Mon Sep 17 00:00:00 2001 From: Ahnaf An Nafee Date: Wed, 17 Dec 2025 16:39:16 -0500 Subject: [PATCH 2/2] Remove @types/glob from devDependencies --- package.json | 1 - yarn.lock | 34 ---------------------------------- 2 files changed, 35 deletions(-) diff --git a/package.json b/package.json index 7e61121..ad4b325 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,6 @@ "test": "node ./out/test/runTest.js" }, "devDependencies": { - "@types/glob": "^7.2.0", "@types/mocha": "^10.0.10", "@types/node": "^25.0.2", "@types/vscode": "^1.46.0", diff --git a/yarn.lock b/yarn.lock index c491c69..b2cc463 100644 --- a/yarn.lock +++ b/yarn.lock @@ -93,18 +93,6 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.4.3.tgz#c2b9d2e374ee62c586d3adbea87199b1d7a7a6ba" integrity sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ== -"@isaacs/balanced-match@^4.0.1": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz#3081dadbc3460661b751e7591d7faea5df39dd29" - integrity sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ== - -"@isaacs/brace-expansion@^5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz#4b3dabab7d8e75a429414a96bd67bf4c1d13e0f3" - integrity sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA== - dependencies: - "@isaacs/balanced-match" "^4.0.1" - "@isaacs/cliui@^8.0.2": version "8.0.2" resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550" @@ -127,26 +115,11 @@ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.8.tgz#958b91c991b1867ced318bedea0e215ee050726e" integrity sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w== -"@types/glob@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb" - integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA== - dependencies: - "@types/minimatch" "*" - "@types/node" "*" - "@types/json-schema@^7.0.15": version "7.0.15" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== -"@types/minimatch@*": - version "6.0.0" - resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-6.0.0.tgz#4d207b1cc941367bdcd195a3a781a7e4fc3b1e03" - integrity sha512-zmPitbQ8+6zNutpwgcQuLcsEpn/Cj54Kbn7L5pX0Os5kdWplB7xPgEh/g+SWOB/qmows2gpuCaPyduq8ZZRnxA== - dependencies: - minimatch "*" - "@types/mocha@^10.0.10": version "10.0.10" resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-10.0.10.tgz#91f62905e8d23cbd66225312f239454a23bebfa0" @@ -922,13 +895,6 @@ mimic-function@^5.0.0: resolved "https://registry.yarnpkg.com/mimic-function/-/mimic-function-5.0.1.tgz#acbe2b3349f99b9deaca7fb70e48b83e94e67076" integrity sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA== -minimatch@*: - version "10.1.1" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.1.1.tgz#e6e61b9b0c1dcab116b5a7d1458e8b6ae9e73a55" - integrity sha512-enIvLvRAFZYXJzkCYG5RKmPfrFArdLv+R+lbQ53BmIMLIry74bjKzX6iHAm8WYamJkhSSEabrWN5D97XnKObjQ== - dependencies: - "@isaacs/brace-expansion" "^5.0.0" - minimatch@^3.1.1, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"