eas-cli 21.2.0 → 21.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +343 -148
- package/build/build/build.js +102 -17
- package/build/commandUtils/context/contextUtils/getProjectIdAsync.js +31 -16
- package/build/commands/observe/events.js +10 -6
- package/build/commands/observe/metrics-summary.js +2 -1
- package/build/commands/observe/metrics.js +3 -2
- package/build/commands/observe/routes.js +3 -2
- package/build/commands/observe/session.js +8 -2
- package/build/commands/project/icon/set.d.ts +15 -0
- package/build/commands/project/icon/set.js +93 -0
- package/build/commands/project/init.d.ts +3 -0
- package/build/commands/project/init.js +34 -7
- package/build/commands/simulator/events.d.ts +16 -0
- package/build/commands/simulator/events.js +136 -0
- package/build/commands/simulator/get.js +2 -0
- package/build/commands/simulator/list.js +2 -0
- package/build/commands/simulator/start.d.ts +1 -0
- package/build/commands/simulator/start.js +8 -0
- package/build/commands/testflight/crashes.d.ts +23 -0
- package/build/commands/testflight/crashes.js +82 -0
- package/build/commands/testflight/feedback.d.ts +23 -0
- package/build/commands/testflight/feedback.js +82 -0
- package/build/graphql/generated.d.ts +370 -254
- package/build/graphql/generated.js +18 -23
- package/build/graphql/mutations/UploadSessionMutation.d.ts +5 -1
- package/build/graphql/mutations/UploadSessionMutation.js +15 -0
- package/build/graphql/queries/AppQuery.d.ts +1 -0
- package/build/graphql/queries/AppQuery.js +19 -0
- package/build/graphql/queries/DeviceRunSessionQuery.d.ts +2 -1
- package/build/graphql/queries/DeviceRunSessionQuery.js +22 -0
- package/build/observe/fetchEvents.js +7 -1
- package/build/observe/fetchMetrics.js +6 -0
- package/build/observe/fetchNavigationRoutes.js +6 -0
- package/build/observe/fetchSessions.d.ts +7 -0
- package/build/observe/fetchSessions.js +16 -0
- package/build/observe/planGating.d.ts +15 -0
- package/build/observe/planGating.js +48 -0
- package/build/project/accountSelection.d.ts +4 -0
- package/build/project/accountSelection.js +56 -0
- package/build/project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync.js +4 -3
- package/build/project/projectInitialization.d.ts +13 -3
- package/build/project/projectInitialization.js +52 -80
- package/build/simulator/events.d.ts +7 -0
- package/build/simulator/events.js +95 -0
- package/build/simulator/utils.js +1 -1
- package/build/testflight/app.d.ts +18 -0
- package/build/testflight/app.js +124 -0
- package/build/testflight/fetch.d.ts +56 -0
- package/build/testflight/fetch.js +116 -0
- package/build/testflight/format.d.ts +4 -0
- package/build/testflight/format.js +104 -0
- package/build/testflight/queries.d.ts +16 -0
- package/build/testflight/queries.js +123 -0
- package/build/testflight/target.d.ts +15 -0
- package/build/testflight/target.js +32 -0
- package/build/uploads.d.ts +7 -1
- package/build/uploads.js +9 -0
- package/build/user/User.d.ts +6 -0
- package/build/user/User.js +18 -0
- package/oclif.manifest.json +2185 -1728
- package/package.json +8 -5
|
@@ -7,17 +7,18 @@ const tslib_1 = require("tslib");
|
|
|
7
7
|
const config_1 = require("@expo/config");
|
|
8
8
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
9
9
|
const nullthrows_1 = tslib_1.__importDefault(require("nullthrows"));
|
|
10
|
+
const accountSelection_1 = require("./accountSelection");
|
|
10
11
|
const expoConfig_1 = require("./expoConfig");
|
|
11
12
|
const fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync_1 = require("./fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync");
|
|
12
13
|
const url_1 = require("../build/utils/url");
|
|
13
14
|
const getProjectIdAsync_1 = require("../commandUtils/context/contextUtils/getProjectIdAsync");
|
|
14
15
|
const projectNameValidation_1 = require("../commandUtils/projectNameValidation");
|
|
15
|
-
const generated_1 = require("../graphql/generated");
|
|
16
16
|
const AppMutation_1 = require("../graphql/mutations/AppMutation");
|
|
17
17
|
const AppQuery_1 = require("../graphql/queries/AppQuery");
|
|
18
18
|
const log_1 = tslib_1.__importStar(require("../log"));
|
|
19
19
|
const ora_1 = require("../ora");
|
|
20
20
|
const prompts_1 = require("../prompts");
|
|
21
|
+
const User_1 = require("../user/User");
|
|
21
22
|
async function saveProjectIdAndLogSuccessAsync(projectDir, projectId) {
|
|
22
23
|
await (0, getProjectIdAsync_1.saveProjectIdToAppConfigAsync)(projectDir, projectId);
|
|
23
24
|
log_1.default.withTick(`Project successfully linked (ID: ${chalk_1.default.bold(projectId)}) (modified app.json)`);
|
|
@@ -103,69 +104,83 @@ async function ensureOwnerSlugConsistencyAsync(graphqlClient, projectId, project
|
|
|
103
104
|
else if (!exp.slug) {
|
|
104
105
|
await modifyExpoConfigAsync(projectDir, { slug: correctSlug });
|
|
105
106
|
}
|
|
107
|
+
return { owner: correctOwner, slug: correctSlug };
|
|
106
108
|
}
|
|
107
109
|
async function setExplicitIDAsync(projectId, projectDir, { force, nonInteractive }) {
|
|
108
110
|
const exp = await (0, expoConfig_1.getPrivateExpoConfigAsync)(projectDir);
|
|
109
111
|
const existingProjectId = exp.extra?.eas?.projectId;
|
|
110
112
|
if (projectId === existingProjectId) {
|
|
111
113
|
log_1.default.succeed(`Project already linked (ID: ${chalk_1.default.bold(existingProjectId)})`);
|
|
112
|
-
return;
|
|
114
|
+
return 'already-linked';
|
|
113
115
|
}
|
|
114
116
|
if (!existingProjectId) {
|
|
115
117
|
await saveProjectIdAndLogSuccessAsync(projectDir, projectId);
|
|
116
|
-
return;
|
|
118
|
+
return 'linked';
|
|
117
119
|
}
|
|
118
|
-
if (
|
|
119
|
-
if (force) {
|
|
120
|
-
await saveProjectIdAndLogSuccessAsync(projectDir, projectId);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (nonInteractive) {
|
|
124
|
-
throw new Error(`Project is already linked to a different ID: ${chalk_1.default.bold(existingProjectId)}. Use --force flag to overwrite.`);
|
|
125
|
-
}
|
|
126
|
-
const confirm = await (0, prompts_1.confirmAsync)({
|
|
127
|
-
message: `Project is already linked to a different ID: ${chalk_1.default.bold(existingProjectId)}. Do you wish to overwrite it?`,
|
|
128
|
-
});
|
|
129
|
-
if (!confirm) {
|
|
130
|
-
throw new Error('Aborting');
|
|
131
|
-
}
|
|
120
|
+
if (force) {
|
|
132
121
|
await saveProjectIdAndLogSuccessAsync(projectDir, projectId);
|
|
122
|
+
return 'linked';
|
|
123
|
+
}
|
|
124
|
+
if (nonInteractive) {
|
|
125
|
+
throw new Error(`Project is already linked to a different ID: ${chalk_1.default.bold(existingProjectId)}. Use --force flag to overwrite.`);
|
|
126
|
+
}
|
|
127
|
+
const confirm = await (0, prompts_1.confirmAsync)({
|
|
128
|
+
message: `Project is already linked to a different ID: ${chalk_1.default.bold(existingProjectId)}. Do you wish to overwrite it?`,
|
|
129
|
+
});
|
|
130
|
+
if (!confirm) {
|
|
131
|
+
throw new Error('Aborting');
|
|
133
132
|
}
|
|
133
|
+
await saveProjectIdAndLogSuccessAsync(projectDir, projectId);
|
|
134
|
+
return 'linked';
|
|
134
135
|
}
|
|
135
136
|
async function initializeWithExplicitIDAsync(projectId, projectDir, { force, nonInteractive }) {
|
|
136
|
-
await setExplicitIDAsync(projectId, projectDir, {
|
|
137
|
+
return await setExplicitIDAsync(projectId, projectDir, {
|
|
137
138
|
force,
|
|
138
139
|
nonInteractive,
|
|
139
140
|
});
|
|
140
141
|
}
|
|
141
|
-
async function initializeWithoutExplicitIDAsync(graphqlClient, actor, projectDir, { force, nonInteractive }) {
|
|
142
|
+
async function initializeWithoutExplicitIDAsync(graphqlClient, actor, projectDir, { force, nonInteractive, accountName: accountNameArgument, }) {
|
|
142
143
|
const exp = await (0, expoConfig_1.getPrivateExpoConfigAsync)(projectDir);
|
|
143
144
|
const existingProjectId = exp.extra?.eas?.projectId;
|
|
144
145
|
if (existingProjectId) {
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
const ownerAccountName = accountNameArgument
|
|
147
|
+
? (await AppQuery_1.AppQuery.byIdAsync(graphqlClient, existingProjectId)).ownerAccount.name
|
|
148
|
+
: undefined;
|
|
149
|
+
if (!accountNameArgument || ownerAccountName === accountNameArgument) {
|
|
150
|
+
log_1.default.succeed(`Project already linked (ID: ${chalk_1.default.bold(existingProjectId)}). To re-configure, remove the "extra.eas.projectId" field from your app config.`);
|
|
151
|
+
return { projectId: existingProjectId, status: 'already-linked' };
|
|
152
|
+
}
|
|
153
|
+
if (!force) {
|
|
154
|
+
throw new Error(`This project is already linked to @${ownerAccountName} (ID: ${existingProjectId}). Pass --force to re-link it to a project owned by ${accountNameArgument}, or remove the "extra.eas.projectId" field from your app config.`);
|
|
155
|
+
}
|
|
156
|
+
// --force with a different --account: fall through to re-link under the new account
|
|
147
157
|
}
|
|
148
158
|
const allAccounts = actor.accounts;
|
|
149
|
-
const accountNamesWhereUserHasSufficientPermissionsToCreateApp =
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
159
|
+
const accountNamesWhereUserHasSufficientPermissionsToCreateApp = (0, accountSelection_1.getAccountNamesWhereUserHasSufficientPermissionsToCreateApp)(actor);
|
|
160
|
+
if (accountNameArgument) {
|
|
161
|
+
// with --force, a conflicting "owner" field is rewritten after linking
|
|
162
|
+
if (exp.owner && exp.owner !== accountNameArgument && !force) {
|
|
163
|
+
throw new Error(`The account specified with --account (${accountNameArgument}) does not match the "owner" field in your app config (${exp.owner}). Provide a matching --account or update the "owner" field.`);
|
|
164
|
+
}
|
|
165
|
+
if (!accountNamesWhereUserHasSufficientPermissionsToCreateApp.has(accountNameArgument)) {
|
|
166
|
+
throw new Error(`You are not able to create projects in the "${accountNameArgument}" account. Accounts you have permissions to create projects in: ${(0, User_1.getCreatableAccountNames)(actor).join(', ')}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// if no --account flag or owner field, ask the user which account they want to use to create/link the project
|
|
170
|
+
let accountName = accountNameArgument ?? exp.owner;
|
|
154
171
|
if (!accountName) {
|
|
155
172
|
if (allAccounts.length === 1) {
|
|
156
173
|
accountName = allAccounts[0].name;
|
|
157
174
|
}
|
|
158
175
|
else if (nonInteractive) {
|
|
159
176
|
if (!force) {
|
|
160
|
-
throw new Error(`
|
|
161
|
-
.map(a => a.name)
|
|
162
|
-
.join(', ')}. Explicitly set the owner property in your app config or run this command with the --force flag to proceed with a default account: ${allAccounts[0].name}.`);
|
|
177
|
+
throw new Error(`You have access to multiple accounts. Choose the account that should own this project with the --account flag:\n\n eas init --account <name> --non-interactive\n\nAccounts you have permissions to create projects in: ${(0, User_1.getCreatableAccountNames)(actor).join(', ')}\n\nAlternatively, set the "owner" field in your app config. (Deprecated: --force without --account will proceed with the default account ${allAccounts[0].name}.)`);
|
|
163
178
|
}
|
|
164
179
|
accountName = allAccounts[0].name;
|
|
165
180
|
log_1.default.log(`Using default account ${accountName} for non-interactive and force mode`);
|
|
166
181
|
}
|
|
167
182
|
else {
|
|
168
|
-
const choices = getAccountChoices(actor, accountNamesWhereUserHasSufficientPermissionsToCreateApp);
|
|
183
|
+
const choices = (0, accountSelection_1.getAccountChoices)(actor, accountNamesWhereUserHasSufficientPermissionsToCreateApp);
|
|
169
184
|
accountName = (await (0, prompts_1.promptAsync)({
|
|
170
185
|
type: 'select',
|
|
171
186
|
name: 'account',
|
|
@@ -180,9 +195,12 @@ async function initializeWithoutExplicitIDAsync(graphqlClient, actor, projectDir
|
|
|
180
195
|
const projectName = (0, projectNameValidation_1.validSlugName)(exp.slug); // This filters out invalid characters
|
|
181
196
|
const projectFullName = `@${accountName}/${projectName}`;
|
|
182
197
|
(0, projectNameValidation_1.validateFullNameAndSlug)(projectFullName, projectName);
|
|
198
|
+
// An explicit --account fully specifies the intended project (@account/slug), so linking or
|
|
199
|
+
// creating it requires no confirmation in non-interactive mode.
|
|
200
|
+
const skipConfirmation = force || (nonInteractive && accountNameArgument !== undefined);
|
|
183
201
|
const existingProjectIdOnServer = await (0, fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync_1.findProjectIdByAccountNameAndSlugNullableAsync)(graphqlClient, accountName, projectName);
|
|
184
202
|
if (existingProjectIdOnServer) {
|
|
185
|
-
if (!
|
|
203
|
+
if (!skipConfirmation) {
|
|
186
204
|
if (nonInteractive) {
|
|
187
205
|
throw new Error(`Existing project found: ${projectFullName} (ID: ${existingProjectIdOnServer}). Use --force flag to continue with this project.`);
|
|
188
206
|
}
|
|
@@ -194,12 +212,12 @@ async function initializeWithoutExplicitIDAsync(graphqlClient, actor, projectDir
|
|
|
194
212
|
}
|
|
195
213
|
}
|
|
196
214
|
await saveProjectIdAndLogSuccessAsync(projectDir, existingProjectIdOnServer);
|
|
197
|
-
return existingProjectIdOnServer;
|
|
215
|
+
return { projectId: existingProjectIdOnServer, status: 'linked' };
|
|
198
216
|
}
|
|
199
217
|
if (!accountNamesWhereUserHasSufficientPermissionsToCreateApp.has(accountName)) {
|
|
200
218
|
throw new Error(`You don't have permission to create a new project on the ${accountName} account and no matching project already exists on the account.`);
|
|
201
219
|
}
|
|
202
|
-
if (!
|
|
220
|
+
if (!skipConfirmation) {
|
|
203
221
|
if (nonInteractive) {
|
|
204
222
|
throw new Error(`Project does not exist: ${projectFullName}. Use --force flag to create this project.`);
|
|
205
223
|
}
|
|
@@ -227,51 +245,5 @@ async function initializeWithoutExplicitIDAsync(graphqlClient, actor, projectDir
|
|
|
227
245
|
throw err;
|
|
228
246
|
}
|
|
229
247
|
await saveProjectIdAndLogSuccessAsync(projectDir, createdProjectId);
|
|
230
|
-
return createdProjectId;
|
|
231
|
-
}
|
|
232
|
-
function getAccountChoices(actor, namesWithSufficientPermissions) {
|
|
233
|
-
const allAccounts = actor.accounts;
|
|
234
|
-
const sortedAccounts = actor.__typename === 'Robot'
|
|
235
|
-
? allAccounts
|
|
236
|
-
: [...allAccounts].sort((a, _b) => actor.__typename === 'User' ? (a.name === actor.username ? -1 : 1) : 0);
|
|
237
|
-
if (actor.__typename !== 'Robot') {
|
|
238
|
-
const personalAccount = allAccounts?.find(account => account?.ownerUserActor?.id === actor.id);
|
|
239
|
-
const personalAccountChoice = personalAccount
|
|
240
|
-
? {
|
|
241
|
-
title: personalAccount.name,
|
|
242
|
-
value: personalAccount,
|
|
243
|
-
description: !namesWithSufficientPermissions.has(personalAccount.name)
|
|
244
|
-
? '(Personal) (Viewer Role)'
|
|
245
|
-
: '(Personal)',
|
|
246
|
-
}
|
|
247
|
-
: undefined;
|
|
248
|
-
const userAccounts = allAccounts
|
|
249
|
-
?.filter(account => account.ownerUserActor && account.name !== actor.username)
|
|
250
|
-
.map(account => ({
|
|
251
|
-
title: account.name,
|
|
252
|
-
value: account,
|
|
253
|
-
description: !namesWithSufficientPermissions.has(account.name)
|
|
254
|
-
? '(Team) (Viewer Role)'
|
|
255
|
-
: '(Team)',
|
|
256
|
-
}));
|
|
257
|
-
const organizationAccounts = allAccounts
|
|
258
|
-
?.filter(account => account.name !== actor.username && !account.ownerUserActor)
|
|
259
|
-
.map(account => ({
|
|
260
|
-
title: account.name,
|
|
261
|
-
value: account,
|
|
262
|
-
description: !namesWithSufficientPermissions.has(account.name)
|
|
263
|
-
? '(Organization) (Viewer Role)'
|
|
264
|
-
: '(Organization)',
|
|
265
|
-
}));
|
|
266
|
-
let choices = [];
|
|
267
|
-
if (personalAccountChoice) {
|
|
268
|
-
choices = [personalAccountChoice];
|
|
269
|
-
}
|
|
270
|
-
return [...choices, ...userAccounts, ...organizationAccounts].sort((a, _b) => actor.__typename === 'User' ? (a.value.name === actor.username ? -1 : 1) : 0);
|
|
271
|
-
}
|
|
272
|
-
return sortedAccounts.map(account => ({
|
|
273
|
-
title: account.name,
|
|
274
|
-
value: account,
|
|
275
|
-
description: !namesWithSufficientPermissions.has(account.name) ? '(Viewer Role)' : undefined,
|
|
276
|
-
}));
|
|
248
|
+
return { projectId: createdProjectId, status: 'created' };
|
|
277
249
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type DeviceRunSessionEvent } from '@expo/eas-build-job';
|
|
2
|
+
export type { DeviceRunSessionEvent };
|
|
3
|
+
export declare function downloadDeviceRunSessionEventsAsync(eventLogUrl: string): Promise<DeviceRunSessionEvent[]>;
|
|
4
|
+
export declare function projectDeviceRunSessionEventsForDisplay(events: DeviceRunSessionEvent[], { includeIncompleteOperations }?: {
|
|
5
|
+
includeIncompleteOperations?: boolean;
|
|
6
|
+
}): DeviceRunSessionEvent[];
|
|
7
|
+
export declare function formatDeviceRunSessionEvent(event: DeviceRunSessionEvent): string;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.downloadDeviceRunSessionEventsAsync = downloadDeviceRunSessionEventsAsync;
|
|
4
|
+
exports.projectDeviceRunSessionEventsForDisplay = projectDeviceRunSessionEventsForDisplay;
|
|
5
|
+
exports.formatDeviceRunSessionEvent = formatDeviceRunSessionEvent;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const util_1 = require("util");
|
|
8
|
+
const eas_build_job_1 = require("@expo/eas-build-job");
|
|
9
|
+
const fetch_1 = tslib_1.__importStar(require("../fetch"));
|
|
10
|
+
const timer_1 = require("../utils/timer");
|
|
11
|
+
async function downloadDeviceRunSessionEventsAsync(eventLogUrl) {
|
|
12
|
+
try {
|
|
13
|
+
const response = await (0, fetch_1.default)(eventLogUrl);
|
|
14
|
+
return (0, eas_build_job_1.parseDeviceRunSessionEvents)(await response.text());
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (error instanceof fetch_1.RequestError && error.response.status === 404) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function projectDeviceRunSessionEventsForDisplay(events, { includeIncompleteOperations = true } = {}) {
|
|
24
|
+
const operations = new Map();
|
|
25
|
+
for (const event of events) {
|
|
26
|
+
if (!event.operationId) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const operationKey = getOperationKey(event);
|
|
30
|
+
const operation = operations.get(operationKey) ?? { interactions: [] };
|
|
31
|
+
if (event.type === 'operation.completed') {
|
|
32
|
+
operation.completed = event;
|
|
33
|
+
}
|
|
34
|
+
else if (event.type === 'interaction.recorded') {
|
|
35
|
+
operation.interactions.push(event);
|
|
36
|
+
}
|
|
37
|
+
operations.set(operationKey, operation);
|
|
38
|
+
}
|
|
39
|
+
return events.flatMap(event => {
|
|
40
|
+
if (!event.operationId) {
|
|
41
|
+
return [event];
|
|
42
|
+
}
|
|
43
|
+
const operation = operations.get(getOperationKey(event));
|
|
44
|
+
const completed = operation?.completed;
|
|
45
|
+
const interactions = operation?.interactions ?? [];
|
|
46
|
+
if (!includeIncompleteOperations &&
|
|
47
|
+
!completed &&
|
|
48
|
+
(event.type === 'operation.started' || event.type === 'interaction.recorded')) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
if (event.type === 'operation.started' && (completed || interactions.length > 0)) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
if (event.type === 'interaction.recorded' && completed?.outcome === 'failure') {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
if (event.type === 'operation.completed' && completed?.outcome !== 'failure') {
|
|
58
|
+
return interactions.length > 0 ? [] : [event];
|
|
59
|
+
}
|
|
60
|
+
if (event.type === 'interaction.recorded' &&
|
|
61
|
+
completed &&
|
|
62
|
+
interactions.at(-1)?.eventId === event.eventId) {
|
|
63
|
+
return [{ ...event, durationMs: completed.durationMs, outcome: completed.outcome }];
|
|
64
|
+
}
|
|
65
|
+
return [event];
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function formatDeviceRunSessionEvent(event) {
|
|
69
|
+
const screenshotFilename = getScreenshotFilename(event);
|
|
70
|
+
const summary = screenshotFilename && !event.summary.includes(screenshotFilename)
|
|
71
|
+
? `${event.summary} ${screenshotFilename}`
|
|
72
|
+
: event.summary;
|
|
73
|
+
const duration = event.durationMs === undefined ? '' : ` (${formatEventDuration(event.durationMs)})`;
|
|
74
|
+
return stripTerminalControlCharacters(`${event.ts} [${event.producer}] ${summary}${duration}`);
|
|
75
|
+
}
|
|
76
|
+
function getOperationKey(event) {
|
|
77
|
+
return JSON.stringify([event.producer, event.operationId]);
|
|
78
|
+
}
|
|
79
|
+
function formatEventDuration(durationMs) {
|
|
80
|
+
return durationMs < 1000 ? `${Math.round(durationMs)}ms` : (0, timer_1.formatMilliseconds)(durationMs);
|
|
81
|
+
}
|
|
82
|
+
function getScreenshotFilename(event) {
|
|
83
|
+
if (event.data?.command !== 'screenshot' || typeof event.data.path !== 'string') {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
return event.data.path.split(/[\\/]/).at(-1);
|
|
87
|
+
}
|
|
88
|
+
function stripTerminalControlCharacters(value) {
|
|
89
|
+
return [...(0, util_1.stripVTControlCharacters)(value)]
|
|
90
|
+
.filter(character => {
|
|
91
|
+
const codePoint = character.codePointAt(0) ?? 0;
|
|
92
|
+
return codePoint >= 0x20 && !(codePoint >= 0x7f && codePoint <= 0x9f);
|
|
93
|
+
})
|
|
94
|
+
.join('');
|
|
95
|
+
}
|
package/build/simulator/utils.js
CHANGED
|
@@ -40,7 +40,7 @@ function formatRemoteSessionInstructions(remoteConfig, configType) {
|
|
|
40
40
|
? [
|
|
41
41
|
'🔑 Run the following to use agent-device with the simulator:',
|
|
42
42
|
'',
|
|
43
|
-
'eas simulator:exec agent-device <command>',
|
|
43
|
+
'eas simulator:exec npx agent-device <command>',
|
|
44
44
|
]
|
|
45
45
|
: [
|
|
46
46
|
'🔑 Run the following in your shell to attach to the agent-device daemon:',
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { App } from '@expo/apple-utils';
|
|
2
|
+
import { ExpoConfig } from '@expo/config';
|
|
3
|
+
import { Analytics } from '../analytics/AnalyticsManager';
|
|
4
|
+
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
|
5
|
+
import { Actor } from '../user/User';
|
|
6
|
+
import { Client } from '../vcs/vcs';
|
|
7
|
+
/** Resolve the App Store Connect app that TestFlight feedback and crashes should be read from. */
|
|
8
|
+
export declare function resolveTestFlightAppAsync({ actor, analytics, exp, graphqlClient, nonInteractive, profileName, projectDir, projectId, vcsClient, }: {
|
|
9
|
+
actor: Actor;
|
|
10
|
+
analytics: Analytics;
|
|
11
|
+
exp: ExpoConfig;
|
|
12
|
+
graphqlClient: ExpoGraphqlClient;
|
|
13
|
+
nonInteractive: boolean;
|
|
14
|
+
profileName?: string;
|
|
15
|
+
projectDir: string;
|
|
16
|
+
projectId: string;
|
|
17
|
+
vcsClient: Client;
|
|
18
|
+
}): Promise<App>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveTestFlightAppAsync = resolveTestFlightAppAsync;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const apple_utils_1 = require("@expo/apple-utils");
|
|
6
|
+
const eas_build_job_1 = require("@expo/eas-build-job");
|
|
7
|
+
const eas_json_1 = require("@expo/eas-json");
|
|
8
|
+
const errors_1 = require("@expo/eas-json/build/errors");
|
|
9
|
+
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
10
|
+
const context_1 = require("../credentials/context");
|
|
11
|
+
const AppStoreConnectApiKeyQuery_1 = require("../credentials/ios/api/graphql/queries/AppStoreConnectApiKeyQuery");
|
|
12
|
+
const authenticate_1 = require("../credentials/ios/appstore/authenticate");
|
|
13
|
+
const AppStoreConnectApiKeyQuery_2 = require("../graphql/queries/AppStoreConnectApiKeyQuery");
|
|
14
|
+
const log_1 = tslib_1.__importDefault(require("../log"));
|
|
15
|
+
const auth_1 = require("../metadata/auth");
|
|
16
|
+
const bundleIdentifier_1 = require("../project/ios/bundleIdentifier");
|
|
17
|
+
const projectUtils_1 = require("../project/projectUtils");
|
|
18
|
+
/** How long the ASC JWTs we mint stay valid, matching the credentials service default. */
|
|
19
|
+
const ASC_TOKEN_DURATION_SECONDS = 1200;
|
|
20
|
+
/**
|
|
21
|
+
* TestFlight data lives in App Store Connect, so we resolve the bundle identifier and the ASC API
|
|
22
|
+
* key from the submit profile the same way `eas metadata` does. When the project has no eas.json
|
|
23
|
+
* we fall back to an empty profile, which resolves the bundle identifier from the app config and
|
|
24
|
+
* the API key from env vars or the EAS credentials service.
|
|
25
|
+
*/
|
|
26
|
+
async function resolveSubmitProfileAsync({ projectDir, profileName, }) {
|
|
27
|
+
try {
|
|
28
|
+
return await eas_json_1.EasJsonUtils.getSubmitProfileAsync(eas_json_1.EasJsonAccessor.fromProjectPath(projectDir), eas_build_job_1.Platform.IOS, profileName);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (error instanceof errors_1.MissingEasJsonError && !profileName) {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Look for the app in every ASC API key registered on the account that owns the project. This is
|
|
39
|
+
* the resolution the Expo MCP server uses for its TestFlight tools, and it covers projects that
|
|
40
|
+
* have no ASC API key assigned to their iOS submission credentials.
|
|
41
|
+
*/
|
|
42
|
+
async function findAppWithAccountAscApiKeysAsync({ bundleId, graphqlClient, projectId, }) {
|
|
43
|
+
const account = await (0, projectUtils_1.getOwnerAccountForProjectIdAsync)(graphqlClient, projectId);
|
|
44
|
+
const keys = await AppStoreConnectApiKeyQuery_1.AppStoreConnectApiKeyQuery.getAllForAccountAsync(graphqlClient, account.name);
|
|
45
|
+
for (const key of keys) {
|
|
46
|
+
try {
|
|
47
|
+
const { keyP8, keyIdentifier, issuerIdentifier } = await AppStoreConnectApiKeyQuery_2.AppStoreConnectApiKeyQuery.getByIdAsync(graphqlClient, key.id);
|
|
48
|
+
const context = {
|
|
49
|
+
token: new apple_utils_1.Token({
|
|
50
|
+
key: keyP8,
|
|
51
|
+
keyId: keyIdentifier,
|
|
52
|
+
issuerId: issuerIdentifier,
|
|
53
|
+
duration: ASC_TOKEN_DURATION_SECONDS,
|
|
54
|
+
}),
|
|
55
|
+
};
|
|
56
|
+
const app = await apple_utils_1.App.findAsync(context, { bundleId });
|
|
57
|
+
if (app) {
|
|
58
|
+
log_1.default.log(`Using App Store Connect API Key ${key.name ?? key.keyIdentifier} from your Expo account.`);
|
|
59
|
+
return app;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
// Never read `.message` off an unknown rejection: a non-Error value (a string, or
|
|
64
|
+
// null from a wrapped fetch) would make this handler throw a TypeError, hiding the
|
|
65
|
+
// real failure and aborting the loop instead of falling through to the next key.
|
|
66
|
+
log_1.default.debug(`ASC API Key ${key.keyIdentifier} cannot access ${bundleId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
/** Resolve the App Store Connect app that TestFlight feedback and crashes should be read from. */
|
|
72
|
+
async function resolveTestFlightAppAsync({ actor, analytics, exp, graphqlClient, nonInteractive, profileName, projectDir, projectId, vcsClient, }) {
|
|
73
|
+
const profile = await resolveSubmitProfileAsync({ projectDir, profileName });
|
|
74
|
+
const createCredentialsContext = (contextNonInteractive) => new context_1.CredentialsContext({
|
|
75
|
+
projectInfo: { exp, projectId },
|
|
76
|
+
projectDir,
|
|
77
|
+
user: actor,
|
|
78
|
+
graphqlClient,
|
|
79
|
+
analytics,
|
|
80
|
+
nonInteractive: contextNonInteractive,
|
|
81
|
+
vcsClient,
|
|
82
|
+
});
|
|
83
|
+
// Prefer the key configured for this project: ASC env vars, the submit profile, or the key
|
|
84
|
+
// assigned to its iOS submission credentials. Forced non-interactive so that a project without
|
|
85
|
+
// any of those falls through to the account-wide lookup instead of prompting for an Apple login.
|
|
86
|
+
try {
|
|
87
|
+
const { app } = await (0, auth_1.getAppStoreAuthAsync)({
|
|
88
|
+
exp,
|
|
89
|
+
credentialsCtx: createCredentialsContext(true),
|
|
90
|
+
graphqlClient,
|
|
91
|
+
nonInteractive: true,
|
|
92
|
+
profile,
|
|
93
|
+
projectDir,
|
|
94
|
+
projectId,
|
|
95
|
+
});
|
|
96
|
+
return app;
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
log_1.default.debug(`Could not resolve an App Store Connect API Key for this project: ${error instanceof Error ? error.message : String(error)}`);
|
|
100
|
+
}
|
|
101
|
+
const bundleId = ('bundleIdentifier' in profile ? profile.bundleIdentifier : undefined) ??
|
|
102
|
+
(await (0, bundleIdentifier_1.getBundleIdentifierAsync)(projectDir, exp, vcsClient));
|
|
103
|
+
const appFromAccountKeys = await findAppWithAccountAscApiKeysAsync({
|
|
104
|
+
bundleId,
|
|
105
|
+
graphqlClient,
|
|
106
|
+
projectId,
|
|
107
|
+
});
|
|
108
|
+
if (appFromAccountKeys) {
|
|
109
|
+
return appFromAccountKeys;
|
|
110
|
+
}
|
|
111
|
+
if (nonInteractive) {
|
|
112
|
+
throw new Error(`Could not find "${bundleId}" in App Store Connect with any App Store Connect API Key available to this project.\n` +
|
|
113
|
+
'Provide a key with access to the app via:\n' +
|
|
114
|
+
' - Environment variables: EXPO_ASC_API_KEY_PATH, EXPO_ASC_KEY_ID, EXPO_ASC_ISSUER_ID\n' +
|
|
115
|
+
' - eas.json submit profile: ascApiKeyPath, ascApiKeyId, ascApiKeyIssuerId\n' +
|
|
116
|
+
' - EAS credentials service: run `eas credentials` to set up an API key');
|
|
117
|
+
}
|
|
118
|
+
// Last resort: an interactive Apple ID login.
|
|
119
|
+
const credentialsCtx = createCredentialsContext(false);
|
|
120
|
+
const authCtx = await credentialsCtx.appStore.ensureUserAuthenticatedAsync();
|
|
121
|
+
const app = await apple_utils_1.App.findAsync((0, authenticate_1.getRequestContext)(authCtx), { bundleId });
|
|
122
|
+
(0, assert_1.default)(app, `Failed to load app "${bundleId}" from App Store Connect`);
|
|
123
|
+
return app;
|
|
124
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { App } from '@expo/apple-utils';
|
|
2
|
+
/** Which kind of TestFlight beta feedback a submission is. Matches the workflow trigger context. */
|
|
3
|
+
export type BetaFeedbackType = 'crash' | 'screenshot';
|
|
4
|
+
/** Screenshot attached to a piece of TestFlight feedback. Its URL expires after a short while. */
|
|
5
|
+
export type TestFlightScreenshot = {
|
|
6
|
+
url: string;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
expirationDate: string;
|
|
10
|
+
};
|
|
11
|
+
/** Fields shared by TestFlight screenshot feedback and TestFlight crash submissions. */
|
|
12
|
+
export type TestFlightSubmission = {
|
|
13
|
+
id: string;
|
|
14
|
+
createdDate: string;
|
|
15
|
+
comment: string | null;
|
|
16
|
+
deviceModel: string;
|
|
17
|
+
osVersion: string;
|
|
18
|
+
locale: string | null;
|
|
19
|
+
timeZone: string | null;
|
|
20
|
+
architecture: string | null;
|
|
21
|
+
connectionType: string | null;
|
|
22
|
+
deviceFamily: string | null;
|
|
23
|
+
appUptimeInMilliseconds: number | null;
|
|
24
|
+
batteryPercentage: number | null;
|
|
25
|
+
diskBytesAvailable: number | null;
|
|
26
|
+
diskBytesTotal: number | null;
|
|
27
|
+
buildVersion: string | null;
|
|
28
|
+
testerName: string | null;
|
|
29
|
+
testerEmail: string | null;
|
|
30
|
+
};
|
|
31
|
+
export type TestFlightFeedback = TestFlightSubmission & {
|
|
32
|
+
screenshots: TestFlightScreenshot[];
|
|
33
|
+
};
|
|
34
|
+
export type TestFlightCrash = TestFlightSubmission;
|
|
35
|
+
/**
|
|
36
|
+
* A paginated view over one App Store Connect collection. App Store Connect has no offset-based
|
|
37
|
+
* paging and apple-utils always walks every page, so the underlying fetch happens once and pages
|
|
38
|
+
* are served from that result — which also makes the total count available for free.
|
|
39
|
+
*/
|
|
40
|
+
export type TestFlightQuery<T> = {
|
|
41
|
+
queryAsync(limit: number, offset: number): Promise<T[]>;
|
|
42
|
+
getTotalAsync(): Promise<number>;
|
|
43
|
+
};
|
|
44
|
+
/** Screenshot feedback that TestFlight testers submitted for the app, newest first. */
|
|
45
|
+
export declare function getTestFlightFeedbackQuery(app: App): TestFlightQuery<TestFlightFeedback>;
|
|
46
|
+
/** Crashes that TestFlight testers reported for the app, newest first. */
|
|
47
|
+
export declare function getTestFlightCrashesQuery(app: App): TestFlightQuery<TestFlightCrash>;
|
|
48
|
+
/** Fetch a single screenshot feedback submission by ID. */
|
|
49
|
+
export declare function fetchTestFlightFeedbackAsync(app: App, feedbackId: string): Promise<TestFlightFeedback>;
|
|
50
|
+
export type TestFlightCrashDetails = {
|
|
51
|
+
crash: TestFlightCrash;
|
|
52
|
+
/** The crash log, or `null` when App Store Connect has none for this submission. */
|
|
53
|
+
logText: string | null;
|
|
54
|
+
};
|
|
55
|
+
/** Fetch a single crash submission together with its full crash log. */
|
|
56
|
+
export declare function fetchTestFlightCrashAsync(app: App, crashId: string): Promise<TestFlightCrashDetails>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTestFlightFeedbackQuery = getTestFlightFeedbackQuery;
|
|
4
|
+
exports.getTestFlightCrashesQuery = getTestFlightCrashesQuery;
|
|
5
|
+
exports.fetchTestFlightFeedbackAsync = fetchTestFlightFeedbackAsync;
|
|
6
|
+
exports.fetchTestFlightCrashAsync = fetchTestFlightCrashAsync;
|
|
7
|
+
const apple_utils_1 = require("@expo/apple-utils");
|
|
8
|
+
/**
|
|
9
|
+
* The largest page size the App Store Connect API accepts. The apple-utils helpers always walk
|
|
10
|
+
* every page, so we ask for the largest pages possible and paginate client-side from there.
|
|
11
|
+
*/
|
|
12
|
+
const MAX_PAGE_SIZE = 200;
|
|
13
|
+
function createQuery(fetchAllAsync) {
|
|
14
|
+
let all;
|
|
15
|
+
const allAsync = async () => {
|
|
16
|
+
all ??= fetchAllAsync();
|
|
17
|
+
return await all;
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
async queryAsync(limit, offset) {
|
|
21
|
+
return (await allAsync()).slice(offset, offset + limit);
|
|
22
|
+
},
|
|
23
|
+
async getTotalAsync() {
|
|
24
|
+
return (await allAsync()).length;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Everything here is attacker-influenced text: any TestFlight tester can put arbitrary bytes in a
|
|
30
|
+
* feedback comment or their own name, and crash logs carry thread and symbol names from the build.
|
|
31
|
+
* Terminal escape sequences in that text could clear the screen or spoof output when it is printed,
|
|
32
|
+
* so strip control characters at the boundary — before the data reaches either the formatters or
|
|
33
|
+
* `--json`. Newlines and tabs survive because multi-line comments and crash logs need them.
|
|
34
|
+
*/
|
|
35
|
+
const CONTROL_CHARACTERS = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/g;
|
|
36
|
+
function sanitizeText(value) {
|
|
37
|
+
return value.replace(/\r\n?/g, '\n').replace(CONTROL_CHARACTERS, '');
|
|
38
|
+
}
|
|
39
|
+
function sanitizeOptionalText(value) {
|
|
40
|
+
return typeof value === 'string' ? sanitizeText(value) : null;
|
|
41
|
+
}
|
|
42
|
+
function formatTesterName(tester) {
|
|
43
|
+
const parts = [tester?.attributes?.firstName, tester?.attributes?.lastName].filter((part) => !!part);
|
|
44
|
+
return parts.length > 0 ? sanitizeText(parts.join(' ')) : null;
|
|
45
|
+
}
|
|
46
|
+
function normalizeSubmission(submission) {
|
|
47
|
+
const attributes = submission.attributes;
|
|
48
|
+
return {
|
|
49
|
+
id: submission.id,
|
|
50
|
+
createdDate: attributes.createdDate,
|
|
51
|
+
comment: sanitizeOptionalText(attributes.comment),
|
|
52
|
+
deviceModel: sanitizeText(attributes.deviceModel ?? ''),
|
|
53
|
+
osVersion: sanitizeText(attributes.osVersion ?? ''),
|
|
54
|
+
locale: sanitizeOptionalText(attributes.locale),
|
|
55
|
+
timeZone: sanitizeOptionalText(attributes.timeZone),
|
|
56
|
+
architecture: sanitizeOptionalText(attributes.architecture),
|
|
57
|
+
connectionType: sanitizeOptionalText(attributes.connectionType),
|
|
58
|
+
deviceFamily: sanitizeOptionalText(attributes.deviceFamily),
|
|
59
|
+
appUptimeInMilliseconds: attributes.appUptimeInMilliseconds ?? null,
|
|
60
|
+
batteryPercentage: attributes.batteryPercentage ?? null,
|
|
61
|
+
diskBytesAvailable: attributes.diskBytesAvailable ?? null,
|
|
62
|
+
diskBytesTotal: attributes.diskBytesTotal ?? null,
|
|
63
|
+
buildVersion: sanitizeOptionalText(attributes.build?.attributes?.version),
|
|
64
|
+
testerName: formatTesterName(attributes.tester),
|
|
65
|
+
// The tester relationship hides the email of testers who joined through a public link, in
|
|
66
|
+
// which case the submission itself still carries the address they submitted feedback with.
|
|
67
|
+
testerEmail: sanitizeOptionalText(attributes.tester?.attributes?.email ?? attributes.email),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function normalizeFeedback(submission) {
|
|
71
|
+
return {
|
|
72
|
+
...normalizeSubmission(submission),
|
|
73
|
+
screenshots: (submission.attributes.screenshots ?? []).map(screenshot => ({
|
|
74
|
+
url: sanitizeText(screenshot.url ?? ''),
|
|
75
|
+
width: screenshot.width,
|
|
76
|
+
height: screenshot.height,
|
|
77
|
+
expirationDate: screenshot.expirationDate,
|
|
78
|
+
})),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** Screenshot feedback that TestFlight testers submitted for the app, newest first. */
|
|
82
|
+
function getTestFlightFeedbackQuery(app) {
|
|
83
|
+
return createQuery(async () => {
|
|
84
|
+
const submissions = await app.getBetaFeedbackScreenshotSubmissionsAsync({
|
|
85
|
+
query: { limit: MAX_PAGE_SIZE },
|
|
86
|
+
});
|
|
87
|
+
return submissions.map(normalizeFeedback);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/** Crashes that TestFlight testers reported for the app, newest first. */
|
|
91
|
+
function getTestFlightCrashesQuery(app) {
|
|
92
|
+
return createQuery(async () => {
|
|
93
|
+
const submissions = await app.getBetaFeedbackCrashSubmissionsAsync({
|
|
94
|
+
query: { limit: MAX_PAGE_SIZE },
|
|
95
|
+
});
|
|
96
|
+
return submissions.map(normalizeSubmission);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/** Fetch a single screenshot feedback submission by ID. */
|
|
100
|
+
async function fetchTestFlightFeedbackAsync(app, feedbackId) {
|
|
101
|
+
const submission = await apple_utils_1.BetaFeedbackScreenshotSubmission.infoAsync(app.context, {
|
|
102
|
+
id: feedbackId,
|
|
103
|
+
});
|
|
104
|
+
return normalizeFeedback(submission);
|
|
105
|
+
}
|
|
106
|
+
/** Fetch a single crash submission together with its full crash log. */
|
|
107
|
+
async function fetchTestFlightCrashAsync(app, crashId) {
|
|
108
|
+
const submission = await apple_utils_1.BetaFeedbackCrashSubmission.infoAsync(app.context, { id: crashId });
|
|
109
|
+
const crashLog = await apple_utils_1.BetaCrashLog.getCrashLogAsync(app.context, {
|
|
110
|
+
betaFeedbackCrashSubmissionId: crashId,
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
crash: normalizeSubmission(submission),
|
|
114
|
+
logText: sanitizeOptionalText(crashLog.attributes.logText),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TestFlightCrash, TestFlightFeedback } from './fetch';
|
|
2
|
+
export declare function formatTestFlightFeedback(feedback: TestFlightFeedback, position?: number): string;
|
|
3
|
+
export declare function formatTestFlightCrash(crash: TestFlightCrash, position?: number): string;
|
|
4
|
+
export declare function formatTestFlightCrashDetails(crash: TestFlightCrash, logText: string | null): string;
|