From 9f0cab112a7365fc0f7513f22a4820a30a329701 Mon Sep 17 00:00:00 2001 From: Wojciech Kozyra Date: Tue, 15 Sep 2020 11:23:38 +0200 Subject: [PATCH] replace doctor call with getConfig --- packages/expo-cli/src/commands/credentials.ts | 55 +++++++------------ packages/expo-cli/src/credentials/context.ts | 10 ++-- 2 files changed, 25 insertions(+), 40 deletions(-) diff --git a/packages/expo-cli/src/commands/credentials.ts b/packages/expo-cli/src/commands/credentials.ts index 4834c723df..118f094844 100644 --- a/packages/expo-cli/src/commands/credentials.ts +++ b/packages/expo-cli/src/commands/credentials.ts @@ -1,7 +1,4 @@ -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 { @@ -9,11 +6,9 @@ import { SelectIosExperience, SelectPlatform, } from '../credentials/views/Select'; -import log from '../log'; type Options = { platform?: 'android' | 'ios'; - config?: string; parent?: { nonInteractive: boolean; }; @@ -21,39 +16,29 @@ type Options = { export default function (program: CommanderStatic) { program - .command('credentials:manager') + .command('credentials:manager [path]') .description('Manage your credentials') .helpGroup('credentials') .option('-p --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(``)}`) - ); - } - 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); + ); } diff --git a/packages/expo-cli/src/credentials/context.ts b/packages/expo-cli/src/credentials/context.ts index 6c9473abc6..c41304e227 100644 --- a/packages/expo-cli/src/credentials/context.ts +++ b/packages/expo-cli/src/credentials/context.ts @@ -105,15 +105,15 @@ export class Context { this._appleCtxOptions = pick(options, ['appleId', 'appleIdPassword', 'teamId']); this._nonInteractive = options.nonInteractive; - // Check if we are in project context by looking for a manifest - const status = await Doctor.validateWithoutNetworkAsync(projectDir, { - skipSDKVersionRequirement: true, - }); - if (status !== Doctor.FATAL) { + // try to acccess project context + try { const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true }); this._manifest = exp; this._hasProjectContext = true; this.logOwnerAndProject(); + } catch (error) { + // ignore error + // startcredentials manager without project context } } }