react-native-update-cli 1.43.6 → 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/utils/check-lockfile.js +62 -11
- package/package.json +1 -1
- package/src/utils/check-lockfile.ts +71 -11
|
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "checkLockFiles", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _nodefs = /*#__PURE__*/ _interop_require_default(require("node:fs"));
|
|
12
|
+
const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
12
13
|
const _i18n = require("./i18n");
|
|
13
14
|
function _interop_require_default(obj) {
|
|
14
15
|
return obj && obj.__esModule ? obj : {
|
|
@@ -22,21 +23,71 @@ const lockFiles = [
|
|
|
22
23
|
'bun.lockb',
|
|
23
24
|
'bun.lock'
|
|
24
25
|
];
|
|
25
|
-
|
|
26
|
-
function
|
|
26
|
+
// Function to check if a package.json has a workspaces field
|
|
27
|
+
function hasWorkspaces(dir) {
|
|
28
|
+
const pkgPath = _nodepath.default.join(dir, 'package.json');
|
|
29
|
+
if (_nodefs.default.existsSync(pkgPath)) {
|
|
30
|
+
try {
|
|
31
|
+
const pkg = JSON.parse(_nodefs.default.readFileSync(pkgPath, 'utf-8'));
|
|
32
|
+
return !!pkg.workspaces;
|
|
33
|
+
} catch (e) {
|
|
34
|
+
// Ignore parsing errors
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
// Helper function to find lock files in a specific directory
|
|
40
|
+
function findLockFilesInDir(directory) {
|
|
41
|
+
const found = [];
|
|
27
42
|
for (const file of lockFiles){
|
|
28
|
-
|
|
29
|
-
|
|
43
|
+
const filePath = _nodepath.default.join(directory, file);
|
|
44
|
+
if (_nodefs.default.existsSync(filePath)) {
|
|
45
|
+
found.push(filePath);
|
|
30
46
|
}
|
|
31
47
|
}
|
|
32
|
-
|
|
48
|
+
return found;
|
|
49
|
+
}
|
|
50
|
+
function checkLockFiles() {
|
|
51
|
+
const cwd = process.cwd();
|
|
52
|
+
let searchDir = cwd;
|
|
53
|
+
let foundLockFiles = findLockFilesInDir(searchDir);
|
|
54
|
+
// If no lock file in cwd, try to find monorepo root and check there
|
|
55
|
+
if (foundLockFiles.length === 0) {
|
|
56
|
+
// Search upwards for package.json with workspaces
|
|
57
|
+
let currentDir = _nodepath.default.dirname(cwd); // Start searching from parent
|
|
58
|
+
let projectRootDir = null;
|
|
59
|
+
while(true){
|
|
60
|
+
if (hasWorkspaces(currentDir)) {
|
|
61
|
+
projectRootDir = currentDir;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
const parentDir = _nodepath.default.dirname(currentDir);
|
|
65
|
+
if (parentDir === currentDir) {
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
currentDir = parentDir;
|
|
69
|
+
}
|
|
70
|
+
// If a potential root was found, switch search directory and re-check
|
|
71
|
+
if (projectRootDir) {
|
|
72
|
+
searchDir = projectRootDir;
|
|
73
|
+
foundLockFiles = findLockFilesInDir(searchDir);
|
|
74
|
+
}
|
|
75
|
+
// If no projectRootDir found, foundLockFiles remains empty and searchDir remains cwd
|
|
76
|
+
}
|
|
77
|
+
// Handle results based on findings in the final searchDir
|
|
78
|
+
if (foundLockFiles.length === 1) {
|
|
79
|
+
// Successfully found one lock file in the determined searchDir
|
|
33
80
|
return;
|
|
34
81
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
82
|
+
if (foundLockFiles.length > 1) {
|
|
83
|
+
// Found multiple lock files in the determined searchDir
|
|
84
|
+
console.warn((0, _i18n.t)('lockBestPractice'));
|
|
85
|
+
throw new Error((0, _i18n.t)('multipleLocksFound', {
|
|
86
|
+
lockFiles: foundLockFiles.join(', ')
|
|
87
|
+
}));
|
|
38
88
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
89
|
+
// If we reach here, foundLockFiles.length === 0
|
|
90
|
+
console.warn((0, _i18n.t)('lockBestPractice'));
|
|
91
|
+
// Warn instead of throwing an error if no lock file is found
|
|
92
|
+
console.warn((0, _i18n.t)('lockNotFound'));
|
|
42
93
|
}
|
package/package.json
CHANGED
|
@@ -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
|
}
|