(
text: string,
options: NormalizeSnapshotOutputOptions = {},
)
| 197 | }; |
| 198 | |
| 199 | export function normalizeSnapshotOutput( |
| 200 | text: string, |
| 201 | options: NormalizeSnapshotOutputOptions = {}, |
| 202 | ): string { |
| 203 | let normalized = text; |
| 204 | |
| 205 | normalized = normalized.replace(ANSI_REGEX, ''); |
| 206 | |
| 207 | const projectRoot = path.resolve(process.cwd()); |
| 208 | normalized = normalized.replace(new RegExp(escapeRegex(projectRoot), 'g'), '<ROOT>'); |
| 209 | |
| 210 | const home = os.homedir(); |
| 211 | normalized = normalized.replace(new RegExp(escapeRegex(home), 'g'), '<HOME>'); |
| 212 | |
| 213 | const username = os.userInfo().username; |
| 214 | normalized = normalized.replace( |
| 215 | new RegExp( |
| 216 | `((?:ALTERNATE_OWNER|INSTALL_OWNER|USER|VERSION_INFO_BUILDER)\\s*=\\s*)${escapeRegex(username)}`, |
| 217 | 'g', |
| 218 | ), |
| 219 | '$1<USER>', |
| 220 | ); |
| 221 | normalized = normalized.replace(new RegExp(`(UID\\s*=\\s*)${os.userInfo().uid}`, 'g'), '$1<UID>'); |
| 222 | |
| 223 | const tmpDir = options.tmpDir ?? os.tmpdir(); |
| 224 | normalized = normalized.replace( |
| 225 | new RegExp(escapeRegex(tmpDir) + '/[A-Za-z0-9._-]+(?=/|[^A-Za-z0-9._/-]|$)', 'g'), |
| 226 | '<TMPDIR>', |
| 227 | ); |
| 228 | normalized = normalized.replace(XCODEBUILDMCP_HOME_PREFIX_REGEX, '~'); |
| 229 | normalized = normalized.replace(XCODEBUILDMCP_WORKSPACE_KEY_REGEX, '$1-<HASH>'); |
| 230 | normalized = normalized.replace(XCODE_IDE_ARTIFACT_OWNER_PID_REGEX, '$1<PID>_'); |
| 231 | normalized = normalized.replace(XCODE_IDE_ARTIFACT_HASH_REGEX, '$1<HASH>'); |
| 232 | normalized = normalized.replace( |
| 233 | /(Build Logs: )(?:<TMPDIR>|~\/Library\/Developer\/XcodeBuildMCP)\/logs\//g, |
| 234 | '$1~/Library/Developer/XcodeBuildMCP/logs/', |
| 235 | ); |
| 236 | normalized = normalized.replace( |
| 237 | /Raw Response JSON: .+\/xcode-ide\/call-tool\/.+\/[A-Za-z0-9._-]+\.json/g, |
| 238 | 'Raw Response JSON: <RAW_RESPONSE_JSON_PATH>', |
| 239 | ); |
| 240 | normalized = normalized.replace( |
| 241 | /Found \d+ tool\(s\)(?=\. Raw response saved to artifact\.|$)/g, |
| 242 | 'Found <XCODE_IDE_TOOL_COUNT> tool(s)', |
| 243 | ); |
| 244 | |
| 245 | normalized = normalized.replace(DERIVED_DATA_HASH_REGEX, '$1-<HASH>'); |
| 246 | normalized = normalized.replace(ISO_TIMESTAMP_REGEX, '<TIMESTAMP>'); |
| 247 | normalized = normalized.replace(LOG_FILENAME_TIMESTAMP_REGEX, '<TIMESTAMP>'); |
| 248 | normalized = normalized.replace(APPLE_DEVICE_UDID_REGEX, '<UUID>'); |
| 249 | normalized = normalized.replace(UUID_REGEX, '<UUID>'); |
| 250 | normalized = normalized.replace(DEVICE_LABEL_REGEX, 'Device: <DEVICE> (<UUID>)'); |
| 251 | normalized = normalized.replace(DEVICE_TRANSPORT_TYPE_REGEX, '<CONNECTION>'); |
| 252 | normalized = normalized.replace(COREDEVICE_PROVISIONING_PREAMBLE_REGEX, '$1'); |
| 253 | normalized = normalized.replace(COREDEVICE_NOT_FOUND_ERROR_PREFIX_REGEX, '$1'); |
| 254 | normalized = normalized.replace(DURATION_REGEX, '<DURATION>'); |
| 255 | normalized = normalized.replace(PID_NUMBER_REGEX, '$1<PID>'); |
| 256 | normalized = normalized.replace(PID_NAME_REGEX, 'PID <PID>'); |
no test coverage detected