import { execSync } from 'node:child_process';
import { mkdirSync } from 'node:fs';

mkdirSync('dist', { recursive: true });

// Only include production files, exclude dev dependencies and source files
const excludes = [
  '*.zip',
  '.git/*',
  '.gitignore',
  'node_modules/*',
  'vendor/*',
  'admin-spa/node_modules/*',
  'admin-spa/src/*',
  'admin-spa/.eslintrc.cjs',
  'admin-spa/tsconfig.json',
  'admin-spa/tsconfig.node.json',
  'admin-spa/vite.config.ts',
  'admin-spa/package.json',
  'admin-spa/package-lock.json',
  'customer-spa/node_modules/*',
  'customer-spa/src/*',
  'customer-spa/.eslintrc.cjs',
  'customer-spa/tsconfig.json',
  'customer-spa/tsconfig.node.json',
  'customer-spa/vite.config.ts',
  'customer-spa/package.json',
  'customer-spa/package-lock.json',
  'scripts/*',
  'dist/*',
  'references/*',
  '.vscode/*',
  '.idea/*',
  '*.log',
  '*.tmp',
  '*.temp',
  '.DS_Store',
  'Thumbs.db',
  '.env',
  '.env.local',
  'package.json',
  'package-lock.json',
  'composer.json',
  'composer.lock',
  '*.md',
].map(pattern => `-x "${pattern}"`).join(' ');

execSync(`zip -r dist/woonoow.zip . ${excludes}`, { stdio: 'inherit' });

console.log('✅ Packed: dist/woonoow.zip');