react-native-update-cli 1.30.4 → 1.31.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/cli.json +3 -1
- package/lib/api.js +177 -186
- package/lib/app.js +136 -114
- package/lib/bundle.js +535 -559
- package/lib/index.js +46 -49
- package/lib/package.js +132 -136
- package/lib/user.js +43 -41
- package/lib/utils/app-info-parser/apk.js +72 -71
- package/lib/utils/app-info-parser/index.js +28 -30
- package/lib/utils/app-info-parser/ipa.js +72 -80
- package/lib/utils/app-info-parser/resource-finder.js +286 -421
- package/lib/utils/app-info-parser/utils.js +106 -120
- package/lib/utils/app-info-parser/xml-parser/binary.js +539 -637
- package/lib/utils/app-info-parser/xml-parser/manifest.js +193 -215
- package/lib/utils/app-info-parser/zip.js +40 -40
- package/lib/utils/index.js +154 -149
- package/lib/versions.js +226 -178
- package/package.json +10 -9
- package/src/api.js +6 -3
- package/src/bundle.js +11 -10
- package/src/versions.js +80 -16
package/lib/utils/index.js
CHANGED
|
@@ -1,170 +1,175 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
getApkInfo: function() {
|
|
13
|
+
return getApkInfo;
|
|
14
|
+
},
|
|
15
|
+
getIpaInfo: function() {
|
|
16
|
+
return getIpaInfo;
|
|
17
|
+
},
|
|
18
|
+
getRNVersion: function() {
|
|
19
|
+
return getRNVersion;
|
|
20
|
+
},
|
|
21
|
+
pricingPageUrl: function() {
|
|
22
|
+
return pricingPageUrl;
|
|
23
|
+
},
|
|
24
|
+
printVersionCommand: function() {
|
|
25
|
+
return printVersionCommand;
|
|
26
|
+
},
|
|
27
|
+
question: function() {
|
|
28
|
+
return question;
|
|
29
|
+
},
|
|
30
|
+
saveToLocal: function() {
|
|
31
|
+
return saveToLocal;
|
|
32
|
+
},
|
|
33
|
+
translateOptions: function() {
|
|
34
|
+
return translateOptions;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra"));
|
|
38
|
+
const _os = /*#__PURE__*/ _interop_require_default(require("os"));
|
|
39
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
40
|
+
const _packagejson = /*#__PURE__*/ _interop_require_default(require("../../package.json"));
|
|
41
|
+
const _appinfoparser = /*#__PURE__*/ _interop_require_default(require("./app-info-parser"));
|
|
42
|
+
const _satisfies = /*#__PURE__*/ _interop_require_default(require("semver/functions/satisfies"));
|
|
43
|
+
const _read = /*#__PURE__*/ _interop_require_default(require("read"));
|
|
44
|
+
function _interop_require_default(obj) {
|
|
45
|
+
return obj && obj.__esModule ? obj : {
|
|
46
|
+
default: obj
|
|
47
|
+
};
|
|
48
|
+
}
|
|
48
49
|
function question(query, password) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
if (NO_INTERACTIVE) {
|
|
51
|
+
return Promise.resolve('');
|
|
52
|
+
}
|
|
53
|
+
return new Promise((resolve, reject)=>(0, _read.default)({
|
|
54
|
+
prompt: query,
|
|
55
|
+
silent: password,
|
|
56
|
+
replace: password ? '*' : undefined
|
|
57
|
+
}, (err, result)=>err ? reject(err) : resolve(result)));
|
|
57
58
|
}
|
|
58
|
-
|
|
59
59
|
function translateOptions(options) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
const ret = {};
|
|
61
|
+
for(let key in options){
|
|
62
|
+
const v = options[key];
|
|
63
|
+
if (typeof v === 'string') {
|
|
64
|
+
ret[key] = v.replace(/\$\{(\w+)\}/g, function(v, n) {
|
|
65
|
+
return options[n] || process.env[n] || v;
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
ret[key] = v;
|
|
69
|
+
}
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
-
return ret;
|
|
71
|
+
return ret;
|
|
72
72
|
}
|
|
73
|
-
|
|
74
73
|
function getRNVersion() {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
74
|
+
const version = JSON.parse(_fsextra.default.readFileSync(require.resolve('react-native/package.json', {
|
|
75
|
+
paths: [
|
|
76
|
+
process.cwd()
|
|
77
|
+
]
|
|
78
|
+
}))).version;
|
|
79
|
+
// We only care about major and minor version.
|
|
80
|
+
const match = /^(\d+)\.(\d+)\./.exec(version);
|
|
81
|
+
return {
|
|
82
|
+
version,
|
|
83
|
+
major: match[1] | 0,
|
|
84
|
+
minor: match[2] | 0
|
|
85
|
+
};
|
|
86
86
|
}
|
|
87
|
-
|
|
88
87
|
async function getApkInfo(fn) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
88
|
+
const appInfoParser = new _appinfoparser.default(fn);
|
|
89
|
+
const bundleFile = await appInfoParser.parser.getEntry(/assets\/index.android.bundle/);
|
|
90
|
+
if (!bundleFile) {
|
|
91
|
+
throw new Error('找不到bundle文件。请确保此apk为release版本,且bundle文件名为默认的index.android.bundle');
|
|
92
|
+
}
|
|
93
|
+
const updateJsonFile = await appInfoParser.parser.getEntry(/res\/raw\/update.json/);
|
|
94
|
+
let appCredential = {};
|
|
95
|
+
if (updateJsonFile) {
|
|
96
|
+
appCredential = JSON.parse(updateJsonFile.toString()).android;
|
|
97
|
+
}
|
|
98
|
+
const { versionName, application } = await appInfoParser.parse();
|
|
99
|
+
let buildTime = 0;
|
|
100
|
+
if (Array.isArray(application.metaData)) {
|
|
101
|
+
for (const meta of application.metaData){
|
|
102
|
+
if (meta.name === 'pushy_build_time') {
|
|
103
|
+
buildTime = meta.value[0];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
if (buildTime == 0) {
|
|
108
|
+
throw new Error('无法获取此包的编译时间戳。请更新 react-native-update 到最新版本后重新打包上传。');
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
versionName,
|
|
112
|
+
buildTime,
|
|
113
|
+
...appCredential
|
|
114
|
+
};
|
|
112
115
|
}
|
|
113
|
-
|
|
114
116
|
async function getIpaInfo(fn) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
117
|
+
const appInfoParser = new _appinfoparser.default(fn);
|
|
118
|
+
const bundleFile = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/main.jsbundle/);
|
|
119
|
+
if (!bundleFile) {
|
|
120
|
+
throw new Error('找不到bundle文件。请确保此ipa为release版本,且bundle文件名为默认的main.jsbundle');
|
|
121
|
+
}
|
|
122
|
+
const updateJsonFile = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/assets\/update.json/);
|
|
123
|
+
let appCredential = {};
|
|
124
|
+
if (updateJsonFile) {
|
|
125
|
+
appCredential = JSON.parse(updateJsonFile.toString()).ios;
|
|
126
|
+
}
|
|
127
|
+
const { CFBundleShortVersionString: versionName } = await appInfoParser.parse();
|
|
128
|
+
let buildTimeTxtBuffer = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/pushy_build_time.txt/);
|
|
129
|
+
if (!buildTimeTxtBuffer) {
|
|
130
|
+
// Not in root bundle when use `use_frameworks`
|
|
131
|
+
buildTimeTxtBuffer = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/frameworks\/react_native_update.framework\/pushy_build_time.txt/);
|
|
132
|
+
}
|
|
133
|
+
if (!buildTimeTxtBuffer) {
|
|
134
|
+
throw new Error('无法获取此包的编译时间戳。请更新 react-native-update 到最新版本后重新打包上传。');
|
|
135
|
+
}
|
|
136
|
+
const buildTime = buildTimeTxtBuffer.toString().replace('\n', '');
|
|
137
|
+
return {
|
|
138
|
+
versionName,
|
|
139
|
+
buildTime,
|
|
140
|
+
...appCredential
|
|
141
|
+
};
|
|
136
142
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
_fsExtra2.default.ensureDirSync(localDir);
|
|
143
|
+
const localDir = _path.default.resolve(_os.default.homedir(), '.pushy');
|
|
144
|
+
_fsextra.default.ensureDirSync(localDir);
|
|
140
145
|
function saveToLocal(originPath, destName) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
146
|
+
// TODO
|
|
147
|
+
// const destPath = path.join(localDir, destName);
|
|
148
|
+
// fs.ensureDirSync(path.dirname(destPath));
|
|
149
|
+
// fs.copyFileSync(originPath, destPath);
|
|
145
150
|
}
|
|
146
|
-
|
|
147
151
|
function printVersionCommand() {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
152
|
+
console.log('react-native-update-cli: ' + _packagejson.default.version);
|
|
153
|
+
let pushyVersion = '';
|
|
154
|
+
try {
|
|
155
|
+
const PACKAGE_JSON_PATH = require.resolve('react-native-update/package.json', {
|
|
156
|
+
paths: [
|
|
157
|
+
process.cwd()
|
|
158
|
+
]
|
|
159
|
+
});
|
|
160
|
+
pushyVersion = require(PACKAGE_JSON_PATH).version;
|
|
161
|
+
console.log('react-native-update: ' + pushyVersion);
|
|
162
|
+
} catch (e) {
|
|
163
|
+
console.log('react-native-update: 无法获取版本号,请在项目目录中运行命令');
|
|
164
|
+
}
|
|
165
|
+
if (pushyVersion) {
|
|
166
|
+
if ((0, _satisfies.default)(pushyVersion, '<8.5.1')) {
|
|
167
|
+
console.warn(`当前版本已不再支持,请至少升级到 v8 的最新小版本后重新打包(代码无需改动): npm i react-native-update@8 .
|
|
162
168
|
如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`);
|
|
163
|
-
|
|
164
|
-
|
|
169
|
+
} else if ((0, _satisfies.default)(pushyVersion, '9.0.0 - 9.2.0')) {
|
|
170
|
+
console.warn(`当前版本已不再支持,请至少升级到 v9 的最新小版本后重新打包(代码无需改动): npm i react-native-update@9 .
|
|
165
171
|
如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`);
|
|
172
|
+
}
|
|
166
173
|
}
|
|
167
|
-
}
|
|
168
174
|
}
|
|
169
|
-
|
|
170
|
-
const pricingPageUrl = exports.pricingPageUrl = 'https://pushy.reactnative.cn/pricing.html';
|
|
175
|
+
const pricingPageUrl = 'https://pushy.reactnative.cn/pricing.html';
|