@revopush/code-push-cli 0.0.8 → 0.0.10
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.
|
@@ -10,7 +10,7 @@ const os = require("os");
|
|
|
10
10
|
const Q = require("q");
|
|
11
11
|
const yazl = require("yazl");
|
|
12
12
|
const promises_1 = require("node:fs/promises");
|
|
13
|
-
const
|
|
13
|
+
const plist = require("plist");
|
|
14
14
|
const bplist = require("bplist-parser");
|
|
15
15
|
async function extractMetadataFromAndroid(extractFolder, outputFolder) {
|
|
16
16
|
const assetsFolder = path.join(extractFolder, "assets");
|
|
@@ -148,7 +148,7 @@ function parseAnyPlistFile(plistPath) {
|
|
|
148
148
|
return arr[0];
|
|
149
149
|
}
|
|
150
150
|
const xml = buf.toString("utf8");
|
|
151
|
-
return
|
|
151
|
+
return plist.parse(xml);
|
|
152
152
|
}
|
|
153
153
|
async function getIosVersion(extractFolder) {
|
|
154
154
|
const payloadFolder = path.join(extractFolder, "Payload");
|
|
@@ -16,6 +16,7 @@ const semver = require("semver");
|
|
|
16
16
|
const cli = require("../script/types/cli");
|
|
17
17
|
const sign_1 = require("./sign");
|
|
18
18
|
const ApkReader = require("@devicefarmer/adbkit-apkreader");
|
|
19
|
+
const aabParser = require("aab-parser");
|
|
19
20
|
const react_native_utils_1 = require("./react-native-utils");
|
|
20
21
|
const file_utils_1 = require("./utils/file-utils");
|
|
21
22
|
const AccountManager = require("./management-sdk");
|
|
@@ -1286,11 +1287,13 @@ const releaseNative = (command) => {
|
|
|
1286
1287
|
throw new Error(`Target binary file "${targetBinaryPath}" does not exist.`);
|
|
1287
1288
|
}
|
|
1288
1289
|
// Validate file extension matches platform
|
|
1289
|
-
|
|
1290
|
+
const targetBinaryPathNormalised = targetBinaryPath.toLowerCase();
|
|
1291
|
+
if (platform === "ios" && !targetBinaryPathNormalised.endsWith(".ipa")) {
|
|
1290
1292
|
throw new Error("For iOS platform, target binary must be an .ipa file.");
|
|
1291
1293
|
}
|
|
1292
|
-
if (platform === "android" &&
|
|
1293
|
-
|
|
1294
|
+
if (platform === "android" &&
|
|
1295
|
+
!(targetBinaryPathNormalised.endsWith(".apk") || targetBinaryPathNormalised.endsWith(".aab"))) {
|
|
1296
|
+
throw new Error("For Android platform, target binary must be an .apk or .aab file.");
|
|
1294
1297
|
}
|
|
1295
1298
|
return exports.sdk
|
|
1296
1299
|
.getDeployment(command.appName, command.deploymentName)
|
|
@@ -1310,12 +1313,24 @@ const releaseNative = (command) => {
|
|
|
1310
1313
|
releaseCommandPartial = { package: metadataZip, appStoreVersion: buildVersion?.version };
|
|
1311
1314
|
}
|
|
1312
1315
|
else {
|
|
1313
|
-
(
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1316
|
+
if (targetBinaryPathNormalised.endsWith(".apk")) {
|
|
1317
|
+
(0, exports.log)(chalk.cyan(`\nExtracting APK/ARR file:\n`));
|
|
1318
|
+
await (0, file_utils_1.extractAPK)(targetBinaryPath, extractFolder);
|
|
1319
|
+
const reader = await ApkReader.open(targetBinaryPath);
|
|
1320
|
+
const { versionName: appStoreVersion } = await reader.readManifest();
|
|
1321
|
+
const metadataZip = await (0, binary_utils_1.extractMetadataFromAndroid)(extractFolder, outputFolder);
|
|
1322
|
+
releaseCommandPartial = { package: metadataZip, appStoreVersion };
|
|
1323
|
+
}
|
|
1324
|
+
else if (targetBinaryPathNormalised.endsWith(".aab")) {
|
|
1325
|
+
(0, exports.log)(chalk.cyan(`\nExtracting AAB file:\n`));
|
|
1326
|
+
await (0, file_utils_1.extractAAB)(targetBinaryPath, extractFolder);
|
|
1327
|
+
const { versionName: appStoreVersion } = await aabParser.parseAabManifest(targetBinaryPath);
|
|
1328
|
+
const metadataZip = await (0, binary_utils_1.extractMetadataFromAndroid)(`${extractFolder}/base`, outputFolder); // base folder is nested in AAB
|
|
1329
|
+
releaseCommandPartial = { package: metadataZip, appStoreVersion };
|
|
1330
|
+
}
|
|
1331
|
+
else {
|
|
1332
|
+
throw new Error("For Android platform, target binary must be an .apk or .aab file.");
|
|
1333
|
+
}
|
|
1319
1334
|
}
|
|
1320
1335
|
const { package: metadataZip, appStoreVersion } = releaseCommandPartial;
|
|
1321
1336
|
// Use the zip file as package for release
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractAPK = exports.extractIPA = exports.downloadBlob = exports.normalizePath = exports.fileDoesNotExistOrIsDirectory = exports.copyFileToTmpDir = exports.fileExists = exports.isDirectory = exports.isBinaryOrZip = void 0;
|
|
3
|
+
exports.extractAAB = exports.extractAPK = exports.extractIPA = exports.downloadBlob = exports.normalizePath = exports.fileDoesNotExistOrIsDirectory = exports.copyFileToTmpDir = exports.fileExists = exports.isDirectory = exports.isBinaryOrZip = void 0;
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const rimraf = require("rimraf");
|
|
@@ -79,3 +79,8 @@ async function extractAPK(zipPath, extractTo) {
|
|
|
79
79
|
zip.extractAllTo(extractTo, true);
|
|
80
80
|
}
|
|
81
81
|
exports.extractAPK = extractAPK;
|
|
82
|
+
async function extractAAB(zipPath, extractTo) {
|
|
83
|
+
const zip = new AdmZip(zipPath);
|
|
84
|
+
zip.extractAllTo(extractTo, true);
|
|
85
|
+
}
|
|
86
|
+
exports.extractAAB = extractAAB;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revopush/code-push-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Management CLI for the CodePush service",
|
|
5
5
|
"main": "./script/cli.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@devicefarmer/adbkit-apkreader": "^3.2.4",
|
|
27
|
+
"aab-parser": "^1.0.1",
|
|
27
28
|
"adm-zip": "^0.5.16",
|
|
28
29
|
"backslash": "^0.2.0",
|
|
29
30
|
"bplist-parser": "^0.3.2",
|
package/script/binary-utils.ts
CHANGED
|
@@ -7,7 +7,7 @@ import * as os from "os";
|
|
|
7
7
|
import * as Q from "q";
|
|
8
8
|
import * as yazl from "yazl";
|
|
9
9
|
import { readFile } from "node:fs/promises";
|
|
10
|
-
import plist from "plist"
|
|
10
|
+
import * as plist from "plist"
|
|
11
11
|
import * as bplist from "bplist-parser";
|
|
12
12
|
|
|
13
13
|
export async function extractMetadataFromAndroid(extractFolder, outputFolder) {
|
|
@@ -15,6 +15,7 @@ import * as semver from "semver";
|
|
|
15
15
|
import * as cli from "../script/types/cli";
|
|
16
16
|
import sign from "./sign";
|
|
17
17
|
const ApkReader = require("@devicefarmer/adbkit-apkreader");
|
|
18
|
+
const aabParser = require("aab-parser");
|
|
18
19
|
import {
|
|
19
20
|
AccessKey,
|
|
20
21
|
Account,
|
|
@@ -39,7 +40,7 @@ import {
|
|
|
39
40
|
runHermesEmitBinaryCommand,
|
|
40
41
|
takeHermesBaseBytecode,
|
|
41
42
|
} from "./react-native-utils";
|
|
42
|
-
import { fileDoesNotExistOrIsDirectory, fileExists, isBinaryOrZip, extractIPA, extractAPK } from "./utils/file-utils";
|
|
43
|
+
import { fileDoesNotExistOrIsDirectory, fileExists, isBinaryOrZip, extractIPA, extractAPK, extractAAB } from "./utils/file-utils";
|
|
43
44
|
|
|
44
45
|
import AccountManager = require("./management-sdk");
|
|
45
46
|
import wordwrap = require("wordwrap");
|
|
@@ -1613,11 +1614,15 @@ export const releaseNative = (command: cli.IReleaseNativeCommand): Promise<void>
|
|
|
1613
1614
|
throw new Error(`Target binary file "${targetBinaryPath}" does not exist.`);
|
|
1614
1615
|
}
|
|
1615
1616
|
// Validate file extension matches platform
|
|
1616
|
-
|
|
1617
|
+
const targetBinaryPathNormalised = targetBinaryPath.toLowerCase();
|
|
1618
|
+
if (platform === "ios" && !targetBinaryPathNormalised.endsWith(".ipa")) {
|
|
1617
1619
|
throw new Error("For iOS platform, target binary must be an .ipa file.");
|
|
1618
1620
|
}
|
|
1619
|
-
if (
|
|
1620
|
-
|
|
1621
|
+
if (
|
|
1622
|
+
platform === "android" &&
|
|
1623
|
+
!(targetBinaryPathNormalised.endsWith(".apk") || targetBinaryPathNormalised.endsWith(".aab"))
|
|
1624
|
+
) {
|
|
1625
|
+
throw new Error("For Android platform, target binary must be an .apk or .aab file.");
|
|
1621
1626
|
}
|
|
1622
1627
|
|
|
1623
1628
|
return sdk
|
|
@@ -1636,16 +1641,27 @@ export const releaseNative = (command: cli.IReleaseNativeCommand): Promise<void>
|
|
|
1636
1641
|
log(chalk.cyan(`\nExtracting IPA file:\n`));
|
|
1637
1642
|
await extractIPA(targetBinaryPath, extractFolder);
|
|
1638
1643
|
const metadataZip = await extractMetadataFromIOS(extractFolder, outputFolder);
|
|
1639
|
-
const buildVersion = await getIosVersion(extractFolder)
|
|
1644
|
+
const buildVersion = await getIosVersion(extractFolder);
|
|
1640
1645
|
releaseCommandPartial = { package: metadataZip, appStoreVersion: buildVersion?.version };
|
|
1641
1646
|
} else {
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1647
|
+
if (targetBinaryPathNormalised.endsWith(".apk")) {
|
|
1648
|
+
log(chalk.cyan(`\nExtracting APK/ARR file:\n`));
|
|
1649
|
+
await extractAPK(targetBinaryPath, extractFolder);
|
|
1650
|
+
|
|
1651
|
+
const reader = await ApkReader.open(targetBinaryPath);
|
|
1652
|
+
const { versionName: appStoreVersion } = await reader.readManifest();
|
|
1653
|
+
const metadataZip = await extractMetadataFromAndroid(extractFolder, outputFolder);
|
|
1654
|
+
releaseCommandPartial = { package: metadataZip, appStoreVersion };
|
|
1655
|
+
} else if (targetBinaryPathNormalised.endsWith(".aab")) {
|
|
1656
|
+
log(chalk.cyan(`\nExtracting AAB file:\n`));
|
|
1657
|
+
await extractAAB(targetBinaryPath, extractFolder);
|
|
1658
|
+
const { versionName: appStoreVersion } = await aabParser.parseAabManifest(targetBinaryPath);
|
|
1659
|
+
|
|
1660
|
+
const metadataZip = await extractMetadataFromAndroid(`${extractFolder}/base`, outputFolder); // base folder is nested in AAB
|
|
1661
|
+
releaseCommandPartial = { package: metadataZip, appStoreVersion };
|
|
1662
|
+
} else {
|
|
1663
|
+
throw new Error("For Android platform, target binary must be an .apk or .aab file.");
|
|
1664
|
+
}
|
|
1649
1665
|
}
|
|
1650
1666
|
|
|
1651
1667
|
const { package: metadataZip, appStoreVersion } = releaseCommandPartial;
|
|
@@ -79,3 +79,8 @@ export async function extractAPK(zipPath: string, extractTo: string) {
|
|
|
79
79
|
const zip = new AdmZip(zipPath);
|
|
80
80
|
zip.extractAllTo(extractTo, true);
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
export async function extractAAB(zipPath: string, extractTo: string) {
|
|
84
|
+
const zip = new AdmZip(zipPath);
|
|
85
|
+
zip.extractAllTo(extractTo, true);
|
|
86
|
+
}
|