1import { TransformPipeline } from '.'; 2 3export function podspecTransforms(versionName: string): TransformPipeline { 4 return { 5 transforms: [ 6 // Common transforms 7 { 8 // Transforms some podspec fields by adding versionName at the beginning 9 replace: /\.(name|header_dir|module_name)(\s*=\s*["'])([^"']+)(["'])/g, 10 with: `.$1$2${versionName}$3$4`, 11 }, 12 { 13 // Prefixes dependencies listed in the podspecs 14 replace: /(\.dependency\s+["'])(Yoga|React\-|ReactCommon|RCT|FB)(?!-Folly)([^"']*["'])/g, 15 with: `$1${versionName}$2$3`, 16 }, 17 { 18 // Removes source conditional 19 replace: /source\s*\=\s*\{[.\S\s]+?end/g, 20 with: '', 21 }, 22 { 23 // Points spec source at correct directory 24 replace: /(\.source\s*\=\s*)\S+\n/g, 25 with: '$1{ :path => "." }\n', 26 }, 27 28 // React-Core & ReactCommon 29 { 30 // Fixes header_subspecs for RCTBlobHeaders 31 paths: 'React-Core.podspec', 32 replace: /\{(RCTBlobManager),(RCTFileReaderModule)\}/g, 33 with: `{${versionName}$1,${versionName}$2}`, 34 }, 35 { 36 // Prefixes conflicting AccessibilityResources 37 paths: 'React-Core.podspec', 38 replace: /"AccessibilityResources"/g, 39 with: `"${versionName}AccessibilityResources"`, 40 }, 41 { 42 // Fixes HEADER_SEARCH_PATHS 43 paths: ['React-Core.podspec', 'ReactCommon.podspec'], 44 replace: /(Headers\/Private\/)(React-Core)/g, 45 with: `$1${versionName}$2`, 46 }, 47 48 // React-cxxreact 49 { 50 // Fixes excluding SampleCxxModule.* files 51 paths: 'React-cxxreact.podspec', 52 replace: /\.exclude_files(\s*=\s*["'])(SampleCxxModule\.\*)(["'])/g, 53 with: `.exclude_files$1${versionName}$2$3`, 54 }, 55 56 // Yoga 57 { 58 // Unprefixes inner directory for source_files 59 paths: 'Yoga.podspec', 60 replace: /\{(Yoga),(YGEnums),(YGMacros),(YGNode),(YGStyle),(YGValue)\}/g, 61 with: `{${versionName}$1,${versionName}$2,${versionName}$3,${versionName}$4,${versionName}$5,${versionName}$6}`, 62 }, 63 64 // FBReactNativeSpec 65 { 66 // Fixes HEADER_SEARCH_PATHS 67 paths: 'FBReactNativeSpec.podspec', 68 replace: /(\/Libraries\/)(FBReactNativeSpec)/g, 69 with: `$1${versionName}$2`, 70 }, 71 { 72 // Disable codegen from build phase script 73 paths: 'FBReactNativeSpec.podspec', 74 replace: /(use_react_native_codegen!)/g, 75 with: '# $1', 76 }, 77 ], 78 }; 79} 80