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
38 changes: 0 additions & 38 deletions .eslintrc.json

This file was deleted.

14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: weekly
groups:
development-dependencies:
dependency-type: development

- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v7

- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}

- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v7
with:
node-version: 22
node-version: 24
cache: "yarn"

- name: Install dependencies
Expand Down
44 changes: 22 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@ jobs:
name: Build and package
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Use Node.js 22
uses: actions/setup-node@v4
- uses: actions/checkout@v7
- name: Use Node.js 24
uses: actions/setup-node@v7
with:
node-version: 22
node-version: 24
cache: "yarn"
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: |
npm install -g @vscode/vsce
npm install --global @vscode/vsce@3.9.2 ovsx@1.1.1
yarn install --frozen-lockfile
- name: Get NPM Version
- name: Get package version
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1
run: |
VERSION=$(node -p "require('./package.json').version")
echo "current-version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Run Tests
run: xvfb-run -a yarn test
- name: Check if version exists
Expand All @@ -34,6 +36,7 @@ jobs:
VERSION: ${{ steps.package-version.outputs.current-version }}
run: |
echo "Checking version $VERSION..."
echo "VERSION=$VERSION" >> "$GITHUB_ENV"

# Check VS Marketplace
VS_Response=$(curl -s --location 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery' \
Expand All @@ -56,21 +59,21 @@ jobs:
# Check if version exists (robust jq boolean)
if echo "$VS_Response" | jq -e --arg v "$VERSION" '.results[0].extensions[0].versions | map(select(.version == $v)) | length > 0' > /dev/null; then
echo "Version $VERSION already exists in VS Marketplace."
echo "VS_EXISTS=true" >> $GITHUB_ENV
echo "VS_EXISTS=true" >> "$GITHUB_ENV"
else
echo "Version $VERSION not found in VS Marketplace."
echo "VS_EXISTS=false" >> $GITHUB_ENV
echo "VS_EXISTS=false" >> "$GITHUB_ENV"
fi

# Check Open VSX
OVSX_Status=$(curl -o /dev/null -s -w "%{http_code}" https://open-vsx.org/api/ahnafnafee/postscript-preview/$VERSION)

if [ "$OVSX_Status" = "200" ]; then
echo "Version $VERSION already exists in Open VSX."
echo "OVSX_EXISTS=true" >> $GITHUB_ENV
echo "OVSX_EXISTS=true" >> "$GITHUB_ENV"
else
echo "Version $VERSION not found in Open VSX."
echo "OVSX_EXISTS=false" >> $GITHUB_ENV
echo "OVSX_EXISTS=false" >> "$GITHUB_ENV"
fi

- name: Validate Version Status
Expand All @@ -85,7 +88,7 @@ jobs:
run: vsce package -o postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix
- name: Upload a Build Artifact
if: env.VS_EXISTS == 'false' || env.OVSX_EXISTS == 'false'
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix
path: postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix
Expand All @@ -106,7 +109,7 @@ jobs:
' CHANGELOG.md > RELEASE_BODY.md
- name: Create release with artifact
if: (env.VS_EXISTS == 'false' || env.OVSX_EXISTS == 'false') && success()
uses: softprops/action-gh-release@v2.0.8
uses: softprops/action-gh-release@v3
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
with:
Expand All @@ -117,14 +120,11 @@ jobs:
files: postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix
- name: Publish to Open VSX Registry
if: env.OVSX_EXISTS == 'false'
uses: HaaLeo/publish-vscode-extension@v1
with:
pat: ${{ secrets.OPEN_VSX_TOKEN }}
extensionFile: postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix
env:
OVSX_PAT: ${{ secrets.OPEN_VSX_TOKEN }}
run: ovsx publish "postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix" --pat "$OVSX_PAT"
- name: Publish to Visual Studio Marketplace
if: env.VS_EXISTS == 'false'
uses: HaaLeo/publish-vscode-extension@v1
with:
pat: ${{ secrets.VS_MARKETPLACE_TOKEN }}
registryUrl: https://marketplace.visualstudio.com
extensionFile: postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix
env:
VSCE_PAT: ${{ secrets.VS_MARKETPLACE_TOKEN }}
run: vsce publish --packagePath "postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix"
9 changes: 5 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ on:
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
name: Test on ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js 22
uses: actions/setup-node@v4
- uses: actions/checkout@v7
- name: Use Node.js 24
uses: actions/setup-node@v7
with:
node-version: 22
node-version: 24
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
Expand Down
11 changes: 11 additions & 0 deletions .vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from "@vscode/test-cli";

export default defineConfig({
files: "out/test/suite/**/*.test.js",
workspaceFolder: ".",
mocha: {
ui: "tdd",
color: true,
timeout: 10_000,
},
});
2 changes: 2 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ demo/**
.eslintcache
.eslintignore
.eslintrc.json
eslint.config.js
.vscode-test.mjs
.gitattributes
.gitignore
.gitignore-revs
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Change Log

## [0.6.0] - 2026-08-29

### Security

- Removed the abandoned `temp` runtime dependency and replaced it with Node.js built-in temporary-directory handling.
- Stopped constructing shell command strings for GhostScript and Poppler tools; executable paths and arguments are now passed directly to child processes.
- Refreshed the supported development dependencies and regenerated the lockfile with patched transitive packages.

### Maintenance

- Updated CI to Node.js 24 and current Node.js 24-based GitHub Actions.
- Migrated extension tests to the current VS Code test CLI, including automatic installation of declared extension dependencies.
- Updated the VS Code test runtime to support current macOS runners.
- Added weekly Dependabot updates for npm packages and GitHub Actions.

## [0.5.4] - 2025-12-23

- Fixed an issue where previewing files with special characters in the filename (e.g., spaces, parentheses) would fail with a syntax error.
Expand Down
2 changes: 1 addition & 1 deletion TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This guide explains how to test the extension locally during development.

Ensure you have the following installed:

1. **Node.js** (v14 or later)
1. **Node.js 24** (the active LTS release used by CI)
2. **GhostScript** (provides `ps2pdf`)
3. **Poppler** (provides `pdftocairo` and `pdfinfo`)

Expand Down
29 changes: 29 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const eslint = require("@eslint/js");
const typescriptEslint = require("@typescript-eslint/eslint-plugin");

module.exports = [
{
ignores: ["out/**", "dist/**", "**/*.d.ts"],
},
eslint.configs.recommended,
...typescriptEslint.configs["flat/recommended"],
{
files: ["src/**/*.ts"],
rules: {
"@typescript-eslint/naming-convention": [
"warn",
{
selector: "class",
format: ["PascalCase"],
},
],
curly: "warn",
eqeqeq: "warn",
"no-throw-literal": "warn",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-empty-function": "off",
},
},
];
35 changes: 17 additions & 18 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.4",
"version": "0.6.0",
"icon": "images/logo.png",
"publisher": "ahnafnafee",
"engines": {
Expand Down Expand Up @@ -68,29 +68,28 @@
}
},
"scripts": {
"vscode:prepublish": "npm run compile",
"vscode:prepublish": "yarn compile",
"compile": "tsc -p ./",
"lint": "eslint src --ext ts",
"lint": "eslint src",
"watch": "tsc -watch -p ./",
"pretest": "npm run compile",
"test": "node ./out/test/runTest.js"
"pretest": "yarn compile",
"test": "vscode-test"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
"@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",
"lodash": "^4.17.21",
"mocha": "^11.7.5",
"typescript": "^5.9.3"
"@types/node": "^12.20.55",
"@types/vscode": "1.46.0",
"@typescript-eslint/eslint-plugin": "^8.68.0",
"@typescript-eslint/parser": "^8.68.0",
"@vscode/test-cli": "^0.0.15",
"@vscode/test-electron": "^3.1.0",
"eslint": "^10.9.1",
"typescript": "^6.0.3"
},
"dependencies": {
"@types/temp": "^0.9.4",
"glob": "^7.2.3",
"temp": "^0.9.1"
"resolutions": {
"diff": "^9.0.0",
"serialize-javascript": "^7.1.1"
},
"repository": {
"type": "git",
Expand Down
18 changes: 15 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import * as vscode from "vscode";
// biome-ignore lint/style/useNodejsImportProtocol: <explanation>
import path = require("path");
import { PreviewState } from "./types";
import { generatePreview } from "./preview";
import {
cleanupAllPreviewFiles,
cleanupPreviewFile,
generatePreview,
} from "./preview";
import { showWhatsNew } from "./whats-new";

/**
Expand Down Expand Up @@ -109,13 +113,19 @@ export function activate(context: vscode.ExtensionContext): void {

// Watch for file changes
const watcher = vscode.workspace.createFileSystemWatcher(filePath);
watcher.onDidChange((_: vscode.Uri) => {
watcher.onDidChange(() => {
channel.appendLine(`File changed, regenerating : ${filePath}`);
// Reset to page 1 on file change and regenerate PDF
generatePreview(mainFilePath, panel, channel);
});
panel.onDidDispose(() => {
watcher.dispose();
const state = (panel as any).__previewState as
| PreviewState
| undefined;
if (state) {
cleanupPreviewFile(state.pdfPath);
}
channel.appendLine(`Stop watching ${filePath}`);
});
}
Expand All @@ -128,4 +138,6 @@ export function activate(context: vscode.ExtensionContext): void {
/**
* Called when the extension is deactivated
*/
export function deactivate(): void {}
export function deactivate(): void {
cleanupAllPreviewFiles();
}
Loading