From 9eb75a36a216a7efe27826c0bed40cfb167421c3 Mon Sep 17 00:00:00 2001 From: Paul Aderoju Date: Thu, 1 Oct 2026 17:51:02 +0100 Subject: [PATCH] fix: remove missing video player icon assets and fail build on download errors The build downloaded dist/fonts/cloudinary_icon_for_*.svg from unpkg, but those files don't exist for any player version, so the 404 response body was written to disk as the SVGs. The package exports also pointed to dist/cloudinary_icon_*.svg, which never existed (4 publint errors). Remove the icon downloads and their export paths (the icons are inlined in the player CSS), and make copy-assets fail when a download returns a non-200 response instead of writing the error page as the asset. --- next-cloudinary/package.json | 12 ++------- next-cloudinary/scripts/copy-assets.ts | 34 ++++++++++++-------------- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/next-cloudinary/package.json b/next-cloudinary/package.json index a7277737..fca6c0c0 100644 --- a/next-cloudinary/package.json +++ b/next-cloudinary/package.json @@ -20,11 +20,7 @@ }, "./package.json": "./package.json", "./cld-video-player.css": "./dist/cld-video-player.css", - "./dist/cld-video-player.css": "./dist/cld-video-player.css", - "./cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg", - "./dist/cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg", - "./cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg", - "./dist/cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg" + "./dist/cld-video-player.css": "./dist/cld-video-player.css" }, "types": "./dist/next-cloudinary.cjs.d.ts", "files": [ @@ -70,11 +66,7 @@ "importConditionDefaultExport": "default", "extra": { "./cld-video-player.css": "./dist/cld-video-player.css", - "./dist/cld-video-player.css": "./dist/cld-video-player.css", - "./cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg", - "./dist/cloudinary_icon_for_black_bg.svg": "./dist/cloudinary_icon_for_black_bg.svg", - "./cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg", - "./dist/cloudinary_icon_for_white_bg.svg": "./dist/cloudinary_icon_for_white_bg.svg" + "./dist/cld-video-player.css": "./dist/cld-video-player.css" } }, "___experimentalFlags_WILL_CHANGE_IN_PATCH": { diff --git a/next-cloudinary/scripts/copy-assets.ts b/next-cloudinary/scripts/copy-assets.ts index 68125f2b..dddb30ce 100644 --- a/next-cloudinary/scripts/copy-assets.ts +++ b/next-cloudinary/scripts/copy-assets.ts @@ -9,13 +9,6 @@ const assets = [ { uri: `https://unpkg.com/cloudinary-video-player@${PLAYER_VERSION}/dist/cld-video-player.min.css`, name: 'cld-video-player.css' - }, - { - directory: 'fonts', - assets: [ - `https://unpkg.com/cloudinary-video-player@${PLAYER_VERSION}/dist/fonts/cloudinary_icon_for_black_bg.svg`, - `https://unpkg.com/cloudinary-video-player@${PLAYER_VERSION}/dist/fonts/cloudinary_icon_for_white_bg.svg`, - ] } ]; @@ -44,14 +37,6 @@ async function copyAssets() { await downloadFile(uri, writePath); console.log(`Wrote ${uri} to ${writePath}`); - } else if ( typeof asset.directory === 'string' ) { - await mkdirp(path.join(distPath, asset.directory)); - - for ( const dirAsset of asset.assets ) { - const writePath = path.join(distPath, asset.directory, path.basename(dirAsset)); - await downloadFile(dirAsset, writePath); - console.log(`Wrote ${dirAsset} to ${writePath}`); - } } } @@ -63,16 +48,27 @@ async function copyAssets() { */ function downloadFile(assetUrl: string, writePath: string) { - return new Promise((resolve) => { - const file = createWriteStream(writePath); + return new Promise((resolve, reject) => { https.get(assetUrl, function(response) { + // Fail instead of writing an error page (e.g. a 404) to disk as the asset + if ( response.statusCode !== 200 ) { + response.resume(); + reject(new Error(`Failed to download ${assetUrl}: HTTP ${response.statusCode}`)); + return; + } + + const file = createWriteStream(writePath); response.pipe(file); file.on('finish', () => { file.close(); resolve(); }); - }); + file.on('error', reject); + }).on('error', reject); }) } -copyAssets(); +copyAssets().catch((error) => { + console.error(error); + process.exit(1); +});