Update flipper-runtime icon in server app bundle
Summary: Changelog: When requesting Keychain Access, you will now see "flipper-runtime" instead of a generic "node" process. Reviewed By: lblasa Differential Revision: D50261830 fbshipit-source-id: ef6fd7d5099c4ff7370f0401a5de3fde1659f1f3
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8f056646d9
commit
d40ccc8786
@@ -31,7 +31,7 @@ import isFB from './isFB';
|
|||||||
import yargs from 'yargs';
|
import yargs from 'yargs';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import {downloadIcons} from './build-icons';
|
import {downloadIcons} from './build-icons';
|
||||||
import {spawn} from 'promisify-child-process';
|
import {spawn, exec as execAsync} from 'promisify-child-process';
|
||||||
import {homedir} from 'os';
|
import {homedir} from 'os';
|
||||||
import {need as pkgFetch} from 'pkg-fetch';
|
import {need as pkgFetch} from 'pkg-fetch';
|
||||||
import {exec} from 'child_process';
|
import {exec} from 'child_process';
|
||||||
@@ -515,7 +515,7 @@ async function download(url: string, dest: string): Promise<void> {
|
|||||||
* @param dest - Destination directory for the extracted contents.
|
* @param dest - Destination directory for the extracted contents.
|
||||||
*/
|
*/
|
||||||
async function unpack(source: string, destination: string) {
|
async function unpack(source: string, destination: string) {
|
||||||
console.log(`⚙️ Extracting ${source}.`);
|
console.log(`⚙️ Extracting ${source} to ${destination}.`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fs.access(destination, fs.constants.F_OK);
|
await fs.access(destination, fs.constants.F_OK);
|
||||||
@@ -553,6 +553,40 @@ function nodePlatformFromBuildPlatform(platform: BuildPlatform): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function setRuntimeAppIcon(binaryPath: string): Promise<void> {
|
||||||
|
console.log(`⚙️ Updating runtime icon for MacOS in ${binaryPath}.`);
|
||||||
|
const iconPath = path.join(staticDir, 'icon.png');
|
||||||
|
const tempRsrcPath = path.join(os.tmpdir(), 'icon.rsrc');
|
||||||
|
const deRezCmd = `DeRez -only icns ${iconPath} > ${tempRsrcPath}`;
|
||||||
|
try {
|
||||||
|
await execAsync(deRezCmd);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(
|
||||||
|
`❌ Error while extracting icon with '${deRezCmd}'. Error: ${err}`,
|
||||||
|
);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
const rezCmd = `Rez -append ${tempRsrcPath} -o ${binaryPath}`;
|
||||||
|
try {
|
||||||
|
await execAsync(rezCmd);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(
|
||||||
|
`❌ Error while setting icon on executable ${binaryPath}. Error: ${err}`,
|
||||||
|
);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
const updateCmd = `SetFile -a C ${binaryPath}`;
|
||||||
|
try {
|
||||||
|
await execAsync(updateCmd);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(
|
||||||
|
`❌ Error while changing icon visibility on ${binaryPath}. Error: ${err}`,
|
||||||
|
);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
console.log(`✅ Updated flipper-runtime icon.`);
|
||||||
|
}
|
||||||
|
|
||||||
async function installNodeBinary(outputPath: string, platform: BuildPlatform) {
|
async function installNodeBinary(outputPath: string, platform: BuildPlatform) {
|
||||||
/**
|
/**
|
||||||
* Below is a temporary patch that doesn't use pkg-fetch to
|
* Below is a temporary patch that doesn't use pkg-fetch to
|
||||||
@@ -584,8 +618,15 @@ async function installNodeBinary(outputPath: string, platform: BuildPlatform) {
|
|||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
if (!cached) {
|
if (!cached) {
|
||||||
// Download node tarball from the distribution site.
|
// Download node tarball from the distribution site.
|
||||||
|
// If this is not present (due to a node update) follow these steps:
|
||||||
|
// - Update the download URL to `https://nodejs.org/dist/${NODE_VERSION}/${name}.tar.gz`
|
||||||
|
// - Ensure the Xcode developer tools are installed
|
||||||
|
// - Build a full MacOS server release locally using `yarn build:flipper-server --mac`
|
||||||
|
// - Enter the dist folder: dist/flipper-server-mac-aarch64/Flipper.app/Contents/MacOS
|
||||||
|
// - `mkdir bin && cp flipper-runtime bin/node && tar -czvf node-${NODE_VERSION}-darwin-arm64.tar.gz bin`
|
||||||
|
// - Upload the resulting tar ball to the Flipper release page as a new tag: https://github.com/facebook/flipper/releases
|
||||||
await download(
|
await download(
|
||||||
`https://nodejs.org/dist/${NODE_VERSION}/${name}.tar.gz`,
|
`https://github.com/facebook/flipper/releases/download/node-${NODE_VERSION}/${name}.tar.gz`,
|
||||||
downloadOutputPath,
|
downloadOutputPath,
|
||||||
);
|
);
|
||||||
// Finally, unpack the tarball to a local folder i.e. outputPath.
|
// Finally, unpack the tarball to a local folder i.e. outputPath.
|
||||||
@@ -607,6 +648,17 @@ async function installNodeBinary(outputPath: string, platform: BuildPlatform) {
|
|||||||
await fs.copyFile(nodePath, outputPath);
|
await fs.copyFile(nodePath, outputPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
platform === BuildPlatform.MAC_AARCH64 ||
|
||||||
|
platform === BuildPlatform.MAC_X64
|
||||||
|
) {
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
await setRuntimeAppIcon(outputPath);
|
||||||
|
} else {
|
||||||
|
console.warn("⚠️ Skipping icon update as it's only supported on macOS.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set +x on the binary as copyFile doesn't maintain the bit.
|
// Set +x on the binary as copyFile doesn't maintain the bit.
|
||||||
await fs.chmod(outputPath, 0o755);
|
await fs.chmod(outputPath, 0o755);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# Bump this to ensure we are getting a new content hash when only changing metadata.
|
||||||
|
1
|
||||||
@@ -58,9 +58,9 @@ server-linux:
|
|||||||
files:
|
files:
|
||||||
frameworks:
|
frameworks:
|
||||||
- '!*'
|
- '!*'
|
||||||
- node
|
- flipper-runtime
|
||||||
core:
|
core:
|
||||||
- '!node'
|
- '!flipper-runtime
|
||||||
- '!static'
|
- '!static'
|
||||||
static:
|
static:
|
||||||
- '!*'
|
- '!*'
|
||||||
|
|||||||
Reference in New Issue
Block a user