4 Commits
Author SHA1 Message Date
Jarvis b322e6801c chore: release 1.4.0
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 18:30:36 +01:00
AlexKucera 9957e4fb58 Merge pull request #9 from AlexKucera/version_checker
Enforces minimum version checks for dependencies
2025-11-09 18:28:16 +01:00
AlexKucera d078215361 Makes version regex case-insensitive
Updates the regex patterns in the dependency checks
to be case-insensitive, improving flexibility and reliability
when parsing version information from executables.

Aligned with improvements on the version_checker branch.
2025-11-09 18:09:20 +01:00
AlexKucera b5ca5d1e47 Enforces minimum version checks for dependencies
Updates the README with specific minimum version requirements
for dependencies. Implements logic to check installed
dependencies against these minimum versions, issuing
warnings for outdated versions. Introduces utilities to
compare version strings for accurate validation.

This ensures compatibility and stability by guiding users
to update necessary tools for optimal performance.

Relates to version control and dependency management.
2025-11-09 18:02:46 +01:00
9 changed files with 162 additions and 29 deletions

No files matched your search

+18
View File
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [1.4.0] - 2025-01-09
### Added
- Minimum version requirements for external dependencies (Pandoc 3.7.0+, Typst 0.13.0+, ImageMagick 7.1.2+)
- Version comparison utilities (`compareVersions`, `isVersionAtLeast`) for semantic version validation
- Outdated dependency warnings in dependency checker with detailed version information
- Enhanced dependency status display showing current version vs. minimum required version
- Comprehensive version checking documentation in README
### Changed
- Updated README to document minimum version requirements in Quick Start and Requirements sections
- Enhanced dependency checker to validate installed versions against minimum requirements
- Improved user-facing dependency status messages with version-specific guidance
### Fixed
- Case-sensitive regex pattern for Typst version detection (now case-insensitive with `/i` flag)
- Version extraction now correctly handles "Typst 0.13.0" (capital T) format
## [1.3.1] - 2025-11-09 ## [1.3.1] - 2025-11-09
### Added ### Added
+11 -8
View File
@@ -131,9 +131,9 @@ For development or the latest changes:
### 1. Install Dependencies ### 1. Install Dependencies
**Required:** **Required:**
- [Pandoc](https://pandoc.org/installing.html) - Markdown to Typst conversion - [Pandoc](https://pandoc.org/installing.html) 3.7.0+ - Markdown to Typst conversion
- [Typst](https://typst.app/docs/reference/foundations/) - PDF generation - [Typst](https://typst.app/docs/reference/foundations/) 0.13.0+ - PDF generation
- [ImageMagick](https://imagemagick.org/script/download.php) - Enhanced image processing - [ImageMagick](https://imagemagick.org/script/download.php) 7.1.2+ - Enhanced image processing
### 2. Export Your First Note ### 2. Export Your First Note
@@ -173,11 +173,13 @@ Go to the plugin settings and click **Check Dependencies** to ensure all require
### External Dependencies ### External Dependencies
| Tool | Purpose | Installation | | Tool | Minimum Version | Purpose | Installation |
|------|---------|-------------| |------|----------------|---------|-------------|
| **Pandoc** | Markdown → Typst conversion | [Download here](https://pandoc.org/installing.html) or `brew install pandoc` | | **Pandoc** | 3.7.0 | Markdown → Typst conversion | [Download here](https://pandoc.org/installing.html) or `brew install pandoc` |
| **Typst** | PDF generation | [Download here](https://typst.app/docs/reference/foundations/) or `brew install typst` | | **Typst** | 0.13.0 | PDF generation | [Download here](https://typst.app/docs/reference/foundations/) or `brew install typst` |
| **ImageMagick** | Enhanced image processing (optional) | [Download here](https://imagemagick.org/script/download.php) or `brew install imagemagick` | | **ImageMagick** | 7.1.2 | Enhanced image processing (optional) | [Download here](https://imagemagick.org/script/download.php) or `brew install imagemagick` |
**Note**: The plugin will display warnings if your installed versions are below the minimum requirements. While older versions may work, they are not officially supported and may cause compatibility issues.
### Dependency Verification ### Dependency Verification
@@ -259,6 +261,7 @@ JB
|---------|----------| |---------|----------|
| **"Pandoc not found"** | Install Pandoc and ensure it's in your system PATH | | **"Pandoc not found"** | Install Pandoc and ensure it's in your system PATH |
| **"Typst not found"** | Install Typst CLI and verify PATH configuration | | **"Typst not found"** | Install Typst CLI and verify PATH configuration |
| **Outdated version warning** | Update dependencies to meet minimum versions (Pandoc 3.7.0+, Typst 0.13.0+, ImageMagick 7.1.2+) |
| **Export hangs** | Check if files are locked by other applications | | **Export hangs** | Check if files are locked by other applications |
| **Images not showing** | Verify image paths and file permissions | | **Images not showing** | Verify image paths and file permissions |
| **Template errors** | Check template syntax and file integrity | | **Template errors** | Check template syntax and file integrity |
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"id": "typst-pdf-export", "id": "typst-pdf-export",
"name": "Typst PDF Export", "name": "Typst PDF Export",
"version": "1.3.1", "version": "1.4.0",
"minAppVersion": "1.9.12", "minAppVersion": "1.9.12",
"description": "Exports a note or collection of notes to a pretty Typst PDF.", "description": "Exports a note or collection of notes to a pretty Typst PDF.",
"author": "Alexander Kucera", "author": "Alexander Kucera",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "obsidian-typst-pdf-export", "name": "obsidian-typst-pdf-export",
"version": "1.3.1", "version": "1.4.0",
"description": "Exports a note or collection of notes to a pretty Typst PDF.", "description": "Exports a note or collection of notes to a pretty Typst PDF.",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
+32 -11
View File
@@ -23,6 +23,7 @@ import { ExecutableChecker, DependencyInfo } from './ExecutableChecker';
* @property imagemagick - Detailed information about ImageMagick installation * @property imagemagick - Detailed information about ImageMagick installation
* @property allAvailable - True if all dependencies are available * @property allAvailable - True if all dependencies are available
* @property missingDependencies - Array of names of missing dependencies * @property missingDependencies - Array of names of missing dependencies
* @property outdatedDependencies - Array of names of dependencies with versions below minimum
*/ */
export interface DependencyCheckResult { export interface DependencyCheckResult {
pandoc: DependencyInfo; pandoc: DependencyInfo;
@@ -30,6 +31,7 @@ export interface DependencyCheckResult {
imagemagick: DependencyInfo; imagemagick: DependencyInfo;
allAvailable: boolean; allAvailable: boolean;
missingDependencies: string[]; missingDependencies: string[];
outdatedDependencies: string[];
} }
/** /**
@@ -141,21 +143,26 @@ export class DependencyChecker {
]); ]);
const [pandocInfo, typstInfo, imagemagickInfo] = await Promise.all([ const [pandocInfo, typstInfo, imagemagickInfo] = await Promise.all([
ExecutableChecker.checkDependency('Pandoc', pandocExec, '--version', /pandoc\s+([\d.]+)/), ExecutableChecker.checkDependency('Pandoc', pandocExec, '--version', /pandoc\s+([\d.]+)/i, DEPENDENCY_CONSTANTS.MINIMUM_VERSIONS.pandoc),
ExecutableChecker.checkDependency('Typst', typstExec, '--version', /typst\s+([\d.]+)/), ExecutableChecker.checkDependency('Typst', typstExec, '--version', /typst\s+([\d.]+)/i, DEPENDENCY_CONSTANTS.MINIMUM_VERSIONS.typst),
ExecutableChecker.checkDependency('ImageMagick', imagemagickExec, '--version', /ImageMagick\s+([\d.-]+)/) ExecutableChecker.checkDependency('ImageMagick', imagemagickExec, '--version', /ImageMagick\s+([\d.-]+)/i, DEPENDENCY_CONSTANTS.MINIMUM_VERSIONS.imagemagick)
]); ]);
const missingDependencies = [pandocInfo, typstInfo, imagemagickInfo] const missingDependencies = [pandocInfo, typstInfo, imagemagickInfo]
.filter(dep => !dep.isAvailable) .filter(dep => !dep.isAvailable)
.map(dep => dep.name); .map(dep => dep.name);
const outdatedDependencies = [pandocInfo, typstInfo, imagemagickInfo]
.filter(dep => dep.isAvailable && !dep.meetsMinimumVersion)
.map(dep => dep.name);
return { return {
pandoc: pandocInfo, pandoc: pandocInfo,
typst: typstInfo, typst: typstInfo,
imagemagick: imagemagickInfo, imagemagick: imagemagickInfo,
allAvailable: missingDependencies.length === 0, allAvailable: missingDependencies.length === 0,
missingDependencies missingDependencies,
outdatedDependencies
}; };
} }
@@ -289,18 +296,32 @@ export class DependencyChecker {
additionalPaths additionalPaths
); );
const formatVersion = (dep: DependencyInfo) => dep.isAvailable ? (dep.version || 'Available') : 'Not found'; const formatVersion = (dep: DependencyInfo) => {
if (!dep.isAvailable) return 'Not found';
if (!dep.meetsMinimumVersion) return `${dep.version} (minimum: ${dep.minimumVersion})`;
return dep.version || 'Available';
};
const statusLines: string[] = [];
// Build status messages
if (!dependencyResult.allAvailable) {
statusLines.push(`Missing dependencies: ${dependencyResult.missingDependencies.join(', ')}. Please install them and check the paths in settings.`);
} else if (dependencyResult.outdatedDependencies.length > 0) {
statusLines.push(`⚠️ Outdated versions detected: ${dependencyResult.outdatedDependencies.join(', ')}.`);
statusLines.push(`Please update to avoid compatibility issues.`);
} else {
statusLines.push('✓ All dependencies found and up to date!');
}
const message = `Dependency Status: const message = `Dependency Status:
Pandoc: ${formatVersion(dependencyResult.pandoc)} Pandoc: ${formatVersion(dependencyResult.pandoc)}
Typst: ${formatVersion(dependencyResult.typst)} Typst: ${formatVersion(dependencyResult.typst)}
ImageMagick: ${formatVersion(dependencyResult.imagemagick)} ImageMagick: ${formatVersion(dependencyResult.imagemagick)}
${dependencyResult.allAvailable ${statusLines.join('\n')}`;
? 'All dependencies found!'
: `Missing dependencies: ${dependencyResult.missingDependencies.join(', ')}. Please install them and check the paths in settings.`}`; ExportErrorHandler.showProgressNotice(message, 15000); // Show for 15 seconds (longer due to version info)
ExportErrorHandler.showProgressNotice(message, 12000); // Show for 12 seconds (longer due to more content)
} }
/** /**
+27 -7
View File
@@ -11,6 +11,7 @@
import { spawn, spawnSync } from 'child_process'; import { spawn, spawnSync } from 'child_process';
import { DEPENDENCY_CONSTANTS } from './constants'; import { DEPENDENCY_CONSTANTS } from './constants';
import { isVersionAtLeast } from '../utils/versionUtils';
import * as path from 'path'; import * as path from 'path';
/** /**
@@ -20,12 +21,16 @@ import * as path from 'path';
* @property version - Detected version string, or null if unavailable * @property version - Detected version string, or null if unavailable
* @property isAvailable - Whether the executable was found and executed successfully * @property isAvailable - Whether the executable was found and executed successfully
* @property executablePath - The resolved path to the executable * @property executablePath - The resolved path to the executable
* @property meetsMinimumVersion - Whether the version meets the minimum requirement (true if no version check performed)
* @property minimumVersion - The minimum required version string (null if not checked)
*/ */
export interface DependencyInfo { export interface DependencyInfo {
name: string; name: string;
version: string | null; version: string | null;
isAvailable: boolean; isAvailable: boolean;
executablePath: string; executablePath: string;
meetsMinimumVersion: boolean;
minimumVersion: string | null;
} }
/** /**
@@ -287,7 +292,8 @@ export class ExecutableChecker {
* This method: * This method:
* 1. Spawns the executable with the version command (e.g., '--version') * 1. Spawns the executable with the version command (e.g., '--version')
* 2. Captures stdout and parses version using the provided regex * 2. Captures stdout and parses version using the provided regex
* 3. Returns comprehensive dependency information * 3. Optionally validates against minimum required version
* 4. Returns comprehensive dependency information
* *
* Security: Uses spawn instead of exec to prevent command injection. Arguments * Security: Uses spawn instead of exec to prevent command injection. Arguments
* are passed separately from the command. * are passed separately from the command.
@@ -296,6 +302,7 @@ export class ExecutableChecker {
* @param executablePath - Path to the executable to check * @param executablePath - Path to the executable to check
* @param versionCommand - Command argument for version (e.g., '--version') * @param versionCommand - Command argument for version (e.g., '--version')
* @param versionRegex - Regex with capture group for version number * @param versionRegex - Regex with capture group for version number
* @param minimumVersion - Optional minimum required version (e.g., "0.13.0")
* @returns DependencyInfo object with availability and version information * @returns DependencyInfo object with availability and version information
* *
* @example * @example
@@ -304,11 +311,14 @@ export class ExecutableChecker {
* 'Pandoc', * 'Pandoc',
* '/usr/bin/pandoc', * '/usr/bin/pandoc',
* '--version', * '--version',
* /pandoc (\d+\.\d+(?:\.\d+)?)/ * /pandoc (\d+\.\d+(?:\.\d+)?)/,
* '3.7.0'
* ); * );
* *
* if (info.isAvailable) { * if (info.isAvailable && info.meetsMinimumVersion) {
* console.log(`Found ${info.name} version ${info.version}`); * console.log(`Found ${info.name} version ${info.version}`);
* } else if (info.isAvailable) {
* console.warn(`${info.name} ${info.version} is below minimum ${info.minimumVersion}`);
* } else { * } else {
* console.error(`${info.name} not available at ${info.executablePath}`); * console.error(`${info.name} not available at ${info.executablePath}`);
* } * }
@@ -318,7 +328,8 @@ export class ExecutableChecker {
name: string, name: string,
executablePath: string, executablePath: string,
versionCommand: string, versionCommand: string,
versionRegex: RegExp versionRegex: RegExp,
minimumVersion: string | null = null
): Promise<DependencyInfo> { ): Promise<DependencyInfo> {
try { try {
// Use spawn instead of exec for security - arguments passed separately // Use spawn instead of exec for security - arguments passed separately
@@ -354,19 +365,28 @@ export class ExecutableChecker {
const match = stdout.match(versionRegex); const match = stdout.match(versionRegex);
const version = match ? match[1] : null; const version = match ? match[1] : null;
// Check version against minimum if both are available
const meetsMinimumVersion = minimumVersion && version
? isVersionAtLeast(version, minimumVersion)
: true; // No minimum version check or version unavailable
return { return {
name, name,
version, version,
isAvailable: true, isAvailable: true,
executablePath executablePath,
meetsMinimumVersion,
minimumVersion
}; };
} catch { } catch {
return { return {
name, name,
version: null, version: null,
isAvailable: false, isAvailable: false,
executablePath executablePath,
meetsMinimumVersion: true, // Not checking if unavailable
minimumVersion
}; };
} }
} }
+16
View File
@@ -201,6 +201,22 @@ export const DEPENDENCY_CONSTANTS = {
imagemagick: 'magick' imagemagick: 'magick'
}, },
/**
* Minimum required versions for external dependencies.
*
* These versions represent the minimum supported versions that have been
* tested with this plugin. Users with older versions will receive warnings.
*
* @property pandoc - Pandoc 3.7.0 (current stable as of plugin development)
* @property typst - Typst 0.13.0 (version used during plugin development)
* @property imagemagick - ImageMagick 7.1.2 (current stable as of plugin development)
*/
MINIMUM_VERSIONS: {
pandoc: '3.7.0',
typst: '0.13.0',
imagemagick: '7.1.2'
},
/** /**
* Common installation paths to search for executables. * Common installation paths to search for executables.
* *
+54
View File
@@ -0,0 +1,54 @@
/**
* Version Utilities
*
* Lightweight utilities for comparing semantic version strings.
* Used for minimum version validation of external dependencies.
*/
/**
* Compares two semantic version strings.
*
* @param version1 - First version string (e.g., "0.13.0")
* @param version2 - Second version string (e.g., "0.5.0")
* @returns Negative if version1 < version2, 0 if equal, positive if version1 > version2
*
* @example
* ```typescript
* compareVersions("0.13.0", "0.5.0") // Returns 8 (0.13.0 > 0.5.0)
* compareVersions("1.0.0", "1.0.0") // Returns 0 (equal)
* ```
*/
export function compareVersions(version1: string, version2: string): number {
// Extract numeric parts, ignoring pre-release tags and build metadata
const v1Parts = version1.split(/[-+]/)[0].split('.').map(Number);
const v2Parts = version2.split(/[-+]/)[0].split('.').map(Number);
const maxLength = Math.max(v1Parts.length, v2Parts.length);
for (let i = 0; i < maxLength; i++) {
const v1 = v1Parts[i] || 0;
const v2 = v2Parts[i] || 0;
if (v1 !== v2) {
return v1 - v2;
}
}
return 0;
}
/**
* Checks if a version meets a minimum required version.
*
* @param actualVersion - The detected version string
* @param minimumVersion - The minimum required version string
* @returns True if actualVersion >= minimumVersion
*
* @example
* ```typescript
* isVersionAtLeast("0.13.0", "0.13.0") // Returns true
* isVersionAtLeast("0.12.0", "0.13.0") // Returns false
* ```
*/
export function isVersionAtLeast(actualVersion: string, minimumVersion: string): boolean {
return compareVersions(actualVersion, minimumVersion) >= 0;
}
+2 -1
View File
@@ -5,5 +5,6 @@
"1.2.0": "1.9.12", "1.2.0": "1.9.12",
"1.2.1": "1.9.12", "1.2.1": "1.9.12",
"1.3.0": "1.9.12", "1.3.0": "1.9.12",
"1.3.1": "1.9.12" "1.3.1": "1.9.12",
"1.4.0": "1.9.12"
} }