This repository has no description
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657import { createHash } from 'node:crypto';import { existsSync } from 'node:fs';import { mkdir, readFile, readdir, writeFile } from 'node:fs/promises';import path from 'node:path';import { zipSync } from 'fflate';import { syncShared } from './sync_shared.mjs';
await syncShared(['firefox']);
const source = process.argv.includes('--source');const entries = {};const hashes = {};// Fixed ZIP metadata and sorted entries make builds byte-for-byte reproducible.const options = { level: 9, mtime: new Date(1980, 0, 1), os: 3, attrs: 0o100644 << 16 };
async function add(file, archivePath = file) { const data = await readFile(file); entries[archivePath] = [data, options]; hashes[archivePath] = createHash('sha256').update(data).digest('hex');}
async function addDirectory(directory, prefix) { for (const entry of (await readdir(directory, { withFileTypes: true })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) { if (entry.name.startsWith('.')) continue; const file = path.join(directory, entry.name); const archivePath = prefix ? `${prefix}/${entry.name}` : entry.name; if (entry.isDirectory()) { if (source && entry.name === 'licenses') continue; // Recreated from pinned npm packages. await addDirectory(file, archivePath); } else { if (source && ['tesseract.min.js', 'worker.min.js', 'tesseract-core-lstm.wasm.js'].includes(entry.name)) continue; await add(file, archivePath); } }}
await addDirectory('extension/firefox', source ? 'extension/firefox' : '');if (source) { await addDirectory('extension/shared', 'extension/shared'); await addDirectory('branding/extension-icons', 'branding/extension-icons'); await add(existsSync('docs/README-firefox-review.md') ? 'docs/README-firefox-review.md' : 'README.md', 'README.md'); for (const file of [ 'package.json', 'package-lock.json', 'scripts/build_firefox_ocr.mjs', 'scripts/firefox_buffer_shim.mjs', 'scripts/package_firefox.mjs', 'test/test_firefox_validation.mjs', 'scripts/sync_shared.mjs', 'PRIVACY.md', ]) await add(file);}
await mkdir('dist/firefox', { recursive: true });const { version } = JSON.parse(await readFile('extension/firefox/manifest.json', 'utf8'));const filename = source ? `bskyplus-firefox-source-v${version}.zip` : `bsky_-${version}.zip`;const zip = zipSync(entries, options);await writeFile(`dist/firefox/${filename}`, zip);if (!source) await writeFile('dist/firefox/build-sha256.json', JSON.stringify(hashes, null, 2) + '\n');console.log(`${filename}: ${zip.length} bytes; SHA-256 ${createHash('sha256').update(zip).digest('hex')}`);