@dealdeploy/skl 1.10.2 → 1.10.3
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/bunfig.toml +3 -0
- package/lib.ts +16 -14
- package/package.json +1 -1
package/bunfig.toml
ADDED
package/lib.ts
CHANGED
|
@@ -299,25 +299,27 @@ export async function downloadSkillFiles(
|
|
|
299
299
|
branch: string,
|
|
300
300
|
prefix: string,
|
|
301
301
|
destDir: string,
|
|
302
|
-
tree: { path: string; type: string }[],
|
|
302
|
+
tree: { path: string; type: string; sha?: string }[],
|
|
303
303
|
): Promise<number> {
|
|
304
304
|
const prefixSlash = prefix + "/";
|
|
305
|
-
const files = tree
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const
|
|
316
|
-
|
|
305
|
+
const files = tree.filter(
|
|
306
|
+
(e) => e.type === "blob" && e.path.startsWith(prefixSlash),
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
for (const file of files) {
|
|
310
|
+
const proc = Bun.spawn(
|
|
311
|
+
["gh", "api", `repos/${repo}/git/blobs/${file.sha}`, "--jq", ".content"],
|
|
312
|
+
{ stdout: "pipe", stderr: "pipe" },
|
|
313
|
+
);
|
|
314
|
+
const out = await new Response(proc.stdout).text();
|
|
315
|
+
const code = await proc.exited;
|
|
316
|
+
if (code !== 0) continue;
|
|
317
|
+
const content = Buffer.from(out.trim(), "base64");
|
|
318
|
+
const relativePath = file.path.substring(prefixSlash.length);
|
|
317
319
|
const dest = join(destDir, relativePath);
|
|
318
320
|
const dir = dest.substring(0, dest.lastIndexOf("/"));
|
|
319
321
|
mkdirSync(dir, { recursive: true });
|
|
320
|
-
writeFileSync(dest,
|
|
322
|
+
writeFileSync(dest, content);
|
|
321
323
|
}
|
|
322
324
|
|
|
323
325
|
return files.length;
|