diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/dist/way_addon.zip b/dist/way_addon.zip new file mode 100644 index 0000000..3e2fc97 Binary files /dev/null and b/dist/way_addon.zip differ diff --git a/way.json b/dist/way_connector.json similarity index 100% rename from way.json rename to dist/way_connector.json diff --git a/scripts/build_addon b/scripts/build_addon new file mode 100755 index 0000000..b881e56 --- /dev/null +++ b/scripts/build_addon @@ -0,0 +1,67 @@ +#!/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`); + }); + +})();