react-native-update-cli 1.42.1 → 1.43.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 +11 -11
- package/lib/api.js +9 -4
- package/lib/app.js +34 -26
- package/lib/bundle.js +10 -1
- package/lib/locales/en.js +22 -2
- package/lib/locales/zh.js +21 -1
- package/lib/utils/add-gitignore.js +43 -0
- package/lib/utils/app-info-parser/index.js +13 -4
- package/lib/utils/check-lockfile.js +42 -0
- package/lib/utils/check-plugin.js +2 -2
- package/lib/utils/constants.js +4 -0
- package/lib/utils/i18n.js +7 -2
- package/lib/utils/index.js +44 -23
- package/lib/versions.js +1 -1
- package/package.json +1 -1
- package/src/api.ts +13 -9
- package/src/app.ts +20 -32
- package/src/bundle.ts +9 -1
- package/src/locales/en.ts +27 -1
- package/src/locales/zh.ts +26 -1
- package/src/utils/add-gitignore.ts +34 -0
- package/src/utils/app-info-parser/{index.js → index.ts} +7 -5
- package/src/utils/check-lockfile.ts +29 -0
- package/src/utils/check-plugin.ts +2 -2
- package/src/utils/constants.ts +5 -3
- package/src/utils/i18n.ts +8 -2
- package/src/utils/index.ts +54 -39
- package/src/versions.ts +9 -3
- package/lib/utils/lock-checker.js +0 -8
- package/src/utils/lock-checker.ts +0 -7
package/src/utils/index.ts
CHANGED
|
@@ -9,8 +9,9 @@ import latestVersion from '@badisi/latest-version';
|
|
|
9
9
|
import { checkPlugins } from './check-plugin';
|
|
10
10
|
|
|
11
11
|
import { read } from 'read';
|
|
12
|
-
import { tempDir } from './constants';
|
|
12
|
+
import { IS_CRESC, tempDir } from './constants';
|
|
13
13
|
import { depVersions } from './dep-versions';
|
|
14
|
+
import { t } from './i18n';
|
|
14
15
|
|
|
15
16
|
export async function question(query: string, password?: boolean) {
|
|
16
17
|
if (NO_INTERACTIVE) {
|
|
@@ -46,7 +47,10 @@ export async function getApkInfo(fn: string) {
|
|
|
46
47
|
);
|
|
47
48
|
if (!bundleFile) {
|
|
48
49
|
throw new Error(
|
|
49
|
-
'
|
|
50
|
+
t('bundleNotFound', {
|
|
51
|
+
packageType: 'apk',
|
|
52
|
+
entryFile: 'index.android.bundle',
|
|
53
|
+
}),
|
|
50
54
|
);
|
|
51
55
|
}
|
|
52
56
|
const updateJsonFile = await appInfoParser.parser.getEntry(
|
|
@@ -66,21 +70,22 @@ export async function getApkInfo(fn: string) {
|
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
if (buildTime == 0) {
|
|
69
|
-
throw new Error(
|
|
70
|
-
'无法获取此包的编译时间戳。请更新 react-native-update 到最新版本后重新打包上传。',
|
|
71
|
-
);
|
|
73
|
+
throw new Error(t('buildTimeNotFound'));
|
|
72
74
|
}
|
|
73
75
|
return { versionName, buildTime, ...appCredential };
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
export async function getAppInfo(fn) {
|
|
78
|
+
export async function getAppInfo(fn: string) {
|
|
77
79
|
const appInfoParser = new AppInfoParser(fn);
|
|
78
80
|
const bundleFile = await appInfoParser.parser.getEntryFromHarmonyApp(
|
|
79
81
|
/rawfile\/bundle.harmony.js/,
|
|
80
82
|
);
|
|
81
83
|
if (!bundleFile) {
|
|
82
84
|
throw new Error(
|
|
83
|
-
'
|
|
85
|
+
t('bundleNotFound', {
|
|
86
|
+
packageType: 'app',
|
|
87
|
+
entryFile: 'bundle.harmony.js',
|
|
88
|
+
}),
|
|
84
89
|
);
|
|
85
90
|
}
|
|
86
91
|
const updateJsonFile = await appInfoParser.parser.getEntryFromHarmonyApp(
|
|
@@ -103,9 +108,7 @@ export async function getAppInfo(fn) {
|
|
|
103
108
|
buildTime = pushy_build_time;
|
|
104
109
|
}
|
|
105
110
|
if (buildTime == 0) {
|
|
106
|
-
throw new Error(
|
|
107
|
-
'无法获取此包的编译时间戳。请更新 react-native-update 到最新版本后重新打包上传。',
|
|
108
|
-
);
|
|
111
|
+
throw new Error(t('buildTimeNotFound'));
|
|
109
112
|
}
|
|
110
113
|
return { versionName, buildTime, ...appCredential };
|
|
111
114
|
}
|
|
@@ -117,7 +120,10 @@ export async function getIpaInfo(fn: string) {
|
|
|
117
120
|
);
|
|
118
121
|
if (!bundleFile) {
|
|
119
122
|
throw new Error(
|
|
120
|
-
'
|
|
123
|
+
t('bundleNotFound', {
|
|
124
|
+
packageType: 'ipa',
|
|
125
|
+
entryFile: 'main.jsbundle',
|
|
126
|
+
}),
|
|
121
127
|
);
|
|
122
128
|
}
|
|
123
129
|
const updateJsonFile = await appInfoParser.parser.getEntry(
|
|
@@ -139,9 +145,7 @@ export async function getIpaInfo(fn: string) {
|
|
|
139
145
|
);
|
|
140
146
|
}
|
|
141
147
|
if (!buildTimeTxtBuffer) {
|
|
142
|
-
throw new Error(
|
|
143
|
-
'无法获取此包的编译时间戳。请更新 react-native-update 到最新版本后重新打包上传。',
|
|
144
|
-
);
|
|
148
|
+
throw new Error(t('buildTimeNotFound'));
|
|
145
149
|
}
|
|
146
150
|
const buildTime = buildTimeTxtBuffer.toString().replace('\n', '');
|
|
147
151
|
return { versionName, buildTime, ...appCredential };
|
|
@@ -168,40 +172,51 @@ async function getLatestVersion(pkgNames: string[]) {
|
|
|
168
172
|
}
|
|
169
173
|
|
|
170
174
|
export async function printVersionCommand() {
|
|
171
|
-
let [
|
|
175
|
+
let [latestRnuCliVersion, latestRnuVersion] = await getLatestVersion([
|
|
172
176
|
'react-native-update-cli',
|
|
173
177
|
'react-native-update',
|
|
174
178
|
]);
|
|
175
|
-
|
|
176
|
-
? `
|
|
179
|
+
latestRnuCliVersion = latestRnuCliVersion
|
|
180
|
+
? ` ${t('latestVersionTag', {
|
|
181
|
+
version: chalk.green(latestRnuCliVersion),
|
|
182
|
+
})}`
|
|
177
183
|
: '';
|
|
178
184
|
console.log(
|
|
179
|
-
`react-native-update-cli: ${pkg.version}${
|
|
185
|
+
`react-native-update-cli: ${pkg.version}${latestRnuCliVersion}`,
|
|
180
186
|
);
|
|
181
|
-
let
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
? `
|
|
187
|
+
let rnuVersion = '';
|
|
188
|
+
rnuVersion = depVersions['react-native-update'];
|
|
189
|
+
latestRnuVersion = latestRnuVersion
|
|
190
|
+
? ` ${t('latestVersionTag', { version: chalk.green(latestRnuVersion) })}`
|
|
185
191
|
: '';
|
|
186
|
-
console.log(`react-native-update: ${
|
|
187
|
-
if (
|
|
188
|
-
if (
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
)
|
|
192
|
+
console.log(`react-native-update: ${rnuVersion}${latestRnuVersion}`);
|
|
193
|
+
if (rnuVersion) {
|
|
194
|
+
if (IS_CRESC) {
|
|
195
|
+
if (semverSatisfies(rnuVersion, '<10.27.0')) {
|
|
196
|
+
console.error(
|
|
197
|
+
'Unsupported version, please update to the latest version: npm i react-native-update@latest',
|
|
198
|
+
);
|
|
199
|
+
process.exit(1);
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
if (semverSatisfies(rnuVersion, '<8.5.2')) {
|
|
203
|
+
console.warn(
|
|
204
|
+
`当前版本已不再支持,请至少升级到 v8 的最新小版本后重新打包(代码无需改动): npm i react-native-update@8 .
|
|
205
|
+
如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`,
|
|
206
|
+
);
|
|
207
|
+
} else if (semverSatisfies(rnuVersion, '9.0.0 - 9.2.1')) {
|
|
208
|
+
console.warn(
|
|
209
|
+
`当前版本已不再支持,请至少升级到 v9 的最新小版本后重新打包(代码无需改动,可直接热更): npm i react-native-update@9 .
|
|
210
|
+
如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`,
|
|
211
|
+
);
|
|
212
|
+
} else if (semverSatisfies(rnuVersion, '10.0.0 - 10.17.0')) {
|
|
213
|
+
console.warn(
|
|
214
|
+
'当前版本已不再支持,请升级到 v10 的最新小版本(代码无需改动,可直接热更): npm i react-native-update@10',
|
|
215
|
+
);
|
|
216
|
+
}
|
|
202
217
|
}
|
|
203
218
|
} else {
|
|
204
|
-
console.log('
|
|
219
|
+
console.log(t('rnuVersionNotFound'));
|
|
205
220
|
}
|
|
206
221
|
}
|
|
207
222
|
|
package/src/versions.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { choosePackage } from './package';
|
|
|
6
6
|
import { compare } from 'compare-versions';
|
|
7
7
|
import { depVersions } from './utils/dep-versions';
|
|
8
8
|
import { getCommitInfo } from './utils/git';
|
|
9
|
+
import { Platform } from 'types';
|
|
9
10
|
|
|
10
11
|
async function showVersion(appId: string, offset: number) {
|
|
11
12
|
const { data, count } = await get(`/app/${appId}/version/list`);
|
|
@@ -61,7 +62,7 @@ async function chooseVersion(appId: string) {
|
|
|
61
62
|
const cmd = await question(
|
|
62
63
|
'Enter versionId or page Up/page Down/Begin(U/D/B)',
|
|
63
64
|
);
|
|
64
|
-
switch (cmd.
|
|
65
|
+
switch (cmd.toUpperCase()) {
|
|
65
66
|
case 'U':
|
|
66
67
|
offset = Math.max(0, offset - 10);
|
|
67
68
|
break;
|
|
@@ -82,7 +83,12 @@ async function chooseVersion(appId: string) {
|
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
export const commands = {
|
|
85
|
-
publish: async function ({ args, options }
|
|
86
|
+
publish: async function ({ args, options }: { args: string[]; options: {
|
|
87
|
+
name: string;
|
|
88
|
+
description?: string;
|
|
89
|
+
metaInfo?: string;
|
|
90
|
+
platform?: Platform;
|
|
91
|
+
} }) {
|
|
86
92
|
const fn = args[0];
|
|
87
93
|
const { name, description, metaInfo } = options;
|
|
88
94
|
|
|
@@ -136,7 +142,7 @@ export const commands = {
|
|
|
136
142
|
versionId = null;
|
|
137
143
|
}
|
|
138
144
|
|
|
139
|
-
let pkgId;
|
|
145
|
+
let pkgId: string | undefined;
|
|
140
146
|
let pkgVersion = options.packageVersion;
|
|
141
147
|
let minPkgVersion = options.minPackageVersion;
|
|
142
148
|
let maxPkgVersion = options.maxPackageVersion;
|