const NIGHTLY_SERVER_VERSION_PATTERN = /-nightly\.\d{8}\.\d+$/; export function formatAppDisplayName(input: { readonly baseName: string; readonly stageLabel: string; }): string { return `${input.baseName} (${input.stageLabel})`; } export function resolveServerBackedAppStageLabel(input: { readonly primaryServerVersion: string | null | undefined; readonly fallbackStageLabel: string; }): string { return input.primaryServerVersion && NIGHTLY_SERVER_VERSION_PATTERN.test(input.primaryServerVersion) ? "Nightly" : input.fallbackStageLabel; } export function resolveServerBackedAppDisplayName(input: { readonly baseName: string; readonly fallbackDisplayName: string; readonly fallbackStageLabel: string; readonly primaryServerVersion: string | null | undefined; }): string { const stageLabel = resolveServerBackedAppStageLabel({ primaryServerVersion: input.primaryServerVersion, fallbackStageLabel: input.fallbackStageLabel, }); return stageLabel === input.fallbackStageLabel ? input.fallbackDisplayName : formatAppDisplayName({ baseName: input.baseName, stageLabel }); }