@better-update/cli 0.3.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 (150) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/oxlint.config.ts +6 -0
  3. package/package.json +36 -0
  4. package/src/app-layer.ts +29 -0
  5. package/src/application/build-workflow.ts +222 -0
  6. package/src/application/command-exit.ts +13 -0
  7. package/src/application/login.ts +87 -0
  8. package/src/application/update-promote.ts +88 -0
  9. package/src/application/update-publish.ts +402 -0
  10. package/src/application/update-rollback.ts +275 -0
  11. package/src/commands/analytics/adoption.ts +40 -0
  12. package/src/commands/analytics/channels.ts +35 -0
  13. package/src/commands/analytics/helpers.ts +3 -0
  14. package/src/commands/analytics/index.ts +13 -0
  15. package/src/commands/analytics/platforms.ts +39 -0
  16. package/src/commands/analytics/updates.ts +35 -0
  17. package/src/commands/audit-logs/helpers.ts +3 -0
  18. package/src/commands/audit-logs/index.ts +8 -0
  19. package/src/commands/audit-logs/list.ts +66 -0
  20. package/src/commands/branches.ts +70 -0
  21. package/src/commands/build/android.ts +129 -0
  22. package/src/commands/build/index.ts +63 -0
  23. package/src/commands/build/ios.ts +199 -0
  24. package/src/commands/build/reserve-and-upload.test.ts +263 -0
  25. package/src/commands/build/reserve-and-upload.ts +160 -0
  26. package/src/commands/build/run-step.ts +131 -0
  27. package/src/commands/builds/compatibility-matrix.ts +48 -0
  28. package/src/commands/builds/delete.ts +15 -0
  29. package/src/commands/builds/get.ts +34 -0
  30. package/src/commands/builds/helpers.ts +3 -0
  31. package/src/commands/builds/index.ts +20 -0
  32. package/src/commands/builds/install-link.ts +20 -0
  33. package/src/commands/builds/list.ts +38 -0
  34. package/src/commands/channels/create.ts +37 -0
  35. package/src/commands/channels/delete.ts +15 -0
  36. package/src/commands/channels/helpers.ts +18 -0
  37. package/src/commands/channels/index.ts +24 -0
  38. package/src/commands/channels/list.ts +38 -0
  39. package/src/commands/channels/pause.ts +15 -0
  40. package/src/commands/channels/resume.ts +15 -0
  41. package/src/commands/channels/rollout/complete.ts +17 -0
  42. package/src/commands/channels/rollout/create.ts +36 -0
  43. package/src/commands/channels/rollout/index.ts +11 -0
  44. package/src/commands/channels/rollout/revert.ts +17 -0
  45. package/src/commands/channels/rollout/update.ts +23 -0
  46. package/src/commands/channels/update.ts +32 -0
  47. package/src/commands/credentials/delete.ts +24 -0
  48. package/src/commands/credentials/index.ts +10 -0
  49. package/src/commands/credentials/list.ts +33 -0
  50. package/src/commands/credentials/upload.ts +91 -0
  51. package/src/commands/env/delete.ts +35 -0
  52. package/src/commands/env/export.ts +27 -0
  53. package/src/commands/env/get.ts +25 -0
  54. package/src/commands/env/helpers.ts +13 -0
  55. package/src/commands/env/import.ts +31 -0
  56. package/src/commands/env/index.ts +24 -0
  57. package/src/commands/env/list.ts +44 -0
  58. package/src/commands/env/pull.ts +27 -0
  59. package/src/commands/env/set.ts +42 -0
  60. package/src/commands/fingerprint/compare.ts +25 -0
  61. package/src/commands/fingerprint/generate.ts +18 -0
  62. package/src/commands/fingerprint/index.ts +9 -0
  63. package/src/commands/init.ts +35 -0
  64. package/src/commands/login.ts +13 -0
  65. package/src/commands/logout.ts +12 -0
  66. package/src/commands/projects.ts +84 -0
  67. package/src/commands/status.ts +48 -0
  68. package/src/commands/update/delete.ts +15 -0
  69. package/src/commands/update/helpers.ts +22 -0
  70. package/src/commands/update/index.ts +22 -0
  71. package/src/commands/update/list.ts +60 -0
  72. package/src/commands/update/promote.ts +30 -0
  73. package/src/commands/update/publish.ts +94 -0
  74. package/src/commands/update/rollback.ts +42 -0
  75. package/src/commands/update/rollout/complete.ts +17 -0
  76. package/src/commands/update/rollout/index.ts +10 -0
  77. package/src/commands/update/rollout/revert.ts +17 -0
  78. package/src/commands/update/rollout/set.ts +23 -0
  79. package/src/index.ts +53 -0
  80. package/src/lib/android-keystore.test.ts +114 -0
  81. package/src/lib/android-keystore.ts +76 -0
  82. package/src/lib/android-signing-gradle.test.ts +95 -0
  83. package/src/lib/android-signing-gradle.ts +52 -0
  84. package/src/lib/app-json.ts +81 -0
  85. package/src/lib/apple-auth.test.ts +402 -0
  86. package/src/lib/apple-auth.ts +132 -0
  87. package/src/lib/artifact-finder.test.ts +195 -0
  88. package/src/lib/artifact-finder.ts +122 -0
  89. package/src/lib/browser-login.test.ts +88 -0
  90. package/src/lib/browser-login.ts +193 -0
  91. package/src/lib/build-profile.test.ts +290 -0
  92. package/src/lib/build-profile.ts +234 -0
  93. package/src/lib/cli-schemas.ts +39 -0
  94. package/src/lib/command-errors.ts +60 -0
  95. package/src/lib/credentials-downloader.ts +181 -0
  96. package/src/lib/credentials-manager.ts +354 -0
  97. package/src/lib/env-exporter.test.ts +96 -0
  98. package/src/lib/env-exporter.ts +28 -0
  99. package/src/lib/exit-codes.ts +82 -0
  100. package/src/lib/expo-config.ts +130 -0
  101. package/src/lib/expo-export.test.ts +94 -0
  102. package/src/lib/expo-export.ts +281 -0
  103. package/src/lib/fingerprint.ts +67 -0
  104. package/src/lib/format-error.ts +22 -0
  105. package/src/lib/git-context.ts +56 -0
  106. package/src/lib/gradle-config.ts +126 -0
  107. package/src/lib/ios-export-options.test.ts +98 -0
  108. package/src/lib/ios-export-options.ts +62 -0
  109. package/src/lib/ios-keychain.ts +181 -0
  110. package/src/lib/ios-provisioning.test.ts +115 -0
  111. package/src/lib/ios-provisioning.ts +179 -0
  112. package/src/lib/output.ts +32 -0
  113. package/src/lib/pkcs12.ts +73 -0
  114. package/src/lib/plist.ts +39 -0
  115. package/src/lib/post-build-validation.ts +146 -0
  116. package/src/lib/presigned-upload.test.ts +140 -0
  117. package/src/lib/presigned-upload.ts +35 -0
  118. package/src/lib/record.ts +5 -0
  119. package/src/lib/resolve-named-resource.ts +24 -0
  120. package/src/lib/runtime-version.test.ts +119 -0
  121. package/src/lib/runtime-version.ts +62 -0
  122. package/src/lib/sha256.test.ts +108 -0
  123. package/src/lib/sha256.ts +80 -0
  124. package/src/lib/signed-payloads.test.ts +181 -0
  125. package/src/lib/signed-payloads.ts +164 -0
  126. package/src/lib/string-utils.ts +4 -0
  127. package/src/lib/temp-dir.ts +14 -0
  128. package/src/lib/test-utils.ts +13 -0
  129. package/src/lib/update-platforms.test.ts +45 -0
  130. package/src/lib/update-platforms.ts +19 -0
  131. package/src/lib/xcpretty-formatter.ts +21 -0
  132. package/src/services/api-client.ts +42 -0
  133. package/src/services/apple-session-store.ts +100 -0
  134. package/src/services/auth-store.ts +85 -0
  135. package/src/services/cli-runtime.ts +46 -0
  136. package/src/services/config-store.ts +108 -0
  137. package/src/services/presigned-upload.ts +84 -0
  138. package/src/services/update-asset-uploader.ts +72 -0
  139. package/src/types/keychain.d.ts +22 -0
  140. package/tests/e2e/build.test.ts +270 -0
  141. package/tests/e2e/commands.test.ts +694 -0
  142. package/tests/e2e/ota-lifecycle.test.ts +275 -0
  143. package/tests/e2e/publish.test.ts +150 -0
  144. package/tests/helpers/cli-e2e.ts +426 -0
  145. package/tests/helpers/pty-driver.ts +142 -0
  146. package/tests/interactive/harness/provider-prompt.ts +54 -0
  147. package/tests/interactive/login.test.ts +47 -0
  148. package/tests/interactive/provider-select.test.ts +59 -0
  149. package/tsconfig.json +7 -0
  150. package/vitest.config.ts +38 -0
@@ -0,0 +1,59 @@
1
+ import path from "node:path";
2
+
3
+ import { spawnPty } from "../helpers/pty-driver";
4
+
5
+ const HARNESS = path.resolve(import.meta.dirname, "./harness/provider-prompt.ts");
6
+
7
+ const RESULT_RE = /^RESULT=(\{.*\})$/m;
8
+
9
+ const runHarness = async (actions: (driver: ReturnType<typeof spawnPty>) => Promise<void>) => {
10
+ const driver = spawnPty("bun", [HARNESS], {
11
+ env: {
12
+ FORCE_COLOR: "0",
13
+ NO_COLOR: "1",
14
+ },
15
+ });
16
+
17
+ await driver.expect("Select App Store Connect provider", { timeoutMs: 15_000 });
18
+ await actions(driver);
19
+ await driver.expect(RESULT_RE, { timeoutMs: 10_000 });
20
+ const code = await driver.waitExit({ timeoutMs: 5000 });
21
+ expect(code).toBe(0);
22
+
23
+ const match = RESULT_RE.exec(driver.stripped());
24
+ expect(match, "harness should print RESULT=<json>").not.toBeNull();
25
+ return JSON.parse(match![1]!) as { providerId: number; switched: boolean };
26
+ };
27
+
28
+ describe("provider select prompt (PTY)", () => {
29
+ it("enter without navigation picks the first provider", async () => {
30
+ const result = await runHarness(async (driver) => {
31
+ driver.enter();
32
+ });
33
+ expect(result).toStrictEqual({ providerId: 10, switched: true });
34
+ });
35
+
36
+ it("down + enter picks the second provider", async () => {
37
+ const result = await runHarness(async (driver) => {
38
+ driver.down();
39
+ driver.enter();
40
+ });
41
+ expect(result).toStrictEqual({ providerId: 20, switched: true });
42
+ });
43
+
44
+ it("down + down + enter picks the third provider", async () => {
45
+ const result = await runHarness(async (driver) => {
46
+ driver.down(2);
47
+ driver.enter();
48
+ });
49
+ expect(result).toStrictEqual({ providerId: 30, switched: true });
50
+ });
51
+
52
+ it("up wraps to the last provider", async () => {
53
+ const result = await runHarness(async (driver) => {
54
+ driver.up();
55
+ driver.enter();
56
+ });
57
+ expect(result).toStrictEqual({ providerId: 30, switched: true });
58
+ });
59
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "@better-update/typescript-config/base.json",
3
+ "compilerOptions": {
4
+ "types": ["node", "vitest/globals"]
5
+ },
6
+ "include": ["src", "tests", "*.ts"]
7
+ }
@@ -0,0 +1,38 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ projects: [
6
+ // ── Unit tests (Node/Bun runtime) ─────────────────────
7
+ {
8
+ test: {
9
+ name: "unit",
10
+ globals: true,
11
+ include: ["src/**/*.test.ts"],
12
+ },
13
+ },
14
+ {
15
+ test: {
16
+ name: "e2e",
17
+ globals: true,
18
+ include: ["tests/e2e/**/*.test.ts"],
19
+ hookTimeout: 120_000,
20
+ testTimeout: 120_000,
21
+ // E2E tests share a common fixture dir (fixtures/e2e-app) and a
22
+ // Wrangler seed SQL path — serialize via fileParallelism=false and
23
+ // The --maxWorkers 1 flag set on test:e2e in package.json.
24
+ fileParallelism: false,
25
+ },
26
+ },
27
+ {
28
+ test: {
29
+ name: "interactive",
30
+ globals: true,
31
+ include: ["tests/interactive/**/*.test.ts"],
32
+ hookTimeout: 30_000,
33
+ testTimeout: 30_000,
34
+ },
35
+ },
36
+ ],
37
+ },
38
+ });