(projectDir: string)
| 340 | } |
| 341 | |
| 342 | export function createPublishArchive(projectDir: string): PublishArchiveResult { |
| 343 | const absProjectDir = resolve(projectDir); |
| 344 | const filePaths: string[] = []; |
| 345 | collectProjectFiles(absProjectDir, absProjectDir, filePaths); |
| 346 | if (!filePaths.includes("index.html")) { |
| 347 | throw new Error("Project must include an index.html file at the root before publish."); |
| 348 | } |
| 349 | |
| 350 | const fileContents = new Map<string, Buffer>(); |
| 351 | for (const filePath of filePaths) { |
| 352 | fileContents.set(filePath, readFileSync(join(absProjectDir, filePath))); |
| 353 | } |
| 354 | |
| 355 | localizeExternalAssets(absProjectDir, fileContents); |
| 356 | |
| 357 | const archive = new AdmZip(); |
| 358 | for (const [filePath, content] of fileContents) { |
| 359 | archive.addFile(filePath, content); |
| 360 | } |
| 361 | |
| 362 | return { |
| 363 | buffer: archive.toBuffer(), |
| 364 | fileCount: fileContents.size, |
| 365 | }; |
| 366 | } |
| 367 | |
| 368 | export function getPublishApiBaseUrl(): string { |
| 369 | return ( |
no test coverage detected