diff --git a/docs/commands.md b/docs/commands.md index bef3d4e1cd..eab8776ab2 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -96,6 +96,10 @@ module.exports = { Skip dependencies installation +#### `--install-pods [boolean]` + +Determine if CocoaPods should be installed when initializing a project. If set to `true` it will install pods, if set to `false`, it will skip the step entirely. If not used, prompt will be displayed + #### `--npm` > [!WARNING] > `--npm` is deprecated and will be removed in the future. Please use `--pm npm` instead. diff --git a/packages/cli/src/commands/init/index.ts b/packages/cli/src/commands/init/index.ts index 6d969e3a55..6763f4cc49 100644 --- a/packages/cli/src/commands/init/index.ts +++ b/packages/cli/src/commands/init/index.ts @@ -37,6 +37,11 @@ export default { name: '--skip-install', description: 'Skips dependencies installation step', }, + { + name: '--install-pods [boolean]', + description: + 'Determine if CocoaPods should be installed when initializing a project', + }, { name: '--package-name ', description: diff --git a/packages/cli/src/commands/init/init.ts b/packages/cli/src/commands/init/init.ts index 8063170c88..0bee33cdf9 100644 --- a/packages/cli/src/commands/init/init.ts +++ b/packages/cli/src/commands/init/init.ts @@ -39,6 +39,7 @@ type Options = { skipInstall?: boolean; version?: string; packageName?: string; + installPods?: boolean; }; interface TemplateOptions { @@ -50,6 +51,7 @@ interface TemplateOptions { projectTitle?: string; skipInstall?: boolean; packageName?: string; + installCocoaPods?: string; } function doesDirectoryExist(dir: string) { @@ -94,6 +96,7 @@ async function createFromTemplate({ projectTitle, skipInstall, packageName, + installCocoaPods, }: TemplateOptions) { logger.debug('Initializing new project'); logger.log(banner); @@ -173,16 +176,24 @@ async function createFromTemplate({ }); if (process.platform === 'darwin') { - const {installCocoapods} = await prompt({ - type: 'confirm', - name: 'installCocoapods', - message: `Do you want to install CocoaPods? ${chalk.reset.dim( - 'Only needed if you run your project in Xcode directly', - )}`, - }); - - if (installCocoapods) { + const installPodsValue = String(installCocoaPods); + + if (installPodsValue === 'true') { await installPods(loader); + loader.succeed(); + } else if (installPodsValue === 'undefined') { + const {installCocoapods} = await prompt({ + type: 'confirm', + name: 'installCocoapods', + message: `Do you want to install CocoaPods? ${chalk.reset.dim( + 'Only needed if you run your project in Xcode directly', + )}`, + }); + + if (installCocoapods) { + await installPods(loader); + loader.succeed(); + } } } } else { @@ -261,6 +272,7 @@ async function createProject( projectTitle: options.title, skipInstall: options.skipInstall, packageName: options.packageName, + installCocoaPods: options.installPods, }); }