update-readmes.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. const path = require('path')
  2. const { readFileSync, writeFileSync } = require('./lib/util')
  3. const { publicPackageStructs } = require('./lib/package-index')
  4. const exec = require('./lib/shell').sync.withOptions({
  5. exitOnError: true,
  6. live: true
  7. })
  8. exec([ path.join(__dirname, 'require-clean-working-tree.sh') ])
  9. const handlebars = require('handlebars')
  10. let template = handlebars.compile(readFileSync(path.join(__dirname, '../packages/README.md.tpl')))
  11. let readmePaths = []
  12. for (let struct of publicPackageStructs) {
  13. let readmePath = path.join(__dirname, '..', struct.dir, 'README.md')
  14. let configPath = path.join(__dirname, '..', struct.dir, 'package.json')
  15. let config = require(configPath)
  16. let text = template(config)
  17. writeFileSync(readmePath, text)
  18. readmePaths.push(readmePath)
  19. }
  20. for (let readmePath of readmePaths) {
  21. exec(
  22. [ 'git', 'add', path.basename(readmePath) ],
  23. { cwd: path.dirname(readmePath) } // will do it in whatever git repo
  24. )
  25. }
  26. exec([ 'git', 'commit', '-m', 'updated readmes' ], { cwd: path.join(__dirname, '../packages-premium') })
  27. exec([ 'git', 'add', 'packages-premium' ], { cwd: path.join(__dirname, '..') })
  28. exec([ 'git', 'commit', '-m', 'updated readmes' ], { cwd: path.join(__dirname, '..') })