mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-08-18 03:57:02 +08:00
chore: 修改打包配置
This commit is contained in:
+3
-2
@@ -26,6 +26,7 @@
|
|||||||
"test:skill-install": "node scripts/test-skill-install-instruction.cjs",
|
"test:skill-install": "node scripts/test-skill-install-instruction.cjs",
|
||||||
"cp:env": "node scripts/ensure-env.cjs",
|
"cp:env": "node scripts/ensure-env.cjs",
|
||||||
"prepare:env": "node scripts/ensure-env.cjs",
|
"prepare:env": "node scripts/ensure-env.cjs",
|
||||||
|
"prepare:ffmpeg:win": "node scripts/prepare-electron-runtime.cjs --platform win32 --arch x64",
|
||||||
"start": "electron-vite preview",
|
"start": "electron-vite preview",
|
||||||
"dev": "node scripts/ensure-env.cjs && node scripts/build-wechat-connector.cjs && electron-vite dev",
|
"dev": "node scripts/ensure-env.cjs && node scripts/build-wechat-connector.cjs && electron-vite dev",
|
||||||
"test:wechat-connector": "go -C services/wechat-connector test ./... && go -C services/wechat-connector vet ./...",
|
"test:wechat-connector": "go -C services/wechat-connector test ./... && go -C services/wechat-connector vet ./...",
|
||||||
@@ -43,12 +44,12 @@
|
|||||||
"build": "npm run typecheck && npm run build:native-services && electron-vite build",
|
"build": "npm run typecheck && npm run build:native-services && electron-vite build",
|
||||||
"postinstall": "electron-builder install-app-deps && node scripts/prepare-electron-runtime.cjs",
|
"postinstall": "electron-builder install-app-deps && node scripts/prepare-electron-runtime.cjs",
|
||||||
"build:unpack": "npm run build && electron-builder --config electron-builder.yml --dir",
|
"build:unpack": "npm run build && electron-builder --config electron-builder.yml --dir",
|
||||||
"build:win": "npm run typecheck && npm run build:wechat-connector:win && electron-vite build && electron-builder --config electron-builder.yml --win --x64",
|
"build:win": "npm run typecheck && npm run build:wechat-connector:win && npm run prepare:ffmpeg:win && electron-vite build && electron-builder --config electron-builder.yml --win --x64",
|
||||||
"build:mac:x64": "npm run typecheck && node scripts/build-wechat-connector.cjs --platform darwin --arch x64 && electron-vite build && electron-builder --config electron-builder.yml --mac --x64",
|
"build:mac:x64": "npm run typecheck && node scripts/build-wechat-connector.cjs --platform darwin --arch x64 && electron-vite build && electron-builder --config electron-builder.yml --mac --x64",
|
||||||
"build:mac:arm64": "npm run typecheck && node scripts/build-wechat-connector.cjs --platform darwin --arch arm64 && electron-vite build && electron-builder --config electron-builder.yml --mac --arm64",
|
"build:mac:arm64": "npm run typecheck && node scripts/build-wechat-connector.cjs --platform darwin --arch arm64 && electron-vite build && electron-builder --config electron-builder.yml --mac --arm64",
|
||||||
"release": "npm run release:mac && npm run release:win",
|
"release": "npm run release:mac && npm run release:win",
|
||||||
"release:mac": "npm run typecheck && npm run build:wechat-connector:mac && electron-vite build && electron-builder --config electron-builder.yml --mac --x64 --arm64 --publish always",
|
"release:mac": "npm run typecheck && npm run build:wechat-connector:mac && electron-vite build && electron-builder --config electron-builder.yml --mac --x64 --arm64 --publish always",
|
||||||
"release:win": "npm run typecheck && npm run build:wechat-connector:win && electron-vite build && electron-builder --config electron-builder.yml --win --x64 --publish always",
|
"release:win": "npm run typecheck && npm run build:wechat-connector:win && npm run prepare:ffmpeg:win && electron-vite build && electron-builder --config electron-builder.yml --win --x64 --publish always",
|
||||||
"release:beta": "cross-env RELEASE_TYPE=prerelease npm run release",
|
"release:beta": "cross-env RELEASE_TYPE=prerelease npm run release",
|
||||||
"release:stable": "cross-env RELEASE_TYPE=release npm run release",
|
"release:stable": "cross-env RELEASE_TYPE=release npm run release",
|
||||||
"build:linux": "electron-vite build && electron-builder --config electron-builder.yml --linux"
|
"build:linux": "electron-vite build && electron-builder --config electron-builder.yml --linux"
|
||||||
|
|||||||
@@ -19,24 +19,49 @@ function copyIfDifferent(sourcePath, targetPath) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareFfmpegRuntime() {
|
function readOption(name, fallback) {
|
||||||
let ffmpegPath = ''
|
const index = process.argv.indexOf(`--${name}`)
|
||||||
|
return index >= 0 && process.argv[index + 1] ? process.argv[index + 1] : fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepareFfmpegRuntime(targetPlatform = process.platform, targetArch = process.arch) {
|
||||||
|
let packageRoot = ''
|
||||||
try {
|
try {
|
||||||
ffmpegPath = require('ffmpeg-static') || ''
|
packageRoot = path.dirname(require.resolve('ffmpeg-static/package.json'))
|
||||||
} catch {
|
} catch {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!ffmpegPath || !fs.existsSync(ffmpegPath) || process.platform === 'win32') return
|
const executable = targetPlatform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg'
|
||||||
|
const ffmpegPath = path.join(packageRoot, executable)
|
||||||
|
|
||||||
|
if (!fs.existsSync(ffmpegPath)) {
|
||||||
|
const installScript = path.join(packageRoot, 'install.js')
|
||||||
|
console.log(
|
||||||
|
`[prepare-electron-runtime] downloading ffmpeg-static for ${targetPlatform}-${targetArch}`
|
||||||
|
)
|
||||||
|
execFileSync(process.execPath, [installScript], {
|
||||||
|
stdio: 'inherit',
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
npm_config_platform: targetPlatform,
|
||||||
|
npm_config_arch: targetArch
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fs.existsSync(ffmpegPath)) {
|
||||||
|
throw new Error(`ffmpeg-static runtime download failed: ${ffmpegPath}`)
|
||||||
|
}
|
||||||
|
if (targetPlatform === 'win32') return
|
||||||
|
|
||||||
fs.chmodSync(ffmpegPath, 0o755)
|
fs.chmodSync(ffmpegPath, 0o755)
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
execFileSync('/usr/bin/codesign', ['--force', '--sign', '-', ffmpegPath], {
|
execFileSync('/usr/bin/codesign', ['--force', '--sign', '-', ffmpegPath], { stdio: 'ignore' })
|
||||||
stdio: 'ignore'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
prepareFfmpegRuntime()
|
prepareFfmpegRuntime(readOption('platform', process.platform), readOption('arch', process.arch))
|
||||||
if (process.platform !== 'win32') return
|
if (process.platform !== 'win32') return
|
||||||
|
|
||||||
const projectRoot = path.resolve(__dirname, '..')
|
const projectRoot = path.resolve(__dirname, '..')
|
||||||
|
|||||||
Reference in New Issue
Block a user