fix: add biome linter + fix the issues

This commit is contained in:
Amin Yahyaabadi 2024-08-06 23:44:32 -07:00
parent 34bb783813
commit 4ab758d47f
No known key found for this signature in database
GPG Key ID: F52AF77F636088F0
75 changed files with 7621 additions and 6125 deletions

View File

@ -1,3 +1,8 @@
{
"recommendations": ["orta.vscode-jest", "esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
"recommendations": [
"orta.vscode-jest",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"biomejs.biome"
]
}

50
biome.jsonc Normal file
View File

@ -0,0 +1,50 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
"files": {
"ignore": [
"**/node_modules/**",
"**/.pnpm-store/**",
"**/dist/**",
"dev/cpp_vcpkg_project/**/*",
"**/.venv/",
"**/.*cache/"
],
"ignoreUnknown": true
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"style": {
"noInferrableTypes": "off",
"noUselessElse": "off",
"noNonNullAssertion": "off",
"useNodejsImportProtocol": "off"
},
"complexity": {
"useLiteralKeys": "off"
},
"suspicious": {
"noConfusingVoidType": "off"
}
}
},
"formatter": {
"enabled": false,
"indentWidth": 4,
"indentStyle": "space"
},
"json": {
"formatter": {
"enabled": false,
"trailingCommas": "none"
},
"parser": {
"allowComments": true,
"allowTrailingCommas": true
}
}
}

View File

@ -15,6 +15,8 @@ words:
- hadolint
- aminya
- applellvm
- biome
- biomejs
- bazel
- bazelisk
- buildtools

View File

@ -34,7 +34,7 @@ function main() {
`./exe/setup-cpp-${process.arch}-${getPlatformName()}${exe}`,
"--",
`{{caxa}}/node_modules/.bin/node${exe}`,
`{{caxa}}/setup-cpp.js`,
"{{caxa}}/setup-cpp.js",
])
),
)

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

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

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

View File

@ -7,7 +7,9 @@
"typescript": {
"semiColons": "asi",
"quoteProps": "asNeeded",
"useBraces": "always"
"useBraces": "always",
"module.sortImportDeclarations": "maintain",
"importDeclaration.sortNamedImports": "maintain"
},
"json": {},
"markdown": {},

View File

@ -39,15 +39,17 @@
"dev": "cross-env NODE_ENV=development parcel watch",
"docs": "shx rm -rf packages/*/README.md && pnpm -r exec readme --path ../../dev/readme/template.md -y && pnpm -r exec ts-readme",
"format": "run-s lint.dprint",
"lint": "run-p --aggregate-output --continue-on-error lint.cspell lint.eslint lint.dprint lint.tsc",
"lint": "run-p --aggregate-output --continue-on-error lint.cspell lint.eslint lint.dprint lint.tsc lint.biome",
"lint.cspell": "cspell lint --no-progress --show-suggestions --cache --cache-location ./.cache/cspell/.cspellcache",
"lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix",
"lint.biome": "biome check --write --unsafe",
"lint.dprint": "dprint fmt",
"lint.tsc": "tsc --noEmit",
"lint.tsc": "tsc --noEmit --pretty",
"pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && node ./dev/scripts/pack-exe.mjs",
"prepublishOnly": "rm ./dist/tsconfig.tsbuildinfo",
"test.lint": "run-p --aggregate-output --continue-on-error lint.cspell test.lint.eslint test.lint.dprint lint.tsc",
"test.lint": "run-p --aggregate-output --continue-on-error lint.cspell test.lint.eslint test.lint.dprint lint.tsc test.lint.biome",
"test.lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/",
"test.lint.biome": "biome check",
"test.lint.dprint": "dprint check",
"test": "jest --runInBand --forceExit --coverage",
"build.docker-ci": "node ./dev/docker/ci/docker-ci.mjs"
@ -58,6 +60,7 @@
"@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1",
"@babel/cli": "^7.24.1",
"@biomejs/biome": "^1.8.3",
"@shockpkg/archive-files": "github:aminya/archive-files#54ec59fad46aca736ac6feb6c7bb526528141b9d",
"@swc/jest": "^0.2.36",
"@types/cross-spawn": "^6.0.6",

View File

@ -1,6 +1,6 @@
import { isSudo } from "admina"
import { homedir } from "os"
import { join } from "path"
import { isSudo } from "admina"
export function userHomeDir() {
if (isSudo() && typeof process.env.SUDO_USER === "string" && process.env.SUDO_USER !== "") {

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
import { parseArgs } from "../cli-options"
import { getCompilerInfo } from "../compilers"
import { Inputs } from "../tool"
import type { Inputs } from "../tool"
import { DefaultLinuxVersion } from "../versions/default_versions"
import { getVersion, syncVersions } from "../versions/versions"

View File

@ -1,4 +1,4 @@
import { InstallationInfo } from "../../utils/setup/setupBin"
import type { InstallationInfo } from "../../utils/setup/setupBin"
import { testBin } from "../../utils/tests/test-helpers"
import { setupBazel } from "../bazel"

View File

@ -38,10 +38,10 @@ export async function setupBazel(version: string, _setupDir: string, _arch: stri
])
return setupAptPack([{ name: "bazel", version }], true)
}
throw new Error(`Unsupported linux distribution`)
throw new Error("Unsupported linux distribution")
}
default: {
throw new Error(`Unsupported platform`)
throw new Error("Unsupported platform")
}
}
}

View File

@ -1,8 +1,8 @@
import { tmpdir } from "os"
import path, { join } from "path"
import { mkdirP } from "@actions/io"
import { execaSync } from "execa"
import { readFile } from "fs/promises"
import { tmpdir } from "os"
import path, { join } from "path"
import { dirname } from "patha"
import which from "which"
import { addPath } from "../utils/env/addEnv"

View File

@ -1,4 +1,4 @@
import { InstallationInfo } from "../../utils/setup/setupBin"
import type { InstallationInfo } from "../../utils/setup/setupBin"
import { testBin } from "../../utils/tests/test-helpers"
import { setupCcache } from "../ccache"

View File

@ -24,10 +24,10 @@ export function setupCcache(version: string, _setupDir: string, _arch: string) {
} else if (isUbuntu()) {
return setupAptPack([{ name: "ccache", version }])
}
throw new Error(`Unsupported linux distribution`)
throw new Error("Unsupported linux distribution")
}
default: {
throw new Error(`Unsupported platform`)
throw new Error("Unsupported platform")
}
}
}

View File

@ -1,4 +1,4 @@
import { InstallationInfo } from "../../utils/setup/setupBin"
import type { InstallationInfo } from "../../utils/setup/setupBin"
import { testBin } from "../../utils/tests/test-helpers"
import { setupChocolatey } from "../chocolatey"

View File

@ -4,7 +4,7 @@ import { pathExists } from "path-exists"
import { dirname } from "patha"
import which from "which"
import { addPath } from "../utils/env/addEnv"
import { InstallationInfo } from "../utils/setup/setupBin"
import type { InstallationInfo } from "../utils/setup/setupBin"
let binDir: string | undefined

View File

@ -1,8 +1,8 @@
import { getInput } from "@actions/core"
import { info } from "ci-log"
import mri from "mri"
import { Inputs, inputs } from "./tool"
import { InstallationInfo } from "./utils/setup/setupBin"
import { type Inputs, inputs } from "./tool"
import type { InstallationInfo } from "./utils/setup/setupBin"
export function parseArgs(args: string[]): Opts {
return mri<Record<Inputs, string | undefined> & { help: boolean }>(args, {
@ -31,13 +31,13 @@ All the available tools:
console.table(
{
"compiler and analyzer": { tools: `--llvm, --gcc, --msvc, --vcvarsall, --cppcheck, --clangtidy, --clangformat` },
"build system": { tools: `--cmake, --ninja, --meson, --make, --task, --bazel` },
"package manager": { tools: `--vcpkg, --conan, --choco, --brew, --nala` },
cache: { tools: `--cppcache, --sccache` },
documentation: { tools: `--doxygen, --graphviz` },
coverage: { tools: `--gcovr, --opencppcoverage, --kcov` },
other: { tools: `--python, --powershell, --sevenzip` },
"compiler and analyzer": { tools: "--llvm, --gcc, --msvc, --vcvarsall, --cppcheck, --clangtidy, --clangformat" },
"build system": { tools: "--cmake, --ninja, --meson, --make, --task, --bazel" },
"package manager": { tools: "--vcpkg, --conan, --choco, --brew, --nala" },
cache: { tools: "--cppcache, --sccache" },
documentation: { tools: "--doxygen, --graphviz" },
coverage: { tools: "--gcovr, --opencppcoverage, --kcov" },
other: { tools: "--python, --powershell, --sevenzip" },
},
["tools"],
)

View File

@ -3,7 +3,7 @@ import { addExeExt } from "patha"
import semverCoerce from "semver/functions/coerce"
import semverLte from "semver/functions/lte"
import { extractZip } from "../utils/setup/extract"
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
import { type InstallationInfo, type PackageInfo, setupBin } from "../utils/setup/setupBin"
/** Get the platform data for cmake */
function getCmakePackageInfo(version: string, platform: NodeJS.Platform, arch: string): PackageInfo {

View File

@ -1,6 +1,6 @@
import { join } from "path"
import { endGroup, notice, startGroup } from "@actions/core"
import { error, info } from "ci-log"
import { join } from "path"
import semverValid from "semver/functions/valid"
import { getSuccessMessage } from "./cli-options"
import { setupGcc, setupMingw } from "./gcc/gcc"

View File

@ -27,10 +27,10 @@ export async function setupCppcheck(version: string | undefined, _setupDir: stri
} else if (isUbuntu()) {
return setupAptPack([{ name: "cppcheck", version }])
}
throw new Error(`Unsupported linux distribution`)
throw new Error("Unsupported linux distribution")
}
default: {
throw new Error(`Unsupported platform`)
throw new Error("Unsupported platform")
}
}
}

View File

@ -1,7 +1,7 @@
import which from "which"
import { macosVersion } from "../../utils/env/macos_version"
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
import { InstallationInfo } from "../../utils/setup/setupBin"
import type { InstallationInfo } from "../../utils/setup/setupBin"
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { getVersion } from "../../versions/versions"
import { setupDoxygen } from "../doxygen"

View File

@ -4,7 +4,7 @@ import { setupGraphviz } from "../graphviz/graphviz"
import { addPath } from "../utils/env/addEnv"
import { extractTar, extractZip } from "../utils/setup/extract"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
import { type InstallationInfo, type PackageInfo, setupBin } from "../utils/setup/setupBin"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
@ -98,7 +98,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
} else if (isUbuntu()) {
installationInfo = await setupAptPack([{ name: "doxygen", version }])
} else {
throw new Error(`Unsupported linux distributions`)
throw new Error("Unsupported linux distributions")
}
} else if (isUbuntu()) {
try {
@ -114,13 +114,13 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
installationInfo = await setupAptPack([{ name: "doxygen" }])
}
} else {
throw new Error(`Unsupported linux distributions`)
throw new Error("Unsupported linux distributions")
}
await setupGraphviz(getVersion("graphviz", undefined, await ubuntuVersion()), "", arch)
return installationInfo
}
default: {
throw new Error(`Unsupported platform`)
throw new Error("Unsupported platform")
}
}
}
@ -145,7 +145,7 @@ async function activateWinDoxygen() {
throw new Error("Failed to find doxygen binary")
}
default: {
throw new Error(`Unsupported platform`)
throw new Error("Unsupported platform")
}
}
}

View File

@ -2,7 +2,7 @@ import { addEnv, addPath } from "../utils/env/addEnv"
import { GITHUB_ACTIONS } from "ci-info"
import { info, warning } from "ci-log"
import { ExecaReturnValue } from "execa"
import type { ExecaReturnValue } from "execa"
import { pathExists } from "path-exists"
import { addExeExt, join } from "patha"
import semverCoerce from "semver/functions/coerce"
@ -13,7 +13,7 @@ import { isArch } from "../utils/env/isArch"
import { isUbuntu } from "../utils/env/isUbuntu"
import { extract7Zip } from "../utils/setup/extract"
import { setupAptPack, updateAptAlternatives } from "../utils/setup/setupAptPack"
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
import { type InstallationInfo, type PackageInfo, setupBin } from "../utils/setup/setupBin"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { setupDnfPack } from "../utils/setup/setupDnfPack"

View File

@ -1,6 +1,6 @@
import { macosVersion } from "../../utils/env/macos_version"
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
import { InstallationInfo } from "../../utils/setup/setupBin"
import type { InstallationInfo } from "../../utils/setup/setupBin"
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { getVersion } from "../../versions/versions"
import { setupGraphviz } from "../graphviz"

View File

@ -3,7 +3,7 @@ import { hasDnf } from "../utils/env/hasDnf"
import { isArch } from "../utils/env/isArch"
import { isUbuntu } from "../utils/env/isUbuntu"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { InstallationInfo } from "../utils/setup/setupBin"
import type { InstallationInfo } from "../utils/setup/setupBin"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
@ -27,10 +27,10 @@ export async function setupGraphviz(version: string, _setupDir: string, _arch: s
} else if (isUbuntu()) {
return setupAptPack([{ name: "graphviz", version }])
}
throw new Error(`Unsupported linux distribution`)
throw new Error("Unsupported linux distribution")
}
default: {
throw new Error(`Unsupported platform`)
throw new Error("Unsupported platform")
}
}
}
@ -43,7 +43,7 @@ async function activateGraphviz(): Promise<InstallationInfo> {
return { binDir }
}
default: {
throw new Error(`Unsupported platform`)
throw new Error("Unsupported platform")
}
}
}

View File

@ -3,8 +3,8 @@ import { error } from "ci-log"
import pTimeout from "p-timeout"
import { join } from "patha"
import { getSuccessMessage } from "./cli-options"
import { setups, ToolName } from "./tool"
import { InstallationInfo } from "./utils/setup/setupBin"
import { type ToolName, setups } from "./tool"
import type { InstallationInfo } from "./utils/setup/setupBin"
import { setupVCVarsall } from "./vcvarsall/vcvarsall"
import { getVersion } from "./versions/versions"
@ -23,7 +23,7 @@ export async function installTool(
startGroup(`Installing ${tool} ${version}`)
let hasLLVM = false
try {
hasLLVM = await pTimeout(installToolImpl(tool, version, osVersion, arch, hasLLVM, setupCppDir, successMessages), {
hasLLVM = await pTimeout(installToolImpl(tool, version, osVersion, arch, setupCppDir, successMessages), {
milliseconds: timeout,
message: `Timeout while installing ${tool} ${version}. You can increase the timeout from options`,
})
@ -41,10 +41,12 @@ async function installToolImpl(
version: string,
osVersion: number[] | null,
arch: string,
hasLLVM: boolean,
setupCppDir: string,
successMessages: string[],
) {
// eslint-disable-next-line no-param-reassign
const hasLLVM = ["llvm", "clangformat", "clangtidy"].includes(tool)
let installationInfo: InstallationInfo | undefined | void
if (tool === "vcvarsall") {
// eslint-disable-next-line no-await-in-loop
@ -53,9 +55,6 @@ async function installToolImpl(
// get the setup function
const setupFunction = setups[tool]
// eslint-disable-next-line no-param-reassign
hasLLVM = ["llvm", "clangformat", "clangtidy"].includes(tool)
// the tool installation directory (for the functions that ue it)
const setupDir = join(setupCppDir, hasLLVM ? "llvm" : tool)

View File

@ -1,6 +1,6 @@
import { info } from "@actions/core"
import which from "which"
import { InstallationInfo } from "../../utils/setup/setupBin"
import type { InstallationInfo } from "../../utils/setup/setupBin"
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { setupKcov } from "../kcov"

View File

@ -11,7 +11,7 @@ import { isUbuntu } from "../utils/env/isUbuntu"
import { ubuntuVersion } from "../utils/env/ubuntu_version"
import { extractTarByExe } from "../utils/setup/extract"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
import { type InstallationInfo, type PackageInfo, setupBin } from "../utils/setup/setupBin"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
import { addVPrefix, removeVPrefix } from "../utils/setup/version"

View File

@ -8,7 +8,7 @@ import { getSpecificVersionAndUrl } from "../../utils/setup/version"
import { setupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { getVersion } from "../../versions/versions"
import { setupClangFormat, setupClangTools, setupLLVM } from "../llvm"
import { getLinuxUrl, getUrl, VERSIONS } from "../llvm_url"
import { VERSIONS, getLinuxUrl, getUrl } from "../llvm_url"
jest.setTimeout(400000)
async function testUrl(version: string) {

View File

@ -1,7 +1,7 @@
import { delimiter } from "path"
import { GITHUB_ACTIONS } from "ci-info"
import { info, warning } from "ci-log"
import memoize from "micro-memoize"
import { delimiter } from "path"
import { pathExists } from "path-exists"
import { addExeExt, join } from "patha"
import { setupGcc } from "../gcc/gcc"
@ -10,7 +10,7 @@ import { addEnv } from "../utils/env/addEnv"
import { isUbuntu } from "../utils/env/isUbuntu"
import { ubuntuVersion } from "../utils/env/ubuntu_version"
import { setupAptPack, updateAptAlternatives } from "../utils/setup/setupAptPack"
import { InstallationInfo, setupBin } from "../utils/setup/setupBin"
import { type InstallationInfo, setupBin } from "../utils/setup/setupBin"
import { semverCoerceIfInvalid } from "../utils/setup/version"
import { getVersion } from "../versions/versions"
import { LLVMPackages, setupLLVMApt } from "./llvm_installer"
@ -55,7 +55,7 @@ async function setupLLVMOnly(
packages: LLVMPackages = LLVMPackages.All,
) {
const coeredVersion = semverCoerceIfInvalid(version)
const majorVersion = parseInt(coeredVersion.split(".")[0], 10)
const majorVersion = Number.parseInt(coeredVersion.split(".")[0], 10)
try {
if (isUbuntu()) {
return await setupLLVMApt(majorVersion, packages)

View File

@ -1,16 +1,16 @@
import { execRoot } from "admina"
import { info } from "console"
import { execRoot } from "admina"
import { execa } from "execa"
import { chmod, readFile, writeFile } from "fs/promises"
import { DEFAULT_TIMEOUT } from "../installTool"
import { addPath } from "../utils/env/addEnv"
import { hasNala, isPackageInstalled, setupAptPack } from "../utils/setup/setupAptPack"
import { InstallationInfo } from "../utils/setup/setupBin"
import type { InstallationInfo } from "../utils/setup/setupBin"
export enum LLVMPackages {
All,
ClangFormat,
Core,
All = 0,
ClangFormat = 1,
Core = 2,
}
export async function setupLLVMApt(

View File

@ -3,7 +3,7 @@ import { isUrlOnline } from "is-url-online"
import { addExeExt } from "patha"
import semverLte from "semver/functions/lte"
import { extractExe, extractTarByExe } from "../utils/setup/extract"
import { PackageInfo } from "../utils/setup/setupBin"
import type { PackageInfo } from "../utils/setup/setupBin"
import { getSpecificVersionAndUrl, getSpecificVersions, getVersions } from "../utils/setup/version"
// ================================================

View File

@ -10,7 +10,7 @@ export async function setupMacOSSDK() {
if (sdkroot) {
await addEnv("SDKROOT", sdkroot.trim())
} else {
error(`SDKROOT not set`)
error("SDKROOT not set")
}
} catch (e) {
error(e as Error | string)

View File

@ -97,7 +97,7 @@ async function main(args: string[]): Promise<number> {
setupCppDir,
successMessages,
errorMessages,
parseFloat(opts.timeout ?? "20") * 60 * 1000,
Number.parseFloat(opts.timeout ?? "20") * 60 * 1000,
)
time2 = Date.now()
info(`took ${timeFormatter.format(time1, time2) || "0 seconds"}`)
@ -123,8 +123,12 @@ async function main(args: string[]): Promise<number> {
}
// report the messages in the end
successMessages.forEach((tool) => success(tool))
errorMessages.forEach((tool) => error(tool))
for (const tool of successMessages) {
success(tool)
}
for (const tool of errorMessages) {
error(tool)
}
info("setup-cpp finished")

View File

@ -1,4 +1,4 @@
import { InstallationInfo } from "../../utils/setup/setupBin"
import type { InstallationInfo } from "../../utils/setup/setupBin"
import { testBin } from "../../utils/tests/test-helpers"
import { setupMake } from "../make"

View File

@ -27,10 +27,10 @@ export async function setupMake(version: string, _setupDir: string, _arch: strin
} else if (isUbuntu()) {
return setupAptPack([{ name: "make", version }])
}
throw new Error(`Unsupported linux distribution`)
throw new Error("Unsupported linux distribution")
}
default: {
throw new Error(`Unsupported platform`)
throw new Error("Unsupported platform")
}
}
}

View File

@ -1,10 +1,10 @@
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { setupVCVarsall } from "../vcvarsall/vcvarsall"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { GITHUB_ACTIONS } from "ci-info"
import { findVcvarsall, vsversion_to_versionnumber } from "msvc-dev-cmd/lib.js"
import { join } from "patha"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { setupVCVarsall } from "../vcvarsall/vcvarsall"
import { error, info, warning } from "ci-log"
import { pathExists } from "path-exists"

View File

@ -1,6 +1,6 @@
import { addExeExt } from "patha"
import { extractZip } from "../utils/setup/extract"
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
import { type InstallationInfo, type PackageInfo, setupBin } from "../utils/setup/setupBin"
/** Get the platform name Ninja uses in their download links */
function getNinjaPlatform(platform: NodeJS.Platform) {

View File

@ -29,7 +29,7 @@ export async function setupPowershell(version: string | undefined, _setupDir: st
await setupDnfPack([{ name: "curl" }])
execRootSync("/bin/bash", [
"-c",
`curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo`,
"curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo",
])
return setupDnfPack([{ name: "powershell", version }])
} else if (isUbuntu()) {
@ -55,10 +55,10 @@ export async function setupPowershell(version: string | undefined, _setupDir: st
return setupAptPack([{ name: "powershell", version }], true)
}
throw new Error(`Unsupported linux distribution`)
throw new Error("Unsupported linux distribution")
}
default: {
throw new Error(`Unsupported platform`)
throw new Error("Unsupported platform")
}
}
}

View File

@ -1,6 +1,6 @@
import assert from "assert"
/* eslint-disable require-atomic-updates */
import { getExecOutput } from "@actions/exec"
import assert from "assert"
import { GITHUB_ACTIONS } from "ci-info"
import { info, warning } from "ci-log"
import { execa } from "execa"
@ -13,7 +13,7 @@ import { hasDnf } from "../utils/env/hasDnf"
import { isArch } from "../utils/env/isArch"
import { isUbuntu } from "../utils/env/isUbuntu"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { InstallationInfo } from "../utils/setup/setupBin"
import type { InstallationInfo } from "../utils/setup/setupBin"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { setupDnfPack } from "../utils/setup/setupDnfPack"

View File

@ -1,4 +1,4 @@
import { InstallationInfo } from "../../utils/setup/setupBin"
import type { InstallationInfo } from "../../utils/setup/setupBin"
import { testBin } from "../../utils/tests/test-helpers"
import { setupSccache } from "../sccache"

View File

@ -12,7 +12,7 @@ export function setupSccache(version: string, _setupDir: string, _arch: string)
return setupBrewPack("sccache", version)
}
default: {
throw new Error(`Unsupported platform`)
throw new Error("Unsupported platform")
}
}
}

View File

@ -1,4 +1,4 @@
import { InstallationInfo } from "../../utils/setup/setupBin"
import type { InstallationInfo } from "../../utils/setup/setupBin"
import { testBin } from "../../utils/tests/test-helpers"
import { setupSevenZip } from "../sevenzip"

View File

@ -27,10 +27,10 @@ export function setupSevenZip(version: string, _setupDir: string, _arch: string)
} else if (isUbuntu()) {
return setupAptPack([{ name: "p7zip-full", version }])
}
throw new Error(`Unsupported linux distribution`)
throw new Error("Unsupported linux distribution")
}
default: {
throw new Error(`Unsupported platform`)
throw new Error("Unsupported platform")
}
}
}

View File

@ -1,6 +1,6 @@
import { addExeExt } from "patha"
import { extractTarByExe, extractZip } from "../utils/setup/extract"
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
import { type InstallationInfo, type PackageInfo, setupBin } from "../utils/setup/setupBin"
/** Get the platform name task uses in their download links */
function getTaskPlatform(platform: NodeJS.Platform) {

View File

@ -4,10 +4,14 @@
import * as stream from "stream"
import { promisify } from "util"
// biome-ignore lint: lint/complexity/noBannedTypes
export const pipeline = "promises" in stream && "pipeline" in (stream as any).promises
// biome-ignore lint: lint/complexity/noBannedTypes
? ((stream.promises as any).pipeline as Function)
: promisify(stream.pipeline)
// biome-ignore lint: lint/complexity/noBannedTypes
export const finished = "promises" in stream && "finished" in (stream as any).promises
// biome-ignore lint: lint/complexity/noBannedTypes
? ((stream.promises as any).finished as Function)
: promisify(stream.finished)

View File

@ -1,4 +1,5 @@
import { addPath as ghAddPath, exportVariable, info, setFailed } from "@actions/core"
import { delimiter } from "path"
import { exportVariable, addPath as ghAddPath, info, setFailed } from "@actions/core"
import { grantUserWriteAccess } from "admina"
import { GITHUB_ACTIONS } from "ci-info"
import { error, warning } from "ci-log"
@ -6,7 +7,6 @@ import escapeSpace from "escape-path-with-spaces"
import escapeQuote from "escape-quotes"
import { execPowershell } from "exec-powershell"
import { appendFile, readFile, writeFile } from "fs/promises"
import { delimiter } from "path"
import { pathExists } from "path-exists"
import { untildifyUser } from "untildify-user"

View File

@ -12,6 +12,6 @@ function macosVersion_raw() {
}
const { version } = macosRelease()
return version.split(".").map((v) => parseInt(v, 10))
return version.split(".").map((v) => Number.parseInt(v, 10))
}
export const macosVersion = memoize(macosVersion_raw)

View File

@ -1,6 +1,6 @@
import os from "os"
import { warning } from "ci-log"
import memoize from "micro-memoize"
import os from "os"
import { getUbuntuVersion } from "ubuntu-version"
import which from "which"
import { setupAptPack } from "../setup/setupAptPack"
@ -45,9 +45,9 @@ function detectUsingOsVersion() {
// #46~22.04.1-Ubuntu SMP ...
const osVersion: string = os.version()
const versionSplitted = osVersion.split(".")
const majorVersion = parseInt(versionSplitted[0].replace("#", ""), 10)
const minorVersion = parseInt(versionSplitted[1].replace("~", ""), 10)
const patchVersion = parseInt(versionSplitted[2].split("-")[0], 10)
const majorVersion = Number.parseInt(versionSplitted[0].replace("#", ""), 10)
const minorVersion = Number.parseInt(versionSplitted[1].replace("~", ""), 10)
const patchVersion = Number.parseInt(versionSplitted[2].split("-")[0], 10)
return [majorVersion, minorVersion, patchVersion]
}

View File

@ -2,12 +2,12 @@ import { execRoot, execRootSync } from "admina"
import { GITHUB_ACTIONS } from "ci-info"
import { info, warning } from "ci-log"
import escapeRegex from "escape-string-regexp"
import { execa, ExecaError } from "execa"
import { type ExecaError, execa } from "execa"
import { appendFile } from "fs/promises"
import { pathExists } from "path-exists"
import which from "which"
import { addEnv, cpprc_path, sourceCpprc } from "../env/addEnv"
import { InstallationInfo } from "./setupBin"
import type { InstallationInfo } from "./setupBin"
/* eslint-disable require-atomic-updates */
let didUpdate: boolean = false
@ -75,10 +75,10 @@ export async function setupAptPack(packages: AptPackage[], update = false): Prom
}
export enum AptPackageType {
NameDashVersion,
NameEqualsVersion,
Name,
None,
NameDashVersion = 0,
NameEqualsVersion = 1,
Name = 2,
None = 3,
}
export async function aptPackageType(name: string, version: string | undefined): Promise<AptPackageType> {
@ -125,7 +125,6 @@ async function getAptArg(name: string, version: string | undefined) {
return `${name}=${version}`
case AptPackageType.Name:
return name
case AptPackageType.None:
default:
throw new Error(`Could not find package ${name} ${version ?? ""}`)
}

View File

@ -3,8 +3,8 @@ import { info } from "ci-log"
import { join } from "patha"
import { addPath } from "../env/addEnv"
import { GITHUB_ACTIONS } from "ci-info"
import { tmpdir } from "os"
import { GITHUB_ACTIONS } from "ci-info"
import { pathExists } from "path-exists"
import retry from "retry-as-promised"
import { hasDnf } from "../env/hasDnf"
@ -25,9 +25,7 @@ export type PackageInfo = {
/** The main binary file. */
binFileName: string
/** The function to extract the downloaded archive. It can be `undefined`, if the binary itself is downloaded directly. */
extractFunction?: {
(file: string, dest: string): Promise<unknown>
}
extractFunction?: (file: string, dest: string) => Promise<unknown>
}
export type InstallationInfo = {
@ -102,7 +100,7 @@ export async function setupBin(
)
if (!didInit) {
info(`Installing extraction dependencies`)
info("Installing extraction dependencies")
if (process.platform === "linux") {
if (isArch()) {
await Promise.all([setupPacmanPack("unzip"), setupPacmanPack("tar"), setupPacmanPack("xz")])

View File

@ -4,7 +4,7 @@ import { execaSync } from "execa"
import { join } from "patha"
import which from "which"
import { getBrewPath, setupBrew } from "../../brew/brew"
import { InstallationInfo } from "./setupBin"
import type { InstallationInfo } from "./setupBin"
let hasBrew = false

View File

@ -4,7 +4,7 @@ import { execaSync } from "execa"
import which from "which"
import { setupChocolatey } from "../../chocolatey/chocolatey"
import { addPath } from "../env/addEnv"
import { InstallationInfo } from "./setupBin"
import type { InstallationInfo } from "./setupBin"
let hasChoco = false
@ -20,9 +20,9 @@ export async function setupChocoPack(name: string, version?: string, args: strin
// https://github.com/jberezanski/ChocolateyPackages/issues/97#issuecomment-986825694
const PATH = process.env.PATH
const env = { ...process.env }
delete env.TMP
delete env.TEMP
delete env.Path
env.TMP = undefined
env.TEMP = undefined
env.Path = undefined
env.PATH = PATH
if (version !== undefined && version !== "") {

View File

@ -1,7 +1,7 @@
import { execRootSync } from "admina"
import { info, warning } from "ci-log"
import { execa } from "execa"
import { InstallationInfo } from "./setupBin"
import type { InstallationInfo } from "./setupBin"
type DnfPackage = {
name: string

View File

@ -2,7 +2,7 @@ import { execRootSync } from "admina"
import { info, warning } from "ci-log"
import { execa, execaSync } from "execa"
import which from "which"
import { InstallationInfo } from "./setupBin"
import type { InstallationInfo } from "./setupBin"
/* eslint-disable require-atomic-updates */
let didUpdate: boolean = false

View File

@ -14,7 +14,7 @@ import { isArch } from "../env/isArch"
import { isUbuntu } from "../env/isUbuntu"
import { ubuntuVersion } from "../env/ubuntu_version"
import { setupAptPack } from "./setupAptPack"
import { InstallationInfo } from "./setupBin"
import type { InstallationInfo } from "./setupBin"
import { setupDnfPack } from "./setupDnfPack"
import { setupPacmanPack } from "./setupPacmanPack"

View File

@ -138,7 +138,7 @@ export function semverCoerceIfInvalid(version: string) {
}
export function removeVPrefix(version: string) {
return parseInt(version.replace(/^v/, ""), 10)
return Number.parseInt(version.replace(/^v/, ""), 10)
}
export function addVPrefix(version: string) {

View File

@ -1,6 +1,6 @@
import { tmpdir } from "os"
import * as io from "@actions/io"
import spawn from "cross-spawn"
import { tmpdir } from "os"
import * as path from "patha"
import { addExeExt, join } from "patha"
@ -66,5 +66,5 @@ export function runnerWindowsVersion() {
return undefined
}
return parseInt(maybeVersionString, 10)
return Number.parseInt(maybeVersionString, 10)
}

View File

@ -9,7 +9,7 @@ import { hasDnf } from "../utils/env/hasDnf"
import { isArch } from "../utils/env/isArch"
import { isUbuntu } from "../utils/env/isUbuntu"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { InstallationInfo } from "../utils/setup/setupBin"
import type { InstallationInfo } from "../utils/setup/setupBin"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"

View File

@ -1,5 +1,5 @@
import { Opts } from "../cli-options"
import { Inputs } from "../tool"
import type { Opts } from "../cli-options"
import type { Inputs } from "../tool"
import { DefaultLinuxVersion, DefaultVersions } from "./default_versions"
/** Get the default version if passed true or undefined, otherwise return the version itself */
@ -24,7 +24,7 @@ function getDefaultLinuxVersion(osVersion: number[], toolLinuxVersions: Record<n
// find which version block the os version is in
const satisfyingVersion = Object.keys(toolLinuxVersions)
.map((v) => parseInt(v, 10))
.map((v) => Number.parseInt(v, 10))
.sort((a, b) => b - a) // sort in descending order
.find((v) => osVersionMaj >= v)
@ -47,9 +47,9 @@ export function syncVersions(opts: Opts, tools: Inputs[]): boolean {
return false
}
toolsInUse.forEach((tool) => {
for (const tool of toolsInUse) {
opts[tool] = targetVersion
})
}
return true
}