react-native-update-cli 2.8.4 → 2.9.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.
Files changed (112) hide show
  1. package/lib/api.d.ts +18 -0
  2. package/lib/app.d.ts +38 -0
  3. package/lib/app.js +5 -4
  4. package/lib/bundle-pack.d.ts +1 -0
  5. package/lib/bundle-pack.js +104 -0
  6. package/lib/bundle-runner.d.ts +20 -0
  7. package/lib/bundle-runner.js +404 -0
  8. package/lib/bundle.d.ts +6 -0
  9. package/lib/bundle.js +73 -471
  10. package/lib/diff.d.ts +13 -0
  11. package/lib/diff.js +144 -123
  12. package/lib/exports.d.ts +12 -0
  13. package/lib/index.d.ts +5 -0
  14. package/lib/index.js +5 -13
  15. package/lib/install.d.ts +4 -0
  16. package/lib/locales/en.d.ts +137 -0
  17. package/lib/locales/en.js +11 -0
  18. package/lib/locales/zh.d.ts +136 -0
  19. package/lib/locales/zh.js +11 -0
  20. package/lib/module-manager.d.ts +20 -0
  21. package/lib/module-manager.js +3 -9
  22. package/lib/modules/app-module.d.ts +2 -0
  23. package/lib/modules/app-module.js +84 -44
  24. package/lib/modules/bundle-module.d.ts +2 -0
  25. package/lib/modules/bundle-module.js +7 -8
  26. package/lib/modules/index.d.ts +6 -0
  27. package/lib/modules/package-module.d.ts +2 -0
  28. package/lib/modules/user-module.d.ts +2 -0
  29. package/lib/modules/user-module.js +55 -44
  30. package/lib/modules/version-module.d.ts +2 -0
  31. package/lib/package.d.ts +58 -0
  32. package/lib/package.js +103 -139
  33. package/lib/provider.d.ts +26 -0
  34. package/lib/provider.js +115 -217
  35. package/lib/types.d.ts +120 -0
  36. package/lib/user.d.ts +8 -0
  37. package/lib/utils/add-gitignore.d.ts +1 -0
  38. package/lib/utils/app-info-parser/aab.d.ts +22 -0
  39. package/lib/utils/app-info-parser/aab.js +0 -4
  40. package/lib/utils/app-info-parser/apk.d.ts +14 -0
  41. package/lib/utils/app-info-parser/apk.js +6 -4
  42. package/lib/utils/app-info-parser/app.d.ts +4 -0
  43. package/lib/utils/app-info-parser/app.js +3 -0
  44. package/lib/utils/app-info-parser/index.d.ts +16 -0
  45. package/lib/utils/app-info-parser/index.js +2 -0
  46. package/lib/utils/app-info-parser/ipa.d.ts +14 -0
  47. package/lib/utils/app-info-parser/ipa.js +1 -1
  48. package/lib/utils/app-info-parser/resource-finder.d.ts +49 -0
  49. package/lib/utils/app-info-parser/utils.d.ts +31 -0
  50. package/lib/utils/app-info-parser/utils.js +1 -0
  51. package/lib/utils/app-info-parser/xml-parser/binary.d.ts +56 -0
  52. package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +10 -0
  53. package/lib/utils/app-info-parser/zip.d.ts +18 -0
  54. package/lib/utils/app-info-parser/zip.js +7 -9
  55. package/lib/utils/check-lockfile.d.ts +1 -0
  56. package/lib/utils/check-plugin.d.ts +7 -0
  57. package/lib/utils/command-result.d.ts +3 -0
  58. package/lib/utils/command-result.js +35 -0
  59. package/lib/utils/constants.d.ts +9 -0
  60. package/lib/utils/dep-versions.d.ts +1 -0
  61. package/lib/utils/git.d.ts +8 -0
  62. package/lib/utils/http-helper.d.ts +4 -0
  63. package/lib/utils/i18n.d.ts +12 -0
  64. package/lib/utils/index.d.ts +22 -0
  65. package/lib/utils/index.js +52 -22
  66. package/lib/utils/latest-version/cli.d.ts +1 -0
  67. package/lib/utils/latest-version/cli.js +24 -60
  68. package/lib/utils/latest-version/index.d.ts +146 -0
  69. package/lib/utils/latest-version/index.js +22 -22
  70. package/lib/utils/options.d.ts +4 -0
  71. package/lib/utils/options.js +63 -0
  72. package/lib/utils/plugin-config.d.ts +9 -0
  73. package/lib/utils/zip-entries.d.ts +3 -0
  74. package/lib/versions.d.ts +43 -0
  75. package/lib/versions.js +186 -2
  76. package/lib/workflow-runner.d.ts +2 -0
  77. package/lib/workflow-runner.js +25 -0
  78. package/package.json +20 -5
  79. package/src/api.ts +1 -1
  80. package/src/app.ts +20 -11
  81. package/src/bundle-pack.ts +51 -0
  82. package/src/bundle-runner.ts +463 -0
  83. package/src/bundle.ts +184 -571
  84. package/src/diff.ts +208 -174
  85. package/src/index.ts +15 -17
  86. package/src/locales/en.ts +15 -0
  87. package/src/locales/zh.ts +13 -0
  88. package/src/module-manager.ts +15 -15
  89. package/src/modules/app-module.ts +120 -48
  90. package/src/modules/bundle-module.ts +21 -11
  91. package/src/modules/package-module.ts +0 -1
  92. package/src/modules/user-module.ts +117 -58
  93. package/src/package.ts +158 -138
  94. package/src/provider.ts +164 -240
  95. package/src/types.ts +15 -8
  96. package/src/utils/app-info-parser/aab.ts +0 -7
  97. package/src/utils/app-info-parser/apk.ts +9 -6
  98. package/src/utils/app-info-parser/app.ts +5 -1
  99. package/src/utils/app-info-parser/index.ts +11 -6
  100. package/src/utils/app-info-parser/ipa.ts +1 -1
  101. package/src/utils/app-info-parser/utils.ts +3 -0
  102. package/src/utils/app-info-parser/xml-parser/manifest.ts +3 -1
  103. package/src/utils/app-info-parser/zip.ts +12 -14
  104. package/src/utils/command-result.ts +24 -0
  105. package/src/utils/index.ts +138 -39
  106. package/src/utils/latest-version/cli.ts +22 -20
  107. package/src/utils/latest-version/index.ts +20 -20
  108. package/src/utils/options.ts +56 -0
  109. package/src/utils/zip-entries.ts +1 -1
  110. package/src/versions.ts +265 -2
  111. package/src/workflow-runner.ts +24 -0
  112. package/index.js +0 -1
package/src/package.ts CHANGED
@@ -18,6 +18,122 @@ import { depVersions } from './utils/dep-versions';
18
18
  import { getCommitInfo } from './utils/git';
19
19
  import { t } from './utils/i18n';
20
20
 
21
+ type PackageCommandOptions = Record<string, unknown> & {
22
+ version?: string;
23
+ includeAllSplits?: boolean | string;
24
+ splits?: string;
25
+ output?: string;
26
+ };
27
+
28
+ type PackageVersionRef = {
29
+ id?: string | number;
30
+ name?: string | number;
31
+ };
32
+
33
+ type NativePackageInfo = {
34
+ versionName?: string | number;
35
+ buildTime?: string | number;
36
+ appId?: string;
37
+ appKey?: string;
38
+ [key: string]: unknown;
39
+ };
40
+
41
+ type NativeUploadConfig = {
42
+ extension: '.ipa' | '.apk' | '.app';
43
+ platform: Platform;
44
+ appIdMismatchKey: string;
45
+ appKeyMismatchKey: string;
46
+ successKey: string;
47
+ getInfo: (filePath: string) => Promise<NativePackageInfo>;
48
+ normalizeBuildTime?: (
49
+ buildTime: NativePackageInfo['buildTime'],
50
+ ) => string | number | undefined;
51
+ };
52
+
53
+ function ensureFileByExt(
54
+ filePath: string | undefined,
55
+ extension: NativeUploadConfig['extension'] | '.aab',
56
+ usageKey: string,
57
+ ): string {
58
+ if (!filePath || !filePath.endsWith(extension)) {
59
+ throw new Error(t(usageKey));
60
+ }
61
+ return filePath;
62
+ }
63
+
64
+ function parseBooleanOption(value: unknown): boolean {
65
+ return value === true || value === 'true';
66
+ }
67
+
68
+ function parseCsvOption(value: unknown): string[] | null {
69
+ if (typeof value !== 'string') {
70
+ return null;
71
+ }
72
+ const parsed = value
73
+ .split(',')
74
+ .map((item) => item.trim())
75
+ .filter(Boolean);
76
+ return parsed.length > 0 ? parsed : null;
77
+ }
78
+
79
+ function getVersionBinding(version: unknown): PackageVersionRef | undefined {
80
+ if (!version || typeof version !== 'object') {
81
+ return undefined;
82
+ }
83
+
84
+ const v = version as PackageVersionRef;
85
+ return { id: v.id, name: v.name };
86
+ }
87
+
88
+ async function uploadNativePackage(
89
+ filePath: string,
90
+ options: PackageCommandOptions,
91
+ config: NativeUploadConfig,
92
+ ): Promise<void> {
93
+ const info = await config.getInfo(filePath);
94
+ const { versionName: extractedVersionName, buildTime } = info;
95
+ const { appId: appIdInPkg, appKey: appKeyInPkg } = info;
96
+ const { appId, appKey } = await getSelectedApp(config.platform);
97
+
98
+ if (appIdInPkg && appIdInPkg != appId) {
99
+ throw new Error(t(config.appIdMismatchKey, { appIdInPkg, appId }));
100
+ }
101
+
102
+ if (appKeyInPkg && appKeyInPkg !== appKey) {
103
+ throw new Error(t(config.appKeyMismatchKey, { appKeyInPkg, appKey }));
104
+ }
105
+
106
+ const customVersion =
107
+ typeof options.version === 'string' && options.version
108
+ ? options.version
109
+ : undefined;
110
+ const versionName = customVersion ?? extractedVersionName;
111
+ if (customVersion !== undefined) {
112
+ console.log(t('usingCustomVersion', { version: versionName }));
113
+ }
114
+
115
+ const { hash } = await uploadFile(filePath);
116
+ const normalizedBuildTime = config.normalizeBuildTime
117
+ ? config.normalizeBuildTime(buildTime)
118
+ : buildTime;
119
+
120
+ const { id } = await post(`/app/${appId}/package/create`, {
121
+ name: versionName,
122
+ hash,
123
+ buildTime: normalizedBuildTime,
124
+ deps: depVersions,
125
+ commit: await getCommitInfo(),
126
+ });
127
+ saveToLocal(filePath, `${appId}/package/${id}${config.extension}`);
128
+ console.log(
129
+ t(config.successKey, {
130
+ id,
131
+ version: versionName,
132
+ buildTime: normalizedBuildTime,
133
+ }),
134
+ );
135
+ }
136
+
21
137
  export async function listPackage(appId: string) {
22
138
  const allPkgs = (await getAllPackages(appId)) || [];
23
139
 
@@ -30,10 +146,10 @@ export async function listPackage(appId: string) {
30
146
  const { version } = pkg;
31
147
  let versionInfo = '';
32
148
  if (version) {
33
- const versionObj = version as any;
149
+ const versionObj = getVersionBinding(version);
34
150
  versionInfo = t('boundTo', {
35
- name: versionObj.name || version,
36
- id: versionObj.id || version,
151
+ name: versionObj?.name ?? version,
152
+ id: versionObj?.id ?? version,
37
153
  });
38
154
  }
39
155
  let output = pkg.name;
@@ -70,112 +186,51 @@ export const packageCommands = {
70
186
  options,
71
187
  }: {
72
188
  args: string[];
73
- options: Record<string, any>;
189
+ options: PackageCommandOptions;
74
190
  }) => {
75
- const fn = args[0];
76
- if (!fn || !fn.endsWith('.ipa')) {
77
- throw new Error(t('usageUploadIpa'));
78
- }
79
- const ipaInfo = await getIpaInfo(fn);
80
- const { versionName: extractedVersionName, buildTime } = ipaInfo;
81
- const appIdInPkg = (ipaInfo as any).appId;
82
- const appKeyInPkg = (ipaInfo as any).appKey;
83
- const { appId, appKey } = await getSelectedApp('ios');
84
-
85
- if (appIdInPkg && appIdInPkg != appId) {
86
- throw new Error(t('appIdMismatchIpa', { appIdInPkg, appId }));
87
- }
88
-
89
- if (appKeyInPkg && appKeyInPkg !== appKey) {
90
- throw new Error(t('appKeyMismatchIpa', { appKeyInPkg, appKey }));
91
- }
92
-
93
- // Use custom version if provided, otherwise use extracted version
94
- const versionName = options.version || extractedVersionName;
95
- if (options.version) {
96
- console.log(t('usingCustomVersion', { version: versionName }));
97
- }
98
-
99
- const { hash } = await uploadFile(fn);
100
-
101
- const { id } = await post(`/app/${appId}/package/create`, {
102
- name: versionName,
103
- hash,
104
- buildTime,
105
- deps: depVersions,
106
- commit: await getCommitInfo(),
191
+ const fn = ensureFileByExt(args[0], '.ipa', 'usageUploadIpa');
192
+ await uploadNativePackage(fn, options, {
193
+ extension: '.ipa',
194
+ platform: 'ios',
195
+ appIdMismatchKey: 'appIdMismatchIpa',
196
+ appKeyMismatchKey: 'appKeyMismatchIpa',
197
+ successKey: 'ipaUploadSuccess',
198
+ getInfo: (filePath) => getIpaInfo(filePath),
107
199
  });
108
- saveToLocal(fn, `${appId}/package/${id}.ipa`);
109
- console.log(t('ipaUploadSuccess', { id, version: versionName, buildTime }));
110
200
  },
111
201
  uploadApk: async ({
112
202
  args,
113
203
  options,
114
204
  }: {
115
205
  args: string[];
116
- options: Record<string, any>;
206
+ options: PackageCommandOptions;
117
207
  }) => {
118
- const fn = args[0];
119
- if (!fn || !fn.endsWith('.apk')) {
120
- throw new Error(t('usageUploadApk'));
121
- }
122
- const apkInfo = await getApkInfo(fn);
123
- const { versionName: extractedVersionName, buildTime } = apkInfo;
124
- const appIdInPkg = (apkInfo as any).appId;
125
- const appKeyInPkg = (apkInfo as any).appKey;
126
- const { appId, appKey } = await getSelectedApp('android');
127
-
128
- if (appIdInPkg && appIdInPkg != appId) {
129
- throw new Error(t('appIdMismatchApk', { appIdInPkg, appId }));
130
- }
131
-
132
- if (appKeyInPkg && appKeyInPkg !== appKey) {
133
- throw new Error(t('appKeyMismatchApk', { appKeyInPkg, appKey }));
134
- }
135
-
136
- // Use custom version if provided, otherwise use extracted version
137
- const versionName = options.version || extractedVersionName;
138
- if (options.version) {
139
- console.log(t('usingCustomVersion', { version: versionName }));
140
- }
141
-
142
- const { hash } = await uploadFile(fn);
143
-
144
- const { id } = await post(`/app/${appId}/package/create`, {
145
- name: versionName,
146
- hash,
147
- buildTime,
148
- deps: depVersions,
149
- commit: await getCommitInfo(),
208
+ const fn = ensureFileByExt(args[0], '.apk', 'usageUploadApk');
209
+ await uploadNativePackage(fn, options, {
210
+ extension: '.apk',
211
+ platform: 'android',
212
+ appIdMismatchKey: 'appIdMismatchApk',
213
+ appKeyMismatchKey: 'appKeyMismatchApk',
214
+ successKey: 'apkUploadSuccess',
215
+ getInfo: (filePath) => getApkInfo(filePath),
150
216
  });
151
- saveToLocal(fn, `${appId}/package/${id}.apk`);
152
- console.log(t('apkUploadSuccess', { id, version: versionName, buildTime }));
153
217
  },
154
218
  uploadAab: async ({
155
219
  args,
156
220
  options,
157
221
  }: {
158
222
  args: string[];
159
- options: Record<string, any>;
223
+ options: PackageCommandOptions;
160
224
  }) => {
161
- const source = args[0];
162
- if (!source || !source.endsWith('.aab')) {
163
- throw new Error(t('usageUploadAab'));
164
- }
225
+ const source = ensureFileByExt(args[0], '.aab', 'usageUploadAab');
165
226
 
166
227
  const output = path.join(
167
228
  os.tmpdir(),
168
229
  `${path.basename(source, path.extname(source))}-${Date.now()}.apk`,
169
230
  );
170
231
 
171
- const includeAllSplits =
172
- options.includeAllSplits === true || options.includeAllSplits === 'true';
173
- const splits = options.splits
174
- ? String(options.splits)
175
- .split(',')
176
- .map((item) => item.trim())
177
- .filter(Boolean)
178
- : null;
232
+ const includeAllSplits = parseBooleanOption(options.includeAllSplits);
233
+ const splits = parseCsvOption(options.splits);
179
234
 
180
235
  const parser = new AabParser(source);
181
236
  try {
@@ -198,43 +253,18 @@ export const packageCommands = {
198
253
  options,
199
254
  }: {
200
255
  args: string[];
201
- options: Record<string, any>;
256
+ options: PackageCommandOptions;
202
257
  }) => {
203
- const fn = args[0];
204
- if (!fn || !fn.endsWith('.app')) {
205
- throw new Error(t('usageUploadApp'));
206
- }
207
- const appInfo = await getAppInfo(fn);
208
- const { versionName: extractedVersionName, buildTime } = appInfo;
209
- const appIdInPkg = (appInfo as any).appId;
210
- const appKeyInPkg = (appInfo as any).appKey;
211
- const { appId, appKey } = await getSelectedApp('harmony');
212
-
213
- if (appIdInPkg && appIdInPkg != appId) {
214
- throw new Error(t('appIdMismatchApp', { appIdInPkg, appId }));
215
- }
216
-
217
- if (appKeyInPkg && appKeyInPkg !== appKey) {
218
- throw new Error(t('appKeyMismatchApp', { appKeyInPkg, appKey }));
219
- }
220
-
221
- // Use custom version if provided, otherwise use extracted version
222
- const versionName = options.version || extractedVersionName;
223
- if (options.version) {
224
- console.log(t('usingCustomVersion', { version: versionName }));
225
- }
226
-
227
- const { hash } = await uploadFile(fn);
228
-
229
- const { id } = await post(`/app/${appId}/package/create`, {
230
- name: versionName,
231
- hash,
232
- buildTime: String(buildTime),
233
- deps: depVersions,
234
- commit: await getCommitInfo(),
258
+ const fn = ensureFileByExt(args[0], '.app', 'usageUploadApp');
259
+ await uploadNativePackage(fn, options, {
260
+ extension: '.app',
261
+ platform: 'harmony',
262
+ appIdMismatchKey: 'appIdMismatchApp',
263
+ appKeyMismatchKey: 'appKeyMismatchApp',
264
+ successKey: 'appUploadSuccess',
265
+ getInfo: (filePath) => getAppInfo(filePath),
266
+ normalizeBuildTime: (buildTime) => String(buildTime),
235
267
  });
236
- saveToLocal(fn, `${appId}/package/${id}.app`);
237
- console.log(t('appUploadSuccess', { id, version: versionName, buildTime }));
238
268
  },
239
269
  parseApp: async ({ args }: { args: string[] }) => {
240
270
  const fn = args[0];
@@ -269,12 +299,9 @@ export const packageCommands = {
269
299
  options,
270
300
  }: {
271
301
  args: string[];
272
- options: Record<string, any>;
302
+ options: PackageCommandOptions;
273
303
  }) => {
274
- const source = args[0];
275
- if (!source || !source.endsWith('.aab')) {
276
- throw new Error(t('usageExtractApk'));
277
- }
304
+ const source = ensureFileByExt(args[0], '.aab', 'usageExtractApk');
278
305
 
279
306
  const output =
280
307
  options.output ||
@@ -283,14 +310,8 @@ export const packageCommands = {
283
310
  `${path.basename(source, path.extname(source))}.apk`,
284
311
  );
285
312
 
286
- const includeAllSplits =
287
- options.includeAllSplits === true || options.includeAllSplits === 'true';
288
- const splits = options.splits
289
- ? String(options.splits)
290
- .split(',')
291
- .map((item) => item.trim())
292
- .filter(Boolean)
293
- : null;
313
+ const includeAllSplits = parseBooleanOption(options.includeAllSplits);
314
+ const splits = parseCsvOption(options.splits);
294
315
 
295
316
  const parser = new AabParser(source);
296
317
  await parser.extractApk(output, {
@@ -355,10 +376,9 @@ export const packageCommands = {
355
376
  try {
356
377
  await doDelete(`/app/${appId}/package/${packageId}`);
357
378
  console.log(t('deletePackageSuccess', { packageId }));
358
- } catch (error: any) {
359
- throw new Error(
360
- t('deletePackageError', { packageId, error: error.message }),
361
- );
379
+ } catch (error) {
380
+ const message = error instanceof Error ? error.message : String(error);
381
+ throw new Error(t('deletePackageError', { packageId, error: message }));
362
382
  }
363
383
  },
364
384
  };