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() {
[cannaiq_product id="123"]
- Download CannaIQ Menus v1.5.3 + Download CannaIQ Menus Plugin diff --git a/wordpress-plugin/VERSION b/wordpress-plugin/VERSION new file mode 100644 index 00000000..94fe62c2 --- /dev/null +++ b/wordpress-plugin/VERSION @@ -0,0 +1 @@ +1.5.4 diff --git a/wordpress-plugin/build-plugin.sh b/wordpress-plugin/build-plugin.sh index 780992c8..9d9c128a 100755 --- a/wordpress-plugin/build-plugin.sh +++ b/wordpress-plugin/build-plugin.sh @@ -36,9 +36,16 @@ zip -r "${OUTPUT_DIR}/${OUTPUT_FILE}" . \ -x "assets/css/crawlsy-menus.css" \ -x "assets/js/crawlsy-menus.js" +# Create/update the "latest" symlink +cd "${OUTPUT_DIR}" +rm -f cannaiq-menus-latest.zip +ln -s "${OUTPUT_FILE}" cannaiq-menus-latest.zip + echo "" echo "Build complete!" echo " File: ${OUTPUT_DIR}/${OUTPUT_FILE}" echo " Size: $(ls -lh "${OUTPUT_DIR}/${OUTPUT_FILE}" | awk '{print $5}')" echo "" -echo "Download URL: https://cannaiq.co/downloads/cannaiq-menus-${VERSION}.zip" +echo "Download URLs:" +echo " Versioned: https://cannaiq.co/downloads/cannaiq-menus-${VERSION}.zip" +echo " Latest: https://cannaiq.co/downloads/cannaiq-menus-latest.zip" diff --git a/wordpress-plugin/cannaiq-menus.php b/wordpress-plugin/cannaiq-menus.php index ebbaa4b2..8c2fc63e 100644 --- a/wordpress-plugin/cannaiq-menus.php +++ b/wordpress-plugin/cannaiq-menus.php @@ -3,7 +3,7 @@ * Plugin Name: CannaIQ Menus * Plugin URI: https://cannaiq.co * Description: Display cannabis product menus from CannaIQ with Elementor integration. Real-time menu data updated daily. - * Version: 1.5.3 + * Version: 1.5.4 * Author: CannaIQ * Author URI: https://cannaiq.co * License: GPL v2 or later @@ -15,7 +15,7 @@ if (!defined('ABSPATH')) { exit; // Exit if accessed directly } -define('CANNAIQ_MENUS_VERSION', '1.5.3'); +define('CANNAIQ_MENUS_VERSION', '1.5.4'); define('CANNAIQ_MENUS_API_URL', 'https://cannaiq.co/api/v1'); define('CANNAIQ_MENUS_PLUGIN_DIR', plugin_dir_path(__FILE__)); define('CANNAIQ_MENUS_PLUGIN_URL', plugin_dir_url(__FILE__)); diff --git a/wordpress-plugin/crawlsy-menus.php b/wordpress-plugin/crawlsy-menus.php index b6e8150b..3cf537d3 100644 --- a/wordpress-plugin/crawlsy-menus.php +++ b/wordpress-plugin/crawlsy-menus.php @@ -3,7 +3,7 @@ * Plugin Name: Crawlsy Menus * Plugin URI: https://creationshop.io * Description: Display cannabis product menus from Crawlsy with Elementor integration - * Version: 1.5.2 + * Version: 1.5.4 * Author: Creationshop * Author URI: https://creationshop.io * License: GPL v2 or later @@ -15,7 +15,7 @@ if (!defined('ABSPATH')) { exit; // Exit if accessed directly } -define('CRAWLSY_MENUS_VERSION', '1.5.2'); +define('CRAWLSY_MENUS_VERSION', '1.5.4'); define('CRAWLSY_MENUS_API_URL', 'https://cannaiq.co/api/v1'); define('CRAWLSY_MENUS_PLUGIN_DIR', plugin_dir_path(__FILE__)); define('CRAWLSY_MENUS_PLUGIN_URL', plugin_dir_url(__FILE__));