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.
@@ -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
- '找不到bundle文件。请确保此apk为release版本,且bundle文件名为默认的index.android.bundle',
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
- '找不到bundle文件。请确保此app为release版本,且bundle文件名为默认的bundle.harmony.js',
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
- '找不到bundle文件。请确保此ipa为release版本,且bundle文件名为默认的main.jsbundle',
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 [latestPushyCliVersion, latestPushyVersion] = await getLatestVersion([
175
+ let [latestRnuCliVersion, latestRnuVersion] = await getLatestVersion([
172
176
  'react-native-update-cli',
173
177
  'react-native-update',
174
178
  ]);
175
- latestPushyCliVersion = latestPushyCliVersion
176
- ? ` (最新:${chalk.green(latestPushyCliVersion)})`
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}${latestPushyCliVersion}`,
185
+ `react-native-update-cli: ${pkg.version}${latestRnuCliVersion}`,
180
186
  );
181
- let pushyVersion = '';
182
- pushyVersion = depVersions['react-native-update'];
183
- latestPushyVersion = latestPushyVersion
184
- ? ` (最新:${chalk.green(latestPushyVersion)})`
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: ${pushyVersion}${latestPushyVersion}`);
187
- if (pushyVersion) {
188
- if (semverSatisfies(pushyVersion, '<8.5.2')) {
189
- console.warn(
190
- `当前版本已不再支持,请至少升级到 v8 的最新小版本后重新打包(代码无需改动): npm i react-native-update@8 .
191
- 如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`,
192
- );
193
- } else if (semverSatisfies(pushyVersion, '9.0.0 - 9.2.1')) {
194
- console.warn(
195
- `当前版本已不再支持,请至少升级到 v9 的最新小版本后重新打包(代码无需改动,可直接热更): npm i react-native-update@9 .
196
- 如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`,
197
- );
198
- } else if (semverSatisfies(pushyVersion, '10.0.0 - 10.17.0')) {
199
- console.warn(
200
- '当前版本已不再支持,请升级到 v10 的最新小版本(代码无需改动,可直接热更): npm i react-native-update@10',
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('react-native-update: 无法获取版本号,请在项目目录中运行命令');
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.toLowerCase()) {
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;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- const lockFiles = [
3
- 'package-lock.json',
4
- 'yarn.lock',
5
- 'pnpm-lock.yaml',
6
- 'bun.lockb',
7
- 'bun.lock'
8
- ];
@@ -1,7 +0,0 @@
1
- const lockFiles = [
2
- 'package-lock.json',
3
- 'yarn.lock',
4
- 'pnpm-lock.yaml',
5
- 'bun.lockb',
6
- 'bun.lock',
7
- ];