// Shared build helper: inline shared/effective-grants.js into a workflow's // Code node body, stripping the module.exports shim. All gen_*.js scripts use // this so the "single source of truth" file is what actually ships. const fs = require('fs'); const path = require('path'); const SHARED_PATH = path.join(__dirname, 'shared', 'effective-grants.js'); const EXPORT_MARKER = '/* SHARED_EXPORT_BEGIN */'; // Returns the shared library source WITHOUT the module.exports block — a // plain script ready to prepend to (or include in) a Code node's jsCode. function sharedSource() { const src = fs.readFileSync(SHARED_PATH, 'utf8'); const idx = src.indexOf(EXPORT_MARKER); if (idx === -1) throw new Error('SHARED_EXPORT_BEGIN marker not found in shared source'); return src.slice(0, idx).replace(/\s+$/, ''); } module.exports = { sharedSource, SHARED_PATH };