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
@@ -18,6 +18,7 @@ const remoteVersionSource_1 = require("../project/remoteVersionSource");
18
18
  const context_1 = require("../submit/context");
19
19
  const submit_1 = require("../submit/submit");
20
20
  const urls_1 = require("../submit/utils/urls");
21
+ const utils_1 = require("../update/utils");
21
22
  const json_1 = require("../utils/json");
22
23
  const profiles_1 = require("../utils/profiles");
23
24
  const vcs_1 = require("../vcs");
@@ -42,7 +43,7 @@ const platformToGraphQLResourceClassMapping = {
42
43
  [types_1.UserInputResourceClass.LARGE]: generated_1.BuildResourceClass.IosLarge,
43
44
  },
44
45
  };
45
- async function runBuildAndSubmitAsync(projectDir, flags) {
46
+ async function runBuildAndSubmitAsync(projectDir, flags, actor, getDynamicProjectConfigAsync) {
46
47
  var _a, _b, _c;
47
48
  await (0, vcs_1.getVcsClient)().ensureRepoExistsAsync();
48
49
  await (0, repository_1.ensureRepoIsCleanAsync)(flags.nonInteractive);
@@ -50,12 +51,12 @@ async function runBuildAndSubmitAsync(projectDir, flags) {
50
51
  projectDir,
51
52
  nonInteractive: flags.nonInteractive,
52
53
  });
53
- const easJsonReader = new eas_json_1.EasJsonReader(projectDir);
54
- const easJsonCliConfig = (_a = (await easJsonReader.getCliConfigAsync())) !== null && _a !== void 0 ? _a : {};
54
+ const easJsonAccessor = new eas_json_1.EasJsonAccessor(projectDir);
55
+ const easJsonCliConfig = (_a = (await eas_json_1.EasJsonUtils.getCliConfigAsync(easJsonAccessor))) !== null && _a !== void 0 ? _a : {};
55
56
  const platforms = (0, platform_1.toPlatforms)(flags.requestedPlatform);
56
57
  const buildProfiles = await (0, profiles_1.getProfilesAsync)({
57
58
  type: 'build',
58
- easJsonReader,
59
+ easJsonAccessor,
59
60
  platforms,
60
61
  profileName: (_b = flags.profile) !== null && _b !== void 0 ? _b : undefined,
61
62
  });
@@ -77,6 +78,8 @@ async function runBuildAndSubmitAsync(projectDir, flags) {
77
78
  buildProfile,
78
79
  resourceClass: platformToGraphQLResourceClassMapping[buildProfile.platform][(_c = flags.userInputResourceClass) !== null && _c !== void 0 ? _c : types_1.UserInputResourceClass.DEFAULT],
79
80
  easJsonCliConfig,
81
+ actor,
82
+ getDynamicProjectConfigAsync,
80
83
  });
81
84
  if (maybeBuild) {
82
85
  startedBuilds.push({ build: maybeBuild, buildProfile });
@@ -92,7 +95,7 @@ async function runBuildAndSubmitAsync(projectDir, flags) {
92
95
  const submissions = [];
93
96
  if (flags.autoSubmit) {
94
97
  const submitProfiles = await (0, profiles_1.getProfilesAsync)({
95
- easJsonReader,
98
+ easJsonAccessor,
96
99
  platforms,
97
100
  profileName: flags.submitProfile,
98
101
  type: 'submit',
@@ -147,7 +150,7 @@ async function runBuildAndSubmitAsync(projectDir, flags) {
147
150
  }
148
151
  }
149
152
  exports.runBuildAndSubmitAsync = runBuildAndSubmitAsync;
150
- async function prepareAndStartBuildAsync({ projectDir, flags, moreBuilds, buildProfile, resourceClass, easJsonCliConfig, }) {
153
+ async function prepareAndStartBuildAsync({ projectDir, flags, moreBuilds, buildProfile, resourceClass, easJsonCliConfig, actor, getDynamicProjectConfigAsync, }) {
151
154
  const buildCtx = await (0, createContext_1.createBuildContextAsync)({
152
155
  buildProfileName: buildProfile.profileName,
153
156
  resourceClass,
@@ -160,12 +163,15 @@ async function prepareAndStartBuildAsync({ projectDir, flags, moreBuilds, buildP
160
163
  localBuildOptions: flags.localBuildOptions,
161
164
  easJsonCliConfig,
162
165
  message: flags.message,
166
+ actor,
167
+ getDynamicProjectConfigAsync,
163
168
  });
164
169
  if (moreBuilds) {
165
170
  log_1.default.newLine();
166
171
  const appPlatform = (0, AppPlatform_1.toAppPlatform)(buildProfile.platform);
167
172
  log_1.default.log(`${platform_1.appPlatformEmojis[appPlatform]} ${chalk_1.default.bold(`${platform_1.appPlatformDisplayNames[appPlatform]} build`)}`);
168
173
  }
174
+ await (0, utils_1.validateBuildProfileConfigMatchesProjectConfigAsync)(buildCtx.exp, buildProfile, buildCtx.projectId, flags.nonInteractive);
169
175
  await (0, projectUtils_1.validateAppVersionRuntimePolicySupportAsync)(buildCtx.projectDir, buildCtx.exp);
170
176
  if ((easJsonCliConfig === null || easJsonCliConfig === void 0 ? void 0 : easJsonCliConfig.appVersionSource) === eas_json_1.AppVersionSource.REMOTE) {
171
177
  (0, remoteVersionSource_1.validateAppConfigForRemoteVersionSource)(buildCtx.exp, buildProfile.platform);
@@ -202,13 +208,15 @@ async function prepareAndStartSubmissionAsync({ build, buildCtx, moreBuilds, pro
202
208
  const submissionCtx = await (0, context_1.createSubmissionContextAsync)({
203
209
  platform,
204
210
  projectDir,
205
- projectId: build.project.id,
206
211
  profile: submitProfile,
207
212
  archiveFlags: { id: build.id },
208
213
  nonInteractive,
209
214
  env: buildProfile.env,
210
215
  credentialsCtx: buildCtx.credentialsCtx,
211
216
  applicationIdentifier: (_b = (_a = buildCtx.android) === null || _a === void 0 ? void 0 : _a.applicationId) !== null && _b !== void 0 ? _b : (_c = buildCtx.ios) === null || _c === void 0 ? void 0 : _c.bundleIdentifier,
217
+ actor: buildCtx.user,
218
+ projectId: buildCtx.projectId,
219
+ exp: buildCtx.exp,
212
220
  });
213
221
  if (moreBuilds) {
214
222
  log_1.default.newLine();
@@ -58,7 +58,11 @@ async function commitPromptAsync({ initialCommitMessage, commitAllFiles, } = {})
58
58
  initial: initialCommitMessage,
59
59
  validate: (input) => input !== '',
60
60
  });
61
- await (0, vcs_1.getVcsClient)().commitAsync({ commitAllFiles, commitMessage: message });
61
+ await (0, vcs_1.getVcsClient)().commitAsync({
62
+ commitAllFiles,
63
+ commitMessage: message,
64
+ nonInteractive: false,
65
+ });
62
66
  }
63
67
  exports.commitPromptAsync = commitPromptAsync;
64
68
  async function makeProjectTarballAsync() {
@@ -0,0 +1,17 @@
1
+ import { PaginatedQueryOptions } from '../commandUtils/pagination';
2
+ import { UpdateChannelObject } from '../graphql/queries/ChannelQuery';
3
+ export declare const CHANNELS_LIMIT = 25;
4
+ export declare function selectChannelOnAppAsync({ projectId, selectionPromptTitle, paginatedQueryOptions, }: {
5
+ projectId: string;
6
+ selectionPromptTitle: string;
7
+ paginatedQueryOptions: PaginatedQueryOptions;
8
+ }): Promise<UpdateChannelObject>;
9
+ export declare function listAndRenderChannelsOnAppAsync({ projectId, paginatedQueryOptions, }: {
10
+ projectId: string;
11
+ paginatedQueryOptions: PaginatedQueryOptions;
12
+ }): Promise<void>;
13
+ export declare function listAndRenderBranchesAndUpdatesOnChannelAsync({ projectId: appId, channelName, paginatedQueryOptions, }: {
14
+ projectId: string;
15
+ channelName: string;
16
+ paginatedQueryOptions: PaginatedQueryOptions;
17
+ }): Promise<void>;
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listAndRenderBranchesAndUpdatesOnChannelAsync = exports.listAndRenderChannelsOnAppAsync = exports.selectChannelOnAppAsync = exports.CHANNELS_LIMIT = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
+ const BranchQuery_1 = require("../graphql/queries/BranchQuery");
7
+ const ChannelQuery_1 = require("../graphql/queries/ChannelQuery");
8
+ const log_1 = tslib_1.__importDefault(require("../log"));
9
+ const formatFields_1 = tslib_1.__importDefault(require("../utils/formatFields"));
10
+ const json_1 = require("../utils/json");
11
+ const queries_1 = require("../utils/queries");
12
+ const utils_1 = require("./utils");
13
+ exports.CHANNELS_LIMIT = 25;
14
+ async function selectChannelOnAppAsync({ projectId, selectionPromptTitle, paginatedQueryOptions, }) {
15
+ var _a;
16
+ if (paginatedQueryOptions.nonInteractive) {
17
+ throw new Error('Unable to select a channel in non-interactive mode.');
18
+ }
19
+ const updateChannel = await (0, queries_1.paginatedQueryWithSelectPromptAsync)({
20
+ limit: (_a = paginatedQueryOptions.limit) !== null && _a !== void 0 ? _a : exports.CHANNELS_LIMIT,
21
+ offset: paginatedQueryOptions.offset,
22
+ queryToPerform: (limit, offset) => queryChannelsOnAppAsync({ appId: projectId, limit, offset }),
23
+ promptOptions: {
24
+ title: selectionPromptTitle,
25
+ createDisplayTextForSelectionPromptListItem: updateChannel => updateChannel.name,
26
+ getIdentifierForQueryItem: updateChannel => updateChannel.id,
27
+ },
28
+ });
29
+ if (!updateChannel) {
30
+ throw new Error(`Could not find any channels for app "${projectId}"`);
31
+ }
32
+ return updateChannel;
33
+ }
34
+ exports.selectChannelOnAppAsync = selectChannelOnAppAsync;
35
+ async function listAndRenderChannelsOnAppAsync({ projectId, paginatedQueryOptions, }) {
36
+ var _a, _b;
37
+ if (paginatedQueryOptions.nonInteractive) {
38
+ const channels = await queryChannelsOnAppAsync({
39
+ appId: projectId,
40
+ limit: (_a = paginatedQueryOptions.limit) !== null && _a !== void 0 ? _a : exports.CHANNELS_LIMIT,
41
+ offset: paginatedQueryOptions.offset,
42
+ });
43
+ renderPageOfChannels(channels, paginatedQueryOptions);
44
+ }
45
+ else {
46
+ await (0, queries_1.paginatedQueryWithConfirmPromptAsync)({
47
+ limit: (_b = paginatedQueryOptions.limit) !== null && _b !== void 0 ? _b : exports.CHANNELS_LIMIT,
48
+ offset: paginatedQueryOptions.offset,
49
+ queryToPerform: (limit, offset) => queryChannelsOnAppAsync({ limit, offset, appId: projectId }),
50
+ promptOptions: {
51
+ title: 'Load more channels?',
52
+ renderListItems: channels => renderPageOfChannels(channels, paginatedQueryOptions),
53
+ },
54
+ });
55
+ }
56
+ }
57
+ exports.listAndRenderChannelsOnAppAsync = listAndRenderChannelsOnAppAsync;
58
+ async function listAndRenderBranchesAndUpdatesOnChannelAsync({ projectId: appId, channelName, paginatedQueryOptions, }) {
59
+ var _a, _b;
60
+ const channel = await ChannelQuery_1.ChannelQuery.viewUpdateChannelAsync({ appId, channelName });
61
+ renderChannelHeaderContent({ channelName: channel.name, channelId: channel.id });
62
+ if (paginatedQueryOptions.nonInteractive) {
63
+ const branches = await queryBranchesAndUpdateGroupsOnChannelAsync({
64
+ appId,
65
+ channelName,
66
+ offset: paginatedQueryOptions.offset,
67
+ limit: (_a = paginatedQueryOptions.limit) !== null && _a !== void 0 ? _a : exports.CHANNELS_LIMIT,
68
+ });
69
+ renderPageOfBranchesOnChannel(channel, branches, paginatedQueryOptions);
70
+ }
71
+ else {
72
+ await (0, queries_1.paginatedQueryWithConfirmPromptAsync)({
73
+ limit: (_b = paginatedQueryOptions.limit) !== null && _b !== void 0 ? _b : exports.CHANNELS_LIMIT,
74
+ offset: paginatedQueryOptions.offset,
75
+ queryToPerform: (limit, offset) => queryBranchesAndUpdateGroupsOnChannelAsync({
76
+ channelName,
77
+ appId,
78
+ offset,
79
+ limit,
80
+ }),
81
+ promptOptions: {
82
+ title: 'Load more channels?',
83
+ renderListItems: branches => renderPageOfBranchesOnChannel(channel, branches, paginatedQueryOptions),
84
+ },
85
+ });
86
+ }
87
+ }
88
+ exports.listAndRenderBranchesAndUpdatesOnChannelAsync = listAndRenderBranchesAndUpdatesOnChannelAsync;
89
+ async function queryChannelsOnAppAsync({ appId, offset, limit, }) {
90
+ return await ChannelQuery_1.ChannelQuery.viewUpdateChannelsOnAppAsync({
91
+ appId,
92
+ offset,
93
+ limit,
94
+ });
95
+ }
96
+ async function queryBranchesAndUpdateGroupsOnChannelAsync(args) {
97
+ return await BranchQuery_1.BranchQuery.listBranchesOnChannelAsync(args);
98
+ }
99
+ function renderPageOfChannels(currentPage, { json }) {
100
+ if (json) {
101
+ (0, json_1.printJsonOnlyOutput)({ currentPage });
102
+ }
103
+ else {
104
+ for (const channel of currentPage) {
105
+ log_1.default.addNewLineIfNone();
106
+ log_1.default.log((0, formatFields_1.default)([
107
+ { label: 'Name', value: channel.name },
108
+ { label: 'ID', value: channel.id },
109
+ ]));
110
+ (0, utils_1.logChannelDetails)(channel);
111
+ }
112
+ }
113
+ }
114
+ function renderPageOfBranchesOnChannel(channel, currentPage, { json }) {
115
+ const channelWithNewBranches = { ...channel, updateBranches: currentPage };
116
+ if (json) {
117
+ (0, json_1.printJsonOnlyOutput)({ currentPage: channelWithNewBranches });
118
+ }
119
+ else {
120
+ log_1.default.addNewLineIfNone();
121
+ log_1.default.log((0, formatFields_1.default)([
122
+ { label: 'Name', value: channel.name },
123
+ { label: 'ID', value: channel.id },
124
+ ]));
125
+ (0, utils_1.logChannelDetails)(channelWithNewBranches);
126
+ }
127
+ }
128
+ function renderChannelHeaderContent({ channelName, channelId, }) {
129
+ log_1.default.addNewLineIfNone();
130
+ log_1.default.log(chalk_1.default.bold('Channel:'));
131
+ log_1.default.log((0, formatFields_1.default)([
132
+ { label: 'Name', value: channelName },
133
+ { label: 'ID', value: channelId },
134
+ ]));
135
+ log_1.default.addNewLineIfNone();
136
+ log_1.default.log((0, chalk_1.default) `{bold Branches pointed at this channel and their most recent update group:}`);
137
+ }
@@ -0,0 +1,22 @@
1
+ import { UpdateChannelObject } from '../graphql/queries/ChannelQuery';
2
+ export declare type BranchMapping = {
3
+ version: number;
4
+ data: {
5
+ branchId: string;
6
+ branchMappingLogic: {
7
+ operand: number;
8
+ clientKey: string;
9
+ branchMappingOperator: string;
10
+ } & string;
11
+ }[];
12
+ };
13
+ /**
14
+ * Get the branch mapping and determine whether it is a rollout.
15
+ * Ensure that the branch mapping is properly formatted.
16
+ */
17
+ export declare function getBranchMapping(branchMappingString?: string): {
18
+ branchMapping: BranchMapping;
19
+ isRollout: boolean;
20
+ rolloutPercent?: number;
21
+ };
22
+ export declare function logChannelDetails(channel: UpdateChannelObject): void;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logChannelDetails = exports.getBranchMapping = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const assert_1 = tslib_1.__importDefault(require("assert"));
6
+ const cli_table3_1 = tslib_1.__importDefault(require("cli-table3"));
7
+ const log_1 = tslib_1.__importDefault(require("../log"));
8
+ const utils_1 = require("../update/utils");
9
+ /**
10
+ * Get the branch mapping and determine whether it is a rollout.
11
+ * Ensure that the branch mapping is properly formatted.
12
+ */
13
+ function getBranchMapping(branchMappingString) {
14
+ if (!branchMappingString) {
15
+ throw new Error('Missing branch mapping.');
16
+ }
17
+ let branchMapping;
18
+ try {
19
+ branchMapping = JSON.parse(branchMappingString);
20
+ }
21
+ catch {
22
+ throw new Error(`Could not parse branchMapping string into a JSON: "${branchMappingString}"`);
23
+ }
24
+ (0, assert_1.default)(branchMapping, 'Branch Mapping must be defined.');
25
+ if (branchMapping.version !== 0) {
26
+ throw new Error('Branch mapping must be version 0.');
27
+ }
28
+ const isRollout = branchMapping.data.length === 2;
29
+ const rolloutPercent = branchMapping.data[0].branchMappingLogic.operand;
30
+ switch (branchMapping.data.length) {
31
+ case 0:
32
+ break;
33
+ case 1:
34
+ if (branchMapping.data[0].branchMappingLogic !== 'true') {
35
+ throw new Error('Branch mapping logic for a single branch must be "true"');
36
+ }
37
+ break;
38
+ case 2:
39
+ if (branchMapping.data[0].branchMappingLogic.clientKey !== 'rolloutToken') {
40
+ throw new Error('Client key of initial branch mapping must be "rolloutToken"');
41
+ }
42
+ if (branchMapping.data[0].branchMappingLogic.branchMappingOperator !== 'hash_lt') {
43
+ throw new Error('Branch mapping operator of initial branch mapping must be "hash_lt"');
44
+ }
45
+ if (rolloutPercent == null) {
46
+ throw new Error('Branch mapping is missing a "rolloutPercent"');
47
+ }
48
+ if (branchMapping.data[1].branchMappingLogic !== 'true') {
49
+ throw new Error('Branch mapping logic for a the second branch of a rollout must be "true"');
50
+ }
51
+ break;
52
+ default:
53
+ throw new Error('Branch mapping data must have length less than or equal to 2.');
54
+ }
55
+ return { branchMapping, isRollout, rolloutPercent };
56
+ }
57
+ exports.getBranchMapping = getBranchMapping;
58
+ function logChannelDetails(channel) {
59
+ const { branchMapping, isRollout, rolloutPercent } = getBranchMapping(channel.branchMapping);
60
+ const updateChannelsTable = new cli_table3_1.default({
61
+ head: ['branch', ...(isRollout ? ['rollout percent'] : []), ...utils_1.UPDATE_COLUMNS],
62
+ wordWrap: true,
63
+ });
64
+ if (branchMapping.data.length > 2) {
65
+ throw new Error('Branch Mapping data must have length less than or equal to 2.');
66
+ }
67
+ const rolloutBranchIds = branchMapping.data.map(data => data.branchId);
68
+ for (const currentBranch of channel.updateBranches) {
69
+ const updateGroupDescriptions = (0, utils_1.getUpdateGroupDescriptionsWithBranch)(currentBranch.updateGroups);
70
+ const isRolloutBranch = isRollout && rolloutBranchIds.includes(currentBranch.id);
71
+ const isBaseBranch = rolloutBranchIds.length > 0 && rolloutBranchIds[0] === currentBranch.id;
72
+ updateGroupDescriptions.forEach(({ branch, message, runtimeVersion, group, platforms }) => {
73
+ updateChannelsTable.push([
74
+ branch,
75
+ ...(isRolloutBranch
76
+ ? [isBaseBranch ? `${rolloutPercent * 100}%` : `${(1 - rolloutPercent) * 100}%`]
77
+ : []),
78
+ message,
79
+ runtimeVersion,
80
+ group,
81
+ platforms,
82
+ ]);
83
+ });
84
+ }
85
+ log_1.default.log(updateChannelsTable.toString());
86
+ }
87
+ exports.logChannelDetails = logChannelDetails;
@@ -1,15 +1,76 @@
1
1
  import { Command } from '@oclif/core';
2
+ import ActorContextField from './context/ActorContextField';
3
+ import ContextField from './context/ContextField';
4
+ import { DynamicProjectConfigContextField } from './context/DynamicProjectConfigContextField';
5
+ import { OptionalProjectConfigContextField } from './context/OptionalProjectConfigContextField';
6
+ import ProjectConfigContextField from './context/ProjectConfigContextField';
7
+ import ProjectDirContextField from './context/ProjectDirContextField';
8
+ declare type ContextInput<T extends {
9
+ [name: string]: any;
10
+ } = object> = {
11
+ [P in keyof T]: ContextField<T[P]>;
12
+ };
13
+ declare type ContextOutput<T extends {
14
+ [name: string]: any;
15
+ } = object> = {
16
+ [P in keyof T]: T[P];
17
+ };
2
18
  export default abstract class EasCommand extends Command {
19
+ protected static readonly ContextOptions: {
20
+ /**
21
+ * Require this command to be run when logged-in. Returns the logged-in actor in the context.
22
+ */
23
+ LoggedIn: {
24
+ actor: ActorContextField;
25
+ };
26
+ /**
27
+ * Require the project to be identified and registered on server if this command is being
28
+ * run within a project directory, null otherwise.
29
+ */
30
+ OptionalProjectConfig: {
31
+ projectConfig: OptionalProjectConfigContextField;
32
+ };
33
+ /**
34
+ * Require this command to be run in a project directory. Return the project directory in the context.
35
+ */
36
+ ProjectDir: {
37
+ projectDir: ProjectDirContextField;
38
+ };
39
+ /**
40
+ * Provides functions to load the project config when dynamic config options are needed (custom Env for example).
41
+ */
42
+ DynamicProjectConfig: {
43
+ getDynamicProjectConfigAsync: DynamicProjectConfigContextField;
44
+ };
45
+ /**
46
+ * Require the project to be identified and registered on server. Returns the project config in the context.
47
+ */
48
+ ProjectConfig: {
49
+ projectConfig: ProjectConfigContextField;
50
+ };
51
+ };
3
52
  /**
4
- * When user data is unavailable locally, determines if the command will
5
- * force the user to log in
53
+ * Context allows for subclasses (commands) to declare their prerequisites in a type-safe manner.
54
+ * These declarative definitions each output a context property that is the result of the prerequisite being
55
+ * satisfied. These allow a unified common interface to be shared amongst commands in order to provide a more
56
+ * consistent CLI experience.
57
+ *
58
+ * For example, let's say a command needs the EAS project ID to make a GraphQL mutation. It should declare that
59
+ * it requires the `ProjectConfig` context, and then call `getContextAsync` to get the project ID.
6
60
  */
7
- protected requiresAuthentication: boolean;
8
- protected mustBeRunInsideProject: boolean;
61
+ static contextDefinition: ContextInput;
62
+ /**
63
+ * Execute the context in the contextDefinition to satisfy command prerequisites.
64
+ */
65
+ protected getContextAsync<C extends {
66
+ [name: string]: any;
67
+ } = object>(commandClass: {
68
+ contextDefinition: ContextInput<C>;
69
+ }, { nonInteractive }: {
70
+ nonInteractive: boolean;
71
+ }): Promise<ContextOutput<C>>;
9
72
  protected abstract runAsync(): Promise<any>;
10
73
  run(): Promise<any>;
11
74
  finally(err: Error): Promise<any>;
12
- private applyCliConfigAsync;
13
- private ensureEasCliIsNotInDependenciesAsync;
14
- private isEasCliInDependenciesAsync;
15
75
  }
76
+ export {};
@@ -1,48 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const eas_json_1 = require("@expo/eas-json");
5
- const PackageManagerUtils = tslib_1.__importStar(require("@expo/package-manager"));
6
4
  const core_1 = require("@oclif/core");
7
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
9
- const path_1 = tslib_1.__importDefault(require("path"));
10
- const semver_1 = tslib_1.__importDefault(require("semver"));
11
5
  const rudderstackClient_1 = require("../analytics/rudderstackClient");
12
- const log_1 = require("../log");
13
- const projectUtils_1 = require("../project/projectUtils");
14
6
  const User_1 = require("../user/User");
15
- const actions_1 = require("../user/actions");
16
- const easCli_1 = require("../utils/easCli");
17
- const vcs_1 = require("../vcs");
18
- const git_1 = tslib_1.__importDefault(require("../vcs/clients/git"));
7
+ const ActorContextField_1 = tslib_1.__importDefault(require("./context/ActorContextField"));
8
+ const DynamicProjectConfigContextField_1 = require("./context/DynamicProjectConfigContextField");
9
+ const OptionalProjectConfigContextField_1 = require("./context/OptionalProjectConfigContextField");
10
+ const ProjectConfigContextField_1 = tslib_1.__importDefault(require("./context/ProjectConfigContextField"));
11
+ const ProjectDirContextField_1 = tslib_1.__importDefault(require("./context/ProjectDirContextField"));
19
12
  class EasCommand extends core_1.Command {
20
- constructor() {
21
- super(...arguments);
22
- /**
23
- * When user data is unavailable locally, determines if the command will
24
- * force the user to log in
25
- */
26
- this.requiresAuthentication = true;
27
- this.mustBeRunInsideProject = true;
13
+ /**
14
+ * Execute the context in the contextDefinition to satisfy command prerequisites.
15
+ */
16
+ async getContextAsync(commandClass, { nonInteractive }) {
17
+ const contextDefinition = commandClass.contextDefinition;
18
+ const contextValuePairs = await Promise.all(Object.keys(contextDefinition).map(async (contextKey) => {
19
+ return [contextKey, await contextDefinition[contextKey].getValueAsync({ nonInteractive })];
20
+ }));
21
+ return Object.fromEntries(contextValuePairs);
28
22
  }
29
23
  // eslint-disable-next-line async-protect/async-suffix
30
24
  async run() {
31
- var _a;
32
25
  await (0, rudderstackClient_1.initAsync)();
33
- if (this.mustBeRunInsideProject) {
34
- const projectDir = await (0, projectUtils_1.findProjectRootAsync)();
35
- await this.applyCliConfigAsync(projectDir);
36
- await this.ensureEasCliIsNotInDependenciesAsync(projectDir);
37
- }
38
- if (this.requiresAuthentication) {
39
- const { flags } = await this.parse();
40
- const nonInteractive = (_a = flags['non-interactive']) !== null && _a !== void 0 ? _a : false;
41
- await (0, actions_1.ensureLoggedInAsync)({ nonInteractive });
42
- }
43
- else {
44
- await (0, User_1.getUserAsync)();
45
- }
26
+ // this is needed for logEvent call below as it identifies the user in the analytics system
27
+ await (0, User_1.getUserAsync)();
46
28
  (0, rudderstackClient_1.logEvent)(rudderstackClient_1.AnalyticsEvent.ACTION, {
47
29
  // id is assigned by oclif in constructor based on the filepath:
48
30
  // commands/submit === submit, commands/build/list === build:list
@@ -55,50 +37,49 @@ class EasCommand extends core_1.Command {
55
37
  await (0, rudderstackClient_1.flushAsync)();
56
38
  return super.finally(err);
57
39
  }
58
- async applyCliConfigAsync(projectDir) {
59
- const easJsonReader = new eas_json_1.EasJsonReader(projectDir);
60
- const config = await easJsonReader.getCliConfigAsync();
61
- if ((config === null || config === void 0 ? void 0 : config.version) && !semver_1.default.satisfies(easCli_1.easCliVersion, config.version)) {
62
- throw new Error(`You are on eas-cli@${easCli_1.easCliVersion} which does not satisfy the CLI version constraint in eas.json (${config.version})`);
63
- }
64
- if (config === null || config === void 0 ? void 0 : config.requireCommit) {
65
- (0, vcs_1.setVcsClient)(new git_1.default());
66
- }
67
- }
68
- async ensureEasCliIsNotInDependenciesAsync(projectDir) {
69
- var _a;
70
- let printCliVersionWarning = false;
71
- const consoleWarn = (msg) => {
72
- if (msg) {
73
- // eslint-disable-next-line no-console
74
- console.warn(chalk_1.default.yellow(msg));
75
- }
76
- else {
77
- // eslint-disable-next-line no-console
78
- console.warn();
79
- }
80
- };
81
- if (await this.isEasCliInDependenciesAsync(projectDir)) {
82
- printCliVersionWarning = true;
83
- consoleWarn(`Found ${chalk_1.default.bold('eas-cli')} in your project dependencies.`);
84
- }
85
- const maybeRepoRoot = (_a = PackageManagerUtils.findWorkspaceRoot(projectDir)) !== null && _a !== void 0 ? _a : projectDir;
86
- if (maybeRepoRoot !== projectDir && (await this.isEasCliInDependenciesAsync(maybeRepoRoot))) {
87
- printCliVersionWarning = true;
88
- consoleWarn(`Found ${chalk_1.default.bold('eas-cli')} in your monorepo dependencies.`);
89
- }
90
- if (printCliVersionWarning) {
91
- consoleWarn(`It's recommended to use the ${chalk_1.default.bold('"cli.version"')} field in eas.json to enforce the ${chalk_1.default.bold('eas-cli')} version for your project.`);
92
- consoleWarn((0, log_1.learnMore)('https://github.com/expo/eas-cli#enforcing-eas-cli-version-for-your-project'));
93
- consoleWarn();
94
- }
95
- }
96
- async isEasCliInDependenciesAsync(dir) {
97
- var _a, _b;
98
- const packageJsonPath = path_1.default.join(dir, 'package.json');
99
- const packageJson = JSON.parse(await fs_extra_1.default.readFile(packageJsonPath, 'utf8'));
100
- return (((_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.dependencies) === null || _a === void 0 ? void 0 : _a['eas-cli']) !== undefined ||
101
- ((_b = packageJson === null || packageJson === void 0 ? void 0 : packageJson.devDependencies) === null || _b === void 0 ? void 0 : _b['eas-cli']) !== undefined);
102
- }
103
40
  }
104
41
  exports.default = EasCommand;
42
+ EasCommand.ContextOptions = {
43
+ /**
44
+ * Require this command to be run when logged-in. Returns the logged-in actor in the context.
45
+ */
46
+ LoggedIn: {
47
+ actor: new ActorContextField_1.default(),
48
+ },
49
+ /**
50
+ * Require the project to be identified and registered on server if this command is being
51
+ * run within a project directory, null otherwise.
52
+ */
53
+ OptionalProjectConfig: {
54
+ projectConfig: new OptionalProjectConfigContextField_1.OptionalProjectConfigContextField(),
55
+ },
56
+ /**
57
+ * Require this command to be run in a project directory. Return the project directory in the context.
58
+ */
59
+ ProjectDir: {
60
+ projectDir: new ProjectDirContextField_1.default(),
61
+ },
62
+ /**
63
+ * Provides functions to load the project config when dynamic config options are needed (custom Env for example).
64
+ */
65
+ DynamicProjectConfig: {
66
+ // eslint-disable-next-line async-protect/async-suffix
67
+ getDynamicProjectConfigAsync: new DynamicProjectConfigContextField_1.DynamicProjectConfigContextField(),
68
+ },
69
+ /**
70
+ * Require the project to be identified and registered on server. Returns the project config in the context.
71
+ */
72
+ ProjectConfig: {
73
+ projectConfig: new ProjectConfigContextField_1.default(),
74
+ },
75
+ };
76
+ /**
77
+ * Context allows for subclasses (commands) to declare their prerequisites in a type-safe manner.
78
+ * These declarative definitions each output a context property that is the result of the prerequisite being
79
+ * satisfied. These allow a unified common interface to be shared amongst commands in order to provide a more
80
+ * consistent CLI experience.
81
+ *
82
+ * For example, let's say a command needs the EAS project ID to make a GraphQL mutation. It should declare that
83
+ * it requires the `ProjectConfig` context, and then call `getContextAsync` to get the project ID.
84
+ */
85
+ EasCommand.contextDefinition = {};
@@ -0,0 +1,5 @@
1
+ import { Actor } from '../../user/User';
2
+ import ContextField, { ContextOptions } from './ContextField';
3
+ export default class ActorContextField extends ContextField<Actor> {
4
+ getValueAsync({ nonInteractive }: ContextOptions): Promise<Actor>;
5
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const ContextField_1 = tslib_1.__importDefault(require("./ContextField"));
5
+ const ensureLoggedInAsync_1 = require("./contextUtils/ensureLoggedInAsync");
6
+ class ActorContextField extends ContextField_1.default {
7
+ async getValueAsync({ nonInteractive }) {
8
+ return await (0, ensureLoggedInAsync_1.ensureLoggedInAsync)({ nonInteractive });
9
+ }
10
+ }
11
+ exports.default = ActorContextField;
@@ -0,0 +1,6 @@
1
+ export interface ContextOptions {
2
+ nonInteractive: boolean;
3
+ }
4
+ export default abstract class ContextField<T> {
5
+ abstract getValueAsync(options: ContextOptions): Promise<T>;
6
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class ContextField {
4
+ }
5
+ exports.default = ContextField;
@@ -0,0 +1,11 @@
1
+ import { ExpoConfig } from '@expo/config-types';
2
+ import { ExpoConfigOptions } from '../../project/expoConfig';
3
+ import ContextField, { ContextOptions } from './ContextField';
4
+ export declare type DynamicConfigContextFn = (options?: ExpoConfigOptions) => Promise<{
5
+ projectId: string;
6
+ exp: ExpoConfig;
7
+ projectDir: string;
8
+ }>;
9
+ export declare class DynamicProjectConfigContextField extends ContextField<DynamicConfigContextFn> {
10
+ getValueAsync({ nonInteractive }: ContextOptions): Promise<DynamicConfigContextFn>;
11
+ }