itismyskillmarket 1.3.32 → 1.3.33
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/dist/index.js +20 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1608,7 +1608,7 @@ async function verifySkill(skillName) {
|
|
|
1608
1608
|
|
|
1609
1609
|
// src/commands/ui.ts
|
|
1610
1610
|
import { createServer } from "http";
|
|
1611
|
-
import { readFileSync as readFileSync2, existsSync as existsSync3, mkdirSync, rmSync } from "fs";
|
|
1611
|
+
import { readFileSync as readFileSync2, existsSync as existsSync3, mkdirSync, rmSync, readdirSync } from "fs";
|
|
1612
1612
|
import { join as join3, extname, dirname, basename } from "path";
|
|
1613
1613
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
1614
1614
|
import AdmZip from "adm-zip";
|
|
@@ -2607,10 +2607,8 @@ API_ROUTES.POST["/api/upload"] = async (req, res, _url) => {
|
|
|
2607
2607
|
});
|
|
2608
2608
|
let skillName = "";
|
|
2609
2609
|
let pkgInfo = {};
|
|
2610
|
-
let pkgEntryRelativePath = "";
|
|
2611
2610
|
if (pkgEntry) {
|
|
2612
2611
|
try {
|
|
2613
|
-
pkgEntryRelativePath = normalizeEntryName(pkgEntry.entryName);
|
|
2614
2612
|
pkgInfo = JSON.parse(pkgEntry.getData().toString("utf-8"));
|
|
2615
2613
|
skillName = pkgInfo.skillmarket?.id || pkgInfo.name?.replace(/^@[^/]+\//, "") || "";
|
|
2616
2614
|
} catch {
|
|
@@ -2631,14 +2629,9 @@ API_ROUTES.POST["/api/upload"] = async (req, res, _url) => {
|
|
|
2631
2629
|
}
|
|
2632
2630
|
mkdirSync(skillDir, { recursive: true });
|
|
2633
2631
|
zip.extractAllTo(skillDir, true);
|
|
2634
|
-
const
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
const extractedPkgPath = join3(skillDir, pkgEntryRelativePath);
|
|
2638
|
-
if (existsSync3(extractedPkgPath)) {
|
|
2639
|
-
pkgJsonPath = extractedPkgPath;
|
|
2640
|
-
}
|
|
2641
|
-
}
|
|
2632
|
+
const skillMdPath = findFileSync(skillDir, "SKILL.md");
|
|
2633
|
+
const skillMdExists = skillMdPath !== null;
|
|
2634
|
+
const pkgJsonPath = findFileSync(skillDir, "package.json") || join3(skillDir, "package.json");
|
|
2642
2635
|
if (existsSync3(pkgJsonPath)) {
|
|
2643
2636
|
try {
|
|
2644
2637
|
pkgInfo = JSON.parse(readFileSync2(pkgJsonPath, "utf-8"));
|
|
@@ -2701,6 +2694,22 @@ API_ROUTES.POST["/api/upload/action"] = async (req, res, _url) => {
|
|
|
2701
2694
|
jsonResponse(res, 500, { error: String(err) });
|
|
2702
2695
|
}
|
|
2703
2696
|
};
|
|
2697
|
+
function findFileSync(dir, filename) {
|
|
2698
|
+
try {
|
|
2699
|
+
const items = readdirSync(dir, { withFileTypes: true });
|
|
2700
|
+
for (const item of items) {
|
|
2701
|
+
const fullPath = join3(dir, item.name);
|
|
2702
|
+
if (item.isDirectory()) {
|
|
2703
|
+
const found = findFileSync(fullPath, filename);
|
|
2704
|
+
if (found) return found;
|
|
2705
|
+
} else if (item.name === filename) {
|
|
2706
|
+
return fullPath;
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
} catch {
|
|
2710
|
+
}
|
|
2711
|
+
return null;
|
|
2712
|
+
}
|
|
2704
2713
|
function serveStaticFile(res, filePath) {
|
|
2705
2714
|
if (!existsSync3(filePath)) {
|
|
2706
2715
|
res.writeHead(404, { "Content-Type": "text/plain" });
|