sdd-full 1.5.0 → 1.5.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.
Files changed (2) hide show
  1. package/bin.js +46 -1
  2. package/package.json +1 -1
package/bin.js CHANGED
@@ -6,17 +6,30 @@ const fs = require('fs');
6
6
  const path = require('path');
7
7
 
8
8
  const SDD = {
9
- version: '1.5.0',
9
+ version: '1.5.1',
10
10
  name: 'sdd-full',
11
11
  description: '完整的软件设计开发技能包'
12
12
  };
13
13
 
14
+ let VERBOSE = false;
15
+
16
+ function debug(msg) {
17
+ if (VERBOSE) {
18
+ console.log(`[DEBUG] ${msg}`);
19
+ }
20
+ }
21
+
14
22
  function copyDirectory(src, dest) {
23
+ debug(`copyDirectory: ${src} -> ${dest}`);
24
+
15
25
  if (!fs.existsSync(dest)) {
26
+ debug(`创建目录: ${dest}`);
16
27
  fs.mkdirSync(dest, { recursive: true });
17
28
  }
18
29
 
19
30
  const items = fs.readdirSync(src);
31
+ debug(`源目录内容: ${items.length} 项`);
32
+
20
33
  items.forEach(item => {
21
34
  const srcPath = path.join(src, item);
22
35
  const destPath = path.join(dest, item);
@@ -25,6 +38,7 @@ function copyDirectory(src, dest) {
25
38
  if (stat.isDirectory()) {
26
39
  copyDirectory(srcPath, destPath);
27
40
  } else {
41
+ debug(`复制文件: ${item}`);
28
42
  fs.copyFileSync(srcPath, destPath);
29
43
  }
30
44
  });
@@ -32,6 +46,9 @@ function copyDirectory(src, dest) {
32
46
 
33
47
  function getSkills() {
34
48
  const skillsDir = path.join(__dirname, 'skills');
49
+ debug(`技能目录: ${skillsDir}`);
50
+ debug(`技能目录存在: ${fs.existsSync(skillsDir)}`);
51
+
35
52
  const skills = [];
36
53
 
37
54
  if (fs.existsSync(skillsDir)) {
@@ -50,11 +67,14 @@ function getSkills() {
50
67
  });
51
68
  }
52
69
 
70
+ debug(`找到技能: ${skills.length} 个`);
53
71
  return skills;
54
72
  }
55
73
 
56
74
  function install(targetDir, environment) {
57
75
  const baseDir = targetDir || process.cwd();
76
+ debug(`安装基准目录: ${baseDir}`);
77
+ debug(`环境: ${environment}`);
58
78
 
59
79
  console.log('========================================');
60
80
  console.log(` ${SDD.name} - ${SDD.description}`);
@@ -62,6 +82,8 @@ function install(targetDir, environment) {
62
82
  console.log('========================================');
63
83
 
64
84
  const sourceDir = path.join(__dirname, 'skills');
85
+ debug(`技能源目录: ${sourceDir}`);
86
+ debug(`技能源目录存在: ${fs.existsSync(sourceDir)}`);
65
87
 
66
88
  // 根据环境选择安装目录
67
89
  let dirsToInstall;
@@ -87,16 +109,19 @@ function install(targetDir, environment) {
87
109
 
88
110
  dirsToInstall.forEach(dirInfo => {
89
111
  const destDir = dirInfo.path;
112
+ debug(`安装目标: ${dirInfo.name} -> ${destDir}`);
90
113
 
91
114
  console.log(`\n正在安装到: ${dirInfo.name} (${destDir})`);
92
115
 
93
116
  if (!fs.existsSync(destDir)) {
117
+ debug(`创建目标目录: ${destDir}`);
94
118
  fs.mkdirSync(destDir, { recursive: true });
95
119
  }
96
120
 
97
121
  let count = 0;
98
122
  if (fs.existsSync(sourceDir)) {
99
123
  const items = fs.readdirSync(sourceDir);
124
+ debug(`源目录内容: ${items.join(', ')}`);
100
125
 
101
126
  items.forEach(item => {
102
127
  const srcItem = path.join(sourceDir, item);
@@ -104,9 +129,11 @@ function install(targetDir, environment) {
104
129
  const stat = fs.statSync(srcItem);
105
130
 
106
131
  if (stat.isDirectory()) {
132
+ debug(`复制目录: ${item}`);
107
133
  copyDirectory(srcItem, destItem);
108
134
  count++;
109
135
  } else if (stat.isFile() && item.endsWith('.md')) {
136
+ debug(`复制文件: ${item}`);
110
137
  fs.copyFileSync(srcItem, destItem);
111
138
  }
112
139
  });
@@ -114,6 +141,13 @@ function install(targetDir, environment) {
114
141
 
115
142
  totalCount += count;
116
143
  console.log(` ✅ ${count} 个技能`);
144
+
145
+ // 验证安装结果
146
+ if (fs.existsSync(destDir)) {
147
+ const installedItems = fs.readdirSync(destDir);
148
+ debug(`目标目录内容: ${installedItems.join(', ')}`);
149
+ console.log(` 📁 已安装内容: ${installedItems.length} 项`);
150
+ }
117
151
  });
118
152
 
119
153
  console.log('\n========================================');
@@ -122,6 +156,7 @@ function install(targetDir, environment) {
122
156
  console.log('\n现在您可以在以下环境中使用这些技能:');
123
157
  dirsToInstall.forEach(dirInfo => {
124
158
  console.log(` - ${dirInfo.name}`);
159
+ console.log(` 位置: ${dirInfo.path}`);
125
160
  });
126
161
  console.log('\n🎉 开始使用吧!\n');
127
162
  }
@@ -130,6 +165,15 @@ function install(targetDir, environment) {
130
165
  function main() {
131
166
  const args = process.argv.slice(2);
132
167
 
168
+ // 检查是否启用 verbose
169
+ VERBOSE = args.some(arg => arg === '--verbose' || arg === '-v');
170
+ if (VERBOSE) {
171
+ debug(`Verbose 模式已启用`);
172
+ debug(`工作目录: ${process.cwd()}`);
173
+ debug(`__dirname: ${__dirname}`);
174
+ debug(`命令行参数: ${args.join(', ')}`);
175
+ }
176
+
133
177
  // 检查是否需要显示帮助
134
178
  const showHelp = args.some(arg => arg === '--help' || arg === '-h');
135
179
 
@@ -144,6 +188,7 @@ function main() {
144
188
  console.log(' npx sdd-full all - 安装到所有环境');
145
189
  console.log(' npx sdd-full --help - 显示帮助');
146
190
  console.log(' npx sdd-full --dir ./myproj - 安装到指定目录');
191
+ console.log(' npx sdd-full --verbose - 显示详细调试信息');
147
192
 
148
193
  const skills = getSkills();
149
194
  console.log('\n可用技能:');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdd-full",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "SDD Full - 完整的软件设计开发技能包",
5
5
  "main": "index.js",
6
6
  "bin": "./bin.js",