Compare commits

...
Author SHA1 Message Date
Christian Falch e447e9aea7 [ios][prebuild] simplify logging in prebuild scripts
To reduce reduntant code by repeating the logging functionality in each JS module, this commit introduces a factory for creating a logger with a given prefix.

- Create factory `createLogger`
- Remove redundant log implementations
- Changed to use factory in hermes.js and ios-prebuild.js
2025-05-22 12:00:12 +02:00
Christian Falch 2dc20c5dc7 [ios][prebuild] fix wrong directory in hermes prebuild check
When checking if we should download hermes artifacts, the path to the folder we're checking was wrong, causing hermes to always be downloaded.

This commit fixes this by renaming it from `Libraries` -> `Library`
2025-05-22 11:52:07 +02:00
Christian Falch 554dbce652 [ios][prebuild] add missing React-RCTSettings
Added missing module React-RCTSettings to the Swift package.

This was found when testing intergrating with a bare bones React Native project.
2025-05-22 08:34:48 +02:00
4 changed files with 34 additions and 32 deletions
+9
View File
@@ -514,6 +514,13 @@ let reactRCTLinking = RNTarget(
dependencies: [.jsi, .reactTurboModuleCore]
)
let reactSettings = RNTarget(
name: .reactSettings,
path: "Libraries/Settings",
searchPaths: ["ReactCommon", ReactFBReactNativeSpecPath, FBLazyVectorPath],
dependencies: [.reactTurboModuleCore, .yoga]
)
let targets = [
reactDebug,
jsi,
@@ -567,6 +574,7 @@ let targets = [
reactFeatureflagsNativemodule,
reactNativeModuleDom,
reactAppDelegate,
reactSettings
]
let package = Package(
@@ -646,6 +654,7 @@ extension String {
static let reactFeatureflagsNativemodule = "React-featureflagsnativemodule"
static let reactNativeModuleDom = "React-domnativemodule"
static let reactAppDelegate = "React-RCTAppDelegate"
static let reactSettings = "React-RCTSettings"
}
func relativeSearchPath(_ depth: Int, _ path: String) -> String {
+3 -1
View File
@@ -11,7 +11,7 @@
const {prepareHermesArtifactsAsync} = require('./ios-prebuild/hermes');
const {
createFolderIfNotExists,
prebuildLog,
createLogger,
throwIfOnEden,
} = require('./ios-prebuild/utils');
const {execSync} = require('child_process');
@@ -24,6 +24,8 @@ const packageJsonPath = path.join(
'package.json',
);
const prebuildLog = createLogger('Prebuild');
// $FlowIgnore[unsupported-syntax]
const {version: currentVersion} = require(packageJsonPath);
+4 -17
View File
@@ -8,12 +8,15 @@
* @format
*/
const {createLogger} = require('./utils');
const {execSync} = require('child_process');
const fs = require('fs');
const path = require('path');
const stream = require('stream');
const {promisify} = require('util');
const pipeline = promisify(stream.pipeline);
const hermesLog = createLogger('Hermes');
/**
* Downloads hermes artifacts from the specified version and build type. If you want to specify a specific
@@ -116,7 +119,7 @@ function checkExistingVersion(
const hermesXCFramework = path.join(
artifactsPath,
'destroot',
'Libraries',
'Library',
'Frameworks',
'universal',
'hermes.xcframework',
@@ -359,22 +362,6 @@ function abort(message /*: string */) {
throw new Error(message);
}
function hermesLog(
message /*: string */,
level /*: 'info' | 'warning' | 'error' */ = 'warning',
) {
// Simple log coloring for terminal output
const prefix = '[Hermes] ';
let colorFn = (x /*:string*/) => x;
if (process.stdout.isTTY) {
if (level === 'info') colorFn = x => `\x1b[32m${x}\x1b[0m`;
else if (level === 'error') colorFn = x => `\x1b[31m${x}\x1b[0m`;
else colorFn = x => `\x1b[33m${x}\x1b[0m`;
}
console.log(colorFn(prefix + message));
}
module.exports = {
prepareHermesArtifactsAsync,
};
+18 -14
View File
@@ -37,24 +37,28 @@ function throwIfOnEden() {
throw new Error('Cannot prepare the iOS prebuilds on an Eden checkout');
}
function prebuildLog(
message /*: string */,
level /*: 'info' | 'warning' | 'error' */ = 'warning',
) {
// Simple log coloring for terminal output
const prefix = '[Prebuild] ';
let colorFn = (x /*:string*/) => x;
if (process.stdout.isTTY) {
if (level === 'info') colorFn = x => `\x1b[32m${x}\x1b[0m`;
else if (level === 'error') colorFn = x => `\x1b[31m${x}\x1b[0m`;
else colorFn = x => `\x1b[33m${x}\x1b[0m`;
}
function createLogger(
prefix /*: string */,
) /*: (message: string, level?: 'info' | 'warning' | 'error') => void */ {
return function (
message /*: string */,
level /*: 'info' | 'warning' | 'error' */ = 'info',
) {
// Simple log coloring for terminal output
const resolvedPrefix = `[${prefix}] `;
let colorFn = (x /*:string*/) => x;
if (process.stdout.isTTY) {
if (level === 'info') colorFn = x => `\x1b[32m${x}\x1b[0m`;
else if (level === 'error') colorFn = x => `\x1b[31m${x}\x1b[0m`;
else colorFn = x => `\x1b[33m${x}\x1b[0m`;
}
console.log(colorFn(prefix + message));
console.log(colorFn(resolvedPrefix) + message);
};
}
module.exports = {
createFolderIfNotExists,
throwIfOnEden,
prebuildLog,
createLogger,
};