Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

verify tauri plugin versions in ci (#882)

Brendan Allanfba1be7dd3ab
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c70c5c6fb..d1fb50fce 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -16,6 +16,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
rust: ${{ steps.filter.outputs.rust }}
+ tauri-plugins: ${{ steps.filter.outputs.tauri-plugins }}
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -32,6 +33,9 @@ jobs:
- 'desktop/src-tauri/**'
- 'Cargo.toml'
- 'Cargo.lock'
+ tauri-plugins:
+ - 'Cargo.lock'
+ - 'pnpm-lock.yaml'
typecheck:
name: Typecheck
@@ -93,8 +97,6 @@ jobs:
with:
shared-key: ${{ matrix.settings.target }}
- - uses: ./.github/actions/setup-js
-
- name: Create .env file in root
run: |
echo "VITE_ENVIRONMENT=production" >> .env
@@ -112,8 +114,8 @@ jobs:
cat .env >> $GITHUB_ENV
- name: Run setup
- run: |
- pnpm cap-setup
+ shell: bash
+ run: node scripts/setup.js
- name: Run Clippy
uses: actions-rs-plus/clippy-check@v2
@@ -189,3 +191,21 @@ jobs:
pnpm tauri build --debug --target ${{ matrix.settings.target }} --no-bundle
env:
RUST_TARGET_TRIPLE: ${{ matrix.settings.target }}
+
+ tauri-plugins:
+ name: Verify Tauri plugin versions
+ runs-on: ubuntu-latest
+ needs: changes
+ if: needs.changes.outputs.tauri-plugins == 'true'
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup node
+ uses: actions/setup-node@v3
+ with:
+ node-version: 20
+
+ - name: Run verify
+ shell: bash
+ run: node scripts/check-tauri-plugin-versions.js
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index acf0ab91c..126dd75d4 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -39,18 +39,18 @@
"@solidjs/start": "^1.1.3",
"@tanstack/solid-query": "^5.51.21",
"@tauri-apps/api": "2.5.0",
- "@tauri-apps/plugin-clipboard-manager": "^2.2.1",
- "@tauri-apps/plugin-deep-link": "^2.2.0",
- "@tauri-apps/plugin-dialog": "2.0.1",
- "@tauri-apps/plugin-fs": "2.2.0",
- "@tauri-apps/plugin-http": "^2.4.4",
- "@tauri-apps/plugin-notification": "2.0.0",
- "@tauri-apps/plugin-opener": "^2.2.6",
- "@tauri-apps/plugin-os": "2.0.0",
- "@tauri-apps/plugin-process": "2.0.0",
- "@tauri-apps/plugin-shell": ">=2.0.1",
- "@tauri-apps/plugin-store": "2.1.0",
- "@tauri-apps/plugin-updater": "2.9.0",
+ "@tauri-apps/plugin-clipboard-manager": "^2.3.0",
+ "@tauri-apps/plugin-deep-link": "^2.4.1",
+ "@tauri-apps/plugin-dialog": "^2.3.2",
+ "@tauri-apps/plugin-fs": "^2.4.1",
+ "@tauri-apps/plugin-http": "^2.5.1",
+ "@tauri-apps/plugin-notification": "^2.3.0",
+ "@tauri-apps/plugin-opener": "^2.4.0",
+ "@tauri-apps/plugin-os": "^2.3.0",
+ "@tauri-apps/plugin-process": "2.3.0",
+ "@tauri-apps/plugin-shell": "^2.3.0",
+ "@tauri-apps/plugin-store": "^2.3.0",
+ "@tauri-apps/plugin-updater": "^2.9.0",
"@ts-rest/core": "^3.52.1",
"@types/react-tooltip": "^4.2.4",
"cva": "npm:class-variance-authority@^0.7.0",
diff --git a/package.json b/package.json
index 25bdfd124..94d5ce6e2 100644
--- a/package.json
+++ b/package.json
@@ -22,6 +22,7 @@
"typecheck": "pnpm tsc -b",
"web": "pnpm run --filter=@cap/web",
"env-setup": "node scripts/env-cli.js",
+ "check-tauri-versions": "node scripts/check-tauri-plugin-versions.js",
"clean": "find . -name node_modules -o -name .next -o -name .output -o -name .turbo -o -name dist -type d -prune | xargs rm -rf"
},
"devDependencies": {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a639cdb7d..880d44daf 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -97,7 +97,7 @@ importers:
version: 1.5.1([email protected])
'@solid-primitives/storage':
specifier: ^4.0.0
- version: 4.3.2(@tauri-apps/[email protected])([email protected])
+ version: 4.3.2(@tauri-apps/[email protected])([email protected])
'@solid-primitives/timer':
specifier: ^1.3.9
version: 1.4.1([email protected])
@@ -117,40 +117,40 @@ importers:
specifier: 2.5.0
version: 2.5.0
'@tauri-apps/plugin-clipboard-manager':
- specifier: ^2.2.1
- version: 2.2.2
+ specifier: ^2.3.0
+ version: 2.3.0
'@tauri-apps/plugin-deep-link':
- specifier: ^2.2.0
- version: 2.2.1
+ specifier: ^2.4.1
+ version: 2.4.1
'@tauri-apps/plugin-dialog':
- specifier: 2.0.1
- version: 2.0.1
+ specifier: ^2.3.2
+ version: 2.3.2
'@tauri-apps/plugin-fs':
- specifier: 2.2.0
- version: 2.2.0
+ specifier: ^2.4.1
+ version: 2.4.1
'@tauri-apps/plugin-http':
- specifier: ^2.4.4
- version: 2.4.4
+ specifier: ^2.5.1
+ version: 2.5.1
'@tauri-apps/plugin-notification':
- specifier: 2.0.0
- version: 2.0.0
+ specifier: ^2.3.0
+ version: 2.3.0
'@tauri-apps/plugin-opener':
- specifier: ^2.2.6
- version: 2.2.6
+ specifier: ^2.4.0
+ version: 2.4.0
'@tauri-apps/plugin-os':
- specifier: 2.0.0
- version: 2.0.0
+ specifier: ^2.3.0
+ version: 2.3.0
'@tauri-apps/plugin-process':
- specifier: 2.0.0
- version: 2.0.0
+ specifier: 2.3.0
+ version: 2.3.0
'@tauri-apps/plugin-shell':
- specifier: '>=2.0.1'
- version: 2.2.1
+ specifier: ^2.3.0
+ version: 2.3.0
'@tauri-apps/plugin-store':
- specifier: 2.1.0
- version: 2.1.0
+ specifier: ^2.3.0
+ version: 2.3.0
'@tauri-apps/plugin-updater':
- specifier: 2.9.0
+ specifier: ^2.9.0
version: 2.9.0
'@ts-rest/core':
specifier: ^3.52.1
@@ -6138,38 +6138,38 @@ packages:
engines: {node: '>= 10'}
hasBin: true
- '@tauri-apps/[email protected]':
- resolution: {integrity: sha512-bZvDLMqfcNmsw7Ag8I49jlaCjdpDvvlJHnpp6P+Gg/3xtpSERdwlDxm7cKGbs2mj46dsw4AuG3RoAgcpwgioUA==}
+ '@tauri-apps/[email protected]':
+ resolution: {integrity: sha512-81NOBA2P+OTY8RLkBwyl9ZR/0CeggLub4F6zxcxUIfFOAqtky7J61+K/MkH2SC1FMxNBxrX0swDuKvkjkHadlA==}
- '@tauri-apps/[email protected]':
- resolution: {integrity: sha512-8skZ6qIH/kWaV8d6jj3aPvvkIOuqkVk0APRDey9n9N3Ueu3n4MIbuxpAKR2EdoAyQxnXxPTNVyjw2D35/vfGyg==}
+ '@tauri-apps/[email protected]':
+ resolution: {integrity: sha512-I8Bo+spcAKGhIIJ1qN/gapp/Ot3mosQL98znxr975Zn2ODAkUZ++BQ9FnTpR7PDwfIl5ANSGdIW/YU01zVTcJw==}
- '@tauri-apps/[email protected]':
- resolution: {integrity: sha512-fnUrNr6EfvTqdls/ufusU7h6UbNFzLKvHk/zTuOiBq01R3dTODqwctZlzakdbfSp/7pNwTKvgKTAgl/NAP/Z0Q==}
+ '@tauri-apps/[email protected]':
+ resolution: {integrity: sha512-cNLo9YeQSC0MF4IgXnotHsqEgJk72MBZLXmQPrLA95qTaaWiiaFQ38hIMdZ6YbGUNkr3oni3EhU+AD5jLHcdUA==}
- '@tauri-apps/[email protected]':
- resolution: {integrity: sha512-+08mApuONKI8/sCNEZ6AR8vf5vI9DXD4YfrQ9NQmhRxYKMLVhRW164vdW5BSLmMpuevftpQ2FVoL9EFkfG9Z+g==}
+ '@tauri-apps/[email protected]':
+ resolution: {integrity: sha512-vJlKZVGF3UAFGoIEVT6Oq5L4HGDCD78WmA4uhzitToqYiBKWAvZR61M6zAyQzHqLs0ADemkE4RSy/5sCmZm6ZQ==}
- '@tauri-apps/[email protected]':
- resolution: {integrity: sha512-IjlaaS4z8ybB10qnh6djZ2FIaHdWVs/U1D1C56udKcjX1f+jAmR8/s7qBV5cv/OmcGkOIzet3LWuH70LKf4J2A==}
+ '@tauri-apps/[email protected]':
+ resolution: {integrity: sha512-SpQ1azXEdQI0UB2NZTIPljJTDEe0bIaKzHYR/k4UQp6yzRYGLC/ktmIgEfQ2RvKAWus8GcYgGr5K6LJPbo/NZw==}
- '@tauri-apps/[email protected]':
- resolution: {integrity: sha512-6qEDYJS7mgXZWLXA0EFL+DVCJh8sJlzSoyw6B50pxhLPVFjc5Vr5DVzl5W3mUHaYhod5wsC984eQnlCCGqxYDA==}
+ '@tauri-apps/[email protected]':
+ resolution: {integrity: sha512-QDwXo9VzAlH97c0veuf19TZI6cRBPfJDl2O6hNEDvI66j60lOO9z+PL6MJrj8A6Y+t55r7mGhe3rQWLmOre2HA==}
- '@tauri-apps/[email protected]':
- resolution: {integrity: sha512-bSdkuP71ZQRepPOn8BOEdBKYJQvl6+jb160QtJX/i2H9BF6ZySY/kYljh76N2Ne5fJMQRge7rlKoStYQY5Jq1w==}
+ '@tauri-apps/[email protected]':
+ resolution: {integrity: sha512-43VyN8JJtvKWJY72WI/KNZszTpDpzHULFxQs0CJBIYUdCRowQ6Q1feWTDb979N7nldqSuDOaBupZ6wz2nvuWwQ==}
- '@tauri-apps/[email protected]':
- resolution: {integrity: sha512-M7hG/nNyQYTJxVG/UhTKhp9mpXriwWzrs9mqDreB8mIgqA3ek5nHLdwRZJWhkKjZrnDT4v9CpA9BhYeplTlAiA==}
+ '@tauri-apps/[email protected]':
+ resolution: {integrity: sha512-dm3bDsMuUngpIQdJ1jaMkMfyQpHyDcaTIKTFaAMHoKeUd+Is3UHO2uzhElr6ZZkfytIIyQtSVnCWdW2Kc58f3g==}
- '@tauri-apps/[email protected]':
- resolution: {integrity: sha512-OYzi0GnkrF4NAnsHZU7U3tjSoP0PbeAlO7T1Z+vJoBUH9sFQ1NSLqWYWQyf8hcb3gVWe7P1JggjiskO+LST1ug==}
+ '@tauri-apps/[email protected]':
+ resolution: {integrity: sha512-0DNj6u+9csODiV4seSxxRbnLpeGYdojlcctCuLOCgpH9X3+ckVZIEj6H7tRQ7zqWr7kSTEWnrxtAdBb0FbtrmQ==}
- '@tauri-apps/[email protected]':
- resolution: {integrity: sha512-G1GFYyWe/KlCsymuLiNImUgC8zGY0tI0Y3p8JgBCWduR5IEXlIJS+JuG1qtveitwYXlfJrsExt3enhv5l2/yhA==}
+ '@tauri-apps/[email protected]':
+ resolution: {integrity: sha512-6GIRxO2z64uxPX4CCTuhQzefvCC0ew7HjdBhMALiGw74vFBDY95VWueAHOHgNOMV4UOUAFupyidN9YulTe5xlA==}
- '@tauri-apps/[email protected]':
- resolution: {integrity: sha512-GADqrc17opUKYIAKnGHIUgEeTZ2wJGu1ZITKQ1WMuOFdv8fvXRFBAqsqPjE3opgWohbczX6e1NpwmZK1AnuWVw==}
+ '@tauri-apps/[email protected]':
+ resolution: {integrity: sha512-mre8er0nXPhyEWQzWCpUd+UnEoBQYcoA5JYlwpwOV9wcxKqlXTGfminpKsE37ic8NUb2BIZqf0QQ9/U3ib2+/A==}
'@tauri-apps/[email protected]':
resolution: {integrity: sha512-j++sgY8XpeDvzImTrzWA08OqqGqgkNyxczLD7FjNJJx/uXxMZFz5nDcfkyoI/rCjYuj2101Tci/r/HFmOmoxCg==}
@@ -8902,6 +8902,7 @@ packages:
resolution: {integrity: sha512-Be3narBNt2s6bsaqP6Jzq91heDgOEaDCJAXcE3qcma/EJBSy5FB4cvO31XBInuAuKBx8Kptf8dkhjK0IOru39Q==}
engines: {node: '>=18'}
+ deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
resolution: {integrity: sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==}
@@ -10846,6 +10847,7 @@ packages:
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
engines: {node: '>=10.5.0'}
+ deprecated: Use your platform's native DOMException instead
resolution: {integrity: sha512-8Mc2HhqPdlIfedsuZoc3yioPuzp6b+L5jRCRY1QzuWZh2EGJVQrGppC6V6cF0bLdbW0+O2YpqCA25aF/1lvipQ==}
@@ -12397,6 +12399,7 @@ packages:
resolution: {integrity: sha512-PgquZC4FiNPCDOIXuXYOco01vMHCXBBAr3Y/a9ylF4+0vOTcL2RAqieUmTbZhBxVWZIm+nPIyOlz8UqhwcgLtQ==}
engines: {node: '>=18.0.0'}
+ deprecated: 'This package is deprecated. Use storybook-solidjs-vite instead: https://www.npmjs.com/package/storybook-solidjs-vite'
peerDependencies:
'@storybook/test': '*'
solid-js: ~1.9.0
@@ -19025,12 +19028,12 @@ snapshots:
'@solid-primitives/utils': 6.3.2([email protected])
solid-js: 1.9.6
- '@solid-primitives/[email protected](@tauri-apps/[email protected])([email protected])':
+ '@solid-primitives/[email protected](@tauri-apps/[email protected])([email protected])':
dependencies:
'@solid-primitives/utils': 6.3.1([email protected])
solid-js: 1.9.6
optionalDependencies:
- '@tauri-apps/plugin-store': 2.1.0
+ '@tauri-apps/plugin-store': 2.3.0
'@solid-primitives/[email protected]([email protected])':
dependencies:
@@ -19540,49 +19543,49 @@ snapshots:
'@tauri-apps/cli-win32-ia32-msvc': 2.5.0
'@tauri-apps/cli-win32-x64-msvc': 2.5.0
- '@tauri-apps/[email protected]':
+ '@tauri-apps/[email protected]':
dependencies:
- '@tauri-apps/api': 2.5.0
+ '@tauri-apps/api': 2.7.0
- '@tauri-apps/[email protected]':
+ '@tauri-apps/[email protected]':
dependencies:
- '@tauri-apps/api': 2.5.0
+ '@tauri-apps/api': 2.7.0
- '@tauri-apps/[email protected]':
+ '@tauri-apps/[email protected]':
dependencies:
- '@tauri-apps/api': 2.5.0
+ '@tauri-apps/api': 2.7.0
- '@tauri-apps/[email protected]':
+ '@tauri-apps/[email protected]':
dependencies:
- '@tauri-apps/api': 2.5.0
+ '@tauri-apps/api': 2.7.0
- '@tauri-apps/[email protected]':
+ '@tauri-apps/[email protected]':
dependencies:
- '@tauri-apps/api': 2.5.0
+ '@tauri-apps/api': 2.7.0
- '@tauri-apps/[email protected]':
+ '@tauri-apps/[email protected]':
dependencies:
- '@tauri-apps/api': 2.5.0
+ '@tauri-apps/api': 2.7.0
- '@tauri-apps/[email protected]':
+ '@tauri-apps/[email protected]':
dependencies:
- '@tauri-apps/api': 2.5.0
+ '@tauri-apps/api': 2.7.0
- '@tauri-apps/[email protected]':
+ '@tauri-apps/[email protected]':
dependencies:
- '@tauri-apps/api': 2.5.0
+ '@tauri-apps/api': 2.7.0
- '@tauri-apps/[email protected]':
+ '@tauri-apps/[email protected]':
dependencies:
- '@tauri-apps/api': 2.5.0
+ '@tauri-apps/api': 2.7.0
- '@tauri-apps/[email protected]':
+ '@tauri-apps/[email protected]':
dependencies:
- '@tauri-apps/api': 2.5.0
+ '@tauri-apps/api': 2.7.0
- '@tauri-apps/[email protected]':
+ '@tauri-apps/[email protected]':
dependencies:
- '@tauri-apps/api': 2.5.0
+ '@tauri-apps/api': 2.7.0
'@tauri-apps/[email protected]':
dependencies:
diff --git a/scripts/check-tauri-plugin-versions.js b/scripts/check-tauri-plugin-versions.js
new file mode 100755
index 000000000..80fae5579
--- /dev/null
+++ b/scripts/check-tauri-plugin-versions.js
@@ -0,0 +1,337 @@
+#!/usr/bin/env node
+
+import fs from "node:fs";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+
+const __filename = fileURLToPath(import.meta.url);
+const __dirname = path.dirname(__filename);
+
+// Check for debug flag
+const DEBUG = process.argv.includes("--debug") || process.env.DEBUG === "true";
+
+function debug(message) {
+ if (DEBUG) {
+ console.log(`[DEBUG] ${message}`);
+ }
+}
+
+// Helper function to parse semantic version
+function parseVersion(version) {
+ const match = version.match(/^(\d+)\.(\d+)\.(\d+)/);
+ if (!match) {
+ throw new Error(`Invalid version format: ${version}`);
+ }
+ return {
+ major: parseInt(match[1], 10),
+ minor: parseInt(match[2], 10),
+ patch: parseInt(match[3], 10),
+ full: version,
+ };
+}
+
+// Parse pnpm-lock.yaml to extract Tauri plugin versions
+function parsePnpmLock(lockfilePath) {
+ const content = fs.readFileSync(lockfilePath, "utf8");
+ const plugins = {};
+
+ const lines = content.split("\n");
+ let currentPlugin = null;
+
+ for (let i = 0; i < lines.length; i++) {
+ const line = lines[i];
+
+ // Look for @tauri-apps/plugin- packages (with or without quotes)
+ const pluginMatch = line.match(
+ /^\s*['"]?(@tauri-apps\/plugin-[^'":\s]+)['"]?:\s*$/,
+ );
+ if (pluginMatch) {
+ currentPlugin = pluginMatch[1];
+ debug(`Found JS plugin: ${currentPlugin} at line ${i + 1}`);
+ continue;
+ }
+
+ // Look for version when we're tracking a plugin
+ if (currentPlugin) {
+ const versionMatch = line.match(/^\s*version:\s*['"]?([^'"]+)['"]?\s*$/);
+ if (versionMatch) {
+ plugins[currentPlugin] = versionMatch[1];
+ debug(` Version: ${versionMatch[1]}`);
+ currentPlugin = null;
+ }
+
+ // Reset if we hit another top-level key
+ if (
+ line.match(/^\s*[^'":\s]+:\s*$/) &&
+ !line.match(/^\s*(specifier|version):/)
+ ) {
+ currentPlugin = null;
+ }
+ }
+
+ // Also check for inline version specifications in dependency lists
+ const inlineMatch = line.match(/@tauri-apps\/plugin-([^@]+)@([^)]+)/);
+ if (inlineMatch) {
+ const pluginName = inlineMatch[1];
+ const version = inlineMatch[2];
+ plugins[`@tauri-apps/plugin-${pluginName}`] = version;
+ debug(
+ `Found inline JS plugin: @tauri-apps/plugin-${pluginName}@${version}`,
+ );
+ }
+ }
+
+ return plugins;
+}
+
+// Parse Cargo.lock to extract Tauri plugin versions
+function parseCargoLock(lockfilePath) {
+ const content = fs.readFileSync(lockfilePath, "utf8");
+ const plugins = {};
+
+ const lines = content.split("\n");
+ let currentPackage = null;
+
+ for (let i = 0; i < lines.length; i++) {
+ const line = lines[i];
+
+ // Look for package declarations
+ const packageMatch = line.match(/^name = "tauri-plugin-(.+)"$/);
+ if (packageMatch) {
+ currentPackage = `tauri-plugin-${packageMatch[1]}`;
+ debug(`Found Rust plugin: ${currentPackage} at line ${i + 1}`);
+ continue;
+ }
+
+ // Look for version when we're in a tauri-plugin package
+ if (currentPackage && line.match(/^version = "(.+)"$/)) {
+ const versionMatch = line.match(/^version = "(.+)"$/);
+ if (versionMatch) {
+ plugins[currentPackage] = versionMatch[1];
+ debug(` Version: ${versionMatch[1]}`);
+ currentPackage = null;
+ }
+ }
+
+ // Reset when we hit a new [[package]] block
+ if (line.match(/^\[\[package\]\]$/)) {
+ currentPackage = null;
+ }
+ }
+
+ return plugins;
+}
+
+// Map plugin names between JS and Rust
+function mapPluginNames(jsName, rustPlugins) {
+ // Convert @tauri-apps/plugin-clipboard-manager to tauri-plugin-clipboard-manager
+ const rustName = jsName.replace("@tauri-apps/plugin-", "tauri-plugin-");
+ return rustPlugins[rustName] ? rustName : null;
+}
+
+// Compare versions and report mismatches
+function compareVersions(jsPlugins, rustPlugins) {
+ const results = {
+ matching: [],
+ mismatched: [],
+ jsOnly: [],
+ rustOnly: [],
+ };
+
+ // Check JS plugins against Rust plugins
+ for (const [jsName, jsVersion] of Object.entries(jsPlugins)) {
+ const rustName = mapPluginNames(jsName, rustPlugins);
+
+ if (!rustName) {
+ results.jsOnly.push({ name: jsName, version: jsVersion });
+ continue;
+ }
+
+ const rustVersion = rustPlugins[rustName];
+
+ try {
+ const jsParsed = parseVersion(jsVersion);
+ const rustParsed = parseVersion(rustVersion);
+
+ if (
+ jsParsed.major === rustParsed.major &&
+ jsParsed.minor === rustParsed.minor
+ ) {
+ results.matching.push({
+ jsName,
+ rustName,
+ jsVersion,
+ rustVersion,
+ majorMinor: `${jsParsed.major}.${jsParsed.minor}`,
+ });
+ } else {
+ results.mismatched.push({
+ jsName,
+ rustName,
+ jsVersion,
+ rustVersion,
+ jsMajorMinor: `${jsParsed.major}.${jsParsed.minor}`,
+ rustMajorMinor: `${rustParsed.major}.${rustParsed.minor}`,
+ });
+ }
+ } catch (error) {
+ console.warn(
+ `Warning: Could not parse versions for ${jsName} (${jsVersion}) / ${rustName} (${rustVersion}): ${error.message}`,
+ );
+ }
+ }
+
+ // Check for Rust-only plugins
+ for (const [rustName, rustVersion] of Object.entries(rustPlugins)) {
+ const jsName = `@tauri-apps/plugin-${rustName.replace("tauri-plugin-", "")}`;
+ if (!jsPlugins[jsName]) {
+ results.rustOnly.push({ name: rustName, version: rustVersion });
+ }
+ }
+
+ return results;
+}
+
+// Main function
+function main() {
+ const rootDir = path.resolve(__dirname, "..");
+ const pnpmLockPath = path.join(rootDir, "pnpm-lock.yaml");
+ const cargoLockPath = path.join(rootDir, "Cargo.lock");
+
+ // Check if files exist
+ if (!fs.existsSync(pnpmLockPath)) {
+ console.error(`❌ Error: pnpm-lock.yaml not found at ${pnpmLockPath}`);
+ console.error("Please run this script from the project root directory.");
+ process.exit(1);
+ }
+
+ if (!fs.existsSync(cargoLockPath)) {
+ console.error(`❌ Error: Cargo.lock not found at ${cargoLockPath}`);
+ console.error("Please run this script from the project root directory.");
+ process.exit(1);
+ }
+
+ debug(`Reading pnpm lockfile: ${pnpmLockPath}`);
+ debug(`Reading Cargo lockfile: ${cargoLockPath}`);
+
+ console.log("🔍 Checking Tauri plugin version consistency...\n");
+
+ try {
+ // Parse both lockfiles
+ const jsPlugins = parsePnpmLock(pnpmLockPath);
+ const rustPlugins = parseCargoLock(cargoLockPath);
+
+ console.log(`Found ${Object.keys(jsPlugins).length} JS Tauri plugins`);
+ console.log(
+ `Found ${Object.keys(rustPlugins).length} Rust Tauri plugins\n`,
+ );
+
+ if (DEBUG) {
+ console.log("JS Plugins found:");
+ Object.entries(jsPlugins).forEach(([name, version]) => {
+ console.log(` ${name}@${version}`);
+ });
+ console.log("\nRust Plugins found:");
+ Object.entries(rustPlugins).forEach(([name, version]) => {
+ console.log(` ${name}@${version}`);
+ });
+ console.log();
+ }
+
+ // Compare versions
+ const results = compareVersions(jsPlugins, rustPlugins);
+
+ // Report results
+ if (results.matching.length > 0) {
+ console.log("✅ Matching versions (major.minor):");
+ results.matching.forEach(
+ ({ jsName, rustName, jsVersion, rustVersion, majorMinor }) => {
+ console.log(
+ ` ${majorMinor}: ${jsName}@${jsVersion} ↔ ${rustName}@${rustVersion}`,
+ );
+ },
+ );
+ console.log();
+ }
+
+ let hasErrors = false;
+
+ if (results.mismatched.length > 0) {
+ hasErrors = true;
+ console.log("❌ Version mismatches (major.minor):");
+ results.mismatched.forEach(
+ ({
+ jsName,
+ rustName,
+ jsVersion,
+ rustVersion,
+ jsMajorMinor,
+ rustMajorMinor,
+ }) => {
+ console.log(
+ ` ${jsName}@${jsVersion} (${jsMajorMinor}) ↔ ${rustName}@${rustVersion} (${rustMajorMinor})`,
+ );
+ },
+ );
+ console.log();
+ }
+
+ if (results.jsOnly.length > 0) {
+ console.log("⚠️ JS-only plugins (no Rust equivalent found):");
+ results.jsOnly.forEach(({ name, version }) => {
+ console.log(` ${name}@${version}`);
+ });
+ console.log();
+ }
+
+ if (results.rustOnly.length > 0) {
+ console.log("⚠️ Rust-only plugins (no JS equivalent found):");
+ results.rustOnly.forEach(({ name, version }) => {
+ console.log(` ${name}@${version}`);
+ });
+ console.log();
+ }
+
+ // Summary
+ if (hasErrors) {
+ console.log("💥 Version consistency check failed!");
+ console.log(
+ "Please ensure that Tauri plugins have matching major.minor versions between package.json and Cargo.toml",
+ );
+ process.exit(1);
+ } else {
+ console.log("🎉 All Tauri plugin versions are consistent!");
+ }
+ } catch (error) {
+ console.error(`❌ Error: ${error.message}`);
+ if (DEBUG) {
+ console.error("Stack trace:", error.stack);
+ }
+ process.exit(1);
+ }
+}
+
+// Show usage if help flag is passed
+if (process.argv.includes("--help") || process.argv.includes("-h")) {
+ console.log(`
+Usage: node check-tauri-plugin-versions.js [options]
+
+Options:
+ --debug Enable debug logging
+ --help Show this help message
+
+Description:
+ Checks that all @tauri-apps/plugin-* packages have matching major.minor
+ versions with their corresponding tauri-plugin-* crates.
+
+ The script reads pnpm-lock.yaml and Cargo.lock from the project root
+ and compares versions to ensure compatibility.
+
+Exit codes:
+ 0 - All versions match
+ 1 - Version mismatches found or error occurred
+`);
+ process.exit(0);
+}
+
+main();