@hot-updater/android-helper 1.2.0-rc.6 → 1.2.0-rc.60

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.
package/dist/index.d.cts CHANGED
@@ -1,27 +1,38 @@
1
- import { CredentialRequest, CredentialResolver, Credentials } from "@hot-updater/cli-tools";
1
+ import { CredentialRequest, CredentialResolver, Credentials, ResolvedNativeBuildAndroidScheme } from "@hot-updater/cli-tools";
2
2
  import { NativeBuildAndroidScheme } from "@hot-updater/plugin-core";
3
3
  //#region src/utils/enrichNativeBuildAndroidScheme.d.ts
4
4
  /**
5
5
  * Validated scheme filled nullish values with default values.
6
6
  */
7
- type EnrichedNativeBuildAndroidScheme = Required<Omit<NativeBuildAndroidScheme, "signing">> & Pick<NativeBuildAndroidScheme, "signing"> & {
7
+ type EnrichedNativeBuildAndroidScheme = Required<Omit<ResolvedNativeBuildAndroidScheme, "signing" | "sandbox" | "sandboxUrlScheme">> & Pick<ResolvedNativeBuildAndroidScheme, "signing" | "sandbox" | "sandboxUrlScheme"> & {
8
8
  hotUpdaterSchemeName: string;
9
9
  };
10
10
  declare const enrichNativeBuildAndroidScheme: ({ schemeConfig, hotUpdaterSchemeName }: {
11
- schemeConfig: NativeBuildAndroidScheme;
11
+ schemeConfig: ResolvedNativeBuildAndroidScheme;
12
12
  hotUpdaterSchemeName: string;
13
13
  }) => Promise<EnrichedNativeBuildAndroidScheme>;
14
14
  //#endregion
15
15
  //#region src/buildAndroid.d.ts
16
- declare const buildAndroid: ({ schemeConfig, minBundleId, credentials }: {
16
+ declare const buildAndroid: ({ schemeConfig, minBundleId, credentials, logHeader, minVersionCode, channel }: {
17
17
  schemeConfig: EnrichedNativeBuildAndroidScheme;
18
18
  /** The MIN_BUNDLE_ID the build compiles in. */
19
19
  minBundleId?: string;
20
20
  /** Resolves the scheme's `signing` keystore, when it signs with one. */
21
21
  credentials?: Pick<CredentialResolver, "resolve">;
22
+ /** Lines the build log starts with, such as the native build key. */
23
+ logHeader?: string[];
24
+ /** The lowest version code a sandbox build may have. */
25
+ minVersionCode?: number;
26
+ /**
27
+ * The channel the build embeds, whatever the project's files or an Expo
28
+ * config plugin set; without it, theirs.
29
+ */
30
+ channel?: string;
22
31
  }) => Promise<{
23
32
  buildDirectory: string;
24
33
  buildArtifactPath: string;
34
+ /** The build log, or null without one. */
35
+ logFilePath: string | null;
25
36
  /** What the built artifact reports, or undefined without aapt2. */
26
37
  builtApp?: {
27
38
  appVersion: string | null;
@@ -32,6 +43,29 @@ declare const buildAndroid: ({ schemeConfig, minBundleId, credentials }: {
32
43
  };
33
44
  }>;
34
45
  //#endregion
46
+ //#region src/device.d.ts
47
+ interface AdbDevice {
48
+ readonly serial: string;
49
+ /** `device` when it takes commands; else `offline`, `unauthorized`, and so on. */
50
+ readonly state: string;
51
+ }
52
+ /** What `adb devices` lists. */
53
+ declare const listAdbDevices: () => Promise<readonly AdbDevice[]>;
54
+ /**
55
+ * The device to install on: `serial`, as adb's own `ANDROID_SERIAL` names it
56
+ * too, or else the only one that takes commands.
57
+ */
58
+ declare const selectAdbDevice: (devices: readonly AdbDevice[], serial?: string | undefined) => AdbDevice;
59
+ /**
60
+ * Installs an APK on a device, and opens its launcher activity. `appId` is
61
+ * the APK's own application ID, whatever suffix its build gave it.
62
+ */
63
+ declare const installOnAndroidDevice: ({ serial, apkPath, appId }: {
64
+ readonly serial: string;
65
+ readonly apkPath: string;
66
+ readonly appId: string;
67
+ }) => Promise<void>;
68
+ //#endregion
35
69
  //#region src/uploadToPlay.d.ts
36
70
  /**
37
71
  * Google Play refused the upload: it already has a bundle or APK with the
@@ -42,12 +76,63 @@ declare class PlayVersionCodeUsedError extends Error {
42
76
  readonly name = "PlayVersionCodeUsedError";
43
77
  constructor(options?: ErrorOptions);
44
78
  }
79
+ /**
80
+ * Play Console's page that invites `email` as a user. `_` stands for the
81
+ * developer account the browser is signed in to, so no ID is needed.
82
+ */
83
+ declare const playConsoleInviteUrl: (email: string) => string;
84
+ /**
85
+ * Whether a service account reaches an app in Google Play:
86
+ * - `ready`: it opened an edit of the app;
87
+ * - `denied`: Google Play refused it (401/403), so it needs a Play Console
88
+ * invite;
89
+ * - `not-found`: Google Play has no such app it can see (404), as before
90
+ * the app's first `.aab` is uploaded in Play Console;
91
+ * - `refused`: Google's token endpoint refused the key itself, such as a
92
+ * deleted key, with Google's reason.
93
+ */
94
+ type PlayAccess = {
95
+ readonly status: "ready";
96
+ } | {
97
+ readonly status: "denied";
98
+ readonly email: string;
99
+ } | {
100
+ readonly status: "not-found";
101
+ readonly email: string;
102
+ } | {
103
+ readonly status: "refused";
104
+ readonly email: string;
105
+ readonly reason: string;
106
+ };
107
+ /**
108
+ * Checks once whether the service account's key reaches `packageName`: it
109
+ * opens an edit of the app and deletes it again, which changes nothing.
110
+ * Throws only for what says nothing about access, such as a network error.
111
+ */
112
+ declare const checkPlayAccess: ({ serviceAccount: { json }, packageName, fetch }: {
113
+ serviceAccount: Credentials["play-service-account"];
114
+ packageName: string;
115
+ fetch?: typeof globalThis.fetch;
116
+ }) => Promise<PlayAccess>;
117
+ /**
118
+ * The status of the selected track's release holding `versionCode`, defaulting
119
+ * to internal testing, such as
120
+ * `completed` or `draft`, or null when the track doesn't hold it: never
121
+ * uploaded, or replaced by a newer release, which testers get instead.
122
+ */
123
+ declare const readPlayTrackRelease: ({ versionCode, track, packageName, serviceAccount, fetch }: {
124
+ versionCode: number;
125
+ track?: string;
126
+ /** The application ID the `.aab` was built with. */
127
+ packageName: string;
128
+ serviceAccount: Credentials["play-service-account"];
129
+ fetch?: typeof globalThis.fetch;
130
+ }) => Promise<string | null>;
45
131
  /**
46
132
  * Whether Google Play's internal testing track already releases the
47
- * `.aab`'s version code, as when a reused native build was uploaded
48
- * before. It reads the track in an edit it then deletes, changing nothing.
133
+ * `.aab`'s version code, as when a reused native build was uploaded before.
49
134
  */
50
- declare const findPlayInternalRelease: ({ versionCode, packageName, serviceAccount: { json }, fetch }: {
135
+ declare const findPlayInternalRelease: (options: {
51
136
  versionCode: number;
52
137
  /** The application ID the `.aab` was built with. */
53
138
  packageName: string;
@@ -55,15 +140,19 @@ declare const findPlayInternalRelease: ({ versionCode, packageName, serviceAccou
55
140
  fetch?: typeof globalThis.fetch;
56
141
  }) => Promise<boolean>;
57
142
  /**
58
- * Whether Google Play releases any version of `packageName` on any track,
59
- * which means Play has the app's upload key. It reads the tracks in an edit
60
- * it then deletes, changing nothing.
143
+ * The highest version code Google Play has taken for the app, on any track,
144
+ * or null with none: a new `.aab` needs one above it.
61
145
  */
62
- declare const hasPlayReleases: ({ packageName, serviceAccount: { json }, fetch }: {
146
+ declare const readPlayHighestVersionCode: ({ packageName, serviceAccount, fetch }: {
63
147
  packageName: string;
64
148
  serviceAccount: Credentials["play-service-account"];
65
149
  fetch?: typeof globalThis.fetch;
66
- }) => Promise<boolean>;
150
+ }) => Promise<number | null>;
151
+ /**
152
+ * The link that opts a tester in to the app's testing tracks. A build on the
153
+ * internal track installs through it, for the testers Play Console lists.
154
+ */
155
+ declare const playTestingUrl: (packageName: string) => string;
67
156
  /**
68
157
  * Throws when the `.aab` is signed with the Android debug keystore, which
69
158
  * Google Play refuses: a release build type left on `signingConfigs.debug`,
@@ -75,16 +164,19 @@ interface UploadToPlayResult {
75
164
  /** The version code Google Play read from the `.aab`. */
76
165
  versionCode: number;
77
166
  /** The release's status: `draft` on an app Play Console has not published. */
78
- status: "completed" | "draft";
167
+ status: "completed" | "draft" | "inProgress";
79
168
  }
80
169
  /**
81
- * Uploads an `.aab` to Google Play's internal testing track with the Google
170
+ * Uploads or promotes an `.aab` to a Google Play track with the Google
82
171
  * Play Developer API: it opens an edit, uploads the bundle, releases its
83
- * version code to the internal track, and commits the edit, which it
172
+ * version code to the selected track, and commits the edit, which it
84
173
  * deletes again when any step fails. The service account stays in memory.
85
174
  */
86
- declare const uploadToPlay: ({ aabPath, packageName, serviceAccount: { json }, fetch, commitRetryDelayMs }: {
175
+ declare const uploadToPlay: ({ aabPath, packageName, serviceAccount: { json }, fetch, commitRetryDelayMs, track, rollout, existingVersionCode }: {
87
176
  aabPath: string;
177
+ track?: "internal" | "alpha" | "beta" | "production";
178
+ rollout?: number;
179
+ existingVersionCode?: number;
88
180
  /** The application ID the `.aab` was built with. */
89
181
  packageName: string;
90
182
  serviceAccount: Credentials["play-service-account"];
@@ -118,6 +210,17 @@ declare const extractBuiltInBundle: ({ artifactPath, outputPath }: {
118
210
  outputPath: string;
119
211
  }) => Promise<void>;
120
212
  //#endregion
213
+ //#region src/utils/sandboxGradle.d.ts
214
+ /**
215
+ * Why a sandbox build of a scheme can't work, read from the project's files
216
+ * before anything is built, or null. The init script checks again, with what
217
+ * Gradle actually resolved.
218
+ */
219
+ declare const findSandboxGradleBlocker: ({ variant, appModuleName }: {
220
+ readonly variant?: string;
221
+ readonly appModuleName?: string;
222
+ }) => string | null;
223
+ //#endregion
121
224
  //#region src/utils/readBuiltApp.d.ts
122
225
  /**
123
226
  * What the built `.apk` or `.aab` reports at runtime: the `versionName` and
@@ -153,94 +256,29 @@ declare const readBuiltVersionCode: ({ artifactPath, androidProjectPath }: {
153
256
  androidProjectPath: string;
154
257
  }) => Promise<number | undefined>;
155
258
  //#endregion
156
- //#region src/google/types.d.ts
157
- /** What stopped Hot Updater from issuing the Play service account key. */
158
- type PlayServiceAccountErrorCode =
159
- /** The gcloud CLI, which signs in to Google, is not installed. */
160
- "gcloud-not-installed" |
161
- /** `gcloud auth login` ended with no active Google Account. */
162
- "gcloud-not-signed-in" |
163
- /** The Google Account may not create a Google Cloud project. */
164
- "project-create-denied" |
165
- /** The Google Account has no Google Cloud project quota left. */
166
- "project-quota" |
167
- /** The Google Account may not enable APIs or create service accounts in the project. */
168
- "project-access-denied" |
169
- /** Google is still enabling an API, or it is disabled in another project. */
170
- "api-not-enabled" |
171
- /** An organization policy (`iam.disableServiceAccountKeyCreation`) forbids keys. */
172
- "key-creation-disabled" |
173
- /** The key never reached the app: the Play Console invite, or the app's first upload, is missing. */
174
- "play-access-pending";
175
- /** A named failure of `issuePlayServiceAccount`, with what to do in its message. */
176
- declare class PlayServiceAccountError extends Error {
177
- readonly code: PlayServiceAccountErrorCode;
178
- constructor(code: PlayServiceAccountErrorCode, message: string, options?: {
179
- cause?: unknown;
180
- });
181
- }
182
- /** The service account Hot Updater creates, `hot-updater-play@<project>.iam.gserviceaccount.com`. */
183
- declare const PLAY_SERVICE_ACCOUNT_ID = "hot-updater-play";
184
- //#endregion
185
- //#region src/playServiceAccount.d.ts
186
- /** A Google Cloud project the signed-in account can use. */
187
- interface GoogleCloudProject {
188
- readonly projectId: string;
189
- readonly displayName?: string;
190
- /** Whether the Google Play Android Developer API is enabled in it. */
191
- readonly playApiEnabled: boolean;
192
- }
193
- interface IssuePlayServiceAccountRequest {
194
- /**
195
- * Asks for the app's package name in Google Play, which the service
196
- * account may release: after the sign-in's own tool is found, before
197
- * anything else.
198
- */
199
- readonly askPackageName: () => Promise<string>;
200
- /**
201
- * Sees Play Console's page that invites the service account `email`, to
202
- * print it and open it in a browser; the issuer then waits for the invite.
203
- */
204
- readonly onInvite: (url: string, email: string) => Promise<void> | void;
205
- /**
206
- * Sees the account's projects when no one of them is the obvious home of
207
- * the service account, the only one with the Google Play Developer API,
208
- * and returns the project ID to create it in, or null for a new project.
209
- * Never called for an account without projects: a new one is created.
210
- */
211
- readonly chooseProject: (projects: readonly GoogleCloudProject[]) => Promise<string | null>;
212
- /** Reports each step, such as "Creating the service account". */
213
- readonly onStep?: (message: string) => void;
214
- }
215
- /**
216
- * A Play service account's JSON key, just created, which already reaches
217
- * the app in Google Play. `revoke` deletes the key with gcloud's sign-in.
218
- */
219
- interface IssuedPlayServiceAccount {
220
- /** The JSON key file, as Google Cloud downloads it. */
221
- readonly json: string;
222
- /** The service account's email, the Play Console user it releases as. */
223
- readonly email: string;
224
- readonly projectId: string;
225
- /** The key's ID, as Google Cloud lists it under the service account's keys. */
226
- readonly keyId: string;
227
- /** Deletes the key with gcloud's sign-in; whether Google Cloud did. */
228
- revoke(): Promise<boolean>;
229
- /** Releases what the issue held; gcloud keeps its own sign-in. */
230
- dispose(): Promise<void>;
231
- }
232
- /**
233
- * Issues a service account key that releases the app to Google Play, with
234
- * the gcloud CLI's Google sign-in: the caller never sees the password, and
235
- * the developer invites the service account in Play Console once.
236
- */
237
- type IssuePlayServiceAccount = (request: IssuePlayServiceAccountRequest) => Promise<IssuedPlayServiceAccount>;
238
- /**
239
- * Hot Updater's issuer, the one place that picks how it is done: gcloud's
240
- * sign-in, then the Cloud Resource Manager, Service Usage, IAM, and Play
241
- * Developer APIs. Another implementation of `IssuePlayServiceAccount`
242
- * replaces it here without touching its callers.
243
- */
244
- declare const issuePlayServiceAccount: IssuePlayServiceAccount;
259
+ //#region src/playTracks.d.ts
260
+ /** Google Play destinations and their API tracks. */
261
+ declare const PLAY_TRACKS: {
262
+ readonly "play-internal": {
263
+ readonly track: "internal";
264
+ readonly label: "Play internal";
265
+ readonly name: "Google Play internal testing";
266
+ };
267
+ readonly "play-closed": {
268
+ readonly track: "alpha";
269
+ readonly label: "Play closed";
270
+ readonly name: "Google Play closed testing";
271
+ };
272
+ readonly "play-open": {
273
+ readonly track: "beta";
274
+ readonly label: "Play open";
275
+ readonly name: "Google Play open testing";
276
+ };
277
+ readonly "play-production": {
278
+ readonly track: "production";
279
+ readonly label: "Play production";
280
+ readonly name: "Google Play production";
281
+ };
282
+ };
245
283
  //#endregion
246
- export { type EnrichedNativeBuildAndroidScheme, type GoogleCloudProject, type IssuePlayServiceAccount, type IssuePlayServiceAccountRequest, type IssuedPlayServiceAccount, PLAY_SERVICE_ACCOUNT_ID, PlayServiceAccountError, type PlayServiceAccountErrorCode, PlayVersionCodeUsedError, type UploadToPlayResult, assertPlaySigned, buildAndroid, enrichNativeBuildAndroidScheme, extractBuiltInBundle, findPlayInternalRelease, hasPlayReleases, issuePlayServiceAccount, readBuiltApp, readBuiltPackageName, readBuiltVersionCode, resolvePlayUploadServiceAccount, uploadToPlay };
284
+ export { type AdbDevice, type EnrichedNativeBuildAndroidScheme, PLAY_TRACKS, type PlayAccess, PlayVersionCodeUsedError, type UploadToPlayResult, assertPlaySigned, buildAndroid, checkPlayAccess, enrichNativeBuildAndroidScheme, extractBuiltInBundle, findPlayInternalRelease, findSandboxGradleBlocker, installOnAndroidDevice, listAdbDevices, playConsoleInviteUrl, playTestingUrl, readBuiltApp, readBuiltPackageName, readBuiltVersionCode, readPlayHighestVersionCode, readPlayTrackRelease, resolvePlayUploadServiceAccount, selectAdbDevice, uploadToPlay };
package/dist/index.d.mts CHANGED
@@ -1,28 +1,39 @@
1
- import { CredentialRequest, CredentialResolver, Credentials } from "@hot-updater/cli-tools";
1
+ import { CredentialRequest, CredentialResolver, Credentials, ResolvedNativeBuildAndroidScheme } from "@hot-updater/cli-tools";
2
2
  import crypto from "crypto";
3
3
  import { NativeBuildAndroidScheme } from "@hot-updater/plugin-core";
4
4
  //#region src/utils/enrichNativeBuildAndroidScheme.d.ts
5
5
  /**
6
6
  * Validated scheme filled nullish values with default values.
7
7
  */
8
- type EnrichedNativeBuildAndroidScheme = Required<Omit<NativeBuildAndroidScheme, "signing">> & Pick<NativeBuildAndroidScheme, "signing"> & {
8
+ type EnrichedNativeBuildAndroidScheme = Required<Omit<ResolvedNativeBuildAndroidScheme, "signing" | "sandbox" | "sandboxUrlScheme">> & Pick<ResolvedNativeBuildAndroidScheme, "signing" | "sandbox" | "sandboxUrlScheme"> & {
9
9
  hotUpdaterSchemeName: string;
10
10
  };
11
11
  declare const enrichNativeBuildAndroidScheme: ({ schemeConfig, hotUpdaterSchemeName }: {
12
- schemeConfig: NativeBuildAndroidScheme;
12
+ schemeConfig: ResolvedNativeBuildAndroidScheme;
13
13
  hotUpdaterSchemeName: string;
14
14
  }) => Promise<EnrichedNativeBuildAndroidScheme>;
15
15
  //#endregion
16
16
  //#region src/buildAndroid.d.ts
17
- declare const buildAndroid: ({ schemeConfig, minBundleId, credentials }: {
17
+ declare const buildAndroid: ({ schemeConfig, minBundleId, credentials, logHeader, minVersionCode, channel }: {
18
18
  schemeConfig: EnrichedNativeBuildAndroidScheme;
19
19
  /** The MIN_BUNDLE_ID the build compiles in. */
20
20
  minBundleId?: string;
21
21
  /** Resolves the scheme's `signing` keystore, when it signs with one. */
22
22
  credentials?: Pick<CredentialResolver, "resolve">;
23
+ /** Lines the build log starts with, such as the native build key. */
24
+ logHeader?: string[];
25
+ /** The lowest version code a sandbox build may have. */
26
+ minVersionCode?: number;
27
+ /**
28
+ * The channel the build embeds, whatever the project's files or an Expo
29
+ * config plugin set; without it, theirs.
30
+ */
31
+ channel?: string;
23
32
  }) => Promise<{
24
33
  buildDirectory: string;
25
34
  buildArtifactPath: string;
35
+ /** The build log, or null without one. */
36
+ logFilePath: string | null;
26
37
  /** What the built artifact reports, or undefined without aapt2. */
27
38
  builtApp?: {
28
39
  appVersion: string | null;
@@ -33,6 +44,29 @@ declare const buildAndroid: ({ schemeConfig, minBundleId, credentials }: {
33
44
  };
34
45
  }>;
35
46
  //#endregion
47
+ //#region src/device.d.ts
48
+ interface AdbDevice {
49
+ readonly serial: string;
50
+ /** `device` when it takes commands; else `offline`, `unauthorized`, and so on. */
51
+ readonly state: string;
52
+ }
53
+ /** What `adb devices` lists. */
54
+ declare const listAdbDevices: () => Promise<readonly AdbDevice[]>;
55
+ /**
56
+ * The device to install on: `serial`, as adb's own `ANDROID_SERIAL` names it
57
+ * too, or else the only one that takes commands.
58
+ */
59
+ declare const selectAdbDevice: (devices: readonly AdbDevice[], serial?: string | undefined) => AdbDevice;
60
+ /**
61
+ * Installs an APK on a device, and opens its launcher activity. `appId` is
62
+ * the APK's own application ID, whatever suffix its build gave it.
63
+ */
64
+ declare const installOnAndroidDevice: ({ serial, apkPath, appId }: {
65
+ readonly serial: string;
66
+ readonly apkPath: string;
67
+ readonly appId: string;
68
+ }) => Promise<void>;
69
+ //#endregion
36
70
  //#region src/uploadToPlay.d.ts
37
71
  /**
38
72
  * Google Play refused the upload: it already has a bundle or APK with the
@@ -43,12 +77,63 @@ declare class PlayVersionCodeUsedError extends Error {
43
77
  readonly name = "PlayVersionCodeUsedError";
44
78
  constructor(options?: ErrorOptions);
45
79
  }
80
+ /**
81
+ * Play Console's page that invites `email` as a user. `_` stands for the
82
+ * developer account the browser is signed in to, so no ID is needed.
83
+ */
84
+ declare const playConsoleInviteUrl: (email: string) => string;
85
+ /**
86
+ * Whether a service account reaches an app in Google Play:
87
+ * - `ready`: it opened an edit of the app;
88
+ * - `denied`: Google Play refused it (401/403), so it needs a Play Console
89
+ * invite;
90
+ * - `not-found`: Google Play has no such app it can see (404), as before
91
+ * the app's first `.aab` is uploaded in Play Console;
92
+ * - `refused`: Google's token endpoint refused the key itself, such as a
93
+ * deleted key, with Google's reason.
94
+ */
95
+ type PlayAccess = {
96
+ readonly status: "ready";
97
+ } | {
98
+ readonly status: "denied";
99
+ readonly email: string;
100
+ } | {
101
+ readonly status: "not-found";
102
+ readonly email: string;
103
+ } | {
104
+ readonly status: "refused";
105
+ readonly email: string;
106
+ readonly reason: string;
107
+ };
108
+ /**
109
+ * Checks once whether the service account's key reaches `packageName`: it
110
+ * opens an edit of the app and deletes it again, which changes nothing.
111
+ * Throws only for what says nothing about access, such as a network error.
112
+ */
113
+ declare const checkPlayAccess: ({ serviceAccount: { json }, packageName, fetch }: {
114
+ serviceAccount: Credentials["play-service-account"];
115
+ packageName: string;
116
+ fetch?: typeof globalThis.fetch;
117
+ }) => Promise<PlayAccess>;
118
+ /**
119
+ * The status of the selected track's release holding `versionCode`, defaulting
120
+ * to internal testing, such as
121
+ * `completed` or `draft`, or null when the track doesn't hold it: never
122
+ * uploaded, or replaced by a newer release, which testers get instead.
123
+ */
124
+ declare const readPlayTrackRelease: ({ versionCode, track, packageName, serviceAccount, fetch }: {
125
+ versionCode: number;
126
+ track?: string;
127
+ /** The application ID the `.aab` was built with. */
128
+ packageName: string;
129
+ serviceAccount: Credentials["play-service-account"];
130
+ fetch?: typeof globalThis.fetch;
131
+ }) => Promise<string | null>;
46
132
  /**
47
133
  * Whether Google Play's internal testing track already releases the
48
- * `.aab`'s version code, as when a reused native build was uploaded
49
- * before. It reads the track in an edit it then deletes, changing nothing.
134
+ * `.aab`'s version code, as when a reused native build was uploaded before.
50
135
  */
51
- declare const findPlayInternalRelease: ({ versionCode, packageName, serviceAccount: { json }, fetch }: {
136
+ declare const findPlayInternalRelease: (options: {
52
137
  versionCode: number;
53
138
  /** The application ID the `.aab` was built with. */
54
139
  packageName: string;
@@ -56,15 +141,19 @@ declare const findPlayInternalRelease: ({ versionCode, packageName, serviceAccou
56
141
  fetch?: typeof globalThis.fetch;
57
142
  }) => Promise<boolean>;
58
143
  /**
59
- * Whether Google Play releases any version of `packageName` on any track,
60
- * which means Play has the app's upload key. It reads the tracks in an edit
61
- * it then deletes, changing nothing.
144
+ * The highest version code Google Play has taken for the app, on any track,
145
+ * or null with none: a new `.aab` needs one above it.
62
146
  */
63
- declare const hasPlayReleases: ({ packageName, serviceAccount: { json }, fetch }: {
147
+ declare const readPlayHighestVersionCode: ({ packageName, serviceAccount, fetch }: {
64
148
  packageName: string;
65
149
  serviceAccount: Credentials["play-service-account"];
66
150
  fetch?: typeof globalThis.fetch;
67
- }) => Promise<boolean>;
151
+ }) => Promise<number | null>;
152
+ /**
153
+ * The link that opts a tester in to the app's testing tracks. A build on the
154
+ * internal track installs through it, for the testers Play Console lists.
155
+ */
156
+ declare const playTestingUrl: (packageName: string) => string;
68
157
  /**
69
158
  * Throws when the `.aab` is signed with the Android debug keystore, which
70
159
  * Google Play refuses: a release build type left on `signingConfigs.debug`,
@@ -76,16 +165,19 @@ interface UploadToPlayResult {
76
165
  /** The version code Google Play read from the `.aab`. */
77
166
  versionCode: number;
78
167
  /** The release's status: `draft` on an app Play Console has not published. */
79
- status: "completed" | "draft";
168
+ status: "completed" | "draft" | "inProgress";
80
169
  }
81
170
  /**
82
- * Uploads an `.aab` to Google Play's internal testing track with the Google
171
+ * Uploads or promotes an `.aab` to a Google Play track with the Google
83
172
  * Play Developer API: it opens an edit, uploads the bundle, releases its
84
- * version code to the internal track, and commits the edit, which it
173
+ * version code to the selected track, and commits the edit, which it
85
174
  * deletes again when any step fails. The service account stays in memory.
86
175
  */
87
- declare const uploadToPlay: ({ aabPath, packageName, serviceAccount: { json }, fetch, commitRetryDelayMs }: {
176
+ declare const uploadToPlay: ({ aabPath, packageName, serviceAccount: { json }, fetch, commitRetryDelayMs, track, rollout, existingVersionCode }: {
88
177
  aabPath: string;
178
+ track?: "internal" | "alpha" | "beta" | "production";
179
+ rollout?: number;
180
+ existingVersionCode?: number;
89
181
  /** The application ID the `.aab` was built with. */
90
182
  packageName: string;
91
183
  serviceAccount: Credentials["play-service-account"];
@@ -119,6 +211,17 @@ declare const extractBuiltInBundle: ({ artifactPath, outputPath }: {
119
211
  outputPath: string;
120
212
  }) => Promise<void>;
121
213
  //#endregion
214
+ //#region src/utils/sandboxGradle.d.ts
215
+ /**
216
+ * Why a sandbox build of a scheme can't work, read from the project's files
217
+ * before anything is built, or null. The init script checks again, with what
218
+ * Gradle actually resolved.
219
+ */
220
+ declare const findSandboxGradleBlocker: ({ variant, appModuleName }: {
221
+ readonly variant?: string;
222
+ readonly appModuleName?: string;
223
+ }) => string | null;
224
+ //#endregion
122
225
  //#region src/utils/readBuiltApp.d.ts
123
226
  /**
124
227
  * What the built `.apk` or `.aab` reports at runtime: the `versionName` and
@@ -154,94 +257,29 @@ declare const readBuiltVersionCode: ({ artifactPath, androidProjectPath }: {
154
257
  androidProjectPath: string;
155
258
  }) => Promise<number | undefined>;
156
259
  //#endregion
157
- //#region src/google/types.d.ts
158
- /** What stopped Hot Updater from issuing the Play service account key. */
159
- type PlayServiceAccountErrorCode =
160
- /** The gcloud CLI, which signs in to Google, is not installed. */
161
- "gcloud-not-installed" |
162
- /** `gcloud auth login` ended with no active Google Account. */
163
- "gcloud-not-signed-in" |
164
- /** The Google Account may not create a Google Cloud project. */
165
- "project-create-denied" |
166
- /** The Google Account has no Google Cloud project quota left. */
167
- "project-quota" |
168
- /** The Google Account may not enable APIs or create service accounts in the project. */
169
- "project-access-denied" |
170
- /** Google is still enabling an API, or it is disabled in another project. */
171
- "api-not-enabled" |
172
- /** An organization policy (`iam.disableServiceAccountKeyCreation`) forbids keys. */
173
- "key-creation-disabled" |
174
- /** The key never reached the app: the Play Console invite, or the app's first upload, is missing. */
175
- "play-access-pending";
176
- /** A named failure of `issuePlayServiceAccount`, with what to do in its message. */
177
- declare class PlayServiceAccountError extends Error {
178
- readonly code: PlayServiceAccountErrorCode;
179
- constructor(code: PlayServiceAccountErrorCode, message: string, options?: {
180
- cause?: unknown;
181
- });
182
- }
183
- /** The service account Hot Updater creates, `hot-updater-play@<project>.iam.gserviceaccount.com`. */
184
- declare const PLAY_SERVICE_ACCOUNT_ID = "hot-updater-play";
185
- //#endregion
186
- //#region src/playServiceAccount.d.ts
187
- /** A Google Cloud project the signed-in account can use. */
188
- interface GoogleCloudProject {
189
- readonly projectId: string;
190
- readonly displayName?: string;
191
- /** Whether the Google Play Android Developer API is enabled in it. */
192
- readonly playApiEnabled: boolean;
193
- }
194
- interface IssuePlayServiceAccountRequest {
195
- /**
196
- * Asks for the app's package name in Google Play, which the service
197
- * account may release: after the sign-in's own tool is found, before
198
- * anything else.
199
- */
200
- readonly askPackageName: () => Promise<string>;
201
- /**
202
- * Sees Play Console's page that invites the service account `email`, to
203
- * print it and open it in a browser; the issuer then waits for the invite.
204
- */
205
- readonly onInvite: (url: string, email: string) => Promise<void> | void;
206
- /**
207
- * Sees the account's projects when no one of them is the obvious home of
208
- * the service account, the only one with the Google Play Developer API,
209
- * and returns the project ID to create it in, or null for a new project.
210
- * Never called for an account without projects: a new one is created.
211
- */
212
- readonly chooseProject: (projects: readonly GoogleCloudProject[]) => Promise<string | null>;
213
- /** Reports each step, such as "Creating the service account". */
214
- readonly onStep?: (message: string) => void;
215
- }
216
- /**
217
- * A Play service account's JSON key, just created, which already reaches
218
- * the app in Google Play. `revoke` deletes the key with gcloud's sign-in.
219
- */
220
- interface IssuedPlayServiceAccount {
221
- /** The JSON key file, as Google Cloud downloads it. */
222
- readonly json: string;
223
- /** The service account's email, the Play Console user it releases as. */
224
- readonly email: string;
225
- readonly projectId: string;
226
- /** The key's ID, as Google Cloud lists it under the service account's keys. */
227
- readonly keyId: string;
228
- /** Deletes the key with gcloud's sign-in; whether Google Cloud did. */
229
- revoke(): Promise<boolean>;
230
- /** Releases what the issue held; gcloud keeps its own sign-in. */
231
- dispose(): Promise<void>;
232
- }
233
- /**
234
- * Issues a service account key that releases the app to Google Play, with
235
- * the gcloud CLI's Google sign-in: the caller never sees the password, and
236
- * the developer invites the service account in Play Console once.
237
- */
238
- type IssuePlayServiceAccount = (request: IssuePlayServiceAccountRequest) => Promise<IssuedPlayServiceAccount>;
239
- /**
240
- * Hot Updater's issuer, the one place that picks how it is done: gcloud's
241
- * sign-in, then the Cloud Resource Manager, Service Usage, IAM, and Play
242
- * Developer APIs. Another implementation of `IssuePlayServiceAccount`
243
- * replaces it here without touching its callers.
244
- */
245
- declare const issuePlayServiceAccount: IssuePlayServiceAccount;
260
+ //#region src/playTracks.d.ts
261
+ /** Google Play destinations and their API tracks. */
262
+ declare const PLAY_TRACKS: {
263
+ readonly "play-internal": {
264
+ readonly track: "internal";
265
+ readonly label: "Play internal";
266
+ readonly name: "Google Play internal testing";
267
+ };
268
+ readonly "play-closed": {
269
+ readonly track: "alpha";
270
+ readonly label: "Play closed";
271
+ readonly name: "Google Play closed testing";
272
+ };
273
+ readonly "play-open": {
274
+ readonly track: "beta";
275
+ readonly label: "Play open";
276
+ readonly name: "Google Play open testing";
277
+ };
278
+ readonly "play-production": {
279
+ readonly track: "production";
280
+ readonly label: "Play production";
281
+ readonly name: "Google Play production";
282
+ };
283
+ };
246
284
  //#endregion
247
- export { type EnrichedNativeBuildAndroidScheme, type GoogleCloudProject, type IssuePlayServiceAccount, type IssuePlayServiceAccountRequest, type IssuedPlayServiceAccount, PLAY_SERVICE_ACCOUNT_ID, PlayServiceAccountError, type PlayServiceAccountErrorCode, PlayVersionCodeUsedError, type UploadToPlayResult, assertPlaySigned, buildAndroid, enrichNativeBuildAndroidScheme, extractBuiltInBundle, findPlayInternalRelease, hasPlayReleases, issuePlayServiceAccount, readBuiltApp, readBuiltPackageName, readBuiltVersionCode, resolvePlayUploadServiceAccount, uploadToPlay };
285
+ export { type AdbDevice, type EnrichedNativeBuildAndroidScheme, PLAY_TRACKS, type PlayAccess, PlayVersionCodeUsedError, type UploadToPlayResult, assertPlaySigned, buildAndroid, checkPlayAccess, enrichNativeBuildAndroidScheme, extractBuiltInBundle, findPlayInternalRelease, findSandboxGradleBlocker, installOnAndroidDevice, listAdbDevices, playConsoleInviteUrl, playTestingUrl, readBuiltApp, readBuiltPackageName, readBuiltVersionCode, readPlayHighestVersionCode, readPlayTrackRelease, resolvePlayUploadServiceAccount, selectAdbDevice, uploadToPlay };