compare-layout.js 662 B

1234567891011121314151617181920
  1. const fs = require('fs');
  2. const { getStorageUpgradeReport } = require('@openzeppelin/upgrades-core/dist/storage');
  3. const { ref, head } = require('yargs').argv;
  4. const oldLayout = JSON.parse(fs.readFileSync(ref));
  5. const newLayout = JSON.parse(fs.readFileSync(head));
  6. for (const name in oldLayout) {
  7. if (name in newLayout) {
  8. const report = getStorageUpgradeReport(oldLayout[name], newLayout[name], {});
  9. if (!report.ok) {
  10. console.log(`Storage layout incompatilibity found in ${name}:`);
  11. console.log(report.explain());
  12. process.exitCode = 1;
  13. }
  14. } else {
  15. console.log(`WARNING: ${name} is missing from the current branch`);
  16. }
  17. }