dk-frontend-skills 3.0.4 → 3.0.5
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 +1 -1
- package/scripts/cli.js +6 -11
package/package.json
CHANGED
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
|
|
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 =
|
|
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
|
|
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
|
-
|
|
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;
|