Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
replace doctor call with getConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
wkozyra95 committed Sep 15, 2020
1 parent d4f6d73 commit 2e59040
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 40 deletions.
55 changes: 20 additions & 35 deletions packages/expo-cli/src/commands/credentials.ts
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);
);
}
10 changes: 5 additions & 5 deletions packages/expo-cli/src/credentials/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

0 comments on commit 2e59040

Please sign in to comment.