fix: fix all the linting errors

This commit is contained in:
Amin Yahyaabadi 2023-05-24 14:57:08 -07:00
parent 36a5b861ce
commit 11b44434f5
19 changed files with 56 additions and 45 deletions

View File

@ -1,4 +1,16 @@
{ {
"extends": "eslint-config-atomic", "extends": "eslint-config-atomic",
"ignorePatterns": ["dist/", "node_modules/", "dev/cpp_vcpkg_project"] "ignorePatterns": ["dist/", "node_modules/", "dev/cpp_vcpkg_project"],
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_"
}
]
}
} }

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

@ -12,7 +12,7 @@
}, },
"dependencies": { "dependencies": {
"@actions/core": "^1.9.1", "@actions/core": "^1.9.1",
"@npmcli/ci-detect": "github:aminya/ci-detect#37fe40075bebec96794ba0a7c4a6d5c70cbea00d" "ci-info": "^3.8.0"
}, },
"keywords": [ "keywords": [
"log", "log",

View File

@ -187,9 +187,9 @@ importers:
'@actions/core': '@actions/core':
specifier: ^1.9.1 specifier: ^1.9.1
version: 1.9.1 version: 1.9.1
'@npmcli/ci-detect': ci-info:
specifier: github:aminya/ci-detect#37fe40075bebec96794ba0a7c4a6d5c70cbea00d specifier: ^3.8.0
version: github.com/aminya/ci-detect/37fe40075bebec96794ba0a7c4a6d5c70cbea00d version: 3.8.0
packages/exec-powershell: packages/exec-powershell:
dependencies: dependencies:
@ -3612,7 +3612,6 @@ packages:
/ci-info@3.8.0: /ci-info@3.8.0:
resolution: {integrity: sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==} resolution: {integrity: sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==}
engines: {node: '>=8'} engines: {node: '>=8'}
dev: true
/cjs-module-lexer@1.2.2: /cjs-module-lexer@1.2.2:
resolution: {integrity: sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==} resolution: {integrity: sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==}
@ -10620,13 +10619,6 @@ packages:
'@babel/core': 7.21.4 '@babel/core': 7.21.4
dev: true dev: true
github.com/aminya/ci-detect/37fe40075bebec96794ba0a7c4a6d5c70cbea00d:
resolution: {tarball: https://codeload.github.com/aminya/ci-detect/tar.gz/37fe40075bebec96794ba0a7c4a6d5c70cbea00d}
name: '@npmcli/ci-detect'
version: 2.0.0
engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0}
dev: false
github.com/aminya/msvc-dev-cmd/9f672c1: github.com/aminya/msvc-dev-cmd/9f672c1:
resolution: {tarball: https://codeload.github.com/aminya/msvc-dev-cmd/tar.gz/9f672c1} resolution: {tarball: https://codeload.github.com/aminya/msvc-dev-cmd/tar.gz/9f672c1}
name: msvc-dev-cmd name: msvc-dev-cmd

View File

@ -7,6 +7,7 @@ import { mkdirP } from "@actions/io"
import { readFileSync } from "fs" import { readFileSync } from "fs"
import { addPath } from "../utils/env/addEnv" import { addPath } from "../utils/env/addEnv"
/* eslint-disable require-atomic-updates */
let binDir: string | undefined let binDir: string | undefined
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars

View File

@ -17,6 +17,7 @@ import { isUbuntu } from "../utils/env/isUbuntu"
import { hasDnf } from "../utils/env/hasDnf" import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack" import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { pathExists } from "path-exists" import { pathExists } from "path-exists"
import { ExecaReturnValue } from "execa"
interface MingwInfo { interface MingwInfo {
releaseName: string releaseName: string
@ -109,7 +110,7 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
} else { } else {
info(`Install g++-multilib because gcc for ${arch} was requested`) info(`Install g++-multilib because gcc for ${arch} was requested`)
if (isArch()) { if (isArch()) {
setupPacmanPack("gcc-multilib", version) await setupPacmanPack("gcc-multilib", version)
} else if (isUbuntu()) { } else if (isUbuntu()) {
await setupAptPack([{ name: "gcc-multilib", version, repositories: ["ppa:ubuntu-toolchain-r/test"] }]) await setupAptPack([{ name: "gcc-multilib", version, repositories: ["ppa:ubuntu-toolchain-r/test"] }])
} }
@ -157,7 +158,7 @@ async function setupChocoMingw(version: string, arch: string): Promise<Installat
} }
async function activateGcc(version: string, binDir: string) { async function activateGcc(version: string, binDir: string) {
const promises: Promise<any>[] = [] const promises: Promise<void | ExecaReturnValue<string>>[] = []
// Setup gcc as the compiler // Setup gcc as the compiler
// TODO // TODO

View File

@ -44,8 +44,7 @@ async function buildKcov(file: string, dest: string) {
if (process.platform === "linux") { if (process.platform === "linux") {
if (isArch()) { if (isArch()) {
setupPacmanPack("libdwarf") await Promise.all([setupPacmanPack("libdwarf"), setupPacmanPack("libcurl-openssl")])
setupPacmanPack("libcurl-openssl")
} else if (hasDnf()) { } else if (hasDnf()) {
setupDnfPack("libdwarf-devel") setupDnfPack("libdwarf-devel")
setupDnfPack("libcurl-devel") setupDnfPack("libcurl-devel")
@ -97,7 +96,7 @@ export async function setupKcov(versionGiven: string, setupDir: string, arch: st
if (installMethod === "binary" && version_number >= 39) { if (installMethod === "binary" && version_number >= 39) {
installationInfo = await setupBin("kcov", version, getDownloadKcovPackageInfo, setupDir, arch) installationInfo = await setupBin("kcov", version, getDownloadKcovPackageInfo, setupDir, arch)
if (isArch()) { if (isArch()) {
setupPacmanPack("binutils") await setupPacmanPack("binutils")
} else if (hasDnf()) { } else if (hasDnf()) {
setupDnfPack("binutils") setupDnfPack("binutils")
} else if (isUbuntu()) { } else if (isUbuntu()) {

View File

@ -1,6 +1,5 @@
import { join, addExeExt } from "patha" import { join, addExeExt } from "patha"
import { delimiter } from "path" import { delimiter } from "path"
import semverMajor from "semver/functions/major"
import { InstallationInfo, setupBin } from "../utils/setup/setupBin" import { InstallationInfo, setupBin } from "../utils/setup/setupBin"
import { semverCoerceIfInvalid } from "../utils/setup/version" import { semverCoerceIfInvalid } from "../utils/setup/version"
import { setupMacOSSDK } from "../macos-sdk/macos-sdk" import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
@ -59,12 +58,12 @@ async function setupLLVMDeps(arch: string, version: string) {
} }
} }
// TODO: install libtinfo on other distros // TODO: install libtinfo on other distros
// setupPacmanPack("ncurses") // await setupPacmanPack("ncurses")
} }
} }
export async function activateLLVM(directory: string, versionGiven: string) { export async function activateLLVM(directory: string, versionGiven: string) {
const version = semverCoerceIfInvalid(versionGiven) const _version = semverCoerceIfInvalid(versionGiven)
const lib = join(directory, "lib") const lib = join(directory, "lib")

View File

@ -131,7 +131,7 @@ export async function main(args: string[]): Promise<number> {
if (isArch() && typeof opts.cppcheck === "string" && typeof opts.gcovr === "string") { if (isArch() && typeof opts.cppcheck === "string" && typeof opts.gcovr === "string") {
info("installing python-pygments to avoid conflicts with cppcheck and gcovr on Arch linux") info("installing python-pygments to avoid conflicts with cppcheck and gcovr on Arch linux")
setupPacmanPack("python-pygments") await setupPacmanPack("python-pygments")
} }
// loop over the tools and run their setup function // loop over the tools and run their setup function

View File

@ -64,7 +64,7 @@ export async function setupPythonViaSystem(
let installInfo: InstallationInfo let installInfo: InstallationInfo
if (isArch()) { if (isArch()) {
installInfo = await setupPacmanPack("python", version) installInfo = await setupPacmanPack("python", version)
setupPacmanPack("python-pip") await setupPacmanPack("python-pip")
} else if (hasDnf()) { } else if (hasDnf()) {
installInfo = setupDnfPack("python3", version) installInfo = setupDnfPack("python3", version)
setupDnfPack("python3-pip") setupDnfPack("python3-pip")
@ -113,7 +113,7 @@ export async function setupPythonAndPip(): Promise<string> {
} else if (process.platform === "linux") { } else if (process.platform === "linux") {
// ensure that pip is installed on Linux (happens when python is found but pip not installed) // ensure that pip is installed on Linux (happens when python is found but pip not installed)
if (isArch()) { if (isArch()) {
setupPacmanPack("python-pip") await setupPacmanPack("python-pip")
} else if (hasDnf()) { } else if (hasDnf()) {
setupDnfPack("python3-pip") setupDnfPack("python3-pip")
} else if (isUbuntu()) { } else if (isUbuntu()) {

View File

@ -111,6 +111,7 @@ async function addPathSystem(path: string) {
} }
} }
/* eslint-disable require-atomic-updates */
let setupCppInProfile_called = false let setupCppInProfile_called = false
/// handles adding conditions to source .cpprc file from .bashrc and .profile /// handles adding conditions to source .cpprc file from .bashrc and .profile

View File

@ -62,7 +62,7 @@ async function getAptArg(name: string, version: string | undefined) {
const { stdout } = await execa("apt-cache", [ const { stdout } = await execa("apt-cache", [
"search", "search",
"--names-only", "--names-only",
`^${escapeRegex(name)}\-${escapeRegex(version)}$`, `^${escapeRegex(name)}-${escapeRegex(version)}$`,
]) ])
if (stdout.trim() !== "") { if (stdout.trim() !== "") {
return `${name}-${version}` return `${name}-${version}`
@ -103,7 +103,7 @@ async function initApt(apt: string) {
"ca-certificates", "ca-certificates",
"gnupg", "gnupg",
]) ])
const promises: Promise<any>[] = [ const promises: Promise<string | void>[] = [
addAptKeyViaServer(["3B4FE6ACC0B21F32", "40976EAF437D05B5"], "setup-cpp-ubuntu-archive.gpg"), addAptKeyViaServer(["3B4FE6ACC0B21F32", "40976EAF437D05B5"], "setup-cpp-ubuntu-archive.gpg"),
addAptKeyViaServer(["1E9377A2BA9EF27F"], "launchpad-toolchain.gpg"), addAptKeyViaServer(["1E9377A2BA9EF27F"], "launchpad-toolchain.gpg"),
] ]

View File

@ -104,9 +104,7 @@ export async function setupBin(
info(`Installing extraction dependencies`) info(`Installing extraction dependencies`)
if (process.platform === "linux") { if (process.platform === "linux") {
if (isArch()) { if (isArch()) {
setupPacmanPack("unzip") await Promise.all([setupPacmanPack("unzip"), setupPacmanPack("tar"), setupPacmanPack("xz")])
setupPacmanPack("tar")
setupPacmanPack("xz")
} else if (hasDnf()) { } else if (hasDnf()) {
setupDnfPack("unzip") setupDnfPack("unzip")
setupDnfPack("tar") setupDnfPack("tar")

View File

@ -1,4 +1,3 @@
/* eslint-disable require-atomic-updates */
import { info } from "@actions/core" import { info } from "@actions/core"
import { execaSync } from "execa" import { execaSync } from "execa"
import { pathExists } from "path-exists" import { pathExists } from "path-exists"
@ -8,6 +7,7 @@ import { addPythonBaseExecPrefix, setupPythonAndPip } from "../../python/python"
import { addPath } from "../env/addEnv" import { addPath } from "../env/addEnv"
import { InstallationInfo } from "./setupBin" import { InstallationInfo } from "./setupBin"
/* eslint-disable require-atomic-updates */
let python: string | undefined let python: string | undefined
let binDirs: string[] | undefined let binDirs: string[] | undefined
@ -37,9 +37,8 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
async function findBinDir(dirs: string[], name: string) { async function findBinDir(dirs: string[], name: string) {
const exists = await Promise.all(dirs.map((dir) => pathExists(join(dir, addExeExt(name))))) const exists = await Promise.all(dirs.map((dir) => pathExists(join(dir, addExeExt(name)))))
const dirIndex = exists.findIndex((exist) => exist) const dirIndex = exists.findIndex((exist) => exist)
if (dirIndex !== -1) {
const foundDir = dirs[dirIndex] const foundDir = dirs[dirIndex]
if (foundDir !== undefined) {
return foundDir return foundDir
} }

View File

@ -12,7 +12,13 @@ import { info } from "ci-log"
export function getSpecificVersions(versions: Set<string>, semversion: string): string[] { export function getSpecificVersions(versions: Set<string>, semversion: string): string[] {
return Array.from(versions) return Array.from(versions)
.filter((v) => /^\d+\.\d+\.\d+$/.test(v) && v.startsWith(semversion)) .filter((v) => /^\d+\.\d+\.\d+$/.test(v) && v.startsWith(semversion))
.sort() .sort((a, b) => {
try {
return semverCompare(a, b)
} catch (err) {
return a.localeCompare(b)
}
})
.reverse() .reverse()
} }
@ -58,11 +64,12 @@ export async function getSpecificVersionAndUrl(
const offlineUrls: string[] = [] const offlineUrls: string[] = []
// TODO use Promise.any
for (const specificVersion of getSpecificVersions(versions, version)) { for (const specificVersion of getSpecificVersions(versions, version)) {
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
const url = await getUrl(platform, specificVersion) const url = await getUrl(platform, specificVersion)
// eslint-disable-next-line no-await-in-loop
if (url !== null) { if (url !== null) {
// eslint-disable-next-line no-await-in-loop
if (await isUrlOnline(url)) { if (await isUrlOnline(url)) {
return [specificVersion, url] return [specificVersion, url]
} else { } else {

View File

@ -21,12 +21,14 @@ export async function setupVcpkg(_version: string, setupDir: string, _arch: stri
if (process.platform === "linux") { if (process.platform === "linux") {
// vcpkg download and extraction dependencies // vcpkg download and extraction dependencies
if (isArch()) { if (isArch()) {
setupPacmanPack("curl") await Promise.all([
setupPacmanPack("zip") setupPacmanPack("curl"),
setupPacmanPack("unzip") setupPacmanPack("zip"),
setupPacmanPack("tar") setupPacmanPack("unzip"),
setupPacmanPack("git") setupPacmanPack("tar"),
setupPacmanPack("pkg-config") setupPacmanPack("git"),
setupPacmanPack("pkg-config"),
])
} else if (hasDnf()) { } else if (hasDnf()) {
setupDnfPack("curl") setupDnfPack("curl")
setupDnfPack("zip") setupDnfPack("zip")