mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52826 Changelog: [internal] This is just an intermediate change to simplify how we format Fantom configs, so we can extend it to use other formatting formats (e.g.: short format to use in file names). Reviewed By: lenaic Differential Revision: D78924771 fbshipit-source-id: 4886a800a6836dc6a66539b1df079adb6c9c52e1
82 lines
2.3 KiB
JavaScript
82 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 {
|
|
FantomTestConfigHermesVariant,
|
|
FantomTestConfigMode,
|
|
} from '../runner/getFantomTestConfigs';
|
|
import {getOverrides} from './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 overrides = getOverrides(config);
|
|
const parts = [];
|
|
|
|
if (overrides.mode) {
|
|
parts.push(formatFantomMode(overrides.mode));
|
|
}
|
|
|
|
if (overrides.hermesVariant) {
|
|
parts.push(formatFantomHermesVariant(overrides.hermesVariant));
|
|
}
|
|
|
|
if (overrides.flags) {
|
|
for (const flagType of ['common', 'jsOnly', 'reactInternal'] as const) {
|
|
if (overrides.flags[flagType]) {
|
|
for (const [flagName, flagValue] of Object.entries(
|
|
overrides.flags[flagType],
|
|
)) {
|
|
parts.push(formatFantomFeatureFlag(flagName, flagValue));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return parts.join(', ');
|
|
}
|