Skip to content

Commit f1671d5

Browse files
committed
fix(build): 自动准备本地媒体工具资源
1 parent 1c02cb2 commit f1671d5

File tree

6 files changed

+485
-3
lines changed

6 files changed

+485
-3
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ jobs:
129129
Remove-Item fpcalc.zip -Force
130130
Remove-Item fpcalc_unzip -Recurse -Force
131131
132+
- name: Validate bundled media tools (Windows)
133+
run: node scripts/validate-bundled-media-tools.mjs --mode package --platform-key win32-x64
134+
132135
- name: Build Rust N-API (rust_package)
133136
working-directory: rust_package
134137
run: npx --yes @napi-rs/cli@2.18.4 build --platform --release --target x86_64-pc-windows-msvc
@@ -420,6 +423,9 @@ jobs:
420423
rm -rf fpcalc-mac.tar.gz chromaprint-fpcalc-${CHROMAPRINT_VERSION}-macos-universal
421424
ls -l vendor/chromaprint/darwin
422425
426+
- name: Validate bundled media tools (macOS)
427+
run: node scripts/validate-bundled-media-tools.mjs --mode package --platform-key darwin-universal
428+
423429
- name: Build Rust N-API for mac (both arch)
424430
working-directory: rust_package
425431
run: |

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,18 @@
147147
"dev": "node scripts/run-frkb-dev.mjs",
148148
"dev:release-runtime": "node scripts/run-frkb-dev.mjs --release-runtime",
149149
"build": "electron-vite build",
150+
"media-tools:ensure": "node scripts/ensure-bundled-media-tools.mjs --mode dev",
151+
"media-tools:ensure:package": "node scripts/ensure-bundled-media-tools.mjs --mode package",
152+
"media-tools:ensure:win": "node scripts/ensure-bundled-media-tools.mjs --mode package --platform-key win32-x64",
153+
"media-tools:validate": "node scripts/validate-bundled-media-tools.mjs --mode dev",
154+
"media-tools:validate:package": "node scripts/validate-bundled-media-tools.mjs --mode package",
155+
"media-tools:validate:win": "node scripts/validate-bundled-media-tools.mjs --mode package --platform-key win32-x64",
156+
"media-tools:validate:mac-universal": "node scripts/validate-bundled-media-tools.mjs --mode package --platform-key darwin-universal",
150157
"postinstall": "electron-builder install-app-deps",
151158
"clean": "rimraf dist",
152-
"build:unpack": "npm run build && npm run rekordbox:runtime:ensure && npm run rekordbox:runtime:validate && electron-builder --dir",
153-
"build:win": "npm run clean && npm run build && npm run rekordbox:runtime:ensure && npm run rekordbox:runtime:validate && electron-builder --win",
154-
"build:mac": "npm run clean && npm run build && npm run rekordbox:runtime:ensure:mac-universal && npm run rekordbox:runtime:validate:mac-universal && electron-builder --mac",
159+
"build:unpack": "npm run media-tools:ensure:package && npm run build && npm run rekordbox:runtime:ensure && npm run rekordbox:runtime:validate && electron-builder --dir",
160+
"build:win": "npm run clean && npm run media-tools:ensure:win && npm run build && npm run rekordbox:runtime:ensure && npm run rekordbox:runtime:validate && electron-builder --win",
161+
"build:mac": "npm run clean && npm run media-tools:validate:mac-universal && npm run build && npm run rekordbox:runtime:ensure:mac-universal && npm run rekordbox:runtime:validate:mac-universal && electron-builder --mac",
155162
"build:linux": "npm run clean && npm run build && electron-builder --linux",
156163
"demucs:runtime:prepare": "node scripts/prepare-demucs-runtimes.mjs",
157164
"demucs:runtime:ensure": "node scripts/ensure-demucs-runtime.mjs",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {
2+
ensureBundledMediaTools,
3+
logMediaToolsValidationResult,
4+
parseMediaToolsCliOptions
5+
} from './lib/media-tools.mjs'
6+
7+
try {
8+
const options = parseMediaToolsCliOptions(process.argv.slice(2))
9+
const result = await ensureBundledMediaTools(options)
10+
if (result.changed) {
11+
console.log(
12+
`[media-tools] Auto-prepared bundled tools for ${result.platformKey} under ${result.vendorRoot}`
13+
)
14+
}
15+
if (!logMediaToolsValidationResult(result)) {
16+
process.exit(1)
17+
}
18+
} catch (error) {
19+
const message =
20+
error instanceof Error
21+
? [String(error.message || '').trim(), String(error.cause || '').trim()]
22+
.filter(Boolean)
23+
.join('\n')
24+
: String(error || 'unknown error')
25+
console.error(message)
26+
process.exit(1)
27+
}

0 commit comments

Comments
 (0)