Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Adds "cocoapods-installer" option
Browse files Browse the repository at this point in the history
Summary:
Adds "cocoapods-installer" option to "setup-dev" command to decide who CocoaPods will be installed on the macOS host system.

The options are "gem" and "homebrew".

## Gem

```
npx torchlive-cli setup-dev --cocoapods-installer=gem
```

## Homebrew

```
npx torchlive-cli setup-dev --cocoapods-installer=homebrew
```

Note: the option will be used for the GitHub Action CI that tests the setup-dev command

## Test

Tested in forked repo: https://github.com/raedle/live/runs/4576829417

Reviewed By: liuyinglao

Differential Revision: D33229271

fbshipit-source-id: 2019748854c25c2f5a71db334040e116e56ef9a0
  • Loading branch information
raedle committed Dec 20, 2021
1 parent 1f2e685 commit be1ba16
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
5 changes: 5 additions & 0 deletions torchlive-cli/src/cli-commands/SetUpDev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {runTasks} from '../utils/TaskUtils';

type SetupDevOptions = {
yes: boolean;
cocoapodsInstaller: string | undefined;
};

const setUpDev = async (options: SetupDevOptions): Promise<void> => {
Expand All @@ -47,5 +48,9 @@ export function makeSetUpDevCommand() {
return new Command('setup-dev')
.description('set up development dependencies')
.option('-y, --yes', 'Accept all questions')
.option(
'--cocoapods-installer [installer]',
'CocoaPods Package Installer (gem or homebrew)',
)
.action(setUpDev);
}
37 changes: 26 additions & 11 deletions torchlive-cli/src/installers/ios/CocoaPodsInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,36 @@ export default class CocoaPodsInstaller implements ICommandInstallerTask {
}

async run(context: TaskContext): Promise<void> {
const source = await context.task.prompt<string>([
{
type: 'Select',
name: 'source',
message:
"CocoaPods (https://cocoapods.org/) is not installed. It's necessary for iOS project to run correctly. Do you want to install it?",
choices: ['Yes, with gem (may require sudo)', 'Yes,‎ with‎ Homebrew'],
},
]);
let {cocoapodsInstaller} = context.ctx;
if (cocoapodsInstaller == null) {
cocoapodsInstaller = await context.task.prompt<string>([
{
type: 'Select',
name: 'source',
message:
"CocoaPods (https://cocoapods.org/) is not installed. It's necessary for iOS project to run correctly. Do you want to install it?",
choices: [
{
name: 'gem',
message: 'Yes, with gem (may require sudo)',
},
{
name: 'homebrew',
message: 'Yes,‎ with‎ Homebrew',
},
],
},
]);
}

if (source === 'Yes, with gem (may require sudo)') {
if (cocoapodsInstaller === 'gem') {
return await this.installWithGem(context);
} else {
} else if (cocoapodsInstaller === 'homebrew') {
return await this.installWithHomebrew(context);
}
throw new Error(
`${cocoapodsInstaller} is not a valid option to install CocoaPods`,
);
}

private async installWithGem(context: TaskContext): Promise<void> {
Expand Down

0 comments on commit be1ba16

Please sign in to comment.