mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-12 06:06:37 +03:00
642adb5e84
* chore(deps-dev): bump archiver from 7.0.1 to 8.0.0 Bumps [archiver](https://github.com/archiverjs/node-archiver) from 7.0.1 to 8.0.0. - [Release notes](https://github.com/archiverjs/node-archiver/releases) - [Changelog](https://github.com/archiverjs/node-archiver/blob/master/CHANGELOG.md) - [Commits](https://github.com/archiverjs/node-archiver/compare/7.0.1...8.0.0) --- updated-dependencies: - dependency-name: archiver dependency-version: 8.0.0 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Fix archiver 8 ZIP creation --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Paul Bakaus <paul.bakaus@gmail.com>
62 lines
1.8 KiB
JavaScript
62 lines
1.8 KiB
JavaScript
/**
|
|
* ZIP Generation Utilities
|
|
*
|
|
* Creates ZIP bundles for each provider's distribution
|
|
* Uses archiver instead of shell `zip` for cross-platform compatibility
|
|
* (Cloudflare Pages build environment may not have zip installed)
|
|
*/
|
|
|
|
import path from 'path';
|
|
import { createWriteStream, existsSync, statSync } from 'fs';
|
|
import { ZipArchive } from 'archiver';
|
|
|
|
/**
|
|
* Create ZIP file for a provider directory
|
|
* @param {string} providerDir - Path to provider directory
|
|
* @param {string} distDir - Path to dist directory
|
|
* @param {string} providerName - Name of the provider
|
|
*/
|
|
export async function createProviderZip(providerDir, distDir, providerName) {
|
|
const zipFileName = `${providerName}.zip`;
|
|
const zipPath = path.join(distDir, zipFileName);
|
|
|
|
if (!existsSync(providerDir)) {
|
|
console.warn(`⚠️ Provider directory not found: ${providerDir}`);
|
|
return;
|
|
}
|
|
|
|
try {
|
|
await new Promise((resolve, reject) => {
|
|
const output = createWriteStream(zipPath);
|
|
const archive = new ZipArchive({ zlib: { level: 9 } });
|
|
|
|
output.on('close', resolve);
|
|
archive.on('error', reject);
|
|
|
|
archive.pipe(output);
|
|
archive.glob('**/*', {
|
|
cwd: providerDir,
|
|
dot: true,
|
|
ignore: ['**/.DS_Store'],
|
|
});
|
|
archive.finalize();
|
|
});
|
|
|
|
const stats = statSync(zipPath);
|
|
const sizeMB = (stats.size / 1024 / 1024).toFixed(2);
|
|
console.log(` 📦 ${zipFileName} (${sizeMB} MB)`);
|
|
} catch (error) {
|
|
console.error(` ❌ Failed to create ${zipFileName}:`, error.message);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Create ZIP files for all providers + universal
|
|
* @param {string} distDir - Path to dist directory
|
|
*/
|
|
export async function createAllZips(distDir) {
|
|
console.log('\n📦 Creating ZIP bundles...');
|
|
|
|
await createProviderZip(path.join(distDir, 'universal'), distDir, 'universal');
|
|
}
|