Merge branch 'main' of github.com:facebook/flipper into universalBuild
This commit is contained in:
@@ -132,7 +132,12 @@ const argv = yargs
|
||||
default: false,
|
||||
},
|
||||
mac: {
|
||||
describe: 'Build a platform-specific bundle for MacOS.',
|
||||
describe: 'Build arm64 and x64 bundles for MacOS.',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
'mac-local': {
|
||||
describe: 'Build local architecture bundle for MacOS.',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
@@ -432,7 +437,7 @@ async function buildServerRelease() {
|
||||
await fs.mkdirp(path.join(dir, 'static', 'defaultPlugins'));
|
||||
|
||||
await prepareDefaultPlugins(argv.channel === 'insiders');
|
||||
await compileServerMain(false);
|
||||
await compileServerMain();
|
||||
await copyStaticResources(dir, versionNumber);
|
||||
await linkLocalDeps(dir);
|
||||
await downloadIcons(path.join(dir, 'static'));
|
||||
@@ -455,6 +460,15 @@ async function buildServerRelease() {
|
||||
platforms.push(BuildPlatform.MAC_X64);
|
||||
platforms.push(BuildPlatform.MAC_AARCH64);
|
||||
}
|
||||
if (argv.macLocal) {
|
||||
const architecture = os.arch();
|
||||
console.log(`⚙️ Local architecture: ${architecture}`);
|
||||
if (architecture == 'arm64') {
|
||||
platforms.push(BuildPlatform.MAC_AARCH64);
|
||||
} else {
|
||||
platforms.push(BuildPlatform.MAC_X64);
|
||||
}
|
||||
}
|
||||
if (argv.win) {
|
||||
platforms.push(BuildPlatform.WINDOWS);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import fetch from '@adobe/node-fetch-retry';
|
||||
// eslint-disable-next-line node/no-extraneous-import
|
||||
import type {Icon} from 'flipper-ui-core';
|
||||
|
||||
const AVAILABLE_SIZES: Icon['size'][] = [8, 10, 12, 16, 18, 20, 24, 28, 32];
|
||||
const AVAILABLE_SIZES: Icon['size'][] = [8, 10, 12, 16, 18, 20, 24, 28, 32, 48];
|
||||
|
||||
export type Icons = {
|
||||
[key: string]: Icon['size'][];
|
||||
@@ -32,37 +32,26 @@ function getIconPartsFromName(icon: string): {
|
||||
}
|
||||
|
||||
export async function downloadIcons(buildFolder: string) {
|
||||
const icons: Icons = JSON.parse(
|
||||
const icons: string[] = JSON.parse(
|
||||
await fs.promises.readFile(path.join(buildFolder, 'icons.json'), {
|
||||
encoding: 'utf8',
|
||||
}),
|
||||
);
|
||||
const iconURLs = Object.entries(icons).reduce<Icon[]>(
|
||||
(acc, [entryName, sizes]) => {
|
||||
const {trimmedName: name, variant} = getIconPartsFromName(entryName);
|
||||
acc.push(
|
||||
// get icons in @1x and @2x
|
||||
...sizes.map((size) => ({name, variant, size, density: 1})),
|
||||
...sizes.map((size) => ({name, variant, size, density: 2})),
|
||||
);
|
||||
return acc;
|
||||
},
|
||||
[],
|
||||
);
|
||||
const iconURLs: Pick<Icon, 'name' | 'variant'>[] = icons.map((rawName) => {
|
||||
const {trimmedName: name, variant} = getIconPartsFromName(rawName);
|
||||
return {name, variant};
|
||||
});
|
||||
|
||||
// Download first largest instance of each icon
|
||||
await Promise.all(
|
||||
iconURLs.map(async (icon) => {
|
||||
const sizeIndex = AVAILABLE_SIZES.indexOf(icon.size);
|
||||
if (sizeIndex === -1) {
|
||||
throw new Error('Size unavailable: ' + icon.size);
|
||||
}
|
||||
const sizesToTry = AVAILABLE_SIZES.slice(sizeIndex);
|
||||
const sizesToTry = [...AVAILABLE_SIZES];
|
||||
|
||||
while (sizesToTry.length) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const size = sizesToTry.shift()!;
|
||||
const size = sizesToTry.pop()!;
|
||||
|
||||
const url = getPublicIconUrl({...icon, size});
|
||||
const url = getPublicIconUrl({...(icon as Icon), size});
|
||||
const res = await fetch(url);
|
||||
if (res.status !== 200) {
|
||||
// console.log(
|
||||
@@ -88,21 +77,21 @@ export async function downloadIcons(buildFolder: string) {
|
||||
console.error(
|
||||
`Could not download the icon ${JSON.stringify(
|
||||
icon,
|
||||
)} from ${getPublicIconUrl(icon)}, didn't find any matching size`,
|
||||
)} from ${getPublicIconUrl({
|
||||
...icon,
|
||||
size: AVAILABLE_SIZES[AVAILABLE_SIZES.length - 1],
|
||||
} as Icon)}, didn't find any matching size`,
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// should match flipper-ui-core/src/utils/icons.tsx
|
||||
export function getPublicIconUrl({name, variant, size, density}: Icon) {
|
||||
export function getPublicIconUrl({name, variant, size}: Icon) {
|
||||
return `https://facebook.com/images/assets_DO_NOT_HARDCODE/facebook_icons/${name}_${variant}_${size}.png`;
|
||||
}
|
||||
|
||||
// should match app/src/utils/icons.tsx
|
||||
function buildLocalIconPath(icon: Icon) {
|
||||
return path.join(
|
||||
'icons',
|
||||
`${icon.name}-${icon.variant}-${icon.size}@${icon.density}x.png`,
|
||||
);
|
||||
function buildLocalIconPath(icon: Pick<Icon, 'name' | 'variant'>) {
|
||||
return path.join('icons', `${icon.name}-${icon.variant}_d.png`);
|
||||
}
|
||||
|
||||
@@ -73,6 +73,11 @@ const argv = yargs
|
||||
'Unique build identifier to be used as the version patch part for the build',
|
||||
type: 'number',
|
||||
},
|
||||
'react-native-only': {
|
||||
description: 'React Native only build',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
channel: {
|
||||
description: 'Release channel for the build',
|
||||
choices: ['stable', 'insiders'],
|
||||
@@ -115,6 +120,10 @@ if (argv['default-plugins-dir']) {
|
||||
process.env.FLIPPER_DEFAULT_PLUGINS_DIR = argv['default-plugins-dir'];
|
||||
}
|
||||
|
||||
if (argv['react-native-only']) {
|
||||
process.env.FLIPPER_REACT_NATIVE_ONLY = 'true';
|
||||
}
|
||||
|
||||
async function generateManifest(versionNumber: string) {
|
||||
await fs.writeFile(
|
||||
path.join(distDir, 'manifest.json'),
|
||||
@@ -130,6 +139,7 @@ async function modifyPackageManifest(
|
||||
versionNumber: string,
|
||||
hgRevision: string | null,
|
||||
channel: string,
|
||||
reactNativeOnly: boolean,
|
||||
) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Creating package.json manifest');
|
||||
@@ -148,6 +158,7 @@ async function modifyPackageManifest(
|
||||
manifest.revision = hgRevision;
|
||||
}
|
||||
manifest.releaseChannel = channel;
|
||||
manifest.reactNativeOnly = reactNativeOnly;
|
||||
await fs.writeFile(
|
||||
path.join(buildFolder, 'package.json'),
|
||||
JSON.stringify(manifest, null, ' '),
|
||||
@@ -265,6 +276,9 @@ async function buildDist(buildFolder: string) {
|
||||
},
|
||||
mac: {
|
||||
bundleVersion: FIX_RELEASE_VERSION,
|
||||
icon: process.env.FLIPPER_REACT_NATIVE_ONLY
|
||||
? path.resolve(buildFolder, 'icon-rn-only.icns')
|
||||
: path.resolve(buildFolder, 'icon.icns'),
|
||||
},
|
||||
win: {
|
||||
signAndEditExecutable: !isFB,
|
||||
@@ -299,7 +313,13 @@ async function copyStaticFolder(buildFolder: string) {
|
||||
await moveSourceMaps(dir, argv['source-map-dir']);
|
||||
const versionNumber = getVersionNumber(argv.version);
|
||||
const hgRevision = await genMercurialRevision();
|
||||
await modifyPackageManifest(dir, versionNumber, hgRevision, argv.channel);
|
||||
await modifyPackageManifest(
|
||||
dir,
|
||||
versionNumber,
|
||||
hgRevision,
|
||||
argv.channel,
|
||||
argv['react-native-only'],
|
||||
);
|
||||
await fs.ensureDir(distDir);
|
||||
await generateManifest(versionNumber);
|
||||
await buildDist(dir);
|
||||
|
||||
@@ -279,7 +279,7 @@ export function genMercurialRevision(): Promise<string | null> {
|
||||
.catch(() => null);
|
||||
}
|
||||
|
||||
export async function compileServerMain(dev: boolean) {
|
||||
export async function compileServerMain() {
|
||||
console.log('⚙️ Compiling server sources...');
|
||||
await exec(`cd ${serverDir} && yarn build`);
|
||||
console.log('✅ Compiled server sources.');
|
||||
|
||||
@@ -70,6 +70,10 @@ const argv = yargs
|
||||
'[FB-internal only] Will yield `true` on any GK. Disabled by default. Setting env var FLIPPER_ENABLE_ALL_GKS is equivalent',
|
||||
type: 'boolean',
|
||||
},
|
||||
'react-native-only': {
|
||||
description: '[FB-internal only] React Native only build',
|
||||
type: 'boolean',
|
||||
},
|
||||
channel: {
|
||||
describe:
|
||||
'[FB-internal only] Release channel. "stable" by default. Setting env var "FLIPPER_RELEASE_CHANNEL" is equivalent.',
|
||||
@@ -148,6 +152,10 @@ if (argv.channel !== undefined) {
|
||||
process.env.FLIPPER_RELEASE_CHANNEL = argv.channel;
|
||||
}
|
||||
|
||||
if (argv['react-native-only'] === true) {
|
||||
process.env.FLIPPER_REACT_NATIVE_ONLY = 'true';
|
||||
}
|
||||
|
||||
if (argv['force-version']) {
|
||||
process.env.FLIPPER_FORCE_VERSION = argv['force-version'];
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ async function copyStaticResources() {
|
||||
|
||||
async function restartServer() {
|
||||
try {
|
||||
await compileServerMain(true);
|
||||
await compileServerMain();
|
||||
await launchServer(true, ++startCount === 1); // only open on the first time
|
||||
} catch (e) {
|
||||
console.error(
|
||||
|
||||
@@ -16,7 +16,6 @@ import {EOL} from 'os';
|
||||
import pmap from 'p-map';
|
||||
import {rootDir} from './paths';
|
||||
import yargs from 'yargs';
|
||||
import {isPluginJson} from 'flipper-common';
|
||||
|
||||
const argv = yargs
|
||||
.usage('yarn tsc-plugins [args]')
|
||||
|
||||
Reference in New Issue
Block a user