1import { FileTransforms, StringTransform } from '../../../Transforms.types';
2
3export function vendoredModulesTransforms(prefix: string): Record<string, FileTransforms> {
4  return {
5    '@shopify/react-native-skia': {
6      content: [
7        {
8          paths: 'build.gradle',
9          find: `def nodeModules = Paths.get(projectDir.getPath(), '../../../../../..', 'react-native-lab').toString()`,
10          replaceWith: `def nodeModules = Paths.get(projectDir.getPath(), '../../../../..').toString()`,
11        },
12        {
13          paths: 'build.gradle',
14          find: 'sourceBuild = true',
15          replaceWith: 'sourceBuild = false',
16        },
17        {
18          paths: 'build.gradle',
19          // The `android/versioned-react-native/ReactAndroid/gradle.properties` is not committed to git,
20          // we use the `ReactAndroid/gradle.properties` for versioned skia instead.
21          // Even though it not always correct, e.g. when ReactAndroid upgrades to newer version, the versions are inconsistent.
22          // Since skia current only uses the `REACT_NATIVE_VERSION` property,
23          // after we prebuild the lib and cleanup CMakeLists.txt, these properties are actually not be used.
24          find: '$nodeModules/versioned-react-native/ReactAndroid/gradle.properties',
25          replaceWith: '$defaultDir/gradle.properties',
26        },
27        {
28          paths: 'ExponentPackage.kt',
29          find: 'import com.shopify',
30          replaceWith: `import ${prefix}.com.shopify`,
31        },
32      ],
33    },
34  };
35}
36
37export function exponentPackageTransforms(prefix: string): Record<string, StringTransform[]> {
38  return {
39    '@shopify/react-native-skia': [
40      {
41        find: /\bimport (com.shopify.reactnative.skia.RNSkiaPackage)/g,
42        replaceWith: `import ${prefix}.$1`,
43      },
44    ],
45    '@shopify/flash-list': [
46      {
47        find: /\bimport (com.shopify.reactnative.flash_list.ReactNativeFlashListPackage)/g,
48        replaceWith: `import ${prefix}.$1`,
49      },
50    ],
51  };
52}
53