eas-cli 2.1.0 → 2.2.1

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 (300) hide show
  1. package/README.md +179 -133
  2. package/build/branch/queries.d.ts +10 -2
  3. package/build/branch/queries.js +30 -30
  4. package/build/branch/utils.d.ts +4 -0
  5. package/build/branch/utils.js +15 -0
  6. package/build/build/android/build.js +3 -3
  7. package/build/build/android/prepareJob.js +1 -2
  8. package/build/build/android/syncProjectConfiguration.d.ts +2 -1
  9. package/build/build/android/syncProjectConfiguration.js +2 -2
  10. package/build/build/build.js +15 -4
  11. package/build/build/configure.js +2 -2
  12. package/build/build/createContext.d.ts +5 -1
  13. package/build/build/createContext.js +8 -14
  14. package/build/build/ios/build.js +2 -1
  15. package/build/build/ios/credentials.js +1 -1
  16. package/build/build/ios/prepareJob.js +1 -2
  17. package/build/build/ios/syncProjectConfiguration.d.ts +2 -1
  18. package/build/build/ios/syncProjectConfiguration.js +2 -2
  19. package/build/build/local.js +1 -1
  20. package/build/build/metadata.js +1 -2
  21. package/build/build/queries.d.ts +9 -0
  22. package/build/build/queries.js +51 -0
  23. package/build/build/runBuildAndSubmit.d.ts +3 -1
  24. package/build/build/runBuildAndSubmit.js +15 -7
  25. package/build/build/utils/repository.js +5 -1
  26. package/build/channel/queries.d.ts +17 -0
  27. package/build/channel/queries.js +137 -0
  28. package/build/channel/utils.d.ts +22 -0
  29. package/build/channel/utils.js +87 -0
  30. package/build/commandUtils/EasCommand.d.ts +68 -7
  31. package/build/commandUtils/EasCommand.js +60 -79
  32. package/build/commandUtils/context/ActorContextField.d.ts +5 -0
  33. package/build/commandUtils/context/ActorContextField.js +11 -0
  34. package/build/commandUtils/context/ContextField.d.ts +6 -0
  35. package/build/commandUtils/context/ContextField.js +5 -0
  36. package/build/commandUtils/context/DynamicProjectConfigContextField.d.ts +11 -0
  37. package/build/commandUtils/context/DynamicProjectConfigContextField.js +27 -0
  38. package/build/commandUtils/context/OptionalProjectConfigContextField.d.ts +13 -0
  39. package/build/commandUtils/context/OptionalProjectConfigContextField.js +37 -0
  40. package/build/commandUtils/context/ProjectConfigContextField.d.ts +13 -0
  41. package/build/commandUtils/context/ProjectConfigContextField.js +23 -0
  42. package/build/commandUtils/context/ProjectDirContextField.d.ts +4 -0
  43. package/build/commandUtils/context/ProjectDirContextField.js +11 -0
  44. package/build/commandUtils/context/contextUtils/ensureLoggedInAsync.d.ts +21 -0
  45. package/build/commandUtils/context/contextUtils/ensureLoggedInAsync.js +75 -0
  46. package/build/commandUtils/context/contextUtils/findProjectDirAndVerifyProjectSetupAsync.d.ts +17 -0
  47. package/build/commandUtils/context/contextUtils/findProjectDirAndVerifyProjectSetupAsync.js +102 -0
  48. package/build/commandUtils/context/contextUtils/getProjectIdAsync.d.ts +24 -0
  49. package/build/commandUtils/context/contextUtils/getProjectIdAsync.js +108 -0
  50. package/build/commandUtils/flags.d.ts +10 -0
  51. package/build/commandUtils/flags.js +23 -0
  52. package/build/commandUtils/pagination.d.ts +7 -4
  53. package/build/commandUtils/pagination.js +11 -15
  54. package/build/commands/account/login.d.ts +0 -2
  55. package/build/commands/account/login.js +2 -7
  56. package/build/commands/account/logout.d.ts +0 -2
  57. package/build/commands/account/logout.js +0 -5
  58. package/build/commands/account/view.d.ts +0 -2
  59. package/build/commands/account/view.js +0 -5
  60. package/build/commands/analytics.d.ts +0 -1
  61. package/build/commands/analytics.js +0 -4
  62. package/build/commands/branch/create.d.ts +4 -0
  63. package/build/commands/branch/create.js +18 -18
  64. package/build/commands/branch/delete.d.ts +4 -0
  65. package/build/commands/branch/delete.js +29 -26
  66. package/build/commands/branch/list.d.ts +5 -2
  67. package/build/commands/branch/list.js +13 -8
  68. package/build/commands/branch/rename.d.ts +5 -1
  69. package/build/commands/branch/rename.js +15 -13
  70. package/build/commands/branch/view.d.ts +5 -2
  71. package/build/commands/branch/view.js +31 -13
  72. package/build/commands/build/cancel.d.ts +7 -0
  73. package/build/commands/build/cancel.js +50 -23
  74. package/build/commands/build/configure.d.ts +3 -0
  75. package/build/commands/build/configure.js +12 -7
  76. package/build/commands/build/index.d.ts +7 -2
  77. package/build/commands/build/index.js +31 -23
  78. package/build/commands/build/inspect.d.ts +5 -0
  79. package/build/commands/build/inspect.js +12 -3
  80. package/build/commands/build/list.d.ts +7 -2
  81. package/build/commands/build/list.js +36 -59
  82. package/build/commands/build/version/set.d.ts +5 -0
  83. package/build/commands/build/version/set.js +22 -14
  84. package/build/commands/build/version/sync.d.ts +5 -0
  85. package/build/commands/build/version/sync.js +22 -13
  86. package/build/commands/build/view.d.ts +3 -0
  87. package/build/commands/build/view.js +20 -14
  88. package/build/commands/channel/create.d.ts +4 -0
  89. package/build/commands/channel/create.js +32 -25
  90. package/build/commands/channel/delete.d.ts +3 -0
  91. package/build/commands/channel/delete.js +36 -59
  92. package/build/commands/channel/edit.d.ts +7 -7
  93. package/build/commands/channel/edit.js +39 -72
  94. package/build/commands/channel/list.d.ts +6 -0
  95. package/build/commands/channel/list.js +20 -76
  96. package/build/commands/channel/rollout.d.ts +5 -1
  97. package/build/commands/channel/rollout.js +34 -35
  98. package/build/commands/channel/view.d.ts +6 -33
  99. package/build/commands/channel/view.js +31 -132
  100. package/build/commands/config.d.ts +6 -2
  101. package/build/commands/config.js +22 -13
  102. package/build/commands/credentials.d.ts +4 -0
  103. package/build/commands/credentials.js +10 -1
  104. package/build/commands/device/create.d.ts +4 -0
  105. package/build/commands/device/create.js +15 -3
  106. package/build/commands/device/delete.d.ts +13 -8
  107. package/build/commands/device/delete.js +81 -130
  108. package/build/commands/device/list.d.ts +7 -0
  109. package/build/commands/device/list.js +42 -63
  110. package/build/commands/device/view.d.ts +3 -0
  111. package/build/commands/device/view.js +10 -5
  112. package/build/commands/diagnostics.d.ts +3 -1
  113. package/build/commands/diagnostics.js +10 -8
  114. package/build/commands/metadata/pull.d.ts +4 -0
  115. package/build/commands/metadata/pull.js +13 -8
  116. package/build/commands/metadata/push.d.ts +4 -0
  117. package/build/commands/metadata/push.js +13 -8
  118. package/build/commands/open.d.ts +3 -0
  119. package/build/commands/open.js +11 -9
  120. package/build/commands/project/info.d.ts +3 -0
  121. package/build/commands/project/info.js +9 -6
  122. package/build/commands/project/init.d.ts +12 -0
  123. package/build/commands/project/init.js +155 -8
  124. package/build/commands/secret/create.d.ts +6 -0
  125. package/build/commands/secret/create.js +88 -30
  126. package/build/commands/secret/delete.d.ts +4 -0
  127. package/build/commands/secret/delete.js +28 -19
  128. package/build/commands/secret/list.d.ts +3 -0
  129. package/build/commands/secret/list.js +19 -13
  130. package/build/commands/submit.d.ts +5 -0
  131. package/build/commands/submit.js +16 -7
  132. package/build/commands/update/configure.d.ts +3 -0
  133. package/build/commands/update/configure.js +22 -16
  134. package/build/commands/update/delete.d.ts +1 -0
  135. package/build/commands/update/delete.js +4 -7
  136. package/build/commands/update/index.d.ts +8 -12
  137. package/build/commands/update/index.js +90 -166
  138. package/build/commands/update/list.d.ts +8 -2
  139. package/build/commands/update/list.js +51 -81
  140. package/build/commands/update/view.d.ts +0 -4
  141. package/build/commands/update/view.js +14 -51
  142. package/build/commands/webhook/create.d.ts +4 -0
  143. package/build/commands/webhook/create.js +10 -5
  144. package/build/commands/webhook/delete.d.ts +6 -0
  145. package/build/commands/webhook/delete.js +26 -14
  146. package/build/commands/webhook/list.d.ts +3 -0
  147. package/build/commands/webhook/list.js +13 -9
  148. package/build/commands/webhook/update.d.ts +1 -0
  149. package/build/commands/webhook/update.js +3 -1
  150. package/build/credentials/android/actions/BuildCredentialsUtils.js +2 -6
  151. package/build/credentials/android/actions/CreateFcm.d.ts +2 -3
  152. package/build/credentials/android/actions/CreateGoogleServiceAccountKey.d.ts +2 -3
  153. package/build/credentials/android/actions/CreateKeystore.d.ts +2 -3
  154. package/build/credentials/android/actions/CreateKeystore.js +1 -2
  155. package/build/credentials/android/actions/RemoveGoogleServiceAccountKey.d.ts +2 -3
  156. package/build/credentials/android/actions/UseExistingGoogleServiceAccountKey.d.ts +2 -3
  157. package/build/credentials/android/api/GraphqlClient.d.ts +6 -7
  158. package/build/credentials/context.d.ts +8 -4
  159. package/build/credentials/context.js +8 -23
  160. package/build/credentials/ios/IosCredentialsProvider.js +11 -6
  161. package/build/credentials/ios/actions/AppleTeamFormatting.d.ts +2 -0
  162. package/build/credentials/ios/actions/AppleTeamFormatting.js +7 -0
  163. package/build/credentials/ios/actions/AppleTeamUtils.d.ts +1 -2
  164. package/build/credentials/ios/actions/AppleTeamUtils.js +1 -5
  165. package/build/credentials/ios/actions/AscApiKeyUtils.d.ts +3 -4
  166. package/build/credentials/ios/actions/AscApiKeyUtils.js +2 -2
  167. package/build/credentials/ios/actions/AssignAscApiKey.d.ts +1 -1
  168. package/build/credentials/ios/actions/AssignPushKey.d.ts +1 -1
  169. package/build/credentials/ios/actions/BuildCredentialsUtils.d.ts +3 -3
  170. package/build/credentials/ios/actions/BuildCredentialsUtils.js +8 -12
  171. package/build/credentials/ios/actions/ConfigureProvisioningProfile.d.ts +1 -1
  172. package/build/credentials/ios/actions/ConfigureProvisioningProfile.js +1 -1
  173. package/build/credentials/ios/actions/CreateAscApiKey.d.ts +2 -3
  174. package/build/credentials/ios/actions/CreateDistributionCertificate.d.ts +2 -2
  175. package/build/credentials/ios/actions/CreateProvisioningProfile.d.ts +1 -1
  176. package/build/credentials/ios/actions/CreatePushKey.d.ts +2 -3
  177. package/build/credentials/ios/actions/DeviceUtils.d.ts +0 -1
  178. package/build/credentials/ios/actions/DeviceUtils.js +3 -19
  179. package/build/credentials/ios/actions/DistributionCertificateUtils.d.ts +3 -4
  180. package/build/credentials/ios/actions/DistributionCertificateUtils.js +2 -2
  181. package/build/credentials/ios/actions/ProvisioningProfileUtils.js +1 -1
  182. package/build/credentials/ios/actions/PushKeyUtils.d.ts +2 -3
  183. package/build/credentials/ios/actions/PushKeyUtils.js +2 -2
  184. package/build/credentials/ios/actions/RemoveAscApiKey.d.ts +2 -3
  185. package/build/credentials/ios/actions/RemoveDistributionCertificate.d.ts +3 -4
  186. package/build/credentials/ios/actions/RemoveProvisioningProfile.d.ts +1 -1
  187. package/build/credentials/ios/actions/RemovePushKey.d.ts +2 -3
  188. package/build/credentials/ios/actions/SetUpAdhocProvisioningProfile.d.ts +1 -1
  189. package/build/credentials/ios/actions/SetUpAdhocProvisioningProfile.js +1 -1
  190. package/build/credentials/ios/actions/SetUpAscApiKey.d.ts +1 -1
  191. package/build/credentials/ios/actions/SetUpDistributionCertificate.d.ts +1 -1
  192. package/build/credentials/ios/actions/SetUpInternalProvisioningProfile.d.ts +1 -1
  193. package/build/credentials/ios/actions/SetUpProvisioningProfile.d.ts +1 -1
  194. package/build/credentials/ios/actions/SetUpProvisioningProfile.js +1 -1
  195. package/build/credentials/ios/actions/SetUpPushKey.d.ts +1 -1
  196. package/build/credentials/ios/actions/SetUpSubmissionCredentials.d.ts +1 -1
  197. package/build/credentials/ios/actions/SetUpTargetBuildCredentials.d.ts +1 -1
  198. package/build/credentials/ios/actions/SetUpTargetBuildCredentialsFromCredentialsJson.d.ts +1 -1
  199. package/build/credentials/ios/api/GraphqlClient.d.ts +9 -15
  200. package/build/credentials/ios/api/graphql/mutations/AppleTeamMutation.d.ts +2 -3
  201. package/build/credentials/ios/api/graphql/mutations/AppleTeamMutation.js +3 -1
  202. package/build/credentials/ios/api/graphql/queries/AppleDeviceQuery.d.ts +3 -3
  203. package/build/credentials/ios/api/graphql/queries/AppleDeviceQuery.js +20 -6
  204. package/build/credentials/ios/api/graphql/queries/AppleTeamQuery.d.ts +2 -2
  205. package/build/credentials/ios/api/graphql/queries/AppleTeamQuery.js +8 -7
  206. package/build/credentials/ios/api/graphql/types/AppLookupParams.d.ts +7 -0
  207. package/build/credentials/ios/api/graphql/types/AppLookupParams.js +2 -0
  208. package/build/credentials/ios/types.d.ts +2 -3
  209. package/build/credentials/ios/utils/printCredentials.d.ts +1 -1
  210. package/build/credentials/ios/validators/validateProvisioningProfile.d.ts +1 -1
  211. package/build/credentials/ios/validators/validateProvisioningProfile.js +1 -1
  212. package/build/credentials/manager/HelperActions.d.ts +4 -1
  213. package/build/credentials/manager/ManageAndroid.js +4 -14
  214. package/build/credentials/manager/ManageIos.js +12 -15
  215. package/build/credentials/manager/SelectBuildProfileFromEasJson.d.ts +1 -1
  216. package/build/credentials/manager/SelectBuildProfileFromEasJson.js +3 -3
  217. package/build/credentials/manager/SelectPlatform.d.ts +5 -1
  218. package/build/credentials/manager/SelectPlatform.js +5 -3
  219. package/build/devices/actions/create/action.d.ts +2 -3
  220. package/build/devices/context.d.ts +3 -5
  221. package/build/devices/context.js +2 -11
  222. package/build/devices/manager.d.ts +4 -5
  223. package/build/devices/manager.js +9 -16
  224. package/build/devices/queries.d.ts +21 -0
  225. package/build/devices/queries.js +121 -0
  226. package/build/devices/utils/errors.d.ts +3 -0
  227. package/build/devices/utils/errors.js +9 -0
  228. package/build/devices/utils/formatDevice.d.ts +3 -3
  229. package/build/devices/utils/formatDevice.js +8 -3
  230. package/build/graphql/generated.d.ts +1101 -191
  231. package/build/graphql/generated.js +13 -2
  232. package/build/graphql/mutations/EnvironmentSecretMutation.d.ts +3 -1
  233. package/build/graphql/queries/AppQuery.d.ts +1 -0
  234. package/build/graphql/queries/AppQuery.js +19 -0
  235. package/build/graphql/queries/BranchQuery.d.ts +5 -6
  236. package/build/graphql/queries/BranchQuery.js +44 -3
  237. package/build/graphql/queries/BuildQuery.d.ts +2 -20
  238. package/build/graphql/queries/BuildQuery.js +2 -2
  239. package/build/graphql/queries/ChannelQuery.d.ts +5 -2
  240. package/build/graphql/queries/ChannelQuery.js +45 -19
  241. package/build/graphql/queries/EnvironmentSecretsQuery.d.ts +5 -3
  242. package/build/graphql/queries/EnvironmentSecretsQuery.js +14 -28
  243. package/build/graphql/queries/UpdateQuery.d.ts +4 -6
  244. package/build/graphql/queries/UpdateQuery.js +59 -50
  245. package/build/graphql/queries/UserQuery.js +8 -1
  246. package/build/graphql/types/Account.d.ts +1 -0
  247. package/build/graphql/types/Account.js +17 -0
  248. package/build/graphql/types/App.js +7 -0
  249. package/build/graphql/types/EnvironmentSecret.d.ts +7 -0
  250. package/build/graphql/types/EnvironmentSecret.js +16 -1
  251. package/build/graphql/types/Update.d.ts +1 -0
  252. package/build/graphql/types/Update.js +30 -0
  253. package/build/graphql/types/UpdateBranch.js +4 -15
  254. package/build/metadata/context.d.ts +1 -1
  255. package/build/metadata/context.js +7 -9
  256. package/build/project/android/applicationId.d.ts +2 -1
  257. package/build/project/android/applicationId.js +7 -7
  258. package/build/project/android/versions.js +1 -1
  259. package/build/project/applicationIdentifier.d.ts +2 -1
  260. package/build/project/applicationIdentifier.js +2 -2
  261. package/build/project/expoConfig.d.ts +3 -3
  262. package/build/project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync.d.ts +22 -0
  263. package/build/project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync.js +93 -0
  264. package/build/project/ios/bundleIdentifier.d.ts +2 -1
  265. package/build/project/ios/bundleIdentifier.js +7 -7
  266. package/build/project/ios/scheme.d.ts +1 -1
  267. package/build/project/ios/target.d.ts +17 -2
  268. package/build/project/ios/target.js +51 -4
  269. package/build/project/projectUtils.d.ts +4 -31
  270. package/build/project/projectUtils.js +13 -123
  271. package/build/project/remoteVersionSource.d.ts +2 -2
  272. package/build/project/remoteVersionSource.js +8 -7
  273. package/build/submit/android/ServiceAccountSource.js +1 -2
  274. package/build/submit/context.d.ts +3 -1
  275. package/build/submit/context.js +12 -14
  276. package/build/submit/ios/CredentialsServiceSource.js +1 -2
  277. package/build/submit/utils/builds.js +3 -1
  278. package/build/update/android/UpdatesModule.d.ts +1 -1
  279. package/build/update/android/UpdatesModule.js +2 -3
  280. package/build/update/ios/UpdatesModule.d.ts +1 -1
  281. package/build/update/ios/UpdatesModule.js +2 -3
  282. package/build/update/queries.d.ts +16 -1
  283. package/build/update/queries.js +96 -30
  284. package/build/update/utils.d.ts +21 -8
  285. package/build/update/utils.js +75 -14
  286. package/build/user/actions.d.ts +2 -8
  287. package/build/user/actions.js +4 -63
  288. package/build/utils/profiles.d.ts +3 -3
  289. package/build/utils/profiles.js +6 -5
  290. package/build/vcs/clients/git.d.ts +1 -1
  291. package/build/vcs/clients/git.js +1 -1
  292. package/build/vcs/vcs.d.ts +1 -1
  293. package/build/webhooks/input.d.ts +2 -1
  294. package/build/webhooks/input.js +10 -1
  295. package/oclif.manifest.json +1 -1
  296. package/package.json +4 -4
  297. package/build/project/ensureProjectExists.d.ts +0 -21
  298. package/build/project/ensureProjectExists.js +0 -88
  299. package/build/user/Account.d.ts +0 -3
  300. package/build/user/Account.js +0 -7
@@ -1,20 +1,16 @@
1
1
  import EasCommand from '../../commandUtils/EasCommand';
2
- import { ViewBranchUpdatesQuery } from '../../graphql/generated';
2
+ import { ViewBranchQueryVariables } from '../../graphql/generated';
3
3
  import { PublishPlatform } from '../../project/publish';
4
4
  export declare const defaultPublishPlatforms: PublishPlatform[];
5
5
  export declare type PublishPlatformFlag = PublishPlatform | 'all';
6
- export declare function ensureBranchExistsAsync({ appId, name: branchName, limit, offset, }: {
7
- appId: string;
8
- name: string;
9
- limit: number;
10
- offset: number;
11
- }): Promise<{
12
- id: string;
13
- updates: Exclude<Exclude<ViewBranchUpdatesQuery['app'], null | undefined>['byId']['updateBranchByName'], null | undefined>['updates'];
6
+ export declare function ensureBranchExistsAsync({ appId, name: branchName, }: ViewBranchQueryVariables): Promise<{
7
+ branchId: string;
14
8
  }>;
15
9
  export default class UpdatePublish extends EasCommand {
16
10
  static description: string;
17
11
  static flags: {
12
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
18
14
  branch: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
19
15
  message: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
20
16
  republish: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
@@ -22,12 +18,12 @@ export default class UpdatePublish extends EasCommand {
22
18
  'input-dir': import("@oclif/core/lib/interfaces").OptionFlag<string>;
23
19
  'skip-bundler': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
24
20
  platform: import("@oclif/core/lib/interfaces").OptionFlag<string>;
25
- json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
26
21
  auto: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
27
22
  'private-key-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
28
- 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
23
+ };
24
+ static contextDefinition: {
25
+ getDynamicProjectConfigAsync: import("../../commandUtils/context/DynamicProjectConfigContextField").DynamicProjectConfigContextField;
29
26
  };
30
27
  runAsync(): Promise<void>;
31
28
  }
32
- export declare function getUpdatesToRepublishInteractiveAsync(projectId: string, branchName: string, platformFlag: string, pageSize: number, offset?: number, cumulativeUpdates?: Exclude<Exclude<ViewBranchUpdatesQuery['app'], null | undefined>['byId']['updateBranchByName'], null | undefined>['updates']): Promise<Exclude<Exclude<ViewBranchUpdatesQuery['app'], null | undefined>['byId']['updateBranchByName'], null | undefined>['updates']>;
33
29
  export declare const truncatePublishUpdateMessage: (originalMessage: string) => string;
@@ -1,36 +1,35 @@
1
1
  "use strict";
2
+ var _a;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.truncatePublishUpdateMessage = exports.getUpdatesToRepublishInteractiveAsync = exports.ensureBranchExistsAsync = exports.defaultPublishPlatforms = void 0;
4
+ exports.truncatePublishUpdateMessage = exports.ensureBranchExistsAsync = exports.defaultPublishPlatforms = void 0;
4
5
  const tslib_1 = require("tslib");
5
6
  const config_plugins_1 = require("@expo/config-plugins");
6
7
  const eas_build_job_1 = require("@expo/eas-build-job");
7
8
  const core_1 = require("@oclif/core");
8
9
  const assert_1 = tslib_1.__importDefault(require("assert"));
9
10
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
10
- const dateformat_1 = tslib_1.__importDefault(require("dateformat"));
11
- const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
12
11
  const nullthrows_1 = tslib_1.__importDefault(require("nullthrows"));
13
12
  const api_1 = require("../../api");
14
13
  const queries_1 = require("../../branch/queries");
14
+ const utils_1 = require("../../branch/utils");
15
15
  const url_1 = require("../../build/utils/url");
16
16
  const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
17
+ const flags_1 = require("../../commandUtils/flags");
18
+ const pagination_1 = require("../../commandUtils/pagination");
17
19
  const fetch_1 = tslib_1.__importDefault(require("../../fetch"));
18
- const client_1 = require("../../graphql/client");
19
20
  const generated_1 = require("../../graphql/generated");
20
21
  const PublishMutation_1 = require("../../graphql/mutations/PublishMutation");
21
22
  const BranchQuery_1 = require("../../graphql/queries/BranchQuery");
22
23
  const UpdateQuery_1 = require("../../graphql/queries/UpdateQuery");
23
24
  const log_1 = tslib_1.__importStar(require("../../log"));
24
25
  const ora_1 = require("../../ora");
25
- const expoConfig_1 = require("../../project/expoConfig");
26
26
  const projectUtils_1 = require("../../project/projectUtils");
27
27
  const publish_1 = require("../../project/publish");
28
28
  const workflow_1 = require("../../project/workflow");
29
29
  const prompts_1 = require("../../prompts");
30
- const utils_1 = require("../../update/utils");
31
- const actions_1 = require("../../user/actions");
30
+ const queries_2 = require("../../update/queries");
31
+ const utils_2 = require("../../update/utils");
32
32
  const code_signing_1 = require("../../utils/code-signing");
33
- const uniqBy_1 = tslib_1.__importDefault(require("../../utils/expodash/uniqBy"));
34
33
  const formatFields_1 = tslib_1.__importDefault(require("../../utils/formatFields"));
35
34
  const json_1 = require("../../utils/json");
36
35
  const statuspageService_1 = require("../../utils/statuspageService");
@@ -38,27 +37,8 @@ const vcs_1 = require("../../vcs");
38
37
  const create_1 = require("../branch/create");
39
38
  const create_2 = require("../channel/create");
40
39
  exports.defaultPublishPlatforms = ['android', 'ios'];
41
- async function getUpdateGroupAsync({ group, }) {
42
- const { updatesByGroup } = await (0, client_1.withErrorHandlingAsync)(client_1.graphqlClient
43
- .query((0, graphql_tag_1.default) `
44
- query getUpdateGroupAsync($group: ID!) {
45
- updatesByGroup(group: $group) {
46
- id
47
- group
48
- runtimeVersion
49
- manifestFragment
50
- platform
51
- message
52
- }
53
- }
54
- `, {
55
- group,
56
- }, { additionalTypenames: ['Update'] })
57
- .toPromise());
58
- return updatesByGroup;
59
- }
60
40
  async function ensureChannelExistsAsync({ appId, branchId, channelName, }) {
61
- var _a;
41
+ var _b;
62
42
  try {
63
43
  await (0, create_2.createUpdateChannelOnAppAsync)({
64
44
  appId,
@@ -68,47 +48,59 @@ async function ensureChannelExistsAsync({ appId, branchId, channelName, }) {
68
48
  log_1.default.withTick(`Created a channel: ${chalk_1.default.bold(channelName)} pointed at branch: ${chalk_1.default.bold(channelName)}.`);
69
49
  }
70
50
  catch (e) {
71
- const isIgnorableError = ((_a = e.graphQLErrors) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
51
+ const isIgnorableError = ((_b = e.graphQLErrors) === null || _b === void 0 ? void 0 : _b.length) === 1 &&
72
52
  e.graphQLErrors[0].extensions.errorCode === 'CHANNEL_ALREADY_EXISTS';
73
53
  if (!isIgnorableError) {
74
54
  throw e;
75
55
  }
76
56
  }
77
57
  }
78
- async function ensureBranchExistsAsync({ appId, name: branchName, limit, offset, }) {
79
- const { app } = await UpdateQuery_1.UpdateQuery.viewBranchAsync({
80
- appId,
81
- name: branchName,
82
- limit,
83
- offset,
84
- });
85
- const updateBranch = app === null || app === void 0 ? void 0 : app.byId.updateBranchByName;
86
- if (updateBranch) {
87
- const { id, updates } = updateBranch;
58
+ async function ensureBranchExistsAsync({ appId, name: branchName, }) {
59
+ try {
60
+ const updateBranch = await BranchQuery_1.BranchQuery.getBranchByNameAsync({
61
+ appId,
62
+ name: branchName,
63
+ });
64
+ const { id } = updateBranch;
88
65
  await ensureChannelExistsAsync({ appId, branchId: id, channelName: branchName });
89
- return { id, updates };
66
+ return { branchId: id };
67
+ }
68
+ catch (error) {
69
+ if (error instanceof utils_1.BranchNotFoundError) {
70
+ const newUpdateBranch = await (0, create_1.createUpdateBranchOnAppAsync)({ appId, name: branchName });
71
+ log_1.default.withTick(`Created branch: ${chalk_1.default.bold(branchName)}`);
72
+ await ensureChannelExistsAsync({
73
+ appId,
74
+ branchId: newUpdateBranch.id,
75
+ channelName: branchName,
76
+ });
77
+ return { branchId: newUpdateBranch.id };
78
+ }
79
+ else {
80
+ throw error;
81
+ }
90
82
  }
91
- const newUpdateBranch = await (0, create_1.createUpdateBranchOnAppAsync)({ appId, name: branchName });
92
- log_1.default.withTick(`Created branch: ${chalk_1.default.bold(branchName)}`);
93
- await ensureChannelExistsAsync({ appId, branchId: newUpdateBranch.id, channelName: branchName });
94
- return { id: newUpdateBranch.id, updates: [] };
95
83
  }
96
84
  exports.ensureBranchExistsAsync = ensureBranchExistsAsync;
97
85
  class UpdatePublish extends EasCommand_1.default {
98
86
  async runAsync() {
99
- var _a, _b, _c;
100
- let { flags: { branch: branchName, json: jsonFlag, auto: autoFlag, message, republish, group, 'input-dir': inputDir, 'skip-bundler': skipBundler, platform, 'private-key-path': privateKeyPath, 'non-interactive': nonInteractive, }, } = await this.parse(UpdatePublish);
87
+ var _b, _c, _d;
88
+ const { flags } = await this.parse(UpdatePublish);
89
+ const paginatedQueryOptions = (0, pagination_1.getPaginatedQueryOptions)(flags);
90
+ let { branch: branchName, auto: autoFlag, message, republish, group, 'input-dir': inputDir, 'skip-bundler': skipBundler, platform, 'private-key-path': privateKeyPath, 'non-interactive': nonInteractive, json: jsonFlag, } = flags;
91
+ const { getDynamicProjectConfigAsync } = await this.getContextAsync(UpdatePublish, {
92
+ nonInteractive,
93
+ });
101
94
  if (jsonFlag) {
102
95
  (0, json_1.enableJsonOutput)();
103
96
  }
104
97
  const platformFlag = platform;
105
98
  // If a group was specified, that means we are republishing it.
106
- republish = group ? true : republish;
107
- const projectDir = await (0, projectUtils_1.findProjectRootAsync)();
108
- const exp = (0, expoConfig_1.getExpoConfig)(projectDir, {
99
+ republish = republish || !!group;
100
+ const { exp, projectId, projectDir } = await getDynamicProjectConfigAsync({
109
101
  isPublicConfig: true,
110
102
  });
111
- const expPrivate = (0, expoConfig_1.getExpoConfig)(projectDir, {
103
+ const { exp: expPrivate } = await getDynamicProjectConfigAsync({
112
104
  isPublicConfig: false,
113
105
  });
114
106
  await (0, statuspageService_1.maybeWarnAboutEasOutagesAsync)([generated_1.StatuspageServiceName.EasUpdate]);
@@ -132,45 +124,36 @@ class UpdatePublish extends EasCommand_1.default {
132
124
  }
133
125
  }
134
126
  const runtimeVersions = await getRuntimeVersionObjectAsync(exp, platformFlag, projectDir);
135
- const projectId = await (0, projectUtils_1.getProjectIdAsync)(exp);
136
- await checkEASUpdateURLIsSetAsync(exp);
137
- if (!branchName && autoFlag) {
138
- branchName =
139
- (await (0, vcs_1.getVcsClient)().getBranchNameAsync()) ||
140
- `branch-${Math.random().toString(36).substr(2, 4)}`;
141
- }
127
+ await checkEASUpdateURLIsSetAsync(exp, projectId);
142
128
  if (!branchName) {
143
- if (nonInteractive) {
144
- throw new Error('Must supply --branch or use --auto when in non-interactive mode');
129
+ if (autoFlag) {
130
+ branchName = await (0, utils_1.getDefaultBranchNameAsync)();
145
131
  }
146
- const validationMessage = 'Branch name may not be empty.';
147
- if (jsonFlag) {
148
- throw new Error(validationMessage);
149
- }
150
- const branches = await BranchQuery_1.BranchQuery.listBranchesAsync({
151
- appId: projectId,
152
- limit: queries_1.BRANCHES_LIMIT,
153
- offset: 0,
154
- });
155
- if (branches.length === 0) {
156
- ({ name: branchName } = await (0, prompts_1.promptAsync)({
157
- type: 'text',
158
- name: 'name',
159
- message: 'No branches found. Provide a branch name:',
160
- initial: (await (0, vcs_1.getVcsClient)().getBranchNameAsync()) ||
161
- `branch-${Math.random().toString(36).substr(2, 4)}`,
162
- validate: value => (value ? true : validationMessage),
163
- }));
132
+ else if (nonInteractive) {
133
+ throw new Error('Must supply --branch or use --auto when in non-interactive mode');
164
134
  }
165
135
  else {
166
- branchName = await (0, prompts_1.selectAsync)('Which branch would you like to publish on?', branches.map(branch => {
167
- return {
168
- title: `${branch.name} ${chalk_1.default.grey(`- current update: ${(0, utils_1.formatUpdate)(branch.updates[0])}`)}`,
169
- value: branch.name,
170
- };
171
- }));
136
+ try {
137
+ const branch = await (0, queries_1.selectBranchOnAppAsync)({
138
+ projectId,
139
+ promptTitle: `Which branch would you like to ${republish ? 'republish' : 'publish'} on?`,
140
+ displayTextForListItem: updateBranch => `${updateBranch.name} ${chalk_1.default.grey(`- current update: ${(0, utils_2.formatUpdateMessage)(updateBranch.updates[0])}`)}`,
141
+ paginatedQueryOptions,
142
+ });
143
+ branchName = branch.name;
144
+ }
145
+ catch {
146
+ // unable to select a branch (network error or no branches for project)
147
+ ({ name: branchName } = await (0, prompts_1.promptAsync)({
148
+ type: 'text',
149
+ name: 'name',
150
+ message: 'No branches found. Provide a branch name:',
151
+ initial: await (0, utils_1.getDefaultBranchNameAsync)(),
152
+ validate: value => (value ? true : 'Branch name may not be empty.'),
153
+ }));
154
+ }
155
+ (0, assert_1.default)(branchName, 'Branch name must be specified.');
172
156
  }
173
- (0, assert_1.default)(branchName, 'Branch name must be specified.');
174
157
  }
175
158
  let unsortedUpdateInfoGroups = {};
176
159
  let oldMessage, oldRuntimeVersion;
@@ -181,17 +164,18 @@ class UpdatePublish extends EasCommand_1.default {
181
164
  // Instead we get the `updateInfoGroup` from the update we wish to republish.
182
165
  let updatesToRepublish;
183
166
  if (group) {
184
- updatesToRepublish = await getUpdateGroupAsync({ group });
167
+ const updatesByGroup = await UpdateQuery_1.UpdateQuery.viewUpdateGroupAsync({ groupId: group });
168
+ updatesToRepublish = updatesByGroup;
185
169
  }
186
170
  else {
187
171
  if (nonInteractive) {
188
172
  throw new Error('Must supply --group when in non-interactive mode');
189
173
  }
190
- // Drop into interactive mode if the user has not specified an update group to republish.
191
- if (jsonFlag) {
192
- throw new Error('You must specify the update group to republish.');
193
- }
194
- updatesToRepublish = await getUpdatesToRepublishInteractiveAsync(projectId, branchName, platformFlag, 50);
174
+ updatesToRepublish = await (0, queries_2.selectUpdateGroupOnBranchAsync)({
175
+ projectId,
176
+ branchName,
177
+ paginatedQueryOptions,
178
+ });
195
179
  }
196
180
  const updatesToRepublishFilteredByPlatform = updatesToRepublish.filter(
197
181
  // Only republish to the specified platforms
@@ -219,7 +203,7 @@ class UpdatePublish extends EasCommand_1.default {
219
203
  }
220
204
  // These are the same for each member of an update group
221
205
  group = updatesToRepublishFilteredByPlatform[0].group;
222
- oldMessage = (_a = updatesToRepublishFilteredByPlatform[0].message) !== null && _a !== void 0 ? _a : '';
206
+ oldMessage = (_b = updatesToRepublishFilteredByPlatform[0].message) !== null && _b !== void 0 ? _b : '';
223
207
  oldRuntimeVersion = updatesToRepublishFilteredByPlatform[0].runtimeVersion;
224
208
  if (!message) {
225
209
  if (nonInteractive) {
@@ -240,7 +224,7 @@ class UpdatePublish extends EasCommand_1.default {
240
224
  }
241
225
  else {
242
226
  if (!message && autoFlag) {
243
- message = (_b = (await (0, vcs_1.getVcsClient)().getLastCommitMessageAsync())) === null || _b === void 0 ? void 0 : _b.trim();
227
+ message = (_c = (await (0, vcs_1.getVcsClient)().getLastCommitMessageAsync())) === null || _c === void 0 ? void 0 : _c.trim();
244
228
  }
245
229
  if (!message) {
246
230
  if (nonInteractive) {
@@ -254,7 +238,7 @@ class UpdatePublish extends EasCommand_1.default {
254
238
  type: 'text',
255
239
  name: 'publishMessage',
256
240
  message: `Provide an update message.`,
257
- initial: (_c = (await (0, vcs_1.getVcsClient)().getLastCommitMessageAsync())) === null || _c === void 0 ? void 0 : _c.trim(),
241
+ initial: (_d = (await (0, vcs_1.getVcsClient)().getLastCommitMessageAsync())) === null || _d === void 0 ? void 0 : _d.trim(),
258
242
  validate: (value) => (value ? true : validationMessage),
259
243
  }));
260
244
  }
@@ -297,11 +281,9 @@ class UpdatePublish extends EasCommand_1.default {
297
281
  .filter(pair => pair[1] === runtime)
298
282
  .map(pair => pair[0]);
299
283
  }
300
- const { id: branchId } = await ensureBranchExistsAsync({
284
+ const { branchId } = await ensureBranchExistsAsync({
301
285
  appId: projectId,
302
286
  name: branchName,
303
- limit: 0,
304
- offset: 0,
305
287
  });
306
288
  // Sort the updates into different groups based on their platform specific runtime versions
307
289
  const updateGroups = Object.entries(runtimeToPlatformMapping).map(([runtime, platforms]) => {
@@ -354,7 +336,7 @@ class UpdatePublish extends EasCommand_1.default {
354
336
  publishSpinner.succeed('Published!');
355
337
  }
356
338
  catch (e) {
357
- publishSpinner.fail('Failed to published updates');
339
+ publishSpinner.fail('Failed to publish updates');
358
340
  throw e;
359
341
  }
360
342
  if (jsonFlag) {
@@ -376,7 +358,7 @@ class UpdatePublish extends EasCommand_1.default {
376
358
  const newIosUpdate = newUpdatesForRuntimeVersion.find(update => update.platform === 'ios');
377
359
  const updateGroupId = newUpdatesForRuntimeVersion[0].group;
378
360
  const projectName = exp.slug;
379
- const accountName = (0, projectUtils_1.getProjectAccountName)(exp, await (0, actions_1.ensureLoggedInAsync)());
361
+ const accountName = (await (0, projectUtils_1.getOwnerAccountForProjectIdAsync)(projectId)).name;
380
362
  const updateGroupUrl = (0, url_1.getUpdateGroupUrl)(accountName, projectName, updateGroupId);
381
363
  const updateGroupLink = (0, log_1.link)(updateGroupUrl, { dim: false });
382
364
  log_1.default.log((0, formatFields_1.default)([
@@ -405,6 +387,7 @@ class UpdatePublish extends EasCommand_1.default {
405
387
  }
406
388
  }
407
389
  exports.default = UpdatePublish;
390
+ _a = UpdatePublish;
408
391
  UpdatePublish.description = 'publish an update group';
409
392
  UpdatePublish.flags = {
410
393
  branch: core_1.Flags.string({
@@ -438,10 +421,6 @@ UpdatePublish.flags = {
438
421
  default: 'all',
439
422
  required: false,
440
423
  }),
441
- json: core_1.Flags.boolean({
442
- description: 'Enable JSON output, non-JSON messages will be printed to stderr',
443
- default: false,
444
- }),
445
424
  auto: core_1.Flags.boolean({
446
425
  description: 'Use the current git branch and commit message for the EAS branch and update message',
447
426
  default: false,
@@ -450,52 +429,16 @@ UpdatePublish.flags = {
450
429
  description: `File containing the PEM-encoded private key corresponding to the certificate in expo-updates' configuration. Defaults to a file named "private-key.pem" in the certificate's directory.`,
451
430
  required: false,
452
431
  }),
453
- 'non-interactive': core_1.Flags.boolean({
454
- default: false,
455
- description: 'Run command in non-interactive mode',
456
- }),
432
+ ...flags_1.EasNonInteractiveAndJsonFlags,
433
+ };
434
+ UpdatePublish.contextDefinition = {
435
+ ..._a.ContextOptions.DynamicProjectConfig,
457
436
  };
458
- async function getUpdatesToRepublishInteractiveAsync(projectId, branchName, platformFlag, pageSize, offset = 0, cumulativeUpdates = []) {
459
- const fetchMoreValue = '_fetchMore';
460
- const { updates } = await ensureBranchExistsAsync({
461
- appId: projectId,
462
- name: branchName,
463
- limit: pageSize + 1,
464
- offset,
465
- });
466
- cumulativeUpdates = [
467
- ...cumulativeUpdates,
468
- // drop that extra item used for pagination from our render logic
469
- ...updates.slice(0, updates.length - 1),
470
- ];
471
- const cumulativeUpdatesForTargetPlatforms = platformFlag === 'all'
472
- ? cumulativeUpdates
473
- : cumulativeUpdates.filter(update => {
474
- // Only show groups that have updates on the specified platform(s).
475
- return update.platform === platformFlag;
476
- });
477
- const updateGroups = (0, uniqBy_1.default)(cumulativeUpdatesForTargetPlatforms, u => u.group).map(update => ({
478
- title: formatUpdateTitle(update),
479
- value: update.group,
480
- }));
481
- if (updateGroups.length === 0) {
482
- throw new Error(`There are no updates on branch "${branchName}" published for the platform(s) ${platformFlag}. Did you mean to publish a new update instead?`);
483
- }
484
- if (updates.length > pageSize) {
485
- updateGroups.push({ title: 'Next page...', value: fetchMoreValue });
486
- }
487
- const selectedUpdateGroup = await (0, prompts_1.selectAsync)('Which update would you like to republish?', updateGroups);
488
- if (selectedUpdateGroup === fetchMoreValue) {
489
- return await getUpdatesToRepublishInteractiveAsync(projectId, branchName, platformFlag, pageSize, offset + pageSize, cumulativeUpdates);
490
- }
491
- return cumulativeUpdates.filter(update => update.group === selectedUpdateGroup);
492
- }
493
- exports.getUpdatesToRepublishInteractiveAsync = getUpdatesToRepublishInteractiveAsync;
494
437
  async function getRuntimeVersionObjectAsync(exp, platformFlag, projectDir) {
495
- var _a, _b;
438
+ var _b, _c;
496
439
  const platforms = (platformFlag === 'all' ? ['android', 'ios'] : [platformFlag]);
497
440
  for (const platform of platforms) {
498
- const isPolicy = typeof ((_b = (_a = exp[platform]) === null || _a === void 0 ? void 0 : _a.runtimeVersion) !== null && _b !== void 0 ? _b : exp.runtimeVersion) === 'object';
441
+ const isPolicy = typeof ((_c = (_b = exp[platform]) === null || _b === void 0 ? void 0 : _b.runtimeVersion) !== null && _c !== void 0 ? _c : exp.runtimeVersion) === 'object';
499
442
  if (isPolicy) {
500
443
  const isManaged = (await (0, workflow_1.resolveWorkflowAsync)(projectDir, platform)) === eas_build_job_1.Workflow.MANAGED;
501
444
  if (!isManaged) {
@@ -508,28 +451,9 @@ async function getRuntimeVersionObjectAsync(exp, platformFlag, projectDir) {
508
451
  (0, nullthrows_1.default)(config_plugins_1.Updates.getRuntimeVersion(exp, platform), `Unable to determine runtime version for ${platform}`),
509
452
  ]));
510
453
  }
511
- function formatUpdateTitle(update) {
512
- const { message, createdAt, actor, runtimeVersion } = update;
513
- let actorName;
514
- switch (actor === null || actor === void 0 ? void 0 : actor.__typename) {
515
- case 'User': {
516
- actorName = actor.username;
517
- break;
518
- }
519
- case 'Robot': {
520
- const { firstName, id } = actor;
521
- actorName = firstName !== null && firstName !== void 0 ? firstName : `robot: ${id.slice(0, 4)}...`;
522
- break;
523
- }
524
- default:
525
- actorName = 'unknown';
526
- }
527
- return `[${(0, dateformat_1.default)(createdAt, 'mmm dd HH:MM')} by ${actorName}, runtimeVersion: ${runtimeVersion}] ${message}`;
528
- }
529
- async function checkEASUpdateURLIsSetAsync(exp) {
530
- var _a;
531
- const configuredURL = (_a = exp.updates) === null || _a === void 0 ? void 0 : _a.url;
532
- const projectId = await (0, projectUtils_1.getProjectIdAsync)(exp);
454
+ async function checkEASUpdateURLIsSetAsync(exp, projectId) {
455
+ var _b;
456
+ const configuredURL = (_b = exp.updates) === null || _b === void 0 ? void 0 : _b.url;
533
457
  const expectedURL = (0, api_1.getEASUpdateURL)(projectId);
534
458
  if (configuredURL !== expectedURL) {
535
459
  throw new Error(`The update URL is incorrectly configured for EAS Update. Set updates.url to ${expectedURL} in your ${chalk_1.default.bold('app.json')}.`);
@@ -1,10 +1,16 @@
1
1
  import EasCommand from '../../commandUtils/EasCommand';
2
- export default class BranchView extends EasCommand {
2
+ export default class UpdateList extends EasCommand {
3
3
  static description: string;
4
4
  static flags: {
5
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
6
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
+ limit: any;
8
+ offset: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
5
9
  branch: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
6
10
  all: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
- json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ static contextDefinition: {
13
+ projectConfig: import("../../commandUtils/context/ProjectConfigContextField").default;
8
14
  };
9
15
  runAsync(): Promise<void>;
10
16
  }
@@ -1,109 +1,79 @@
1
1
  "use strict";
2
+ var _a;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  const tslib_1 = require("tslib");
4
5
  const core_1 = require("@oclif/core");
5
- const assert_1 = tslib_1.__importDefault(require("assert"));
6
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
- const cli_table3_1 = tslib_1.__importDefault(require("cli-table3"));
6
+ const queries_1 = require("../../branch/queries");
8
7
  const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
9
- const UpdateQuery_1 = require("../../graphql/queries/UpdateQuery");
10
- const log_1 = tslib_1.__importDefault(require("../../log"));
11
- const expoConfig_1 = require("../../project/expoConfig");
12
- const projectUtils_1 = require("../../project/projectUtils");
13
- const prompts_1 = require("../../prompts");
14
- const queries_1 = require("../../update/queries");
15
- const utils_1 = require("../../update/utils");
8
+ const flags_1 = require("../../commandUtils/flags");
9
+ const pagination_1 = require("../../commandUtils/pagination");
10
+ const queries_2 = require("../../update/queries");
16
11
  const json_1 = require("../../utils/json");
17
- const vcs_1 = require("../../vcs");
18
- class BranchView extends EasCommand_1.default {
12
+ class UpdateList extends EasCommand_1.default {
19
13
  async runAsync() {
20
- var _a, _b;
21
- const { flags: { branch: branchFlag, all, json: jsonFlag }, } = await this.parse(BranchView);
14
+ const { flags } = await this.parse(UpdateList);
15
+ const { branch: branchFlag, all, json: jsonFlag, 'non-interactive': nonInteractive } = flags;
16
+ const { projectConfig: { projectId }, } = await this.getContextAsync(UpdateList, {
17
+ nonInteractive,
18
+ });
19
+ const paginatedQueryOptions = (0, pagination_1.getPaginatedQueryOptions)(flags);
22
20
  if (jsonFlag) {
23
21
  (0, json_1.enableJsonOutput)();
24
22
  }
25
- const projectDir = await (0, projectUtils_1.findProjectRootAsync)();
26
- const exp = (0, expoConfig_1.getExpoConfig)(projectDir);
27
- const projectId = await (0, projectUtils_1.getProjectIdAsync)(exp);
28
- let updateGroupDescriptions;
29
23
  if (all) {
30
- const branchesAndUpdates = await UpdateQuery_1.UpdateQuery.viewAllAsync({
31
- appId: projectId,
32
- limit: queries_1.UPDATES_LIMIT,
33
- offset: 0,
34
- });
35
- updateGroupDescriptions = (0, utils_1.getUpdateGroupsWithPlatforms)(branchesAndUpdates.app.byId.updates.map(update => ({
36
- ...update,
37
- branch: update.branch.name,
38
- }))).sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
24
+ (0, queries_2.listAndRenderUpdateGroupsOnAppAsync)({ projectId, paginatedQueryOptions });
39
25
  }
40
26
  else {
41
- let branchInteractive;
42
- if (!branchFlag) {
27
+ if (branchFlag) {
28
+ (0, queries_2.listAndRenderUpdateGroupsOnBranchAsync)({
29
+ projectId,
30
+ branchName: branchFlag,
31
+ paginatedQueryOptions,
32
+ });
33
+ }
34
+ else {
43
35
  const validationMessage = 'Branch name may not be empty.';
44
- if (jsonFlag) {
36
+ if (nonInteractive) {
45
37
  throw new Error(validationMessage);
46
38
  }
47
- ({ name: branchInteractive } = await (0, prompts_1.promptAsync)({
48
- type: 'text',
49
- name: 'name',
50
- message: 'Provide the name of the branch whose updates you wish to view:',
51
- initial: (_a = (await (0, vcs_1.getVcsClient)().getBranchNameAsync())) !== null && _a !== void 0 ? _a : undefined,
52
- validate: (value) => (value ? true : validationMessage),
53
- }));
54
- }
55
- const branch = branchFlag !== null && branchFlag !== void 0 ? branchFlag : branchInteractive;
56
- (0, assert_1.default)(branch, 'Branch name may not be empty.');
57
- const branchesAndUpdates = await UpdateQuery_1.UpdateQuery.viewBranchAsync({
58
- appId: projectId,
59
- name: branch,
60
- limit: queries_1.UPDATES_LIMIT,
61
- offset: 0,
62
- });
63
- const UpdateBranch = (_b = branchesAndUpdates.app) === null || _b === void 0 ? void 0 : _b.byId.updateBranchByName;
64
- if (!UpdateBranch) {
65
- throw new Error(`Could not find branch "${branch}"`);
39
+ const selectedBranch = await (0, queries_1.selectBranchOnAppAsync)({
40
+ projectId,
41
+ promptTitle: 'Which branch would you like to view?',
42
+ displayTextForListItem: updateBranch => updateBranch.name,
43
+ paginatedQueryOptions:
44
+ // discard limit and offset because this query is not those flag's intended target
45
+ {
46
+ json: paginatedQueryOptions.json,
47
+ nonInteractive: paginatedQueryOptions.nonInteractive,
48
+ offset: 0,
49
+ },
50
+ });
51
+ (0, queries_2.listAndRenderUpdateGroupsOnBranchAsync)({
52
+ projectId,
53
+ branchName: selectedBranch.name,
54
+ paginatedQueryOptions,
55
+ });
66
56
  }
67
- updateGroupDescriptions = (0, utils_1.getUpdateGroupsWithPlatforms)(UpdateBranch.updates.map(update => ({ ...update, branch }))).sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
68
- }
69
- if (jsonFlag) {
70
- (0, json_1.printJsonOnlyOutput)(updateGroupDescriptions);
71
- }
72
- else {
73
- logAsTable(updateGroupDescriptions);
74
57
  }
75
58
  }
76
59
  }
77
- exports.default = BranchView;
78
- BranchView.description = 'view the recent updates for a branch';
79
- BranchView.flags = {
60
+ exports.default = UpdateList;
61
+ _a = UpdateList;
62
+ UpdateList.description = 'view the recent updates';
63
+ UpdateList.flags = {
80
64
  branch: core_1.Flags.string({
81
- description: 'List all updates on this branch',
65
+ description: 'List updates only on this branch',
82
66
  exclusive: ['all'],
83
67
  }),
84
68
  all: core_1.Flags.boolean({
85
- description: 'List all updates associated with this project',
69
+ description: 'List updates on all branches',
86
70
  exclusive: ['branch'],
87
71
  default: false,
88
72
  }),
89
- json: core_1.Flags.boolean({
90
- description: `Return a json with all of the recent update groups.`,
91
- default: false,
92
- }),
73
+ ...pagination_1.EasPaginatedQueryFlags,
74
+ limit: (0, pagination_1.getLimitFlagWithCustomValues)({ defaultTo: 25, limit: 50 }),
75
+ ...flags_1.EasNonInteractiveAndJsonFlags,
76
+ };
77
+ UpdateList.contextDefinition = {
78
+ ..._a.ContextOptions.ProjectConfig,
93
79
  };
94
- function logAsTable(updateGroupDescriptions) {
95
- const table = new cli_table3_1.default({
96
- head: ['Branch', ...utils_1.UPDATE_COLUMNS],
97
- wordWrap: true,
98
- });
99
- table.push(...updateGroupDescriptions.map(updateGroupDescription => [
100
- updateGroupDescription.branch,
101
- (0, utils_1.formatUpdate)(updateGroupDescription),
102
- updateGroupDescription.runtimeVersion,
103
- updateGroupDescription.group,
104
- updateGroupDescription.platforms,
105
- ]));
106
- log_1.default.addNewLineIfNone();
107
- log_1.default.log(chalk_1.default.bold('Recently published update groups:'));
108
- log_1.default.log(table.toString());
109
- }
@@ -1,8 +1,4 @@
1
1
  import EasCommand from '../../commandUtils/EasCommand';
2
- import { UpdatesByGroupQuery } from '../../graphql/generated';
3
- export declare function viewUpdateAsync({ groupId, }: {
4
- groupId: string;
5
- }): Promise<UpdatesByGroupQuery>;
6
2
  export default class UpdateView extends EasCommand {
7
3
  static description: string;
8
4
  static args: {