morghulis 1.0.46 → 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 +82 -18
- package/dist/index.js +5689 -5685
- package/dist/index.js.map +1 -1
- package/install-deps.cjs +116 -0
- package/package.json +7 -2
package/install-deps.cjs
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
// 使用CommonJS语法确保最大兼容性
|
4
|
+
const { execSync } = require('child_process');
|
5
|
+
const fs = require('fs');
|
6
|
+
const path = require('path');
|
7
|
+
|
8
|
+
// 打印当前目录,用于调试
|
9
|
+
console.log('当前执行目录:', process.cwd());
|
10
|
+
|
11
|
+
/**
|
12
|
+
* 确保element-plus被安装
|
13
|
+
*/
|
14
|
+
function ensureElementPlusInstalled() {
|
15
|
+
try {
|
16
|
+
// 尝试找到package.json,从当前目录开始向上查找
|
17
|
+
const projectRoot = findPackageJson(process.cwd());
|
18
|
+
if (!projectRoot) {
|
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
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
const rootDir = projectRoot || path.dirname(process.cwd());
|
29
|
+
console.log('使用目录:', rootDir);
|
30
|
+
|
31
|
+
// 检查package.json中是否已经有element-plus
|
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
|
+
|
40
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
41
|
+
const deps = packageJson.dependencies || {};
|
42
|
+
const devDeps = packageJson.devDependencies || {};
|
43
|
+
|
44
|
+
// 如果已经安装了element-plus,则不需要再安装
|
45
|
+
if (deps['element-plus'] || devDeps['element-plus']) {
|
46
|
+
console.log('element-plus已经在package.json中,跳过安装步骤');
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
|
50
|
+
console.log('正在安装element-plus...');
|
51
|
+
|
52
|
+
try {
|
53
|
+
// 先检查npm是否可用
|
54
|
+
execSync('npm --version', { stdio: 'ignore' });
|
55
|
+
|
56
|
+
// 使用npm安装element-plus
|
57
|
+
execSync('npm install element-plus --save', {
|
58
|
+
stdio: 'inherit',
|
59
|
+
cwd: rootDir
|
60
|
+
});
|
61
|
+
|
62
|
+
console.log('element-plus安装成功');
|
63
|
+
} catch (npmError) {
|
64
|
+
console.error('npm安装失败,尝试使用yarn:', npmError.message);
|
65
|
+
// 如果npm不可用,尝试使用yarn
|
66
|
+
try {
|
67
|
+
execSync('yarn --version', { stdio: 'ignore' });
|
68
|
+
|
69
|
+
execSync('yarn add element-plus', {
|
70
|
+
stdio: 'inherit',
|
71
|
+
cwd: rootDir
|
72
|
+
});
|
73
|
+
|
74
|
+
console.log('使用yarn安装element-plus成功');
|
75
|
+
} catch (yarnError) {
|
76
|
+
console.error('yarn安装失败:', yarnError.message);
|
77
|
+
console.error('无法使用npm或yarn安装element-plus');
|
78
|
+
console.error('请手动安装: npm install element-plus --save');
|
79
|
+
}
|
80
|
+
}
|
81
|
+
} catch (error) {
|
82
|
+
console.error('安装element-plus时出错:', error.message);
|
83
|
+
console.error('请手动安装: npm install element-plus --save');
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
/**
|
88
|
+
* 递归向上查找package.json所在目录
|
89
|
+
*/
|
90
|
+
function findPackageJson(dir) {
|
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
|
+
}
|
99
|
+
|
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);
|
109
|
+
return null;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
// 执行安装
|
114
|
+
console.log('开始执行element-plus安装脚本');
|
115
|
+
ensureElementPlusInstalled();
|
116
|
+
console.log('element-plus安装脚本执行完成');
|
package/package.json
CHANGED
@@ -1,14 +1,18 @@
|
|
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",
|
7
7
|
"main": "dist/index.js",
|
8
8
|
"module": "dist/index.js",
|
9
9
|
"types": "dist/index.d.ts",
|
10
|
+
"bin": {
|
11
|
+
"install-element-plus": "install-deps.cjs"
|
12
|
+
},
|
10
13
|
"files": [
|
11
|
-
"dist"
|
14
|
+
"dist",
|
15
|
+
"install-deps.cjs"
|
12
16
|
],
|
13
17
|
"scripts": {
|
14
18
|
"dev": "vite",
|
@@ -18,6 +22,7 @@
|
|
18
22
|
"type-check": "vue-tsc --build",
|
19
23
|
"prepare": "npm run build",
|
20
24
|
"prepublishOnly": "npm run build",
|
25
|
+
"postinstall": "node ./install-deps.cjs",
|
21
26
|
"generate-types": "node copy-dts.js"
|
22
27
|
},
|
23
28
|
"dependencies": {
|