react-native-update-cli 2.18.0 → 2.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api.d.ts +1 -1
- package/lib/api.js +143 -134
- package/lib/app.d.ts +2 -2
- package/lib/app.js +60 -107
- package/lib/bin.js +38 -35
- package/lib/bundle-pack.js +57 -77
- package/lib/bundle-runner.js +249 -312
- package/lib/bundle.js +71 -89
- package/lib/diff.js +190 -240
- package/lib/exports.js +14 -37
- package/lib/index.js +16 -17
- package/lib/install.js +24 -37
- package/lib/locales/en.js +3 -11
- package/lib/locales/zh.js +3 -11
- package/lib/native-package.d.ts +17 -0
- package/lib/native-package.js +232 -0
- package/lib/package.js +180 -225
- package/lib/provider.js +85 -107
- package/lib/types.js +1 -3
- package/lib/user.d.ts +1 -1
- package/lib/user.js +26 -39
- package/lib/utils/add-gitignore.js +16 -29
- package/lib/utils/app-info-parser/aab.js +133 -157
- package/lib/utils/app-info-parser/apk.js +42 -39
- package/lib/utils/app-info-parser/app.js +5 -11
- package/lib/utils/app-info-parser/index.js +21 -31
- package/lib/utils/app-info-parser/ipa.js +35 -35
- package/lib/utils/app-info-parser/resource-finder.js +84 -71
- package/lib/utils/app-info-parser/utils.js +52 -77
- package/lib/utils/app-info-parser/xml-parser/binary.js +82 -90
- package/lib/utils/app-info-parser/xml-parser/manifest.js +88 -98
- package/lib/utils/app-info-parser/zip.js +43 -51
- package/lib/utils/check-lockfile.js +28 -37
- package/lib/utils/check-plugin.js +16 -32
- package/lib/utils/command-result.js +7 -20
- package/lib/utils/constants.js +23 -63
- package/lib/utils/dep-versions.js +21 -27
- package/lib/utils/git.js +20 -64
- package/lib/utils/hbcTransform.js +133 -246
- package/lib/utils/http-helper.js +33 -44
- package/lib/utils/i18n.js +17 -26
- package/lib/utils/index.js +137 -179
- package/lib/utils/latest-version/index.js +128 -137
- package/lib/utils/options.js +13 -34
- package/lib/utils/plugin-config.js +43 -56
- package/lib/utils/runtime.js +50 -108
- package/lib/utils/zip-entries.js +70 -97
- package/lib/utils/zip-options.js +80 -181
- package/lib/versions.js +231 -265
- package/package.json +19 -21
- package/src/api.ts +47 -3
- package/src/diff.ts +12 -20
- package/src/native-package.ts +248 -0
- package/src/package.ts +29 -19
- package/src/user.ts +1 -1
- package/src/versions.ts +1 -1
package/lib/utils/i18n.js
CHANGED
|
@@ -1,38 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const _zh = /*#__PURE__*/ _interop_require_default(require("../locales/zh"));
|
|
14
|
-
const _constants = require("./constants");
|
|
15
|
-
function _interop_require_default(obj) {
|
|
16
|
-
return obj && obj.__esModule ? obj : {
|
|
17
|
-
default: obj
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
_i18next.default.init({
|
|
21
|
-
lng: _constants.IS_CRESC ? 'en' : 'zh',
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.t = t;
|
|
7
|
+
const i18next_1 = __importDefault(require("i18next"));
|
|
8
|
+
const en_1 = __importDefault(require("../locales/en"));
|
|
9
|
+
const zh_1 = __importDefault(require("../locales/zh"));
|
|
10
|
+
const constants_1 = require("./constants");
|
|
11
|
+
i18next_1.default.init({
|
|
12
|
+
lng: constants_1.IS_CRESC ? 'en' : 'zh',
|
|
22
13
|
// debug: process.env.NODE_ENV !== 'production',
|
|
23
14
|
// debug: true,
|
|
24
15
|
resources: {
|
|
25
16
|
en: {
|
|
26
|
-
translation:
|
|
17
|
+
translation: en_1.default,
|
|
27
18
|
},
|
|
28
19
|
zh: {
|
|
29
|
-
translation:
|
|
30
|
-
}
|
|
20
|
+
translation: zh_1.default,
|
|
21
|
+
},
|
|
31
22
|
},
|
|
32
23
|
interpolation: {
|
|
33
|
-
escapeValue: false
|
|
34
|
-
}
|
|
24
|
+
escapeValue: false,
|
|
25
|
+
},
|
|
35
26
|
});
|
|
36
27
|
function t(key, options) {
|
|
37
|
-
return
|
|
28
|
+
return i18next_1.default.t(key, options);
|
|
38
29
|
}
|
package/lib/utils/index.js
CHANGED
|
@@ -1,99 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return isNonInteractive;
|
|
29
|
-
},
|
|
30
|
-
get printVersionCommand () {
|
|
31
|
-
return printVersionCommand;
|
|
32
|
-
},
|
|
33
|
-
get question () {
|
|
34
|
-
return question;
|
|
35
|
-
},
|
|
36
|
-
get translateOptions () {
|
|
37
|
-
return translateOptions;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
|
|
41
|
-
const _compareversions = require("compare-versions");
|
|
42
|
-
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
43
|
-
const _read = require("read");
|
|
44
|
-
const _yauzl = require("yauzl");
|
|
45
|
-
const _packagejson = /*#__PURE__*/ _interop_require_default(require("../../package.json"));
|
|
46
|
-
const _latestversion = /*#__PURE__*/ _interop_require_default(require("./latest-version"));
|
|
47
|
-
const _appinfoparser = /*#__PURE__*/ _interop_require_default(require("./app-info-parser"));
|
|
48
|
-
const _checkplugin = require("./check-plugin");
|
|
49
|
-
const _constants = require("./constants");
|
|
50
|
-
const _depversions = require("./dep-versions");
|
|
51
|
-
const _i18n = require("./i18n");
|
|
52
|
-
function _interop_require_default(obj) {
|
|
53
|
-
return obj && obj.__esModule ? obj : {
|
|
54
|
-
default: obj
|
|
55
|
-
};
|
|
56
|
-
}
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.checkPlugins = void 0;
|
|
7
|
+
exports.isNonInteractive = isNonInteractive;
|
|
8
|
+
exports.question = question;
|
|
9
|
+
exports.translateOptions = translateOptions;
|
|
10
|
+
exports.getApkInfo = getApkInfo;
|
|
11
|
+
exports.getAppInfo = getAppInfo;
|
|
12
|
+
exports.getIpaInfo = getIpaInfo;
|
|
13
|
+
exports.getAabInfo = getAabInfo;
|
|
14
|
+
exports.printVersionCommand = printVersionCommand;
|
|
15
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
16
|
+
const compare_versions_1 = require("compare-versions");
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const read_1 = require("read");
|
|
19
|
+
const yauzl_1 = require("yauzl");
|
|
20
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
|
21
|
+
const latest_version_1 = __importDefault(require("../utils/latest-version"));
|
|
22
|
+
const app_info_parser_1 = __importDefault(require("./app-info-parser"));
|
|
23
|
+
const check_plugin_1 = require("./check-plugin");
|
|
24
|
+
Object.defineProperty(exports, "checkPlugins", { enumerable: true, get: function () { return check_plugin_1.checkPlugins; } });
|
|
25
|
+
const constants_1 = require("./constants");
|
|
26
|
+
const dep_versions_1 = require("./dep-versions");
|
|
27
|
+
const i18n_1 = require("./i18n");
|
|
57
28
|
function isNonInteractive() {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return global.NO_INTERACTIVE === true || envValue === 'true' || envValue === '1';
|
|
29
|
+
const envValue = process.env.NO_INTERACTIVE?.toLowerCase();
|
|
30
|
+
return (global.NO_INTERACTIVE === true || envValue === 'true' || envValue === '1');
|
|
61
31
|
}
|
|
62
32
|
async function question(query, password) {
|
|
63
33
|
if (isNonInteractive()) {
|
|
64
34
|
return '';
|
|
65
35
|
}
|
|
66
|
-
return (0,
|
|
36
|
+
return (0, read_1.read)({
|
|
67
37
|
prompt: query,
|
|
68
38
|
silent: password,
|
|
69
|
-
replace: password ? '*' : undefined
|
|
39
|
+
replace: password ? '*' : undefined,
|
|
70
40
|
});
|
|
71
41
|
}
|
|
72
42
|
function translateOptions(options, map) {
|
|
73
43
|
if (!map) {
|
|
74
44
|
// Existing logic for template replacement if no map is provided
|
|
75
45
|
const ret = {};
|
|
76
|
-
for(const key in options){
|
|
46
|
+
for (const key in options) {
|
|
77
47
|
const value = options[key];
|
|
78
48
|
if (typeof value === 'string') {
|
|
79
|
-
ret[key] = value.replace(/\$\{(\w+)\}/g, (placeholder, name)=>{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
49
|
+
ret[key] = value.replace(/\$\{(\w+)\}/g, (placeholder, name) => {
|
|
50
|
+
const replacement = options[name] ?? process.env[name];
|
|
51
|
+
if (typeof replacement === 'string' ||
|
|
52
|
+
typeof replacement === 'number' ||
|
|
53
|
+
typeof replacement === 'boolean') {
|
|
83
54
|
return String(replacement);
|
|
84
55
|
}
|
|
85
56
|
return placeholder;
|
|
86
57
|
});
|
|
87
|
-
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
88
60
|
ret[key] = value;
|
|
89
61
|
}
|
|
90
62
|
}
|
|
91
63
|
return ret;
|
|
92
64
|
}
|
|
93
|
-
const result = {
|
|
94
|
-
|
|
95
|
-
};
|
|
96
|
-
for (const [key, value] of Object.entries(map)){
|
|
65
|
+
const result = { ...options };
|
|
66
|
+
for (const [key, value] of Object.entries(map)) {
|
|
97
67
|
if (result[key] !== undefined) {
|
|
98
68
|
result[value] = result[key];
|
|
99
69
|
delete result[key];
|
|
@@ -104,17 +74,17 @@ function translateOptions(options, map) {
|
|
|
104
74
|
const ApkBundleFileName = /assets\/index.android.bundle/;
|
|
105
75
|
const ApkUpdateJsonName = /res\/raw\/update.json/;
|
|
106
76
|
async function getApkInfo(fn) {
|
|
107
|
-
const appInfoParser = new
|
|
77
|
+
const appInfoParser = new app_info_parser_1.default(fn);
|
|
108
78
|
// read both entries in a single scan over the archive
|
|
109
79
|
const entries = await appInfoParser.parser.getEntries([
|
|
110
80
|
ApkBundleFileName,
|
|
111
|
-
ApkUpdateJsonName
|
|
81
|
+
ApkUpdateJsonName,
|
|
112
82
|
]);
|
|
113
83
|
const bundleFile = entries[String(ApkBundleFileName)];
|
|
114
84
|
if (!bundleFile) {
|
|
115
|
-
throw new Error((0,
|
|
85
|
+
throw new Error((0, i18n_1.t)('bundleNotFound', {
|
|
116
86
|
packageType: 'apk',
|
|
117
|
-
entryFile: 'index.android.bundle'
|
|
87
|
+
entryFile: 'index.android.bundle',
|
|
118
88
|
}));
|
|
119
89
|
}
|
|
120
90
|
const updateJsonFile = entries[String(ApkUpdateJsonName)];
|
|
@@ -125,38 +95,35 @@ async function getApkInfo(fn) {
|
|
|
125
95
|
const { versionName, application } = await appInfoParser.parse();
|
|
126
96
|
let buildTime = 0;
|
|
127
97
|
if (Array.isArray(application.metaData)) {
|
|
128
|
-
for (const meta of application.metaData){
|
|
98
|
+
for (const meta of application.metaData) {
|
|
129
99
|
if (meta.name === 'pushy_build_time') {
|
|
130
100
|
if (Array.isArray(meta.value)) {
|
|
131
101
|
const firstValue = meta.value[0];
|
|
132
102
|
buildTime = Number(firstValue);
|
|
133
|
-
}
|
|
103
|
+
}
|
|
104
|
+
else if (meta.value !== undefined) {
|
|
134
105
|
buildTime = Number(meta.value);
|
|
135
106
|
}
|
|
136
107
|
}
|
|
137
108
|
}
|
|
138
109
|
}
|
|
139
110
|
if (!Number.isFinite(buildTime) || buildTime === 0) {
|
|
140
|
-
throw new Error((0,
|
|
111
|
+
throw new Error((0, i18n_1.t)('buildTimeNotFound'));
|
|
141
112
|
}
|
|
142
|
-
return {
|
|
143
|
-
versionName,
|
|
144
|
-
buildTime,
|
|
145
|
-
...appCredential
|
|
146
|
-
};
|
|
113
|
+
return { versionName, buildTime, ...appCredential };
|
|
147
114
|
}
|
|
148
115
|
async function getAppInfo(fn) {
|
|
149
|
-
const appInfoParser = new
|
|
116
|
+
const appInfoParser = new app_info_parser_1.default(fn);
|
|
150
117
|
// single scan (and single nested .hap extraction) for all three entries
|
|
151
118
|
const [bundleFile, updateJsonFile, metaJsonFile] = await appInfoParser.parser.getEntriesFromHarmonyApp([
|
|
152
119
|
/rawfile\/bundle.harmony.js/,
|
|
153
120
|
/rawfile\/update.json/,
|
|
154
|
-
/rawfile\/meta.json
|
|
121
|
+
/rawfile\/meta.json/,
|
|
155
122
|
]);
|
|
156
123
|
if (!bundleFile) {
|
|
157
|
-
throw new Error((0,
|
|
124
|
+
throw new Error((0, i18n_1.t)('bundleNotFound', {
|
|
158
125
|
packageType: 'app',
|
|
159
|
-
entryFile: 'bundle.harmony.js'
|
|
126
|
+
entryFile: 'bundle.harmony.js',
|
|
160
127
|
}));
|
|
161
128
|
}
|
|
162
129
|
let appCredential = {};
|
|
@@ -173,13 +140,9 @@ async function getAppInfo(fn) {
|
|
|
173
140
|
buildTime = Number(pushy_build_time);
|
|
174
141
|
}
|
|
175
142
|
if (!Number.isFinite(buildTime) || buildTime === 0) {
|
|
176
|
-
throw new Error((0,
|
|
143
|
+
throw new Error((0, i18n_1.t)('buildTimeNotFound'));
|
|
177
144
|
}
|
|
178
|
-
return {
|
|
179
|
-
versionName,
|
|
180
|
-
buildTime,
|
|
181
|
-
...appCredential
|
|
182
|
-
};
|
|
145
|
+
return { versionName, buildTime, ...appCredential };
|
|
183
146
|
}
|
|
184
147
|
const IpaBundleFileName = /payload\/.+?\.app\/main.jsbundle/;
|
|
185
148
|
const IpaUpdateJsonName = /payload\/.+?\.app\/assets\/update.json/;
|
|
@@ -187,20 +150,19 @@ const IpaBuildTimeName = /payload\/.+?\.app\/pushy_build_time.txt/;
|
|
|
187
150
|
// Not in root bundle when use `use_frameworks`
|
|
188
151
|
const IpaBuildTimeFrameworkName = /payload\/.+?\.app\/frameworks\/react_native_update.framework\/pushy_build_time.txt/;
|
|
189
152
|
async function getIpaInfo(fn) {
|
|
190
|
-
|
|
191
|
-
const appInfoParser = new _appinfoparser.default(fn);
|
|
153
|
+
const appInfoParser = new app_info_parser_1.default(fn);
|
|
192
154
|
// read all four entries in a single scan over the archive
|
|
193
155
|
const entries = await appInfoParser.parser.getEntries([
|
|
194
156
|
IpaBundleFileName,
|
|
195
157
|
IpaUpdateJsonName,
|
|
196
158
|
IpaBuildTimeName,
|
|
197
|
-
IpaBuildTimeFrameworkName
|
|
159
|
+
IpaBuildTimeFrameworkName,
|
|
198
160
|
]);
|
|
199
161
|
const bundleFile = entries[String(IpaBundleFileName)];
|
|
200
162
|
if (!bundleFile) {
|
|
201
|
-
throw new Error((0,
|
|
163
|
+
throw new Error((0, i18n_1.t)('bundleNotFound', {
|
|
202
164
|
packageType: 'ipa',
|
|
203
|
-
entryFile: 'main.jsbundle'
|
|
165
|
+
entryFile: 'main.jsbundle',
|
|
204
166
|
}));
|
|
205
167
|
}
|
|
206
168
|
const updateJsonFile = entries[String(IpaUpdateJsonName)];
|
|
@@ -209,20 +171,17 @@ async function getIpaInfo(fn) {
|
|
|
209
171
|
appCredential = JSON.parse(updateJsonFile.toString()).ios;
|
|
210
172
|
}
|
|
211
173
|
const { CFBundleShortVersionString: versionName } = await appInfoParser.parse();
|
|
212
|
-
const buildTimeTxtBuffer =
|
|
174
|
+
const buildTimeTxtBuffer = entries[String(IpaBuildTimeName)] ??
|
|
175
|
+
entries[String(IpaBuildTimeFrameworkName)];
|
|
213
176
|
if (!buildTimeTxtBuffer) {
|
|
214
|
-
throw new Error((0,
|
|
177
|
+
throw new Error((0, i18n_1.t)('buildTimeNotFound'));
|
|
215
178
|
}
|
|
216
179
|
const buildTime = buildTimeTxtBuffer.toString().trim();
|
|
217
|
-
return {
|
|
218
|
-
versionName,
|
|
219
|
-
buildTime,
|
|
220
|
-
...appCredential
|
|
221
|
-
};
|
|
180
|
+
return { versionName, buildTime, ...appCredential };
|
|
222
181
|
}
|
|
223
182
|
async function getAabInfo(fn) {
|
|
224
183
|
const protobuf = require('protobufjs');
|
|
225
|
-
const root = await protobuf.load(
|
|
184
|
+
const root = await protobuf.load(path_1.default.join(__dirname, '../../proto/Resources.proto'));
|
|
226
185
|
const XmlNode = root.lookupType('aapt.pb.XmlNode');
|
|
227
186
|
const buffer = await readZipEntry(fn, 'base/manifest/AndroidManifest.xml');
|
|
228
187
|
const message = XmlNode.decode(buffer);
|
|
@@ -231,14 +190,14 @@ async function getAabInfo(fn) {
|
|
|
231
190
|
longs: String,
|
|
232
191
|
bytes: String,
|
|
233
192
|
defaults: true,
|
|
234
|
-
arrays: true
|
|
193
|
+
arrays: true,
|
|
235
194
|
});
|
|
236
195
|
const manifestElement = object.element;
|
|
237
196
|
if (manifestElement.name !== 'manifest') {
|
|
238
|
-
throw new Error((0,
|
|
197
|
+
throw new Error((0, i18n_1.t)('invalidManifest'));
|
|
239
198
|
}
|
|
240
199
|
let versionName = '';
|
|
241
|
-
for (const attr of manifestElement.attribute){
|
|
200
|
+
for (const attr of manifestElement.attribute) {
|
|
242
201
|
if (attr.name === 'versionName') {
|
|
243
202
|
versionName = attr.value;
|
|
244
203
|
}
|
|
@@ -246,17 +205,11 @@ async function getAabInfo(fn) {
|
|
|
246
205
|
let buildTime = 0;
|
|
247
206
|
const appCredential = {};
|
|
248
207
|
// Find application node
|
|
249
|
-
const applicationNode = manifestElement.child.find((child)=>
|
|
250
|
-
|
|
251
|
-
return ((_child_element = child.element) == null ? void 0 : _child_element.name) === 'application';
|
|
252
|
-
});
|
|
253
|
-
const applicationElement = applicationNode == null ? void 0 : applicationNode.element;
|
|
208
|
+
const applicationNode = manifestElement.child.find((child) => child.element?.name === 'application');
|
|
209
|
+
const applicationElement = applicationNode?.element;
|
|
254
210
|
if (applicationElement) {
|
|
255
|
-
const metaDataNodes = applicationElement.child.filter((child)=>
|
|
256
|
-
|
|
257
|
-
return ((_child_element = child.element) == null ? void 0 : _child_element.name) === 'meta-data';
|
|
258
|
-
});
|
|
259
|
-
for (const meta of metaDataNodes){
|
|
211
|
+
const metaDataNodes = applicationElement.child.filter((child) => child.element?.name === 'meta-data');
|
|
212
|
+
for (const meta of metaDataNodes) {
|
|
260
213
|
let name = '';
|
|
261
214
|
let value = '';
|
|
262
215
|
let resourceId = 0;
|
|
@@ -264,16 +217,16 @@ async function getAabInfo(fn) {
|
|
|
264
217
|
if (!metaElement) {
|
|
265
218
|
continue;
|
|
266
219
|
}
|
|
267
|
-
for (const attr of metaElement.attribute){
|
|
220
|
+
for (const attr of metaElement.attribute) {
|
|
268
221
|
if (attr.name === 'name') {
|
|
269
222
|
name = attr.value;
|
|
270
223
|
}
|
|
271
224
|
if (attr.name === 'value') {
|
|
272
|
-
var _attr_compiledItem_ref, _attr_compiledItem, _attr_compiledItem_prim, _attr_compiledItem1;
|
|
273
225
|
value = attr.value;
|
|
274
|
-
if (
|
|
226
|
+
if (attr.compiledItem?.ref?.id) {
|
|
275
227
|
resourceId = attr.compiledItem.ref.id;
|
|
276
|
-
}
|
|
228
|
+
}
|
|
229
|
+
else if (attr.compiledItem?.prim?.intDecimalValue) {
|
|
277
230
|
value = attr.compiledItem.prim.intDecimalValue.toString();
|
|
278
231
|
}
|
|
279
232
|
}
|
|
@@ -290,59 +243,55 @@ async function getAabInfo(fn) {
|
|
|
290
243
|
}
|
|
291
244
|
}
|
|
292
245
|
if (!Number.isFinite(buildTime) || buildTime === 0) {
|
|
293
|
-
throw new Error((0,
|
|
246
|
+
throw new Error((0, i18n_1.t)('buildTimeNotFound'));
|
|
294
247
|
}
|
|
295
|
-
return {
|
|
296
|
-
versionName,
|
|
297
|
-
buildTime,
|
|
298
|
-
...appCredential
|
|
299
|
-
};
|
|
248
|
+
return { versionName, buildTime, ...appCredential };
|
|
300
249
|
}
|
|
301
250
|
async function readZipEntry(fn, entryName) {
|
|
302
|
-
return new Promise((resolve, reject)=>{
|
|
303
|
-
(0,
|
|
304
|
-
lazyEntries: true
|
|
305
|
-
}, (err, zipfile)=>{
|
|
251
|
+
return new Promise((resolve, reject) => {
|
|
252
|
+
(0, yauzl_1.open)(fn, { lazyEntries: true }, (err, zipfile) => {
|
|
306
253
|
if (err || !zipfile) {
|
|
307
|
-
reject(err
|
|
254
|
+
reject(err ?? new Error('Failed to open zip file'));
|
|
308
255
|
return;
|
|
309
256
|
}
|
|
310
257
|
let found = false;
|
|
311
258
|
zipfile.readEntry();
|
|
312
|
-
zipfile.on('entry', (entry)=>{
|
|
259
|
+
zipfile.on('entry', (entry) => {
|
|
313
260
|
if (entry.fileName === entryName) {
|
|
314
261
|
found = true;
|
|
315
|
-
zipfile.openReadStream(entry, (streamError, readStream)=>{
|
|
262
|
+
zipfile.openReadStream(entry, (streamError, readStream) => {
|
|
316
263
|
if (streamError || !readStream) {
|
|
317
264
|
zipfile.close();
|
|
318
|
-
reject(streamError
|
|
265
|
+
reject(streamError ?? new Error('Failed to read zip entry'));
|
|
319
266
|
return;
|
|
320
267
|
}
|
|
321
268
|
const chunks = [];
|
|
322
|
-
readStream.on('data', (chunk)=>chunks.push(chunk));
|
|
323
|
-
readStream.on('end', ()=>{
|
|
269
|
+
readStream.on('data', (chunk) => chunks.push(chunk));
|
|
270
|
+
readStream.on('end', () => {
|
|
324
271
|
zipfile.close();
|
|
325
272
|
resolve(Buffer.concat(chunks));
|
|
326
273
|
});
|
|
327
|
-
readStream.on('error', (error)=>{
|
|
274
|
+
readStream.on('error', (error) => {
|
|
328
275
|
zipfile.close();
|
|
329
276
|
reject(error);
|
|
330
277
|
});
|
|
331
278
|
});
|
|
332
|
-
}
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
333
281
|
zipfile.readEntry();
|
|
334
282
|
}
|
|
335
283
|
});
|
|
336
|
-
zipfile.on('end', ()=>{
|
|
337
|
-
if (!found)
|
|
284
|
+
zipfile.on('end', () => {
|
|
285
|
+
if (!found)
|
|
286
|
+
reject(new Error(`${entryName} not found in AAB`));
|
|
338
287
|
});
|
|
339
288
|
zipfile.on('error', reject);
|
|
340
289
|
});
|
|
341
290
|
});
|
|
342
291
|
}
|
|
343
292
|
async function resolveResource(fn, resourceId, root) {
|
|
344
|
-
const pkgId = resourceId >> 24 & 0xff;
|
|
345
|
-
const typeId = resourceId >> 16 & 0xff;
|
|
293
|
+
const pkgId = (resourceId >> 24) & 0xff;
|
|
294
|
+
const typeId = (resourceId >> 16) & 0xff;
|
|
346
295
|
const entryId = resourceId & 0xffff;
|
|
347
296
|
try {
|
|
348
297
|
const buffer = await readZipEntry(fn, 'base/resources.pb');
|
|
@@ -353,73 +302,82 @@ async function resolveResource(fn, resourceId, root) {
|
|
|
353
302
|
longs: String,
|
|
354
303
|
bytes: String,
|
|
355
304
|
defaults: true,
|
|
356
|
-
arrays: true
|
|
305
|
+
arrays: true,
|
|
357
306
|
});
|
|
358
307
|
// Find package
|
|
359
|
-
const pkg = object.package.find((pkgItem)=>pkgItem.packageId === pkgId);
|
|
360
|
-
if (!pkg)
|
|
308
|
+
const pkg = object.package.find((pkgItem) => pkgItem.packageId === pkgId);
|
|
309
|
+
if (!pkg)
|
|
310
|
+
return null;
|
|
361
311
|
// Find type
|
|
362
|
-
const type = pkg.type.find((typeItem)=>typeItem.typeId === typeId);
|
|
363
|
-
if (!type)
|
|
312
|
+
const type = pkg.type.find((typeItem) => typeItem.typeId === typeId);
|
|
313
|
+
if (!type)
|
|
314
|
+
return null;
|
|
364
315
|
// Find entry
|
|
365
|
-
const entry = type.entry.find((entryItem)=>entryItem.entryId === entryId);
|
|
366
|
-
if (!entry)
|
|
316
|
+
const entry = type.entry.find((entryItem) => entryItem.entryId === entryId);
|
|
317
|
+
if (!entry)
|
|
318
|
+
return null;
|
|
367
319
|
// Get value from configValue
|
|
368
320
|
if (entry.configValue && entry.configValue.length > 0) {
|
|
369
|
-
|
|
370
|
-
const
|
|
371
|
-
const stringValue = val == null ? void 0 : (_val_item = val.item) == null ? void 0 : (_val_item_str = _val_item.str) == null ? void 0 : _val_item_str.value;
|
|
321
|
+
const val = entry.configValue[0]?.value;
|
|
322
|
+
const stringValue = val?.item?.str?.value;
|
|
372
323
|
if (typeof stringValue === 'string') {
|
|
373
324
|
return stringValue;
|
|
374
325
|
}
|
|
375
326
|
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}));
|
|
327
|
+
}
|
|
328
|
+
catch (e) {
|
|
329
|
+
console.warn((0, i18n_1.t)('failedToResolveResource', { error: e }));
|
|
380
330
|
}
|
|
381
331
|
return null;
|
|
382
332
|
}
|
|
383
333
|
async function getLatestVersion(pkgNames) {
|
|
384
|
-
return (0,
|
|
334
|
+
return (0, latest_version_1.default)(pkgNames, {
|
|
385
335
|
// useCache: true,
|
|
386
336
|
requestOptions: {
|
|
387
|
-
timeout: 2000
|
|
388
|
-
}
|
|
389
|
-
})
|
|
337
|
+
timeout: 2000,
|
|
338
|
+
},
|
|
339
|
+
})
|
|
340
|
+
.then((pkgs) => pkgs.map((pkg) => pkg.latest))
|
|
341
|
+
.catch(() => []);
|
|
390
342
|
}
|
|
391
343
|
async function printVersionCommand() {
|
|
392
344
|
let [latestRnuCliVersion, latestRnuVersion] = await getLatestVersion([
|
|
393
345
|
'react-native-update-cli',
|
|
394
|
-
'react-native-update'
|
|
346
|
+
'react-native-update',
|
|
395
347
|
]);
|
|
396
|
-
latestRnuCliVersion = latestRnuCliVersion
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
348
|
+
latestRnuCliVersion = latestRnuCliVersion
|
|
349
|
+
? ` ${(0, i18n_1.t)('latestVersionTag', {
|
|
350
|
+
version: chalk_1.default.green(latestRnuCliVersion),
|
|
351
|
+
})}`
|
|
352
|
+
: '';
|
|
353
|
+
console.log(`react-native-update-cli: ${package_json_1.default.version}${latestRnuCliVersion}`);
|
|
354
|
+
const rnuVersion = dep_versions_1.depVersions['react-native-update'];
|
|
401
355
|
if (rnuVersion) {
|
|
402
|
-
latestRnuVersion = latestRnuVersion
|
|
403
|
-
version:
|
|
404
|
-
|
|
356
|
+
latestRnuVersion = latestRnuVersion
|
|
357
|
+
? ` ${(0, i18n_1.t)('latestVersionTag', { version: chalk_1.default.green(latestRnuVersion) })}`
|
|
358
|
+
: '';
|
|
405
359
|
console.log(`react-native-update: ${rnuVersion}${latestRnuVersion}`);
|
|
406
|
-
if (
|
|
407
|
-
if ((0,
|
|
360
|
+
if (constants_1.IS_CRESC) {
|
|
361
|
+
if ((0, compare_versions_1.satisfies)(rnuVersion, '<10.27.0')) {
|
|
408
362
|
console.error('Unsupported version, please update to the latest version: npm i react-native-update@latest');
|
|
409
363
|
process.exit(1);
|
|
410
364
|
}
|
|
411
|
-
}
|
|
412
|
-
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
if ((0, compare_versions_1.satisfies)(rnuVersion, '<8.5.2')) {
|
|
413
368
|
console.warn(`当前版本已不再支持,请至少升级到 v8 的最新小版本后重新打包(代码无需改动): npm i react-native-update@8 .
|
|
414
369
|
如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`);
|
|
415
|
-
}
|
|
370
|
+
}
|
|
371
|
+
else if ((0, compare_versions_1.satisfies)(rnuVersion, '9.0.0 - 9.2.1')) {
|
|
416
372
|
console.warn(`当前版本已不再支持,请至少升级到 v9 的最新小版本后重新打包(代码无需改动,可直接热更): npm i react-native-update@9 .
|
|
417
373
|
如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`);
|
|
418
|
-
}
|
|
374
|
+
}
|
|
375
|
+
else if ((0, compare_versions_1.satisfies)(rnuVersion, '10.0.0 - 10.17.0')) {
|
|
419
376
|
console.warn('当前版本已不再支持,请升级到 v10 的最新小版本(代码无需改动,可直接热更): npm i react-native-update@10');
|
|
420
377
|
}
|
|
421
378
|
}
|
|
422
|
-
}
|
|
423
|
-
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
console.log((0, i18n_1.t)('rnuVersionNotFound'));
|
|
424
382
|
}
|
|
425
383
|
}
|