example-run.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. const path = require('path')
  2. const exec = require('./lib/shell')
  3. const globby = require('globby')
  4. let rootDir = path.resolve(__dirname, '..')
  5. let examplesDir = path.join(rootDir, 'example-projects')
  6. let givenProjName = process.argv[2]
  7. let runCmd = process.argv[3]
  8. if (!givenProjName) {
  9. console.error('Must specify an example-project name, or "all"')
  10. process.exit(1)
  11. }
  12. if (!runCmd) {
  13. console.error('Must specify a run command')
  14. process.exit(1)
  15. }
  16. let projNames = givenProjName === 'all' ?
  17. globby.sync('*', { cwd: examplesDir, onlyDirectories: true }) :
  18. [ givenProjName ]
  19. for (let projName of projNames) {
  20. let projDir = path.join(examplesDir, projName)
  21. console.log('')
  22. console.log('PROJECT:', projName)
  23. console.log(projDir)
  24. switch(projName) {
  25. /*
  26. each of these projects need to be built with old-fashioned npm-install in their individual directories.
  27. to exclude them from yarn workspaces and cache their directories in CI, keep these files in sync:
  28. - package.json
  29. - .travis.yml
  30. */
  31. case 'next': // somehow incompatible with babel-plugin-transform-require-ignore. REVISIT
  32. case 'next-scheduler': // same
  33. case 'nuxt': // nuxt cli tool uses webpack 4
  34. case 'vue-typescript': // vue cli tool uses webpack 4
  35. case 'vue-vuex': // vue cli tool uses webpack 4
  36. case 'parcel': // doesn't support pnp yet. parcel 2 WILL
  37. console.log('Using NPM simulation')
  38. console.log()
  39. exec.sync(
  40. [ 'yarn', 'run', 'example:npm', projName, runCmd ],
  41. { cwd: rootDir, exitOnError: true, live: true }
  42. )
  43. break
  44. case 'angular':
  45. // !!! - HACK: pnpify is broken with our built yarn (see .yarnrc.yml)
  46. console.log('SKIPPING PnP simulation')
  47. continue
  48. // !!!
  49. console.log('Using PnP simulation')
  50. console.log()
  51. exec.sync(
  52. [ 'yarn', 'run', 'example:pnp', projName, runCmd ],
  53. { cwd: rootDir, exitOnError: true, live: true }
  54. )
  55. break
  56. default:
  57. console.log('Normal Yarn execution')
  58. console.log()
  59. exec.sync(
  60. [ 'yarn', 'run', runCmd ],
  61. { cwd: projDir, exitOnError: true, live: true }
  62. )
  63. break
  64. }
  65. console.log('')
  66. }