prepublish.mjs 688 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env zx
  2. import 'zx/globals'
  3. await $`pnpm build`
  4. await $`pnpm snapshot`
  5. let { version } = JSON.parse(await fs.readFile('./package.json'))
  6. const playgroundDir = path.resolve(__dirname, '../playground/')
  7. cd(playgroundDir)
  8. await $`pnpm install`
  9. await $`git add -A .`
  10. try {
  11. await $`git commit -m "version ${version} snapshot"`
  12. } catch (e) {
  13. if (!e.stdout.includes('nothing to commit')) {
  14. throw e
  15. }
  16. }
  17. await $`git tag -m "v${version}" v${version}`
  18. await $`git push --follow-tags`
  19. const projectRoot = path.resolve(__dirname, '../')
  20. cd(projectRoot)
  21. await $`git add playground`
  22. await $`git commit -m 'chore: update snapshot' --allow-empty`
  23. await $`git push --follow-tags`