xref: /expo/tools/src/vendoring/types.ts (revision f179ccd5)
1import { Podspec } from '../CocoaPods';
2import { FileTransforms } from '../Transforms.types';
3
4export type VendoringModulePlatformConfig<T = object> = T & {
5  transforms?: FileTransforms;
6};
7
8export type VendoringModuleConfig = {
9  source: string;
10  semverPrefix?: string;
11  packageJsonPath?: string;
12
13  // Specify root directory for copying files. This is useful for workspace that the module is in a subfolder.
14  rootDir?: string;
15
16  sourceType?: 'git' | 'npm';
17
18  ios?: VendoringModulePlatformConfig<{
19    excludeFiles?: string | string[];
20
21    // this hook can do some transformation before running `pod ipc spec ...`.
22    // use this hook as a workaround for some podspecs showing errors and violating json format.
23    preReadPodspecHookAsync?: (podspecPath: string) => Promise<string>;
24
25    mutatePodspec?: (
26      podspec: Podspec,
27      sourceDirectory: string,
28      targetDirectory: string
29    ) => Promise<void>;
30  }>;
31  android?: VendoringModulePlatformConfig<{
32    includeFiles?: string | string[];
33    excludeFiles?: string | string[];
34
35    // using this hook to do some customization after copying vendoring files
36    postCopyFilesHookAsync?: (sourceDirectory: string, targetDirectory: string) => Promise<void>;
37  }>;
38};
39
40export type VendoringTargetModulesConfig = {
41  [key: string]: VendoringModuleConfig;
42};
43
44export type VendoringTargetPlatformConfig = {
45  targetDirectory: string;
46};
47
48export type VendoringTargetConfig = {
49  name: string;
50  platforms: {
51    ios?: VendoringTargetPlatformConfig;
52    android?: VendoringTargetPlatformConfig;
53  };
54  modules: VendoringTargetModulesConfig;
55};
56
57export type VendoringConfig = {
58  [key: string]: VendoringTargetConfig;
59};
60
61export type VendoringProvider<T = object> = {
62  vendorAsync: (
63    sourceDirectory: string,
64    targetDirectory: string,
65    platformConfig?: VendoringModulePlatformConfig<T>
66  ) => Promise<void>;
67};
68