@hot-updater/android-helper 1.2.0-rc.3 → 1.2.0-rc.31

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