compare-layout.js 591 B

12345678910111213141516171819
  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(report.explain());
  11. process.exitCode = 1;
  12. }
  13. } else {
  14. console.log(`WARNING: ${name} is missing from the current branch`);
  15. }
  16. }