eas-cli 23.1.0 → 24.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 +424 -226
- package/build/api.d.ts +1 -0
- package/build/api.js +12 -0
- package/build/build/utils/url.d.ts +1 -0
- package/build/build/utils/url.js +4 -0
- package/build/channel/protection.d.ts +4 -0
- package/build/channel/protection.js +49 -0
- package/build/channel/queries.d.ts +6 -0
- package/build/channel/queries.js +5 -1
- package/build/commandUtils/workflow/logs/fetchLogs.d.ts +5 -0
- package/build/commandUtils/workflow/logs/fetchLogs.js +24 -0
- package/build/commandUtils/workflow/logs/parseLogs.d.ts +14 -0
- package/build/commandUtils/workflow/logs/parseLogs.js +69 -0
- package/build/commandUtils/workflow/logs/watcher.d.ts +32 -0
- package/build/commandUtils/workflow/logs/watcher.js +162 -0
- package/build/commandUtils/workflow/stateMachine.js +2 -1
- package/build/commandUtils/workflow/types.d.ts +12 -5
- package/build/commandUtils/workflow/utils.d.ts +9 -5
- package/build/commandUtils/workflow/utils.js +144 -146
- package/build/commands/channel/protect.d.ts +16 -0
- package/build/commands/channel/protect.js +68 -0
- package/build/commands/channel/unprotect.d.ts +16 -0
- package/build/commands/channel/unprotect.js +78 -0
- package/build/commands/observe/errors.d.ts +27 -0
- package/build/commands/observe/errors.js +122 -0
- package/build/commands/observe/event.d.ts +18 -0
- package/build/commands/observe/event.js +149 -0
- package/build/commands/observe/events.d.ts +2 -0
- package/build/commands/observe/events.js +10 -4
- package/build/commands/observe/metrics-summary.d.ts +1 -0
- package/build/commands/observe/metrics-summary.js +3 -2
- package/build/commands/observe/metrics.d.ts +2 -0
- package/build/commands/observe/metrics.js +8 -4
- package/build/commands/observe/routes.d.ts +2 -1
- package/build/commands/observe/routes.js +5 -5
- package/build/commands/observe/session.d.ts +1 -0
- package/build/commands/observe/session.js +14 -8
- package/build/commands/observe/versions.d.ts +1 -0
- package/build/commands/observe/versions.js +3 -2
- package/build/commands/project/status.d.ts +16 -0
- package/build/commands/project/status.js +47 -0
- package/build/commands/simulator/get.js +5 -1
- package/build/commands/simulator/index.d.ts +1 -0
- package/build/commands/simulator/index.js +16 -2
- package/build/commands/simulator/list.d.ts +1 -0
- package/build/commands/simulator/list.js +9 -0
- package/build/commands/workflow/run.d.ts +8 -0
- package/build/commands/workflow/run.js +27 -0
- package/build/commands/workflow/ssh.d.ts +31 -0
- package/build/commands/workflow/ssh.js +190 -0
- package/build/credentials/ios/credentials.d.ts +5 -3
- package/build/credentials/ios/utils/printCredentials.js +6 -1
- package/build/graphql/generated.d.ts +2474 -1079
- package/build/graphql/generated.js +71 -16
- package/build/graphql/mutations/RealtimeLogsMutation.d.ts +6 -0
- package/build/graphql/mutations/RealtimeLogsMutation.js +40 -0
- package/build/graphql/mutations/WorkflowRunMutation.d.ts +3 -2
- package/build/graphql/mutations/WorkflowRunMutation.js +4 -1
- package/build/graphql/queries/AppStoreConnectApiKeyQuery.d.ts +1 -1
- package/build/graphql/queries/AppStoreConnectApiKeyQuery.js +1 -1
- package/build/graphql/queries/ChannelQuery.js +2 -0
- package/build/graphql/queries/DeviceRunSessionQuery.js +10 -0
- package/build/graphql/queries/ObserveQuery.d.ts +62 -30
- package/build/graphql/queries/ObserveQuery.js +276 -121
- package/build/graphql/queries/SubmissionQuery.d.ts +6 -1
- package/build/graphql/queries/SubmissionQuery.js +41 -0
- package/build/graphql/queries/WorkflowJobSshQuery.d.ts +20 -0
- package/build/graphql/queries/WorkflowJobSshQuery.js +133 -0
- package/build/graphql/types/Observe.d.ts +5 -3
- package/build/graphql/types/Observe.js +80 -21
- package/build/graphql/types/UpdateChannelBasicInfo.js +1 -0
- package/build/observe/fetchCustomEvents.d.ts +6 -4
- package/build/observe/fetchCustomEvents.js +4 -2
- package/build/observe/fetchErrors.d.ts +32 -0
- package/build/observe/fetchErrors.js +42 -0
- package/build/observe/fetchEvents.d.ts +9 -6
- package/build/observe/fetchEvents.js +16 -17
- package/build/observe/fetchMetrics.d.ts +2 -2
- package/build/observe/fetchMetrics.js +9 -9
- package/build/observe/fetchNavigationRoutes.d.ts +7 -5
- package/build/observe/fetchNavigationRoutes.js +8 -8
- package/build/observe/fetchSessions.d.ts +13 -11
- package/build/observe/fetchSessions.js +59 -30
- package/build/observe/fetchVersions.d.ts +4 -3
- package/build/observe/fetchVersions.js +7 -11
- package/build/observe/flags.d.ts +6 -0
- package/build/observe/flags.js +12 -2
- package/build/observe/formatCustomEvents.d.ts +16 -10
- package/build/observe/formatCustomEvents.js +61 -28
- package/build/observe/formatErrors.d.ts +97 -0
- package/build/observe/formatErrors.js +203 -0
- package/build/observe/formatEvents.d.ts +11 -5
- package/build/observe/formatEvents.js +46 -18
- package/build/observe/formatMetrics.d.ts +4 -4
- package/build/observe/formatMetrics.js +2 -2
- package/build/observe/formatNavigationRoutes.d.ts +4 -4
- package/build/observe/formatNavigationRoutes.js +3 -3
- package/build/observe/formatSessions.d.ts +3 -3
- package/build/observe/formatSessions.js +8 -8
- package/build/observe/formatVersions.js +2 -2
- package/build/observe/platforms.d.ts +10 -19
- package/build/observe/platforms.js +42 -40
- package/build/ora.d.ts +7 -0
- package/build/ora.js +12 -0
- package/build/project/projectStatus.d.ts +96 -0
- package/build/project/projectStatus.js +314 -0
- package/build/simulator/utils.d.ts +11 -0
- package/build/simulator/utils.js +51 -4
- package/build/submit/utils/urls.js +2 -3
- package/build/utils/centrifuge.d.ts +10 -0
- package/build/utils/centrifuge.js +89 -0
- package/build/utils/expodash/uniqBy.js +3 -2
- package/oclif.manifest.json +2947 -2328
- package/package.json +10 -7
- package/build/chat/chatClient.d.ts +0 -37
- package/build/chat/chatClient.js +0 -359
- package/build/chat/detectProject.d.ts +0 -5
- package/build/chat/detectProject.js +0 -41
- package/build/chat/renderMarkdown.d.ts +0 -7
- package/build/chat/renderMarkdown.js +0 -47
- package/build/chat/replInput.d.ts +0 -10
- package/build/chat/replInput.js +0 -52
- package/build/commandUtils/workflow/fetchLogs.d.ts +0 -6
- package/build/commandUtils/workflow/fetchLogs.js +0 -44
- package/build/commands/chat.d.ts +0 -18
- package/build/commands/chat.js +0 -221
package/build/api.d.ts
CHANGED
|
@@ -20,4 +20,5 @@ export declare function getExpoApiBaseUrl(): string;
|
|
|
20
20
|
export declare function getExpoWebsiteBaseUrl(): string;
|
|
21
21
|
export declare function getEASUpdateURL(projectId: string, manifestHostOverride: string | null): string;
|
|
22
22
|
export declare function getExpoApiWorkflowSchemaURL(): string;
|
|
23
|
+
export declare function getEASLogsWebsocketUrl(): string;
|
|
23
24
|
export {};
|
package/build/api.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.getExpoApiBaseUrl = getExpoApiBaseUrl;
|
|
|
5
5
|
exports.getExpoWebsiteBaseUrl = getExpoWebsiteBaseUrl;
|
|
6
6
|
exports.getEASUpdateURL = getEASUpdateURL;
|
|
7
7
|
exports.getExpoApiWorkflowSchemaURL = getExpoApiWorkflowSchemaURL;
|
|
8
|
+
exports.getEASLogsWebsocketUrl = getEASLogsWebsocketUrl;
|
|
8
9
|
const tslib_1 = require("tslib");
|
|
9
10
|
const ApiV2Error_1 = require("./ApiV2Error");
|
|
10
11
|
const fetch_1 = tslib_1.__importStar(require("./fetch"));
|
|
@@ -109,3 +110,14 @@ function getEASUpdateURL(projectId, manifestHostOverride) {
|
|
|
109
110
|
function getExpoApiWorkflowSchemaURL() {
|
|
110
111
|
return getExpoApiBaseUrl() + '/v2/workflows/schema';
|
|
111
112
|
}
|
|
113
|
+
function getEASLogsWebsocketUrl() {
|
|
114
|
+
if (process.env.EXPO_STAGING) {
|
|
115
|
+
return `wss://staging-logs.expo.dev/connection/websocket`;
|
|
116
|
+
}
|
|
117
|
+
else if (process.env.EXPO_LOCAL) {
|
|
118
|
+
return `ws://localhost:4997/connection/websocket`;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
return `wss://logs.expo.dev/connection/websocket`;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -5,6 +5,7 @@ export declare function getBuildLogsUrl(build: BuildFragment, hash?: string): st
|
|
|
5
5
|
export declare function getArtifactUrl(artifactId: string): string;
|
|
6
6
|
export declare function getInternalDistributionInstallUrl(build: BuildFragment): string;
|
|
7
7
|
export declare function getUpdateGroupUrl(accountName: string, projectName: string, updateGroupId: string): string;
|
|
8
|
+
export declare function getSubmissionUrl(accountName: string, projectName: string, submissionId: string): string;
|
|
8
9
|
export declare function getWorkflowRunUrl(accountName: string, projectName: string, workflowRunId: string): string;
|
|
9
10
|
export declare function getDeviceRunSessionUrl(accountName: string, projectName: string, deviceRunSessionId: string): string;
|
|
10
11
|
/**
|
package/build/build/utils/url.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.getBuildLogsUrl = getBuildLogsUrl;
|
|
|
6
6
|
exports.getArtifactUrl = getArtifactUrl;
|
|
7
7
|
exports.getInternalDistributionInstallUrl = getInternalDistributionInstallUrl;
|
|
8
8
|
exports.getUpdateGroupUrl = getUpdateGroupUrl;
|
|
9
|
+
exports.getSubmissionUrl = getSubmissionUrl;
|
|
9
10
|
exports.getWorkflowRunUrl = getWorkflowRunUrl;
|
|
10
11
|
exports.getDeviceRunSessionUrl = getDeviceRunSessionUrl;
|
|
11
12
|
exports.getBareJobRunUrl = getBareJobRunUrl;
|
|
@@ -40,6 +41,9 @@ function getInternalDistributionInstallUrl(build) {
|
|
|
40
41
|
function getUpdateGroupUrl(accountName, projectName, updateGroupId) {
|
|
41
42
|
return new URL(`/accounts/${encodeURIComponent(accountName)}/projects/${encodeURIComponent(projectName)}/updates/${encodeURIComponent(updateGroupId)}`, (0, api_1.getExpoWebsiteBaseUrl)()).toString();
|
|
42
43
|
}
|
|
44
|
+
function getSubmissionUrl(accountName, projectName, submissionId) {
|
|
45
|
+
return new URL(`/accounts/${encodeURIComponent(accountName)}/projects/${encodeURIComponent(projectName)}/submissions/${encodeURIComponent(submissionId)}`, (0, api_1.getExpoWebsiteBaseUrl)()).toString();
|
|
46
|
+
}
|
|
43
47
|
function getWorkflowRunUrl(accountName, projectName, workflowRunId) {
|
|
44
48
|
return new URL(`/accounts/${encodeURIComponent(accountName)}/projects/${encodeURIComponent(projectName)}/workflows/${workflowRunId}`, (0, api_1.getExpoWebsiteBaseUrl)()).toString();
|
|
45
49
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
|
2
|
+
import { ProtectUpdateChannelMutationVariables, UnprotectUpdateChannelMutationVariables, UpdateChannelBasicInfoFragment } from '../graphql/generated';
|
|
3
|
+
export declare function protectUpdateChannelAsync(graphqlClient: ExpoGraphqlClient, { channelId }: ProtectUpdateChannelMutationVariables): Promise<UpdateChannelBasicInfoFragment>;
|
|
4
|
+
export declare function unprotectUpdateChannelAsync(graphqlClient: ExpoGraphqlClient, { channelId }: UnprotectUpdateChannelMutationVariables): Promise<UpdateChannelBasicInfoFragment>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.protectUpdateChannelAsync = protectUpdateChannelAsync;
|
|
4
|
+
exports.unprotectUpdateChannelAsync = unprotectUpdateChannelAsync;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const graphql_1 = require("graphql");
|
|
7
|
+
const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
|
|
8
|
+
const client_1 = require("../graphql/client");
|
|
9
|
+
const UpdateChannelBasicInfo_1 = require("../graphql/types/UpdateChannelBasicInfo");
|
|
10
|
+
async function protectUpdateChannelAsync(graphqlClient, { channelId }) {
|
|
11
|
+
const data = await (0, client_1.withErrorHandlingAsync)(graphqlClient
|
|
12
|
+
.mutation((0, graphql_tag_1.default) `
|
|
13
|
+
mutation ProtectUpdateChannel($channelId: ID!) {
|
|
14
|
+
updateChannel {
|
|
15
|
+
protectUpdateChannel(channelId: $channelId) {
|
|
16
|
+
id
|
|
17
|
+
...UpdateChannelBasicInfoFragment
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
${(0, graphql_1.print)(UpdateChannelBasicInfo_1.UpdateChannelBasicInfoFragmentNode)}
|
|
22
|
+
`, { channelId })
|
|
23
|
+
.toPromise());
|
|
24
|
+
const channel = data.updateChannel.protectUpdateChannel;
|
|
25
|
+
if (!channel) {
|
|
26
|
+
throw new Error(`Could not find a channel with id: ${channelId}`);
|
|
27
|
+
}
|
|
28
|
+
return channel;
|
|
29
|
+
}
|
|
30
|
+
async function unprotectUpdateChannelAsync(graphqlClient, { channelId }) {
|
|
31
|
+
const data = await (0, client_1.withErrorHandlingAsync)(graphqlClient
|
|
32
|
+
.mutation((0, graphql_tag_1.default) `
|
|
33
|
+
mutation UnprotectUpdateChannel($channelId: ID!) {
|
|
34
|
+
updateChannel {
|
|
35
|
+
unprotectUpdateChannel(channelId: $channelId) {
|
|
36
|
+
id
|
|
37
|
+
...UpdateChannelBasicInfoFragment
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
${(0, graphql_1.print)(UpdateChannelBasicInfo_1.UpdateChannelBasicInfoFragmentNode)}
|
|
42
|
+
`, { channelId })
|
|
43
|
+
.toPromise());
|
|
44
|
+
const channel = data.updateChannel.unprotectUpdateChannel;
|
|
45
|
+
if (!channel) {
|
|
46
|
+
throw new Error(`Could not find a channel with id: ${channelId}`);
|
|
47
|
+
}
|
|
48
|
+
return channel;
|
|
49
|
+
}
|
|
@@ -18,6 +18,12 @@ export declare function listAndRenderBranchesAndUpdatesOnChannelAsync(graphqlCli
|
|
|
18
18
|
channelName: string;
|
|
19
19
|
paginatedQueryOptions: PaginatedQueryOptions;
|
|
20
20
|
}): Promise<void>;
|
|
21
|
+
export declare function renderChannelHeaderContent({ channelName, channelId, isPaused, isProtected, }: {
|
|
22
|
+
channelName: string;
|
|
23
|
+
channelId: string;
|
|
24
|
+
isPaused: boolean;
|
|
25
|
+
isProtected: boolean;
|
|
26
|
+
}): void;
|
|
21
27
|
export declare function createChannelOnAppAsync(graphqlClient: ExpoGraphqlClient, { appId, branchId, channelName, }: {
|
|
22
28
|
appId: string;
|
|
23
29
|
branchId: string;
|
package/build/channel/queries.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.CHANNELS_LIMIT = void 0;
|
|
|
4
4
|
exports.selectChannelOnAppAsync = selectChannelOnAppAsync;
|
|
5
5
|
exports.listAndRenderChannelsOnAppAsync = listAndRenderChannelsOnAppAsync;
|
|
6
6
|
exports.listAndRenderBranchesAndUpdatesOnChannelAsync = listAndRenderBranchesAndUpdatesOnChannelAsync;
|
|
7
|
+
exports.renderChannelHeaderContent = renderChannelHeaderContent;
|
|
7
8
|
exports.createChannelOnAppAsync = createChannelOnAppAsync;
|
|
8
9
|
exports.ensureChannelExistsAsync = ensureChannelExistsAsync;
|
|
9
10
|
exports.doesChannelExistAsync = doesChannelExistAsync;
|
|
@@ -83,6 +84,7 @@ async function listAndRenderBranchesAndUpdatesOnChannelAsync(graphqlClient, { pr
|
|
|
83
84
|
channelName: channel.name,
|
|
84
85
|
channelId: channel.id,
|
|
85
86
|
isPaused: channel.isPaused,
|
|
87
|
+
isProtected: channel.isProtected,
|
|
86
88
|
});
|
|
87
89
|
if (paginatedQueryOptions.nonInteractive) {
|
|
88
90
|
const branches = await queryBranchesAndUpdateGroupsOnChannelAsync(graphqlClient, {
|
|
@@ -132,6 +134,7 @@ function renderPageOfChannels(currentPage, { json }) {
|
|
|
132
134
|
channelName: channel.name,
|
|
133
135
|
channelId: channel.id,
|
|
134
136
|
isPaused: channel.isPaused,
|
|
137
|
+
isProtected: channel.isProtected,
|
|
135
138
|
});
|
|
136
139
|
log_1.default.addNewLineIfNone();
|
|
137
140
|
(0, print_utils_1.logChannelDetails)(channel);
|
|
@@ -152,13 +155,14 @@ function renderPageOfBranchesOnChannel(channel, currentPage, { json }) {
|
|
|
152
155
|
(0, print_utils_1.logChannelDetails)(channelWithNewBranches);
|
|
153
156
|
}
|
|
154
157
|
}
|
|
155
|
-
function renderChannelHeaderContent({ channelName, channelId, isPaused, }) {
|
|
158
|
+
function renderChannelHeaderContent({ channelName, channelId, isPaused, isProtected, }) {
|
|
156
159
|
log_1.default.addNewLineIfNone();
|
|
157
160
|
log_1.default.log(chalk_1.default.bold('Channel:'));
|
|
158
161
|
log_1.default.log((0, formatFields_1.default)([
|
|
159
162
|
{ label: 'Name', value: channelName },
|
|
160
163
|
{ label: 'ID', value: channelId },
|
|
161
164
|
{ label: 'Status', value: isPaused ? 'Paused' : 'Active' },
|
|
165
|
+
{ label: 'Protection', value: isProtected ? 'Protected' : 'Unprotected' },
|
|
162
166
|
]));
|
|
163
167
|
log_1.default.addNewLineIfNone();
|
|
164
168
|
log_1.default.log((0, chalk_1.default) `{bold Branches pointed at this channel and their most recent update group:}`);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { WorkflowJobResult } from '../types';
|
|
2
|
+
import { ExpoGraphqlClient } from '../../context/contextUtils/createGraphqlClient';
|
|
3
|
+
export declare function fetchRawLogsForJobAsync(state: {
|
|
4
|
+
graphqlClient: ExpoGraphqlClient;
|
|
5
|
+
}, job: WorkflowJobResult): Promise<string | null>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchRawLogsForJobAsync = fetchRawLogsForJobAsync;
|
|
4
|
+
const BuildQuery_1 = require("../../../graphql/queries/BuildQuery");
|
|
5
|
+
async function fetchRawLogsForJobAsync(state, job) {
|
|
6
|
+
const turtleLogFileUrl = job.turtleJobRun?.logFileUrls?.[0];
|
|
7
|
+
if (turtleLogFileUrl) {
|
|
8
|
+
const response = await fetch(turtleLogFileUrl);
|
|
9
|
+
return await response.text();
|
|
10
|
+
}
|
|
11
|
+
const buildId = job.outputs?.build_id;
|
|
12
|
+
if (!buildId) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const buildFragment = await BuildQuery_1.BuildQuery.byIdAsync(state.graphqlClient, buildId, {
|
|
16
|
+
useCache: false,
|
|
17
|
+
});
|
|
18
|
+
const firstLogFileUrl = buildFragment.logFiles?.[0];
|
|
19
|
+
if (!firstLogFileUrl) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const response = await fetch(firstLogFileUrl);
|
|
23
|
+
return await response.text();
|
|
24
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { WorkflowJobResult, WorkflowLogs, WorkflowRawLogLine } from '../types';
|
|
2
|
+
import { ExpoGraphqlClient } from '../../context/contextUtils/createGraphqlClient';
|
|
3
|
+
export declare function parseLogLines(rawLogs: string): {
|
|
4
|
+
logLines: WorkflowRawLogLine[];
|
|
5
|
+
errors: Error[];
|
|
6
|
+
};
|
|
7
|
+
export declare function mergeLogLines<T extends WorkflowRawLogLine>(...logLineGroups: T[][]): T[];
|
|
8
|
+
export declare function groupLogLinesIntoSteps(logLines: WorkflowRawLogLine[], accumulator?: WorkflowLogs): WorkflowLogs;
|
|
9
|
+
export declare function fetchAndParseLogsFromJobAsync(state: {
|
|
10
|
+
graphqlClient: ExpoGraphqlClient;
|
|
11
|
+
}, job: WorkflowJobResult): Promise<WorkflowRawLogLine[] | null>;
|
|
12
|
+
export declare function fetchAndProcessLogsFromJobAsync(state: {
|
|
13
|
+
graphqlClient: ExpoGraphqlClient;
|
|
14
|
+
}, job: WorkflowJobResult): Promise<WorkflowLogs | null>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseLogLines = parseLogLines;
|
|
4
|
+
exports.mergeLogLines = mergeLogLines;
|
|
5
|
+
exports.groupLogLinesIntoSteps = groupLogLinesIntoSteps;
|
|
6
|
+
exports.fetchAndParseLogsFromJobAsync = fetchAndParseLogsFromJobAsync;
|
|
7
|
+
exports.fetchAndProcessLogsFromJobAsync = fetchAndProcessLogsFromJobAsync;
|
|
8
|
+
const tslib_1 = require("tslib");
|
|
9
|
+
const fetchLogs_1 = require("./fetchLogs");
|
|
10
|
+
const log_1 = tslib_1.__importDefault(require("../../../log"));
|
|
11
|
+
const uniqBy_1 = tslib_1.__importDefault(require("../../../utils/expodash/uniqBy"));
|
|
12
|
+
function parseLogLines(rawLogs) {
|
|
13
|
+
const logLines = [];
|
|
14
|
+
const errors = [];
|
|
15
|
+
for (const rawLogLine of rawLogs.split('\n')) {
|
|
16
|
+
if (!rawLogLine) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
logLines.push(JSON.parse(rawLogLine));
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
errors.push(err);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return { logLines, errors };
|
|
27
|
+
}
|
|
28
|
+
function mergeLogLines(...logLineGroups) {
|
|
29
|
+
return (0, uniqBy_1.default)(logLineGroups.flat().reverse(), logLine => logLine.logId ?? Symbol()).reverse();
|
|
30
|
+
}
|
|
31
|
+
function groupLogLinesIntoSteps(logLines, accumulator = new Map()) {
|
|
32
|
+
for (const logLine of logLines) {
|
|
33
|
+
const { buildStepDisplayName, buildStepId, phase, time, msg, result, marker, err } = logLine;
|
|
34
|
+
const stepKey = buildStepId ?? buildStepDisplayName ?? phase;
|
|
35
|
+
const stepLabel = buildStepDisplayName ?? buildStepId ?? phase;
|
|
36
|
+
if (!stepKey || !stepLabel || !msg) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
let logGroup = accumulator.get(stepKey);
|
|
40
|
+
if (!logGroup) {
|
|
41
|
+
logGroup = { key: stepKey, label: stepLabel, logLines: [] };
|
|
42
|
+
accumulator.set(stepKey, logGroup);
|
|
43
|
+
}
|
|
44
|
+
if (buildStepDisplayName) {
|
|
45
|
+
logGroup.label = buildStepDisplayName;
|
|
46
|
+
}
|
|
47
|
+
if (logGroup.result === undefined && (marker === 'end-step' || marker === 'END_PHASE')) {
|
|
48
|
+
logGroup.result = result ?? '';
|
|
49
|
+
}
|
|
50
|
+
logGroup.logLines.push({ time, msg, result, marker, err });
|
|
51
|
+
}
|
|
52
|
+
return accumulator;
|
|
53
|
+
}
|
|
54
|
+
async function fetchAndParseLogsFromJobAsync(state, job) {
|
|
55
|
+
const rawLogs = await (0, fetchLogs_1.fetchRawLogsForJobAsync)(state, job);
|
|
56
|
+
if (!rawLogs) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
log_1.default.debug(`rawLogs = ${JSON.stringify(rawLogs, null, 2)}`);
|
|
60
|
+
const { logLines, errors } = parseLogLines(rawLogs);
|
|
61
|
+
for (const error of errors) {
|
|
62
|
+
log_1.default.debug(`Failed to parse a log line: ${error.message}`);
|
|
63
|
+
}
|
|
64
|
+
return logLines;
|
|
65
|
+
}
|
|
66
|
+
async function fetchAndProcessLogsFromJobAsync(state, job) {
|
|
67
|
+
const logLines = await fetchAndParseLogsFromJobAsync(state, job);
|
|
68
|
+
return logLines && groupLogLinesIntoSteps(logLines);
|
|
69
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { WorkflowJobResult, WorkflowLogs, WorkflowRawLogLine } from '../types';
|
|
2
|
+
import { RealtimeLogsTargetInput } from '../../../graphql/generated';
|
|
3
|
+
import { RealtimeLogsClient } from '../../../utils/centrifuge';
|
|
4
|
+
import { ExpoGraphqlClient } from '../../context/contextUtils/createGraphqlClient';
|
|
5
|
+
export declare class WorkflowJobLogsState {
|
|
6
|
+
private fileLogIds;
|
|
7
|
+
private realtimeLogLines;
|
|
8
|
+
private realtimeLogIds;
|
|
9
|
+
private haveFileLogsCaughtUp;
|
|
10
|
+
private realtimeLogsRevealed;
|
|
11
|
+
private groupedLogs;
|
|
12
|
+
ingestFileLogLines(logLines: WorkflowRawLogLine[]): void;
|
|
13
|
+
ingestRealtimeLogLines(data: unknown): boolean;
|
|
14
|
+
markCompleted(): void;
|
|
15
|
+
getLogs(): WorkflowLogs;
|
|
16
|
+
private revealRealtimeLogs;
|
|
17
|
+
}
|
|
18
|
+
export declare function realtimeLogsTargetForJob(job: WorkflowJobResult): RealtimeLogsTargetInput | null;
|
|
19
|
+
export declare class WorkflowRunLogsWatcher {
|
|
20
|
+
private readonly graphqlClient;
|
|
21
|
+
private readonly createRealtimeLogsClient;
|
|
22
|
+
private readonly onRealtimeLogs;
|
|
23
|
+
private readonly trackedJobs;
|
|
24
|
+
private realtimeLogsClient?;
|
|
25
|
+
constructor(graphqlClient: ExpoGraphqlClient, createRealtimeLogsClient: () => RealtimeLogsClient | null, onRealtimeLogs: () => void);
|
|
26
|
+
syncJobsAsync(jobs: WorkflowJobResult[]): Promise<Map<string, WorkflowJobLogsState>>;
|
|
27
|
+
close(): void;
|
|
28
|
+
private syncJobAsync;
|
|
29
|
+
private fetchLogsAsync;
|
|
30
|
+
private getRealtimeLogsClient;
|
|
31
|
+
private subscribeAsync;
|
|
32
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkflowRunLogsWatcher = exports.WorkflowJobLogsState = void 0;
|
|
4
|
+
exports.realtimeLogsTargetForJob = realtimeLogsTargetForJob;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const parseLogs_1 = require("./parseLogs");
|
|
7
|
+
const generated_1 = require("../../../graphql/generated");
|
|
8
|
+
const log_1 = tslib_1.__importDefault(require("../../../log"));
|
|
9
|
+
const nullthrows_1 = tslib_1.__importDefault(require("nullthrows"));
|
|
10
|
+
function isRealtimeLogLine(entry) {
|
|
11
|
+
return (typeof entry === 'object' &&
|
|
12
|
+
entry !== null &&
|
|
13
|
+
typeof entry.logId === 'string');
|
|
14
|
+
}
|
|
15
|
+
class WorkflowJobLogsState {
|
|
16
|
+
fileLogIds = new Set();
|
|
17
|
+
realtimeLogLines = [];
|
|
18
|
+
realtimeLogIds = new Set();
|
|
19
|
+
haveFileLogsCaughtUp = false;
|
|
20
|
+
realtimeLogsRevealed = false;
|
|
21
|
+
groupedLogs = new Map();
|
|
22
|
+
ingestFileLogLines(logLines) {
|
|
23
|
+
this.fileLogIds = new Set(logLines.flatMap(logLine => (logLine.logId ? [logLine.logId] : [])));
|
|
24
|
+
if (!this.haveFileLogsCaughtUp &&
|
|
25
|
+
this.realtimeLogLines.some(logLine => this.fileLogIds.has(logLine.logId))) {
|
|
26
|
+
this.haveFileLogsCaughtUp = true;
|
|
27
|
+
}
|
|
28
|
+
this.realtimeLogLines = this.realtimeLogLines.filter(logLine => !this.fileLogIds.has(logLine.logId));
|
|
29
|
+
this.realtimeLogIds = new Set(this.realtimeLogLines.map(logLine => logLine.logId));
|
|
30
|
+
if (this.haveFileLogsCaughtUp) {
|
|
31
|
+
this.realtimeLogsRevealed = true;
|
|
32
|
+
}
|
|
33
|
+
this.groupedLogs = (0, parseLogs_1.groupLogLinesIntoSteps)((0, parseLogs_1.mergeLogLines)(logLines, this.realtimeLogsRevealed ? this.realtimeLogLines : []));
|
|
34
|
+
}
|
|
35
|
+
ingestRealtimeLogLines(data) {
|
|
36
|
+
if (!Array.isArray(data)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const publishedLogLines = data.filter(isRealtimeLogLine);
|
|
40
|
+
if (publishedLogLines.length === 0) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
if (!this.haveFileLogsCaughtUp &&
|
|
44
|
+
publishedLogLines.some(logLine => this.fileLogIds.has(logLine.logId))) {
|
|
45
|
+
this.haveFileLogsCaughtUp = true;
|
|
46
|
+
}
|
|
47
|
+
const newLogLines = publishedLogLines.filter(logLine => !this.fileLogIds.has(logLine.logId) && !this.realtimeLogIds.has(logLine.logId));
|
|
48
|
+
for (const logLine of newLogLines) {
|
|
49
|
+
this.realtimeLogLines.push(logLine);
|
|
50
|
+
this.realtimeLogIds.add(logLine.logId);
|
|
51
|
+
}
|
|
52
|
+
if (!this.realtimeLogsRevealed) {
|
|
53
|
+
if (this.haveFileLogsCaughtUp) {
|
|
54
|
+
this.revealRealtimeLogs();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else if (newLogLines.length > 0) {
|
|
58
|
+
(0, parseLogs_1.groupLogLinesIntoSteps)(newLogLines, this.groupedLogs);
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
markCompleted() {
|
|
63
|
+
this.revealRealtimeLogs();
|
|
64
|
+
}
|
|
65
|
+
getLogs() {
|
|
66
|
+
return this.groupedLogs;
|
|
67
|
+
}
|
|
68
|
+
revealRealtimeLogs() {
|
|
69
|
+
if (this.realtimeLogsRevealed) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this.realtimeLogsRevealed = true;
|
|
73
|
+
(0, parseLogs_1.groupLogLinesIntoSteps)(this.realtimeLogLines, this.groupedLogs);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.WorkflowJobLogsState = WorkflowJobLogsState;
|
|
77
|
+
function realtimeLogsTargetForJob(job) {
|
|
78
|
+
if (job.turtleJobRun?.id) {
|
|
79
|
+
return { type: generated_1.RealtimeLogsTargetType.JobRun, id: job.turtleJobRun.id };
|
|
80
|
+
}
|
|
81
|
+
const buildId = job.turtleBuild?.id ?? job.outputs?.build_id;
|
|
82
|
+
if (buildId) {
|
|
83
|
+
return { type: generated_1.RealtimeLogsTargetType.Build, id: buildId };
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
class WorkflowRunLogsWatcher {
|
|
88
|
+
graphqlClient;
|
|
89
|
+
createRealtimeLogsClient;
|
|
90
|
+
onRealtimeLogs;
|
|
91
|
+
trackedJobs = new Map();
|
|
92
|
+
realtimeLogsClient;
|
|
93
|
+
constructor(graphqlClient, createRealtimeLogsClient, onRealtimeLogs) {
|
|
94
|
+
this.graphqlClient = graphqlClient;
|
|
95
|
+
this.createRealtimeLogsClient = createRealtimeLogsClient;
|
|
96
|
+
this.onRealtimeLogs = onRealtimeLogs;
|
|
97
|
+
}
|
|
98
|
+
async syncJobsAsync(jobs) {
|
|
99
|
+
await Promise.all(jobs.map(job => this.syncJobAsync(job)));
|
|
100
|
+
return new Map(jobs.map(job => [
|
|
101
|
+
job.id,
|
|
102
|
+
(0, nullthrows_1.default)(this.trackedJobs.get(job.id), 'job has to be in tracked jobs after it was synced').logsState,
|
|
103
|
+
]));
|
|
104
|
+
}
|
|
105
|
+
close() {
|
|
106
|
+
for (const trackedJob of this.trackedJobs.values()) {
|
|
107
|
+
trackedJob.subscription?.close();
|
|
108
|
+
trackedJob.subscription = null;
|
|
109
|
+
}
|
|
110
|
+
this.realtimeLogsClient?.close();
|
|
111
|
+
}
|
|
112
|
+
async syncJobAsync(job) {
|
|
113
|
+
let trackedJob = this.trackedJobs.get(job.id);
|
|
114
|
+
if (!trackedJob) {
|
|
115
|
+
trackedJob = { logsState: new WorkflowJobLogsState(), subscription: null };
|
|
116
|
+
this.trackedJobs.set(job.id, trackedJob);
|
|
117
|
+
}
|
|
118
|
+
const workflowInProgress = job.status === generated_1.WorkflowJobStatus.InProgress;
|
|
119
|
+
if (!workflowInProgress) {
|
|
120
|
+
trackedJob.subscription?.close();
|
|
121
|
+
trackedJob.subscription = null;
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
await Promise.all([
|
|
125
|
+
trackedJob.subscription ? Promise.resolve() : this.subscribeAsync(job, trackedJob),
|
|
126
|
+
this.fetchLogsAsync(job, trackedJob),
|
|
127
|
+
]);
|
|
128
|
+
}
|
|
129
|
+
async fetchLogsAsync(job, trackedJob) {
|
|
130
|
+
try {
|
|
131
|
+
const logLines = await (0, parseLogs_1.fetchAndParseLogsFromJobAsync)({ graphqlClient: this.graphqlClient }, job);
|
|
132
|
+
if (logLines) {
|
|
133
|
+
trackedJob.logsState.ingestFileLogLines(logLines);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
log_1.default.debug(`Failed to fetch logs for job ${job.id}: ${err.message}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
getRealtimeLogsClient() {
|
|
141
|
+
if (this.realtimeLogsClient === undefined) {
|
|
142
|
+
this.realtimeLogsClient = this.createRealtimeLogsClient();
|
|
143
|
+
}
|
|
144
|
+
return this.realtimeLogsClient;
|
|
145
|
+
}
|
|
146
|
+
async subscribeAsync(job, trackedJob) {
|
|
147
|
+
const target = realtimeLogsTargetForJob(job);
|
|
148
|
+
if (!target) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const realtimeLogsClient = this.getRealtimeLogsClient();
|
|
152
|
+
if (!realtimeLogsClient) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
trackedJob.subscription = await realtimeLogsClient.subscribeAsync({ target }, data => {
|
|
156
|
+
if (trackedJob.logsState.ingestRealtimeLogLines(data)) {
|
|
157
|
+
this.onRealtimeLogs();
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
exports.WorkflowRunLogsWatcher = WorkflowRunLogsWatcher;
|
|
@@ -8,6 +8,7 @@ exports.moveToWorkflowStepSelectionState = moveToWorkflowStepSelectionState;
|
|
|
8
8
|
exports.moveToWorkflowSelectionFinishedState = moveToWorkflowSelectionFinishedState;
|
|
9
9
|
exports.moveToWorkflowSelectionErrorState = moveToWorkflowSelectionErrorState;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
+
const parseLogs_1 = require("./logs/parseLogs");
|
|
11
12
|
const utils_1 = require("./utils");
|
|
12
13
|
const AppQuery_1 = require("../../graphql/queries/AppQuery");
|
|
13
14
|
const WorkflowJobQuery_1 = require("../../graphql/queries/WorkflowJobQuery");
|
|
@@ -161,7 +162,7 @@ const workflowStepSelectionAction = async (prevState) => {
|
|
|
161
162
|
if (!job) {
|
|
162
163
|
return moveToWorkflowSelectionErrorState(prevState, 'No job found');
|
|
163
164
|
}
|
|
164
|
-
const logs = await (0,
|
|
165
|
+
const logs = await (0, parseLogs_1.fetchAndProcessLogsFromJobAsync)(prevState, job);
|
|
165
166
|
if (!logs) {
|
|
166
167
|
return moveToWorkflowSelectionErrorState(prevState, 'No logs found');
|
|
167
168
|
}
|
|
@@ -30,15 +30,22 @@ export type WorkflowRunWithJobsResult = WorkflowRunResult & {
|
|
|
30
30
|
jobs: WorkflowJobResult[];
|
|
31
31
|
logs?: string;
|
|
32
32
|
};
|
|
33
|
-
export type
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
export type WorkflowRawLogLine = {
|
|
34
|
+
logId?: string;
|
|
35
|
+
buildStepId?: string;
|
|
36
|
+
buildStepDisplayName?: string;
|
|
37
|
+
phase?: string;
|
|
38
|
+
time?: string;
|
|
39
|
+
msg?: string;
|
|
36
40
|
result?: string;
|
|
37
41
|
marker?: string;
|
|
38
42
|
err?: any;
|
|
39
43
|
};
|
|
40
|
-
export type
|
|
44
|
+
export type WorkflowLogLine = Pick<WorkflowRawLogLine, 'time' | 'result' | 'marker' | 'err'> & Required<Pick<WorkflowRawLogLine, 'msg'>>;
|
|
45
|
+
export type StepLogs = {
|
|
41
46
|
key: string;
|
|
42
47
|
label: string;
|
|
48
|
+
result?: string;
|
|
43
49
|
logLines: WorkflowLogLine[];
|
|
44
|
-
}
|
|
50
|
+
};
|
|
51
|
+
export type WorkflowLogs = Map<string, StepLogs>;
|
|
@@ -14,11 +14,14 @@ export declare function choicesFromWorkflowLogs(logs: WorkflowLogs): (Choice & {
|
|
|
14
14
|
logLines: WorkflowLogLine[] | undefined;
|
|
15
15
|
})[];
|
|
16
16
|
export declare function processWorkflowRuns(runs: WorkflowRunFragment[]): WorkflowRunResult[];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
type WorkflowRunWithJobs = WorkflowRunByIdWithJobsQuery['workflowRuns']['byId'];
|
|
18
|
+
type JobWithLogs = {
|
|
19
|
+
job: WorkflowRunWithJobs['jobs'][number];
|
|
20
|
+
logs: WorkflowLogs;
|
|
21
|
+
};
|
|
22
|
+
export declare function logsForFailedWorkflowRunAsync(graphqlClient: ExpoGraphqlClient, workflowRun: WorkflowRunWithJobs): Promise<JobWithLogs[]>;
|
|
23
|
+
export declare function formatActiveWorkflowRun(jobLogs: JobWithLogs[], maxLogLines?: number): string;
|
|
24
|
+
export declare function formatFailedWorkflowRun(jobLogs: JobWithLogs[], maxLogLines?: number): string;
|
|
22
25
|
export declare function fileExistsAsync(filePath: string): Promise<boolean>;
|
|
23
26
|
export declare function maybeReadStdinAsync(): Promise<string | null>;
|
|
24
27
|
export declare function showWorkflowStatusAsync(graphqlClient: ExpoGraphqlClient, { workflowRunId, spinnerUsesStdErr, waitForCompletion, }: {
|
|
@@ -31,3 +34,4 @@ export declare const workflowRunExitCodes: {
|
|
|
31
34
|
WORKFLOW_CANCELED: number;
|
|
32
35
|
WAIT_ABORTED: number;
|
|
33
36
|
};
|
|
37
|
+
export {};
|