morghulis 1.0.47 → 1.0.48
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.css +1 -1
- package/dist/index.d.ts +88 -34
- package/dist/index.js.map +1 -1
- package/install-deps.cjs +46 -15
- package/package.json +3 -3
package/install-deps.cjs
CHANGED
@@ -5,20 +5,38 @@ const { execSync } = require('child_process');
|
|
5
5
|
const fs = require('fs');
|
6
6
|
const path = require('path');
|
7
7
|
|
8
|
+
// 打印当前目录,用于调试
|
9
|
+
console.log('当前执行目录:', process.cwd());
|
10
|
+
|
8
11
|
/**
|
9
12
|
* 确保element-plus被安装
|
10
13
|
*/
|
11
14
|
function ensureElementPlusInstalled() {
|
12
15
|
try {
|
13
|
-
// 尝试找到package.json
|
16
|
+
// 尝试找到package.json,从当前目录开始向上查找
|
14
17
|
const projectRoot = findPackageJson(process.cwd());
|
15
18
|
if (!projectRoot) {
|
16
|
-
console.log('未找到package.json
|
17
|
-
|
19
|
+
console.log('未找到package.json文件,尝试在parent目录查找');
|
20
|
+
// 尝试在父级目录查找
|
21
|
+
const parentRoot = findPackageJson(path.dirname(process.cwd()));
|
22
|
+
if (!parentRoot) {
|
23
|
+
console.log('在父级目录中也未找到package.json文件,无法安装element-plus');
|
24
|
+
return;
|
25
|
+
}
|
18
26
|
}
|
19
27
|
|
28
|
+
const rootDir = projectRoot || path.dirname(process.cwd());
|
29
|
+
console.log('使用目录:', rootDir);
|
30
|
+
|
20
31
|
// 检查package.json中是否已经有element-plus
|
21
|
-
const packageJsonPath = path.join(
|
32
|
+
const packageJsonPath = path.join(rootDir, 'package.json');
|
33
|
+
console.log('package.json路径:', packageJsonPath);
|
34
|
+
|
35
|
+
if (!fs.existsSync(packageJsonPath)) {
|
36
|
+
console.log('package.json文件不存在:', packageJsonPath);
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
|
22
40
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
23
41
|
const deps = packageJson.dependencies || {};
|
24
42
|
const devDeps = packageJson.devDependencies || {};
|
@@ -38,22 +56,24 @@ function ensureElementPlusInstalled() {
|
|
38
56
|
// 使用npm安装element-plus
|
39
57
|
execSync('npm install element-plus --save', {
|
40
58
|
stdio: 'inherit',
|
41
|
-
cwd:
|
59
|
+
cwd: rootDir
|
42
60
|
});
|
43
61
|
|
44
62
|
console.log('element-plus安装成功');
|
45
63
|
} catch (npmError) {
|
64
|
+
console.error('npm安装失败,尝试使用yarn:', npmError.message);
|
46
65
|
// 如果npm不可用,尝试使用yarn
|
47
66
|
try {
|
48
67
|
execSync('yarn --version', { stdio: 'ignore' });
|
49
68
|
|
50
69
|
execSync('yarn add element-plus', {
|
51
70
|
stdio: 'inherit',
|
52
|
-
cwd:
|
71
|
+
cwd: rootDir
|
53
72
|
});
|
54
73
|
|
55
74
|
console.log('使用yarn安装element-plus成功');
|
56
75
|
} catch (yarnError) {
|
76
|
+
console.error('yarn安装失败:', yarnError.message);
|
57
77
|
console.error('无法使用npm或yarn安装element-plus');
|
58
78
|
console.error('请手动安装: npm install element-plus --save');
|
59
79
|
}
|
@@ -68,18 +88,29 @@ function ensureElementPlusInstalled() {
|
|
68
88
|
* 递归向上查找package.json所在目录
|
69
89
|
*/
|
70
90
|
function findPackageJson(dir) {
|
71
|
-
if (
|
72
|
-
|
73
|
-
|
91
|
+
if (!dir) return null;
|
92
|
+
|
93
|
+
console.log('检查目录:', dir);
|
94
|
+
|
95
|
+
try {
|
96
|
+
if (fs.existsSync(path.join(dir, 'package.json'))) {
|
97
|
+
return dir;
|
98
|
+
}
|
74
99
|
|
75
|
-
|
76
|
-
|
77
|
-
|
100
|
+
const parentDir = path.dirname(dir);
|
101
|
+
// 到达根目录,停止查找
|
102
|
+
if (parentDir === dir) {
|
103
|
+
return null;
|
104
|
+
}
|
105
|
+
|
106
|
+
return findPackageJson(parentDir);
|
107
|
+
} catch (error) {
|
108
|
+
console.error('查找package.json时出错:', error.message);
|
78
109
|
return null;
|
79
110
|
}
|
80
|
-
|
81
|
-
return findPackageJson(parentDir);
|
82
111
|
}
|
83
112
|
|
84
113
|
// 执行安装
|
85
|
-
|
114
|
+
console.log('开始执行element-plus安装脚本');
|
115
|
+
ensureElementPlusInstalled();
|
116
|
+
console.log('element-plus安装脚本执行完成');
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "morghulis",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.48",
|
4
4
|
"description": "数据库模型",
|
5
5
|
"private": false,
|
6
6
|
"type": "module",
|
@@ -8,7 +8,7 @@
|
|
8
8
|
"module": "dist/index.js",
|
9
9
|
"types": "dist/index.d.ts",
|
10
10
|
"bin": {
|
11
|
-
"install-element-plus": "
|
11
|
+
"install-element-plus": "install-deps.cjs"
|
12
12
|
},
|
13
13
|
"files": [
|
14
14
|
"dist",
|
@@ -22,7 +22,7 @@
|
|
22
22
|
"type-check": "vue-tsc --build",
|
23
23
|
"prepare": "npm run build",
|
24
24
|
"prepublishOnly": "npm run build",
|
25
|
-
"postinstall": "node install-deps.cjs",
|
25
|
+
"postinstall": "node ./install-deps.cjs",
|
26
26
|
"generate-types": "node copy-dts.js"
|
27
27
|
},
|
28
28
|
"dependencies": {
|