Compare commits

...
20 Commits
Author SHA1 Message Date
Dominik Sokal 34563070f4 v0.17.0 2021-06-02 12:07:46 +02:00
Dominik Sokal 66b269f4bf update CHANGELOG 2021-06-02 12:06:41 +02:00
Brent Vatne 168cb4d4a0 [eas-cli] Fix git repo root path on Windows (#429)
* Fix git repo root path on Windows

* Update CHANGELOG
2021-06-02 12:03:33 +02:00
Quinlan Jung 91b531da43 [eas-cli] use correct method to determine android application identifier (#431)
* [eas-cli] use correct method to determine android application identifier

* pr feedback
2021-06-02 12:00:51 +02:00
Quinlan Jung 2e0d567361 update changelog 2021-06-01 11:59:51 -07:00
Quinlan Jung 81e6280cff [eas-cli] use new android build credentials provider (#427)
* [eas-cli] use new android build credentials provider

* pr feedback

* fix tsc

* pr feedback:
2021-06-01 11:56:37 -07:00
Quinlan Jung e2fda7b9d3 [eas-cli] refactor application id configuration (#432) 2021-06-01 10:34:08 -07:00
Dominik Sokal ede30807f5 fix bundle identifier getter (#434)
* fix bundle identifier getter

* update CHANGELOG
2021-06-01 14:25:03 +02:00
Brent Vatne 9f354013fa Update CHANGELOG 2021-05-26 15:09:59 -07:00
Brent Vatne 30552f134c v0.16.0 2021-05-26 14:49:42 -07:00
Brent Vatne e4beba9a21 Add env var to disable capability sync and extra logs when EXPO_DEBUG is set (#426) 2021-05-26 13:11:42 -07:00
Dominik Sokal b71ab7ec84 implement managed credentials support for multitarget iOS projects (#414)
* ignore --skip-credentials-check flag for ios builds

* account for parent bundle identifier when creating apple app identifier

* implement managed credentials support for multitarget ios projects

* update CHANGELOG.md

* address PR feedback

* upgrade @expo/config-plugins 1.0.32 -> 1.0.33

* fix lint warning

* address more PR feedback

* address PR feedback
2021-05-26 11:06:29 +02:00
Brent Vatne 596cfc372b Move updating the release on Github to after the release is completed (#418) 2021-05-25 15:56:55 +02:00
Dominik Sokal d5f6c5680c update CHANGELOG 2021-05-25 15:55:23 +02:00
Dominik Sokal 28c508ff62 v0.15.1 2021-05-25 15:44:36 +02:00
Dominik Sokal 97ff6f406d fix sending appBuildVersion to api (#423)
* generate graphql code

* fix sending appBuildVersion to api

* update CHANGELOG
2021-05-25 15:40:22 +02:00
Evan Bacon bd39b296fa Use config introspection to get all entitlements (#419)
* Use config introspection to get all entitlements

* Update CHANGELOG.md

* Updated getAppBuildGradle -> getAppBuildGradleFilePath

* Update RemoveProvisioningProfile.ts

* Update view.ts

* Update applicationId.ts

* Update entitlements.ts
2021-05-24 17:30:13 -07:00
Quinlan Jung bfbe1e930b [eas-cli] add tests for unencrypted/empty password keystores (#396)
* [eas-cli] add tests for unencrypted/empty password keystores

* detect unencrypted pem

* much sad

* much sad 2

* much sad

* much sad
2021-05-24 16:25:07 -07:00
jkh 3fe45176cc [eas-cli] make republish work smoothly with different platforms (#417) 2021-05-21 10:11:57 -07:00
Test User bffa6fbf03 Release 0.15.0 2021-05-20 14:58:23 -07:00
48 changed files with 1896 additions and 468 deletions

No files matched your search

+35 -3
View File
@@ -6,6 +6,40 @@ This is the log of notable changes to EAS CLI and related packages.
### 🛠 Breaking changes
### 🎉 New features
### 🐛 Bug fixes
- Fix bundle identifier resolution when native target is not provided. ([#434](https://github.com/expo/eas-cli/pull/434) by [@dsokal](https://github.com/dsokal))
- Fix git repo root path getter on Windows. ([#429](https://github.com/expo/eas-cli/pull/429) by [@brentvatne](https://github.com/brentvatne))
- Fix resolving Android application identifier. ([#431](https://github.com/expo/eas-cli/pull/431) by [@quinlanj](https://github.com/quinlanj))
### 🧹 Chores
- Android credentials setup now on Graphql API. ([#434](https://github.com/expo/eas-cli/pull/427) by [@quinlanj](https://github.com/quinlanj))
## [0.16.0](https://github.com/expo/eas-cli/releases/tag/v0.16.0) - 2021-05-26
### 🎉 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))
## [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))
## [0.15.0](https://github.com/expo/eas-cli/releases/tag/v0.15.0) - 2021-05-20
### 🛠 Breaking changes
- `[EAS BUILD API]` Remove "Auto" option for `schemeBuildConfiguration` and make the old "Auto" behaviour the default. ([#394](https://github.com/expo/eas-cli/pull/394) by [@randomhajile](https://github.com/randomhajile))
- Remove `experimental.disableIosBundleIdentifierValidation` flag from eas.json. ([#407](https://github.com/expo/eas-cli/pull/407) by [@dsokal](https://github.com/dsokal))
- Deprecate `android.package` and `ios.bundleIdentifier` in app config for generic projects. EAS CLI depends on the values in native code now. ([#407](https://github.com/expo/eas-cli/pull/407) by [@dsokal](https://github.com/dsokal))
@@ -23,13 +57,11 @@ This is the log of notable changes to EAS CLI and related packages.
### 🐛 Bug fixes
- Fix failure when publishing without the platform flag. ([#415](https://github.com/expo/eas-cli/pull/415) by [@jkhales](https://github.com/jkhales))
- Fix failure when publishing without the platform flag. ([#415](https://github.com/expo/eas-cli/pull/415) by [@jkhales](https://github.com/jkhales))
- Pin versions in package.json. ([#399](https://github.com/expo/eas-cli/pull/399) by [@dsokal](https://github.com/dsokal))
- Revert [0ac2f](https://github.com/expo/eas-cli/commit/0ac2fb77a118df609381c4e350aa68609340c3cd) as the root cause of the issue has been fixed in [#399](https://github.com/expo/eas-cli/pull/399).
- Include development-client in valid buildType for internal distribution. ([#410](https://github.com/expo/eas-cli/pull/410) by [@brentvatne](https://github.com/brentvatne))
### 🧹 Chores
## [0.14.1](https://github.com/expo/eas-cli/releases/tag/v0.14.1) - 2021-05-11
### 🐛 Bug fixes
+4 -4
View File
@@ -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.**
![Wait for all three jobs to complete](./.gh-assets/release-workflow.png)
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.
![There are 5 assets for each release](./.gh-assets/draft-release.png)
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.
![There are 5 assets for each release](./.gh-assets/draft-release.png)
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
View File
@@ -1,5 +1,5 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.15.0"
"version": "0.17.0"
}
+24 -23
View File
@@ -69,7 +69,7 @@ ALIASES
$ eas login
```
_See code: [build/commands/account/login.ts](https://github.com/expo/eas-cli/blob/v0.15.0/build/commands/account/login.ts)_
_See code: [build/commands/account/login.ts](https://github.com/expo/eas-cli/blob/v0.17.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.0/build/commands/account/logout.ts)_
_See code: [build/commands/account/logout.ts](https://github.com/expo/eas-cli/blob/v0.17.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.0/build/commands/account/view.ts)_
_See code: [build/commands/account/view.ts](https://github.com/expo/eas-cli/blob/v0.17.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.0/build/commands/analytics.ts)_
_See code: [build/commands/analytics.ts](https://github.com/expo/eas-cli/blob/v0.17.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.0/build/commands/build/index.ts)_
_See code: [build/commands/build/index.ts](https://github.com/expo/eas-cli/blob/v0.17.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.0/build/commands/build/cancel.ts)_
_See code: [build/commands/build/cancel.ts](https://github.com/expo/eas-cli/blob/v0.17.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.0/build/commands/build/configure.ts)_
_See code: [build/commands/build/configure.ts](https://github.com/expo/eas-cli/blob/v0.17.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.0/build/commands/build/list.ts)_
_See code: [build/commands/build/list.ts](https://github.com/expo/eas-cli/blob/v0.17.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.0/build/commands/build/view.ts)_
_See code: [build/commands/build/view.ts](https://github.com/expo/eas-cli/blob/v0.17.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.0/build/commands/credentials.ts)_
_See code: [build/commands/credentials.ts](https://github.com/expo/eas-cli/blob/v0.17.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.0/build/commands/device/create.ts)_
_See code: [build/commands/device/create.ts](https://github.com/expo/eas-cli/blob/v0.17.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.0/build/commands/device/list.ts)_
_See code: [build/commands/device/list.ts](https://github.com/expo/eas-cli/blob/v0.17.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.0/build/commands/device/view.ts)_
_See code: [build/commands/device/view.ts](https://github.com/expo/eas-cli/blob/v0.17.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.0/build/commands/secret/create.ts)_
_See code: [build/commands/secret/create.ts](https://github.com/expo/eas-cli/blob/v0.17.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.0/build/commands/secret/delete.ts)_
_See code: [build/commands/secret/delete.ts](https://github.com/expo/eas-cli/blob/v0.17.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.0/build/commands/secret/list.ts)_
_See code: [build/commands/secret/list.ts](https://github.com/expo/eas-cli/blob/v0.17.0/build/commands/secret/list.ts)_
## `eas submit --platform=(android|ios)`
@@ -316,7 +316,8 @@ 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.
app creation step. Learn more:
https://expo.fyi/asc-app-id
iOS specific options=bundle-identifier Your iOS Bundle Identifier (default:
expo.ios.bundleIdentifier from app config)
@@ -369,7 +370,7 @@ EXAMPLES
and provide its App ID
```
_See code: [build/commands/submit.ts](https://github.com/expo/eas-cli/blob/v0.15.0/build/commands/submit.ts)_
_See code: [build/commands/submit.ts](https://github.com/expo/eas-cli/blob/v0.17.0/build/commands/submit.ts)_
## `eas webhook:create`
@@ -388,7 +389,7 @@ OPTIONS
--url=url Webhook URL
```
_See code: [build/commands/webhook/create.ts](https://github.com/expo/eas-cli/blob/v0.15.0/build/commands/webhook/create.ts)_
_See code: [build/commands/webhook/create.ts](https://github.com/expo/eas-cli/blob/v0.17.0/build/commands/webhook/create.ts)_
## `eas webhook:delete [ID]`
@@ -402,7 +403,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.0/build/commands/webhook/delete.ts)_
_See code: [build/commands/webhook/delete.ts](https://github.com/expo/eas-cli/blob/v0.17.0/build/commands/webhook/delete.ts)_
## `eas webhook:list`
@@ -416,7 +417,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.0/build/commands/webhook/list.ts)_
_See code: [build/commands/webhook/list.ts](https://github.com/expo/eas-cli/blob/v0.17.0/build/commands/webhook/list.ts)_
## `eas webhook:update`
@@ -436,7 +437,7 @@ OPTIONS
--url=url Webhook URL
```
_See code: [build/commands/webhook/update.ts](https://github.com/expo/eas-cli/blob/v0.15.0/build/commands/webhook/update.ts)_
_See code: [build/commands/webhook/update.ts](https://github.com/expo/eas-cli/blob/v0.17.0/build/commands/webhook/update.ts)_
## `eas webhook:view ID`
@@ -450,5 +451,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.0/build/commands/webhook/view.ts)_
_See code: [build/commands/webhook/view.ts](https://github.com/expo/eas-cli/blob/v0.17.0/build/commands/webhook/view.ts)_
<!-- commandsstop -->
+282
View File
@@ -1884,6 +1884,30 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "appleAppSpecificPasswords",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "AppleAppSpecificPassword",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "environmentSecrets",
"description": "Environment secrets for an account",
@@ -4100,6 +4124,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "appBuildVersion",
"description": "",
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "sdkVersion",
"description": "",
@@ -6703,6 +6739,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "appSpecificPassword",
"description": "",
"args": [],
"type": {
"kind": "OBJECT",
"name": "AppleAppSpecificPassword",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "iosAppBuildCredentialsArray",
"description": "",
@@ -7878,6 +7926,109 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "AppleAppSpecificPassword",
"description": "",
"fields": [
{
"name": "id",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "account",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Account",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "appleIdUsername",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "passwordLabel",
"description": "",
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "createdAt",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "DateTime",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "updatedAt",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "DateTime",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "AndroidAppCredentialsFilter",
@@ -11711,6 +11862,22 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "appleAppSpecificPassword",
"description": "Mutations that modify an App Specific Password for an Apple User Account",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "AppleAppSpecificPasswordMutation",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "appleDevice",
"description": "Mutations that modify an Apple Device",
@@ -13742,6 +13909,111 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "AppleAppSpecificPasswordMutation",
"description": "",
"fields": [
{
"name": "createAppleAppSpecificPassword",
"description": "Create an App Specific Password for an Apple User Account",
"args": [
{
"name": "appleAppSpecificPasswordInput",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "INPUT_OBJECT",
"name": "AppleAppSpecificPasswordInput",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "accountId",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"defaultValue": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "AppleAppSpecificPassword",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "AppleAppSpecificPasswordInput",
"description": "",
"fields": null,
"inputFields": [
{
"name": "appleIdUsername",
"description": "",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "passwordLabel",
"description": "",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "appSpecificPassword",
"description": "",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "AppleDeviceMutation",
@@ -15712,6 +15984,16 @@
},
"defaultValue": null
},
{
"name": "appBuildVersion",
"description": "",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "cliVersion",
"description": "",
+6 -5
View File
@@ -1,7 +1,7 @@
{
"name": "eas-cli",
"description": "EAS command line tool",
"version": "0.15.0",
"version": "0.17.0",
"author": "Expo <[email protected]>",
"bin": {
"eas": "./bin/run"
@@ -11,10 +11,10 @@
"@amplitude/identify": "1.5.0",
"@amplitude/node": "1.5.0",
"@expo/apple-utils": "0.0.0-alpha.20",
"@expo/config": "3.3.19",
"@expo/config-plugins": "1.0.31",
"@expo/config": "3.3.42",
"@expo/config-plugins": "2.0.2",
"@expo/eas-build-job": "0.2.35",
"@expo/eas-json": "^0.15.0",
"@expo/eas-json": "^0.17.0",
"@expo/json-file": "8.2.25",
"@expo/pkcs12": "0.0.4",
"@expo/plist": "0.0.11",
@@ -174,5 +174,6 @@
"version": "yarn oclif-dev readme && git add README.md",
"generate-graphql-code": "graphql-codegen --config graphql-codegen.yml"
},
"types": "build/index.d.ts"
"types": "build/index.d.ts",
"gitHead": "161808bc37c255fdea6801d69d23dbc725c056c3"
}
@@ -10,7 +10,7 @@ import { ensureValidVersions } from '../utils/updates';
export async function configureUpdatesAsync(projectDir: string, exp: ExpoConfig): Promise<void> {
ensureValidVersions(exp);
const accountName = getProjectAccountName(exp, await ensureLoggedInAsync());
const buildGradlePath = AndroidConfig.Paths.getAppBuildGradle(projectDir);
const buildGradlePath = AndroidConfig.Paths.getAppBuildGradleFilePath(projectDir);
const buildGradleContents = await fs.readFile(buildGradlePath, 'utf8');
if (!AndroidConfig.Updates.isBuildGradleConfigured(projectDir, buildGradleContents)) {
@@ -70,7 +70,7 @@ export async function syncUpdatesConfigurationAsync(
}
async function ensureUpdatesConfiguredAsync(projectDir: string, exp: ExpoConfig): Promise<void> {
const buildGradlePath = AndroidConfig.Paths.getAppBuildGradle(projectDir);
const buildGradlePath = AndroidConfig.Paths.getAppBuildGradleFilePath(projectDir);
const buildGradleContents = await fs.readFile(buildGradlePath, 'utf8');
if (!AndroidConfig.Updates.isBuildGradleConfigured(projectDir, buildGradleContents)) {
+18 -5
View File
@@ -2,6 +2,7 @@ import { Android, Metadata, Workflow } from '@expo/eas-build-job';
import { EasConfig } from '@expo/eas-json';
import chalk from 'chalk';
import fs from 'fs-extra';
import nullthrows from 'nullthrows';
import path from 'path';
import AndroidCredentialsProvider, {
@@ -10,8 +11,12 @@ import AndroidCredentialsProvider, {
import { createCredentialsContextAsync } from '../../credentials/context';
import { BuildMutation, BuildResult } from '../../graphql/mutations/BuildMutation';
import Log from '../../log';
import { getOrConfigureApplicationIdAsync } from '../../project/android/applicationId';
import {
ensureApplicationIdIsDefinedForManagedProjectAsync,
getApplicationId,
} from '../../project/android/applicationId';
import { toggleConfirmAsync } from '../../prompts';
import { findAccountByName } from '../../user/Account';
import { CredentialsResult, prepareBuildRequestForPlatformAsync } from '../build';
import { BuildContext, CommandContext, createBuildContext } from '../context';
import { transformMetadata } from '../graphql';
@@ -63,12 +68,12 @@ This means that it will most likely produce an AAB and you will not be able to i
}
}
// this function throws if application id is invalid
await getOrConfigureApplicationIdAsync(commandCtx.projectDir, commandCtx.exp);
if (buildCtx.buildProfile.workflow === Workflow.MANAGED) {
await ensureApplicationIdIsDefinedForManagedProjectAsync(commandCtx.projectDir, commandCtx.exp);
}
return await prepareBuildRequestForPlatformAsync({
ctx: buildCtx,
projectConfiguration: {},
ensureCredentialsAsync: ensureAndroidCredentialsAsync,
ensureProjectConfiguredAsync: async () => {
if (buildCtx.buildProfile.workflow === Workflow.GENERIC) {
@@ -114,14 +119,22 @@ async function ensureAndroidCredentialsAsync(
if (!shouldProvideCredentials(ctx)) {
return;
}
const androidApplicationIdentifier = getApplicationId(
ctx.commandCtx.projectDir,
ctx.commandCtx.exp
);
const provider = new AndroidCredentialsProvider(
await createCredentialsContextAsync(ctx.commandCtx.projectDir, {
nonInteractive: ctx.commandCtx.nonInteractive,
}),
{
app: {
account: nullthrows(
findAccountByName(ctx.commandCtx.user.accounts, ctx.commandCtx.accountName),
`You do not have access to account: ${ctx.commandCtx.accountName}`
),
projectName: ctx.commandCtx.projectName,
accountName: ctx.commandCtx.accountName,
androidApplicationIdentifier,
},
skipCredentialsCheck: ctx.commandCtx.skipCredentialsCheck,
}
@@ -3,7 +3,7 @@ import { AndroidConfig } from '@expo/config-plugins';
import Log from '../../log';
import {
getOrConfigureApplicationIdAsync,
ensureApplicationIdIsDefinedForManagedProjectAsync,
warnIfAndroidPackageDefinedInAppConfigForGenericProject,
} from '../../project/android/applicationId';
import { gitAddAsync } from '../../utils/git';
@@ -13,7 +13,7 @@ import { configureUpdatesAsync, syncUpdatesConfigurationAsync } from './UpdatesM
export async function configureAndroidAsync(ctx: ConfigureContext): Promise<void> {
if (!ctx.hasAndroidNativeProject) {
await getOrConfigureApplicationIdAsync(ctx.projectDir, ctx.exp);
await ensureApplicationIdIsDefinedForManagedProjectAsync(ctx.projectDir, ctx.exp);
return;
}
@@ -36,7 +36,7 @@ export function readVersionName(projectDir: string, exp: ExpoConfig): string | u
}
function readBuildGradle(projectDir: string): string | undefined {
const buildGradlePath = AndroidConfig.Paths.getAppBuildGradle(projectDir);
const buildGradlePath = AndroidConfig.Paths.getAppBuildGradleFilePath(projectDir);
if (!fs.pathExistsSync(buildGradlePath)) {
return undefined;
}
+10 -22
View File
@@ -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 -9
View File
@@ -27,18 +27,10 @@ export function transformProjectArchive(archiveSource: ArchiveSource): ProjectAr
export function transformMetadata(metadata: Metadata): BuildMetadataInput {
return {
appIdentifier: metadata.appIdentifier,
appName: metadata.appName,
appVersion: metadata.appVersion,
buildProfile: metadata.buildProfile,
cliVersion: metadata.cliVersion,
...metadata,
credentialsSource:
metadata.credentialsSource && transformCredentialsSource(metadata.credentialsSource),
distribution: metadata.distribution && transformDistribution(metadata.distribution),
gitCommitHash: metadata.gitCommitHash,
releaseChannel: metadata.releaseChannel,
sdkVersion: metadata.sdkVersion,
trackingContext: metadata.trackingContext,
workflow: metadata.workflow && transformWorkflow(metadata.workflow),
};
}
+60 -26
View File
@@ -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) {
+2 -2
View File
@@ -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;
}
+28 -53
View File
@@ -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';
}
+13 -44
View File
@@ -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, '');
}
+13 -1
View File
@@ -123,7 +123,7 @@ async function makeProjectTarballAsync(): Promise<{ path: string; size: number }
'--no-hardlinks',
'--depth',
'1',
`file://${await gitRootDirectoryAsync()}`,
await getGitRootFullPathAsync(),
shallowClonePath,
]);
await tar.create({ cwd: shallowClonePath, file: tarPath, prefix: 'project', gzip: true }, [
@@ -152,6 +152,18 @@ async function makeProjectTarballAsync(): Promise<{ path: string; size: number }
return { size, path: tarPath };
}
async function getGitRootFullPathAsync() {
if (process.platform === 'win32') {
// getRootDirectoryAsync() will return C:/path/to/repo on Windows and path
// prefix should be file:///
return `file:///${await gitRootDirectoryAsync()}`;
} else {
// getRootDirectoryAsync() will /path/to/repo, and path prefix should be
// file:/// so only file:// needs to be prepended
return `file://${await gitRootDirectoryAsync()}`;
}
}
async function showDiffAsync() {
const outputTooLarge = (await getGitDiffOutputAsync()).split(/\r\n|\r|\n/).length > 100;
await gitDiffAsync({ withPager: outputTooLarge });
+45 -20
View File
@@ -192,43 +192,68 @@ export default class BranchPublish extends Command {
if (group) {
updatesToRepublish = await getUpdateGroupAsync({ group });
} else {
const updateGroups = uniqBy(updates, u => u.group).map(update => ({
title: formatUpdateTitle(update),
value: update.group,
}));
// Drop into interactive mode if the user has not specified an update group to republish.
if (jsonFlag) {
throw new Error('You must specify the update group to republish.');
}
const updateGroups = uniqBy(updates, u => u.group)
.filter(update => {
// Only show groups that have updates on the specified platform(s).
return platformFlag === 'all' || update.platform === platformFlag;
})
.map(update => ({
title: formatUpdateTitle(update),
value: update.group,
}));
if (updateGroups.length === 0) {
throw new Error(
`There are no updates on branch "${name}". Did you mean to do a regular publish?`
`There are no updates on branch "${name}" published on the platform(s) ${platformFlag}. Did you mean to publish a new update instead?`
);
}
const updateGroup = await selectAsync<string>(
const selectedUpdateGroup = await selectAsync<string>(
'which update would you like to republish?',
updateGroups
);
updatesToRepublish = updates.filter(update => update.group === updateGroup);
updatesToRepublish = updates.filter(update => update.group === selectedUpdateGroup);
}
const updatesToRepublishFilteredByPlatform = updatesToRepublish.filter(
// Only republish to the specified platforms
update => platformFlag === 'all' || update.platform === platformFlag
);
if (updatesToRepublishFilteredByPlatform.length === 0) {
throw new Error(
`There are no updates on branch "${name}" published on the platform(s) "${platformFlag}" with group ID "${
group ? group : updatesToRepublish[0].group
}". Did you mean to publish a new update instead?`
);
}
if (updatesToRepublish.length === 0) {
throw new Error(`There are no updates in this group`);
let publicationPlatformMessage: string;
if (platformFlag === 'all') {
if (updatesToRepublishFilteredByPlatform.length !== defaultPublishPlatforms.length) {
Log.warn(`You are republishing an update that wasn't published for all platforms.`);
}
publicationPlatformMessage = `The republished update will appear on the same plaforms it was originally published on: ${updatesToRepublishFilteredByPlatform
.map(update => update.platform)
.join(',')}`;
} else {
publicationPlatformMessage = `The republished update will appear only on: ${platformFlag}`;
}
Log.withTick(publicationPlatformMessage);
for (const update of updatesToRepublish) {
for (const update of updatesToRepublishFilteredByPlatform) {
const { manifestFragment } = update;
const platform = update.platform as PublishPlatform;
if (platformFlag === 'all' || platformFlag === platform) {
updateInfoGroup[platform] = JSON.parse(manifestFragment);
}
}
if (Object.keys(updateInfoGroup).length === 0) {
throw new Error(`There are no updates for platform ${platformFlag} in this group`);
updateInfoGroup[platform] = JSON.parse(manifestFragment);
}
// These are the same for each member of an update group
group = updatesToRepublish[0].group;
oldMessage = updatesToRepublish[0].message ?? '';
oldRuntimeVersion = updatesToRepublish[0].runtimeVersion;
group = updatesToRepublishFilteredByPlatform[0].group;
oldMessage = updatesToRepublishFilteredByPlatform[0].message ?? '';
oldRuntimeVersion = updatesToRepublishFilteredByPlatform[0].runtimeVersion;
} else {
// build bundle and upload assets for a new publish
if (!skipBundler) {
@@ -1,8 +1,8 @@
import { getConfig } from '@expo/config';
import { Command, flags } from '@oclif/command';
import assert from 'assert';
import chalk from 'chalk';
import Table from 'cli-table3';
import { assert } from 'console';
import gql from 'graphql-tag';
import { graphqlClient, withErrorHandlingAsync } from '../../graphql/client';
@@ -3,6 +3,7 @@ import {
testKeystore2Base64,
testKeystoreBase64,
testPKCS12KeystoreBase64,
testPKCS12KeystoreEmptyPasswordBase64,
} from './fixtures-base64-data';
import { testExperienceName, testJester2ExperienceName } from './fixtures-constants';
@@ -28,6 +29,16 @@ export const testPKCS12Keystore: Keystore = {
keyAlias: 'test-alias',
};
// openssl req -new -newkey rsa:4096 -nodes -keyout test.key -out test.csr
// openssl x509 -req -sha256 -days 365 -in test.csr -signkey test.key -out test.pem
// openssl pkcs12 -export -in test.pem -inkey test.key -name "test-alias" -passout pass: -out emptyPassword.p12
// cat emptyPassword.p12 | base64
export const testPKCS12EmptyPasswordKeystore: Keystore = {
keystore: testPKCS12KeystoreEmptyPasswordBase64,
keystorePassword: '',
keyAlias: 'test-alias',
};
export const testPushCredentials = {
fcmApiKey: 'examplefcmapikey',
};
@@ -1,21 +1,18 @@
import { Platform } from '@expo/eas-build-job';
import { CredentialsSource } from '@expo/eas-json';
import nullthrows from 'nullthrows';
import { CredentialsManager } from '../CredentialsManager';
import { AndroidAppBuildCredentialsFragment } from '../../graphql/generated';
import { Context } from '../context';
import * as credentialsJsonReader from '../credentialsJson/read';
import { SetupBuildCredentials } from './actions/SetupBuildCredentials';
import { SetupBuildCredentials } from './actions/new/SetupBuildCredentials';
import { AppLookupParams } from './api/GraphqlClient';
import { Keystore } from './credentials';
export interface AndroidCredentials {
keystore: Keystore;
}
interface AppLookupParams {
projectName: string;
accountName: string;
}
interface Options {
app: AppLookupParams;
skipCredentialsCheck?: boolean;
@@ -26,11 +23,6 @@ export default class AndroidCredentialsProvider {
constructor(private ctx: Context, private options: Options) {}
private get projectFullName(): string {
const { projectName, accountName } = this.options.app;
return `@${accountName}/${projectName}`;
}
public async getCredentialsAsync(
src: CredentialsSource.LOCAL | CredentialsSource.REMOTE
): Promise<AndroidCredentials> {
@@ -43,14 +35,22 @@ export default class AndroidCredentialsProvider {
}
private async getRemoteAsync(): Promise<AndroidCredentials> {
await new CredentialsManager(this.ctx).runActionAsync(
new SetupBuildCredentials(this.projectFullName)
);
const keystore = await this.ctx.android.fetchKeystoreAsync(this.projectFullName);
if (!keystore) {
throw new Error('Unable to set up credentials, failed to fetch keystore from EAS servers');
}
return { keystore };
const setupBuildCredentialsAction = await new SetupBuildCredentials({ app: this.options.app });
const buildCredentials = await setupBuildCredentialsAction.runAsync(this.ctx);
return this.toAndroidCredentials(buildCredentials);
}
private toAndroidCredentials(
androidBuildCredentials: AndroidAppBuildCredentialsFragment
): AndroidCredentials {
return {
keystore: {
keystore: nullthrows(androidBuildCredentials.androidKeystore?.keystore),
keystorePassword: nullthrows(androidBuildCredentials.androidKeystore?.keystorePassword),
keyAlias: nullthrows(androidBuildCredentials.androidKeystore?.keyAlias),
keyPassword: nullthrows(androidBuildCredentials.androidKeystore?.keyPassword),
},
};
}
private async getLocalAsync(): Promise<AndroidCredentials> {
@@ -2,6 +2,7 @@ import assert from 'assert';
import { nanoid } from 'nanoid';
import { AndroidAppBuildCredentialsFragment } from '../../../graphql/generated';
import { getApplicationId } from '../../../project/android/applicationId';
import { getProjectAccountName, getProjectConfigDescription } from '../../../project/projectUtils';
import { promptAsync } from '../../../prompts';
import { findAccountByName } from '../../../user/Account';
@@ -17,7 +18,7 @@ export function getAppLookupParamsFromContext(ctx: Context): AppLookupParams {
throw new Error(`You do not have access to account: ${accountName}`);
}
const androidApplicationIdentifier = ctx.exp.android?.package;
const androidApplicationIdentifier = getApplicationId(ctx.projectDir, ctx.exp);
if (!androidApplicationIdentifier) {
throw new Error(
`android.package needs to be defined in your ${getProjectConfigDescription(
@@ -1,5 +1,9 @@
import { AndroidKeystoreType } from '../../../../graphql/generated';
import { testKeystore, testPKCS12Keystore } from '../../../__tests__/fixtures-android';
import {
testKeystore,
testPKCS12EmptyPasswordKeystore,
testPKCS12Keystore,
} from '../../../__tests__/fixtures-android';
import { getKeystoreType, getKeystoreWithType, validateKeystore } from '../keystoreNew';
describe('getKeystoreType', () => {
@@ -34,6 +38,7 @@ describe('getKeystoreType', () => {
describe('validateKeystore', () => {
it('validates a correctly formatted jks keystore', async () => {
const keystoreWithType = getKeystoreWithType(testKeystore);
expect(keystoreWithType.type).toBe(AndroidKeystoreType.Jks);
expect(() => validateKeystore(keystoreWithType)).not.toThrow();
});
it('doesnt validate a jks keystore with wrong alias', async () => {
@@ -52,6 +57,7 @@ describe('validateKeystore', () => {
});
it('validates a correctly formatted pkcs 12 keystore', async () => {
const keystoreWithType = getKeystoreWithType(testPKCS12Keystore);
expect(keystoreWithType.type).toBe(AndroidKeystoreType.Pkcs12);
expect(() => validateKeystore(keystoreWithType)).not.toThrow();
});
it('doesnt validate a PKCS 12 keystore with wrong alias', async () => {
@@ -61,4 +67,9 @@ describe('validateKeystore', () => {
});
expect(() => validateKeystore(keystoreWithType)).toThrow();
});
it('validates an PKCS 12 Keystore with an empty password', async () => {
const keystoreWithType = getKeystoreWithType(testPKCS12EmptyPasswordKeystore);
expect(keystoreWithType.type).toBe(AndroidKeystoreType.Pkcs12);
expect(() => validateKeystore(keystoreWithType)).not.toThrow();
});
});
@@ -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,
}
);
});
@@ -1,4 +1,4 @@
import { assert } from '@expo/config';
import assert from 'assert';
import { AppleProvisioningProfileIdentifiersFragment } from '../../../graphql/generated';
import Log from '../../../log';
@@ -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(', ')})`;
}
@@ -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
);
}
}
}
@@ -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
);
}
@@ -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,
@@ -1,5 +1,5 @@
import { getConfig } from '@expo/config';
import { IOSConfig } from '@expo/config-plugins';
import { getPrebuildConfig } from '@expo/config';
import { IOSConfig, compileModsAsync } from '@expo/config-plugins';
import { Workflow } from '@expo/eas-build-job';
import { JSONObject } from '@expo/json-file';
import plist from '@expo/plist';
@@ -16,14 +16,14 @@ function getEntitlementsJson(projectDir: string): JSONObject | null {
}
export async function getManagedEntitlementsJsonAsync(projectDir: string): Promise<JSONObject> {
// TODO: Support prebuild mods
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
return (
exp.ios?.entitlements ?? {
// Always enable notifications...
'aps-environment': 'production',
}
);
let { exp } = getPrebuildConfig(projectDir, { platforms: ['ios'] });
exp = await compileModsAsync(exp, {
projectRoot: projectDir,
platforms: ['ios'],
introspect: true,
});
return exp.ios?.entitlements || {};
}
export async function resolveEntitlementsJsonAsync(
@@ -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: {
+34
View File
@@ -225,6 +225,7 @@ export type Account = {
applePushKeys: Array<ApplePushKey>;
appleProvisioningProfiles: Array<AppleProvisioningProfile>;
appleDevices: Array<AppleDevice>;
appleAppSpecificPasswords: Array<AppleAppSpecificPassword>;
/** Environment secrets for an account */
environmentSecrets: Array<EnvironmentSecret>;
/** @deprecated Legacy access tokens are deprecated */
@@ -631,6 +632,7 @@ export type Build = ActivityTimelineProjectActivity & BuildOrBuildJob & {
expirationDate?: Maybe<Scalars['DateTime']>;
platform: AppPlatform;
appVersion?: Maybe<Scalars['String']>;
appBuildVersion?: Maybe<Scalars['String']>;
sdkVersion?: Maybe<Scalars['String']>;
releaseChannel?: Maybe<Scalars['String']>;
metrics?: Maybe<BuildMetrics>;
@@ -961,6 +963,7 @@ export type IosAppCredentials = {
appleAppIdentifier: AppleAppIdentifier;
iosAppBuildCredentialsList: Array<IosAppBuildCredentials>;
pushKey?: Maybe<ApplePushKey>;
appSpecificPassword?: Maybe<AppleAppSpecificPassword>;
/** @deprecated use iosAppBuildCredentialsList instead */
iosAppBuildCredentialsArray: Array<IosAppBuildCredentials>;
};
@@ -1091,6 +1094,16 @@ export type IosAppBuildCredentialsFilter = {
iosDistributionType?: Maybe<IosDistributionType>;
};
export type AppleAppSpecificPassword = {
__typename?: 'AppleAppSpecificPassword';
id: Scalars['ID'];
account: Account;
appleIdUsername: Scalars['String'];
passwordLabel?: Maybe<Scalars['String']>;
createdAt: Scalars['DateTime'];
updatedAt: Scalars['DateTime'];
};
export type AndroidAppCredentialsFilter = {
legacyOnly?: Maybe<Scalars['Boolean']>;
applicationIdentifier?: Maybe<Scalars['String']>;
@@ -1686,6 +1699,8 @@ export type RootMutation = {
androidKeystore: AndroidKeystoreMutation;
/** Mutations that modify an Identifier for an iOS App */
appleAppIdentifier: AppleAppIdentifierMutation;
/** Mutations that modify an App Specific Password for an Apple User Account */
appleAppSpecificPassword: AppleAppSpecificPasswordMutation;
/** Mutations that modify an Apple Device */
appleDevice: AppleDeviceMutation;
/** Mutations that modify an Apple Device registration request */
@@ -2073,6 +2088,24 @@ export type AppleAppIdentifierInput = {
parentAppleAppId?: Maybe<Scalars['ID']>;
};
export type AppleAppSpecificPasswordMutation = {
__typename?: 'AppleAppSpecificPasswordMutation';
/** Create an App Specific Password for an Apple User Account */
createAppleAppSpecificPassword: AppleAppSpecificPassword;
};
export type AppleAppSpecificPasswordMutationCreateAppleAppSpecificPasswordArgs = {
appleAppSpecificPasswordInput: AppleAppSpecificPasswordInput;
accountId: Scalars['ID'];
};
export type AppleAppSpecificPasswordInput = {
appleIdUsername: Scalars['String'];
passwordLabel?: Maybe<Scalars['String']>;
appSpecificPassword: Scalars['String'];
};
export type AppleDeviceMutation = {
__typename?: 'AppleDeviceMutation';
/** Create an Apple Device */
@@ -2412,6 +2445,7 @@ export type BuildCacheInput = {
export type BuildMetadataInput = {
trackingContext?: Maybe<Scalars['JSONObject']>;
appVersion?: Maybe<Scalars['String']>;
appBuildVersion?: Maybe<Scalars['String']>;
cliVersion?: Maybe<Scalars['String']>;
workflow?: Maybe<BuildWorkflow>;
credentialsSource?: Maybe<BuildCredentialsSource>;
@@ -4,7 +4,10 @@ import os from 'os';
import { asMock } from '../../../__tests__/utils';
import { promptAsync } from '../../../prompts';
import { getApplicationId, getOrConfigureApplicationIdAsync } from '../applicationId';
import {
ensureApplicationIdIsDefinedForManagedProjectAsync,
getApplicationId,
} from '../applicationId';
jest.mock('fs');
jest.mock('../../../prompts');
@@ -92,7 +95,7 @@ describe(getApplicationId, () => {
});
});
describe(getOrConfigureApplicationIdAsync, () => {
describe(ensureApplicationIdIsDefinedForManagedProjectAsync, () => {
describe('managed project + android.package missing in app config', () => {
it('throws an error if using app.config.js', async () => {
vol.fromJSON(
@@ -101,9 +104,9 @@ describe(getOrConfigureApplicationIdAsync, () => {
},
'/app'
);
await expect(getOrConfigureApplicationIdAsync('/app', {} as any)).rejects.toThrowError(
/we can't update this file programatically/
);
await expect(
ensureApplicationIdIsDefinedForManagedProjectAsync('/app', {} as any)
).rejects.toThrowError(/we can't update this file programatically/);
});
it('prompts for the Android package if using app.json', async () => {
vol.fromJSON(
@@ -117,9 +120,9 @@ describe(getOrConfigureApplicationIdAsync, () => {
packageName: 'com.expo.notdominik',
}));
await expect(getOrConfigureApplicationIdAsync('/app', {} as any)).resolves.toBe(
'com.expo.notdominik'
);
await expect(
ensureApplicationIdIsDefinedForManagedProjectAsync('/app', {} as any)
).resolves.toBe('com.expo.notdominik');
expect(promptAsync).toHaveBeenCalled();
});
it('puts the Android package in app.json', async () => {
@@ -134,9 +137,9 @@ describe(getOrConfigureApplicationIdAsync, () => {
packageName: 'com.expo.notdominik',
}));
await expect(getOrConfigureApplicationIdAsync('/app', {} as any)).resolves.toBe(
'com.expo.notdominik'
);
await expect(
ensureApplicationIdIsDefinedForManagedProjectAsync('/app', {} as any)
).resolves.toBe('com.expo.notdominik');
expect(JSON.parse(fs.readFileSync('/app/app.json', 'utf-8'))).toMatchObject({
expo: { android: { package: 'com.expo.notdominik' } },
});
@@ -13,19 +13,17 @@ import { resolveWorkflow } from '../workflow';
const INVALID_APPLICATION_ID_MESSAGE = `Invalid format of Android applicationId. Only alphanumeric characters, '.' and '_' are allowed, and each '.' must be followed by a letter.`;
export async function getOrConfigureApplicationIdAsync(
export async function ensureApplicationIdIsDefinedForManagedProjectAsync(
projectDir: string,
exp: ExpoConfig
): Promise<string> {
const workflow = resolveWorkflow(projectDir, Platform.ANDROID);
assert(workflow === Workflow.MANAGED, 'This function should be called only for managed projects');
try {
return getApplicationId(projectDir, exp);
} catch (err) {
const workflow = resolveWorkflow(projectDir, Platform.ANDROID);
if (workflow === Workflow.MANAGED) {
return await configureApplicationIdAsync(projectDir, exp);
} else {
throw err;
}
return await configureApplicationIdAsync(projectDir, exp);
}
}
@@ -35,8 +33,11 @@ export function getApplicationId(projectDir: string, exp: ExpoConfig): string {
warnIfAndroidPackageDefinedInAppConfigForGenericProject(projectDir, exp);
const errorMessage = 'Could not read application id from Android project.';
const buildGradlePath = AndroidConfig.Paths.getAppBuildGradle(projectDir);
if (!fs.pathExistsSync(buildGradlePath)) {
let buildGradlePath = null;
try {
buildGradlePath = AndroidConfig.Paths.getAppBuildGradleFilePath(projectDir);
} catch {}
if (!buildGradlePath || !fs.pathExistsSync(buildGradlePath)) {
throw new Error(errorMessage);
}
const buildGradle = fs.readFileSync(buildGradlePath, 'utf8');
@@ -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, '');
}
+3 -2
View File
@@ -1,7 +1,7 @@
{
"name": "@expo/eas-json",
"description": "A library for interacting with the eas.json",
"version": "0.15.0",
"version": "0.17.0",
"author": "Expo <[email protected]>",
"bugs": "https://github.com/expo/eas-cli/issues",
"dependencies": {
@@ -39,5 +39,6 @@
},
"publishConfig": {
"access": "public"
}
},
"gitHead": "161808bc37c255fdea6801d69d23dbc725c056c3"
}
+802 -20
View File
File diff suppressed because it is too large. Load diff