customs-ui-kit-mcp 1.0.1 → 1.0.2
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/dist/index.js +13 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47,7 +47,6 @@ let versionCheckCache = {
|
|
|
47
47
|
lastChecked: 0,
|
|
48
48
|
};
|
|
49
49
|
// 动态解析 UI package 路径
|
|
50
|
-
// 当作为 npm 包全局安装时,尝试在 node_modules 中寻找 customs-ui-kit
|
|
51
50
|
function getUiPackageInfo() {
|
|
52
51
|
let uiPath = path.resolve(__dirname, "../../ui/src/components");
|
|
53
52
|
let version = "unknown";
|
|
@@ -61,12 +60,20 @@ function getUiPackageInfo() {
|
|
|
61
60
|
catch (e) { }
|
|
62
61
|
return { path: uiPath, version };
|
|
63
62
|
}
|
|
64
|
-
// 2. 作为 npm
|
|
63
|
+
// 2. 作为 npm 包安装后,在其他业务项目中使用
|
|
65
64
|
try {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
// 关键修复 1:以当前执行目录 (业务项目根目录) 为起点进行解析
|
|
66
|
+
// 关键修复 2:解析主入口文件,而不是 package.json,避开 exports 限制
|
|
67
|
+
const mainPath = require.resolve("customs-ui-kit", { paths: [process.cwd()] });
|
|
68
|
+
// 向上两级找到 customs-ui-kit 的包根目录 (从 dist/xxx.js 回到包根目录)
|
|
69
|
+
const pkgRoot = path.resolve(path.dirname(mainPath), "..");
|
|
70
|
+
const uiPkgPath = path.join(pkgRoot, "package.json");
|
|
71
|
+
if (fs.existsSync(uiPkgPath)) {
|
|
72
|
+
const pkg = JSON.parse(fs.readFileSync(uiPkgPath, "utf-8"));
|
|
73
|
+
version = pkg.version;
|
|
74
|
+
}
|
|
75
|
+
// 寻找 src/components 目录
|
|
76
|
+
const resolvedPath = path.join(pkgRoot, "src/components");
|
|
70
77
|
if (fs.existsSync(resolvedPath)) {
|
|
71
78
|
uiPath = resolvedPath;
|
|
72
79
|
}
|