@nocobase/cli 2.1.0-alpha.33 → 2.1.0-alpha.35

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.
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import path from 'node:path';
10
- import { access, lstat, mkdir, readdir, readlink, realpath, rm, stat, symlink } from 'node:fs/promises';
10
+ import { access, lstat, readlink, rm } from 'node:fs/promises';
11
11
  async function pathExists(target) {
12
12
  try {
13
13
  await access(target);
@@ -28,69 +28,6 @@ export function resolvePluginStoragePath(storagePath) {
28
28
  }
29
29
  return path.resolve(process.cwd(), 'storage', 'plugins');
30
30
  }
31
- async function getStoragePluginNames(target) {
32
- const plugins = [];
33
- const items = await readdir(target);
34
- for (const item of items) {
35
- const itemPath = path.resolve(target, item);
36
- if (item.startsWith('@')) {
37
- const statResult = await stat(itemPath);
38
- if (!statResult.isDirectory()) {
39
- continue;
40
- }
41
- const children = await getStoragePluginNames(itemPath);
42
- plugins.push(...children.map((child) => `${item}/${child}`));
43
- continue;
44
- }
45
- if (await pathExists(path.resolve(itemPath, 'package.json'))) {
46
- plugins.push(item);
47
- }
48
- }
49
- return plugins;
50
- }
51
- async function ensureOrgDirectory(nodeModulesPath, pluginName) {
52
- if (!pluginName.startsWith('@')) {
53
- return;
54
- }
55
- const [orgName] = pluginName.split('/');
56
- await mkdir(path.resolve(nodeModulesPath, orgName), { recursive: true });
57
- }
58
- async function isSymlinkValid(linkPath, targetPath) {
59
- try {
60
- if (await pathExists(linkPath)) {
61
- const realPath = await realpath(linkPath);
62
- return realPath === targetPath;
63
- }
64
- }
65
- catch {
66
- return false;
67
- }
68
- return false;
69
- }
70
- async function createStoragePluginSymlink(storagePluginsPath, nodeModulesPath, pluginName) {
71
- const targetPath = path.resolve(storagePluginsPath, pluginName);
72
- if (!(await pathExists(targetPath))) {
73
- return;
74
- }
75
- await ensureOrgDirectory(nodeModulesPath, pluginName);
76
- const linkPath = path.resolve(nodeModulesPath, pluginName);
77
- if (await isSymlinkValid(linkPath, targetPath)) {
78
- return;
79
- }
80
- await rm(linkPath, { recursive: true, force: true });
81
- await symlink(targetPath, linkPath, 'dir');
82
- }
83
- export async function createStoragePluginsSymlink(storagePath, nodeModulesPath = String(process.env.NODE_MODULES_PATH ?? '').trim()) {
84
- if (!nodeModulesPath) {
85
- return;
86
- }
87
- const storagePluginsPath = resolvePluginStoragePath(storagePath);
88
- if (!(await pathExists(storagePluginsPath))) {
89
- return;
90
- }
91
- const pluginNames = await getStoragePluginNames(storagePluginsPath);
92
- await Promise.all(pluginNames.map(async (pluginName) => await createStoragePluginSymlink(storagePluginsPath, nodeModulesPath, pluginName)));
93
- }
94
31
  export async function removeStoragePluginSymlink(pluginName, storagePath, nodeModulesPath = String(process.env.NODE_MODULES_PATH ?? '').trim()) {
95
32
  if (!nodeModulesPath) {
96
33
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "2.1.0-alpha.33",
3
+ "version": "2.1.0-alpha.35",
4
4
  "description": "NocoBase Command Line Tool",
5
5
  "type": "module",
6
6
  "main": "dist/generated/command-registry.js",
@@ -103,5 +103,5 @@
103
103
  "type": "git",
104
104
  "url": "git+https://github.com/nocobase/nocobase.git"
105
105
  },
106
- "gitHead": "64aaff11b9d9cab6890fb4835d7ae6933f2d3081"
106
+ "gitHead": "313a9e19e84a99924c86f9855c2ae48943f450b0"
107
107
  }