| 123456789101112131415161718192021 |
- // Build only the two new functions; do not rebuild/deploy the existing identity functions.
- import fs from 'node:fs';
- import path from 'node:path';
- import crypto from 'node:crypto';
- import { fileURLToPath } from 'node:url';
- const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
- const data = JSON.parse(fs.readFileSync(path.join(root, 'references/runtime-data.json')));
- const out = path.join(root, 'dist/member-groups');fs.mkdirSync(out, { recursive: true });
- const source = [path.join(root, '../src/core/member-groups.js'), ...['postgres.mjs', 'files.mjs', 'core.mjs', 'confirmation.mjs',
- 'workshop.mjs', 'board-actions.mjs', 'member-groups.mjs', 'bootstrap.mjs'].map((f) => path.join(root, 'src', f))]
- .map((p) => fs.readFileSync(p, 'utf8').replace(/^import .*;\r?\n/gm, '').replace(/^export /gm, '')).join('\n');
- const html = fs.readFileSync(path.join(root, 'web/confirm.html'), 'utf8');
- const functions = [];
- for (const name of ['ksfGetPublicMemberGroups', 'ksfManagePublicMemberGroups']) {
- const code = source + '\nasync function handler(request,response){return runDatabaseFunction(' + JSON.stringify(name) + ',request,response,' + JSON.stringify(data) + ',' + JSON.stringify(html) + ');}\n';
- new Function(code);
- fs.writeFileSync(path.join(out, name + '.js'), code);
- functions.push({ name, path: '/' + name, file: name + '.js', sha256: crypto.createHash('sha256').update(code).digest('hex') });
- }
- fs.writeFileSync(path.join(out, 'manifest.json'), JSON.stringify({ release: 'ksf.member-groups.20261105.v1', existingFunctionsModified: false, functions }, null, 2));
- console.log(JSON.stringify({ built: functions.length, out, existingFunctionsModified: false }));
|