Summary: Bumps [prettier](https://github.com/prettier/prettier) from 2.2.1 to 2.3.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/prettier/prettier/releases">prettier's releases</a>.</em></p> <blockquote> <h2>2.3.0</h2> <p><a href="https://github.com/prettier/prettier/compare/2.2.1...2.3.0">diff</a></p> <p>{emoji:1f517} <a href="https://prettier.io/blog/2021/05/09/2.3.0.html">Release Notes</a></p> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/prettier/prettier/blob/main/CHANGELOG.md">prettier's changelog</a>.</em></p> <blockquote> <h1>2.3.0</h1> <p><a href="https://github.com/prettier/prettier/compare/2.2.1...2.3.0">diff</a></p> <p>{emoji:1f517} <a href="https://prettier.io/blog/2021/05/09/2.3.0.html">Release Notes</a></p> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="2afc3b9ae6"><code>2afc3b9</code></a> Release 2.3.0</li> <li><a href="7cfa9aa89b"><code>7cfa9aa</code></a> Fix pre-commit hook setup command (<a href="https://github-redirect.dependabot.com/prettier/prettier/issues/10710">#10710</a>)</li> <li><a href="c8c02b4753"><code>c8c02b4</code></a> Build(deps-dev): Bump concurrently from 6.0.2 to 6.1.0 in /website (<a href="https://github-redirect.dependabot.com/prettier/prettier/issues/10834">#10834</a>)</li> <li><a href="6506e0f50e"><code>6506e0f</code></a> Build(deps-dev): Bump webpack-cli from 4.6.0 to 4.7.0 in /website (<a href="https://github-redirect.dependabot.com/prettier/prettier/issues/10836">#10836</a>)</li> <li><a href="69fae9c291"><code>69fae9c</code></a> Build(deps): Bump flow-parser from 0.150.0 to 0.150.1 (<a href="https://github-redirect.dependabot.com/prettier/prettier/issues/10839">#10839</a>)</li> <li><a href="164a6e2351"><code>164a6e2</code></a> Switch CLI to async (<a href="https://github-redirect.dependabot.com/prettier/prettier/issues/10804">#10804</a>)</li> <li><a href="d3e7e2f634"><code>d3e7e2f</code></a> Build(deps): Bump codecov/codecov-action from v1.4.1 to v1.5.0 (<a href="https://github-redirect.dependabot.com/prettier/prettier/issues/10833">#10833</a>)</li> <li><a href="9e09845da0"><code>9e09845</code></a> Build(deps): Bump <code>@angular/compiler</code> from 11.2.12 to 11.2.13 (<a href="https://github-redirect.dependabot.com/prettier/prettier/issues/10838">#10838</a>)</li> <li><a href="1bfab3d045"><code>1bfab3d</code></a> Build(deps-dev): Bump eslint from 7.25.0 to 7.26.0 (<a href="https://github-redirect.dependabot.com/prettier/prettier/issues/10840">#10840</a>)</li> <li><a href="387fce4ed8"><code>387fce4</code></a> Minor formatting tweaks (<a href="https://github-redirect.dependabot.com/prettier/prettier/issues/10807">#10807</a>)</li> <li>Additional commits viewable in <a href="https://github.com/prettier/prettier/compare/2.2.1...2.3.0">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/2300 Reviewed By: passy Differential Revision: D28323849 Pulled By: cekkaewnumchai fbshipit-source-id: 1842877ccc9a9587af7f0d9ff9432c2075c8ee22
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();
|
|
})();
|