react-native-update-cli 1.43.6 → 1.44.1

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/locales/en.js CHANGED
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "default", {
11
11
  const _default = {
12
12
  loginFirst: 'Not logged in.\nPlease run `cresc login` in the project directory to login.',
13
13
  lockNotFound: 'No lock file detected, which may cause inconsistent dependencies and hot-updating issues.',
14
- multipleLocksFound: 'Multiple lock files detected ({{lockFiles}}), which may cause inconsistent dependencies and hot-updating issues.',
14
+ multipleLocksFound: 'Multiple lock files detected ({{- lockFiles}}), which may cause inconsistent dependencies and hot-updating issues.',
15
15
  lockBestPractice: `
16
16
  Best practices for lock files:
17
17
  1. All members of the development team should use the same package manager to maintain a single lock file.
package/lib/locales/zh.js CHANGED
@@ -18,7 +18,7 @@ const _default = {
18
18
  3. 代码审核时应关注 lock 文件的变化。
19
19
  这样可以最大限度避免因依赖关系不一致而导致的热更异常,也降低供应链攻击等安全隐患。
20
20
  `,
21
- multipleLocksFound: '检测到多种不同格式的锁文件({{lockFiles}}),这可能导致依赖关系不一致而使热更异常。',
21
+ multipleLocksFound: '检测到多种不同格式的锁文件({{- lockFiles}}),这可能导致依赖关系不一致而使热更异常。',
22
22
  loginExpired: '登录信息已过期,请使用 `pushy login` 命令重新登录',
23
23
  fileSizeExceeded: '此文件大小 {{fileSize}} , 超出当前额度 {{maxSize}} 。您可以考虑升级付费业务以提升此额度。详情请访问: {{pricingPageUrl}}',
24
24
  bundleNotFound: '找不到 bundle 文件。请确保此 {{packageType}} 为 release 版本,且 bundle 文件名为默认的 `{{entryFile}}`',
@@ -53,7 +53,7 @@ const _default = {
53
53
  packing: '正在打包',
54
54
  deletingFile: '删除 {{- file}}',
55
55
  bundlingWithRN: '正在使用 react-native {{version}} 打包',
56
- fileGenerated: '已生成 {{- file}}',
56
+ fileGenerated: '已生成 {{- file}}',
57
57
  processingError: '处理文件时出错:{{error}}',
58
58
  usageDiff: '用法:pushy {{command}} <origin> <next>',
59
59
  pluginDetected: '检测到 {{name}} 插件',
@@ -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
- const existingLockFiles = [];
26
- function checkLockFiles() {
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
- if (_nodefs.default.existsSync(file)) {
29
- existingLockFiles.push(file);
43
+ const filePath = _nodepath.default.join(directory, file);
44
+ if (_nodefs.default.existsSync(filePath)) {
45
+ found.push(filePath);
30
46
  }
31
47
  }
32
- if (existingLockFiles.length === 1) {
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
- console.warn((0, _i18n.t)('lockBestPractice'));
36
- if (existingLockFiles.length === 0) {
37
- throw new Error((0, _i18n.t)('lockNotFound'));
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
- throw new Error((0, _i18n.t)('multipleLocksFound', {
40
- lockFiles: existingLockFiles.join(', ')
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
  }
@@ -9,25 +9,27 @@ Object.defineProperty(exports, "depVersions", {
9
9
  }
10
10
  });
11
11
  const currentPackage = require(`${process.cwd()}/package.json`);
12
- const depKeys = Object.keys(currentPackage.dependencies);
13
- const devDepKeys = Object.keys(currentPackage.devDependencies);
14
- const dedupedDeps = [
15
- ...new Set([
16
- ...depKeys,
17
- ...devDepKeys
18
- ])
19
- ];
20
12
  const _depVersions = {};
21
- for (const dep of dedupedDeps){
22
- try {
23
- const packageJsonPath = require.resolve(`${dep}/package.json`, {
24
- paths: [
25
- process.cwd()
26
- ]
27
- });
28
- const version = require(packageJsonPath).version;
29
- _depVersions[dep] = version;
30
- } catch (e) {}
13
+ if (currentPackage) {
14
+ const depKeys = currentPackage.dependencies ? Object.keys(currentPackage.dependencies) : [];
15
+ const devDepKeys = currentPackage.devDependencies ? Object.keys(currentPackage.devDependencies) : [];
16
+ const dedupedDeps = [
17
+ ...new Set([
18
+ ...depKeys,
19
+ ...devDepKeys
20
+ ])
21
+ ];
22
+ for (const dep of dedupedDeps){
23
+ try {
24
+ const packageJsonPath = require.resolve(`${dep}/package.json`, {
25
+ paths: [
26
+ process.cwd()
27
+ ]
28
+ });
29
+ const version = require(packageJsonPath).version;
30
+ _depVersions[dep] = version;
31
+ } catch (e) {}
32
+ }
31
33
  }
32
34
  const depVersions = Object.keys(_depVersions).sort() // Sort the keys alphabetically
33
35
  .reduce((obj, key)=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "1.43.6",
3
+ "version": "1.44.1",
4
4
  "description": "command line tool for react-native-update (remote updates for react native)",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/locales/en.ts CHANGED
@@ -4,7 +4,7 @@ export default {
4
4
  lockNotFound:
5
5
  'No lock file detected, which may cause inconsistent dependencies and hot-updating issues.',
6
6
  multipleLocksFound:
7
- 'Multiple lock files detected ({{lockFiles}}), which may cause inconsistent dependencies and hot-updating issues.',
7
+ 'Multiple lock files detected ({{- lockFiles}}), which may cause inconsistent dependencies and hot-updating issues.',
8
8
  lockBestPractice: `
9
9
  Best practices for lock files:
10
10
  1. All members of the development team should use the same package manager to maintain a single lock file.
package/src/locales/zh.ts CHANGED
@@ -10,7 +10,7 @@ export default {
10
10
  这样可以最大限度避免因依赖关系不一致而导致的热更异常,也降低供应链攻击等安全隐患。
11
11
  `,
12
12
  multipleLocksFound:
13
- '检测到多种不同格式的锁文件({{lockFiles}}),这可能导致依赖关系不一致而使热更异常。',
13
+ '检测到多种不同格式的锁文件({{- lockFiles}}),这可能导致依赖关系不一致而使热更异常。',
14
14
  loginExpired: '登录信息已过期,请使用 `pushy login` 命令重新登录',
15
15
  fileSizeExceeded:
16
16
  '此文件大小 {{fileSize}} , 超出当前额度 {{maxSize}} 。您可以考虑升级付费业务以提升此额度。详情请访问: {{pricingPageUrl}}',
@@ -50,7 +50,7 @@ export default {
50
50
  packing: '正在打包',
51
51
  deletingFile: '删除 {{- file}}',
52
52
  bundlingWithRN: '正在使用 react-native {{version}} 打包',
53
- fileGenerated: '已生成 {{- file}}',
53
+ fileGenerated: '已生成 {{- file}}',
54
54
  processingError: '处理文件时出错:{{error}}',
55
55
  usageDiff: '用法:pushy {{command}} <origin> <next>',
56
56
  pluginDetected: '检测到 {{name}} 插件',
@@ -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
- const existingLockFiles: string[] = [];
13
- export function checkLockFiles() {
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
- if (fs.existsSync(file)) {
16
- existingLockFiles.push(file);
31
+ const filePath = path.join(directory, file);
32
+ if (fs.existsSync(filePath)) {
33
+ found.push(filePath);
17
34
  }
18
35
  }
19
- if (existingLockFiles.length === 1) {
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
- console.warn(t('lockBestPractice'));
23
- if (existingLockFiles.length === 0) {
24
- throw new Error(t('lockNotFound'));
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
- throw new Error(
27
- t('multipleLocksFound', { lockFiles: existingLockFiles.join(', ') }),
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,19 +1,21 @@
1
1
  const currentPackage = require(`${process.cwd()}/package.json`);
2
2
 
3
- const depKeys = Object.keys(currentPackage.dependencies);
4
- const devDepKeys = Object.keys(currentPackage.devDependencies);
5
- const dedupedDeps = [...new Set([...depKeys, ...devDepKeys])];
6
-
7
3
  const _depVersions: Record<string, string> = {};
8
4
 
9
- for (const dep of dedupedDeps) {
10
- try {
11
- const packageJsonPath = require.resolve(`${dep}/package.json`, {
12
- paths: [process.cwd()],
13
- });
14
- const version = require(packageJsonPath).version;
15
- _depVersions[dep] = version;
16
- } catch (e) {}
5
+ if (currentPackage) {
6
+ const depKeys = currentPackage.dependencies ? Object.keys(currentPackage.dependencies) : [];
7
+ const devDepKeys = currentPackage.devDependencies ? Object.keys(currentPackage.devDependencies) : [];
8
+ const dedupedDeps = [...new Set([...depKeys, ...devDepKeys])];
9
+
10
+ for (const dep of dedupedDeps) {
11
+ try {
12
+ const packageJsonPath = require.resolve(`${dep}/package.json`, {
13
+ paths: [process.cwd()],
14
+ });
15
+ const version = require(packageJsonPath).version;
16
+ _depVersions[dep] = version;
17
+ } catch (e) {}
18
+ }
17
19
  }
18
20
 
19
21
  export const depVersions = Object.keys(_depVersions)