dk-frontend-skills 3.0.4 → 3.0.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dk-frontend-skills",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "description": "dk-engineer - 幽默沉稳靠谱的前端开发助手 Claude Skills 配置包,一键注入 .claude/ 技能目录和 CLAUDE.md 人设配置",
5
5
  "author": "XiaoMa",
6
6
  "license": "MIT",
package/scripts/cli.js CHANGED
@@ -56,12 +56,12 @@ async function downloadAndInstallSkill(name, index) {
56
56
 
57
57
  const destDir = path.join(skillsDest, name);
58
58
 
59
- // 检查本地版本
59
+ // 已安装且版本一致则跳过
60
60
  const localMetaPath = path.join(destDir, ".meta.json");
61
61
  if (fs.existsSync(localMetaPath)) {
62
62
  try {
63
63
  const localMeta = JSON.parse(fs.readFileSync(localMetaPath, "utf-8"));
64
- if (localMeta.version === skillInfo.version) return true;
64
+ if (localMeta.version === skillInfo.version) return "skipped";
65
65
  } catch {}
66
66
  }
67
67
 
@@ -77,12 +77,11 @@ async function downloadAndInstallSkill(name, index) {
77
77
  hideCursor: true,
78
78
  }, Presets.shades_classic);
79
79
 
80
- const MAX_RETRIES = 3;
80
+ const MAX_RETRIES = 5;
81
81
 
82
82
  for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
83
83
  const tempFile = path.join(tempDir, skillInfo.fileName);
84
84
  try {
85
- if (attempt > 1) console.log(` ↻ ${name} 重试第 ${attempt} 次...`);
86
85
  bar.start(100, 0);
87
86
  await downloadFile(url, tempFile, (d, t) => {
88
87
  bar.setTotal(t || skillInfo.size || 100);
@@ -97,7 +96,7 @@ async function downloadAndInstallSkill(name, index) {
97
96
 
98
97
  fs.rmSync(tempFile, { force: true });
99
98
  console.log(` ✓ ${name}`);
100
- return true;
99
+ return "installed";
101
100
  } catch (err) {
102
101
  bar.stop();
103
102
  if (fs.existsSync(tempFile)) fs.rmSync(tempFile, { force: true });
@@ -112,7 +111,6 @@ async function downloadAndInstallSkill(name, index) {
112
111
  }
113
112
 
114
113
  async function installSelectedSkills(selectedNames) {
115
- // 创建目录
116
114
  if (!fs.existsSync(skillsDest)) {
117
115
  fs.mkdirSync(skillsDest, { recursive: true });
118
116
  }
@@ -130,11 +128,9 @@ async function installSelectedSkills(selectedNames) {
130
128
  const dest = path.join(skillsDest, name);
131
129
 
132
130
  if (selectedNames.includes(name)) {
133
- // 勾选了的 下载/更新
134
- const ok = await downloadAndInstallSkill(name, index);
135
- if (ok) installedCount++;
131
+ const result = await downloadAndInstallSkill(name, index);
132
+ if (result === "installed") installedCount++;
136
133
  } else {
137
- // 没勾选的 → 移除
138
134
  if (fs.existsSync(dest)) {
139
135
  fs.rmSync(dest, { recursive: true, force: true });
140
136
  }
@@ -160,7 +156,6 @@ async function installSelectedSkills(selectedNames) {
160
156
  const mdDest = path.join(projectRoot, "CLAUDE.md");
161
157
  if (fs.existsSync(mdSource) && !fs.existsSync(mdDest)) {
162
158
  fs.copyFileSync(mdSource, mdDest);
163
- console.log(" 📝 CLAUDE.md 已创建");
164
159
  }
165
160
 
166
161
  return installedCount;
package/scripts/core.js CHANGED
@@ -242,10 +242,11 @@ async function downloadFile(url, destPath, onProgress) {
242
242
  if (done) break;
243
243
  downloaded += value.length;
244
244
  if (onProgress) onProgress(downloaded, total);
245
- writer.write(value);
245
+ const ok = writer.write(value);
246
+ if (!ok) await new Promise((resolve) => writer.once("drain", resolve));
246
247
  }
247
248
  } finally {
248
- writer.close();
249
+ await new Promise((resolve) => writer.end(resolve));
249
250
  }
250
251
 
251
252
  // 下载完后校验 gzip 格式