From 661165bd6568ecd7f9481138541771db55b3b3af Mon Sep 17 00:00:00 2001 From: Nexmoe <16796652+nexmoe@users.noreply.github.com> Date: Fri, 24 Oct 2025 22:06:59 +0800 Subject: [PATCH] chore: add script to check yt-dlp binary existence for cross-platform builds --- package.json | 6 +++--- scripts/check-ytdlp.js | 48 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 scripts/check-ytdlp.js diff --git a/package.json b/package.json index c5fbfe5..2869e12 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,9 @@ "build": "pnpm run typecheck && electron-vite build", "postinstall": "electron-builder install-app-deps", "build:unpack": "pnpm run build && electron-builder --dir", - "build:win": "pnpm run build && electron-builder --win", - "build:mac": "pnpm run build && electron-builder --mac", - "build:linux": "pnpm run build && electron-builder --linux", + "build:win": "node scripts/check-ytdlp.js win && pnpm run build && electron-builder --win", + "build:mac": "node scripts/check-ytdlp.js mac && pnpm run build && electron-builder --mac", + "build:linux": "node scripts/check-ytdlp.js linux && pnpm run build && electron-builder --linux", "release": "pnpm run check && bumpp" }, "dependencies": { diff --git a/scripts/check-ytdlp.js b/scripts/check-ytdlp.js new file mode 100644 index 0000000..dc284ff --- /dev/null +++ b/scripts/check-ytdlp.js @@ -0,0 +1,48 @@ +#!/usr/bin/env node + +const fs = require('node:fs') +const path = require('node:path') + +/** + * Check if yt-dlp binary exists in resources directory + * Usage: node scripts/check-ytdlp.js [platform] + * Platform options: win, mac, linux + * Exit with error code 1 if not found + */ +function checkYtDlpExists(platform) { + const platformMap = { + win: 'yt-dlp.exe', + mac: 'yt-dlp_macos', + linux: 'yt-dlp_linux' + } + + const filename = platformMap[platform] + if (!filename) { + console.error('❌ Error: Invalid platform specified!') + console.error('Usage: node scripts/check-ytdlp.js [win|mac|linux]') + process.exit(1) + } + + const ytdlpPath = path.join(__dirname, '..', 'resources', filename) + + if (!fs.existsSync(ytdlpPath)) { + console.error(`❌ Error: resources/${filename} not found!`) + console.error(`Please download ${filename} to the resources/ directory first.`) + console.error('You can download it from: https://github.com/yt-dlp/yt-dlp/releases/latest') + process.exit(1) + } + + console.log(`✅ ${filename} found in resources/ directory`) +} + +// Get platform from command line arguments +const platform = process.argv[2] + +if (!platform) { + console.error('❌ Error: Platform argument is required!') + console.error('Usage: node scripts/check-ytdlp.js [win|mac|linux]') + process.exit(1) +} + +// Run the check +checkYtDlpExists(platform)