Files
pbakaus_impeccable/scripts/lib/zip.js
T
Paul BakausandClaude Opus 4.6 4ff4f4643a Add Kiro provider support, clean up legacy code and unused ZIPs
- Add Kiro transformer and build integration (.kiro/skills/ structure)
- Add Kiro to validation allowlists, API handlers, and homepage badge
- Replace legacy getFilePath in Vercel API with unified skills directory structure
- Remove individual provider ZIP creation (only universal ZIPs needed)
- Simplify bundle API allowlist to universal/universal-prefixed only

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 10:33:51 -08:00

58 lines
1.7 KiB
JavaScript

/**
* ZIP Generation Utilities
*
* Creates ZIP bundles for each provider's distribution
*/
import { $ } from 'bun';
import path from 'path';
import { existsSync, readdirSync, statSync } from 'fs';
/**
* 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);
// Check if provider directory exists
if (!existsSync(providerDir)) {
console.warn(`⚠️ Provider directory not found: ${providerDir}`);
return;
}
// Remove existing zip if present
if (existsSync(zipPath)) {
await $`rm ${zipPath}`.quiet();
}
try {
// Create zip using bun's shell
// cd into provider dir and zip all contents
await $`cd ${providerDir} && zip -r ../${zipFileName} . -x "*.DS_Store"`.quiet();
// Get file size for reporting
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...');
// Universal ZIPs (unprefixed + prefixed)
await createProviderZip(path.join(distDir, 'universal'), distDir, 'universal');
await createProviderZip(path.join(distDir, 'universal-prefixed'), distDir, 'universal-prefixed');
}