diff --git a/CLAUDE.md b/CLAUDE.md index c890fb3b..9a52deb3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1195,3 +1195,32 @@ Every analytics v2 endpoint must: --- # END Analytics V2 spec extension + +--- + +## WordPress Plugin Versioning + +The WordPress plugin version is tracked in `wordpress-plugin/VERSION`. + +**Current version:** Check `wordpress-plugin/VERSION` for the latest version. + +**Versioning rules:** +- **Minor bumps (x.x.N)**: Bug fixes, small improvements - default for most changes +- **Middle bumps (x.N.0)**: New features, significant improvements +- **Major bumps (N.0.0)**: Breaking changes, major rewrites - only when user explicitly requests + +**When making WP plugin changes:** +1. Read `wordpress-plugin/VERSION` to get current version +2. Bump the version number (minor by default) +3. Update both files: + - `wordpress-plugin/VERSION` + - Plugin header `Version:` in `cannaiq-menus.php` and/or `crawlsy-menus.php` + - The `define('..._VERSION', '...')` constant in each plugin file + +**Plugin files:** +| File | Brand | API URL | +|------|-------|---------| +| `cannaiq-menus.php` | CannaIQ | `https://cannaiq.co/api/v1` | +| `crawlsy-menus.php` | Crawlsy (legacy) | `https://cannaiq.co/api/v1` | + +Both plugins use the same API endpoint. The Crawlsy version exists for backward compatibility with existing installations. diff --git a/backend/public/downloads/cannaiq-menus-1.5.4.zip b/backend/public/downloads/cannaiq-menus-1.5.4.zip new file mode 100644 index 00000000..a71e72fa Binary files /dev/null and b/backend/public/downloads/cannaiq-menus-1.5.4.zip differ diff --git a/backend/src/index.ts b/backend/src/index.ts index 5e7222e0..d0bf51ca 100755 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -32,6 +32,37 @@ app.use('/images', express.static(LOCAL_IMAGES_PATH)); // Serve static downloads (plugin files, etc.) // Uses ./public/downloads relative to working directory (works for both Docker and local dev) const LOCAL_DOWNLOADS_PATH = process.env.LOCAL_DOWNLOADS_PATH || './public/downloads'; + +// Dynamic "latest" redirect for WordPress plugin - finds highest version automatically +app.get('/downloads/cannaiq-menus-latest.zip', (req, res) => { + const fs = require('fs'); + const path = require('path'); + try { + const files = fs.readdirSync(LOCAL_DOWNLOADS_PATH); + const pluginFiles = files + .filter((f: string) => f.match(/^cannaiq-menus-\d+\.\d+\.\d+\.zip$/)) + .sort((a: string, b: string) => { + const vA = a.match(/(\d+)\.(\d+)\.(\d+)/); + const vB = b.match(/(\d+)\.(\d+)\.(\d+)/); + if (!vA || !vB) return 0; + for (let i = 1; i <= 3; i++) { + const diff = parseInt(vB[i]) - parseInt(vA[i]); + if (diff !== 0) return diff; + } + return 0; + }); + + if (pluginFiles.length > 0) { + const latestFile = pluginFiles[0]; + res.redirect(302, `/downloads/${latestFile}`); + } else { + res.status(404).json({ error: 'No plugin versions found' }); + } + } catch (err) { + res.status(500).json({ error: 'Failed to find latest plugin' }); + } +}); + app.use('/downloads', express.static(LOCAL_DOWNLOADS_PATH)); // Simple health check for load balancers/K8s probes diff --git a/cannaiq/src/pages/Home.tsx b/cannaiq/src/pages/Home.tsx index 308540af..bb16f913 100644 --- a/cannaiq/src/pages/Home.tsx +++ b/cannaiq/src/pages/Home.tsx @@ -20,7 +20,7 @@ import { } from 'lucide-react'; const API_URL = import.meta.env.VITE_API_URL || ''; -const PLUGIN_DOWNLOAD_URL = `${API_URL}/downloads/cannaiq-menus-1.5.3.zip`; +const PLUGIN_DOWNLOAD_URL = `${API_URL}/downloads/cannaiq-menus-latest.zip`; import { api } from '../lib/api'; interface VersionInfo { diff --git a/cannaiq/src/pages/LandingPage.tsx b/cannaiq/src/pages/LandingPage.tsx index 36b6c388..42893188 100644 --- a/cannaiq/src/pages/LandingPage.tsx +++ b/cannaiq/src/pages/LandingPage.tsx @@ -23,7 +23,7 @@ export default function LandingPage() { Sign In - + Download WordPress Plugin @@ -84,10 +84,10 @@ export default function LandingPage() {