feat: WordPress plugin versioning + heatmap fix + dynamic latest download
- Add VERSION file (1.5.4) for tracking WP plugin version - Update plugin headers to 1.5.4 (cannaiq-menus.php, crawlsy-menus.php) - Add dynamic /downloads/cannaiq-menus-latest.zip route that auto-redirects to highest version (no manual symlinks needed) - Update frontend download links to use -latest.zip - Fix StateHeatmap.tsx to parse API values as numbers (fixes string concat bug) - Document versioning rules in CLAUDE.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user