mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-10 23:59:45 +08:00
fix(install): update return codes for bun and uv installation scripts (#8039)
This commit is contained in:
parent
16ca373c55
commit
ea40cc7692
@ -43,7 +43,7 @@ async function downloadBunBinary(platform, arch, version = DEFAULT_BUN_VERSION,
|
|||||||
|
|
||||||
if (!packageName) {
|
if (!packageName) {
|
||||||
console.error(`No binary available for ${platformKey}`)
|
console.error(`No binary available for ${platformKey}`)
|
||||||
return false
|
return 101
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create output directory structure
|
// Create output directory structure
|
||||||
@ -86,7 +86,7 @@ async function downloadBunBinary(platform, arch, version = DEFAULT_BUN_VERSION,
|
|||||||
fs.chmodSync(outputPath, 0o755)
|
fs.chmodSync(outputPath, 0o755)
|
||||||
} catch (chmodError) {
|
} catch (chmodError) {
|
||||||
console.error(`Warning: Failed to set executable permissions on ${filename}`)
|
console.error(`Warning: Failed to set executable permissions on ${filename}`)
|
||||||
return false
|
return 102
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(`Extracted ${entry.name} -> ${outputPath}`)
|
console.log(`Extracted ${entry.name} -> ${outputPath}`)
|
||||||
@ -97,8 +97,10 @@ async function downloadBunBinary(platform, arch, version = DEFAULT_BUN_VERSION,
|
|||||||
// Clean up
|
// Clean up
|
||||||
fs.unlinkSync(tempFilename)
|
fs.unlinkSync(tempFilename)
|
||||||
console.log(`Successfully installed bun ${version} for ${platformKey}`)
|
console.log(`Successfully installed bun ${version} for ${platformKey}`)
|
||||||
return true
|
return 0
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
let retCode = 103
|
||||||
|
|
||||||
console.error(`Error installing bun for ${platformKey}: ${error.message}`)
|
console.error(`Error installing bun for ${platformKey}: ${error.message}`)
|
||||||
// Clean up temporary file if it exists
|
// Clean up temporary file if it exists
|
||||||
if (fs.existsSync(tempFilename)) {
|
if (fs.existsSync(tempFilename)) {
|
||||||
@ -114,9 +116,10 @@ async function downloadBunBinary(platform, arch, version = DEFAULT_BUN_VERSION,
|
|||||||
}
|
}
|
||||||
} catch (cleanupError) {
|
} catch (cleanupError) {
|
||||||
console.warn(`Warning: Failed to clean up directory: ${cleanupError.message}`)
|
console.warn(`Warning: Failed to clean up directory: ${cleanupError.message}`)
|
||||||
|
retCode = 104
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return retCode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,16 +162,21 @@ async function installBun() {
|
|||||||
`Installing bun ${version} for ${platform}-${arch}${isMusl ? ' (MUSL)' : ''}${isBaseline ? ' (baseline)' : ''}...`
|
`Installing bun ${version} for ${platform}-${arch}${isMusl ? ' (MUSL)' : ''}${isBaseline ? ' (baseline)' : ''}...`
|
||||||
)
|
)
|
||||||
|
|
||||||
await downloadBunBinary(platform, arch, version, isMusl, isBaseline)
|
return await downloadBunBinary(platform, arch, version, isMusl, isBaseline)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the installation
|
// Run the installation
|
||||||
installBun()
|
installBun()
|
||||||
.then(() => {
|
.then((retCode) => {
|
||||||
|
if (retCode === 0) {
|
||||||
console.log('Installation successful')
|
console.log('Installation successful')
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
|
} else {
|
||||||
|
console.error('Installation failed')
|
||||||
|
process.exit(retCode)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Installation failed:', error)
|
console.error('Installation failed:', error)
|
||||||
process.exit(1)
|
process.exit(100)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -44,7 +44,7 @@ async function downloadUvBinary(platform, arch, version = DEFAULT_UV_VERSION, is
|
|||||||
|
|
||||||
if (!packageName) {
|
if (!packageName) {
|
||||||
console.error(`No binary available for ${platformKey}`)
|
console.error(`No binary available for ${platformKey}`)
|
||||||
return false
|
return 101
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create output directory structure
|
// Create output directory structure
|
||||||
@ -85,7 +85,7 @@ async function downloadUvBinary(platform, arch, version = DEFAULT_UV_VERSION, is
|
|||||||
fs.chmodSync(outputPath, 0o755)
|
fs.chmodSync(outputPath, 0o755)
|
||||||
} catch (chmodError) {
|
} catch (chmodError) {
|
||||||
console.error(`Warning: Failed to set executable permissions on ${filename}`)
|
console.error(`Warning: Failed to set executable permissions on ${filename}`)
|
||||||
return false
|
return 102
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(`Extracted ${entry.name} -> ${outputPath}`)
|
console.log(`Extracted ${entry.name} -> ${outputPath}`)
|
||||||
@ -95,8 +95,10 @@ async function downloadUvBinary(platform, arch, version = DEFAULT_UV_VERSION, is
|
|||||||
await zip.close()
|
await zip.close()
|
||||||
fs.unlinkSync(tempFilename)
|
fs.unlinkSync(tempFilename)
|
||||||
console.log(`Successfully installed uv ${version} for ${platform}-${arch}`)
|
console.log(`Successfully installed uv ${version} for ${platform}-${arch}`)
|
||||||
return true
|
return 0
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
let retCode = 103
|
||||||
|
|
||||||
console.error(`Error installing uv for ${platformKey}: ${error.message}`)
|
console.error(`Error installing uv for ${platformKey}: ${error.message}`)
|
||||||
|
|
||||||
if (fs.existsSync(tempFilename)) {
|
if (fs.existsSync(tempFilename)) {
|
||||||
@ -112,9 +114,10 @@ async function downloadUvBinary(platform, arch, version = DEFAULT_UV_VERSION, is
|
|||||||
}
|
}
|
||||||
} catch (cleanupError) {
|
} catch (cleanupError) {
|
||||||
console.warn(`Warning: Failed to clean up directory: ${cleanupError.message}`)
|
console.warn(`Warning: Failed to clean up directory: ${cleanupError.message}`)
|
||||||
|
retCode = 104
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return retCode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,16 +157,21 @@ async function installUv() {
|
|||||||
|
|
||||||
console.log(`Installing uv ${version} for ${platform}-${arch}${isMusl ? ' (MUSL)' : ''}...`)
|
console.log(`Installing uv ${version} for ${platform}-${arch}${isMusl ? ' (MUSL)' : ''}...`)
|
||||||
|
|
||||||
await downloadUvBinary(platform, arch, version, isMusl)
|
return await downloadUvBinary(platform, arch, version, isMusl)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the installation
|
// Run the installation
|
||||||
installUv()
|
installUv()
|
||||||
.then(() => {
|
.then((retCode) => {
|
||||||
|
if (retCode === 0) {
|
||||||
console.log('Installation successful')
|
console.log('Installation successful')
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
|
} else {
|
||||||
|
console.error('Installation failed')
|
||||||
|
process.exit(retCode)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Installation failed:', error)
|
console.error('Installation failed:', error)
|
||||||
process.exit(1)
|
process.exit(100)
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user