postVersion.ts 792 B

123456789101112131415161718192021222324
  1. import { OUTPUT_DIR, VERSION } from '../constant';
  2. import fs, { writeFileSync } from 'fs-extra';
  3. import chalk from 'chalk';
  4. import { getRootPath } from '../utils';
  5. import { nanoid } from 'nanoid';
  6. export const runBuild = async () => {
  7. try {
  8. try {
  9. const versionJson = {
  10. version: 'V' + nanoid(10),
  11. };
  12. fs.mkdirp(getRootPath(OUTPUT_DIR));
  13. writeFileSync(getRootPath(`${OUTPUT_DIR}/${VERSION}`), JSON.stringify(versionJson));
  14. console.log(chalk.cyan(`✨ [${VERSION}]`) + ` - file is build successfully!`);
  15. } catch (error) {
  16. console.log(chalk.red('configuration file configuration file failed to package:\n' + error));
  17. }
  18. } catch (error) {
  19. console.log(chalk.red('vite build error:\n' + error));
  20. process.exit(1);
  21. }
  22. };
  23. runBuild();