( importSuffix: string, fileName: string )
| 466 | } |
| 467 | |
| 468 | async function writeImportBasedAssetDeclarationFile( |
| 469 | importSuffix: string, |
| 470 | fileName: string |
| 471 | ): Promise<void> { |
| 472 | const codeFile = new CodeFile(` |
| 473 | // eslint-disable-next-line @typescript-eslint/triple-slash-reference |
| 474 | /// <reference path="./modules.d.ts" /> |
| 475 | import { formatAssetUrl } from './utils.js' |
| 476 | `) |
| 477 | |
| 478 | const fn = codeFile.appendFn(` |
| 479 | /** |
| 480 | * @param {AssetUrlOptions} [opts] |
| 481 | * @public |
| 482 | */ |
| 483 | export function getAssetUrlsByImport(opts) { |
| 484 | `) |
| 485 | |
| 486 | fn.append('return {') |
| 487 | for (const [type, assets] of Object.entries(collectedAssetUrls)) { |
| 488 | fn.append(`${type}: {`) |
| 489 | for (const [name, { file, hash }] of Object.entries(assets)) { |
| 490 | const variableName = codeFile.import(`./${file}${importSuffix}`) |
| 491 | const formattedUrl = fn.memo(file, `formatAssetUrl(${variableName}, opts)`) |
| 492 | const value = hash ? `${formattedUrl} + ${JSON.stringify('#' + hash)}` : formattedUrl |
| 493 | fn.append(`${JSON.stringify(name)}: ${value},`) |
| 494 | } |
| 495 | fn.append('},') |
| 496 | } |
| 497 | fn.append('}') |
| 498 | |
| 499 | const codeFilePath = join(REPO_ROOT, 'packages', 'assets', fileName) |
| 500 | await writeCodeFile( |
| 501 | 'internal/scripts/refresh-assets.ts', |
| 502 | 'javascript', |
| 503 | codeFilePath, |
| 504 | codeFile.toString() |
| 505 | ) |
| 506 | } |
| 507 | |
| 508 | async function writeSelfHostedAssetDeclarationFile(): Promise<void> { |
| 509 | const codeFilePath = join(REPO_ROOT, 'packages', 'assets', 'selfHosted.js') |
no test coverage detected
searching dependent graphs…