mirror of
https://github.com/expo/eas-cli.git
synced 2026-11-15 17:31:46 -10:00
Compare commits
71
Commits
v3.5.2
...
@quin/warnPlan
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0bcd94e83f | ||
|
|
da4b56a58d | ||
|
|
1080600af6 | ||
|
|
dcb6713f12 | ||
|
|
24a1d2d581 | ||
|
|
8af88c2d29 | ||
|
|
d416ac2162 | ||
|
|
7bf0493a4d | ||
|
|
91f32cc377 | ||
|
|
cf54f62bac | ||
|
|
3ef3e8447c | ||
|
|
ad64e1afad | ||
|
|
a0800cf7ef | ||
|
|
34436ee674 | ||
|
|
1072b75927 | ||
|
|
c0c9d2e7df | ||
|
|
19b831667f | ||
|
|
09db7da23b | ||
|
|
f08dde2469 | ||
|
|
213b5d240c | ||
|
|
16ebdce913 | ||
|
|
121ff7a718 | ||
|
|
360393f647 | ||
|
|
82d66054dc | ||
|
|
d8849dbf8c | ||
|
|
4d6b5f435b | ||
|
|
8fe7dfea29 | ||
|
|
8750155c25 | ||
|
|
a0fce1c773 | ||
|
|
cad3dca5df | ||
|
|
2ef6e79395 | ||
|
|
44270814a7 | ||
|
|
95155681db | ||
|
|
53fd599d0a | ||
|
|
b51201d010 | ||
|
|
f86c079733 | ||
|
|
843ec7407b | ||
|
|
537cd7872a | ||
|
|
007c40bed4 | ||
|
|
ba9f8d8ddd | ||
|
|
e4bd933e81 | ||
|
|
a6434bf6b8 | ||
|
|
19bad84109 | ||
|
|
5d9f8f9d76 | ||
|
|
d9d884d211 | ||
|
|
f902bb845b | ||
|
|
03c76c1e0e | ||
|
|
1d0d329cdb | ||
|
|
7ed1efb7d6 | ||
|
|
b7bfec0366 | ||
|
|
a5308f0d37 | ||
|
|
3ad644bb9d | ||
|
|
233e5451a8 | ||
|
|
ce954cdecc | ||
|
|
59bd1caf98 | ||
|
|
86877fdda3 | ||
|
|
9299c9b7cc | ||
|
|
64fb2e5b3a | ||
|
|
91fdbac773 | ||
|
|
507eadb914 | ||
|
|
f1cde7a291 | ||
|
|
8b9ad47d16 | ||
|
|
192984b47d | ||
|
|
2c36810ce7 | ||
|
|
bfa63f95fe | ||
|
|
c414b9f975 | ||
|
|
6946a085cb | ||
|
|
317d2fcbb6 | ||
|
|
dd61b4bb70 | ||
|
|
80fbf7cf62 | ||
|
|
26b6a17160 |
No files matched your search
@@ -37,7 +37,7 @@ body:
|
|||||||
required: true
|
required: true
|
||||||
attributes:
|
attributes:
|
||||||
label: Environment
|
label: Environment
|
||||||
description: Run `npx expo-env-info` and `expo doctor`, and paste the output here.
|
description: Run `npx expo-env-info` and `npx expo-doctor`, and paste the output here.
|
||||||
- type: textarea
|
- type: textarea
|
||||||
validations:
|
validations:
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 100,
|
||||||
|
"singleQuote": true
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
name: notify-slack-on-fail-or-recover
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
channel:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
slack_webhook:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
steps:
|
||||||
|
- name: Get previous workflow run status
|
||||||
|
uses: actions/github-script@v6
|
||||||
|
id: run-status
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const script = require('.github/internal-actions/notify-slack-on-fail-or-recover/main.js');
|
||||||
|
return await script({github, context, core});
|
||||||
|
|
||||||
|
- name: Commit subject
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
subject="$(git show --format=%s --quiet | sed 's/"/\\"/g')"
|
||||||
|
echo "${{ fromJSON(steps.run-status.outputs.result).previous }}"
|
||||||
|
echo "SUBJECT=$subject" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Send Slack Success Notification
|
||||||
|
if: fromJSON(steps.run-status.outputs.result).previous == 'failure' && fromJSON(steps.run-status.outputs.result).current == 'success'
|
||||||
|
uses: rtCamp/action-slack-notify@v2
|
||||||
|
env:
|
||||||
|
SLACK_CHANNEL: ${{ inputs.channel }}
|
||||||
|
SLACK_COLOR: good
|
||||||
|
SLACK_ICON: https://github.com/expo-bot.png?size=48
|
||||||
|
SLACK_TITLE: 'Fixed, was failing'
|
||||||
|
SLACK_MESSAGE: ${{ env.SUBJECT }}
|
||||||
|
SLACK_USERNAME: 'EAS CLI CI'
|
||||||
|
SLACK_WEBHOOK: ${{ inputs.slack_webhook }}
|
||||||
|
SLACK_FOOTER: ''
|
||||||
|
|
||||||
|
- name: Send Slack Failure Notification
|
||||||
|
if: fromJSON(steps.run-status.outputs.result).current == 'failure'
|
||||||
|
uses: rtCamp/action-slack-notify@v2
|
||||||
|
env:
|
||||||
|
SLACK_CHANNEL: ${{ inputs.channel }}
|
||||||
|
SLACK_COLOR: danger
|
||||||
|
SLACK_ICON: https://github.com/expo-bot.png?size=48
|
||||||
|
SLACK_TITLE: 'Failed'
|
||||||
|
SLACK_MESSAGE: ${{ env.SUBJECT }}
|
||||||
|
SLACK_USERNAME: 'EAS CLI CI'
|
||||||
|
SLACK_WEBHOOK: ${{ inputs.slack_webhook }}
|
||||||
|
SLACK_FOOTER: ''
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
function updateOctokitInstance(github) {
|
||||||
|
updateGithubRestActions(github);
|
||||||
|
addConvenienceMethods(github);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addConvenienceMethods(github) {
|
||||||
|
Object.assign(github, {
|
||||||
|
// checks if a run is a failure from the perspective of sending Slack
|
||||||
|
// notifications. Works for both runs and run attempts, which should be the
|
||||||
|
// same object shapes.
|
||||||
|
// When a run has not been completed, it fetches the jobs for the workflow
|
||||||
|
// to check if the job is "failing" instead of "failed".
|
||||||
|
async isFailedRun(run) {
|
||||||
|
console.log(`checking run: ${run.id}`);
|
||||||
|
console.log(`status: ${run.status}`);
|
||||||
|
console.log(`conclusion: ${run.conclusion}`);
|
||||||
|
console.log(`run_attempt: ${run.run_attempt}`);
|
||||||
|
|
||||||
|
if (run.status === 'completed') {
|
||||||
|
console.log('completed -- checking conclusion');
|
||||||
|
return run.conclusion === 'failure' || run.conclusion === 'timed_out';
|
||||||
|
}
|
||||||
|
|
||||||
|
const owner = run.repository.owner.login;
|
||||||
|
const repo = run.repository.name;
|
||||||
|
const jobsResp = await github.rest.actions.listJobsForWorkflowRun({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
run_id: run.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('checking jobs');
|
||||||
|
const jobs = jobsResp.data;
|
||||||
|
for (const job of jobs.jobs) {
|
||||||
|
if (job.conclusion === 'failure' || job.conclusion === 'timed_out') {
|
||||||
|
console.log('job failed');
|
||||||
|
return true;
|
||||||
|
} else if (job.status === 'completed') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const step of job.steps) {
|
||||||
|
if (step.conclusion === 'failure') {
|
||||||
|
console.log('job step failed');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// github-script's Octokit/REST plugins are out of date, so we have to
|
||||||
|
// add our own custom endpoint method
|
||||||
|
// see https://octokit.github.io/rest.js/v18#custom-endpoint-methods for
|
||||||
|
// documentation
|
||||||
|
function updateGithubRestActions(github) {
|
||||||
|
Object.assign(github.rest.actions, {
|
||||||
|
getWorkflowRunAttempt: github.request.defaults({
|
||||||
|
method: 'GET',
|
||||||
|
url: '/repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}',
|
||||||
|
params: {
|
||||||
|
owner: {
|
||||||
|
required: true,
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
repo: {
|
||||||
|
required: true,
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
run_id: {
|
||||||
|
required: true,
|
||||||
|
type: 'number',
|
||||||
|
},
|
||||||
|
attempt_number: {
|
||||||
|
required: true,
|
||||||
|
type: 'number',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns { current: 'failure' } | { current: 'success', previous: 'success' | 'failure' } to indicate the failure status
|
||||||
|
// of the current and previous runs
|
||||||
|
module.exports = async ({ github }) => {
|
||||||
|
const { GITHUB_REPOSITORY, GITHUB_RUN_ID, GITHUB_REF_NAME } = process.env;
|
||||||
|
const [owner, repo] = GITHUB_REPOSITORY.split('/');
|
||||||
|
updateOctokitInstance(github);
|
||||||
|
|
||||||
|
const workflowRunResp = await github.rest.actions.getWorkflowRun({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
run_id: GITHUB_RUN_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const currentRun = workflowRunResp.data;
|
||||||
|
const listWorkflowRunsResp = await github.rest.actions.listWorkflowRuns({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
workflow_id: currentRun.workflow_id,
|
||||||
|
branch: GITHUB_REF_NAME,
|
||||||
|
});
|
||||||
|
const { workflow_runs } = listWorkflowRunsResp.data;
|
||||||
|
|
||||||
|
if (workflow_runs.length === 1 && workflow_runs[0].run_attempt === 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const previousRuns = workflow_runs.filter(
|
||||||
|
(run) => run.status === 'completed' && run.conclusion !== 'cancelled'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (await github.isFailedRun(currentRun)) {
|
||||||
|
return { current: 'failure', previous: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentRun.run_attempt === 1 && previousRuns.length > 0) {
|
||||||
|
return {
|
||||||
|
current: 'success',
|
||||||
|
previous: (await github.isFailedRun(previousRuns[0])) ? 'failure' : 'success',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = currentRun.run_attempt - 1; i > 0; i--) {
|
||||||
|
const previousAttemptResp = await github.rest.actions.getWorkflowRunAttempt({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
run_id: currentRun.id,
|
||||||
|
attempt_number: i,
|
||||||
|
});
|
||||||
|
const previousAttempt = previousAttemptResp.data;
|
||||||
|
if (
|
||||||
|
previousAttempt.conclusion === 'success' ||
|
||||||
|
previousAttempt.conclusion === 'failure' ||
|
||||||
|
previousAttempt.conclusion === 'timed_out'
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
current: 'success',
|
||||||
|
previous: (await github.isFailedRun(previousAttempt)) ? 'failure' : 'success',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previousRuns.length > 0) {
|
||||||
|
return {
|
||||||
|
current: 'success',
|
||||||
|
previous: (await github.isFailedRun(previousRuns[0])) ? 'failure' : 'success',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return { current: 'success', previous: 'success' };
|
||||||
|
};
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "notify-slack-on-fail-or-recover",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "A GitHub Action to notify Expo Slack of build failures and recovery.",
|
||||||
|
"main": "main.js",
|
||||||
|
"author": "Expo",
|
||||||
|
"license": "UNLICENSED",
|
||||||
|
"private": true,
|
||||||
|
"devDependencies": {
|
||||||
|
"prettier": "^2.5.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
version "2.5.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a"
|
||||||
|
integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==
|
||||||
@@ -161,6 +161,8 @@ jobs:
|
|||||||
needs: publish-to-npm
|
needs: publish-to-npm
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.EXPO_BOT_PAT }}
|
||||||
- uses: actions/setup-node@v2
|
- uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
@@ -197,9 +199,9 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
SLACK_CHANNEL: eas-cli
|
SLACK_CHANNEL: eas-cli
|
||||||
SLACK_COLOR: ${{ job.status }}
|
SLACK_COLOR: ${{ job.status }}
|
||||||
SLACK_ICON: https://github.com/expo-ci.png?size=48
|
SLACK_ICON: https://github.com/expo-bot.png?size=48
|
||||||
SLACK_TITLE: 'Released eas-cli@${{ env.EAS_CLI_VERSION }}'
|
SLACK_TITLE: 'Released eas-cli@${{ env.EAS_CLI_VERSION }}'
|
||||||
SLACK_MESSAGE: ${{ env.SLACK_CHANGELOG }}
|
SLACK_MESSAGE: ${{ env.SLACK_CHANGELOG }}
|
||||||
SLACK_USERNAME: 'Expo CI'
|
SLACK_USERNAME: 'EAS CLI CI'
|
||||||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
|
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
|
||||||
SLACK_FOOTER: ''
|
SLACK_FOOTER: ''
|
||||||
@@ -39,3 +39,15 @@ jobs:
|
|||||||
if: ${{ matrix.coverage }}
|
if: ${{ matrix.coverage }}
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
notify-slack:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
|
name: Notify Slack
|
||||||
|
if: ${{ github.ref == 'refs/heads/main' && always() }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Notify Slack
|
||||||
|
uses: ./.github/internal-actions/notify-slack-on-fail-or-recover
|
||||||
|
with:
|
||||||
|
channel: eas-cli
|
||||||
|
slack_webhook: ${{ secrets.SLACK_WEBHOOK }}
|
||||||
+113
-1
@@ -10,10 +10,122 @@ This is the log of notable changes to EAS CLI and related packages.
|
|||||||
|
|
||||||
### 🐛 Bug fixes
|
### 🐛 Bug fixes
|
||||||
|
|
||||||
- Use the new developer-mdn.apple.com subdomain instead of developer.apple.com. ([#1673](https://github.com/expo/eas-cli/pull/1673) by [@brentvatne](https://github.com/brentvatne))
|
### 🧹 Chores
|
||||||
|
|
||||||
|
## [3.9.3](https://github.com/expo/eas-cli/releases/tag/v3.9.3) - 2023-04-18
|
||||||
|
|
||||||
|
### 🐛 Bug fixes
|
||||||
|
|
||||||
|
- Fix prompts in `eas update`. ([#1797](https://github.com/expo/eas-cli/pull/1797) by [@wschurman](https://github.com/wschurman))
|
||||||
|
|
||||||
|
## [3.9.2](https://github.com/expo/eas-cli/releases/tag/v3.9.2) - 2023-04-13
|
||||||
|
|
||||||
|
### 🐛 Bug fixes
|
||||||
|
|
||||||
|
- Fixes the rollout percentages when ending a rollout. ([#1781](https://github.com/expo/eas-cli/pull/1781) by [@jonsamp](https://github.com/jonsamp))
|
||||||
|
- Print meaningful error message if `extra.eas.projectId` is not a string. ([#1788](https://github.com/expo/eas-cli/pull/1788) by [@dsokal](https://github.com/dsokal))
|
||||||
|
|
||||||
### 🧹 Chores
|
### 🧹 Chores
|
||||||
|
|
||||||
|
- Show output of `expo install expo-updates`. ([#1782](https://github.com/expo/eas-cli/pull/1782) by [@wkozyra95](https://github.com/wkozyra95))
|
||||||
|
- Print deprecation warnings for deprecated `eas.json` fields. ([#1768](https://github.com/expo/eas-cli/pull/1768) by [@szdziedzic](https://github.com/szdziedzic))
|
||||||
|
|
||||||
|
## [3.9.1](https://github.com/expo/eas-cli/releases/tag/v3.9.1) - 2023-04-10
|
||||||
|
|
||||||
|
### 🐛 Bug fixes
|
||||||
|
|
||||||
|
- Update apple utilities to work around the maintenance error. ([#1780](https://github.com/expo/eas-cli/pull/1780) by [@byCedric](https://github.com/byCedric))
|
||||||
|
|
||||||
|
### 🧹 Chores
|
||||||
|
|
||||||
|
- Don't use defaults for the `cache.cacheDefaultPaths` build profile field. ([#1769](https://github.com/expo/eas-cli/pull/1769) by [@szdziedzic](https://github.com/szdziedzic))
|
||||||
|
|
||||||
|
## [3.9.0](https://github.com/expo/eas-cli/releases/tag/v3.9.0) - 2023-04-06
|
||||||
|
|
||||||
|
### 🎉 New features
|
||||||
|
|
||||||
|
- Add support for roll back to embedded updates. ([#1754](https://github.com/expo/eas-cli/pull/1754), [#1755](https://github.com/expo/eas-cli/pull/1755) by [@wschurman](https://github.com/wschurman))
|
||||||
|
|
||||||
|
### 🐛 Bug fixes
|
||||||
|
|
||||||
|
- Update `expoCommandAsync` to support the new Expo CLI bin path. ([#1772](https://github.com/expo/eas-cli/pull/1772) by [@gabrieldonadel](https://github.com/gabrieldonadel))
|
||||||
|
|
||||||
|
### 🧹 Chores
|
||||||
|
|
||||||
|
- Use the `eas-cli` npm tag for checking for the local build plugin updates. ([#1759](https://github.com/expo/eas-cli/pull/1759) by [@dsokal](https://github.com/dsokal))
|
||||||
|
- Ignore `requireCommit` option in `eas build:internal`. ([#1760](https://github.com/expo/eas-cli/pull/1760) by [@wkozyra95](https://github.com/wkozyra95))
|
||||||
|
- Support parsing eas.json from a string. ([#1766](https://github.com/expo/eas-cli/pull/1766) by [@wkozyra95](https://github.com/wkozyra95))
|
||||||
|
|
||||||
|
## [3.8.1](https://github.com/expo/eas-cli/releases/tag/v3.8.1) - 2023-03-16
|
||||||
|
|
||||||
|
### 🐛 Bug fixes
|
||||||
|
|
||||||
|
- Ensure public config is used as update. ([#1745](https://github.com/expo/eas-cli/pull/1745) by [@byCedric](https://github.com/byCedric))
|
||||||
|
|
||||||
|
### 🧹 Chores
|
||||||
|
|
||||||
|
- Unify how the command errors are displayed. ([#1738](https://github.com/expo/eas-cli/pull/1738) by [@radoslawkrzemien](https://github.com/radoslawkrzemien))
|
||||||
|
- Unify the case of base error messages for command failures. ([#1744](https://github.com/expo/eas-cli/pull/1744) by [@radoslawkrzemien](https://github.com/radoslawkrzemien))
|
||||||
|
|
||||||
|
## [3.8.0](https://github.com/expo/eas-cli/releases/tag/v3.8.0) - 2023-03-13
|
||||||
|
|
||||||
|
### 🎉 New features
|
||||||
|
|
||||||
|
- Add new `m-medium` and `m-large` resource classes. ([#1739](https://github.com/expo/eas-cli/pull/1739) by [@szdziedzic](https://github.com/szdziedzic))
|
||||||
|
|
||||||
|
## [3.7.2](https://github.com/expo/eas-cli/releases/tag/v3.7.2) - 2023-02-24
|
||||||
|
|
||||||
|
### 🐛 Bug fixes
|
||||||
|
|
||||||
|
- Implement Apple's proprietary Hashcash algorithm for signing authentication requests. ([#1719](https://github.com/expo/eas-cli/pull/1719) by [@EvanBacon](https://github.com/EvanBacon))
|
||||||
|
|
||||||
|
## [3.7.1](https://github.com/expo/eas-cli/releases/tag/v3.7.1) - 2023-02-23
|
||||||
|
|
||||||
|
### 🐛 Bug fixes
|
||||||
|
|
||||||
|
- Bump `@expo/apple-utils` to fix Apple developer auth. ([03c76c1](https://github.com/expo/eas-cli/commit/03c76c1e0efb9ec55e40b45e33c80b3479f920c3) by [@brentvatne](https://github.com/brentvatne))
|
||||||
|
|
||||||
|
## [3.7.0](https://github.com/expo/eas-cli/releases/tag/v3.7.0) - 2023-02-23
|
||||||
|
|
||||||
|
### 🎉 New features
|
||||||
|
|
||||||
|
- Support variant detection for package*UniversalApk Gradle Commands. ([#1708](https://github.com/expo/eas-cli/pull/1708) by [@frw](https://github.com/frw))
|
||||||
|
|
||||||
|
## [3.6.1](https://github.com/expo/eas-cli/releases/tag/v3.6.1) - 2023-02-20
|
||||||
|
|
||||||
|
### 🐛 Bug fixes
|
||||||
|
|
||||||
|
- Disable analytics when running behind a proxy. ([#1696](https://github.com/expo/eas-cli/pull/1696) by [@wkozyra95](https://github.com/wkozyra95))
|
||||||
|
- Clarify missing owner field error message for Robot users. ([#1702](https://github.com/expo/eas-cli/pull/1702) by [@wschurman](https://github.com/wschurman))
|
||||||
|
|
||||||
|
### 🧹 Chores
|
||||||
|
|
||||||
|
- Validate the platform for local builds earlier. ([#1698](https://github.com/expo/eas-cli/pull/1698) by [@wkozyra95](https://github.com/wkozyra95))
|
||||||
|
- Display build message when picking build in `eas submit`, `eas build:resign`, and `eas build:run` commands. ([#1700](https://github.com/expo/eas-cli/pull/1700) by [@szdziedzic](https://github.com/szdziedzic))
|
||||||
|
- Add a link directly to a build phase logs in the EAS CLI build error message. ([#1699](https://github.com/expo/eas-cli/pull/1699) by [@szdziedzic](https://github.com/szdziedzic))
|
||||||
|
|
||||||
|
## [3.6.0](https://github.com/expo/eas-cli/releases/tag/v3.6.0) - 2023-02-14
|
||||||
|
|
||||||
|
### 🎉 New features
|
||||||
|
|
||||||
|
- Use `sdkVersion` as default runtime version policy when running `eas update:configure`. ([#1669](https://github.com/expo/eas-cli/pull/1669) by [@jonsamp](https://github.com/jonsamp))
|
||||||
|
- Warn when project ID but no owner specified and mismatch logged in user. ([#1667](https://github.com/expo/eas-cli/pull/1667) by [@wschurman](https://github.com/wschurman))
|
||||||
|
- Return the build `message` if one is available. ([#1691](https://github.com/expo/eas-cli/pull/1691) by [@raulriera](https://github.com/raulriera))
|
||||||
|
|
||||||
|
### 🐛 Bug fixes
|
||||||
|
|
||||||
|
- Fix suggested application identifier to match owning account name. ([#1670](https://github.com/expo/eas-cli/pull/1670) by [@wschurman](https://github.com/wschurman))
|
||||||
|
|
||||||
|
### 🧹 Chores
|
||||||
|
|
||||||
|
- Add Xcode 14.2 image to the VSCode schema. ([#1693](https://github.com/expo/eas-cli/pull/1693) by [@szdziedzic](https://github.com/szdziedzic))
|
||||||
|
|
||||||
|
## [3.5.2](https://github.com/expo/eas-cli/releases/tag/v3.5.2) - 2023-02-05
|
||||||
|
|
||||||
|
### 🐛 Bug fixes
|
||||||
|
|
||||||
|
- Use the new developer-mdn.apple.com subdomain instead of developer.apple.com. ([#1673](https://github.com/expo/eas-cli/pull/1673) by [@brentvatne](https://github.com/brentvatne))
|
||||||
|
|
||||||
## [3.5.1](https://github.com/expo/eas-cli/releases/tag/v3.5.1) - 2023-02-01
|
## [3.5.1](https://github.com/expo/eas-cli/releases/tag/v3.5.1) - 2023-02-01
|
||||||
|
|
||||||
### 🐛 Bug fixes
|
### 🐛 Bug fixes
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"useWorkspaces": true,
|
"useWorkspaces": true,
|
||||||
"version": "3.5.2",
|
"version": "3.9.3",
|
||||||
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
|
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
|
||||||
}
|
}
|
||||||
+1
-1
@@ -14,7 +14,7 @@
|
|||||||
"eas": "packages/eas-cli/bin/run",
|
"eas": "packages/eas-cli/bin/run",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"lint-changelog": "./scripts/bin/run lint-changelog",
|
"lint-changelog": "./scripts/bin/run lint-changelog",
|
||||||
"release": "./scripts/bin/run release",
|
"release": "lerna run rebuild && ./scripts/bin/run release",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"clean": "lerna run clean && rm -rf node_modules coverage"
|
"clean": "lerna run clean && rm -rf node_modules coverage"
|
||||||
},
|
},
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
Generated
+3296
-664
File diff suppressed because it is too large.
Load diff
@@ -1,20 +1,20 @@
|
|||||||
{
|
{
|
||||||
"name": "eas-cli",
|
"name": "eas-cli",
|
||||||
"description": "EAS command line tool",
|
"description": "EAS command line tool",
|
||||||
"version": "3.5.2",
|
"version": "3.9.3",
|
||||||
"author": "Expo <[email protected]>",
|
"author": "Expo <[email protected]>",
|
||||||
"bin": {
|
"bin": {
|
||||||
"eas": "./bin/run"
|
"eas": "./bin/run"
|
||||||
},
|
},
|
||||||
"bugs": "https://github.com/expo/eas-cli/issues",
|
"bugs": "https://github.com/expo/eas-cli/issues",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@expo/apple-utils": "0.0.0-alpha.37",
|
"@expo/apple-utils": "1.2.0",
|
||||||
"@expo/code-signing-certificates": "0.0.5",
|
"@expo/code-signing-certificates": "0.0.5",
|
||||||
"@expo/config": "7.0.3",
|
"@expo/config": "7.0.3",
|
||||||
"@expo/config-plugins": "5.0.4",
|
"@expo/config-plugins": "5.0.4",
|
||||||
"@expo/config-types": "47.0.0",
|
"@expo/config-types": "47.0.0",
|
||||||
"@expo/eas-build-job": "0.2.103",
|
"@expo/eas-build-job": "1.0.7",
|
||||||
"@expo/eas-json": "3.5.0",
|
"@expo/eas-json": "3.9.2",
|
||||||
"@expo/json-file": "8.2.37",
|
"@expo/json-file": "8.2.37",
|
||||||
"@expo/multipart-body-parser": "1.1.0",
|
"@expo/multipart-body-parser": "1.1.0",
|
||||||
"@expo/osascript": "2.0.33",
|
"@expo/osascript": "2.0.33",
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
"@expo/results": "1.0.0",
|
"@expo/results": "1.0.0",
|
||||||
"@expo/rudder-sdk-node": "1.1.1",
|
"@expo/rudder-sdk-node": "1.1.1",
|
||||||
"@expo/spawn-async": "1.7.0",
|
"@expo/spawn-async": "1.7.0",
|
||||||
|
"@expo/steps": "1.0.8",
|
||||||
"@expo/timeago.js": "1.0.0",
|
"@expo/timeago.js": "1.0.0",
|
||||||
"@oclif/core": "1.23.2",
|
"@oclif/core": "1.23.2",
|
||||||
"@oclif/plugin-autocomplete": "1.3.10",
|
"@oclif/plugin-autocomplete": "1.3.10",
|
||||||
@@ -202,7 +203,8 @@
|
|||||||
"repository": "expo/eas-cli",
|
"repository": "expo/eas-cli",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postpack": "rimraf oclif.manifest.json",
|
"postpack": "rimraf oclif.manifest.json",
|
||||||
"prepack": "rimraf build && yarn build && node ./scripts/prepack.js",
|
"prepack": "yarn rebuild && node ./scripts/prepack.js",
|
||||||
|
"rebuild": "rimraf build && yarn build",
|
||||||
"pretarball-ci": "./scripts/pretarball-ci.sh",
|
"pretarball-ci": "./scripts/pretarball-ci.sh",
|
||||||
"build": "tsc --project tsconfig.build.json",
|
"build": "tsc --project tsconfig.build.json",
|
||||||
"watch": "yarn build --watch --preserveWatchOutput",
|
"watch": "yarn build --watch --preserveWatchOutput",
|
||||||
|
|||||||
@@ -133,7 +133,9 @@ export async function createAnalyticsAsync(): Promise<AnalyticsWithOrchestration
|
|||||||
await UserSettings.setAsync(USER_SETTINGS_KEY_ANALYTICS_ENABLED, false);
|
await UserSettings.setAsync(USER_SETTINGS_KEY_ANALYTICS_ENABLED, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const analyticsEnabled = await UserSettings.getAsync(USER_SETTINGS_KEY_ANALYTICS_ENABLED, true);
|
const analyticsEnabled =
|
||||||
|
!process.env.https_proxy && // disable analytics if running behind proxy
|
||||||
|
(await UserSettings.getAsync(USER_SETTINGS_KEY_ANALYTICS_ENABLED, true));
|
||||||
if (!analyticsEnabled) {
|
if (!analyticsEnabled) {
|
||||||
return new NoOpAnalytics();
|
return new NoOpAnalytics();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,362 @@
|
|||||||
|
import { Platform } from '@expo/eas-build-job';
|
||||||
|
import { CombinedError } from '@urql/core';
|
||||||
|
import { GraphQLError } from 'graphql/error';
|
||||||
|
|
||||||
|
import { EasCommandError } from '../../commandUtils/errors';
|
||||||
|
import Build from '../../commands/build';
|
||||||
|
import Log, { link } from '../../log';
|
||||||
|
import { handleBuildRequestError } from '../build';
|
||||||
|
import {
|
||||||
|
EasBuildDownForMaintenanceError,
|
||||||
|
EasBuildFreeTierDisabledAndroidError,
|
||||||
|
EasBuildFreeTierDisabledError,
|
||||||
|
EasBuildFreeTierDisabledIOSError,
|
||||||
|
EasBuildTooManyPendingBuildsError,
|
||||||
|
RequestValidationError,
|
||||||
|
TurtleDeprecatedJobFormatError,
|
||||||
|
} from '../errors';
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
const EXPECTED_STRINGIFIED_GRAPHQL_ERROR_JSON = `[
|
||||||
|
{
|
||||||
|
"message": "Error 1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"message": "Error 2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"message": "Error 3"
|
||||||
|
}
|
||||||
|
]`;
|
||||||
|
|
||||||
|
const EXPECTED_EAS_BUILD_DOWN_MESSAGE = `EAS Build is down for maintenance. Try again later. Check ${link(
|
||||||
|
'https://status.expo.dev/'
|
||||||
|
)} for updates.`;
|
||||||
|
|
||||||
|
const EXPECTED_MAX_BUILD_COUNT_MESSAGE_ANDROID = `You have already reached the maximum number of pending Android builds for your account. Try again later.`;
|
||||||
|
const EXPECTED_MAX_BUILD_COUNT_MESSAGE_IOS = `You have already reached the maximum number of pending iOS builds for your account. Try again later.`;
|
||||||
|
|
||||||
|
const EXPECTED_GENERIC_MESSAGE =
|
||||||
|
'Build request failed. Make sure you are using the latest eas-cli version. If the problem persists, report the issue.';
|
||||||
|
|
||||||
|
const getGraphQLError = (message: string, errorCode: string): GraphQLError => {
|
||||||
|
return new GraphQLError(message, null, null, null, null, null, {
|
||||||
|
errorCode,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const assertReThrownError = (
|
||||||
|
caughtError: CombinedError | Error,
|
||||||
|
expectedType: typeof EasCommandError,
|
||||||
|
expectedMessage: string = 'Error 1'
|
||||||
|
): void => {
|
||||||
|
expect(caughtError).toBeInstanceOf(expectedType);
|
||||||
|
expect((caughtError as Error).message).toEqual(expectedMessage);
|
||||||
|
};
|
||||||
|
|
||||||
|
describe(Build.name, () => {
|
||||||
|
describe('handle build request errors', () => {
|
||||||
|
describe('logs graphQL errors to debug if present', () => {
|
||||||
|
it('does it with Android', async () => {
|
||||||
|
const platform = Platform.ANDROID;
|
||||||
|
const logDebugSpy = jest.spyOn(Log, 'debug');
|
||||||
|
const graphQLErrors = ['Error 1', 'Error 2', 'Error 3'];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
expect(logDebugSpy).toBeCalledWith(EXPECTED_STRINGIFIED_GRAPHQL_ERROR_JSON);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does it with iOS', async () => {
|
||||||
|
const platform = Platform.IOS;
|
||||||
|
const logDebugSpy = jest.spyOn(Log, 'debug');
|
||||||
|
const graphQLErrors = ['Error 1', 'Error 2', 'Error 3'];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
expect(logDebugSpy).toBeCalledWith(EXPECTED_STRINGIFIED_GRAPHQL_ERROR_JSON);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('logs nothing to debug if graphQLErrors not present', () => {
|
||||||
|
it('does it with Android', async () => {
|
||||||
|
const platform = Platform.ANDROID;
|
||||||
|
const logDebugSpy = jest.spyOn(Log, 'debug');
|
||||||
|
const error = new Error('Generic error');
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
expect(logDebugSpy).toBeCalledWith(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does it with iOS', async () => {
|
||||||
|
const platform = Platform.IOS;
|
||||||
|
const logDebugSpy = jest.spyOn(Log, 'debug');
|
||||||
|
const error = new Error('Generic error');
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
expect(logDebugSpy).toBeCalledWith(undefined);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('error is server-side defined error', () => {
|
||||||
|
describe('throws correct EasCommandError subclass', () => {
|
||||||
|
describe('for TURTLE_DEPRECATED_JOB_FORMAT', () => {
|
||||||
|
it('does it with Android', async () => {
|
||||||
|
const platform = Platform.ANDROID;
|
||||||
|
const graphQLError = getGraphQLError('Error 1', 'TURTLE_DEPRECATED_JOB_FORMAT');
|
||||||
|
const graphQLErrors = [graphQLError];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch (caughtError) {
|
||||||
|
assertReThrownError(caughtError as Error, TurtleDeprecatedJobFormatError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does it with iOS', async () => {
|
||||||
|
const platform = Platform.IOS;
|
||||||
|
const graphQLError = getGraphQLError('Error 1', 'TURTLE_DEPRECATED_JOB_FORMAT');
|
||||||
|
const graphQLErrors = [graphQLError];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch (caughtError) {
|
||||||
|
assertReThrownError(caughtError as Error, TurtleDeprecatedJobFormatError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('for EAS_BUILD_FREE_TIER_DISABLED', () => {
|
||||||
|
it('does it with Android', async () => {
|
||||||
|
const platform = Platform.ANDROID;
|
||||||
|
const graphQLError = getGraphQLError('Error 1', 'EAS_BUILD_FREE_TIER_DISABLED');
|
||||||
|
const graphQLErrors = [graphQLError];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch (caughtError) {
|
||||||
|
assertReThrownError(caughtError as Error, EasBuildFreeTierDisabledError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does it with iOS', async () => {
|
||||||
|
const platform = Platform.IOS;
|
||||||
|
const graphQLError = getGraphQLError('Error 1', 'EAS_BUILD_FREE_TIER_DISABLED');
|
||||||
|
const graphQLErrors = [graphQLError];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch (caughtError) {
|
||||||
|
assertReThrownError(caughtError as Error, EasBuildFreeTierDisabledError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does it for EAS_BUILD_FREE_TIER_DISABLED_IOS', async () => {
|
||||||
|
const platform = Platform.IOS;
|
||||||
|
const graphQLError = getGraphQLError('Error 1', 'EAS_BUILD_FREE_TIER_DISABLED_IOS');
|
||||||
|
const graphQLErrors = [graphQLError];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch (caughtError) {
|
||||||
|
assertReThrownError(caughtError as Error, EasBuildFreeTierDisabledIOSError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does it for EAS_BUILD_FREE_TIER_DISABLED_ANDROID', async () => {
|
||||||
|
const platform = Platform.ANDROID;
|
||||||
|
const graphQLError = getGraphQLError('Error 1', 'EAS_BUILD_FREE_TIER_DISABLED_ANDROID');
|
||||||
|
const graphQLErrors = [graphQLError];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch (caughtError) {
|
||||||
|
assertReThrownError(caughtError as Error, EasBuildFreeTierDisabledAndroidError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('for VALIDATION_ERROR', () => {
|
||||||
|
it('does it with Android', async () => {
|
||||||
|
const platform = Platform.ANDROID;
|
||||||
|
const graphQLError = getGraphQLError('Error 1', 'VALIDATION_ERROR');
|
||||||
|
const graphQLErrors = [graphQLError];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch (caughtError) {
|
||||||
|
assertReThrownError(caughtError as Error, RequestValidationError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does it with iOS', async () => {
|
||||||
|
const platform = Platform.IOS;
|
||||||
|
const graphQLError = getGraphQLError('Error 1', 'VALIDATION_ERROR');
|
||||||
|
const graphQLErrors = [graphQLError];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch (caughtError) {
|
||||||
|
assertReThrownError(caughtError as Error, RequestValidationError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('error is other expected graphQL-related error', () => {
|
||||||
|
describe('throws correct EasCommandError subclass', () => {
|
||||||
|
describe('for EAS_BUILD_DOWN_FOR_MAINTENANCE', () => {
|
||||||
|
it('does it with Android', async () => {
|
||||||
|
const platform = Platform.ANDROID;
|
||||||
|
const graphQLError = getGraphQLError('Error 1', 'EAS_BUILD_DOWN_FOR_MAINTENANCE');
|
||||||
|
const graphQLErrors = [graphQLError];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch (caughtError) {
|
||||||
|
assertReThrownError(
|
||||||
|
caughtError as Error,
|
||||||
|
EasBuildDownForMaintenanceError,
|
||||||
|
EXPECTED_EAS_BUILD_DOWN_MESSAGE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does it with iOS', async () => {
|
||||||
|
const platform = Platform.IOS;
|
||||||
|
const graphQLError = getGraphQLError('Error 1', 'EAS_BUILD_DOWN_FOR_MAINTENANCE');
|
||||||
|
const graphQLErrors = [graphQLError];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch (caughtError) {
|
||||||
|
assertReThrownError(
|
||||||
|
caughtError as Error,
|
||||||
|
EasBuildDownForMaintenanceError,
|
||||||
|
EXPECTED_EAS_BUILD_DOWN_MESSAGE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('for EAS_BUILD_TOO_MANY_PENDING_BUILDS', () => {
|
||||||
|
it('does it with Android', async () => {
|
||||||
|
const platform = Platform.ANDROID;
|
||||||
|
const graphQLError = getGraphQLError('Error 1', 'EAS_BUILD_TOO_MANY_PENDING_BUILDS');
|
||||||
|
const graphQLErrors = [graphQLError];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch (caughtError) {
|
||||||
|
assertReThrownError(
|
||||||
|
caughtError as Error,
|
||||||
|
EasBuildTooManyPendingBuildsError,
|
||||||
|
EXPECTED_MAX_BUILD_COUNT_MESSAGE_ANDROID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does it with iOS', async () => {
|
||||||
|
const platform = Platform.IOS;
|
||||||
|
const graphQLError = getGraphQLError('Error 1', 'EAS_BUILD_TOO_MANY_PENDING_BUILDS');
|
||||||
|
const graphQLErrors = [graphQLError];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch (caughtError) {
|
||||||
|
assertReThrownError(
|
||||||
|
caughtError as Error,
|
||||||
|
EasBuildTooManyPendingBuildsError,
|
||||||
|
EXPECTED_MAX_BUILD_COUNT_MESSAGE_IOS
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('error is unexpected graphQL-related error', () => {
|
||||||
|
describe('throws base Error class with custom message', () => {
|
||||||
|
it('does it with Android', async () => {
|
||||||
|
const platform = Platform.ANDROID;
|
||||||
|
const graphQLError = getGraphQLError('Error 1', 'UNKNOWN_GRAPHQL_ERROR');
|
||||||
|
const graphQLErrors = [graphQLError];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch (caughtError) {
|
||||||
|
assertReThrownError(caughtError as Error, Error, EXPECTED_GENERIC_MESSAGE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does it with iOS', async () => {
|
||||||
|
const platform = Platform.IOS;
|
||||||
|
const graphQLError = getGraphQLError('Error 1', 'UNKNOWN_GRAPHQL_ERROR');
|
||||||
|
const graphQLErrors = [graphQLError];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch (caughtError) {
|
||||||
|
assertReThrownError(caughtError as Error, Error, EXPECTED_GENERIC_MESSAGE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('error is unexpected non-graphQL-related error', () => {
|
||||||
|
describe('throws base Error class with propagated message', () => {
|
||||||
|
it('does it with Android', async () => {
|
||||||
|
const platform = Platform.ANDROID;
|
||||||
|
const error = new Error('Non-graphQL-related error');
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch (caughtError) {
|
||||||
|
expect(caughtError).toStrictEqual(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does it with iOS', async () => {
|
||||||
|
const platform = Platform.IOS;
|
||||||
|
const error = new Error('Non-graphQL-related error');
|
||||||
|
|
||||||
|
try {
|
||||||
|
handleBuildRequestError(error, platform);
|
||||||
|
} catch (caughtError) {
|
||||||
|
expect(caughtError).toStrictEqual(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -62,7 +62,7 @@ This means that it will most likely produce an AAB and you will not be able to i
|
|||||||
const gradleContext = await resolveGradleBuildContextAsync(ctx.projectDir, buildProfile);
|
const gradleContext = await resolveGradleBuildContextAsync(ctx.projectDir, buildProfile);
|
||||||
|
|
||||||
if (ctx.workflow === Workflow.MANAGED) {
|
if (ctx.workflow === Workflow.MANAGED) {
|
||||||
await ensureApplicationIdIsDefinedForManagedProjectAsync(ctx.projectDir, ctx.exp, ctx.user);
|
await ensureApplicationIdIsDefinedForManagedProjectAsync(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
const applicationId = await getApplicationIdAsync(ctx.projectDir, ctx.exp, gradleContext);
|
const applicationId = await getApplicationIdAsync(ctx.projectDir, ctx.exp, gradleContext);
|
||||||
@@ -124,7 +124,8 @@ export async function prepareAndroidBuildAsync(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function shouldProvideCredentials(ctx: BuildContext<Platform.ANDROID>): boolean {
|
function shouldProvideCredentials(ctx: BuildContext<Platform.ANDROID>): boolean {
|
||||||
return !ctx.buildProfile.withoutCredentials;
|
const isCustomBuild = ctx.buildProfile.config !== undefined;
|
||||||
|
return !ctx.buildProfile.withoutCredentials && !isCustomBuild;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function ensureAndroidCredentialsAsync(
|
async function ensureAndroidCredentialsAsync(
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
import { Android } from '@expo/eas-build-job';
|
import { Android } from '@expo/eas-build-job';
|
||||||
|
|
||||||
import { AndroidBuildType, AndroidJobInput } from '../../graphql/generated';
|
import { AndroidBuildType, AndroidJobInput } from '../../graphql/generated';
|
||||||
import { transformBuildTrigger, transformProjectArchive, transformWorkflow } from '../graphql';
|
import {
|
||||||
|
transformBuildMode,
|
||||||
|
transformBuildTrigger,
|
||||||
|
transformProjectArchive,
|
||||||
|
transformWorkflow,
|
||||||
|
} from '../graphql';
|
||||||
|
|
||||||
export function transformJob(job: Android.Job): AndroidJobInput {
|
export function transformJob(job: Android.Job): AndroidJobInput {
|
||||||
return {
|
return {
|
||||||
@@ -22,6 +27,8 @@ export function transformJob(job: Android.Job): AndroidJobInput {
|
|||||||
buildType: job.buildType && transformBuildType(job.buildType),
|
buildType: job.buildType && transformBuildType(job.buildType),
|
||||||
developmentClient: job.developmentClient,
|
developmentClient: job.developmentClient,
|
||||||
experimental: job.experimental,
|
experimental: job.experimental,
|
||||||
|
mode: transformBuildMode(job.mode),
|
||||||
|
customBuildConfig: job.customBuildConfig,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import path from 'path';
|
|||||||
import slash from 'slash';
|
import slash from 'slash';
|
||||||
|
|
||||||
import { AndroidCredentials } from '../../credentials/android/AndroidCredentialsProvider';
|
import { AndroidCredentials } from '../../credentials/android/AndroidCredentialsProvider';
|
||||||
|
import { getCustomBuildConfigPath } from '../../project/customBuildConfig';
|
||||||
import { getUsername } from '../../project/projectUtils';
|
import { getUsername } from '../../project/projectUtils';
|
||||||
import { getVcsClient } from '../../vcs';
|
import { getVcsClient } from '../../vcs';
|
||||||
import { BuildContext } from '../context';
|
import { BuildContext } from '../context';
|
||||||
@@ -24,7 +25,6 @@ interface JobData {
|
|||||||
const cacheDefaults = {
|
const cacheDefaults = {
|
||||||
disabled: false,
|
disabled: false,
|
||||||
customPaths: [],
|
customPaths: [],
|
||||||
cacheDefaultPaths: true,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function prepareJobAsync(
|
export async function prepareJobAsync(
|
||||||
@@ -49,11 +49,15 @@ export async function prepareJobAsync(
|
|||||||
}
|
}
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
let buildType = ctx.buildProfile.buildType;
|
let buildType = buildProfile.buildType;
|
||||||
if (!buildType && !buildProfile.gradleCommand && ctx.buildProfile.distribution === 'internal') {
|
if (!buildType && !buildProfile.gradleCommand && buildProfile.distribution === 'internal') {
|
||||||
buildType = Android.BuildType.APK;
|
buildType = Android.BuildType.APK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const maybeCustomBuildConfigPath = buildProfile.config
|
||||||
|
? getCustomBuildConfigPath(buildProfile.config)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const job: Android.Job = {
|
const job: Android.Job = {
|
||||||
type: ctx.workflow,
|
type: ctx.workflow,
|
||||||
platform: Platform.ANDROID,
|
platform: Platform.ANDROID,
|
||||||
@@ -75,8 +79,8 @@ export async function prepareJobAsync(
|
|||||||
secrets: {
|
secrets: {
|
||||||
...buildCredentials,
|
...buildCredentials,
|
||||||
},
|
},
|
||||||
releaseChannel: ctx.buildProfile.releaseChannel,
|
releaseChannel: buildProfile.releaseChannel,
|
||||||
updates: { channel: ctx.buildProfile.channel },
|
updates: { channel: buildProfile.channel },
|
||||||
developmentClient: buildProfile.developmentClient,
|
developmentClient: buildProfile.developmentClient,
|
||||||
gradleCommand: buildProfile.gradleCommand,
|
gradleCommand: buildProfile.gradleCommand,
|
||||||
applicationArchivePath: buildProfile.applicationArchivePath ?? buildProfile.artifactPath,
|
applicationArchivePath: buildProfile.applicationArchivePath ?? buildProfile.artifactPath,
|
||||||
@@ -89,10 +93,15 @@ export async function prepareJobAsync(
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
experimental: {
|
experimental: {
|
||||||
prebuildCommand: ctx.buildProfile.prebuildCommand,
|
prebuildCommand: buildProfile.prebuildCommand,
|
||||||
},
|
},
|
||||||
mode: BuildMode.BUILD,
|
mode: buildProfile.config ? BuildMode.CUSTOM : BuildMode.BUILD,
|
||||||
triggeredBy: BuildTrigger.EAS_CLI,
|
triggeredBy: BuildTrigger.EAS_CLI,
|
||||||
|
...(maybeCustomBuildConfigPath && {
|
||||||
|
customBuildConfig: {
|
||||||
|
path: maybeCustomBuildConfigPath,
|
||||||
|
},
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
return sanitizeJob(job);
|
return sanitizeJob(job);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { BuildEvent } from '../analytics/AnalyticsManager';
|
|||||||
import { withAnalyticsAsync } from '../analytics/common';
|
import { withAnalyticsAsync } from '../analytics/common';
|
||||||
import { getExpoWebsiteBaseUrl } from '../api';
|
import { getExpoWebsiteBaseUrl } from '../api';
|
||||||
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
|
import { EasCommandError } from '../commandUtils/errors';
|
||||||
import {
|
import {
|
||||||
AppPlatform,
|
AppPlatform,
|
||||||
BuildFragment,
|
BuildFragment,
|
||||||
@@ -36,6 +37,15 @@ import { createProgressTracker } from '../utils/progress';
|
|||||||
import { sleepAsync } from '../utils/promise';
|
import { sleepAsync } from '../utils/promise';
|
||||||
import { getVcsClient } from '../vcs';
|
import { getVcsClient } from '../vcs';
|
||||||
import { BuildContext } from './context';
|
import { BuildContext } from './context';
|
||||||
|
import {
|
||||||
|
EasBuildDownForMaintenanceError,
|
||||||
|
EasBuildFreeTierDisabledAndroidError,
|
||||||
|
EasBuildFreeTierDisabledError,
|
||||||
|
EasBuildFreeTierDisabledIOSError,
|
||||||
|
EasBuildTooManyPendingBuildsError,
|
||||||
|
RequestValidationError,
|
||||||
|
TurtleDeprecatedJobFormatError,
|
||||||
|
} from './errors';
|
||||||
import { transformMetadata } from './graphql';
|
import { transformMetadata } from './graphql';
|
||||||
import { LocalBuildMode, runLocalBuildAsync } from './local';
|
import { LocalBuildMode, runLocalBuildAsync } from './local';
|
||||||
import { collectMetadataAsync } from './metadata';
|
import { collectMetadataAsync } from './metadata';
|
||||||
@@ -161,38 +171,33 @@ export async function prepareBuildRequestForPlatformAsync<
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const SERVER_SIDE_DEFINED_ERRORS = [
|
const SERVER_SIDE_DEFINED_ERRORS: Record<string, typeof EasCommandError> = {
|
||||||
'TURTLE_DEPRECATED_JOB_FORMAT',
|
TURTLE_DEPRECATED_JOB_FORMAT: TurtleDeprecatedJobFormatError,
|
||||||
'EAS_BUILD_FREE_TIER_DISABLED',
|
EAS_BUILD_FREE_TIER_DISABLED: EasBuildFreeTierDisabledError,
|
||||||
'EAS_BUILD_FREE_TIER_DISABLED_IOS',
|
EAS_BUILD_FREE_TIER_DISABLED_IOS: EasBuildFreeTierDisabledIOSError,
|
||||||
'EAS_BUILD_FREE_TIER_DISABLED_ANDROID',
|
EAS_BUILD_FREE_TIER_DISABLED_ANDROID: EasBuildFreeTierDisabledAndroidError,
|
||||||
'VALIDATION_ERROR',
|
VALIDATION_ERROR: RequestValidationError,
|
||||||
];
|
};
|
||||||
|
|
||||||
function handleBuildRequestError(error: any, platform: Platform): never {
|
export function handleBuildRequestError(error: any, platform: Platform): never {
|
||||||
Log.debug(JSON.stringify(error.graphQLErrors, null, 2));
|
Log.debug(JSON.stringify(error.graphQLErrors, null, 2));
|
||||||
|
|
||||||
if (SERVER_SIDE_DEFINED_ERRORS.includes(error?.graphQLErrors?.[0]?.extensions?.errorCode)) {
|
const graphQLErrorCode: string = error?.graphQLErrors?.[0]?.extensions?.errorCode;
|
||||||
Log.error(error?.graphQLErrors?.[0]?.message);
|
if (graphQLErrorCode in SERVER_SIDE_DEFINED_ERRORS) {
|
||||||
throw new Error('Build request failed.');
|
const ErrorClass: typeof EasCommandError = SERVER_SIDE_DEFINED_ERRORS[graphQLErrorCode];
|
||||||
} else if (
|
throw new ErrorClass(error?.graphQLErrors?.[0]?.message);
|
||||||
error?.graphQLErrors?.[0]?.extensions?.errorCode === 'EAS_BUILD_DOWN_FOR_MAINTENANCE'
|
} else if (graphQLErrorCode === 'EAS_BUILD_DOWN_FOR_MAINTENANCE') {
|
||||||
) {
|
throw new EasBuildDownForMaintenanceError(
|
||||||
Log.error(
|
|
||||||
`EAS Build is down for maintenance. Try again later. Check ${link(
|
`EAS Build is down for maintenance. Try again later. Check ${link(
|
||||||
'https://status.expo.dev/'
|
'https://status.expo.dev/'
|
||||||
)} for updates.`
|
)} for updates.`
|
||||||
);
|
);
|
||||||
throw new Error('Build request failed.');
|
} else if (graphQLErrorCode === 'EAS_BUILD_TOO_MANY_PENDING_BUILDS') {
|
||||||
} else if (
|
throw new EasBuildTooManyPendingBuildsError(
|
||||||
error?.graphQLErrors?.[0]?.extensions?.errorCode === 'EAS_BUILD_TOO_MANY_PENDING_BUILDS'
|
|
||||||
) {
|
|
||||||
Log.error(
|
|
||||||
`You have already reached the maximum number of pending ${requestedPlatformDisplayNames[platform]} builds for your account. Try again later.`
|
`You have already reached the maximum number of pending ${requestedPlatformDisplayNames[platform]} builds for your account. Try again later.`
|
||||||
);
|
);
|
||||||
throw new Error('Build request failed.');
|
|
||||||
} else if (error?.graphQLErrors) {
|
} else if (error?.graphQLErrors) {
|
||||||
Log.error(
|
throw new Error(
|
||||||
'Build request failed. Make sure you are using the latest eas-cli version. If the problem persists, report the issue.'
|
'Build request failed. Make sure you are using the latest eas-cli version. If the problem persists, report the issue.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -607,7 +612,7 @@ function formatAccountSubscriptionsUrl(accountName: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function updateIosBuildProfilesToUseM1WorkersAsync(projectDir: string): Promise<void> {
|
async function updateIosBuildProfilesToUseM1WorkersAsync(projectDir: string): Promise<void> {
|
||||||
const easJsonAccessor = new EasJsonAccessor(projectDir);
|
const easJsonAccessor = EasJsonAccessor.fromProjectPath(projectDir);
|
||||||
await easJsonAccessor.readRawJsonAsync();
|
await easJsonAccessor.readRawJsonAsync();
|
||||||
|
|
||||||
const profileNames = await EasJsonUtils.getBuildProfileNamesAsync(easJsonAccessor);
|
const profileNames = await EasJsonUtils.getBuildProfileNamesAsync(easJsonAccessor);
|
||||||
@@ -615,7 +620,7 @@ async function updateIosBuildProfilesToUseM1WorkersAsync(projectDir: string): Pr
|
|||||||
for (const profileName of profileNames) {
|
for (const profileName of profileNames) {
|
||||||
easJsonRawObject.build[profileName].ios = {
|
easJsonRawObject.build[profileName].ios = {
|
||||||
...easJsonRawObject.build[profileName].ios,
|
...easJsonRawObject.build[profileName].ios,
|
||||||
resourceClass: ResourceClass.M1_MEDIUM,
|
resourceClass: ResourceClass.M_MEDIUM,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return easJsonRawObject;
|
return easJsonRawObject;
|
||||||
|
|||||||
@@ -54,18 +54,18 @@ const EAS_JSON_MANAGED_DEFAULT: EasJson = {
|
|||||||
developmentClient: true,
|
developmentClient: true,
|
||||||
distribution: 'internal',
|
distribution: 'internal',
|
||||||
ios: {
|
ios: {
|
||||||
resourceClass: ResourceClass.M1_MEDIUM,
|
resourceClass: ResourceClass.M_MEDIUM,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
preview: {
|
preview: {
|
||||||
distribution: 'internal',
|
distribution: 'internal',
|
||||||
ios: {
|
ios: {
|
||||||
resourceClass: ResourceClass.M1_MEDIUM,
|
resourceClass: ResourceClass.M_MEDIUM,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
production: {
|
production: {
|
||||||
ios: {
|
ios: {
|
||||||
resourceClass: ResourceClass.M1_MEDIUM,
|
resourceClass: ResourceClass.M_MEDIUM,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -86,18 +86,18 @@ const EAS_JSON_BARE_DEFAULT: EasJson = {
|
|||||||
},
|
},
|
||||||
ios: {
|
ios: {
|
||||||
buildConfiguration: 'Debug',
|
buildConfiguration: 'Debug',
|
||||||
resourceClass: ResourceClass.M1_MEDIUM,
|
resourceClass: ResourceClass.M_MEDIUM,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
preview: {
|
preview: {
|
||||||
distribution: 'internal',
|
distribution: 'internal',
|
||||||
ios: {
|
ios: {
|
||||||
resourceClass: ResourceClass.M1_MEDIUM,
|
resourceClass: ResourceClass.M_MEDIUM,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
production: {
|
production: {
|
||||||
ios: {
|
ios: {
|
||||||
resourceClass: ResourceClass.M1_MEDIUM,
|
resourceClass: ResourceClass.M_MEDIUM,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { EasCommandError } from '../commandUtils/errors';
|
||||||
|
|
||||||
|
export class TurtleDeprecatedJobFormatError extends EasCommandError {}
|
||||||
|
|
||||||
|
export class EasBuildFreeTierDisabledError extends EasCommandError {}
|
||||||
|
|
||||||
|
export class EasBuildFreeTierDisabledIOSError extends EasCommandError {}
|
||||||
|
|
||||||
|
export class EasBuildFreeTierDisabledAndroidError extends EasCommandError {}
|
||||||
|
|
||||||
|
export class RequestValidationError extends EasCommandError {}
|
||||||
|
|
||||||
|
export class EasBuildDownForMaintenanceError extends EasCommandError {}
|
||||||
|
|
||||||
|
export class EasBuildTooManyPendingBuildsError extends EasCommandError {}
|
||||||
@@ -91,11 +91,16 @@ export function transformIosEnterpriseProvisioning(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function transformBuildMode(buildMode: Metadata['buildMode']): BuildMode {
|
// TODO: check what in metadata
|
||||||
|
export function transformBuildMode(buildMode: string): BuildMode {
|
||||||
if (buildMode === 'build') {
|
if (buildMode === 'build') {
|
||||||
return BuildMode.Build;
|
return BuildMode.Build;
|
||||||
} else {
|
} else if (buildMode === 'resign') {
|
||||||
return BuildMode.Resign;
|
return BuildMode.Resign;
|
||||||
|
} else if (buildMode === 'custom') {
|
||||||
|
return BuildMode.Custom;
|
||||||
|
} else {
|
||||||
|
throw new Error(`Unsupported build mode: ${buildMode}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export async function createIosContextAsync(
|
|||||||
const { buildProfile } = ctx;
|
const { buildProfile } = ctx;
|
||||||
|
|
||||||
if (ctx.workflow === Workflow.MANAGED) {
|
if (ctx.workflow === Workflow.MANAGED) {
|
||||||
await ensureBundleIdentifierIsDefinedForManagedProjectAsync(ctx.projectDir, ctx.exp, ctx.user);
|
await ensureBundleIdentifierIsDefinedForManagedProjectAsync(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkNodeEnvVariable(ctx);
|
checkNodeEnvVariable(ctx);
|
||||||
|
|||||||
@@ -55,5 +55,6 @@ export async function ensureIosCredentialsForBuildResignAsync(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function shouldProvideCredentials(buildCtx: BuildContext<Platform.IOS>): boolean {
|
function shouldProvideCredentials(buildCtx: BuildContext<Platform.IOS>): boolean {
|
||||||
return !buildCtx.buildProfile.simulator;
|
const isCustomBuild = buildCtx.buildProfile.config !== undefined;
|
||||||
|
return !buildCtx.buildProfile.simulator && !isCustomBuild;
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,12 @@ import { Ios } from '@expo/eas-build-job';
|
|||||||
import nullthrows from 'nullthrows';
|
import nullthrows from 'nullthrows';
|
||||||
|
|
||||||
import { IosJobInput, IosJobSecretsInput } from '../../graphql/generated';
|
import { IosJobInput, IosJobSecretsInput } from '../../graphql/generated';
|
||||||
import { transformBuildTrigger, transformProjectArchive, transformWorkflow } from '../graphql';
|
import {
|
||||||
|
transformBuildMode,
|
||||||
|
transformBuildTrigger,
|
||||||
|
transformProjectArchive,
|
||||||
|
transformWorkflow,
|
||||||
|
} from '../graphql';
|
||||||
|
|
||||||
export function transformJob(job: Ios.Job): IosJobInput {
|
export function transformJob(job: Ios.Job): IosJobInput {
|
||||||
return {
|
return {
|
||||||
@@ -12,7 +17,7 @@ export function transformJob(job: Ios.Job): IosJobInput {
|
|||||||
projectRootDirectory: nullthrows(job.projectRootDirectory),
|
projectRootDirectory: nullthrows(job.projectRootDirectory),
|
||||||
releaseChannel: job.releaseChannel,
|
releaseChannel: job.releaseChannel,
|
||||||
updates: job.updates,
|
updates: job.updates,
|
||||||
secrets: transformIosSecrets(job.secrets),
|
secrets: job.secrets ? transformIosSecrets(job.secrets) : undefined,
|
||||||
builderEnvironment: job.builderEnvironment,
|
builderEnvironment: job.builderEnvironment,
|
||||||
cache: job.cache,
|
cache: job.cache,
|
||||||
version: job.version?.buildNumber ? { buildNumber: job.version.buildNumber } : undefined,
|
version: job.version?.buildNumber ? { buildNumber: job.version.buildNumber } : undefined,
|
||||||
@@ -24,6 +29,8 @@ export function transformJob(job: Ios.Job): IosJobInput {
|
|||||||
developmentClient: job.developmentClient,
|
developmentClient: job.developmentClient,
|
||||||
simulator: job.simulator,
|
simulator: job.simulator,
|
||||||
experimental: job.experimental,
|
experimental: job.experimental,
|
||||||
|
mode: transformBuildMode(job.mode),
|
||||||
|
customBuildConfig: job.customBuildConfig,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,14 @@ import {
|
|||||||
Platform,
|
Platform,
|
||||||
sanitizeJob,
|
sanitizeJob,
|
||||||
} from '@expo/eas-build-job';
|
} from '@expo/eas-build-job';
|
||||||
|
import { BuildProfile } from '@expo/eas-json';
|
||||||
import nullthrows from 'nullthrows';
|
import nullthrows from 'nullthrows';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import slash from 'slash';
|
import slash from 'slash';
|
||||||
|
|
||||||
import { IosCredentials, TargetCredentials } from '../../credentials/ios/types';
|
import { IosCredentials, TargetCredentials } from '../../credentials/ios/types';
|
||||||
import { IosJobSecretsInput } from '../../graphql/generated';
|
import { IosJobSecretsInput } from '../../graphql/generated';
|
||||||
|
import { getCustomBuildConfigPath } from '../../project/customBuildConfig';
|
||||||
import { getUsername } from '../../project/projectUtils';
|
import { getUsername } from '../../project/projectUtils';
|
||||||
import { getVcsClient } from '../../vcs';
|
import { getVcsClient } from '../../vcs';
|
||||||
import { BuildContext } from '../context';
|
import { BuildContext } from '../context';
|
||||||
@@ -26,17 +28,17 @@ interface JobData {
|
|||||||
const cacheDefaults = {
|
const cacheDefaults = {
|
||||||
disabled: false,
|
disabled: false,
|
||||||
customPaths: [],
|
customPaths: [],
|
||||||
cacheDefaultPaths: true,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function prepareJobAsync(
|
export async function prepareJobAsync(
|
||||||
ctx: BuildContext<Platform.IOS>,
|
ctx: BuildContext<Platform.IOS>,
|
||||||
jobData: JobData
|
jobData: JobData
|
||||||
): Promise<Job> {
|
): Promise<Job> {
|
||||||
|
const username = getUsername(ctx.exp, ctx.user);
|
||||||
|
const buildProfile: BuildProfile<Platform.IOS> = ctx.buildProfile;
|
||||||
const projectRootDirectory =
|
const projectRootDirectory =
|
||||||
slash(path.relative(await getVcsClient().getRootPathAsync(), ctx.projectDir)) || '.';
|
slash(path.relative(await getVcsClient().getRootPathAsync(), ctx.projectDir)) || '.';
|
||||||
const username = getUsername(ctx.exp, ctx.user);
|
const buildCredentials: Ios.BuildSecrets['buildCredentials'] = {};
|
||||||
const buildCredentials: Ios.Job['secrets']['buildCredentials'] = {};
|
|
||||||
if (jobData.credentials) {
|
if (jobData.credentials) {
|
||||||
const targetNames = Object.keys(jobData.credentials);
|
const targetNames = Object.keys(jobData.credentials);
|
||||||
for (const targetName of targetNames) {
|
for (const targetName of targetNames) {
|
||||||
@@ -44,38 +46,41 @@ export async function prepareJobAsync(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const maybeCustomBuildConfigPath = buildProfile.config
|
||||||
|
? getCustomBuildConfigPath(buildProfile.config)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const job: Ios.Job = {
|
const job: Ios.Job = {
|
||||||
type: ctx.workflow,
|
type: ctx.workflow,
|
||||||
platform: Platform.IOS,
|
platform: Platform.IOS,
|
||||||
projectArchive: jobData.projectArchive,
|
projectArchive: jobData.projectArchive,
|
||||||
projectRootDirectory,
|
projectRootDirectory,
|
||||||
builderEnvironment: {
|
builderEnvironment: {
|
||||||
image: ctx.buildProfile.image,
|
image: buildProfile.image,
|
||||||
node: ctx.buildProfile.node,
|
node: buildProfile.node,
|
||||||
yarn: ctx.buildProfile.yarn,
|
yarn: buildProfile.yarn,
|
||||||
bundler: ctx.buildProfile.bundler,
|
bundler: buildProfile.bundler,
|
||||||
cocoapods: ctx.buildProfile.cocoapods,
|
cocoapods: buildProfile.cocoapods,
|
||||||
fastlane: ctx.buildProfile.fastlane,
|
fastlane: buildProfile.fastlane,
|
||||||
expoCli: ctx.buildProfile.expoCli,
|
expoCli: buildProfile.expoCli,
|
||||||
env: ctx.buildProfile.env,
|
env: buildProfile.env,
|
||||||
},
|
},
|
||||||
cache: {
|
cache: {
|
||||||
...cacheDefaults,
|
...cacheDefaults,
|
||||||
...ctx.buildProfile.cache,
|
...buildProfile.cache,
|
||||||
clear: ctx.clearCache,
|
clear: ctx.clearCache,
|
||||||
},
|
},
|
||||||
secrets: {
|
secrets: {
|
||||||
buildCredentials,
|
buildCredentials,
|
||||||
},
|
},
|
||||||
releaseChannel: ctx.buildProfile.releaseChannel,
|
releaseChannel: buildProfile.releaseChannel,
|
||||||
updates: { channel: ctx.buildProfile.channel },
|
updates: { channel: buildProfile.channel },
|
||||||
developmentClient: ctx.buildProfile.developmentClient,
|
developmentClient: buildProfile.developmentClient,
|
||||||
simulator: ctx.buildProfile.simulator,
|
simulator: buildProfile.simulator,
|
||||||
scheme: jobData.buildScheme,
|
scheme: jobData.buildScheme,
|
||||||
buildConfiguration: ctx.buildProfile.buildConfiguration,
|
buildConfiguration: buildProfile.buildConfiguration,
|
||||||
applicationArchivePath:
|
applicationArchivePath: buildProfile.applicationArchivePath ?? buildProfile.artifactPath,
|
||||||
ctx.buildProfile.applicationArchivePath ?? ctx.buildProfile.artifactPath,
|
buildArtifactPaths: buildProfile.buildArtifactPaths,
|
||||||
buildArtifactPaths: ctx.buildProfile.buildArtifactPaths,
|
|
||||||
username,
|
username,
|
||||||
...(ctx.ios.buildNumberOverride && {
|
...(ctx.ios.buildNumberOverride && {
|
||||||
version: {
|
version: {
|
||||||
@@ -83,10 +88,15 @@ export async function prepareJobAsync(
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
experimental: {
|
experimental: {
|
||||||
prebuildCommand: ctx.buildProfile.prebuildCommand,
|
prebuildCommand: buildProfile.prebuildCommand,
|
||||||
},
|
},
|
||||||
mode: BuildMode.BUILD,
|
mode: buildProfile.config ? BuildMode.CUSTOM : BuildMode.BUILD,
|
||||||
triggeredBy: BuildTrigger.EAS_CLI,
|
triggeredBy: BuildTrigger.EAS_CLI,
|
||||||
|
...(maybeCustomBuildConfigPath && {
|
||||||
|
customBuildConfig: {
|
||||||
|
path: maybeCustomBuildConfigPath,
|
||||||
|
},
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
return sanitizeJob(job);
|
return sanitizeJob(job);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Updates } from '@expo/config-plugins';
|
import { Updates } from '@expo/config-plugins';
|
||||||
import { Metadata, Platform, sanitizeMetadata } from '@expo/eas-build-job';
|
import { BuildMode, Metadata, Platform, sanitizeMetadata } from '@expo/eas-build-job';
|
||||||
import { IosEnterpriseProvisioning } from '@expo/eas-json';
|
import { IosEnterpriseProvisioning } from '@expo/eas-json';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import resolveFrom from 'resolve-from';
|
import resolveFrom from 'resolve-from';
|
||||||
@@ -57,6 +57,7 @@ export async function collectMetadataAsync<T extends Platform>(
|
|||||||
}),
|
}),
|
||||||
runWithNoWaitFlag: ctx.noWait,
|
runWithNoWaitFlag: ctx.noWait,
|
||||||
runFromCI: ctx.runFromCI,
|
runFromCI: ctx.runFromCI,
|
||||||
|
buildMode: ctx.buildProfile.config ? BuildMode.CUSTOM : BuildMode.BUILD,
|
||||||
};
|
};
|
||||||
return sanitizeMetadata(metadata);
|
return sanitizeMetadata(metadata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,10 +99,6 @@ export async function listAndSelectBuildOnAppAsync(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatBuildChoiceValue(value: string | undefined | null): string {
|
|
||||||
return value ? chalk.bold(value) : 'Unknown';
|
|
||||||
}
|
|
||||||
|
|
||||||
function createBuildToPartialChoiceMaker(
|
function createBuildToPartialChoiceMaker(
|
||||||
selectPromptDisabledFunction?: (build: BuildFragment) => boolean
|
selectPromptDisabledFunction?: (build: BuildFragment) => boolean
|
||||||
) {
|
) {
|
||||||
@@ -119,19 +115,34 @@ function createBuildToPartialChoiceMaker(
|
|||||||
? `${build.gitCommitHash.slice(0, 7)} "${chalk.bold(
|
? `${build.gitCommitHash.slice(0, 7)} "${chalk.bold(
|
||||||
splitCommitMessage[0] + (splitCommitMessage.length > 1 ? '…' : '')
|
splitCommitMessage[0] + (splitCommitMessage.length > 1 ? '…' : '')
|
||||||
)}"`
|
)}"`
|
||||||
: 'Unknown';
|
: null;
|
||||||
|
|
||||||
|
const descriptionItems: { name: string; value: string | null }[] = [
|
||||||
|
{ name: 'Version', value: build.appVersion ? chalk.bold(build.appVersion) : null },
|
||||||
|
{ name: 'Commit', value: formattedCommitData },
|
||||||
|
{
|
||||||
|
name: 'Message',
|
||||||
|
value: build.message
|
||||||
|
? chalk.bold(
|
||||||
|
build.message.length > 200 ? `${build.message.slice(0, 200)}...` : build.message
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: build.platform === AppPlatform.Ios ? 'Build number' : 'Version code',
|
||||||
|
value: build.appBuildVersion ? chalk.bold(build.appBuildVersion) : null,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const filteredDescriptionArray: string[] = descriptionItems
|
||||||
|
.filter(item => item.value)
|
||||||
|
.map(item => `${chalk.bold(item.name)}: ${item.value}`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: `${chalk.bold(`ID:`)} ${build.id} (${chalk.bold(
|
title: `${chalk.bold(`ID:`)} ${build.id} (${chalk.bold(
|
||||||
`${fromNow(new Date(build.completedAt))} ago`
|
`${fromNow(new Date(build.completedAt))} ago`
|
||||||
)})`,
|
)})`,
|
||||||
description: [
|
description: filteredDescriptionArray.length > 0 ? filteredDescriptionArray.join('\n') : '',
|
||||||
`\t${chalk.bold(`Version:`)} ${formatBuildChoiceValue(build.appVersion)}`,
|
|
||||||
`\t${chalk.bold(
|
|
||||||
build.platform === AppPlatform.Ios ? 'Build number:' : 'Version code:'
|
|
||||||
)} ${formatBuildChoiceValue(build.appBuildVersion)}`,
|
|
||||||
`\t${chalk.bold(`Commit:`)} ${formattedCommitData}`,
|
|
||||||
].join('\n'),
|
|
||||||
disabled: selectPromptDisabledFunction?.(build),
|
disabled: selectPromptDisabledFunction?.(build),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import {
|
|||||||
appPlatformEmojis,
|
appPlatformEmojis,
|
||||||
toPlatforms,
|
toPlatforms,
|
||||||
} from '../platform';
|
} from '../platform';
|
||||||
|
import { validateCustomBuildConfigAsync } from '../project/customBuildConfig';
|
||||||
import { checkExpoSdkIsSupportedAsync } from '../project/expoSdk';
|
import { checkExpoSdkIsSupportedAsync } from '../project/expoSdk';
|
||||||
import { validateMetroConfigForManagedWorkflowAsync } from '../project/metroConfig';
|
import { validateMetroConfigForManagedWorkflowAsync } from '../project/metroConfig';
|
||||||
import { validateAppVersionRuntimePolicySupportAsync } from '../project/projectUtils';
|
import { validateAppVersionRuntimePolicySupportAsync } from '../project/projectUtils';
|
||||||
@@ -98,7 +99,7 @@ export async function runBuildAndSubmitAsync(
|
|||||||
projectDir,
|
projectDir,
|
||||||
nonInteractive: flags.nonInteractive,
|
nonInteractive: flags.nonInteractive,
|
||||||
});
|
});
|
||||||
const easJsonAccessor = new EasJsonAccessor(projectDir);
|
const easJsonAccessor = EasJsonAccessor.fromProjectPath(projectDir);
|
||||||
const easJsonCliConfig: EasJson['cli'] =
|
const easJsonCliConfig: EasJson['cli'] =
|
||||||
(await EasJsonUtils.getCliConfigAsync(easJsonAccessor)) ?? {};
|
(await EasJsonUtils.getCliConfigAsync(easJsonAccessor)) ?? {};
|
||||||
|
|
||||||
@@ -118,6 +119,7 @@ export async function runBuildAndSubmitAsync(
|
|||||||
|
|
||||||
for (const buildProfile of buildProfiles) {
|
for (const buildProfile of buildProfiles) {
|
||||||
validateBuildProfileVersionSettings(buildProfile, easJsonCliConfig);
|
validateBuildProfileVersionSettings(buildProfile, easJsonCliConfig);
|
||||||
|
await validateCustomBuildConfigAsync(projectDir, buildProfile.profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
const startedBuilds: {
|
const startedBuilds: {
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ export function formatGraphQLBuild(build: BuildFragment): string {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Message',
|
||||||
|
value: build.message,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Distribution',
|
label: 'Distribution',
|
||||||
value: build.distribution?.toLowerCase(),
|
value: build.distribution?.toLowerCase(),
|
||||||
|
|||||||
@@ -15,6 +15,32 @@ import Log, { learnMore, link } from '../../log';
|
|||||||
import { appPlatformDisplayNames, appPlatformEmojis } from '../../platform';
|
import { appPlatformDisplayNames, appPlatformEmojis } from '../../platform';
|
||||||
import { getBuildLogsUrl, getInternalDistributionInstallUrl } from './url';
|
import { getBuildLogsUrl, getInternalDistributionInstallUrl } from './url';
|
||||||
|
|
||||||
|
function terminalLinkFallback(url: string, text: string): string {
|
||||||
|
return `${text} (${url})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const errorCodeToErrorMessageOverride: Record<string, (build: BuildFragment) => string> = {
|
||||||
|
EAS_BUILD_UNKNOWN_FASTLANE_ERROR: build =>
|
||||||
|
`The ${link(getBuildLogsUrl(build, 'run-fastlane'), {
|
||||||
|
text: '"Run fastlane"',
|
||||||
|
fallback: terminalLinkFallback(getBuildLogsUrl(build, 'run-fastlane'), '"Run fastlane"'),
|
||||||
|
})} step failed with an unknown error. Refer to the ${link(
|
||||||
|
getBuildLogsUrl(build, 'xcode-logs'),
|
||||||
|
{
|
||||||
|
text: '"Xcode logs"',
|
||||||
|
fallback: terminalLinkFallback(getBuildLogsUrl(build, 'xcode-logs'), '"Xcode logs"'),
|
||||||
|
}
|
||||||
|
)} phase for additional, more detailed logs`,
|
||||||
|
EAS_BUILD_UNKNOWN_GRADLE_ERROR: build =>
|
||||||
|
`Gradle build failed with unknown error. See logs for the ${link(
|
||||||
|
getBuildLogsUrl(build, 'run-gradlew'),
|
||||||
|
{
|
||||||
|
text: '"Run gradlew"',
|
||||||
|
fallback: terminalLinkFallback(getBuildLogsUrl(build, 'run-gradlew'), '"Run gradlew"'),
|
||||||
|
}
|
||||||
|
)} phase for more information.`,
|
||||||
|
};
|
||||||
|
|
||||||
export function printLogsUrls(builds: BuildFragment[]): void {
|
export function printLogsUrls(builds: BuildFragment[]): void {
|
||||||
if (builds.length === 1) {
|
if (builds.length === 1) {
|
||||||
Log.log(`Build details: ${link(getBuildLogsUrl(builds[0]))}`);
|
Log.log(`Build details: ${link(getBuildLogsUrl(builds[0]))}`);
|
||||||
@@ -31,7 +57,6 @@ export function printLogsUrls(builds: BuildFragment[]): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function printBuildResults(builds: (BuildFragment | null)[]): void {
|
export function printBuildResults(builds: (BuildFragment | null)[]): void {
|
||||||
Log.newLine();
|
|
||||||
if (builds.length === 1) {
|
if (builds.length === 1) {
|
||||||
const [build] = builds;
|
const [build] = builds;
|
||||||
assert(build, 'Build should be defined');
|
assert(build, 'Build should be defined');
|
||||||
@@ -42,8 +67,8 @@ export function printBuildResults(builds: (BuildFragment | null)[]): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function printBuildResult(build: BuildFragment): void {
|
function printBuildResult(build: BuildFragment): void {
|
||||||
Log.addNewLineIfNone();
|
|
||||||
if (build.status === BuildStatus.Errored) {
|
if (build.status === BuildStatus.Errored) {
|
||||||
|
Log.addNewLineIfNone();
|
||||||
const userError = build.error;
|
const userError = build.error;
|
||||||
Log.error(
|
Log.error(
|
||||||
`${appPlatformEmojis[build.platform]} ${
|
`${appPlatformEmojis[build.platform]} ${
|
||||||
@@ -51,11 +76,12 @@ function printBuildResult(build: BuildFragment): void {
|
|||||||
} build failed${userError ? ':' : ''}`
|
} build failed${userError ? ':' : ''}`
|
||||||
);
|
);
|
||||||
if (userError) {
|
if (userError) {
|
||||||
printUserError(userError);
|
printUserError(userError, build);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (build.status === BuildStatus.Canceled) {
|
if (build.status === BuildStatus.Canceled) {
|
||||||
|
Log.addNewLineIfNone();
|
||||||
Log.error(
|
Log.error(
|
||||||
`${appPlatformEmojis[build.platform]} ${
|
`${appPlatformEmojis[build.platform]} ${
|
||||||
appPlatformDisplayNames[build.platform]
|
appPlatformDisplayNames[build.platform]
|
||||||
@@ -65,6 +91,7 @@ function printBuildResult(build: BuildFragment): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (build.distribution === DistributionType.Internal) {
|
if (build.distribution === DistributionType.Internal) {
|
||||||
|
Log.addNewLineIfNone();
|
||||||
const logsUrl = getBuildLogsUrl(build);
|
const logsUrl = getBuildLogsUrl(build);
|
||||||
// It's tricky to install the .apk file directly on Android so let's fallback
|
// It's tricky to install the .apk file directly on Android so let's fallback
|
||||||
// to the build details page and let people press the button to download there
|
// to the build details page and let people press the button to download there
|
||||||
@@ -82,9 +109,14 @@ function printBuildResult(build: BuildFragment): void {
|
|||||||
} else {
|
} else {
|
||||||
// TODO: it looks like buildUrl could possibly be undefined, based on the code below.
|
// TODO: it looks like buildUrl could possibly be undefined, based on the code below.
|
||||||
// we should account for this case better if it is possible
|
// we should account for this case better if it is possible
|
||||||
const url = build.artifacts?.buildUrl ?? '';
|
const url = build.artifacts?.buildUrl;
|
||||||
Log.log(`${appPlatformEmojis[build.platform]} ${appPlatformDisplayNames[build.platform]} app:`);
|
if (url) {
|
||||||
Log.log(`${link(url)}`);
|
Log.addNewLineIfNone();
|
||||||
|
Log.log(
|
||||||
|
`${appPlatformEmojis[build.platform]} ${appPlatformDisplayNames[build.platform]} app:`
|
||||||
|
);
|
||||||
|
Log.log(link(url));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,9 +137,22 @@ export function printDeprecationWarnings(deprecationInfo?: EasBuildDeprecationIn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function printUserError(error: BuildError): void {
|
export function printUserError(error: BuildError, build: BuildFragment): void {
|
||||||
Log.error(error.message);
|
const maybeErrorMessageOverride = maybeGetErrorMessageOverride(error, build);
|
||||||
if (error.docsUrl) {
|
if (maybeErrorMessageOverride) {
|
||||||
Log.error(learnMore(error.docsUrl, { dim: false }));
|
Log.error(maybeErrorMessageOverride);
|
||||||
|
} else {
|
||||||
|
Log.error(error.message);
|
||||||
|
if (error.docsUrl) {
|
||||||
|
Log.error(learnMore(error.docsUrl, { dim: false }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function maybeGetErrorMessageOverride(error: BuildError, build: BuildFragment): string | null {
|
||||||
|
if (!(error.errorCode in errorCodeToErrorMessageOverride)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return errorCodeToErrorMessageOverride[error.errorCode](build);
|
||||||
|
}
|
||||||
@@ -8,24 +8,30 @@ import { BuildResourceClass } from '../../graphql/generated';
|
|||||||
import Log from '../../log';
|
import Log from '../../log';
|
||||||
import { getReactNativeVersionAsync } from '../metadata';
|
import { getReactNativeVersionAsync } from '../metadata';
|
||||||
|
|
||||||
|
type AndroidResourceClass = Exclude<
|
||||||
|
ResourceClass,
|
||||||
|
| ResourceClass.M1_EXPERIMENTAL
|
||||||
|
| ResourceClass.M1_MEDIUM
|
||||||
|
| ResourceClass.M1_LARGE
|
||||||
|
| ResourceClass.INTEL_MEDIUM
|
||||||
|
| ResourceClass.M_MEDIUM
|
||||||
|
| ResourceClass.M_LARGE
|
||||||
|
>;
|
||||||
|
|
||||||
const iosResourceClassToBuildResourceClassMapping: Record<ResourceClass, BuildResourceClass> = {
|
const iosResourceClassToBuildResourceClassMapping: Record<ResourceClass, BuildResourceClass> = {
|
||||||
[ResourceClass.DEFAULT]: BuildResourceClass.IosDefault,
|
[ResourceClass.DEFAULT]: BuildResourceClass.IosDefault,
|
||||||
[ResourceClass.LARGE]: BuildResourceClass.IosLarge,
|
[ResourceClass.LARGE]: BuildResourceClass.IosLarge,
|
||||||
[ResourceClass.M1_EXPERIMENTAL]: BuildResourceClass.IosM1Large,
|
[ResourceClass.M1_EXPERIMENTAL]: BuildResourceClass.IosMMedium,
|
||||||
[ResourceClass.M1_MEDIUM]: BuildResourceClass.IosM1Medium,
|
[ResourceClass.M1_MEDIUM]: BuildResourceClass.IosMMedium,
|
||||||
[ResourceClass.M1_LARGE]: BuildResourceClass.IosM1Large,
|
[ResourceClass.M1_LARGE]: BuildResourceClass.IosMLarge,
|
||||||
[ResourceClass.INTEL_MEDIUM]: BuildResourceClass.IosIntelMedium,
|
[ResourceClass.INTEL_MEDIUM]: BuildResourceClass.IosIntelMedium,
|
||||||
[ResourceClass.MEDIUM]: BuildResourceClass.IosMedium,
|
[ResourceClass.MEDIUM]: BuildResourceClass.IosMedium,
|
||||||
|
[ResourceClass.M_MEDIUM]: BuildResourceClass.IosMMedium,
|
||||||
|
[ResourceClass.M_LARGE]: BuildResourceClass.IosMLarge,
|
||||||
};
|
};
|
||||||
|
|
||||||
const androidResourceClassToBuildResourceClassMapping: Record<
|
const androidResourceClassToBuildResourceClassMapping: Record<
|
||||||
Exclude<
|
AndroidResourceClass,
|
||||||
ResourceClass,
|
|
||||||
| ResourceClass.M1_EXPERIMENTAL
|
|
||||||
| ResourceClass.M1_MEDIUM
|
|
||||||
| ResourceClass.M1_LARGE
|
|
||||||
| ResourceClass.INTEL_MEDIUM
|
|
||||||
>,
|
|
||||||
BuildResourceClass
|
BuildResourceClass
|
||||||
> = {
|
> = {
|
||||||
[ResourceClass.DEFAULT]: BuildResourceClass.AndroidDefault,
|
[ResourceClass.DEFAULT]: BuildResourceClass.AndroidDefault,
|
||||||
@@ -70,15 +76,7 @@ function resolveAndroidResourceClass(selectedResourceClass?: ResourceClass): Bui
|
|||||||
|
|
||||||
const resourceClass = selectedResourceClass ?? ResourceClass.DEFAULT;
|
const resourceClass = selectedResourceClass ?? ResourceClass.DEFAULT;
|
||||||
|
|
||||||
return androidResourceClassToBuildResourceClassMapping[
|
return androidResourceClassToBuildResourceClassMapping[resourceClass as AndroidResourceClass];
|
||||||
resourceClass as Exclude<
|
|
||||||
ResourceClass,
|
|
||||||
| ResourceClass.M1_EXPERIMENTAL
|
|
||||||
| ResourceClass.M1_MEDIUM
|
|
||||||
| ResourceClass.M1_LARGE
|
|
||||||
| ResourceClass.INTEL_MEDIUM
|
|
||||||
>
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resolveIosResourceClassAsync(
|
async function resolveIosResourceClassAsync(
|
||||||
@@ -89,8 +87,20 @@ async function resolveIosResourceClassAsync(
|
|||||||
const resourceClass =
|
const resourceClass =
|
||||||
selectedResourceClass ?? (await resolveIosDefaultRequestedResourceClassAsync(exp, projectDir));
|
selectedResourceClass ?? (await resolveIosDefaultRequestedResourceClassAsync(exp, projectDir));
|
||||||
|
|
||||||
if (resourceClass === ResourceClass.M1_EXPERIMENTAL) {
|
if ([ResourceClass.M1_EXPERIMENTAL, ResourceClass.M1_MEDIUM].includes(resourceClass)) {
|
||||||
Log.warn(`Resource class ${chalk.bold('m1-experimental')} is deprecated.`);
|
Log.warn(
|
||||||
|
`Resource class ${chalk.bold(resourceClass)} is deprecated. Use ${chalk.bold(
|
||||||
|
'm-medium'
|
||||||
|
)} instead.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resourceClass === ResourceClass.M1_LARGE) {
|
||||||
|
Log.warn(
|
||||||
|
`Resource class ${chalk.bold('m1-large')} is deprecated. Use ${chalk.bold(
|
||||||
|
'm-large'
|
||||||
|
)} instead.`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return iosResourceClassToBuildResourceClassMapping[resourceClass];
|
return iosResourceClassToBuildResourceClassMapping[resourceClass];
|
||||||
@@ -106,7 +116,7 @@ async function resolveIosDefaultRequestedResourceClassAsync(
|
|||||||
(sdkVersion && semver.satisfies(sdkVersion, '>=48')) ||
|
(sdkVersion && semver.satisfies(sdkVersion, '>=48')) ||
|
||||||
(reactNativeVersion && semver.satisfies(reactNativeVersion, '>=0.71.0'))
|
(reactNativeVersion && semver.satisfies(reactNativeVersion, '>=0.71.0'))
|
||||||
) {
|
) {
|
||||||
return ResourceClass.M1_MEDIUM;
|
return ResourceClass.M_MEDIUM;
|
||||||
} else {
|
} else {
|
||||||
return ResourceClass.DEFAULT;
|
return ResourceClass.DEFAULT;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,14 @@ export function getProjectDashboardUrl(accountName: string, projectName: string)
|
|||||||
).toString();
|
).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBuildLogsUrl(build: BuildFragment): string {
|
export function getBuildLogsUrl(build: BuildFragment, hash?: string): string {
|
||||||
const { project } = build;
|
const { project } = build;
|
||||||
const url =
|
const url =
|
||||||
project.__typename !== 'App'
|
project.__typename !== 'App'
|
||||||
? `/builds/${build.id}`
|
? `/builds/${build.id}`
|
||||||
: `/accounts/${project.ownerAccount.name}/projects/${project.slug}/builds/${build.id}`;
|
: `/accounts/${project.ownerAccount.name}/projects/${project.slug}/builds/${build.id}${
|
||||||
|
hash ? `#${hash}` : ''
|
||||||
|
}`;
|
||||||
|
|
||||||
return new URL(url, getExpoWebsiteBaseUrl()).toString();
|
return new URL(url, getExpoWebsiteBaseUrl()).toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Command } from '@oclif/core';
|
import { Command } from '@oclif/core';
|
||||||
|
import { CombinedError } from '@urql/core';
|
||||||
import nullthrows from 'nullthrows';
|
import nullthrows from 'nullthrows';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -6,6 +7,7 @@ import {
|
|||||||
CommandEvent,
|
CommandEvent,
|
||||||
createAnalyticsAsync,
|
createAnalyticsAsync,
|
||||||
} from '../analytics/AnalyticsManager';
|
} from '../analytics/AnalyticsManager';
|
||||||
|
import Log from '../log';
|
||||||
import SessionManager from '../user/SessionManager';
|
import SessionManager from '../user/SessionManager';
|
||||||
import AnalyticsContextField from './context/AnalyticsContextField';
|
import AnalyticsContextField from './context/AnalyticsContextField';
|
||||||
import ContextField from './context/ContextField';
|
import ContextField from './context/ContextField';
|
||||||
@@ -16,6 +18,7 @@ import { OptionalProjectConfigContextField } from './context/OptionalProjectConf
|
|||||||
import ProjectConfigContextField from './context/ProjectConfigContextField';
|
import ProjectConfigContextField from './context/ProjectConfigContextField';
|
||||||
import ProjectDirContextField from './context/ProjectDirContextField';
|
import ProjectDirContextField from './context/ProjectDirContextField';
|
||||||
import SessionManagementContextField from './context/SessionManagementContextField';
|
import SessionManagementContextField from './context/SessionManagementContextField';
|
||||||
|
import { EasCommandError } from './errors';
|
||||||
|
|
||||||
type ContextInput<
|
type ContextInput<
|
||||||
T extends {
|
T extends {
|
||||||
@@ -33,6 +36,8 @@ type ContextOutput<
|
|||||||
[P in keyof T]: T[P];
|
[P in keyof T]: T[P];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const BASE_GRAPHQL_ERROR_MESSAGE: string = 'GraphQL request failed.';
|
||||||
|
|
||||||
export default abstract class EasCommand extends Command {
|
export default abstract class EasCommand extends Command {
|
||||||
protected static readonly ContextOptions = {
|
protected static readonly ContextOptions = {
|
||||||
/**
|
/**
|
||||||
@@ -103,6 +108,18 @@ export default abstract class EasCommand extends Command {
|
|||||||
*/
|
*/
|
||||||
static contextDefinition: ContextInput = {};
|
static contextDefinition: ContextInput = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The user session manager. Responsible for coordinating all user session related state.
|
||||||
|
* If needed in a subclass, use the SessionManager ContextOption.
|
||||||
|
*/
|
||||||
|
private sessionManagerInternal?: SessionManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The analytics manager. Used for logging analytics.
|
||||||
|
* It is set up here to ensure a consistent setup.
|
||||||
|
*/
|
||||||
|
private analyticsInternal?: AnalyticsWithOrchestration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the context in the contextDefinition to satisfy command prerequisites.
|
* Execute the context in the contextDefinition to satisfy command prerequisites.
|
||||||
*/
|
*/
|
||||||
@@ -132,20 +149,10 @@ export default abstract class EasCommand extends Command {
|
|||||||
return Object.fromEntries(contextValuePairs);
|
return Object.fromEntries(contextValuePairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The user session manager. Responsible for coordinating all user session related state.
|
|
||||||
* If needed in a subclass, use the SessionManager ContextOption.
|
|
||||||
*/
|
|
||||||
private sessionManagerInternal?: SessionManager;
|
|
||||||
private get sessionManager(): SessionManager {
|
private get sessionManager(): SessionManager {
|
||||||
return nullthrows(this.sessionManagerInternal);
|
return nullthrows(this.sessionManagerInternal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The analytics manager. Used for logging analytics.
|
|
||||||
* It is set up here to ensure a consistent set up.
|
|
||||||
*/
|
|
||||||
private analyticsInternal?: AnalyticsWithOrchestration;
|
|
||||||
private get analytics(): AnalyticsWithOrchestration {
|
private get analytics(): AnalyticsWithOrchestration {
|
||||||
return nullthrows(this.analyticsInternal);
|
return nullthrows(this.analyticsInternal);
|
||||||
}
|
}
|
||||||
@@ -175,4 +182,19 @@ export default abstract class EasCommand extends Command {
|
|||||||
await this.analytics.flushAsync();
|
await this.analytics.flushAsync();
|
||||||
return super.finally(err);
|
return super.finally(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override catch(err: Error): Promise<any> {
|
||||||
|
let baseMessage = `${this.id} command failed.`;
|
||||||
|
if (err instanceof EasCommandError) {
|
||||||
|
Log.error(err.message);
|
||||||
|
} else if (err instanceof CombinedError && err?.graphQLErrors) {
|
||||||
|
const cleanMessage = err.message.replace('[GraphQL] ', '');
|
||||||
|
Log.error(cleanMessage);
|
||||||
|
baseMessage = BASE_GRAPHQL_ERROR_MESSAGE;
|
||||||
|
} else {
|
||||||
|
Log.error(err.message);
|
||||||
|
}
|
||||||
|
Log.debug(err);
|
||||||
|
throw new Error(baseMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
|
import { CombinedError } from '@urql/core';
|
||||||
|
|
||||||
import { AnalyticsWithOrchestration, createAnalyticsAsync } from '../../analytics/AnalyticsManager';
|
import { AnalyticsWithOrchestration, createAnalyticsAsync } from '../../analytics/AnalyticsManager';
|
||||||
|
import Log from '../../log';
|
||||||
import SessionManager from '../../user/SessionManager';
|
import SessionManager from '../../user/SessionManager';
|
||||||
import EasCommand from '../EasCommand';
|
import EasCommand from '../EasCommand';
|
||||||
|
|
||||||
@@ -11,6 +14,7 @@ jest.mock('../../analytics/AnalyticsManager', () => {
|
|||||||
createAnalyticsAsync: jest.fn(),
|
createAnalyticsAsync: jest.fn(),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
jest.mock('../../log');
|
||||||
|
|
||||||
let originalProcessArgv: string[];
|
let originalProcessArgv: string[];
|
||||||
|
|
||||||
@@ -40,7 +44,7 @@ const createTestEasCommand = (): typeof EasCommand => {
|
|||||||
async runAsync(): Promise<void> {}
|
async runAsync(): Promise<void> {}
|
||||||
}
|
}
|
||||||
|
|
||||||
TestEasCommand.id = 'TestEasCommand'; // normally oclif will assign ids, but b/c this is located outside the commands folder it will not
|
TestEasCommand.id = 'testEasCommand'; // normally oclif will assign ids, but b/c this is located outside the commands folder it will not
|
||||||
return TestEasCommand;
|
return TestEasCommand;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -96,5 +100,71 @@ describe(EasCommand.name, () => {
|
|||||||
|
|
||||||
expect(analytics.flushAsync).toHaveBeenCalled();
|
expect(analytics.flushAsync).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('catch', () => {
|
||||||
|
it('logs the message', async () => {
|
||||||
|
const TestEasCommand = createTestEasCommand();
|
||||||
|
const logErrorSpy = jest.spyOn(Log, 'error');
|
||||||
|
const logDebugSpy = jest.spyOn(Log, 'debug');
|
||||||
|
const runAsyncMock = jest.spyOn(TestEasCommand.prototype as any, 'runAsync');
|
||||||
|
const error = new Error('Unexpected, internal error message');
|
||||||
|
runAsyncMock.mockImplementation(() => {
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await TestEasCommand.run();
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
expect(logErrorSpy).toBeCalledWith('Unexpected, internal error message');
|
||||||
|
expect(logDebugSpy).toBeCalledWith(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('logs the cleaned message if needed', async () => {
|
||||||
|
const TestEasCommand = createTestEasCommand();
|
||||||
|
const logErrorSpy = jest.spyOn(Log, 'error');
|
||||||
|
const logDebugSpy = jest.spyOn(Log, 'debug');
|
||||||
|
const runAsyncMock = jest.spyOn(TestEasCommand.prototype as any, 'runAsync');
|
||||||
|
const graphQLErrors = ['Unexpected GraphQL error message'];
|
||||||
|
const error = new CombinedError({ graphQLErrors });
|
||||||
|
runAsyncMock.mockImplementation(() => {
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await TestEasCommand.run();
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
expect(logErrorSpy).toBeCalledWith('Unexpected GraphQL error message');
|
||||||
|
expect(logDebugSpy).toBeCalledWith(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('re-throws the error with default base message', async () => {
|
||||||
|
const TestEasCommand = createTestEasCommand();
|
||||||
|
const runAsyncMock = jest.spyOn(TestEasCommand.prototype as any, 'runAsync');
|
||||||
|
runAsyncMock.mockImplementation(() => {
|
||||||
|
throw new Error('Error message');
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await TestEasCommand.run();
|
||||||
|
} catch (caughtError) {
|
||||||
|
expect(caughtError).toBeInstanceOf(Error);
|
||||||
|
expect((caughtError as Error).message).toEqual('testEasCommand command failed.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('re-throws the error with a different default base message in case of graphQLError', async () => {
|
||||||
|
const TestEasCommand = createTestEasCommand();
|
||||||
|
const runAsyncMock = jest.spyOn(TestEasCommand.prototype as any, 'runAsync');
|
||||||
|
runAsyncMock.mockImplementation(() => {
|
||||||
|
const graphQLErrors = ['Unexpected GraphQL error message'];
|
||||||
|
throw new CombinedError({ graphQLErrors });
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await TestEasCommand.run();
|
||||||
|
} catch (caughtError) {
|
||||||
|
expect(caughtError).toBeInstanceOf(Error);
|
||||||
|
expect((caughtError as Error).message).toEqual('GraphQL request failed.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -16,8 +16,8 @@ export class DynamicProjectConfigContextField extends ContextField<DynamicConfig
|
|||||||
nonInteractive,
|
nonInteractive,
|
||||||
sessionManager,
|
sessionManager,
|
||||||
}: ContextOptions): Promise<DynamicConfigContextFn> {
|
}: ContextOptions): Promise<DynamicConfigContextFn> {
|
||||||
|
const projectDir = await findProjectDirAndVerifyProjectSetupAsync();
|
||||||
return async (options?: ExpoConfigOptions) => {
|
return async (options?: ExpoConfigOptions) => {
|
||||||
const projectDir = await findProjectDirAndVerifyProjectSetupAsync();
|
|
||||||
const expBefore = getExpoConfig(projectDir, options);
|
const expBefore = getExpoConfig(projectDir, options);
|
||||||
const projectId = await getProjectIdAsync(sessionManager, expBefore, {
|
const projectId = await getProjectIdAsync(sessionManager, expBefore, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
|
|||||||
+95
-2
@@ -15,7 +15,6 @@ jest.mock('fs');
|
|||||||
|
|
||||||
jest.mock('../../../../graphql/queries/AppQuery');
|
jest.mock('../../../../graphql/queries/AppQuery');
|
||||||
jest.mock('../../contextUtils/findProjectDirAndVerifyProjectSetupAsync');
|
jest.mock('../../contextUtils/findProjectDirAndVerifyProjectSetupAsync');
|
||||||
jest.mock('../../../../user/User');
|
|
||||||
jest.mock('../../../../ora', () => ({
|
jest.mock('../../../../ora', () => ({
|
||||||
ora: () => ({
|
ora: () => ({
|
||||||
start: () => ({ succeed: () => {}, fail: () => {} }),
|
start: () => ({ succeed: () => {}, fail: () => {} }),
|
||||||
@@ -107,7 +106,79 @@ describe(getProjectIdAsync, () => {
|
|||||||
{ nonInteractive: false }
|
{ nonInteractive: false }
|
||||||
)
|
)
|
||||||
).rejects.toThrow(
|
).rejects.toThrow(
|
||||||
`Project config: Project identified by "extra.eas.projectId" (notnotbrent) is not owned by owner specified in the "owner" field (wat). ${learnMore(
|
`Project config: Owner of project identified by "extra.eas.projectId" (notnotbrent) does not match owner specified in the "owner" field (wat). ${learnMore(
|
||||||
|
'https://expo.fyi/eas-project-id'
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('throws when the owner is not specified and is different than logged in user', async () => {
|
||||||
|
jest.mocked(getConfig).mockReturnValue({
|
||||||
|
exp: { name: 'test', slug: 'test', extra: { eas: { projectId: '1234' } } },
|
||||||
|
} as any);
|
||||||
|
jest.mocked(AppQuery.byIdAsync).mockResolvedValue({
|
||||||
|
id: '1234',
|
||||||
|
fullName: '@totallybrent/test',
|
||||||
|
slug: 'test',
|
||||||
|
ownerAccount: { name: 'totallybrent' } as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
getProjectIdAsync(
|
||||||
|
sessionManager,
|
||||||
|
{ name: 'test', slug: 'test', extra: { eas: { projectId: '1234' } } },
|
||||||
|
{ nonInteractive: false }
|
||||||
|
)
|
||||||
|
).rejects.toThrow(
|
||||||
|
`Project config: Owner of project identified by "extra.eas.projectId" (totallybrent) does not match the logged in user (notnotbrent) and the "owner" field is not specified. To ensure all libraries work correctly, "owner": "totallybrent" should be added to the project config, which can be done automatically by re-running "eas init". ${learnMore(
|
||||||
|
'https://expo.fyi/eas-project-id'
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('throws when the owner is not specified and is different than logged in user which is a robot', async () => {
|
||||||
|
const sessionManagerMock = mock<SessionManager>();
|
||||||
|
when(sessionManagerMock.ensureLoggedInAsync(anything())).thenResolve({
|
||||||
|
actor: {
|
||||||
|
__typename: 'Robot',
|
||||||
|
id: 'robot_id',
|
||||||
|
accounts: [
|
||||||
|
{
|
||||||
|
id: 'account_id_1',
|
||||||
|
name: 'notnotbrent',
|
||||||
|
users: [{ role: Role.Admin, actor: { id: 'robot_id' } }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'account_id_2',
|
||||||
|
name: 'dominik',
|
||||||
|
users: [{ role: Role.ViewOnly, actor: { id: 'robot_id' } }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
isExpoAdmin: false,
|
||||||
|
featureGates: {},
|
||||||
|
},
|
||||||
|
authenticationInfo: { accessToken: 'fake', sessionSecret: null },
|
||||||
|
});
|
||||||
|
const sessionManagerRobot = instance(sessionManagerMock);
|
||||||
|
|
||||||
|
jest.mocked(getConfig).mockReturnValue({
|
||||||
|
exp: { name: 'test', slug: 'test', extra: { eas: { projectId: '1234' } } },
|
||||||
|
} as any);
|
||||||
|
jest.mocked(AppQuery.byIdAsync).mockResolvedValue({
|
||||||
|
id: '1234',
|
||||||
|
fullName: '@totallybrent/test',
|
||||||
|
slug: 'test',
|
||||||
|
ownerAccount: { name: 'totallybrent' } as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
getProjectIdAsync(
|
||||||
|
sessionManagerRobot,
|
||||||
|
{ name: 'test', slug: 'test', extra: { eas: { projectId: '1234' } } },
|
||||||
|
{ nonInteractive: false }
|
||||||
|
)
|
||||||
|
).rejects.toThrow(
|
||||||
|
`Project config: Owner of project identified by "extra.eas.projectId" (totallybrent) must be specified in "owner" field when using a robot access token. To ensure all libraries work correctly, "owner": "totallybrent" should be added to the project config, which can be done automatically by re-running "eas init". ${learnMore(
|
||||||
'https://expo.fyi/eas-project-id'
|
'https://expo.fyi/eas-project-id'
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
@@ -181,4 +252,26 @@ describe(getProjectIdAsync, () => {
|
|||||||
getProjectIdAsync(sessionManager, { name: 'test', slug: 'test' }, { nonInteractive: false })
|
getProjectIdAsync(sessionManager, { name: 'test', slug: 'test' }, { nonInteractive: false })
|
||||||
).rejects.toThrow();
|
).rejects.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('throws if extra.eas.projectId is not a string', async () => {
|
||||||
|
jest.mocked(getConfig).mockReturnValue({
|
||||||
|
exp: { name: 'test', slug: 'test', extra: { eas: { projectId: 1234 } } },
|
||||||
|
} as any);
|
||||||
|
jest.mocked(AppQuery.byIdAsync).mockResolvedValue({
|
||||||
|
id: '1234',
|
||||||
|
fullName: '@notnotbrent/test',
|
||||||
|
slug: 'test',
|
||||||
|
ownerAccount: { name: 'notnotbrent' } as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
getProjectIdAsync(
|
||||||
|
sessionManager,
|
||||||
|
{ name: 'test', slug: 'wat', extra: { eas: { projectId: 1234 } } },
|
||||||
|
{ nonInteractive: false }
|
||||||
|
)
|
||||||
|
).rejects.toThrow(
|
||||||
|
`Project config: "extra.eas.projectId" must be a string, found number. If you're not sure how to set it up on your own, remove the property entirely and it will be automatically configured on the next EAS CLI run.`
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
+1
-1
@@ -12,7 +12,7 @@ import { getVcsClient, setVcsClient } from '../../../vcs';
|
|||||||
import GitClient from '../../../vcs/clients/git';
|
import GitClient from '../../../vcs/clients/git';
|
||||||
|
|
||||||
async function applyCliConfigAsync(projectDir: string): Promise<void> {
|
async function applyCliConfigAsync(projectDir: string): Promise<void> {
|
||||||
const easJsonAccessor = new EasJsonAccessor(projectDir);
|
const easJsonAccessor = EasJsonAccessor.fromProjectPath(projectDir);
|
||||||
const config = await EasJsonUtils.getCliConfigAsync(easJsonAccessor);
|
const config = await EasJsonUtils.getCliConfigAsync(easJsonAccessor);
|
||||||
if (config?.version && !semver.satisfies(easCliVersion, config.version)) {
|
if (config?.version && !semver.satisfies(easCliVersion, config.version)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { getExpoConfig } from '../../../project/expoConfig';
|
|||||||
import { fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync } from '../../../project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync';
|
import { fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync } from '../../../project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync';
|
||||||
import { toAppPrivacy } from '../../../project/projectUtils';
|
import { toAppPrivacy } from '../../../project/projectUtils';
|
||||||
import SessionManager from '../../../user/SessionManager';
|
import SessionManager from '../../../user/SessionManager';
|
||||||
import { Actor } from '../../../user/User';
|
import { Actor, getActorUsername } from '../../../user/User';
|
||||||
import { createGraphqlClient } from './createGraphqlClient';
|
import { createGraphqlClient } from './createGraphqlClient';
|
||||||
import { findProjectRootAsync } from './findProjectDirAndVerifyProjectSetupAsync';
|
import { findProjectRootAsync } from './findProjectDirAndVerifyProjectSetupAsync';
|
||||||
|
|
||||||
@@ -89,18 +89,50 @@ export async function getProjectIdAsync(
|
|||||||
|
|
||||||
const localProjectId = exp.extra?.eas?.projectId;
|
const localProjectId = exp.extra?.eas?.projectId;
|
||||||
if (localProjectId) {
|
if (localProjectId) {
|
||||||
|
if (typeof localProjectId !== 'string') {
|
||||||
|
throw new Error(
|
||||||
|
`Project config: "extra.eas.projectId" must be a string, found ${typeof localProjectId}. If you're not sure how to set it up on your own, remove the property entirely and it will be automatically configured on the next EAS CLI run.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// check that the local project ID matches account and slug
|
// check that the local project ID matches account and slug
|
||||||
const appForProjectId = await AppQuery.byIdAsync(graphqlClient, localProjectId);
|
const appForProjectId = await AppQuery.byIdAsync(graphqlClient, localProjectId);
|
||||||
if (exp.owner && exp.owner !== appForProjectId.ownerAccount.name) {
|
if (exp.owner && exp.owner !== appForProjectId.ownerAccount.name) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Project config: Project identified by "extra.eas.projectId" (${
|
`Project config: Owner of project identified by "extra.eas.projectId" (${
|
||||||
appForProjectId.ownerAccount.name
|
appForProjectId.ownerAccount.name
|
||||||
}) is not owned by owner specified in the "owner" field (${exp.owner}). ${learnMore(
|
}) does not match owner specified in the "owner" field (${exp.owner}). ${learnMore(
|
||||||
'https://expo.fyi/eas-project-id'
|
'https://expo.fyi/eas-project-id'
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const actorUsername = getActorUsername(actor);
|
||||||
|
if (!exp.owner && appForProjectId.ownerAccount.name !== actorUsername) {
|
||||||
|
if (actorUsername) {
|
||||||
|
throw new Error(
|
||||||
|
`Project config: Owner of project identified by "extra.eas.projectId" (${
|
||||||
|
appForProjectId.ownerAccount.name
|
||||||
|
}) does not match the logged in user (${actorUsername}) and the "owner" field is not specified. To ensure all libraries work correctly, "owner": "${
|
||||||
|
appForProjectId.ownerAccount.name
|
||||||
|
}" should be added to the project config, which can be done automatically by re-running "eas init". ${learnMore(
|
||||||
|
'https://expo.fyi/eas-project-id'
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// robot caller
|
||||||
|
throw new Error(
|
||||||
|
`Project config: Owner of project identified by "extra.eas.projectId" (${
|
||||||
|
appForProjectId.ownerAccount.name
|
||||||
|
}) must be specified in "owner" field when using a robot access token. To ensure all libraries work correctly, "owner": "${
|
||||||
|
appForProjectId.ownerAccount.name
|
||||||
|
}" should be added to the project config, which can be done automatically by re-running "eas init". ${learnMore(
|
||||||
|
'https://expo.fyi/eas-project-id'
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (exp.slug && exp.slug !== appForProjectId.slug) {
|
if (exp.slug && exp.slug !== appForProjectId.slug) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Project config: Slug for project identified by "extra.eas.projectId" (${
|
`Project config: Slug for project identified by "extra.eas.projectId" (${
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export class EasCommandError extends Error {
|
||||||
|
// constructor is not useless, since the constructor for Error allows for optional `message`
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
||||||
|
constructor(message: string) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -227,6 +227,13 @@ export default class Build extends EasCommand {
|
|||||||
});
|
});
|
||||||
} else if (process.platform !== 'darwin' && requestedPlatform === RequestedPlatform.Ios) {
|
} else if (process.platform !== 'darwin' && requestedPlatform === RequestedPlatform.Ios) {
|
||||||
Errors.error('Unsupported platform, macOS is required to build apps for iOS', { exit: 1 });
|
Errors.error('Unsupported platform, macOS is required to build apps for iOS', { exit: 1 });
|
||||||
|
} else if (
|
||||||
|
!['linux', 'darwin'].includes(process.platform) &&
|
||||||
|
requestedPlatform === RequestedPlatform.Android
|
||||||
|
) {
|
||||||
|
Errors.error('Unsupported platform, macOS or Linux is required to build apps for Android', {
|
||||||
|
exit: 1,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +251,7 @@ export async function handleDeprecatedEasJsonAsync(
|
|||||||
if (!(await fs.pathExists(EasJsonAccessor.formatEasJsonPath(projectDir)))) {
|
if (!(await fs.pathExists(EasJsonAccessor.formatEasJsonPath(projectDir)))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const easJsonAccessor = new EasJsonAccessor(projectDir);
|
const easJsonAccessor = EasJsonAccessor.fromProjectPath(projectDir);
|
||||||
const profileNames = await EasJsonUtils.getBuildProfileNamesAsync(easJsonAccessor);
|
const profileNames = await EasJsonUtils.getBuildProfileNamesAsync(easJsonAccessor);
|
||||||
const platformAndProfileNames: [Platform, string][] = profileNames.flatMap(profileName => [
|
const platformAndProfileNames: [Platform, string][] = profileNames.flatMap(profileName => [
|
||||||
[Platform.ANDROID, profileName],
|
[Platform.ANDROID, profileName],
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import { runBuildAndSubmitAsync } from '../../build/runBuildAndSubmit';
|
|||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
import { RequestedPlatform } from '../../platform';
|
import { RequestedPlatform } from '../../platform';
|
||||||
import { enableJsonOutput } from '../../utils/json';
|
import { enableJsonOutput } from '../../utils/json';
|
||||||
|
import { setVcsClient } from '../../vcs';
|
||||||
|
import GitNoCommitClient from '../../vcs/clients/gitNoCommit';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This command will be run on the EAS Build workers, when building
|
* This command will be run on the EAS Build workers, when building
|
||||||
@@ -51,6 +53,8 @@ export default class BuildInternal extends EasCommand {
|
|||||||
nonInteractive: true,
|
nonInteractive: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setVcsClient(new GitNoCommitClient());
|
||||||
|
|
||||||
await handleDeprecatedEasJsonAsync(projectDir, flags.nonInteractive);
|
await handleDeprecatedEasJsonAsync(projectDir, flags.nonInteractive);
|
||||||
|
|
||||||
await runBuildAndSubmitAsync(
|
await runBuildAndSubmitAsync(
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ export default class BuildResign extends EasCommand {
|
|||||||
await handleDeprecatedEasJsonAsync(projectDir, flags.nonInteractive);
|
await handleDeprecatedEasJsonAsync(projectDir, flags.nonInteractive);
|
||||||
|
|
||||||
await maybeWarnAboutEasOutagesAsync(graphqlClient, [StatuspageServiceName.EasBuild]);
|
await maybeWarnAboutEasOutagesAsync(graphqlClient, [StatuspageServiceName.EasBuild]);
|
||||||
const easJsonAccessor = new EasJsonAccessor(projectDir);
|
const easJsonAccessor = EasJsonAccessor.fromProjectPath(projectDir);
|
||||||
const easJsonCliConfig: EasJson['cli'] =
|
const easJsonCliConfig: EasJson['cli'] =
|
||||||
(await EasJsonUtils.getCliConfigAsync(easJsonAccessor)) ?? {};
|
(await EasJsonUtils.getCliConfigAsync(easJsonAccessor)) ?? {};
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export default class BuildVersionSetView extends EasCommand {
|
|||||||
public async runAsync(): Promise<void> {
|
public async runAsync(): Promise<void> {
|
||||||
const { flags } = await this.parse(BuildVersionSetView);
|
const { flags } = await this.parse(BuildVersionSetView);
|
||||||
const {
|
const {
|
||||||
loggedIn: { actor, graphqlClient },
|
loggedIn: { graphqlClient },
|
||||||
getDynamicProjectConfigAsync,
|
getDynamicProjectConfigAsync,
|
||||||
projectDir,
|
projectDir,
|
||||||
} = await this.getContextAsync(BuildVersionSetView, {
|
} = await this.getContextAsync(BuildVersionSetView, {
|
||||||
@@ -54,7 +54,7 @@ export default class BuildVersionSetView extends EasCommand {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const platform = await selectPlatformAsync(flags.platform);
|
const platform = await selectPlatformAsync(flags.platform);
|
||||||
const easJsonAccessor = new EasJsonAccessor(projectDir);
|
const easJsonAccessor = EasJsonAccessor.fromProjectPath(projectDir);
|
||||||
await ensureVersionSourceIsRemoteAsync(easJsonAccessor);
|
await ensureVersionSourceIsRemoteAsync(easJsonAccessor);
|
||||||
const profile = await EasJsonUtils.getBuildProfileAsync(
|
const profile = await EasJsonUtils.getBuildProfileAsync(
|
||||||
easJsonAccessor,
|
easJsonAccessor,
|
||||||
@@ -67,13 +67,14 @@ export default class BuildVersionSetView extends EasCommand {
|
|||||||
|
|
||||||
validateAppConfigForRemoteVersionSource(exp, platform);
|
validateAppConfigForRemoteVersionSource(exp, platform);
|
||||||
|
|
||||||
const applicationIdentifier = await getApplicationIdentifierAsync(
|
const applicationIdentifier = await getApplicationIdentifierAsync({
|
||||||
|
graphqlClient,
|
||||||
projectDir,
|
projectDir,
|
||||||
|
projectId,
|
||||||
exp,
|
exp,
|
||||||
profile,
|
buildProfile: profile,
|
||||||
platform,
|
platform,
|
||||||
actor
|
});
|
||||||
);
|
|
||||||
const remoteVersions = await AppVersionQuery.latestVersionAsync(
|
const remoteVersions = await AppVersionQuery.latestVersionAsync(
|
||||||
graphqlClient,
|
graphqlClient,
|
||||||
projectId,
|
projectId,
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export default class BuildVersionSyncView extends EasCommand {
|
|||||||
public async runAsync(): Promise<void> {
|
public async runAsync(): Promise<void> {
|
||||||
const { flags } = await this.parse(BuildVersionSyncView);
|
const { flags } = await this.parse(BuildVersionSyncView);
|
||||||
const {
|
const {
|
||||||
loggedIn: { actor, graphqlClient },
|
loggedIn: { graphqlClient },
|
||||||
getDynamicProjectConfigAsync,
|
getDynamicProjectConfigAsync,
|
||||||
projectDir,
|
projectDir,
|
||||||
} = await this.getContextAsync(BuildVersionSyncView, {
|
} = await this.getContextAsync(BuildVersionSyncView, {
|
||||||
@@ -71,7 +71,7 @@ export default class BuildVersionSyncView extends EasCommand {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const requestedPlatform = await selectRequestedPlatformAsync(flags.platform);
|
const requestedPlatform = await selectRequestedPlatformAsync(flags.platform);
|
||||||
const easJsonAccessor = new EasJsonAccessor(projectDir);
|
const easJsonAccessor = EasJsonAccessor.fromProjectPath(projectDir);
|
||||||
await ensureVersionSourceIsRemoteAsync(easJsonAccessor);
|
await ensureVersionSourceIsRemoteAsync(easJsonAccessor);
|
||||||
|
|
||||||
const platforms = toPlatforms(requestedPlatform);
|
const platforms = toPlatforms(requestedPlatform);
|
||||||
@@ -89,13 +89,14 @@ export default class BuildVersionSyncView extends EasCommand {
|
|||||||
validateAppConfigForRemoteVersionSource(exp, profileInfo.platform);
|
validateAppConfigForRemoteVersionSource(exp, profileInfo.platform);
|
||||||
const platformDisplayName = appPlatformDisplayNames[toAppPlatform(profileInfo.platform)];
|
const platformDisplayName = appPlatformDisplayNames[toAppPlatform(profileInfo.platform)];
|
||||||
|
|
||||||
const applicationIdentifier = await getApplicationIdentifierAsync(
|
const applicationIdentifier = await getApplicationIdentifierAsync({
|
||||||
|
graphqlClient,
|
||||||
projectDir,
|
projectDir,
|
||||||
|
projectId,
|
||||||
exp,
|
exp,
|
||||||
profileInfo.profile,
|
buildProfile: profileInfo.profile,
|
||||||
profileInfo.platform,
|
platform: profileInfo.platform,
|
||||||
actor
|
});
|
||||||
);
|
|
||||||
const remoteVersions = await AppVersionQuery.latestVersionAsync(
|
const remoteVersions = await AppVersionQuery.latestVersionAsync(
|
||||||
graphqlClient,
|
graphqlClient,
|
||||||
projectId,
|
projectId,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { Flags } from '@oclif/core';
|
import { Flags } from '@oclif/core';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
|
|
||||||
|
import { selectBranchOnAppAsync } from '../../branch/queries';
|
||||||
|
import { selectChannelOnAppAsync } from '../../channel/queries';
|
||||||
import { BranchMapping, getBranchMapping } from '../../channel/utils';
|
import { BranchMapping, getBranchMapping } from '../../channel/utils';
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
@@ -132,13 +134,11 @@ async function startRolloutAsync(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const logMessage = `️Started a rollout of branch ${chalk.bold(
|
const logMessage = `Started a rollout of branch ${chalk.bold(branchName)} on channel ${chalk.bold(
|
||||||
|
channelName!
|
||||||
|
)}! ${chalk.bold(percent)}% of users will be directed to branch ${chalk.bold(
|
||||||
branchName
|
branchName
|
||||||
)} onto channel ${chalk.bold(channelName!)}! ${chalk.bold(
|
)}, ${chalk.bold(100 - percent)}% to branch ${chalk.bold(oldBranch.name)}.`;
|
||||||
percent
|
|
||||||
)}% of users will be directed to branch ${chalk.bold(branchName)}, ${chalk.bold(
|
|
||||||
100 - percent
|
|
||||||
)}% to branch ${chalk.bold(oldBranch.name)}.`;
|
|
||||||
|
|
||||||
return { newChannelInfo, logMessage };
|
return { newChannelInfo, logMessage };
|
||||||
}
|
}
|
||||||
@@ -190,7 +190,7 @@ async function editRolloutAsync(
|
|||||||
branchMapping: JSON.stringify(newBranchMapping),
|
branchMapping: JSON.stringify(newBranchMapping),
|
||||||
});
|
});
|
||||||
|
|
||||||
const logMessage = `️Rollout of branch ${chalk.bold(newBranch.name)} onto channel ${chalk.bold(
|
const logMessage = `Rollout of branch ${chalk.bold(newBranch.name)} on channel ${chalk.bold(
|
||||||
channelName!
|
channelName!
|
||||||
)} updated from ${chalk.bold(currentPercent)}% to ${chalk.bold(percent)}%. ${chalk.bold(
|
)} updated from ${chalk.bold(currentPercent)}% to ${chalk.bold(percent)}%. ${chalk.bold(
|
||||||
percent
|
percent
|
||||||
@@ -256,11 +256,11 @@ async function endRolloutAsync(
|
|||||||
'Ending the rollout will send all traffic to a single branch. Which one should that be?',
|
'Ending the rollout will send all traffic to a single branch. Which one should that be?',
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
title: `${newBranch.name} ${chalk.grey(`- current percent: ${100 - currentPercent}%`)}`,
|
title: `${newBranch.name} ${chalk.grey(`- current percent: ${currentPercent}%`)}`,
|
||||||
value: true,
|
value: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: `${oldBranch.name} ${chalk.grey(`- current percent: ${currentPercent}%`)}`,
|
title: `${oldBranch.name} ${chalk.grey(`- current percent: ${100 - currentPercent}%`)}`,
|
||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -284,7 +284,7 @@ async function endRolloutAsync(
|
|||||||
channelId: channel.id,
|
channelId: channel.id,
|
||||||
branchMapping: JSON.stringify(newBranchMapping),
|
branchMapping: JSON.stringify(newBranchMapping),
|
||||||
});
|
});
|
||||||
const logMessage = `️Rollout on channel ${chalk.bold(
|
const logMessage = `Rollout on channel ${chalk.bold(
|
||||||
channelName
|
channelName
|
||||||
)} ended. All traffic is now sent to branch ${chalk.bold(
|
)} ended. All traffic is now sent to branch ${chalk.bold(
|
||||||
endOnNewBranch ? newBranch.name : oldBranch.name
|
endOnNewBranch ? newBranch.name : oldBranch.name
|
||||||
@@ -294,14 +294,12 @@ async function endRolloutAsync(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class ChannelRollout extends EasCommand {
|
export default class ChannelRollout extends EasCommand {
|
||||||
static override hidden = true;
|
static override description = 'Roll a new branch out on a channel incrementally.';
|
||||||
static override description = 'Rollout a new branch out to a channel incrementally.';
|
|
||||||
|
|
||||||
static override args = [
|
static override args = [
|
||||||
{
|
{
|
||||||
name: 'channel',
|
name: 'channel',
|
||||||
required: true,
|
description: 'channel on which the rollout should be done',
|
||||||
description: 'rollout that the channel is on',
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -311,7 +309,7 @@ export default class ChannelRollout extends EasCommand {
|
|||||||
required: false,
|
required: false,
|
||||||
}),
|
}),
|
||||||
percent: Flags.integer({
|
percent: Flags.integer({
|
||||||
description: 'percent of traffic to redirect to the new branch',
|
description: 'percent of users to send to the new branch',
|
||||||
required: false,
|
required: false,
|
||||||
}),
|
}),
|
||||||
end: Flags.boolean({
|
end: Flags.boolean({
|
||||||
@@ -328,7 +326,7 @@ export default class ChannelRollout extends EasCommand {
|
|||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
const {
|
const {
|
||||||
args: { channel: channelName },
|
args: { channel: channelNameArg },
|
||||||
flags: {
|
flags: {
|
||||||
json: jsonFlag,
|
json: jsonFlag,
|
||||||
end: endFlag,
|
end: endFlag,
|
||||||
@@ -349,9 +347,23 @@ export default class ChannelRollout extends EasCommand {
|
|||||||
|
|
||||||
const projectDisplayName = await getDisplayNameForProjectIdAsync(graphqlClient, projectId);
|
const projectDisplayName = await getDisplayNameForProjectIdAsync(graphqlClient, projectId);
|
||||||
|
|
||||||
|
let channelName: string = channelNameArg;
|
||||||
|
if (!channelName) {
|
||||||
|
const { name } = await selectChannelOnAppAsync(graphqlClient, {
|
||||||
|
projectId,
|
||||||
|
selectionPromptTitle: 'Select a channel on which to perform a rollout',
|
||||||
|
paginatedQueryOptions: {
|
||||||
|
json: jsonFlag,
|
||||||
|
nonInteractive,
|
||||||
|
offset: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
channelName = name;
|
||||||
|
}
|
||||||
|
|
||||||
const channel = await ChannelQuery.viewUpdateChannelAsync(graphqlClient, {
|
const channel = await ChannelQuery.viewUpdateChannelAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
channelName: channelName!,
|
channelName,
|
||||||
});
|
});
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@@ -396,7 +408,15 @@ export default class ChannelRollout extends EasCommand {
|
|||||||
if (!isRollout) {
|
if (!isRollout) {
|
||||||
rolloutMutationResult = await startRolloutAsync(graphqlClient, {
|
rolloutMutationResult = await startRolloutAsync(graphqlClient, {
|
||||||
channelName,
|
channelName,
|
||||||
branchName: branchName ?? (await promptForBranchNameAsync(channelName, nonInteractive)),
|
branchName:
|
||||||
|
branchName ??
|
||||||
|
(await promptForBranchNameAsync({
|
||||||
|
graphqlClient,
|
||||||
|
projectId,
|
||||||
|
channelName,
|
||||||
|
nonInteractive,
|
||||||
|
json: jsonFlag,
|
||||||
|
})),
|
||||||
percent,
|
percent,
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
projectId,
|
projectId,
|
||||||
@@ -433,18 +453,36 @@ export default class ChannelRollout extends EasCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function promptForBranchNameAsync(
|
async function promptForBranchNameAsync({
|
||||||
channelName: string,
|
graphqlClient,
|
||||||
nonInteractive: boolean
|
projectId,
|
||||||
): Promise<string> {
|
channelName,
|
||||||
|
nonInteractive,
|
||||||
|
json,
|
||||||
|
}: {
|
||||||
|
graphqlClient: ExpoGraphqlClient;
|
||||||
|
projectId: string;
|
||||||
|
channelName: string;
|
||||||
|
nonInteractive: boolean;
|
||||||
|
json: boolean;
|
||||||
|
}): Promise<string> {
|
||||||
if (nonInteractive) {
|
if (nonInteractive) {
|
||||||
throw new Error('Must supply branch flag in non-interactive mode');
|
throw new Error('Must supply branch flag in non-interactive mode');
|
||||||
}
|
}
|
||||||
const { name } = await promptAsync({
|
|
||||||
type: 'text',
|
const { name: branchName } = await selectBranchOnAppAsync(graphqlClient, {
|
||||||
name: 'name',
|
projectId,
|
||||||
message: `Select a branch to rollout onto ${channelName}`,
|
promptTitle: `Which branch would you like roll out on ${channelName}?`,
|
||||||
validate: value => (value ? true : 'A branch must be specified.'),
|
displayTextForListItem: updateBranch => ({
|
||||||
|
title: updateBranch.name,
|
||||||
|
}),
|
||||||
|
// discard limit and offset because this query is not their intended target
|
||||||
|
paginatedQueryOptions: {
|
||||||
|
json,
|
||||||
|
nonInteractive,
|
||||||
|
offset: 0,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
return name;
|
|
||||||
|
return branchName;
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ export default class Config extends EasCommand {
|
|||||||
nonInteractive: false,
|
nonInteractive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor(projectDir);
|
const accessor = EasJsonAccessor.fromProjectPath(projectDir);
|
||||||
const profileName =
|
const profileName =
|
||||||
maybeProfile ??
|
maybeProfile ??
|
||||||
(await selectAsync(
|
(await selectAsync(
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export default class MetadataLint extends EasCommand {
|
|||||||
|
|
||||||
const submitProfiles = await getProfilesAsync({
|
const submitProfiles = await getProfilesAsync({
|
||||||
type: 'submit',
|
type: 'submit',
|
||||||
easJsonAccessor: new EasJsonAccessor(projectDir),
|
easJsonAccessor: EasJsonAccessor.fromProjectPath(projectDir),
|
||||||
platforms: [Platform.IOS],
|
platforms: [Platform.IOS],
|
||||||
profileName: flags.profile,
|
profileName: flags.profile,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export default class MetadataPull extends EasCommand {
|
|||||||
|
|
||||||
const submitProfiles = await getProfilesAsync({
|
const submitProfiles = await getProfilesAsync({
|
||||||
type: 'submit',
|
type: 'submit',
|
||||||
easJsonAccessor: new EasJsonAccessor(projectDir),
|
easJsonAccessor: EasJsonAccessor.fromProjectPath(projectDir),
|
||||||
platforms: [Platform.IOS],
|
platforms: [Platform.IOS],
|
||||||
profileName: flags.profile,
|
profileName: flags.profile,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export default class MetadataPush extends EasCommand {
|
|||||||
|
|
||||||
const submitProfiles = await getProfilesAsync({
|
const submitProfiles = await getProfilesAsync({
|
||||||
type: 'submit',
|
type: 'submit',
|
||||||
easJsonAccessor: new EasJsonAccessor(projectDir),
|
easJsonAccessor: EasJsonAccessor.fromProjectPath(projectDir),
|
||||||
platforms: [Platform.IOS],
|
platforms: [Platform.IOS],
|
||||||
profileName: flags.profile,
|
profileName: flags.profile,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -344,12 +344,38 @@ describe(ProjectInit.name, () => {
|
|||||||
describe('when it is already configured', () => {
|
describe('when it is already configured', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockTestProject({ configuredProjectId: '1234', configuredOwner: jester.accounts[0].name });
|
mockTestProject({ configuredProjectId: '1234', configuredOwner: jester.accounts[0].name });
|
||||||
|
|
||||||
|
jest.mocked(AppQuery.byIdAsync).mockResolvedValue({
|
||||||
|
id: '1234',
|
||||||
|
slug: 'testing-123',
|
||||||
|
fullName: '@jester/testing-123',
|
||||||
|
ownerAccount: jester.accounts[0],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not configure', async () => {
|
it('does not configure', async () => {
|
||||||
await new ProjectInit([], commandOptions).run();
|
await new ProjectInit([], commandOptions).run();
|
||||||
expect(saveProjectIdToAppConfigAsync).not.toHaveBeenCalled();
|
expect(saveProjectIdToAppConfigAsync).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('checks owner and slug consistency', async () => {
|
||||||
|
jest.mocked(AppQuery.byIdAsync).mockResolvedValue({
|
||||||
|
id: '1234',
|
||||||
|
slug: 'testing-124',
|
||||||
|
fullName: '@jester2/testing-124',
|
||||||
|
ownerAccount: jester2.accounts[0],
|
||||||
|
});
|
||||||
|
|
||||||
|
jest.mocked(confirmAsync).mockResolvedValue(true);
|
||||||
|
jest.mocked(modifyConfigAsync).mockResolvedValue({ type: 'success', config: {} as any });
|
||||||
|
|
||||||
|
await new ProjectInit([], commandOptions).run();
|
||||||
|
|
||||||
|
expect(confirmAsync).toHaveBeenCalled();
|
||||||
|
expect(modifyConfigAsync).toHaveBeenCalledTimes(2);
|
||||||
|
expect(modifyConfigAsync).toHaveBeenCalledWith('/test-project', { owner: 'jester2' });
|
||||||
|
expect(modifyConfigAsync).toHaveBeenCalledWith('/test-project', { slug: 'testing-124' });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when it is not yet configured', () => {
|
describe('when it is not yet configured', () => {
|
||||||
@@ -365,6 +391,14 @@ describe(ProjectInit.name, () => {
|
|||||||
|
|
||||||
it('prompts for confirmation to link', async () => {
|
it('prompts for confirmation to link', async () => {
|
||||||
jest.mocked(confirmAsync).mockResolvedValue(true);
|
jest.mocked(confirmAsync).mockResolvedValue(true);
|
||||||
|
|
||||||
|
jest.mocked(AppQuery.byIdAsync).mockResolvedValue({
|
||||||
|
id: '1234',
|
||||||
|
slug: 'testing-123',
|
||||||
|
fullName: '@jester/testing-123',
|
||||||
|
ownerAccount: jester.accounts[0],
|
||||||
|
});
|
||||||
|
|
||||||
await new ProjectInit([], commandOptions).run();
|
await new ProjectInit([], commandOptions).run();
|
||||||
expect(saveProjectIdToAppConfigAsync).toHaveBeenCalledWith('/test-project', '123456');
|
expect(saveProjectIdToAppConfigAsync).toHaveBeenCalledWith('/test-project', '123456');
|
||||||
expect(confirmAsync).toHaveBeenCalledTimes(1);
|
expect(confirmAsync).toHaveBeenCalledTimes(1);
|
||||||
@@ -384,6 +418,14 @@ describe(ProjectInit.name, () => {
|
|||||||
it('asks to create it', async () => {
|
it('asks to create it', async () => {
|
||||||
jest.mocked(confirmAsync).mockResolvedValue(true);
|
jest.mocked(confirmAsync).mockResolvedValue(true);
|
||||||
jest.mocked(AppMutation.createAppAsync).mockResolvedValue('0129');
|
jest.mocked(AppMutation.createAppAsync).mockResolvedValue('0129');
|
||||||
|
|
||||||
|
jest.mocked(AppQuery.byIdAsync).mockResolvedValue({
|
||||||
|
id: '0129',
|
||||||
|
slug: 'testing-123',
|
||||||
|
fullName: '@jester/testing-123',
|
||||||
|
ownerAccount: jester.accounts[0],
|
||||||
|
});
|
||||||
|
|
||||||
await new ProjectInit([], commandOptions).run();
|
await new ProjectInit([], commandOptions).run();
|
||||||
expect(saveProjectIdToAppConfigAsync).toHaveBeenCalledWith('/test-project', '0129');
|
expect(saveProjectIdToAppConfigAsync).toHaveBeenCalledWith('/test-project', '0129');
|
||||||
expect(confirmAsync).toHaveBeenCalledTimes(1);
|
expect(confirmAsync).toHaveBeenCalledTimes(1);
|
||||||
|
|||||||
@@ -194,7 +194,6 @@ export default class ProjectInit extends EasCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static async initializeWithExplicitIDAsync(
|
private static async initializeWithExplicitIDAsync(
|
||||||
graphqlClient: ExpoGraphqlClient,
|
|
||||||
projectId: string,
|
projectId: string,
|
||||||
projectDir: string,
|
projectDir: string,
|
||||||
{ force, nonInteractive }: InitializeMethodOptions
|
{ force, nonInteractive }: InitializeMethodOptions
|
||||||
@@ -203,17 +202,13 @@ export default class ProjectInit extends EasCommand {
|
|||||||
force,
|
force,
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
await this.ensureOwnerSlugConsistencyAsync(graphqlClient, projectId, projectDir, {
|
|
||||||
force,
|
|
||||||
nonInteractive,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async initializeWithInteractiveSelectionAsync(
|
private static async initializeWithInteractiveSelectionAsync(
|
||||||
graphqlClient: ExpoGraphqlClient,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
actor: Actor,
|
actor: Actor,
|
||||||
projectDir: string
|
projectDir: string
|
||||||
): Promise<void> {
|
): Promise<string> {
|
||||||
const exp = getExpoConfig(projectDir);
|
const exp = getExpoConfig(projectDir);
|
||||||
const existingProjectId = exp.extra?.eas?.projectId;
|
const existingProjectId = exp.extra?.eas?.projectId;
|
||||||
|
|
||||||
@@ -223,7 +218,7 @@ export default class ProjectInit extends EasCommand {
|
|||||||
existingProjectId
|
existingProjectId
|
||||||
)}). To re-configure, remove the "extra.eas.projectId" field from your app config.`
|
)}). To re-configure, remove the "extra.eas.projectId" field from your app config.`
|
||||||
);
|
);
|
||||||
return;
|
return existingProjectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const allAccounts = actor.accounts;
|
const allAccounts = actor.accounts;
|
||||||
@@ -287,7 +282,7 @@ export default class ProjectInit extends EasCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await ProjectInit.saveProjectIdAndLogSuccessAsync(projectDir, existingProjectIdOnServer);
|
await ProjectInit.saveProjectIdAndLogSuccessAsync(projectDir, existingProjectIdOnServer);
|
||||||
return;
|
return existingProjectIdOnServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!accountNamesWhereUserHasSufficientPermissionsToCreateApp.has(accountName)) {
|
if (!accountNamesWhereUserHasSufficientPermissionsToCreateApp.has(accountName)) {
|
||||||
@@ -323,24 +318,36 @@ export default class ProjectInit extends EasCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await ProjectInit.saveProjectIdAndLogSuccessAsync(projectDir, createdProjectId);
|
await ProjectInit.saveProjectIdAndLogSuccessAsync(projectDir, createdProjectId);
|
||||||
|
return createdProjectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
const {
|
const {
|
||||||
flags: { id, force, 'non-interactive': nonInteractive },
|
flags: { id: idArgument, force, 'non-interactive': nonInteractive },
|
||||||
} = await this.parse(ProjectInit);
|
} = await this.parse(ProjectInit);
|
||||||
const {
|
const {
|
||||||
loggedIn: { actor, graphqlClient },
|
loggedIn: { actor, graphqlClient },
|
||||||
projectDir,
|
projectDir,
|
||||||
} = await this.getContextAsync(ProjectInit, { nonInteractive });
|
} = await this.getContextAsync(ProjectInit, { nonInteractive });
|
||||||
|
|
||||||
if (id) {
|
let idForConsistency: string;
|
||||||
await ProjectInit.initializeWithExplicitIDAsync(graphqlClient, id, projectDir, {
|
if (idArgument) {
|
||||||
|
await ProjectInit.initializeWithExplicitIDAsync(idArgument, projectDir, {
|
||||||
force,
|
force,
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
|
idForConsistency = idArgument;
|
||||||
} else {
|
} else {
|
||||||
await ProjectInit.initializeWithInteractiveSelectionAsync(graphqlClient, actor, projectDir);
|
idForConsistency = await ProjectInit.initializeWithInteractiveSelectionAsync(
|
||||||
|
graphqlClient,
|
||||||
|
actor,
|
||||||
|
projectDir
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await ProjectInit.ensureOwnerSlugConsistencyAsync(graphqlClient, idForConsistency, projectDir, {
|
||||||
|
force,
|
||||||
|
nonInteractive,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ export default class Submit extends EasCommand {
|
|||||||
const platforms = toPlatforms(flagsWithPlatform.requestedPlatform);
|
const platforms = toPlatforms(flagsWithPlatform.requestedPlatform);
|
||||||
const submissionProfiles = await getProfilesAsync({
|
const submissionProfiles = await getProfilesAsync({
|
||||||
type: 'submit',
|
type: 'submit',
|
||||||
easJsonAccessor: new EasJsonAccessor(projectDir),
|
easJsonAccessor: EasJsonAccessor.fromProjectPath(projectDir),
|
||||||
platforms,
|
platforms,
|
||||||
profileName: flagsWithPlatform.profile,
|
profileName: flagsWithPlatform.profile,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
import { AppJSONConfig, PackageJSONConfig, Platform, getConfig } from '@expo/config';
|
import {
|
||||||
|
AppJSONConfig,
|
||||||
|
ExpoConfig,
|
||||||
|
GetConfigOptions,
|
||||||
|
PackageJSONConfig,
|
||||||
|
Platform,
|
||||||
|
getConfig,
|
||||||
|
} from '@expo/config';
|
||||||
import { Updates } from '@expo/config-plugins';
|
import { Updates } from '@expo/config-plugins';
|
||||||
import { vol } from 'memfs';
|
import { vol } from 'memfs';
|
||||||
|
import nullthrows from 'nullthrows';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { instance, mock } from 'ts-mockito';
|
import { instance, mock } from 'ts-mockito';
|
||||||
|
|
||||||
@@ -29,6 +37,7 @@ const updateStub: UpdateFragment = {
|
|||||||
platform: 'ios',
|
platform: 'ios',
|
||||||
gitCommitHash: 'commit',
|
gitCommitHash: 'commit',
|
||||||
manifestFragment: JSON.stringify({ fake: 'manifest' }),
|
manifestFragment: JSON.stringify({ fake: 'manifest' }),
|
||||||
|
isRollBackToEmbedded: false,
|
||||||
manifestPermalink: 'https://expo.dev/fake/manifest/link',
|
manifestPermalink: 'https://expo.dev/fake/manifest/link',
|
||||||
codeSigningInfo: null,
|
codeSigningInfo: null,
|
||||||
createdAt: '2022-01-01T12:00:00Z',
|
createdAt: '2022-01-01T12:00:00Z',
|
||||||
@@ -46,7 +55,7 @@ jest.mock('../../../graphql/queries/AppQuery');
|
|||||||
jest.mock('../../../graphql/queries/UpdateQuery');
|
jest.mock('../../../graphql/queries/UpdateQuery');
|
||||||
jest.mock('../../../ora', () => ({
|
jest.mock('../../../ora', () => ({
|
||||||
ora: () => ({
|
ora: () => ({
|
||||||
start: () => ({ succeed: () => {}, fail: () => {} }),
|
start: () => ({ succeed: () => {}, fail: () => {}, stop: () => {} }),
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
jest.mock('../../../project/publish', () => ({
|
jest.mock('../../../project/publish', () => ({
|
||||||
@@ -58,7 +67,10 @@ jest.mock('../../../project/publish', () => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
describe(UpdatePublish.name, () => {
|
describe(UpdatePublish.name, () => {
|
||||||
afterEach(() => vol.reset());
|
afterEach(() => {
|
||||||
|
vol.reset();
|
||||||
|
jest.mocked(PublishMutation.publishUpdateGroupAsync).mockClear();
|
||||||
|
});
|
||||||
|
|
||||||
// Deprecated and split to a new command: update:republish
|
// Deprecated and split to a new command: update:republish
|
||||||
it('errors with --republish', async () => {
|
it('errors with --republish', async () => {
|
||||||
@@ -80,7 +92,7 @@ describe(UpdatePublish.name, () => {
|
|||||||
mockTestProject();
|
mockTestProject();
|
||||||
|
|
||||||
await expect(new UpdatePublish(flags, commandOptions).run()).rejects.toThrow(
|
await expect(new UpdatePublish(flags, commandOptions).run()).rejects.toThrow(
|
||||||
'Cannot specify both --channel and --branch. Specify either --channel, --branch, or --auto'
|
'Cannot specify both --channel and --branch. Specify either --channel, --branch, or --auto.'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -136,14 +148,59 @@ describe(UpdatePublish.name, () => {
|
|||||||
|
|
||||||
expect(PublishMutation.publishUpdateGroupAsync).toHaveBeenCalled();
|
expect(PublishMutation.publishUpdateGroupAsync).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('creates a new update with the public expo config', async () => {
|
||||||
|
const flags = ['--non-interactive', '--branch=branch123', '--message=abc'];
|
||||||
|
|
||||||
|
// Add configuration to the project that should not be included in the update
|
||||||
|
const { appJson } = mockTestProject({
|
||||||
|
expoConfig: {
|
||||||
|
hooks: {
|
||||||
|
postPublish: [
|
||||||
|
{
|
||||||
|
file: 'custom-hook.js',
|
||||||
|
config: { some: 'config' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const { platforms, runtimeVersion } = mockTestExport({ platforms: ['ios'] });
|
||||||
|
|
||||||
|
// Mock an existing branch, so we don't create a new one
|
||||||
|
jest.mocked(ensureBranchExistsAsync).mockResolvedValue({
|
||||||
|
branchId: 'branch123',
|
||||||
|
createdBranch: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
jest
|
||||||
|
.mocked(PublishMutation.publishUpdateGroupAsync)
|
||||||
|
.mockResolvedValue(platforms.map(platform => ({ ...updateStub, platform, runtimeVersion })));
|
||||||
|
|
||||||
|
await new UpdatePublish(flags, commandOptions).run();
|
||||||
|
|
||||||
|
// Pull the publish data from the mocked publish function
|
||||||
|
const publishData = jest.mocked(PublishMutation.publishUpdateGroupAsync).mock.calls[0][1][0];
|
||||||
|
// Pull the Expo config from the publish data
|
||||||
|
const expoConfig = nullthrows(publishData.updateInfoGroup).ios!.extra.expoClient;
|
||||||
|
|
||||||
|
// Ensure the basic properties are present
|
||||||
|
expect(expoConfig).toHaveProperty('name', appJson.expo.name);
|
||||||
|
expect(expoConfig).toHaveProperty('slug', appJson.expo.slug);
|
||||||
|
// Ensure non-public config is not present
|
||||||
|
expect(expoConfig).not.toHaveProperty('hooks');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Create a new in-memory project, copied from src/commands/update/__tests__/republish.test.ts */
|
/** Create a new in-memory project, copied from src/commands/update/__tests__/republish.test.ts */
|
||||||
function mockTestProject({
|
function mockTestProject({
|
||||||
configuredProjectId = '1234',
|
configuredProjectId = '1234',
|
||||||
|
expoConfig = {},
|
||||||
}: {
|
}: {
|
||||||
configuredProjectId?: string;
|
configuredProjectId?: string;
|
||||||
} = {}): { projectId: string } {
|
expoConfig?: Partial<ExpoConfig>;
|
||||||
|
} = {}): { projectId: string; appJson: AppJSONConfig } {
|
||||||
const packageJSON: PackageJSONConfig = {
|
const packageJSON: PackageJSONConfig = {
|
||||||
name: 'testing123',
|
name: 'testing123',
|
||||||
version: '0.1.0',
|
version: '0.1.0',
|
||||||
@@ -163,6 +220,7 @@ function mockTestProject({
|
|||||||
projectId: configuredProjectId,
|
projectId: configuredProjectId,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
...expoConfig,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -180,11 +238,27 @@ function mockTestProject({
|
|||||||
jest.mocked(getConfig).mockReturnValue(mockManifest as any);
|
jest.mocked(getConfig).mockReturnValue(mockManifest as any);
|
||||||
jest
|
jest
|
||||||
.spyOn(DynamicProjectConfigContextField.prototype, 'getValueAsync')
|
.spyOn(DynamicProjectConfigContextField.prototype, 'getValueAsync')
|
||||||
.mockResolvedValue(async () => ({
|
.mockResolvedValue(async (options?: GetConfigOptions) => {
|
||||||
exp: mockManifest.exp,
|
let exp = { ...mockManifest.exp };
|
||||||
projectDir: projectRoot,
|
|
||||||
projectId: configuredProjectId,
|
// Fake a limited public config
|
||||||
}));
|
if (options?.isPublicConfig) {
|
||||||
|
exp = {
|
||||||
|
name: mockManifest.exp.name,
|
||||||
|
version: mockManifest.exp.version,
|
||||||
|
slug: mockManifest.exp.slug,
|
||||||
|
sdkVersion: mockManifest.exp.sdkVersion,
|
||||||
|
owner: mockManifest.exp.owner,
|
||||||
|
extra: mockManifest.exp.extra,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
exp,
|
||||||
|
projectDir: projectRoot,
|
||||||
|
projectId: configuredProjectId,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
jest.spyOn(LoggedInContextField.prototype, 'getValueAsync').mockResolvedValue({
|
jest.spyOn(LoggedInContextField.prototype, 'getValueAsync').mockResolvedValue({
|
||||||
actor: jester,
|
actor: jester,
|
||||||
@@ -199,7 +273,7 @@ function mockTestProject({
|
|||||||
ownerAccount: jester.accounts[0],
|
ownerAccount: jester.accounts[0],
|
||||||
});
|
});
|
||||||
|
|
||||||
return { projectId: configuredProjectId };
|
return { projectId: configuredProjectId, appJson: appJSON };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create a new in-memory export of the project */
|
/** Create a new in-memory export of the project */
|
||||||
@@ -246,6 +320,8 @@ function mockTestExport({
|
|||||||
uniqueAssetCount: platforms.length,
|
uniqueAssetCount: platforms.length,
|
||||||
uniqueUploadedAssetCount: platforms.length,
|
uniqueUploadedAssetCount: platforms.length,
|
||||||
assetLimitPerUpdateGroup: 9001,
|
assetLimitPerUpdateGroup: 9001,
|
||||||
|
launchAssetCount: 2,
|
||||||
|
uniqueUploadedAssetPaths: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.mocked(Updates.getRuntimeVersion).mockReturnValue(runtimeVersion);
|
jest.mocked(Updates.getRuntimeVersion).mockReturnValue(runtimeVersion);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ const updateStub: UpdateFragment = {
|
|||||||
platform: 'ios',
|
platform: 'ios',
|
||||||
gitCommitHash: 'commit',
|
gitCommitHash: 'commit',
|
||||||
manifestFragment: JSON.stringify({ fake: 'manifest' }),
|
manifestFragment: JSON.stringify({ fake: 'manifest' }),
|
||||||
|
isRollBackToEmbedded: false,
|
||||||
manifestPermalink: 'https://expo.dev/fake/manifest/link',
|
manifestPermalink: 'https://expo.dev/fake/manifest/link',
|
||||||
codeSigningInfo: null,
|
codeSigningInfo: null,
|
||||||
createdAt: '2022-01-01T12:00:00Z',
|
createdAt: '2022-01-01T12:00:00Z',
|
||||||
|
|||||||
@@ -0,0 +1,257 @@
|
|||||||
|
import {
|
||||||
|
AppJSONConfig,
|
||||||
|
ExpoConfig,
|
||||||
|
GetConfigOptions,
|
||||||
|
PackageJSONConfig,
|
||||||
|
getConfig,
|
||||||
|
} from '@expo/config';
|
||||||
|
import { Updates } from '@expo/config-plugins';
|
||||||
|
import { vol } from 'memfs';
|
||||||
|
import nullthrows from 'nullthrows';
|
||||||
|
import path from 'path';
|
||||||
|
import { instance, mock } from 'ts-mockito';
|
||||||
|
|
||||||
|
import { ensureBranchExistsAsync } from '../../../branch/queries';
|
||||||
|
import { DynamicProjectConfigContextField } from '../../../commandUtils/context/DynamicProjectConfigContextField';
|
||||||
|
import LoggedInContextField from '../../../commandUtils/context/LoggedInContextField';
|
||||||
|
import { ExpoGraphqlClient } from '../../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
|
import FeatureGateEnvOverrides from '../../../commandUtils/gating/FeatureGateEnvOverrides';
|
||||||
|
import FeatureGating from '../../../commandUtils/gating/FeatureGating';
|
||||||
|
import { jester } from '../../../credentials/__tests__/fixtures-constants';
|
||||||
|
import { UpdateFragment } from '../../../graphql/generated';
|
||||||
|
import { PublishMutation } from '../../../graphql/mutations/PublishMutation';
|
||||||
|
import { AppQuery } from '../../../graphql/queries/AppQuery';
|
||||||
|
import { getBranchNameFromChannelNameAsync } from '../../../update/getBranchNameFromChannelNameAsync';
|
||||||
|
import UpdateRollBackToEmbedded from '../roll-back-to-embedded';
|
||||||
|
|
||||||
|
const projectRoot = '/test-project';
|
||||||
|
const commandOptions = { root: projectRoot } as any;
|
||||||
|
const updateStub: UpdateFragment = {
|
||||||
|
id: 'update-1234',
|
||||||
|
group: 'group-1234',
|
||||||
|
branch: { id: 'branch-1234', name: 'main' },
|
||||||
|
message: 'test message',
|
||||||
|
runtimeVersion: 'exposdk:47.0.0',
|
||||||
|
platform: 'ios',
|
||||||
|
gitCommitHash: 'commit',
|
||||||
|
manifestFragment: JSON.stringify({ fake: 'manifest' }),
|
||||||
|
isRollBackToEmbedded: false,
|
||||||
|
manifestPermalink: 'https://expo.dev/fake/manifest/link',
|
||||||
|
codeSigningInfo: null,
|
||||||
|
createdAt: '2022-01-01T12:00:00Z',
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.mock('fs');
|
||||||
|
jest.mock('@expo/config');
|
||||||
|
jest.mock('@expo/config-plugins');
|
||||||
|
jest.mock('../../../branch/queries');
|
||||||
|
jest.mock('../../../commandUtils/context/contextUtils/getProjectIdAsync');
|
||||||
|
jest.mock('../../../update/configure');
|
||||||
|
jest.mock('../../../update/getBranchNameFromChannelNameAsync');
|
||||||
|
jest.mock('../../../graphql/mutations/PublishMutation');
|
||||||
|
jest.mock('../../../graphql/queries/AppQuery');
|
||||||
|
jest.mock('../../../graphql/queries/UpdateQuery');
|
||||||
|
jest.mock('../../../ora', () => ({
|
||||||
|
ora: () => ({
|
||||||
|
start: () => ({ succeed: () => {}, fail: () => {}, stop: () => {} }),
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
jest.mock('../../../project/publish', () => ({
|
||||||
|
...jest.requireActual('../../../project/publish'),
|
||||||
|
buildBundlesAsync: jest.fn(),
|
||||||
|
collectAssetsAsync: jest.fn(),
|
||||||
|
resolveInputDirectoryAsync: jest.fn((inputDir = 'dist') => path.join(projectRoot, inputDir)),
|
||||||
|
uploadAssetsAsync: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe(UpdateRollBackToEmbedded.name, () => {
|
||||||
|
afterEach(() => vol.reset());
|
||||||
|
|
||||||
|
it('errors with both --channel and --branch', async () => {
|
||||||
|
const flags = ['--channel=channel123', '--branch=branch123'];
|
||||||
|
|
||||||
|
mockTestProject();
|
||||||
|
|
||||||
|
await expect(new UpdateRollBackToEmbedded(flags, commandOptions).run()).rejects.toThrow(
|
||||||
|
'Cannot specify both --channel and --branch. Specify either --channel, --branch, or --auto.'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('creates a roll back to embedded with --non-interactive, --branch, and --message', async () => {
|
||||||
|
const flags = ['--non-interactive', '--branch=branch123', '--message=abc'];
|
||||||
|
|
||||||
|
mockTestProject();
|
||||||
|
const platforms = ['android', 'ios'];
|
||||||
|
const runtimeVersion = 'exposdk:47.0.0';
|
||||||
|
jest.mocked(Updates.getRuntimeVersion).mockReturnValue(runtimeVersion);
|
||||||
|
|
||||||
|
jest.mocked(ensureBranchExistsAsync).mockResolvedValue({
|
||||||
|
branchId: 'branch123',
|
||||||
|
createdBranch: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
jest
|
||||||
|
.mocked(PublishMutation.publishUpdateGroupAsync)
|
||||||
|
.mockResolvedValue(platforms.map(platform => ({ ...updateStub, platform, runtimeVersion })));
|
||||||
|
|
||||||
|
await new UpdateRollBackToEmbedded(flags, commandOptions).run();
|
||||||
|
|
||||||
|
expect(PublishMutation.publishUpdateGroupAsync).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('creates a roll back to embedded with --non-interactive, --channel, and --message', async () => {
|
||||||
|
const flags = ['--non-interactive', '--channel=channel123', '--message=abc'];
|
||||||
|
|
||||||
|
const { projectId } = mockTestProject();
|
||||||
|
const platforms = ['android', 'ios'];
|
||||||
|
const runtimeVersion = 'exposdk:47.0.0';
|
||||||
|
jest.mocked(Updates.getRuntimeVersion).mockReturnValue(runtimeVersion);
|
||||||
|
|
||||||
|
jest.mocked(getBranchNameFromChannelNameAsync).mockResolvedValue('branchFromChannel');
|
||||||
|
jest.mocked(ensureBranchExistsAsync).mockResolvedValue({
|
||||||
|
branchId: 'branch123',
|
||||||
|
createdBranch: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
jest.mocked(PublishMutation.publishUpdateGroupAsync).mockResolvedValue(
|
||||||
|
platforms.map(platform => ({
|
||||||
|
...updateStub,
|
||||||
|
runtimeVersion,
|
||||||
|
platform,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
|
||||||
|
await new UpdateRollBackToEmbedded(flags, commandOptions).run();
|
||||||
|
|
||||||
|
expect(ensureBranchExistsAsync).toHaveBeenCalledWith(
|
||||||
|
expect.any(Object), // graphql client
|
||||||
|
{
|
||||||
|
appId: projectId,
|
||||||
|
branchName: 'branchFromChannel',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(PublishMutation.publishUpdateGroupAsync).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('creates a roll back to embedded with the public expo config', async () => {
|
||||||
|
const flags = ['--non-interactive', '--branch=branch123', '--message=abc'];
|
||||||
|
|
||||||
|
// Add configuration to the project that should not be included in the update
|
||||||
|
mockTestProject({
|
||||||
|
expoConfig: {
|
||||||
|
hooks: {
|
||||||
|
postPublish: [
|
||||||
|
{
|
||||||
|
file: 'custom-hook.js',
|
||||||
|
config: { some: 'config' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const platforms = ['ios'];
|
||||||
|
const runtimeVersion = 'exposdk:47.0.0';
|
||||||
|
jest.mocked(Updates.getRuntimeVersion).mockReturnValue(runtimeVersion);
|
||||||
|
|
||||||
|
// Mock an existing branch, so we don't create a new one
|
||||||
|
jest.mocked(ensureBranchExistsAsync).mockResolvedValue({
|
||||||
|
branchId: 'branch123',
|
||||||
|
createdBranch: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
jest
|
||||||
|
.mocked(PublishMutation.publishUpdateGroupAsync)
|
||||||
|
.mockResolvedValue(platforms.map(platform => ({ ...updateStub, platform, runtimeVersion })));
|
||||||
|
|
||||||
|
await new UpdateRollBackToEmbedded(flags, commandOptions).run();
|
||||||
|
|
||||||
|
// Pull the publish data from the mocked publish function
|
||||||
|
const publishData = jest.mocked(PublishMutation.publishUpdateGroupAsync).mock.calls[0][1][0];
|
||||||
|
expect(nullthrows(publishData.rollBackToEmbeddedInfoGroup).ios).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/** Create a new in-memory project, based on src/commands/project/__tests__/init.test.ts */
|
||||||
|
function mockTestProject({
|
||||||
|
configuredProjectId = '1234',
|
||||||
|
expoConfig = {},
|
||||||
|
}: {
|
||||||
|
configuredProjectId?: string;
|
||||||
|
expoConfig?: Partial<ExpoConfig>;
|
||||||
|
} = {}): { projectId: string; appJson: AppJSONConfig } {
|
||||||
|
const packageJSON: PackageJSONConfig = {
|
||||||
|
name: 'testing123',
|
||||||
|
version: '0.1.0',
|
||||||
|
description: 'fake description',
|
||||||
|
main: 'index.js',
|
||||||
|
};
|
||||||
|
|
||||||
|
const appJSON: AppJSONConfig = {
|
||||||
|
expo: {
|
||||||
|
name: 'testing 123',
|
||||||
|
version: '0.1.0',
|
||||||
|
slug: 'testing-123',
|
||||||
|
sdkVersion: '33.0.0',
|
||||||
|
owner: jester.accounts[0].name,
|
||||||
|
extra: {
|
||||||
|
eas: {
|
||||||
|
projectId: configuredProjectId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
...expoConfig,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
vol.fromJSON(
|
||||||
|
{
|
||||||
|
'package.json': JSON.stringify(packageJSON),
|
||||||
|
'app.json': JSON.stringify(appJSON),
|
||||||
|
},
|
||||||
|
projectRoot
|
||||||
|
);
|
||||||
|
|
||||||
|
const mockManifest = { exp: appJSON.expo };
|
||||||
|
const graphqlClient = instance(mock<ExpoGraphqlClient>({}));
|
||||||
|
|
||||||
|
jest.mocked(getConfig).mockReturnValue(mockManifest as any);
|
||||||
|
jest
|
||||||
|
.spyOn(DynamicProjectConfigContextField.prototype, 'getValueAsync')
|
||||||
|
.mockResolvedValue(async (options?: GetConfigOptions) => {
|
||||||
|
let exp = { ...mockManifest.exp };
|
||||||
|
|
||||||
|
// Fake a limited public config
|
||||||
|
if (options?.isPublicConfig) {
|
||||||
|
exp = {
|
||||||
|
name: mockManifest.exp.name,
|
||||||
|
version: mockManifest.exp.version,
|
||||||
|
slug: mockManifest.exp.slug,
|
||||||
|
sdkVersion: mockManifest.exp.sdkVersion,
|
||||||
|
owner: mockManifest.exp.owner,
|
||||||
|
extra: mockManifest.exp.extra,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
exp,
|
||||||
|
projectDir: projectRoot,
|
||||||
|
projectId: configuredProjectId,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
jest.spyOn(LoggedInContextField.prototype, 'getValueAsync').mockResolvedValue({
|
||||||
|
actor: jester,
|
||||||
|
featureGating: new FeatureGating({}, new FeatureGateEnvOverrides()),
|
||||||
|
graphqlClient,
|
||||||
|
});
|
||||||
|
|
||||||
|
jest.mocked(AppQuery.byIdAsync).mockResolvedValue({
|
||||||
|
id: '1234',
|
||||||
|
slug: 'testing-123',
|
||||||
|
fullName: '@jester/testing-123',
|
||||||
|
ownerAccount: jester.accounts[0],
|
||||||
|
});
|
||||||
|
|
||||||
|
return { projectId: configuredProjectId, appJson: appJSON };
|
||||||
|
}
|
||||||
@@ -1,13 +1,9 @@
|
|||||||
import { ExpoConfig, Platform as PublishPlatform } from '@expo/config';
|
import { Platform as PublishPlatform } from '@expo/config';
|
||||||
import { Updates } from '@expo/config-plugins';
|
|
||||||
import { Platform, Workflow } from '@expo/eas-build-job';
|
|
||||||
import { Errors, Flags } from '@oclif/core';
|
import { Errors, Flags } from '@oclif/core';
|
||||||
import assert from 'assert';
|
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import nullthrows from 'nullthrows';
|
import nullthrows from 'nullthrows';
|
||||||
|
|
||||||
import { ensureBranchExistsAsync, selectBranchOnAppAsync } from '../../branch/queries';
|
import { ensureBranchExistsAsync } from '../../branch/queries';
|
||||||
import { getDefaultBranchNameAsync } from '../../branch/utils';
|
|
||||||
import { getUpdateGroupUrl } from '../../build/utils/url';
|
import { getUpdateGroupUrl } from '../../build/utils/url';
|
||||||
import { ensureChannelExistsAsync } from '../../channel/queries';
|
import { ensureChannelExistsAsync } from '../../channel/queries';
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
@@ -23,32 +19,32 @@ import {
|
|||||||
import { PublishMutation } from '../../graphql/mutations/PublishMutation';
|
import { PublishMutation } from '../../graphql/mutations/PublishMutation';
|
||||||
import Log, { learnMore, link } from '../../log';
|
import Log, { learnMore, link } from '../../log';
|
||||||
import { ora } from '../../ora';
|
import { ora } from '../../ora';
|
||||||
import { RequestedPlatform, requestedPlatformDisplayNames } from '../../platform';
|
import { RequestedPlatform } from '../../platform';
|
||||||
import { getOwnerAccountForProjectIdAsync } from '../../project/projectUtils';
|
import { getOwnerAccountForProjectIdAsync } from '../../project/projectUtils';
|
||||||
import {
|
import {
|
||||||
ExpoCLIExportPlatformFlag,
|
ExpoCLIExportPlatformFlag,
|
||||||
buildBundlesAsync,
|
buildBundlesAsync,
|
||||||
buildUnsortedUpdateInfoGroupAsync,
|
buildUnsortedUpdateInfoGroupAsync,
|
||||||
collectAssetsAsync,
|
collectAssetsAsync,
|
||||||
|
defaultPublishPlatforms,
|
||||||
filterExportedPlatformsByFlag,
|
filterExportedPlatformsByFlag,
|
||||||
|
getBranchNameForCommandAsync,
|
||||||
|
getRequestedPlatform,
|
||||||
|
getRuntimeToPlatformMappingFromRuntimeVersions,
|
||||||
|
getRuntimeVersionObjectAsync,
|
||||||
|
getUpdateMessageForCommandAsync,
|
||||||
isUploadedAssetCountAboveWarningThreshold,
|
isUploadedAssetCountAboveWarningThreshold,
|
||||||
resolveInputDirectoryAsync,
|
resolveInputDirectoryAsync,
|
||||||
uploadAssetsAsync,
|
uploadAssetsAsync,
|
||||||
} from '../../project/publish';
|
} from '../../project/publish';
|
||||||
import { resolveWorkflowAsync } from '../../project/workflow';
|
|
||||||
import { promptAsync } from '../../prompts';
|
|
||||||
import { ensureEASUpdateIsConfiguredAsync } from '../../update/configure';
|
import { ensureEASUpdateIsConfiguredAsync } from '../../update/configure';
|
||||||
import { getBranchNameFromChannelNameAsync } from '../../update/getBranchNameFromChannelNameAsync';
|
import { getUpdateGroupJsonInfo } from '../../update/utils';
|
||||||
import {
|
import { maybeWarnAboutEasPlanOverageAsync } from '../../utils/billing';
|
||||||
formatUpdateMessage,
|
|
||||||
getUpdateGroupJsonInfo,
|
|
||||||
truncateString as truncateUpdateMessage,
|
|
||||||
} from '../../update/utils';
|
|
||||||
import {
|
import {
|
||||||
checkManifestBodyAgainstUpdateInfoGroup,
|
checkManifestBodyAgainstUpdateInfoGroup,
|
||||||
getCodeSigningInfoAsync,
|
getCodeSigningInfoAsync,
|
||||||
getManifestBodyAsync,
|
getManifestBodyAsync,
|
||||||
signManifestBody,
|
signBody,
|
||||||
} from '../../utils/code-signing';
|
} from '../../utils/code-signing';
|
||||||
import uniqBy from '../../utils/expodash/uniqBy';
|
import uniqBy from '../../utils/expodash/uniqBy';
|
||||||
import formatFields from '../../utils/formatFields';
|
import formatFields from '../../utils/formatFields';
|
||||||
@@ -56,8 +52,6 @@ import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
|
|||||||
import { maybeWarnAboutEasOutagesAsync } from '../../utils/statuspageService';
|
import { maybeWarnAboutEasOutagesAsync } from '../../utils/statuspageService';
|
||||||
import { getVcsClient } from '../../vcs';
|
import { getVcsClient } from '../../vcs';
|
||||||
|
|
||||||
export const defaultPublishPlatforms: Partial<PublishPlatform>[] = ['android', 'ios'];
|
|
||||||
|
|
||||||
type RawUpdateFlags = {
|
type RawUpdateFlags = {
|
||||||
auto: boolean;
|
auto: boolean;
|
||||||
branch?: string;
|
branch?: string;
|
||||||
@@ -88,21 +82,6 @@ type UpdateFlags = {
|
|||||||
nonInteractive: boolean;
|
nonInteractive: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
function getRequestedPlatform(platform: ExpoCLIExportPlatformFlag): RequestedPlatform | null {
|
|
||||||
switch (platform) {
|
|
||||||
case 'android':
|
|
||||||
return RequestedPlatform.Android;
|
|
||||||
case 'ios':
|
|
||||||
return RequestedPlatform.Ios;
|
|
||||||
case 'web':
|
|
||||||
return null;
|
|
||||||
case 'all':
|
|
||||||
return RequestedPlatform.All;
|
|
||||||
default:
|
|
||||||
throw new Error(`Unsupported platform: ${platform}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class UpdatePublish extends EasCommand {
|
export default class UpdatePublish extends EasCommand {
|
||||||
static override description = 'publish an update group';
|
static override description = 'publish an update group';
|
||||||
|
|
||||||
@@ -166,18 +145,18 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
const { flags: rawFlags } = await this.parse(UpdatePublish);
|
const { flags: rawFlags } = await this.parse(UpdatePublish);
|
||||||
const paginatedQueryOptions = getPaginatedQueryOptions(rawFlags);
|
const paginatedQueryOptions = getPaginatedQueryOptions(rawFlags);
|
||||||
let {
|
const {
|
||||||
auto: autoFlag,
|
auto: autoFlag,
|
||||||
platform: platformFlag,
|
platform: platformFlag,
|
||||||
channelName,
|
channelName: channelNameArg,
|
||||||
updateMessage,
|
updateMessage: updateMessageArg,
|
||||||
inputDir,
|
inputDir,
|
||||||
skipBundler,
|
skipBundler,
|
||||||
privateKeyPath,
|
privateKeyPath,
|
||||||
json: jsonFlag,
|
json: jsonFlag,
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
|
branchName: branchNameArg,
|
||||||
} = this.sanitizeFlags(rawFlags);
|
} = this.sanitizeFlags(rawFlags);
|
||||||
let branchName = this.sanitizeFlags(rawFlags).branchName;
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
getDynamicProjectConfigAsync,
|
getDynamicProjectConfigAsync,
|
||||||
@@ -198,10 +177,7 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
isPublicConfig: true,
|
isPublicConfig: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { exp: expPrivate } = await getDynamicProjectConfigAsync({
|
await maybeWarnAboutEasPlanOverageAsync(graphqlClient, projectId);
|
||||||
isPublicConfig: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
await maybeWarnAboutEasOutagesAsync(graphqlClient, [StatuspageServiceName.EasUpdate]);
|
await maybeWarnAboutEasOutagesAsync(graphqlClient, [StatuspageServiceName.EasUpdate]);
|
||||||
|
|
||||||
await ensureEASUpdateIsConfiguredAsync(graphqlClient, {
|
await ensureEASUpdateIsConfiguredAsync(graphqlClient, {
|
||||||
@@ -211,75 +187,28 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
projectId,
|
projectId,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { exp } = await getDynamicProjectConfigAsync({});
|
const { exp } = await getDynamicProjectConfigAsync({ isPublicConfig: true });
|
||||||
|
const { exp: expPrivate } = await getDynamicProjectConfigAsync({
|
||||||
|
isPublicConfig: false,
|
||||||
|
});
|
||||||
const codeSigningInfo = await getCodeSigningInfoAsync(expPrivate, privateKeyPath);
|
const codeSigningInfo = await getCodeSigningInfoAsync(expPrivate, privateKeyPath);
|
||||||
|
|
||||||
let realizedPlatforms: PublishPlatform[] = [];
|
const branchName = await getBranchNameForCommandAsync({
|
||||||
|
graphqlClient,
|
||||||
|
projectId,
|
||||||
|
channelNameArg,
|
||||||
|
branchNameArg,
|
||||||
|
autoFlag,
|
||||||
|
nonInteractive,
|
||||||
|
paginatedQueryOptions,
|
||||||
|
});
|
||||||
|
|
||||||
if (channelName && branchName) {
|
const updateMessage = await getUpdateMessageForCommandAsync({
|
||||||
throw new Error(
|
updateMessageArg,
|
||||||
'Cannot specify both --channel and --branch. Specify either --channel, --branch, or --auto'
|
autoFlag,
|
||||||
);
|
nonInteractive,
|
||||||
}
|
jsonFlag,
|
||||||
|
});
|
||||||
if (channelName) {
|
|
||||||
branchName = await getBranchNameFromChannelNameAsync(graphqlClient, projectId, channelName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!branchName) {
|
|
||||||
if (autoFlag) {
|
|
||||||
branchName = await getDefaultBranchNameAsync();
|
|
||||||
} else if (nonInteractive) {
|
|
||||||
throw new Error('Must supply --channel, --branch or --auto when in non-interactive mode');
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
const branch = await selectBranchOnAppAsync(graphqlClient, {
|
|
||||||
projectId,
|
|
||||||
promptTitle: `Which branch would you like to publish on?`,
|
|
||||||
displayTextForListItem: updateBranch => ({
|
|
||||||
title: `${updateBranch.name} ${chalk.grey(
|
|
||||||
`- current update: ${formatUpdateMessage(updateBranch.updates[0])}`
|
|
||||||
)}`,
|
|
||||||
}),
|
|
||||||
paginatedQueryOptions,
|
|
||||||
});
|
|
||||||
branchName = branch.name;
|
|
||||||
} catch {
|
|
||||||
// unable to select a branch (network error or no branches for project)
|
|
||||||
({ name: branchName } = await promptAsync({
|
|
||||||
type: 'text',
|
|
||||||
name: 'name',
|
|
||||||
message: 'No branches found. Provide a branch name:',
|
|
||||||
initial: await getDefaultBranchNameAsync(),
|
|
||||||
validate: value => (value ? true : 'Branch name may not be empty.'),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(branchName, 'Branch name must be specified.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!updateMessage && autoFlag) {
|
|
||||||
updateMessage = (await getVcsClient().getLastCommitMessageAsync())?.trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!updateMessage) {
|
|
||||||
if (nonInteractive) {
|
|
||||||
throw new Error('Must supply --message or use --auto when in non-interactive mode');
|
|
||||||
}
|
|
||||||
|
|
||||||
const validationMessage = 'publish message may not be empty.';
|
|
||||||
if (jsonFlag) {
|
|
||||||
throw new Error(validationMessage);
|
|
||||||
}
|
|
||||||
({ updateMessage } = await promptAsync({
|
|
||||||
type: 'text',
|
|
||||||
name: 'updateMessage',
|
|
||||||
message: `Provide an update message.`,
|
|
||||||
initial: (await getVcsClient().getLastCommitMessageAsync())?.trim(),
|
|
||||||
validate: (value: any) => (value ? true : validationMessage),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
// build bundle and upload assets for a new publish
|
// build bundle and upload assets for a new publish
|
||||||
if (!skipBundler) {
|
if (!skipBundler) {
|
||||||
@@ -300,6 +229,7 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
let unsortedUpdateInfoGroups: UpdateInfoGroup = {};
|
let unsortedUpdateInfoGroups: UpdateInfoGroup = {};
|
||||||
let uploadedAssetCount = 0;
|
let uploadedAssetCount = 0;
|
||||||
let assetLimitPerUpdateGroup = 0;
|
let assetLimitPerUpdateGroup = 0;
|
||||||
|
let realizedPlatforms: PublishPlatform[] = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const collectedAssets = await collectAssetsAsync(distRoot);
|
const collectedAssets = await collectAssetsAsync(distRoot);
|
||||||
@@ -318,31 +248,42 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
uploadedAssetCount = uploadResults.uniqueUploadedAssetCount;
|
uploadedAssetCount = uploadResults.uniqueUploadedAssetCount;
|
||||||
assetLimitPerUpdateGroup = uploadResults.assetLimitPerUpdateGroup;
|
assetLimitPerUpdateGroup = uploadResults.assetLimitPerUpdateGroup;
|
||||||
unsortedUpdateInfoGroups = await buildUnsortedUpdateInfoGroupAsync(assets, exp);
|
unsortedUpdateInfoGroups = await buildUnsortedUpdateInfoGroupAsync(assets, exp);
|
||||||
const uploadAssetSuccessMessage = uploadedAssetCount
|
|
||||||
? `Uploaded ${uploadedAssetCount} ${uploadedAssetCount === 1 ? 'platform' : 'platforms'}`
|
// NOTE(cedric): we assume that bundles are always uploaded, and always are part of
|
||||||
: `Uploaded: No changes detected`;
|
// `uploadedAssetCount`, perferably we don't assume. For that, we need to refactor the
|
||||||
assetSpinner.succeed(uploadAssetSuccessMessage);
|
// `uploadAssetsAsync` and be able to determine asset type from the uploaded assets.
|
||||||
|
const uploadedBundleCount = uploadResults.launchAssetCount;
|
||||||
|
const uploadedNormalAssetCount = Math.max(0, uploadedAssetCount - uploadedBundleCount);
|
||||||
|
const reusedNormalAssetCount = uploadResults.uniqueAssetCount - uploadedNormalAssetCount;
|
||||||
|
|
||||||
|
assetSpinner.stop();
|
||||||
|
Log.withTick(
|
||||||
|
`Uploaded ${uploadedBundleCount} app ${uploadedBundleCount === 1 ? 'bundle' : 'bundles'}`
|
||||||
|
);
|
||||||
|
if (uploadedNormalAssetCount === 0) {
|
||||||
|
Log.withTick(`Uploading assets skipped - no new assets found`);
|
||||||
|
} else {
|
||||||
|
let message = `Uploaded ${uploadedNormalAssetCount} ${
|
||||||
|
uploadedNormalAssetCount === 1 ? 'asset' : 'assets'
|
||||||
|
}`;
|
||||||
|
if (reusedNormalAssetCount > 0) {
|
||||||
|
message += ` (reused ${reusedNormalAssetCount} ${
|
||||||
|
reusedNormalAssetCount === 1 ? 'asset' : 'assets'
|
||||||
|
})`;
|
||||||
|
}
|
||||||
|
Log.withTick(message);
|
||||||
|
}
|
||||||
|
for (const uploadedAssetPath of uploadResults.uniqueUploadedAssetPaths) {
|
||||||
|
Log.debug(chalk.dim(`- ${uploadedAssetPath}`));
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
assetSpinner.fail('Failed to upload');
|
assetSpinner.fail('Failed to upload');
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
const truncatedMessage = truncateUpdateMessage(updateMessage!, 1024);
|
|
||||||
if (truncatedMessage !== updateMessage) {
|
|
||||||
Log.warn('Update message exceeds the allowed 1024 character limit. Truncating message...');
|
|
||||||
}
|
|
||||||
|
|
||||||
const runtimeVersions = await getRuntimeVersionObjectAsync(exp, realizedPlatforms, projectDir);
|
const runtimeVersions = await getRuntimeVersionObjectAsync(exp, realizedPlatforms, projectDir);
|
||||||
|
const runtimeToPlatformMapping =
|
||||||
const runtimeToPlatformMapping: { runtimeVersion: string; platforms: string[] }[] = [];
|
getRuntimeToPlatformMappingFromRuntimeVersions(runtimeVersions);
|
||||||
for (const runtime of runtimeVersions) {
|
|
||||||
const platforms = runtimeVersions
|
|
||||||
.filter(({ runtimeVersion }) => runtimeVersion === runtime.runtimeVersion)
|
|
||||||
.map(({ platform }) => platform);
|
|
||||||
if (!runtimeToPlatformMapping.find(item => item.runtimeVersion === runtime.runtimeVersion)) {
|
|
||||||
runtimeToPlatformMapping.push({ runtimeVersion: runtime.runtimeVersion, platforms });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const { branchId, createdBranch } = await ensureBranchExistsAsync(graphqlClient, {
|
const { branchId, createdBranch } = await ensureBranchExistsAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
@@ -377,7 +318,7 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
branchId,
|
branchId,
|
||||||
updateInfoGroup: localUpdateInfoGroup,
|
updateInfoGroup: localUpdateInfoGroup,
|
||||||
runtimeVersion,
|
runtimeVersion,
|
||||||
message: truncatedMessage,
|
message: updateMessage,
|
||||||
gitCommitHash,
|
gitCommitHash,
|
||||||
isGitWorkingTreeDirty,
|
isGitWorkingTreeDirty,
|
||||||
awaitingCodeSigningInfo: !!codeSigningInfo,
|
awaitingCodeSigningInfo: !!codeSigningInfo,
|
||||||
@@ -394,7 +335,10 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
|
|
||||||
const updatesTemp = [...newUpdates];
|
const updatesTemp = [...newUpdates];
|
||||||
const updateGroupsAndTheirUpdates = updateGroups.map(updateGroup => {
|
const updateGroupsAndTheirUpdates = updateGroups.map(updateGroup => {
|
||||||
const newUpdates = updatesTemp.splice(0, Object.keys(updateGroup.updateInfoGroup).length);
|
const newUpdates = updatesTemp.splice(
|
||||||
|
0,
|
||||||
|
Object.keys(nullthrows(updateGroup.updateInfoGroup)).length
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
updateGroup,
|
updateGroup,
|
||||||
newUpdates,
|
newUpdates,
|
||||||
@@ -414,11 +358,13 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
checkManifestBodyAgainstUpdateInfoGroup(
|
checkManifestBodyAgainstUpdateInfoGroup(
|
||||||
manifestBody,
|
manifestBody,
|
||||||
nullthrows(
|
nullthrows(
|
||||||
updateGroup.updateInfoGroup[newUpdate.platform as keyof UpdateInfoGroup]
|
nullthrows(updateGroup.updateInfoGroup)[
|
||||||
|
newUpdate.platform as keyof UpdateInfoGroup
|
||||||
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
const manifestSignature = signManifestBody(manifestBody, codeSigningInfo);
|
const manifestSignature = signBody(manifestBody, codeSigningInfo);
|
||||||
|
|
||||||
await PublishMutation.setCodeSigningInfoAsync(graphqlClient, newUpdate.id, {
|
await PublishMutation.setCodeSigningInfoAsync(graphqlClient, newUpdate.id, {
|
||||||
alg: codeSigningInfo.codeSigningMetadata.alg,
|
alg: codeSigningInfo.codeSigningMetadata.alg,
|
||||||
@@ -480,7 +426,7 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
? [{ label: 'Android update ID', value: newAndroidUpdate.id }]
|
? [{ label: 'Android update ID', value: newAndroidUpdate.id }]
|
||||||
: []),
|
: []),
|
||||||
...(newIosUpdate ? [{ label: 'iOS update ID', value: newIosUpdate.id }] : []),
|
...(newIosUpdate ? [{ label: 'iOS update ID', value: newIosUpdate.id }] : []),
|
||||||
{ label: 'Message', value: truncatedMessage },
|
{ label: 'Message', value: updateMessage },
|
||||||
...(gitCommitHash
|
...(gitCommitHash
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
@@ -551,41 +497,3 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get runtime versions grouped by platform. Runtime version is always `null` on web where the platform is always backwards compatible. */
|
|
||||||
async function getRuntimeVersionObjectAsync(
|
|
||||||
exp: ExpoConfig,
|
|
||||||
platforms: PublishPlatform[],
|
|
||||||
projectDir: string
|
|
||||||
): Promise<{ platform: string; runtimeVersion: string }[]> {
|
|
||||||
for (const platform of platforms) {
|
|
||||||
if (platform === 'web') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const isPolicy = typeof (exp[platform]?.runtimeVersion ?? exp.runtimeVersion) === 'object';
|
|
||||||
if (isPolicy) {
|
|
||||||
const isManaged =
|
|
||||||
(await resolveWorkflowAsync(projectDir, platform as Platform)) === Workflow.MANAGED;
|
|
||||||
if (!isManaged) {
|
|
||||||
throw new Error(
|
|
||||||
'Runtime version policies are only supported in the managed workflow. In the bare workflow, runtime version needs to be set manually.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return [...new Set(platforms)].map(platform => {
|
|
||||||
if (platform === 'web') {
|
|
||||||
return { platform: 'web', runtimeVersion: 'UNVERSIONED' };
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
platform,
|
|
||||||
runtimeVersion: nullthrows(
|
|
||||||
Updates.getRuntimeVersion(exp, platform),
|
|
||||||
`Unable to determine runtime version for ${
|
|
||||||
requestedPlatformDisplayNames[platform]
|
|
||||||
}. ${learnMore('https://docs.expo.dev/eas-update/runtime-versions/')}`
|
|
||||||
),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -56,7 +56,7 @@ type UpdateToRepublish = {
|
|||||||
>;
|
>;
|
||||||
|
|
||||||
export default class UpdateRepublish extends EasCommand {
|
export default class UpdateRepublish extends EasCommand {
|
||||||
static override description = 'rollback to an existing update';
|
static override description = 'roll back to an existing update';
|
||||||
|
|
||||||
static override flags = {
|
static override flags = {
|
||||||
channel: Flags.string({
|
channel: Flags.string({
|
||||||
|
|||||||
@@ -0,0 +1,389 @@
|
|||||||
|
import { Platform as PublishPlatform } from '@expo/config';
|
||||||
|
import { Errors, Flags } from '@oclif/core';
|
||||||
|
import chalk from 'chalk';
|
||||||
|
import nullthrows from 'nullthrows';
|
||||||
|
|
||||||
|
import { ensureBranchExistsAsync } from '../../branch/queries';
|
||||||
|
import { getUpdateGroupUrl } from '../../build/utils/url';
|
||||||
|
import { ensureChannelExistsAsync } from '../../channel/queries';
|
||||||
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
|
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
||||||
|
import { getPaginatedQueryOptions } from '../../commandUtils/pagination';
|
||||||
|
import fetch from '../../fetch';
|
||||||
|
import {
|
||||||
|
PublishUpdateGroupInput,
|
||||||
|
StatuspageServiceName,
|
||||||
|
UpdatePublishMutation,
|
||||||
|
} from '../../graphql/generated';
|
||||||
|
import { PublishMutation } from '../../graphql/mutations/PublishMutation';
|
||||||
|
import Log, { link } from '../../log';
|
||||||
|
import { ora } from '../../ora';
|
||||||
|
import { RequestedPlatform } from '../../platform';
|
||||||
|
import { getOwnerAccountForProjectIdAsync } from '../../project/projectUtils';
|
||||||
|
import {
|
||||||
|
ExpoCLIExportPlatformFlag,
|
||||||
|
defaultPublishPlatforms,
|
||||||
|
getBranchNameForCommandAsync,
|
||||||
|
getRequestedPlatform,
|
||||||
|
getRuntimeToPlatformMappingFromRuntimeVersions,
|
||||||
|
getRuntimeVersionObjectAsync,
|
||||||
|
getUpdateMessageForCommandAsync,
|
||||||
|
} from '../../project/publish';
|
||||||
|
import { ensureEASUpdateIsConfiguredAsync } from '../../update/configure';
|
||||||
|
import { getUpdateGroupJsonInfo } from '../../update/utils';
|
||||||
|
import {
|
||||||
|
CodeSigningInfo,
|
||||||
|
checkDirectiveBodyAgainstUpdateInfoGroup,
|
||||||
|
getCodeSigningInfoAsync,
|
||||||
|
getDirectiveBodyAsync,
|
||||||
|
signBody,
|
||||||
|
} from '../../utils/code-signing';
|
||||||
|
import uniqBy from '../../utils/expodash/uniqBy';
|
||||||
|
import formatFields from '../../utils/formatFields';
|
||||||
|
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
|
||||||
|
import { maybeWarnAboutEasOutagesAsync } from '../../utils/statuspageService';
|
||||||
|
import { getVcsClient } from '../../vcs';
|
||||||
|
|
||||||
|
type RawUpdateFlags = {
|
||||||
|
auto: boolean;
|
||||||
|
branch?: string;
|
||||||
|
channel?: string;
|
||||||
|
message?: string;
|
||||||
|
platform: string;
|
||||||
|
'private-key-path'?: string;
|
||||||
|
'non-interactive': boolean;
|
||||||
|
json: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
type UpdateFlags = {
|
||||||
|
auto: boolean;
|
||||||
|
platform: ExpoCLIExportPlatformFlag;
|
||||||
|
branchName?: string;
|
||||||
|
channelName?: string;
|
||||||
|
updateMessage?: string;
|
||||||
|
privateKeyPath?: string;
|
||||||
|
json: boolean;
|
||||||
|
nonInteractive: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class UpdateRollBackToEmbedded extends EasCommand {
|
||||||
|
static override hidden = true; // until we launch
|
||||||
|
static override description = 'roll back to the embedded update';
|
||||||
|
|
||||||
|
static override flags = {
|
||||||
|
branch: Flags.string({
|
||||||
|
description: 'Branch to publish the rollback to embedded update group on',
|
||||||
|
required: false,
|
||||||
|
}),
|
||||||
|
channel: Flags.string({
|
||||||
|
description: 'Channel that the published rollback to embedded update should affect',
|
||||||
|
required: false,
|
||||||
|
}),
|
||||||
|
message: Flags.string({
|
||||||
|
description: 'A short message describing the rollback to embedded update',
|
||||||
|
required: false,
|
||||||
|
}),
|
||||||
|
platform: Flags.enum({
|
||||||
|
char: 'p',
|
||||||
|
options: [...defaultPublishPlatforms, 'all'],
|
||||||
|
default: 'all',
|
||||||
|
required: false,
|
||||||
|
}),
|
||||||
|
auto: Flags.boolean({
|
||||||
|
description:
|
||||||
|
'Use the current git branch and commit message for the EAS branch and update message',
|
||||||
|
default: false,
|
||||||
|
}),
|
||||||
|
'private-key-path': Flags.string({
|
||||||
|
description: `File containing the PEM-encoded private key corresponding to the certificate in expo-updates' configuration. Defaults to a file named "private-key.pem" in the certificate's directory.`,
|
||||||
|
required: false,
|
||||||
|
}),
|
||||||
|
...EasNonInteractiveAndJsonFlags,
|
||||||
|
};
|
||||||
|
|
||||||
|
static override contextDefinition = {
|
||||||
|
...this.ContextOptions.DynamicProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
|
};
|
||||||
|
|
||||||
|
async runAsync(): Promise<void> {
|
||||||
|
const { flags: rawFlags } = await this.parse(UpdateRollBackToEmbedded);
|
||||||
|
const paginatedQueryOptions = getPaginatedQueryOptions(rawFlags);
|
||||||
|
const {
|
||||||
|
auto: autoFlag,
|
||||||
|
platform: platformFlag,
|
||||||
|
channelName: channelNameArg,
|
||||||
|
updateMessage: updateMessageArg,
|
||||||
|
privateKeyPath,
|
||||||
|
json: jsonFlag,
|
||||||
|
nonInteractive,
|
||||||
|
branchName: branchNameArg,
|
||||||
|
} = this.sanitizeFlags(rawFlags);
|
||||||
|
|
||||||
|
const {
|
||||||
|
getDynamicProjectConfigAsync,
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
|
} = await this.getContextAsync(UpdateRollBackToEmbedded, {
|
||||||
|
nonInteractive,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (jsonFlag) {
|
||||||
|
enableJsonOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
const {
|
||||||
|
exp: expPossiblyWithoutEasUpdateConfigured,
|
||||||
|
projectId,
|
||||||
|
projectDir,
|
||||||
|
} = await getDynamicProjectConfigAsync({
|
||||||
|
isPublicConfig: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
await maybeWarnAboutEasOutagesAsync(graphqlClient, [StatuspageServiceName.EasUpdate]);
|
||||||
|
|
||||||
|
await ensureEASUpdateIsConfiguredAsync(graphqlClient, {
|
||||||
|
exp: expPossiblyWithoutEasUpdateConfigured,
|
||||||
|
platform: getRequestedPlatform(platformFlag),
|
||||||
|
projectDir,
|
||||||
|
projectId,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { exp } = await getDynamicProjectConfigAsync({ isPublicConfig: true });
|
||||||
|
const { exp: expPrivate } = await getDynamicProjectConfigAsync({
|
||||||
|
isPublicConfig: false,
|
||||||
|
});
|
||||||
|
const codeSigningInfo = await getCodeSigningInfoAsync(expPrivate, privateKeyPath);
|
||||||
|
|
||||||
|
const branchName = await getBranchNameForCommandAsync({
|
||||||
|
graphqlClient,
|
||||||
|
projectId,
|
||||||
|
channelNameArg,
|
||||||
|
branchNameArg,
|
||||||
|
autoFlag,
|
||||||
|
nonInteractive,
|
||||||
|
paginatedQueryOptions,
|
||||||
|
});
|
||||||
|
|
||||||
|
const updateMessage = await getUpdateMessageForCommandAsync({
|
||||||
|
updateMessageArg,
|
||||||
|
autoFlag,
|
||||||
|
nonInteractive,
|
||||||
|
jsonFlag,
|
||||||
|
});
|
||||||
|
|
||||||
|
const realizedPlatforms: PublishPlatform[] =
|
||||||
|
platformFlag === 'all' ? defaultPublishPlatforms : [platformFlag];
|
||||||
|
|
||||||
|
const { branchId, createdBranch } = await ensureBranchExistsAsync(graphqlClient, {
|
||||||
|
appId: projectId,
|
||||||
|
branchName,
|
||||||
|
});
|
||||||
|
if (createdBranch) {
|
||||||
|
await ensureChannelExistsAsync(graphqlClient, {
|
||||||
|
appId: projectId,
|
||||||
|
branchId,
|
||||||
|
channelName: branchName,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.withTick(`Channel: ${chalk.bold(branchName)} pointed at branch: ${chalk.bold(branchName)}`);
|
||||||
|
|
||||||
|
const vcsClient = getVcsClient();
|
||||||
|
|
||||||
|
const gitCommitHash = await vcsClient.getCommitHashAsync();
|
||||||
|
const isGitWorkingTreeDirty = await vcsClient.hasUncommittedChangesAsync();
|
||||||
|
|
||||||
|
const runtimeVersions = await getRuntimeVersionObjectAsync(exp, realizedPlatforms, projectDir);
|
||||||
|
|
||||||
|
let newUpdates: UpdatePublishMutation['updateBranch']['publishUpdateGroups'];
|
||||||
|
const publishSpinner = ora('Publishing...').start();
|
||||||
|
try {
|
||||||
|
newUpdates = await this.publishRollbacksAsync({
|
||||||
|
graphqlClient,
|
||||||
|
isGitWorkingTreeDirty,
|
||||||
|
gitCommitHash,
|
||||||
|
updateMessage,
|
||||||
|
branchId,
|
||||||
|
codeSigningInfo,
|
||||||
|
runtimeVersions,
|
||||||
|
realizedPlatforms,
|
||||||
|
});
|
||||||
|
publishSpinner.succeed('Published!');
|
||||||
|
} catch (e) {
|
||||||
|
publishSpinner.fail('Failed to publish updates');
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jsonFlag) {
|
||||||
|
printJsonOnlyOutput(getUpdateGroupJsonInfo(newUpdates));
|
||||||
|
} else {
|
||||||
|
if (new Set(newUpdates.map(update => update.group)).size > 1) {
|
||||||
|
Log.addNewLineIfNone();
|
||||||
|
Log.log(
|
||||||
|
'👉 Since multiple runtime versions are defined, multiple update groups have been published.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.addNewLineIfNone();
|
||||||
|
|
||||||
|
for (const runtime of uniqBy(runtimeVersions, version => version.runtimeVersion)) {
|
||||||
|
const newUpdatesForRuntimeVersion = newUpdates.filter(
|
||||||
|
update => update.runtimeVersion === runtime.runtimeVersion
|
||||||
|
);
|
||||||
|
if (newUpdatesForRuntimeVersion.length === 0) {
|
||||||
|
throw new Error(
|
||||||
|
`Publish response is missing updates with runtime ${runtime.runtimeVersion}.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const platforms = newUpdatesForRuntimeVersion.map(update => update.platform);
|
||||||
|
const newAndroidUpdate = newUpdatesForRuntimeVersion.find(
|
||||||
|
update => update.platform === 'android'
|
||||||
|
);
|
||||||
|
const newIosUpdate = newUpdatesForRuntimeVersion.find(update => update.platform === 'ios');
|
||||||
|
const updateGroupId = newUpdatesForRuntimeVersion[0].group;
|
||||||
|
|
||||||
|
const projectName = exp.slug;
|
||||||
|
const accountName = (await getOwnerAccountForProjectIdAsync(graphqlClient, projectId)).name;
|
||||||
|
const updateGroupUrl = getUpdateGroupUrl(accountName, projectName, updateGroupId);
|
||||||
|
const updateGroupLink = link(updateGroupUrl, { dim: false });
|
||||||
|
|
||||||
|
Log.log(
|
||||||
|
formatFields([
|
||||||
|
{ label: 'Branch', value: branchName },
|
||||||
|
{ label: 'Runtime version', value: runtime.runtimeVersion },
|
||||||
|
{ label: 'Platform', value: platforms.join(', ') },
|
||||||
|
{ label: 'Update group ID', value: updateGroupId },
|
||||||
|
...(newAndroidUpdate
|
||||||
|
? [{ label: 'Android update ID', value: newAndroidUpdate.id }]
|
||||||
|
: []),
|
||||||
|
...(newIosUpdate ? [{ label: 'iOS update ID', value: newIosUpdate.id }] : []),
|
||||||
|
{ label: 'Message', value: updateMessage },
|
||||||
|
...(gitCommitHash
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
label: 'Commit',
|
||||||
|
value: `${gitCommitHash}${isGitWorkingTreeDirty ? '*' : ''}`,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
{ label: 'Website link', value: updateGroupLink },
|
||||||
|
])
|
||||||
|
);
|
||||||
|
Log.addNewLineIfNone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async publishRollbacksAsync({
|
||||||
|
graphqlClient,
|
||||||
|
isGitWorkingTreeDirty,
|
||||||
|
gitCommitHash,
|
||||||
|
updateMessage,
|
||||||
|
branchId,
|
||||||
|
codeSigningInfo,
|
||||||
|
runtimeVersions,
|
||||||
|
realizedPlatforms,
|
||||||
|
}: {
|
||||||
|
graphqlClient: ExpoGraphqlClient;
|
||||||
|
isGitWorkingTreeDirty: boolean | undefined;
|
||||||
|
gitCommitHash: string | undefined;
|
||||||
|
updateMessage: string;
|
||||||
|
branchId: string;
|
||||||
|
codeSigningInfo: CodeSigningInfo | undefined;
|
||||||
|
runtimeVersions: { platform: string; runtimeVersion: string }[];
|
||||||
|
realizedPlatforms: PublishPlatform[];
|
||||||
|
}): Promise<UpdatePublishMutation['updateBranch']['publishUpdateGroups']> {
|
||||||
|
const runtimeToPlatformMapping =
|
||||||
|
getRuntimeToPlatformMappingFromRuntimeVersions(runtimeVersions);
|
||||||
|
const rollbackInfoGroups = Object.fromEntries(
|
||||||
|
realizedPlatforms.map(platform => [platform, true])
|
||||||
|
);
|
||||||
|
|
||||||
|
// Sort the updates into different groups based on their platform specific runtime versions
|
||||||
|
const updateGroups: PublishUpdateGroupInput[] = runtimeToPlatformMapping.map(
|
||||||
|
({ runtimeVersion, platforms }) => {
|
||||||
|
const localRollbackInfoGroup = Object.fromEntries(
|
||||||
|
platforms.map(platform => [platform, rollbackInfoGroups[platform]])
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
branchId,
|
||||||
|
rollBackToEmbeddedInfoGroup: localRollbackInfoGroup,
|
||||||
|
runtimeVersion,
|
||||||
|
message: updateMessage,
|
||||||
|
gitCommitHash,
|
||||||
|
isGitWorkingTreeDirty,
|
||||||
|
awaitingCodeSigningInfo: !!codeSigningInfo,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const newUpdates = await PublishMutation.publishUpdateGroupAsync(graphqlClient, updateGroups);
|
||||||
|
|
||||||
|
if (codeSigningInfo) {
|
||||||
|
Log.log('🔒 Signing roll back');
|
||||||
|
|
||||||
|
const updatesTemp = [...newUpdates];
|
||||||
|
const updateGroupsAndTheirUpdates = updateGroups.map(updateGroup => {
|
||||||
|
const newUpdates = updatesTemp.splice(
|
||||||
|
0,
|
||||||
|
Object.keys(nullthrows(updateGroup.rollBackToEmbeddedInfoGroup)).length
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
updateGroup,
|
||||||
|
newUpdates,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
updateGroupsAndTheirUpdates.map(async ({ newUpdates }) => {
|
||||||
|
await Promise.all(
|
||||||
|
newUpdates.map(async newUpdate => {
|
||||||
|
const response = await fetch(newUpdate.manifestPermalink, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: { accept: 'multipart/mixed' },
|
||||||
|
});
|
||||||
|
const directiveBody = nullthrows(await getDirectiveBodyAsync(response));
|
||||||
|
|
||||||
|
checkDirectiveBodyAgainstUpdateInfoGroup(directiveBody);
|
||||||
|
|
||||||
|
const directiveSignature = signBody(directiveBody, codeSigningInfo);
|
||||||
|
|
||||||
|
await PublishMutation.setCodeSigningInfoAsync(graphqlClient, newUpdate.id, {
|
||||||
|
alg: codeSigningInfo.codeSigningMetadata.alg,
|
||||||
|
keyid: codeSigningInfo.codeSigningMetadata.keyid,
|
||||||
|
sig: directiveSignature,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return newUpdates;
|
||||||
|
}
|
||||||
|
|
||||||
|
private sanitizeFlags(flags: RawUpdateFlags): UpdateFlags {
|
||||||
|
const nonInteractive = flags['non-interactive'] ?? false;
|
||||||
|
|
||||||
|
const { auto, branch: branchName, channel: channelName, message: updateMessage } = flags;
|
||||||
|
if (nonInteractive && !auto && !(updateMessage && (branchName || channelName))) {
|
||||||
|
Errors.error(
|
||||||
|
'--branch and --message, or --channel and --message are required when updating in non-interactive mode unless --auto is specified',
|
||||||
|
{ exit: 1 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
auto,
|
||||||
|
branchName,
|
||||||
|
channelName,
|
||||||
|
updateMessage,
|
||||||
|
platform: flags.platform as RequestedPlatform,
|
||||||
|
privateKeyPath: flags['private-key-path'],
|
||||||
|
nonInteractive,
|
||||||
|
json: flags.json ?? false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -128,7 +128,7 @@ export default class IosCredentialsProvider {
|
|||||||
private async disablePushNotificationsSetupInEasJsonAsync(
|
private async disablePushNotificationsSetupInEasJsonAsync(
|
||||||
ctx: CredentialsContext
|
ctx: CredentialsContext
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const easJsonAccessor = new EasJsonAccessor(ctx.projectDir);
|
const easJsonAccessor = EasJsonAccessor.fromProjectPath(ctx.projectDir);
|
||||||
await easJsonAccessor.readRawJsonAsync();
|
await easJsonAccessor.readRawJsonAsync();
|
||||||
easJsonAccessor.patch(easJsonRawObject => {
|
easJsonAccessor.patch(easJsonRawObject => {
|
||||||
easJsonRawObject.cli = {
|
easJsonRawObject.cli = {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export class SelectBuildProfileFromEasJson<T extends Platform> {
|
|||||||
private easJsonAccessor: EasJsonAccessor;
|
private easJsonAccessor: EasJsonAccessor;
|
||||||
|
|
||||||
constructor(projectDir: string, private platform: T) {
|
constructor(projectDir: string, private platform: T) {
|
||||||
this.easJsonAccessor = new EasJsonAccessor(projectDir);
|
this.easJsonAccessor = EasJsonAccessor.fromProjectPath(projectDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
async runAsync(): Promise<BuildProfile<T>> {
|
async runAsync(): Promise<BuildProfile<T>> {
|
||||||
|
|||||||
+510
-115
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,66 @@
|
|||||||
|
import assert from 'assert';
|
||||||
|
import gql from 'graphql-tag';
|
||||||
|
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
|
import { withErrorHandlingAsync } from '../client';
|
||||||
|
import { BillingUpdateByAccountQuery } from '../generated';
|
||||||
|
|
||||||
|
export const BillingUpdateQuery = {
|
||||||
|
async byAccountIdAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
|
accountId: string,
|
||||||
|
date: Date
|
||||||
|
): Promise<BillingUpdateByAccountQuery['account']['byId']> {
|
||||||
|
const data = await withErrorHandlingAsync(
|
||||||
|
graphqlClient
|
||||||
|
.query<BillingUpdateByAccountQuery>(
|
||||||
|
gql`
|
||||||
|
query BillingUpdateByAccountQuery($accountId: String!, $date: DateTime!) {
|
||||||
|
account {
|
||||||
|
byId(accountId: $accountId) {
|
||||||
|
id
|
||||||
|
billing {
|
||||||
|
id
|
||||||
|
subscription {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
meteredBillingStatus {
|
||||||
|
EAS_UPDATE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
usageMetrics {
|
||||||
|
byBillingPeriod(date: $date, service: UPDATES) {
|
||||||
|
id
|
||||||
|
planMetrics {
|
||||||
|
id
|
||||||
|
serviceMetric
|
||||||
|
metricType
|
||||||
|
value
|
||||||
|
limit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
{ accountId, date },
|
||||||
|
{
|
||||||
|
additionalTypenames: [
|
||||||
|
'Account',
|
||||||
|
'Billing',
|
||||||
|
'SubscriptionDetails',
|
||||||
|
'AccountUsageMetrics',
|
||||||
|
'UsageMetricTotal',
|
||||||
|
'EstimatedUsage',
|
||||||
|
],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.toPromise()
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(data.account, 'GraphQL: `account` not defined in server response');
|
||||||
|
return data.account.byId;
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import gql from 'graphql-tag';
|
||||||
|
|
||||||
|
export const AccountUpdatesUsageFragmentNode = gql`
|
||||||
|
fragment AccountUpdatesUsageFragment on Account {
|
||||||
|
id
|
||||||
|
billing {
|
||||||
|
id
|
||||||
|
subscription {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
meteredBillingStatus {
|
||||||
|
EAS_UPDATE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
usageMetrics {
|
||||||
|
byBillingPeriod(date: $date, service: UPDATES) {
|
||||||
|
id
|
||||||
|
planMetrics {
|
||||||
|
id
|
||||||
|
serviceMetric
|
||||||
|
metricType
|
||||||
|
value
|
||||||
|
limit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@@ -52,6 +52,7 @@ export const BuildFragmentNode = gql`
|
|||||||
priority
|
priority
|
||||||
createdAt
|
createdAt
|
||||||
updatedAt
|
updatedAt
|
||||||
|
message
|
||||||
completedAt
|
completedAt
|
||||||
resourceClass
|
resourceClass
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export const UpdateFragmentNode = gql`
|
|||||||
runtimeVersion
|
runtimeVersion
|
||||||
platform
|
platform
|
||||||
manifestFragment
|
manifestFragment
|
||||||
|
isRollBackToEmbedded
|
||||||
manifestPermalink
|
manifestPermalink
|
||||||
gitCommitHash
|
gitCommitHash
|
||||||
actor {
|
actor {
|
||||||
|
|||||||
@@ -90,11 +90,12 @@ export default class Log {
|
|||||||
*/
|
*/
|
||||||
export function link(
|
export function link(
|
||||||
url: string,
|
url: string,
|
||||||
{ text = url, dim = true }: { text?: string; dim?: boolean } = {}
|
{ text = url, fallback, dim = true }: { text?: string; dim?: boolean; fallback?: string } = {}
|
||||||
): string {
|
): string {
|
||||||
// Links can be disabled via env variables https://github.com/jamestalmage/supports-hyperlinks/blob/master/index.js
|
// Links can be disabled via env variables https://github.com/jamestalmage/supports-hyperlinks/blob/master/index.js
|
||||||
const output = terminalLink(text, url, {
|
const output = terminalLink(text, url, {
|
||||||
fallback: () => (text === url ? chalk.underline(url) : `${text}: ${chalk.underline(url)}`),
|
fallback: () =>
|
||||||
|
fallback ?? (text === url ? chalk.underline(url) : `${text}: ${chalk.underline(url)}`),
|
||||||
});
|
});
|
||||||
return dim ? chalk.dim(output) : output;
|
return dim ? chalk.dim(output) : output;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { instance, mock } from 'ts-mockito';
|
|||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { defaultPublishPlatforms } from '../../commands/update';
|
|
||||||
import { AssetMetadataStatus } from '../../graphql/generated';
|
import { AssetMetadataStatus } from '../../graphql/generated';
|
||||||
import { PublishMutation } from '../../graphql/mutations/PublishMutation';
|
import { PublishMutation } from '../../graphql/mutations/PublishMutation';
|
||||||
import { PublishQuery } from '../../graphql/queries/PublishQuery';
|
import { PublishQuery } from '../../graphql/queries/PublishQuery';
|
||||||
@@ -14,9 +13,12 @@ import {
|
|||||||
buildUnsortedUpdateInfoGroupAsync,
|
buildUnsortedUpdateInfoGroupAsync,
|
||||||
collectAssetsAsync,
|
collectAssetsAsync,
|
||||||
convertAssetToUpdateInfoGroupFormatAsync,
|
convertAssetToUpdateInfoGroupFormatAsync,
|
||||||
|
defaultPublishPlatforms,
|
||||||
filterExportedPlatformsByFlag,
|
filterExportedPlatformsByFlag,
|
||||||
filterOutAssetsThatAlreadyExistAsync,
|
filterOutAssetsThatAlreadyExistAsync,
|
||||||
|
getAssetHashFromPath,
|
||||||
getBase64URLEncoding,
|
getBase64URLEncoding,
|
||||||
|
getOriginalPathFromAssetMap,
|
||||||
getStorageKey,
|
getStorageKey,
|
||||||
getStorageKeyForAssetAsync,
|
getStorageKeyForAssetAsync,
|
||||||
guessContentTypeFromExtension,
|
guessContentTypeFromExtension,
|
||||||
@@ -279,9 +281,55 @@ describe(resolveInputDirectoryAsync, () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe(getAssetHashFromPath, () => {
|
||||||
|
it('returns asset hash from path', () => {
|
||||||
|
expect(getAssetHashFromPath('assets/5b2a819c71d035ca45d223e4c47ed4f9')).toBe(
|
||||||
|
'5b2a819c71d035ca45d223e4c47ed4f9'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('returns null for incorrect path', () => {
|
||||||
|
expect(getAssetHashFromPath('assets/this/is/not/a/hash.jpg')).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe(getOriginalPathFromAssetMap, () => {
|
||||||
|
// Partial assetmap.json, with only fields we need
|
||||||
|
const fakeAssetMap = {
|
||||||
|
'5b2a819c71d035ca45d223e4c47ed4f9': {
|
||||||
|
httpServerLocation: '/assets/src/assets',
|
||||||
|
name: 'asset-420',
|
||||||
|
type: 'jpg',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
it('returns null path when asset map is null', () => {
|
||||||
|
expect(
|
||||||
|
getOriginalPathFromAssetMap(null, {
|
||||||
|
path: 'assets/5b2a819c71d035ca45d223e4c47ed4f9',
|
||||||
|
ext: 'jpg',
|
||||||
|
})
|
||||||
|
).toBeNull();
|
||||||
|
});
|
||||||
|
it('returns null when asset is not found in asset map', () => {
|
||||||
|
expect(
|
||||||
|
getOriginalPathFromAssetMap(fakeAssetMap, {
|
||||||
|
path: 'assets/fb64d3b2fb71b3d739ad5c13a93e12c5',
|
||||||
|
ext: 'jpg',
|
||||||
|
})
|
||||||
|
).toBeNull();
|
||||||
|
});
|
||||||
|
it('returns reconstructed original path from existing asset in asset map', () => {
|
||||||
|
expect(
|
||||||
|
getOriginalPathFromAssetMap(fakeAssetMap, {
|
||||||
|
path: 'assets/5b2a819c71d035ca45d223e4c47ed4f9',
|
||||||
|
ext: 'jpg',
|
||||||
|
})
|
||||||
|
).toBe('/src/assets/asset-420.jpg');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe(collectAssetsAsync, () => {
|
describe(collectAssetsAsync, () => {
|
||||||
it('builds an update info group', async () => {
|
it('builds an update info group', async () => {
|
||||||
const fakeHash = 'md5-hash-of-jpg';
|
const fakeHash = 'hdahukw8adhawi8fawhfa8';
|
||||||
const bundles = {
|
const bundles = {
|
||||||
android: 'android-bundle-code',
|
android: 'android-bundle-code',
|
||||||
ios: 'ios-bundle-code',
|
ios: 'ios-bundle-code',
|
||||||
@@ -294,6 +342,7 @@ describe(collectAssetsAsync, () => {
|
|||||||
fileExtension: '.jpg',
|
fileExtension: '.jpg',
|
||||||
contentType: 'image/jpeg',
|
contentType: 'image/jpeg',
|
||||||
path: `${inputDir}/assets/${fakeHash}`,
|
path: `${inputDir}/assets/${fakeHash}`,
|
||||||
|
originalPath: `assets/wat.jpg`,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -326,6 +375,24 @@ describe(collectAssetsAsync, () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
await fs.writeFile(
|
||||||
|
path.resolve(inputDir, 'assetmap.json'),
|
||||||
|
JSON.stringify({
|
||||||
|
[fakeHash]: {
|
||||||
|
__packager_asset: true,
|
||||||
|
fileSystemLocation: '/Users/blah/temp/assets',
|
||||||
|
httpServerLocation: 'assets/assets',
|
||||||
|
width: 2339,
|
||||||
|
height: 1560,
|
||||||
|
scales: [1],
|
||||||
|
files: ['/Users/blah/temp/assets/wat.jpg'],
|
||||||
|
hash: fakeHash,
|
||||||
|
name: 'wat',
|
||||||
|
type: 'jpg',
|
||||||
|
fileHashes: [fakeHash],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
expect(await collectAssetsAsync(inputDir)).toEqual({
|
expect(await collectAssetsAsync(inputDir)).toEqual({
|
||||||
android: {
|
android: {
|
||||||
@@ -410,6 +477,7 @@ describe(uploadAssetsAsync, () => {
|
|||||||
const androidBundlePath = uuidv4();
|
const androidBundlePath = uuidv4();
|
||||||
const iosBundlePath = uuidv4();
|
const iosBundlePath = uuidv4();
|
||||||
const dummyFilePath = uuidv4();
|
const dummyFilePath = uuidv4();
|
||||||
|
const dummyOriginalFilePath = uuidv4();
|
||||||
const userDefinedPath = uuidv4();
|
const userDefinedPath = uuidv4();
|
||||||
const testProjectId = uuidv4();
|
const testProjectId = uuidv4();
|
||||||
const expectedAssetLimit = 1400;
|
const expectedAssetLimit = 1400;
|
||||||
@@ -427,7 +495,15 @@ describe(uploadAssetsAsync, () => {
|
|||||||
contentType: 'application/javascript',
|
contentType: 'application/javascript',
|
||||||
path: androidBundlePath,
|
path: androidBundlePath,
|
||||||
},
|
},
|
||||||
assets: [userDefinedAsset, { type: 'jpg', contentType: 'image/jpeg', path: dummyFilePath }],
|
assets: [
|
||||||
|
userDefinedAsset,
|
||||||
|
{
|
||||||
|
type: 'jpg',
|
||||||
|
contentType: 'image/jpeg',
|
||||||
|
path: dummyFilePath,
|
||||||
|
originalPath: dummyOriginalFilePath,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
ios: {
|
ios: {
|
||||||
launchAsset: {
|
launchAsset: {
|
||||||
@@ -435,7 +511,15 @@ describe(uploadAssetsAsync, () => {
|
|||||||
contentType: 'application/javascript',
|
contentType: 'application/javascript',
|
||||||
path: androidBundlePath,
|
path: androidBundlePath,
|
||||||
},
|
},
|
||||||
assets: [userDefinedAsset, { type: 'jpg', contentType: 'image/jpeg', path: dummyFilePath }],
|
assets: [
|
||||||
|
userDefinedAsset,
|
||||||
|
{
|
||||||
|
type: 'jpg',
|
||||||
|
contentType: 'image/jpeg',
|
||||||
|
path: dummyFilePath,
|
||||||
|
originalPath: dummyOriginalFilePath,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -490,8 +574,10 @@ describe(uploadAssetsAsync, () => {
|
|||||||
uploadAssetsAsync(graphqlClient, assetsForUpdateInfoGroup, testProjectId)
|
uploadAssetsAsync(graphqlClient, assetsForUpdateInfoGroup, testProjectId)
|
||||||
).resolves.toEqual({
|
).resolves.toEqual({
|
||||||
assetCount: 6,
|
assetCount: 6,
|
||||||
|
launchAssetCount: 2,
|
||||||
uniqueAssetCount: 3,
|
uniqueAssetCount: 3,
|
||||||
uniqueUploadedAssetCount: 0,
|
uniqueUploadedAssetCount: 0,
|
||||||
|
uniqueUploadedAssetPaths: [],
|
||||||
assetLimitPerUpdateGroup: expectedAssetLimit,
|
assetLimitPerUpdateGroup: expectedAssetLimit,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -526,8 +612,10 @@ describe(uploadAssetsAsync, () => {
|
|||||||
uploadAssetsAsync(graphqlClient, assetsForUpdateInfoGroup, testProjectId)
|
uploadAssetsAsync(graphqlClient, assetsForUpdateInfoGroup, testProjectId)
|
||||||
).resolves.toEqual({
|
).resolves.toEqual({
|
||||||
assetCount: 6,
|
assetCount: 6,
|
||||||
|
launchAssetCount: 2,
|
||||||
uniqueAssetCount: 3,
|
uniqueAssetCount: 3,
|
||||||
uniqueUploadedAssetCount: 2,
|
uniqueUploadedAssetCount: 2,
|
||||||
|
uniqueUploadedAssetPaths: [],
|
||||||
assetLimitPerUpdateGroup: expectedAssetLimit,
|
assetLimitPerUpdateGroup: expectedAssetLimit,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import { vol } from 'memfs';
|
import { vol } from 'memfs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
import { instance, mock } from 'ts-mockito';
|
||||||
|
|
||||||
import { jester as mockJester } from '../../../credentials/__tests__/fixtures-constants';
|
import { ExpoGraphqlClient } from '../../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
|
import { jester, jester as mockJester } from '../../../credentials/__tests__/fixtures-constants';
|
||||||
|
import { AppQuery } from '../../../graphql/queries/AppQuery';
|
||||||
import { promptAsync } from '../../../prompts';
|
import { promptAsync } from '../../../prompts';
|
||||||
import {
|
import {
|
||||||
ensureApplicationIdIsDefinedForManagedProjectAsync,
|
ensureApplicationIdIsDefinedForManagedProjectAsync,
|
||||||
@@ -11,6 +14,7 @@ import {
|
|||||||
|
|
||||||
jest.mock('fs');
|
jest.mock('fs');
|
||||||
jest.mock('../../../prompts');
|
jest.mock('../../../prompts');
|
||||||
|
jest.mock('../../../graphql/queries/AppQuery');
|
||||||
jest.mock('../../../user/actions', () => ({ ensureLoggedInAsync: jest.fn(() => mockJester) }));
|
jest.mock('../../../user/actions', () => ({ ensureLoggedInAsync: jest.fn(() => mockJester) }));
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@@ -103,6 +107,8 @@ describe(getApplicationIdAsync, () => {
|
|||||||
describe(ensureApplicationIdIsDefinedForManagedProjectAsync, () => {
|
describe(ensureApplicationIdIsDefinedForManagedProjectAsync, () => {
|
||||||
describe('managed project + android.package missing in app config', () => {
|
describe('managed project + android.package missing in app config', () => {
|
||||||
it('throws an error if using app.config.js', async () => {
|
it('throws an error if using app.config.js', async () => {
|
||||||
|
const graphqlClient = instance(mock<ExpoGraphqlClient>());
|
||||||
|
|
||||||
vol.fromJSON(
|
vol.fromJSON(
|
||||||
{
|
{
|
||||||
'app.config.js': 'module.exports = { blah: {} };',
|
'app.config.js': 'module.exports = { blah: {} };',
|
||||||
@@ -110,10 +116,23 @@ describe(ensureApplicationIdIsDefinedForManagedProjectAsync, () => {
|
|||||||
'/app'
|
'/app'
|
||||||
);
|
);
|
||||||
await expect(
|
await expect(
|
||||||
ensureApplicationIdIsDefinedForManagedProjectAsync('/app', {} as any, mockJester)
|
ensureApplicationIdIsDefinedForManagedProjectAsync({
|
||||||
|
graphqlClient,
|
||||||
|
projectDir: '/app',
|
||||||
|
projectId: '',
|
||||||
|
exp: {} as any,
|
||||||
|
})
|
||||||
).rejects.toThrowError(/we can't update this file programmatically/);
|
).rejects.toThrowError(/we can't update this file programmatically/);
|
||||||
});
|
});
|
||||||
it('prompts for the Android package if using app.json', async () => {
|
it('prompts for the Android package if using app.json', async () => {
|
||||||
|
const graphqlClient = instance(mock<ExpoGraphqlClient>());
|
||||||
|
jest.mocked(AppQuery.byIdAsync).mockResolvedValue({
|
||||||
|
id: '1234',
|
||||||
|
slug: 'testing-123',
|
||||||
|
fullName: '@jester/testing-123',
|
||||||
|
ownerAccount: jester.accounts[0],
|
||||||
|
});
|
||||||
|
|
||||||
vol.fromJSON(
|
vol.fromJSON(
|
||||||
{
|
{
|
||||||
'app.json': '{ "expo": {} }',
|
'app.json': '{ "expo": {} }',
|
||||||
@@ -126,11 +145,26 @@ describe(ensureApplicationIdIsDefinedForManagedProjectAsync, () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
ensureApplicationIdIsDefinedForManagedProjectAsync('/app', {} as any, mockJester)
|
ensureApplicationIdIsDefinedForManagedProjectAsync({
|
||||||
|
graphqlClient,
|
||||||
|
projectDir: '/app',
|
||||||
|
projectId: '',
|
||||||
|
exp: {} as any,
|
||||||
|
})
|
||||||
).resolves.toBe('com.expo.notdominik');
|
).resolves.toBe('com.expo.notdominik');
|
||||||
expect(promptAsync).toHaveBeenCalled();
|
expect(promptAsync).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('puts the Android package in app.json', async () => {
|
it('puts the Android package in app.json', async () => {
|
||||||
|
const graphqlClient = instance(mock<ExpoGraphqlClient>());
|
||||||
|
|
||||||
|
jest.mocked(AppQuery.byIdAsync).mockResolvedValue({
|
||||||
|
id: '1234',
|
||||||
|
slug: 'testing-123',
|
||||||
|
fullName: '@jester/testing-123',
|
||||||
|
ownerAccount: jester.accounts[0],
|
||||||
|
});
|
||||||
|
|
||||||
vol.fromJSON(
|
vol.fromJSON(
|
||||||
{
|
{
|
||||||
'app.json': '{ "expo": {} }',
|
'app.json': '{ "expo": {} }',
|
||||||
@@ -143,7 +177,12 @@ describe(ensureApplicationIdIsDefinedForManagedProjectAsync, () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
ensureApplicationIdIsDefinedForManagedProjectAsync('/app', {} as any, mockJester)
|
ensureApplicationIdIsDefinedForManagedProjectAsync({
|
||||||
|
graphqlClient,
|
||||||
|
projectDir: '/app',
|
||||||
|
projectId: '',
|
||||||
|
exp: {} as any,
|
||||||
|
})
|
||||||
).resolves.toBe('com.expo.notdominik');
|
).resolves.toBe('com.expo.notdominik');
|
||||||
const appJson = JSON.parse(await fs.readFile('/app/app.json', 'utf-8'));
|
const appJson = JSON.parse(await fs.readFile('/app/app.json', 'utf-8'));
|
||||||
expect(appJson).toMatchObject({
|
expect(appJson).toMatchObject({
|
||||||
|
|||||||
@@ -7,22 +7,31 @@ import fs from 'fs-extra';
|
|||||||
import nullthrows from 'nullthrows';
|
import nullthrows from 'nullthrows';
|
||||||
|
|
||||||
import { readAppJson } from '../../build/utils/appJson';
|
import { readAppJson } from '../../build/utils/appJson';
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import env from '../../env';
|
import env from '../../env';
|
||||||
import Log, { learnMore } from '../../log';
|
import Log, { learnMore } from '../../log';
|
||||||
import { getProjectConfigDescription, getUsername } from '../../project/projectUtils';
|
import {
|
||||||
|
getOwnerAccountForProjectIdAsync,
|
||||||
|
getProjectConfigDescription,
|
||||||
|
} from '../../project/projectUtils';
|
||||||
import { promptAsync } from '../../prompts';
|
import { promptAsync } from '../../prompts';
|
||||||
import { Actor } from '../../user/User';
|
|
||||||
import { resolveWorkflowAsync } from '../workflow';
|
import { resolveWorkflowAsync } from '../workflow';
|
||||||
import { GradleBuildContext } from './gradle';
|
import { GradleBuildContext } from './gradle';
|
||||||
import * as gradleUtils from './gradleUtils';
|
import * as gradleUtils from './gradleUtils';
|
||||||
|
|
||||||
export const INVALID_APPLICATION_ID_MESSAGE = `Invalid format of Android applicationId. Only alphanumeric characters, '.' and '_' are allowed, and each '.' must be followed by a letter.`;
|
export const INVALID_APPLICATION_ID_MESSAGE = `Invalid format of Android applicationId. Only alphanumeric characters, '.' and '_' are allowed, and each '.' must be followed by a letter.`;
|
||||||
|
|
||||||
export async function ensureApplicationIdIsDefinedForManagedProjectAsync(
|
export async function ensureApplicationIdIsDefinedForManagedProjectAsync({
|
||||||
projectDir: string,
|
graphqlClient,
|
||||||
exp: ExpoConfig,
|
projectDir,
|
||||||
actor: Actor
|
projectId,
|
||||||
): Promise<string> {
|
exp,
|
||||||
|
}: {
|
||||||
|
graphqlClient: ExpoGraphqlClient;
|
||||||
|
projectDir: string;
|
||||||
|
projectId: string;
|
||||||
|
exp: ExpoConfig;
|
||||||
|
}): Promise<string> {
|
||||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.ANDROID);
|
const workflow = await resolveWorkflowAsync(projectDir, Platform.ANDROID);
|
||||||
assert(workflow === Workflow.MANAGED, 'This function should be called only for managed projects');
|
assert(workflow === Workflow.MANAGED, 'This function should be called only for managed projects');
|
||||||
|
|
||||||
@@ -31,7 +40,7 @@ export async function ensureApplicationIdIsDefinedForManagedProjectAsync(
|
|||||||
moduleName: gradleUtils.DEFAULT_MODULE_NAME,
|
moduleName: gradleUtils.DEFAULT_MODULE_NAME,
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
return await configureApplicationIdAsync(projectDir, exp, actor);
|
return await configureApplicationIdAsync({ graphqlClient, projectDir, projectId, exp });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,11 +119,17 @@ export async function getApplicationIdAsync(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function configureApplicationIdAsync(
|
async function configureApplicationIdAsync({
|
||||||
projectDir: string,
|
graphqlClient,
|
||||||
exp: ExpoConfig,
|
projectDir,
|
||||||
actor: Actor
|
projectId,
|
||||||
): Promise<string> {
|
exp,
|
||||||
|
}: {
|
||||||
|
graphqlClient: ExpoGraphqlClient;
|
||||||
|
projectDir: string;
|
||||||
|
projectId: string;
|
||||||
|
exp: ExpoConfig;
|
||||||
|
}): Promise<string> {
|
||||||
const paths = getConfigFilePaths(projectDir);
|
const paths = getConfigFilePaths(projectDir);
|
||||||
// we can't automatically update app.config.js
|
// we can't automatically update app.config.js
|
||||||
if (paths.dynamicConfigPath) {
|
if (paths.dynamicConfigPath) {
|
||||||
@@ -132,7 +147,11 @@ async function configureApplicationIdAsync(
|
|||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
const suggestedAndroidApplicationId = await getSuggestedApplicationIdAsync(exp, actor);
|
const suggestedAndroidApplicationId = await getSuggestedApplicationIdAsync(
|
||||||
|
graphqlClient,
|
||||||
|
exp,
|
||||||
|
projectId
|
||||||
|
);
|
||||||
const { packageName } = await promptAsync({
|
const { packageName } = await promptAsync({
|
||||||
name: 'packageName',
|
name: 'packageName',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
@@ -174,8 +193,9 @@ export function warnIfAndroidPackageDefinedInAppConfigForBareWorkflowProject(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getSuggestedApplicationIdAsync(
|
async function getSuggestedApplicationIdAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
exp: ExpoConfig,
|
exp: ExpoConfig,
|
||||||
actor: Actor
|
projectId: string
|
||||||
): Promise<string | undefined> {
|
): Promise<string | undefined> {
|
||||||
// Attempt to use the ios bundle id first since it's convenient to have them aligned.
|
// Attempt to use the ios bundle id first since it's convenient to have them aligned.
|
||||||
const maybeBundleId = IOSConfig.BundleIdentifier.getBundleIdentifier(exp);
|
const maybeBundleId = IOSConfig.BundleIdentifier.getBundleIdentifier(exp);
|
||||||
@@ -183,9 +203,9 @@ async function getSuggestedApplicationIdAsync(
|
|||||||
return maybeBundleId;
|
return maybeBundleId;
|
||||||
} else {
|
} else {
|
||||||
// the only callsite is heavily interactive
|
// the only callsite is heavily interactive
|
||||||
const username = getUsername(exp, actor);
|
const account = await getOwnerAccountForProjectIdAsync(graphqlClient, projectId);
|
||||||
// It's common to use dashes in your node project name, strip them from the suggested package name.
|
// 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('');
|
const possibleId = `com.${account.name}.${exp.slug}`.split('-').join('');
|
||||||
if (isApplicationIdValid(possibleId)) {
|
if (isApplicationIdValid(possibleId)) {
|
||||||
return possibleId;
|
return possibleId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export function parseGradleCommand(cmd: string, buildGradle: AppBuildGradle): Gr
|
|||||||
const [moduleName, taskName] =
|
const [moduleName, taskName] =
|
||||||
splitCmd.length > 1 ? [splitCmd[0], splitCmd[1]] : [undefined, splitCmd[0]];
|
splitCmd.length > 1 ? [splitCmd[0], splitCmd[1]] : [undefined, splitCmd[0]];
|
||||||
|
|
||||||
const matchResult = taskName.match(/(build|bundle|assemble)(.*)(Release|Debug)/);
|
const matchResult = taskName.match(/(build|bundle|assemble|package)(.*)(Release|Debug)/);
|
||||||
if (!matchResult) {
|
if (!matchResult) {
|
||||||
throw new Error(`Failed to parse gradle command: ${cmd}`);
|
throw new Error(`Failed to parse gradle command: ${cmd}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ExpoConfig } from '@expo/config';
|
|||||||
import { Platform, Workflow } from '@expo/eas-build-job';
|
import { Platform, Workflow } from '@expo/eas-build-job';
|
||||||
import { BuildProfile } from '@expo/eas-json';
|
import { BuildProfile } from '@expo/eas-json';
|
||||||
|
|
||||||
import { Actor } from '../user/User';
|
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import {
|
import {
|
||||||
ensureApplicationIdIsDefinedForManagedProjectAsync,
|
ensureApplicationIdIsDefinedForManagedProjectAsync,
|
||||||
getApplicationIdAsync,
|
getApplicationIdAsync,
|
||||||
@@ -16,19 +16,32 @@ import { resolveXcodeBuildContextAsync } from './ios/scheme';
|
|||||||
import { findApplicationTarget, resolveTargetsAsync } from './ios/target';
|
import { findApplicationTarget, resolveTargetsAsync } from './ios/target';
|
||||||
import { resolveWorkflowAsync } from './workflow';
|
import { resolveWorkflowAsync } from './workflow';
|
||||||
|
|
||||||
export async function getApplicationIdentifierAsync(
|
export async function getApplicationIdentifierAsync({
|
||||||
projectDir: string,
|
graphqlClient,
|
||||||
exp: ExpoConfig,
|
projectDir,
|
||||||
buildProfile: BuildProfile,
|
projectId,
|
||||||
platform: Platform,
|
exp,
|
||||||
actor: Actor
|
buildProfile,
|
||||||
): Promise<string> {
|
platform,
|
||||||
|
}: {
|
||||||
|
graphqlClient: ExpoGraphqlClient;
|
||||||
|
projectDir: string;
|
||||||
|
projectId: string;
|
||||||
|
exp: ExpoConfig;
|
||||||
|
buildProfile: BuildProfile;
|
||||||
|
platform: Platform;
|
||||||
|
}): Promise<string> {
|
||||||
if (platform === Platform.ANDROID) {
|
if (platform === Platform.ANDROID) {
|
||||||
const profile = buildProfile as BuildProfile<Platform.ANDROID>;
|
const profile = buildProfile as BuildProfile<Platform.ANDROID>;
|
||||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.ANDROID);
|
const workflow = await resolveWorkflowAsync(projectDir, Platform.ANDROID);
|
||||||
|
|
||||||
if (workflow === Workflow.MANAGED) {
|
if (workflow === Workflow.MANAGED) {
|
||||||
return await ensureApplicationIdIsDefinedForManagedProjectAsync(projectDir, exp, actor);
|
return await ensureApplicationIdIsDefinedForManagedProjectAsync({
|
||||||
|
graphqlClient,
|
||||||
|
projectDir,
|
||||||
|
projectId,
|
||||||
|
exp,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const gradleContext = await resolveGradleBuildContextAsync(projectDir, profile);
|
const gradleContext = await resolveGradleBuildContextAsync(projectDir, profile);
|
||||||
@@ -37,7 +50,12 @@ export async function getApplicationIdentifierAsync(
|
|||||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.IOS);
|
const workflow = await resolveWorkflowAsync(projectDir, Platform.IOS);
|
||||||
const profile = buildProfile as BuildProfile<Platform.IOS>;
|
const profile = buildProfile as BuildProfile<Platform.IOS>;
|
||||||
if (workflow === Workflow.MANAGED) {
|
if (workflow === Workflow.MANAGED) {
|
||||||
return await ensureBundleIdentifierIsDefinedForManagedProjectAsync(projectDir, exp, actor);
|
return await ensureBundleIdentifierIsDefinedForManagedProjectAsync({
|
||||||
|
graphqlClient,
|
||||||
|
projectDir,
|
||||||
|
projectId,
|
||||||
|
exp,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const xcodeBuildContext = await resolveXcodeBuildContextAsync(
|
const xcodeBuildContext = await resolveXcodeBuildContextAsync(
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import { Platform } from '@expo/eas-build-job';
|
||||||
|
import { BuildProfile } from '@expo/eas-json';
|
||||||
|
import { errors, readAndValidateBuildConfigAsync } from '@expo/steps';
|
||||||
|
import chalk from 'chalk';
|
||||||
|
import fs from 'fs-extra';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
export async function validateCustomBuildConfigAsync(
|
||||||
|
projectDir: string,
|
||||||
|
profile: BuildProfile<Platform>
|
||||||
|
): Promise<void> {
|
||||||
|
if (!profile.config) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const relativeConfigPath = getCustomBuildConfigPath(profile.config);
|
||||||
|
const configPath = path.join(projectDir, relativeConfigPath);
|
||||||
|
if (!(await fs.pathExists(configPath))) {
|
||||||
|
throw new Error(
|
||||||
|
`Custom build configuration file ${chalk.bold(relativeConfigPath)} does not exist.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await readAndValidateBuildConfigAsync(configPath, { skipNamespacedFunctionsCheck: true });
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof errors.BuildConfigYAMLError) {
|
||||||
|
throw new Error(
|
||||||
|
`Custom build configuration file ${chalk.bold(
|
||||||
|
relativeConfigPath
|
||||||
|
)} contains invalid YAML.\n\n${err.message}`
|
||||||
|
);
|
||||||
|
} else if (err instanceof errors.BuildConfigError) {
|
||||||
|
throw new Error(
|
||||||
|
`Custom build configuration file ${chalk.bold(
|
||||||
|
relativeConfigPath
|
||||||
|
)} contains invalid configuration. Please check the docs!\n${err.message}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCustomBuildConfigPath(configFilename: string): string {
|
||||||
|
return path.join('.eas/build', configFilename);
|
||||||
|
}
|
||||||
@@ -2,8 +2,11 @@ import fs from 'fs-extra';
|
|||||||
import { vol } from 'memfs';
|
import { vol } from 'memfs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import { instance, mock } from 'ts-mockito';
|
||||||
|
|
||||||
import { jester as mockJester } from '../../../credentials/__tests__/fixtures-constants';
|
import { ExpoGraphqlClient } from '../../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
|
import { jester, jester as mockJester } from '../../../credentials/__tests__/fixtures-constants';
|
||||||
|
import { AppQuery } from '../../../graphql/queries/AppQuery';
|
||||||
import { promptAsync } from '../../../prompts';
|
import { promptAsync } from '../../../prompts';
|
||||||
import {
|
import {
|
||||||
ensureBundleIdentifierIsDefinedForManagedProjectAsync,
|
ensureBundleIdentifierIsDefinedForManagedProjectAsync,
|
||||||
@@ -13,6 +16,7 @@ import {
|
|||||||
|
|
||||||
jest.mock('fs');
|
jest.mock('fs');
|
||||||
jest.mock('../../../prompts');
|
jest.mock('../../../prompts');
|
||||||
|
jest.mock('../../../graphql/queries/AppQuery');
|
||||||
jest.mock('../../../user/actions', () => ({ ensureLoggedInAsync: jest.fn(() => mockJester) }));
|
jest.mock('../../../user/actions', () => ({ ensureLoggedInAsync: jest.fn(() => mockJester) }));
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@@ -86,6 +90,7 @@ describe(getBundleIdentifierAsync, () => {
|
|||||||
describe(ensureBundleIdentifierIsDefinedForManagedProjectAsync, () => {
|
describe(ensureBundleIdentifierIsDefinedForManagedProjectAsync, () => {
|
||||||
describe('managed project + ios.bundleIdentifier missing in app config', () => {
|
describe('managed project + ios.bundleIdentifier missing in app config', () => {
|
||||||
it('throws an error if using app.config.js', async () => {
|
it('throws an error if using app.config.js', async () => {
|
||||||
|
const graphqlClient = instance(mock<ExpoGraphqlClient>());
|
||||||
vol.fromJSON(
|
vol.fromJSON(
|
||||||
{
|
{
|
||||||
'app.config.js': 'module.exports = { blah: {} };',
|
'app.config.js': 'module.exports = { blah: {} };',
|
||||||
@@ -93,10 +98,23 @@ describe(ensureBundleIdentifierIsDefinedForManagedProjectAsync, () => {
|
|||||||
'/app'
|
'/app'
|
||||||
);
|
);
|
||||||
await expect(
|
await expect(
|
||||||
ensureBundleIdentifierIsDefinedForManagedProjectAsync('/app', {} as any, mockJester)
|
ensureBundleIdentifierIsDefinedForManagedProjectAsync({
|
||||||
|
graphqlClient,
|
||||||
|
projectDir: '/app',
|
||||||
|
projectId: '1234',
|
||||||
|
exp: {} as any,
|
||||||
|
})
|
||||||
).rejects.toThrowError(/we can't update this file programmatically/);
|
).rejects.toThrowError(/we can't update this file programmatically/);
|
||||||
});
|
});
|
||||||
it('prompts for the bundle identifier if using app.json', async () => {
|
it('prompts for the bundle identifier if using app.json', async () => {
|
||||||
|
const graphqlClient = instance(mock<ExpoGraphqlClient>());
|
||||||
|
jest.mocked(AppQuery.byIdAsync).mockResolvedValue({
|
||||||
|
id: '1234',
|
||||||
|
slug: 'testing-123',
|
||||||
|
fullName: '@jester/testing-123',
|
||||||
|
ownerAccount: jester.accounts[0],
|
||||||
|
});
|
||||||
|
|
||||||
vol.fromJSON(
|
vol.fromJSON(
|
||||||
{
|
{
|
||||||
'app.json': '{ "expo": {} }',
|
'app.json': '{ "expo": {} }',
|
||||||
@@ -109,11 +127,24 @@ describe(ensureBundleIdentifierIsDefinedForManagedProjectAsync, () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
ensureBundleIdentifierIsDefinedForManagedProjectAsync('/app', {} as any, mockJester)
|
ensureBundleIdentifierIsDefinedForManagedProjectAsync({
|
||||||
|
graphqlClient,
|
||||||
|
projectDir: '/app',
|
||||||
|
projectId: '1234',
|
||||||
|
exp: {} as any,
|
||||||
|
})
|
||||||
).resolves.toBe('com.expo.notdominik');
|
).resolves.toBe('com.expo.notdominik');
|
||||||
expect(promptAsync).toHaveBeenCalled();
|
expect(promptAsync).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
it('puts the bundle identifier in app.json', async () => {
|
it('puts the bundle identifier in app.json', async () => {
|
||||||
|
const graphqlClient = instance(mock<ExpoGraphqlClient>());
|
||||||
|
jest.mocked(AppQuery.byIdAsync).mockResolvedValue({
|
||||||
|
id: '1234',
|
||||||
|
slug: 'testing-123',
|
||||||
|
fullName: '@jester/testing-123',
|
||||||
|
ownerAccount: jester.accounts[0],
|
||||||
|
});
|
||||||
|
|
||||||
vol.fromJSON(
|
vol.fromJSON(
|
||||||
{
|
{
|
||||||
'app.json': '{ "expo": {} }',
|
'app.json': '{ "expo": {} }',
|
||||||
@@ -126,7 +157,12 @@ describe(ensureBundleIdentifierIsDefinedForManagedProjectAsync, () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
ensureBundleIdentifierIsDefinedForManagedProjectAsync('/app', {} as any, mockJester)
|
ensureBundleIdentifierIsDefinedForManagedProjectAsync({
|
||||||
|
graphqlClient,
|
||||||
|
projectDir: '/app',
|
||||||
|
projectId: '1234',
|
||||||
|
exp: {} as any,
|
||||||
|
})
|
||||||
).resolves.toBe('com.expo.notdominik');
|
).resolves.toBe('com.expo.notdominik');
|
||||||
const appJson = JSON.parse(await fs.readFile('/app/app.json', 'utf-8'));
|
const appJson = JSON.parse(await fs.readFile('/app/app.json', 'utf-8'));
|
||||||
expect(appJson).toMatchObject({
|
expect(appJson).toMatchObject({
|
||||||
|
|||||||
@@ -6,26 +6,37 @@ import chalk from 'chalk';
|
|||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
|
|
||||||
import { readAppJson } from '../../build/utils/appJson';
|
import { readAppJson } from '../../build/utils/appJson';
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import Log, { learnMore } from '../../log';
|
import Log, { learnMore } from '../../log';
|
||||||
import { promptAsync } from '../../prompts';
|
import { promptAsync } from '../../prompts';
|
||||||
import { Actor } from '../../user/User';
|
import { getOwnerAccountForProjectIdAsync, getProjectConfigDescription } from '../projectUtils';
|
||||||
import { getProjectConfigDescription, getUsername } from '../projectUtils';
|
|
||||||
import { resolveWorkflowAsync } from '../workflow';
|
import { resolveWorkflowAsync } from '../workflow';
|
||||||
|
|
||||||
export const INVALID_BUNDLE_IDENTIFIER_MESSAGE = `Invalid format of iOS bundle identifier. Only alphanumeric characters, '.' and '-' are allowed, and each '.' must be followed by a letter.`;
|
export const INVALID_BUNDLE_IDENTIFIER_MESSAGE = `Invalid format of iOS bundle identifier. Only alphanumeric characters, '.' and '-' are allowed, and each '.' must be followed by a letter.`;
|
||||||
|
|
||||||
export async function ensureBundleIdentifierIsDefinedForManagedProjectAsync(
|
export async function ensureBundleIdentifierIsDefinedForManagedProjectAsync({
|
||||||
projectDir: string,
|
graphqlClient,
|
||||||
exp: ExpoConfig,
|
projectDir,
|
||||||
actor: Actor
|
projectId,
|
||||||
): Promise<string> {
|
exp,
|
||||||
|
}: {
|
||||||
|
graphqlClient: ExpoGraphqlClient;
|
||||||
|
projectDir: string;
|
||||||
|
projectId: string;
|
||||||
|
exp: ExpoConfig;
|
||||||
|
}): Promise<string> {
|
||||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.IOS);
|
const workflow = await resolveWorkflowAsync(projectDir, Platform.IOS);
|
||||||
assert(workflow === Workflow.MANAGED, 'This function should be called only for managed projects');
|
assert(workflow === Workflow.MANAGED, 'This function should be called only for managed projects');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await getBundleIdentifierAsync(projectDir, exp);
|
return await getBundleIdentifierAsync(projectDir, exp);
|
||||||
} catch {
|
} catch {
|
||||||
return await configureBundleIdentifierAsync(projectDir, exp, actor);
|
return await configureBundleIdentifierAsync({
|
||||||
|
graphqlClient,
|
||||||
|
projectDir,
|
||||||
|
exp,
|
||||||
|
projectId,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,11 +111,17 @@ export async function getBundleIdentifierAsync(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function configureBundleIdentifierAsync(
|
async function configureBundleIdentifierAsync({
|
||||||
projectDir: string,
|
graphqlClient,
|
||||||
exp: ExpoConfig,
|
projectDir,
|
||||||
actor: Actor
|
projectId,
|
||||||
): Promise<string> {
|
exp,
|
||||||
|
}: {
|
||||||
|
graphqlClient: ExpoGraphqlClient;
|
||||||
|
projectDir: string;
|
||||||
|
projectId: string;
|
||||||
|
exp: ExpoConfig;
|
||||||
|
}): Promise<string> {
|
||||||
const paths = getConfigFilePaths(projectDir);
|
const paths = getConfigFilePaths(projectDir);
|
||||||
// we can't automatically update app.config.js
|
// we can't automatically update app.config.js
|
||||||
if (paths.dynamicConfigPath) {
|
if (paths.dynamicConfigPath) {
|
||||||
@@ -122,7 +139,11 @@ async function configureBundleIdentifierAsync(
|
|||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
const suggestedBundleIdentifier = await getSuggestedBundleIdentifierAsync(exp, actor);
|
const suggestedBundleIdentifier = await getSuggestedBundleIdentifierAsync(
|
||||||
|
graphqlClient,
|
||||||
|
exp,
|
||||||
|
projectId
|
||||||
|
);
|
||||||
const { bundleIdentifier } = await promptAsync({
|
const { bundleIdentifier } = await promptAsync({
|
||||||
name: 'bundleIdentifier',
|
name: 'bundleIdentifier',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
@@ -169,8 +190,9 @@ export function isWildcardBundleIdentifier(bundleIdentifier: string): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getSuggestedBundleIdentifierAsync(
|
async function getSuggestedBundleIdentifierAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
exp: ExpoConfig,
|
exp: ExpoConfig,
|
||||||
actor: Actor
|
projectId: string
|
||||||
): Promise<string | undefined> {
|
): Promise<string | undefined> {
|
||||||
// Attempt to use the android package name first since it's convenient to have them aligned.
|
// Attempt to use the android package name first since it's convenient to have them aligned.
|
||||||
const maybeAndroidPackage = AndroidConfig.Package.getPackage(exp);
|
const maybeAndroidPackage = AndroidConfig.Package.getPackage(exp);
|
||||||
@@ -178,9 +200,9 @@ async function getSuggestedBundleIdentifierAsync(
|
|||||||
return maybeAndroidPackage;
|
return maybeAndroidPackage;
|
||||||
} else {
|
} else {
|
||||||
// the only callsite is heavily interactive
|
// the only callsite is heavily interactive
|
||||||
const username = getUsername(exp, actor);
|
const account = await getOwnerAccountForProjectIdAsync(graphqlClient, projectId);
|
||||||
// It's common to use dashes in your node project name, strip them from the suggested package name.
|
// 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('');
|
const possibleId = `com.${account.name}.${exp.slug}`.split('-').join('');
|
||||||
if (isBundleIdentifierValid(possibleId)) {
|
if (isBundleIdentifierValid(possibleId)) {
|
||||||
return possibleId;
|
return possibleId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,36 @@
|
|||||||
import { ExpoConfig, Platform } from '@expo/config';
|
import { ExpoConfig, Platform } from '@expo/config';
|
||||||
|
import { Updates } from '@expo/config-plugins';
|
||||||
|
import { Platform as EASBuildJobPlatform, Workflow } from '@expo/eas-build-job';
|
||||||
import JsonFile from '@expo/json-file';
|
import JsonFile from '@expo/json-file';
|
||||||
|
import assert from 'assert';
|
||||||
|
import chalk from 'chalk';
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import Joi from 'joi';
|
import Joi from 'joi';
|
||||||
import mime from 'mime';
|
import mime from 'mime';
|
||||||
|
import nullthrows from 'nullthrows';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import promiseLimit from 'promise-limit';
|
import promiseLimit from 'promise-limit';
|
||||||
|
|
||||||
|
import { selectBranchOnAppAsync } from '../branch/queries';
|
||||||
|
import { getDefaultBranchNameAsync } from '../branch/utils';
|
||||||
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
|
import { PaginatedQueryOptions } from '../commandUtils/pagination';
|
||||||
import { AssetMetadataStatus, PartialManifestAsset } from '../graphql/generated';
|
import { AssetMetadataStatus, PartialManifestAsset } from '../graphql/generated';
|
||||||
import { PublishMutation } from '../graphql/mutations/PublishMutation';
|
import { PublishMutation } from '../graphql/mutations/PublishMutation';
|
||||||
import { PublishQuery } from '../graphql/queries/PublishQuery';
|
import { PublishQuery } from '../graphql/queries/PublishQuery';
|
||||||
import Log from '../log';
|
import Log, { learnMore } from '../log';
|
||||||
|
import { RequestedPlatform, requestedPlatformDisplayNames } from '../platform';
|
||||||
|
import { promptAsync } from '../prompts';
|
||||||
|
import { getBranchNameFromChannelNameAsync } from '../update/getBranchNameFromChannelNameAsync';
|
||||||
|
import { formatUpdateMessage, truncateString as truncateUpdateMessage } from '../update/utils';
|
||||||
import { PresignedPost, uploadWithPresignedPostWithRetryAsync } from '../uploads';
|
import { PresignedPost, uploadWithPresignedPostWithRetryAsync } from '../uploads';
|
||||||
import { expoCommandAsync, shouldUseVersionedExpoCLI } from '../utils/expoCli';
|
import { expoCommandAsync, shouldUseVersionedExpoCLI } from '../utils/expoCli';
|
||||||
import chunk from '../utils/expodash/chunk';
|
import chunk from '../utils/expodash/chunk';
|
||||||
|
import { truthy } from '../utils/expodash/filter';
|
||||||
import uniqBy from '../utils/expodash/uniqBy';
|
import uniqBy from '../utils/expodash/uniqBy';
|
||||||
|
import { getVcsClient } from '../vcs';
|
||||||
|
import { resolveWorkflowAsync } from './workflow';
|
||||||
|
|
||||||
export type ExpoCLIExportPlatformFlag = Platform | 'all';
|
export type ExpoCLIExportPlatformFlag = Platform | 'all';
|
||||||
|
|
||||||
@@ -30,6 +45,8 @@ export type RawAsset = {
|
|||||||
fileExtension?: string;
|
fileExtension?: string;
|
||||||
contentType: string;
|
contentType: string;
|
||||||
path: string;
|
path: string;
|
||||||
|
/** Original asset path derrived from asset map, or exported folder */
|
||||||
|
originalPath?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type CollectedAssets = {
|
type CollectedAssets = {
|
||||||
@@ -52,6 +69,16 @@ type UpdateInfoGroup = {
|
|||||||
[key in Platform]: ManifestFragment;
|
[key in Platform]: ManifestFragment;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Partial copy of `@expo/dev-server` `BundleAssetWithFileHashes`
|
||||||
|
type AssetMap = Record<
|
||||||
|
string,
|
||||||
|
{
|
||||||
|
httpServerLocation: string;
|
||||||
|
name: string;
|
||||||
|
type: string;
|
||||||
|
}
|
||||||
|
>;
|
||||||
|
|
||||||
const fileMetadataJoi = Joi.object({
|
const fileMetadataJoi = Joi.object({
|
||||||
assets: Joi.array()
|
assets: Joi.array()
|
||||||
.required()
|
.required()
|
||||||
@@ -170,6 +197,7 @@ export async function buildBundlesAsync({
|
|||||||
'--output-dir',
|
'--output-dir',
|
||||||
inputDir,
|
inputDir,
|
||||||
'--dump-sourcemap',
|
'--dump-sourcemap',
|
||||||
|
'--dump-assetmap',
|
||||||
'--platform',
|
'--platform',
|
||||||
platformFlag,
|
platformFlag,
|
||||||
]);
|
]);
|
||||||
@@ -182,6 +210,7 @@ export async function buildBundlesAsync({
|
|||||||
'--experimental-bundle',
|
'--experimental-bundle',
|
||||||
'--non-interactive',
|
'--non-interactive',
|
||||||
'--dump-sourcemap',
|
'--dump-sourcemap',
|
||||||
|
'--dump-assetmap',
|
||||||
'--platform',
|
'--platform',
|
||||||
platformFlag,
|
platformFlag,
|
||||||
]);
|
]);
|
||||||
@@ -246,9 +275,48 @@ export function filterExportedPlatformsByFlag<T extends Partial<Record<Platform,
|
|||||||
return { [platform]: record[platform] } as T;
|
return { [platform]: record[platform] } as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Try to load the asset map for logging the names of assets published */
|
||||||
|
export async function loadAssetMapAsync(distRoot: string): Promise<AssetMap | null> {
|
||||||
|
const assetMapPath = path.join(distRoot, 'assetmap.json');
|
||||||
|
|
||||||
|
if (!(await fs.pathExists(assetMapPath))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const assetMap: AssetMap = JsonFile.read(path.join(distRoot, 'assetmap.json'));
|
||||||
|
// TODO: basic validation?
|
||||||
|
return assetMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
// exposed for testing
|
||||||
|
export function getAssetHashFromPath(assetPath: string): string | null {
|
||||||
|
const [, hash] = assetPath.match(new RegExp(/assets\/([a-z0-9]+)$/, 'i')) ?? [];
|
||||||
|
return hash ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// exposed for testing
|
||||||
|
export function getOriginalPathFromAssetMap(
|
||||||
|
assetMap: AssetMap | null,
|
||||||
|
asset: { path: string; ext: string }
|
||||||
|
): string | null {
|
||||||
|
if (!assetMap) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const assetHash = getAssetHashFromPath(asset.path);
|
||||||
|
const assetMapEntry = assetHash && assetMap[assetHash];
|
||||||
|
|
||||||
|
if (!assetMapEntry) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const pathPrefix = assetMapEntry.httpServerLocation.substring('/assets'.length);
|
||||||
|
return `${pathPrefix}/${assetMapEntry.name}.${assetMapEntry.type}`;
|
||||||
|
}
|
||||||
|
|
||||||
/** Given a directory, load the metadata.json and collect the assets for each platform. */
|
/** Given a directory, load the metadata.json and collect the assets for each platform. */
|
||||||
export async function collectAssetsAsync(dir: string): Promise<CollectedAssets> {
|
export async function collectAssetsAsync(dir: string): Promise<CollectedAssets> {
|
||||||
const metadata = loadMetadata(dir);
|
const metadata = loadMetadata(dir);
|
||||||
|
const assetmap = await loadAssetMapAsync(dir);
|
||||||
|
|
||||||
const collectedAssets: CollectedAssets = {};
|
const collectedAssets: CollectedAssets = {};
|
||||||
|
|
||||||
@@ -261,6 +329,7 @@ export async function collectAssetsAsync(dir: string): Promise<CollectedAssets>
|
|||||||
},
|
},
|
||||||
assets: metadata.fileMetadata[platform].assets.map(asset => ({
|
assets: metadata.fileMetadata[platform].assets.map(asset => ({
|
||||||
fileExtension: asset.ext ? ensureLeadingPeriod(asset.ext) : undefined,
|
fileExtension: asset.ext ? ensureLeadingPeriod(asset.ext) : undefined,
|
||||||
|
originalPath: getOriginalPathFromAssetMap(assetmap, asset) ?? undefined,
|
||||||
contentType: guessContentTypeFromExtension(asset.ext),
|
contentType: guessContentTypeFromExtension(asset.ext),
|
||||||
path: path.join(dir, asset.path),
|
path: path.join(dir, asset.path),
|
||||||
})),
|
})),
|
||||||
@@ -294,9 +363,17 @@ export async function filterOutAssetsThatAlreadyExistAsync(
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AssetUploadResult = {
|
type AssetUploadResult = {
|
||||||
|
/** All found assets within the exported folder per platform */
|
||||||
assetCount: number;
|
assetCount: number;
|
||||||
|
/** The uploaded JS bundles, per platform */
|
||||||
|
launchAssetCount: number;
|
||||||
|
/** All unique assets within the exported folder with platforms combined */
|
||||||
uniqueAssetCount: number;
|
uniqueAssetCount: number;
|
||||||
|
/** All unique assets uploaded */
|
||||||
uniqueUploadedAssetCount: number;
|
uniqueUploadedAssetCount: number;
|
||||||
|
/** All (non-launch) asset original paths, used for logging */
|
||||||
|
uniqueUploadedAssetPaths: string[];
|
||||||
|
/** The asset limit received from the server */
|
||||||
assetLimitPerUpdateGroup: number;
|
assetLimitPerUpdateGroup: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -308,7 +385,9 @@ export async function uploadAssetsAsync(
|
|||||||
): Promise<AssetUploadResult> {
|
): Promise<AssetUploadResult> {
|
||||||
let assets: RawAsset[] = [];
|
let assets: RawAsset[] = [];
|
||||||
let platform: keyof CollectedAssets;
|
let platform: keyof CollectedAssets;
|
||||||
|
const launchAssets: RawAsset[] = [];
|
||||||
for (platform in assetsForUpdateInfoGroup) {
|
for (platform in assetsForUpdateInfoGroup) {
|
||||||
|
launchAssets.push(assetsForUpdateInfoGroup[platform]!.launchAsset);
|
||||||
assets = [
|
assets = [
|
||||||
...assets,
|
...assets,
|
||||||
assetsForUpdateInfoGroup[platform]!.launchAsset,
|
assetsForUpdateInfoGroup[platform]!.launchAsset,
|
||||||
@@ -335,6 +414,7 @@ export async function uploadAssetsAsync(
|
|||||||
updateSpinnerText?.(totalAssets, totalAssets);
|
updateSpinnerText?.(totalAssets, totalAssets);
|
||||||
let missingAssets = await filterOutAssetsThatAlreadyExistAsync(graphqlClient, uniqueAssets);
|
let missingAssets = await filterOutAssetsThatAlreadyExistAsync(graphqlClient, uniqueAssets);
|
||||||
const uniqueUploadedAssetCount = missingAssets.length;
|
const uniqueUploadedAssetCount = missingAssets.length;
|
||||||
|
const uniqueUploadedAssetPaths = missingAssets.map(asset => asset.originalPath).filter(truthy);
|
||||||
|
|
||||||
const missingAssetChunks = chunk(missingAssets, 100);
|
const missingAssetChunks = chunk(missingAssets, 100);
|
||||||
const specifications: string[] = [];
|
const specifications: string[] = [];
|
||||||
@@ -372,8 +452,10 @@ export async function uploadAssetsAsync(
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
assetCount: assets.length,
|
assetCount: assets.length,
|
||||||
|
launchAssetCount: launchAssets.length,
|
||||||
uniqueAssetCount: uniqueAssets.length,
|
uniqueAssetCount: uniqueAssets.length,
|
||||||
uniqueUploadedAssetCount,
|
uniqueUploadedAssetCount,
|
||||||
|
uniqueUploadedAssetPaths,
|
||||||
assetLimitPerUpdateGroup,
|
assetLimitPerUpdateGroup,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -385,3 +467,188 @@ export function isUploadedAssetCountAboveWarningThreshold(
|
|||||||
const warningThreshold = Math.floor(assetLimitPerUpdateGroup * 0.75);
|
const warningThreshold = Math.floor(assetLimitPerUpdateGroup * 0.75);
|
||||||
return uploadedAssetCount > warningThreshold;
|
return uploadedAssetCount > warningThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getBranchNameForCommandAsync({
|
||||||
|
graphqlClient,
|
||||||
|
projectId,
|
||||||
|
channelNameArg,
|
||||||
|
branchNameArg,
|
||||||
|
autoFlag,
|
||||||
|
nonInteractive,
|
||||||
|
paginatedQueryOptions,
|
||||||
|
}: {
|
||||||
|
graphqlClient: ExpoGraphqlClient;
|
||||||
|
projectId: string;
|
||||||
|
channelNameArg: string | undefined;
|
||||||
|
branchNameArg: string | undefined;
|
||||||
|
autoFlag: boolean;
|
||||||
|
nonInteractive: boolean;
|
||||||
|
paginatedQueryOptions: PaginatedQueryOptions;
|
||||||
|
}): Promise<string> {
|
||||||
|
if (channelNameArg && branchNameArg) {
|
||||||
|
throw new Error(
|
||||||
|
'Cannot specify both --channel and --branch. Specify either --channel, --branch, or --auto.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (channelNameArg) {
|
||||||
|
return await getBranchNameFromChannelNameAsync(graphqlClient, projectId, channelNameArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (branchNameArg) {
|
||||||
|
return branchNameArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (autoFlag) {
|
||||||
|
return await getDefaultBranchNameAsync();
|
||||||
|
} else if (nonInteractive) {
|
||||||
|
throw new Error('Must supply --channel, --branch or --auto when in non-interactive mode.');
|
||||||
|
} else {
|
||||||
|
let branchName: string;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const branch = await selectBranchOnAppAsync(graphqlClient, {
|
||||||
|
projectId,
|
||||||
|
promptTitle: `Which branch would you like to use?`,
|
||||||
|
displayTextForListItem: updateBranch => ({
|
||||||
|
title: `${updateBranch.name} ${chalk.grey(
|
||||||
|
`- current update: ${formatUpdateMessage(updateBranch.updates[0])}`
|
||||||
|
)}`,
|
||||||
|
}),
|
||||||
|
paginatedQueryOptions,
|
||||||
|
});
|
||||||
|
branchName = branch.name;
|
||||||
|
} catch {
|
||||||
|
// unable to select a branch (network error or no branches for project)
|
||||||
|
const { name } = await promptAsync({
|
||||||
|
type: 'text',
|
||||||
|
name: 'name',
|
||||||
|
message: 'No branches found. Provide a branch name:',
|
||||||
|
initial: await getDefaultBranchNameAsync(),
|
||||||
|
validate: value => (value ? true : 'Branch name may not be empty.'),
|
||||||
|
});
|
||||||
|
branchName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(branchName, 'Branch name must be specified.');
|
||||||
|
return branchName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getUpdateMessageForCommandAsync({
|
||||||
|
updateMessageArg,
|
||||||
|
autoFlag,
|
||||||
|
nonInteractive,
|
||||||
|
jsonFlag,
|
||||||
|
}: {
|
||||||
|
updateMessageArg: string | undefined;
|
||||||
|
autoFlag: boolean;
|
||||||
|
nonInteractive: boolean;
|
||||||
|
jsonFlag: boolean;
|
||||||
|
}): Promise<string> {
|
||||||
|
let updateMessage = updateMessageArg;
|
||||||
|
if (!updateMessageArg && autoFlag) {
|
||||||
|
updateMessage = (await getVcsClient().getLastCommitMessageAsync())?.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!updateMessage) {
|
||||||
|
if (nonInteractive) {
|
||||||
|
throw new Error('Must supply --message or use --auto when in non-interactive mode');
|
||||||
|
}
|
||||||
|
|
||||||
|
const validationMessage = 'publish message may not be empty.';
|
||||||
|
if (jsonFlag) {
|
||||||
|
throw new Error(validationMessage);
|
||||||
|
}
|
||||||
|
const { updateMessageLocal } = await promptAsync({
|
||||||
|
type: 'text',
|
||||||
|
name: 'updateMessageLocal',
|
||||||
|
message: `Provide an update message:`,
|
||||||
|
initial: (await getVcsClient().getLastCommitMessageAsync())?.trim(),
|
||||||
|
validate: (value: any) => (value ? true : validationMessage),
|
||||||
|
});
|
||||||
|
updateMessage = updateMessageLocal;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(updateMessage, 'Update message must be specified.');
|
||||||
|
|
||||||
|
const truncatedMessage = truncateUpdateMessage(updateMessage, 1024);
|
||||||
|
if (truncatedMessage !== updateMessage) {
|
||||||
|
Log.warn('Update message exceeds the allowed 1024 character limit. Truncating message...');
|
||||||
|
}
|
||||||
|
|
||||||
|
return updateMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const defaultPublishPlatforms: Platform[] = ['android', 'ios'];
|
||||||
|
|
||||||
|
export function getRequestedPlatform(
|
||||||
|
platform: ExpoCLIExportPlatformFlag
|
||||||
|
): RequestedPlatform | null {
|
||||||
|
switch (platform) {
|
||||||
|
case 'android':
|
||||||
|
return RequestedPlatform.Android;
|
||||||
|
case 'ios':
|
||||||
|
return RequestedPlatform.Ios;
|
||||||
|
case 'web':
|
||||||
|
return null;
|
||||||
|
case 'all':
|
||||||
|
return RequestedPlatform.All;
|
||||||
|
default:
|
||||||
|
throw new Error(`Unsupported platform: ${platform}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get runtime versions grouped by platform. Runtime version is always `null` on web where the platform is always backwards compatible. */
|
||||||
|
export async function getRuntimeVersionObjectAsync(
|
||||||
|
exp: ExpoConfig,
|
||||||
|
platforms: Platform[],
|
||||||
|
projectDir: string
|
||||||
|
): Promise<{ platform: string; runtimeVersion: string }[]> {
|
||||||
|
for (const platform of platforms) {
|
||||||
|
if (platform === 'web') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const isPolicy = typeof (exp[platform]?.runtimeVersion ?? exp.runtimeVersion) === 'object';
|
||||||
|
if (isPolicy) {
|
||||||
|
const isManaged =
|
||||||
|
(await resolveWorkflowAsync(projectDir, platform as EASBuildJobPlatform)) ===
|
||||||
|
Workflow.MANAGED;
|
||||||
|
if (!isManaged) {
|
||||||
|
throw new Error(
|
||||||
|
'Runtime version policies are only supported in the managed workflow. In the bare workflow, runtime version needs to be set manually.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...new Set(platforms)].map(platform => {
|
||||||
|
if (platform === 'web') {
|
||||||
|
return { platform: 'web', runtimeVersion: 'UNVERSIONED' };
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
platform,
|
||||||
|
runtimeVersion: nullthrows(
|
||||||
|
Updates.getRuntimeVersion(exp, platform),
|
||||||
|
`Unable to determine runtime version for ${
|
||||||
|
requestedPlatformDisplayNames[platform]
|
||||||
|
}. ${learnMore('https://docs.expo.dev/eas-update/runtime-versions/')}`
|
||||||
|
),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getRuntimeToPlatformMappingFromRuntimeVersions(
|
||||||
|
runtimeVersions: { platform: string; runtimeVersion: string }[]
|
||||||
|
): { runtimeVersion: string; platforms: string[] }[] {
|
||||||
|
const runtimeToPlatformMapping: { runtimeVersion: string; platforms: string[] }[] = [];
|
||||||
|
for (const runtime of runtimeVersions) {
|
||||||
|
const platforms = runtimeVersions
|
||||||
|
.filter(({ runtimeVersion }) => runtimeVersion === runtime.runtimeVersion)
|
||||||
|
.map(({ platform }) => platform);
|
||||||
|
if (!runtimeToPlatformMapping.find(item => item.runtimeVersion === runtime.runtimeVersion)) {
|
||||||
|
runtimeToPlatformMapping.push({ runtimeVersion: runtime.runtimeVersion, platforms });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return runtimeToPlatformMapping;
|
||||||
|
}
|
||||||
@@ -317,30 +317,48 @@ async function handleBuildListSourceAsync(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatBuildChoice(build: BuildFragment, expiryDate: Date): prompts.Choice {
|
function formatBuildChoice(build: BuildFragment, expiryDate: Date): prompts.Choice {
|
||||||
const { id, updatedAt, runtimeVersion, buildProfile, gitCommitHash, gitCommitMessage, channel } =
|
const {
|
||||||
build;
|
id,
|
||||||
|
updatedAt,
|
||||||
const formatValue = (field?: string | null): string => (field ? chalk.bold(field) : 'Unknown');
|
runtimeVersion,
|
||||||
|
buildProfile,
|
||||||
|
gitCommitHash,
|
||||||
|
gitCommitMessage,
|
||||||
|
channel,
|
||||||
|
message,
|
||||||
|
} = build;
|
||||||
const buildDate = new Date(updatedAt);
|
const buildDate = new Date(updatedAt);
|
||||||
|
|
||||||
|
const splitCommitMessage = gitCommitMessage?.split('\n');
|
||||||
const formattedCommitData =
|
const formattedCommitData =
|
||||||
gitCommitHash && gitCommitMessage
|
gitCommitHash && splitCommitMessage && splitCommitMessage.length > 0
|
||||||
? `${gitCommitHash.slice(0, 7)} "${chalk.bold(gitCommitMessage)}"`
|
? `${gitCommitHash.slice(0, 7)} "${chalk.bold(
|
||||||
: 'Unknown';
|
splitCommitMessage[0] + (splitCommitMessage.length > 1 ? '…' : '')
|
||||||
|
)}"`
|
||||||
|
: null;
|
||||||
|
|
||||||
const title = `${chalk.bold(`ID:`)} ${id} (${chalk.bold(`${fromNow(buildDate)} ago`)})`;
|
const title = `${chalk.bold(`ID:`)} ${id} (${chalk.bold(`${fromNow(buildDate)} ago`)})`;
|
||||||
|
|
||||||
const description = [
|
const descriptionItems: { name: string; value: string | null }[] = [
|
||||||
`\t${chalk.bold(`Profile:`)} ${formatValue(buildProfile)}`,
|
{ name: 'Profile', value: buildProfile ? chalk.bold(buildProfile) : null },
|
||||||
`\t${chalk.bold(`Channel:`)} ${formatValue(channel)}`,
|
{ name: 'Channel', value: channel ? chalk.bold(channel) : null },
|
||||||
`\t${chalk.bold(`Runtime version:`)} ${formatValue(runtimeVersion)}`,
|
{ name: 'Runtime version', value: runtimeVersion ? chalk.bold(runtimeVersion) : null },
|
||||||
`\t${chalk.bold(`Commit:`)} ${formattedCommitData}`,
|
{ name: 'Commit', value: formattedCommitData },
|
||||||
].join('\n');
|
{
|
||||||
|
name: 'Message',
|
||||||
|
value: message
|
||||||
|
? chalk.bold(message.length > 200 ? `${message.slice(0, 200)}...` : message)
|
||||||
|
: null,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const filteredDescriptionArray: string[] = descriptionItems
|
||||||
|
.filter(item => item.value)
|
||||||
|
.map(item => `${chalk.bold(item.name)}: ${item.value}`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title,
|
title,
|
||||||
description,
|
description: filteredDescriptionArray.length > 0 ? filteredDescriptionArray.join('\n') : '',
|
||||||
value: build,
|
value: build,
|
||||||
disabled: buildDate < expiryDate,
|
disabled: buildDate < expiryDate,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ function mockUpdateBranches(branchNames: string[]): UpdateBranch[] {
|
|||||||
runtime: {} as Runtime, // Temporary fix to resolve type errors
|
runtime: {} as Runtime, // Temporary fix to resolve type errors
|
||||||
platform: 'ios',
|
platform: 'ios',
|
||||||
manifestFragment: '...',
|
manifestFragment: '...',
|
||||||
|
isRollBackToEmbedded: false,
|
||||||
activityTimestamp: '2022-12-07T02:24:43.487Z',
|
activityTimestamp: '2022-12-07T02:24:43.487Z',
|
||||||
branchId: '',
|
branchId: '',
|
||||||
awaitingCodeSigningInfo: false,
|
awaitingCodeSigningInfo: false,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import { resolveWorkflowPerPlatformAsync } from '../project/workflow';
|
|||||||
import { syncUpdatesConfigurationAsync as syncAndroidUpdatesConfigurationAsync } from './android/UpdatesModule';
|
import { syncUpdatesConfigurationAsync as syncAndroidUpdatesConfigurationAsync } from './android/UpdatesModule';
|
||||||
import { syncUpdatesConfigurationAsync as syncIosUpdatesConfigurationAsync } from './ios/UpdatesModule';
|
import { syncUpdatesConfigurationAsync as syncIosUpdatesConfigurationAsync } from './ios/UpdatesModule';
|
||||||
|
|
||||||
export const DEFAULT_MANAGED_RUNTIME_VERSION = { policy: 'appVersion' } as const;
|
export const DEFAULT_MANAGED_RUNTIME_VERSION = { policy: 'sdkVersion' } as const;
|
||||||
export const DEFAULT_BARE_RUNTIME_VERSION = '1.0.0' as const;
|
export const DEFAULT_BARE_RUNTIME_VERSION = '1.0.0' as const;
|
||||||
|
|
||||||
function getDefaultRuntimeVersion(workflow: Workflow): NonNullable<ExpoConfig['runtimeVersion']> {
|
function getDefaultRuntimeVersion(workflow: Workflow): NonNullable<ExpoConfig['runtimeVersion']> {
|
||||||
@@ -273,7 +273,7 @@ export async function ensureEASUpdateIsConfiguredInEasJsonAsync(projectDir: stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const easJsonAccessor = new EasJsonAccessor(projectDir);
|
const easJsonAccessor = EasJsonAccessor.fromProjectPath(projectDir);
|
||||||
await easJsonAccessor.readRawJsonAsync();
|
await easJsonAccessor.readRawJsonAsync();
|
||||||
|
|
||||||
easJsonAccessor.patch(easJsonRawObject => {
|
easJsonAccessor.patch(easJsonRawObject => {
|
||||||
@@ -343,7 +343,7 @@ export async function ensureEASUpdateIsConfiguredAsync(
|
|||||||
expWithoutUpdates.sdkVersion
|
expWithoutUpdates.sdkVersion
|
||||||
);
|
);
|
||||||
if (!hasExpoUpdates) {
|
if (!hasExpoUpdates) {
|
||||||
await installExpoUpdatesAsync(projectDir, { silent: !Log.isDebug });
|
await installExpoUpdatesAsync(projectDir, { silent: false });
|
||||||
Log.withTick('Installed expo updates');
|
Log.withTick('Installed expo updates');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ export type FormattedUpdateGroupDescription = {
|
|||||||
group: string;
|
group: string;
|
||||||
platforms: string;
|
platforms: string;
|
||||||
runtimeVersion: string;
|
runtimeVersion: string;
|
||||||
|
codeSigningKey: string | undefined;
|
||||||
|
isRollBackToEmbedded: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FormattedBranchDescription = {
|
export type FormattedBranchDescription = {
|
||||||
@@ -74,6 +76,8 @@ export function formatUpdateGroup(update: FormattedUpdateGroupDescription): stri
|
|||||||
{ label: 'Platforms', value: update.platforms },
|
{ label: 'Platforms', value: update.platforms },
|
||||||
{ label: 'Runtime Version', value: update.runtimeVersion },
|
{ label: 'Runtime Version', value: update.runtimeVersion },
|
||||||
{ label: 'Message', value: update.message },
|
{ label: 'Message', value: update.message },
|
||||||
|
{ label: 'Code Signing Key', value: update.codeSigningKey ?? 'N/A' },
|
||||||
|
{ label: 'Is Roll Back to Embedded', value: update.isRollBackToEmbedded ? 'Yes' : 'No' },
|
||||||
{ label: 'Group ID', value: update.group },
|
{ label: 'Group ID', value: update.group },
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -203,6 +207,7 @@ export function getUpdateGroupJsonInfo(updateGroups: UpdateFragment[]): UpdateJs
|
|||||||
runtimeVersion: update.runtimeVersion,
|
runtimeVersion: update.runtimeVersion,
|
||||||
platform: update.platform,
|
platform: update.platform,
|
||||||
manifestPermalink: update.manifestPermalink,
|
manifestPermalink: update.manifestPermalink,
|
||||||
|
isRollBackToEmbedded: update.isRollBackToEmbedded,
|
||||||
gitCommitHash: update.gitCommitHash,
|
gitCommitHash: update.gitCommitHash,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -213,6 +218,8 @@ export function getUpdateGroupDescriptions(
|
|||||||
return updateGroups.map(updateGroup => ({
|
return updateGroups.map(updateGroup => ({
|
||||||
message: formatUpdateMessage(updateGroup[0]),
|
message: formatUpdateMessage(updateGroup[0]),
|
||||||
runtimeVersion: updateGroup[0].runtimeVersion,
|
runtimeVersion: updateGroup[0].runtimeVersion,
|
||||||
|
isRollBackToEmbedded: updateGroup[0].isRollBackToEmbedded,
|
||||||
|
codeSigningKey: updateGroup[0].codeSigningInfo?.keyid,
|
||||||
group: updateGroup[0].group,
|
group: updateGroup[0].group,
|
||||||
platforms: formatPlatformForUpdateGroup(updateGroup),
|
platforms: formatPlatformForUpdateGroup(updateGroup),
|
||||||
}));
|
}));
|
||||||
@@ -225,6 +232,8 @@ export function getUpdateGroupDescriptionsWithBranch(
|
|||||||
branch: updateGroup[0].branch.name,
|
branch: updateGroup[0].branch.name,
|
||||||
message: formatUpdateMessage(updateGroup[0]),
|
message: formatUpdateMessage(updateGroup[0]),
|
||||||
runtimeVersion: updateGroup[0].runtimeVersion,
|
runtimeVersion: updateGroup[0].runtimeVersion,
|
||||||
|
isRollBackToEmbedded: updateGroup[0].isRollBackToEmbedded,
|
||||||
|
codeSigningKey: updateGroup[0].codeSigningInfo?.keyid,
|
||||||
group: updateGroup[0].group,
|
group: updateGroup[0].group,
|
||||||
platforms: formatPlatformForUpdateGroup(updateGroup),
|
platforms: formatPlatformForUpdateGroup(updateGroup),
|
||||||
}));
|
}));
|
||||||
@@ -241,6 +250,8 @@ export function getBranchDescription(branch: UpdateBranchFragment): FormattedBra
|
|||||||
update: {
|
update: {
|
||||||
message: formatUpdateMessage(latestUpdate),
|
message: formatUpdateMessage(latestUpdate),
|
||||||
runtimeVersion: latestUpdate.runtimeVersion,
|
runtimeVersion: latestUpdate.runtimeVersion,
|
||||||
|
isRollBackToEmbedded: latestUpdate.isRollBackToEmbedded,
|
||||||
|
codeSigningKey: latestUpdate.codeSigningInfo?.keyid,
|
||||||
group: latestUpdate.group,
|
group: latestUpdate.group,
|
||||||
platforms: getPlatformsForGroup({
|
platforms: getPlatformsForGroup({
|
||||||
group: latestUpdate.group,
|
group: latestUpdate.group,
|
||||||
|
|||||||
@@ -7,15 +7,25 @@ export type Actor = NonNullable<CurrentUserQuery['meActor']>;
|
|||||||
* This should be used whenever the "current user" needs to be displayed.
|
* This should be used whenever the "current user" needs to be displayed.
|
||||||
* The display name CANNOT be used as project owner.
|
* The display name CANNOT be used as project owner.
|
||||||
*/
|
*/
|
||||||
export function getActorDisplayName(user?: Actor): string {
|
export function getActorDisplayName(actor?: Actor): string {
|
||||||
switch (user?.__typename) {
|
switch (actor?.__typename) {
|
||||||
case 'User':
|
case 'User':
|
||||||
return user.username;
|
return actor.username;
|
||||||
case 'Robot':
|
case 'Robot':
|
||||||
return user.firstName ? `${user.firstName} (robot)` : 'robot';
|
return actor.firstName ? `${actor.firstName} (robot)` : 'robot';
|
||||||
case 'SSOUser':
|
case 'SSOUser':
|
||||||
return user.username ? `${user.username} (sso user)` : 'sso user';
|
return actor.username ? `${actor.username} (sso user)` : 'sso user';
|
||||||
default:
|
default:
|
||||||
return 'anonymous';
|
return 'anonymous';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getActorUsername(actor?: Actor): string | null {
|
||||||
|
switch (actor?.__typename) {
|
||||||
|
case 'User':
|
||||||
|
case 'SSOUser':
|
||||||
|
return actor.username;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ jest.mock('@expo/eas-json', () => {
|
|||||||
const EasJsonUtilsMock = {
|
const EasJsonUtilsMock = {
|
||||||
getBuildProfileAsync: jest.fn(),
|
getBuildProfileAsync: jest.fn(),
|
||||||
getBuildProfileNamesAsync: jest.fn(),
|
getBuildProfileNamesAsync: jest.fn(),
|
||||||
|
getBuildProfileDeprecationWarnings: jest.fn(() => []),
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
...actual,
|
...actual,
|
||||||
@@ -29,7 +30,7 @@ describe(getProfilesAsync, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('defaults to production profile', async () => {
|
it('defaults to production profile', async () => {
|
||||||
const easJsonAccessor = new EasJsonAccessor('/fake');
|
const easJsonAccessor = EasJsonAccessor.fromProjectPath('/fake');
|
||||||
const result = await getProfilesAsync({
|
const result = await getProfilesAsync({
|
||||||
easJsonAccessor,
|
easJsonAccessor,
|
||||||
platforms: [Platform.ANDROID, Platform.IOS],
|
platforms: [Platform.ANDROID, Platform.IOS],
|
||||||
@@ -51,7 +52,7 @@ describe(getProfilesAsync, () => {
|
|||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
getProfilesAsync({
|
getProfilesAsync({
|
||||||
easJsonAccessor: new EasJsonAccessor('/fake'),
|
easJsonAccessor: EasJsonAccessor.fromProjectPath('/fake'),
|
||||||
platforms: [Platform.ANDROID],
|
platforms: [Platform.ANDROID],
|
||||||
profileName: undefined,
|
profileName: undefined,
|
||||||
type: 'build',
|
type: 'build',
|
||||||
@@ -60,7 +61,7 @@ describe(getProfilesAsync, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('gets a specific profile', async () => {
|
it('gets a specific profile', async () => {
|
||||||
const easJsonAccessor = new EasJsonAccessor('/fake');
|
const easJsonAccessor = EasJsonAccessor.fromProjectPath('/fake');
|
||||||
const result = await getProfilesAsync({
|
const result = await getProfilesAsync({
|
||||||
easJsonAccessor,
|
easJsonAccessor,
|
||||||
platforms: [Platform.ANDROID, Platform.IOS],
|
platforms: [Platform.ANDROID, Platform.IOS],
|
||||||
@@ -85,7 +86,7 @@ describe(getProfilesAsync, () => {
|
|||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
getProfilesAsync({
|
getProfilesAsync({
|
||||||
easJsonAccessor: new EasJsonAccessor('/fake'),
|
easJsonAccessor: EasJsonAccessor.fromProjectPath('/fake'),
|
||||||
platforms: [Platform.ANDROID, Platform.IOS],
|
platforms: [Platform.ANDROID, Platform.IOS],
|
||||||
profileName: undefined,
|
profileName: undefined,
|
||||||
type: 'build',
|
type: 'build',
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
|
import { BillingUpdateQuery } from '../graphql/queries/BillingUpdateQuery';
|
||||||
|
import Log from '../log';
|
||||||
|
import { getOwnerAccountForProjectIdAsync } from '../project/projectUtils';
|
||||||
|
|
||||||
|
const WARNING_THRESHOLD = 0.85;
|
||||||
|
export async function maybeWarnAboutEasPlanOverageAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
|
projectId: string
|
||||||
|
): Promise<void> {
|
||||||
|
const account = await getOwnerAccountForProjectIdAsync(graphqlClient, projectId);
|
||||||
|
const billingUpdateQuery = await BillingUpdateQuery.byAccountIdAsync(
|
||||||
|
graphqlClient,
|
||||||
|
account.id,
|
||||||
|
new Date()
|
||||||
|
);
|
||||||
|
|
||||||
|
const isFree = !billingUpdateQuery.billing; // TODO: no billing means free?
|
||||||
|
const isMetered = !!billingUpdateQuery.billing?.subscription?.meteredBillingStatus?.EAS_UPDATE;
|
||||||
|
// TODO: verify correctness
|
||||||
|
if (!isFree || isMetered) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const planMetrics = billingUpdateQuery.usageMetrics.byBillingPeriod.planMetrics;
|
||||||
|
for (const metric of planMetrics) {
|
||||||
|
const { value, limit, serviceMetric } = metric;
|
||||||
|
const percentageUsed = value / limit;
|
||||||
|
if (percentageUsed >= 1) {
|
||||||
|
Log.error(
|
||||||
|
'You have exceeded your EAS Update plan limit. You can create updates but they will no longer be distributed to users.'
|
||||||
|
);
|
||||||
|
Log.error('Please upgrade your plan to continue receiving updates.');
|
||||||
|
return;
|
||||||
|
} else if (percentageUsed >= WARNING_THRESHOLD && percentageUsed < 1) {
|
||||||
|
Log.warn(
|
||||||
|
`You are approaching your EAS Update plan limit. You have used ${Math.round(
|
||||||
|
percentageUsed * 100
|
||||||
|
)}% of your plan's ${serviceMetric}.`
|
||||||
|
);
|
||||||
|
Log.warn('Please upgrade your plan to continue receiving updates.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,8 +16,9 @@ import nullthrows from 'nullthrows';
|
|||||||
|
|
||||||
import { Response } from '../fetch';
|
import { Response } from '../fetch';
|
||||||
import { PartialManifest, PartialManifestAsset } from '../graphql/generated';
|
import { PartialManifest, PartialManifestAsset } from '../graphql/generated';
|
||||||
|
import areSetsEqual from './expodash/areSetsEqual';
|
||||||
|
|
||||||
type CodeSigningInfo = {
|
export type CodeSigningInfo = {
|
||||||
privateKey: PKI.rsa.PrivateKey;
|
privateKey: PKI.rsa.PrivateKey;
|
||||||
certificate: PKI.Certificate;
|
certificate: PKI.Certificate;
|
||||||
codeSigningMetadata: { alg: string; keyid: string };
|
codeSigningMetadata: { alg: string; keyid: string };
|
||||||
@@ -101,7 +102,7 @@ export async function getKeyAndCertificateFromPathsAsync({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getManifestBodyAsync(res: Response): Promise<string | null> {
|
async function getMultipartBodyPartAsync(res: Response, partName: string): Promise<string | null> {
|
||||||
const contentType = res.headers.get('content-type');
|
const contentType = res.headers.get('content-type');
|
||||||
if (!contentType) {
|
if (!contentType) {
|
||||||
throw new Error('The multipart manifest response is missing the content-type header');
|
throw new Error('The multipart manifest response is missing the content-type header');
|
||||||
@@ -111,11 +112,19 @@ export async function getManifestBodyAsync(res: Response): Promise<string | null
|
|||||||
contentType,
|
contentType,
|
||||||
Buffer.from(bodyBuffer)
|
Buffer.from(bodyBuffer)
|
||||||
);
|
);
|
||||||
const manifestPart = multipartParts.find(part => isMultipartPartWithName(part, 'manifest'));
|
const manifestPart = multipartParts.find(part => isMultipartPartWithName(part, partName));
|
||||||
return manifestPart?.body ?? null;
|
return manifestPart?.body ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function signManifestBody(body: string, codeSigningInfo: CodeSigningInfo): string {
|
export async function getManifestBodyAsync(res: Response): Promise<string | null> {
|
||||||
|
return await getMultipartBodyPartAsync(res, 'manifest');
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getDirectiveBodyAsync(res: Response): Promise<string | null> {
|
||||||
|
return await getMultipartBodyPartAsync(res, 'directive');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function signBody(body: string, codeSigningInfo: CodeSigningInfo): string {
|
||||||
return signBufferRSASHA256AndVerify(
|
return signBufferRSASHA256AndVerify(
|
||||||
codeSigningInfo.privateKey,
|
codeSigningInfo.privateKey,
|
||||||
codeSigningInfo.certificate,
|
codeSigningInfo.certificate,
|
||||||
@@ -181,3 +190,20 @@ export function checkManifestBodyAgainstUpdateInfoGroup(
|
|||||||
assertAssetParity(correspondingManifestResponseBodyAssetJSON, nullthrows(partialManifestAsset));
|
assertAssetParity(correspondingManifestResponseBodyAssetJSON, nullthrows(partialManifestAsset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function checkDirectiveBodyAgainstUpdateInfoGroup(directiveResponseBody: string): void {
|
||||||
|
const directiveResponseBodyJSON = JSON.parse(directiveResponseBody);
|
||||||
|
|
||||||
|
if (
|
||||||
|
!areSetsEqual(
|
||||||
|
new Set(Object.keys(directiveResponseBodyJSON)),
|
||||||
|
new Set(['extra', 'type', 'parameters'])
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
throw new Error('Code signing directive integrity error: Unexpected keys');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (directiveResponseBodyJSON.type !== 'rollBackToEmbedded') {
|
||||||
|
throw new Error('Code signing directive integrity error: Incorrect directive type');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ import { ExpoConfig } from '@expo/config-types';
|
|||||||
import spawnAsync from '@expo/spawn-async';
|
import spawnAsync from '@expo/spawn-async';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import { boolish } from 'getenv';
|
import { boolish } from 'getenv';
|
||||||
import resolveFrom from 'resolve-from';
|
import resolveFrom, { silent as silentResolveFrom } from 'resolve-from';
|
||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
|
|
||||||
import Log from '../log';
|
import Log from '../log';
|
||||||
@@ -63,7 +63,8 @@ export async function expoCommandAsync(
|
|||||||
args: string[],
|
args: string[],
|
||||||
{ silent = false }: { silent?: boolean } = {}
|
{ silent = false }: { silent?: boolean } = {}
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const expoCliPath = resolveFrom(projectDir, 'expo/bin/cli.js');
|
const expoCliPath =
|
||||||
|
silentResolveFrom(projectDir, 'expo/bin/cli') ?? resolveFrom(projectDir, 'expo/bin/cli.js');
|
||||||
const spawnPromise = spawnAsync(expoCliPath, args, {
|
const spawnPromise = spawnAsync(expoCliPath, args, {
|
||||||
stdio: ['inherit', 'pipe', 'pipe'], // inherit stdin so user can install a missing expo-cli from inside this command
|
stdio: ['inherit', 'pipe', 'pipe'], // inherit stdin so user can install a missing expo-cli from inside this command
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import areSetsEqual from '../areSetsEqual';
|
||||||
|
|
||||||
|
describe(areSetsEqual, () => {
|
||||||
|
it.each([
|
||||||
|
[new Set([1, 2]), new Set([1, 2])],
|
||||||
|
[new Set([1, 2]), new Set([2, 1])],
|
||||||
|
])('equal cases: %p', (a, b) => {
|
||||||
|
expect(areSetsEqual(a, b)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[new Set([1, 2, 3]), new Set([1, 2])],
|
||||||
|
[new Set([1, 2]), new Set([1, 2, 3])],
|
||||||
|
])('non-equal cases: %p', (a, b) => {
|
||||||
|
expect(areSetsEqual(a, b)).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export default function areSetsEqual<T>(a: Set<T>, b: Set<T>): boolean {
|
||||||
|
return a.size === b.size && [...a].every(value => b.has(value));
|
||||||
|
}
|
||||||
@@ -7,6 +7,8 @@ import {
|
|||||||
SubmitProfile,
|
SubmitProfile,
|
||||||
} from '@expo/eas-json';
|
} from '@expo/eas-json';
|
||||||
|
|
||||||
|
import Log, { learnMore } from '../log';
|
||||||
|
|
||||||
type EasProfile<T extends ProfileType> = T extends 'build'
|
type EasProfile<T extends ProfileType> = T extends 'build'
|
||||||
? BuildProfile<Platform>
|
? BuildProfile<Platform>
|
||||||
: SubmitProfile<Platform>;
|
: SubmitProfile<Platform>;
|
||||||
@@ -57,11 +59,15 @@ async function readProfileAsync<T extends ProfileType>({
|
|||||||
profileName?: string;
|
profileName?: string;
|
||||||
}): Promise<EasProfile<T>> {
|
}): Promise<EasProfile<T>> {
|
||||||
if (type === 'build') {
|
if (type === 'build') {
|
||||||
return (await EasJsonUtils.getBuildProfileAsync(
|
const buildProfile = await EasJsonUtils.getBuildProfileAsync(
|
||||||
easJsonAccessor,
|
easJsonAccessor,
|
||||||
platform,
|
platform,
|
||||||
profileName
|
profileName
|
||||||
)) as EasProfile<T>;
|
);
|
||||||
|
|
||||||
|
maybePrintBuildProfileDeprecationWarnings(buildProfile, profileName);
|
||||||
|
|
||||||
|
return buildProfile as EasProfile<T>;
|
||||||
} else {
|
} else {
|
||||||
return (await EasJsonUtils.getSubmitProfileAsync(
|
return (await EasJsonUtils.getSubmitProfileAsync(
|
||||||
easJsonAccessor,
|
easJsonAccessor,
|
||||||
@@ -70,3 +76,32 @@ async function readProfileAsync<T extends ProfileType>({
|
|||||||
)) as EasProfile<T>;
|
)) as EasProfile<T>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let hasPrintedDeprecationWarnings = false;
|
||||||
|
|
||||||
|
function maybePrintBuildProfileDeprecationWarnings(
|
||||||
|
buildProfile: BuildProfile<Platform>,
|
||||||
|
profileName?: string
|
||||||
|
): void {
|
||||||
|
if (hasPrintedDeprecationWarnings) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const deprecationWarnings = EasJsonUtils.getBuildProfileDeprecationWarnings(
|
||||||
|
buildProfile,
|
||||||
|
profileName
|
||||||
|
);
|
||||||
|
if (deprecationWarnings.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log.newLine();
|
||||||
|
Log.warn('Detected deprecated fields in eas.json:');
|
||||||
|
for (const warning of deprecationWarnings) {
|
||||||
|
const warnlog: string = warning.message.map(line => `\t${line}`).join('\n');
|
||||||
|
Log.warn(warnlog);
|
||||||
|
if (warning.docsUrl) {
|
||||||
|
Log.warn(`\t${learnMore(warning.docsUrl)}`);
|
||||||
|
}
|
||||||
|
Log.newLine();
|
||||||
|
}
|
||||||
|
hasPrintedDeprecationWarnings = true;
|
||||||
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@expo/eas-json",
|
"name": "@expo/eas-json",
|
||||||
"description": "A library for interacting with eas.json",
|
"description": "A library for interacting with eas.json",
|
||||||
"version": "3.5.0",
|
"version": "3.9.2",
|
||||||
"author": "Expo <[email protected]>",
|
"author": "Expo <[email protected]>",
|
||||||
"bugs": "https://github.com/expo/eas-cli/issues",
|
"bugs": "https://github.com/expo/eas-cli/issues",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/code-frame": "7.18.6",
|
"@babel/code-frame": "7.18.6",
|
||||||
"@expo/eas-build-job": "0.2.102",
|
"@expo/eas-build-job": "1.0.7",
|
||||||
"chalk": "4.1.2",
|
"chalk": "4.1.2",
|
||||||
"env-string": "1.0.1",
|
"env-string": "1.0.1",
|
||||||
"fs-extra": "10.1.0",
|
"fs-extra": "10.1.0",
|
||||||
@@ -36,7 +36,8 @@
|
|||||||
"build": "tsc --project tsconfig.build.json",
|
"build": "tsc --project tsconfig.build.json",
|
||||||
"watch": "yarn build --watch --preserveWatchOutput",
|
"watch": "yarn build --watch --preserveWatchOutput",
|
||||||
"typecheck": "tsc",
|
"typecheck": "tsc",
|
||||||
"prepack": "rimraf build && yarn build",
|
"prepack": "yarn rebuild",
|
||||||
|
"rebuild": "rimraf build && yarn build",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"clean": "rimraf build node_modules yarn-error.log"
|
"clean": "rimraf build node_modules yarn-error.log"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -74,11 +74,6 @@
|
|||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"cacheDefaultPaths": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "Specifies whether to cache the recommended set of files, currently only Podfile.lock is cached by default for iOS build and nothing is cached for Android.",
|
|
||||||
"default": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -329,6 +324,7 @@
|
|||||||
"enum": [
|
"enum": [
|
||||||
"default",
|
"default",
|
||||||
"latest",
|
"latest",
|
||||||
|
"macos-monterey-12.6-xcode-14.2",
|
||||||
"macos-monterey-12.6-xcode-14.1",
|
"macos-monterey-12.6-xcode-14.1",
|
||||||
"macos-monterey-12.6-xcode-14.0",
|
"macos-monterey-12.6-xcode-14.0",
|
||||||
"macos-monterey-12.4-xcode-13.4",
|
"macos-monterey-12.4-xcode-13.4",
|
||||||
@@ -338,8 +334,8 @@
|
|||||||
"macos-big-sur-11.4-xcode-12.5"
|
"macos-big-sur-11.4-xcode-12.5"
|
||||||
],
|
],
|
||||||
"markdownEnumDescriptions": [
|
"markdownEnumDescriptions": [
|
||||||
"`macos-monterey-12.6-xcode-14.0`",
|
"`macos-monterey-12.6-xcode-14.1`",
|
||||||
"`macos-monterey-12.6-xcode-14.1`"
|
"`macos-monterey-12.6-xcode-14.2`"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -353,7 +349,7 @@
|
|||||||
"default": "default",
|
"default": "default",
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"enum": ["default", "medium", "m1-medium", "intel-medium"]
|
"enum": ["default", "medium", "intel-medium", "m-medium"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`EasJsonAccessor patching JSON file 1`] = `
|
exports[`fromProjectPath patching JSON file 1`] = `
|
||||||
"{
|
"{
|
||||||
"build": {
|
"build": {
|
||||||
"production": {
|
"production": {
|
||||||
@@ -14,7 +14,7 @@ exports[`EasJsonAccessor patching JSON file 1`] = `
|
|||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`EasJsonAccessor patching JSON5 file (preserves comments) 1`] = `
|
exports[`fromProjectPath patching JSON5 file (preserves comments) 1`] = `
|
||||||
"{
|
"{
|
||||||
"build": {
|
"build": {
|
||||||
"production": {
|
"production": {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ beforeEach(async () => {
|
|||||||
vol.reset();
|
vol.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe(EasJsonAccessor, () => {
|
describe(EasJsonAccessor.fromProjectPath, () => {
|
||||||
test('patching JSON file', async () => {
|
test('patching JSON file', async () => {
|
||||||
vol.fromJSON(
|
vol.fromJSON(
|
||||||
{
|
{
|
||||||
@@ -24,7 +24,7 @@ describe(EasJsonAccessor, () => {
|
|||||||
fakeAppPath
|
fakeAppPath
|
||||||
);
|
);
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor(fakeAppPath);
|
const accessor = EasJsonAccessor.fromProjectPath(fakeAppPath);
|
||||||
await accessor.readAsync();
|
await accessor.readAsync();
|
||||||
accessor.patch(o => {
|
accessor.patch(o => {
|
||||||
o.build.production.env.ABC = '456';
|
o.build.production.env.ABC = '456';
|
||||||
@@ -44,7 +44,7 @@ describe(EasJsonAccessor, () => {
|
|||||||
fakeAppPath
|
fakeAppPath
|
||||||
);
|
);
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor(fakeAppPath);
|
const accessor = EasJsonAccessor.fromProjectPath(fakeAppPath);
|
||||||
await accessor.readAsync();
|
await accessor.readAsync();
|
||||||
accessor.patch(o => {
|
accessor.patch(o => {
|
||||||
o.build.production.env.ABC = '456';
|
o.build.production.env.ABC = '456';
|
||||||
@@ -67,7 +67,7 @@ describe(EasJsonAccessor, () => {
|
|||||||
fakeAppPath
|
fakeAppPath
|
||||||
);
|
);
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor(fakeAppPath);
|
const accessor = EasJsonAccessor.fromProjectPath(fakeAppPath);
|
||||||
await expect(accessor.readAsync()).rejects.toThrowError(InvalidEasJsonError);
|
await expect(accessor.readAsync()).rejects.toThrowError(InvalidEasJsonError);
|
||||||
await expect(accessor.readAsync()).rejects.toThrowError(
|
await expect(accessor.readAsync()).rejects.toThrowError(
|
||||||
/^Found invalid character in .*eas\.json.+/
|
/^Found invalid character in .*eas\.json.+/
|
||||||
@@ -82,7 +82,57 @@ describe(EasJsonAccessor, () => {
|
|||||||
fakeAppPath
|
fakeAppPath
|
||||||
);
|
);
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor(fakeAppPath);
|
const accessor = EasJsonAccessor.fromProjectPath(fakeAppPath);
|
||||||
|
await expect(accessor.readAsync()).rejects.toThrowError(InvalidEasJsonError);
|
||||||
|
await expect(accessor.readAsync()).rejects.toThrowError(/^.*eas\.json.* is empty\.$/g);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe(EasJsonAccessor.fromRawString, () => {
|
||||||
|
test('patching JSON file', async () => {
|
||||||
|
const accessor = EasJsonAccessor.fromRawString(
|
||||||
|
await fsReal.readFile(path.join(fixturesDir, 'eas-json.json'), 'utf-8')
|
||||||
|
);
|
||||||
|
await accessor.readAsync();
|
||||||
|
expect(() =>
|
||||||
|
accessor.patch(o => {
|
||||||
|
o.build.production.env.ABC = '456';
|
||||||
|
return o;
|
||||||
|
})
|
||||||
|
).toThrowError();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('reading invalid JSON5 object', async () => {
|
||||||
|
vol.fromJSON(
|
||||||
|
{
|
||||||
|
'./eas.json': await fsReal.readFile(
|
||||||
|
path.join(fixturesDir, 'eas-invalid-json5.json'),
|
||||||
|
'utf-8'
|
||||||
|
),
|
||||||
|
},
|
||||||
|
fakeAppPath
|
||||||
|
);
|
||||||
|
|
||||||
|
const accessor = EasJsonAccessor.fromRawString(
|
||||||
|
await fsReal.readFile(path.join(fixturesDir, 'eas-invalid-json5.json'), 'utf-8')
|
||||||
|
);
|
||||||
|
await expect(accessor.readAsync()).rejects.toThrowError(InvalidEasJsonError);
|
||||||
|
await expect(accessor.readAsync()).rejects.toThrowError(
|
||||||
|
/^Found invalid character in .*eas\.json.+/
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('reading empty JSON file', async () => {
|
||||||
|
vol.fromJSON(
|
||||||
|
{
|
||||||
|
'./eas.json': await fsReal.readFile(path.join(fixturesDir, 'eas-empty.json'), 'utf-8'),
|
||||||
|
},
|
||||||
|
fakeAppPath
|
||||||
|
);
|
||||||
|
|
||||||
|
const accessor = EasJsonAccessor.fromRawString(
|
||||||
|
await fsReal.readFile(path.join(fixturesDir, 'eas-empty.json'), 'utf-8')
|
||||||
|
);
|
||||||
await expect(accessor.readAsync()).rejects.toThrowError(InvalidEasJsonError);
|
await expect(accessor.readAsync()).rejects.toThrowError(InvalidEasJsonError);
|
||||||
await expect(accessor.readAsync()).rejects.toThrowError(/^.*eas\.json.* is empty\.$/g);
|
await expect(accessor.readAsync()).rejects.toThrowError(/^.*eas\.json.* is empty\.$/g);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,7 +20,33 @@ test('minimal valid eas.json for both platforms', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
|
const iosProfile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.IOS, 'production');
|
||||||
|
const androidProfile = await EasJsonUtils.getBuildProfileAsync(
|
||||||
|
accessor,
|
||||||
|
Platform.ANDROID,
|
||||||
|
'production'
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(androidProfile).toEqual({
|
||||||
|
distribution: 'store',
|
||||||
|
credentialsSource: 'remote',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(iosProfile).toEqual({
|
||||||
|
distribution: 'store',
|
||||||
|
credentialsSource: 'remote',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('minimal valid eas.json for both platforms when reading eas.json from string', async () => {
|
||||||
|
const accessor = EasJsonAccessor.fromRawString(
|
||||||
|
JSON.stringify({
|
||||||
|
build: {
|
||||||
|
production: {},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
const iosProfile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.IOS, 'production');
|
const iosProfile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.IOS, 'production');
|
||||||
const androidProfile = await EasJsonUtils.getBuildProfileAsync(
|
const androidProfile = await EasJsonUtils.getBuildProfileAsync(
|
||||||
accessor,
|
accessor,
|
||||||
@@ -52,7 +78,7 @@ test('valid eas.json for development client builds', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const iosProfile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.IOS, 'debug');
|
const iosProfile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.IOS, 'debug');
|
||||||
const androidProfile = await EasJsonUtils.getBuildProfileAsync(
|
const androidProfile = await EasJsonUtils.getBuildProfileAsync(
|
||||||
accessor,
|
accessor,
|
||||||
@@ -82,7 +108,7 @@ test(`valid eas.json with autoIncrement flag at build profile root`, async () =>
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const iosProfile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.IOS, 'production');
|
const iosProfile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.IOS, 'production');
|
||||||
const androidProfile = await EasJsonUtils.getBuildProfileAsync(
|
const androidProfile = await EasJsonUtils.getBuildProfileAsync(
|
||||||
accessor,
|
accessor,
|
||||||
@@ -111,7 +137,7 @@ test('valid profile for internal distribution on Android', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const profile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'internal');
|
const profile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'internal');
|
||||||
expect(profile).toEqual({
|
expect(profile).toEqual({
|
||||||
distribution: 'internal',
|
distribution: 'internal',
|
||||||
@@ -133,7 +159,7 @@ test('valid profile extending other profile', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const baseProfile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'base');
|
const baseProfile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'base');
|
||||||
const extendedProfile = await EasJsonUtils.getBuildProfileAsync(
|
const extendedProfile = await EasJsonUtils.getBuildProfileAsync(
|
||||||
accessor,
|
accessor,
|
||||||
@@ -176,7 +202,7 @@ test('valid profile extending other profile with platform specific envs', async
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const baseProfile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'base');
|
const baseProfile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'base');
|
||||||
const extendedAndroidProfile = await EasJsonUtils.getBuildProfileAsync(
|
const extendedAndroidProfile = await EasJsonUtils.getBuildProfileAsync(
|
||||||
accessor,
|
accessor,
|
||||||
@@ -230,7 +256,6 @@ test('valid profile extending other profile with platform specific caching', asy
|
|||||||
},
|
},
|
||||||
android: {
|
android: {
|
||||||
cache: {
|
cache: {
|
||||||
cacheDefaultPaths: false,
|
|
||||||
customPaths: ['somefakepath'],
|
customPaths: ['somefakepath'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -238,7 +263,7 @@ test('valid profile extending other profile with platform specific caching', asy
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const baseProfile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'base');
|
const baseProfile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'base');
|
||||||
const extendedAndroidProfile = await EasJsonUtils.getBuildProfileAsync(
|
const extendedAndroidProfile = await EasJsonUtils.getBuildProfileAsync(
|
||||||
accessor,
|
accessor,
|
||||||
@@ -261,7 +286,6 @@ test('valid profile extending other profile with platform specific caching', asy
|
|||||||
distribution: 'internal',
|
distribution: 'internal',
|
||||||
credentialsSource: 'remote',
|
credentialsSource: 'remote',
|
||||||
cache: {
|
cache: {
|
||||||
cacheDefaultPaths: false,
|
|
||||||
customPaths: ['somefakepath'],
|
customPaths: ['somefakepath'],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -282,7 +306,7 @@ test('valid eas.json with missing profile', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const promise = EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'debug');
|
const promise = EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'debug');
|
||||||
await expect(promise).rejects.toThrowError('Missing build profile in eas.json: debug');
|
await expect(promise).rejects.toThrowError('Missing build profile in eas.json: debug');
|
||||||
});
|
});
|
||||||
@@ -294,7 +318,7 @@ test('invalid eas.json when using wrong buildType', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const promise = EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'production');
|
const promise = EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'production');
|
||||||
await expect(promise).rejects.toThrowError(InvalidEasJsonError);
|
await expect(promise).rejects.toThrowError(InvalidEasJsonError);
|
||||||
await expect(promise).rejects.toThrowError(
|
await expect(promise).rejects.toThrowError(
|
||||||
@@ -305,7 +329,7 @@ test('invalid eas.json when using wrong buildType', async () => {
|
|||||||
test('empty json', async () => {
|
test('empty json', async () => {
|
||||||
await fs.writeJson('/project/eas.json', {});
|
await fs.writeJson('/project/eas.json', {});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const promise = EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'production');
|
const promise = EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'production');
|
||||||
await expect(promise).rejects.toThrowError('Missing build profile in eas.json: production');
|
await expect(promise).rejects.toThrowError('Missing build profile in eas.json: production');
|
||||||
});
|
});
|
||||||
@@ -317,7 +341,7 @@ test('invalid semver value', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const promise = EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'production');
|
const promise = EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'production');
|
||||||
await expect(promise).rejects.toThrowError(InvalidEasJsonError);
|
await expect(promise).rejects.toThrowError(InvalidEasJsonError);
|
||||||
await expect(promise).rejects.toThrowError(
|
await expect(promise).rejects.toThrowError(
|
||||||
@@ -332,7 +356,7 @@ test('invalid release channel', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const promise = EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'production');
|
const promise = EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'production');
|
||||||
await expect(promise).rejects.toThrowError(/fails to match the required pattern/);
|
await expect(promise).rejects.toThrowError(/fails to match the required pattern/);
|
||||||
});
|
});
|
||||||
@@ -345,7 +369,7 @@ test('get profile names', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const allProfileNames = await EasJsonUtils.getBuildProfileNamesAsync(accessor);
|
const allProfileNames = await EasJsonUtils.getBuildProfileNamesAsync(accessor);
|
||||||
expect(allProfileNames.sort()).toEqual(['blah', 'production'].sort());
|
expect(allProfileNames.sort()).toEqual(['blah', 'production'].sort());
|
||||||
});
|
});
|
||||||
@@ -359,7 +383,7 @@ test('invalid resourceClass at build profile root', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
EasJsonUtils.getBuildProfileAsync(accessor, Platform.IOS, 'production')
|
EasJsonUtils.getBuildProfileAsync(accessor, Platform.IOS, 'production')
|
||||||
@@ -377,7 +401,7 @@ test('iOS-specific resourceClass', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
await expect(
|
await expect(
|
||||||
EasJsonUtils.getBuildProfileAsync(accessor, Platform.IOS, 'production')
|
EasJsonUtils.getBuildProfileAsync(accessor, Platform.IOS, 'production')
|
||||||
).resolves.not.toThrow();
|
).resolves.not.toThrow();
|
||||||
@@ -394,8 +418,69 @@ test('Android-specific resourceClass', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
await expect(
|
await expect(
|
||||||
EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'production')
|
EasJsonUtils.getBuildProfileAsync(accessor, Platform.ANDROID, 'production')
|
||||||
).resolves.not.toThrow();
|
).resolves.not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('build profile with platform-specific custom build config', async () => {
|
||||||
|
await fs.writeJson('/project/eas.json', {
|
||||||
|
build: {
|
||||||
|
production: {
|
||||||
|
android: {
|
||||||
|
config: 'production.android.yml',
|
||||||
|
},
|
||||||
|
ios: {
|
||||||
|
config: 'production.ios.yml',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
|
const androidProfile = await EasJsonUtils.getBuildProfileAsync(
|
||||||
|
accessor,
|
||||||
|
Platform.ANDROID,
|
||||||
|
'production'
|
||||||
|
);
|
||||||
|
const iosProfile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.IOS, 'production');
|
||||||
|
expect(androidProfile).toEqual({
|
||||||
|
config: 'production.android.yml',
|
||||||
|
distribution: 'store',
|
||||||
|
credentialsSource: 'remote',
|
||||||
|
});
|
||||||
|
expect(iosProfile).toEqual({
|
||||||
|
config: 'production.ios.yml',
|
||||||
|
distribution: 'store',
|
||||||
|
credentialsSource: 'remote',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('build profiles with both platform build config', async () => {
|
||||||
|
await fs.writeJson('/project/eas.json', {
|
||||||
|
build: {
|
||||||
|
production: {
|
||||||
|
config: 'production.yml',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
|
const androidProfile = await EasJsonUtils.getBuildProfileAsync(
|
||||||
|
accessor,
|
||||||
|
Platform.ANDROID,
|
||||||
|
'production'
|
||||||
|
);
|
||||||
|
const iosProfile = await EasJsonUtils.getBuildProfileAsync(accessor, Platform.IOS, 'production');
|
||||||
|
expect(androidProfile).toEqual({
|
||||||
|
config: 'production.yml',
|
||||||
|
distribution: 'store',
|
||||||
|
credentialsSource: 'remote',
|
||||||
|
});
|
||||||
|
expect(iosProfile).toEqual({
|
||||||
|
config: 'production.yml',
|
||||||
|
distribution: 'store',
|
||||||
|
credentialsSource: 'remote',
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -19,7 +19,7 @@ test('minimal allowed eas.json for both platforms', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const iosProfile = await EasJsonUtils.getSubmitProfileAsync(accessor, Platform.IOS, 'production');
|
const iosProfile = await EasJsonUtils.getSubmitProfileAsync(accessor, Platform.IOS, 'production');
|
||||||
const androidProfile = await EasJsonUtils.getSubmitProfileAsync(
|
const androidProfile = await EasJsonUtils.getSubmitProfileAsync(
|
||||||
accessor,
|
accessor,
|
||||||
@@ -50,7 +50,7 @@ test('android config with all required values', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const androidProfile = await EasJsonUtils.getSubmitProfileAsync(
|
const androidProfile = await EasJsonUtils.getSubmitProfileAsync(
|
||||||
accessor,
|
accessor,
|
||||||
Platform.ANDROID,
|
Platform.ANDROID,
|
||||||
@@ -80,7 +80,7 @@ test('android config with serviceAccountKeyPath set to env var', async () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
process.env.GOOGLE_SERVICE_ACCOUNT = './path.json';
|
process.env.GOOGLE_SERVICE_ACCOUNT = './path.json';
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const androidProfile = await EasJsonUtils.getSubmitProfileAsync(
|
const androidProfile = await EasJsonUtils.getSubmitProfileAsync(
|
||||||
accessor,
|
accessor,
|
||||||
Platform.ANDROID,
|
Platform.ANDROID,
|
||||||
@@ -114,7 +114,7 @@ test('ios config with all required values', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const iosProfile = await EasJsonUtils.getSubmitProfileAsync(accessor, Platform.IOS, 'production');
|
const iosProfile = await EasJsonUtils.getSubmitProfileAsync(accessor, Platform.IOS, 'production');
|
||||||
|
|
||||||
expect(iosProfile).toEqual({
|
expect(iosProfile).toEqual({
|
||||||
@@ -148,7 +148,7 @@ test('ios config with ascApiKey fields set to env var', async () => {
|
|||||||
process.env.ASC_API_KEY_PATH = './path-ABCD.p8';
|
process.env.ASC_API_KEY_PATH = './path-ABCD.p8';
|
||||||
process.env.ASC_API_KEY_ISSUER_ID = 'abc-123-def-456';
|
process.env.ASC_API_KEY_ISSUER_ID = 'abc-123-def-456';
|
||||||
process.env.ASC_API_KEY_ID = 'ABCD';
|
process.env.ASC_API_KEY_ID = 'ABCD';
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const iosProfile = await EasJsonUtils.getSubmitProfileAsync(accessor, Platform.IOS, 'release');
|
const iosProfile = await EasJsonUtils.getSubmitProfileAsync(accessor, Platform.IOS, 'release');
|
||||||
|
|
||||||
expect(iosProfile).toEqual({
|
expect(iosProfile).toEqual({
|
||||||
@@ -189,7 +189,7 @@ test('valid profile extending other profile', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const baseProfile = await EasJsonUtils.getSubmitProfileAsync(accessor, Platform.IOS, 'base');
|
const baseProfile = await EasJsonUtils.getSubmitProfileAsync(accessor, Platform.IOS, 'base');
|
||||||
const extendedProfile = await EasJsonUtils.getSubmitProfileAsync(
|
const extendedProfile = await EasJsonUtils.getSubmitProfileAsync(
|
||||||
accessor,
|
accessor,
|
||||||
@@ -233,7 +233,7 @@ test('get profile names', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const accessor = new EasJsonAccessor('/project');
|
const accessor = EasJsonAccessor.fromProjectPath('/project');
|
||||||
const allProfileNames = await EasJsonUtils.getSubmitProfileNamesAsync(accessor);
|
const allProfileNames = await EasJsonUtils.getSubmitProfileNamesAsync(accessor);
|
||||||
expect(allProfileNames.sort()).toEqual(['production', 'blah'].sort());
|
expect(allProfileNames.sort()).toEqual(['production', 'blah'].sort());
|
||||||
});
|
});
|
||||||
@@ -38,7 +38,7 @@ const customErrorMessageHandlers: ((err: ValidationError) => void)[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export class EasJsonAccessor {
|
export class EasJsonAccessor {
|
||||||
private easJsonPath: string;
|
private easJsonPath: string | undefined;
|
||||||
|
|
||||||
private isJson5 = false;
|
private isJson5 = false;
|
||||||
private easJson: EasJson | undefined;
|
private easJson: EasJson | undefined;
|
||||||
@@ -46,8 +46,25 @@ export class EasJsonAccessor {
|
|||||||
private easJsonRawObject: any | undefined;
|
private easJsonRawObject: any | undefined;
|
||||||
private easJsonPatched: boolean = false;
|
private easJsonPatched: boolean = false;
|
||||||
|
|
||||||
constructor(projectDir: string) {
|
private constructor({ projectDir }: { projectDir: string });
|
||||||
this.easJsonPath = EasJsonAccessor.formatEasJsonPath(projectDir);
|
private constructor({ easJsonRawContents }: { easJsonRawContents: string });
|
||||||
|
private constructor({
|
||||||
|
projectDir,
|
||||||
|
easJsonRawContents,
|
||||||
|
}: {
|
||||||
|
projectDir?: string;
|
||||||
|
easJsonRawContents?: string;
|
||||||
|
}) {
|
||||||
|
this.easJsonPath = projectDir && EasJsonAccessor.formatEasJsonPath(projectDir);
|
||||||
|
this.easJsonRawContents = easJsonRawContents;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static fromProjectPath(projectDir: string): EasJsonAccessor {
|
||||||
|
return new EasJsonAccessor({ projectDir });
|
||||||
|
}
|
||||||
|
|
||||||
|
public static fromRawString(easJsonRawContents: string): EasJsonAccessor {
|
||||||
|
return new EasJsonAccessor({ easJsonRawContents });
|
||||||
}
|
}
|
||||||
|
|
||||||
public static formatEasJsonPath(projectDir: string): string {
|
public static formatEasJsonPath(projectDir: string): string {
|
||||||
@@ -81,6 +98,9 @@ export class EasJsonAccessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async writeAsync(): Promise<void> {
|
public async writeAsync(): Promise<void> {
|
||||||
|
if (!this.easJsonPath) {
|
||||||
|
throw new Error('Updates are not supported for EasJsonAccessor created from string.');
|
||||||
|
}
|
||||||
if (!this.easJsonPatched) {
|
if (!this.easJsonPatched) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -89,6 +109,9 @@ export class EasJsonAccessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public patch(fn: (easJsonRawObject: any) => any): void {
|
public patch(fn: (easJsonRawObject: any) => any): void {
|
||||||
|
if (!this.easJsonPath) {
|
||||||
|
throw new Error('Updates are not supported for EasJsonAccessor created from string.');
|
||||||
|
}
|
||||||
assert(
|
assert(
|
||||||
this.easJsonRawContents && this.easJsonRawObject,
|
this.easJsonRawContents && this.easJsonRawObject,
|
||||||
'call readAsync/readRawJsonAsync first'
|
'call readAsync/readRawJsonAsync first'
|
||||||
@@ -104,16 +127,24 @@ export class EasJsonAccessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async readRawJsonAsync(): Promise<any> {
|
public async readRawJsonAsync(): Promise<any> {
|
||||||
if (!(await fs.pathExists(this.easJsonPath))) {
|
if (this.easJsonPath) {
|
||||||
throw new MissingEasJsonError(
|
if (!(await fs.pathExists(this.easJsonPath))) {
|
||||||
`${chalk.bold('eas.json')} could not be found at ${
|
throw new MissingEasJsonError(
|
||||||
this.easJsonPath
|
`${chalk.bold('eas.json')} could not be found at ${
|
||||||
}. Learn more at https://expo.fyi/eas-json`
|
this.easJsonPath
|
||||||
);
|
}. Learn more at https://expo.fyi/eas-json`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
this.easJsonRawContents = await fs.readFile(this.easJsonPath, 'utf-8');
|
||||||
}
|
}
|
||||||
|
return this.parseRawJson();
|
||||||
|
}
|
||||||
|
|
||||||
this.easJsonRawContents = await fs.readFile(this.easJsonPath, 'utf-8');
|
private parseRawJson(): any {
|
||||||
|
assert(
|
||||||
|
this.easJsonRawContents !== undefined,
|
||||||
|
'easJsonRawContents needs to be set before calling parseRawJson'
|
||||||
|
);
|
||||||
if (this.easJsonRawContents.trim().length === 0) {
|
if (this.easJsonRawContents.trim().length === 0) {
|
||||||
throw new InvalidEasJsonError(`${chalk.bold('eas.json')} is empty.`);
|
throw new InvalidEasJsonError(`${chalk.bold('eas.json')} is empty.`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ const AllowedIosResourceClasses: ResourceClass[] = [
|
|||||||
...AllowedCommonResourceClasses,
|
...AllowedCommonResourceClasses,
|
||||||
ResourceClass.M1_MEDIUM,
|
ResourceClass.M1_MEDIUM,
|
||||||
ResourceClass.INTEL_MEDIUM,
|
ResourceClass.INTEL_MEDIUM,
|
||||||
|
ResourceClass.M_MEDIUM,
|
||||||
|
ResourceClass.M_LARGE,
|
||||||
];
|
];
|
||||||
|
|
||||||
const CacheSchema = Joi.object({
|
const CacheSchema = Joi.object({
|
||||||
@@ -24,69 +26,98 @@ const CacheSchema = Joi.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const CommonBuildProfileSchema = Joi.object({
|
const CommonBuildProfileSchema = Joi.object({
|
||||||
credentialsSource: Joi.string().valid('local', 'remote').default('remote'),
|
// builder
|
||||||
distribution: Joi.string().valid('store', 'internal').default('store'),
|
resourceClass: Joi.string().valid(...AllowedCommonResourceClasses),
|
||||||
cache: CacheSchema,
|
|
||||||
releaseChannel: Joi.string().regex(/^[a-z\d][a-z\d._-]*$/),
|
|
||||||
channel: Joi.string().regex(/^[a-z\d][a-z\d._-]*$/),
|
|
||||||
developmentClient: Joi.boolean(),
|
|
||||||
prebuildCommand: Joi.string(),
|
|
||||||
buildArtifactPaths: Joi.array().items(Joi.string()),
|
|
||||||
|
|
||||||
|
// build environment
|
||||||
|
env: Joi.object().pattern(Joi.string(), Joi.string().empty(null)),
|
||||||
node: Joi.string().empty(null).custom(semverCheck),
|
node: Joi.string().empty(null).custom(semverCheck),
|
||||||
yarn: Joi.string().empty(null).custom(semverCheck),
|
yarn: Joi.string().empty(null).custom(semverCheck),
|
||||||
expoCli: Joi.string().empty(null).custom(semverCheck),
|
expoCli: Joi.string().empty(null).custom(semverCheck),
|
||||||
env: Joi.object().pattern(Joi.string(), Joi.string().empty(null)),
|
|
||||||
|
// credentials
|
||||||
|
credentialsSource: Joi.string().valid('local', 'remote').default('remote'),
|
||||||
|
distribution: Joi.string().valid('store', 'internal').default('store'),
|
||||||
|
|
||||||
|
// updates
|
||||||
|
releaseChannel: Joi.string().regex(/^[a-z\d][a-z\d._-]*$/),
|
||||||
|
channel: Joi.string().regex(/^[a-z\d][a-z\d._-]*$/),
|
||||||
|
|
||||||
|
// build configuration
|
||||||
|
developmentClient: Joi.boolean(),
|
||||||
|
prebuildCommand: Joi.string(),
|
||||||
|
|
||||||
|
// versions
|
||||||
autoIncrement: Joi.alternatives().try(Joi.boolean()),
|
autoIncrement: Joi.alternatives().try(Joi.boolean()),
|
||||||
resourceClass: Joi.string().valid(...AllowedCommonResourceClasses),
|
|
||||||
|
// artifacts
|
||||||
|
buildArtifactPaths: Joi.array().items(Joi.string()),
|
||||||
|
|
||||||
|
// cache
|
||||||
|
cache: CacheSchema,
|
||||||
|
|
||||||
|
// custom build configuration
|
||||||
|
config: Joi.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const AndroidBuildProfileSchema = CommonBuildProfileSchema.concat(
|
const PlatformBuildProfileSchema = CommonBuildProfileSchema.concat(
|
||||||
Joi.object({
|
Joi.object({
|
||||||
credentialsSource: Joi.string().valid('local', 'remote'),
|
// build environment
|
||||||
distribution: Joi.string().valid('store', 'internal'),
|
image: Joi.string(),
|
||||||
|
|
||||||
|
// artifacts
|
||||||
|
artifactPath: Joi.string(),
|
||||||
|
applicationArchivePath: Joi.string(),
|
||||||
|
}).oxor('artifactPath', 'applicationArchivePath')
|
||||||
|
);
|
||||||
|
|
||||||
|
const AndroidBuildProfileSchema = PlatformBuildProfileSchema.concat(
|
||||||
|
Joi.object({
|
||||||
|
// builder
|
||||||
|
resourceClass: Joi.string().valid(...AllowedAndroidResourceClasses),
|
||||||
|
|
||||||
|
// build environment
|
||||||
|
ndk: Joi.string().empty(null).custom(semverCheck),
|
||||||
|
|
||||||
|
// credentials
|
||||||
withoutCredentials: Joi.boolean(),
|
withoutCredentials: Joi.boolean(),
|
||||||
|
|
||||||
image: Joi.string(),
|
// build configuration
|
||||||
ndk: Joi.string().empty(null).custom(semverCheck),
|
gradleCommand: Joi.string(),
|
||||||
|
buildType: Joi.string().valid('apk', 'app-bundle'),
|
||||||
|
|
||||||
|
// versions
|
||||||
autoIncrement: Joi.alternatives().try(
|
autoIncrement: Joi.alternatives().try(
|
||||||
Joi.boolean(),
|
Joi.boolean(),
|
||||||
Joi.string().valid('version', 'versionCode')
|
Joi.string().valid('version', 'versionCode')
|
||||||
),
|
),
|
||||||
resourceClass: Joi.string().valid(...AllowedAndroidResourceClasses),
|
})
|
||||||
|
|
||||||
artifactPath: Joi.string(),
|
|
||||||
applicationArchivePath: Joi.string(),
|
|
||||||
buildArtifactPaths: Joi.array().items(Joi.string()),
|
|
||||||
gradleCommand: Joi.string(),
|
|
||||||
|
|
||||||
buildType: Joi.string().valid('apk', 'app-bundle'),
|
|
||||||
}).oxor('artifactPath', 'applicationArchivePath')
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const IosBuildProfileSchema = CommonBuildProfileSchema.concat(
|
const IosBuildProfileSchema = PlatformBuildProfileSchema.concat(
|
||||||
Joi.object({
|
Joi.object({
|
||||||
credentialsSource: Joi.string().valid('local', 'remote'),
|
// builder
|
||||||
distribution: Joi.string().valid('store', 'internal'),
|
|
||||||
enterpriseProvisioning: Joi.string().valid('adhoc', 'universal'),
|
|
||||||
autoIncrement: Joi.alternatives().try(
|
|
||||||
Joi.boolean(),
|
|
||||||
Joi.string().valid('version', 'buildNumber')
|
|
||||||
),
|
|
||||||
simulator: Joi.boolean(),
|
|
||||||
resourceClass: Joi.string().valid(...AllowedIosResourceClasses),
|
resourceClass: Joi.string().valid(...AllowedIosResourceClasses),
|
||||||
|
|
||||||
image: Joi.string(),
|
// build environment
|
||||||
bundler: Joi.string().empty(null).custom(semverCheck),
|
bundler: Joi.string().empty(null).custom(semverCheck),
|
||||||
fastlane: Joi.string().empty(null).custom(semverCheck),
|
fastlane: Joi.string().empty(null).custom(semverCheck),
|
||||||
cocoapods: Joi.string().empty(null).custom(semverCheck),
|
cocoapods: Joi.string().empty(null).custom(semverCheck),
|
||||||
|
|
||||||
artifactPath: Joi.string(),
|
// credentials
|
||||||
applicationArchivePath: Joi.string(),
|
enterpriseProvisioning: Joi.string().valid('adhoc', 'universal'),
|
||||||
buildArtifactPaths: Joi.array().items(Joi.string()),
|
|
||||||
|
// build configuration
|
||||||
|
simulator: Joi.boolean(),
|
||||||
scheme: Joi.string(),
|
scheme: Joi.string(),
|
||||||
buildConfiguration: Joi.string(),
|
buildConfiguration: Joi.string(),
|
||||||
}).oxor('artifactPath', 'applicationArchivePath')
|
|
||||||
|
// versions
|
||||||
|
autoIncrement: Joi.alternatives().try(
|
||||||
|
Joi.boolean(),
|
||||||
|
Joi.string().valid('version', 'buildNumber')
|
||||||
|
),
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
export const BuildProfileSchema = CommonBuildProfileSchema.concat(
|
export const BuildProfileSchema = CommonBuildProfileSchema.concat(
|
||||||
|
|||||||
@@ -9,15 +9,21 @@ export enum ResourceClass {
|
|||||||
DEFAULT = 'default',
|
DEFAULT = 'default',
|
||||||
LARGE = 'large',
|
LARGE = 'large',
|
||||||
/**
|
/**
|
||||||
* @deprecated use M1_MEDIUM instead
|
* @deprecated use M_MEDIUM instead
|
||||||
* @experimental
|
|
||||||
* This resource class is not yet ready to be used in production. For testing purposes only. Might be deprecated / deleted at any time.
|
|
||||||
*/
|
*/
|
||||||
M1_EXPERIMENTAL = 'm1-experimental',
|
M1_EXPERIMENTAL = 'm1-experimental',
|
||||||
|
/**
|
||||||
|
* @deprecated use M_MEDIUM instead
|
||||||
|
*/
|
||||||
M1_MEDIUM = 'm1-medium',
|
M1_MEDIUM = 'm1-medium',
|
||||||
|
/**
|
||||||
|
* @deprecated use M_LARGE instead
|
||||||
|
*/
|
||||||
M1_LARGE = 'm1-large',
|
M1_LARGE = 'm1-large',
|
||||||
INTEL_MEDIUM = 'intel-medium',
|
INTEL_MEDIUM = 'intel-medium',
|
||||||
MEDIUM = 'medium',
|
MEDIUM = 'medium',
|
||||||
|
M_MEDIUM = 'm-medium',
|
||||||
|
M_LARGE = 'm-large',
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DistributionType = 'store' | 'internal';
|
export type DistributionType = 'store' | 'internal';
|
||||||
@@ -29,32 +35,42 @@ export type IosVersionAutoIncrement = VersionAutoIncrement | 'buildNumber';
|
|||||||
export type AndroidVersionAutoIncrement = VersionAutoIncrement | 'versionCode';
|
export type AndroidVersionAutoIncrement = VersionAutoIncrement | 'versionCode';
|
||||||
|
|
||||||
export interface CommonBuildProfile {
|
export interface CommonBuildProfile {
|
||||||
credentialsSource: CredentialsSource;
|
// builder
|
||||||
distribution: DistributionType;
|
|
||||||
cache?: Omit<Cache, 'clear'>;
|
|
||||||
releaseChannel?: string;
|
|
||||||
channel?: string;
|
|
||||||
developmentClient?: boolean;
|
|
||||||
prebuildCommand?: string;
|
|
||||||
autoIncrement?: boolean;
|
|
||||||
resourceClass?: ResourceClass;
|
resourceClass?: ResourceClass;
|
||||||
buildArtifactPaths?: string[];
|
|
||||||
|
|
||||||
|
// build environment
|
||||||
|
env?: Record<string, string>;
|
||||||
node?: string;
|
node?: string;
|
||||||
yarn?: string;
|
yarn?: string;
|
||||||
expoCli?: string;
|
expoCli?: string;
|
||||||
env?: Record<string, string>;
|
|
||||||
|
// credentials
|
||||||
|
credentialsSource: CredentialsSource;
|
||||||
|
distribution: DistributionType;
|
||||||
|
|
||||||
|
// updates
|
||||||
|
releaseChannel?: string;
|
||||||
|
channel?: string;
|
||||||
|
|
||||||
|
// build configuration
|
||||||
|
developmentClient?: boolean;
|
||||||
|
prebuildCommand?: string;
|
||||||
|
|
||||||
|
// versions
|
||||||
|
autoIncrement?: boolean;
|
||||||
|
|
||||||
|
// artifacts
|
||||||
|
buildArtifactPaths?: string[];
|
||||||
|
|
||||||
|
// cache
|
||||||
|
cache?: Omit<Cache, 'clear'>;
|
||||||
|
|
||||||
|
// custom build configuration
|
||||||
|
config?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AndroidBuildProfile extends Omit<CommonBuildProfile, 'autoIncrement'> {
|
interface PlatformBuildProfile extends Omit<CommonBuildProfile, 'autoIncrement'> {
|
||||||
withoutCredentials?: boolean;
|
// artifacts
|
||||||
image?: Android.BuilderEnvironment['image'];
|
|
||||||
ndk?: string;
|
|
||||||
autoIncrement?: AndroidVersionAutoIncrement;
|
|
||||||
|
|
||||||
buildType?: Android.BuildType.APK | Android.BuildType.APP_BUNDLE;
|
|
||||||
|
|
||||||
gradleCommand?: string;
|
|
||||||
/**
|
/**
|
||||||
* @deprecated use applicationArchivePath
|
* @deprecated use applicationArchivePath
|
||||||
*/
|
*/
|
||||||
@@ -62,22 +78,39 @@ export interface AndroidBuildProfile extends Omit<CommonBuildProfile, 'autoIncre
|
|||||||
applicationArchivePath?: string;
|
applicationArchivePath?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IosBuildProfile extends Omit<CommonBuildProfile, 'autoIncrement'> {
|
export interface AndroidBuildProfile extends PlatformBuildProfile {
|
||||||
enterpriseProvisioning?: IosEnterpriseProvisioning;
|
// build environment
|
||||||
autoIncrement?: IosVersionAutoIncrement;
|
image?: Android.BuilderEnvironment['image'];
|
||||||
simulator?: boolean;
|
ndk?: string;
|
||||||
|
|
||||||
|
// credentials
|
||||||
|
withoutCredentials?: boolean;
|
||||||
|
|
||||||
|
// build configuration
|
||||||
|
gradleCommand?: string;
|
||||||
|
buildType?: Android.BuildType.APK | Android.BuildType.APP_BUNDLE;
|
||||||
|
|
||||||
|
// versions
|
||||||
|
autoIncrement?: AndroidVersionAutoIncrement;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IosBuildProfile extends PlatformBuildProfile {
|
||||||
|
// build environment
|
||||||
image?: Ios.BuilderEnvironment['image'];
|
image?: Ios.BuilderEnvironment['image'];
|
||||||
bundler?: string;
|
bundler?: string;
|
||||||
fastlane?: string;
|
fastlane?: string;
|
||||||
cocoapods?: string;
|
cocoapods?: string;
|
||||||
|
|
||||||
/**
|
// credentials
|
||||||
* @deprecated use applicationArchivePath
|
enterpriseProvisioning?: IosEnterpriseProvisioning;
|
||||||
*/
|
|
||||||
artifactPath?: string;
|
// build configuration
|
||||||
applicationArchivePath?: string;
|
simulator?: boolean;
|
||||||
scheme?: string;
|
scheme?: string;
|
||||||
buildConfiguration?: string;
|
buildConfiguration?: string;
|
||||||
|
|
||||||
|
// versions
|
||||||
|
autoIncrement?: IosVersionAutoIncrement;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BuildProfile<TPlatform extends Platform = Platform> = TPlatform extends Platform.ANDROID
|
export type BuildProfile<TPlatform extends Platform = Platform> = TPlatform extends Platform.ANDROID
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export { AndroidReleaseStatus, AndroidReleaseTrack, SubmitProfile } from './submit/types';
|
export { AndroidReleaseStatus, AndroidReleaseTrack, SubmitProfile } from './submit/types';
|
||||||
export { getDefaultProfile as getDefaultSubmitProfile } from './submit/resolver';
|
export { getDefaultProfile as getDefaultSubmitProfile } from './submit/resolver';
|
||||||
export { EasJson, ProfileType, AppVersionSource } from './types';
|
export { EasJson, ProfileType, AppVersionSource } from './types';
|
||||||
|
export { Platform } from '@expo/eas-build-job';
|
||||||
export {
|
export {
|
||||||
AndroidVersionAutoIncrement,
|
AndroidVersionAutoIncrement,
|
||||||
BuildProfile,
|
BuildProfile,
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ import { resolveSubmitProfile } from './submit/resolver';
|
|||||||
import { SubmitProfile } from './submit/types';
|
import { SubmitProfile } from './submit/types';
|
||||||
import { EasJson } from './types';
|
import { EasJson } from './types';
|
||||||
|
|
||||||
|
interface EasJsonDeprecationWarning {
|
||||||
|
message: string[];
|
||||||
|
docsUrl?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class EasJsonUtils {
|
export class EasJsonUtils {
|
||||||
public static async getBuildProfileNamesAsync(accessor: EasJsonAccessor): Promise<string[]> {
|
public static async getBuildProfileNamesAsync(accessor: EasJsonAccessor): Promise<string[]> {
|
||||||
const easJson = await accessor.readAsync();
|
const easJson = await accessor.readAsync();
|
||||||
@@ -23,6 +28,26 @@ export class EasJsonUtils {
|
|||||||
return resolveBuildProfile({ easJson, platform, profileName });
|
return resolveBuildProfile({ easJson, platform, profileName });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static getBuildProfileDeprecationWarnings(
|
||||||
|
buildProfile: BuildProfile,
|
||||||
|
profileName?: string
|
||||||
|
): EasJsonDeprecationWarning[] {
|
||||||
|
const warnings: EasJsonDeprecationWarning[] = [];
|
||||||
|
|
||||||
|
if (buildProfile.cache?.cacheDefaultPaths !== undefined) {
|
||||||
|
warnings.push({
|
||||||
|
message: [
|
||||||
|
`The "build.${
|
||||||
|
profileName ?? 'production'
|
||||||
|
}.cache.cacheDefaultPaths" field in eas.json is deprecated and will be removed in the future.`,
|
||||||
|
],
|
||||||
|
docsUrl: 'https://docs.expo.dev/build-reference/caching/#ios-dependencies',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return warnings;
|
||||||
|
}
|
||||||
|
|
||||||
public static async getCliConfigAsync(accessor: EasJsonAccessor): Promise<EasJson['cli'] | null> {
|
public static async getCliConfigAsync(accessor: EasJsonAccessor): Promise<EasJson['cli'] | null> {
|
||||||
try {
|
try {
|
||||||
const easJson = await accessor.readAsync();
|
const easJson = await accessor.readAsync();
|
||||||
|
|||||||
Loaded 100 of 102 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user