const fs = require('node:fs'); const path = require('node:path'); const crypto = require('node:crypto'); const root = path.resolve(__dirname, '..'); const sources = { common: 'E:/workspace/frontend/cmvr-iot-frontend/cmvr-iot-common', aima: 'E:/workspace/frontend/cmvr-iot-frontend/CMVR-AIMA' }; const inventory = JSON.parse(fs.readFileSync(path.join(root, 'docs/cmvr-source-inventory.json'), 'utf8')); let mismatches = 0; for (const item of inventory) { const [project, ...relative] = item.source.split('/'); const filename = path.join(sources[project], ...relative); const actual = crypto.createHash('sha256').update(fs.readFileSync(filename)).digest('hex'); if (actual !== item.sha256) { console.error(`Source changed: ${item.source}`); mismatches++; } if (!fs.existsSync(path.join(root, item.target))) { console.error(`Missing imported file: ${item.target}`); mismatches++; } } console.log(`${inventory.length} original files checked; ${mismatches} source changes or missing imported files.`); process.exitCode = mismatches ? 1 : 0;