diff --git a/.build/zip-package.mjs b/.build/zip-package.mjs new file mode 100644 index 000000000..8b0de57ff --- /dev/null +++ b/.build/zip-package.mjs @@ -0,0 +1,30 @@ +#!/usr/bin/env node + +import AdmZip from 'adm-zip'; +import path from 'path'; +import { fileURLToPath } from 'url'; +import { readFileSync } from 'fs'; + +// Get __dirname in ESM +const __dirname = path.dirname(fileURLToPath(import.meta.url)) + +const pkg = JSON.parse( + readFileSync(path.join(__dirname, '../core', 'package.json'), 'utf8') +) + +// Create zip instance and add folder +const zip = new AdmZip(); +zip.addLocalFolder(path.join(__dirname, '../preview/dist'), 'dashboard'); + +zip.addLocalFile(path.join(__dirname, '../preview/static', 'og.png'), '.', 'preview.png'); + +zip.addFile("documentation.url", Buffer.from("[InternetShortcut]\nURL = https://tabler.io/docs")); + + +// Folder to zip and output path +const outputZipPath = path.join(__dirname, '../packages-zip', `tabler-${pkg.version}.zip`); + +// Write the zip file +zip.writeZip(outputZipPath); + +console.log(`Zipped folder to ${outputZipPath}`); \ No newline at end of file diff --git a/package.json b/package.json index 4ee7d2776..cb97cfe66 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "Premium and Open Source dashboard template with responsive and high quality UI.", "homepage": "https://tabler.io", "scripts": { - "build": "turbo build && pnpm run zip", + "build": "turbo build && pnpm run zip-package", "dev": "turbo dev", "clean": "turbo clean", "bundlewatch": "turbo bundlewatch", @@ -11,8 +11,8 @@ "publish": "changeset publish", "playwright": "pnpm run build && pnpm run vt", "reformat-md": "node .build/reformat-md.mjs", - "start": "pnpm dev", - "zip": "mkdir -p packages-zip && zip -r packages-zip/tabler-$(node -p \"require('./core/package.json').version\").zip preview/dist/*" + "zip-package": "node .build/zip-package.mjs", + "start": "pnpm dev" }, "packageManager": "pnpm@10.6.5", "devDependencies": { @@ -24,6 +24,7 @@ "@rollup/plugin-commonjs": "^28.0.3", "@rollup/plugin-node-resolve": "^16.0.1", "@rollup/plugin-replace": "^6.0.2", + "adm-zip": "^0.5.16", "autoprefixer": "^10.4.21", "bundlewatch": "^0.4.0", "clean-css-cli": "^5.6.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index af4c84e69..d71d04fb4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,6 +32,9 @@ importers: '@rollup/plugin-replace': specifier: ^6.0.2 version: 6.0.2(rollup@4.37.0) + adm-zip: + specifier: ^0.5.16 + version: 0.5.16 autoprefixer: specifier: ^10.4.21 version: 10.4.21(postcss@8.5.3) @@ -999,6 +1002,10 @@ packages: engines: {node: '>=0.4.0'} hasBin: true + adm-zip@0.5.16: + resolution: {integrity: sha512-TGw5yVi4saajsSEgz25grObGHEUaDrniwvA2qwSC060KfqGPdglhvPMA2lPIoxs3PQIItj2iag35fONcQqgUaQ==} + engines: {node: '>=12.0'} + ajv@6.12.6: resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} @@ -3971,6 +3978,8 @@ snapshots: acorn@8.14.0: {} + adm-zip@0.5.16: {} + ajv@6.12.6: dependencies: fast-deep-equal: 3.1.3