Skip to content

Commit

Permalink
Remove traveling-fastlane (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
fson authored Nov 26, 2020
1 parent a139571 commit 932f641
Show file tree
Hide file tree
Showing 17 changed files with 126 additions and 744 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
asset_content_type: application/gzip
build-mac:
name: Build for macOS
# Use macOS to get the platform specific dependencies like traveling-fastlane-darwin
# Use macOS to get the correct platform specific dependencies
runs-on: macos-latest
needs: release
steps:
Expand Down
4 changes: 0 additions & 4 deletions packages/eas-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@
"typescript": "^3.9.7",
"wonka": "^4.0.14"
},
"optionalDependencies": {
"@expo/traveling-fastlane-darwin": "1.15.3",
"@expo/traveling-fastlane-linux": "1.15.3"
},
"engines": {
"node": ">=8.0.0"
},
Expand Down
6 changes: 0 additions & 6 deletions packages/eas-cli/src/credentials/ios/appstore/AppStoreApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import {
PushKeyStoreInfo,
} from './Credentials.types';
import { AuthCtx, authenticateAsync } from './authenticate';
import { checkWSLAsync } from './checkWSL';
import {
AppleTooManyCertsError,
createDistributionCertificateAsync,
listDistributionCertificatesAsync,
revokeDistributionCertificateAsync,
} from './distributionCertificate';
import { AppLookupParams, EnsureAppExistsOptions, ensureAppExistsAsync } from './ensureAppExists';
import { USE_APPLE_UTILS } from './experimental';
import {
ProfileClass,
createProvisioningProfileAsync,
Expand Down Expand Up @@ -45,10 +43,6 @@ class AppStoreApi {

public async ensureAuthenticatedAsync(): Promise<AuthCtx> {
if (!this._authCtx) {
if (!USE_APPLE_UTILS) {
// Only check Fastlane compat when using Fastlane (default).
await checkWSLAsync();
}
this._authCtx = await authenticateAsync(this.options);
}
return this._authCtx;
Expand Down
70 changes: 1 addition & 69 deletions packages/eas-cli/src/credentials/ios/appstore/authenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import wordwrap from 'wordwrap';
import log from '../../../log';
import { promptAsync, toggleConfirmAsync } from '../../../prompts';
import UserSettings from '../../../user/UserSettings';
import { USE_APPLE_UTILS } from './experimental';
import { runActionAsync, travelingFastlane } from './fastlane';
import * as Keychain from './keychain';

const APPLE_IN_HOUSE_TEAM_TYPE = 'in-house';
Expand Down Expand Up @@ -65,7 +63,7 @@ export function getRequestContext(authCtx: AuthCtx): RequestContext {
return authCtx.authState.context;
}

async function authenticateWithExperimentalAsync(options: Options = {}): Promise<AuthCtx> {
export async function authenticateAsync(options: Options = {}): Promise<AuthCtx> {
const { appleId, appleIdPassword } = await requestAppleCredentialsAsync(options);
log(`Authenticating to Apple Developer Portal...`); // use log instead of spinner in case we need to prompt user for 2fa

Expand Down Expand Up @@ -114,36 +112,6 @@ async function authenticateWithExperimentalAsync(options: Options = {}): Promise
}
}

export async function authenticateAsync(options: Options = {}): Promise<AuthCtx> {
if (USE_APPLE_UTILS) {
return await authenticateWithExperimentalAsync(options);
}
const { appleId, appleIdPassword } = await requestAppleCredentialsAsync(options);
log(`Authenticating to Apple Developer Portal...`); // use log instead of spinner in case we need to prompt user for 2fa
try {
const { teams, fastlaneSession } = await runActionAsync(
travelingFastlane.authenticate,
[appleId, appleIdPassword],
{
pipeStdout: true,
}
);
log(chalk.green('Authenticated with Apple Developer Portal successfully!'));
const team = await chooseTeamAsync(teams, options.teamId);
return { appleId, appleIdPassword, team, fastlaneSession };
} catch (err) {
if (err.rawDump?.match(/Invalid username and password combination/)) {
log(chalk.red('Invalid username and password combination, try again.'));
const anotherPromptResult = await promptForAppleCredentialsAsync({
firstAttempt: false,
});
return authenticateAsync({ ...options, ...anotherPromptResult });
}
log(chalk.red('Authentication with Apple Developer Portal failed!'));
throw err;
}
}

export async function requestAppleCredentialsAsync(options: Options): Promise<AppleCredentials> {
return getAppleCredentialsFromParams(options) ?? (await promptForAppleCredentialsAsync());
}
Expand Down Expand Up @@ -238,42 +206,6 @@ async function promptForAppleCredentialsAsync({
return { appleId: promptAppleId, appleIdPassword };
}

async function chooseTeamAsync(teams: FastlaneTeam[], userProvidedTeamId?: string): Promise<Team> {
if (teams.length === 0) {
throw new Error(`You have no team associated with your Apple account, cannot proceed.
(Do you have a paid Apple Developer account?)`);
}

if (userProvidedTeamId) {
const foundTeam = teams.find(({ teamId }) => teamId === userProvidedTeamId);
if (foundTeam) {
log(`Using Apple Team with ID: ${userProvidedTeamId}`);
return formatTeam(foundTeam);
} else {
log.warn(`Your account is not associated with Apple Team with ID: ${userProvidedTeamId}`);
}
}

if (teams.length === 1) {
const [team] = teams;
log(`Only 1 team associated with your account, using Apple Team with ID: ${team.teamId}`);
return formatTeam(team);
} else {
log(`You have ${teams.length} teams associated with your account`);
const choices = teams.map((team, i) => ({
title: `${i + 1}) ${team.teamId} "${team.name}" (${team.type})`,
value: team,
}));
const { team } = await promptAsync({
type: 'select',
name: 'team',
message: 'Which team would you like to use?',
choices,
});
return formatTeam(team);
}
}

function formatTeam({ teamId, name, type }: FastlaneTeam): Team {
return {
id: teamId,
Expand Down
35 changes: 0 additions & 35 deletions packages/eas-cli/src/credentials/ios/appstore/checkWSL.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import ora from 'ora';

import { DistributionCertificate, DistributionCertificateStoreInfo } from './Credentials.types';
import { AuthCtx, getRequestContext } from './authenticate';
import { USE_APPLE_UTILS } from './experimental';
import { runActionAsync, travelingFastlane } from './fastlane';

export class AppleTooManyCertsError extends Error {}

Expand Down Expand Up @@ -82,33 +80,20 @@ export async function listDistributionCertificatesAsync(
): Promise<DistributionCertificateStoreInfo[]> {
const spinner = ora(`Getting Distribution Certificates from Apple...`).start();
try {
if (USE_APPLE_UTILS) {
const context = getRequestContext(authCtx);
const certs = (
await Certificate.getAsync(context, {
query: {
filter: {
certificateType: [
CertificateType.DISTRIBUTION,
CertificateType.IOS_DISTRIBUTION,
CertificateType.MAC_APP_DISTRIBUTION,
],
},
const context = getRequestContext(authCtx);
const certs = (
await Certificate.getAsync(context, {
query: {
filter: {
certificateType: [
CertificateType.DISTRIBUTION,
CertificateType.IOS_DISTRIBUTION,
CertificateType.MAC_APP_DISTRIBUTION,
],
},
})
).map(transformCertificate);
spinner.succeed();
return certs;
}

const args = [
'list',
authCtx.appleId,
authCtx.appleIdPassword,
authCtx.team.id,
String(authCtx.team.inHouse),
];
const { certs } = await runActionAsync(travelingFastlane.manageDistCerts, args);
},
})
).map(transformCertificate);
spinner.succeed();
return certs;
} catch (error) {
Expand All @@ -124,59 +109,32 @@ export async function createDistributionCertificateAsync(
authCtx: AuthCtx
): Promise<DistributionCertificate> {
const spinner = ora(`Creating Distribution Certificate on Apple Servers...`).start();
if (USE_APPLE_UTILS) {
try {
const context = getRequestContext(authCtx);
const results = await createCertificateAndP12Async(context, {
certificateType: CertificateType.IOS_DISTRIBUTION,
});
spinner.succeed();
return {
certId: results.certificate.id,
certP12: results.certificateP12,
certPassword: results.password,
certPrivateSigningKey: results.privateSigningKey,
distCertSerialNumber: results.certificate.attributes.serialNumber,
teamId: authCtx.team.id,
teamName: authCtx.team.name,
};
} catch (error) {
spinner.fail('Failed to create Distribution Certificate on Apple Servers');
// TODO: Move check into apple-utils
const resultString = error.message;
if (
resultString?.match(
/You already have a current .* certificate or a pending certificate request./
)
) {
throw new AppleTooManyCertsError('Maximum number of certificates generated');
}
throw error;
}
}

try {
const args = [
'create',
authCtx.appleId,
authCtx.appleIdPassword,
authCtx.team.id,
String(authCtx.team.inHouse),
];
const result = {
...(await runActionAsync(travelingFastlane.manageDistCerts, args)),
const context = getRequestContext(authCtx);
const results = await createCertificateAndP12Async(context, {
certificateType: CertificateType.IOS_DISTRIBUTION,
});
spinner.succeed();
return {
certId: results.certificate.id,
certP12: results.certificateP12,
certPassword: results.password,
certPrivateSigningKey: results.privateSigningKey,
distCertSerialNumber: results.certificate.attributes.serialNumber,
teamId: authCtx.team.id,
teamName: authCtx.team.name,
};
spinner.succeed();
return result;
} catch (err) {
} catch (error) {
spinner.fail('Failed to create Distribution Certificate on Apple Servers');
const resultString = err.rawDump?.resultString;
if (resultString && resultString.match(/Maximum number of certificates generated/)) {
// TODO: Move check into apple-utils
if (
/You already have a current .* certificate or a pending certificate request/.test(
error.message
)
) {
throw new AppleTooManyCertsError('Maximum number of certificates generated');
}
throw err;
throw error;
}
}

Expand All @@ -186,20 +144,8 @@ export async function revokeDistributionCertificateAsync(
): Promise<void> {
const spinner = ora(`Revoking Distribution Certificate on Apple Servers...`).start();
try {
if (USE_APPLE_UTILS) {
const context = getRequestContext(authCtx);
await Promise.all(ids.map(id => Certificate.deleteAsync(context, { id })));
} else {
const args = [
'revoke',
authCtx.appleId,
authCtx.appleIdPassword,
authCtx.team.id,
String(authCtx.team.inHouse),
ids.join(','),
];
await runActionAsync(travelingFastlane.manageDistCerts, args);
}
const context = getRequestContext(authCtx);
await Promise.all(ids.map(id => Certificate.deleteAsync(context, { id })));

spinner.succeed();
} catch (error) {
Expand Down
36 changes: 1 addition & 35 deletions packages/eas-cli/src/credentials/ios/appstore/ensureAppExists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { BundleId, CapabilityType, CapabilityTypeOption } from '@expo/apple-util
import ora from 'ora';

import { AuthCtx, getRequestContext } from './authenticate';
import { USE_APPLE_UTILS } from './experimental';
import { runActionAsync, travelingFastlane } from './fastlane';

export interface EnsureAppExistsOptions {
enablePushNotifications?: boolean;
Expand All @@ -15,7 +13,7 @@ export interface AppLookupParams {
bundleIdentifier: string;
}

async function ensureBundleIdExistsAsync(
export async function ensureAppExistsAsync(
authCtx: AuthCtx,
{ accountName, projectName, bundleIdentifier }: AppLookupParams,
options: EnsureAppExistsOptions = {}
Expand Down Expand Up @@ -60,35 +58,3 @@ async function ensureBundleIdExistsAsync(
throw err;
}
}

export async function ensureAppExistsAsync(
authCtx: AuthCtx,
app: AppLookupParams,
options: EnsureAppExistsOptions = {}
) {
if (USE_APPLE_UTILS) {
return await ensureBundleIdExistsAsync(authCtx, app, options);
}

const spinner = ora(`Ensuring App ID exists on Apple Developer Portal...`).start();
try {
const { created } = await runActionAsync(travelingFastlane.ensureAppExists, [
...(options.enablePushNotifications ? ['--push-notifications'] : []),
authCtx.appleId,
authCtx.appleIdPassword,
authCtx.team.id,
app.bundleIdentifier,
`@${app.accountName}/${app.projectName}`,
]);
if (created) {
spinner.succeed(`App ID created with bundle identifier ${app.bundleIdentifier}.`);
} else {
spinner.succeed('App ID found on Apple Developer Portal.');
}
} catch (err) {
spinner.fail(
'Something went wrong when trying to ensure App ID exists on Apple Developer Portal!'
);
throw err;
}
}
Loading

0 comments on commit 932f641

Please sign in to comment.