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
18 changes: 16 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,24 @@ jobs:
uses: actions/setup-node@v7
with:
node-version: 24
cache: "yarn"

- name: Enable Corepack
run: corepack enable

- name: Locate Yarn cache
id: yarn-cache
run: echo "path=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"

- name: Cache Yarn packages
uses: actions/cache@v5
with:
path: ${{ steps.yarn-cache.outputs.path }}
key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-${{ runner.os }}-

- name: Install dependencies
run: yarn install --frozen-lockfile
run: yarn install --immutable

- name: Build
run: yarn compile
Expand Down
23 changes: 19 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,26 @@ jobs:
uses: actions/setup-node@v7
with:
node-version: 24
cache: "yarn"
- name: Enable Corepack
run: corepack enable
- name: Locate Yarn cache
id: yarn-cache
run: echo "path=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
- name: Cache Yarn packages
uses: actions/cache@v5
with:
path: ${{ steps.yarn-cache.outputs.path }}
key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-${{ runner.os }}-
- name: Install dependencies
run: |
npm install --global @vscode/vsce@3.9.2 ovsx@1.1.1
yarn install --frozen-lockfile
yarn install --immutable
- name: Install native dependencies
run: |
sudo apt-get update
sudo apt-get install --yes ghostscript poppler-utils
- name: Get package version
id: package-version
run: |
Expand Down Expand Up @@ -84,7 +99,7 @@ jobs:

- name: Build extension
if: env.VS_EXISTS == 'false' || env.OVSX_EXISTS == 'false'
run: vsce package -o postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix
run: vsce package --no-dependencies -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@v7
Expand Down Expand Up @@ -126,4 +141,4 @@ jobs:
if: env.VS_EXISTS == 'false'
env:
VSCE_PAT: ${{ secrets.VS_MARKETPLACE_TOKEN }}
run: vsce publish --packagePath "postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix"
run: vsce publish --no-dependencies --packagePath "postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix"
85 changes: 78 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Unit Tests
name: Tests

on:
push:
Expand All @@ -20,12 +20,83 @@ jobs:
uses: actions/setup-node@v7
with:
node-version: 24
cache: 'yarn'
- name: Enable Corepack
run: corepack enable
- name: Locate Yarn cache
id: yarn-cache
shell: bash
run: echo "path=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
- name: Cache Yarn packages
uses: actions/cache@v5
with:
path: ${{ steps.yarn-cache.outputs.path }}
key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-${{ runner.os }}-
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run Tests (Linux)
run: yarn install --immutable
- name: Install native dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install --yes ghostscript poppler-utils
- name: Install native dependencies (macOS)
if: runner.os == 'macOS'
run: brew install ghostscript poppler
- name: Install native dependencies (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
choco install ghostscript --yes --no-progress

$popplerVersion = "26.02.0-0"
$popplerArchive = Join-Path $env:RUNNER_TEMP "poppler-$popplerVersion.zip"
$popplerDirectory = Join-Path $env:RUNNER_TEMP "poppler-$popplerVersion"
$popplerUrl = "https://github.com/oschwartz10612/poppler-windows/releases/download/v$popplerVersion/Release-$popplerVersion.zip"
$expectedHash = "993E4A94376ED712FAFC7058D724EA0B943D118BBD2305CD9ED55174EB85CDA5"

Invoke-WebRequest $popplerUrl -OutFile $popplerArchive
$actualHash = (Get-FileHash $popplerArchive -Algorithm SHA256).Hash
if ($actualHash -ne $expectedHash) {
throw "Poppler archive checksum mismatch"
}
Expand-Archive $popplerArchive -DestinationPath $popplerDirectory

$ghostscript = Get-ChildItem "$env:ProgramFiles\gs" -Filter gswin64c.exe -Recurse -File |
Sort-Object FullName |
Select-Object -Last 1
$pdftocairo = Get-ChildItem $popplerDirectory -Filter pdftocairo.exe -Recurse -File |
Sort-Object FullName |
Select-Object -Last 1
$pdfinfo = Get-ChildItem $popplerDirectory -Filter pdfinfo.exe -Recurse -File |
Sort-Object FullName |
Select-Object -Last 1

if (-not $ghostscript -or -not $pdftocairo -or -not $pdfinfo) {
throw "Ghostscript or Poppler executables were not installed"
}

$nativeDirectories = @(
$ghostscript.DirectoryName
$pdftocairo.DirectoryName
) | Select-Object -Unique

foreach ($directory in $nativeDirectories) {
$directory | Out-File $env:GITHUB_PATH -Encoding utf8 -Append
$env:Path = "$directory;$env:Path"
}

& $ghostscript.FullName -version
if ($LASTEXITCODE -ne 0) { throw "Ghostscript failed to start" }
& $pdftocairo.FullName -v
if ($LASTEXITCODE -ne 0) { throw "pdftocairo failed to start" }
& $pdfinfo.FullName -v
if ($LASTEXITCODE -ne 0) { throw "pdfinfo failed to start" }
- name: Run unit tests
run: yarn test:unit
- name: Run integration tests (Linux)
if: runner.os == 'Linux'
run: xvfb-run -a yarn test
- name: Run Tests (Windows/Mac)
run: xvfb-run -a yarn test:integration
- name: Run integration tests (Windows/macOS)
if: runner.os != 'Linux'
run: yarn test
run: yarn test:integration
8 changes: 7 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.vscode/**
.vscode-test/**
.github/**
.yarn/**
out/test/**
src/**
.gitignore
Expand All @@ -21,7 +23,11 @@ eslint.config.js
.mailmap
.prettierignore
.prettierrc
.yarnrc
.yarnrc.yml
ANTIGRAVITY.md
TESTING.md
docs/**
examples/**
CODE_OF_CONDUCT.md
CONTRIBUTING.md
generateEmojiShortcodeMap.js
Expand Down
2 changes: 0 additions & 2 deletions .yarnrc

This file was deleted.

2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
enableGlobalCache: true
nodeLinker: node-modules
12 changes: 7 additions & 5 deletions ANTIGRAVITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@

**PostScript Preview** is a VS Code extension that renders previews for `.ps` and `.eps` files.

- **Core Logic**: Uses `Ghostscript` (`ps2pdf`) to convert PS -> PDF, then `Poppler` (`pdftocairo`) to convert PDF -> SVG for display in a webview.
- **Core Logic**: Uses `Ghostscript` (`ps2pdf`, or native `gswin64c.exe` on Windows) to convert PS -> PDF, then `Poppler` (`pdftocairo`) to convert PDF -> SVG for display in a webview.
- **Languages**: TypeScript.

## Build & Test

- **Build**: `yarn compile` (runs `tsc`).
- **Test**: `yarn test` (runs VS Code extension tests via `mocha`).
- **Test**: `yarn test` (runs unit tests with Mocha, then integration tests in the VS Code extension host).
- **Lint**: `yarn lint` (`eslint`).

## Key Files

- **`src/extension.ts`**: Entry point. Registers commands (`postscript-preview.sidePreview`).
- **`src/preview.ts`**: Core logic.
- `generatePreview()`: Handles the `ps2pdf` and `pdftocairo` pipeline.
- **CRITICAL**: usage of `spawnSync` for `ps2pdf` must use `{ shell: false }` to support special characters in filenames.
- `generatePreview()`: Handles the Ghostscript and `pdftocairo` pipeline.
- **`src/postscript-command.ts`**: Builds shell-free Ghostscript commands, including the native `gswin64c.exe` invocation used on Windows.
- **CRITICAL**: converter processes must use `{ shell: false }` so filenames remain direct arguments and cannot be interpreted by a command shell.
- **`src/webview.ts`**: Generates HTML content for the webview.
- **`src/config.ts`**: Manages configuration settings (paths to executables).
- **`src/test/suite/extension.test.ts`**: Integration tests. Includes cases for special character filenames.
- **`src/test/unit/`**: Unit tests for pure parsing, command construction, and webview rendering behavior.
- **`src/test/integration/extension.test.ts`**: Integration tests. Includes cases for special character filenames.
- **`.github/workflows/release.yml`**: CI/CD for publishing. Automatically extracts changelog entries for release descriptions.

## Workflows
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Change Log

## [0.6.1] - 2026-08-29

### Improvements

- Redesigned the README for the Visual Studio Marketplace with current badges, clearer setup instructions, and streamlined project navigation.
- Added focused unit coverage and separated it from the VS Code integration test suite.
- Upgraded the project from Yarn Classic to Corepack-managed Yarn 4 with immutable CI installs.

### Fixes

- Made Windows PostScript conversion use the native Ghostscript executable without a command shell.
- Escaped filenames rendered in the preview and improved single-page and accessible pagination layouts.

## [0.6.0] - 2026-08-29

### Security
Expand Down
Loading
Loading