MCPcopy Index your code
hub / github.com/github/awesome-copilot / downloadZipBundle

Function downloadZipBundle

website/src/scripts/utils.ts:94–136  ·  view source on GitHub ↗
(
  bundleName: string,
  files: ZipDownloadFile[]
)

Source from the content-addressed store, hash-verified

92}
93
94export async function downloadZipBundle(
95 bundleName: string,
96 files: ZipDownloadFile[]
97): Promise<void> {
98 if (files.length === 0) {
99 throw new Error("No files found for this download.");
100 }
101
102 const JSZip = await loadJSZip();
103 const zip = new JSZip();
104 const folder = zip.folder(bundleName);
105
106 const fetchPromises = files.map(async (file) => {
107 try {
108 const response = await fetch(getRawGitHubUrl(file.path));
109 if (!response.ok) return null;
110
111 return {
112 name: file.name,
113 content: await response.text(),
114 };
115 } catch {
116 return null;
117 }
118 });
119
120 const results = await Promise.all(fetchPromises);
121 let addedFiles = 0;
122
123 for (const result of results) {
124 if (result && folder) {
125 folder.file(result.name, result.content);
126 addedFiles++;
127 }
128 }
129
130 if (addedFiles === 0) {
131 throw new Error("Failed to fetch any files");
132 }
133
134 const blob = await zip.generateAsync({ type: "blob" });
135 triggerBlobDownload(blob, `${bundleName}.zip`);
136}
137
138/**
139 * Fetch raw file content from GitHub

Callers 3

setupModalFunction · 0.90
downloadSkillFunction · 0.90
downloadHookFunction · 0.90

Calls 3

loadJSZipFunction · 0.85
getRawGitHubUrlFunction · 0.85
triggerBlobDownloadFunction · 0.85

Tested by

no test coverage detected