zip-package.mjs 894 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env node
  2. import AdmZip from 'adm-zip';
  3. import path from 'path';
  4. import { fileURLToPath } from 'url';
  5. import { readFileSync } from 'fs';
  6. // Get __dirname in ESM
  7. const __dirname = path.dirname(fileURLToPath(import.meta.url))
  8. const pkg = JSON.parse(
  9. readFileSync(path.join(__dirname, '../core', 'package.json'), 'utf8')
  10. )
  11. // Create zip instance and add folder
  12. const zip = new AdmZip();
  13. zip.addLocalFolder(path.join(__dirname, '../preview/dist'), 'dashboard');
  14. zip.addLocalFile(path.join(__dirname, '../preview/static', 'og.png'), '.', 'preview.png');
  15. zip.addFile("documentation.url", Buffer.from("[InternetShortcut]\nURL = https://tabler.io/docs"));
  16. // Folder to zip and output path
  17. const outputZipPath = path.join(__dirname, '../packages-zip', `tabler-${pkg.version}.zip`);
  18. // Write the zip file
  19. zip.writeZip(outputZipPath);
  20. console.log(`Zipped folder to ${outputZipPath}`);