eas-cli 25.2.0 → 26.0.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 +234 -216
- package/build/analytics/AnalyticsManager.d.ts +1 -0
- package/build/analytics/AnalyticsManager.js +1 -0
- package/build/billing/resolveAccount.d.ts +12 -0
- package/build/billing/resolveAccount.js +1 -0
- package/build/build/build.d.ts +2 -1
- package/build/build/build.js +12 -11
- package/build/build/context.d.ts +2 -0
- package/build/build/createContext.d.ts +6 -3
- package/build/build/createContext.js +2 -4
- package/build/build/freeTierLimitCheckout.d.ts +39 -0
- package/build/build/freeTierLimitCheckout.js +106 -0
- package/build/build/runBuildAndSubmit.d.ts +11 -3
- package/build/build/runBuildAndSubmit.js +11 -8
- package/build/build/utils/url.d.ts +1 -0
- package/build/build/utils/url.js +4 -0
- package/build/commandUtils/EasCommand.js +3 -1
- package/build/commandUtils/context/DynamicProjectConfigContextField.d.ts +2 -2
- package/build/commandUtils/context/DynamicProjectConfigContextField.js +40 -61
- package/build/commandUtils/context/LoggedInContextField.js +1 -2
- package/build/commandUtils/context/MaybeLoggedInContextField.js +1 -2
- package/build/commandUtils/context/OptionalPrivateProjectConfigContextField.js +3 -1
- package/build/commandUtils/context/PrivateProjectConfigContextField.js +3 -1
- package/build/commandUtils/context/contextUtils/getProjectIdAsync.d.ts +1 -0
- package/build/commandUtils/context/contextUtils/getProjectIdAsync.js +5 -2
- package/build/commandUtils/errors.d.ts +5 -1
- package/build/commandUtils/errors.js +4 -3
- package/build/commands/browse.js +1 -1
- package/build/commands/build/dev.js +3 -3
- package/build/commands/build/index.js +2 -1
- package/build/commands/channel/delete.js +1 -1
- package/build/commands/channel/rollout.js +1 -1
- package/build/commands/credentials/configure-build.js +1 -1
- package/build/commands/deploy/alias/delete.js +1 -1
- package/build/commands/deploy/alias/index.js +1 -1
- package/build/commands/deploy/delete.js +1 -1
- package/build/commands/go.js +1 -1
- package/build/commands/observe/event.js +1 -1
- package/build/commands/observe/events.js +1 -1
- package/build/commands/project/new.js +1 -1
- package/build/commands/simulator/control.js +1 -1
- package/build/commands/simulator/get.js +14 -1
- package/build/commands/simulator/index.d.ts +1 -0
- package/build/commands/simulator/index.js +30 -8
- package/build/commands/workflow/cancel.js +1 -1
- package/build/commands/workflow/list.js +1 -1
- package/build/commands/workflow/logs.js +1 -1
- package/build/commands/workflow/run.js +1 -1
- package/build/commands/workflow/status.js +1 -1
- package/build/commands/workflow/view.js +1 -1
- package/build/graphql/generated.d.ts +146 -112
- package/build/graphql/generated.js +18 -8
- package/build/graphql/queries/DeviceRunSessionQuery.d.ts +8 -1
- package/build/graphql/queries/DeviceRunSessionQuery.js +67 -0
- package/build/simulator/jobRunErrors.d.ts +22 -0
- package/build/simulator/jobRunErrors.js +134 -0
- package/build/user/SessionManager.d.ts +10 -0
- package/build/user/SessionManager.js +12 -0
- package/oclif.manifest.json +275 -268
- package/package.json +7 -7
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
|
2
|
-
import { DeviceRunSessionByIdQuery, DeviceRunSessionEventsByIdQuery, DeviceRunSessionFilterInput, DeviceRunSessionsByAppIdQuery } from '../generated';
|
|
2
|
+
import { DeviceRunSessionByIdQuery, DeviceRunSessionEventsByIdQuery, DeviceRunSessionFilterInput, DeviceRunSessionJobRunErrorsByIdQuery, DeviceRunSessionsByAppIdQuery } from '../generated';
|
|
3
3
|
export declare const DeviceRunSessionQuery: {
|
|
4
4
|
eventsByIdAsync(graphqlClient: ExpoGraphqlClient, deviceRunSessionId: string): Promise<DeviceRunSessionEventsByIdQuery["deviceRunSessions"]["byId"]>;
|
|
5
|
+
/**
|
|
6
|
+
* Best-effort lookup of why the session's job run failed. It doesn't retry or print errors, and it
|
|
7
|
+
* rejects with `signal.reason` and cancels the request when `signal` aborts.
|
|
8
|
+
*/
|
|
9
|
+
jobRunErrorsByIdAsync(graphqlClient: ExpoGraphqlClient, deviceRunSessionId: string, { signal }: {
|
|
10
|
+
signal: AbortSignal;
|
|
11
|
+
}): Promise<DeviceRunSessionJobRunErrorsByIdQuery["deviceRunSessions"]["byId"]["turtleJobRun"]>;
|
|
5
12
|
byIdAsync(graphqlClient: ExpoGraphqlClient, deviceRunSessionId: string): Promise<DeviceRunSessionByIdQuery["deviceRunSessions"]["byId"]>;
|
|
6
13
|
listByAppIdAsync(graphqlClient: ExpoGraphqlClient, { appId, first, after, filter, }: {
|
|
7
14
|
appId: string;
|
|
@@ -25,6 +25,39 @@ exports.DeviceRunSessionQuery = {
|
|
|
25
25
|
.toPromise());
|
|
26
26
|
return data.deviceRunSessions.byId;
|
|
27
27
|
},
|
|
28
|
+
/**
|
|
29
|
+
* Best-effort lookup of why the session's job run failed. It doesn't retry or print errors, and it
|
|
30
|
+
* rejects with `signal.reason` and cancels the request when `signal` aborts.
|
|
31
|
+
*/
|
|
32
|
+
async jobRunErrorsByIdAsync(graphqlClient, deviceRunSessionId, { signal }) {
|
|
33
|
+
const { data, error } = await firstResultUntilAbortedAsync(graphqlClient.query((0, graphql_tag_1.default) `
|
|
34
|
+
query DeviceRunSessionJobRunErrorsByIdQuery($deviceRunSessionId: ID!) {
|
|
35
|
+
deviceRunSessions {
|
|
36
|
+
byId(deviceRunSessionId: $deviceRunSessionId) {
|
|
37
|
+
id
|
|
38
|
+
turtleJobRun {
|
|
39
|
+
id
|
|
40
|
+
errors {
|
|
41
|
+
errorCode
|
|
42
|
+
message
|
|
43
|
+
docsUrl
|
|
44
|
+
}
|
|
45
|
+
logFileUrls
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`, { deviceRunSessionId },
|
|
51
|
+
// Retries would keep a timer alive after the caller gives up.
|
|
52
|
+
{ requestPolicy: 'network-only', noRetry: true }), signal);
|
|
53
|
+
if (error) {
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
if (!data) {
|
|
57
|
+
throw new Error('Returned query result data is null!');
|
|
58
|
+
}
|
|
59
|
+
return data.deviceRunSessions.byId.turtleJobRun;
|
|
60
|
+
},
|
|
28
61
|
async byIdAsync(graphqlClient, deviceRunSessionId) {
|
|
29
62
|
const data = await (0, client_1.withErrorHandlingAsync)(graphqlClient
|
|
30
63
|
.query((0, graphql_tag_1.default) `
|
|
@@ -179,3 +212,37 @@ exports.DeviceRunSessionQuery = {
|
|
|
179
212
|
return data.app.byId.deviceRunSessionsPaginated;
|
|
180
213
|
},
|
|
181
214
|
};
|
|
215
|
+
// Like `toPromise()`, but unsubscribing on abort makes urql cancel the request.
|
|
216
|
+
async function firstResultUntilAbortedAsync(source, signal) {
|
|
217
|
+
signal.throwIfAborted();
|
|
218
|
+
return await new Promise((resolve, reject) => {
|
|
219
|
+
let subscription;
|
|
220
|
+
let settled = false;
|
|
221
|
+
const settle = (finish) => {
|
|
222
|
+
if (settled) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
settled = true;
|
|
226
|
+
signal.removeEventListener('abort', onAbort);
|
|
227
|
+
subscription?.unsubscribe();
|
|
228
|
+
finish();
|
|
229
|
+
};
|
|
230
|
+
const onAbort = () => {
|
|
231
|
+
settle(() => {
|
|
232
|
+
reject(signal.reason);
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
236
|
+
subscription = source.subscribe(result => {
|
|
237
|
+
if (!result.stale && !result.hasNext) {
|
|
238
|
+
settle(() => {
|
|
239
|
+
resolve(result);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
// The result can arrive synchronously, before `subscription` is assigned.
|
|
244
|
+
if (settled) {
|
|
245
|
+
subscription.unsubscribe();
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
|
2
|
+
import { RawLogLine } from '../commandUtils/logs/types';
|
|
3
|
+
export type SimulatorSessionError = {
|
|
4
|
+
errorCode: string;
|
|
5
|
+
message: string;
|
|
6
|
+
docsUrl?: string | null;
|
|
7
|
+
};
|
|
8
|
+
export type FetchSimulatorSessionErrorsOptions = {
|
|
9
|
+
/** Aborts the lookup, e.g. on Ctrl+C. */
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
queryTimeoutMs?: number;
|
|
12
|
+
logDownloadTimeoutMs?: number;
|
|
13
|
+
maxLogSizeBytes?: number;
|
|
14
|
+
};
|
|
15
|
+
type JobRunLogLine = RawLogLine & {
|
|
16
|
+
level?: number;
|
|
17
|
+
source?: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function fetchSimulatorSessionErrorsAsync(graphqlClient: ExpoGraphqlClient, deviceRunSessionId: string, { signal, queryTimeoutMs, logDownloadTimeoutMs, maxLogSizeBytes, }?: FetchSimulatorSessionErrorsOptions): Promise<SimulatorSessionError[]>;
|
|
20
|
+
export declare function formatSimulatorSessionError(error: SimulatorSessionError): string;
|
|
21
|
+
export declare function selectFailedStepErrors(logLines: JobRunLogLine[]): string[];
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchSimulatorSessionErrorsAsync = fetchSimulatorSessionErrorsAsync;
|
|
4
|
+
exports.formatSimulatorSessionError = formatSimulatorSessionError;
|
|
5
|
+
exports.selectFailedStepErrors = selectFailedStepErrors;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const util_1 = require("util");
|
|
8
|
+
const parseLogs_1 = require("../commandUtils/logs/parseLogs");
|
|
9
|
+
const fetch_1 = tslib_1.__importDefault(require("../fetch"));
|
|
10
|
+
const DeviceRunSessionQuery_1 = require("../graphql/queries/DeviceRunSessionQuery");
|
|
11
|
+
const log_1 = tslib_1.__importStar(require("../log"));
|
|
12
|
+
const terminalText_1 = require("../utils/terminalText");
|
|
13
|
+
// ErrorCode.UNKNOWN_ERROR and ErrorCode.UNKNOWN_CUSTOM_BUILD_ERROR from @expo/eas-build-job.
|
|
14
|
+
const UNKNOWN_ERROR_CODES = new Set(['UNKNOWN_ERROR', 'UNKNOWN_CUSTOM_BUILD_ERROR']);
|
|
15
|
+
const DEFAULT_QUERY_TIMEOUT_MS = 10_000;
|
|
16
|
+
const DEFAULT_LOG_DOWNLOAD_TIMEOUT_MS = 10_000;
|
|
17
|
+
const DEFAULT_MAX_LOG_SIZE_BYTES = 20 * 1024 * 1024;
|
|
18
|
+
const MAX_LOGGED_ERRORS = 4;
|
|
19
|
+
const MAX_LOGGED_ERROR_LENGTH = 500;
|
|
20
|
+
// Bunyan's "error" level.
|
|
21
|
+
const ERROR_LOG_LEVEL = 50;
|
|
22
|
+
const STDERR_CAUSE_PATTERN = /\b(error|exception|fatal)\b/i;
|
|
23
|
+
// Returns why the session's job run failed, or an empty list when that is not available.
|
|
24
|
+
async function fetchSimulatorSessionErrorsAsync(graphqlClient, deviceRunSessionId, { signal, queryTimeoutMs = DEFAULT_QUERY_TIMEOUT_MS, logDownloadTimeoutMs = DEFAULT_LOG_DOWNLOAD_TIMEOUT_MS, maxLogSizeBytes = DEFAULT_MAX_LOG_SIZE_BYTES, } = {}) {
|
|
25
|
+
if (signal?.aborted) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
let jobRun;
|
|
29
|
+
try {
|
|
30
|
+
jobRun = await DeviceRunSessionQuery_1.DeviceRunSessionQuery.jobRunErrorsByIdAsync(graphqlClient, deviceRunSessionId, {
|
|
31
|
+
signal: withTimeout(signal, queryTimeoutMs),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
log_1.default.debug(`Failed to fetch simulator session errors: ${err}`);
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const errors = jobRun?.errors ?? [];
|
|
39
|
+
// Uncategorized failures only say "Unknown error. See logs", so read the real cause from the job run logs.
|
|
40
|
+
const logFileUrl = jobRun?.logFileUrls[0];
|
|
41
|
+
if (logFileUrl &&
|
|
42
|
+
errors.length > 0 &&
|
|
43
|
+
errors.every(error => UNKNOWN_ERROR_CODES.has(error.errorCode))) {
|
|
44
|
+
const logErrors = await fetchJobRunLogErrorsAsync(logFileUrl, {
|
|
45
|
+
signal: withTimeout(signal, logDownloadTimeoutMs),
|
|
46
|
+
maxLogSizeBytes,
|
|
47
|
+
});
|
|
48
|
+
if (logErrors.length > 0) {
|
|
49
|
+
return logErrors.map(message => ({ errorCode: errors[0].errorCode, message, docsUrl: null }));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return errors.map(({ errorCode, message, docsUrl }) => ({
|
|
53
|
+
errorCode,
|
|
54
|
+
message: formatMessage(message),
|
|
55
|
+
docsUrl,
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
function formatSimulatorSessionError(error) {
|
|
59
|
+
return `${error.message}${error.docsUrl ? ` ${(0, log_1.learnMore)(error.docsUrl)}` : ''}`;
|
|
60
|
+
}
|
|
61
|
+
function withTimeout(signal, timeoutMs) {
|
|
62
|
+
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
63
|
+
return signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
|
|
64
|
+
}
|
|
65
|
+
async function fetchJobRunLogErrorsAsync(logFileUrl, { signal, maxLogSizeBytes }) {
|
|
66
|
+
// node-fetch stops reading on its own only when the body ends, so abort to close the connection
|
|
67
|
+
// after an error, an oversized body or a timeout.
|
|
68
|
+
const controller = new AbortController();
|
|
69
|
+
try {
|
|
70
|
+
const response = await (0, fetch_1.default)(logFileUrl, {
|
|
71
|
+
size: maxLogSizeBytes,
|
|
72
|
+
signal: AbortSignal.any([signal, controller.signal]),
|
|
73
|
+
});
|
|
74
|
+
const { logLines } = (0, parseLogs_1.parseLogLines)(await response.text());
|
|
75
|
+
return selectFailedStepErrors(logLines);
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
// node-fetch's error messages include the signed log URL, so leave the message out.
|
|
79
|
+
log_1.default.debug(`Failed to read simulator session logs: ${err instanceof Error ? err.name : 'unknown error'}`);
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
controller.abort();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Describes the steps that failed, the first one first: its last error line, preceded by the stderr
|
|
87
|
+
// line that names the cause and the line after it. Later failed steps only add their error line.
|
|
88
|
+
// Uses the log message rather than err.message because only the message has secrets masked.
|
|
89
|
+
function selectFailedStepErrors(logLines) {
|
|
90
|
+
const failedStepIds = [
|
|
91
|
+
...new Set(logLines
|
|
92
|
+
.filter(line => line.marker === 'end-step' && line.result === 'fail' && line.buildStepId)
|
|
93
|
+
.map(line => line.buildStepId)),
|
|
94
|
+
];
|
|
95
|
+
const messages = failedStepIds.flatMap((stepId, index) => {
|
|
96
|
+
const lines = selectStepFailureLines(logLines.filter(line => line.buildStepId === stepId));
|
|
97
|
+
return (index === 0 ? lines : lines.slice(-1)).map(formatLogLine);
|
|
98
|
+
});
|
|
99
|
+
return [...new Set(messages)].slice(0, MAX_LOGGED_ERRORS);
|
|
100
|
+
}
|
|
101
|
+
function selectStepFailureLines(stepLines) {
|
|
102
|
+
let selected = [];
|
|
103
|
+
let stderrCause = [];
|
|
104
|
+
for (const [index, line] of stepLines.entries()) {
|
|
105
|
+
const text = toPlainText(line.msg ?? '');
|
|
106
|
+
if (line.source === 'stderr') {
|
|
107
|
+
if (STDERR_CAUSE_PATTERN.test(text)) {
|
|
108
|
+
stderrCause = [line];
|
|
109
|
+
}
|
|
110
|
+
else if (stderrCause.length === 1 && stepLines[index - 1] === stderrCause[0]) {
|
|
111
|
+
stderrCause.push(line);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (line.err && (line.level ?? 0) >= ERROR_LOG_LEVEL && text) {
|
|
115
|
+
selected = [...stderrCause, line];
|
|
116
|
+
stderrCause = [];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return selected;
|
|
120
|
+
}
|
|
121
|
+
function formatLogLine(line) {
|
|
122
|
+
return formatMessage(line.buildStepDisplayName ? `${line.buildStepDisplayName}: ${line.msg}` : String(line.msg));
|
|
123
|
+
}
|
|
124
|
+
// Log text comes from commands run in the session, so strip escape sequences and control
|
|
125
|
+
// characters that could clear the terminal or spoof output.
|
|
126
|
+
function toPlainText(message) {
|
|
127
|
+
return (0, terminalText_1.sanitizeTerminalText)((0, util_1.stripVTControlCharacters)(message));
|
|
128
|
+
}
|
|
129
|
+
function formatMessage(message) {
|
|
130
|
+
const text = toPlainText(message);
|
|
131
|
+
return text.length > MAX_LOGGED_ERROR_LENGTH
|
|
132
|
+
? `${text.slice(0, MAX_LOGGED_ERROR_LENGTH)}…`
|
|
133
|
+
: text;
|
|
134
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AnalyticsWithOrchestration } from '../analytics/AnalyticsManager';
|
|
2
|
+
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
|
2
3
|
import { CurrentUserQuery } from '../graphql/generated';
|
|
3
4
|
export type LoggedInAuthenticationInfo = {
|
|
4
5
|
accessToken: string;
|
|
@@ -11,12 +12,21 @@ type Actor = NonNullable<CurrentUserQuery['meActor']>;
|
|
|
11
12
|
export default class SessionManager {
|
|
12
13
|
private readonly analytics;
|
|
13
14
|
private currentActor;
|
|
15
|
+
private graphqlClient;
|
|
14
16
|
constructor(analytics: AnalyticsWithOrchestration);
|
|
15
17
|
getAccessToken(): string | null;
|
|
16
18
|
getSessionSecret(): string | null;
|
|
17
19
|
private getSession;
|
|
18
20
|
private setSessionAsync;
|
|
19
21
|
logoutAsync(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Returns one GraphQL client per credential, so context fields of one command share
|
|
24
|
+
* the urql cache. For example, the project ID check and the command both query the app.
|
|
25
|
+
*/
|
|
26
|
+
getGraphqlClient(authenticationInfo: {
|
|
27
|
+
accessToken: string | null;
|
|
28
|
+
sessionSecret: string | null;
|
|
29
|
+
}): ExpoGraphqlClient;
|
|
20
30
|
/**
|
|
21
31
|
* @param requestTimeoutMs caps the actor lookup when no actor is cached yet. Callers that must
|
|
22
32
|
* not delay a command past a deadline pass it; the default has no timeout. A capped lookup
|
|
@@ -18,6 +18,7 @@ const paths_1 = require("../utils/paths");
|
|
|
18
18
|
class SessionManager {
|
|
19
19
|
analytics;
|
|
20
20
|
currentActor;
|
|
21
|
+
graphqlClient;
|
|
21
22
|
constructor(analytics) {
|
|
22
23
|
this.analytics = analytics;
|
|
23
24
|
}
|
|
@@ -59,6 +60,17 @@ class SessionManager {
|
|
|
59
60
|
this.currentActor = undefined;
|
|
60
61
|
await this.setSessionAsync(undefined);
|
|
61
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns one GraphQL client per credential, so context fields of one command share
|
|
65
|
+
* the urql cache. For example, the project ID check and the command both query the app.
|
|
66
|
+
*/
|
|
67
|
+
getGraphqlClient(authenticationInfo) {
|
|
68
|
+
const credential = authenticationInfo.accessToken ?? authenticationInfo.sessionSecret;
|
|
69
|
+
if (this.graphqlClient?.credential !== credential) {
|
|
70
|
+
this.graphqlClient = { credential, client: (0, createGraphqlClient_1.createGraphqlClient)(authenticationInfo) };
|
|
71
|
+
}
|
|
72
|
+
return this.graphqlClient.client;
|
|
73
|
+
}
|
|
62
74
|
/**
|
|
63
75
|
* @param requestTimeoutMs caps the actor lookup when no actor is cached yet. Callers that must
|
|
64
76
|
* not delay a command past a deadline pass it; the default has no timeout. A capped lookup
|