@alanwang-merit/meritdata-platform-skill-package 1.0.7 → 1.0.8
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/package.json +2 -2
- package/scripts/postinstall.js +7 -8
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alanwang-merit/meritdata-platform-skill-package",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/"
|
|
6
6
|
},
|
|
7
7
|
"scripts": {
|
|
8
|
-
"
|
|
8
|
+
"init-skill": "node scripts/postinstall.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"skills",
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
// 1. 获取当前 npm 包所在的目录
|
|
4
|
+
// 1. 获取当前 npm 包所在的目录
|
|
5
5
|
const currentPackagePath = path.resolve(__dirname, '..');
|
|
6
6
|
|
|
7
7
|
// 2. 【纯原生实现】精准定位项目根目录:向上回溯找到 node_modules 的父级
|
|
8
|
-
// 无论当前在哪一层级,只要路径中包含 node_modules,就截取它之前的部分作为项目根目录
|
|
9
8
|
const nodeModulesIndex = currentPackagePath.indexOf('node_modules');
|
|
10
9
|
if (nodeModulesIndex === -1) {
|
|
11
|
-
console.error('❌ [
|
|
12
|
-
process.exit(1);
|
|
10
|
+
console.error('❌ [init-skill] Error: Cannot find node_modules in path.');
|
|
11
|
+
process.exit(1);
|
|
13
12
|
}
|
|
14
13
|
const projectRoot = currentPackagePath.substring(0, nodeModulesIndex);
|
|
15
14
|
|
|
@@ -22,7 +21,7 @@ const copyMappings = [
|
|
|
22
21
|
// 4. 递归复制文件夹的函数
|
|
23
22
|
function copyDir(src, dest) {
|
|
24
23
|
if (!fs.existsSync(src)) {
|
|
25
|
-
console.log(`⚠️ [
|
|
24
|
+
console.log(`⚠️ [init-skill] Source not found, skipping: ${src}`);
|
|
26
25
|
return;
|
|
27
26
|
}
|
|
28
27
|
|
|
@@ -41,12 +40,12 @@ function copyDir(src, dest) {
|
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
// 5. 执行复制操作
|
|
44
|
-
console.log(`🚀 [
|
|
43
|
+
console.log(`🚀 [init-skill] Project root detected: ${projectRoot}`);
|
|
45
44
|
copyMappings.forEach(({ source, target }) => {
|
|
46
45
|
const srcPath = path.join(currentPackagePath, source);
|
|
47
46
|
const destPath = path.join(projectRoot, target);
|
|
48
47
|
copyDir(srcPath, destPath);
|
|
49
|
-
console.log(`✅ [
|
|
48
|
+
console.log(`✅ [init-skill] Copied ${source} -> ${destPath}`);
|
|
50
49
|
});
|
|
51
50
|
|
|
52
|
-
console.log('🎉 [
|
|
51
|
+
console.log('🎉 [init-skill] Skill package initialized successfully!');
|