feat(react-native): run pod commands with bundler (#19727)

Signed-off-by: Stefano Formicola <stefano.formicola@cloudacademy.com>
Co-authored-by: Stefano Formicola <stefano.formicola@cloudacademy.com>
This commit is contained in:
Stefano Formicola 2023-10-24 18:57:16 +02:00 committed by GitHub
parent 2c850cfd27
commit 1f903ed924
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 9 deletions

View File

@ -25,6 +25,11 @@
"description": "Disallow any changes to the Podfile or the Podfile.lock during installation.",
"type": "boolean",
"default": false
},
"useBundler": {
"description": "Run cocoapods within a Bundler environment, i.e. with the `bundle exec pod install` command",
"type": "boolean",
"default": false
}
},
"required": ["buildFolder"],

View File

@ -2,4 +2,5 @@ export interface ReactNativePodInstallOptions {
buildFolder: string; // default is './build'
repoUpdate: boolean; // default is false
deployment: boolean; // default is false
useBundler: boolean; // default is false
}

View File

@ -22,6 +22,11 @@
"description": "Disallow any changes to the Podfile or the Podfile.lock during installation.",
"type": "boolean",
"default": false
},
"useBundler": {
"description": "Run cocoapods within a Bundler environment, i.e. with the `bundle exec pod install` command",
"type": "boolean",
"default": false
}
},
"required": ["buildFolder"]

View File

@ -28,10 +28,12 @@ export function runPodInstall(
buildFolder?: string;
repoUpdate?: boolean;
deployment?: boolean;
useBundler?: boolean;
} = {
buildFolder: './build',
repoUpdate: false,
deployment: false,
useBundler: false,
}
): GeneratorCallback {
return () => {
@ -57,10 +59,12 @@ export function podInstall(
buildFolder?: string;
repoUpdate?: boolean;
deployment?: boolean;
useBundler?: boolean;
} = {
buildFolder: './build',
repoUpdate: false,
deployment: false,
useBundler: false,
}
) {
try {
@ -70,15 +74,15 @@ export function podInstall(
stdio: 'inherit',
});
}
execSync(
`pod install ${options.repoUpdate ? '--repo-update' : ''} ${
options.deployment ? '--deployment' : ''
}`,
{
cwd: iosDirectory,
stdio: 'inherit',
}
);
const podCommand = [
options.useBundler ? 'bundle exec pod install' : 'pod install',
options.repoUpdate ? '--repo-update' : '',
options.deployment ? '--deployment' : '',
].join(' ');
execSync(podCommand, {
cwd: iosDirectory,
stdio: 'inherit',
});
} catch (e) {
logger.error(podInstallErrorMessage);
throw e;