eas-cli
Version:
EAS command line tool
88 lines (87 loc) • 3.72 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CredentialsContext = void 0;
const tslib_1 = require("tslib");
const chalk_1 = tslib_1.__importDefault(require("chalk"));
const AndroidGraphqlClient = tslib_1.__importStar(require("./android/api/GraphqlClient"));
const IosGraphqlClient = tslib_1.__importStar(require("./ios/api/GraphqlClient"));
const AppStoreApi_1 = tslib_1.__importDefault(require("./ios/appstore/AppStoreApi"));
const authenticateTypes_1 = require("./ios/appstore/authenticateTypes");
const log_1 = tslib_1.__importDefault(require("../log"));
const expoConfig_1 = require("../project/expoConfig");
const prompts_1 = require("../prompts");
class CredentialsContext {
options;
android = AndroidGraphqlClient;
appStore = new AppStoreApi_1.default();
ios = IosGraphqlClient;
nonInteractive;
freezeCredentials = false;
projectDir;
user;
graphqlClient;
analytics;
vcsClient;
easJsonCliConfig;
usesBroadcastPushNotifications;
shouldAskAuthenticateAppStore = true;
projectInfo;
constructor(options) {
this.options = options;
this.easJsonCliConfig = options.easJsonCliConfig;
this.projectDir = options.projectDir;
this.user = options.user;
this.graphqlClient = options.graphqlClient;
this.analytics = options.analytics;
this.vcsClient = options.vcsClient;
this.nonInteractive = options.nonInteractive ?? false;
this.projectInfo = options.projectInfo;
this.freezeCredentials = options.freezeCredentials ?? false;
this.usesBroadcastPushNotifications =
options.projectInfo?.exp.ios?.usesBroadcastPushNotifications ?? false;
}
get hasProjectContext() {
return !!this.projectInfo;
}
async getExpoConfigAsync() {
await this.ensureProjectContextAsync();
return this.projectInfo.exp;
}
async getProjectIdAsync() {
await this.ensureProjectContextAsync();
return this.projectInfo.projectId;
}
async ensureProjectContextAsync() {
if (this.hasProjectContext) {
return;
}
// trigger getConfig error
await (0, expoConfig_1.getPrivateExpoConfigAsync)(this.options.projectDir);
}
async bestEffortAppStoreAuthenticateAsync() {
if (!!this.appStore.authCtx || !this.shouldAskAuthenticateAppStore) {
// skip prompts if already have apple ctx or already asked about it
return;
}
if (this.nonInteractive) {
return;
}
if (this.appStore.defaultAuthenticationMode === authenticateTypes_1.AuthenticationMode.API_KEY) {
await this.appStore.ensureAuthenticatedAsync();
return;
}
log_1.default.log(chalk_1.default.green('If you provide your Apple account credentials we will be able to generate all necessary build credentials and fully validate them.'));
log_1.default.log(chalk_1.default.green('This is optional, but without Apple account access you will need to provide all the missing values manually and we can only run minimal validation on them.'));
const confirm = await (0, prompts_1.confirmAsync)({
message: `Do you want to log in to your Apple account?`,
});
if (confirm) {
await this.appStore.ensureAuthenticatedAsync();
}
else {
log_1.default.log(chalk_1.default.green('No problem! 👌 If any of the next steps will require Apple account access we will ask you again about it.'));
}
this.shouldAskAuthenticateAppStore = false;
}
}
exports.CredentialsContext = CredentialsContext;