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.
Files changed (126) hide show
  1. package/README.md +424 -226
  2. package/build/api.d.ts +1 -0
  3. package/build/api.js +12 -0
  4. package/build/build/utils/url.d.ts +1 -0
  5. package/build/build/utils/url.js +4 -0
  6. package/build/channel/protection.d.ts +4 -0
  7. package/build/channel/protection.js +49 -0
  8. package/build/channel/queries.d.ts +6 -0
  9. package/build/channel/queries.js +5 -1
  10. package/build/commandUtils/workflow/logs/fetchLogs.d.ts +5 -0
  11. package/build/commandUtils/workflow/logs/fetchLogs.js +24 -0
  12. package/build/commandUtils/workflow/logs/parseLogs.d.ts +14 -0
  13. package/build/commandUtils/workflow/logs/parseLogs.js +69 -0
  14. package/build/commandUtils/workflow/logs/watcher.d.ts +32 -0
  15. package/build/commandUtils/workflow/logs/watcher.js +162 -0
  16. package/build/commandUtils/workflow/stateMachine.js +2 -1
  17. package/build/commandUtils/workflow/types.d.ts +12 -5
  18. package/build/commandUtils/workflow/utils.d.ts +9 -5
  19. package/build/commandUtils/workflow/utils.js +144 -146
  20. package/build/commands/channel/protect.d.ts +16 -0
  21. package/build/commands/channel/protect.js +68 -0
  22. package/build/commands/channel/unprotect.d.ts +16 -0
  23. package/build/commands/channel/unprotect.js +78 -0
  24. package/build/commands/observe/errors.d.ts +27 -0
  25. package/build/commands/observe/errors.js +122 -0
  26. package/build/commands/observe/event.d.ts +18 -0
  27. package/build/commands/observe/event.js +149 -0
  28. package/build/commands/observe/events.d.ts +2 -0
  29. package/build/commands/observe/events.js +10 -4
  30. package/build/commands/observe/metrics-summary.d.ts +1 -0
  31. package/build/commands/observe/metrics-summary.js +3 -2
  32. package/build/commands/observe/metrics.d.ts +2 -0
  33. package/build/commands/observe/metrics.js +8 -4
  34. package/build/commands/observe/routes.d.ts +2 -1
  35. package/build/commands/observe/routes.js +5 -5
  36. package/build/commands/observe/session.d.ts +1 -0
  37. package/build/commands/observe/session.js +14 -8
  38. package/build/commands/observe/versions.d.ts +1 -0
  39. package/build/commands/observe/versions.js +3 -2
  40. package/build/commands/project/status.d.ts +16 -0
  41. package/build/commands/project/status.js +47 -0
  42. package/build/commands/simulator/get.js +5 -1
  43. package/build/commands/simulator/index.d.ts +1 -0
  44. package/build/commands/simulator/index.js +16 -2
  45. package/build/commands/simulator/list.d.ts +1 -0
  46. package/build/commands/simulator/list.js +9 -0
  47. package/build/commands/workflow/run.d.ts +8 -0
  48. package/build/commands/workflow/run.js +27 -0
  49. package/build/commands/workflow/ssh.d.ts +31 -0
  50. package/build/commands/workflow/ssh.js +190 -0
  51. package/build/credentials/ios/credentials.d.ts +5 -3
  52. package/build/credentials/ios/utils/printCredentials.js +6 -1
  53. package/build/graphql/generated.d.ts +2474 -1079
  54. package/build/graphql/generated.js +71 -16
  55. package/build/graphql/mutations/RealtimeLogsMutation.d.ts +6 -0
  56. package/build/graphql/mutations/RealtimeLogsMutation.js +40 -0
  57. package/build/graphql/mutations/WorkflowRunMutation.d.ts +3 -2
  58. package/build/graphql/mutations/WorkflowRunMutation.js +4 -1
  59. package/build/graphql/queries/AppStoreConnectApiKeyQuery.d.ts +1 -1
  60. package/build/graphql/queries/AppStoreConnectApiKeyQuery.js +1 -1
  61. package/build/graphql/queries/ChannelQuery.js +2 -0
  62. package/build/graphql/queries/DeviceRunSessionQuery.js +10 -0
  63. package/build/graphql/queries/ObserveQuery.d.ts +62 -30
  64. package/build/graphql/queries/ObserveQuery.js +276 -121
  65. package/build/graphql/queries/SubmissionQuery.d.ts +6 -1
  66. package/build/graphql/queries/SubmissionQuery.js +41 -0
  67. package/build/graphql/queries/WorkflowJobSshQuery.d.ts +20 -0
  68. package/build/graphql/queries/WorkflowJobSshQuery.js +133 -0
  69. package/build/graphql/types/Observe.d.ts +5 -3
  70. package/build/graphql/types/Observe.js +80 -21
  71. package/build/graphql/types/UpdateChannelBasicInfo.js +1 -0
  72. package/build/observe/fetchCustomEvents.d.ts +6 -4
  73. package/build/observe/fetchCustomEvents.js +4 -2
  74. package/build/observe/fetchErrors.d.ts +32 -0
  75. package/build/observe/fetchErrors.js +42 -0
  76. package/build/observe/fetchEvents.d.ts +9 -6
  77. package/build/observe/fetchEvents.js +16 -17
  78. package/build/observe/fetchMetrics.d.ts +2 -2
  79. package/build/observe/fetchMetrics.js +9 -9
  80. package/build/observe/fetchNavigationRoutes.d.ts +7 -5
  81. package/build/observe/fetchNavigationRoutes.js +8 -8
  82. package/build/observe/fetchSessions.d.ts +13 -11
  83. package/build/observe/fetchSessions.js +59 -30
  84. package/build/observe/fetchVersions.d.ts +4 -3
  85. package/build/observe/fetchVersions.js +7 -11
  86. package/build/observe/flags.d.ts +6 -0
  87. package/build/observe/flags.js +12 -2
  88. package/build/observe/formatCustomEvents.d.ts +16 -10
  89. package/build/observe/formatCustomEvents.js +61 -28
  90. package/build/observe/formatErrors.d.ts +97 -0
  91. package/build/observe/formatErrors.js +203 -0
  92. package/build/observe/formatEvents.d.ts +11 -5
  93. package/build/observe/formatEvents.js +46 -18
  94. package/build/observe/formatMetrics.d.ts +4 -4
  95. package/build/observe/formatMetrics.js +2 -2
  96. package/build/observe/formatNavigationRoutes.d.ts +4 -4
  97. package/build/observe/formatNavigationRoutes.js +3 -3
  98. package/build/observe/formatSessions.d.ts +3 -3
  99. package/build/observe/formatSessions.js +8 -8
  100. package/build/observe/formatVersions.js +2 -2
  101. package/build/observe/platforms.d.ts +10 -19
  102. package/build/observe/platforms.js +42 -40
  103. package/build/ora.d.ts +7 -0
  104. package/build/ora.js +12 -0
  105. package/build/project/projectStatus.d.ts +96 -0
  106. package/build/project/projectStatus.js +314 -0
  107. package/build/simulator/utils.d.ts +11 -0
  108. package/build/simulator/utils.js +51 -4
  109. package/build/submit/utils/urls.js +2 -3
  110. package/build/utils/centrifuge.d.ts +10 -0
  111. package/build/utils/centrifuge.js +89 -0
  112. package/build/utils/expodash/uniqBy.js +3 -2
  113. package/oclif.manifest.json +2947 -2328
  114. package/package.json +10 -7
  115. package/build/chat/chatClient.d.ts +0 -37
  116. package/build/chat/chatClient.js +0 -359
  117. package/build/chat/detectProject.d.ts +0 -5
  118. package/build/chat/detectProject.js +0 -41
  119. package/build/chat/renderMarkdown.d.ts +0 -7
  120. package/build/chat/renderMarkdown.js +0 -47
  121. package/build/chat/replInput.d.ts +0 -10
  122. package/build/chat/replInput.js +0 -52
  123. package/build/commandUtils/workflow/fetchLogs.d.ts +0 -6
  124. package/build/commandUtils/workflow/fetchLogs.js +0 -44
  125. package/build/commands/chat.d.ts +0 -18
  126. package/build/commands/chat.js +0 -221
@@ -1,52 +1,54 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.appPlatformToObservePlatform = exports.allowedPlatformFlagValues = void 0;
4
- exports.appObservePlatformFromFlag = appObservePlatformFromFlag;
5
- exports.appPlatformsFromFlag = appPlatformsFromFlag;
3
+ exports.observePlatformDisplayNames = exports.allowedPlatformFlagValues = exports.APPLE_PLATFORM_FLAG_VALUE = void 0;
4
+ exports.observePlatformsFromFlag = observePlatformsFromFlag;
5
+ exports.observePlatformTargetsFromFlag = observePlatformTargetsFromFlag;
6
6
  const generated_1 = require("../graphql/generated");
7
- /**
8
- * Allowed values for the --platform flag in observe commands.
9
- * Derived from the AppObservePlatform enum so new platforms added on
10
- * the server are automatically picked up.
11
- */
12
- exports.allowedPlatformFlagValues = Object.values(generated_1.AppObservePlatform).map(s => s.toLowerCase());
13
- const defaultAppObservePlatform = generated_1.AppObservePlatform.Ios;
14
- const defaultAppPlatform = generated_1.AppPlatform.Ios;
15
- /**
16
- * Resolve a single AppObservePlatform from a --platform flag value.
17
- * Returns undefined when no flag was provided.
18
- */
19
- function appObservePlatformFromFlag(flag) {
7
+ exports.APPLE_PLATFORM_FLAG_VALUE = 'apple';
8
+ const APPLE_OBSERVE_PLATFORMS = [
9
+ generated_1.AppObservePlatform.Ios,
10
+ generated_1.AppObservePlatform.Ipados,
11
+ generated_1.AppObservePlatform.Tvos,
12
+ generated_1.AppObservePlatform.Macos,
13
+ ];
14
+ exports.allowedPlatformFlagValues = [
15
+ ...Object.values(generated_1.AppObservePlatform).map(s => s.toLowerCase()),
16
+ exports.APPLE_PLATFORM_FLAG_VALUE,
17
+ ];
18
+ exports.observePlatformDisplayNames = {
19
+ [generated_1.AppObservePlatform.Android]: 'Android',
20
+ [generated_1.AppObservePlatform.Ios]: 'iOS',
21
+ [generated_1.AppObservePlatform.Ipados]: 'iPadOS',
22
+ [generated_1.AppObservePlatform.Tvos]: 'tvOS',
23
+ [generated_1.AppObservePlatform.Macos]: 'macOS',
24
+ APPLE: 'Apple',
25
+ };
26
+ function singlePlatformFromFlag(flag) {
27
+ const platform = Object.values(generated_1.AppObservePlatform).find(p => p.toLowerCase() === flag);
28
+ if (!platform) {
29
+ throw new Error(`Unknown platform flag value: "${flag}"`);
30
+ }
31
+ return platform;
32
+ }
33
+ function observePlatformsFromFlag(flag) {
20
34
  if (!flag) {
21
35
  return undefined;
22
36
  }
23
- switch (flag) {
24
- case 'android':
25
- return generated_1.AppObservePlatform.Android;
26
- case 'ios':
27
- return generated_1.AppObservePlatform.Ios;
37
+ if (flag === exports.APPLE_PLATFORM_FLAG_VALUE) {
38
+ return APPLE_OBSERVE_PLATFORMS;
28
39
  }
29
- return defaultAppObservePlatform;
40
+ return [singlePlatformFromFlag(flag)];
30
41
  }
31
- /**
32
- * Resolve a list of AppPlatform values from a --platform flag value.
33
- * Returns the single matching platform when a flag is provided, or all
34
- * known platforms when no flag is provided (so the caller queries every
35
- * platform).
36
- */
37
- function appPlatformsFromFlag(flag) {
42
+ function observePlatformTargetsFromFlag(flag) {
38
43
  if (!flag) {
39
- return [generated_1.AppPlatform.Android, generated_1.AppPlatform.Ios];
44
+ return [
45
+ { key: generated_1.AppObservePlatform.Android, platforms: [generated_1.AppObservePlatform.Android] },
46
+ { key: generated_1.AppObservePlatform.Ios, platforms: [generated_1.AppObservePlatform.Ios] },
47
+ ];
40
48
  }
41
- switch (flag) {
42
- case 'android':
43
- return [generated_1.AppPlatform.Android];
44
- case 'ios':
45
- return [generated_1.AppPlatform.Ios];
49
+ if (flag === exports.APPLE_PLATFORM_FLAG_VALUE) {
50
+ return [{ key: 'APPLE', platforms: APPLE_OBSERVE_PLATFORMS }];
46
51
  }
47
- return [defaultAppPlatform];
52
+ const platform = singlePlatformFromFlag(flag);
53
+ return [{ key: platform, platforms: [platform] }];
48
54
  }
49
- exports.appPlatformToObservePlatform = {
50
- [generated_1.AppPlatform.Android]: generated_1.AppObservePlatform.Android,
51
- [generated_1.AppPlatform.Ios]: generated_1.AppObservePlatform.Ios,
52
- };
package/build/ora.d.ts CHANGED
@@ -7,3 +7,10 @@ export { Ora, Options };
7
7
  * @returns
8
8
  */
9
9
  export declare function ora(options?: Options | string): Ora;
10
+ /**
11
+ * Updates the text of a spinner. Does nothing if new text is the same as old text to prevent flickering.
12
+ */
13
+ export declare function updateSpinnerText(spinner: Ora, { prefixText, text }: {
14
+ prefixText?: string;
15
+ text?: string;
16
+ }): void;
package/build/ora.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ora = ora;
4
+ exports.updateSpinnerText = updateSpinnerText;
4
5
  const tslib_1 = require("tslib");
5
6
  const getenv_1 = require("getenv");
6
7
  // eslint-disable-next-line
@@ -99,3 +100,14 @@ function ora(options) {
99
100
  };
100
101
  return spinner;
101
102
  }
103
+ /**
104
+ * Updates the text of a spinner. Does nothing if new text is the same as old text to prevent flickering.
105
+ */
106
+ function updateSpinnerText(spinner, { prefixText, text }) {
107
+ if (prefixText !== undefined && spinner.prefixText !== prefixText) {
108
+ spinner.prefixText = prefixText;
109
+ }
110
+ if (text !== undefined && spinner.text !== text) {
111
+ spinner.text = text;
112
+ }
113
+ }
@@ -0,0 +1,96 @@
1
+ import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
2
+ import { WorkflowRunResult } from '../commandUtils/workflow/types';
3
+ import { AppPlatform, BuildStatus, DistributionType, SubmissionAndroidReleaseStatus, SubmissionStatus } from '../graphql/generated';
4
+ export declare const PROJECT_STATUS_DEFAULT_LIMIT = 3;
5
+ export interface ProjectStatusSummary {
6
+ generatedAt: string;
7
+ limit: number;
8
+ hasMore: {
9
+ productionBuilds: boolean;
10
+ developmentBuilds: boolean;
11
+ workflowRuns: boolean;
12
+ submissions: boolean;
13
+ updates: boolean;
14
+ };
15
+ project: {
16
+ id: string;
17
+ name: string;
18
+ fullName: string;
19
+ slug: string;
20
+ account: string;
21
+ url: string;
22
+ };
23
+ productionBuilds: BuildStatusSummary[];
24
+ developmentBuilds: BuildStatusSummary[];
25
+ workflowRuns: WorkflowRunStatusSummary[];
26
+ submissions: SubmissionStatusSummary[];
27
+ updates: UpdateStatusSummary[];
28
+ }
29
+ interface ActivityErrorSummary {
30
+ code: string | null;
31
+ message: string | null;
32
+ }
33
+ interface BuildStatusSummary {
34
+ id: string;
35
+ platform: AppPlatform;
36
+ status: BuildStatus;
37
+ distribution: DistributionType | null;
38
+ buildProfile: string | null;
39
+ appVersion: string | null;
40
+ appBuildVersion: string | null;
41
+ runtimeVersion: string | null;
42
+ sdkVersion: string | null;
43
+ channel: string | null;
44
+ gitCommitHash: string | null;
45
+ gitCommitMessage: string | null;
46
+ message: string | null;
47
+ initiatingActor: string | null;
48
+ createdAt: string;
49
+ completedAt: string | null;
50
+ url: string;
51
+ error: (ActivityErrorSummary & {
52
+ docsUrl: string | null;
53
+ }) | null;
54
+ }
55
+ interface SubmissionStatusSummary {
56
+ id: string;
57
+ platform: AppPlatform;
58
+ status: SubmissionStatus;
59
+ appIdentifier: string | null;
60
+ androidTrack: string | null;
61
+ androidReleaseStatus: SubmissionAndroidReleaseStatus | null;
62
+ rollout: number | null;
63
+ buildId: string | null;
64
+ initiatingActor: string | null;
65
+ createdAt: string;
66
+ completedAt: string | null;
67
+ url: string;
68
+ error: ActivityErrorSummary | null;
69
+ }
70
+ interface WorkflowRunStatusSummary extends WorkflowRunResult {
71
+ errors: {
72
+ title: string | null;
73
+ message: string;
74
+ }[];
75
+ url: string;
76
+ }
77
+ interface UpdateStatusSummary {
78
+ group: string;
79
+ branch: string;
80
+ message: string | null;
81
+ runtimeVersion: string;
82
+ platforms: string[];
83
+ isRollBackToEmbedded: boolean;
84
+ gitCommitHash: string | null;
85
+ rolloutPercentage: number | null;
86
+ environment: unknown | null;
87
+ initiatingActor: string | null;
88
+ createdAt: string;
89
+ url: string;
90
+ }
91
+ export declare function getProjectStatusAsync(graphqlClient: ExpoGraphqlClient, { projectId, limit }: {
92
+ projectId: string;
93
+ limit: number;
94
+ }): Promise<ProjectStatusSummary>;
95
+ export declare function printProjectStatusAsText(status: ProjectStatusSummary): void;
96
+ export {};
@@ -0,0 +1,314 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PROJECT_STATUS_DEFAULT_LIMIT = void 0;
4
+ exports.getProjectStatusAsync = getProjectStatusAsync;
5
+ exports.printProjectStatusAsText = printProjectStatusAsText;
6
+ const tslib_1 = require("tslib");
7
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
+ const url_1 = require("../build/utils/url");
9
+ const utils_1 = require("../commandUtils/workflow/utils");
10
+ const generated_1 = require("../graphql/generated");
11
+ const AppQuery_1 = require("../graphql/queries/AppQuery");
12
+ const BuildQuery_1 = require("../graphql/queries/BuildQuery");
13
+ const SubmissionQuery_1 = require("../graphql/queries/SubmissionQuery");
14
+ const UpdateQuery_1 = require("../graphql/queries/UpdateQuery");
15
+ const log_1 = tslib_1.__importDefault(require("../log"));
16
+ const platform_1 = require("../platform");
17
+ const User_1 = require("../user/User");
18
+ const date_1 = require("../utils/date");
19
+ exports.PROJECT_STATUS_DEFAULT_LIMIT = 3;
20
+ async function getProjectStatusAsync(graphqlClient, { projectId, limit }) {
21
+ const queryLimitForHasMore = limit + 1;
22
+ const [app, productionBuilds, developmentBuilds, workflowRuns, submissions, updateGroups] = await Promise.all([
23
+ AppQuery_1.AppQuery.byIdAsync(graphqlClient, projectId),
24
+ BuildQuery_1.BuildQuery.viewBuildsOnAppAsync(graphqlClient, {
25
+ appId: projectId,
26
+ limit: queryLimitForHasMore,
27
+ offset: 0,
28
+ filter: { developmentClient: false, distribution: generated_1.DistributionType.Store },
29
+ }),
30
+ BuildQuery_1.BuildQuery.viewBuildsOnAppAsync(graphqlClient, {
31
+ appId: projectId,
32
+ limit: queryLimitForHasMore,
33
+ offset: 0,
34
+ filter: { developmentClient: true },
35
+ }),
36
+ AppQuery_1.AppQuery.byIdWorkflowRunsFilteredByStatusAsync(graphqlClient, projectId, undefined, queryLimitForHasMore),
37
+ SubmissionQuery_1.SubmissionQuery.forProjectStatusAsync(graphqlClient, projectId, {
38
+ limit: queryLimitForHasMore,
39
+ offset: 0,
40
+ }),
41
+ UpdateQuery_1.UpdateQuery.viewUpdateGroupsOnAppAsync(graphqlClient, {
42
+ appId: projectId,
43
+ limit: queryLimitForHasMore,
44
+ offset: 0,
45
+ }),
46
+ ]);
47
+ const accountName = app.ownerAccount.name;
48
+ const projectName = app.slug;
49
+ const limitedWorkflowRuns = workflowRuns.slice(0, limit);
50
+ return {
51
+ generatedAt: new Date().toISOString(),
52
+ limit,
53
+ hasMore: {
54
+ productionBuilds: productionBuilds.length > limit,
55
+ developmentBuilds: developmentBuilds.length > limit,
56
+ workflowRuns: workflowRuns.length > limit,
57
+ submissions: submissions.length > limit,
58
+ updates: updateGroups.length > limit,
59
+ },
60
+ project: {
61
+ id: app.id,
62
+ name: app.name,
63
+ fullName: app.fullName,
64
+ slug: app.slug,
65
+ account: accountName,
66
+ url: (0, url_1.getProjectDashboardUrl)(accountName, projectName),
67
+ },
68
+ productionBuilds: productionBuilds.slice(0, limit).map(toBuildSummary),
69
+ developmentBuilds: developmentBuilds.slice(0, limit).map(toBuildSummary),
70
+ workflowRuns: (0, utils_1.processWorkflowRuns)(limitedWorkflowRuns).map((run, index) => ({
71
+ ...run,
72
+ errors: limitedWorkflowRuns[index].errors.map(error => ({
73
+ title: error.title ?? null,
74
+ message: error.message,
75
+ })),
76
+ url: (0, url_1.getWorkflowRunUrl)(accountName, projectName, run.id),
77
+ })),
78
+ submissions: submissions
79
+ .slice(0, limit)
80
+ .map(submission => toSubmissionSummary(submission, accountName, projectName)),
81
+ updates: updateGroups
82
+ .slice(0, limit)
83
+ .map(updateGroup => toUpdateSummary(updateGroup, accountName, projectName)),
84
+ };
85
+ }
86
+ function toBuildSummary(build) {
87
+ return {
88
+ id: build.id,
89
+ platform: build.platform,
90
+ status: build.status,
91
+ distribution: build.distribution ?? null,
92
+ buildProfile: build.buildProfile ?? null,
93
+ appVersion: build.appVersion ?? null,
94
+ appBuildVersion: build.appBuildVersion ?? null,
95
+ runtimeVersion: build.runtime?.version ?? null,
96
+ sdkVersion: build.sdkVersion ?? null,
97
+ channel: build.updateChannel?.name ?? null,
98
+ gitCommitHash: build.gitCommitHash ?? null,
99
+ gitCommitMessage: build.gitCommitMessage?.split('\n')[0] ?? null,
100
+ message: build.message ?? null,
101
+ initiatingActor: build.initiatingActor?.displayName ?? null,
102
+ createdAt: build.createdAt,
103
+ completedAt: build.completedAt ?? null,
104
+ url: (0, url_1.getBuildLogsUrl)(build),
105
+ error: build.error
106
+ ? {
107
+ code: build.error.errorCode,
108
+ message: build.error.message,
109
+ docsUrl: build.error.docsUrl ?? null,
110
+ }
111
+ : null,
112
+ };
113
+ }
114
+ function toSubmissionSummary(submission, accountName, projectName) {
115
+ return {
116
+ id: submission.id,
117
+ platform: submission.platform,
118
+ status: submission.status,
119
+ appIdentifier: submission.androidConfig?.applicationIdentifier ??
120
+ submission.iosConfig?.ascAppIdentifier ??
121
+ null,
122
+ androidTrack: submission.androidConfig?.track ?? null,
123
+ androidReleaseStatus: submission.androidConfig?.releaseStatus ?? null,
124
+ rollout: submission.androidConfig?.rollout ?? null,
125
+ buildId: submission.submittedBuild?.id ?? null,
126
+ initiatingActor: submission.initiatingActor?.displayName ?? null,
127
+ createdAt: submission.createdAt,
128
+ completedAt: submission.completedAt ?? null,
129
+ url: (0, url_1.getSubmissionUrl)(accountName, projectName, submission.id),
130
+ error: submission.error
131
+ ? {
132
+ code: submission.error.errorCode ?? null,
133
+ message: submission.error.message ?? null,
134
+ }
135
+ : null,
136
+ };
137
+ }
138
+ function toUpdateSummary(updateGroup, accountName, projectName) {
139
+ const representativeUpdate = updateGroup[0];
140
+ const platforms = [...new Set(updateGroup.map(update => update.platform))].sort();
141
+ return {
142
+ group: representativeUpdate.group,
143
+ branch: representativeUpdate.branch.name,
144
+ message: representativeUpdate.message ?? null,
145
+ runtimeVersion: representativeUpdate.runtime.version,
146
+ platforms,
147
+ isRollBackToEmbedded: representativeUpdate.isRollBackToEmbedded,
148
+ gitCommitHash: representativeUpdate.gitCommitHash ?? null,
149
+ rolloutPercentage: representativeUpdate.rolloutPercentage ?? null,
150
+ environment: representativeUpdate.environment ?? null,
151
+ initiatingActor: representativeUpdate.actor
152
+ ? (0, User_1.getActorDisplayName)(representativeUpdate.actor)
153
+ : null,
154
+ createdAt: representativeUpdate.createdAt,
155
+ url: (0, url_1.getUpdateGroupUrl)(accountName, projectName, representativeUpdate.group),
156
+ };
157
+ }
158
+ function printProjectStatusAsText(status) {
159
+ log_1.default.addNewLineIfNone();
160
+ log_1.default.log(chalk_1.default.bold(status.project.fullName));
161
+ log_1.default.log(chalk_1.default.dim(status.project.url));
162
+ renderSection('Production builds', status.productionBuilds, renderBuild, status.hasMore.productionBuilds);
163
+ renderSection('Development builds', status.developmentBuilds, renderBuild, status.hasMore.developmentBuilds);
164
+ renderSection('Workflow runs', status.workflowRuns, renderWorkflowRun, status.hasMore.workflowRuns);
165
+ renderSection('Submissions', status.submissions, renderSubmission, status.hasMore.submissions);
166
+ renderSection('Updates', status.updates, renderUpdate, status.hasMore.updates);
167
+ }
168
+ function renderSection(title, items, renderItem, hasMore) {
169
+ log_1.default.newLine();
170
+ log_1.default.log(chalk_1.default.bold(title));
171
+ if (items.length === 0) {
172
+ log_1.default.log(chalk_1.default.dim(' None'));
173
+ return;
174
+ }
175
+ for (const item of items) {
176
+ log_1.default.log(renderItem(item));
177
+ }
178
+ if (hasMore) {
179
+ log_1.default.log(chalk_1.default.dim(' More available; use --limit to show more.'));
180
+ }
181
+ }
182
+ function renderBuild(build) {
183
+ const lines = [
184
+ ` ${joinMeta([
185
+ colorBuildStatus(build.status),
186
+ platform_1.appPlatformDisplayNames[build.platform],
187
+ build.buildProfile,
188
+ timeAgo(build.createdAt),
189
+ ])}`,
190
+ ];
191
+ const version = build.appVersion
192
+ ? `${build.appVersion}${build.appBuildVersion ? ` (${build.appBuildVersion})` : ''}`
193
+ : null;
194
+ if (version) {
195
+ lines.push(` ${chalk_1.default.dim('version')} ${version}`);
196
+ }
197
+ if (build.gitCommitMessage) {
198
+ lines.push(` ${chalk_1.default.dim(shortHash(build.gitCommitHash))} ${build.gitCommitMessage}`);
199
+ }
200
+ if (build.error?.message) {
201
+ lines.push(` ${chalk_1.default.red(build.error.message)}`);
202
+ }
203
+ lines.push(` ${chalk_1.default.dim(build.url)}`);
204
+ return lines.join('\n');
205
+ }
206
+ function renderWorkflowRun(run) {
207
+ const lines = [
208
+ ` ${joinMeta([
209
+ colorWorkflowStatus(run.status),
210
+ run.workflowName ?? run.workflowFileName,
211
+ timeAgo(run.startedAt),
212
+ ])}`,
213
+ ];
214
+ if (run.gitCommitMessage) {
215
+ lines.push(` ${chalk_1.default.dim(shortHash(run.gitCommitHash))} ${run.gitCommitMessage}`);
216
+ }
217
+ for (const error of run.errors) {
218
+ lines.push(` ${chalk_1.default.red(error.message)}`);
219
+ }
220
+ lines.push(` ${chalk_1.default.dim(run.url)}`);
221
+ return lines.join('\n');
222
+ }
223
+ function renderSubmission(submission) {
224
+ const lines = [
225
+ ` ${joinMeta([
226
+ colorSubmissionStatus(submission.status),
227
+ platform_1.appPlatformDisplayNames[submission.platform],
228
+ submission.androidTrack ? `track: ${submission.androidTrack}` : null,
229
+ timeAgo(submission.createdAt),
230
+ ])}`,
231
+ ];
232
+ if (submission.buildId) {
233
+ lines.push(` ${chalk_1.default.dim('build')} ${submission.buildId}`);
234
+ }
235
+ if (submission.error?.message) {
236
+ lines.push(` ${chalk_1.default.red(submission.error.message)}`);
237
+ }
238
+ lines.push(` ${chalk_1.default.dim(submission.url)}`);
239
+ return lines.join('\n');
240
+ }
241
+ function renderUpdate(update) {
242
+ const lines = [
243
+ ` ${joinMeta([
244
+ chalk_1.default.cyan(update.branch),
245
+ update.platforms.join(', '),
246
+ `runtime: ${update.runtimeVersion}`,
247
+ timeAgo(update.createdAt),
248
+ ])}`,
249
+ ];
250
+ const message = update.isRollBackToEmbedded ? 'Roll back to embedded' : update.message;
251
+ if (message) {
252
+ lines.push(` ${chalk_1.default.dim(shortHash(update.gitCommitHash))} ${message}`);
253
+ }
254
+ lines.push(` ${chalk_1.default.dim(update.url)}`);
255
+ return lines.join('\n');
256
+ }
257
+ function joinMeta(parts) {
258
+ return parts.filter((part) => Boolean(part)).join(chalk_1.default.dim(' · '));
259
+ }
260
+ function timeAgo(isoDate) {
261
+ if (!isoDate) {
262
+ return null;
263
+ }
264
+ return `${(0, date_1.fromNow)(new Date(isoDate))} ago`;
265
+ }
266
+ function shortHash(hash) {
267
+ return hash ? hash.slice(0, 7) : '-------';
268
+ }
269
+ function colorBuildStatus(status) {
270
+ switch (status) {
271
+ case generated_1.BuildStatus.Finished:
272
+ return chalk_1.default.green('finished');
273
+ case generated_1.BuildStatus.Errored:
274
+ return chalk_1.default.red('errored');
275
+ case generated_1.BuildStatus.Canceled:
276
+ case generated_1.BuildStatus.PendingCancel:
277
+ return chalk_1.default.gray('canceled');
278
+ case generated_1.BuildStatus.New:
279
+ case generated_1.BuildStatus.InQueue:
280
+ case generated_1.BuildStatus.InProgress:
281
+ return chalk_1.default.blue(status.toLowerCase().replace(/_/g, ' '));
282
+ default:
283
+ return String(status).toLowerCase().replace(/_/g, ' ');
284
+ }
285
+ }
286
+ function colorSubmissionStatus(status) {
287
+ switch (status) {
288
+ case generated_1.SubmissionStatus.Finished:
289
+ return chalk_1.default.green('finished');
290
+ case generated_1.SubmissionStatus.Errored:
291
+ return chalk_1.default.red('errored');
292
+ case generated_1.SubmissionStatus.Canceled:
293
+ return chalk_1.default.gray('canceled');
294
+ default:
295
+ return chalk_1.default.blue(status.toLowerCase().replace(/_/g, ' '));
296
+ }
297
+ }
298
+ function colorWorkflowStatus(status) {
299
+ switch (status) {
300
+ case generated_1.WorkflowRunStatus.Success:
301
+ return chalk_1.default.green('success');
302
+ case generated_1.WorkflowRunStatus.Failure:
303
+ return chalk_1.default.red('failure');
304
+ case generated_1.WorkflowRunStatus.Canceled:
305
+ return chalk_1.default.gray('canceled');
306
+ case generated_1.WorkflowRunStatus.ActionRequired:
307
+ return chalk_1.default.yellow('action required');
308
+ case generated_1.WorkflowRunStatus.New:
309
+ case generated_1.WorkflowRunStatus.InProgress:
310
+ return chalk_1.default.blue(status.toLowerCase().replace(/_/g, ' '));
311
+ default:
312
+ return status.toLowerCase().replace(/_/g, ' ');
313
+ }
314
+ }
@@ -15,5 +15,16 @@ export declare const DEVICE_RUN_SESSION_RESOURCE_CLASS_FLAG_VALUES: Record<Devic
15
15
  export declare const DEVICE_RUN_SESSION_RESOURCE_CLASS_BY_FLAG_VALUE: Record<string, DeviceRunSessionResourceClass>;
16
16
  export declare function getRemoteSessionEnvironmentVariables(remoteConfig: DeviceRunSessionRemoteConfig): Record<string, string>;
17
17
  type RemoteSessionInstructionsConfigType = 'env' | 'dotenv';
18
+ /**
19
+ * Preview link for a session. A gated serve-sim needs the session token, and a browser cannot send
20
+ * a header on a page load, so it rides the query. serve-sim swaps it for a cookie on the first load.
21
+ */
22
+ export declare function formatPreviewUrl(url: string, token: string | null | undefined): string;
23
+ /**
24
+ * Remote config for `--json`. The preview URL carries the token and the standalone token field is
25
+ * dropped, so a consumer gets one URL that works rather than a bare URL that 401s next to a secret
26
+ * it has to know to combine.
27
+ */
28
+ export declare function sanitizeRemoteConfigForJson(remoteConfig: DeviceRunSessionRemoteConfig): DeviceRunSessionRemoteConfig;
18
29
  export declare function formatRemoteSessionInstructions(remoteConfig: DeviceRunSessionRemoteConfig, configType: RemoteSessionInstructionsConfigType): string;
19
30
  export {};
@@ -4,6 +4,8 @@ exports.DEVICE_RUN_SESSION_RESOURCE_CLASS_BY_FLAG_VALUE = exports.DEVICE_RUN_SES
4
4
  exports.formatSimulatorUnavailableMessage = formatSimulatorUnavailableMessage;
5
5
  exports.deviceRunSessionTypeToFlagValue = deviceRunSessionTypeToFlagValue;
6
6
  exports.getRemoteSessionEnvironmentVariables = getRemoteSessionEnvironmentVariables;
7
+ exports.formatPreviewUrl = formatPreviewUrl;
8
+ exports.sanitizeRemoteConfigForJson = sanitizeRemoteConfigForJson;
7
9
  exports.formatRemoteSessionInstructions = formatRemoteSessionInstructions;
8
10
  const generated_1 = require("../graphql/generated");
9
11
  const log_1 = require("../log");
@@ -26,6 +28,7 @@ exports.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES = {
26
28
  [generated_1.DeviceRunSessionType.Appium]: 'appium',
27
29
  [generated_1.DeviceRunSessionType.Argent]: 'argent',
28
30
  [generated_1.DeviceRunSessionType.ServeSim]: 'web-preview-only',
31
+ [generated_1.DeviceRunSessionType.WebPreviewOnly]: 'web-preview-only',
29
32
  };
30
33
  exports.DEVICE_RUN_SESSION_TYPE_BY_FLAG_VALUE = Object.fromEntries(Object.entries(exports.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES).map(([type, value]) => [value, type]));
31
34
  function deviceRunSessionTypeToFlagValue(type) {
@@ -54,9 +57,47 @@ function getRemoteSessionEnvironmentVariables(remoteConfig) {
54
57
  APPIUM_CAPS: JSON.stringify(remoteConfig.capabilities),
55
58
  };
56
59
  case 'ServeSimRunSessionRemoteConfig':
60
+ case 'WebPreviewOnlyRunSessionRemoteConfig':
57
61
  return {};
58
62
  }
59
63
  }
64
+ /**
65
+ * Preview link for a session. A gated serve-sim needs the session token, and a browser cannot send
66
+ * a header on a page load, so it rides the query. serve-sim swaps it for a cookie on the first load.
67
+ */
68
+ function formatPreviewUrl(url, token) {
69
+ if (!token) {
70
+ return url;
71
+ }
72
+ const withToken = new URL(url);
73
+ withToken.searchParams.set('token', token);
74
+ return withToken.toString();
75
+ }
76
+ /**
77
+ * Remote config for `--json`. The preview URL carries the token and the standalone token field is
78
+ * dropped, so a consumer gets one URL that works rather than a bare URL that 401s next to a secret
79
+ * it has to know to combine.
80
+ */
81
+ function sanitizeRemoteConfigForJson(remoteConfig) {
82
+ switch (remoteConfig.__typename) {
83
+ case 'ServeSimRunSessionRemoteConfig':
84
+ case 'WebPreviewOnlyRunSessionRemoteConfig': {
85
+ const { previewToken, ...rest } = remoteConfig;
86
+ return { ...rest, previewUrl: formatPreviewUrl(remoteConfig.previewUrl, previewToken) };
87
+ }
88
+ case 'AgentDeviceRunSessionRemoteConfig':
89
+ case 'ArgentRunSessionRemoteConfig':
90
+ case 'AppiumRunSessionRemoteConfig': {
91
+ const { webPreviewToken, ...rest } = remoteConfig;
92
+ return {
93
+ ...rest,
94
+ webPreviewUrl: remoteConfig.webPreviewUrl
95
+ ? formatPreviewUrl(remoteConfig.webPreviewUrl, webPreviewToken)
96
+ : remoteConfig.webPreviewUrl,
97
+ };
98
+ }
99
+ }
100
+ }
60
101
  function formatRemoteSessionInstructions(remoteConfig, configType) {
61
102
  switch (remoteConfig.__typename) {
62
103
  case 'AgentDeviceRunSessionRemoteConfig': {
@@ -73,7 +114,7 @@ function formatRemoteSessionInstructions(remoteConfig, configType) {
73
114
  ...Object.entries(environmentVariables).map(([key, value]) => `export ${key}='${value}'`),
74
115
  ];
75
116
  if (remoteConfig.webPreviewUrl) {
76
- lines.push('', '🌐 Open the following URL in your browser to preview the simulator:', '', remoteConfig.webPreviewUrl);
117
+ lines.push('', '🌐 Open the following URL in your browser to preview the simulator:', '', formatPreviewUrl(remoteConfig.webPreviewUrl, remoteConfig.webPreviewToken));
77
118
  }
78
119
  return lines.join('\n');
79
120
  }
@@ -103,7 +144,7 @@ function formatRemoteSessionInstructions(remoteConfig, configType) {
103
144
  ...Object.entries(environmentVariables).map(([key, value]) => `export ${key}='${value}'`),
104
145
  ];
105
146
  if (remoteConfig.webPreviewUrl) {
106
- lines.push('', '🌐 Open the following URL in your browser to preview the simulator:', '', remoteConfig.webPreviewUrl);
147
+ lines.push('', '🌐 Open the following URL in your browser to preview the simulator:', '', formatPreviewUrl(remoteConfig.webPreviewUrl, remoteConfig.webPreviewToken));
107
148
  }
108
149
  return lines.join('\n');
109
150
  }
@@ -123,7 +164,7 @@ function formatRemoteSessionInstructions(remoteConfig, configType) {
123
164
  '<appium-client> [args...]',
124
165
  ];
125
166
  if (remoteConfig.webPreviewUrl) {
126
- lines.push('', 'Open the iOS simulator preview:', '', remoteConfig.webPreviewUrl);
167
+ lines.push('', 'Open the simulator preview:', '', formatPreviewUrl(remoteConfig.webPreviewUrl, remoteConfig.webPreviewToken));
127
168
  }
128
169
  return lines.join('\n');
129
170
  }
@@ -131,7 +172,13 @@ function formatRemoteSessionInstructions(remoteConfig, configType) {
131
172
  return [
132
173
  '🌐 Open the following URL in your browser to access the simulator:',
133
174
  '',
134
- remoteConfig.previewUrl,
175
+ formatPreviewUrl(remoteConfig.previewUrl, remoteConfig.previewToken),
176
+ ].join('\n');
177
+ case 'WebPreviewOnlyRunSessionRemoteConfig':
178
+ return [
179
+ '🌐 Open the following URL in your browser to access the simulator:',
180
+ '',
181
+ formatPreviewUrl(remoteConfig.previewUrl, remoteConfig.previewToken),
135
182
  ].join('\n');
136
183
  }
137
184
  }
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.printSubmissionDetailsUrls = printSubmissionDetailsUrls;
4
4
  exports.getSubmissionDetailsUrl = getSubmissionDetailsUrl;
5
5
  const tslib_1 = require("tslib");
6
- const url_1 = require("url");
7
- const api_1 = require("../../api");
6
+ const url_1 = require("../../build/utils/url");
8
7
  const log_1 = tslib_1.__importStar(require("../../log"));
9
8
  const platform_1 = require("../../platform");
10
9
  function printSubmissionDetailsUrls(submissions) {
@@ -20,5 +19,5 @@ function printSubmissionDetailsUrls(submissions) {
20
19
  }
21
20
  function getSubmissionDetailsUrl(submission) {
22
21
  const { id, app } = submission;
23
- return new url_1.URL(`/accounts/${app.ownerAccount.name}/projects/${app.slug}/submissions/${id}`, (0, api_1.getExpoWebsiteBaseUrl)()).toString();
22
+ return (0, url_1.getSubmissionUrl)(app.ownerAccount.name, app.slug, id);
24
23
  }