chore: separate windows install script
This commit is contained in:
parent
57110d2bd7
commit
e322e46e4b
@ -27,7 +27,8 @@
|
|||||||
"copy:assets:tauri": "cpx \"pre-install/*.tgz\" \"src-tauri/resources/pre-install/\" && cpx \"LICENSE\" \"src-tauri/resources/\"",
|
"copy:assets:tauri": "cpx \"pre-install/*.tgz\" \"src-tauri/resources/pre-install/\" && cpx \"LICENSE\" \"src-tauri/resources/\"",
|
||||||
"download:lib": "node ./scripts/download-lib.mjs",
|
"download:lib": "node ./scripts/download-lib.mjs",
|
||||||
"download:bin": "node ./scripts/download-bin.mjs",
|
"download:bin": "node ./scripts/download-bin.mjs",
|
||||||
"build:tauri:win32": "yarn download:bin && yarn download:lib && yarn tauri build",
|
"download:windows-installer": "node ./scripts/download-win-installer-deps.mjs",
|
||||||
|
"build:tauri:win32": "yarn download:bin && yarn download:lib && yarn download:windows-installer && yarn tauri build",
|
||||||
"build:tauri:linux": "yarn download:bin && yarn download:lib && NO_STRIP=1 ./src-tauri/build-utils/shim-linuxdeploy.sh yarn tauri build && ./src-tauri/build-utils/buildAppImage.sh",
|
"build:tauri:linux": "yarn download:bin && yarn download:lib && NO_STRIP=1 ./src-tauri/build-utils/shim-linuxdeploy.sh yarn tauri build && ./src-tauri/build-utils/buildAppImage.sh",
|
||||||
"build:tauri:darwin": "yarn download:bin && yarn tauri build --target universal-apple-darwin",
|
"build:tauri:darwin": "yarn download:bin && yarn tauri build --target universal-apple-darwin",
|
||||||
"build:tauri": "yarn build:icon && yarn copy:assets:tauri && run-script-os",
|
"build:tauri": "yarn build:icon && yarn copy:assets:tauri && run-script-os",
|
||||||
|
|||||||
@ -77,25 +77,6 @@ async function main() {
|
|||||||
// Expect EEXIST error
|
// Expect EEXIST error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download VC++ Redistributable 17
|
|
||||||
if (platform == 'win32') {
|
|
||||||
const vcFilename = 'vc_redist.x64.exe'
|
|
||||||
const vcUrl = 'https://aka.ms/vs/17/release/vc_redist.x64.exe'
|
|
||||||
|
|
||||||
console.log(`Downloading VC++ Redistributable...`)
|
|
||||||
const vcSavePath = path.join(tempDir, vcFilename)
|
|
||||||
if (!fs.existsSync(vcSavePath)) {
|
|
||||||
await download(vcUrl, vcSavePath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy to tauri resources
|
|
||||||
try {
|
|
||||||
copySync(vcSavePath, libDir)
|
|
||||||
} catch (err) {
|
|
||||||
// Expect EEXIST error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Downloads completed.')
|
console.log('Downloads completed.')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
83
scripts/download-win-installer-deps.mjs
Normal file
83
scripts/download-win-installer-deps.mjs
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
console.log('Downloading Windows installer dependencies...')
|
||||||
|
// scripts/download-win-installer-deps.mjs
|
||||||
|
import https from 'https'
|
||||||
|
import fs, { mkdirSync } from 'fs'
|
||||||
|
import os from 'os'
|
||||||
|
import path from 'path'
|
||||||
|
import { copySync } from 'cpx'
|
||||||
|
|
||||||
|
function download(url, dest) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
console.log(`Downloading ${url} to ${dest}`)
|
||||||
|
const file = fs.createWriteStream(dest)
|
||||||
|
https
|
||||||
|
.get(url, (response) => {
|
||||||
|
console.log(`Response status code: ${response.statusCode}`)
|
||||||
|
if (
|
||||||
|
response.statusCode >= 300 &&
|
||||||
|
response.statusCode < 400 &&
|
||||||
|
response.headers.location
|
||||||
|
) {
|
||||||
|
// Handle redirect
|
||||||
|
const redirectURL = response.headers.location
|
||||||
|
console.log(`Redirecting to ${redirectURL}`)
|
||||||
|
download(redirectURL, dest).then(resolve, reject) // Recursive call
|
||||||
|
return
|
||||||
|
} else if (response.statusCode !== 200) {
|
||||||
|
reject(`Failed to get '${url}' (${response.statusCode})`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.pipe(file)
|
||||||
|
file.on('finish', () => {
|
||||||
|
file.close(resolve)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.on('error', (err) => {
|
||||||
|
fs.unlink(dest, () => reject(err.message))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
console.log('Starting Windows installer dependencies download')
|
||||||
|
const platform = os.platform() // 'darwin', 'linux', 'win32'
|
||||||
|
const arch = os.arch() // 'x64', 'arm64', etc.
|
||||||
|
|
||||||
|
if (arch != 'x64') return
|
||||||
|
|
||||||
|
|
||||||
|
const libDir = 'src-tauri/resources/lib'
|
||||||
|
const tempDir = 'scripts/dist'
|
||||||
|
|
||||||
|
try {
|
||||||
|
mkdirSync('scripts/dist')
|
||||||
|
} catch (err) {
|
||||||
|
// Expect EEXIST error if the directory already exists
|
||||||
|
}
|
||||||
|
|
||||||
|
// Download VC++ Redistributable 17
|
||||||
|
if (platform == 'win32') {
|
||||||
|
const vcFilename = 'vc_redist.x64.exe'
|
||||||
|
const vcUrl = 'https://aka.ms/vs/17/release/vc_redist.x64.exe'
|
||||||
|
|
||||||
|
console.log(`Downloading VC++ Redistributable...`)
|
||||||
|
const vcSavePath = path.join(tempDir, vcFilename)
|
||||||
|
if (!fs.existsSync(vcSavePath)) {
|
||||||
|
await download(vcUrl, vcSavePath)
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy to tauri resources
|
||||||
|
try {
|
||||||
|
copySync(vcSavePath, libDir)
|
||||||
|
} catch (err) {
|
||||||
|
// Expect EEXIST error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Windows installer dependencies downloads completed.')
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((err) => {
|
||||||
|
console.error('Error:', err)
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
Loading…
x
Reference in New Issue
Block a user