@hot-updater/android-helper 1.2.0-rc.23 → 1.2.0-rc.25
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.cjs +90 -29
- package/dist/index.d.cts +40 -10
- package/dist/index.d.mts +40 -10
- package/dist/index.mjs +90 -30
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -566,6 +566,26 @@ const resolveSandboxLauncher = (mergedManifest) => {
|
|
|
566
566
|
...shortcutsResource === void 0 ? {} : { shortcuts: shortcutsResource }
|
|
567
567
|
};
|
|
568
568
|
};
|
|
569
|
+
const COMPONENTS = [
|
|
570
|
+
"activity",
|
|
571
|
+
"activity-alias",
|
|
572
|
+
"service",
|
|
573
|
+
"receiver"
|
|
574
|
+
];
|
|
575
|
+
/**
|
|
576
|
+
* The URL schemes a variant's merged manifest declares in its components'
|
|
577
|
+
* intent filters, in lower case: a sandbox build registers none of them.
|
|
578
|
+
*/
|
|
579
|
+
const declaredUrlSchemes = (mergedManifest) => {
|
|
580
|
+
const application = new fast_xml_parser.XMLParser({
|
|
581
|
+
ignoreAttributes: false,
|
|
582
|
+
attributeNamePrefix: ""
|
|
583
|
+
}).parse(mergedManifest)?.manifest?.application;
|
|
584
|
+
return COMPONENTS.flatMap((component) => asArray(application?.[component])).flatMap((element) => filtersOf(element).flatMap(({ data }) => data.flatMap((item) => {
|
|
585
|
+
const scheme = attribute(item, "scheme");
|
|
586
|
+
return scheme === void 0 ? [] : [scheme.toLowerCase()];
|
|
587
|
+
})));
|
|
588
|
+
};
|
|
569
589
|
const xml = (text) => text.replace(/&/gu, "&").replace(/"/gu, """).replace(/</gu, "<").replace(/>/gu, ">");
|
|
570
590
|
const attributesOf = (element) => Object.entries(element).filter(([, value]) => typeof value === "string").map(([name, value]) => ` ${name}="${xml(value)}"`).join("");
|
|
571
591
|
/** A launcher filter, element by element: the merger matches a filter by content. */
|
|
@@ -581,26 +601,27 @@ const optional = (name, value) => value === void 0 ? "" : ` android:${name}="${x
|
|
|
581
601
|
* The manifest a sandbox build overlays on the app's. `tools:replace` wins over
|
|
582
602
|
* a channel the app's manifest sets, as an Expo project's does. The launcher's
|
|
583
603
|
* filter, label, icon and static shortcuts move to the sandbox's activity, which
|
|
584
|
-
* also takes the links of `
|
|
585
|
-
* stays, so its own links still
|
|
586
|
-
*
|
|
604
|
+
* also takes the links of `urlScheme`, which its `<meta-data>` names for the
|
|
605
|
+
* build to read; the rest of the app's activity stays, so its own links still
|
|
606
|
+
* reach it.
|
|
587
607
|
* The dev server is plain http, which a project's network security config can
|
|
588
608
|
* still refuse: the screen then says so.
|
|
589
609
|
*/
|
|
590
|
-
const sandboxManifestOverlay = ({ channel,
|
|
610
|
+
const sandboxManifestOverlay = ({ channel, urlScheme, launcher }) => `<?xml version="1.0" encoding="utf-8"?>
|
|
591
611
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
|
|
592
612
|
<application android:usesCleartextTraffic="true" tools:replace="android:usesCleartextTraffic">
|
|
593
613
|
<meta-data android:name="com.hotupdater.CHANNEL" android:value="${xml(channel)}" tools:replace="android:value" />
|
|
594
614
|
<meta-data android:name="${_hot_updater_protocol_native_artifact.SANDBOX_META_DATA}" android:value="true" />
|
|
595
|
-
<activity android:name="${_hot_updater_protocol_native_artifact.SANDBOX_ACTIVITY}" android:exported="true" android:launchMode="singleTop" android:theme="@style/HotUpdaterSandboxTheme" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"${optional("label", launcher.label)}${optional("icon", launcher.icon)}${optional("roundIcon", launcher.roundIcon)}>
|
|
615
|
+
<activity android:name="${_hot_updater_protocol_native_artifact.SANDBOX_ACTIVITY}" android:exported="true" android:launchMode="singleTop" android:theme="@style/HotUpdaterSandboxTheme" android:configChanges="density|fontScale|fontWeightAdjustment|keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:enableOnBackInvokedCallback="true"${optional("label", launcher.label)}${optional("icon", launcher.icon)}${optional("roundIcon", launcher.roundIcon)}>
|
|
596
616
|
${filterXml(launcher.filter)}
|
|
597
617
|
<intent-filter>
|
|
598
618
|
<action android:name="android.intent.action.VIEW" />
|
|
599
619
|
<category android:name="android.intent.category.DEFAULT" />
|
|
600
620
|
<category android:name="android.intent.category.BROWSABLE" />
|
|
601
|
-
<data android:scheme="${(
|
|
621
|
+
<data android:scheme="${xml(urlScheme)}" />
|
|
602
622
|
</intent-filter>
|
|
603
|
-
<meta-data android:name="com.hotupdater.sandbox.HOST_ACTIVITY" android:value="${xml(launcher.name)}"
|
|
623
|
+
<meta-data android:name="com.hotupdater.sandbox.HOST_ACTIVITY" android:value="${xml(launcher.name)}" />
|
|
624
|
+
<meta-data android:name="${_hot_updater_protocol_native_artifact.SANDBOX_URL_SCHEME_META_DATA}" android:value="${xml(urlScheme)}" />${launcher.shortcuts === void 0 ? "" : `\n <meta-data android:name="${SHORTCUTS}" android:resource="${xml(launcher.shortcuts)}" />`}
|
|
604
625
|
</activity>
|
|
605
626
|
<${launcher.kind} android:name="${xml(launcher.name)}"${optional("targetActivity", launcher.targetActivity)}>
|
|
606
627
|
${filterXml(launcher.filter, " tools:node=\"remove\"")}${launcher.shortcuts === void 0 ? "" : `\n <meta-data android:name="${SHORTCUTS}" tools:node="remove" />`}
|
|
@@ -699,14 +720,17 @@ allprojects { project ->
|
|
|
699
720
|
const withSandboxGradleArgs = async (scheme, readEffectiveManifest, build, { minVersionCode } = {}) => {
|
|
700
721
|
if (!scheme.sandbox) return build([]);
|
|
701
722
|
if (!scheme.packageName) throw new Error(`The sandbox scheme ${scheme.hotUpdaterSchemeName} sets no packageName, which its URL scheme comes from.\nSet packageName on the scheme.`);
|
|
702
|
-
const
|
|
723
|
+
const effectiveManifest = await readEffectiveManifest();
|
|
724
|
+
const launcher = resolveSandboxLauncher(effectiveManifest);
|
|
725
|
+
const urlScheme = scheme.sandboxUrlScheme ?? (0, _hot_updater_protocol_native_artifact.sandboxUrlSchemeOf)(scheme.packageName);
|
|
726
|
+
if (declaredUrlSchemes(effectiveManifest).includes(urlScheme.toLowerCase())) throw new Error(`The sandbox scheme ${scheme.hotUpdaterSchemeName} registers URL scheme ${urlScheme}, which the app registers itself.\nSet sandbox.urlScheme to a scheme the app doesn't register.`);
|
|
703
727
|
const directory = await fs.default.promises.mkdtemp(path.default.join(os.default.tmpdir(), "hot-updater-sandbox-"));
|
|
704
728
|
try {
|
|
705
729
|
const overlay = path.default.join(directory, "AndroidManifest.xml");
|
|
706
730
|
const initScript = path.default.join(directory, "sandbox.init.gradle");
|
|
707
731
|
await fs.default.promises.writeFile(overlay, sandboxManifestOverlay({
|
|
708
732
|
channel: (0, _hot_updater_protocol_native_artifact.sandboxChannelOf)(scheme.hotUpdaterSchemeName),
|
|
709
|
-
|
|
733
|
+
urlScheme,
|
|
710
734
|
launcher
|
|
711
735
|
}));
|
|
712
736
|
await fs.default.promises.writeFile(initScript, sandboxInitScript({
|
|
@@ -1000,7 +1024,7 @@ const explain = (error, packageName) => {
|
|
|
1000
1024
|
if (status === 401 || /does not have permission/i.test(apiMessage)) return new Error([
|
|
1001
1025
|
`The Play service account can't release ${packageName}.`,
|
|
1002
1026
|
"Invite its email in Play Console (Users and permissions) to release to",
|
|
1003
|
-
"testing tracks, and enable the Google Play Android Developer API."
|
|
1027
|
+
"testing tracks (Release to production for production), and enable the Google Play Android Developer API."
|
|
1004
1028
|
].join("\n"), { cause: error });
|
|
1005
1029
|
if (/package not found/i.test(apiMessage)) return new Error(`Google Play has no app ${packageName}.\nCreate it in Play Console and upload its first .aab there.`, { cause: error });
|
|
1006
1030
|
if (/version code .*(already been used|already used)/i.test(apiMessage)) return new PlayVersionCodeUsedError({ cause: error });
|
|
@@ -1143,16 +1167,17 @@ const readInEdit = async ({ packageName, serviceAccount: { json }, fetch }, read
|
|
|
1143
1167
|
}
|
|
1144
1168
|
};
|
|
1145
1169
|
/**
|
|
1146
|
-
* The status of the
|
|
1170
|
+
* The status of the selected track's release holding `versionCode`, defaulting
|
|
1171
|
+
* to internal testing, such as
|
|
1147
1172
|
* `completed` or `draft`, or null when the track doesn't hold it: never
|
|
1148
1173
|
* uploaded, or replaced by a newer release, which testers get instead.
|
|
1149
1174
|
*/
|
|
1150
|
-
const
|
|
1175
|
+
const readPlayTrackRelease = ({ versionCode, track = INTERNAL_TRACK, packageName, serviceAccount, fetch = globalThis.fetch }) => readInEdit({
|
|
1151
1176
|
packageName,
|
|
1152
1177
|
serviceAccount,
|
|
1153
1178
|
fetch
|
|
1154
1179
|
}, async (request, edit) => {
|
|
1155
|
-
const { releases = [] } = await request(
|
|
1180
|
+
const { releases = [] } = await request(`Reading the ${track} track`, "GET", `${edit}/tracks/${encodeURIComponent(track)}`);
|
|
1156
1181
|
const release = releases.find(({ versionCodes = [] }) => versionCodes.includes(String(versionCode)));
|
|
1157
1182
|
return release ? release.status ?? "completed" : null;
|
|
1158
1183
|
});
|
|
@@ -1160,7 +1185,7 @@ const readPlayInternalRelease = ({ versionCode, packageName, serviceAccount, fet
|
|
|
1160
1185
|
* Whether Google Play's internal testing track already releases the
|
|
1161
1186
|
* `.aab`'s version code, as when a reused native build was uploaded before.
|
|
1162
1187
|
*/
|
|
1163
|
-
const findPlayInternalRelease = async (options) => await
|
|
1188
|
+
const findPlayInternalRelease = async (options) => await readPlayTrackRelease(options) !== null;
|
|
1164
1189
|
/**
|
|
1165
1190
|
* The highest version code Google Play has taken for the app, on any track,
|
|
1166
1191
|
* or null with none: a new `.aab` needs one above it.
|
|
@@ -1207,12 +1232,13 @@ const assertPlaySigned = async (aabPath) => {
|
|
|
1207
1232
|
].join("\n"));
|
|
1208
1233
|
};
|
|
1209
1234
|
/**
|
|
1210
|
-
* Uploads an `.aab` to Google Play
|
|
1235
|
+
* Uploads or promotes an `.aab` to a Google Play track with the Google
|
|
1211
1236
|
* Play Developer API: it opens an edit, uploads the bundle, releases its
|
|
1212
|
-
* version code to the
|
|
1237
|
+
* version code to the selected track, and commits the edit, which it
|
|
1213
1238
|
* deletes again when any step fails. The service account stays in memory.
|
|
1214
1239
|
*/
|
|
1215
|
-
const uploadToPlay = async ({ aabPath, packageName, serviceAccount: { json }, fetch = globalThis.fetch, commitRetryDelayMs = 2e3 }) => {
|
|
1240
|
+
const uploadToPlay = async ({ aabPath, packageName, serviceAccount: { json }, fetch = globalThis.fetch, commitRetryDelayMs = 2e3, track = "internal", rollout = 100, existingVersionCode }) => {
|
|
1241
|
+
if (!Number.isInteger(rollout) || rollout < 1 || rollout > 100 || track === "internal" && rollout < 100) throw new Error(track === "internal" && rollout < 100 ? "Play internal testing does not support staged rollout." : "Rollout must be an integer from 1 to 100.");
|
|
1216
1242
|
const { app, authorization, request } = createPlayClient({
|
|
1217
1243
|
json,
|
|
1218
1244
|
packageName,
|
|
@@ -1226,20 +1252,28 @@ const uploadToPlay = async ({ aabPath, packageName, serviceAccount: { json }, fe
|
|
|
1226
1252
|
}
|
|
1227
1253
|
const edit = `${API_URL}${app}/edits/${encodeURIComponent(editId)}`;
|
|
1228
1254
|
try {
|
|
1229
|
-
_hot_updater_cli_tools.p.log.info(
|
|
1230
|
-
const versionCode = await uploadBundle({
|
|
1255
|
+
_hot_updater_cli_tools.p.log.info(`${existingVersionCode === void 0 ? "Uploading" : "Promoting"} ${packageName} to Google Play`);
|
|
1256
|
+
const versionCode = existingVersionCode ?? await uploadBundle({
|
|
1231
1257
|
aabPath,
|
|
1232
1258
|
sessionUrl: `${API_URL}/upload${app}/edits/${encodeURIComponent(editId)}/bundles?uploadType=resumable`,
|
|
1233
1259
|
authorization,
|
|
1234
1260
|
fetch
|
|
1235
1261
|
});
|
|
1262
|
+
const existingRelease = (existingVersionCode === void 0 ? void 0 : await request("Reading the Google Play track", "GET", `${edit}/tracks/${track}`))?.releases?.find((release) => release.versionCodes?.includes(String(versionCode)));
|
|
1236
1263
|
const release = async (status) => {
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1264
|
+
const updatedRelease = {
|
|
1265
|
+
...existingRelease,
|
|
1266
|
+
versionCodes: existingRelease?.versionCodes ?? [String(versionCode)],
|
|
1267
|
+
status
|
|
1268
|
+
};
|
|
1269
|
+
if (status === "inProgress") updatedRelease.userFraction = rollout / 100;
|
|
1270
|
+
else {
|
|
1271
|
+
delete updatedRelease.userFraction;
|
|
1272
|
+
delete updatedRelease.countryTargeting;
|
|
1273
|
+
}
|
|
1274
|
+
await request(`Releasing to the ${track} track`, "PUT", `${edit}/tracks/${track}`, {
|
|
1275
|
+
track,
|
|
1276
|
+
releases: [updatedRelease]
|
|
1243
1277
|
});
|
|
1244
1278
|
await commit({
|
|
1245
1279
|
request,
|
|
@@ -1248,10 +1282,11 @@ const uploadToPlay = async ({ aabPath, packageName, serviceAccount: { json }, fe
|
|
|
1248
1282
|
});
|
|
1249
1283
|
};
|
|
1250
1284
|
try {
|
|
1251
|
-
|
|
1285
|
+
const status = rollout < 100 ? "inProgress" : "completed";
|
|
1286
|
+
await release(status);
|
|
1252
1287
|
return {
|
|
1253
1288
|
versionCode,
|
|
1254
|
-
status
|
|
1289
|
+
status
|
|
1255
1290
|
};
|
|
1256
1291
|
} catch (error) {
|
|
1257
1292
|
if (!(error instanceof GooglePlayError) || !DRAFT_APP_ERRORS.some((message) => error.apiMessage.includes(message))) throw error;
|
|
@@ -1283,7 +1318,7 @@ const commit = async ({ request, edit, retryDelayMs }) => {
|
|
|
1283
1318
|
if (!(error instanceof GooglePlayError) || error.status >= 500 || error.status === 429) throw new Error([
|
|
1284
1319
|
"Google Play didn't confirm the release.",
|
|
1285
1320
|
error instanceof Error ? error.message : String(error),
|
|
1286
|
-
"Check
|
|
1321
|
+
"Check the release in Play Console before you upload it again."
|
|
1287
1322
|
].join("\n"), { cause: error });
|
|
1288
1323
|
if (error.status !== 400) throw error;
|
|
1289
1324
|
if (!changesNotSentForReview && error.apiMessage.includes(NEEDS_CHANGES_NOT_SENT_FOR_REVIEW)) {
|
|
@@ -1522,6 +1557,32 @@ const extractBuiltInBundle = async ({ artifactPath, outputPath }) => {
|
|
|
1522
1557
|
await (entry.method === 8 ? (0, stream_promises.pipeline)(source, (0, zlib.createInflateRaw)(), fs.default.createWriteStream(outputPath)) : (0, stream_promises.pipeline)(source, fs.default.createWriteStream(outputPath)));
|
|
1523
1558
|
};
|
|
1524
1559
|
//#endregion
|
|
1560
|
+
//#region src/playTracks.ts
|
|
1561
|
+
/** Google Play destinations and their API tracks. */
|
|
1562
|
+
const PLAY_TRACKS = {
|
|
1563
|
+
"play-internal": {
|
|
1564
|
+
track: "internal",
|
|
1565
|
+
label: "Play internal",
|
|
1566
|
+
name: "Google Play internal testing"
|
|
1567
|
+
},
|
|
1568
|
+
"play-closed": {
|
|
1569
|
+
track: "alpha",
|
|
1570
|
+
label: "Play closed",
|
|
1571
|
+
name: "Google Play closed testing"
|
|
1572
|
+
},
|
|
1573
|
+
"play-open": {
|
|
1574
|
+
track: "beta",
|
|
1575
|
+
label: "Play open",
|
|
1576
|
+
name: "Google Play open testing"
|
|
1577
|
+
},
|
|
1578
|
+
"play-production": {
|
|
1579
|
+
track: "production",
|
|
1580
|
+
label: "Play production",
|
|
1581
|
+
name: "Google Play production"
|
|
1582
|
+
}
|
|
1583
|
+
};
|
|
1584
|
+
//#endregion
|
|
1585
|
+
exports.PLAY_TRACKS = PLAY_TRACKS;
|
|
1525
1586
|
exports.PlayVersionCodeUsedError = PlayVersionCodeUsedError;
|
|
1526
1587
|
exports.assertPlaySigned = assertPlaySigned;
|
|
1527
1588
|
exports.buildAndroid = buildAndroid;
|
|
@@ -1538,7 +1599,7 @@ exports.readBuiltApp = readBuiltApp;
|
|
|
1538
1599
|
exports.readBuiltPackageName = readBuiltPackageName;
|
|
1539
1600
|
exports.readBuiltVersionCode = readBuiltVersionCode;
|
|
1540
1601
|
exports.readPlayHighestVersionCode = readPlayHighestVersionCode;
|
|
1541
|
-
exports.
|
|
1602
|
+
exports.readPlayTrackRelease = readPlayTrackRelease;
|
|
1542
1603
|
exports.resolvePlayUploadServiceAccount = resolvePlayUploadServiceAccount;
|
|
1543
1604
|
exports.selectAdbDevice = selectAdbDevice;
|
|
1544
1605
|
exports.uploadToPlay = uploadToPlay;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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<
|
|
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:
|
|
11
|
+
schemeConfig: ResolvedNativeBuildAndroidScheme;
|
|
12
12
|
hotUpdaterSchemeName: string;
|
|
13
13
|
}) => Promise<EnrichedNativeBuildAndroidScheme>;
|
|
14
14
|
//#endregion
|
|
@@ -110,12 +110,14 @@ declare const checkPlayAccess: ({ serviceAccount: { json }, packageName, fetch }
|
|
|
110
110
|
fetch?: typeof globalThis.fetch;
|
|
111
111
|
}) => Promise<PlayAccess>;
|
|
112
112
|
/**
|
|
113
|
-
* The status of the
|
|
113
|
+
* The status of the selected track's release holding `versionCode`, defaulting
|
|
114
|
+
* to internal testing, such as
|
|
114
115
|
* `completed` or `draft`, or null when the track doesn't hold it: never
|
|
115
116
|
* uploaded, or replaced by a newer release, which testers get instead.
|
|
116
117
|
*/
|
|
117
|
-
declare const
|
|
118
|
+
declare const readPlayTrackRelease: ({ versionCode, track, packageName, serviceAccount, fetch }: {
|
|
118
119
|
versionCode: number;
|
|
120
|
+
track?: string;
|
|
119
121
|
/** The application ID the `.aab` was built with. */
|
|
120
122
|
packageName: string;
|
|
121
123
|
serviceAccount: Credentials["play-service-account"];
|
|
@@ -157,16 +159,19 @@ interface UploadToPlayResult {
|
|
|
157
159
|
/** The version code Google Play read from the `.aab`. */
|
|
158
160
|
versionCode: number;
|
|
159
161
|
/** The release's status: `draft` on an app Play Console has not published. */
|
|
160
|
-
status: "completed" | "draft";
|
|
162
|
+
status: "completed" | "draft" | "inProgress";
|
|
161
163
|
}
|
|
162
164
|
/**
|
|
163
|
-
* Uploads an `.aab` to Google Play
|
|
165
|
+
* Uploads or promotes an `.aab` to a Google Play track with the Google
|
|
164
166
|
* Play Developer API: it opens an edit, uploads the bundle, releases its
|
|
165
|
-
* version code to the
|
|
167
|
+
* version code to the selected track, and commits the edit, which it
|
|
166
168
|
* deletes again when any step fails. The service account stays in memory.
|
|
167
169
|
*/
|
|
168
|
-
declare const uploadToPlay: ({ aabPath, packageName, serviceAccount: { json }, fetch, commitRetryDelayMs }: {
|
|
170
|
+
declare const uploadToPlay: ({ aabPath, packageName, serviceAccount: { json }, fetch, commitRetryDelayMs, track, rollout, existingVersionCode }: {
|
|
169
171
|
aabPath: string;
|
|
172
|
+
track?: "internal" | "alpha" | "beta" | "production";
|
|
173
|
+
rollout?: number;
|
|
174
|
+
existingVersionCode?: number;
|
|
170
175
|
/** The application ID the `.aab` was built with. */
|
|
171
176
|
packageName: string;
|
|
172
177
|
serviceAccount: Credentials["play-service-account"];
|
|
@@ -246,4 +251,29 @@ declare const readBuiltVersionCode: ({ artifactPath, androidProjectPath }: {
|
|
|
246
251
|
androidProjectPath: string;
|
|
247
252
|
}) => Promise<number | undefined>;
|
|
248
253
|
//#endregion
|
|
249
|
-
|
|
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
|
+
};
|
|
277
|
+
};
|
|
278
|
+
//#endregion
|
|
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 };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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<
|
|
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:
|
|
12
|
+
schemeConfig: ResolvedNativeBuildAndroidScheme;
|
|
13
13
|
hotUpdaterSchemeName: string;
|
|
14
14
|
}) => Promise<EnrichedNativeBuildAndroidScheme>;
|
|
15
15
|
//#endregion
|
|
@@ -111,12 +111,14 @@ declare const checkPlayAccess: ({ serviceAccount: { json }, packageName, fetch }
|
|
|
111
111
|
fetch?: typeof globalThis.fetch;
|
|
112
112
|
}) => Promise<PlayAccess>;
|
|
113
113
|
/**
|
|
114
|
-
* The status of the
|
|
114
|
+
* The status of the selected track's release holding `versionCode`, defaulting
|
|
115
|
+
* to internal testing, such as
|
|
115
116
|
* `completed` or `draft`, or null when the track doesn't hold it: never
|
|
116
117
|
* uploaded, or replaced by a newer release, which testers get instead.
|
|
117
118
|
*/
|
|
118
|
-
declare const
|
|
119
|
+
declare const readPlayTrackRelease: ({ versionCode, track, packageName, serviceAccount, fetch }: {
|
|
119
120
|
versionCode: number;
|
|
121
|
+
track?: string;
|
|
120
122
|
/** The application ID the `.aab` was built with. */
|
|
121
123
|
packageName: string;
|
|
122
124
|
serviceAccount: Credentials["play-service-account"];
|
|
@@ -158,16 +160,19 @@ interface UploadToPlayResult {
|
|
|
158
160
|
/** The version code Google Play read from the `.aab`. */
|
|
159
161
|
versionCode: number;
|
|
160
162
|
/** The release's status: `draft` on an app Play Console has not published. */
|
|
161
|
-
status: "completed" | "draft";
|
|
163
|
+
status: "completed" | "draft" | "inProgress";
|
|
162
164
|
}
|
|
163
165
|
/**
|
|
164
|
-
* Uploads an `.aab` to Google Play
|
|
166
|
+
* Uploads or promotes an `.aab` to a Google Play track with the Google
|
|
165
167
|
* Play Developer API: it opens an edit, uploads the bundle, releases its
|
|
166
|
-
* version code to the
|
|
168
|
+
* version code to the selected track, and commits the edit, which it
|
|
167
169
|
* deletes again when any step fails. The service account stays in memory.
|
|
168
170
|
*/
|
|
169
|
-
declare const uploadToPlay: ({ aabPath, packageName, serviceAccount: { json }, fetch, commitRetryDelayMs }: {
|
|
171
|
+
declare const uploadToPlay: ({ aabPath, packageName, serviceAccount: { json }, fetch, commitRetryDelayMs, track, rollout, existingVersionCode }: {
|
|
170
172
|
aabPath: string;
|
|
173
|
+
track?: "internal" | "alpha" | "beta" | "production";
|
|
174
|
+
rollout?: number;
|
|
175
|
+
existingVersionCode?: number;
|
|
171
176
|
/** The application ID the `.aab` was built with. */
|
|
172
177
|
packageName: string;
|
|
173
178
|
serviceAccount: Credentials["play-service-account"];
|
|
@@ -247,4 +252,29 @@ declare const readBuiltVersionCode: ({ artifactPath, androidProjectPath }: {
|
|
|
247
252
|
androidProjectPath: string;
|
|
248
253
|
}) => Promise<number | undefined>;
|
|
249
254
|
//#endregion
|
|
250
|
-
|
|
255
|
+
//#region src/playTracks.d.ts
|
|
256
|
+
/** Google Play destinations and their API tracks. */
|
|
257
|
+
declare const PLAY_TRACKS: {
|
|
258
|
+
readonly "play-internal": {
|
|
259
|
+
readonly track: "internal";
|
|
260
|
+
readonly label: "Play internal";
|
|
261
|
+
readonly name: "Google Play internal testing";
|
|
262
|
+
};
|
|
263
|
+
readonly "play-closed": {
|
|
264
|
+
readonly track: "alpha";
|
|
265
|
+
readonly label: "Play closed";
|
|
266
|
+
readonly name: "Google Play closed testing";
|
|
267
|
+
};
|
|
268
|
+
readonly "play-open": {
|
|
269
|
+
readonly track: "beta";
|
|
270
|
+
readonly label: "Play open";
|
|
271
|
+
readonly name: "Google Play open testing";
|
|
272
|
+
};
|
|
273
|
+
readonly "play-production": {
|
|
274
|
+
readonly track: "production";
|
|
275
|
+
readonly label: "Play production";
|
|
276
|
+
readonly name: "Google Play production";
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
//#endregion
|
|
280
|
+
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.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { ExecaError, execa } from "execa";
|
|
|
5
5
|
import os from "os";
|
|
6
6
|
import JSZip from "jszip";
|
|
7
7
|
import { createRequire } from "module";
|
|
8
|
-
import { SANDBOX_ACTIVITY, SANDBOX_APPLICATION_ID_SUFFIX, SANDBOX_META_DATA, sandboxChannelOf, sandboxUrlSchemeOf } from "@hot-updater/protocol/native-artifact";
|
|
8
|
+
import { SANDBOX_ACTIVITY, SANDBOX_APPLICATION_ID_SUFFIX, SANDBOX_META_DATA, SANDBOX_URL_SCHEME_META_DATA, sandboxChannelOf, sandboxUrlSchemeOf } from "@hot-updater/protocol/native-artifact";
|
|
9
9
|
import { XMLParser } from "fast-xml-parser";
|
|
10
10
|
import crypto from "crypto";
|
|
11
11
|
import { pipeline } from "stream/promises";
|
|
@@ -538,6 +538,26 @@ const resolveSandboxLauncher = (mergedManifest) => {
|
|
|
538
538
|
...shortcutsResource === void 0 ? {} : { shortcuts: shortcutsResource }
|
|
539
539
|
};
|
|
540
540
|
};
|
|
541
|
+
const COMPONENTS = [
|
|
542
|
+
"activity",
|
|
543
|
+
"activity-alias",
|
|
544
|
+
"service",
|
|
545
|
+
"receiver"
|
|
546
|
+
];
|
|
547
|
+
/**
|
|
548
|
+
* The URL schemes a variant's merged manifest declares in its components'
|
|
549
|
+
* intent filters, in lower case: a sandbox build registers none of them.
|
|
550
|
+
*/
|
|
551
|
+
const declaredUrlSchemes = (mergedManifest) => {
|
|
552
|
+
const application = new XMLParser({
|
|
553
|
+
ignoreAttributes: false,
|
|
554
|
+
attributeNamePrefix: ""
|
|
555
|
+
}).parse(mergedManifest)?.manifest?.application;
|
|
556
|
+
return COMPONENTS.flatMap((component) => asArray(application?.[component])).flatMap((element) => filtersOf(element).flatMap(({ data }) => data.flatMap((item) => {
|
|
557
|
+
const scheme = attribute(item, "scheme");
|
|
558
|
+
return scheme === void 0 ? [] : [scheme.toLowerCase()];
|
|
559
|
+
})));
|
|
560
|
+
};
|
|
541
561
|
const xml = (text) => text.replace(/&/gu, "&").replace(/"/gu, """).replace(/</gu, "<").replace(/>/gu, ">");
|
|
542
562
|
const attributesOf = (element) => Object.entries(element).filter(([, value]) => typeof value === "string").map(([name, value]) => ` ${name}="${xml(value)}"`).join("");
|
|
543
563
|
/** A launcher filter, element by element: the merger matches a filter by content. */
|
|
@@ -553,26 +573,27 @@ const optional = (name, value) => value === void 0 ? "" : ` android:${name}="${x
|
|
|
553
573
|
* The manifest a sandbox build overlays on the app's. `tools:replace` wins over
|
|
554
574
|
* a channel the app's manifest sets, as an Expo project's does. The launcher's
|
|
555
575
|
* filter, label, icon and static shortcuts move to the sandbox's activity, which
|
|
556
|
-
* also takes the links of `
|
|
557
|
-
* stays, so its own links still
|
|
558
|
-
*
|
|
576
|
+
* also takes the links of `urlScheme`, which its `<meta-data>` names for the
|
|
577
|
+
* build to read; the rest of the app's activity stays, so its own links still
|
|
578
|
+
* reach it.
|
|
559
579
|
* The dev server is plain http, which a project's network security config can
|
|
560
580
|
* still refuse: the screen then says so.
|
|
561
581
|
*/
|
|
562
|
-
const sandboxManifestOverlay = ({ channel,
|
|
582
|
+
const sandboxManifestOverlay = ({ channel, urlScheme, launcher }) => `<?xml version="1.0" encoding="utf-8"?>
|
|
563
583
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
|
|
564
584
|
<application android:usesCleartextTraffic="true" tools:replace="android:usesCleartextTraffic">
|
|
565
585
|
<meta-data android:name="com.hotupdater.CHANNEL" android:value="${xml(channel)}" tools:replace="android:value" />
|
|
566
586
|
<meta-data android:name="${SANDBOX_META_DATA}" android:value="true" />
|
|
567
|
-
<activity android:name="${SANDBOX_ACTIVITY}" android:exported="true" android:launchMode="singleTop" android:theme="@style/HotUpdaterSandboxTheme" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"${optional("label", launcher.label)}${optional("icon", launcher.icon)}${optional("roundIcon", launcher.roundIcon)}>
|
|
587
|
+
<activity android:name="${SANDBOX_ACTIVITY}" android:exported="true" android:launchMode="singleTop" android:theme="@style/HotUpdaterSandboxTheme" android:configChanges="density|fontScale|fontWeightAdjustment|keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:enableOnBackInvokedCallback="true"${optional("label", launcher.label)}${optional("icon", launcher.icon)}${optional("roundIcon", launcher.roundIcon)}>
|
|
568
588
|
${filterXml(launcher.filter)}
|
|
569
589
|
<intent-filter>
|
|
570
590
|
<action android:name="android.intent.action.VIEW" />
|
|
571
591
|
<category android:name="android.intent.category.DEFAULT" />
|
|
572
592
|
<category android:name="android.intent.category.BROWSABLE" />
|
|
573
|
-
<data android:scheme="${
|
|
593
|
+
<data android:scheme="${xml(urlScheme)}" />
|
|
574
594
|
</intent-filter>
|
|
575
|
-
<meta-data android:name="com.hotupdater.sandbox.HOST_ACTIVITY" android:value="${xml(launcher.name)}"
|
|
595
|
+
<meta-data android:name="com.hotupdater.sandbox.HOST_ACTIVITY" android:value="${xml(launcher.name)}" />
|
|
596
|
+
<meta-data android:name="${SANDBOX_URL_SCHEME_META_DATA}" android:value="${xml(urlScheme)}" />${launcher.shortcuts === void 0 ? "" : `\n <meta-data android:name="${SHORTCUTS}" android:resource="${xml(launcher.shortcuts)}" />`}
|
|
576
597
|
</activity>
|
|
577
598
|
<${launcher.kind} android:name="${xml(launcher.name)}"${optional("targetActivity", launcher.targetActivity)}>
|
|
578
599
|
${filterXml(launcher.filter, " tools:node=\"remove\"")}${launcher.shortcuts === void 0 ? "" : `\n <meta-data android:name="${SHORTCUTS}" tools:node="remove" />`}
|
|
@@ -671,14 +692,17 @@ allprojects { project ->
|
|
|
671
692
|
const withSandboxGradleArgs = async (scheme, readEffectiveManifest, build, { minVersionCode } = {}) => {
|
|
672
693
|
if (!scheme.sandbox) return build([]);
|
|
673
694
|
if (!scheme.packageName) throw new Error(`The sandbox scheme ${scheme.hotUpdaterSchemeName} sets no packageName, which its URL scheme comes from.\nSet packageName on the scheme.`);
|
|
674
|
-
const
|
|
695
|
+
const effectiveManifest = await readEffectiveManifest();
|
|
696
|
+
const launcher = resolveSandboxLauncher(effectiveManifest);
|
|
697
|
+
const urlScheme = scheme.sandboxUrlScheme ?? sandboxUrlSchemeOf(scheme.packageName);
|
|
698
|
+
if (declaredUrlSchemes(effectiveManifest).includes(urlScheme.toLowerCase())) throw new Error(`The sandbox scheme ${scheme.hotUpdaterSchemeName} registers URL scheme ${urlScheme}, which the app registers itself.\nSet sandbox.urlScheme to a scheme the app doesn't register.`);
|
|
675
699
|
const directory = await fs.promises.mkdtemp(path.join(os.tmpdir(), "hot-updater-sandbox-"));
|
|
676
700
|
try {
|
|
677
701
|
const overlay = path.join(directory, "AndroidManifest.xml");
|
|
678
702
|
const initScript = path.join(directory, "sandbox.init.gradle");
|
|
679
703
|
await fs.promises.writeFile(overlay, sandboxManifestOverlay({
|
|
680
704
|
channel: sandboxChannelOf(scheme.hotUpdaterSchemeName),
|
|
681
|
-
|
|
705
|
+
urlScheme,
|
|
682
706
|
launcher
|
|
683
707
|
}));
|
|
684
708
|
await fs.promises.writeFile(initScript, sandboxInitScript({
|
|
@@ -972,7 +996,7 @@ const explain = (error, packageName) => {
|
|
|
972
996
|
if (status === 401 || /does not have permission/i.test(apiMessage)) return new Error([
|
|
973
997
|
`The Play service account can't release ${packageName}.`,
|
|
974
998
|
"Invite its email in Play Console (Users and permissions) to release to",
|
|
975
|
-
"testing tracks, and enable the Google Play Android Developer API."
|
|
999
|
+
"testing tracks (Release to production for production), and enable the Google Play Android Developer API."
|
|
976
1000
|
].join("\n"), { cause: error });
|
|
977
1001
|
if (/package not found/i.test(apiMessage)) return new Error(`Google Play has no app ${packageName}.\nCreate it in Play Console and upload its first .aab there.`, { cause: error });
|
|
978
1002
|
if (/version code .*(already been used|already used)/i.test(apiMessage)) return new PlayVersionCodeUsedError({ cause: error });
|
|
@@ -1115,16 +1139,17 @@ const readInEdit = async ({ packageName, serviceAccount: { json }, fetch }, read
|
|
|
1115
1139
|
}
|
|
1116
1140
|
};
|
|
1117
1141
|
/**
|
|
1118
|
-
* The status of the
|
|
1142
|
+
* The status of the selected track's release holding `versionCode`, defaulting
|
|
1143
|
+
* to internal testing, such as
|
|
1119
1144
|
* `completed` or `draft`, or null when the track doesn't hold it: never
|
|
1120
1145
|
* uploaded, or replaced by a newer release, which testers get instead.
|
|
1121
1146
|
*/
|
|
1122
|
-
const
|
|
1147
|
+
const readPlayTrackRelease = ({ versionCode, track = INTERNAL_TRACK, packageName, serviceAccount, fetch = globalThis.fetch }) => readInEdit({
|
|
1123
1148
|
packageName,
|
|
1124
1149
|
serviceAccount,
|
|
1125
1150
|
fetch
|
|
1126
1151
|
}, async (request, edit) => {
|
|
1127
|
-
const { releases = [] } = await request(
|
|
1152
|
+
const { releases = [] } = await request(`Reading the ${track} track`, "GET", `${edit}/tracks/${encodeURIComponent(track)}`);
|
|
1128
1153
|
const release = releases.find(({ versionCodes = [] }) => versionCodes.includes(String(versionCode)));
|
|
1129
1154
|
return release ? release.status ?? "completed" : null;
|
|
1130
1155
|
});
|
|
@@ -1132,7 +1157,7 @@ const readPlayInternalRelease = ({ versionCode, packageName, serviceAccount, fet
|
|
|
1132
1157
|
* Whether Google Play's internal testing track already releases the
|
|
1133
1158
|
* `.aab`'s version code, as when a reused native build was uploaded before.
|
|
1134
1159
|
*/
|
|
1135
|
-
const findPlayInternalRelease = async (options) => await
|
|
1160
|
+
const findPlayInternalRelease = async (options) => await readPlayTrackRelease(options) !== null;
|
|
1136
1161
|
/**
|
|
1137
1162
|
* The highest version code Google Play has taken for the app, on any track,
|
|
1138
1163
|
* or null with none: a new `.aab` needs one above it.
|
|
@@ -1179,12 +1204,13 @@ const assertPlaySigned = async (aabPath) => {
|
|
|
1179
1204
|
].join("\n"));
|
|
1180
1205
|
};
|
|
1181
1206
|
/**
|
|
1182
|
-
* Uploads an `.aab` to Google Play
|
|
1207
|
+
* Uploads or promotes an `.aab` to a Google Play track with the Google
|
|
1183
1208
|
* Play Developer API: it opens an edit, uploads the bundle, releases its
|
|
1184
|
-
* version code to the
|
|
1209
|
+
* version code to the selected track, and commits the edit, which it
|
|
1185
1210
|
* deletes again when any step fails. The service account stays in memory.
|
|
1186
1211
|
*/
|
|
1187
|
-
const uploadToPlay = async ({ aabPath, packageName, serviceAccount: { json }, fetch = globalThis.fetch, commitRetryDelayMs = 2e3 }) => {
|
|
1212
|
+
const uploadToPlay = async ({ aabPath, packageName, serviceAccount: { json }, fetch = globalThis.fetch, commitRetryDelayMs = 2e3, track = "internal", rollout = 100, existingVersionCode }) => {
|
|
1213
|
+
if (!Number.isInteger(rollout) || rollout < 1 || rollout > 100 || track === "internal" && rollout < 100) throw new Error(track === "internal" && rollout < 100 ? "Play internal testing does not support staged rollout." : "Rollout must be an integer from 1 to 100.");
|
|
1188
1214
|
const { app, authorization, request } = createPlayClient({
|
|
1189
1215
|
json,
|
|
1190
1216
|
packageName,
|
|
@@ -1198,20 +1224,28 @@ const uploadToPlay = async ({ aabPath, packageName, serviceAccount: { json }, fe
|
|
|
1198
1224
|
}
|
|
1199
1225
|
const edit = `${API_URL}${app}/edits/${encodeURIComponent(editId)}`;
|
|
1200
1226
|
try {
|
|
1201
|
-
p.log.info(
|
|
1202
|
-
const versionCode = await uploadBundle({
|
|
1227
|
+
p.log.info(`${existingVersionCode === void 0 ? "Uploading" : "Promoting"} ${packageName} to Google Play`);
|
|
1228
|
+
const versionCode = existingVersionCode ?? await uploadBundle({
|
|
1203
1229
|
aabPath,
|
|
1204
1230
|
sessionUrl: `${API_URL}/upload${app}/edits/${encodeURIComponent(editId)}/bundles?uploadType=resumable`,
|
|
1205
1231
|
authorization,
|
|
1206
1232
|
fetch
|
|
1207
1233
|
});
|
|
1234
|
+
const existingRelease = (existingVersionCode === void 0 ? void 0 : await request("Reading the Google Play track", "GET", `${edit}/tracks/${track}`))?.releases?.find((release) => release.versionCodes?.includes(String(versionCode)));
|
|
1208
1235
|
const release = async (status) => {
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1236
|
+
const updatedRelease = {
|
|
1237
|
+
...existingRelease,
|
|
1238
|
+
versionCodes: existingRelease?.versionCodes ?? [String(versionCode)],
|
|
1239
|
+
status
|
|
1240
|
+
};
|
|
1241
|
+
if (status === "inProgress") updatedRelease.userFraction = rollout / 100;
|
|
1242
|
+
else {
|
|
1243
|
+
delete updatedRelease.userFraction;
|
|
1244
|
+
delete updatedRelease.countryTargeting;
|
|
1245
|
+
}
|
|
1246
|
+
await request(`Releasing to the ${track} track`, "PUT", `${edit}/tracks/${track}`, {
|
|
1247
|
+
track,
|
|
1248
|
+
releases: [updatedRelease]
|
|
1215
1249
|
});
|
|
1216
1250
|
await commit({
|
|
1217
1251
|
request,
|
|
@@ -1220,10 +1254,11 @@ const uploadToPlay = async ({ aabPath, packageName, serviceAccount: { json }, fe
|
|
|
1220
1254
|
});
|
|
1221
1255
|
};
|
|
1222
1256
|
try {
|
|
1223
|
-
|
|
1257
|
+
const status = rollout < 100 ? "inProgress" : "completed";
|
|
1258
|
+
await release(status);
|
|
1224
1259
|
return {
|
|
1225
1260
|
versionCode,
|
|
1226
|
-
status
|
|
1261
|
+
status
|
|
1227
1262
|
};
|
|
1228
1263
|
} catch (error) {
|
|
1229
1264
|
if (!(error instanceof GooglePlayError) || !DRAFT_APP_ERRORS.some((message) => error.apiMessage.includes(message))) throw error;
|
|
@@ -1255,7 +1290,7 @@ const commit = async ({ request, edit, retryDelayMs }) => {
|
|
|
1255
1290
|
if (!(error instanceof GooglePlayError) || error.status >= 500 || error.status === 429) throw new Error([
|
|
1256
1291
|
"Google Play didn't confirm the release.",
|
|
1257
1292
|
error instanceof Error ? error.message : String(error),
|
|
1258
|
-
"Check
|
|
1293
|
+
"Check the release in Play Console before you upload it again."
|
|
1259
1294
|
].join("\n"), { cause: error });
|
|
1260
1295
|
if (error.status !== 400) throw error;
|
|
1261
1296
|
if (!changesNotSentForReview && error.apiMessage.includes(NEEDS_CHANGES_NOT_SENT_FOR_REVIEW)) {
|
|
@@ -1494,4 +1529,29 @@ const extractBuiltInBundle = async ({ artifactPath, outputPath }) => {
|
|
|
1494
1529
|
await (entry.method === 8 ? pipeline(source, createInflateRaw(), fs.createWriteStream(outputPath)) : pipeline(source, fs.createWriteStream(outputPath)));
|
|
1495
1530
|
};
|
|
1496
1531
|
//#endregion
|
|
1497
|
-
|
|
1532
|
+
//#region src/playTracks.ts
|
|
1533
|
+
/** Google Play destinations and their API tracks. */
|
|
1534
|
+
const PLAY_TRACKS = {
|
|
1535
|
+
"play-internal": {
|
|
1536
|
+
track: "internal",
|
|
1537
|
+
label: "Play internal",
|
|
1538
|
+
name: "Google Play internal testing"
|
|
1539
|
+
},
|
|
1540
|
+
"play-closed": {
|
|
1541
|
+
track: "alpha",
|
|
1542
|
+
label: "Play closed",
|
|
1543
|
+
name: "Google Play closed testing"
|
|
1544
|
+
},
|
|
1545
|
+
"play-open": {
|
|
1546
|
+
track: "beta",
|
|
1547
|
+
label: "Play open",
|
|
1548
|
+
name: "Google Play open testing"
|
|
1549
|
+
},
|
|
1550
|
+
"play-production": {
|
|
1551
|
+
track: "production",
|
|
1552
|
+
label: "Play production",
|
|
1553
|
+
name: "Google Play production"
|
|
1554
|
+
}
|
|
1555
|
+
};
|
|
1556
|
+
//#endregion
|
|
1557
|
+
export { PLAY_TRACKS, PlayVersionCodeUsedError, assertPlaySigned, buildAndroid, checkPlayAccess, enrichNativeBuildAndroidScheme, extractBuiltInBundle, findPlayInternalRelease, findSandboxGradleBlocker, installOnAndroidDevice, listAdbDevices, playConsoleInviteUrl, playTestingUrl, readBuiltApp, readBuiltPackageName, readBuiltVersionCode, readPlayHighestVersionCode, readPlayTrackRelease, resolvePlayUploadServiceAccount, selectAdbDevice, uploadToPlay };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/android-helper",
|
|
3
|
-
"version": "1.2.0-rc.
|
|
3
|
+
"version": "1.2.0-rc.25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"execa": "9.5.2",
|
|
31
31
|
"fast-xml-parser": "5.7.2",
|
|
32
32
|
"jszip": "^3.10.1",
|
|
33
|
-
"@hot-updater/cli-tools": "1.2.0-rc.
|
|
34
|
-
"@hot-updater/plugin-core": "1.2.0-rc.
|
|
35
|
-
"@hot-updater/protocol": "1.2.0-rc.
|
|
33
|
+
"@hot-updater/cli-tools": "1.2.0-rc.25",
|
|
34
|
+
"@hot-updater/plugin-core": "1.2.0-rc.25",
|
|
35
|
+
"@hot-updater/protocol": "1.2.0-rc.25"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^20"
|