mirror of
https://github.com/expo/eas-cli.git
synced 2026-11-15 17:31:46 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30552f134c | ||
|
|
e4beba9a21 | ||
|
|
b71ab7ec84 | ||
|
|
596cfc372b | ||
|
|
d5f6c5680c |
No files matched your search
+12
-2
@@ -8,14 +8,24 @@ This is the log of notable changes to EAS CLI and related packages.
|
||||
|
||||
### 🎉 New features
|
||||
|
||||
- Opt out of capability syncing with `EXPO_NO_CAPABILITY_SYNC=1`. ([#426](https://github.com/expo/eas-cli/pull/426) by [@brentvatne](https://github.com/brentvatne))
|
||||
- Add more verbose logging around capability syncing to help debug reported issues. ([#426](https://github.com/expo/eas-cli/pull/426) by [@brentvatne](https://github.com/brentvatne))
|
||||
- Add managed credentials support for multitarget iOS projects. ([#414](https://github.com/expo/eas-cli/pull/414) by [@dsokal](https://github.com/dsokal))
|
||||
|
||||
### 🐛 Bug fixes
|
||||
|
||||
### 🧹 Chores
|
||||
|
||||
## [0.15.1](https://github.com/expo/eas-cli/releases/tag/v0.15.1) - 2021-05-25
|
||||
|
||||
### 🎉 New features
|
||||
|
||||
- Support auto capabilities in managed workflow using Expo config plugin introspection. ([#419](https://github.com/expo/eas-cli/pull/419) by [@EvanBacon](https://github.com/EvanBacon))
|
||||
|
||||
### 🐛 Bug fixes
|
||||
|
||||
- Fix sending `appBuildVersion` as part of the build metadata. ([#423](https://github.com/expo/eas-cli/pull/423) by [@dsokal](https://github.com/dsokal))
|
||||
|
||||
### 🧹 Chores
|
||||
|
||||
## [0.15.0](https://github.com/expo/eas-cli/releases/tag/v0.15.0) - 2021-05-20
|
||||
|
||||
### 🛠 Breaking changes
|
||||
|
||||
+4
-4
@@ -3,10 +3,6 @@
|
||||
1. Run `yarn release` in the repository root folder. This will create a new tag like `v1.0.0`.
|
||||
1. **Wait until the `release` GitHub workflow has finished.**
|
||||

|
||||
1. Once the release is ready to go, you can go to https://github.com/expo/eas-cli/releases and mark it as not draft.
|
||||
- Remember to copy the changelog entries from `CHANGELOG.md`.
|
||||
- Before hitting the submit button, make sure there are 5 assets available under the release entry.
|
||||

|
||||
1. Run `yarn lerna publish from-git` in the repository root folder. This will publish the packages to npm.
|
||||
|
||||
- This command works only if `HEAD` is on the release commit, e.g. when `git log -1` prints:
|
||||
@@ -31,6 +27,10 @@
|
||||
1. Update `CHANGELOG.md`.
|
||||
- Add the new section with the release version in the title.
|
||||
- Leave the `main` section empty (without any changelog entries).
|
||||
1. Once the release is ready to go, you can go to https://github.com/expo/eas-cli/releases and mark it as not draft.
|
||||
- Remember to copy the changelog entries from `CHANGELOG.md`.
|
||||
- Before hitting the submit button, make sure there are 5 assets available under the release entry.
|
||||

|
||||
1. If any of the changelog entries have been tagged with `[EAS BUILD API]`
|
||||
- Open `package.json` and note the version of `@expo/eas-build-job` used in the eas-cli.
|
||||
- Find the `Publish` commit in [expo/eas-build](https://github.com/expo/eas-build/commit/) for that version. In most cases, it will be the latest `Publish` commit.
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"npmClient": "yarn",
|
||||
"useWorkspaces": true,
|
||||
"version": "0.15.1"
|
||||
"version": "0.16.0"
|
||||
}
|
||||
+23
-24
@@ -69,7 +69,7 @@ ALIASES
|
||||
$ eas login
|
||||
```
|
||||
|
||||
_See code: [build/commands/account/login.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/account/login.ts)_
|
||||
_See code: [build/commands/account/login.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/account/login.ts)_
|
||||
|
||||
## `eas account:logout`
|
||||
|
||||
@@ -83,7 +83,7 @@ ALIASES
|
||||
$ eas logout
|
||||
```
|
||||
|
||||
_See code: [build/commands/account/logout.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/account/logout.ts)_
|
||||
_See code: [build/commands/account/logout.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/account/logout.ts)_
|
||||
|
||||
## `eas account:view`
|
||||
|
||||
@@ -97,7 +97,7 @@ ALIASES
|
||||
$ eas whoami
|
||||
```
|
||||
|
||||
_See code: [build/commands/account/view.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/account/view.ts)_
|
||||
_See code: [build/commands/account/view.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/account/view.ts)_
|
||||
|
||||
## `eas analytics [STATUS]`
|
||||
|
||||
@@ -108,7 +108,7 @@ USAGE
|
||||
$ eas analytics [STATUS]
|
||||
```
|
||||
|
||||
_See code: [build/commands/analytics.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/analytics.ts)_
|
||||
_See code: [build/commands/analytics.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/analytics.ts)_
|
||||
|
||||
## `eas build`
|
||||
|
||||
@@ -129,7 +129,7 @@ OPTIONS
|
||||
--[no-]wait Wait for build(s) to complete
|
||||
```
|
||||
|
||||
_See code: [build/commands/build/index.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/build/index.ts)_
|
||||
_See code: [build/commands/build/index.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/build/index.ts)_
|
||||
|
||||
## `eas build:cancel [BUILD_ID]`
|
||||
|
||||
@@ -140,7 +140,7 @@ USAGE
|
||||
$ eas build:cancel [BUILD_ID]
|
||||
```
|
||||
|
||||
_See code: [build/commands/build/cancel.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/build/cancel.ts)_
|
||||
_See code: [build/commands/build/cancel.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/build/cancel.ts)_
|
||||
|
||||
## `eas build:configure`
|
||||
|
||||
@@ -155,7 +155,7 @@ OPTIONS
|
||||
--allow-experimental Enable experimental configuration steps.
|
||||
```
|
||||
|
||||
_See code: [build/commands/build/configure.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/build/configure.ts)_
|
||||
_See code: [build/commands/build/configure.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/build/configure.ts)_
|
||||
|
||||
## `eas build:list`
|
||||
|
||||
@@ -171,7 +171,7 @@ OPTIONS
|
||||
--status=(in-queue|in-progress|errored|finished|canceled)
|
||||
```
|
||||
|
||||
_See code: [build/commands/build/list.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/build/list.ts)_
|
||||
_See code: [build/commands/build/list.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/build/list.ts)_
|
||||
|
||||
## `eas build:view [BUILD_ID]`
|
||||
|
||||
@@ -182,7 +182,7 @@ USAGE
|
||||
$ eas build:view [BUILD_ID]
|
||||
```
|
||||
|
||||
_See code: [build/commands/build/view.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/build/view.ts)_
|
||||
_See code: [build/commands/build/view.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/build/view.ts)_
|
||||
|
||||
## `eas credentials`
|
||||
|
||||
@@ -193,7 +193,7 @@ USAGE
|
||||
$ eas credentials
|
||||
```
|
||||
|
||||
_See code: [build/commands/credentials.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/credentials.ts)_
|
||||
_See code: [build/commands/credentials.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/credentials.ts)_
|
||||
|
||||
## `eas device:create`
|
||||
|
||||
@@ -204,7 +204,7 @@ USAGE
|
||||
$ eas device:create
|
||||
```
|
||||
|
||||
_See code: [build/commands/device/create.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/device/create.ts)_
|
||||
_See code: [build/commands/device/create.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/device/create.ts)_
|
||||
|
||||
## `eas device:list`
|
||||
|
||||
@@ -218,7 +218,7 @@ OPTIONS
|
||||
--apple-team-id=apple-team-id
|
||||
```
|
||||
|
||||
_See code: [build/commands/device/list.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/device/list.ts)_
|
||||
_See code: [build/commands/device/list.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/device/list.ts)_
|
||||
|
||||
## `eas device:view [UDID]`
|
||||
|
||||
@@ -229,7 +229,7 @@ USAGE
|
||||
$ eas device:view [UDID]
|
||||
```
|
||||
|
||||
_See code: [build/commands/device/view.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/device/view.ts)_
|
||||
_See code: [build/commands/device/view.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/device/view.ts)_
|
||||
|
||||
## `eas help [COMMAND]`
|
||||
|
||||
@@ -262,7 +262,7 @@ OPTIONS
|
||||
--value=value Value of the secret
|
||||
```
|
||||
|
||||
_See code: [build/commands/secret/create.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/secret/create.ts)_
|
||||
_See code: [build/commands/secret/create.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/secret/create.ts)_
|
||||
|
||||
## `eas secret:delete`
|
||||
|
||||
@@ -279,7 +279,7 @@ DESCRIPTION
|
||||
Unsure where to find the secret's ID? Run eas secrets:list
|
||||
```
|
||||
|
||||
_See code: [build/commands/secret/delete.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/secret/delete.ts)_
|
||||
_See code: [build/commands/secret/delete.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/secret/delete.ts)_
|
||||
|
||||
## `eas secret:list`
|
||||
|
||||
@@ -290,7 +290,7 @@ USAGE
|
||||
$ eas secret:list
|
||||
```
|
||||
|
||||
_See code: [build/commands/secret/list.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/secret/list.ts)_
|
||||
_See code: [build/commands/secret/list.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/secret/list.ts)_
|
||||
|
||||
## `eas submit --platform=(android|ios)`
|
||||
|
||||
@@ -316,8 +316,7 @@ OPTIONS
|
||||
|
||||
iOS specific options=asc-app-id App Store Connect unique application Apple ID
|
||||
number. Providing this param results in skipping
|
||||
app creation step. Learn more:
|
||||
https://expo.fyi/asc-app-id
|
||||
app creation step. Learn more.
|
||||
|
||||
iOS specific options=bundle-identifier Your iOS Bundle Identifier (default:
|
||||
expo.ios.bundleIdentifier from app config)
|
||||
@@ -370,7 +369,7 @@ EXAMPLES
|
||||
and provide its App ID
|
||||
```
|
||||
|
||||
_See code: [build/commands/submit.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/submit.ts)_
|
||||
_See code: [build/commands/submit.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/submit.ts)_
|
||||
|
||||
## `eas webhook:create`
|
||||
|
||||
@@ -389,7 +388,7 @@ OPTIONS
|
||||
--url=url Webhook URL
|
||||
```
|
||||
|
||||
_See code: [build/commands/webhook/create.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/webhook/create.ts)_
|
||||
_See code: [build/commands/webhook/create.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/webhook/create.ts)_
|
||||
|
||||
## `eas webhook:delete [ID]`
|
||||
|
||||
@@ -403,7 +402,7 @@ ARGUMENTS
|
||||
ID ID of the webhook to delete
|
||||
```
|
||||
|
||||
_See code: [build/commands/webhook/delete.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/webhook/delete.ts)_
|
||||
_See code: [build/commands/webhook/delete.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/webhook/delete.ts)_
|
||||
|
||||
## `eas webhook:list`
|
||||
|
||||
@@ -417,7 +416,7 @@ OPTIONS
|
||||
--event=(BUILD) Event type that triggers the webhook
|
||||
```
|
||||
|
||||
_See code: [build/commands/webhook/list.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/webhook/list.ts)_
|
||||
_See code: [build/commands/webhook/list.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/webhook/list.ts)_
|
||||
|
||||
## `eas webhook:update`
|
||||
|
||||
@@ -437,7 +436,7 @@ OPTIONS
|
||||
--url=url Webhook URL
|
||||
```
|
||||
|
||||
_See code: [build/commands/webhook/update.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/webhook/update.ts)_
|
||||
_See code: [build/commands/webhook/update.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/webhook/update.ts)_
|
||||
|
||||
## `eas webhook:view ID`
|
||||
|
||||
@@ -451,5 +450,5 @@ ARGUMENTS
|
||||
ID ID of the webhook to view
|
||||
```
|
||||
|
||||
_See code: [build/commands/webhook/view.ts](https://github.com/expo/eas-cli/blob/v0.15.1/build/commands/webhook/view.ts)_
|
||||
_See code: [build/commands/webhook/view.ts](https://github.com/expo/eas-cli/blob/v0.16.0/build/commands/webhook/view.ts)_
|
||||
<!-- commandsstop -->
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "eas-cli",
|
||||
"description": "EAS command line tool",
|
||||
"version": "0.15.1",
|
||||
"version": "0.16.0",
|
||||
"author": "Expo <[email protected]>",
|
||||
"bin": {
|
||||
"eas": "./bin/run"
|
||||
@@ -12,9 +12,9 @@
|
||||
"@amplitude/node": "1.5.0",
|
||||
"@expo/apple-utils": "0.0.0-alpha.20",
|
||||
"@expo/config": "3.3.42",
|
||||
"@expo/config-plugins": "1.0.32",
|
||||
"@expo/config-plugins": "1.0.33",
|
||||
"@expo/eas-build-job": "0.2.35",
|
||||
"@expo/eas-json": "^0.15.1",
|
||||
"@expo/eas-json": "^0.16.0",
|
||||
"@expo/json-file": "8.2.25",
|
||||
"@expo/pkcs12": "0.0.4",
|
||||
"@expo/plist": "0.0.11",
|
||||
|
||||
@@ -68,7 +68,6 @@ This means that it will most likely produce an AAB and you will not be able to i
|
||||
|
||||
return await prepareBuildRequestForPlatformAsync({
|
||||
ctx: buildCtx,
|
||||
projectConfiguration: {},
|
||||
ensureCredentialsAsync: ensureAndroidCredentialsAsync,
|
||||
ensureProjectConfiguredAsync: async () => {
|
||||
if (buildCtx.buildProfile.workflow === Workflow.GENERIC) {
|
||||
|
||||
@@ -29,33 +29,27 @@ export interface CredentialsResult<Credentials> {
|
||||
credentials: Credentials;
|
||||
}
|
||||
|
||||
interface Builder<TPlatform extends Platform, Credentials, ProjectConfiguration, TJob extends Job> {
|
||||
export interface JobData<Credentials> {
|
||||
credentials?: Credentials;
|
||||
projectArchive: ArchiveSource;
|
||||
}
|
||||
|
||||
interface Builder<TPlatform extends Platform, Credentials, TJob extends Job> {
|
||||
ctx: BuildContext<TPlatform>;
|
||||
projectConfiguration: ProjectConfiguration;
|
||||
|
||||
ensureCredentialsAsync(
|
||||
ctx: BuildContext<TPlatform>
|
||||
): Promise<CredentialsResult<Credentials> | undefined>;
|
||||
ensureProjectConfiguredAsync(ctx: BuildContext<TPlatform>): Promise<void>;
|
||||
prepareJobAsync(
|
||||
ctx: BuildContext<TPlatform>,
|
||||
jobData: {
|
||||
credentials?: Credentials;
|
||||
projectConfiguration?: ProjectConfiguration;
|
||||
projectArchive: ArchiveSource;
|
||||
}
|
||||
): Promise<Job>;
|
||||
prepareJobAsync(ctx: BuildContext<TPlatform>, jobData: JobData<Credentials>): Promise<Job>;
|
||||
sendBuildRequestAsync(appId: string, job: TJob, metadata: Metadata): Promise<BuildResult>;
|
||||
}
|
||||
|
||||
export async function prepareBuildRequestForPlatformAsync<
|
||||
TPlatform extends Platform,
|
||||
Credentials,
|
||||
ProjectConfiguration,
|
||||
TJob extends Job
|
||||
>(
|
||||
builder: Builder<TPlatform, Credentials, ProjectConfiguration, TJob>
|
||||
): Promise<() => Promise<string | undefined>> {
|
||||
>(builder: Builder<TPlatform, Credentials, TJob>): Promise<() => Promise<string | undefined>> {
|
||||
const credentialsResult = await withAnalyticsAsync(
|
||||
async () => await builder.ensureCredentialsAsync(builder.ctx),
|
||||
{
|
||||
@@ -100,7 +94,6 @@ export async function prepareBuildRequestForPlatformAsync<
|
||||
const job = await builder.prepareJobAsync(builder.ctx, {
|
||||
projectArchive,
|
||||
credentials: credentialsResult?.credentials,
|
||||
projectConfiguration: builder.projectConfiguration,
|
||||
});
|
||||
|
||||
return async () => {
|
||||
@@ -171,13 +164,8 @@ async function uploadProjectAsync<TPlatform extends Platform>(
|
||||
}
|
||||
}
|
||||
|
||||
async function sendBuildRequestAsync<
|
||||
TPlatform extends Platform,
|
||||
Credentials,
|
||||
ProjectConfiguration,
|
||||
TJob extends Job
|
||||
>(
|
||||
builder: Builder<TPlatform, Credentials, ProjectConfiguration, TJob>,
|
||||
async function sendBuildRequestAsync<TPlatform extends Platform, Credentials, TJob extends Job>(
|
||||
builder: Builder<TPlatform, Credentials, TJob>,
|
||||
job: TJob,
|
||||
metadata: Metadata
|
||||
): Promise<string> {
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
import { IOSConfig } from '@expo/config-plugins';
|
||||
import { Ios, Metadata, Workflow } from '@expo/eas-build-job';
|
||||
import { Ios, Job, Metadata, Workflow } from '@expo/eas-build-job';
|
||||
import { EasConfig } from '@expo/eas-json';
|
||||
import chalk from 'chalk';
|
||||
import fs from 'fs-extra';
|
||||
import sortBy from 'lodash/sortBy';
|
||||
import path from 'path';
|
||||
|
||||
import { IosCredentials } from '../../credentials/ios/types';
|
||||
import { BuildMutation, BuildResult } from '../../graphql/mutations/BuildMutation';
|
||||
import Log from '../../log';
|
||||
import { getOrConfigureBundleIdentifierAsync } from '../../project/ios/bundleIdentifier';
|
||||
import { ensureBundleIdentifierIsDefinedForManagedProjectAsync } from '../../project/ios/bundleIdentifier';
|
||||
import { XcodeBuildContext, resolveTargetsAsync } from '../../project/ios/target';
|
||||
import { sanitizedProjectName } from '../../project/projectUtils';
|
||||
import { promptAsync } from '../../prompts';
|
||||
import { prepareBuildRequestForPlatformAsync } from '../build';
|
||||
import { JobData, prepareBuildRequestForPlatformAsync } from '../build';
|
||||
import { BuildContext, CommandContext, createBuildContext } from '../context';
|
||||
import { transformMetadata } from '../graphql';
|
||||
import { Platform } from '../types';
|
||||
import { validateAndSyncProjectConfigurationAsync } from './configure';
|
||||
import { ensureIosCredentialsAsync } from './credentials';
|
||||
import { transformGenericJob, transformManagedJob } from './graphql';
|
||||
import { prepareJobAsync, sanitizedTargetName } from './prepareJob';
|
||||
import { prepareJobAsync } from './prepareJob';
|
||||
|
||||
export async function prepareIosBuildAsync(
|
||||
commandCtx: CommandContext,
|
||||
@@ -40,34 +43,27 @@ export async function prepareIosBuildAsync(
|
||||
);
|
||||
}
|
||||
|
||||
let iosBuildScheme: string | undefined;
|
||||
let iosApplicationTarget: string | undefined;
|
||||
if (buildCtx.buildProfile.workflow === Workflow.GENERIC) {
|
||||
iosBuildScheme = buildCtx.buildProfile.scheme ?? (await resolveSchemeAsync(buildCtx));
|
||||
iosApplicationTarget = await IOSConfig.BuildScheme.getApplicationTargetForSchemeAsync(
|
||||
buildCtx.commandCtx.projectDir,
|
||||
iosBuildScheme
|
||||
if (buildCtx.buildProfile.workflow === Workflow.MANAGED) {
|
||||
await ensureBundleIdentifierIsDefinedForManagedProjectAsync(
|
||||
commandCtx.projectDir,
|
||||
commandCtx.exp
|
||||
);
|
||||
} else {
|
||||
if (!commandCtx.exp.name) {
|
||||
throw new Error('"expo.name" is required in your app.json');
|
||||
}
|
||||
iosApplicationTarget = sanitizedTargetName(commandCtx.exp.name);
|
||||
if (!iosApplicationTarget) {
|
||||
throw new Error('"expo.name" needs to contain some alphanumeric characters');
|
||||
}
|
||||
}
|
||||
|
||||
// this function throws if bundle id is invalid
|
||||
await getOrConfigureBundleIdentifierAsync(commandCtx.projectDir, commandCtx.exp);
|
||||
const xcodeBuildContext = await resolveXcodeBuildContextAsync(buildCtx);
|
||||
const targets = await resolveTargetsAsync(
|
||||
{
|
||||
projectDir: commandCtx.projectDir,
|
||||
exp: commandCtx.exp,
|
||||
},
|
||||
xcodeBuildContext
|
||||
);
|
||||
|
||||
return await prepareBuildRequestForPlatformAsync({
|
||||
ctx: buildCtx,
|
||||
projectConfiguration: {
|
||||
iosBuildScheme,
|
||||
iosApplicationTarget,
|
||||
ensureCredentialsAsync: async (ctx: BuildContext<Platform.IOS>) => {
|
||||
return ensureIosCredentialsAsync(ctx, targets);
|
||||
},
|
||||
ensureCredentialsAsync: ensureIosCredentialsAsync,
|
||||
ensureProjectConfiguredAsync: async () => {
|
||||
await validateAndSyncProjectConfigurationAsync({
|
||||
projectDir: commandCtx.projectDir,
|
||||
@@ -75,7 +71,12 @@ export async function prepareIosBuildAsync(
|
||||
buildProfile: buildCtx.buildProfile,
|
||||
});
|
||||
},
|
||||
prepareJobAsync,
|
||||
prepareJobAsync: async (
|
||||
ctx: BuildContext<Platform.IOS>,
|
||||
jobData: JobData<IosCredentials>
|
||||
): Promise<Job> => {
|
||||
return await prepareJobAsync(ctx, { ...jobData, buildScheme: xcodeBuildContext.buildScheme });
|
||||
},
|
||||
sendBuildRequestAsync: async (
|
||||
appId: string,
|
||||
job: Ios.Job,
|
||||
@@ -101,6 +102,39 @@ export async function prepareIosBuildAsync(
|
||||
});
|
||||
}
|
||||
|
||||
async function resolveXcodeBuildContextAsync(
|
||||
buildCtx: BuildContext<Platform.IOS>
|
||||
): Promise<XcodeBuildContext> {
|
||||
if (buildCtx.buildProfile.workflow === Workflow.GENERIC) {
|
||||
const buildScheme = buildCtx.buildProfile.scheme ?? (await resolveSchemeAsync(buildCtx));
|
||||
return {
|
||||
buildScheme,
|
||||
buildConfiguration:
|
||||
buildCtx.buildProfile.schemeBuildConfiguration ??
|
||||
(await IOSConfig.BuildScheme.getArchiveBuildConfigurationForSchemeAsync(
|
||||
buildCtx.commandCtx.projectDir,
|
||||
buildScheme
|
||||
)),
|
||||
applicationTarget: await IOSConfig.BuildScheme.getApplicationTargetNameForSchemeAsync(
|
||||
buildCtx.commandCtx.projectDir,
|
||||
buildScheme
|
||||
),
|
||||
};
|
||||
} else {
|
||||
const expoName = buildCtx.commandCtx.exp.name;
|
||||
if (!expoName) {
|
||||
throw new Error('"expo.name" is required in your app.json');
|
||||
}
|
||||
const sanitizedExpoName = sanitizedProjectName(expoName);
|
||||
if (!sanitizedExpoName) {
|
||||
throw new Error('"expo.name" needs to contain some alphanumeric characters');
|
||||
}
|
||||
return {
|
||||
buildScheme: sanitizedExpoName,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async function resolveSchemeAsync(ctx: BuildContext<Platform.IOS>): Promise<string> {
|
||||
const schemes = IOSConfig.BuildScheme.getSchemesFromXcodeproj(ctx.commandCtx.projectDir);
|
||||
if (schemes.length === 1) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { IosBuildProfile, VersionAutoIncrement } from '@expo/eas-json';
|
||||
|
||||
import Log from '../../log';
|
||||
import {
|
||||
getOrConfigureBundleIdentifierAsync,
|
||||
ensureBundleIdentifierIsDefinedForManagedProjectAsync,
|
||||
warnIfBundleIdentifierDefinedInAppConfigForGenericProject,
|
||||
} from '../../project/ios/bundleIdentifier';
|
||||
import { ConfigureContext } from '../context';
|
||||
@@ -14,7 +14,7 @@ import { BumpStrategy, bumpVersionAsync, bumpVersionInAppJsonAsync } from './ver
|
||||
|
||||
export async function configureIosAsync(ctx: ConfigureContext): Promise<void> {
|
||||
if (!ctx.hasIosNativeProject) {
|
||||
await getOrConfigureBundleIdentifierAsync(ctx.projectDir, ctx.exp);
|
||||
await ensureBundleIdentifierIsDefinedForManagedProjectAsync(ctx.projectDir, ctx.exp);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,75 +1,50 @@
|
||||
import { Workflow } from '@expo/eas-build-job';
|
||||
import { CredentialsSource, IosDistributionType, IosEnterpriseProvisioning } from '@expo/eas-json';
|
||||
import nullthrows from 'nullthrows';
|
||||
|
||||
import { createCredentialsContextAsync } from '../../credentials/context';
|
||||
import IosCredentialsProvider, {
|
||||
IosCredentials,
|
||||
} from '../../credentials/ios/IosCredentialsProvider';
|
||||
import { getAppLookupParamsFromContext } from '../../credentials/ios/actions/BuildCredentialsUtils';
|
||||
import { IosCapabilitiesOptions } from '../../credentials/ios/appstore/ensureAppExists';
|
||||
import IosCredentialsProvider from '../../credentials/ios/IosCredentialsProvider';
|
||||
import { resolveEntitlementsJsonAsync } from '../../credentials/ios/appstore/entitlements';
|
||||
import { AppLookupParams } from '../../credentials/ios/credentials';
|
||||
import { getBundleIdentifier } from '../../project/ios/bundleIdentifier';
|
||||
import { IosCredentials, Target } from '../../credentials/ios/types';
|
||||
import { findAccountByName } from '../../user/Account';
|
||||
import { CredentialsResult } from '../build';
|
||||
import { BuildContext } from '../context';
|
||||
import { Platform } from '../types';
|
||||
import { logCredentialsSource } from '../utils/credentials';
|
||||
|
||||
export async function ensureIosCredentialsAsync(
|
||||
ctx: BuildContext<Platform.IOS>
|
||||
buildCtx: BuildContext<Platform.IOS>,
|
||||
targets: Target[]
|
||||
): Promise<CredentialsResult<IosCredentials> | undefined> {
|
||||
if (!shouldProvideCredentials(ctx)) {
|
||||
if (!shouldProvideCredentials(buildCtx)) {
|
||||
return;
|
||||
}
|
||||
const bundleIdentifier = getBundleIdentifier(ctx.commandCtx.projectDir, ctx.commandCtx.exp);
|
||||
return await resolveIosCredentialsAsync(ctx.commandCtx.projectDir, {
|
||||
|
||||
const { projectDir } = buildCtx.commandCtx;
|
||||
|
||||
const ctx = await createCredentialsContextAsync(projectDir, {
|
||||
nonInteractive: buildCtx.commandCtx.nonInteractive,
|
||||
});
|
||||
|
||||
const provider = new IosCredentialsProvider(ctx, {
|
||||
app: {
|
||||
accountName: ctx.commandCtx.accountName,
|
||||
projectName: ctx.commandCtx.projectName,
|
||||
bundleIdentifier,
|
||||
account: nullthrows(
|
||||
findAccountByName(ctx.user.accounts, buildCtx.commandCtx.accountName),
|
||||
`You do not have access to account: ${buildCtx.commandCtx.accountName}`
|
||||
),
|
||||
projectName: buildCtx.commandCtx.projectName,
|
||||
},
|
||||
targets,
|
||||
iosCapabilitiesOptions: {
|
||||
entitlements: await resolveEntitlementsJsonAsync(
|
||||
ctx.commandCtx.projectDir,
|
||||
ctx.buildProfile.workflow
|
||||
buildCtx.commandCtx.projectDir,
|
||||
buildCtx.buildProfile.workflow
|
||||
),
|
||||
},
|
||||
workflow: ctx.buildProfile.workflow,
|
||||
credentialsSource: ctx.buildProfile.credentialsSource,
|
||||
distribution: ctx.buildProfile.distribution ?? 'store',
|
||||
enterpriseProvisioning: ctx.buildProfile.enterpriseProvisioning,
|
||||
nonInteractive: ctx.commandCtx.nonInteractive,
|
||||
skipCredentialsCheck: ctx.commandCtx.skipCredentialsCheck,
|
||||
distribution: buildCtx.buildProfile.distribution ?? 'store',
|
||||
enterpriseProvisioning: buildCtx.buildProfile.enterpriseProvisioning,
|
||||
});
|
||||
}
|
||||
|
||||
interface ResolveCredentialsParams {
|
||||
app: AppLookupParams;
|
||||
workflow: Workflow;
|
||||
credentialsSource: CredentialsSource;
|
||||
distribution: IosDistributionType;
|
||||
enterpriseProvisioning?: IosEnterpriseProvisioning;
|
||||
iosCapabilitiesOptions?: IosCapabilitiesOptions;
|
||||
nonInteractive: boolean;
|
||||
skipCredentialsCheck: boolean;
|
||||
}
|
||||
const { credentialsSource } = buildCtx.buildProfile;
|
||||
|
||||
export async function resolveIosCredentialsAsync(
|
||||
projectDir: string,
|
||||
params: ResolveCredentialsParams
|
||||
): Promise<CredentialsResult<IosCredentials>> {
|
||||
const ctx = await createCredentialsContextAsync(projectDir, {
|
||||
nonInteractive: params.nonInteractive,
|
||||
});
|
||||
const app = getAppLookupParamsFromContext(ctx);
|
||||
const provider = new IosCredentialsProvider(ctx, {
|
||||
app,
|
||||
iosCapabilitiesOptions: params.iosCapabilitiesOptions,
|
||||
distribution: params.distribution,
|
||||
enterpriseProvisioning: params.enterpriseProvisioning,
|
||||
skipCredentialsCheck: params.skipCredentialsCheck,
|
||||
});
|
||||
const { credentialsSource } = params;
|
||||
logCredentialsSource(credentialsSource, Platform.IOS);
|
||||
return {
|
||||
credentials: await provider.getCredentialsAsync(credentialsSource),
|
||||
@@ -77,6 +52,6 @@ export async function resolveIosCredentialsAsync(
|
||||
};
|
||||
}
|
||||
|
||||
function shouldProvideCredentials(ctx: BuildContext<Platform.IOS>): boolean {
|
||||
return ctx.buildProfile.distribution !== 'simulator';
|
||||
function shouldProvideCredentials(buildCtx: BuildContext<Platform.IOS>): boolean {
|
||||
return buildCtx.buildProfile.distribution !== 'simulator';
|
||||
}
|
||||
@@ -1,14 +1,9 @@
|
||||
import { ArchiveSource, Cache, Ios, Job, Workflow, sanitizeJob } from '@expo/eas-build-job';
|
||||
import { IosGenericBuildProfile, IosManagedBuildProfile } from '@expo/eas-json';
|
||||
import assert from 'assert';
|
||||
import path from 'path';
|
||||
|
||||
import {
|
||||
IosCredentials,
|
||||
IosTargetCredentials,
|
||||
isCredentialsMap,
|
||||
readEnvironmentSecretsAsync,
|
||||
} from '../../credentials/credentialsJson/read';
|
||||
import { readEnvironmentSecretsAsync } from '../../credentials/credentialsJson/read';
|
||||
import { IosCredentials, TargetCredentials } from '../../credentials/ios/types';
|
||||
import { getUsername } from '../../project/projectUtils';
|
||||
import { ensureLoggedInAsync } from '../../user/actions';
|
||||
import { gitRootDirectoryAsync } from '../../utils/git';
|
||||
@@ -18,10 +13,7 @@ import { Platform } from '../types';
|
||||
interface JobData {
|
||||
projectArchive: ArchiveSource;
|
||||
credentials?: IosCredentials;
|
||||
projectConfiguration: {
|
||||
iosBuildScheme?: string;
|
||||
iosApplicationTarget?: string;
|
||||
};
|
||||
buildScheme: string;
|
||||
}
|
||||
|
||||
export async function prepareJobAsync(
|
||||
@@ -54,28 +46,16 @@ interface CommonJobProperties {
|
||||
|
||||
async function prepareJobCommonAsync(
|
||||
ctx: BuildContext<Platform.IOS>,
|
||||
{
|
||||
credentials,
|
||||
targetName,
|
||||
projectArchive,
|
||||
}: { credentials?: IosCredentials; targetName?: string; projectArchive: ArchiveSource }
|
||||
{ credentials, projectArchive }: { credentials?: IosCredentials; projectArchive: ArchiveSource }
|
||||
): Promise<Partial<CommonJobProperties>> {
|
||||
const environmentSecrets = await readEnvironmentSecretsAsync(ctx.commandCtx.projectDir);
|
||||
|
||||
let buildCredentials: CommonJobProperties['secrets']['buildCredentials'] = {};
|
||||
if (credentials && isCredentialsMap(credentials)) {
|
||||
const targets = Object.keys(credentials);
|
||||
for (const target of targets) {
|
||||
buildCredentials[target] = prepareTargetCredentials(credentials[target]);
|
||||
const buildCredentials: CommonJobProperties['secrets']['buildCredentials'] = {};
|
||||
if (credentials) {
|
||||
const targetNames = Object.keys(credentials);
|
||||
for (const targetName of targetNames) {
|
||||
buildCredentials[targetName] = prepareTargetCredentials(credentials[targetName]);
|
||||
}
|
||||
} else if (credentials) {
|
||||
// targetName
|
||||
// - for managed projects: sanitized .name from the app config
|
||||
// - for generic projects: name of the application target
|
||||
assert(targetName, 'target name should be defined');
|
||||
buildCredentials = {
|
||||
[targetName]: prepareTargetCredentials(credentials),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -103,12 +83,12 @@ async function prepareJobCommonAsync(
|
||||
};
|
||||
}
|
||||
|
||||
function prepareTargetCredentials(targetCredentials: IosTargetCredentials): Ios.TargetCredentials {
|
||||
function prepareTargetCredentials(targetCredentials: TargetCredentials): Ios.TargetCredentials {
|
||||
return {
|
||||
provisioningProfileBase64: targetCredentials.provisioningProfile,
|
||||
distributionCertificate: {
|
||||
dataBase64: targetCredentials.distributionCertificate.certP12,
|
||||
password: targetCredentials.distributionCertificate.certPassword,
|
||||
dataBase64: targetCredentials.distributionCertificate.certificateP12,
|
||||
password: targetCredentials.distributionCertificate.certificatePassword,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -123,11 +103,10 @@ async function prepareGenericJobAsync(
|
||||
return {
|
||||
...(await prepareJobCommonAsync(ctx, {
|
||||
credentials: jobData.credentials,
|
||||
targetName: jobData.projectConfiguration.iosApplicationTarget,
|
||||
projectArchive: jobData.projectArchive,
|
||||
})),
|
||||
type: Workflow.GENERIC,
|
||||
scheme: jobData.projectConfiguration.iosBuildScheme,
|
||||
scheme: jobData.buildScheme,
|
||||
buildConfiguration: buildProfile.schemeBuildConfiguration,
|
||||
artifactPath: buildProfile.artifactPath,
|
||||
releaseChannel: buildProfile.releaseChannel,
|
||||
@@ -146,7 +125,6 @@ async function prepareManagedJobAsync(
|
||||
return {
|
||||
...(await prepareJobCommonAsync(ctx, {
|
||||
credentials: jobData.credentials,
|
||||
targetName: jobData.projectConfiguration.iosApplicationTarget,
|
||||
projectArchive: jobData.projectArchive,
|
||||
})),
|
||||
type: Workflow.MANAGED,
|
||||
@@ -156,12 +134,3 @@ async function prepareManagedJobAsync(
|
||||
projectRootDirectory,
|
||||
};
|
||||
}
|
||||
|
||||
// copy-pasted from expo-cli/packages/xdl/src/Exp.ts
|
||||
// it's used in eject
|
||||
export function sanitizedTargetName(name: string) {
|
||||
return name
|
||||
.replace(/[\W_]+/g, '')
|
||||
.normalize('NFD')
|
||||
.replace(/[\u0300-\u036f]/g, '');
|
||||
}
|
||||
@@ -109,8 +109,8 @@ describe('credentialsJson', () => {
|
||||
expect(result).toEqual({
|
||||
provisioningProfile: 'c29tZWJpbmFyeWNvbnRlbnQ=',
|
||||
distributionCertificate: {
|
||||
certP12: 'c29tZWJpbmFyeWNvbnRlbnQy',
|
||||
certPassword: 'certPass',
|
||||
certificateP12: 'c29tZWJpbmFyeWNvbnRlbnQy',
|
||||
certificatePassword: 'certPass',
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -211,15 +211,15 @@ describe('credentialsJson', () => {
|
||||
target1: {
|
||||
provisioningProfile: 'cHByb2ZpbGUtMS1zb21lYmluYXJ5Y29udGVudA==',
|
||||
distributionCertificate: {
|
||||
certP12: 'Y2VydC0xLXNvbWViaW5hcnljb250ZW50',
|
||||
certPassword: 'cert-pass-1',
|
||||
certificateP12: 'Y2VydC0xLXNvbWViaW5hcnljb250ZW50',
|
||||
certificatePassword: 'cert-pass-1',
|
||||
},
|
||||
},
|
||||
target2: {
|
||||
provisioningProfile: 'cHByb2ZpbGUtMi1zb21lYmluYXJ5Y29udGVudA==',
|
||||
distributionCertificate: {
|
||||
certP12: 'Y2VydC0yLXNvbWViaW5hcnljb250ZW50',
|
||||
certPassword: 'cert-pass-2',
|
||||
certificateP12: 'Y2VydC0yLXNvbWViaW5hcnljb250ZW50',
|
||||
certificatePassword: 'cert-pass-2',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -59,8 +59,8 @@ interface AndroidCredentials {
|
||||
export interface IosTargetCredentials {
|
||||
provisioningProfile: string;
|
||||
distributionCertificate: {
|
||||
certP12: string;
|
||||
certPassword: string;
|
||||
certificateP12: string;
|
||||
certificatePassword: string;
|
||||
};
|
||||
}
|
||||
export type IosTargetCredentialsMap = Record<string, IosTargetCredentials>;
|
||||
@@ -127,11 +127,11 @@ async function readCredentialsForTargetAsync(
|
||||
'base64'
|
||||
),
|
||||
distributionCertificate: {
|
||||
certP12: await fs.readFile(
|
||||
certificateP12: await fs.readFile(
|
||||
getAbsolutePath(projectDir, targetCredentials.distributionCertificate.path),
|
||||
'base64'
|
||||
),
|
||||
certPassword: targetCredentials.distributionCertificate.password,
|
||||
certificatePassword: targetCredentials.distributionCertificate.password,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
import { Platform } from '@expo/eas-build-job';
|
||||
import { CredentialsSource, IosDistributionType, IosEnterpriseProvisioning } from '@expo/eas-json';
|
||||
import nullthrows from 'nullthrows';
|
||||
|
||||
import { CredentialsManager } from '../CredentialsManager';
|
||||
import { Context } from '../context';
|
||||
import * as credentialsJsonReader from '../credentialsJson/read';
|
||||
import type { IosCredentials } from '../credentialsJson/read';
|
||||
import { SetupBuildCredentials } from './actions/SetupBuildCredentials';
|
||||
import { AppLookupParams } from './api/GraphqlClient';
|
||||
import { IosCapabilitiesOptions } from './appstore/ensureAppExists';
|
||||
import { App, IosCredentials, Target } from './types';
|
||||
import { isAdHocProfile } from './utils/provisioningProfile';
|
||||
|
||||
export type { IosCredentials };
|
||||
|
||||
interface Options {
|
||||
app: AppLookupParams;
|
||||
app: App;
|
||||
targets: Target[];
|
||||
distribution: IosDistributionType;
|
||||
enterpriseProvisioning?: IosEnterpriseProvisioning;
|
||||
skipCredentialsCheck?: boolean;
|
||||
iosCapabilitiesOptions?: IosCapabilitiesOptions;
|
||||
}
|
||||
|
||||
@@ -36,19 +33,64 @@ export default class IosCredentialsProvider {
|
||||
}
|
||||
|
||||
private async getLocalAsync(): Promise<IosCredentials> {
|
||||
const credentials = await credentialsJsonReader.readIosCredentialsAsync(this.ctx.projectDir);
|
||||
if (credentialsJsonReader.isCredentialsMap(credentials)) {
|
||||
for (const targetName of Object.keys(credentials)) {
|
||||
this.assertProvisioningProfileType(credentials[targetName].provisioningProfile, targetName);
|
||||
const mainTarget = nullthrows(
|
||||
this.options.targets.find(({ parentBundleIdentifier }) => !parentBundleIdentifier),
|
||||
'Could not find the application target'
|
||||
);
|
||||
|
||||
const iosTargetCredentialsMap = this.enforceIosTargetCredentialsMap(
|
||||
await credentialsJsonReader.readIosCredentialsAsync(this.ctx.projectDir),
|
||||
mainTarget
|
||||
);
|
||||
|
||||
const notConfiguredTargets: string[] = [];
|
||||
for (const target of this.options.targets) {
|
||||
if (!(target.targetName in iosTargetCredentialsMap)) {
|
||||
notConfiguredTargets.push(target.targetName);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
this.assertProvisioningProfileType(credentials.provisioningProfile);
|
||||
this.assertProvisioningProfileType(
|
||||
iosTargetCredentialsMap[target.targetName].provisioningProfile,
|
||||
target.targetName
|
||||
);
|
||||
}
|
||||
return credentials;
|
||||
|
||||
if (notConfiguredTargets.length > 0) {
|
||||
throw new Error(
|
||||
`Credentials for target${
|
||||
notConfiguredTargets.length === 1 ? '' : 's'
|
||||
} ${notConfiguredTargets.map(i => `'${i}'`).join(',')} are not defined in credentials.json`
|
||||
);
|
||||
}
|
||||
|
||||
return iosTargetCredentialsMap;
|
||||
}
|
||||
|
||||
private assertProvisioningProfileType(provisionigProfile: string, targetName?: string) {
|
||||
const isAdHoc = isAdHocProfile(provisionigProfile);
|
||||
private async getRemoteAsync(): Promise<IosCredentials> {
|
||||
return await new SetupBuildCredentials({
|
||||
app: this.options.app,
|
||||
targets: this.options.targets,
|
||||
distribution: this.options.distribution,
|
||||
enterpriseProvisioning: this.options.enterpriseProvisioning,
|
||||
iosCapabilitiesOptions: this.options.iosCapabilitiesOptions,
|
||||
}).runAsync(this.ctx);
|
||||
}
|
||||
|
||||
private enforceIosTargetCredentialsMap(
|
||||
iosCredentials: credentialsJsonReader.IosCredentials,
|
||||
mainTarget: Target
|
||||
): credentialsJsonReader.IosTargetCredentialsMap {
|
||||
if (credentialsJsonReader.isCredentialsMap(iosCredentials)) {
|
||||
return iosCredentials;
|
||||
} else {
|
||||
return {
|
||||
[mainTarget.targetName]: iosCredentials,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private assertProvisioningProfileType(provisioningProfile: string, targetName?: string): void {
|
||||
const isAdHoc = isAdHocProfile(provisioningProfile);
|
||||
if (this.options.distribution === 'internal' && !isAdHoc) {
|
||||
throw new Error(
|
||||
`You must use an adhoc provisioning profile${
|
||||
@@ -63,21 +105,4 @@ export default class IosCredentialsProvider {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private async getRemoteAsync(): Promise<IosCredentials> {
|
||||
const manager = new CredentialsManager(this.ctx);
|
||||
const { provisioningProfile, distributionCertificate } = await new SetupBuildCredentials({
|
||||
app: this.options.app,
|
||||
distribution: this.options.distribution,
|
||||
enterpriseProvisioning: this.options.enterpriseProvisioning,
|
||||
iosCapabilitiesOptions: this.options.iosCapabilitiesOptions,
|
||||
}).runAsync(manager, this.ctx);
|
||||
return {
|
||||
provisioningProfile,
|
||||
distributionCertificate: {
|
||||
certP12: distributionCertificate.certificateP12,
|
||||
certPassword: distributionCertificate.certificatePassword,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -65,9 +65,9 @@ describe(IosCredentialsProvider, () => {
|
||||
id: `id-${appLookupParams.account.name}`,
|
||||
name: appLookupParams.account.name,
|
||||
},
|
||||
bundleIdentifier: appLookupParams.bundleIdentifier,
|
||||
projectName: appLookupParams.projectName,
|
||||
},
|
||||
targets: [{ targetName: 'testapp', bundleIdentifier: appLookupParams.bundleIdentifier }],
|
||||
distribution: 'store',
|
||||
});
|
||||
await expect(provider.getCredentialsAsync(CredentialsSource.REMOTE)).rejects.toThrowError(
|
||||
@@ -99,9 +99,9 @@ describe(IosCredentialsProvider, () => {
|
||||
id: `id-${appLookupParams.account.name}`,
|
||||
name: appLookupParams.account.name,
|
||||
},
|
||||
bundleIdentifier: appLookupParams.bundleIdentifier,
|
||||
projectName: appLookupParams.projectName,
|
||||
},
|
||||
targets: [{ targetName: 'testapp', bundleIdentifier: appLookupParams.bundleIdentifier }],
|
||||
distribution: 'store',
|
||||
});
|
||||
|
||||
@@ -109,11 +109,13 @@ describe(IosCredentialsProvider, () => {
|
||||
testIosAppCredentialsWithBuildCredentialsQueryResult.iosAppBuildCredentialsList[0];
|
||||
await expect(provider.getCredentialsAsync(CredentialsSource.REMOTE)).resolves.toMatchObject(
|
||||
{
|
||||
distributionCertificate: {
|
||||
certP12: buildCredentials.distributionCertificate?.certificateP12,
|
||||
certPassword: buildCredentials.distributionCertificate?.certificatePassword,
|
||||
testapp: {
|
||||
distributionCertificate: {
|
||||
certificateP12: buildCredentials.distributionCertificate?.certificateP12,
|
||||
certificatePassword: buildCredentials.distributionCertificate?.certificatePassword,
|
||||
},
|
||||
provisioningProfile: buildCredentials.provisioningProfile?.provisioningProfile,
|
||||
},
|
||||
provisioningProfile: buildCredentials.provisioningProfile?.provisioningProfile,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
@@ -2,95 +2,93 @@ import { IosDistributionType, IosEnterpriseProvisioning } from '@expo/eas-json';
|
||||
import chalk from 'chalk';
|
||||
import nullthrows from 'nullthrows';
|
||||
|
||||
import {
|
||||
IosDistributionType as GraphQLIosDistributionType,
|
||||
IosAppBuildCredentialsFragment,
|
||||
} from '../../../graphql/generated';
|
||||
import Log from '../../../log';
|
||||
import { Action, CredentialsManager } from '../../CredentialsManager';
|
||||
import { CredentialsManager } from '../../CredentialsManager';
|
||||
import { Context } from '../../context';
|
||||
import { AppLookupParams as GraphQLAppLookupParams } from '../api/GraphqlClient';
|
||||
import { IosCapabilitiesOptions } from '../appstore/ensureAppExists';
|
||||
import { App, IosAppBuildCredentialsMap, IosCredentials, Target } from '../types';
|
||||
import { displayProjectCredentials } from '../utils/printCredentials';
|
||||
import { SetupAdhocProvisioningProfile } from './SetupAdhocProvisioningProfile';
|
||||
import { SetupInternalProvisioningProfile } from './SetupInternalProvisioningProfile';
|
||||
import { SetupProvisioningProfile } from './SetupProvisioningProfile';
|
||||
import { SetupTargetBuildCredentials } from './SetupTargetBuildCredentials';
|
||||
|
||||
interface Options {
|
||||
app: GraphQLAppLookupParams;
|
||||
app: App;
|
||||
targets: Target[];
|
||||
distribution: IosDistributionType;
|
||||
enterpriseProvisioning?: IosEnterpriseProvisioning;
|
||||
skipCredentialsCheck?: boolean;
|
||||
iosCapabilitiesOptions?: IosCapabilitiesOptions;
|
||||
}
|
||||
|
||||
interface IosAppBuildCredentials {
|
||||
iosDistributionType: GraphQLIosDistributionType;
|
||||
provisioningProfile: string;
|
||||
distributionCertificate: {
|
||||
certificateP12: string;
|
||||
certificatePassword: string;
|
||||
};
|
||||
}
|
||||
|
||||
export class SetupBuildCredentials implements Action<IosAppBuildCredentials> {
|
||||
export class SetupBuildCredentials {
|
||||
constructor(private options: Options) {}
|
||||
|
||||
async runAsync(manager: CredentialsManager, ctx: Context): Promise<IosAppBuildCredentials> {
|
||||
const { app, iosCapabilitiesOptions } = this.options;
|
||||
async runAsync(ctx: Context): Promise<IosCredentials> {
|
||||
const manager = new CredentialsManager(ctx);
|
||||
|
||||
await ctx.bestEffortAppStoreAuthenticateAsync();
|
||||
|
||||
if (ctx.appStore.authCtx) {
|
||||
await ctx.appStore.ensureBundleIdExistsAsync(
|
||||
{
|
||||
accountName: app.account.name,
|
||||
bundleIdentifier: app.bundleIdentifier,
|
||||
projectName: app.projectName,
|
||||
},
|
||||
iosCapabilitiesOptions
|
||||
const hasManyTargets = this.options.targets.length > 1;
|
||||
const iosAppBuildCredentialsMap: IosAppBuildCredentialsMap = {};
|
||||
if (hasManyTargets) {
|
||||
Log.newLine();
|
||||
Log.log(`We found that the scheme you want to build consists of many targets.`);
|
||||
Log.log(`You have to set up credentials for each of the targets.`);
|
||||
Log.log(
|
||||
`They can share the same Distribution Certificate but require separate Provisioning Profiles.`
|
||||
);
|
||||
}
|
||||
try {
|
||||
const buildCredentials = await this.setupBuildCredentials(ctx);
|
||||
const appInfo = `@${app.account.name}/${app.projectName} (${app.bundleIdentifier})`;
|
||||
displayProjectCredentials(app, buildCredentials);
|
||||
Log.newLine();
|
||||
Log.log(chalk.green(`All credentials are ready to build ${appInfo}`));
|
||||
Log.newLine();
|
||||
return {
|
||||
iosDistributionType: buildCredentials.iosDistributionType,
|
||||
provisioningProfile: nullthrows(buildCredentials.provisioningProfile?.provisioningProfile),
|
||||
distributionCertificate: {
|
||||
certificateP12: nullthrows(buildCredentials.distributionCertificate?.certificateP12),
|
||||
certificatePassword: nullthrows(
|
||||
buildCredentials.distributionCertificate?.certificatePassword
|
||||
),
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
Log.error('Failed to setup credentials.');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async setupBuildCredentials(ctx: Context): Promise<IosAppBuildCredentialsFragment> {
|
||||
const { app, distribution, enterpriseProvisioning } = this.options;
|
||||
if (distribution === 'internal') {
|
||||
if (enterpriseProvisioning === 'adhoc') {
|
||||
return await new SetupAdhocProvisioningProfile(app).runAsync(ctx);
|
||||
} else if (enterpriseProvisioning === 'universal') {
|
||||
return await new SetupProvisioningProfile(
|
||||
app,
|
||||
GraphQLIosDistributionType.Enterprise
|
||||
).runAsync(ctx);
|
||||
} else {
|
||||
return await new SetupInternalProvisioningProfile(app).runAsync(ctx);
|
||||
Log.log(`Setting up credentials for following targets:`);
|
||||
for (const { targetName, bundleIdentifier } of this.options.targets) {
|
||||
Log.log(`- Target: ${chalk.bold(targetName)}`);
|
||||
Log.log(` Bundle Identifier: ${chalk.bold(bundleIdentifier)}`);
|
||||
}
|
||||
} else {
|
||||
return await new SetupProvisioningProfile(app, GraphQLIosDistributionType.AppStore).runAsync(
|
||||
ctx
|
||||
);
|
||||
}
|
||||
for (const target of this.options.targets) {
|
||||
if (hasManyTargets) {
|
||||
Log.newLine();
|
||||
Log.log(
|
||||
`Setting up credentials for target ${chalk.bold(target.targetName)} (${chalk.bold(
|
||||
target.bundleIdentifier
|
||||
)})`
|
||||
);
|
||||
Log.newLine();
|
||||
} else {
|
||||
Log.newLine();
|
||||
}
|
||||
const action = new SetupTargetBuildCredentials({
|
||||
...this.options,
|
||||
app: {
|
||||
...this.options.app,
|
||||
bundleIdentifier: target.bundleIdentifier,
|
||||
parentBundleIdentifier: target.parentBundleIdentifier,
|
||||
},
|
||||
});
|
||||
iosAppBuildCredentialsMap[target.targetName] = await action.runAsync(manager, ctx);
|
||||
}
|
||||
|
||||
const appInfo = formatAppInfo(this.options.app, this.options.targets);
|
||||
Log.newLine();
|
||||
displayProjectCredentials(this.options.app, iosAppBuildCredentialsMap, this.options.targets);
|
||||
Log.log(chalk.green(`All credentials are ready to build ${chalk.bold(appInfo)}`));
|
||||
Log.newLine();
|
||||
|
||||
return toIosCredentials(iosAppBuildCredentialsMap);
|
||||
}
|
||||
}
|
||||
|
||||
function toIosCredentials(appBuildCredentialsMap: IosAppBuildCredentialsMap): IosCredentials {
|
||||
return Object.entries(appBuildCredentialsMap).reduce((acc, [targetName, appBuildCredentials]) => {
|
||||
acc[targetName] = {
|
||||
distributionCertificate: {
|
||||
certificateP12: nullthrows(appBuildCredentials.distributionCertificate?.certificateP12),
|
||||
certificatePassword: nullthrows(
|
||||
appBuildCredentials.distributionCertificate?.certificatePassword
|
||||
),
|
||||
},
|
||||
provisioningProfile: nullthrows(appBuildCredentials.provisioningProfile?.provisioningProfile),
|
||||
};
|
||||
return acc;
|
||||
}, {} as IosCredentials);
|
||||
}
|
||||
|
||||
function formatAppInfo({ account, projectName }: App, targets: Target[]): string {
|
||||
const bundleIds = targets.map(target => target.bundleIdentifier);
|
||||
return `@${account.name}/${projectName} (${bundleIds.join(', ')})`;
|
||||
}
|
||||
+18
-8
@@ -36,22 +36,22 @@ export class SetupBuildCredentialsFromCredentialsJson {
|
||||
currentDistributionCertificate: AppleDistributionCertificateFragment | null
|
||||
): Promise<AppleDistributionCertificateFragment> {
|
||||
const { distributionCertificate } = targetCredentials;
|
||||
const { certP12, certPassword } = distributionCertificate;
|
||||
const { certificateP12, certificatePassword } = distributionCertificate;
|
||||
|
||||
if (!currentDistributionCertificate) {
|
||||
return await ctx.ios.createDistributionCertificateAsync(this.app.account, {
|
||||
certP12,
|
||||
certPassword,
|
||||
certP12: certificateP12,
|
||||
certPassword: certificatePassword,
|
||||
teamId: appleTeam.appleTeamIdentifier,
|
||||
teamName: appleTeam.appleTeamName ?? undefined,
|
||||
});
|
||||
}
|
||||
|
||||
const isSameCertificate = currentDistributionCertificate.certificateP12 === certP12;
|
||||
const isSameCertificate = currentDistributionCertificate.certificateP12 === certificateP12;
|
||||
if (!isSameCertificate) {
|
||||
return await ctx.ios.createDistributionCertificateAsync(this.app.account, {
|
||||
certP12,
|
||||
certPassword,
|
||||
certP12: certificateP12,
|
||||
certPassword: certificatePassword,
|
||||
teamId: appleTeam.appleTeamIdentifier,
|
||||
teamName: appleTeam.appleTeamName ?? undefined,
|
||||
});
|
||||
@@ -157,7 +157,7 @@ export class SetupBuildCredentialsFromCredentialsJson {
|
||||
|
||||
if (buildCredentials) {
|
||||
Log.log('Currently configured credentials:');
|
||||
displayProjectCredentials(this.app, buildCredentials);
|
||||
displaySingleTargetProjectCredentials(this.app, buildCredentials);
|
||||
if (!ctx.nonInteractive) {
|
||||
const confirm = await confirmAsync({
|
||||
message: `Would you like to replace this configuration with credentials from credentials json?`,
|
||||
@@ -179,7 +179,7 @@ export class SetupBuildCredentialsFromCredentialsJson {
|
||||
);
|
||||
|
||||
Log.log('New credentials configuration:');
|
||||
displayProjectCredentials(this.app, newBuildCredentials);
|
||||
displaySingleTargetProjectCredentials(this.app, newBuildCredentials);
|
||||
|
||||
Log.newLine();
|
||||
Log.log(chalk.green(`All credentials are ready to build ${appInfo}`));
|
||||
@@ -187,3 +187,13 @@ export class SetupBuildCredentialsFromCredentialsJson {
|
||||
return newBuildCredentials;
|
||||
}
|
||||
}
|
||||
|
||||
function displaySingleTargetProjectCredentials(
|
||||
app: AppLookupParams,
|
||||
buildCredentials: IosAppBuildCredentialsFragment
|
||||
) {
|
||||
const targetName = app.projectName;
|
||||
displayProjectCredentials(app, { [targetName]: buildCredentials }, [
|
||||
{ targetName, bundleIdentifier: app.bundleIdentifier },
|
||||
]);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
import { IosDistributionType, IosEnterpriseProvisioning } from '@expo/eas-json';
|
||||
|
||||
import {
|
||||
IosDistributionType as GraphQLIosDistributionType,
|
||||
IosAppBuildCredentialsFragment,
|
||||
} from '../../../graphql/generated';
|
||||
import Log from '../../../log';
|
||||
import { Action, CredentialsManager } from '../../CredentialsManager';
|
||||
import { Context } from '../../context';
|
||||
import { AppLookupParams as GraphQLAppLookupParams } from '../api/GraphqlClient';
|
||||
import { IosCapabilitiesOptions } from '../appstore/ensureAppExists';
|
||||
import { SetupAdhocProvisioningProfile } from './SetupAdhocProvisioningProfile';
|
||||
import { SetupInternalProvisioningProfile } from './SetupInternalProvisioningProfile';
|
||||
import { SetupProvisioningProfile } from './SetupProvisioningProfile';
|
||||
|
||||
interface Options {
|
||||
app: GraphQLAppLookupParams;
|
||||
distribution: IosDistributionType;
|
||||
enterpriseProvisioning?: IosEnterpriseProvisioning;
|
||||
iosCapabilitiesOptions?: IosCapabilitiesOptions;
|
||||
}
|
||||
export class SetupTargetBuildCredentials implements Action<IosAppBuildCredentialsFragment> {
|
||||
constructor(private options: Options) {}
|
||||
|
||||
async runAsync(
|
||||
manager: CredentialsManager,
|
||||
ctx: Context
|
||||
): Promise<IosAppBuildCredentialsFragment> {
|
||||
const { app, iosCapabilitiesOptions } = this.options;
|
||||
|
||||
await ctx.bestEffortAppStoreAuthenticateAsync();
|
||||
|
||||
if (ctx.appStore.authCtx) {
|
||||
await ctx.appStore.ensureBundleIdExistsAsync(
|
||||
{
|
||||
accountName: app.account.name,
|
||||
bundleIdentifier: app.bundleIdentifier,
|
||||
projectName: app.projectName,
|
||||
},
|
||||
iosCapabilitiesOptions
|
||||
);
|
||||
}
|
||||
try {
|
||||
return await this.setupBuildCredentials(ctx);
|
||||
} catch (error) {
|
||||
Log.error('Failed to setup credentials.');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async setupBuildCredentials(ctx: Context): Promise<IosAppBuildCredentialsFragment> {
|
||||
const { app, distribution, enterpriseProvisioning } = this.options;
|
||||
if (distribution === 'internal') {
|
||||
if (enterpriseProvisioning === 'adhoc') {
|
||||
return await new SetupAdhocProvisioningProfile(app).runAsync(ctx);
|
||||
} else if (enterpriseProvisioning === 'universal') {
|
||||
return await new SetupProvisioningProfile(
|
||||
app,
|
||||
GraphQLIosDistributionType.Enterprise
|
||||
).runAsync(ctx);
|
||||
} else {
|
||||
return await new SetupInternalProvisioningProfile(app).runAsync(ctx);
|
||||
}
|
||||
} else {
|
||||
return await new SetupProvisioningProfile(app, GraphQLIosDistributionType.AppStore).runAsync(
|
||||
ctx
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -35,8 +35,8 @@ beforeEach(() => {
|
||||
(readIosCredentialsAsync as jest.Mock).mockImplementation(() => ({
|
||||
provisioningProfile: testProvisioningProfile.provisioningProfile,
|
||||
distributionCertificate: {
|
||||
certP12: testDistCert.certP12,
|
||||
certPassword: testDistCert.certPassword,
|
||||
certificateP12: testDistCert.certP12,
|
||||
certificatePassword: testDistCert.certPassword,
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -43,6 +43,7 @@ export interface AppLookupParams {
|
||||
account: Account;
|
||||
projectName: string;
|
||||
bundleIdentifier: string;
|
||||
parentBundleIdentifier?: string;
|
||||
}
|
||||
|
||||
async function getAppAsync(appLookupParams: AppLookupParams): Promise<AppFragment> {
|
||||
@@ -191,7 +192,7 @@ export async function createOrGetExistingAppleTeamAsync(
|
||||
}
|
||||
|
||||
export async function createOrGetExistingAppleAppIdentifierAsync(
|
||||
{ account, bundleIdentifier }: AppLookupParams,
|
||||
{ account, projectName, bundleIdentifier, parentBundleIdentifier }: AppLookupParams,
|
||||
appleTeam: AppleTeamFragment | null
|
||||
): Promise<AppleAppIdentifierFragment> {
|
||||
const appleAppIdentifier = await AppleAppIdentifierQuery.byBundleIdentifierAsync(
|
||||
@@ -204,8 +205,18 @@ export async function createOrGetExistingAppleAppIdentifierAsync(
|
||||
if (!appleTeam) {
|
||||
throw new AppleTeamMissingError();
|
||||
}
|
||||
const parentAppleAppIdentifier = parentBundleIdentifier
|
||||
? await createOrGetExistingAppleAppIdentifierAsync(
|
||||
{ account, projectName, bundleIdentifier: parentBundleIdentifier },
|
||||
appleTeam
|
||||
)
|
||||
: null;
|
||||
return await AppleAppIdentifierMutation.createAppleAppIdentifierAsync(
|
||||
{ bundleIdentifier, appleTeamId: appleTeam.id },
|
||||
{
|
||||
bundleIdentifier,
|
||||
appleTeamId: appleTeam.id,
|
||||
parentAppleAppId: parentAppleAppIdentifier?.id,
|
||||
},
|
||||
account.id
|
||||
);
|
||||
}
|
||||
|
||||
+1
@@ -14,6 +14,7 @@ const AppleAppIdentifierMutation = {
|
||||
appleAppIdentifierInput: {
|
||||
bundleIdentifier: string;
|
||||
appleTeamId?: string;
|
||||
parentAppleAppId?: string;
|
||||
},
|
||||
accountId: string
|
||||
): Promise<AppleAppIdentifierFragment> {
|
||||
|
||||
@@ -7,9 +7,12 @@ import {
|
||||
CapabilityTypeOption,
|
||||
} from '@expo/apple-utils';
|
||||
import { JSONObject, JSONValue } from '@expo/json-file';
|
||||
import getenv from 'getenv';
|
||||
|
||||
import Log from '../../../log';
|
||||
|
||||
const EXPO_NO_CAPABILITY_SYNC = getenv.boolish('EXPO_NO_CAPABILITY_SYNC', false);
|
||||
|
||||
type GetOptionsMethod<T extends CapabilityType = any> = (
|
||||
entitlement: JSONValue,
|
||||
entitlementsJson: JSONObject
|
||||
@@ -59,8 +62,13 @@ const getDefinedOptions: GetOptionsMethod = entitlement => {
|
||||
export async function syncCapabilitiesForEntitlementsAsync(
|
||||
bundleId: BundleId,
|
||||
entitlements: JSONObject = {}
|
||||
) {
|
||||
): Promise<{ enabled: string[]; disabled: string[] }> {
|
||||
if (EXPO_NO_CAPABILITY_SYNC) return { enabled: [], disabled: [] };
|
||||
const currentCapabilities = await bundleId.getBundleIdCapabilitiesAsync();
|
||||
if (Log.isDebug) {
|
||||
Log.log(`Current remote capabilities:\n${JSON.stringify(currentCapabilities, null, 2)}`);
|
||||
Log.log(`\nCurrent local entitlements:\n${JSON.stringify(entitlements, null, 2)}`);
|
||||
}
|
||||
|
||||
const { enabledCapabilityNames, request, remainingCapabilities } = getCapabilitiesToEnable(
|
||||
currentCapabilities,
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { IosAppBuildCredentialsFragment } from '../../graphql/generated';
|
||||
import { Account } from '../../user/Account';
|
||||
|
||||
export interface App {
|
||||
account: Account;
|
||||
projectName: string;
|
||||
}
|
||||
|
||||
export interface Target {
|
||||
targetName: string;
|
||||
bundleIdentifier: string;
|
||||
parentBundleIdentifier?: string;
|
||||
}
|
||||
|
||||
export interface TargetCredentials {
|
||||
distributionCertificate: {
|
||||
certificateP12: string;
|
||||
certificatePassword: string;
|
||||
};
|
||||
provisioningProfile: string;
|
||||
}
|
||||
|
||||
export type IosCredentials = Record<string, TargetCredentials>;
|
||||
|
||||
export type IosAppBuildCredentialsMap = Record<string, IosAppBuildCredentialsFragment>;
|
||||
@@ -11,6 +11,7 @@ import { APPLE_DEVICE_CLASS_LABELS } from '../../../graphql/types/credentials/Ap
|
||||
import Log from '../../../log';
|
||||
import { fromNow } from '../../../utils/date';
|
||||
import { AppLookupParams } from '../api/GraphqlClient';
|
||||
import { App, IosAppBuildCredentialsMap, Target } from '../types';
|
||||
|
||||
function prettyIosDistributionType(distributionType: IosDistributionType): string {
|
||||
switch (distributionType) {
|
||||
@@ -82,22 +83,35 @@ export function displayIosAppCredentials(credentials: CommonIosAppCredentialsFra
|
||||
}
|
||||
|
||||
export function displayProjectCredentials(
|
||||
appLookupParams: AppLookupParams,
|
||||
buildCredentials: IosAppBuildCredentialsFragment
|
||||
app: App,
|
||||
iosCredentials: IosAppBuildCredentialsMap,
|
||||
targets: Target[]
|
||||
): void {
|
||||
const experienceName = `@${appLookupParams.account.name}/${appLookupParams.projectName}`;
|
||||
const projectFullName = `@${app.account.name}/${app.projectName}`;
|
||||
const targetToBundleId = targets.reduce<Record<string, string>>((acc, target) => {
|
||||
acc[target.targetName] = target.bundleIdentifier;
|
||||
return acc;
|
||||
}, {});
|
||||
const areMultitarget = Object.keys(iosCredentials).length > 1;
|
||||
|
||||
Log.addNewLineIfNone();
|
||||
Log.log(chalk.bold('Project Credentials Configuration:'));
|
||||
Log.log(` Project: ${chalk.bold(experienceName)}`);
|
||||
Log.log(` Bundle Identifier: ${appLookupParams.bundleIdentifier}`);
|
||||
displayIosAppBuildCredentials(buildCredentials);
|
||||
Log.log(` Project: ${chalk.bold(projectFullName)}`);
|
||||
for (const [targetName, buildCredentials] of Object.entries(iosCredentials)) {
|
||||
if (areMultitarget) {
|
||||
Log.newLine();
|
||||
Log.log(` Target: ${chalk.bold(targetName)}`);
|
||||
}
|
||||
Log.log(` Bundle Identifier: ${chalk.bold(targetToBundleId[targetName])}`);
|
||||
displayIosAppBuildCredentials(buildCredentials);
|
||||
}
|
||||
}
|
||||
|
||||
function displayIosAppBuildCredentials(buildCredentials: IosAppBuildCredentialsFragment): void {
|
||||
Log.log(
|
||||
chalk.bold(
|
||||
` Configuration: ${prettyIosDistributionType(buildCredentials.iosDistributionType)}`
|
||||
)
|
||||
` Configuration: ${chalk.bold(
|
||||
prettyIosDistributionType(buildCredentials.iosDistributionType)
|
||||
)}`
|
||||
);
|
||||
Log.newLine();
|
||||
const maybeDistCert = buildCredentials.distributionCertificate;
|
||||
|
||||
@@ -18,9 +18,9 @@ import { selectValidDistributionCertificateAsync } from '../ios/actions/Distribu
|
||||
import { SelectAndRemoveDistributionCertificate } from '../ios/actions/RemoveDistributionCertificate';
|
||||
import { RemoveProvisioningProfiles } from '../ios/actions/RemoveProvisioningProfile';
|
||||
import { SetupAdhocProvisioningProfile } from '../ios/actions/SetupAdhocProvisioningProfile';
|
||||
import { SetupBuildCredentials } from '../ios/actions/SetupBuildCredentials';
|
||||
import { SetupBuildCredentialsFromCredentialsJson } from '../ios/actions/SetupBuildCredentialsFromCredentialsJson';
|
||||
import { SetupProvisioningProfile } from '../ios/actions/SetupProvisioningProfile';
|
||||
import { SetupTargetBuildCredentials } from '../ios/actions/SetupTargetBuildCredentials';
|
||||
import { UpdateCredentialsJson } from '../ios/actions/UpdateCredentialsJson';
|
||||
import { AppLookupParams } from '../ios/api/GraphqlClient';
|
||||
import { getManagedEntitlementsJsonAsync } from '../ios/appstore/entitlements';
|
||||
@@ -175,7 +175,7 @@ export class ManageIos implements Action {
|
||||
}
|
||||
} else if (actionInfo.scope === Scope.Project) {
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const easJsonReader = await new EasJsonReader(ctx.projectDir, 'ios');
|
||||
const easJsonReader = new EasJsonReader(ctx.projectDir, 'ios');
|
||||
const easConfig = await new SelectBuildProfileFromEasJson(easJsonReader).runAsync(ctx);
|
||||
await this.runProjectSpecificActionAsync(
|
||||
manager,
|
||||
@@ -224,7 +224,7 @@ export class ManageIos implements Action {
|
||||
if (!iosDistributionTypeEasConfig) {
|
||||
throw new Error(`The distributionType field is required in your iOS build profile`);
|
||||
}
|
||||
await new SetupBuildCredentials({
|
||||
await new SetupTargetBuildCredentials({
|
||||
app: appLookupParams,
|
||||
distribution: iosDistributionTypeEasConfig,
|
||||
iosCapabilitiesOptions: {
|
||||
|
||||
@@ -5,7 +5,10 @@ import path from 'path';
|
||||
|
||||
import { asMock } from '../../../__tests__/utils';
|
||||
import { promptAsync } from '../../../prompts';
|
||||
import { getBundleIdentifier, getOrConfigureBundleIdentifierAsync } from '../bundleIdentifier';
|
||||
import {
|
||||
ensureBundleIdentifierIsDefinedForManagedProjectAsync,
|
||||
getBundleIdentifier,
|
||||
} from '../bundleIdentifier';
|
||||
|
||||
jest.mock('fs');
|
||||
jest.mock('../../../prompts');
|
||||
@@ -87,7 +90,7 @@ describe(getBundleIdentifier, () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe(getOrConfigureBundleIdentifierAsync, () => {
|
||||
describe(ensureBundleIdentifierIsDefinedForManagedProjectAsync, () => {
|
||||
describe('managed project + ios.bundleIdentifier missing in app config', () => {
|
||||
it('throws an error if using app.config.js', async () => {
|
||||
vol.fromJSON(
|
||||
@@ -96,9 +99,9 @@ describe(getOrConfigureBundleIdentifierAsync, () => {
|
||||
},
|
||||
'/app'
|
||||
);
|
||||
await expect(getOrConfigureBundleIdentifierAsync('/app', {} as any)).rejects.toThrowError(
|
||||
/we can't update this file programatically/
|
||||
);
|
||||
await expect(
|
||||
ensureBundleIdentifierIsDefinedForManagedProjectAsync('/app', {} as any)
|
||||
).rejects.toThrowError(/we can't update this file programatically/);
|
||||
});
|
||||
it('prompts for the bundle identifier if using app.json', async () => {
|
||||
vol.fromJSON(
|
||||
@@ -112,9 +115,9 @@ describe(getOrConfigureBundleIdentifierAsync, () => {
|
||||
bundleIdentifier: 'com.expo.notdominik',
|
||||
}));
|
||||
|
||||
await expect(getOrConfigureBundleIdentifierAsync('/app', {} as any)).resolves.toBe(
|
||||
'com.expo.notdominik'
|
||||
);
|
||||
await expect(
|
||||
ensureBundleIdentifierIsDefinedForManagedProjectAsync('/app', {} as any)
|
||||
).resolves.toBe('com.expo.notdominik');
|
||||
expect(promptAsync).toHaveBeenCalled();
|
||||
});
|
||||
it('puts the bundle identifier in app.json', async () => {
|
||||
@@ -129,9 +132,9 @@ describe(getOrConfigureBundleIdentifierAsync, () => {
|
||||
bundleIdentifier: 'com.expo.notdominik',
|
||||
}));
|
||||
|
||||
await expect(getOrConfigureBundleIdentifierAsync('/app', {} as any)).resolves.toBe(
|
||||
'com.expo.notdominik'
|
||||
);
|
||||
await expect(
|
||||
ensureBundleIdentifierIsDefinedForManagedProjectAsync('/app', {} as any)
|
||||
).resolves.toBe('com.expo.notdominik');
|
||||
expect(JSON.parse(fs.readFileSync('/app/app.json', 'utf-8'))).toMatchObject({
|
||||
expo: { ios: { bundleIdentifier: 'com.expo.notdominik' } },
|
||||
});
|
||||
|
||||
@@ -4,39 +4,62 @@ import { Platform, Workflow } from '@expo/eas-build-job';
|
||||
import assert from 'assert';
|
||||
import fs from 'fs-extra';
|
||||
import once from 'lodash/once';
|
||||
import nullthrows from 'nullthrows';
|
||||
|
||||
import Log from '../../log';
|
||||
import { promptAsync } from '../../prompts';
|
||||
import { getProjectConfigDescription } from '../projectUtils';
|
||||
import { getProjectConfigDescription, sanitizedProjectName } from '../projectUtils';
|
||||
import { resolveWorkflow } from '../workflow';
|
||||
|
||||
const INVALID_BUNDLE_IDENTIFIER_MESSAGE = `Invalid format of iOS bundle identifier. Only alphanumeric characters, '.' and '-' are allowed, and each '.' must be followed by a letter.`;
|
||||
|
||||
export async function getOrConfigureBundleIdentifierAsync(
|
||||
export async function ensureBundleIdentifierIsDefinedForManagedProjectAsync(
|
||||
projectDir: string,
|
||||
exp: ExpoConfig
|
||||
): Promise<string> {
|
||||
const workflow = resolveWorkflow(projectDir, Platform.IOS);
|
||||
assert(workflow === Workflow.MANAGED, 'This function should be called only for managed projects');
|
||||
|
||||
try {
|
||||
return getBundleIdentifier(projectDir, exp);
|
||||
} catch (err) {
|
||||
const workflow = resolveWorkflow(projectDir, Platform.IOS);
|
||||
if (workflow === Workflow.MANAGED) {
|
||||
return await configureBundleIdentifierAsync(projectDir, exp);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
return await configureBundleIdentifierAsync(projectDir, exp);
|
||||
}
|
||||
}
|
||||
|
||||
export function getBundleIdentifier(projectDir: string, exp: ExpoConfig): string {
|
||||
export function getBundleIdentifier(
|
||||
projectDir: string,
|
||||
exp: ExpoConfig,
|
||||
{ targetName, buildConfiguration }: { targetName?: string; buildConfiguration?: string } = {}
|
||||
): string {
|
||||
const workflow = resolveWorkflow(projectDir, Platform.IOS);
|
||||
if (workflow === Workflow.GENERIC) {
|
||||
warnIfBundleIdentifierDefinedInAppConfigForGenericProject(projectDir, exp);
|
||||
|
||||
const bundleIdentifier = IOSConfig.BundleIdentifier.getBundleIdentifierFromPbxproj(projectDir);
|
||||
return nullthrows(bundleIdentifier, 'Could not read bundle identifier from Xcode project.');
|
||||
const bundleIdentifier = IOSConfig.BundleIdentifier.getBundleIdentifierFromPbxproj(projectDir, {
|
||||
targetName,
|
||||
buildConfiguration,
|
||||
});
|
||||
const buildConfigurationDesc =
|
||||
targetName && buildConfiguration
|
||||
? ` (target = ${targetName}, build configuration = ${buildConfiguration})`
|
||||
: '';
|
||||
assert(
|
||||
bundleIdentifier,
|
||||
`Could not read bundle identifier from Xcode project${buildConfigurationDesc}.`
|
||||
);
|
||||
if (!isBundleIdentifierValid(bundleIdentifier)) {
|
||||
throw new Error(
|
||||
`Bundle identifier "${bundleIdentifier}" is not valid${buildConfigurationDesc}. Open the project in Xcode to fix it.`
|
||||
);
|
||||
}
|
||||
return bundleIdentifier;
|
||||
} else {
|
||||
// TODO: the following asserts are only temporary until we support app extensions in managed projects
|
||||
assert(
|
||||
!targetName || targetName === sanitizedProjectName(exp.name),
|
||||
'targetName cannot be set to an arbitrary value for managed projects'
|
||||
);
|
||||
assert(!buildConfiguration, 'buildConfiguration cannot be passed for managed projects');
|
||||
const bundleIdentifer = IOSConfig.BundleIdentifier.getBundleIdentifier(exp);
|
||||
if (!bundleIdentifer || !isBundleIdentifierValid(bundleIdentifer)) {
|
||||
if (bundleIdentifer) {
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import { ExpoConfig } from '@expo/config';
|
||||
import { IOSConfig } from '@expo/config-plugins';
|
||||
import { Platform, Workflow } from '@expo/eas-build-job';
|
||||
|
||||
import { Target } from '../../credentials/ios/types';
|
||||
import { resolveWorkflow } from '../workflow';
|
||||
import { getBundleIdentifier } from './bundleIdentifier';
|
||||
|
||||
export interface XcodeBuildContext {
|
||||
buildScheme: string;
|
||||
buildConfiguration?: string;
|
||||
applicationTarget?: string;
|
||||
}
|
||||
|
||||
export async function resolveTargetsAsync(
|
||||
{ exp, projectDir }: { exp: ExpoConfig; projectDir: string },
|
||||
{ buildConfiguration, buildScheme }: XcodeBuildContext
|
||||
): Promise<Target[]> {
|
||||
const result: Target[] = [];
|
||||
|
||||
const applicationTarget = await getApplicationTargetAsync(projectDir, buildScheme);
|
||||
const bundleIdentifier = getBundleIdentifier(projectDir, exp, {
|
||||
targetName: applicationTarget.name,
|
||||
buildConfiguration,
|
||||
});
|
||||
result.push({
|
||||
targetName: applicationTarget.name,
|
||||
bundleIdentifier,
|
||||
});
|
||||
|
||||
if (applicationTarget.dependencies && applicationTarget.dependencies.length > 0) {
|
||||
for (const dependency of applicationTarget.dependencies) {
|
||||
result.push({
|
||||
targetName: dependency.name,
|
||||
bundleIdentifier: getBundleIdentifier(projectDir, exp, {
|
||||
targetName: dependency.name,
|
||||
buildConfiguration,
|
||||
}),
|
||||
parentBundleIdentifier: bundleIdentifier,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async function getApplicationTargetAsync(
|
||||
projectDir: string,
|
||||
scheme: string
|
||||
): Promise<IOSConfig.Target.Target> {
|
||||
const workflow = resolveWorkflow(projectDir, Platform.IOS);
|
||||
if (workflow === Workflow.GENERIC) {
|
||||
return await IOSConfig.Target.findApplicationTargetWithDependenciesAsync(projectDir, scheme);
|
||||
} else {
|
||||
return {
|
||||
name: scheme,
|
||||
type: IOSConfig.Target.TargetType.APPLICATION,
|
||||
dependencies: [],
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -216,3 +216,12 @@ export async function getBranchByNameAsync({
|
||||
);
|
||||
return data.app.byId.updateBranchByName;
|
||||
}
|
||||
|
||||
// copy-pasted from expo-cli
|
||||
// https://github.com/expo/expo-cli/blob/master/packages/expo-cli/src/utils/extractTemplateAppAsync.ts#L15
|
||||
export function sanitizedProjectName(name: string) {
|
||||
return name
|
||||
.replace(/[\W_]+/g, '')
|
||||
.normalize('NFD')
|
||||
.replace(/[\u0300-\u036f]/g, '');
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@expo/eas-json",
|
||||
"description": "A library for interacting with the eas.json",
|
||||
"version": "0.15.1",
|
||||
"version": "0.16.0",
|
||||
"author": "Expo <[email protected]>",
|
||||
"bugs": "https://github.com/expo/eas-cli/issues",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1856,6 +1856,25 @@
|
||||
xcode "^3.0.1"
|
||||
xml2js "^0.4.23"
|
||||
|
||||
"@expo/[email protected]":
|
||||
version "1.0.33"
|
||||
resolved "https://registry.yarnpkg.com/@expo/config-plugins/-/config-plugins-1.0.33.tgz#8ee78ea6f939f7e04606e9afa22b32139ea974a0"
|
||||
integrity sha512-YQJop0c69LKD/6ZJJto7klS7TDmzgs44TI0Z5RBqesOjYlDwNFcQk2Rl2BaA1wlAYkH+rRrhN2+WjjSyD9HiPg==
|
||||
dependencies:
|
||||
"@expo/config-types" "^40.0.0-beta.2"
|
||||
"@expo/configure-splash-screen" "0.4.0"
|
||||
"@expo/image-utils" "0.3.14"
|
||||
"@expo/json-file" "8.2.30"
|
||||
"@expo/plist" "0.0.13"
|
||||
find-up "~5.0.0"
|
||||
fs-extra "9.0.0"
|
||||
getenv "^1.0.0"
|
||||
glob "7.1.6"
|
||||
resolve-from "^5.0.0"
|
||||
slash "^3.0.0"
|
||||
xcode "^3.0.1"
|
||||
xml2js "^0.4.23"
|
||||
|
||||
"@expo/config-types@^40.0.0-beta.2":
|
||||
version "40.0.0-beta.2"
|
||||
resolved "https://registry.yarnpkg.com/@expo/config-types/-/config-types-40.0.0-beta.2.tgz#4fea4ef5654d02218b02b0b3772529a9ce5b0471"
|
||||
|
||||
Reference in new issue
Block a user