This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
25 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,44 @@ | ||
import * as ConfigUtils from '@expo/config'; | ||
import { CommanderStatic } from 'commander'; | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
|
||
import { Context, runCredentialsManagerStandalone } from '../credentials'; | ||
import { | ||
SelectAndroidExperience, | ||
SelectIosExperience, | ||
SelectPlatform, | ||
} from '../credentials/views/Select'; | ||
import log from '../log'; | ||
|
||
type Options = { | ||
platform?: 'android' | 'ios'; | ||
config?: string; | ||
parent?: { | ||
nonInteractive: boolean; | ||
}; | ||
}; | ||
|
||
export default function (program: CommanderStatic) { | ||
program | ||
.command('credentials:manager') | ||
.command('credentials:manager [path]') | ||
.description('Manage your credentials') | ||
.helpGroup('credentials') | ||
.option('-p --platform <platform>', 'Platform: [android|ios]', /^(android|ios)$/i) | ||
.option('--config [file]', 'Specify a path to app.json or app.config.js') | ||
.asyncAction(async (options: Options) => { | ||
const projectDir = process.cwd(); | ||
// @ts-ignore: This guards against someone passing --config without a path. | ||
if (options.config === true) { | ||
log('Please specify your custom config path:'); | ||
log( | ||
log.chalk.green(` expo credentials:manager --config ${log.chalk.cyan(`<app-config>`)}`) | ||
); | ||
} | ||
if (options.config) { | ||
const configPath = path.resolve(projectDir, options.config); | ||
if (!(await fs.pathExists(configPath))) { | ||
throw new Error(`File ${configPath} does not exist`); | ||
.asyncActionProjectDir( | ||
async (projectDir: string, options: Options) => { | ||
const context = new Context(); | ||
await context.init(projectDir, { | ||
nonInteractive: options.parent?.nonInteractive, | ||
}); | ||
let mainpage; | ||
if (options.platform === 'android') { | ||
mainpage = new SelectAndroidExperience(); | ||
} else if (options.platform === 'ios') { | ||
mainpage = new SelectIosExperience(); | ||
} else { | ||
mainpage = new SelectPlatform(); | ||
} | ||
ConfigUtils.setCustomConfigPath(projectDir, configPath); | ||
} | ||
const context = new Context(); | ||
await context.init(projectDir, { | ||
nonInteractive: options.parent?.nonInteractive, | ||
}); | ||
let mainpage; | ||
if (options.platform === 'android') { | ||
mainpage = new SelectAndroidExperience(); | ||
} else if (options.platform === 'ios') { | ||
mainpage = new SelectIosExperience(); | ||
} else { | ||
mainpage = new SelectPlatform(); | ||
await runCredentialsManagerStandalone(context, mainpage); | ||
}, | ||
{ | ||
checkConfig: false, | ||
skipSDKVersionRequirement: true, | ||
} | ||
await runCredentialsManagerStandalone(context, mainpage); | ||
}, /* skip project validation */ true); | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters