sdd-full 1.1.0 → 1.2.1
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/index.js +95 -13
- package/package.json +2 -1
package/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
1
3
|
// sdd-full npm 包
|
|
2
4
|
// 完整的软件设计开发技能包
|
|
3
5
|
|
|
@@ -6,7 +8,7 @@ const path = require('path');
|
|
|
6
8
|
|
|
7
9
|
// 技能包的主入口
|
|
8
10
|
const SDD = {
|
|
9
|
-
version: '1.
|
|
11
|
+
version: '1.2.1',
|
|
10
12
|
name: 'sdd-full',
|
|
11
13
|
description: '完整的软件设计开发技能包',
|
|
12
14
|
|
|
@@ -67,24 +69,104 @@ const SDD = {
|
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
return null;
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
// 安装技能到当前目录
|
|
75
|
+
install: function(targetDir) {
|
|
76
|
+
const destDir = path.join(targetDir || process.cwd(), '.sdd-full', 'skills');
|
|
77
|
+
const sourceDir = path.join(__dirname, 'skills');
|
|
78
|
+
|
|
79
|
+
console.log('========================================');
|
|
80
|
+
console.log(` ${SDD.name} - ${SDD.description}`);
|
|
81
|
+
console.log(` 版本: ${SDD.version}`);
|
|
82
|
+
console.log('========================================');
|
|
83
|
+
console.log(`\n正在安装技能到: ${destDir}`);
|
|
84
|
+
|
|
85
|
+
// 确保目标目录存在
|
|
86
|
+
if (!fs.existsSync(destDir)) {
|
|
87
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// 复制所有技能文件
|
|
91
|
+
let count = 0;
|
|
92
|
+
if (fs.existsSync(sourceDir)) {
|
|
93
|
+
const items = fs.readdirSync(sourceDir);
|
|
94
|
+
|
|
95
|
+
items.forEach(item => {
|
|
96
|
+
const srcItem = path.join(sourceDir, item);
|
|
97
|
+
const destItem = path.join(destDir, item);
|
|
98
|
+
const stat = fs.statSync(srcItem);
|
|
99
|
+
|
|
100
|
+
if (stat.isDirectory()) {
|
|
101
|
+
// 复制目录(技能)
|
|
102
|
+
copyDirectory(srcItem, destItem);
|
|
103
|
+
count++;
|
|
104
|
+
} else if (stat.isFile() && item.endsWith('.md')) {
|
|
105
|
+
// 复制文档文件
|
|
106
|
+
fs.copyFileSync(srcItem, destItem);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
console.log(`\n✅ 成功安装 ${count} 个技能!`);
|
|
112
|
+
console.log(`\n技能目录: ${destDir}`);
|
|
113
|
+
console.log('\n您现在可以在支持技能的环境中使用这些技能了!\n');
|
|
70
114
|
}
|
|
71
115
|
};
|
|
72
116
|
|
|
117
|
+
// 复制目录的辅助函数
|
|
118
|
+
function copyDirectory(src, dest) {
|
|
119
|
+
if (!fs.existsSync(dest)) {
|
|
120
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const items = fs.readdirSync(src);
|
|
124
|
+
items.forEach(item => {
|
|
125
|
+
const srcPath = path.join(src, item);
|
|
126
|
+
const destPath = path.join(dest, item);
|
|
127
|
+
const stat = fs.statSync(srcPath);
|
|
128
|
+
|
|
129
|
+
if (stat.isDirectory()) {
|
|
130
|
+
copyDirectory(srcPath, destPath);
|
|
131
|
+
} else {
|
|
132
|
+
fs.copyFileSync(srcPath, destPath);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
73
137
|
// 导出模块
|
|
74
138
|
module.exports = SDD;
|
|
75
139
|
|
|
76
|
-
//
|
|
140
|
+
// 如果直接运行,显示版本和技能列表或安装
|
|
77
141
|
if (require.main === module) {
|
|
78
|
-
|
|
79
|
-
console.log(` ${SDD.name} - ${SDD.description}`);
|
|
80
|
-
console.log(` 版本: ${SDD.version}`);
|
|
81
|
-
console.log('========================================');
|
|
142
|
+
const args = process.argv.slice(2);
|
|
82
143
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
144
|
+
if (args.includes('install') || args.includes('i')) {
|
|
145
|
+
// 安装模式
|
|
146
|
+
const targetIndex = args.indexOf('--dir') || args.indexOf('-d');
|
|
147
|
+
let targetDir;
|
|
148
|
+
if (targetIndex !== -1 && args[targetIndex + 1]) {
|
|
149
|
+
targetDir = args[targetIndex + 1];
|
|
150
|
+
}
|
|
151
|
+
SDD.install(targetDir);
|
|
152
|
+
} else {
|
|
153
|
+
// 默认显示模式
|
|
154
|
+
console.log('========================================');
|
|
155
|
+
console.log(` ${SDD.name} - ${SDD.description}`);
|
|
156
|
+
console.log(` 版本: ${SDD.version}`);
|
|
157
|
+
console.log('========================================');
|
|
158
|
+
console.log('\n用法:');
|
|
159
|
+
console.log(' npx sdd-full - 显示帮助和技能列表');
|
|
160
|
+
console.log(' npx sdd-full install - 安装技能到当前目录');
|
|
161
|
+
console.log(' npx sdd-full i - 安装技能(简写)');
|
|
162
|
+
console.log(' npx sdd-full install --dir ./my-project - 安装到指定目录');
|
|
163
|
+
|
|
164
|
+
const skills = SDD.getSkills();
|
|
165
|
+
console.log('\n可用技能:');
|
|
166
|
+
skills.forEach(skill => {
|
|
167
|
+
console.log(` - ${skill}`);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
console.log(`\n总计 ${skills.length} 个技能\n`);
|
|
171
|
+
}
|
|
90
172
|
}
|