Skip to content

Commit d281d72

Browse files
committed
check lockfiles
1 parent d351243 commit d281d72

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update-cli",
3-
"version": "1.42.2",
3+
"version": "1.43.0",
44
"description": "Command tools for javaScript updater with `pushy` service for react native apps.",
55
"main": "index.js",
66
"bin": {

src/locales/en.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
lockNotFound:
77
'No lock file detected, which may cause inconsistent dependencies and hot-updating issues.',
88
multipleLocksFound:
9-
'Multiple lock files detected ({lockFiles}), which may cause inconsistent dependencies and hot-updating issues.',
9+
'Multiple lock files detected ({{lockFiles}}), which may cause inconsistent dependencies and hot-updating issues.',
1010
lockBestPractice: `
1111
Best practices for lock files:
1212
1. All members of the development team should use the same package manager to maintain a single lock file.

src/locales/zh.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
这样可以最大限度避免因依赖关系不一致而导致的热更异常,也降低供应链攻击等安全隐患。
1313
`,
1414
multipleLocksFound:
15-
'检测到多种不同格式的锁文件({lockFiles}),这可能导致依赖关系不一致而使热更异常。',
15+
'检测到多种不同格式的锁文件({{lockFiles}}),这可能导致依赖关系不一致而使热更异常。',
1616
loginExpired: '登录信息已过期,请使用 `pushy login` 命令重新登录',
1717
fileSizeExceeded:
1818
'此文件大小 {{fileSize}} , 超出当前额度 {{maxSize}} 。您可以考虑升级付费业务以提升此额度。详情请访问: {{pricingPageUrl}}',

src/utils/add-gitignore.ts

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export function addGitIgnore() {
2323
}
2424

2525
if (shouldIgnore.length > 0) {
26+
gitignoreLines.push('# react-native-update');
2627
for (const line of shouldIgnore) {
2728
gitignoreLines.push(line);
2829
console.log(`Added ${line} to .gitignore`);

src/utils/check-lockfile.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import fs from 'node:fs';
2-
import { t } from '../../lib/utils/i18n';
2+
import { t } from './i18n';
33

44
const lockFiles = [
55
'package-lock.json',
@@ -16,9 +16,14 @@ export function checkLockFiles() {
1616
existingLockFiles.push(file);
1717
}
1818
}
19+
if (existingLockFiles.length === 1) {
20+
return;
21+
}
22+
console.warn(t('lockBestPractice'));
1923
if (existingLockFiles.length === 0) {
20-
console.warn(t('lockFilesNotFound'));
21-
} else if (existingLockFiles.length > 1) {
22-
console.warn(t('multipleLockFilesFound'));
24+
throw new Error(t('lockNotFound'));
2325
}
26+
throw new Error(
27+
t('multipleLocksFound', { lockFiles: existingLockFiles.join(', ') }),
28+
);
2429
}

0 commit comments

Comments
 (0)