client-build-stats.ts 845 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { registerTSPaths } from '../server/helpers/register-ts-paths'
  2. registerTSPaths()
  3. import { readdir, stat } from 'fs-extra'
  4. import { join } from 'path'
  5. import { root } from '@server/helpers/core-utils'
  6. async function run () {
  7. const result = {
  8. app: await buildResult(join(root(), 'client', 'dist', 'en-US')),
  9. embed: await buildResult(join(root(), 'client', 'dist', 'standalone', 'videos'))
  10. }
  11. console.log(JSON.stringify(result))
  12. }
  13. run()
  14. .catch(err => console.error(err))
  15. async function buildResult (path: string) {
  16. const distFiles = await readdir(path)
  17. const files: { name: string, size: number }[] = []
  18. for (const file of distFiles) {
  19. const filePath = join(path, file)
  20. const statsResult = await stat(filePath)
  21. files.push({
  22. name: file,
  23. size: statsResult.size
  24. })
  25. }
  26. return files
  27. }