mirror of https://github.com/aminya/setup-cpp
feat: add binary-based powershell installation
This commit is contained in:
parent
35ec48abe6
commit
555cb15f76
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,18 +1,88 @@
|
|||
import { execRootSync } from "admina"
|
||||
import { error } from "ci-log"
|
||||
import { addPath } from "envosman"
|
||||
import { addExeExt } from "patha"
|
||||
import { installAptPack } from "setup-apt"
|
||||
import { rcOptions } from "../cli-options.js"
|
||||
import { hasDnf } from "../utils/env/hasDnf.js"
|
||||
import { isArch } from "../utils/env/isArch.js"
|
||||
import { isUbuntu } from "../utils/env/isUbuntu.js"
|
||||
import { ubuntuVersion } from "../utils/env/ubuntu_version.js"
|
||||
import { extractTarByExe, extractZip } from "../utils/setup/extract.js"
|
||||
import { type PackageInfo, setupBin } from "../utils/setup/setupBin.js"
|
||||
import { setupBrewPack } from "../utils/setup/setupBrewPack.js"
|
||||
import { setupChocoPack } from "../utils/setup/setupChocoPack.js"
|
||||
import { setupDnfPack } from "../utils/setup/setupDnfPack.js"
|
||||
import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
|
||||
|
||||
/** Get the platform data for cmake */
|
||||
function getPowerShellPackageInfo(version: string, platform: NodeJS.Platform, arch: string): PackageInfo {
|
||||
const binFileName = addExeExt("pwsh")
|
||||
|
||||
switch (platform) {
|
||||
case "win32": {
|
||||
const osArchStr = (["ia32", "x86", "i386", "x32"].includes(arch))
|
||||
? "win-x86"
|
||||
: "win-x64"
|
||||
|
||||
return {
|
||||
binRelativeDir: "",
|
||||
binFileName,
|
||||
extractedFolderName: "",
|
||||
extractFunction: extractZip,
|
||||
url:
|
||||
`https://github.com/PowerShell/PowerShell/releases/download/v${version}/PowerShell-${version}-${osArchStr}.zip`,
|
||||
}
|
||||
}
|
||||
case "darwin": {
|
||||
const osArchStr = ["arm", "arm64"].includes(arch) ? "osx-arm64" : "osx-x64"
|
||||
|
||||
return {
|
||||
binRelativeDir: "",
|
||||
binFileName,
|
||||
extractedFolderName: "",
|
||||
extractFunction: extractTarByExe,
|
||||
url:
|
||||
`https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-${osArchStr}.tar.gz`,
|
||||
}
|
||||
}
|
||||
case "linux": {
|
||||
const archMap = {
|
||||
arm64: "linux-arm64",
|
||||
arm: "linux-arm64",
|
||||
arm32: "linux-arm32",
|
||||
aarch64: "linux-arm64",
|
||||
x64: "linux-x64",
|
||||
} as Record<string, string | undefined>
|
||||
const osArchStr = archMap[arch] ?? "linux-x64"
|
||||
// TODO support musl
|
||||
|
||||
return {
|
||||
binRelativeDir: "",
|
||||
binFileName,
|
||||
extractedFolderName: "",
|
||||
extractFunction: extractTarByExe,
|
||||
url:
|
||||
`https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-${osArchStr}.tar.gz`,
|
||||
}
|
||||
}
|
||||
default:
|
||||
throw new Error(`Unsupported platform '${platform}'`)
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export async function setupPowershell(version: string | undefined, _setupDir: string, _arch: string) {
|
||||
export async function setupPowershell(version: string, setupDir: string, arch: string) {
|
||||
try {
|
||||
return await setupBin("pwsh", version, getPowerShellPackageInfo, setupDir, arch)
|
||||
} catch (err) {
|
||||
error(`Failed to setup pwsh via download: ${err}. Trying package managers...`)
|
||||
return setupPowershellSystem(version, setupDir, arch)
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export async function setupPowershellSystem(version: string | undefined, _setupDir: string, _arch: string) {
|
||||
switch (process.platform) {
|
||||
case "win32": {
|
||||
await setupChocoPack("powershell-core", version)
|
||||
|
|
|
@ -32,6 +32,7 @@ export const DefaultVersions: Record<string, string | undefined> = {
|
|||
doxygen: isArch() ? "1.11.0-4" : "1.11.0", // https://www.doxygen.nl/download.html // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=doxygen // https://formulae.brew.sh/formula/doxygen // https://archlinux.org/packages/extra/x86_64/doxygen/
|
||||
gcc: isArch() ? "13.2.1-3" : "13", // https://github.com/brechtsanders/winlibs_mingw/releases and // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=gcc
|
||||
// mingw: isArch() ? "12.2.0-1" : "8", // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=mingw-w64 // https://archlinux.org/packages/extra/x86_64/mingw-w64-gcc/
|
||||
powershell: "7.4.5", // https://github.com/PowerShell/PowerShell/releases/tag/v7.4.5
|
||||
}
|
||||
|
||||
export const MinVersions: Record<string, string | undefined> = {
|
||||
|
|
Loading…
Reference in New Issue