Open-Generative-AI/afterPack.js
Anil Matcha aa6917e339 release: v1.0.2 — rename Seedance 2.0 models to SD 2, fix Windows build size
- Rename Seedance 2.0 → SD 2 (t2v, extend, i2v models)
- Bump version to 1.0.2
- Update README download links to v1.0.2
- Fix afterPack.js to strip platform-inappropriate @next/swc native binaries,
  reducing Windows installer from ~739 MB unpacked to ~144 MB
- Windows build now targets x64 only (arm64 cross-compile via Wine is broken on macOS)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 06:57:25 +05:30

38 lines
1.5 KiB
JavaScript

import { execSync } from 'child_process';
import path from 'path';
import fs from 'fs';
export default async function afterPack({ appOutDir, packager }) {
const platformName = packager.platform.name;
// Remove Next.js SWC native binaries that don't belong on this target platform.
// They are bundled because `next` is in dependencies, but only the host-platform
// binary is ever used at runtime in the Electron app.
const nextDir = path.join(appOutDir,
platformName === 'mac'
? `${packager.appInfo.productName}.app/Contents/Resources`
: 'resources',
'app.asar.unpacked/node_modules/@next'
);
if (fs.existsSync(nextDir)) {
const keepPrefix = platformName === 'mac' ? 'swc-darwin'
: platformName === 'windows' ? 'swc-win32'
: 'swc-linux';
for (const entry of fs.readdirSync(nextDir)) {
if (entry.startsWith('swc-') && !entry.startsWith(keepPrefix)) {
const fullPath = path.join(nextDir, entry);
fs.rmSync(fullPath, { recursive: true, force: true });
console.log(` • removed foreign SWC binary path=${fullPath}`);
}
}
}
if (platformName !== 'mac') return;
const appPath = path.join(appOutDir, `${packager.appInfo.productName}.app`);
console.log(` • ad-hoc signing path=${appPath}`);
execSync(`codesign --deep --force --sign - "${appPath}"`, { stdio: 'inherit' });
console.log(` • ad-hoc signing complete`);
}