feat move setup-nala to setup-apt

This commit is contained in:
Amin Yahyaabadi 2025-05-20 02:38:25 -07:00
parent 62036a9dd7
commit 6540167f34
12 changed files with 52 additions and 49 deletions

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

@ -1,10 +1,6 @@
import { join } from "path"
import { execRootSync } from "admina"
import spawn from "cross-spawn"
import { pathExists } from "path-exists"
import { addExeExt } from "patha"
import which from "which"
import { hasAptGet, setupAptFast } from "../src/index.js"
import { testBin } from "./testBin.js"
jest.setTimeout(300000)
describe("setup-apt-fast", () => {
@ -13,7 +9,7 @@ describe("setup-apt-fast", () => {
return
}
it("should setup apt-fast", async () => {
const installInfo = await setupAptFast("", "", process.arch)
const installInfo = await setupAptFast()
await testBin("apt-fast", ["--version"], installInfo?.binDir)
})
@ -22,30 +18,3 @@ describe("setup-apt-fast", () => {
execRootSync("apt-get", ["remove", "-y", "apt-fast"])
})
})
async function testBin(
name: string,
args: string[] | null = ["--version"],
binDir: string | undefined = undefined,
) {
try {
let bin = name
if (typeof binDir === "string") {
console.log(`Testing the existence of ${binDir}`)
expect(binDir).toBeDefined()
expect(binDir).not.toHaveLength(0)
expect(await pathExists(binDir)).toBeTruthy()
bin = join(binDir, addExeExt(name))
}
if (args !== null) {
console.log(`Running ${bin} ${args.join(" ")}`)
const { status } = spawn.sync(bin, args, { stdio: "inherit" })
expect(status).toBe(0)
}
expect((await which(name, { nothrow: true }))?.includes(bin))
} catch (err) {
throw new Error(`Failed to test bin ${name}: ${err}`)
}
}

View File

@ -1,7 +1,7 @@
import { execRootSync } from "admina"
import { hasAptGet } from "setup-apt"
import { testBin } from "../../utils/tests/test-helpers.js"
import { setupNala } from "../nala.js"
import { hasAptGet } from "../src/get-apt.js"
import { setupNala } from "../src/nala.js"
import { testBin } from "./testBin.js"
jest.setTimeout(300000)
describe("setup-nala", () => {
@ -10,7 +10,7 @@ describe("setup-nala", () => {
return
}
it("should setup nala", async () => {
const installInfo = await setupNala("", "", process.arch)
const installInfo = await setupNala()
await testBin("nala", ["--version"], installInfo?.binDir)
})

View File

@ -0,0 +1,32 @@
import type spawn from "cross-spawn"
import { pathExists } from "path-exists"
import { join } from "path/posix"
import { addExeExt } from "patha"
import type which from "which"
export async function testBin(
name: string,
args: string[] | null = ["--version"],
binDir: string | undefined = undefined,
) {
try {
let bin = name
if (typeof binDir === "string") {
console.log(`Testing the existence of ${binDir}`)
expect(binDir).toBeDefined()
expect(binDir).not.toHaveLength(0)
expect(await pathExists(binDir)).toBeTruthy()
bin = join(binDir, addExeExt(name))
}
if (args !== null) {
console.log(`Running ${bin} ${args.join(" ")}`)
const { status } = spawn.sync(bin, args, { stdio: "inherit" })
expect(status).toBe(0)
}
expect((await which(name, { nothrow: true }))?.includes(bin))
} catch (err) {
throw new Error(`Failed to test bin ${name}: ${err}`)
}
}

View File

@ -53,7 +53,9 @@
"ubuntu",
"debian",
"package",
"apt-key"
"apt-key",
"apt-fast",
"nala"
],
"devDependencies": {
"@types/memoizee": "0.4.11",

View File

@ -10,8 +10,7 @@ import { installAptPack } from "./install.js"
let binDir: string | undefined
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function setupAptFast(_version: string, _setupDir: string, _arch: string) {
export async function setupAptFast() {
if (!hasAptGet()) {
return undefined
}

View File

@ -7,5 +7,6 @@ export * from "./get-apt.js"
export * from "./init-apt.js"
export * from "./install.js"
export * from "./is-installed.js"
export * from "./nala.js"
export * from "./qualify-install.js"
export * from "./update.js"

View File

@ -4,13 +4,14 @@ import { execRootSync } from "admina"
import { error, info } from "ci-log"
import { readFile, writeFile } from "fs/promises"
import { DownloaderHelper } from "node-downloader-helper"
import { hasAptGet, hasNala, installAptPack, qualifiedNeededAptPackage } from "setup-apt"
import which from "which"
import { hasAptGet, hasNala } from "./get-apt.js"
import { installAptPack } from "./install.js"
import { qualifiedNeededAptPackage } from "./qualify-install.js"
let binDir: string | undefined
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function setupNala(version: string, _setupDir: string, _arch: string) {
export async function setupNala(version?: string) {
if (!hasAptGet()) {
return undefined
}

View File

@ -1,4 +1,4 @@
import { setupAptFast } from "setup-apt"
import { setupAptFast, setupNala } from "setup-apt"
import { setupBrew } from "setup-brew"
import { setupBazel } from "./bazel/bazel.js"
import { setupCcache } from "./ccache/ccache.js"
@ -23,7 +23,6 @@ import { setupClangFormat, setupClangTools, setupLLVM } from "./llvm/llvm.js"
import { setupMake } from "./make/make.js"
import { setupMeson } from "./meson/meson.js"
import { setupMSVC } from "./msvc/msvc.js"
import { setupNala } from "./nala/nala.js"
import { setupNinja } from "./ninja/ninja.js"
import { setupOpencppcoverage } from "./opencppcoverage/opencppcoverage.js"
import { setupPowershell } from "./powershell/powershell.js"