promptgraph-mcp 2.8.1 → 2.8.2
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/github-import.js +16 -9
- package/package.json +1 -1
package/github-import.js
CHANGED
|
@@ -675,18 +675,25 @@ export async function importFromGitHubLight(repoUrl) {
|
|
|
675
675
|
if (fs.existsSync(destBase)) fs.rmSync(destBase, { recursive: true, force: true });
|
|
676
676
|
fs.mkdirSync(destBase, { recursive: true });
|
|
677
677
|
|
|
678
|
+
const CONCURRENT = 5;
|
|
679
|
+
let dlIdx = 0;
|
|
678
680
|
let downloaded = 0;
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
const
|
|
684
|
-
fs.
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
681
|
+
const dlErr = [];
|
|
682
|
+
async function dlWorker() {
|
|
683
|
+
while (dlIdx < mdFiles.length) {
|
|
684
|
+
const file = mdFiles[dlIdx++];
|
|
685
|
+
const destPath = path.join(destBase, file.fullPath);
|
|
686
|
+
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
687
|
+
try {
|
|
688
|
+
const content = await streamDownload(file.download_url);
|
|
689
|
+
fs.writeFileSync(destPath, content);
|
|
690
|
+
downloaded++;
|
|
691
|
+
} catch (e) {
|
|
692
|
+
dlErr.push(e.message?.slice(0, 80) || 'download failed');
|
|
693
|
+
}
|
|
688
694
|
}
|
|
689
695
|
}
|
|
696
|
+
await Promise.all(Array.from({ length: Math.min(CONCURRENT, mdFiles.length) }, () => dlWorker()));
|
|
690
697
|
|
|
691
698
|
if (downloaded === 0) {
|
|
692
699
|
fs.rmSync(destBase, { recursive: true, force: true });
|