Summary: allow-large-files Bumps [app-builder-lib](https://github.com/electron-userland/electron-builder) from 22.9.1 to 22.10.5. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/electron-userland/electron-builder/releases">app-builder-lib's releases</a>.</em></p> <blockquote> <h2>22.10.5</h2> <p>We have a new maintainer — welcome Mike Maietta (<a href="https://github.com/mmaietta"><code>@mmaietta</code></a>)!</p> <p><strong>electron-updater</strong> 4.3.8 contains fix for <a href="https://github.com/electron-userland/electron-builder/issues/5595">#5595</a>. This version is a pre-release.</p> <h3>Bug Fixes</h3> <ul> <li>Look for the Amazon cred header to remove auth header (<a href="https://github.com/electron-userland/electron-builder/issues/5594">#5594</a>) (<a href="46a8840bb4">46a8840</a>)</li> <li><strong>mac:</strong> fix "Contents/Info.plist" don't have identical SHAs when creating a universal build (<a href="https://github.com/electron-userland/electron-builder/issues/5550">#5550</a>) (<a href="0ba839b72b">0ba839b</a>)</li> <li>updating nsis script to properly identify arm64 vs x64 vs ia32 package files within universal installers. (<a href="https://github.com/electron-userland/electron-builder/issues/5558">#5558</a>) (<a href="60f7fe367c">60f7fe3</a>)</li> <li><strong>mac:</strong> Allow arm64 macs to update to x64 version if no arm64 version available (<a href="https://github.com/electron-userland/electron-builder/issues/5524">#5524</a>) (<a href="dc5c2f8e77">dc5c2f8</a>)</li> <li><strong>mac:</strong> Pass platformName and options in doPack (<a href="https://github.com/electron-userland/electron-builder/issues/5511">#5511</a>) (<a href="f78e3f48d7">f78e3f4</a>)</li> <li><strong>mac:</strong> Workaround for hdiutil randomly failing (<a href="https://github.com/electron-userland/electron-builder/issues/5431">#5431</a>) (<a href="https://github.com/electron-userland/electron-builder/issues/5464">#5464</a>) (<a href="53270cfe4e">53270cf</a>)</li> <li>binary detection signing (<a href="https://github.com/electron-userland/electron-builder/issues/5493">#5493</a>) (<a href="a6e86b5930">a6e86b5</a>), closes <a href="https://github.com/electron-userland/electron-builder/issues/5465">#5465</a></li> <li>ci-tests (<a href="https://github.com/electron-userland/electron-builder/issues/5523">#5523</a>) (<a href="ced6e50b93">ced6e50</a>)</li> </ul> <h3>Features</h3> <ul> <li><strong>electron-updater:</strong> follow <code>autoInstallOnAppQuit = false</code> on macOS (<a href="https://github.com/electron-userland/electron-builder/issues/5271">#5271</a>) (<a href="1643d56960">1643d56</a>)</li> <li>add support for executableName to non-Linux Platforms (<a href="https://github.com/electron-userland/electron-builder/issues/5409">#5409</a>) (<a href="106b68010f">106b680</a>)</li> <li>Custom electronDist callback (<a href="https://github.com/electron-userland/electron-builder/issues/5527">#5527</a>) (<a href="4f4e018771">4f4e018</a>)</li> <li>macOS default architecture (<a href="https://github.com/electron-userland/electron-builder/issues/5495">#5495</a>) (<a href="https://github.com/electron-userland/electron-builder/issues/5504">#5504</a>) (<a href="5203d7eb15">5203d7e</a>)</li> </ul> <h2>22.10.4</h2> <h3>Bug Fixes</h3> <ul> <li>CI unit tests (<a href="https://github.com/electron-userland/electron-builder/issues/5489">#5489</a>) (<a href="637334ddba">637334d</a>)</li> </ul> <h3>Features</h3> <ul> <li>Apple Silicon Universal Support (<a href="https://github.com/electron-userland/electron-builder/issues/5481">#5481</a>) (<a href="ca20151c34">ca20151</a>)</li> <li><strong>mas:</strong> Apple Silicon support (<a href="https://github.com/electron-userland/electron-builder/issues/5484">#5484</a>) (<a href="6b7d30555d">6b7d305</a>)</li> </ul> <h3>Reverts</h3> <ul> <li>Revert "fix: codesign all binary-like files (<a href="https://github.com/electron-userland/electron-builder/issues/5322">#5322</a>)" (<a href="https://github.com/electron-userland/electron-builder/issues/5488">#5488</a>) (<a href="026227888f">0262278</a>), closes <a href="https://github.com/electron-userland/electron-builder/issues/5322">#5322</a> <a href="https://github.com/electron-userland/electron-builder/issues/5488">#5488</a></li> </ul> <h2>22.10.3</h2> <h3>Bug Fixes</h3> <ul> <li>signing of playwright (<a href="https://github.com/electron-userland/electron-builder/issues/5451">#5451</a>) (<a href="50750683b1">5075068</a>)</li> <li><strong>dmg:</strong> new version of mac_alias (<a href="https://github.com/electron-userland/electron-builder/issues/5460">#5460</a>) (<a href="a8acb583bc">a8acb58</a>)</li> <li>compiler error and test updates (<a href="https://github.com/electron-userland/electron-builder/issues/5449">#5449</a>) (<a href="0dec1b8c19">0dec1b8</a>)</li> <li><strong>AppImage:</strong> Add default argument --no-sandbox (<a href="https://github.com/electron-userland/electron-builder/issues/4496">#4496</a>) (<a href="ede6d50ddb">ede6d50</a>)</li> <li><strong>linux:</strong> Linux icon is not set if path is not explicitly defined in config (<a href="https://github.com/electron-userland/electron-builder/issues/5385">#5385</a>) (<a href="9fd950bc04">9fd950b</a>)</li> <li><strong>nsis:</strong> cs locale typos in messages (<a href="https://github.com/electron-userland/electron-builder/issues/5358">#5358</a>) (<a href="0fb69b5d11">0fb69b5</a>)</li> <li>codesign all binary-like files (<a href="https://github.com/electron-userland/electron-builder/issues/5322">#5322</a>) (<a href="27ea1b2b9c">27ea1b2</a>)</li> </ul> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="79940292bd"><code>7994029</code></a> Cannot read property 'log' of undefined (<a href="https://github.com/electron-userland/electron-builder/issues/5622">#5622</a>)</li> <li><a href="1643d56960"><code>1643d56</code></a> feat(electron-updater): follow <code>autoInstallOnAppQuit = false</code> on macOS (<a href="https://github.com/electron-userland/electron-builder/issues/5271">#5271</a>)</li> <li><a href="0360cd1705"><code>0360cd1</code></a> chore(build-utils): remove unreachable useless statement in createMessage (<a href="https://github.com/electron-userland/electron-builder/issues/5">https://github.com/facebook/flipper/issues/5</a>...</li> <li><a href="c348e318ce"><code>c348e31</code></a> Add "open" guard for AsarUtil to fix concurrent builds (<a href="https://github.com/electron-userland/electron-builder/issues/5567">#5567</a>)</li> <li><a href="11aa06c701"><code>11aa06c</code></a> Detect CI tag for Bitbucket pipelines</li> <li><a href="8decc18674"><code>8decc18</code></a> (fix) master branch depCheck + tests (<a href="https://github.com/electron-userland/electron-builder/issues/5630">#5630</a>)</li> <li><a href="46a8840bb4"><code>46a8840</code></a> fix: Look for the Amazon cred header to remove auth header (<a href="https://github.com/electron-userland/electron-builder/issues/5594">#5594</a>)</li> <li><a href="0ba839b72b"><code>0ba839b</code></a> fix(mac): fix "Contents/Info.plist" don't have identical SHAs when creating a...</li> <li><a href="60f7fe367c"><code>60f7fe3</code></a> fix: updating nsis script to properly identify arm64 vs x64 vs ia32 package f...</li> <li><a href="5de0db981d"><code>5de0db9</code></a> chore: lint</li> <li>Additional commits viewable in <a href="https://github.com/electron-userland/electron-builder/compare/v22.9.1...v22.10.5">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `dependabot rebase` will rebase this PR - `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `dependabot merge` will merge this PR after your CI passes on it - `dependabot squash and merge` will squash and merge this PR after your CI passes on it - `dependabot cancel merge` will cancel a previously requested merge and block automerging - `dependabot reopen` will reopen this PR if it is closed - `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Pull Request resolved: https://github.com/facebook/flipper/pull/2072 Reviewed By: passy Differential Revision: D27230105 Pulled By: priteshrnandgaonkar fbshipit-source-id: e53e942319a15d982797f7ce3af128a8b25b357f
336 lines
9.8 KiB
TypeScript
Executable File
336 lines
9.8 KiB
TypeScript
Executable File
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import path from 'path';
|
|
import fs from 'fs-extra';
|
|
import {
|
|
Platform,
|
|
Arch,
|
|
ElectronDownloadOptions,
|
|
build,
|
|
AfterPackContext,
|
|
AppInfo,
|
|
} from 'electron-builder';
|
|
import {spawn} from 'promisify-child-process';
|
|
import {
|
|
buildFolder,
|
|
compileRenderer,
|
|
compileMain,
|
|
die,
|
|
getVersionNumber,
|
|
genMercurialRevision,
|
|
generatePluginEntryPoints,
|
|
} from './build-utils';
|
|
import fetch from '@adobe/node-fetch-retry';
|
|
import {getIcons, buildLocalIconPath, getIconURL} from '../app/src/utils/icons';
|
|
import isFB from './isFB';
|
|
import copyPackageWithDependencies from './copy-package-with-dependencies';
|
|
import {staticDir, distDir} from './paths';
|
|
import yargs from 'yargs';
|
|
import {WinPackager} from 'app-builder-lib/out/winPackager';
|
|
|
|
// Used in some places to avoid release-to-release changes. Needs
|
|
// to be this high for some MacOS-specific things that I can't
|
|
// remember right now.
|
|
const FIX_RELEASE_VERSION = '50.0.0';
|
|
|
|
const argv = yargs
|
|
.usage('yarn build [args]')
|
|
.version(false)
|
|
.options({
|
|
mac: {
|
|
type: 'boolean',
|
|
group: 'targets',
|
|
},
|
|
'mac-dmg': {
|
|
type: 'boolean',
|
|
group: 'targets',
|
|
},
|
|
win: {
|
|
type: 'boolean',
|
|
group: 'targets',
|
|
},
|
|
linux: {
|
|
type: 'boolean',
|
|
group: 'targets',
|
|
},
|
|
'linux-deb': {
|
|
type: 'boolean',
|
|
group: 'targets',
|
|
},
|
|
'linux-snap': {
|
|
type: 'boolean',
|
|
group: 'targets',
|
|
},
|
|
version: {
|
|
description:
|
|
'Unique build identifier to be used as the version patch part for the build',
|
|
type: 'number',
|
|
},
|
|
channel: {
|
|
description: 'Release channel for the build',
|
|
choices: ['stable', 'insiders'],
|
|
default: 'stable',
|
|
},
|
|
})
|
|
.help()
|
|
.strict()
|
|
.check((argv) => {
|
|
const targetSpecified =
|
|
argv.mac ||
|
|
argv['mac-dmg'] ||
|
|
argv.win ||
|
|
argv.linux ||
|
|
argv['linux-deb'] ||
|
|
argv['linux-snap'];
|
|
if (!targetSpecified) {
|
|
throw new Error('No targets specified. eg. --mac, --win, or --linux');
|
|
}
|
|
return true;
|
|
})
|
|
.parse(process.argv.slice(1));
|
|
|
|
if (isFB) {
|
|
process.env.FLIPPER_FB = 'true';
|
|
}
|
|
|
|
process.env.FLIPPER_RELEASE_CHANNEL = argv.channel;
|
|
|
|
async function generateManifest(versionNumber: string) {
|
|
await fs.writeFile(
|
|
path.join(distDir, 'manifest.json'),
|
|
JSON.stringify({
|
|
package: 'com.facebook.sonar',
|
|
version_name: versionNumber,
|
|
}),
|
|
);
|
|
}
|
|
|
|
async function modifyPackageManifest(
|
|
buildFolder: string,
|
|
versionNumber: string,
|
|
hgRevision: string | null,
|
|
channel: string,
|
|
) {
|
|
// eslint-disable-next-line no-console
|
|
console.log('Creating package.json manifest');
|
|
const manifest = require('../package.json');
|
|
const manifestStatic = require('../static/package.json');
|
|
|
|
// The manifest's dependencies are bundled with the final app by
|
|
// electron-builder. We want to bundle the dependencies from the static-folder
|
|
// because all dependencies from the root-folder are already bundled by metro.
|
|
manifest.dependencies = manifestStatic.dependencies;
|
|
manifest.main = 'index.js';
|
|
manifest.version = versionNumber;
|
|
if (hgRevision != null) {
|
|
manifest.revision = hgRevision;
|
|
}
|
|
manifest.releaseChannel = channel;
|
|
await fs.writeFile(
|
|
path.join(buildFolder, 'package.json'),
|
|
JSON.stringify(manifest, null, ' '),
|
|
);
|
|
}
|
|
|
|
// Same as for MacOS, we are hardcoding version information and other
|
|
// properties on Windows that change from release to release to improve cache
|
|
// behaviour. This is especially important as the .exe contains the Electron/Chromium
|
|
// frameworks which are > 120 MB in size.
|
|
// Note: This is run *after* packing has completed, meaning that ZIP file will
|
|
// not include these changes. As our packer operates on the unpacked results,
|
|
// this doesn't matter.
|
|
async function afterPack(context: AfterPackContext) {
|
|
if (context.electronPlatformName !== 'win32' || !isFB) {
|
|
return;
|
|
}
|
|
|
|
// Because all of this is implemented in an OOP way,
|
|
// we're having to do a lot of hacky shit here to
|
|
// temporarily override properties. While it may look
|
|
// cleaner to just have a big ts-ignore block, by
|
|
// only disabling `readonly` flags, we at least
|
|
// get remaining guarantees regarding type alignment
|
|
// and property names being present.
|
|
type Mutable<T> = {-readonly [P in keyof T]: T[P]};
|
|
const originalPackager = Object.assign({}, context.packager);
|
|
const packager = (context.packager as unknown) as WinPackager;
|
|
const appInfo: Mutable<AppInfo> = packager.appInfo;
|
|
const exeFileName = `${packager.appInfo.productFilename}.exe`;
|
|
appInfo.version = FIX_RELEASE_VERSION;
|
|
appInfo.buildVersion = FIX_RELEASE_VERSION;
|
|
appInfo.shortVersion = FIX_RELEASE_VERSION;
|
|
// Contains a side-effect dependent on the current year.
|
|
Object.defineProperty(appInfo, 'copyright', {
|
|
get: () => 'Facebook, Inc.',
|
|
});
|
|
packager.signAndEditResources(
|
|
path.join(context.appOutDir, exeFileName),
|
|
context.arch,
|
|
context.outDir,
|
|
path.basename(exeFileName, '.exe'),
|
|
packager.platformSpecificBuildOptions.requestedExecutionLevel,
|
|
);
|
|
(context as Mutable<AfterPackContext>).packager = originalPackager;
|
|
}
|
|
|
|
async function buildDist(buildFolder: string) {
|
|
const targetsRaw: Map<Platform, Map<Arch, string[]>>[] = [];
|
|
const postBuildCallbacks: (() => void)[] = [];
|
|
|
|
if (argv.mac || argv['mac-dmg']) {
|
|
targetsRaw.push(Platform.MAC.createTarget(['dir']));
|
|
// You can build mac apps on Linux but can't build dmgs, so we separate those.
|
|
if (argv['mac-dmg']) {
|
|
targetsRaw.push(Platform.MAC.createTarget(['dmg']));
|
|
}
|
|
postBuildCallbacks.push(() =>
|
|
spawn('zip', ['-qyr9', '../Flipper-mac.zip', 'Flipper.app'], {
|
|
cwd: path.join(distDir, 'mac'),
|
|
encoding: 'utf-8',
|
|
}),
|
|
);
|
|
}
|
|
if (argv.linux || argv['linux-deb'] || argv['linux-snap']) {
|
|
targetsRaw.push(Platform.LINUX.createTarget(['zip']));
|
|
|
|
if (argv['linux-deb']) {
|
|
// linux targets can be:
|
|
// AppImage, snap, deb, rpm, freebsd, pacman, p5p, apk, 7z, zip, tar.xz, tar.lz, tar.gz, tar.bz2, dir
|
|
targetsRaw.push(Platform.LINUX.createTarget(['deb']));
|
|
}
|
|
if (argv['linux-snap']) {
|
|
targetsRaw.push(Platform.LINUX.createTarget(['snap']));
|
|
}
|
|
}
|
|
if (argv.win) {
|
|
targetsRaw.push(Platform.WINDOWS.createTarget(['zip']));
|
|
}
|
|
|
|
if (!targetsRaw.length) {
|
|
throw new Error('No targets specified. eg. --mac, --win, or --linux');
|
|
}
|
|
|
|
// merge all target maps into a single map
|
|
let targetsMerged: [Platform, Map<Arch, string[]>][] = [];
|
|
for (const target of targetsRaw) {
|
|
targetsMerged = targetsMerged.concat(Array.from(target));
|
|
}
|
|
const targets = new Map(targetsMerged);
|
|
|
|
const electronDownloadOptions: ElectronDownloadOptions = {};
|
|
if (process.env.electron_config_cache) {
|
|
electronDownloadOptions.cache = process.env.electron_config_cache;
|
|
}
|
|
|
|
try {
|
|
await build({
|
|
publish: 'never',
|
|
config: {
|
|
appId: `com.facebook.sonar`,
|
|
productName: 'Flipper',
|
|
directories: {
|
|
buildResources: buildFolder,
|
|
output: distDir,
|
|
},
|
|
electronDownload: electronDownloadOptions,
|
|
npmRebuild: false,
|
|
linux: {
|
|
executableName: 'flipper',
|
|
},
|
|
mac: {
|
|
bundleVersion: FIX_RELEASE_VERSION,
|
|
},
|
|
win: {
|
|
signAndEditExecutable: !isFB,
|
|
},
|
|
afterPack,
|
|
},
|
|
projectDir: buildFolder,
|
|
targets,
|
|
});
|
|
return await Promise.all(postBuildCallbacks.map((p) => p()));
|
|
} catch (err) {
|
|
return die(err);
|
|
}
|
|
}
|
|
|
|
async function copyStaticFolder(buildFolder: string) {
|
|
console.log(`⚙️ Copying static package with dependencies...`);
|
|
await copyPackageWithDependencies(staticDir, buildFolder);
|
|
console.log('✅ Copied static package with dependencies.');
|
|
}
|
|
|
|
function downloadIcons(buildFolder: string) {
|
|
const iconURLs = Object.entries(getIcons()).reduce<
|
|
{
|
|
name: string;
|
|
size: number;
|
|
density: number;
|
|
}[]
|
|
>((acc, [name, sizes]) => {
|
|
acc.push(
|
|
// get icons in @1x and @2x
|
|
...sizes.map((size) => ({name, size, density: 1})),
|
|
...sizes.map((size) => ({name, size, density: 2})),
|
|
);
|
|
return acc;
|
|
}, []);
|
|
|
|
return Promise.all(
|
|
iconURLs.map(({name, size, density}) => {
|
|
const url = getIconURL(name, size, density);
|
|
return fetch(url, {})
|
|
.then((res) => {
|
|
if (res.status !== 200) {
|
|
throw new Error(
|
|
// eslint-disable-next-line prettier/prettier
|
|
`Could not download the icon ${name} from ${url}: got status ${
|
|
res.status
|
|
}`,
|
|
);
|
|
}
|
|
return res;
|
|
})
|
|
.then(
|
|
(res) =>
|
|
new Promise((resolve, reject) => {
|
|
const fileStream = fs.createWriteStream(
|
|
path.join(buildFolder, buildLocalIconPath(name, size, density)),
|
|
);
|
|
res.body.pipe(fileStream);
|
|
res.body.on('error', reject);
|
|
fileStream.on('finish', resolve);
|
|
}),
|
|
);
|
|
}),
|
|
);
|
|
}
|
|
|
|
(async () => {
|
|
const dir = await buildFolder();
|
|
// eslint-disable-next-line no-console
|
|
console.log('Created build directory', dir);
|
|
|
|
await compileMain();
|
|
await generatePluginEntryPoints(argv.channel === 'insiders');
|
|
await copyStaticFolder(dir);
|
|
await downloadIcons(dir);
|
|
await compileRenderer(dir);
|
|
const versionNumber = getVersionNumber(argv.version);
|
|
const hgRevision = await genMercurialRevision();
|
|
await modifyPackageManifest(dir, versionNumber, hgRevision, argv.channel);
|
|
await fs.ensureDir(distDir);
|
|
await generateManifest(versionNumber);
|
|
await buildDist(dir);
|
|
// eslint-disable-next-line no-console
|
|
console.log('✨ Done');
|
|
process.exit();
|
|
})();
|