react-native-update-cli 1.43.5 → 1.44.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/bundle.js +36 -19
- package/lib/index.js +0 -13
- package/lib/locales/en.js +50 -3
- package/lib/locales/zh.js +50 -3
- package/lib/package.js +10 -7
- package/lib/user.js +5 -2
- package/lib/utils/add-gitignore.js +4 -1
- package/lib/utils/check-lockfile.js +62 -11
- package/lib/utils/check-plugin.js +8 -2
- package/lib/versions.js +54 -17
- package/package.json +9 -7
- package/src/bundle.ts +18 -24
- package/src/index.ts +0 -7
- package/src/locales/en.ts +56 -4
- package/src/locales/zh.ts +51 -3
- package/src/package.ts +8 -7
- package/src/user.ts +3 -2
- package/src/utils/add-gitignore.ts +2 -1
- package/src/utils/check-lockfile.ts +71 -11
- package/src/utils/check-plugin.ts +3 -2
- package/src/versions.ts +40 -21
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
2
3
|
import { t } from './i18n';
|
|
3
4
|
|
|
4
5
|
const lockFiles = [
|
|
@@ -9,21 +10,80 @@ const lockFiles = [
|
|
|
9
10
|
'bun.lock',
|
|
10
11
|
];
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
// Function to check if a package.json has a workspaces field
|
|
14
|
+
function hasWorkspaces(dir: string): boolean {
|
|
15
|
+
const pkgPath = path.join(dir, 'package.json');
|
|
16
|
+
if (fs.existsSync(pkgPath)) {
|
|
17
|
+
try {
|
|
18
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
19
|
+
return !!pkg.workspaces;
|
|
20
|
+
} catch (e) {
|
|
21
|
+
// Ignore parsing errors
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Helper function to find lock files in a specific directory
|
|
28
|
+
function findLockFilesInDir(directory: string): string[] {
|
|
29
|
+
const found: string[] = [];
|
|
14
30
|
for (const file of lockFiles) {
|
|
15
|
-
|
|
16
|
-
|
|
31
|
+
const filePath = path.join(directory, file);
|
|
32
|
+
if (fs.existsSync(filePath)) {
|
|
33
|
+
found.push(filePath);
|
|
17
34
|
}
|
|
18
35
|
}
|
|
19
|
-
|
|
36
|
+
return found;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function checkLockFiles() {
|
|
40
|
+
const cwd = process.cwd();
|
|
41
|
+
let searchDir = cwd;
|
|
42
|
+
let foundLockFiles = findLockFilesInDir(searchDir);
|
|
43
|
+
|
|
44
|
+
// If no lock file in cwd, try to find monorepo root and check there
|
|
45
|
+
if (foundLockFiles.length === 0) {
|
|
46
|
+
// Search upwards for package.json with workspaces
|
|
47
|
+
let currentDir = path.dirname(cwd); // Start searching from parent
|
|
48
|
+
let projectRootDir: string | null = null;
|
|
49
|
+
|
|
50
|
+
while (true) {
|
|
51
|
+
if (hasWorkspaces(currentDir)) {
|
|
52
|
+
projectRootDir = currentDir;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
const parentDir = path.dirname(currentDir);
|
|
56
|
+
if (parentDir === currentDir) {
|
|
57
|
+
// Reached the filesystem root
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
currentDir = parentDir;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// If a potential root was found, switch search directory and re-check
|
|
64
|
+
if (projectRootDir) {
|
|
65
|
+
searchDir = projectRootDir;
|
|
66
|
+
foundLockFiles = findLockFilesInDir(searchDir);
|
|
67
|
+
}
|
|
68
|
+
// If no projectRootDir found, foundLockFiles remains empty and searchDir remains cwd
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Handle results based on findings in the final searchDir
|
|
72
|
+
if (foundLockFiles.length === 1) {
|
|
73
|
+
// Successfully found one lock file in the determined searchDir
|
|
20
74
|
return;
|
|
21
75
|
}
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
76
|
+
|
|
77
|
+
if (foundLockFiles.length > 1) {
|
|
78
|
+
// Found multiple lock files in the determined searchDir
|
|
79
|
+
console.warn(t('lockBestPractice'));
|
|
80
|
+
throw new Error(
|
|
81
|
+
t('multipleLocksFound', { lockFiles: foundLockFiles.join(', ') }),
|
|
82
|
+
);
|
|
25
83
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
);
|
|
84
|
+
|
|
85
|
+
// If we reach here, foundLockFiles.length === 0
|
|
86
|
+
console.warn(t('lockBestPractice'));
|
|
87
|
+
// Warn instead of throwing an error if no lock file is found
|
|
88
|
+
console.warn(t('lockNotFound'));
|
|
29
89
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { plugins } from './plugin-config';
|
|
2
|
+
import { t } from './i18n';
|
|
2
3
|
|
|
3
4
|
interface BundleParams {
|
|
4
5
|
sentry: boolean;
|
|
@@ -17,10 +18,10 @@ export async function checkPlugins(): Promise<BundleParams> {
|
|
|
17
18
|
const isEnabled = await plugin.detect();
|
|
18
19
|
if (isEnabled && plugin.bundleParams) {
|
|
19
20
|
Object.assign(params, plugin.bundleParams);
|
|
20
|
-
console.log(
|
|
21
|
+
console.log(t('pluginDetected', { name: plugin.name }));
|
|
21
22
|
}
|
|
22
23
|
} catch (err) {
|
|
23
|
-
console.warn(
|
|
24
|
+
console.warn(t('pluginDetectionError', { name: plugin.name, error: err }));
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
|
package/src/versions.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { get, post, put, uploadFile } from './api';
|
|
2
2
|
import { question, saveToLocal } from './utils';
|
|
3
|
+
import { t } from './utils/i18n';
|
|
3
4
|
|
|
4
5
|
import { checkPlatform, getSelectedApp } from './app';
|
|
5
6
|
import { choosePackage } from './package';
|
|
@@ -35,7 +36,7 @@ interface CommandOptions {
|
|
|
35
36
|
|
|
36
37
|
async function showVersion(appId: string, offset: number) {
|
|
37
38
|
const { data, count } = await get(`/app/${appId}/version/list`);
|
|
38
|
-
console.log(
|
|
39
|
+
console.log(t('offset', { offset }));
|
|
39
40
|
for (const version of data) {
|
|
40
41
|
const pkgCount = version.packages?.length || 0;
|
|
41
42
|
let packageInfo = '';
|
|
@@ -149,7 +150,7 @@ export const commands = {
|
|
|
149
150
|
});
|
|
150
151
|
// TODO local diff
|
|
151
152
|
saveToLocal(fn, `${appId}/ppk/${id}.ppk`);
|
|
152
|
-
console.log(
|
|
153
|
+
console.log(t('packageUploadSuccess', { id }));
|
|
153
154
|
|
|
154
155
|
const v = await question('是否现在将此热更应用到原生包上?(Y/N)');
|
|
155
156
|
if (v.toLowerCase() === 'y') {
|
|
@@ -192,10 +193,10 @@ export const commands = {
|
|
|
192
193
|
try {
|
|
193
194
|
rollout = Number.parseInt(options.rollout);
|
|
194
195
|
} catch (e) {
|
|
195
|
-
throw new Error('
|
|
196
|
+
throw new Error(t('rolloutRangeError'));
|
|
196
197
|
}
|
|
197
198
|
if (rollout < 1 || rollout > 100) {
|
|
198
|
-
throw new Error('
|
|
199
|
+
throw new Error(t('rolloutRangeError'));
|
|
199
200
|
}
|
|
200
201
|
}
|
|
201
202
|
|
|
@@ -206,7 +207,7 @@ export const commands = {
|
|
|
206
207
|
compare(pkg.name, minPkgVersion, '>='),
|
|
207
208
|
);
|
|
208
209
|
if (pkgs.length === 0) {
|
|
209
|
-
throw new Error(
|
|
210
|
+
throw new Error(t('nativeVersionNotFound', { version: minPkgVersion }));
|
|
210
211
|
}
|
|
211
212
|
if (rollout !== undefined) {
|
|
212
213
|
const rolloutConfig: Record<string, number> = {};
|
|
@@ -219,9 +220,10 @@ export const commands = {
|
|
|
219
220
|
},
|
|
220
221
|
});
|
|
221
222
|
console.log(
|
|
222
|
-
|
|
223
|
-
.map((pkg: Package) => pkg.name)
|
|
224
|
-
|
|
223
|
+
`${t('rolloutConfigSet', {
|
|
224
|
+
versions: pkgs.map((pkg: Package) => pkg.name).join(', '),
|
|
225
|
+
rollout: rollout,
|
|
226
|
+
})}`,
|
|
225
227
|
);
|
|
226
228
|
}
|
|
227
229
|
for (const pkg of pkgs) {
|
|
@@ -229,10 +231,14 @@ export const commands = {
|
|
|
229
231
|
versionId,
|
|
230
232
|
});
|
|
231
233
|
console.log(
|
|
232
|
-
|
|
234
|
+
`${t('versionBind', {
|
|
235
|
+
version: versionId,
|
|
236
|
+
nativeVersion: pkg.name,
|
|
237
|
+
id: pkg.id,
|
|
238
|
+
})}`,
|
|
233
239
|
);
|
|
234
240
|
}
|
|
235
|
-
console.log(
|
|
241
|
+
console.log(t('operationComplete', { count: pkgs.length }));
|
|
236
242
|
return;
|
|
237
243
|
}
|
|
238
244
|
if (maxPkgVersion) {
|
|
@@ -242,7 +248,7 @@ export const commands = {
|
|
|
242
248
|
compare(pkg.name, maxPkgVersion, '<='),
|
|
243
249
|
);
|
|
244
250
|
if (pkgs.length === 0) {
|
|
245
|
-
throw new Error(
|
|
251
|
+
throw new Error(t('nativeVersionNotFoundLess', { version: maxPkgVersion }));
|
|
246
252
|
}
|
|
247
253
|
if (rollout !== undefined) {
|
|
248
254
|
const rolloutConfig: Record<string, number> = {};
|
|
@@ -255,9 +261,10 @@ export const commands = {
|
|
|
255
261
|
},
|
|
256
262
|
});
|
|
257
263
|
console.log(
|
|
258
|
-
|
|
259
|
-
.map((pkg: Package) => pkg.name)
|
|
260
|
-
|
|
264
|
+
`${t('rolloutConfigSet', {
|
|
265
|
+
versions: pkgs.map((pkg: Package) => pkg.name).join(', '),
|
|
266
|
+
rollout: rollout,
|
|
267
|
+
})}`,
|
|
261
268
|
);
|
|
262
269
|
}
|
|
263
270
|
for (const pkg of pkgs) {
|
|
@@ -265,10 +272,14 @@ export const commands = {
|
|
|
265
272
|
versionId,
|
|
266
273
|
});
|
|
267
274
|
console.log(
|
|
268
|
-
|
|
275
|
+
`${t('versionBind', {
|
|
276
|
+
version: versionId,
|
|
277
|
+
nativeVersion: pkg.name,
|
|
278
|
+
id: pkg.id,
|
|
279
|
+
})}`,
|
|
269
280
|
);
|
|
270
281
|
}
|
|
271
|
-
console.log(
|
|
282
|
+
console.log(t('operationComplete', { count: pkgs.length }));
|
|
272
283
|
return;
|
|
273
284
|
}
|
|
274
285
|
|
|
@@ -279,7 +290,7 @@ export const commands = {
|
|
|
279
290
|
if (pkg) {
|
|
280
291
|
pkgId = pkg.id;
|
|
281
292
|
} else {
|
|
282
|
-
throw new Error(
|
|
293
|
+
throw new Error(t('nativeVersionNotFoundMatch', { version: pkgVersion }));
|
|
283
294
|
}
|
|
284
295
|
}
|
|
285
296
|
if (!pkgId) {
|
|
@@ -287,7 +298,7 @@ export const commands = {
|
|
|
287
298
|
}
|
|
288
299
|
|
|
289
300
|
if (!pkgId) {
|
|
290
|
-
throw new Error('
|
|
301
|
+
throw new Error(t('packageIdRequired'));
|
|
291
302
|
}
|
|
292
303
|
|
|
293
304
|
if (!pkgVersion) {
|
|
@@ -306,7 +317,10 @@ export const commands = {
|
|
|
306
317
|
},
|
|
307
318
|
});
|
|
308
319
|
console.log(
|
|
309
|
-
|
|
320
|
+
`${t('rolloutConfigSet', {
|
|
321
|
+
versions: pkgVersion,
|
|
322
|
+
rollout: rollout,
|
|
323
|
+
})}`,
|
|
310
324
|
);
|
|
311
325
|
}
|
|
312
326
|
|
|
@@ -315,9 +329,14 @@ export const commands = {
|
|
|
315
329
|
versionId,
|
|
316
330
|
});
|
|
317
331
|
console.log(
|
|
318
|
-
|
|
332
|
+
`${t('versionBind', {
|
|
333
|
+
version: versionId,
|
|
334
|
+
nativeVersion: pkgVersion,
|
|
335
|
+
id: pkgId,
|
|
336
|
+
})}`,
|
|
319
337
|
);
|
|
320
338
|
}
|
|
339
|
+
console.log(t('operationSuccess'));
|
|
321
340
|
},
|
|
322
341
|
updateVersionInfo: async ({
|
|
323
342
|
args,
|
|
@@ -339,6 +358,6 @@ export const commands = {
|
|
|
339
358
|
if (options.metaInfo) updateParams.metaInfo = options.metaInfo;
|
|
340
359
|
|
|
341
360
|
await put(`/app/${appId}/version/${versionId}`, updateParams);
|
|
342
|
-
console.log('
|
|
361
|
+
console.log(t('operationSuccess'));
|
|
343
362
|
},
|
|
344
363
|
};
|