|
| 1 | +#!/usr/bin/env node |
| 2 | + |
| 3 | +/** |
| 4 | + * Sync Extension Version Script |
| 5 | + * |
| 6 | + * Automatically syncs the extension version from extensions/roopik-roo/package.json |
| 7 | + * to the builtInExtensions array in product.json. |
| 8 | + * |
| 9 | + * This ensures the IDE build downloads the correct version from the marketplace. |
| 10 | + * |
| 11 | + * Usage: |
| 12 | + * node .github/scripts/sync-extension-version.cjs |
| 13 | + */ |
| 14 | + |
| 15 | +const fs = require('fs'); |
| 16 | +const path = require('path'); |
| 17 | + |
| 18 | +const ROOT_DIR = path.join(__dirname, '..', '..'); |
| 19 | +const PRODUCT_JSON_PATH = path.join(ROOT_DIR, 'product.json'); |
| 20 | +const EXTENSION_PACKAGE_JSON_PATH = path.join(ROOT_DIR, 'extensions', 'roopik-roo', 'package.json'); |
| 21 | + |
| 22 | +function syncVersion() { |
| 23 | + try { |
| 24 | + // Read extension package.json |
| 25 | + const extensionPackage = JSON.parse(fs.readFileSync(EXTENSION_PACKAGE_JSON_PATH, 'utf8')); |
| 26 | + const extensionVersion = extensionPackage.version; |
| 27 | + |
| 28 | + if (!extensionVersion) { |
| 29 | + console.error('Error: Could not find version in extension package.json'); |
| 30 | + process.exit(1); |
| 31 | + } |
| 32 | + |
| 33 | + // Read product.json |
| 34 | + const productJson = JSON.parse(fs.readFileSync(PRODUCT_JSON_PATH, 'utf8')); |
| 35 | + |
| 36 | + // Find the roopik.roodio extension in builtInExtensions |
| 37 | + const roodioExtension = productJson.builtInExtensions?.find(ext => ext.name === 'roopik.roodio'); |
| 38 | + |
| 39 | + if (!roodioExtension) { |
| 40 | + console.error('Error: Could not find roopik.roodio extension in product.json builtInExtensions'); |
| 41 | + process.exit(1); |
| 42 | + } |
| 43 | + |
| 44 | + const currentProductVersion = roodioExtension.version; |
| 45 | + |
| 46 | + if (currentProductVersion === extensionVersion) { |
| 47 | + console.log(`Versions already in sync: ${extensionVersion}`); |
| 48 | + return; |
| 49 | + } |
| 50 | + |
| 51 | + // Update the version |
| 52 | + roodioExtension.version = extensionVersion; |
| 53 | + |
| 54 | + // Write back to product.json |
| 55 | + fs.writeFileSync(PRODUCT_JSON_PATH, JSON.stringify(productJson, null, '\t') + '\n', 'utf8'); |
| 56 | + |
| 57 | + console.log(`Updated product.json version: ${currentProductVersion} -> ${extensionVersion}`); |
| 58 | + |
| 59 | + } catch (error) { |
| 60 | + console.error('Error syncing version:', error.message); |
| 61 | + process.exit(1); |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +syncVersion(); |
0 commit comments