#!/usr/bin/env node const fs = require('fs').promises; const os = require('os'); const path = require('path'); const { exec } = require('child_process'); const ADDONS_PATH = path.join(os.homedir(), '/Library/Application Support/FileMaker/Extensions/AddonModules'); const ADDON_PATH = path.join(ADDONS_PATH, 'Way_FileMaker_add-on'); const LANGUAGES = 'zh de en es fr it ja ko nl pt sv'.split(' '); const TITLE = 'Way FileMaker add-on'; const DESCRIPTION = 'FileMaker add-on for easy communication with Way, your all-in-one platform to document, track, and streamline your business operations.'; const CATEGORY = 'Integrations'; const GUID = '8709587F-FB80-4337-AC4E-0332249FAAA5'; const VERSION = '1.0'; (async () => { await fs.mkdir('./dist', { recursive: true }); try { await fs.rm(path.join(ADDON_PATH, '.DS_Store'), { recursive: true }); console.log('Removed .DS_Store'); } catch {} const infoPath = path.join(ADDON_PATH, 'info.json'); const info = JSON.stringify({ GUID, Attribution: 'Smart Yellow', URL: 'https://www.workourway.com', Icon_Color: '#ffffff', Version: VERSION, Clients: ['Pro'], }, null, 4); await fs.writeFile(infoPath, info); console.log(`Wrote info to ${path.basename(infoPath)}`); for (const language of LANGUAGES) { const infoPath = path.join(ADDON_PATH, `info_${language}.json`); const info = JSON.stringify({ Title: TITLE, Description: DESCRIPTION, Category: CATEGORY, Features: [], Optimized: ['Desktop', 'Tablet', 'Mobile'], }, null, 4); await fs.writeFile(infoPath, info); console.log(`Wrote info to ${path.basename(infoPath)}`); } const zipPath = path.join(process.cwd(), `dist/way_addon.zip`); exec(`zip -r ${zipPath} .`, { cwd: ADDON_PATH }, (error, stdout, stderr) => { if (error) { console.error(`Error creating archive: ${error.message}`); return; } if (stderr) { console.error(`Error creating archive: ${stderr}`); return; } console.log(`Archive created: ${ADDON_PATH}.zip`); }); })();