eas-cli 2.0.0 → 2.2.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 (321) hide show
  1. package/README.md +8 -1034
  2. package/build/branch/queries.d.ts +10 -2
  3. package/build/branch/queries.js +27 -24
  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/graphql.js +2 -1
  8. package/build/build/android/prepareJob.js +4 -3
  9. package/build/build/android/syncProjectConfiguration.d.ts +2 -1
  10. package/build/build/android/syncProjectConfiguration.js +2 -2
  11. package/build/build/build.js +15 -4
  12. package/build/build/configure.js +2 -2
  13. package/build/build/createContext.d.ts +5 -1
  14. package/build/build/createContext.js +8 -14
  15. package/build/build/ios/build.js +2 -1
  16. package/build/build/ios/credentials.js +1 -1
  17. package/build/build/ios/graphql.js +2 -1
  18. package/build/build/ios/prepareJob.js +4 -3
  19. package/build/build/ios/syncProjectConfiguration.d.ts +2 -1
  20. package/build/build/ios/syncProjectConfiguration.js +2 -2
  21. package/build/build/local.js +1 -1
  22. package/build/build/metadata.js +1 -2
  23. package/build/build/queries.d.ts +9 -0
  24. package/build/build/queries.js +51 -0
  25. package/build/build/runBuildAndSubmit.d.ts +3 -1
  26. package/build/build/runBuildAndSubmit.js +15 -7
  27. package/build/build/utils/repository.js +5 -1
  28. package/build/channel/queries.d.ts +17 -0
  29. package/build/channel/queries.js +137 -0
  30. package/build/channel/utils.d.ts +22 -0
  31. package/build/channel/utils.js +87 -0
  32. package/build/commandUtils/EasCommand.d.ts +68 -7
  33. package/build/commandUtils/EasCommand.js +60 -79
  34. package/build/commandUtils/context/ActorContextField.d.ts +5 -0
  35. package/build/commandUtils/context/ActorContextField.js +11 -0
  36. package/build/commandUtils/context/ContextField.d.ts +6 -0
  37. package/build/commandUtils/context/ContextField.js +5 -0
  38. package/build/commandUtils/context/DynamicProjectConfigContextField.d.ts +11 -0
  39. package/build/commandUtils/context/DynamicProjectConfigContextField.js +27 -0
  40. package/build/commandUtils/context/OptionalProjectConfigContextField.d.ts +13 -0
  41. package/build/commandUtils/context/OptionalProjectConfigContextField.js +37 -0
  42. package/build/commandUtils/context/ProjectConfigContextField.d.ts +13 -0
  43. package/build/commandUtils/context/ProjectConfigContextField.js +23 -0
  44. package/build/commandUtils/context/ProjectDirContextField.d.ts +4 -0
  45. package/build/commandUtils/context/ProjectDirContextField.js +11 -0
  46. package/build/commandUtils/context/contextUtils/ensureLoggedInAsync.d.ts +21 -0
  47. package/build/commandUtils/context/contextUtils/ensureLoggedInAsync.js +75 -0
  48. package/build/commandUtils/context/contextUtils/findProjectDirAndVerifyProjectSetupAsync.d.ts +17 -0
  49. package/build/commandUtils/context/contextUtils/findProjectDirAndVerifyProjectSetupAsync.js +102 -0
  50. package/build/commandUtils/context/contextUtils/getProjectIdAsync.d.ts +24 -0
  51. package/build/commandUtils/context/contextUtils/getProjectIdAsync.js +108 -0
  52. package/build/commandUtils/flags.d.ts +10 -0
  53. package/build/commandUtils/flags.js +23 -0
  54. package/build/commandUtils/pagination.d.ts +7 -4
  55. package/build/commandUtils/pagination.js +11 -15
  56. package/build/commands/account/login.d.ts +0 -2
  57. package/build/commands/account/login.js +2 -7
  58. package/build/commands/account/logout.d.ts +0 -2
  59. package/build/commands/account/logout.js +0 -5
  60. package/build/commands/account/view.d.ts +0 -2
  61. package/build/commands/account/view.js +0 -5
  62. package/build/commands/analytics.d.ts +0 -1
  63. package/build/commands/analytics.js +0 -4
  64. package/build/commands/branch/create.d.ts +4 -0
  65. package/build/commands/branch/create.js +18 -18
  66. package/build/commands/branch/delete.d.ts +4 -0
  67. package/build/commands/branch/delete.js +29 -26
  68. package/build/commands/branch/list.d.ts +5 -2
  69. package/build/commands/branch/list.js +13 -8
  70. package/build/commands/branch/rename.d.ts +5 -1
  71. package/build/commands/branch/rename.js +15 -13
  72. package/build/commands/branch/view.d.ts +5 -2
  73. package/build/commands/branch/view.js +31 -13
  74. package/build/commands/build/cancel.d.ts +7 -0
  75. package/build/commands/build/cancel.js +50 -23
  76. package/build/commands/build/configure.d.ts +3 -0
  77. package/build/commands/build/configure.js +12 -7
  78. package/build/commands/build/index.d.ts +7 -2
  79. package/build/commands/build/index.js +77 -15
  80. package/build/commands/build/inspect.d.ts +5 -0
  81. package/build/commands/build/inspect.js +12 -3
  82. package/build/commands/build/list.d.ts +7 -2
  83. package/build/commands/build/list.js +36 -59
  84. package/build/commands/build/version/set.d.ts +5 -0
  85. package/build/commands/build/version/set.js +22 -14
  86. package/build/commands/build/version/sync.d.ts +5 -0
  87. package/build/commands/build/version/sync.js +22 -13
  88. package/build/commands/build/view.d.ts +3 -0
  89. package/build/commands/build/view.js +20 -14
  90. package/build/commands/channel/create.d.ts +4 -0
  91. package/build/commands/channel/create.js +32 -25
  92. package/build/commands/channel/delete.d.ts +3 -0
  93. package/build/commands/channel/delete.js +36 -59
  94. package/build/commands/channel/edit.d.ts +7 -7
  95. package/build/commands/channel/edit.js +39 -72
  96. package/build/commands/channel/list.d.ts +6 -0
  97. package/build/commands/channel/list.js +20 -76
  98. package/build/commands/channel/rollout.d.ts +5 -1
  99. package/build/commands/channel/rollout.js +34 -35
  100. package/build/commands/channel/view.d.ts +6 -33
  101. package/build/commands/channel/view.js +31 -132
  102. package/build/commands/config.d.ts +6 -2
  103. package/build/commands/config.js +22 -13
  104. package/build/commands/credentials.d.ts +4 -0
  105. package/build/commands/credentials.js +10 -1
  106. package/build/commands/device/create.d.ts +4 -0
  107. package/build/commands/device/create.js +15 -3
  108. package/build/commands/device/delete.d.ts +13 -8
  109. package/build/commands/device/delete.js +81 -129
  110. package/build/commands/device/list.d.ts +7 -0
  111. package/build/commands/device/list.js +42 -63
  112. package/build/commands/device/view.d.ts +3 -0
  113. package/build/commands/device/view.js +10 -5
  114. package/build/commands/diagnostics.d.ts +3 -1
  115. package/build/commands/diagnostics.js +10 -8
  116. package/build/commands/metadata/pull.d.ts +4 -0
  117. package/build/commands/metadata/pull.js +13 -8
  118. package/build/commands/metadata/push.d.ts +4 -0
  119. package/build/commands/metadata/push.js +13 -8
  120. package/build/commands/open.d.ts +8 -0
  121. package/build/commands/open.js +42 -0
  122. package/build/commands/project/info.d.ts +3 -0
  123. package/build/commands/project/info.js +9 -6
  124. package/build/commands/project/init.d.ts +12 -0
  125. package/build/commands/project/init.js +155 -8
  126. package/build/commands/secret/create.d.ts +6 -0
  127. package/build/commands/secret/create.js +87 -30
  128. package/build/commands/secret/delete.d.ts +4 -0
  129. package/build/commands/secret/delete.js +28 -19
  130. package/build/commands/secret/list.d.ts +3 -0
  131. package/build/commands/secret/list.js +19 -13
  132. package/build/commands/submit.d.ts +5 -0
  133. package/build/commands/submit.js +16 -7
  134. package/build/commands/update/configure.d.ts +3 -0
  135. package/build/commands/update/configure.js +24 -18
  136. package/build/commands/update/delete.d.ts +1 -0
  137. package/build/commands/update/delete.js +5 -8
  138. package/build/commands/update/index.d.ts +8 -12
  139. package/build/commands/update/index.js +90 -166
  140. package/build/commands/update/list.d.ts +8 -2
  141. package/build/commands/update/list.js +51 -81
  142. package/build/commands/update/view.d.ts +0 -4
  143. package/build/commands/update/view.js +14 -51
  144. package/build/commands/webhook/create.d.ts +4 -0
  145. package/build/commands/webhook/create.js +10 -5
  146. package/build/commands/webhook/delete.d.ts +6 -0
  147. package/build/commands/webhook/delete.js +26 -14
  148. package/build/commands/webhook/list.d.ts +3 -0
  149. package/build/commands/webhook/list.js +13 -9
  150. package/build/commands/webhook/update.d.ts +1 -0
  151. package/build/commands/webhook/update.js +3 -1
  152. package/build/credentials/android/actions/BuildCredentialsUtils.js +2 -6
  153. package/build/credentials/android/actions/CreateFcm.d.ts +2 -3
  154. package/build/credentials/android/actions/CreateGoogleServiceAccountKey.d.ts +2 -3
  155. package/build/credentials/android/actions/CreateKeystore.d.ts +2 -3
  156. package/build/credentials/android/actions/CreateKeystore.js +1 -2
  157. package/build/credentials/android/actions/RemoveGoogleServiceAccountKey.d.ts +2 -3
  158. package/build/credentials/android/actions/UseExistingGoogleServiceAccountKey.d.ts +2 -3
  159. package/build/credentials/android/api/GraphqlClient.d.ts +6 -7
  160. package/build/credentials/context.d.ts +8 -4
  161. package/build/credentials/context.js +8 -23
  162. package/build/credentials/ios/IosCredentialsProvider.js +11 -6
  163. package/build/credentials/ios/actions/AppleTeamFormatting.d.ts +2 -0
  164. package/build/credentials/ios/actions/AppleTeamFormatting.js +7 -0
  165. package/build/credentials/ios/actions/AppleTeamUtils.d.ts +1 -2
  166. package/build/credentials/ios/actions/AppleTeamUtils.js +1 -5
  167. package/build/credentials/ios/actions/AscApiKeyUtils.d.ts +3 -4
  168. package/build/credentials/ios/actions/AscApiKeyUtils.js +2 -2
  169. package/build/credentials/ios/actions/AssignAscApiKey.d.ts +1 -1
  170. package/build/credentials/ios/actions/AssignPushKey.d.ts +1 -1
  171. package/build/credentials/ios/actions/BuildCredentialsUtils.d.ts +3 -3
  172. package/build/credentials/ios/actions/BuildCredentialsUtils.js +8 -12
  173. package/build/credentials/ios/actions/ConfigureProvisioningProfile.d.ts +4 -2
  174. package/build/credentials/ios/actions/ConfigureProvisioningProfile.js +5 -2
  175. package/build/credentials/ios/actions/CreateAscApiKey.d.ts +2 -3
  176. package/build/credentials/ios/actions/CreateDistributionCertificate.d.ts +2 -2
  177. package/build/credentials/ios/actions/CreateProvisioningProfile.d.ts +4 -2
  178. package/build/credentials/ios/actions/CreateProvisioningProfile.js +3 -2
  179. package/build/credentials/ios/actions/CreatePushKey.d.ts +2 -3
  180. package/build/credentials/ios/actions/DeviceUtils.d.ts +0 -1
  181. package/build/credentials/ios/actions/DeviceUtils.js +3 -19
  182. package/build/credentials/ios/actions/DistributionCertificateUtils.d.ts +3 -4
  183. package/build/credentials/ios/actions/DistributionCertificateUtils.js +2 -2
  184. package/build/credentials/ios/actions/ProvisioningProfileUtils.d.ts +2 -1
  185. package/build/credentials/ios/actions/ProvisioningProfileUtils.js +4 -2
  186. package/build/credentials/ios/actions/PushKeyUtils.d.ts +2 -3
  187. package/build/credentials/ios/actions/PushKeyUtils.js +2 -2
  188. package/build/credentials/ios/actions/RemoveAscApiKey.d.ts +2 -3
  189. package/build/credentials/ios/actions/RemoveDistributionCertificate.d.ts +3 -4
  190. package/build/credentials/ios/actions/RemoveProvisioningProfile.d.ts +1 -1
  191. package/build/credentials/ios/actions/RemovePushKey.d.ts +2 -3
  192. package/build/credentials/ios/actions/SetUpAdhocProvisioningProfile.d.ts +9 -3
  193. package/build/credentials/ios/actions/SetUpAdhocProvisioningProfile.js +30 -18
  194. package/build/credentials/ios/actions/SetUpAscApiKey.d.ts +1 -1
  195. package/build/credentials/ios/actions/SetUpBuildCredentials.js +1 -0
  196. package/build/credentials/ios/actions/SetUpDistributionCertificate.d.ts +1 -1
  197. package/build/credentials/ios/actions/SetUpInternalProvisioningProfile.d.ts +9 -3
  198. package/build/credentials/ios/actions/SetUpInternalProvisioningProfile.js +6 -12
  199. package/build/credentials/ios/actions/SetUpProvisioningProfile.d.ts +4 -2
  200. package/build/credentials/ios/actions/SetUpProvisioningProfile.js +8 -5
  201. package/build/credentials/ios/actions/SetUpPushKey.d.ts +1 -1
  202. package/build/credentials/ios/actions/SetUpSubmissionCredentials.d.ts +1 -1
  203. package/build/credentials/ios/actions/SetUpTargetBuildCredentials.d.ts +3 -1
  204. package/build/credentials/ios/actions/SetUpTargetBuildCredentials.js +5 -5
  205. package/build/credentials/ios/actions/SetUpTargetBuildCredentialsFromCredentialsJson.d.ts +1 -1
  206. package/build/credentials/ios/api/GraphqlClient.d.ts +9 -15
  207. package/build/credentials/ios/api/graphql/mutations/AppleTeamMutation.d.ts +2 -3
  208. package/build/credentials/ios/api/graphql/mutations/AppleTeamMutation.js +3 -1
  209. package/build/credentials/ios/api/graphql/queries/AppleDeviceQuery.d.ts +3 -3
  210. package/build/credentials/ios/api/graphql/queries/AppleDeviceQuery.js +20 -6
  211. package/build/credentials/ios/api/graphql/queries/AppleTeamQuery.d.ts +2 -2
  212. package/build/credentials/ios/api/graphql/queries/AppleTeamQuery.js +8 -7
  213. package/build/credentials/ios/api/graphql/types/AppLookupParams.d.ts +7 -0
  214. package/build/credentials/ios/api/graphql/types/AppLookupParams.js +2 -0
  215. package/build/credentials/ios/appstore/AppStoreApi.d.ts +7 -4
  216. package/build/credentials/ios/appstore/AppStoreApi.js +8 -8
  217. package/build/credentials/ios/appstore/Credentials.types.d.ts +0 -14
  218. package/build/credentials/ios/appstore/Credentials.types.js +0 -6
  219. package/build/credentials/ios/appstore/constants.d.ts +1 -0
  220. package/build/credentials/ios/appstore/constants.js +6 -0
  221. package/build/credentials/ios/appstore/distributionCertificate.js +1 -1
  222. package/build/credentials/ios/appstore/provisioningProfile.d.ts +5 -3
  223. package/build/credentials/ios/appstore/provisioningProfile.js +30 -7
  224. package/build/credentials/ios/appstore/provisioningProfileAdhoc.d.ts +3 -1
  225. package/build/credentials/ios/appstore/provisioningProfileAdhoc.js +10 -10
  226. package/build/credentials/ios/types.d.ts +2 -3
  227. package/build/credentials/ios/utils/printCredentials.d.ts +1 -1
  228. package/build/credentials/ios/validators/validateProvisioningProfile.d.ts +3 -2
  229. package/build/credentials/ios/validators/validateProvisioningProfile.js +6 -4
  230. package/build/credentials/manager/HelperActions.d.ts +4 -1
  231. package/build/credentials/manager/ManageAndroid.js +4 -14
  232. package/build/credentials/manager/ManageIos.js +20 -20
  233. package/build/credentials/manager/SelectBuildProfileFromEasJson.d.ts +1 -1
  234. package/build/credentials/manager/SelectBuildProfileFromEasJson.js +3 -3
  235. package/build/credentials/manager/SelectPlatform.d.ts +5 -1
  236. package/build/credentials/manager/SelectPlatform.js +5 -3
  237. package/build/devices/actions/create/action.d.ts +2 -3
  238. package/build/devices/actions/create/developerPortalMethod.js +2 -2
  239. package/build/devices/context.d.ts +3 -5
  240. package/build/devices/context.js +2 -11
  241. package/build/devices/manager.d.ts +4 -5
  242. package/build/devices/manager.js +9 -16
  243. package/build/devices/queries.d.ts +21 -0
  244. package/build/devices/queries.js +121 -0
  245. package/build/devices/utils/errors.d.ts +3 -0
  246. package/build/devices/utils/errors.js +9 -0
  247. package/build/devices/utils/formatDevice.d.ts +3 -3
  248. package/build/devices/utils/formatDevice.js +8 -3
  249. package/build/graphql/generated.d.ts +1141 -192
  250. package/build/graphql/generated.js +13 -2
  251. package/build/graphql/mutations/EnvironmentSecretMutation.d.ts +3 -1
  252. package/build/graphql/queries/AppQuery.d.ts +1 -0
  253. package/build/graphql/queries/AppQuery.js +19 -0
  254. package/build/graphql/queries/BranchQuery.d.ts +5 -6
  255. package/build/graphql/queries/BranchQuery.js +44 -3
  256. package/build/graphql/queries/BuildQuery.d.ts +2 -20
  257. package/build/graphql/queries/BuildQuery.js +2 -2
  258. package/build/graphql/queries/ChannelQuery.d.ts +5 -2
  259. package/build/graphql/queries/ChannelQuery.js +45 -19
  260. package/build/graphql/queries/EnvironmentSecretsQuery.d.ts +5 -3
  261. package/build/graphql/queries/EnvironmentSecretsQuery.js +14 -28
  262. package/build/graphql/queries/UpdateQuery.d.ts +4 -6
  263. package/build/graphql/queries/UpdateQuery.js +59 -50
  264. package/build/graphql/queries/UserQuery.js +8 -1
  265. package/build/graphql/types/Account.d.ts +1 -0
  266. package/build/graphql/types/Account.js +17 -0
  267. package/build/graphql/types/App.js +7 -0
  268. package/build/graphql/types/EnvironmentSecret.d.ts +7 -0
  269. package/build/graphql/types/EnvironmentSecret.js +16 -1
  270. package/build/graphql/types/Update.d.ts +1 -0
  271. package/build/graphql/types/Update.js +30 -0
  272. package/build/graphql/types/UpdateBranch.js +4 -15
  273. package/build/metadata/context.d.ts +1 -1
  274. package/build/metadata/context.js +7 -9
  275. package/build/project/android/applicationId.d.ts +2 -1
  276. package/build/project/android/applicationId.js +7 -7
  277. package/build/project/android/versions.js +1 -1
  278. package/build/project/applicationIdentifier.d.ts +2 -1
  279. package/build/project/applicationIdentifier.js +2 -2
  280. package/build/project/expoConfig.d.ts +3 -3
  281. package/build/project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync.d.ts +22 -0
  282. package/build/project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync.js +93 -0
  283. package/build/project/ios/bundleIdentifier.d.ts +2 -1
  284. package/build/project/ios/bundleIdentifier.js +7 -7
  285. package/build/project/ios/scheme.d.ts +1 -1
  286. package/build/project/ios/target.d.ts +7 -0
  287. package/build/project/ios/target.js +26 -1
  288. package/build/project/projectUtils.d.ts +4 -31
  289. package/build/project/projectUtils.js +13 -123
  290. package/build/project/remoteVersionSource.d.ts +2 -2
  291. package/build/project/remoteVersionSource.js +8 -7
  292. package/build/project/workflow.js +3 -1
  293. package/build/submit/android/ServiceAccountSource.js +1 -2
  294. package/build/submit/context.d.ts +3 -1
  295. package/build/submit/context.js +12 -14
  296. package/build/submit/ios/CredentialsServiceSource.js +1 -2
  297. package/build/submit/utils/builds.js +3 -1
  298. package/build/update/android/UpdatesModule.d.ts +1 -1
  299. package/build/update/android/UpdatesModule.js +2 -3
  300. package/build/update/ios/UpdatesModule.d.ts +1 -1
  301. package/build/update/ios/UpdatesModule.js +2 -3
  302. package/build/update/queries.d.ts +16 -1
  303. package/build/update/queries.js +96 -30
  304. package/build/update/utils.d.ts +21 -8
  305. package/build/update/utils.js +75 -14
  306. package/build/user/actions.d.ts +2 -8
  307. package/build/user/actions.js +4 -63
  308. package/build/utils/profiles.d.ts +3 -3
  309. package/build/utils/profiles.js +6 -5
  310. package/build/vcs/clients/git.d.ts +1 -1
  311. package/build/vcs/clients/git.js +5 -2
  312. package/build/vcs/clients/gitNoCommit.js +2 -1
  313. package/build/vcs/vcs.d.ts +1 -1
  314. package/build/webhooks/input.d.ts +2 -1
  315. package/build/webhooks/input.js +10 -1
  316. package/oclif.manifest.json +1 -1
  317. package/package.json +6 -5
  318. package/build/project/ensureProjectExists.d.ts +0 -21
  319. package/build/project/ensureProjectExists.js +0 -88
  320. package/build/user/Account.d.ts +0 -3
  321. package/build/user/Account.js +0 -7
@@ -1,4 +1,5 @@
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 eas_build_job_1 = require("@expo/eas-build-job");
@@ -15,35 +16,36 @@ const platform_1 = require("../../../platform");
15
16
  const gradleUtils_1 = require("../../../project/android/gradleUtils");
16
17
  const versions_1 = require("../../../project/android/versions");
17
18
  const applicationIdentifier_1 = require("../../../project/applicationIdentifier");
18
- const expoConfig_1 = require("../../../project/expoConfig");
19
19
  const scheme_1 = require("../../../project/ios/scheme");
20
20
  const target_1 = require("../../../project/ios/target");
21
21
  const versions_2 = require("../../../project/ios/versions");
22
- const projectUtils_1 = require("../../../project/projectUtils");
23
22
  const remoteVersionSource_1 = require("../../../project/remoteVersionSource");
24
23
  const workflow_1 = require("../../../project/workflow");
25
24
  const profiles_1 = require("../../../utils/profiles");
26
25
  class BuildVersionSyncView extends EasCommand_1.default {
27
26
  async runAsync() {
28
- var _a;
27
+ var _b;
29
28
  const { flags } = await this.parse(BuildVersionSyncView);
30
- const projectDir = await (0, projectUtils_1.findProjectRootAsync)();
29
+ const { actor, getDynamicProjectConfigAsync, projectDir } = await this.getContextAsync(BuildVersionSyncView, {
30
+ nonInteractive: true,
31
+ });
31
32
  const requestedPlatform = await (0, platform_1.selectRequestedPlatformAsync)(flags.platform);
32
- const easJsonReader = new eas_json_1.EasJsonReader(projectDir);
33
- await (0, remoteVersionSource_1.ensureVersionSourceIsRemoteAsync)(projectDir, easJsonReader);
33
+ const easJsonAccessor = new eas_json_1.EasJsonAccessor(projectDir);
34
+ await (0, remoteVersionSource_1.ensureVersionSourceIsRemoteAsync)(easJsonAccessor);
34
35
  const platforms = (0, platform_1.toPlatforms)(requestedPlatform);
35
36
  const buildProfiles = await (0, profiles_1.getProfilesAsync)({
36
37
  type: 'build',
37
- easJsonReader,
38
+ easJsonAccessor,
38
39
  platforms,
39
- profileName: (_a = flags.profile) !== null && _a !== void 0 ? _a : undefined,
40
+ profileName: (_b = flags.profile) !== null && _b !== void 0 ? _b : undefined,
40
41
  });
41
42
  for (const profileInfo of buildProfiles) {
42
- const exp = (0, expoConfig_1.getExpoConfig)(projectDir, { env: profileInfo.profile.env });
43
- const projectId = await (0, projectUtils_1.getProjectIdAsync)(exp);
43
+ const { exp, projectId } = await getDynamicProjectConfigAsync({
44
+ env: profileInfo.profile.env,
45
+ });
44
46
  (0, remoteVersionSource_1.validateAppConfigForRemoteVersionSource)(exp, profileInfo.platform);
45
47
  const platformDisplayName = platform_1.appPlatformDisplayNames[(0, AppPlatform_1.toAppPlatform)(profileInfo.platform)];
46
- const applicationIdentifier = await (0, applicationIdentifier_1.getApplicationIdentifierAsync)(projectDir, exp, profileInfo.profile, profileInfo.platform);
48
+ const applicationIdentifier = await (0, applicationIdentifier_1.getApplicationIdentifierAsync)(projectDir, exp, profileInfo.profile, profileInfo.platform, actor);
47
49
  const remoteVersions = await AppVersionQuery_1.AppVersionQuery.latestVersionAsync(projectId, (0, AppPlatform_1.toAppPlatform)(profileInfo.platform), applicationIdentifier);
48
50
  const workflow = await (0, workflow_1.resolveWorkflowAsync)(projectDir, profileInfo.platform);
49
51
  if (!(remoteVersions === null || remoteVersions === void 0 ? void 0 : remoteVersions.buildVersion)) {
@@ -95,13 +97,13 @@ class BuildVersionSyncView extends EasCommand_1.default {
95
97
  }
96
98
  }
97
99
  async syncAndroidAsync({ projectDir, workflow, buildVersion, }) {
98
- var _a, _b;
100
+ var _b, _c;
99
101
  if (!(0, versions_1.isValidVersionCode)(buildVersion)) {
100
102
  throw new Error(`Invalid versionCode (${buildVersion}), ${versions_1.VERSION_CODE_REQUIREMENTS}.`);
101
103
  }
102
104
  if (workflow === eas_build_job_1.Workflow.GENERIC) {
103
105
  const buildGradle = await (0, gradleUtils_1.getAppBuildGradleAsync)(projectDir);
104
- const isMultiFlavor = ((_a = buildGradle.android) === null || _a === void 0 ? void 0 : _a.productFlavors) || ((_b = buildGradle.android) === null || _b === void 0 ? void 0 : _b.flavorDimensions);
106
+ const isMultiFlavor = ((_b = buildGradle.android) === null || _b === void 0 ? void 0 : _b.productFlavors) || ((_c = buildGradle.android) === null || _c === void 0 ? void 0 : _c.flavorDimensions);
105
107
  if (isMultiFlavor) {
106
108
  throw new Error("Versions in native code can't be automatically synced in multi-flavor Android projects. If you are using EAS Build with app version source set to remote, the correct values will be injected at the build time.");
107
109
  }
@@ -110,6 +112,7 @@ class BuildVersionSyncView extends EasCommand_1.default {
110
112
  }
111
113
  }
112
114
  exports.default = BuildVersionSyncView;
115
+ _a = BuildVersionSyncView;
113
116
  BuildVersionSyncView.description = 'Update a version in native code with a value stored on EAS servers';
114
117
  BuildVersionSyncView.flags = {
115
118
  platform: core_1.Flags.enum({
@@ -117,7 +120,13 @@ BuildVersionSyncView.flags = {
117
120
  options: ['android', 'ios', 'all'],
118
121
  }),
119
122
  profile: core_1.Flags.string({
123
+ char: 'e',
120
124
  description: 'Name of the build profile from eas.json. Defaults to "production" if defined in eas.json.',
121
125
  helpValue: 'PROFILE_NAME',
122
126
  }),
123
127
  };
128
+ BuildVersionSyncView.contextDefinition = {
129
+ ..._a.ContextOptions.LoggedIn,
130
+ ..._a.ContextOptions.DynamicProjectConfig,
131
+ ..._a.ContextOptions.ProjectDir,
132
+ };
@@ -7,5 +7,8 @@ export default class BuildView extends EasCommand {
7
7
  static flags: {
8
8
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
9
  };
10
+ static contextDefinition: {
11
+ projectConfig: import("../../commandUtils/context/ProjectConfigContextField").default;
12
+ };
10
13
  runAsync(): Promise<void>;
11
14
  }
@@ -1,25 +1,25 @@
1
1
  "use strict";
2
+ var _a;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  const tslib_1 = require("tslib");
4
- const core_1 = require("@oclif/core");
5
5
  const formatBuild_1 = require("../../build/utils/formatBuild");
6
6
  const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
7
+ const flags_1 = require("../../commandUtils/flags");
7
8
  const BuildQuery_1 = require("../../graphql/queries/BuildQuery");
8
9
  const log_1 = tslib_1.__importDefault(require("../../log"));
9
10
  const ora_1 = require("../../ora");
10
- const expoConfig_1 = require("../../project/expoConfig");
11
11
  const projectUtils_1 = require("../../project/projectUtils");
12
12
  const json_1 = require("../../utils/json");
13
13
  class BuildView extends EasCommand_1.default {
14
14
  async runAsync() {
15
15
  const { args: { BUILD_ID: buildId }, flags, } = await this.parse(BuildView);
16
+ const { projectConfig: { projectId }, } = await this.getContextAsync(BuildView, {
17
+ nonInteractive: true,
18
+ });
16
19
  if (flags.json) {
17
20
  (0, json_1.enableJsonOutput)();
18
21
  }
19
- const projectDir = await (0, projectUtils_1.findProjectRootAsync)();
20
- const exp = (0, expoConfig_1.getExpoConfig)(projectDir);
21
- const projectId = await (0, projectUtils_1.getProjectIdAsync)(exp);
22
- const projectName = await (0, projectUtils_1.getProjectFullNameAsync)(exp);
22
+ const displayName = await (0, projectUtils_1.getDisplayNameForProjectIdAsync)(projectId);
23
23
  const spinner = (0, ora_1.ora)().start('Fetching the build…');
24
24
  try {
25
25
  let build;
@@ -27,18 +27,22 @@ class BuildView extends EasCommand_1.default {
27
27
  build = await BuildQuery_1.BuildQuery.byIdAsync(buildId);
28
28
  }
29
29
  else {
30
- const builds = await BuildQuery_1.BuildQuery.allForAppAsync(projectId, { limit: 1 });
30
+ const builds = await BuildQuery_1.BuildQuery.viewBuildsOnAppAsync({
31
+ appId: projectId,
32
+ offset: 0,
33
+ limit: 1,
34
+ });
31
35
  if (builds.length === 0) {
32
- spinner.fail(`Couldn't find any builds for the project ${projectName}`);
36
+ spinner.fail(`Couldn't find any builds for the project ${displayName}`);
33
37
  return;
34
38
  }
35
39
  build = builds[0];
36
40
  }
37
41
  if (buildId) {
38
- spinner.succeed(`Found a matching build for the project ${projectName}`);
42
+ spinner.succeed(`Found a matching build for the project ${displayName}`);
39
43
  }
40
44
  else {
41
- spinner.succeed(`Showing the last build for the project ${projectName}`);
45
+ spinner.succeed(`Showing the last build for the project ${displayName}`);
42
46
  }
43
47
  if (flags.json) {
44
48
  (0, json_1.printJsonOnlyOutput)(build);
@@ -52,17 +56,19 @@ class BuildView extends EasCommand_1.default {
52
56
  spinner.fail(`Something went wrong and we couldn't fetch the build with id ${buildId}`);
53
57
  }
54
58
  else {
55
- spinner.fail(`Something went wrong and we couldn't fetch the last build for the project ${projectName}`);
59
+ spinner.fail(`Something went wrong and we couldn't fetch the last build for the project ${displayName}`);
56
60
  }
57
61
  throw err;
58
62
  }
59
63
  }
60
64
  }
61
65
  exports.default = BuildView;
66
+ _a = BuildView;
62
67
  BuildView.description = 'view a build for your project';
63
68
  BuildView.args = [{ name: 'BUILD_ID' }];
64
69
  BuildView.flags = {
65
- json: core_1.Flags.boolean({
66
- description: 'Enable JSON output, non-JSON messages will be printed to stderr',
67
- }),
70
+ ...flags_1.EasJsonOnlyFlag,
71
+ };
72
+ BuildView.contextDefinition = {
73
+ ..._a.ContextOptions.ProjectConfig,
68
74
  };
@@ -14,6 +14,10 @@ export default class ChannelCreate extends EasCommand {
14
14
  }[];
15
15
  static flags: {
16
16
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
17
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
18
+ };
19
+ static contextDefinition: {
20
+ projectConfig: import("../../commandUtils/context/ProjectConfigContextField").default;
17
21
  };
18
22
  runAsync(): Promise<void>;
19
23
  }
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
+ var _a;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.createUpdateChannelOnAppAsync = void 0;
4
5
  const tslib_1 = require("tslib");
5
- const core_1 = require("@oclif/core");
6
6
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
7
  const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
8
+ const utils_1 = require("../../branch/utils");
8
9
  const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
10
+ const flags_1 = require("../../commandUtils/flags");
9
11
  const client_1 = require("../../graphql/client");
10
12
  const BranchQuery_1 = require("../../graphql/queries/BranchQuery");
11
13
  const log_1 = tslib_1.__importDefault(require("../../log"));
12
- const expoConfig_1 = require("../../project/expoConfig");
13
14
  const projectUtils_1 = require("../../project/projectUtils");
14
15
  const prompts_1 = require("../../prompts");
15
16
  const formatFields_1 = tslib_1.__importDefault(require("../../utils/formatFields"));
@@ -42,16 +43,16 @@ async function createUpdateChannelOnAppAsync({ appId, channelName, branchId, })
42
43
  exports.createUpdateChannelOnAppAsync = createUpdateChannelOnAppAsync;
43
44
  class ChannelCreate extends EasCommand_1.default {
44
45
  async runAsync() {
45
- let { args: { name: channelName }, flags: { json: jsonFlag }, } = await this.parse(ChannelCreate);
46
+ let { args: { name: channelName }, flags: { json: jsonFlag, 'non-interactive': nonInteractive }, } = await this.parse(ChannelCreate);
47
+ const { projectConfig: { projectId }, } = await this.getContextAsync(ChannelCreate, {
48
+ nonInteractive,
49
+ });
46
50
  if (jsonFlag) {
47
51
  (0, json_1.enableJsonOutput)();
48
52
  }
49
- const projectDir = await (0, projectUtils_1.findProjectRootAsync)();
50
- const exp = (0, expoConfig_1.getExpoConfig)(projectDir);
51
- const projectId = await (0, projectUtils_1.getProjectIdAsync)(exp);
52
53
  if (!channelName) {
53
54
  const validationMessage = 'Channel name may not be empty.';
54
- if (jsonFlag) {
55
+ if (nonInteractive) {
55
56
  throw new Error(validationMessage);
56
57
  }
57
58
  ({ name: channelName } = await (0, prompts_1.promptAsync)({
@@ -63,21 +64,26 @@ class ChannelCreate extends EasCommand_1.default {
63
64
  }
64
65
  let branchId;
65
66
  let branchMessage;
66
- const existingBranch = await BranchQuery_1.BranchQuery.getBranchByNameAsync({
67
- appId: projectId,
68
- name: channelName,
69
- });
70
- if (existingBranch) {
71
- branchId = existingBranch.id;
72
- branchMessage = `We found a branch with the same name`;
73
- }
74
- else {
75
- const newBranch = await (0, create_1.createUpdateBranchOnAppAsync)({
67
+ try {
68
+ const branch = await BranchQuery_1.BranchQuery.getBranchByNameAsync({
76
69
  appId: projectId,
77
70
  name: channelName,
78
71
  });
79
- branchId = newBranch.id;
80
- branchMessage = `We also went ahead and made a branch with the same name`;
72
+ branchId = branch.id;
73
+ branchMessage = `We found a branch with the same name`;
74
+ }
75
+ catch (error) {
76
+ if (error instanceof utils_1.BranchNotFoundError) {
77
+ const newBranch = await (0, create_1.createUpdateBranchOnAppAsync)({
78
+ appId: projectId,
79
+ name: channelName,
80
+ });
81
+ branchId = newBranch.id;
82
+ branchMessage = `We also went ahead and made a branch with the same name`;
83
+ }
84
+ else {
85
+ throw error;
86
+ }
81
87
  }
82
88
  const { updateChannel: { createUpdateChannelForApp: newChannel }, } = await createUpdateChannelOnAppAsync({
83
89
  appId: projectId,
@@ -85,14 +91,14 @@ class ChannelCreate extends EasCommand_1.default {
85
91
  branchId,
86
92
  });
87
93
  if (!newChannel) {
88
- throw new Error(`Could not create channel with name ${channelName} on app with id ${projectId}`);
94
+ throw new Error(`Could not create channel with name ${channelName} on project with id ${projectId}`);
89
95
  }
90
96
  if (jsonFlag) {
91
97
  (0, json_1.printJsonOnlyOutput)(newChannel);
92
98
  }
93
99
  else {
94
100
  log_1.default.addNewLineIfNone();
95
- log_1.default.withTick(`Created a new channel on project ${chalk_1.default.bold(await (0, projectUtils_1.getProjectFullNameAsync)(exp))}`);
101
+ log_1.default.withTick(`Created a new channel on project ${chalk_1.default.bold(await (0, projectUtils_1.getDisplayNameForProjectIdAsync)(projectId))}`);
96
102
  log_1.default.log((0, formatFields_1.default)([
97
103
  { label: 'Name', value: newChannel.name },
98
104
  { label: 'ID', value: newChannel.id },
@@ -109,6 +115,7 @@ class ChannelCreate extends EasCommand_1.default {
109
115
  }
110
116
  }
111
117
  exports.default = ChannelCreate;
118
+ _a = ChannelCreate;
112
119
  ChannelCreate.description = 'create a channel';
113
120
  ChannelCreate.args = [
114
121
  {
@@ -118,8 +125,8 @@ ChannelCreate.args = [
118
125
  },
119
126
  ];
120
127
  ChannelCreate.flags = {
121
- json: core_1.Flags.boolean({
122
- description: 'print output as a JSON object with the new channel ID, name and branch mapping.',
123
- default: false,
124
- }),
128
+ ...flags_1.EasNonInteractiveAndJsonFlags,
129
+ };
130
+ ChannelCreate.contextDefinition = {
131
+ ..._a.ContextOptions.ProjectConfig,
125
132
  };
@@ -11,5 +11,8 @@ export default class ChannelDelete extends EasCommand {
11
11
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
12
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
13
  };
14
+ static contextDefinition: {
15
+ projectConfig: import("../../commandUtils/context/ProjectConfigContextField").default;
16
+ };
14
17
  runAsync(): Promise<void>;
15
18
  }
@@ -1,56 +1,57 @@
1
1
  "use strict";
2
+ var _a;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  const tslib_1 = require("tslib");
4
- const core_1 = require("@oclif/core");
5
5
  const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
6
+ const queries_1 = require("../../channel/queries");
6
7
  const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
8
+ const flags_1 = require("../../commandUtils/flags");
7
9
  const client_1 = require("../../graphql/client");
10
+ const ChannelQuery_1 = require("../../graphql/queries/ChannelQuery");
8
11
  const log_1 = tslib_1.__importDefault(require("../../log"));
9
- const expoConfig_1 = require("../../project/expoConfig");
10
- const projectUtils_1 = require("../../project/projectUtils");
11
12
  const prompts_1 = require("../../prompts");
12
13
  const json_1 = require("../../utils/json");
13
14
  class ChannelDelete extends EasCommand_1.default {
14
15
  async runAsync() {
15
- var _a, _b;
16
- const { args: { name: nameArg }, flags: { json: jsonFlag, 'non-interactive': nonInteractiveFlag }, } = await this.parse(ChannelDelete);
17
- if (jsonFlag && !nonInteractiveFlag) {
18
- throw new Error('--json is allowed only in non-interactive mode');
19
- }
16
+ const { args: { name: nameArg }, flags: { json: jsonFlag, 'non-interactive': nonInteractive }, } = await this.parse(ChannelDelete);
17
+ const { projectConfig: { projectId }, } = await this.getContextAsync(ChannelDelete, {
18
+ nonInteractive,
19
+ });
20
20
  if (jsonFlag) {
21
21
  (0, json_1.enableJsonOutput)();
22
22
  }
23
- const projectDir = await (0, projectUtils_1.findProjectRootAsync)();
24
- const exp = (0, expoConfig_1.getExpoConfig)(projectDir);
25
- const fullName = await (0, projectUtils_1.getProjectFullNameAsync)(exp);
26
- const projectId = await (0, projectUtils_1.getProjectIdAsync)(exp);
27
- let name;
23
+ let channelId, channelName;
28
24
  if (nameArg) {
29
- name = nameArg;
25
+ const { id, name } = await ChannelQuery_1.ChannelQuery.viewUpdateChannelAsync({
26
+ appId: projectId,
27
+ channelName: nameArg,
28
+ });
29
+ channelId = id;
30
+ channelName = name;
30
31
  }
31
32
  else {
32
- if (nonInteractiveFlag) {
33
+ if (nonInteractive) {
33
34
  throw new Error('Channel name must be set when running in non-interactive mode');
34
35
  }
35
- name = (await (0, prompts_1.promptAsync)({
36
- type: 'text',
37
- name: 'name',
38
- message: 'Provide the name of the channel to delete:',
39
- validate: (value) => (value ? true : 'Channel name may not be empty.'),
40
- })).name;
41
- }
42
- const data = await getChannelInfoAsync({ appId: projectId, name });
43
- const channelId = (_b = (_a = data.app) === null || _a === void 0 ? void 0 : _a.byId.updateChannelByName) === null || _b === void 0 ? void 0 : _b.id;
44
- if (!channelId) {
45
- throw new Error(`Could not find channel ${name} on ${fullName}`);
36
+ const { id, name } = await (0, queries_1.selectChannelOnAppAsync)({
37
+ projectId,
38
+ selectionPromptTitle: 'Select a channel to delete',
39
+ paginatedQueryOptions: {
40
+ json: jsonFlag,
41
+ nonInteractive,
42
+ offset: 0,
43
+ },
44
+ });
45
+ channelId = id;
46
+ channelName = name;
46
47
  }
47
- if (!nonInteractiveFlag) {
48
+ if (!nonInteractive) {
48
49
  log_1.default.addNewLineIfNone();
49
- log_1.default.warn(`You are about to permamently delete channel: "${name}".\nThis action is irreversible.`);
50
+ log_1.default.warn(`You are about to permanently delete channel: "${channelName}".\nThis action is irreversible.`);
50
51
  log_1.default.newLine();
51
52
  const confirmed = await (0, prompts_1.toggleConfirmAsync)({ message: 'Are you sure you wish to proceed?' });
52
53
  if (!confirmed) {
53
- log_1.default.error(`Canceled deletion of channel: "${name}".`);
54
+ log_1.default.error(`Canceled deletion of channel: "${channelName}".`);
54
55
  process.exit(1);
55
56
  }
56
57
  }
@@ -61,11 +62,12 @@ class ChannelDelete extends EasCommand_1.default {
61
62
  (0, json_1.printJsonOnlyOutput)(deletionResult);
62
63
  }
63
64
  else {
64
- log_1.default.withTick(`️Deleted channel "${name}".`);
65
+ log_1.default.withTick(`️Deleted channel "${channelName}".`);
65
66
  }
66
67
  }
67
68
  }
68
69
  exports.default = ChannelDelete;
70
+ _a = ChannelDelete;
69
71
  ChannelDelete.hidden = true;
70
72
  ChannelDelete.description = 'Delete a channel';
71
73
  ChannelDelete.args = [
@@ -76,36 +78,11 @@ ChannelDelete.args = [
76
78
  },
77
79
  ];
78
80
  ChannelDelete.flags = {
79
- json: core_1.Flags.boolean({
80
- description: 'print output as a JSON object',
81
- default: false,
82
- }),
83
- 'non-interactive': core_1.Flags.boolean({
84
- default: false,
85
- description: 'Run command in non-interactive mode',
86
- }),
81
+ ...flags_1.EasNonInteractiveAndJsonFlags,
82
+ };
83
+ ChannelDelete.contextDefinition = {
84
+ ..._a.ContextOptions.ProjectConfig,
87
85
  };
88
- async function getChannelInfoAsync({ appId, name, }) {
89
- const data = await (0, client_1.withErrorHandlingAsync)(client_1.graphqlClient
90
- .query((0, graphql_tag_1.default) `
91
- query GetChannelInfo($appId: String!, $name: String!) {
92
- app {
93
- byId(appId: $appId) {
94
- id
95
- updateChannelByName(name: $name) {
96
- id
97
- name
98
- }
99
- }
100
- }
101
- }
102
- `, {
103
- appId,
104
- name,
105
- }, { additionalTypenames: ['UpdateChannel'] })
106
- .toPromise());
107
- return data;
108
- }
109
86
  async function deleteChannelOnAppAsync({ channelId, }) {
110
87
  const data = await (0, client_1.withErrorHandlingAsync)(client_1.graphqlClient
111
88
  .mutation((0, graphql_tag_1.default) `
@@ -1,10 +1,6 @@
1
1
  import EasCommand from '../../commandUtils/EasCommand';
2
- import { UpdateChannelBranchMappingMutationVariables } from '../../graphql/generated';
3
- export declare function updateChannelBranchMappingAsync({ channelId, branchMapping, }: UpdateChannelBranchMappingMutationVariables): Promise<{
4
- id: string;
5
- name: string;
6
- branchMapping: string;
7
- }>;
2
+ import { UpdateChannelBranchMappingMutation, UpdateChannelBranchMappingMutationVariables } from '../../graphql/generated';
3
+ export declare function updateChannelBranchMappingAsync({ channelId, branchMapping, }: UpdateChannelBranchMappingMutationVariables): Promise<UpdateChannelBranchMappingMutation['updateChannel']['editUpdateChannel']>;
8
4
  export default class ChannelEdit extends EasCommand {
9
5
  static description: string;
10
6
  static args: {
@@ -13,8 +9,12 @@ export default class ChannelEdit extends EasCommand {
13
9
  description: string;
14
10
  }[];
15
11
  static flags: {
16
- branch: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
17
12
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
+ branch: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
15
+ };
16
+ static contextDefinition: {
17
+ projectConfig: import("../../commandUtils/context/ProjectConfigContextField").default;
18
18
  };
19
19
  runAsync(): Promise<void>;
20
20
  }
@@ -1,45 +1,20 @@
1
1
  "use strict";
2
+ var _a;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.updateChannelBranchMappingAsync = void 0;
4
5
  const tslib_1 = require("tslib");
5
6
  const core_1 = require("@oclif/core");
6
7
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
8
  const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
9
+ const queries_1 = require("../../branch/queries");
10
+ const queries_2 = require("../../channel/queries");
8
11
  const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
12
+ const flags_1 = require("../../commandUtils/flags");
9
13
  const client_1 = require("../../graphql/client");
10
14
  const BranchQuery_1 = require("../../graphql/queries/BranchQuery");
15
+ const ChannelQuery_1 = require("../../graphql/queries/ChannelQuery");
11
16
  const log_1 = tslib_1.__importDefault(require("../../log"));
12
- const expoConfig_1 = require("../../project/expoConfig");
13
- const projectUtils_1 = require("../../project/projectUtils");
14
- const prompts_1 = require("../../prompts");
15
17
  const json_1 = require("../../utils/json");
16
- async function getChannelByNameForAppAsync({ appId, channelName, }) {
17
- var _a;
18
- const data = await (0, client_1.withErrorHandlingAsync)(client_1.graphqlClient
19
- .query((0, graphql_tag_1.default) `
20
- query GetChannelByNameToEdit($appId: String!, $channelName: String!) {
21
- app {
22
- byId(appId: $appId) {
23
- id
24
- updateChannelByName(name: $channelName) {
25
- id
26
- name
27
- updateBranches(offset: 0, limit: 1) {
28
- id
29
- name
30
- }
31
- }
32
- }
33
- }
34
- }
35
- `, { appId, channelName }, { additionalTypenames: ['UpdateChannel', 'UpdateBranch'] })
36
- .toPromise());
37
- const updateChannelByNameResult = (_a = data.app) === null || _a === void 0 ? void 0 : _a.byId.updateChannelByName;
38
- if (!updateChannelByNameResult) {
39
- throw new Error(`Could not find a channel named ${channelName} on app with id ${appId}`);
40
- }
41
- return updateChannelByNameResult;
42
- }
43
18
  async function updateChannelBranchMappingAsync({ channelId, branchMapping, }) {
44
19
  const data = await (0, client_1.withErrorHandlingAsync)(client_1.graphqlClient
45
20
  .mutation((0, graphql_tag_1.default) `
@@ -58,32 +33,43 @@ async function updateChannelBranchMappingAsync({ channelId, branchMapping, }) {
58
33
  if (!channel) {
59
34
  throw new Error(`Could not find a channel with id: ${channelId}`);
60
35
  }
61
- return data.updateChannel.editUpdateChannel;
36
+ return channel;
62
37
  }
63
38
  exports.updateChannelBranchMappingAsync = updateChannelBranchMappingAsync;
64
39
  class ChannelEdit extends EasCommand_1.default {
65
40
  async runAsync() {
66
- var _a, _b;
67
- const { args, flags } = await this.parse(ChannelEdit);
68
- if (flags.json) {
41
+ const { args, flags: { branch: branchFlag, json, 'non-interactive': nonInteractive }, } = await this.parse(ChannelEdit);
42
+ const { projectConfig: { projectId }, } = await this.getContextAsync(ChannelEdit, {
43
+ nonInteractive,
44
+ });
45
+ if (json) {
69
46
  (0, json_1.enableJsonOutput)();
70
47
  }
71
- const projectDir = await (0, projectUtils_1.findProjectRootAsync)();
72
- const exp = (0, expoConfig_1.getExpoConfig)(projectDir);
73
- const projectId = await (0, projectUtils_1.getProjectIdAsync)(exp);
74
- const channelName = (_a = args.name) !== null && _a !== void 0 ? _a : (await promptForChannelAsync());
75
- const existingChannel = await getChannelByNameForAppAsync({ appId: projectId, channelName });
48
+ const existingChannel = args.name
49
+ ? await ChannelQuery_1.ChannelQuery.viewUpdateChannelAsync({ appId: projectId, channelName: args.name })
50
+ : await (0, queries_2.selectChannelOnAppAsync)({
51
+ projectId,
52
+ selectionPromptTitle: 'Select a channel to edit',
53
+ paginatedQueryOptions: { json, nonInteractive, offset: 0 },
54
+ });
76
55
  if (existingChannel.updateBranches.length > 1) {
77
56
  throw new Error('There is a rollout in progress. Manage it with "channel:rollout" instead.');
78
57
  }
79
- const branchName = (_b = flags.branch) !== null && _b !== void 0 ? _b : (await promptForBranchAsync());
80
- const branch = await BranchQuery_1.BranchQuery.getBranchByNameAsync({
81
- appId: projectId,
82
- name: branchName,
83
- });
84
- if (!branch) {
85
- throw new Error(`Could not find a branch named "${branchName}". Check what branches exist on this project with ${chalk_1.default.bold('eas branch:list')}.`);
86
- }
58
+ const branch = branchFlag
59
+ ? await BranchQuery_1.BranchQuery.getBranchByNameAsync({
60
+ appId: projectId,
61
+ name: branchFlag,
62
+ })
63
+ : await (0, queries_1.selectBranchOnAppAsync)({
64
+ projectId,
65
+ promptTitle: `Which branch would you like ${existingChannel.name} to point at?`,
66
+ displayTextForListItem: updateBranch => updateBranch.name,
67
+ paginatedQueryOptions: {
68
+ json,
69
+ nonInteractive,
70
+ offset: 0,
71
+ },
72
+ });
87
73
  const channel = await updateChannelBranchMappingAsync({
88
74
  channelId: existingChannel.id,
89
75
  // todo: move branch mapping logic to utility
@@ -92,7 +78,7 @@ class ChannelEdit extends EasCommand_1.default {
92
78
  version: 0,
93
79
  }),
94
80
  });
95
- if (flags.json) {
81
+ if (json) {
96
82
  (0, json_1.printJsonOnlyOutput)(channel);
97
83
  }
98
84
  else {
@@ -103,6 +89,7 @@ class ChannelEdit extends EasCommand_1.default {
103
89
  }
104
90
  }
105
91
  exports.default = ChannelEdit;
92
+ _a = ChannelEdit;
106
93
  ChannelEdit.description = 'point a channel at a new branch';
107
94
  ChannelEdit.args = [
108
95
  {
@@ -115,28 +102,8 @@ ChannelEdit.flags = {
115
102
  branch: core_1.Flags.string({
116
103
  description: 'Name of the branch to point to',
117
104
  }),
118
- json: core_1.Flags.boolean({
119
- description: 'Print output as a JSON object with the channel ID, name and branch mapping',
120
- default: false,
121
- }),
105
+ ...flags_1.EasNonInteractiveAndJsonFlags,
106
+ };
107
+ ChannelEdit.contextDefinition = {
108
+ ..._a.ContextOptions.ProjectConfig,
122
109
  };
123
- async function promptForChannelAsync() {
124
- log_1.default.addNewLineIfNone();
125
- const { name } = await (0, prompts_1.promptAsync)({
126
- type: 'text',
127
- name: 'name',
128
- message: 'Provide the name of the channel to edit:',
129
- validate: value => (value ? true : 'The channel name may not be empty.'),
130
- });
131
- return name;
132
- }
133
- async function promptForBranchAsync() {
134
- log_1.default.addNewLineIfNone();
135
- const { name } = await (0, prompts_1.promptAsync)({
136
- type: 'text',
137
- name: 'name',
138
- message: `To which branch should the channel link?`,
139
- validate: value => (value ? true : 'The branch name may not be empty.'),
140
- });
141
- return name;
142
- }