genScript.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const services = require('./services')
  2. console.log('#!/bin/bash')
  3. console.log('set -ex')
  4. switch (process.argv.pop()) {
  5. case 'install':
  6. console.log('yarn workspaces focus --all --production')
  7. break
  8. case 'compile':
  9. for (const service of services) {
  10. console.log('pushd', `services/${service.name}`)
  11. switch (service.name) {
  12. case 'web':
  13. // precompile pug in background
  14. console.log('yarn run precompile-pug &')
  15. console.log('pug_precompile=$!')
  16. // Avoid downloading of cypress
  17. console.log('export CYPRESS_INSTALL_BINARY=0')
  18. // install webpack and frontend dependencies
  19. console.log('yarn install')
  20. // run webpack
  21. console.log('yarn run webpack:production')
  22. // uninstall webpack and frontend dependencies
  23. console.log('yarn workspaces focus --all --production')
  24. // Wait for pug precompile to finish
  25. console.log('wait "$pug_precompile"')
  26. break
  27. default:
  28. console.log(`echo ${service.name} does not require a compilation`)
  29. }
  30. console.log('popd')
  31. }
  32. break
  33. default:
  34. console.error('unknown command')
  35. console.log('exit 101')
  36. process.exit(101)
  37. }