Files
Rubén Norte 29704b1f02 Add support for Static Hermes staging in Fantom (#52105)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52105

Changelog: [internal]

I just learnt there's a Hermes variant that we don't support (staging) so this adds support for it.

Reviewed By: christophpurrer

Differential Revision: D76897715

fbshipit-source-id: 3113edde3c785d71ad4a57dd435f16e13ab46976
2025-06-18 09:36:36 -07:00

81 lines
2.3 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import type {FeatureFlagValue} from '../../../packages/react-native/scripts/featureflags/types';
import type {FantomTestConfig} from '../runner/getFantomTestConfigs';
import type {HermesVariant} from '../runner/utils';
import {
DEFAULT_FEATURE_FLAGS,
DEFAULT_HERMES_VARIANT,
DEFAULT_MODE,
FantomTestConfigHermesVariant,
FantomTestConfigMode,
} from '../runner/getFantomTestConfigs';
function formatFantomMode(mode: FantomTestConfigMode): string {
switch (mode) {
case FantomTestConfigMode.DevelopmentWithSource:
return 'mode 🐛';
case FantomTestConfigMode.DevelopmentWithBytecode:
return 'mode 🐛🔢';
case FantomTestConfigMode.Optimized:
return 'mode 🚀';
}
}
function formatFantomHermesVariant(hermesVariant: HermesVariant): string {
switch (hermesVariant) {
case FantomTestConfigHermesVariant.Hermes:
return 'hermes';
case FantomTestConfigHermesVariant.StaticHermesStable:
return 'shermes 🆕';
case FantomTestConfigHermesVariant.StaticHermesStaging:
return 'shermes ⏭️';
case FantomTestConfigHermesVariant.StaticHermesExperimental:
return 'shermes 🧪';
}
}
function formatFantomFeatureFlag(
flagName: string,
flagValue: FeatureFlagValue,
): string {
if (typeof flagValue === 'boolean') {
return `${flagName} ${flagValue ? '✅' : '🛑'}`;
}
return `🔐 ${flagName} = ${flagValue}`;
}
export default function formatFantomConfig(config: FantomTestConfig): string {
const parts = [];
if (config.mode !== DEFAULT_MODE) {
parts.push(formatFantomMode(config.mode));
}
if (config.hermesVariant !== DEFAULT_HERMES_VARIANT) {
parts.push(formatFantomHermesVariant(config.hermesVariant));
}
for (const flagType of ['common', 'jsOnly', 'reactInternal'] as const) {
for (const [flagName, flagValue] of Object.entries(
config.flags[flagType],
)) {
if (flagValue !== DEFAULT_FEATURE_FLAGS[flagType][flagName]) {
parts.push(formatFantomFeatureFlag(flagName, flagValue));
}
}
}
return parts.join(', ');
}