Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ about: Create a report to help us improve
title: "[BUG] "
labels: bug
assignees: ahnafnafee

---

**Describe the bug**
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 '....'
Expand All @@ -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.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -26,7 +26,6 @@
"preview"
],
"activationEvents": [
"onCommand:postscript-preview.sidePreview",
"onLanguage:postscript"
],
"main": "./out/extension.js",
Expand Down Expand Up @@ -77,21 +76,20 @@
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"@types/glob": "^9.0.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": {
Expand Down
10 changes: 9 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -120,6 +127,7 @@ export function activate(context: vscode.ExtensionContext): void {
);

context.subscriptions.push(disposable);
console.log("PostScript Preview: Activation complete. Command registered.");
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/test/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});
45 changes: 27 additions & 18 deletions src/test/suite/index.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
// Create the mocha test
Expand All @@ -11,25 +11,34 @@ export async function run(): Promise<void> {

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);
}
}
);
});
}
8 changes: 6 additions & 2 deletions src/whats-new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ function isMajorUpdate(
*/
export async function showWhatsNew(context: ExtensionContext): Promise<void> {
const previousVersion = context.globalState.get<string>(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);
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -18,4 +19,4 @@
"node_modules",
".vscode-test"
]
}
}
50 changes: 1 addition & 49 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -127,13 +115,6 @@
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==
dependencies:
glob "*"

"@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"
Expand Down Expand Up @@ -655,15 +636,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"
Expand All @@ -676,7 +648,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==
Expand Down Expand Up @@ -918,23 +890,11 @@ 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:
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"
Expand Down Expand Up @@ -1098,14 +1058,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"
Expand Down