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.", "description": "Disallow any changes to the Podfile or the Podfile.lock during installation.",
"type": "boolean", "type": "boolean",
"default": false "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"], "required": ["buildFolder"],

View File

@ -2,4 +2,5 @@ export interface ReactNativePodInstallOptions {
buildFolder: string; // default is './build' buildFolder: string; // default is './build'
repoUpdate: boolean; // default is false repoUpdate: boolean; // default is false
deployment: 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.", "description": "Disallow any changes to the Podfile or the Podfile.lock during installation.",
"type": "boolean", "type": "boolean",
"default": false "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"] "required": ["buildFolder"]

View File

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