#!/usr/bin/env node // Builds wayBetter for X's part of the shared wayBetter Store in apps/web/public/store/ with the // framework CLI (`waybetter store build`, waybetter/packages/waybetter/cli/store.mjs) and X's // items (scripts/store.config.mjs). Other apps' items in catalog.json are kept as they are. // Then sign it: `node scripts/sign-store.mjs` (needs the store key; writes catalog.json.sig). // The site (/themes/, /plugins/) and the in-app store read the same catalog. // // node scripts/build-store.mjs [--base https://waybetter.fyi/store/] [--out dir] [--plugins dir] // (--plugins: read the first-party plugins from another folder, e.g. an export of committed files.) import { dirname, join, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; import { buildStore } from '../waybetter/packages/waybetter/cli/store.mjs'; import config from './store.config.mjs'; const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..'); function options(argv) { const out = { base: undefined, out: join(ROOT, 'apps/web/public/store') }; for (let i = 0; i < argv.length; i += 1) { if (argv[i] === '--base') out.base = argv[++i]; else if (argv[i] === '--out') out.out = resolve(argv[++i]); else if (argv[i] === '--plugins') process.env.WAYBETTER_STORE_PLUGINS = resolve(argv[++i]); else throw new Error(`unknown option ${argv[i]}`); } return out; } try { const { path, items } = await buildStore(config, options(process.argv.slice(2))); console.log(`store: ${items.filter(i => i.kind === 'plugin').length} plugins, ${items.filter(i => i.kind === 'theme').length} themes, ${items.filter(i => i.kind === 'strings').length} string packs → ${dirname(path)}`); console.log('Now sign it: node scripts/sign-store.mjs'); } catch (error) { console.error(`build-store: ${error.stack ?? error}`); process.exit(1); }