merge-package-customization.js 973 B

1234567891011121314151617181920212223242526272829
  1. // Merges customization configs (package.next.js, package.expo.js) into apps' package.json
  2. const fs = require('fs');
  3. const path = require('path');
  4. const root = path.resolve(__dirname, '..');
  5. const configPath = path.join(root, 'packages/app/customization/config');
  6. const nextCustom = require(path.join(configPath, 'package.next.js'));
  7. const expoCustom = require(path.join(configPath, 'package.expo.js'));
  8. const merge = (base, custom) => ({
  9. ...base,
  10. dependencies: { ...base.dependencies, ...(custom?.dependencies || {}) },
  11. });
  12. const nextPkg = require(path.join(root, 'apps/next/package.json'));
  13. const expoPkg = require(path.join(root, 'apps/expo/package.json'));
  14. const mergedNext = merge(nextPkg, nextCustom);
  15. const mergedExpo = merge(expoPkg, expoCustom);
  16. fs.writeFileSync(
  17. path.join(root, 'apps/next/package.json'),
  18. JSON.stringify(mergedNext, null, 2)
  19. );
  20. fs.writeFileSync(
  21. path.join(root, 'apps/expo/package.json'),
  22. JSON.stringify(mergedExpo, null, 2)
  23. );