mirror of
https://github.com/expo/eas-cli.git
synced 2026-11-15 17:31:46 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6920ebb0ba | ||
|
|
55f35949e1 | ||
|
|
ccb998a221 | ||
|
|
30bc27b4c4 | ||
|
|
da3c95ccaf | ||
|
|
bbcbe1dceb | ||
|
|
f15beea454 | ||
|
|
16e384be76 | ||
|
|
e74e6d8fc5 | ||
|
|
b6f4603107 | ||
|
|
0e7d7f765a | ||
|
|
33b4d8d719 | ||
|
|
0d765748e3 | ||
|
|
93953f1424 | ||
|
|
e9b67db05c | ||
|
|
09bf912b9e | ||
|
|
e701bacdaa | ||
|
|
cc22542031 | ||
|
|
6c53262b5b | ||
|
|
7d7d4995d8 | ||
|
|
977546c8c9 | ||
|
|
53dcd4cb43 | ||
|
|
9e18e738eb | ||
|
|
252c7187d5 | ||
|
|
90852b9557 | ||
|
|
0df16236a2 | ||
|
|
ecaf5a4318 | ||
|
|
86e5e1a7b1 | ||
|
|
ab10094071 | ||
|
|
2d536d73fe | ||
|
|
80ea8ee50b | ||
|
|
b49c5f47d1 | ||
|
|
a9da78946b | ||
|
|
b6d9accea4 | ||
|
|
4611a65bce | ||
|
|
db29b3fc18 | ||
|
|
2534a46bd3 | ||
|
|
7def4b502e | ||
|
|
4ea26d7ca3 | ||
|
|
c4c8075b1f | ||
|
|
266545d2a0 | ||
|
|
ddd7046513 | ||
|
|
7a44eeb22b | ||
|
|
5bcf8263cf | ||
|
|
f380ba0106 |
No files matched your search
@@ -10,6 +10,7 @@ module.exports = {
|
||||
jasmine: false,
|
||||
},
|
||||
rules: {
|
||||
'no-console':'warn',
|
||||
'no-constant-condition': ['warn', { checkLoops: false }],
|
||||
'sort-imports': [
|
||||
'warn',
|
||||
|
||||
+76
-2
@@ -6,6 +6,82 @@ This is the log of notable changes to EAS CLI and related packages.
|
||||
|
||||
### 🛠 Breaking changes
|
||||
|
||||
### 🎉 New features
|
||||
|
||||
- Added support for iOS 15 capabilities: Communication Notifications, Time Sensitive Notifications, Group Activities, and Family Controls. ([#499](https://github.com/expo/eas-cli/pull/499) by [@EvanBacon](https://github.com/EvanBacon))
|
||||
- Show more build metadata in `build:view` and `build:list`. ([#504](https://github.com/expo/eas-cli/pull/504) and [#508](https://github.com/expo/eas-cli/pull/508) by [@dsokal](https://github.com/dsokal))
|
||||
- Add runtime version to build metadata. ([#493](https://github.com/expo/eas-cli/pull/493) by [@dsokal](https://github.com/dsokal))
|
||||
|
||||
### 🐛 Bug fixes
|
||||
|
||||
### 🧹 Chores
|
||||
|
||||
## [0.20.0](https://github.com/expo/eas-cli/releases/tag/v0.20.0) - 2021-07-09
|
||||
|
||||
### 🛠 Breaking changes
|
||||
|
||||
- Unifify generic and managed workflow, deprecate `workflow` field. ([#497](https://github.com/expo/eas-cli/pull/497) by [@wkozyra95](https://github.com/wkozyra95))
|
||||
|
||||
### 🐛 Bug fixes
|
||||
|
||||
- Fix runtime version checks. ([#495](https://github.com/expo/eas-cli/pull/495) by [@dsokal](https://github.com/dsokal))
|
||||
- Resolve `--android-package` correctly in `eas submit` command. ([#494](https://github.com/expo/eas-cli/pull/494) by [@wkozyra95](https://github.com/wkozyra95))
|
||||
|
||||
## [0.19.1](https://github.com/expo/eas-cli/releases/tag/v0.19.1) - 2021-07-02
|
||||
|
||||
### 🎉 New features
|
||||
|
||||
- Improve project workflow detection (fixes the case where the `android` and/or `ios` directories are git-ignored). ([#490](https://github.com/expo/eas-cli/pull/490) by [@dsokal](https://github.com/dsokal))
|
||||
- Improve credentials workflow with project creation and current working directories ([#491](https://github.com/expo/eas-cli/pull/491) by [@quinlanj](https://github.com/quinlanj))
|
||||
|
||||
### 🐛 Bug fixes
|
||||
|
||||
- Better debugging experience ([#492](https://github.com/expo/eas-cli/pull/492) by [@quinlanj](https://github.com/quinlanj))
|
||||
|
||||
## [0.19.0](https://github.com/expo/eas-cli/releases/tag/v0.19.0) - 2021-07-01
|
||||
|
||||
### 🎉 New features
|
||||
|
||||
- Auto-suggest application id and bundle identifier when running `eas build:configure` for a managed project. ([#487](https://github.com/expo/eas-cli/pull/487) by [@dsokal](https://github.com/dsokal))
|
||||
- Support configuring one platform at a time when running `eas build`. ([#483](https://github.com/expo/eas-cli/pull/483) by [@brentvatne](https://github.com/brentvatne))
|
||||
|
||||
## [0.18.3](https://github.com/expo/eas-cli/releases/tag/v0.18.3) - 2021-06-28
|
||||
|
||||
### 🎉 New features
|
||||
|
||||
- Support bundle identifiers that begin with `.`. ([#459](https://github.com/expo/eas-cli/pull/459) by [@EvanBacon](https://github.com/EvanBacon))
|
||||
- Push Key setup integrated with ios build command ([#473](https://github.com/expo/eas-cli/pull/473) by [@quinlanj](https://github.com/quinlanj))
|
||||
|
||||
### 🐛 Bug fixes
|
||||
|
||||
- Fix android builds for PKCS12 keystores. ([#484](https://github.com/expo/eas-cli/pull/484) by [@quinlanj](https://github.com/quinlanj))
|
||||
|
||||
## [0.18.2](https://github.com/expo/eas-cli/releases/tag/v0.18.2) - 2021-06-25
|
||||
|
||||
### 🎉 New features
|
||||
|
||||
- Change default iOS image for projects with Expo SDK <= 41 (SDK 41 won't build with Xcode 12.5). ([#479](https://github.com/expo/eas-cli/pull/479) by [@dsokal](https://github.com/dsokal))
|
||||
- Make Apple team optional in appropriate cases. ([#468](https://github.com/expo/eas-cli/pull/468) by [@quinlanj](https://github.com/quinlanj))
|
||||
- Show projects that depend on a push key. ([#472](https://github.com/expo/eas-cli/pull/472) by [@quinlanj](https://github.com/quinlanj))
|
||||
|
||||
### 🐛 Bug fixes
|
||||
|
||||
- Fix inverted conditional so we actually only prompt about commit when index is dirty. ([#481](https://github.com/expo/eas-cli/pull/481) by [@brentvatne](https://github.com/brentvatne))
|
||||
|
||||
## [0.18.1](https://github.com/expo/eas-cli/releases/tag/v0.18.1) - 2021-06-24
|
||||
|
||||
### 🎉 New features
|
||||
|
||||
- Add basic printing support for Apple App Specific Password. ([#474](https://github.com/expo/eas-cli/pull/474) by [@quinlanj](https://github.com/quinlanj))
|
||||
|
||||
### 🐛 Bug fixes
|
||||
|
||||
- Fix CLI UI getting blocked on credentials migration, leading to partially migrated state. ([#477](https://github.com/expo/eas-cli/pull/477) by [@brentvatne](https://github.com/brentvatne))
|
||||
|
||||
## [0.18.0](https://github.com/expo/eas-cli/releases/tag/v0.18.0) - 2021-06-24
|
||||
|
||||
### 🛠 Breaking changes
|
||||
|
||||
- Drop support for `experimental.npmToken` in credentials.json, EAS Secrets can be used instead. ([#444](https://github.com/expo/eas-cli/pull/444) by [@dsokal](https://github.com/dsokal))
|
||||
- Remove `--allow-experimental` flag from `eas build:configure` as it has no effect now. ([#444](https://github.com/expo/eas-cli/pull/444) by [@dsokal](https://github.com/dsokal))
|
||||
|
||||
@@ -20,8 +96,6 @@ This is the log of notable changes to EAS CLI and related packages.
|
||||
- iOS push key setup and management now available in `eas-cli credentials`. ([#469](https://github.com/expo/eas-cli/pull/469) [#470](https://github.com/expo/eas-cli/pull/470) by [@quinlanj](https://github.com/quinlanj))
|
||||
- Support new build status: `new`. ([#475](https://github.com/expo/eas-cli/pull/475) by [@dsokal](https://github.com/dsokal))
|
||||
|
||||
### 🐛 Bug fixes
|
||||
|
||||
### 🧹 Chores
|
||||
|
||||
- Deprecate `--skip-credentials-check` flag because it doesn't do anything and is no longer needed. ([#442](https://github.com/expo/eas-cli/pull/442) by [@brentvatne](https://github.com/brentvatne))
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"npmClient": "yarn",
|
||||
"useWorkspaces": true,
|
||||
"version": "0.18.0"
|
||||
"version": "0.21.0"
|
||||
}
|
||||
+22
-22
@@ -69,7 +69,7 @@ ALIASES
|
||||
$ eas login
|
||||
```
|
||||
|
||||
_See code: [src/commands/account/login.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/account/login.ts)_
|
||||
_See code: [src/commands/account/login.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/account/login.ts)_
|
||||
|
||||
## `eas account:logout`
|
||||
|
||||
@@ -83,7 +83,7 @@ ALIASES
|
||||
$ eas logout
|
||||
```
|
||||
|
||||
_See code: [src/commands/account/logout.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/account/logout.ts)_
|
||||
_See code: [src/commands/account/logout.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/account/logout.ts)_
|
||||
|
||||
## `eas account:view`
|
||||
|
||||
@@ -97,7 +97,7 @@ ALIASES
|
||||
$ eas whoami
|
||||
```
|
||||
|
||||
_See code: [src/commands/account/view.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/account/view.ts)_
|
||||
_See code: [src/commands/account/view.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/account/view.ts)_
|
||||
|
||||
## `eas analytics [STATUS]`
|
||||
|
||||
@@ -108,7 +108,7 @@ USAGE
|
||||
$ eas analytics [STATUS]
|
||||
```
|
||||
|
||||
_See code: [src/commands/analytics.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/analytics.ts)_
|
||||
_See code: [src/commands/analytics.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/analytics.ts)_
|
||||
|
||||
## `eas build`
|
||||
|
||||
@@ -128,7 +128,7 @@ OPTIONS
|
||||
--[no-]wait Wait for build(s) to complete
|
||||
```
|
||||
|
||||
_See code: [src/commands/build/index.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/build/index.ts)_
|
||||
_See code: [src/commands/build/index.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/build/index.ts)_
|
||||
|
||||
## `eas build:cancel [BUILD_ID]`
|
||||
|
||||
@@ -139,7 +139,7 @@ USAGE
|
||||
$ eas build:cancel [BUILD_ID]
|
||||
```
|
||||
|
||||
_See code: [src/commands/build/cancel.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/build/cancel.ts)_
|
||||
_See code: [src/commands/build/cancel.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/build/cancel.ts)_
|
||||
|
||||
## `eas build:configure`
|
||||
|
||||
@@ -153,7 +153,7 @@ OPTIONS
|
||||
-p, --platform=(android|ios|all) Platform to configure
|
||||
```
|
||||
|
||||
_See code: [src/commands/build/configure.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/build/configure.ts)_
|
||||
_See code: [src/commands/build/configure.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/build/configure.ts)_
|
||||
|
||||
## `eas build:list`
|
||||
|
||||
@@ -169,7 +169,7 @@ OPTIONS
|
||||
--status=(new|in-queue|in-progress|errored|finished|canceled)
|
||||
```
|
||||
|
||||
_See code: [src/commands/build/list.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/build/list.ts)_
|
||||
_See code: [src/commands/build/list.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/build/list.ts)_
|
||||
|
||||
## `eas build:view [BUILD_ID]`
|
||||
|
||||
@@ -180,7 +180,7 @@ USAGE
|
||||
$ eas build:view [BUILD_ID]
|
||||
```
|
||||
|
||||
_See code: [src/commands/build/view.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/build/view.ts)_
|
||||
_See code: [src/commands/build/view.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/build/view.ts)_
|
||||
|
||||
## `eas credentials`
|
||||
|
||||
@@ -191,7 +191,7 @@ USAGE
|
||||
$ eas credentials
|
||||
```
|
||||
|
||||
_See code: [src/commands/credentials.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/credentials.ts)_
|
||||
_See code: [src/commands/credentials.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/credentials.ts)_
|
||||
|
||||
## `eas device:create`
|
||||
|
||||
@@ -202,7 +202,7 @@ USAGE
|
||||
$ eas device:create
|
||||
```
|
||||
|
||||
_See code: [src/commands/device/create.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/device/create.ts)_
|
||||
_See code: [src/commands/device/create.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/device/create.ts)_
|
||||
|
||||
## `eas device:list`
|
||||
|
||||
@@ -216,7 +216,7 @@ OPTIONS
|
||||
--apple-team-id=apple-team-id
|
||||
```
|
||||
|
||||
_See code: [src/commands/device/list.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/device/list.ts)_
|
||||
_See code: [src/commands/device/list.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/device/list.ts)_
|
||||
|
||||
## `eas device:view [UDID]`
|
||||
|
||||
@@ -227,7 +227,7 @@ USAGE
|
||||
$ eas device:view [UDID]
|
||||
```
|
||||
|
||||
_See code: [src/commands/device/view.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/device/view.ts)_
|
||||
_See code: [src/commands/device/view.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/device/view.ts)_
|
||||
|
||||
## `eas help [COMMAND]`
|
||||
|
||||
@@ -260,7 +260,7 @@ OPTIONS
|
||||
--value=value Value of the secret
|
||||
```
|
||||
|
||||
_See code: [src/commands/secret/create.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/secret/create.ts)_
|
||||
_See code: [src/commands/secret/create.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/secret/create.ts)_
|
||||
|
||||
## `eas secret:delete`
|
||||
|
||||
@@ -277,7 +277,7 @@ DESCRIPTION
|
||||
Unsure where to find the secret's ID? Run eas secrets:list
|
||||
```
|
||||
|
||||
_See code: [src/commands/secret/delete.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/secret/delete.ts)_
|
||||
_See code: [src/commands/secret/delete.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/secret/delete.ts)_
|
||||
|
||||
## `eas secret:list`
|
||||
|
||||
@@ -288,7 +288,7 @@ USAGE
|
||||
$ eas secret:list
|
||||
```
|
||||
|
||||
_See code: [src/commands/secret/list.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/secret/list.ts)_
|
||||
_See code: [src/commands/secret/list.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/secret/list.ts)_
|
||||
|
||||
## `eas submit --platform=(android|ios)`
|
||||
|
||||
@@ -368,7 +368,7 @@ EXAMPLES
|
||||
and provide its App ID
|
||||
```
|
||||
|
||||
_See code: [src/commands/submit.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/submit.ts)_
|
||||
_See code: [src/commands/submit.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/submit.ts)_
|
||||
|
||||
## `eas webhook:create`
|
||||
|
||||
@@ -387,7 +387,7 @@ OPTIONS
|
||||
--url=url Webhook URL
|
||||
```
|
||||
|
||||
_See code: [src/commands/webhook/create.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/webhook/create.ts)_
|
||||
_See code: [src/commands/webhook/create.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/webhook/create.ts)_
|
||||
|
||||
## `eas webhook:delete [ID]`
|
||||
|
||||
@@ -401,7 +401,7 @@ ARGUMENTS
|
||||
ID ID of the webhook to delete
|
||||
```
|
||||
|
||||
_See code: [src/commands/webhook/delete.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/webhook/delete.ts)_
|
||||
_See code: [src/commands/webhook/delete.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/webhook/delete.ts)_
|
||||
|
||||
## `eas webhook:list`
|
||||
|
||||
@@ -415,7 +415,7 @@ OPTIONS
|
||||
--event=(BUILD) Event type that triggers the webhook
|
||||
```
|
||||
|
||||
_See code: [src/commands/webhook/list.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/webhook/list.ts)_
|
||||
_See code: [src/commands/webhook/list.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/webhook/list.ts)_
|
||||
|
||||
## `eas webhook:update`
|
||||
|
||||
@@ -435,7 +435,7 @@ OPTIONS
|
||||
--url=url Webhook URL
|
||||
```
|
||||
|
||||
_See code: [src/commands/webhook/update.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/webhook/update.ts)_
|
||||
_See code: [src/commands/webhook/update.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/webhook/update.ts)_
|
||||
|
||||
## `eas webhook:view ID`
|
||||
|
||||
@@ -449,5 +449,5 @@ ARGUMENTS
|
||||
ID ID of the webhook to view
|
||||
```
|
||||
|
||||
_See code: [src/commands/webhook/view.ts](https://github.com/expo/eas-cli/blob/v0.18.0/packages/eas-cli/src/commands/webhook/view.ts)_
|
||||
_See code: [src/commands/webhook/view.ts](https://github.com/expo/eas-cli/blob/v0.21.0/packages/eas-cli/src/commands/webhook/view.ts)_
|
||||
<!-- commandsstop -->
|
||||
@@ -1,2 +1,9 @@
|
||||
import { fs } from 'memfs';
|
||||
|
||||
// needed because of a weird bug with tempy (dependency of @expo/config-plugins)
|
||||
fs.mkdirSync('/tmp');
|
||||
if (process.env.TMPDIR) {
|
||||
fs.mkdirSync(process.env.TMPDIR, { recursive: true });
|
||||
}
|
||||
|
||||
module.exports = fs;
|
||||
@@ -1,3 +0,0 @@
|
||||
module.exports = async () => {
|
||||
process.env.TZ = 'UTC';
|
||||
};
|
||||
+1132
-971
File diff suppressed because it is too large.
Load diff
@@ -2,5 +2,6 @@ module.exports = {
|
||||
...require('../../jest/jest.config.js'),
|
||||
rootDir: __dirname,
|
||||
roots: ['src', '__mocks__'],
|
||||
globalSetup: './global-setup.ts',
|
||||
globalSetup: './jest/global-setup.ts',
|
||||
setupFilesAfterEnv: ['./jest/setup-after-env.ts'],
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = async () => {
|
||||
process.env.TZ = 'UTC';
|
||||
process.env.EAS_NO_VCS = '1';
|
||||
process.env.EAS_PROJECT_ROOT = '/app';
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
/* eslint-disable no-console */
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
console.warn = jest.fn();
|
||||
console.error = jest.fn();
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "eas-cli",
|
||||
"description": "EAS command line tool",
|
||||
"version": "0.18.0",
|
||||
"version": "0.21.0",
|
||||
"author": "Expo <[email protected]>",
|
||||
"bin": {
|
||||
"eas": "./bin/run"
|
||||
@@ -10,11 +10,11 @@
|
||||
"dependencies": {
|
||||
"@amplitude/identify": "1.5.0",
|
||||
"@amplitude/node": "1.5.0",
|
||||
"@expo/apple-utils": "0.0.0-alpha.20",
|
||||
"@expo/apple-utils": "0.0.0-alpha.23",
|
||||
"@expo/config": "3.3.42",
|
||||
"@expo/config-plugins": "2.0.2",
|
||||
"@expo/eas-build-job": "0.2.37",
|
||||
"@expo/eas-json": "^0.18.0",
|
||||
"@expo/config-plugins": "3.0.3",
|
||||
"@expo/eas-build-job": "0.2.43",
|
||||
"@expo/eas-json": "^0.21.0",
|
||||
"@expo/json-file": "8.2.25",
|
||||
"@expo/pkcs12": "0.0.4",
|
||||
"@expo/plist": "0.0.11",
|
||||
|
||||
@@ -6,4 +6,5 @@ readmeContent = readmeContent.replace(/\[build\//g, '[src/');
|
||||
readmeContent = readmeContent.replace(/build\/commands/g, 'packages/eas-cli/src/commands');
|
||||
fs.writeFileSync('README.md', readmeContent);
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Patched README path generation');
|
||||
@@ -94,14 +94,13 @@ export async function readChannelSafelyAsync(projectDir: string): Promise<string
|
||||
const androidManifest = await getAndroidManifestAsync(projectDir);
|
||||
const stringifiedRequestHeaders = AndroidConfig.Manifest.getMainApplicationMetaDataValue(
|
||||
androidManifest,
|
||||
'expo.modules.updates.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY' //TODO-JJ AndroidConfig.Updates.Config.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY once https://github.com/expo/expo-cli/pull/3571 is published
|
||||
AndroidConfig.Updates.Config.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY
|
||||
);
|
||||
if (!stringifiedRequestHeaders) {
|
||||
return null;
|
||||
}
|
||||
return JSON.parse(stringifiedRequestHeaders)['expo-channel-name'] ?? null;
|
||||
} catch (err) {
|
||||
console.log({ err });
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import fs from 'fs-extra';
|
||||
import { vol } from 'memfs';
|
||||
import os from 'os';
|
||||
|
||||
import { readVersionCode, readVersionName } from '../version';
|
||||
import { readVersionCodeAsync, readVersionNameAsync } from '../version';
|
||||
|
||||
jest.mock('fs');
|
||||
|
||||
@@ -20,35 +20,35 @@ beforeEach(() => {
|
||||
fs.mkdirpSync(os.tmpdir());
|
||||
});
|
||||
|
||||
describe(readVersionCode, () => {
|
||||
describe(readVersionCodeAsync, () => {
|
||||
describe('generic project', () => {
|
||||
it('reads the version code from native code', () => {
|
||||
it('reads the version code from native code', async () => {
|
||||
const exp = initGenericProject();
|
||||
const versionCode = readVersionCode('/repo', exp);
|
||||
const versionCode = await readVersionCodeAsync('/repo', exp);
|
||||
expect(versionCode).toBe(123);
|
||||
});
|
||||
});
|
||||
describe('managed project', () => {
|
||||
it('reads the version code from expo config', () => {
|
||||
it('reads the version code from expo config', async () => {
|
||||
const exp = initManagedProject();
|
||||
const versionCode = readVersionCode('/repo', exp);
|
||||
const versionCode = await readVersionCodeAsync('/repo', exp);
|
||||
expect(versionCode).toBe(123);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe(readVersionName, () => {
|
||||
describe(readVersionNameAsync, () => {
|
||||
describe('generic project', () => {
|
||||
it('reads the version name from native code', () => {
|
||||
it('reads the version name from native code', async () => {
|
||||
const exp = initGenericProject();
|
||||
const versionName = readVersionName('/repo', exp);
|
||||
const versionName = await readVersionNameAsync('/repo', exp);
|
||||
expect(versionName).toBe('1.0');
|
||||
});
|
||||
});
|
||||
describe('managed project', () => {
|
||||
it('reads the version from expo config', () => {
|
||||
it('reads the version from expo config', async () => {
|
||||
const exp = initManagedProject();
|
||||
const versionName = readVersionName('/repo', exp);
|
||||
const versionName = await readVersionNameAsync('/repo', exp);
|
||||
expect(versionName).toBe('1.0.0');
|
||||
});
|
||||
});
|
||||
@@ -72,6 +72,7 @@ function initGenericProject(): ExpoConfig {
|
||||
versionName "1.0"
|
||||
}
|
||||
}`,
|
||||
'./android/app/src/main/AndroidManifest.xml': 'fake',
|
||||
},
|
||||
'/repo'
|
||||
);
|
||||
|
||||
@@ -1,9 +1,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, {
|
||||
AndroidCredentials,
|
||||
@@ -13,46 +11,31 @@ import { BuildMutation, BuildResult } from '../../graphql/mutations/BuildMutatio
|
||||
import Log from '../../log';
|
||||
import {
|
||||
ensureApplicationIdIsDefinedForManagedProjectAsync,
|
||||
getApplicationId,
|
||||
getApplicationIdAsync,
|
||||
} 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 { BuildContext, CommandContext, createBuildContextAsync } from '../context';
|
||||
import { transformMetadata } from '../graphql';
|
||||
import { Platform } from '../types';
|
||||
import { logCredentialsSource } from '../utils/credentials';
|
||||
import { validateAndSyncProjectConfigurationAsync } from './configure';
|
||||
import { transformGenericJob, transformManagedJob } from './graphql';
|
||||
import { transformJob } from './graphql';
|
||||
import { prepareJobAsync } from './prepareJob';
|
||||
|
||||
export async function prepareAndroidBuildAsync(
|
||||
commandCtx: CommandContext,
|
||||
easConfig: EasConfig
|
||||
): Promise<() => Promise<string | undefined>> {
|
||||
const buildCtx = createBuildContext<Platform.ANDROID>({
|
||||
const buildCtx = await createBuildContextAsync<Platform.ANDROID>({
|
||||
commandCtx,
|
||||
platform: Platform.ANDROID,
|
||||
easConfig,
|
||||
});
|
||||
const { buildProfile } = buildCtx;
|
||||
|
||||
if (
|
||||
buildProfile.workflow === Workflow.GENERIC &&
|
||||
!(await fs.pathExists(path.join(commandCtx.projectDir, 'android')))
|
||||
) {
|
||||
throw new Error(
|
||||
`"android" directory not found. If you're trying to build a managed project, set ${chalk.bold(
|
||||
`builds.android.${commandCtx.profile}.workflow`
|
||||
)} in "eas.json" to "managed".`
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
buildProfile.workflow === Workflow.GENERIC &&
|
||||
buildProfile.distribution === 'internal' &&
|
||||
buildProfile.gradleCommand?.match(/bundle/)
|
||||
) {
|
||||
if (buildProfile.distribution === 'internal' && buildProfile.gradleCommand?.match(/bundle/)) {
|
||||
Log.addNewLineIfNone();
|
||||
Log.warn(
|
||||
`You're building your Android app for internal distribution. However, we've detected that the Gradle command you defined (${chalk.underline(
|
||||
@@ -68,7 +51,7 @@ This means that it will most likely produce an AAB and you will not be able to i
|
||||
}
|
||||
}
|
||||
|
||||
if (buildCtx.buildProfile.workflow === Workflow.MANAGED) {
|
||||
if (buildCtx.workflow === Workflow.MANAGED) {
|
||||
await ensureApplicationIdIsDefinedForManagedProjectAsync(commandCtx.projectDir, commandCtx.exp);
|
||||
}
|
||||
|
||||
@@ -76,7 +59,7 @@ This means that it will most likely produce an AAB and you will not be able to i
|
||||
ctx: buildCtx,
|
||||
ensureCredentialsAsync: ensureAndroidCredentialsAsync,
|
||||
ensureProjectConfiguredAsync: async () => {
|
||||
if (buildCtx.buildProfile.workflow === Workflow.GENERIC) {
|
||||
if (buildCtx.workflow === Workflow.GENERIC) {
|
||||
await validateAndSyncProjectConfigurationAsync(commandCtx.projectDir, commandCtx.exp);
|
||||
}
|
||||
},
|
||||
@@ -87,30 +70,18 @@ This means that it will most likely produce an AAB and you will not be able to i
|
||||
metadata: Metadata
|
||||
): Promise<BuildResult> => {
|
||||
const graphqlMetadata = transformMetadata(metadata);
|
||||
if (job.type === Workflow.GENERIC) {
|
||||
const graphqlJob = transformGenericJob(job);
|
||||
return await BuildMutation.createAndroidGenericBuildAsync({
|
||||
appId,
|
||||
job: graphqlJob,
|
||||
metadata: graphqlMetadata,
|
||||
});
|
||||
} else {
|
||||
const graphqlJob = transformManagedJob(job);
|
||||
return await BuildMutation.createAndroidManagedBuildAsync({
|
||||
appId,
|
||||
job: graphqlJob,
|
||||
metadata: graphqlMetadata,
|
||||
});
|
||||
}
|
||||
const graphqlJob = transformJob(job);
|
||||
return await BuildMutation.createAndroidBuildAsync({
|
||||
appId,
|
||||
job: graphqlJob,
|
||||
metadata: graphqlMetadata,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function shouldProvideCredentials(ctx: BuildContext<Platform.ANDROID>): boolean {
|
||||
return (
|
||||
ctx.buildProfile.workflow === Workflow.MANAGED ||
|
||||
(ctx.buildProfile.workflow === Workflow.GENERIC && !ctx.buildProfile.withoutCredentials)
|
||||
);
|
||||
return !ctx.buildProfile.withoutCredentials;
|
||||
}
|
||||
|
||||
async function ensureAndroidCredentialsAsync(
|
||||
@@ -119,7 +90,7 @@ async function ensureAndroidCredentialsAsync(
|
||||
if (!shouldProvideCredentials(ctx)) {
|
||||
return;
|
||||
}
|
||||
const androidApplicationIdentifier = getApplicationId(
|
||||
const androidApplicationIdentifier = await getApplicationIdAsync(
|
||||
ctx.commandCtx.projectDir,
|
||||
ctx.commandCtx.exp
|
||||
);
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { Android } from '@expo/eas-build-job';
|
||||
|
||||
import {
|
||||
AndroidGenericJobInput,
|
||||
AndroidManagedBuildType,
|
||||
AndroidManagedJobInput,
|
||||
} from '../../graphql/generated';
|
||||
import { transformProjectArchive } from '../graphql';
|
||||
import { AndroidBuildType, AndroidJobInput } from '../../graphql/generated';
|
||||
import { transformProjectArchive, transformWorkflow } from '../graphql';
|
||||
|
||||
export function transformGenericJob(job: Android.GenericJob): AndroidGenericJobInput {
|
||||
export function transformJob(job: Android.Job): AndroidJobInput {
|
||||
return {
|
||||
type: transformWorkflow(job.type),
|
||||
projectArchive: transformProjectArchive(job.projectArchive),
|
||||
projectRootDirectory: job.projectRootDirectory,
|
||||
releaseChannel: job.releaseChannel,
|
||||
@@ -18,29 +15,17 @@ export function transformGenericJob(job: Android.GenericJob): AndroidGenericJobI
|
||||
cache: job.cache,
|
||||
gradleCommand: job.gradleCommand,
|
||||
artifactPath: job.artifactPath,
|
||||
};
|
||||
}
|
||||
|
||||
export function transformManagedJob(job: Android.ManagedJob): AndroidManagedJobInput {
|
||||
return {
|
||||
projectArchive: transformProjectArchive(job.projectArchive),
|
||||
projectRootDirectory: job.projectRootDirectory,
|
||||
releaseChannel: job.releaseChannel,
|
||||
updates: job.updates,
|
||||
secrets: job.secrets,
|
||||
builderEnvironment: job.builderEnvironment,
|
||||
cache: job.cache,
|
||||
username: job.username,
|
||||
buildType: transformBuildType(job.buildType),
|
||||
buildType: job.buildType && transformBuildType(job.buildType),
|
||||
};
|
||||
}
|
||||
|
||||
function transformBuildType(buildType: Android.ManagedBuildType): AndroidManagedBuildType {
|
||||
if (buildType === Android.ManagedBuildType.APK) {
|
||||
return AndroidManagedBuildType.Apk;
|
||||
} else if (buildType === Android.ManagedBuildType.APP_BUNDLE) {
|
||||
return AndroidManagedBuildType.AppBundle;
|
||||
function transformBuildType(buildType: Android.BuildType): AndroidBuildType {
|
||||
if (buildType === Android.BuildType.APK) {
|
||||
return AndroidBuildType.Apk;
|
||||
} else if (buildType === Android.BuildType.APP_BUNDLE) {
|
||||
return AndroidBuildType.AppBundle;
|
||||
} else {
|
||||
return AndroidManagedBuildType.DevelopmentClient;
|
||||
return AndroidBuildType.DevelopmentClient;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Android, ArchiveSource, Cache, Job, Workflow, sanitizeJob } from '@expo/eas-build-job';
|
||||
import { AndroidGenericBuildProfile, AndroidManagedBuildProfile } from '@expo/eas-json';
|
||||
import { ArchiveSource, Job, sanitizeJob } from '@expo/eas-build-job';
|
||||
import path from 'path';
|
||||
|
||||
import { AndroidCredentials } from '../../credentials/android/AndroidCredentialsProvider';
|
||||
@@ -18,33 +17,9 @@ export async function prepareJobAsync(
|
||||
ctx: BuildContext<Platform.ANDROID>,
|
||||
jobData: JobData
|
||||
): Promise<Job> {
|
||||
if (ctx.buildProfile.workflow === Workflow.GENERIC) {
|
||||
const partialJob = await prepareGenericJobAsync(ctx, jobData, ctx.buildProfile);
|
||||
return sanitizeJob(partialJob);
|
||||
} else if (ctx.buildProfile.workflow === Workflow.MANAGED) {
|
||||
const partialJob = await prepareManagedJobAsync(ctx, jobData, ctx.buildProfile);
|
||||
return sanitizeJob(partialJob);
|
||||
} else {
|
||||
throw new Error("Unknown workflow. Shouldn't happen");
|
||||
}
|
||||
}
|
||||
|
||||
interface CommonJobProperties {
|
||||
platform: Platform.ANDROID;
|
||||
projectArchive: ArchiveSource;
|
||||
builderEnvironment: Android.BuilderEnvironment;
|
||||
cache: Cache;
|
||||
secrets: {
|
||||
buildCredentials?: {
|
||||
keystore: Android.Keystore;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
async function prepareJobCommonAsync(
|
||||
ctx: BuildContext<Platform.ANDROID>,
|
||||
jobData: JobData
|
||||
): Promise<Partial<CommonJobProperties>> {
|
||||
const username = getUsername(ctx.commandCtx.exp, await ensureLoggedInAsync());
|
||||
const projectRootDirectory =
|
||||
path.relative(await vcs.getRootPathAsync(), ctx.commandCtx.projectDir) || '.';
|
||||
const { credentials } = jobData;
|
||||
const buildCredentials = credentials
|
||||
? {
|
||||
@@ -59,8 +34,10 @@ async function prepareJobCommonAsync(
|
||||
}
|
||||
: {};
|
||||
|
||||
return {
|
||||
const job = {
|
||||
type: ctx.workflow,
|
||||
platform: Platform.ANDROID,
|
||||
projectRootDirectory,
|
||||
projectArchive: jobData.projectArchive,
|
||||
builderEnvironment: {
|
||||
image: ctx.buildProfile.image,
|
||||
@@ -77,42 +54,15 @@ async function prepareJobCommonAsync(
|
||||
secrets: {
|
||||
...buildCredentials,
|
||||
},
|
||||
};
|
||||
}
|
||||
releaseChannel: ctx.buildProfile.releaseChannel,
|
||||
updates: { channel: ctx.buildProfile.channel },
|
||||
|
||||
async function prepareGenericJobAsync(
|
||||
ctx: BuildContext<Platform.ANDROID>,
|
||||
jobData: JobData,
|
||||
buildProfile: AndroidGenericBuildProfile
|
||||
): Promise<Partial<Android.GenericJob>> {
|
||||
const projectRootDirectory =
|
||||
path.relative(await vcs.getRootPathAsync(), ctx.commandCtx.projectDir) || '.';
|
||||
return {
|
||||
...(await prepareJobCommonAsync(ctx, jobData)),
|
||||
type: Workflow.GENERIC,
|
||||
gradleCommand: buildProfile.gradleCommand,
|
||||
artifactPath: buildProfile.artifactPath,
|
||||
releaseChannel: buildProfile.releaseChannel,
|
||||
updates: { channel: buildProfile.channel },
|
||||
projectRootDirectory,
|
||||
};
|
||||
}
|
||||
gradleCommand: ctx.buildProfile.gradleCommand,
|
||||
artifactPath: ctx.buildProfile.artifactPath,
|
||||
|
||||
async function prepareManagedJobAsync(
|
||||
ctx: BuildContext<Platform.ANDROID>,
|
||||
jobData: JobData,
|
||||
buildProfile: AndroidManagedBuildProfile
|
||||
): Promise<Partial<Android.ManagedJob>> {
|
||||
const projectRootDirectory =
|
||||
path.relative(await vcs.getRootPathAsync(), ctx.commandCtx.projectDir) || '.';
|
||||
const username = getUsername(ctx.commandCtx.exp, await ensureLoggedInAsync());
|
||||
return {
|
||||
...(await prepareJobCommonAsync(ctx, jobData)),
|
||||
type: Workflow.MANAGED,
|
||||
username,
|
||||
buildType: buildProfile.buildType,
|
||||
releaseChannel: buildProfile.releaseChannel,
|
||||
updates: { channel: buildProfile.channel },
|
||||
projectRootDirectory,
|
||||
buildType: ctx.buildProfile.buildType,
|
||||
};
|
||||
|
||||
return sanitizeJob(job);
|
||||
}
|
||||
@@ -3,10 +3,13 @@ import { AndroidConfig } from '@expo/config-plugins';
|
||||
import { Platform, Workflow } from '@expo/eas-build-job';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
import { resolveWorkflow } from '../../project/workflow';
|
||||
import { resolveWorkflowAsync } from '../../project/workflow';
|
||||
|
||||
export function readVersionCode(projectDir: string, exp: ExpoConfig): number | undefined {
|
||||
const workflow = resolveWorkflow(projectDir, Platform.ANDROID);
|
||||
export async function readVersionCodeAsync(
|
||||
projectDir: string,
|
||||
exp: ExpoConfig
|
||||
): Promise<number | undefined> {
|
||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.ANDROID);
|
||||
if (workflow === Workflow.GENERIC) {
|
||||
const buildGradle = readBuildGradle(projectDir);
|
||||
const matchResult = buildGradle?.match(/versionCode (.*)/);
|
||||
@@ -20,8 +23,11 @@ export function readVersionCode(projectDir: string, exp: ExpoConfig): number | u
|
||||
}
|
||||
}
|
||||
|
||||
export function readVersionName(projectDir: string, exp: ExpoConfig): string | undefined {
|
||||
const workflow = resolveWorkflow(projectDir, Platform.ANDROID);
|
||||
export async function readVersionNameAsync(
|
||||
projectDir: string,
|
||||
exp: ExpoConfig
|
||||
): Promise<string | undefined> {
|
||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.ANDROID);
|
||||
if (workflow === Workflow.GENERIC) {
|
||||
const buildGradle = readBuildGradle(projectDir);
|
||||
const matchResult = buildGradle?.match(/versionName ["'](.*)["']/);
|
||||
|
||||
@@ -102,6 +102,13 @@ export async function prepareBuildRequestForPlatformAsync<
|
||||
if (error?.graphQLErrors?.[0]?.extensions?.errorCode === 'TURTLE_DEPRECATED_JOB_FORMAT') {
|
||||
Log.error('EAS Build API has changed, please upgrade to the latest eas-cli version.');
|
||||
throw new Error('Build request failed.');
|
||||
} else if (
|
||||
error?.graphQLErrors?.[0]?.extensions?.errorCode === 'EAS_BUILD_DOWN_FOR_MAINTENANCE'
|
||||
) {
|
||||
Log.error(
|
||||
'EAS Build is down for maintenance, please try again later. Check https://status.expo.dev/ for updates.'
|
||||
);
|
||||
throw new Error('Build request failed.');
|
||||
} else if (
|
||||
error?.graphQLErrors?.[0]?.extensions?.errorCode === 'EAS_BUILD_TOO_MANY_PENDING_BUILDS'
|
||||
) {
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { getConfig } from '@expo/config';
|
||||
import { Platform, Workflow } from '@expo/eas-build-job';
|
||||
import { EasJsonReader } from '@expo/eas-json';
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
|
||||
import Log from '../log';
|
||||
import { resolveWorkflowAsync } from '../project/workflow';
|
||||
import { promptAsync } from '../prompts';
|
||||
import { ensureLoggedInAsync } from '../user/actions';
|
||||
import vcs from '../vcs';
|
||||
@@ -37,8 +39,10 @@ export async function configureAsync(options: {
|
||||
options.platform
|
||||
),
|
||||
shouldConfigureIos: [RequestedPlatform.All, RequestedPlatform.Ios].includes(options.platform),
|
||||
hasAndroidNativeProject: await fs.pathExists(path.join(options.projectDir, 'android')),
|
||||
hasIosNativeProject: await fs.pathExists(path.join(options.projectDir, 'ios')),
|
||||
hasAndroidNativeProject:
|
||||
(await resolveWorkflowAsync(options.projectDir, Platform.ANDROID)) === Workflow.GENERIC,
|
||||
hasIosNativeProject:
|
||||
(await resolveWorkflowAsync(options.projectDir, Platform.IOS)) === Workflow.GENERIC,
|
||||
};
|
||||
|
||||
Log.newLine();
|
||||
@@ -59,32 +63,40 @@ export async function configureAsync(options: {
|
||||
}
|
||||
}
|
||||
|
||||
const MANAGED_DEFAULTS = {
|
||||
const ANDROID_MANAGED_DEFAULTS = {
|
||||
release: {
|
||||
workflow: 'managed',
|
||||
buildType: 'app-bundle',
|
||||
},
|
||||
development: {
|
||||
workflow: 'managed',
|
||||
buildType: 'development-client',
|
||||
distribution: 'internal',
|
||||
},
|
||||
};
|
||||
const ANDROID_GENERIC_DEFAULTS = {
|
||||
release: {
|
||||
workflow: 'generic',
|
||||
gradleCommand: ':app:bundleRelease',
|
||||
},
|
||||
development: {
|
||||
workflow: 'generic',
|
||||
gradleCommand: ':app:assembleDebug',
|
||||
distribution: 'internal',
|
||||
},
|
||||
};
|
||||
const IOS_GENERIC_DEFAULTS = {
|
||||
|
||||
const IOS_MANAGED_DEFAULTS = {
|
||||
release: {
|
||||
workflow: 'generic',
|
||||
buildType: 'release',
|
||||
},
|
||||
development: {
|
||||
buildType: 'development-client',
|
||||
distribution: 'internal',
|
||||
},
|
||||
};
|
||||
|
||||
const IOS_GENERIC_DEFAULTS = {
|
||||
release: {
|
||||
schemeBuildConfiguration: 'Release',
|
||||
},
|
||||
development: {
|
||||
workflow: 'generic',
|
||||
schemeBuildConfiguration: 'Debug',
|
||||
distribution: 'internal',
|
||||
},
|
||||
@@ -121,15 +133,17 @@ export async function ensureEasJsonExistsAsync(ctx: ConfigureContext): Promise<v
|
||||
|
||||
const easJson = {
|
||||
builds: {
|
||||
...existingEasJson,
|
||||
...existingEasJson?.builds,
|
||||
...(shouldInitAndroid
|
||||
? {
|
||||
android: ctx.hasAndroidNativeProject ? ANDROID_GENERIC_DEFAULTS : MANAGED_DEFAULTS,
|
||||
android: ctx.hasAndroidNativeProject
|
||||
? ANDROID_GENERIC_DEFAULTS
|
||||
: ANDROID_MANAGED_DEFAULTS,
|
||||
}
|
||||
: null),
|
||||
...(shouldInitIOS
|
||||
? {
|
||||
ios: ctx.hasIosNativeProject ? IOS_GENERIC_DEFAULTS : MANAGED_DEFAULTS,
|
||||
ios: ctx.hasIosNativeProject ? IOS_GENERIC_DEFAULTS : IOS_MANAGED_DEFAULTS,
|
||||
}
|
||||
: null),
|
||||
},
|
||||
|
||||
@@ -6,6 +6,7 @@ import resolveFrom from 'resolve-from';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import { getProjectAccountName } from '../project/projectUtils';
|
||||
import { resolveWorkflowAsync } from '../project/workflow';
|
||||
import { findAccountByName } from '../user/Account';
|
||||
import { Actor } from '../user/User';
|
||||
import { ensureLoggedInAsync } from '../user/actions';
|
||||
@@ -92,9 +93,10 @@ export interface BuildContext<T extends Platform> {
|
||||
trackingCtx: TrackingContext;
|
||||
platform: T;
|
||||
buildProfile: PlatformBuildProfile<T>;
|
||||
workflow: Workflow;
|
||||
}
|
||||
|
||||
export function createBuildContext<T extends Platform>({
|
||||
export async function createBuildContextAsync<T extends Platform>({
|
||||
platform,
|
||||
easConfig,
|
||||
commandCtx,
|
||||
@@ -102,45 +104,58 @@ export function createBuildContext<T extends Platform>({
|
||||
platform: T;
|
||||
easConfig: EasConfig;
|
||||
commandCtx: CommandContext;
|
||||
}): BuildContext<T> {
|
||||
}): Promise<BuildContext<T>> {
|
||||
const buildProfile = easConfig.builds[platform] as PlatformBuildProfile<T> | undefined;
|
||||
if (!buildProfile) {
|
||||
throw new Error(`${platform} build profile does not exist`);
|
||||
}
|
||||
|
||||
const workflow = await resolveWorkflowAsync(commandCtx.projectDir, platform);
|
||||
const accountId = findAccountByName(commandCtx.user.accounts, commandCtx.accountName)?.id;
|
||||
const devClientProperties = getDevClientEventProperties(platform, commandCtx, buildProfile);
|
||||
const devClientProperties = getDevClientEventProperties({
|
||||
platform,
|
||||
projectDir: commandCtx.projectDir,
|
||||
buildProfile,
|
||||
workflow,
|
||||
});
|
||||
const trackingCtx = {
|
||||
tracking_id: uuidv4(),
|
||||
platform,
|
||||
...(accountId && { account_id: accountId }),
|
||||
account_name: commandCtx.accountName,
|
||||
project_id: commandCtx.projectId,
|
||||
project_type: buildProfile.workflow,
|
||||
project_type: workflow,
|
||||
...devClientProperties,
|
||||
};
|
||||
Analytics.logEvent(Event.BUILD_COMMAND, trackingCtx);
|
||||
return {
|
||||
commandCtx,
|
||||
workflow,
|
||||
trackingCtx,
|
||||
platform,
|
||||
buildProfile,
|
||||
};
|
||||
}
|
||||
|
||||
function getDevClientEventProperties(
|
||||
platform: Platform,
|
||||
commandCtx: CommandContext,
|
||||
buildProfile: AndroidBuildProfile | IosBuildProfile
|
||||
): Partial<TrackingContext> {
|
||||
function getDevClientEventProperties({
|
||||
platform,
|
||||
projectDir,
|
||||
buildProfile,
|
||||
workflow,
|
||||
}: {
|
||||
platform: Platform;
|
||||
projectDir: string;
|
||||
buildProfile: AndroidBuildProfile | IosBuildProfile;
|
||||
workflow: Workflow;
|
||||
}): Partial<TrackingContext> {
|
||||
let includesDevClient;
|
||||
const version = tryGetDevClientVersion(commandCtx.projectDir);
|
||||
if (buildProfile.workflow === Workflow.MANAGED) {
|
||||
includesDevClient = buildProfile.buildType === 'development-client';
|
||||
} else if (platform === Platform.ANDROID && 'gradleCommand' in buildProfile) {
|
||||
const version = tryGetDevClientVersion(projectDir);
|
||||
if (platform === Platform.ANDROID && 'gradleCommand' in buildProfile) {
|
||||
includesDevClient = Boolean(version && buildProfile.gradleCommand?.includes('Debug'));
|
||||
} else if (platform === Platform.IOS && 'schemeBuildConfiguration' in buildProfile) {
|
||||
includesDevClient = Boolean(version && buildProfile.schemeBuildConfiguration === 'Debug');
|
||||
} else if ('buildType' in buildProfile) {
|
||||
includesDevClient = buildProfile.buildType === 'development-client';
|
||||
} else {
|
||||
includesDevClient = false;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ function transformDistribution(distribution: Metadata['distribution']): Distribu
|
||||
}
|
||||
}
|
||||
|
||||
function transformWorkflow(workflow: Metadata['workflow']): BuildWorkflow {
|
||||
export function transformWorkflow(workflow: Workflow): BuildWorkflow {
|
||||
if (workflow === Workflow.GENERIC) {
|
||||
return BuildWorkflow.Generic;
|
||||
} else {
|
||||
|
||||
@@ -75,7 +75,7 @@ async function ensureUpdatesConfiguredAsync(projectDir: string, exp: ExpoConfig)
|
||||
|
||||
async function readExpoPlistAsync(projectDir: string): Promise<IOSConfig.ExpoPlist> {
|
||||
const expoPlistPath = IOSConfig.Paths.getExpoPlistPath(projectDir);
|
||||
return await readPlistAsync(expoPlistPath);
|
||||
return (await readPlistAsync(expoPlistPath)) as IOSConfig.ExpoPlist;
|
||||
}
|
||||
|
||||
async function writeExpoPlistAsync(
|
||||
|
||||
@@ -15,12 +15,7 @@ import {
|
||||
|
||||
jest.mock('fs');
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
// do not remove the following line
|
||||
// this fixes a weird error with tempy in @expo/image-utils
|
||||
fs.removeSync(os.tmpdir());
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
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 path from 'path';
|
||||
|
||||
import { IosCredentials } from '../../credentials/ios/types';
|
||||
import { BuildMutation, BuildResult } from '../../graphql/mutations/BuildMutation';
|
||||
@@ -10,37 +7,26 @@ import { ensureBundleIdentifierIsDefinedForManagedProjectAsync } from '../../pro
|
||||
import { resolveXcodeBuildContextAsync } from '../../project/ios/scheme';
|
||||
import { resolveTargetsAsync } from '../../project/ios/target';
|
||||
import { JobData, prepareBuildRequestForPlatformAsync } from '../build';
|
||||
import { BuildContext, CommandContext, createBuildContext } from '../context';
|
||||
import { BuildContext, CommandContext, createBuildContextAsync } from '../context';
|
||||
import { transformMetadata } from '../graphql';
|
||||
import { Platform } from '../types';
|
||||
import { validateAndSyncProjectConfigurationAsync } from './configure';
|
||||
import { ensureIosCredentialsAsync } from './credentials';
|
||||
import { transformGenericJob, transformManagedJob } from './graphql';
|
||||
import { transformJob } from './graphql';
|
||||
import { prepareJobAsync } from './prepareJob';
|
||||
|
||||
export async function prepareIosBuildAsync(
|
||||
commandCtx: CommandContext,
|
||||
easConfig: EasConfig
|
||||
): Promise<() => Promise<string | undefined>> {
|
||||
const buildCtx = createBuildContext<Platform.IOS>({
|
||||
const buildCtx = await createBuildContextAsync<Platform.IOS>({
|
||||
commandCtx,
|
||||
platform: Platform.IOS,
|
||||
easConfig,
|
||||
});
|
||||
const { buildProfile } = buildCtx;
|
||||
|
||||
if (
|
||||
buildProfile.workflow === Workflow.GENERIC &&
|
||||
!(await fs.pathExists(path.join(commandCtx.projectDir, 'ios')))
|
||||
) {
|
||||
throw new Error(
|
||||
`"ios" directory not found. If you're trying to build a managed project, set ${chalk.bold(
|
||||
`builds.ios.${commandCtx.profile}.workflow`
|
||||
)} in "eas.json" to "managed".`
|
||||
);
|
||||
}
|
||||
|
||||
if (buildProfile.workflow === Workflow.MANAGED) {
|
||||
if (buildCtx.workflow === Workflow.MANAGED) {
|
||||
await ensureBundleIdentifierIsDefinedForManagedProjectAsync(
|
||||
commandCtx.projectDir,
|
||||
commandCtx.exp
|
||||
@@ -87,21 +73,12 @@ export async function prepareIosBuildAsync(
|
||||
metadata: Metadata
|
||||
): Promise<BuildResult> => {
|
||||
const graphqlMetadata = transformMetadata(metadata);
|
||||
if (job.type === Workflow.GENERIC) {
|
||||
const graphqlJob = transformGenericJob(job);
|
||||
return await BuildMutation.createIosGenericBuildAsync({
|
||||
appId,
|
||||
job: graphqlJob,
|
||||
metadata: graphqlMetadata,
|
||||
});
|
||||
} else {
|
||||
const graphqlJob = transformManagedJob(job);
|
||||
return await BuildMutation.createIosManagedBuildAsync({
|
||||
appId,
|
||||
job: graphqlJob,
|
||||
metadata: graphqlMetadata,
|
||||
});
|
||||
}
|
||||
const graphqlJob = transformJob(job);
|
||||
return await BuildMutation.createIosBuildAsync({
|
||||
appId,
|
||||
job: graphqlJob,
|
||||
metadata: graphqlMetadata,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ExpoConfig } from '@expo/config';
|
||||
import { Workflow } from '@expo/eas-build-job';
|
||||
import { Platform, Workflow } from '@expo/eas-build-job';
|
||||
import { IosBuildProfile, VersionAutoIncrement } from '@expo/eas-json';
|
||||
|
||||
import Log from '../../log';
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
ensureBundleIdentifierIsDefinedForManagedProjectAsync,
|
||||
warnIfBundleIdentifierDefinedInAppConfigForGenericProject,
|
||||
} from '../../project/ios/bundleIdentifier';
|
||||
import { resolveWorkflowAsync } from '../../project/workflow';
|
||||
import { ConfigureContext } from '../context';
|
||||
import { isExpoUpdatesInstalled } from '../utils/updates';
|
||||
import { configureUpdatesAsync, syncUpdatesConfigurationAsync } from './UpdatesModule';
|
||||
@@ -35,7 +36,8 @@ export async function validateAndSyncProjectConfigurationAsync({
|
||||
exp: ExpoConfig;
|
||||
buildProfile: IosBuildProfile;
|
||||
}): Promise<void> {
|
||||
const { workflow, autoIncrement } = buildProfile;
|
||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.IOS);
|
||||
const { autoIncrement } = buildProfile;
|
||||
const versionBumpStrategy = resolveVersionBumpStrategy(autoIncrement);
|
||||
|
||||
if (workflow === Workflow.GENERIC) {
|
||||
|
||||
@@ -28,7 +28,7 @@ export async function ensureIosCredentialsAsync(
|
||||
iosCapabilitiesOptions: {
|
||||
entitlements: await resolveEntitlementsJsonAsync(
|
||||
buildCtx.commandCtx.projectDir,
|
||||
buildCtx.buildProfile.workflow
|
||||
buildCtx.workflow
|
||||
),
|
||||
},
|
||||
distribution: buildCtx.buildProfile.distribution ?? 'store',
|
||||
|
||||
@@ -3,15 +3,15 @@ import nullthrows from 'nullthrows';
|
||||
|
||||
import {
|
||||
DistributionType,
|
||||
IosGenericJobInput,
|
||||
IosBuildType,
|
||||
IosJobInput,
|
||||
IosJobSecretsInput,
|
||||
IosManagedBuildType,
|
||||
IosManagedJobInput,
|
||||
} from '../../graphql/generated';
|
||||
import { transformProjectArchive } from '../graphql';
|
||||
import { transformProjectArchive, transformWorkflow } from '../graphql';
|
||||
|
||||
export function transformGenericJob(job: Ios.GenericJob): IosGenericJobInput {
|
||||
export function transformJob(job: Ios.Job): IosJobInput {
|
||||
return {
|
||||
type: transformWorkflow(job.type),
|
||||
projectArchive: transformProjectArchive(job.projectArchive),
|
||||
projectRootDirectory: job.projectRootDirectory,
|
||||
releaseChannel: job.releaseChannel,
|
||||
@@ -20,22 +20,11 @@ export function transformGenericJob(job: Ios.GenericJob): IosGenericJobInput {
|
||||
secrets: transformIosSecrets(job.secrets),
|
||||
builderEnvironment: job.builderEnvironment,
|
||||
cache: job.cache,
|
||||
|
||||
scheme: job.scheme,
|
||||
buildConfiguration: job.buildConfiguration,
|
||||
artifactPath: job.artifactPath,
|
||||
};
|
||||
}
|
||||
|
||||
export function transformManagedJob(job: Ios.ManagedJob): IosManagedJobInput {
|
||||
return {
|
||||
projectArchive: transformProjectArchive(job.projectArchive),
|
||||
projectRootDirectory: job.projectRootDirectory,
|
||||
releaseChannel: job.releaseChannel,
|
||||
updates: job.updates,
|
||||
distribution: job.distribution && transformDistributionType(job.distribution),
|
||||
secrets: transformIosSecrets(job.secrets),
|
||||
builderEnvironment: job.builderEnvironment,
|
||||
cache: job.cache,
|
||||
buildType: job.buildType && transformBuildType(job.buildType),
|
||||
username: job.username,
|
||||
};
|
||||
@@ -73,10 +62,10 @@ function transformIosSecrets(secrets: {
|
||||
};
|
||||
}
|
||||
|
||||
function transformBuildType(buildType: Ios.ManagedBuildType): IosManagedBuildType {
|
||||
if (buildType === Ios.ManagedBuildType.DEVELOPMENT_CLIENT) {
|
||||
return IosManagedBuildType.DevelopmentClient;
|
||||
function transformBuildType(buildType: Ios.BuildType): IosBuildType {
|
||||
if (buildType === Ios.BuildType.DEVELOPMENT_CLIENT) {
|
||||
return IosBuildType.DevelopmentClient;
|
||||
} else {
|
||||
return IosManagedBuildType.Release;
|
||||
return IosBuildType.Release;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ArchiveSource, Cache, Ios, Job, Workflow, sanitizeJob } from '@expo/eas-build-job';
|
||||
import { IosGenericBuildProfile, IosManagedBuildProfile } from '@expo/eas-json';
|
||||
import { ArchiveSource, Ios, Job, sanitizeJob } from '@expo/eas-build-job';
|
||||
import path from 'path';
|
||||
import semver from 'semver';
|
||||
|
||||
import { IosCredentials, TargetCredentials } from '../../credentials/ios/types';
|
||||
import { getUsername } from '../../project/projectUtils';
|
||||
@@ -19,47 +19,25 @@ export async function prepareJobAsync(
|
||||
ctx: BuildContext<Platform.IOS>,
|
||||
jobData: JobData
|
||||
): Promise<Job> {
|
||||
if (ctx.buildProfile.workflow === Workflow.GENERIC) {
|
||||
const partialJob = await prepareGenericJobAsync(ctx, jobData, ctx.buildProfile);
|
||||
return sanitizeJob(partialJob);
|
||||
} else if (ctx.buildProfile.workflow === Workflow.MANAGED) {
|
||||
const partialJob = await prepareManagedJobAsync(ctx, jobData, ctx.buildProfile);
|
||||
return sanitizeJob(partialJob);
|
||||
} else {
|
||||
throw new Error("Unknown workflow. Shouldn't happen");
|
||||
}
|
||||
}
|
||||
|
||||
interface CommonJobProperties {
|
||||
platform: Platform.IOS;
|
||||
projectArchive: ArchiveSource;
|
||||
builderEnvironment: Ios.BuilderEnvironment;
|
||||
distribution?: Ios.DistributionType;
|
||||
cache: Cache;
|
||||
secrets: {
|
||||
buildCredentials: Ios.BuildCredentials;
|
||||
environmentSecrets?: Record<string, string>;
|
||||
};
|
||||
}
|
||||
|
||||
async function prepareJobCommonAsync(
|
||||
ctx: BuildContext<Platform.IOS>,
|
||||
{ credentials, projectArchive }: { credentials?: IosCredentials; projectArchive: ArchiveSource }
|
||||
): Promise<Partial<CommonJobProperties>> {
|
||||
const buildCredentials: CommonJobProperties['secrets']['buildCredentials'] = {};
|
||||
if (credentials) {
|
||||
const targetNames = Object.keys(credentials);
|
||||
const projectRootDirectory =
|
||||
path.relative(await vcs.getRootPathAsync(), ctx.commandCtx.projectDir) || '.';
|
||||
const username = getUsername(ctx.commandCtx.exp, await ensureLoggedInAsync());
|
||||
const buildCredentials: Ios.Job['secrets']['buildCredentials'] = {};
|
||||
if (jobData.credentials) {
|
||||
const targetNames = Object.keys(jobData.credentials);
|
||||
for (const targetName of targetNames) {
|
||||
buildCredentials[targetName] = prepareTargetCredentials(credentials[targetName]);
|
||||
buildCredentials[targetName] = prepareTargetCredentials(jobData.credentials[targetName]);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
const job = {
|
||||
type: ctx.workflow,
|
||||
platform: Platform.IOS,
|
||||
projectArchive,
|
||||
projectArchive: jobData.projectArchive,
|
||||
projectRootDirectory,
|
||||
distribution: ctx.buildProfile.distribution,
|
||||
builderEnvironment: {
|
||||
image: ctx.buildProfile.image,
|
||||
image: resolveImage(ctx),
|
||||
node: ctx.buildProfile.node,
|
||||
yarn: ctx.buildProfile.yarn,
|
||||
bundler: ctx.buildProfile.bundler,
|
||||
@@ -75,7 +53,29 @@ async function prepareJobCommonAsync(
|
||||
secrets: {
|
||||
buildCredentials,
|
||||
},
|
||||
releaseChannel: ctx.buildProfile.releaseChannel,
|
||||
updates: { channel: ctx.buildProfile.channel },
|
||||
|
||||
scheme: jobData.buildScheme,
|
||||
buildConfiguration: ctx.buildProfile.schemeBuildConfiguration,
|
||||
artifactPath: ctx.buildProfile.artifactPath,
|
||||
|
||||
buildType: ctx.buildProfile.buildType,
|
||||
username,
|
||||
};
|
||||
|
||||
return sanitizeJob(job);
|
||||
}
|
||||
|
||||
function resolveImage(ctx: BuildContext<Platform.IOS>): Ios.BuilderEnvironment['image'] {
|
||||
// see https://linear.app/expo/issue/ENG-1396/make-default-image-dependent-on-sdk-version
|
||||
if (!ctx.buildProfile.image && ctx.commandCtx.exp.sdkVersion) {
|
||||
const majorSdkVersion = semver.major(ctx.commandCtx.exp.sdkVersion);
|
||||
if (majorSdkVersion <= 41) {
|
||||
return 'macos-catalina-10.15-xcode-12.4';
|
||||
}
|
||||
}
|
||||
return ctx.buildProfile.image ?? 'default';
|
||||
}
|
||||
|
||||
function prepareTargetCredentials(targetCredentials: TargetCredentials): Ios.TargetCredentials {
|
||||
@@ -87,47 +87,3 @@ function prepareTargetCredentials(targetCredentials: TargetCredentials): Ios.Tar
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
async function prepareGenericJobAsync(
|
||||
ctx: BuildContext<Platform.IOS>,
|
||||
jobData: JobData,
|
||||
buildProfile: IosGenericBuildProfile
|
||||
): Promise<Partial<Ios.GenericJob>> {
|
||||
const projectRootDirectory =
|
||||
path.relative(await vcs.getRootPathAsync(), ctx.commandCtx.projectDir) || '.';
|
||||
return {
|
||||
...(await prepareJobCommonAsync(ctx, {
|
||||
credentials: jobData.credentials,
|
||||
projectArchive: jobData.projectArchive,
|
||||
})),
|
||||
type: Workflow.GENERIC,
|
||||
scheme: jobData.buildScheme,
|
||||
buildConfiguration: buildProfile.schemeBuildConfiguration,
|
||||
artifactPath: buildProfile.artifactPath,
|
||||
releaseChannel: buildProfile.releaseChannel,
|
||||
updates: { channel: buildProfile.channel },
|
||||
projectRootDirectory,
|
||||
};
|
||||
}
|
||||
|
||||
async function prepareManagedJobAsync(
|
||||
ctx: BuildContext<Platform.IOS>,
|
||||
jobData: JobData,
|
||||
buildProfile: IosManagedBuildProfile
|
||||
): Promise<Partial<Ios.ManagedJob>> {
|
||||
const projectRootDirectory =
|
||||
path.relative(await vcs.getRootPathAsync(), ctx.commandCtx.projectDir) || '.';
|
||||
const username = getUsername(ctx.commandCtx.exp, await ensureLoggedInAsync());
|
||||
return {
|
||||
...(await prepareJobCommonAsync(ctx, {
|
||||
credentials: jobData.credentials,
|
||||
projectArchive: jobData.projectArchive,
|
||||
})),
|
||||
type: Workflow.MANAGED,
|
||||
buildType: buildProfile.buildType,
|
||||
username,
|
||||
releaseChannel: buildProfile.releaseChannel,
|
||||
updates: { channel: buildProfile.channel },
|
||||
projectRootDirectory,
|
||||
};
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import nullthrows from 'nullthrows';
|
||||
import semver from 'semver';
|
||||
|
||||
import Log from '../../log';
|
||||
import { resolveWorkflow } from '../../project/workflow';
|
||||
import { resolveWorkflowAsync } from '../../project/workflow';
|
||||
import { promptAsync } from '../../prompts';
|
||||
import { updateAppJsonConfigAsync } from '../utils/appJson';
|
||||
import { readPlistAsync, writePlistAsync } from './plist';
|
||||
@@ -106,7 +106,7 @@ export async function readShortVersionAsync(
|
||||
projectDir: string,
|
||||
exp: ExpoConfig
|
||||
): Promise<string | undefined> {
|
||||
const workflow = resolveWorkflow(projectDir, Platform.IOS);
|
||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.IOS);
|
||||
if (workflow === Workflow.GENERIC) {
|
||||
const infoPlist = await readInfoPlistAsync(projectDir);
|
||||
return infoPlist.CFBundleShortVersionString;
|
||||
@@ -119,7 +119,7 @@ export async function readBuildNumberAsync(
|
||||
projectDir: string,
|
||||
exp: ExpoConfig
|
||||
): Promise<string | undefined> {
|
||||
const workflow = resolveWorkflow(projectDir, Platform.IOS);
|
||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.IOS);
|
||||
if (workflow === Workflow.GENERIC) {
|
||||
const infoPlist = await readInfoPlistAsync(projectDir);
|
||||
return infoPlist.CFBundleVersion;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Metadata } from '@expo/eas-build-job';
|
||||
import { CredentialsSource } from '@expo/eas-json';
|
||||
|
||||
import { getApplicationId } from '../project/android/applicationId';
|
||||
import { getBundleIdentifier } from '../project/ios/bundleIdentifier';
|
||||
import { getApplicationIdAsync } from '../project/android/applicationId';
|
||||
import { getBundleIdentifierAsync } from '../project/ios/bundleIdentifier';
|
||||
import { getUsername } from '../project/projectUtils';
|
||||
import { ensureLoggedInAsync } from '../user/actions';
|
||||
import vcs from '../vcs';
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
readChannelSafelyAsync as readAndroidChannelSafelyAsync,
|
||||
readReleaseChannelSafelyAsync as readAndroidReleaseChannelSafelyAsync,
|
||||
} from './android/UpdatesModule';
|
||||
import { readVersionCode, readVersionName } from './android/version';
|
||||
import { readVersionCodeAsync, readVersionNameAsync } from './android/version';
|
||||
import { BuildContext } from './context';
|
||||
import {
|
||||
readChannelSafelyAsync as readIosChannelSafelyAsync,
|
||||
@@ -37,20 +37,18 @@ export async function collectMetadata<T extends Platform>(
|
||||
): Promise<Metadata> {
|
||||
const channelOrReleaseChannel = await resolveChannelOrReleaseChannelAsync(ctx);
|
||||
return {
|
||||
// TODO: type error fixed in https://github.com/expo/eas-build/pull/34
|
||||
// remove @ts-expect-error after upgrading @expo/eas-build-job
|
||||
// @ts-expect-error error TS2322: not assignable to type 'Record<string, string | number>'
|
||||
trackingContext: ctx.trackingCtx,
|
||||
appVersion: await resolveAppVersionAsync(ctx),
|
||||
appBuildVersion: await resolveAppBuildVersionAsync(ctx),
|
||||
cliVersion: packageJSON.version,
|
||||
workflow: ctx.buildProfile.workflow,
|
||||
workflow: ctx.workflow,
|
||||
credentialsSource,
|
||||
sdkVersion: ctx.commandCtx.exp.sdkVersion,
|
||||
runtimeVersion: ctx.commandCtx.exp.runtimeVersion,
|
||||
...channelOrReleaseChannel,
|
||||
distribution: ctx.buildProfile.distribution ?? 'store',
|
||||
appName: ctx.commandCtx.exp.name,
|
||||
appIdentifier: resolveAppIdentifier(ctx),
|
||||
appIdentifier: await resolveAppIdentifierAsync(ctx),
|
||||
buildProfile: ctx.commandCtx.profile,
|
||||
gitCommitHash: await vcs.getCommitHashAsync(),
|
||||
username: getUsername(ctx.commandCtx.exp, await ensureLoggedInAsync()),
|
||||
@@ -63,7 +61,7 @@ async function resolveAppVersionAsync<T extends Platform>(
|
||||
if (ctx.platform === Platform.IOS) {
|
||||
return await readShortVersionAsync(ctx.commandCtx.projectDir, ctx.commandCtx.exp);
|
||||
} else {
|
||||
return readVersionName(ctx.commandCtx.projectDir, ctx.commandCtx.exp);
|
||||
return await readVersionNameAsync(ctx.commandCtx.projectDir, ctx.commandCtx.exp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,16 +71,18 @@ async function resolveAppBuildVersionAsync<T extends Platform>(
|
||||
if (ctx.platform === Platform.IOS) {
|
||||
return await readBuildNumberAsync(ctx.commandCtx.projectDir, ctx.commandCtx.exp);
|
||||
} else {
|
||||
const versionCode = readVersionCode(ctx.commandCtx.projectDir, ctx.commandCtx.exp);
|
||||
const versionCode = await readVersionCodeAsync(ctx.commandCtx.projectDir, ctx.commandCtx.exp);
|
||||
return versionCode !== undefined ? String(versionCode) : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function resolveAppIdentifier<T extends Platform>(ctx: BuildContext<T>): string {
|
||||
async function resolveAppIdentifierAsync<T extends Platform>(
|
||||
ctx: BuildContext<T>
|
||||
): Promise<string> {
|
||||
if (ctx.platform === Platform.IOS) {
|
||||
return getBundleIdentifier(ctx.commandCtx.projectDir, ctx.commandCtx.exp);
|
||||
return await getBundleIdentifierAsync(ctx.commandCtx.projectDir, ctx.commandCtx.exp);
|
||||
} else {
|
||||
return getApplicationId(ctx.commandCtx.projectDir, ctx.commandCtx.exp);
|
||||
return await getApplicationIdAsync(ctx.commandCtx.projectDir, ctx.commandCtx.exp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import chalk from 'chalk';
|
||||
|
||||
import { BuildFragment, BuildStatus as GraphQLBuildStatus } from '../../graphql/generated';
|
||||
import {
|
||||
AppPlatform,
|
||||
BuildFragment,
|
||||
BuildStatus as GraphQLBuildStatus,
|
||||
} from '../../graphql/generated';
|
||||
import formatFields from '../../utils/formatFields';
|
||||
import { appPlatformDisplayNames } from '../constants';
|
||||
import { getBuildLogsUrl } from './url';
|
||||
@@ -8,7 +12,7 @@ import { getBuildLogsUrl } from './url';
|
||||
export function formatGraphQLBuild(build: BuildFragment) {
|
||||
const actor = getActorName(build);
|
||||
const account = build.project.__typename === 'App' ? build.project.ownerAccount.name : 'unknown';
|
||||
const fields: { label: string; value: string }[] = [
|
||||
const fields: { label: string; value?: string | null }[] = [
|
||||
{ label: 'ID', value: build.id },
|
||||
{
|
||||
label: 'Platform',
|
||||
@@ -37,11 +41,35 @@ export function formatGraphQLBuild(build: BuildFragment) {
|
||||
},
|
||||
{
|
||||
label: 'Distribution',
|
||||
value: build.distribution?.toLowerCase() ?? chalk.gray('unknown'),
|
||||
value: build.distribution?.toLowerCase(),
|
||||
},
|
||||
{
|
||||
label: 'Release Channel',
|
||||
value: build.releaseChannel ?? chalk.gray('unknown'),
|
||||
value: build.releaseChannel,
|
||||
},
|
||||
{
|
||||
label: 'Channel',
|
||||
value: build.channel,
|
||||
},
|
||||
{
|
||||
label: 'SDK Version',
|
||||
value: build.sdkVersion,
|
||||
},
|
||||
{
|
||||
label: 'Runtime Version',
|
||||
value: build.runtimeVersion,
|
||||
},
|
||||
{
|
||||
label: 'Version',
|
||||
value: build.appVersion,
|
||||
},
|
||||
{
|
||||
label: build.platform === AppPlatform.Android ? 'Version code' : 'Build number',
|
||||
value: build.appBuildVersion,
|
||||
},
|
||||
{
|
||||
label: 'Commit',
|
||||
value: build.gitCommitHash,
|
||||
},
|
||||
{
|
||||
label: 'Logs',
|
||||
@@ -57,13 +85,13 @@ export function formatGraphQLBuild(build: BuildFragment) {
|
||||
return '<in progress>';
|
||||
case GraphQLBuildStatus.Canceled:
|
||||
case GraphQLBuildStatus.Errored:
|
||||
return '---------';
|
||||
return null;
|
||||
case GraphQLBuildStatus.Finished: {
|
||||
const url = build.artifacts?.buildUrl;
|
||||
return url ? url : chalk.red('not found');
|
||||
}
|
||||
default:
|
||||
return 'unknown';
|
||||
return null;
|
||||
}
|
||||
},
|
||||
},
|
||||
@@ -81,7 +109,11 @@ export function formatGraphQLBuild(build: BuildFragment) {
|
||||
{ label: 'Started by', value: actor ?? 'unknown' },
|
||||
];
|
||||
|
||||
return formatFields(fields);
|
||||
const filteredFields = fields.filter(({ value }) => value !== undefined && value !== null) as {
|
||||
label: string;
|
||||
value: string;
|
||||
}[];
|
||||
return formatFields(filteredFields);
|
||||
}
|
||||
|
||||
const getActorName = (build: BuildFragment): string => {
|
||||
|
||||
@@ -85,7 +85,7 @@ function printBuildResult(accountName: string, build: BuildFragment): void {
|
||||
account: accountName,
|
||||
});
|
||||
const installUrl = getInternalDistributionInstallUrl(build);
|
||||
qrcodeTerminal.generate(installUrl, code => console.log(`${indentString(code, 2)}\n`));
|
||||
qrcodeTerminal.generate(installUrl, code => Log.log(`${indentString(code, 2)}\n`));
|
||||
Log.log(
|
||||
`${appPlatformEmojis[build.platform]} Open this link on your ${
|
||||
appPlatformDisplayNames[build.platform]
|
||||
|
||||
@@ -13,7 +13,7 @@ import { endTimer, formatMilliseconds, startTimer } from '../../utils/timer';
|
||||
import vcs from '../../vcs';
|
||||
|
||||
export async function maybeBailOnRepoStatusAsync(): Promise<void> {
|
||||
if (await vcs.hasUncommittedChangesAsync()) {
|
||||
if (!(await vcs.hasUncommittedChangesAsync())) {
|
||||
return;
|
||||
}
|
||||
Log.addNewLineIfNone();
|
||||
|
||||
@@ -22,7 +22,7 @@ import { promptAsync, toggleConfirmAsync } from '../../prompts';
|
||||
async function getBranchInfoAsync({
|
||||
appId,
|
||||
name,
|
||||
}: GetBranchInfoQueryVariables): Promise<{ branchId: string }> {
|
||||
}: GetBranchInfoQueryVariables): Promise<GetBranchInfoQuery> {
|
||||
const data = await withErrorHandlingAsync(
|
||||
graphqlClient
|
||||
.query<GetBranchInfoQuery, GetBranchInfoQueryVariables>(
|
||||
@@ -46,11 +46,7 @@ async function getBranchInfoAsync({
|
||||
)
|
||||
.toPromise()
|
||||
);
|
||||
const branchId = data.app?.byId.updateBranchByName?.id;
|
||||
if (!branchId) {
|
||||
throw new Error(`Could not find branch ${name} on ${appId}`);
|
||||
}
|
||||
return { branchId };
|
||||
return data;
|
||||
}
|
||||
|
||||
async function deleteBranchOnAppAsync({
|
||||
@@ -122,7 +118,11 @@ export default class BranchDelete extends Command {
|
||||
}));
|
||||
}
|
||||
|
||||
const { branchId } = await getBranchInfoAsync({ appId: projectId, name });
|
||||
const data = await getBranchInfoAsync({ appId: projectId, name });
|
||||
const branchId = data.app?.byId.updateBranchByName?.id;
|
||||
if (!branchId) {
|
||||
throw new Error(`Could not find branch ${name} on ${fullName}`);
|
||||
}
|
||||
|
||||
if (!jsonFlag) {
|
||||
Log.addNewLineIfNone();
|
||||
|
||||
@@ -100,6 +100,8 @@ export default class BranchList extends Command {
|
||||
}),
|
||||
])
|
||||
);
|
||||
|
||||
Log.addNewLineIfNone();
|
||||
Log.log(chalk.bold('Branches with their most recent update group:'));
|
||||
Log.log(table.toString());
|
||||
if (branches.length >= BRANCHES_LIMIT) {
|
||||
|
||||
@@ -3,7 +3,6 @@ import { getRuntimeVersionForSDKVersion } from '@expo/sdk-runtime-versions';
|
||||
import { Command, flags } from '@oclif/command';
|
||||
import assert from 'assert';
|
||||
import chalk from 'chalk';
|
||||
import Table from 'cli-table3';
|
||||
import dateFormat from 'dateformat';
|
||||
import gql from 'graphql-tag';
|
||||
import { uniqBy } from 'lodash';
|
||||
@@ -19,11 +18,7 @@ import {
|
||||
} from '../../graphql/generated';
|
||||
import { PublishMutation } from '../../graphql/mutations/PublishMutation';
|
||||
import Log from '../../log';
|
||||
import {
|
||||
findProjectRootAsync,
|
||||
getProjectAccountNameAsync,
|
||||
getProjectIdAsync,
|
||||
} from '../../project/projectUtils';
|
||||
import { findProjectRootAsync, getProjectIdAsync } from '../../project/projectUtils';
|
||||
import {
|
||||
PublishPlatform,
|
||||
buildBundlesAsync,
|
||||
@@ -33,6 +28,7 @@ import {
|
||||
} from '../../project/publish';
|
||||
import { promptAsync, selectAsync } from '../../prompts';
|
||||
import { formatUpdate } from '../../update/utils';
|
||||
import formatFields from '../../utils/formatFields';
|
||||
import vcs from '../../vcs';
|
||||
import { listBranchesAsync } from './list';
|
||||
import { viewUpdateBranchAsync } from './view';
|
||||
@@ -135,8 +131,7 @@ export default class BranchPublish extends Command {
|
||||
}
|
||||
|
||||
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
|
||||
const accountName = await getProjectAccountNameAsync(exp);
|
||||
let { slug, runtimeVersion, sdkVersion } = exp;
|
||||
let { runtimeVersion, sdkVersion } = exp;
|
||||
|
||||
// When a SDK version is supplied instead of a runtime version and we're in the managed workflow
|
||||
// construct the runtimeVersion with special meaning indicating that the runtime is an
|
||||
@@ -307,35 +302,14 @@ export default class BranchPublish extends Command {
|
||||
if (jsonFlag) {
|
||||
Log.log(JSON.stringify(newUpdateGroup));
|
||||
} else {
|
||||
const outputMessage = new Table({
|
||||
wordWrap: true,
|
||||
chars: {
|
||||
top: '',
|
||||
'top-mid': '',
|
||||
'top-left': '',
|
||||
'top-right': '',
|
||||
bottom: '',
|
||||
'bottom-mid': '',
|
||||
'bottom-left': '',
|
||||
'bottom-right': '',
|
||||
left: '',
|
||||
'left-mid': '',
|
||||
mid: '',
|
||||
'mid-mid': '',
|
||||
right: '',
|
||||
'right-mid': '',
|
||||
middle: ' ',
|
||||
},
|
||||
style: { 'padding-left': 0, 'padding-right': 0 },
|
||||
});
|
||||
outputMessage.push(
|
||||
[chalk.dim('project'), `@${accountName}/${slug}`],
|
||||
[chalk.dim('branch'), name],
|
||||
[chalk.dim('runtimeVersion'), runtimeVersion],
|
||||
[chalk.dim('groupID'), newUpdateGroup.group],
|
||||
[chalk.dim('message'), message]
|
||||
Log.log(
|
||||
formatFields([
|
||||
{ label: 'branch', value: name },
|
||||
{ label: 'runtime version', value: runtimeVersion },
|
||||
{ label: 'update group ID', value: newUpdateGroup.group },
|
||||
{ label: 'message', value: message },
|
||||
])
|
||||
);
|
||||
Log.log(outputMessage.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,10 @@ import {
|
||||
ViewBranchQueryVariables,
|
||||
} from '../../graphql/generated';
|
||||
import Log from '../../log';
|
||||
import {
|
||||
findProjectRootAsync,
|
||||
getProjectFullNameAsync,
|
||||
getProjectIdAsync,
|
||||
} from '../../project/projectUtils';
|
||||
import { findProjectRootAsync, getProjectIdAsync } from '../../project/projectUtils';
|
||||
import { promptAsync } from '../../prompts';
|
||||
import { UPDATE_COLUMNS, formatUpdate, getPlatformsForGroup } from '../../update/utils';
|
||||
import formatFields from '../../utils/formatFields';
|
||||
|
||||
const PAGE_LIMIT = 10_000;
|
||||
|
||||
@@ -121,7 +118,6 @@ export default class BranchView extends Command {
|
||||
}
|
||||
|
||||
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
|
||||
const fullName = await getProjectFullNameAsync(exp);
|
||||
const projectId = await getProjectIdAsync(exp);
|
||||
|
||||
if (!name) {
|
||||
@@ -168,12 +164,16 @@ export default class BranchView extends Command {
|
||||
]);
|
||||
}
|
||||
|
||||
Log.withTick(
|
||||
`️Branch: ${chalk.bold(UpdateBranch.name)} on project ${chalk.bold(
|
||||
fullName
|
||||
)}. Branch ID: ${chalk.bold(UpdateBranch.id)}`
|
||||
Log.addNewLineIfNone();
|
||||
Log.log(chalk.bold('Branch:'));
|
||||
Log.log(
|
||||
formatFields([
|
||||
{ label: 'Name', value: UpdateBranch.name },
|
||||
{ label: 'ID', value: UpdateBranch.id },
|
||||
])
|
||||
);
|
||||
Log.log(chalk.bold('Recent update groups published on this branch:'));
|
||||
Log.addNewLineIfNone();
|
||||
Log.log(chalk.bold('Recently published update groups:'));
|
||||
Log.log(groupTable.toString());
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ExpoConfig, getConfig } from '@expo/config';
|
||||
import { EasJsonReader } from '@expo/eas-json';
|
||||
import { flags } from '@oclif/command';
|
||||
import chalk from 'chalk';
|
||||
import fs from 'fs-extra';
|
||||
@@ -87,7 +88,7 @@ export default class Build extends EasCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
exp = (await ensureProjectConfiguredAsync(projectDir)) ?? exp;
|
||||
exp = (await ensureProjectConfiguredAsync(projectDir, platform)) ?? exp;
|
||||
|
||||
const commandCtx = await createCommandContextAsync({
|
||||
requestedPlatform: platform,
|
||||
@@ -101,6 +102,7 @@ export default class Build extends EasCommand {
|
||||
skipProjectConfiguration: flags['skip-project-configuration'],
|
||||
waitForBuildEnd: flags.wait,
|
||||
});
|
||||
|
||||
await buildAsync(commandCtx);
|
||||
}
|
||||
}
|
||||
@@ -140,17 +142,29 @@ async function promptForPlatformAsync(): Promise<RequestedPlatform> {
|
||||
return platform;
|
||||
}
|
||||
|
||||
async function ensureProjectConfiguredAsync(projectDir: string): Promise<ExpoConfig | null> {
|
||||
if (await fs.pathExists(path.join(projectDir, 'eas.json'))) {
|
||||
async function ensureProjectConfiguredAsync(
|
||||
projectDir: string,
|
||||
platform: RequestedPlatform
|
||||
): Promise<ExpoConfig | null> {
|
||||
const platformsToConfigure = await getPlatformsToConfigureAsync(projectDir, platform);
|
||||
|
||||
if (!platformsToConfigure) {
|
||||
return null;
|
||||
}
|
||||
const confirm = await confirmAsync({
|
||||
message: 'This app is not set up for building with EAS. Set it up now?',
|
||||
});
|
||||
|
||||
// Ensure the prompt is consistent with the platforms we need to configure
|
||||
let message = 'This project is not configured to build with EAS. Set it up now?';
|
||||
if (platformsToConfigure === RequestedPlatform.Ios) {
|
||||
message = 'Your iOS project is not configured to build with EAS. Set it up now?';
|
||||
} else if (platformsToConfigure === RequestedPlatform.Android) {
|
||||
message = 'Your Android project is not configured to build with EAS. Set it up now?';
|
||||
}
|
||||
|
||||
const confirm = await confirmAsync({ message });
|
||||
if (confirm) {
|
||||
await configureAsync({
|
||||
projectDir,
|
||||
platform: RequestedPlatform.All,
|
||||
platform: platformsToConfigure,
|
||||
});
|
||||
if (await vcs.hasUncommittedChangesAsync()) {
|
||||
throw new Error(
|
||||
@@ -167,3 +181,30 @@ async function ensureProjectConfiguredAsync(projectDir: string): Promise<ExpoCon
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function getPlatformsToConfigureAsync(
|
||||
projectDir: string,
|
||||
platform: RequestedPlatform
|
||||
): Promise<RequestedPlatform | null> {
|
||||
if (!(await fs.pathExists(path.join(projectDir, 'eas.json')))) {
|
||||
return platform;
|
||||
}
|
||||
|
||||
const easConfig = await new EasJsonReader(projectDir, platform).readRawAsync();
|
||||
if (platform === RequestedPlatform.All) {
|
||||
if (easConfig.builds?.android && easConfig.builds?.ios) {
|
||||
return null;
|
||||
} else if (easConfig.builds?.ios) {
|
||||
return RequestedPlatform.Android;
|
||||
} else if (easConfig.builds?.android) {
|
||||
return RequestedPlatform.Ios;
|
||||
}
|
||||
} else if (
|
||||
(platform === RequestedPlatform.Android || platform === RequestedPlatform.Ios) &&
|
||||
easConfig.builds?.[platform]
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return platform;
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
getProjectIdAsync,
|
||||
} from '../../project/projectUtils';
|
||||
import { promptAsync } from '../../prompts';
|
||||
import formatFields from '../../utils/formatFields';
|
||||
import { createUpdateBranchOnAppAsync } from '../branch/create';
|
||||
|
||||
async function createUpdateChannelOnAppAsync({
|
||||
@@ -87,7 +88,6 @@ export default class ChannelCreate extends Command {
|
||||
throw new Error('Please run this command inside a project directory.');
|
||||
}
|
||||
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
|
||||
const fullName = await getProjectFullNameAsync(exp);
|
||||
const projectId = await getProjectIdAsync(exp);
|
||||
|
||||
if (!channelName) {
|
||||
@@ -140,10 +140,26 @@ export default class ChannelCreate extends Command {
|
||||
return;
|
||||
}
|
||||
|
||||
Log.addNewLineIfNone();
|
||||
Log.withTick(
|
||||
`️Created a new channel ${chalk.bold(newChannel.name)} on project ${chalk.bold(
|
||||
fullName
|
||||
)}. ${branchMessage} and have pointed the channel at it. You can now update your app by publishing!`
|
||||
`Created a new channel on project ${chalk.bold(await getProjectFullNameAsync(exp))}`
|
||||
);
|
||||
Log.log(
|
||||
formatFields([
|
||||
{ label: 'Name', value: newChannel.name },
|
||||
{ label: 'ID', value: newChannel.id },
|
||||
])
|
||||
);
|
||||
Log.addNewLineIfNone();
|
||||
Log.withTick(`${branchMessage} and have pointed the channel at it.`);
|
||||
Log.log(
|
||||
formatFields([
|
||||
{ label: 'Name', value: newChannel.name },
|
||||
{ label: 'ID', value: branchId },
|
||||
])
|
||||
);
|
||||
|
||||
Log.addNewLineIfNone();
|
||||
Log.log(chalk.bold('You can now update your app by publishing!'));
|
||||
}
|
||||
}
|
||||
@@ -146,13 +146,6 @@ export default class ChannelEdit extends Command {
|
||||
'There is a rollout in progress. Please manage it with "channel:rollout" instead.'
|
||||
);
|
||||
}
|
||||
const existingBranch = existingChannel.updateBranches[0];
|
||||
|
||||
Log.addNewLineIfNone();
|
||||
Log.log(
|
||||
chalk`Channel {bold ${existingChannel.name}} is currently set to branch {bold ${existingBranch.name}}`
|
||||
);
|
||||
Log.addNewLineIfNone();
|
||||
|
||||
if (!branchName) {
|
||||
const validationMessage = 'branch name may not be empty.';
|
||||
@@ -185,6 +178,7 @@ export default class ChannelEdit extends Command {
|
||||
Log.withTick(
|
||||
chalk`Channel {bold ${channel.name}} is now set to branch {bold ${branch.name}}.\n`
|
||||
);
|
||||
Log.addNewLineIfNone();
|
||||
Log.log(
|
||||
chalk`Users with builds on channel {bold ${channel.name}} will now receive the active update on {bold ${branch.name}}.`
|
||||
);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { getConfig } from '@expo/config';
|
||||
import { Command, flags } from '@oclif/command';
|
||||
import chalk from 'chalk';
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
import { graphqlClient, withErrorHandlingAsync } from '../../graphql/client';
|
||||
@@ -10,6 +9,7 @@ import {
|
||||
} from '../../graphql/generated';
|
||||
import Log from '../../log';
|
||||
import { findProjectRootAsync, getProjectIdAsync } from '../../project/projectUtils';
|
||||
import formatFields from '../../utils/formatFields';
|
||||
import { logChannelDetails } from './view';
|
||||
|
||||
const CHANNEL_LIMIT = 10_000;
|
||||
@@ -99,9 +99,14 @@ export default class ChannelList extends Command {
|
||||
return;
|
||||
}
|
||||
|
||||
Log.log(); // spacing
|
||||
for (const channel of channels) {
|
||||
Log.log(`Details of channel ${chalk.bold(chalk.cyan(channel.name))}:`);
|
||||
Log.addNewLineIfNone();
|
||||
Log.log(
|
||||
formatFields([
|
||||
{ label: 'Name', value: channel.name },
|
||||
{ label: 'ID', value: channel.id },
|
||||
])
|
||||
);
|
||||
logChannelDetails(channel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,7 @@ import {
|
||||
GetChannelByNameForAppQueryVariables,
|
||||
} from '../../graphql/generated';
|
||||
import Log from '../../log';
|
||||
import {
|
||||
findProjectRootAsync,
|
||||
getProjectFullNameAsync,
|
||||
getProjectIdAsync,
|
||||
} from '../../project/projectUtils';
|
||||
import { findProjectRootAsync, getProjectIdAsync } from '../../project/projectUtils';
|
||||
import { promptAsync } from '../../prompts';
|
||||
import {
|
||||
FormatUpdateParameter,
|
||||
@@ -23,6 +19,7 @@ import {
|
||||
formatUpdate,
|
||||
getPlatformsForGroup,
|
||||
} from '../../update/utils';
|
||||
import formatFields from '../../utils/formatFields';
|
||||
|
||||
export type BranchMapping = {
|
||||
version: number;
|
||||
@@ -220,7 +217,6 @@ export default class ChannelView extends Command {
|
||||
throw new Error('Please run this command inside a project directory.');
|
||||
}
|
||||
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
|
||||
const fullName = await getProjectFullNameAsync(exp);
|
||||
const projectId = await getProjectIdAsync(exp);
|
||||
|
||||
if (!channelName) {
|
||||
@@ -250,9 +246,15 @@ export default class ChannelView extends Command {
|
||||
return;
|
||||
}
|
||||
|
||||
Log.withTick(
|
||||
chalk`Channel: {bold ${channel.name}} on project {bold ${fullName}}. Channel ID: {bold ${channel.id}}`
|
||||
Log.addNewLineIfNone();
|
||||
Log.log(chalk.bold('Channel:'));
|
||||
Log.log(
|
||||
formatFields([
|
||||
{ label: 'Name', value: channel.name },
|
||||
{ label: 'ID', value: channel.id },
|
||||
])
|
||||
);
|
||||
Log.addNewLineIfNone();
|
||||
Log.log(
|
||||
chalk`{bold Branches, pointed at by this channel, and their most recent update group:}`
|
||||
);
|
||||
|
||||
@@ -45,7 +45,6 @@ If you are not sure what is the UDID of the device you are looking for, run:
|
||||
spinner.fail(`Couldn't find a device with the UDID ${UDID}`);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
spinner.fail(`Something went wrong and we couldn't fetch the device with UDID ${UDID}`);
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import { getConfig } from '@expo/config';
|
||||
import { Command } from '@oclif/command';
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
import { graphqlClient, withErrorHandlingAsync } from '../../graphql/client';
|
||||
import { AppInfoQuery, AppInfoQueryVariables } from '../../graphql/generated';
|
||||
import Log from '../../log';
|
||||
import { findProjectRootAsync, getProjectIdAsync } from '../../project/projectUtils';
|
||||
import formatFields from '../../utils/formatFields';
|
||||
|
||||
async function projectInfoByIdAsync(appId: string): Promise<AppInfoQuery> {
|
||||
const data = await withErrorHandlingAsync(
|
||||
graphqlClient
|
||||
.query<AppInfoQuery, AppInfoQueryVariables>(
|
||||
gql`
|
||||
query AppInfo($appId: String!) {
|
||||
app {
|
||||
byId(appId: $appId) {
|
||||
id
|
||||
fullName
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
{ appId }
|
||||
)
|
||||
.toPromise()
|
||||
);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export default class ProjectInfo extends Command {
|
||||
static hidden = true;
|
||||
static description = 'information about the current project';
|
||||
|
||||
async run() {
|
||||
const projectDir = await findProjectRootAsync(process.cwd());
|
||||
if (!projectDir) {
|
||||
throw new Error('Please run this command inside a project directory.');
|
||||
}
|
||||
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
|
||||
const projectId = await getProjectIdAsync(exp);
|
||||
const { app } = await projectInfoByIdAsync(projectId);
|
||||
if (!app) {
|
||||
throw new Error(`Could not find project with ID: ${projectId}`);
|
||||
}
|
||||
|
||||
Log.addNewLineIfNone();
|
||||
Log.log(
|
||||
formatFields([
|
||||
{ label: 'ID', value: projectId },
|
||||
{ label: 'fullName', value: app.byId.fullName },
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
||||
+5
-4
@@ -2,12 +2,13 @@ import { getConfig } from '@expo/config';
|
||||
import { Command } from '@oclif/command';
|
||||
import chalk from 'chalk';
|
||||
|
||||
import Log from '../log';
|
||||
import { findProjectRootAsync, setProjectIdAsync } from '../project/projectUtils';
|
||||
import Log from '../../log';
|
||||
import { findProjectRootAsync, setProjectIdAsync } from '../../project/projectUtils';
|
||||
|
||||
export default class InitView extends Command {
|
||||
export default class ProjectInit extends Command {
|
||||
static hidden = true;
|
||||
static description = 'Create or link an EAS project';
|
||||
static description = 'create or link an EAS project';
|
||||
static aliases = ['init'];
|
||||
|
||||
async run() {
|
||||
const projectDir = await findProjectRootAsync(process.cwd());
|
||||
@@ -40,6 +40,7 @@ export const testPushKey: ApplePushKeyFragment = {
|
||||
keyIdentifier: 'test-key-identifier',
|
||||
appleTeam: { ...testAppleTeamFragment },
|
||||
updatedAt: new Date(),
|
||||
iosAppCredentialsList: [],
|
||||
};
|
||||
|
||||
export const testTargets: Target[] = [{ targetName: 'testapp', bundleIdentifier: 'foo.bar.com' }];
|
||||
|
||||
@@ -47,7 +47,7 @@ export default class AndroidCredentialsProvider {
|
||||
keystore: nullthrows(androidBuildCredentials.androidKeystore?.keystore),
|
||||
keystorePassword: nullthrows(androidBuildCredentials.androidKeystore?.keystorePassword),
|
||||
keyAlias: nullthrows(androidBuildCredentials.androidKeystore?.keyAlias),
|
||||
keyPassword: nullthrows(androidBuildCredentials.androidKeystore?.keyPassword),
|
||||
keyPassword: androidBuildCredentials.androidKeystore?.keyPassword ?? undefined,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,10 +3,9 @@ import { nanoid } from 'nanoid';
|
||||
import ora from 'ora';
|
||||
|
||||
import { AndroidAppBuildCredentialsFragment } from '../../../graphql/generated';
|
||||
import Log from '../../../log';
|
||||
import { getApplicationId } from '../../../project/android/applicationId';
|
||||
import { getApplicationIdAsync } from '../../../project/android/applicationId';
|
||||
import { getProjectAccountName, getProjectConfigDescription } from '../../../project/projectUtils';
|
||||
import { confirmAsync, promptAsync } from '../../../prompts';
|
||||
import { promptAsync } from '../../../prompts';
|
||||
import { findAccountByName } from '../../../user/Account';
|
||||
import { Context } from '../../context';
|
||||
import { AppLookupParams } from '../api/GraphqlClient';
|
||||
@@ -34,65 +33,60 @@ export async function promptUserAndCopyLegacyCredentialsAsync(
|
||||
ctx: Context,
|
||||
app: AppLookupParams
|
||||
): Promise<void> {
|
||||
assert(
|
||||
!ctx.nonInteractive,
|
||||
'Copying over Expo Classic credentials cannot be run in non-interactive mode'
|
||||
);
|
||||
assert(
|
||||
await canCopyLegacyCredentialsAsync(ctx, app),
|
||||
'User not eligible to copy Expo Classic credentials to EAS'
|
||||
'User not eligible to copy classic build credentials to EAS'
|
||||
);
|
||||
const shouldCopy = await confirmAsync({
|
||||
message: `We've detected credentials from Expo Classic (expo-cli). Would you like to copy them over to Expo Application Services (EAS)?`,
|
||||
});
|
||||
if (!shouldCopy) {
|
||||
return;
|
||||
}
|
||||
|
||||
Log.log('Copying credentials...');
|
||||
const spinner = ora().start();
|
||||
const spinner = ora('Classic credentials detected, copying to EAS...').start();
|
||||
|
||||
const legacyAppCredentials = await ctx.android.getLegacyAndroidAppCredentialsWithCommonFieldsAsync(
|
||||
app
|
||||
);
|
||||
if (!legacyAppCredentials) {
|
||||
return;
|
||||
}
|
||||
|
||||
const appCredentials = await ctx.android.createOrGetExistingAndroidAppCredentialsWithBuildCredentialsAsync(
|
||||
app
|
||||
);
|
||||
const legacyFcm = legacyAppCredentials.androidFcm;
|
||||
if (legacyFcm) {
|
||||
const clonedFcm = await ctx.android.createFcmAsync(
|
||||
app.account,
|
||||
legacyFcm.credential,
|
||||
legacyFcm.version
|
||||
try {
|
||||
const legacyAppCredentials = await ctx.android.getLegacyAndroidAppCredentialsWithCommonFieldsAsync(
|
||||
app
|
||||
);
|
||||
await ctx.android.updateAndroidAppCredentialsAsync(appCredentials, {
|
||||
androidFcmId: clonedFcm.id,
|
||||
});
|
||||
if (!legacyAppCredentials) {
|
||||
return;
|
||||
}
|
||||
|
||||
const appCredentials = await ctx.android.createOrGetExistingAndroidAppCredentialsWithBuildCredentialsAsync(
|
||||
app
|
||||
);
|
||||
const legacyFcm = legacyAppCredentials.androidFcm;
|
||||
if (legacyFcm) {
|
||||
const clonedFcm = await ctx.android.createFcmAsync(
|
||||
app.account,
|
||||
legacyFcm.credential,
|
||||
legacyFcm.version
|
||||
);
|
||||
await ctx.android.updateAndroidAppCredentialsAsync(appCredentials, {
|
||||
androidFcmId: clonedFcm.id,
|
||||
});
|
||||
}
|
||||
|
||||
const legacyBuildCredentials = await ctx.android.getLegacyAndroidAppBuildCredentialsAsync(app);
|
||||
const legacyKeystore = legacyBuildCredentials?.androidKeystore ?? null;
|
||||
|
||||
if (legacyKeystore) {
|
||||
const clonedKeystore = await ctx.android.createKeystoreAsync(app.account, {
|
||||
keystore: legacyKeystore.keystore,
|
||||
keystorePassword: legacyKeystore.keystorePassword,
|
||||
keyAlias: legacyKeystore.keyAlias,
|
||||
keyPassword: legacyKeystore.keyPassword ?? undefined,
|
||||
type: legacyKeystore.type,
|
||||
});
|
||||
await createOrUpdateDefaultAndroidAppBuildCredentialsAsync(ctx, app, {
|
||||
androidKeystoreId: clonedKeystore.id,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
spinner.fail(`Unable to migrate credentials to EAS.`);
|
||||
throw e;
|
||||
}
|
||||
|
||||
const legacyBuildCredentials = await ctx.android.getLegacyAndroidAppBuildCredentialsAsync(app);
|
||||
const legacyKeystore = legacyBuildCredentials?.androidKeystore ?? null;
|
||||
|
||||
if (legacyKeystore) {
|
||||
const clonedKeystore = await ctx.android.createKeystoreAsync(app.account, {
|
||||
keystore: legacyKeystore.keystore,
|
||||
keystorePassword: legacyKeystore.keystorePassword,
|
||||
keyAlias: legacyKeystore.keyAlias,
|
||||
keyPassword: legacyKeystore.keyPassword ?? undefined,
|
||||
type: legacyKeystore.type,
|
||||
});
|
||||
await createOrUpdateDefaultAndroidAppBuildCredentialsAsync(ctx, app, {
|
||||
androidKeystoreId: clonedKeystore.id,
|
||||
});
|
||||
}
|
||||
spinner.succeed('Credentials successfully copied');
|
||||
spinner.succeed('Credentials copied to EAS.');
|
||||
}
|
||||
|
||||
export function getAppLookupParamsFromContext(ctx: Context): AppLookupParams {
|
||||
export async function getAppLookupParamsFromContextAsync(ctx: Context): Promise<AppLookupParams> {
|
||||
ctx.ensureProjectContext();
|
||||
const projectName = ctx.exp.slug;
|
||||
const accountName = getProjectAccountName(ctx.exp, ctx.user);
|
||||
@@ -101,7 +95,7 @@ export function getAppLookupParamsFromContext(ctx: Context): AppLookupParams {
|
||||
throw new Error(`You do not have access to account: ${accountName}`);
|
||||
}
|
||||
|
||||
const androidApplicationIdentifier = getApplicationId(ctx.projectDir, ctx.exp);
|
||||
const androidApplicationIdentifier = await getApplicationIdAsync(ctx.projectDir, ctx.exp);
|
||||
if (!androidApplicationIdentifier) {
|
||||
throw new Error(
|
||||
`android.package needs to be defined in your ${getProjectConfigDescription(
|
||||
@@ -135,9 +129,8 @@ export async function createOrUpdateDefaultAndroidAppBuildCredentialsAsync(
|
||||
{ androidKeystoreId }
|
||||
);
|
||||
}
|
||||
const providedName = await promptForNameAsync();
|
||||
return await ctx.android.createAndroidAppBuildCredentialsAsync(appLookupParams, {
|
||||
name: providedName,
|
||||
name: generateRandomName(),
|
||||
isDefault: true,
|
||||
androidKeystoreId,
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import nullthrows from 'nullthrows';
|
||||
import ora from 'ora';
|
||||
|
||||
import {
|
||||
AndroidAppBuildCredentialsFragment,
|
||||
@@ -94,9 +95,9 @@ export class SetupBuildCredentials {
|
||||
);
|
||||
const defaultKeystore = defaultBuildCredentials?.androidKeystore ?? null;
|
||||
if (defaultKeystore) {
|
||||
Log.log(
|
||||
ora(
|
||||
`Using Keystore from configuration: ${nullthrows(defaultBuildCredentials).name} (default)`
|
||||
);
|
||||
).succeed();
|
||||
return defaultBuildCredentials;
|
||||
}
|
||||
return null;
|
||||
@@ -118,11 +119,11 @@ export class SetupBuildCredentials {
|
||||
const keystore = maybeBuildCredentials?.androidKeystore ?? null;
|
||||
if (keystore) {
|
||||
const buildCredentials = nullthrows(maybeBuildCredentials);
|
||||
Log.log(
|
||||
ora(
|
||||
`Using Keystore from configuration: ${buildCredentials.name}${
|
||||
buildCredentials.isDefault ? ' (default)' : ''
|
||||
}`
|
||||
);
|
||||
).succeed();
|
||||
return buildCredentials;
|
||||
}
|
||||
Log.log(
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { testLegacyAndroidFcmFragment } from '../../../__tests__/fixtures-android';
|
||||
import { createCtxMock } from '../../../__tests__/fixtures-context';
|
||||
import { AssignFcm } from '../AssignFcm';
|
||||
import { getAppLookupParamsFromContext } from '../BuildCredentialsUtils';
|
||||
import { getAppLookupParamsFromContextAsync } from '../BuildCredentialsUtils';
|
||||
|
||||
describe(AssignFcm, () => {
|
||||
it('assigns an fcm api key in Interactive Mode', async () => {
|
||||
const ctx = createCtxMock({
|
||||
nonInteractive: false,
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const assignFcmAction = new AssignFcm(appLookupParams);
|
||||
await assignFcmAction.runAsync(ctx, testLegacyAndroidFcmFragment);
|
||||
|
||||
@@ -22,7 +22,7 @@ describe(AssignFcm, () => {
|
||||
const ctx = createCtxMock({
|
||||
nonInteractive: true,
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const assignFcmAction = new AssignFcm(appLookupParams);
|
||||
|
||||
// dont fail if users are running in non-interactive mode
|
||||
|
||||
+7
-18
@@ -10,24 +10,13 @@ import {
|
||||
import { createCtxMock } from '../../../__tests__/fixtures-context';
|
||||
import {
|
||||
canCopyLegacyCredentialsAsync,
|
||||
getAppLookupParamsFromContext,
|
||||
getAppLookupParamsFromContextAsync,
|
||||
promptUserAndCopyLegacyCredentialsAsync,
|
||||
} from '../BuildCredentialsUtils';
|
||||
|
||||
jest.mock('../../../../prompts');
|
||||
(confirmAsync as jest.Mock).mockImplementation(() => true);
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
const originalConsoleWarn = console.warn;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
console.warn = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
console.warn = originalConsoleWarn;
|
||||
});
|
||||
|
||||
describe('BuildCredentialsUtils', () => {
|
||||
describe(canCopyLegacyCredentialsAsync, () => {
|
||||
it('returns true if the user has legacy credentials and no modern ones', async () => {
|
||||
@@ -41,7 +30,7 @@ describe('BuildCredentialsUtils', () => {
|
||||
),
|
||||
},
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const canCopyLegacyCredentials = await canCopyLegacyCredentialsAsync(ctx, appLookupParams);
|
||||
expect(canCopyLegacyCredentials).toBe(true);
|
||||
});
|
||||
@@ -58,7 +47,7 @@ describe('BuildCredentialsUtils', () => {
|
||||
),
|
||||
},
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const canCopyLegacyCredentials = await canCopyLegacyCredentialsAsync(ctx, appLookupParams);
|
||||
expect(canCopyLegacyCredentials).toBe(false);
|
||||
});
|
||||
@@ -71,7 +60,7 @@ describe('BuildCredentialsUtils', () => {
|
||||
getLegacyAndroidAppCredentialsWithCommonFieldsAsync: jest.fn(() => null),
|
||||
},
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const canCopyLegacyCredentials = await canCopyLegacyCredentialsAsync(ctx, appLookupParams);
|
||||
expect(canCopyLegacyCredentials).toBe(false);
|
||||
});
|
||||
@@ -86,7 +75,7 @@ describe('BuildCredentialsUtils', () => {
|
||||
),
|
||||
},
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const canCopyLegacyCredentials = await canCopyLegacyCredentialsAsync(ctx, appLookupParams);
|
||||
expect(canCopyLegacyCredentials).toBe(true);
|
||||
});
|
||||
@@ -109,7 +98,7 @@ describe('BuildCredentialsUtils', () => {
|
||||
createFcmAsync: jest.fn(() => testLegacyAndroidFcmFragment),
|
||||
},
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
await promptUserAndCopyLegacyCredentialsAsync(ctx, appLookupParams);
|
||||
|
||||
expect(
|
||||
@@ -131,7 +120,7 @@ describe('BuildCredentialsUtils', () => {
|
||||
),
|
||||
},
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
await expect(
|
||||
promptUserAndCopyLegacyCredentialsAsync(ctx, appLookupParams)
|
||||
).rejects.toThrowError();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { promptAsync } from '../../../../prompts';
|
||||
import { createCtxMock } from '../../../__tests__/fixtures-context';
|
||||
import { getAppLookupParamsFromContext } from '../BuildCredentialsUtils';
|
||||
import { getAppLookupParamsFromContextAsync } from '../BuildCredentialsUtils';
|
||||
import { CreateFcm } from '../CreateFcm';
|
||||
|
||||
jest.mock('../../../../prompts');
|
||||
@@ -9,7 +9,7 @@ jest.mock('../../../../prompts');
|
||||
describe(CreateFcm, () => {
|
||||
it('creates an fcm api key in Interactive Mode', async () => {
|
||||
const ctx = createCtxMock({ nonInteractive: false });
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const createFcmAction = new CreateFcm(appLookupParams.account);
|
||||
await createFcmAction.runAsync(ctx);
|
||||
|
||||
@@ -18,7 +18,7 @@ describe(CreateFcm, () => {
|
||||
});
|
||||
it('errors in Non-Interactive Mode', async () => {
|
||||
const ctx = createCtxMock({ nonInteractive: true });
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const createFcmAction = new CreateFcm(appLookupParams.account);
|
||||
|
||||
// fail if users are running in non-interactive mode
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { confirmAsync } from '../../../../prompts';
|
||||
import { createCtxMock } from '../../../__tests__/fixtures-context';
|
||||
import { getAppLookupParamsFromContext } from '../BuildCredentialsUtils';
|
||||
import { getAppLookupParamsFromContextAsync } from '../BuildCredentialsUtils';
|
||||
import { CreateKeystore } from '../CreateKeystore';
|
||||
|
||||
jest.mock('../../../../prompts');
|
||||
@@ -9,7 +9,7 @@ jest.mock('../../../../prompts');
|
||||
describe('CreateKeystore', () => {
|
||||
it('creates a keystore in Interactive Mode', async () => {
|
||||
const ctx = createCtxMock({ nonInteractive: false });
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const createKeystoreAction = new CreateKeystore(appLookupParams.account);
|
||||
await createKeystoreAction.runAsync(ctx);
|
||||
|
||||
@@ -18,7 +18,7 @@ describe('CreateKeystore', () => {
|
||||
});
|
||||
it('errors in Non-Interactive Mode', async () => {
|
||||
const ctx = createCtxMock({ nonInteractive: true });
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const createKeystoreAction = new CreateKeystore(appLookupParams.account);
|
||||
|
||||
// fail if users are running in non-interactive mode
|
||||
|
||||
+5
-13
@@ -2,26 +2,18 @@ import fs from 'fs-extra';
|
||||
|
||||
import { testAndroidBuildCredentialsFragment } from '../../../__tests__/fixtures-android';
|
||||
import { createCtxMock } from '../../../__tests__/fixtures-context';
|
||||
import { getAppLookupParamsFromContext } from '../BuildCredentialsUtils';
|
||||
import { getAppLookupParamsFromContextAsync } from '../BuildCredentialsUtils';
|
||||
import { DownloadKeystore } from '../DownloadKeystore';
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
const originalConsoleWarn = console.warn;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
console.warn = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
console.warn = originalConsoleWarn;
|
||||
});
|
||||
jest.mock('fs-extra');
|
||||
|
||||
describe(DownloadKeystore, () => {
|
||||
it('downloads a keystore', async () => {
|
||||
const fsWriteFileSpy = jest.spyOn(fs, 'writeFile');
|
||||
const ctx = createCtxMock({
|
||||
nonInteractive: false,
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const downloadKeystoreAction = new DownloadKeystore({ app: appLookupParams });
|
||||
await downloadKeystoreAction.runAsync(ctx, testAndroidBuildCredentialsFragment);
|
||||
expect(fsWriteFileSpy as any).toHaveBeenCalledTimes(1);
|
||||
@@ -34,7 +26,7 @@ describe(DownloadKeystore, () => {
|
||||
});
|
||||
it('works in Non-Interactive Mode', async () => {
|
||||
const ctx = createCtxMock({ nonInteractive: true });
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const downloadKeystoreAction = new DownloadKeystore({ app: appLookupParams });
|
||||
await expect(
|
||||
downloadKeystoreAction.runAsync(ctx, testAndroidBuildCredentialsFragment)
|
||||
|
||||
@@ -4,22 +4,12 @@ import {
|
||||
testAndroidAppCredentialsFragment,
|
||||
} from '../../../__tests__/fixtures-android';
|
||||
import { createCtxMock } from '../../../__tests__/fixtures-context';
|
||||
import { getAppLookupParamsFromContext } from '../BuildCredentialsUtils';
|
||||
import { getAppLookupParamsFromContextAsync } from '../BuildCredentialsUtils';
|
||||
import { RemoveFcm } from '../RemoveFcm';
|
||||
|
||||
jest.mock('../../../../prompts');
|
||||
(confirmAsync as jest.Mock).mockImplementation(() => true);
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
const originalConsoleWarn = console.warn;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
console.warn = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
console.warn = originalConsoleWarn;
|
||||
});
|
||||
describe(RemoveFcm, () => {
|
||||
it('removes an FCM Api Key', async () => {
|
||||
const ctx = createCtxMock({
|
||||
@@ -31,14 +21,14 @@ describe(RemoveFcm, () => {
|
||||
),
|
||||
},
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const removeFcmApiKeyAction = new RemoveFcm(appLookupParams);
|
||||
await removeFcmApiKeyAction.runAsync(ctx);
|
||||
expect(ctx.android.deleteFcmAsync as any).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
it('errors in Non-Interactive Mode', async () => {
|
||||
const ctx = createCtxMock({ nonInteractive: true });
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const removeFcmApiKeyAction = new RemoveFcm(appLookupParams);
|
||||
await expect(removeFcmApiKeyAction.runAsync(ctx)).rejects.toThrowError();
|
||||
});
|
||||
|
||||
@@ -1,35 +1,26 @@
|
||||
import { confirmAsync } from '../../../../prompts';
|
||||
import { testAndroidBuildCredentialsFragment } from '../../../__tests__/fixtures-android';
|
||||
import { createCtxMock } from '../../../__tests__/fixtures-context';
|
||||
import { getAppLookupParamsFromContext } from '../BuildCredentialsUtils';
|
||||
import { getAppLookupParamsFromContextAsync } from '../BuildCredentialsUtils';
|
||||
import { RemoveKeystore } from '../RemoveKeystore';
|
||||
|
||||
jest.mock('fs-extra');
|
||||
jest.mock('../../../../prompts');
|
||||
(confirmAsync as jest.Mock).mockImplementation(() => true);
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
const originalConsoleWarn = console.warn;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
console.warn = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
console.warn = originalConsoleWarn;
|
||||
});
|
||||
describe(RemoveKeystore, () => {
|
||||
it('removes a keystore', async () => {
|
||||
const ctx = createCtxMock({
|
||||
nonInteractive: false,
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const removeKeystoreAction = new RemoveKeystore(appLookupParams);
|
||||
await removeKeystoreAction.runAsync(ctx, testAndroidBuildCredentialsFragment);
|
||||
expect(ctx.android.deleteKeystoreAsync as any).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
it('errors in Non-Interactive Mode', async () => {
|
||||
const ctx = createCtxMock({ nonInteractive: true });
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const removeKeystoreAction = new RemoveKeystore(appLookupParams);
|
||||
await expect(
|
||||
removeKeystoreAction.runAsync(ctx, testAndroidBuildCredentialsFragment)
|
||||
|
||||
+4
-15
@@ -6,23 +6,12 @@ import {
|
||||
} from '../../../__tests__/fixtures-android';
|
||||
import { createCtxMock } from '../../../__tests__/fixtures-context';
|
||||
import { MissingCredentialsNonInteractiveError } from '../../../errors';
|
||||
import { getAppLookupParamsFromContext } from '../BuildCredentialsUtils';
|
||||
import { getAppLookupParamsFromContextAsync } from '../BuildCredentialsUtils';
|
||||
import { SetupBuildCredentials } from '../SetupBuildCredentials';
|
||||
|
||||
jest.mock('../../../../prompts');
|
||||
(confirmAsync as jest.Mock).mockImplementation(() => true);
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
const originalConsoleWarn = console.warn;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
console.warn = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
console.warn = originalConsoleWarn;
|
||||
});
|
||||
|
||||
describe('SetupBuildCredentials', () => {
|
||||
it('skips setup when there are prior credentials', async () => {
|
||||
const ctx = createCtxMock({
|
||||
@@ -34,7 +23,7 @@ describe('SetupBuildCredentials', () => {
|
||||
),
|
||||
},
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const setupBuildCredentialsAction = new SetupBuildCredentials({ app: appLookupParams });
|
||||
await setupBuildCredentialsAction.runAsync(ctx);
|
||||
|
||||
@@ -50,7 +39,7 @@ describe('SetupBuildCredentials', () => {
|
||||
createKeystoreAsync: jest.fn(() => testJksAndroidKeystoreFragment),
|
||||
},
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const setupBuildCredentialsAction = new SetupBuildCredentials({ app: appLookupParams });
|
||||
await setupBuildCredentialsAction.runAsync(ctx);
|
||||
|
||||
@@ -65,7 +54,7 @@ describe('SetupBuildCredentials', () => {
|
||||
...getNewAndroidApiMock(),
|
||||
},
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const setupBuildCredentialsAction = new SetupBuildCredentials({ app: appLookupParams });
|
||||
await expect(setupBuildCredentialsAction.runAsync(ctx)).rejects.toThrowError(
|
||||
MissingCredentialsNonInteractiveError
|
||||
|
||||
+4
-14
@@ -12,7 +12,7 @@ import {
|
||||
SelectAndroidBuildCredentials,
|
||||
SelectAndroidBuildCredentialsResultType,
|
||||
} from '../../../manager/SelectAndroidBuildCredentials';
|
||||
import { getAppLookupParamsFromContext } from '../BuildCredentialsUtils';
|
||||
import { getAppLookupParamsFromContextAsync } from '../BuildCredentialsUtils';
|
||||
import { SetupBuildCredentialsFromCredentialsJson } from '../SetupBuildCredentialsFromCredentialsJson';
|
||||
|
||||
jest.mock('fs');
|
||||
@@ -21,16 +21,6 @@ jest.mock('../../../../prompts');
|
||||
(confirmAsync as jest.Mock).mockImplementation(() => true);
|
||||
jest.mock('../../../manager/SelectAndroidBuildCredentials');
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
const originalConsoleWarn = console.warn;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
console.warn = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
console.warn = originalConsoleWarn;
|
||||
});
|
||||
beforeEach(() => {
|
||||
vol.reset();
|
||||
});
|
||||
@@ -67,7 +57,7 @@ describe(SetupBuildCredentialsFromCredentialsJson, () => {
|
||||
}),
|
||||
'keystore.jks': 'some-binary-content',
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const setupBuildCredentialsAction = new SetupBuildCredentialsFromCredentialsJson(
|
||||
appLookupParams
|
||||
);
|
||||
@@ -117,7 +107,7 @@ describe(SetupBuildCredentialsFromCredentialsJson, () => {
|
||||
}),
|
||||
'keystore.jks': 'some-binary-content',
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const setupBuildCredentialsAction = new SetupBuildCredentialsFromCredentialsJson(
|
||||
appLookupParams
|
||||
);
|
||||
@@ -140,7 +130,7 @@ describe(SetupBuildCredentialsFromCredentialsJson, () => {
|
||||
const ctx = createCtxMock({
|
||||
nonInteractive: true,
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const setupBuildCredentialsAction = new SetupBuildCredentialsFromCredentialsJson(
|
||||
appLookupParams
|
||||
);
|
||||
|
||||
@@ -3,7 +3,7 @@ import mockdate from 'mockdate';
|
||||
import Log from '../../../../log';
|
||||
import { testAndroidAppCredentialsFragment } from '../../../__tests__/fixtures-android';
|
||||
import { createCtxMock } from '../../../__tests__/fixtures-context';
|
||||
import { getAppLookupParamsFromContext } from '../../actions/BuildCredentialsUtils';
|
||||
import { getAppLookupParamsFromContextAsync } from '../../actions/BuildCredentialsUtils';
|
||||
import { displayAndroidAppCredentials } from '../printCredentials';
|
||||
|
||||
jest.mock('../../../../log');
|
||||
@@ -14,7 +14,7 @@ mockdate.set(new Date('4/20/2021'));
|
||||
describe('print credentials', () => {
|
||||
it('prints the AndroidAppCredentials fragment', async () => {
|
||||
const ctx = createCtxMock();
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
displayAndroidAppCredentials({
|
||||
appLookupParams,
|
||||
appCredentials: testAndroidAppCredentialsFragment,
|
||||
|
||||
@@ -22,22 +22,6 @@ import { updateAndroidCredentialsAsync, updateIosCredentialsAsync } from '../upd
|
||||
jest.mock('fs');
|
||||
jest.mock('prompts');
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
const originalConsoleWarn = console.warn;
|
||||
const originalConsoleError = console.error;
|
||||
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
console.warn = jest.fn();
|
||||
console.error = jest.fn();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
console.warn = originalConsoleWarn;
|
||||
console.error = originalConsoleError;
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vol.reset();
|
||||
asMock(prompts).mockReset();
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
import { Platform } from '@expo/eas-build-job';
|
||||
import { CredentialsSource, IosDistributionType, IosEnterpriseProvisioning } from '@expo/eas-json';
|
||||
|
||||
import { CommonIosAppCredentialsFragment } from '../../graphql/generated';
|
||||
import Log from '../../log';
|
||||
import { findApplicationTarget } from '../../project/ios/target';
|
||||
import { confirmAsync } from '../../prompts';
|
||||
import { Context } from '../context';
|
||||
import * as credentialsJsonReader from '../credentialsJson/read';
|
||||
import { ensureAllTargetsAreConfigured } from '../credentialsJson/utils';
|
||||
import { getAppFromContext } from './actions/BuildCredentialsUtils';
|
||||
import { SetupBuildCredentials } from './actions/SetupBuildCredentials';
|
||||
import { SetupPushKey } from './actions/SetupPushKey';
|
||||
import { IosCapabilitiesOptions } from './appstore/ensureAppExists';
|
||||
import { App, IosCredentials, Target } from './types';
|
||||
import { isAdHocProfile } from './utils/provisioningProfile';
|
||||
@@ -26,11 +31,14 @@ export default class IosCredentialsProvider {
|
||||
public async getCredentialsAsync(
|
||||
src: CredentialsSource.LOCAL | CredentialsSource.REMOTE
|
||||
): Promise<IosCredentials> {
|
||||
let buildCredentials;
|
||||
if (src === CredentialsSource.LOCAL) {
|
||||
return await this.getLocalAsync();
|
||||
buildCredentials = await this.getLocalAsync();
|
||||
} else {
|
||||
return await this.getRemoteAsync();
|
||||
buildCredentials = await this.getRemoteAsync();
|
||||
}
|
||||
await this.getPushKeyAsync(this.ctx, this.options.targets);
|
||||
return buildCredentials;
|
||||
}
|
||||
|
||||
private async getLocalAsync(): Promise<IosCredentials> {
|
||||
@@ -59,6 +67,40 @@ export default class IosCredentialsProvider {
|
||||
}).runAsync(this.ctx);
|
||||
}
|
||||
|
||||
private async getPushKeyAsync(
|
||||
ctx: Context,
|
||||
targets: Target[]
|
||||
): Promise<CommonIosAppCredentialsFragment | null> {
|
||||
if (ctx.nonInteractive) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const applicationTarget = findApplicationTarget(targets);
|
||||
const app = getAppFromContext(ctx);
|
||||
const appLookupParams = {
|
||||
...app,
|
||||
bundleIdentifier: applicationTarget.bundleIdentifier,
|
||||
parentBundleIdentifier: applicationTarget.parentBundleIdentifier,
|
||||
};
|
||||
|
||||
const setupPushKeyAction = new SetupPushKey(appLookupParams);
|
||||
const isPushKeySetup = await setupPushKeyAction.isPushKeySetupAsync(ctx);
|
||||
if (isPushKeySetup) {
|
||||
Log.succeed(
|
||||
`Push Notifications setup for ${app.projectName}:${applicationTarget.bundleIdentifier}`
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
const confirmSetup = await confirmAsync({
|
||||
message: `Would you like to setup Push Notifications for your project?`,
|
||||
});
|
||||
if (!confirmSetup) {
|
||||
return null;
|
||||
}
|
||||
return await setupPushKeyAction.runAsync(ctx);
|
||||
}
|
||||
|
||||
private assertProvisioningProfileType(provisioningProfile: string, targetName?: string): void {
|
||||
const isAdHoc = isAdHocProfile(provisioningProfile);
|
||||
if (this.options.distribution === 'internal' && !isAdHoc) {
|
||||
|
||||
@@ -29,20 +29,6 @@ jest.mock('../validators/validateProvisioningProfile', () => ({
|
||||
}));
|
||||
jest.mock('../../../project/ios/bundleIdentifier');
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
const originalConsoleError = console.error;
|
||||
const originalConsoleWarn = console.warn;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
console.error = jest.fn();
|
||||
console.warn = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
console.error = originalConsoleError;
|
||||
console.warn = originalConsoleWarn;
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vol.reset();
|
||||
});
|
||||
|
||||
@@ -2,7 +2,6 @@ import { ApplePushKeyFragment, CommonIosAppCredentialsFragment } from '../../../
|
||||
import Log from '../../../log';
|
||||
import { Context } from '../../context';
|
||||
import { AppLookupParams } from '../api/GraphqlClient';
|
||||
import { AppleTeamMissingError } from '../errors';
|
||||
import { resolveAppleTeamIfAuthenticatedAsync } from './AppleTeamUtils';
|
||||
|
||||
export class AssignPushKey {
|
||||
@@ -14,15 +13,9 @@ export class AssignPushKey {
|
||||
): Promise<CommonIosAppCredentialsFragment> {
|
||||
const appleTeam =
|
||||
(await resolveAppleTeamIfAuthenticatedAsync(ctx, this.app)) ?? pushKey.appleTeam ?? null;
|
||||
if (!appleTeam) {
|
||||
// TODO(quin): make this optional
|
||||
throw new AppleTeamMissingError(
|
||||
'An Apple Team is required to proceed. You must be authenticated to your Apple account'
|
||||
);
|
||||
}
|
||||
const appCredentials = await ctx.ios.createOrGetIosAppCredentialsWithCommonFieldsAsync(
|
||||
this.app,
|
||||
{ appleTeam }
|
||||
{ appleTeam: appleTeam ?? undefined }
|
||||
);
|
||||
const updatedAppCredentials = await ctx.ios.updateIosAppCredentialsAsync(appCredentials, {
|
||||
applePushKeyId: pushKey.id,
|
||||
|
||||
@@ -187,6 +187,12 @@ export function formatPushKey(
|
||||
line += ` ${appleTeam ? `, ${formatAppleTeam(appleTeam)}` : ''}`;
|
||||
line += chalk.gray(`\n Updated: ${fromNow(new Date(updatedAt))} ago,`);
|
||||
|
||||
const apps = pushKey.iosAppCredentialsList.map(appCredentials => appCredentials.app);
|
||||
if (apps.length) {
|
||||
const appFullNames = apps.map(app => app.fullName).join(',');
|
||||
line += chalk.gray(`\n 📲 Used by: ${appFullNames}`);
|
||||
}
|
||||
|
||||
if (validPushKeyIdentifiers?.includes(keyIdentifier)) {
|
||||
line += chalk.gray("\n ✅ Currently valid on Apple's servers.");
|
||||
} else {
|
||||
|
||||
@@ -26,13 +26,16 @@ export class RemovePushKey {
|
||||
throw new Error(`Cannot remove push keys in non-interactive mode`);
|
||||
}
|
||||
|
||||
// TODO(quin): show the projects that rely on this
|
||||
const confirm = await confirmAsync({
|
||||
message: `Removing this push key will disable push notifications for projects that rely on it. Do you want to continue?`,
|
||||
});
|
||||
|
||||
if (!confirm) {
|
||||
return;
|
||||
const apps = this.pushKey.iosAppCredentialsList.map(appCredentials => appCredentials.app);
|
||||
if (apps.length !== 0) {
|
||||
const appFullNames = apps.map(app => app.fullName).join(',');
|
||||
const confirm = await confirmAsync({
|
||||
message: `Removing this push key will disable push notifications for ${appFullNames}. Do you want to continue?`,
|
||||
});
|
||||
if (!confirm) {
|
||||
Log.log('Aborting');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Log.log('Removing Push Key');
|
||||
|
||||
-8
@@ -12,14 +12,6 @@ import { RemoveDistributionCertificate } from '../RemoveDistributionCertificate'
|
||||
jest.mock('../../../../prompts');
|
||||
(confirmAsync as jest.Mock).mockImplementation(() => true);
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
});
|
||||
|
||||
describe('RemoveDistributionCertificate', () => {
|
||||
it('deletes the distribution certificate on Expo and Apple servers when there are no App Dependencies in Interactive Mode', async () => {
|
||||
const ctx = createCtxMock({ nonInteractive: false });
|
||||
|
||||
@@ -8,14 +8,6 @@ import { RemovePushKey } from '../RemovePushKey';
|
||||
jest.mock('../../../../prompts');
|
||||
(confirmAsync as jest.Mock).mockImplementation(() => true);
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
});
|
||||
|
||||
describe(RemovePushKey, () => {
|
||||
it('deletes the push key on Expo and Apple servers in Interactive Mode', async () => {
|
||||
const ctx = createCtxMock({ nonInteractive: false });
|
||||
|
||||
-8
@@ -13,14 +13,6 @@ jest.mock('../SetupAdhocProvisioningProfile');
|
||||
jest.mock('../SetupProvisioningProfile');
|
||||
jest.mock('../BuildCredentialsUtils', () => ({ getAllBuildCredentialsAsync: jest.fn() }));
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
asMock(promptAsync).mockReset();
|
||||
|
||||
|
||||
@@ -9,14 +9,6 @@ import { SetupPushKey } from '../SetupPushKey';
|
||||
jest.mock('../../../../prompts');
|
||||
(confirmAsync as jest.Mock).mockImplementation(() => true);
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
});
|
||||
|
||||
describe(SetupPushKey, () => {
|
||||
it('skips setting up a Push Key if it is already configured', async () => {
|
||||
const ctx = createCtxMock({
|
||||
|
||||
-11
@@ -20,17 +20,6 @@ import { SetupTargetBuildCredentialsFromCredentialsJson } from '../SetupTargetBu
|
||||
jest.mock('../../../../prompts');
|
||||
jest.mock('../../../credentialsJson/read');
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
const originalConsoleWarn = console.warn;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
console.warn = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
console.warn = originalConsoleWarn;
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
asMock(confirmAsync).mockReset();
|
||||
(confirmAsync as jest.Mock).mockImplementation(() => true);
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
IosAppBuildCredentialsFragment,
|
||||
IosDistributionType,
|
||||
} from '../../../graphql/generated';
|
||||
import { isWildcardBundleIdentifier } from '../../../project/ios/bundleIdentifier';
|
||||
import { Account } from '../../../user/Account';
|
||||
import { DistributionCertificate, PushKey } from '../appstore/Credentials.types';
|
||||
import { AppleTeamMissingError } from '../errors';
|
||||
@@ -138,7 +139,7 @@ export async function createOrGetIosAppCredentialsWithCommonFieldsAsync(
|
||||
{
|
||||
appleTeam,
|
||||
}: {
|
||||
appleTeam: AppleTeamFragment;
|
||||
appleTeam?: AppleTeamFragment;
|
||||
}
|
||||
): Promise<CommonIosAppCredentialsFragment> {
|
||||
const maybeIosAppCredentials = await getIosAppCredentialsWithCommonFieldsAsync(appLookupParams);
|
||||
@@ -147,10 +148,10 @@ export async function createOrGetIosAppCredentialsWithCommonFieldsAsync(
|
||||
}
|
||||
const [app, appleAppIdentifier] = await Promise.all([
|
||||
getAppAsync(appLookupParams),
|
||||
createOrGetExistingAppleAppIdentifierAsync(appLookupParams, appleTeam),
|
||||
createOrGetExistingAppleAppIdentifierAsync(appLookupParams, appleTeam ?? null),
|
||||
]);
|
||||
return await IosAppCredentialsMutation.createIosAppCredentialsAsync(
|
||||
{ appleTeamId: appleTeam.id },
|
||||
{ appleTeamId: appleTeam?.id },
|
||||
app.id,
|
||||
appleAppIdentifier.id
|
||||
);
|
||||
@@ -181,7 +182,7 @@ async function createOrGetExistingIosAppCredentialsWithBuildCredentialsAsync(
|
||||
appleAppIdentifierId,
|
||||
iosDistributionType,
|
||||
}: {
|
||||
appleTeam: AppleTeamFragment;
|
||||
appleTeam?: AppleTeamFragment;
|
||||
appleAppIdentifierId: string;
|
||||
iosDistributionType: IosDistributionType;
|
||||
}
|
||||
@@ -197,10 +198,10 @@ async function createOrGetExistingIosAppCredentialsWithBuildCredentialsAsync(
|
||||
} else {
|
||||
const [app, appleAppIdentifier] = await Promise.all([
|
||||
getAppAsync(appLookupParams),
|
||||
createOrGetExistingAppleAppIdentifierAsync(appLookupParams, appleTeam),
|
||||
createOrGetExistingAppleAppIdentifierAsync(appLookupParams, appleTeam ?? null),
|
||||
]);
|
||||
await IosAppCredentialsMutation.createIosAppCredentialsAsync(
|
||||
{ appleTeamId: appleTeam.id },
|
||||
{ appleTeamId: appleTeam?.id },
|
||||
app.id,
|
||||
appleAppIdentifier.id
|
||||
);
|
||||
@@ -243,8 +244,10 @@ export async function createOrGetExistingAppleAppIdentifierAsync(
|
||||
if (appleAppIdentifier) {
|
||||
return appleAppIdentifier;
|
||||
} else {
|
||||
if (!appleTeam) {
|
||||
throw new AppleTeamMissingError();
|
||||
if (isWildcardBundleIdentifier(bundleIdentifier) && !appleTeam) {
|
||||
throw new AppleTeamMissingError(
|
||||
`An Apple Team is required for wildcard bundle identifier: ${bundleIdentifier}`
|
||||
);
|
||||
}
|
||||
const parentAppleAppIdentifier = parentBundleIdentifier
|
||||
? await createOrGetExistingAppleAppIdentifierAsync(
|
||||
@@ -255,7 +258,7 @@ export async function createOrGetExistingAppleAppIdentifierAsync(
|
||||
return await AppleAppIdentifierMutation.createAppleAppIdentifierAsync(
|
||||
{
|
||||
bundleIdentifier,
|
||||
appleTeamId: appleTeam.id,
|
||||
appleTeamId: appleTeam?.id,
|
||||
parentAppleAppId: parentAppleAppIdentifier?.id,
|
||||
},
|
||||
account.id
|
||||
|
||||
+7
@@ -30,6 +30,13 @@ const IosAppCredentialsQuery = {
|
||||
},
|
||||
__typename: 'ApplePushKey',
|
||||
},
|
||||
appSpecificPassword: {
|
||||
id: '64bdd007-da7b-4190-a571-edb87e9324a1',
|
||||
appleIdUsername: '[email protected]',
|
||||
passwordLabel: 'description for super secret password',
|
||||
updatedAt: '2020-10-13T18:39:04.463Z',
|
||||
__typename: 'AppleAppSpecificPassword',
|
||||
},
|
||||
iosAppBuildCredentialsList: [
|
||||
{
|
||||
id: '6f8d0175-0caf-4922-b09b-eae757b83144',
|
||||
|
||||
@@ -33,6 +33,10 @@ describe(syncCapabilitiesForEntitlementsAsync, () => {
|
||||
'com.apple.developer.applesignin': ['Default'],
|
||||
'com.apple.developer.siri': true,
|
||||
'com.apple.developer.networking.wifi-info': true,
|
||||
'com.apple.developer.usernotifications.communication': true,
|
||||
'com.apple.developer.usernotifications.time-sensitive': true,
|
||||
'com.apple.developer.group-session': true,
|
||||
'com.apple.developer.family-controls': true,
|
||||
'com.apple.developer.authentication-services.autofill-credential-provider': true,
|
||||
// 'com.apple.developer.game-center': true,
|
||||
'com.apple.security.application-groups': [
|
||||
@@ -61,6 +65,22 @@ describe(syncCapabilitiesForEntitlementsAsync, () => {
|
||||
{ capabilityType: 'APPLE_ID_AUTH', option: 'ON' },
|
||||
{ capabilityType: 'SIRIKIT', option: 'ON' },
|
||||
{ capabilityType: 'ACCESS_WIFI_INFORMATION', option: 'ON' },
|
||||
{
|
||||
capabilityType: 'USERNOTIFICATIONS_COMMUNICATION',
|
||||
option: 'ON',
|
||||
},
|
||||
{
|
||||
capabilityType: 'USERNOTIFICATIONS_TIMESENSITIVE',
|
||||
option: 'ON',
|
||||
},
|
||||
{
|
||||
capabilityType: 'GROUP_ACTIVITIES',
|
||||
option: 'ON',
|
||||
},
|
||||
{
|
||||
capabilityType: 'FAMILY_CONTROLS',
|
||||
option: 'ON',
|
||||
},
|
||||
{ capabilityType: 'AUTOFILL_CREDENTIAL_PROVIDER', option: 'ON' },
|
||||
{ capabilityType: 'APP_GROUPS', option: 'ON' },
|
||||
]);
|
||||
@@ -86,6 +106,10 @@ describe(syncCapabilitiesForEntitlementsAsync, () => {
|
||||
'Sign In with Apple',
|
||||
'SiriKit',
|
||||
'Access WiFi Information',
|
||||
'Communication Notifications',
|
||||
'Time Sensitive Notifications',
|
||||
'Group Activities',
|
||||
'Family Controls',
|
||||
'AutoFill Credential Provider',
|
||||
'App Groups',
|
||||
]);
|
||||
|
||||
@@ -313,6 +313,34 @@ export const CapabilityMapping: {
|
||||
validateOptions: validateDevProdString,
|
||||
getOptions: getDefinedOptions,
|
||||
},
|
||||
{
|
||||
name: 'Communication Notifications',
|
||||
entitlement: 'com.apple.developer.usernotifications.communication',
|
||||
capability: CapabilityType.USER_NOTIFICATIONS_COMMUNICATION,
|
||||
validateOptions: validateBooleanOptions,
|
||||
getOptions: getBooleanOptions,
|
||||
},
|
||||
{
|
||||
name: 'Time Sensitive Notifications',
|
||||
entitlement: 'com.apple.developer.usernotifications.time-sensitive',
|
||||
capability: CapabilityType.USER_NOTIFICATIONS_TIME_SENSITIVE,
|
||||
validateOptions: validateBooleanOptions,
|
||||
getOptions: getBooleanOptions,
|
||||
},
|
||||
{
|
||||
name: 'Group Activities',
|
||||
entitlement: 'com.apple.developer.group-session',
|
||||
capability: CapabilityType.GROUP_ACTIVITIES,
|
||||
validateOptions: validateBooleanOptions,
|
||||
getOptions: getBooleanOptions,
|
||||
},
|
||||
{
|
||||
name: 'Family Controls',
|
||||
entitlement: 'com.apple.developer.family-controls',
|
||||
capability: CapabilityType.FAMILY_CONTROLS,
|
||||
validateOptions: validateBooleanOptions,
|
||||
getOptions: getBooleanOptions,
|
||||
},
|
||||
{
|
||||
// https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_default-data-protection
|
||||
name: 'Data Protection',
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`print credentials prints the IosAppCredentials map 1`] = `"iOS Credentials Project: @quinlanj/test52 Bundle Identifier: com.quinlanj.test52 Apple Team: test-apple-identifier Push Key: Developer Portal ID: 9839M6AY8W Apple Team: 77KQ969CHE Updated 6 months ago Configuration: App Store Distribution Certificate: Serial Number: test-serial Expiration Date: Wed, 13 Oct 2021 18:28:44 GMT+0000 Apple Team: test-apple-identifier Updated 6 months ago Provisioning Profile: Developer Portal ID: test-profile-id Status: active Expiration Date: Wed, 13 Oct 2021 18:28:44 GMT+0000 Apple Team: test-apple-identifier Updated 5 months ago Configuration: Ad Hoc Distribution Certificate: Serial Number: test-serial Expiration Date: Wed, 13 Oct 2021 18:28:44 GMT+0000 Apple Team: test-apple-identifier Updated 6 months ago Provisioning Profile: Developer Portal ID: test-profile-id Status: active Expiration Date: Wed, 13 Oct 2021 18:28:44 GMT+0000 Apple Team: test-apple-identifier Updated 5 months ago"`;
|
||||
exports[`print credentials prints the IosAppCredentials map 1`] = `"iOS Credentials Project: @quinlanj/test52 Bundle Identifier: com.quinlanj.test52 Apple Team: test-apple-identifier Push Key: Developer Portal ID: 9839M6AY8W Apple Team: 77KQ969CHE Updated 6 months ago App Specific Password: Apple ID Username: [email protected] Password Label: description for super secret password Updated 6 months ago Configuration: App Store Distribution Certificate: Serial Number: test-serial Expiration Date: Wed, 13 Oct 2021 18:28:44 GMT+0000 Apple Team: test-apple-identifier Updated 6 months ago Provisioning Profile: Developer Portal ID: test-profile-id Status: active Expiration Date: Wed, 13 Oct 2021 18:28:44 GMT+0000 Apple Team: test-apple-identifier Updated 5 months ago Configuration: Ad Hoc Distribution Certificate: Serial Number: test-serial Expiration Date: Wed, 13 Oct 2021 18:28:44 GMT+0000 Apple Team: test-apple-identifier Updated 6 months ago Provisioning Profile: Developer Portal ID: test-profile-id Status: active Expiration Date: Wed, 13 Oct 2021 18:28:44 GMT+0000 Apple Team: test-apple-identifier Updated 5 months ago"`;
|
||||
@@ -2,6 +2,7 @@ import chalk from 'chalk';
|
||||
import dateformat from 'dateformat';
|
||||
|
||||
import {
|
||||
AppleAppSpecificPasswordFragment,
|
||||
AppleDeviceFragment,
|
||||
ApplePushKeyFragment,
|
||||
IosAppBuildCredentialsFragment,
|
||||
@@ -77,14 +78,14 @@ export function displayIosCredentials(
|
||||
}
|
||||
Log.log(` Bundle Identifier: ${chalk.bold(bundleIdentifier)}`);
|
||||
const targetAppCredentials = appCredentialsMap[targetName];
|
||||
if (!targetAppCredentials || targetAppCredentials.iosAppBuildCredentialsList.length === 0) {
|
||||
if (!targetAppCredentials) {
|
||||
Log.newLine();
|
||||
Log.log(` No credentials set up yet!`);
|
||||
Log.newLine();
|
||||
continue;
|
||||
}
|
||||
|
||||
const { appleTeam, pushKey } = targetAppCredentials;
|
||||
const { appleTeam, pushKey, appSpecificPassword } = targetAppCredentials;
|
||||
if (appleTeam) {
|
||||
const { appleTeamIdentifier, appleTeamName } = appleTeam;
|
||||
Log.log(` Apple Team: ${appleTeamIdentifier} ${appleTeamName ? `(${appleTeamName})` : ''}`);
|
||||
@@ -95,6 +96,10 @@ export function displayIosCredentials(
|
||||
displayApplePushKey(pushKey);
|
||||
}
|
||||
|
||||
if (appSpecificPassword) {
|
||||
displayAppSpecificPassword(appSpecificPassword);
|
||||
}
|
||||
|
||||
const sortedIosAppBuildCredentialsList = sortBuildCredentialsByDistributionType(
|
||||
targetAppCredentials.iosAppBuildCredentialsList
|
||||
);
|
||||
@@ -189,6 +194,23 @@ function displayIosAppBuildCredentials(buildCredentials: IosAppBuildCredentialsF
|
||||
Log.newLine();
|
||||
}
|
||||
|
||||
function displayAppSpecificPassword(
|
||||
maybeAppSpecificPassword: AppleAppSpecificPasswordFragment | null
|
||||
): void {
|
||||
Log.log(` App Specific Password:`);
|
||||
if (maybeAppSpecificPassword) {
|
||||
const { appleIdUsername, passwordLabel, updatedAt } = maybeAppSpecificPassword;
|
||||
Log.log(` Apple ID Username: ${appleIdUsername}`);
|
||||
if (passwordLabel) {
|
||||
Log.log(` Password Label: ${passwordLabel}`);
|
||||
}
|
||||
Log.log(` Updated ${fromNow(new Date(updatedAt))} ago`);
|
||||
} else {
|
||||
Log.log(` None assigned yet`);
|
||||
}
|
||||
Log.newLine();
|
||||
}
|
||||
|
||||
function displayApplePushKey(maybePushKey: ApplePushKeyFragment | null): void {
|
||||
Log.log(` Push Key:`);
|
||||
if (maybePushKey) {
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
import Log from '../../log';
|
||||
import { getProjectAccountName } from '../../project/projectUtils';
|
||||
import assert from 'assert';
|
||||
|
||||
import Log, { learnMore } from '../../log';
|
||||
import {
|
||||
getProjectAccountName,
|
||||
promptToCreateProjectIfNotExistsAsync,
|
||||
} from '../../project/projectUtils';
|
||||
import { promptAsync } from '../../prompts';
|
||||
import { findAccountByName } from '../../user/Account';
|
||||
import { ensureActorHasUsername } from '../../user/actions';
|
||||
import { AssignFcm } from '../android/actions/AssignFcm';
|
||||
import {
|
||||
canCopyLegacyCredentialsAsync,
|
||||
getAppLookupParamsFromContext,
|
||||
getAppLookupParamsFromContextAsync,
|
||||
promptUserAndCopyLegacyCredentialsAsync,
|
||||
} from '../android/actions/BuildCredentialsUtils';
|
||||
import { CreateFcm } from '../android/actions/CreateFcm';
|
||||
@@ -147,7 +152,13 @@ export class ManageAndroid {
|
||||
throw new Error(`You do not have access to account: ${accountName}`);
|
||||
}
|
||||
if (ctx.hasProjectContext) {
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const maybeProjectId = await promptToCreateProjectIfNotExistsAsync(ctx.exp);
|
||||
if (!maybeProjectId) {
|
||||
throw new Error(
|
||||
'Your project must be registered with EAS in order to use the credentials manager.'
|
||||
);
|
||||
}
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const appCredentials = await ctx.android.getAndroidAppCredentialsWithCommonFieldsAsync(
|
||||
appLookupParams
|
||||
);
|
||||
@@ -196,61 +207,74 @@ export class ManageAndroid {
|
||||
return await this.callingAction.runAsync(ctx);
|
||||
}
|
||||
}
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
if (chosenAction === ActionType.CreateKeystore) {
|
||||
const selectBuildCredentialsResult = await new SelectAndroidBuildCredentials(
|
||||
appLookupParams
|
||||
).runAsync(ctx);
|
||||
const keystore = await new CreateKeystore(appLookupParams.account).runAsync(ctx);
|
||||
if (
|
||||
selectBuildCredentialsResult.resultType ===
|
||||
SelectAndroidBuildCredentialsResultType.CREATE_REQUEST
|
||||
) {
|
||||
await ctx.android.createAndroidAppBuildCredentialsAsync(appLookupParams, {
|
||||
...selectBuildCredentialsResult.result,
|
||||
androidKeystoreId: keystore.id,
|
||||
});
|
||||
} else {
|
||||
await ctx.android.updateAndroidAppBuildCredentialsAsync(
|
||||
selectBuildCredentialsResult.result,
|
||||
{
|
||||
androidKeystoreId: keystore.id,
|
||||
}
|
||||
);
|
||||
}
|
||||
} else if (chosenAction === ActionType.DownloadKeystore) {
|
||||
const buildCredentials = await new SelectExistingAndroidBuildCredentials(
|
||||
appLookupParams
|
||||
).runAsync(ctx);
|
||||
if (buildCredentials) {
|
||||
await new DownloadKeystore({ app: appLookupParams }).runAsync(ctx, buildCredentials);
|
||||
}
|
||||
} else if (chosenAction === ActionType.RemoveKeystore) {
|
||||
const buildCredentials = await new SelectExistingAndroidBuildCredentials(
|
||||
appLookupParams
|
||||
).runAsync(ctx);
|
||||
if (buildCredentials) {
|
||||
await new RemoveKeystore(appLookupParams).runAsync(ctx, buildCredentials);
|
||||
}
|
||||
} else if (chosenAction === ActionType.CreateFcm) {
|
||||
const fcm = await new CreateFcm(appLookupParams.account).runAsync(ctx);
|
||||
await new AssignFcm(appLookupParams).runAsync(ctx, fcm);
|
||||
} else if (chosenAction === ActionType.RemoveFcm) {
|
||||
await new RemoveFcm(appLookupParams).runAsync(ctx);
|
||||
} else if (chosenAction === ActionType.UpdateCredentialsJson) {
|
||||
const buildCredentials = await new SelectExistingAndroidBuildCredentials(
|
||||
appLookupParams
|
||||
).runAsync(ctx);
|
||||
if (buildCredentials) {
|
||||
await new UpdateCredentialsJson().runAsync(ctx, buildCredentials);
|
||||
}
|
||||
} else if (chosenAction === ActionType.SetupBuildCredentialsFromCredentialsJson) {
|
||||
await new SetupBuildCredentialsFromCredentialsJson(appLookupParams).runAsync(ctx);
|
||||
}
|
||||
|
||||
await this.runProjectSpecificActionAsync(ctx, chosenAction);
|
||||
} catch (err) {
|
||||
Log.error(err);
|
||||
if (process.env.DEBUG) {
|
||||
throw err; // breaks out of the loop so we can get stack trace
|
||||
}
|
||||
Log.error(`Cryptic error? ${learnMore('https://expo.fyi/cryptic-error-eas')}`);
|
||||
}
|
||||
await new PressAnyKeyToContinue().runAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async runProjectSpecificActionAsync(ctx: Context, action: ActionType): Promise<void> {
|
||||
assert(
|
||||
ctx.hasProjectContext,
|
||||
'You must be in your project directory in order to perform this action'
|
||||
);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
if (action === ActionType.CreateKeystore) {
|
||||
const selectBuildCredentialsResult = await new SelectAndroidBuildCredentials(
|
||||
appLookupParams
|
||||
).runAsync(ctx);
|
||||
const keystore = await new CreateKeystore(appLookupParams.account).runAsync(ctx);
|
||||
if (
|
||||
selectBuildCredentialsResult.resultType ===
|
||||
SelectAndroidBuildCredentialsResultType.CREATE_REQUEST
|
||||
) {
|
||||
await ctx.android.createAndroidAppBuildCredentialsAsync(appLookupParams, {
|
||||
...selectBuildCredentialsResult.result,
|
||||
androidKeystoreId: keystore.id,
|
||||
});
|
||||
} else {
|
||||
await ctx.android.updateAndroidAppBuildCredentialsAsync(
|
||||
selectBuildCredentialsResult.result,
|
||||
{
|
||||
androidKeystoreId: keystore.id,
|
||||
}
|
||||
);
|
||||
}
|
||||
} else if (action === ActionType.DownloadKeystore) {
|
||||
const buildCredentials = await new SelectExistingAndroidBuildCredentials(
|
||||
appLookupParams
|
||||
).runAsync(ctx);
|
||||
if (buildCredentials) {
|
||||
await new DownloadKeystore({ app: appLookupParams }).runAsync(ctx, buildCredentials);
|
||||
}
|
||||
} else if (action === ActionType.RemoveKeystore) {
|
||||
const buildCredentials = await new SelectExistingAndroidBuildCredentials(
|
||||
appLookupParams
|
||||
).runAsync(ctx);
|
||||
if (buildCredentials) {
|
||||
await new RemoveKeystore(appLookupParams).runAsync(ctx, buildCredentials);
|
||||
}
|
||||
} else if (action === ActionType.CreateFcm) {
|
||||
const fcm = await new CreateFcm(appLookupParams.account).runAsync(ctx);
|
||||
await new AssignFcm(appLookupParams).runAsync(ctx, fcm);
|
||||
} else if (action === ActionType.RemoveFcm) {
|
||||
await new RemoveFcm(appLookupParams).runAsync(ctx);
|
||||
} else if (action === ActionType.UpdateCredentialsJson) {
|
||||
const buildCredentials = await new SelectExistingAndroidBuildCredentials(
|
||||
appLookupParams
|
||||
).runAsync(ctx);
|
||||
if (buildCredentials) {
|
||||
await new UpdateCredentialsJson().runAsync(ctx, buildCredentials);
|
||||
}
|
||||
} else if (action === ActionType.SetupBuildCredentialsFromCredentialsJson) {
|
||||
await new SetupBuildCredentialsFromCredentialsJson(appLookupParams).runAsync(ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,13 @@ import {
|
||||
IosAppBuildCredentialsFragment,
|
||||
IosDistributionType as IosDistributionTypeGraphql,
|
||||
} from '../../graphql/generated';
|
||||
import Log from '../../log';
|
||||
import Log, { learnMore } from '../../log';
|
||||
import { resolveXcodeBuildContextAsync } from '../../project/ios/scheme';
|
||||
import { resolveTargetsAsync } from '../../project/ios/target';
|
||||
import { getProjectAccountName } from '../../project/projectUtils';
|
||||
import {
|
||||
getProjectAccountName,
|
||||
promptToCreateProjectIfNotExistsAsync,
|
||||
} from '../../project/projectUtils';
|
||||
import { confirmAsync, promptAsync, selectAsync } from '../../prompts';
|
||||
import { Account, findAccountByName } from '../../user/Account';
|
||||
import { ensureActorHasUsername } from '../../user/actions';
|
||||
@@ -235,11 +238,15 @@ export class ManageIos {
|
||||
return await this.callingAction.runAsync(ctx);
|
||||
}
|
||||
} else if (actionInfo.scope === Scope.Project) {
|
||||
assert(
|
||||
ctx.hasProjectContext,
|
||||
'You must be in your project directory in order to perform this action'
|
||||
);
|
||||
await this.runProjectSpecificActionAsync(
|
||||
ctx,
|
||||
nullthrows(app),
|
||||
nullthrows(targets),
|
||||
nullthrows(buildProfile),
|
||||
nullthrows(app, 'app must be defined in project context'),
|
||||
nullthrows(targets, 'targets must be defined in project context'),
|
||||
nullthrows(buildProfile, 'buildProfile must be defined in project context'),
|
||||
chosenAction
|
||||
);
|
||||
} else if (actionInfo.scope === Scope.Account) {
|
||||
@@ -249,6 +256,10 @@ export class ManageIos {
|
||||
}
|
||||
} catch (err) {
|
||||
Log.error(err);
|
||||
if (process.env.DEBUG) {
|
||||
throw err; // breaks out of the loop so we can get stack trace
|
||||
}
|
||||
Log.error(`Cryptic error? ${learnMore('https://expo.fyi/cryptic-error-eas')}`);
|
||||
}
|
||||
await new PressAnyKeyToContinue().runAsync();
|
||||
}
|
||||
@@ -266,6 +277,13 @@ export class ManageIos {
|
||||
};
|
||||
}
|
||||
|
||||
const maybeProjectId = await promptToCreateProjectIfNotExistsAsync(ctx.exp);
|
||||
if (!maybeProjectId) {
|
||||
throw new Error(
|
||||
'Your project must be registered with EAS in order to use the credentials manager.'
|
||||
);
|
||||
}
|
||||
|
||||
const app = { account, projectName: ctx.exp.slug };
|
||||
const easJsonReader = new EasJsonReader(ctx.projectDir, 'ios');
|
||||
const easConfig = await new SelectBuildProfileFromEasJson(easJsonReader).runAsync(ctx);
|
||||
|
||||
+5
-5
@@ -4,7 +4,7 @@ import {
|
||||
testAndroidBuildCredentialsFragment,
|
||||
} from '../../__tests__/fixtures-android';
|
||||
import { createCtxMock } from '../../__tests__/fixtures-context';
|
||||
import { getAppLookupParamsFromContext } from '../../android/actions/BuildCredentialsUtils';
|
||||
import { getAppLookupParamsFromContextAsync } from '../../android/actions/BuildCredentialsUtils';
|
||||
import {
|
||||
SelectAndroidBuildCredentials,
|
||||
SelectAndroidBuildCredentialsResultType,
|
||||
@@ -28,7 +28,7 @@ describe(SelectAndroidBuildCredentials, () => {
|
||||
getAndroidAppBuildCredentialsListAsync: jest.fn(() => []),
|
||||
},
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const selectAndroidBuildCredentialsAction = new SelectAndroidBuildCredentials(appLookupParams);
|
||||
const buildCredentialsMetadataInput = await selectAndroidBuildCredentialsAction.runAsync(ctx);
|
||||
expect(buildCredentialsMetadataInput).toMatchObject({
|
||||
@@ -50,7 +50,7 @@ describe(SelectAndroidBuildCredentials, () => {
|
||||
]),
|
||||
},
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const selectAndroidBuildCredentialsAction = new SelectAndroidBuildCredentials(appLookupParams);
|
||||
const buildCredentialsMetadataInput = await selectAndroidBuildCredentialsAction.runAsync(ctx);
|
||||
expect(buildCredentialsMetadataInput).toMatchObject({
|
||||
@@ -70,7 +70,7 @@ describe(SelectAndroidBuildCredentials, () => {
|
||||
getAndroidAppBuildCredentialsListAsync: jest.fn(() => []),
|
||||
},
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const selectAndroidBuildCredentialsAction = new SelectAndroidBuildCredentials(appLookupParams);
|
||||
const buildCredentialsMetadataInput = await selectAndroidBuildCredentialsAction.runAsync(ctx);
|
||||
expect(buildCredentialsMetadataInput).toMatchObject({
|
||||
@@ -90,7 +90,7 @@ describe(SelectAndroidBuildCredentials, () => {
|
||||
]),
|
||||
},
|
||||
});
|
||||
const appLookupParams = getAppLookupParamsFromContext(ctx);
|
||||
const appLookupParams = await getAppLookupParamsFromContextAsync(ctx);
|
||||
const selectAndroidBuildCredentialsAction = new SelectAndroidBuildCredentials(appLookupParams);
|
||||
const buildCredentialsMetadataInput = await selectAndroidBuildCredentialsAction.runAsync(ctx);
|
||||
expect(buildCredentialsMetadataInput).toMatchObject({
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import prompts from 'prompts';
|
||||
|
||||
import { asMock } from '../../__tests__/utils';
|
||||
import Log from '../../log';
|
||||
import { Actor } from '../../user/User';
|
||||
import { AccountResolver } from '../manager';
|
||||
|
||||
@@ -69,15 +70,11 @@ describe(AccountResolver, () => {
|
||||
accounts: [user.accounts[0]],
|
||||
};
|
||||
|
||||
const originalConsoleWarn = console.warn;
|
||||
console.warn = jest.fn();
|
||||
|
||||
jest.spyOn(Log, 'warn');
|
||||
const resolver = new AccountResolver(exp, userWithAccessToProjectAccount);
|
||||
const account = await resolver.resolveAccountAsync();
|
||||
expect(account).toEqual(user.accounts[0]);
|
||||
expect(console.warn).toBeCalledWith(expect.stringMatching(/doesn't have access to the/));
|
||||
|
||||
console.warn = originalConsoleWarn;
|
||||
expect(Log.warn).toBeCalledWith(expect.stringMatching(/doesn't have access to the/));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -6,14 +6,6 @@ import DeviceCreateAction, { RegistrationMethod } from '../action';
|
||||
import { runInputMethodAsync } from '../inputMethod';
|
||||
import { runRegistrationUrlMethodAsync } from '../registrationUrlMethod';
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
});
|
||||
|
||||
jest.mock('prompts');
|
||||
jest.mock('../registrationUrlMethod');
|
||||
jest.mock('../inputMethod');
|
||||
|
||||
@@ -8,17 +8,6 @@ import { runInputMethodAsync } from '../inputMethod';
|
||||
jest.mock('prompts');
|
||||
jest.mock('../../../../credentials/ios/api/graphql/mutations/AppleDeviceMutation');
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
const originalConsoleWarn = console.warn;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
console.warn = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
console.warn = originalConsoleWarn;
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
asMock(prompts).mockReset();
|
||||
asMock(prompts).mockImplementation(() => {
|
||||
|
||||
@@ -14,7 +14,7 @@ export async function runRegistrationUrlMethodAsync(
|
||||
): Promise<void> {
|
||||
const registrationURL = await generateDeviceRegistrationURLAsync(accountId, appleTeam);
|
||||
Log.newLine();
|
||||
qrcodeTerminal.generate(registrationURL, code => console.log(`${indentString(code, 2)}\n`));
|
||||
qrcodeTerminal.generate(registrationURL, code => Log.log(`${indentString(code, 2)}\n`));
|
||||
Log.log(
|
||||
'Open the following link on your iOS devices (or scan the QR code) and follow the instructions to install the development profile:'
|
||||
);
|
||||
|
||||
@@ -61,10 +61,6 @@ export type RootQuery = {
|
||||
/** Top-level query object for querying Experimentation configuration. */
|
||||
experimentation: ExperimentationQuery;
|
||||
project: ProjectQuery;
|
||||
/** Search for Snacks */
|
||||
search: Array<SearchResult>;
|
||||
/** @deprecated Use 'search' root field. */
|
||||
searchUsersAndApps: Array<Maybe<SearchResult>>;
|
||||
snack: SnackQuery;
|
||||
submissions: SubmissionQuery;
|
||||
/** Top-level query object for querying UserInvitationPublicData publicly. */
|
||||
@@ -113,22 +109,6 @@ export type RootQueryAllPublicAppsArgs = {
|
||||
};
|
||||
|
||||
|
||||
export type RootQuerySearchArgs = {
|
||||
type: SearchType;
|
||||
query: Scalars['String'];
|
||||
offset: Scalars['Int'];
|
||||
limit: Scalars['Int'];
|
||||
};
|
||||
|
||||
|
||||
export type RootQuerySearchUsersAndAppsArgs = {
|
||||
type: SearchType;
|
||||
query: Scalars['String'];
|
||||
offset: Scalars['Int'];
|
||||
limit: Scalars['Int'];
|
||||
};
|
||||
|
||||
|
||||
export type RootQueryUserByUserIdArgs = {
|
||||
userId: Scalars['String'];
|
||||
};
|
||||
@@ -637,6 +617,7 @@ export type Build = ActivityTimelineProjectActivity & BuildOrBuildJob & {
|
||||
appVersion?: Maybe<Scalars['String']>;
|
||||
appBuildVersion?: Maybe<Scalars['String']>;
|
||||
sdkVersion?: Maybe<Scalars['String']>;
|
||||
runtimeVersion?: Maybe<Scalars['String']>;
|
||||
releaseChannel?: Maybe<Scalars['String']>;
|
||||
channel?: Maybe<Scalars['String']>;
|
||||
metrics?: Maybe<BuildMetrics>;
|
||||
@@ -644,6 +625,7 @@ export type Build = ActivityTimelineProjectActivity & BuildOrBuildJob & {
|
||||
buildProfile?: Maybe<Scalars['String']>;
|
||||
gitCommitHash?: Maybe<Scalars['String']>;
|
||||
error?: Maybe<BuildError>;
|
||||
submissions: Array<Submission>;
|
||||
};
|
||||
|
||||
export type BuildOrBuildJob = {
|
||||
@@ -825,6 +807,72 @@ export type BuildError = {
|
||||
docsUrl?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
/** Represents an EAS Submission */
|
||||
export type Submission = ActivityTimelineProjectActivity & {
|
||||
__typename?: 'Submission';
|
||||
id: Scalars['ID'];
|
||||
actor?: Maybe<Actor>;
|
||||
activityTimestamp: Scalars['DateTime'];
|
||||
app?: Maybe<App>;
|
||||
initiatingActor?: Maybe<Actor>;
|
||||
submittedBuild?: Maybe<Build>;
|
||||
platform: AppPlatform;
|
||||
status: SubmissionStatus;
|
||||
androidConfig?: Maybe<AndroidSubmissionConfig>;
|
||||
iosConfig?: Maybe<IosSubmissionConfig>;
|
||||
logsUrl?: Maybe<Scalars['String']>;
|
||||
error?: Maybe<SubmissionError>;
|
||||
createdAt: Scalars['DateTime'];
|
||||
updatedAt: Scalars['DateTime'];
|
||||
};
|
||||
|
||||
export enum SubmissionStatus {
|
||||
InQueue = 'IN_QUEUE',
|
||||
InProgress = 'IN_PROGRESS',
|
||||
Finished = 'FINISHED',
|
||||
Errored = 'ERRORED'
|
||||
}
|
||||
|
||||
export type AndroidSubmissionConfig = {
|
||||
__typename?: 'AndroidSubmissionConfig';
|
||||
applicationIdentifier: Scalars['String'];
|
||||
archiveType: SubmissionAndroidArchiveType;
|
||||
track: SubmissionAndroidTrack;
|
||||
releaseStatus?: Maybe<SubmissionAndroidReleaseStatus>;
|
||||
};
|
||||
|
||||
export enum SubmissionAndroidArchiveType {
|
||||
Apk = 'APK',
|
||||
Aab = 'AAB'
|
||||
}
|
||||
|
||||
export enum SubmissionAndroidTrack {
|
||||
Production = 'PRODUCTION',
|
||||
Internal = 'INTERNAL',
|
||||
Alpha = 'ALPHA',
|
||||
Beta = 'BETA'
|
||||
}
|
||||
|
||||
export enum SubmissionAndroidReleaseStatus {
|
||||
Draft = 'DRAFT',
|
||||
InProgress = 'IN_PROGRESS',
|
||||
Halted = 'HALTED',
|
||||
Completed = 'COMPLETED'
|
||||
}
|
||||
|
||||
export type IosSubmissionConfig = {
|
||||
__typename?: 'IosSubmissionConfig';
|
||||
ascAppIdentifier: Scalars['String'];
|
||||
appleIdUsername: Scalars['String'];
|
||||
appleAppSpecificPasswordId?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export type SubmissionError = {
|
||||
__typename?: 'SubmissionError';
|
||||
errorCode?: Maybe<Scalars['String']>;
|
||||
message?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
/** Represents an Standalone App build job */
|
||||
export type BuildJob = ActivityTimelineProjectActivity & BuildOrBuildJob & {
|
||||
__typename?: 'BuildJob';
|
||||
@@ -891,71 +939,6 @@ export type SubmissionFilter = {
|
||||
status?: Maybe<SubmissionStatus>;
|
||||
};
|
||||
|
||||
export enum SubmissionStatus {
|
||||
InQueue = 'IN_QUEUE',
|
||||
InProgress = 'IN_PROGRESS',
|
||||
Finished = 'FINISHED',
|
||||
Errored = 'ERRORED'
|
||||
}
|
||||
|
||||
/** Represents an EAS Submission */
|
||||
export type Submission = ActivityTimelineProjectActivity & {
|
||||
__typename?: 'Submission';
|
||||
id: Scalars['ID'];
|
||||
actor?: Maybe<Actor>;
|
||||
activityTimestamp: Scalars['DateTime'];
|
||||
app?: Maybe<App>;
|
||||
initiatingActor?: Maybe<Actor>;
|
||||
platform: AppPlatform;
|
||||
status: SubmissionStatus;
|
||||
androidConfig?: Maybe<AndroidSubmissionConfig>;
|
||||
iosConfig?: Maybe<IosSubmissionConfig>;
|
||||
logsUrl?: Maybe<Scalars['String']>;
|
||||
error?: Maybe<SubmissionError>;
|
||||
createdAt: Scalars['DateTime'];
|
||||
updatedAt: Scalars['DateTime'];
|
||||
};
|
||||
|
||||
export type AndroidSubmissionConfig = {
|
||||
__typename?: 'AndroidSubmissionConfig';
|
||||
applicationIdentifier: Scalars['String'];
|
||||
archiveType: SubmissionAndroidArchiveType;
|
||||
track: SubmissionAndroidTrack;
|
||||
releaseStatus?: Maybe<SubmissionAndroidReleaseStatus>;
|
||||
};
|
||||
|
||||
export enum SubmissionAndroidArchiveType {
|
||||
Apk = 'APK',
|
||||
Aab = 'AAB'
|
||||
}
|
||||
|
||||
export enum SubmissionAndroidTrack {
|
||||
Production = 'PRODUCTION',
|
||||
Internal = 'INTERNAL',
|
||||
Alpha = 'ALPHA',
|
||||
Beta = 'BETA'
|
||||
}
|
||||
|
||||
export enum SubmissionAndroidReleaseStatus {
|
||||
Draft = 'DRAFT',
|
||||
InProgress = 'IN_PROGRESS',
|
||||
Halted = 'HALTED',
|
||||
Completed = 'COMPLETED'
|
||||
}
|
||||
|
||||
export type IosSubmissionConfig = {
|
||||
__typename?: 'IosSubmissionConfig';
|
||||
ascAppIdentifier: Scalars['String'];
|
||||
appleIdUsername: Scalars['String'];
|
||||
appleAppSpecificPasswordId?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export type SubmissionError = {
|
||||
__typename?: 'SubmissionError';
|
||||
errorCode?: Maybe<Scalars['String']>;
|
||||
message?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export type IosAppCredentialsFilter = {
|
||||
appleAppIdentifierId?: Maybe<Scalars['String']>;
|
||||
};
|
||||
@@ -1513,6 +1496,12 @@ export type BuildQuery = {
|
||||
* @deprecated Use App.builds instead
|
||||
*/
|
||||
allForApp: Array<Maybe<Build>>;
|
||||
/**
|
||||
* Get all builds.
|
||||
* By default, they are sorted from latest to oldest.
|
||||
* Available only for admin users.
|
||||
*/
|
||||
all: Array<Build>;
|
||||
};
|
||||
|
||||
|
||||
@@ -1529,6 +1518,19 @@ export type BuildQueryAllForAppArgs = {
|
||||
limit?: Maybe<Scalars['Int']>;
|
||||
};
|
||||
|
||||
|
||||
export type BuildQueryAllArgs = {
|
||||
statuses?: Maybe<Array<BuildStatus>>;
|
||||
offset?: Maybe<Scalars['Int']>;
|
||||
limit?: Maybe<Scalars['Int']>;
|
||||
order?: Maybe<Order>;
|
||||
};
|
||||
|
||||
export enum Order {
|
||||
Desc = 'DESC',
|
||||
Asc = 'ASC'
|
||||
}
|
||||
|
||||
export type ClientBuildQuery = {
|
||||
__typename?: 'ClientBuildQuery';
|
||||
byId: ClientBuild;
|
||||
@@ -1590,19 +1592,6 @@ export type ProjectQueryByPathsArgs = {
|
||||
paths?: Maybe<Array<Maybe<Scalars['String']>>>;
|
||||
};
|
||||
|
||||
export enum SearchType {
|
||||
All = 'ALL',
|
||||
Users = 'USERS',
|
||||
Apps = 'APPS',
|
||||
Snacks = 'SNACKS'
|
||||
}
|
||||
|
||||
/** Represents a search result for an app */
|
||||
export type SearchResult = {
|
||||
id: Scalars['ID'];
|
||||
rank?: Maybe<Scalars['Int']>;
|
||||
};
|
||||
|
||||
export type SnackQuery = {
|
||||
__typename?: 'SnackQuery';
|
||||
/**
|
||||
@@ -2352,14 +2341,24 @@ export type BuildMutation = {
|
||||
* @deprecated Use cancelBuild instead
|
||||
*/
|
||||
cancel: Build;
|
||||
/** Create an Android generic build */
|
||||
/**
|
||||
* Create an Android generic build
|
||||
* @deprecated Use createAndroidBuild instead
|
||||
*/
|
||||
createAndroidGenericBuild: CreateBuildResult;
|
||||
/** Create an Android managed build */
|
||||
/**
|
||||
* Create an Android managed build
|
||||
* @deprecated Use createAndroidBuild instead
|
||||
*/
|
||||
createAndroidManagedBuild: CreateBuildResult;
|
||||
/** Create an Android build */
|
||||
createAndroidBuild: CreateBuildResult;
|
||||
/** Create an iOS generic build */
|
||||
createIosGenericBuild: CreateBuildResult;
|
||||
/** Create an iOS managed build */
|
||||
createIosManagedBuild: CreateBuildResult;
|
||||
/** Create an iOS build */
|
||||
createIosBuild: CreateBuildResult;
|
||||
};
|
||||
|
||||
|
||||
@@ -2387,6 +2386,13 @@ export type BuildMutationCreateAndroidManagedBuildArgs = {
|
||||
};
|
||||
|
||||
|
||||
export type BuildMutationCreateAndroidBuildArgs = {
|
||||
appId: Scalars['ID'];
|
||||
job: AndroidJobInput;
|
||||
metadata?: Maybe<BuildMetadataInput>;
|
||||
};
|
||||
|
||||
|
||||
export type BuildMutationCreateIosGenericBuildArgs = {
|
||||
appId: Scalars['ID'];
|
||||
job: IosGenericJobInput;
|
||||
@@ -2400,6 +2406,13 @@ export type BuildMutationCreateIosManagedBuildArgs = {
|
||||
metadata?: Maybe<BuildMetadataInput>;
|
||||
};
|
||||
|
||||
|
||||
export type BuildMutationCreateIosBuildArgs = {
|
||||
appId: Scalars['ID'];
|
||||
job: IosJobInput;
|
||||
metadata?: Maybe<BuildMetadataInput>;
|
||||
};
|
||||
|
||||
export type AndroidGenericJobInput = {
|
||||
projectArchive: ProjectArchiveSourceInput;
|
||||
projectRootDirectory: Scalars['String'];
|
||||
@@ -2468,6 +2481,7 @@ export type BuildMetadataInput = {
|
||||
workflow?: Maybe<BuildWorkflow>;
|
||||
credentialsSource?: Maybe<BuildCredentialsSource>;
|
||||
sdkVersion?: Maybe<Scalars['String']>;
|
||||
runtimeVersion?: Maybe<Scalars['String']>;
|
||||
releaseChannel?: Maybe<Scalars['String']>;
|
||||
channel?: Maybe<Scalars['String']>;
|
||||
distribution?: Maybe<DistributionType>;
|
||||
@@ -2523,6 +2537,27 @@ export enum AndroidManagedBuildType {
|
||||
DevelopmentClient = 'DEVELOPMENT_CLIENT'
|
||||
}
|
||||
|
||||
export type AndroidJobInput = {
|
||||
type: BuildWorkflow;
|
||||
projectArchive: ProjectArchiveSourceInput;
|
||||
projectRootDirectory: Scalars['String'];
|
||||
releaseChannel?: Maybe<Scalars['String']>;
|
||||
updates?: Maybe<BuildUpdatesInput>;
|
||||
secrets?: Maybe<AndroidJobSecretsInput>;
|
||||
builderEnvironment?: Maybe<AndroidBuilderEnvironmentInput>;
|
||||
cache?: Maybe<BuildCacheInput>;
|
||||
gradleCommand?: Maybe<Scalars['String']>;
|
||||
artifactPath?: Maybe<Scalars['String']>;
|
||||
buildType?: Maybe<AndroidBuildType>;
|
||||
username?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export enum AndroidBuildType {
|
||||
Apk = 'APK',
|
||||
AppBundle = 'APP_BUNDLE',
|
||||
DevelopmentClient = 'DEVELOPMENT_CLIENT'
|
||||
}
|
||||
|
||||
export type IosGenericJobInput = {
|
||||
projectArchive: ProjectArchiveSourceInput;
|
||||
projectRootDirectory: Scalars['String'];
|
||||
@@ -2588,6 +2623,28 @@ export enum IosManagedBuildType {
|
||||
DevelopmentClient = 'DEVELOPMENT_CLIENT'
|
||||
}
|
||||
|
||||
export type IosJobInput = {
|
||||
type: BuildWorkflow;
|
||||
projectArchive: ProjectArchiveSourceInput;
|
||||
projectRootDirectory: Scalars['String'];
|
||||
releaseChannel?: Maybe<Scalars['String']>;
|
||||
updates?: Maybe<BuildUpdatesInput>;
|
||||
distribution?: Maybe<DistributionType>;
|
||||
secrets?: Maybe<IosJobSecretsInput>;
|
||||
builderEnvironment?: Maybe<IosBuilderEnvironmentInput>;
|
||||
cache?: Maybe<BuildCacheInput>;
|
||||
scheme?: Maybe<Scalars['String']>;
|
||||
buildConfiguration?: Maybe<Scalars['String']>;
|
||||
artifactPath?: Maybe<Scalars['String']>;
|
||||
buildType?: Maybe<IosBuildType>;
|
||||
username?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export enum IosBuildType {
|
||||
Release = 'RELEASE',
|
||||
DevelopmentClient = 'DEVELOPMENT_CLIENT'
|
||||
}
|
||||
|
||||
export type IosAppBuildCredentialsMutation = {
|
||||
__typename?: 'IosAppBuildCredentialsMutation';
|
||||
/** Create a set of build credentials for an iOS app */
|
||||
@@ -2740,6 +2797,7 @@ export type CreateSubmissionInput = {
|
||||
appId: Scalars['ID'];
|
||||
platform: AppPlatform;
|
||||
config: Scalars['JSONObject'];
|
||||
submittedBuildId?: Maybe<Scalars['ID']>;
|
||||
};
|
||||
|
||||
export type CreateSubmissionResult = {
|
||||
@@ -2751,6 +2809,7 @@ export type CreateSubmissionResult = {
|
||||
export type CreateIosSubmissionInput = {
|
||||
appId: Scalars['ID'];
|
||||
config: NewIosSubmissionConfig;
|
||||
submittedBuildId?: Maybe<Scalars['ID']>;
|
||||
};
|
||||
|
||||
export type NewIosSubmissionConfig = {
|
||||
@@ -3283,44 +3342,6 @@ export type DeleteWebhookResult = {
|
||||
id: Scalars['ID'];
|
||||
};
|
||||
|
||||
export type BaseSearchResult = SearchResult & {
|
||||
__typename?: 'BaseSearchResult';
|
||||
/** @deprecated Use SearchResult instead */
|
||||
id: Scalars['ID'];
|
||||
/** @deprecated Use SearchResult instead */
|
||||
rank?: Maybe<Scalars['Int']>;
|
||||
};
|
||||
|
||||
/** Represents a search result for an app */
|
||||
export type AppSearchResult = SearchResult & {
|
||||
__typename?: 'AppSearchResult';
|
||||
/** @deprecated Field no longer supported */
|
||||
id: Scalars['ID'];
|
||||
/** @deprecated Field no longer supported */
|
||||
rank?: Maybe<Scalars['Int']>;
|
||||
/** @deprecated Field no longer supported */
|
||||
app: App;
|
||||
};
|
||||
|
||||
/** Represents a search result for a user */
|
||||
export type UserSearchResult = SearchResult & {
|
||||
__typename?: 'UserSearchResult';
|
||||
/** @deprecated Field no longer supported */
|
||||
id: Scalars['ID'];
|
||||
/** @deprecated Field no longer supported */
|
||||
rank?: Maybe<Scalars['Int']>;
|
||||
/** @deprecated Field no longer supported */
|
||||
user: User;
|
||||
};
|
||||
|
||||
/** Represents a search result for a snack */
|
||||
export type SnackSearchResult = SearchResult & {
|
||||
__typename?: 'SnackSearchResult';
|
||||
id: Scalars['ID'];
|
||||
rank?: Maybe<Scalars['Int']>;
|
||||
snack: Snack;
|
||||
};
|
||||
|
||||
export enum CacheControlScope {
|
||||
Public = 'PUBLIC',
|
||||
Private = 'PRIVATE'
|
||||
@@ -3624,6 +3645,22 @@ export type GetChannelByNameForAppQuery = (
|
||||
)> }
|
||||
);
|
||||
|
||||
export type AppInfoQueryVariables = Exact<{
|
||||
appId: Scalars['String'];
|
||||
}>;
|
||||
|
||||
|
||||
export type AppInfoQuery = (
|
||||
{ __typename?: 'RootQuery' }
|
||||
& { app?: Maybe<(
|
||||
{ __typename?: 'AppQuery' }
|
||||
& { byId: (
|
||||
{ __typename?: 'App' }
|
||||
& Pick<App, 'id' | 'fullName'>
|
||||
) }
|
||||
)> }
|
||||
);
|
||||
|
||||
export type DeleteUpdateGroupMutationVariables = Exact<{
|
||||
group: Scalars['ID'];
|
||||
}>;
|
||||
@@ -4497,18 +4534,18 @@ export type CreateAppMutation = (
|
||||
)> }
|
||||
);
|
||||
|
||||
export type CreateAndroidGenericBuildMutationVariables = Exact<{
|
||||
export type CreateAndroidBuildMutationVariables = Exact<{
|
||||
appId: Scalars['ID'];
|
||||
job: AndroidGenericJobInput;
|
||||
job: AndroidJobInput;
|
||||
metadata?: Maybe<BuildMetadataInput>;
|
||||
}>;
|
||||
|
||||
|
||||
export type CreateAndroidGenericBuildMutation = (
|
||||
export type CreateAndroidBuildMutation = (
|
||||
{ __typename?: 'RootMutation' }
|
||||
& { build?: Maybe<(
|
||||
{ __typename?: 'BuildMutation' }
|
||||
& { createAndroidGenericBuild: (
|
||||
& { createAndroidBuild: (
|
||||
{ __typename?: 'CreateBuildResult' }
|
||||
& { build: (
|
||||
{ __typename?: 'Build' }
|
||||
@@ -4521,66 +4558,18 @@ export type CreateAndroidGenericBuildMutation = (
|
||||
)> }
|
||||
);
|
||||
|
||||
export type CreateAndroidManagedBuildMutationVariables = Exact<{
|
||||
export type CreateIosBuildMutationVariables = Exact<{
|
||||
appId: Scalars['ID'];
|
||||
job: AndroidManagedJobInput;
|
||||
job: IosJobInput;
|
||||
metadata?: Maybe<BuildMetadataInput>;
|
||||
}>;
|
||||
|
||||
|
||||
export type CreateAndroidManagedBuildMutation = (
|
||||
export type CreateIosBuildMutation = (
|
||||
{ __typename?: 'RootMutation' }
|
||||
& { build?: Maybe<(
|
||||
{ __typename?: 'BuildMutation' }
|
||||
& { createAndroidManagedBuild: (
|
||||
{ __typename?: 'CreateBuildResult' }
|
||||
& { build: (
|
||||
{ __typename?: 'Build' }
|
||||
& Pick<Build, 'id'>
|
||||
), deprecationInfo?: Maybe<(
|
||||
{ __typename?: 'EASBuildDeprecationInfo' }
|
||||
& Pick<EasBuildDeprecationInfo, 'type' | 'message'>
|
||||
)> }
|
||||
) }
|
||||
)> }
|
||||
);
|
||||
|
||||
export type CreateIosGenericBuildMutationVariables = Exact<{
|
||||
appId: Scalars['ID'];
|
||||
job: IosGenericJobInput;
|
||||
metadata?: Maybe<BuildMetadataInput>;
|
||||
}>;
|
||||
|
||||
|
||||
export type CreateIosGenericBuildMutation = (
|
||||
{ __typename?: 'RootMutation' }
|
||||
& { build?: Maybe<(
|
||||
{ __typename?: 'BuildMutation' }
|
||||
& { createIosGenericBuild: (
|
||||
{ __typename?: 'CreateBuildResult' }
|
||||
& { build: (
|
||||
{ __typename?: 'Build' }
|
||||
& Pick<Build, 'id'>
|
||||
), deprecationInfo?: Maybe<(
|
||||
{ __typename?: 'EASBuildDeprecationInfo' }
|
||||
& Pick<EasBuildDeprecationInfo, 'type' | 'message'>
|
||||
)> }
|
||||
) }
|
||||
)> }
|
||||
);
|
||||
|
||||
export type CreateIosManagedBuildMutationVariables = Exact<{
|
||||
appId: Scalars['ID'];
|
||||
job: IosManagedJobInput;
|
||||
metadata?: Maybe<BuildMetadataInput>;
|
||||
}>;
|
||||
|
||||
|
||||
export type CreateIosManagedBuildMutation = (
|
||||
{ __typename?: 'RootMutation' }
|
||||
& { build?: Maybe<(
|
||||
{ __typename?: 'BuildMutation' }
|
||||
& { createIosManagedBuild: (
|
||||
& { createIosBuild: (
|
||||
{ __typename?: 'CreateBuildResult' }
|
||||
& { build: (
|
||||
{ __typename?: 'Build' }
|
||||
@@ -4993,7 +4982,7 @@ export type AppFragment = (
|
||||
|
||||
export type BuildFragment = (
|
||||
{ __typename?: 'Build' }
|
||||
& Pick<Build, 'id' | 'status' | 'platform' | 'releaseChannel' | 'distribution' | 'createdAt' | 'updatedAt'>
|
||||
& Pick<Build, 'id' | 'status' | 'platform' | 'channel' | 'releaseChannel' | 'distribution' | 'buildProfile' | 'sdkVersion' | 'appVersion' | 'appBuildVersion' | 'runtimeVersion' | 'gitCommitHash' | 'createdAt' | 'updatedAt'>
|
||||
& { error?: Maybe<(
|
||||
{ __typename?: 'BuildError' }
|
||||
& Pick<BuildError, 'errorCode' | 'message' | 'docsUrl'>
|
||||
@@ -5088,6 +5077,11 @@ export type AppleAppIdentifierFragment = (
|
||||
& Pick<AppleAppIdentifier, 'id' | 'bundleIdentifier'>
|
||||
);
|
||||
|
||||
export type AppleAppSpecificPasswordFragment = (
|
||||
{ __typename?: 'AppleAppSpecificPassword' }
|
||||
& Pick<AppleAppSpecificPassword, 'id' | 'appleIdUsername' | 'passwordLabel' | 'updatedAt'>
|
||||
);
|
||||
|
||||
export type AppleDeviceFragment = (
|
||||
{ __typename?: 'AppleDevice' }
|
||||
& Pick<AppleDevice, 'id' | 'identifier' | 'name' | 'model' | 'deviceClass'>
|
||||
@@ -5154,6 +5148,18 @@ export type ApplePushKeyFragment = (
|
||||
{ __typename?: 'AppleTeam' }
|
||||
& Pick<AppleTeam, 'id'>
|
||||
& AppleTeamFragment
|
||||
)>, iosAppCredentialsList: Array<(
|
||||
{ __typename?: 'IosAppCredentials' }
|
||||
& Pick<IosAppCredentials, 'id'>
|
||||
& { app: (
|
||||
{ __typename?: 'App' }
|
||||
& Pick<App, 'id'>
|
||||
& AppFragment
|
||||
), appleAppIdentifier: (
|
||||
{ __typename?: 'AppleAppIdentifier' }
|
||||
& Pick<AppleAppIdentifier, 'id'>
|
||||
& AppleAppIdentifierFragment
|
||||
) }
|
||||
)> }
|
||||
);
|
||||
|
||||
@@ -5195,6 +5201,10 @@ export type CommonIosAppCredentialsWithoutBuildCredentialsFragment = (
|
||||
{ __typename?: 'ApplePushKey' }
|
||||
& Pick<ApplePushKey, 'id'>
|
||||
& ApplePushKeyFragment
|
||||
)>, appSpecificPassword?: Maybe<(
|
||||
{ __typename?: 'AppleAppSpecificPassword' }
|
||||
& Pick<AppleAppSpecificPassword, 'id'>
|
||||
& AppleAppSpecificPasswordFragment
|
||||
)> }
|
||||
);
|
||||
|
||||
|
||||
@@ -3,20 +3,14 @@ import nullthrows from 'nullthrows';
|
||||
|
||||
import { graphqlClient, withErrorHandlingAsync } from '../client';
|
||||
import {
|
||||
AndroidGenericJobInput,
|
||||
AndroidManagedJobInput,
|
||||
AndroidJobInput,
|
||||
BuildMetadataInput,
|
||||
CreateAndroidGenericBuildMutation,
|
||||
CreateAndroidGenericBuildMutationVariables,
|
||||
CreateAndroidManagedBuildMutation,
|
||||
CreateAndroidManagedBuildMutationVariables,
|
||||
CreateIosGenericBuildMutation,
|
||||
CreateIosGenericBuildMutationVariables,
|
||||
CreateIosManagedBuildMutation,
|
||||
CreateIosManagedBuildMutationVariables,
|
||||
CreateAndroidBuildMutation,
|
||||
CreateAndroidBuildMutationVariables,
|
||||
CreateIosBuildMutation,
|
||||
CreateIosBuildMutationVariables,
|
||||
EasBuildDeprecationInfo,
|
||||
IosGenericJobInput,
|
||||
IosManagedJobInput,
|
||||
IosJobInput,
|
||||
} from '../generated';
|
||||
|
||||
export interface BuildResult {
|
||||
@@ -25,22 +19,22 @@ export interface BuildResult {
|
||||
}
|
||||
|
||||
const BuildMutation = {
|
||||
async createAndroidGenericBuildAsync(input: {
|
||||
async createAndroidBuildAsync(input: {
|
||||
appId: string;
|
||||
job: AndroidGenericJobInput;
|
||||
job: AndroidJobInput;
|
||||
metadata: BuildMetadataInput;
|
||||
}): Promise<BuildResult> {
|
||||
const data = await withErrorHandlingAsync(
|
||||
graphqlClient
|
||||
.mutation<CreateAndroidGenericBuildMutation, CreateAndroidGenericBuildMutationVariables>(
|
||||
.mutation<CreateAndroidBuildMutation, CreateAndroidBuildMutationVariables>(
|
||||
gql`
|
||||
mutation CreateAndroidGenericBuildMutation(
|
||||
mutation CreateAndroidBuildMutation(
|
||||
$appId: ID!
|
||||
$job: AndroidGenericJobInput!
|
||||
$job: AndroidJobInput!
|
||||
$metadata: BuildMetadataInput
|
||||
) {
|
||||
build {
|
||||
createAndroidGenericBuild(appId: $appId, job: $job, metadata: $metadata) {
|
||||
createAndroidBuild(appId: $appId, job: $job, metadata: $metadata) {
|
||||
build {
|
||||
id
|
||||
}
|
||||
@@ -56,24 +50,24 @@ const BuildMutation = {
|
||||
)
|
||||
.toPromise()
|
||||
);
|
||||
return nullthrows(data.build?.createAndroidGenericBuild);
|
||||
return nullthrows(data.build?.createAndroidBuild);
|
||||
},
|
||||
async createAndroidManagedBuildAsync(input: {
|
||||
async createIosBuildAsync(input: {
|
||||
appId: string;
|
||||
job: AndroidManagedJobInput;
|
||||
job: IosJobInput;
|
||||
metadata: BuildMetadataInput;
|
||||
}): Promise<BuildResult> {
|
||||
const data = await withErrorHandlingAsync(
|
||||
graphqlClient
|
||||
.mutation<CreateAndroidManagedBuildMutation, CreateAndroidManagedBuildMutationVariables>(
|
||||
.mutation<CreateIosBuildMutation, CreateIosBuildMutationVariables>(
|
||||
gql`
|
||||
mutation CreateAndroidManagedBuildMutation(
|
||||
mutation CreateIosBuildMutation(
|
||||
$appId: ID!
|
||||
$job: AndroidManagedJobInput!
|
||||
$job: IosJobInput!
|
||||
$metadata: BuildMetadataInput
|
||||
) {
|
||||
build {
|
||||
createAndroidManagedBuild(appId: $appId, job: $job, metadata: $metadata) {
|
||||
createIosBuild(appId: $appId, job: $job, metadata: $metadata) {
|
||||
build {
|
||||
id
|
||||
}
|
||||
@@ -89,73 +83,7 @@ const BuildMutation = {
|
||||
)
|
||||
.toPromise()
|
||||
);
|
||||
return nullthrows(data.build?.createAndroidManagedBuild);
|
||||
},
|
||||
async createIosGenericBuildAsync(input: {
|
||||
appId: string;
|
||||
job: IosGenericJobInput;
|
||||
metadata: BuildMetadataInput;
|
||||
}): Promise<BuildResult> {
|
||||
const data = await withErrorHandlingAsync(
|
||||
graphqlClient
|
||||
.mutation<CreateIosGenericBuildMutation, CreateIosGenericBuildMutationVariables>(
|
||||
gql`
|
||||
mutation CreateIosGenericBuildMutation(
|
||||
$appId: ID!
|
||||
$job: IosGenericJobInput!
|
||||
$metadata: BuildMetadataInput
|
||||
) {
|
||||
build {
|
||||
createIosGenericBuild(appId: $appId, job: $job, metadata: $metadata) {
|
||||
build {
|
||||
id
|
||||
}
|
||||
deprecationInfo {
|
||||
type
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
input
|
||||
)
|
||||
.toPromise()
|
||||
);
|
||||
return nullthrows(data.build?.createIosGenericBuild);
|
||||
},
|
||||
async createIosManagedBuildAsync(input: {
|
||||
appId: string;
|
||||
job: IosManagedJobInput;
|
||||
metadata: BuildMetadataInput;
|
||||
}): Promise<BuildResult> {
|
||||
const data = await withErrorHandlingAsync(
|
||||
graphqlClient
|
||||
.mutation<CreateIosManagedBuildMutation, CreateIosManagedBuildMutationVariables>(
|
||||
gql`
|
||||
mutation CreateIosManagedBuildMutation(
|
||||
$appId: ID!
|
||||
$job: IosManagedJobInput!
|
||||
$metadata: BuildMetadataInput
|
||||
) {
|
||||
build {
|
||||
createIosManagedBuild(appId: $appId, job: $job, metadata: $metadata) {
|
||||
build {
|
||||
id
|
||||
}
|
||||
deprecationInfo {
|
||||
type
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
input
|
||||
)
|
||||
.toPromise()
|
||||
);
|
||||
return nullthrows(data.build?.createIosManagedBuild);
|
||||
return nullthrows(data.build?.createIosBuild);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import gql from 'graphql-tag';
|
||||
import { graphqlClient, withErrorHandlingAsync } from '../client';
|
||||
import {
|
||||
AppPlatform,
|
||||
Build,
|
||||
BuildFragment,
|
||||
BuildStatus,
|
||||
BuildsByIdQuery,
|
||||
@@ -21,8 +20,6 @@ type Filters = {
|
||||
limit?: number;
|
||||
};
|
||||
|
||||
type PendingBuildQueryResult = Pick<Build, 'id' | 'platform'>;
|
||||
|
||||
export const BuildQuery = {
|
||||
async byIdAsync(
|
||||
buildId: string,
|
||||
|
||||
@@ -34,8 +34,15 @@ export const BuildFragmentNode = gql`
|
||||
}
|
||||
}
|
||||
}
|
||||
channel
|
||||
releaseChannel
|
||||
distribution
|
||||
buildProfile
|
||||
sdkVersion
|
||||
appVersion
|
||||
appBuildVersion
|
||||
runtimeVersion
|
||||
gitCommitHash
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const AppleAppSpecificPasswordFragmentNode = gql`
|
||||
fragment AppleAppSpecificPasswordFragment on AppleAppSpecificPassword {
|
||||
id
|
||||
appleIdUsername
|
||||
passwordLabel
|
||||
updatedAt
|
||||
}
|
||||
`;
|
||||
@@ -1,6 +1,8 @@
|
||||
import { print } from 'graphql';
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
import { AppFragmentNode } from '../App';
|
||||
import { AppleAppIdentifierFragmentNode } from './AppleAppIdentifier';
|
||||
import { AppleTeamFragmentNode } from './AppleTeam';
|
||||
|
||||
export const ApplePushKeyFragmentNode = gql`
|
||||
@@ -12,6 +14,19 @@ export const ApplePushKeyFragmentNode = gql`
|
||||
id
|
||||
...AppleTeamFragment
|
||||
}
|
||||
iosAppCredentialsList {
|
||||
id
|
||||
app {
|
||||
id
|
||||
...AppFragment
|
||||
}
|
||||
appleAppIdentifier {
|
||||
id
|
||||
...AppleAppIdentifierFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
${print(AppleTeamFragmentNode)}
|
||||
${print(AppFragmentNode)}
|
||||
${print(AppleAppIdentifierFragmentNode)}
|
||||
`;
|
||||
@@ -2,6 +2,7 @@ import gql from 'graphql-tag';
|
||||
|
||||
import { AppFragmentNode } from '../App';
|
||||
import { AppleAppIdentifierFragmentNode } from './AppleAppIdentifier';
|
||||
import { AppleAppSpecificPasswordFragmentNode } from './AppleAppSpecificPassword';
|
||||
import { ApplePushKeyFragmentNode } from './ApplePushKey';
|
||||
import { AppleTeamFragmentNode } from './AppleTeam';
|
||||
import { IosAppBuildCredentialsFragmentNode } from './IosAppBuildCredentials';
|
||||
@@ -25,11 +26,16 @@ export const CommonIosAppCredentialsWithoutBuildCredentialsFragmentNode = gql`
|
||||
id
|
||||
...ApplePushKeyFragment
|
||||
}
|
||||
appSpecificPassword {
|
||||
id
|
||||
...AppleAppSpecificPasswordFragment
|
||||
}
|
||||
}
|
||||
${AppFragmentNode}
|
||||
${AppleTeamFragmentNode}
|
||||
${AppleAppIdentifierFragmentNode}
|
||||
${ApplePushKeyFragmentNode}
|
||||
${AppleAppSpecificPasswordFragmentNode}
|
||||
`;
|
||||
|
||||
export const CommonIosAppCredentialsFragmentNode = gql`
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-console */
|
||||
import chalk from 'chalk';
|
||||
import figures from 'figures';
|
||||
import { boolish } from 'getenv';
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
import { vol } from 'memfs';
|
||||
|
||||
import { asMock } from '../../__tests__/utils';
|
||||
import { confirmAsync } from '../../prompts';
|
||||
import { Actor, getUserAsync } from '../../user/User';
|
||||
import {
|
||||
ensureProjectExistsAsync,
|
||||
findProjectIdByAccountNameAndSlugNullableAsync,
|
||||
} from '../ensureProjectExists';
|
||||
import {
|
||||
findProjectRootAsync,
|
||||
getProjectAccountName,
|
||||
getProjectAccountNameAsync,
|
||||
promptToCreateProjectIfNotExistsAsync,
|
||||
} from '../projectUtils';
|
||||
|
||||
jest.mock('@expo/config');
|
||||
jest.mock('fs');
|
||||
|
||||
jest.mock('../../user/User');
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
const originalConsoleWarn = console.warn;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
console.warn = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
console.warn = originalConsoleWarn;
|
||||
});
|
||||
jest.mock('../ensureProjectExists');
|
||||
|
||||
describe(findProjectRootAsync, () => {
|
||||
beforeEach(() => {
|
||||
@@ -168,3 +164,62 @@ describe(getProjectAccountNameAsync, () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe(promptToCreateProjectIfNotExistsAsync, () => {
|
||||
beforeEach(() => {
|
||||
asMock(getUserAsync).mockReset();
|
||||
asMock(findProjectIdByAccountNameAndSlugNullableAsync).mockReset();
|
||||
});
|
||||
|
||||
it('returns the existing project', async () => {
|
||||
asMock(getUserAsync).mockImplementation((): Actor | undefined => ({
|
||||
__typename: 'User',
|
||||
id: 'user_id',
|
||||
username: 'quin',
|
||||
accounts: [{ id: 'account_id_1', name: 'quin' }],
|
||||
isExpoAdmin: false,
|
||||
}));
|
||||
asMock(findProjectIdByAccountNameAndSlugNullableAsync).mockImplementation(
|
||||
() => 'already-existing-project-id'
|
||||
);
|
||||
const exp: any = {};
|
||||
const projectId = await promptToCreateProjectIfNotExistsAsync(exp);
|
||||
expect(projectId).toBe('already-existing-project-id');
|
||||
});
|
||||
it('makes a new project if none exists', async () => {
|
||||
jest.mock('../../prompts');
|
||||
asMock(getUserAsync).mockImplementation((): Actor | undefined => ({
|
||||
__typename: 'User',
|
||||
id: 'user_id',
|
||||
username: 'quin',
|
||||
accounts: [{ id: 'account_id_1', name: 'quin' }],
|
||||
isExpoAdmin: false,
|
||||
}));
|
||||
asMock(findProjectIdByAccountNameAndSlugNullableAsync).mockImplementation(() => null);
|
||||
asMock(ensureProjectExistsAsync).mockImplementation(() => 'new-project-id');
|
||||
|
||||
// user agrees to make new project
|
||||
(confirmAsync as jest.Mock).mockImplementation(() => true);
|
||||
const exp: any = {};
|
||||
const projectId = await promptToCreateProjectIfNotExistsAsync(exp);
|
||||
expect(projectId).toBe('new-project-id');
|
||||
});
|
||||
it('aborts making a new project if the user declines', async () => {
|
||||
jest.mock('../../prompts');
|
||||
asMock(getUserAsync).mockImplementation((): Actor | undefined => ({
|
||||
__typename: 'User',
|
||||
id: 'user_id',
|
||||
username: 'quin',
|
||||
accounts: [{ id: 'account_id_1', name: 'quin' }],
|
||||
isExpoAdmin: false,
|
||||
}));
|
||||
asMock(findProjectIdByAccountNameAndSlugNullableAsync).mockImplementation(() => null);
|
||||
asMock(ensureProjectExistsAsync).mockImplementation(() => 'new-project-id');
|
||||
|
||||
// user doesnt agree to make new project
|
||||
(confirmAsync as jest.Mock).mockImplementation(() => false);
|
||||
const exp: any = {};
|
||||
const projectId = await promptToCreateProjectIfNotExistsAsync(exp);
|
||||
expect(projectId).toBe(null);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
import { Platform, Workflow } from '@expo/eas-build-job';
|
||||
import { vol } from 'memfs';
|
||||
|
||||
import { resolveWorkflowAsync } from '../workflow';
|
||||
|
||||
jest.mock('fs');
|
||||
|
||||
describe(resolveWorkflowAsync, () => {
|
||||
beforeEach(() => {
|
||||
vol.reset();
|
||||
});
|
||||
|
||||
const projectDir = '/app';
|
||||
|
||||
test('generic workflow for both platforms', async () => {
|
||||
vol.fromJSON(
|
||||
{
|
||||
'./ios/helloworld.xcodeproj/project.pbxproj': 'fake',
|
||||
'./android/app/src/main/AndroidManifest.xml': 'fake',
|
||||
},
|
||||
projectDir
|
||||
);
|
||||
|
||||
await expect(resolveWorkflowAsync(projectDir, Platform.ANDROID)).resolves.toBe(
|
||||
Workflow.GENERIC
|
||||
);
|
||||
await expect(resolveWorkflowAsync(projectDir, Platform.IOS)).resolves.toBe(Workflow.GENERIC);
|
||||
});
|
||||
|
||||
test('generic workflow for single platform', async () => {
|
||||
vol.fromJSON(
|
||||
{
|
||||
'./ios/helloworld.xcodeproj/project.pbxproj': 'fake',
|
||||
},
|
||||
projectDir
|
||||
);
|
||||
|
||||
await expect(resolveWorkflowAsync(projectDir, Platform.ANDROID)).resolves.toBe(
|
||||
Workflow.MANAGED
|
||||
);
|
||||
await expect(resolveWorkflowAsync(projectDir, Platform.IOS)).resolves.toBe(Workflow.GENERIC);
|
||||
});
|
||||
|
||||
test('android/ios directories are ignored', async () => {
|
||||
vol.fromJSON(
|
||||
{
|
||||
'./ios/helloworld.xcodeproj/project.pbxproj': 'fake',
|
||||
'./android/app/src/main/AndroidManifest.xml': 'fake',
|
||||
'./.easignore': 'android/\nios/',
|
||||
},
|
||||
projectDir
|
||||
);
|
||||
|
||||
await expect(resolveWorkflowAsync(projectDir, Platform.ANDROID)).resolves.toBe(
|
||||
Workflow.MANAGED
|
||||
);
|
||||
await expect(resolveWorkflowAsync(projectDir, Platform.IOS)).resolves.toBe(Workflow.MANAGED);
|
||||
});
|
||||
});
|
||||
@@ -3,19 +3,16 @@ import { vol } from 'memfs';
|
||||
import os from 'os';
|
||||
|
||||
import { asMock } from '../../../__tests__/utils';
|
||||
import { jester as mockJester } from '../../../credentials/__tests__/fixtures-constants';
|
||||
import { promptAsync } from '../../../prompts';
|
||||
import {
|
||||
ensureApplicationIdIsDefinedForManagedProjectAsync,
|
||||
getApplicationId,
|
||||
getApplicationIdAsync,
|
||||
} from '../applicationId';
|
||||
|
||||
jest.mock('fs');
|
||||
jest.mock('../../../prompts');
|
||||
|
||||
const originalConsoleWarn = console.warn;
|
||||
beforeAll(() => {
|
||||
console.warn = jest.fn();
|
||||
});
|
||||
jest.mock('../../../user/actions', () => ({ ensureLoggedInAsync: jest.fn(() => mockJester) }));
|
||||
|
||||
beforeEach(() => {
|
||||
vol.reset();
|
||||
@@ -26,71 +23,69 @@ beforeEach(() => {
|
||||
asMock(promptAsync).mockReset();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
fs.removeSync(os.tmpdir());
|
||||
console.warn = originalConsoleWarn;
|
||||
});
|
||||
|
||||
describe(getApplicationId, () => {
|
||||
describe(getApplicationIdAsync, () => {
|
||||
describe('generic projects', () => {
|
||||
it('reads applicationId from build.gradle', () => {
|
||||
it('reads applicationId from build.gradle', async () => {
|
||||
vol.fromJSON(
|
||||
{
|
||||
'android/app/build.gradle': `
|
||||
applicationId "com.expo.notdominik"
|
||||
`,
|
||||
'android/app/src/main/AndroidManifest.xml': 'fake',
|
||||
},
|
||||
'/app'
|
||||
);
|
||||
|
||||
const applicationId = getApplicationId('/app', {} as any);
|
||||
const applicationId = await getApplicationIdAsync('/app', {} as any);
|
||||
expect(applicationId).toBe('com.expo.notdominik');
|
||||
});
|
||||
|
||||
it('throws an error if build.gradle does not exist', () => {
|
||||
it('throws an error if build.gradle does not exist', async () => {
|
||||
vol.fromJSON(
|
||||
{
|
||||
'android/gradle.properties': 'fake file',
|
||||
'android/app/src/main/AndroidManifest.xml': 'fake',
|
||||
},
|
||||
'/app'
|
||||
);
|
||||
expect(() => {
|
||||
getApplicationId('/app', {} as any);
|
||||
}).toThrowError(/Could not read application id/);
|
||||
await expect(getApplicationIdAsync('/app', {} as any)).rejects.toThrowError(
|
||||
/Could not read application id/
|
||||
);
|
||||
});
|
||||
|
||||
it('throws an error if the project does not have applicationId defined in build.gradle', () => {
|
||||
it('throws an error if the project does not have applicationId defined in build.gradle', async () => {
|
||||
vol.fromJSON(
|
||||
{
|
||||
'android/app/build.gradle': `fake build.gradle`,
|
||||
'android/app/src/main/AndroidManifest.xml': 'fake',
|
||||
},
|
||||
'/app'
|
||||
);
|
||||
|
||||
expect(() => {
|
||||
getApplicationId('/app', {} as any);
|
||||
}).toThrowError(/Could not read application id/);
|
||||
await expect(getApplicationIdAsync('/app', {} as any)).rejects.toThrowError(
|
||||
/Could not read application id/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('managed projects', () => {
|
||||
it('reads applicationId (Android package) from app config', () => {
|
||||
const applicationId = getApplicationId('/app', {
|
||||
it('reads applicationId (Android package) from app config', async () => {
|
||||
const applicationId = await getApplicationIdAsync('/app', {
|
||||
android: { package: 'com.expo.notdominik' },
|
||||
} as any);
|
||||
expect(applicationId).toBe('com.expo.notdominik');
|
||||
});
|
||||
|
||||
it('throws an error if Android package is not defined in app config', () => {
|
||||
expect(() => {
|
||||
getApplicationId('/app', {} as any);
|
||||
}).toThrowError(/Specify "android.package"/);
|
||||
it('throws an error if Android package is not defined in app config', async () => {
|
||||
await expect(getApplicationIdAsync('/app', {} as any)).rejects.toThrowError(
|
||||
/Specify "android.package"/
|
||||
);
|
||||
});
|
||||
|
||||
it('throws an error if Android package in app config is invalid', () => {
|
||||
expect(() => {
|
||||
getApplicationId('/app', { android: { package: '1com.expo.notdominik' } } as any);
|
||||
}).toThrowError(/Specify "android.package"/);
|
||||
it('throws an error if Android package in app config is invalid', async () => {
|
||||
await expect(
|
||||
getApplicationIdAsync('/app', { android: { package: '1com.expo.notdominik' } } as any)
|
||||
).rejects.toThrowError(/Specify "android.package"/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import { ExpoConfig, getConfigFilePaths } from '@expo/config';
|
||||
import { AndroidConfig } from '@expo/config-plugins';
|
||||
import { AndroidConfig, IOSConfig } from '@expo/config-plugins';
|
||||
import { Platform, Workflow } from '@expo/eas-build-job';
|
||||
import assert from 'assert';
|
||||
import chalk from 'chalk';
|
||||
import fs from 'fs-extra';
|
||||
import once from 'lodash/once';
|
||||
import nullthrows from 'nullthrows';
|
||||
|
||||
import Log from '../../log';
|
||||
import { getProjectConfigDescription } from '../../project/projectUtils';
|
||||
import Log, { learnMore } from '../../log';
|
||||
import { getProjectConfigDescription, getUsername } from '../../project/projectUtils';
|
||||
import { promptAsync } from '../../prompts';
|
||||
import { resolveWorkflow } from '../workflow';
|
||||
import { ensureLoggedInAsync } from '../../user/actions';
|
||||
import { resolveWorkflowAsync } 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.`;
|
||||
|
||||
@@ -17,18 +19,18 @@ export async function ensureApplicationIdIsDefinedForManagedProjectAsync(
|
||||
projectDir: string,
|
||||
exp: ExpoConfig
|
||||
): Promise<string> {
|
||||
const workflow = resolveWorkflow(projectDir, Platform.ANDROID);
|
||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.ANDROID);
|
||||
assert(workflow === Workflow.MANAGED, 'This function should be called only for managed projects');
|
||||
|
||||
try {
|
||||
return getApplicationId(projectDir, exp);
|
||||
return await getApplicationIdAsync(projectDir, exp);
|
||||
} catch (err) {
|
||||
return await configureApplicationIdAsync(projectDir, exp);
|
||||
}
|
||||
}
|
||||
|
||||
export function getApplicationId(projectDir: string, exp: ExpoConfig): string {
|
||||
const workflow = resolveWorkflow(projectDir, Platform.ANDROID);
|
||||
export async function getApplicationIdAsync(projectDir: string, exp: ExpoConfig): Promise<string> {
|
||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.ANDROID);
|
||||
if (workflow === Workflow.GENERIC) {
|
||||
warnIfAndroidPackageDefinedInAppConfigForGenericProject(projectDir, exp);
|
||||
|
||||
@@ -71,10 +73,19 @@ async function configureApplicationIdAsync(projectDir: string, exp: ExpoConfig):
|
||||
|
||||
assert(paths.staticConfigPath, 'app.json must exist');
|
||||
|
||||
Log.addNewLineIfNone();
|
||||
Log.log(
|
||||
`${chalk.bold(`📝 Android application id`)} ${chalk.dim(
|
||||
learnMore('https://expo.fyi/android-package')
|
||||
)}`
|
||||
);
|
||||
|
||||
const suggestedAndroidApplicationId = await getSuggestedApplicationIdAsync(exp);
|
||||
const { packageName } = await promptAsync({
|
||||
name: 'packageName',
|
||||
type: 'text',
|
||||
message: `What would you like your Android application id to be?`,
|
||||
initial: suggestedAndroidApplicationId,
|
||||
validate: value => (isApplicationIdValid(value) ? true : INVALID_APPLICATION_ID_MESSAGE),
|
||||
});
|
||||
|
||||
@@ -111,3 +122,19 @@ function _warnIfAndroidPackageDefinedInAppConfigForGenericProject(
|
||||
export const warnIfAndroidPackageDefinedInAppConfigForGenericProject = once(
|
||||
_warnIfAndroidPackageDefinedInAppConfigForGenericProject
|
||||
);
|
||||
|
||||
async function getSuggestedApplicationIdAsync(exp: ExpoConfig): Promise<string | undefined> {
|
||||
// Attempt to use the ios bundle id first since it's convenient to have them aligned.
|
||||
const maybeBundleId = IOSConfig.BundleIdentifier.getBundleIdentifier(exp);
|
||||
if (maybeBundleId && isApplicationIdValid(maybeBundleId)) {
|
||||
return maybeBundleId;
|
||||
} else {
|
||||
const username = getUsername(exp, await ensureLoggedInAsync());
|
||||
// It's common to use dashes in your node project name, strip them from the suggested package name.
|
||||
const possibleId = `com.${username}.${exp.slug}`.split('-').join('');
|
||||
if (isApplicationIdValid(possibleId)) {
|
||||
return possibleId;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -29,15 +29,10 @@ export async function ensureProjectExistsAsync(projectInfo: ProjectInfo): Promis
|
||||
|
||||
const spinner = ora(`Linking to project ${chalk.bold(projectFullName)}`).start();
|
||||
|
||||
try {
|
||||
const id = await findProjectIdByAccountNameAndSlugAsync(accountName, projectName);
|
||||
const maybeId = await findProjectIdByAccountNameAndSlugNullableAsync(accountName, projectName);
|
||||
if (maybeId) {
|
||||
spinner.succeed(`Linked to project ${chalk.bold(projectFullName)}`);
|
||||
return id;
|
||||
} catch (err) {
|
||||
if (err.graphQLErrors?.some((it: any) => it.extensions?.errorCode !== 'EXPERIENCE_NOT_FOUND')) {
|
||||
spinner.fail(`Something went wrong while looking for ${chalk.bold(projectFullName)} on Expo`);
|
||||
throw err;
|
||||
}
|
||||
return maybeId;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -55,6 +50,26 @@ export async function ensureProjectExistsAsync(projectInfo: ProjectInfo): Promis
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds project by `@accountName/slug` and returns its ID, return null if the project does not exist
|
||||
* @param accountName account name
|
||||
* @param slug project slug
|
||||
* @returns A promise resolving to Project ID, null if it doesn't exist
|
||||
*/
|
||||
export async function findProjectIdByAccountNameAndSlugNullableAsync(
|
||||
accountName: string,
|
||||
slug: string
|
||||
): Promise<string | null> {
|
||||
try {
|
||||
return await findProjectIdByAccountNameAndSlugAsync(accountName, slug);
|
||||
} catch (err) {
|
||||
if (err.graphQLErrors?.some((it: any) => it.extensions?.errorCode !== 'EXPERIENCE_NOT_FOUND')) {
|
||||
throw err;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds project by `@accountName/slug` and returns its ID
|
||||
* @param accountName account name
|
||||
@@ -73,7 +88,7 @@ async function findProjectIdByAccountNameAndSlugAsync(
|
||||
* Registers new project on EAS servers
|
||||
* @returns Created project's ID
|
||||
*/
|
||||
async function registerNewProjectAsync({
|
||||
export async function registerNewProjectAsync({
|
||||
accountId,
|
||||
projectName,
|
||||
privacy,
|
||||
|
||||
@@ -4,19 +4,17 @@ import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
import { asMock } from '../../../__tests__/utils';
|
||||
import { jester as mockJester } from '../../../credentials/__tests__/fixtures-constants';
|
||||
import { promptAsync } from '../../../prompts';
|
||||
import {
|
||||
ensureBundleIdentifierIsDefinedForManagedProjectAsync,
|
||||
getBundleIdentifier,
|
||||
getBundleIdentifierAsync,
|
||||
isWildcardBundleIdentifier,
|
||||
} from '../bundleIdentifier';
|
||||
|
||||
jest.mock('fs');
|
||||
jest.mock('../../../prompts');
|
||||
|
||||
const originalConsoleWarn = console.warn;
|
||||
beforeAll(() => {
|
||||
console.warn = jest.fn();
|
||||
});
|
||||
jest.mock('../../../user/actions', () => ({ ensureLoggedInAsync: jest.fn(() => mockJester) }));
|
||||
|
||||
beforeEach(() => {
|
||||
vol.reset();
|
||||
@@ -27,16 +25,11 @@ beforeEach(() => {
|
||||
asMock(promptAsync).mockReset();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
fs.removeSync(os.tmpdir());
|
||||
console.warn = originalConsoleWarn;
|
||||
});
|
||||
|
||||
const originalFs = jest.requireActual('fs');
|
||||
|
||||
describe(getBundleIdentifier, () => {
|
||||
describe(getBundleIdentifierAsync, () => {
|
||||
describe('generic projects', () => {
|
||||
it('reads bundle identifier from project.', () => {
|
||||
it('reads bundle identifier from project.', async () => {
|
||||
vol.fromJSON(
|
||||
{
|
||||
'ios/myproject.xcodeproj/project.pbxproj': originalFs.readFileSync(
|
||||
@@ -47,11 +40,11 @@ describe(getBundleIdentifier, () => {
|
||||
'/app'
|
||||
);
|
||||
|
||||
const bundleIdentifier = getBundleIdentifier('/app', {} as any);
|
||||
const bundleIdentifier = await getBundleIdentifierAsync('/app', {} as any);
|
||||
expect(bundleIdentifier).toBe('org.name.testproject');
|
||||
});
|
||||
|
||||
it('throws an error if the pbxproj is not configured with bundle id', () => {
|
||||
it('throws an error if the pbxproj is not configured with bundle id', async () => {
|
||||
vol.fromJSON(
|
||||
{
|
||||
'ios/myproject.xcodeproj/project.pbxproj': originalFs.readFileSync(
|
||||
@@ -62,30 +55,30 @@ describe(getBundleIdentifier, () => {
|
||||
'/app'
|
||||
);
|
||||
|
||||
expect(() => {
|
||||
getBundleIdentifier('/app', {} as any);
|
||||
}).toThrowError(/Could not read bundle identifier/);
|
||||
await expect(getBundleIdentifierAsync('/app', {} as any)).rejects.toThrowError(
|
||||
/Could not read bundle identifier/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('managed projects', () => {
|
||||
it('reads bundleIdentifier from app config', () => {
|
||||
const applicationId = getBundleIdentifier('/app', {
|
||||
it('reads bundleIdentifier from app config', async () => {
|
||||
const applicationId = await getBundleIdentifierAsync('/app', {
|
||||
ios: { bundleIdentifier: 'com.expo.notdominik' },
|
||||
} as any);
|
||||
expect(applicationId).toBe('com.expo.notdominik');
|
||||
});
|
||||
|
||||
it('throws an error if bundleIdentifier is not defined in app config', () => {
|
||||
expect(() => {
|
||||
getBundleIdentifier('/app', {} as any);
|
||||
}).toThrowError(/Specify "ios.bundleIdentifier"/);
|
||||
it('throws an error if bundleIdentifier is not defined in app config', async () => {
|
||||
await expect(getBundleIdentifierAsync('/app', {} as any)).rejects.toThrowError(
|
||||
/Specify "ios.bundleIdentifier"/
|
||||
);
|
||||
});
|
||||
|
||||
it('throws an error if bundleIdentifier in app config is invalid', () => {
|
||||
expect(() => {
|
||||
getBundleIdentifier('/app', { ios: { bundleIdentifier: '' } } as any);
|
||||
}).toThrowError(/Specify "ios.bundleIdentifier"/);
|
||||
it('throws an error if bundleIdentifier in app config is invalid', async () => {
|
||||
await expect(
|
||||
getBundleIdentifierAsync('/app', { ios: { bundleIdentifier: '' } } as any)
|
||||
).rejects.toThrowError(/Specify "ios.bundleIdentifier"/);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -141,3 +134,15 @@ describe(ensureBundleIdentifierIsDefinedForManagedProjectAsync, () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe(isWildcardBundleIdentifier, () => {
|
||||
it('classifies wildcard bundle identifiers correctly', async () => {
|
||||
expect(isWildcardBundleIdentifier('doge.doge.*')).toBe(true);
|
||||
expect(isWildcardBundleIdentifier('doge*')).toBe(true);
|
||||
|
||||
expect(isWildcardBundleIdentifier('*')).toBe(false);
|
||||
expect(isWildcardBundleIdentifier('*.doge')).toBe(false);
|
||||
expect(isWildcardBundleIdentifier('doge')).toBe(false);
|
||||
expect(isWildcardBundleIdentifier('doge.doge.doge')).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -9,11 +9,6 @@ import { selectSchemeAsync } from '../scheme';
|
||||
jest.mock('fs');
|
||||
jest.mock('../../../prompts');
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vol.reset();
|
||||
// do not remove the following line
|
||||
@@ -23,11 +18,6 @@ beforeEach(() => {
|
||||
asMock(promptAsync).mockReset();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
fs.removeSync(os.tmpdir());
|
||||
console.log = originalConsoleLog;
|
||||
});
|
||||
|
||||
describe(selectSchemeAsync, () => {
|
||||
const projectDir = '/app';
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { ExpoConfig, getConfigFilePaths } from '@expo/config';
|
||||
import { IOSConfig } from '@expo/config-plugins';
|
||||
import { AndroidConfig, IOSConfig } from '@expo/config-plugins';
|
||||
import { Platform, Workflow } from '@expo/eas-build-job';
|
||||
import assert from 'assert';
|
||||
import chalk from 'chalk';
|
||||
import fs from 'fs-extra';
|
||||
import once from 'lodash/once';
|
||||
|
||||
import Log from '../../log';
|
||||
import Log, { learnMore } from '../../log';
|
||||
import { promptAsync } from '../../prompts';
|
||||
import { getProjectConfigDescription, sanitizedProjectName } from '../projectUtils';
|
||||
import { resolveWorkflow } from '../workflow';
|
||||
import { ensureLoggedInAsync } from '../../user/actions';
|
||||
import { getProjectConfigDescription, getUsername, sanitizedProjectName } from '../projectUtils';
|
||||
import { resolveWorkflowAsync } 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.`;
|
||||
|
||||
@@ -16,22 +18,22 @@ export async function ensureBundleIdentifierIsDefinedForManagedProjectAsync(
|
||||
projectDir: string,
|
||||
exp: ExpoConfig
|
||||
): Promise<string> {
|
||||
const workflow = resolveWorkflow(projectDir, Platform.IOS);
|
||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.IOS);
|
||||
assert(workflow === Workflow.MANAGED, 'This function should be called only for managed projects');
|
||||
|
||||
try {
|
||||
return getBundleIdentifier(projectDir, exp);
|
||||
return await getBundleIdentifierAsync(projectDir, exp);
|
||||
} catch (err) {
|
||||
return await configureBundleIdentifierAsync(projectDir, exp);
|
||||
}
|
||||
}
|
||||
|
||||
export function getBundleIdentifier(
|
||||
export async function getBundleIdentifierAsync(
|
||||
projectDir: string,
|
||||
exp: ExpoConfig,
|
||||
{ targetName, buildConfiguration }: { targetName?: string; buildConfiguration?: string } = {}
|
||||
): string {
|
||||
const workflow = resolveWorkflow(projectDir, Platform.IOS);
|
||||
): Promise<string> {
|
||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.IOS);
|
||||
if (workflow === Workflow.GENERIC) {
|
||||
warnIfBundleIdentifierDefinedInAppConfigForGenericProject(projectDir, exp);
|
||||
|
||||
@@ -90,10 +92,19 @@ async function configureBundleIdentifierAsync(
|
||||
|
||||
assert(paths.staticConfigPath, 'app.json must exist');
|
||||
|
||||
Log.addNewLineIfNone();
|
||||
Log.log(
|
||||
`${chalk.bold(`📝 iOS Bundle Identifier`)} ${chalk.dim(
|
||||
learnMore('https://expo.fyi/bundle-identifier')
|
||||
)}`
|
||||
);
|
||||
|
||||
const suggestedBundleIdentifier = await getSuggestedBundleIdentifierAsync(exp);
|
||||
const { bundleIdentifier } = await promptAsync({
|
||||
name: 'bundleIdentifier',
|
||||
type: 'text',
|
||||
message: `What would you like your iOS bundle identifier to be?`,
|
||||
initial: suggestedBundleIdentifier,
|
||||
validate: value => (isBundleIdentifierValid(value) ? true : INVALID_BUNDLE_IDENTIFIER_MESSAGE),
|
||||
});
|
||||
|
||||
@@ -110,7 +121,7 @@ async function configureBundleIdentifierAsync(
|
||||
}
|
||||
|
||||
function isBundleIdentifierValid(bundleIdentifier: string): boolean {
|
||||
return /^[a-zA-Z]+(\.[a-zA-Z0-9-]+)*$/.test(bundleIdentifier);
|
||||
return /^[a-zA-Z0-9-.]+$/.test(bundleIdentifier);
|
||||
}
|
||||
|
||||
function _warnIfBundleIdentifierDefinedInAppConfigForGenericProject(
|
||||
@@ -130,3 +141,24 @@ function _warnIfBundleIdentifierDefinedInAppConfigForGenericProject(
|
||||
export const warnIfBundleIdentifierDefinedInAppConfigForGenericProject = once(
|
||||
_warnIfBundleIdentifierDefinedInAppConfigForGenericProject
|
||||
);
|
||||
|
||||
export function isWildcardBundleIdentifier(bundleIdentifier: string): boolean {
|
||||
const wildcardRegex = /^[A-Za-z0-9.-]+\*$/;
|
||||
return wildcardRegex.test(bundleIdentifier);
|
||||
}
|
||||
|
||||
async function getSuggestedBundleIdentifierAsync(exp: ExpoConfig): Promise<string | undefined> {
|
||||
// Attempt to use the android package name first since it's convenient to have them aligned.
|
||||
const maybeAndroidPackage = AndroidConfig.Package.getPackage(exp);
|
||||
if (maybeAndroidPackage && isBundleIdentifierValid(maybeAndroidPackage)) {
|
||||
return maybeAndroidPackage;
|
||||
} else {
|
||||
const username = getUsername(exp, await ensureLoggedInAsync());
|
||||
// It's common to use dashes in your node project name, strip them from the suggested package name.
|
||||
const possibleId = `com.${username}.${exp.slug}`.split('-').join('');
|
||||
if (isBundleIdentifierValid(possibleId)) {
|
||||
return possibleId;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
Loaded 100 of 120 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user