Skip to content

Commit 6540167

Browse files
committed
feat move setup-nala to setup-apt
1 parent 62036a9 commit 6540167

File tree

12 files changed

+52
-49
lines changed

12 files changed

+52
-49
lines changed

dist/legacy/setup-cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import { join } from "path"
21
import { execRootSync } from "admina"
3-
import spawn from "cross-spawn"
4-
import { pathExists } from "path-exists"
5-
import { addExeExt } from "patha"
6-
import which from "which"
72
import { hasAptGet, setupAptFast } from "../src/index.js"
3+
import { testBin } from "./testBin.js"
84

95
jest.setTimeout(300000)
106
describe("setup-apt-fast", () => {
@@ -13,7 +9,7 @@ describe("setup-apt-fast", () => {
139
return
1410
}
1511
it("should setup apt-fast", async () => {
16-
const installInfo = await setupAptFast("", "", process.arch)
12+
const installInfo = await setupAptFast()
1713
await testBin("apt-fast", ["--version"], installInfo?.binDir)
1814
})
1915

@@ -22,30 +18,3 @@ describe("setup-apt-fast", () => {
2218
execRootSync("apt-get", ["remove", "-y", "apt-fast"])
2319
})
2420
})
25-
26-
async function testBin(
27-
name: string,
28-
args: string[] | null = ["--version"],
29-
binDir: string | undefined = undefined,
30-
) {
31-
try {
32-
let bin = name
33-
if (typeof binDir === "string") {
34-
console.log(`Testing the existence of ${binDir}`)
35-
expect(binDir).toBeDefined()
36-
expect(binDir).not.toHaveLength(0)
37-
expect(await pathExists(binDir)).toBeTruthy()
38-
bin = join(binDir, addExeExt(name))
39-
}
40-
41-
if (args !== null) {
42-
console.log(`Running ${bin} ${args.join(" ")}`)
43-
const { status } = spawn.sync(bin, args, { stdio: "inherit" })
44-
expect(status).toBe(0)
45-
}
46-
47-
expect((await which(name, { nothrow: true }))?.includes(bin))
48-
} catch (err) {
49-
throw new Error(`Failed to test bin ${name}: ${err}`)
50-
}
51-
}

src/nala/__tests__/nala.test.ts renamed to packages/setup-apt/__tests__/nala.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { execRootSync } from "admina"
2-
import { hasAptGet } from "setup-apt"
3-
import { testBin } from "../../utils/tests/test-helpers.js"
4-
import { setupNala } from "../nala.js"
2+
import { hasAptGet } from "../src/get-apt.js"
3+
import { setupNala } from "../src/nala.js"
4+
import { testBin } from "./testBin.js"
55

66
jest.setTimeout(300000)
77
describe("setup-nala", () => {
@@ -10,7 +10,7 @@ describe("setup-nala", () => {
1010
return
1111
}
1212
it("should setup nala", async () => {
13-
const installInfo = await setupNala("", "", process.arch)
13+
const installInfo = await setupNala()
1414
await testBin("nala", ["--version"], installInfo?.binDir)
1515
})
1616

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import type spawn from "cross-spawn"
2+
import { pathExists } from "path-exists"
3+
import { join } from "path/posix"
4+
import { addExeExt } from "patha"
5+
import type which from "which"
6+
7+
export async function testBin(
8+
name: string,
9+
args: string[] | null = ["--version"],
10+
binDir: string | undefined = undefined,
11+
) {
12+
try {
13+
let bin = name
14+
if (typeof binDir === "string") {
15+
console.log(`Testing the existence of ${binDir}`)
16+
expect(binDir).toBeDefined()
17+
expect(binDir).not.toHaveLength(0)
18+
expect(await pathExists(binDir)).toBeTruthy()
19+
bin = join(binDir, addExeExt(name))
20+
}
21+
22+
if (args !== null) {
23+
console.log(`Running ${bin} ${args.join(" ")}`)
24+
const { status } = spawn.sync(bin, args, { stdio: "inherit" })
25+
expect(status).toBe(0)
26+
}
27+
28+
expect((await which(name, { nothrow: true }))?.includes(bin))
29+
} catch (err) {
30+
throw new Error(`Failed to test bin ${name}: ${err}`)
31+
}
32+
}

packages/setup-apt/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353
"ubuntu",
5454
"debian",
5555
"package",
56-
"apt-key"
56+
"apt-key",
57+
"apt-fast",
58+
"nala"
5759
],
5860
"devDependencies": {
5961
"@types/memoizee": "0.4.11",

packages/setup-apt/src/apt-fast.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import { installAptPack } from "./install.js"
1010

1111
let binDir: string | undefined
1212

13-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
14-
export async function setupAptFast(_version: string, _setupDir: string, _arch: string) {
13+
export async function setupAptFast() {
1514
if (!hasAptGet()) {
1615
return undefined
1716
}

packages/setup-apt/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ export * from "./get-apt.js"
77
export * from "./init-apt.js"
88
export * from "./install.js"
99
export * from "./is-installed.js"
10+
export * from "./nala.js"
1011
export * from "./qualify-install.js"
1112
export * from "./update.js"

src/nala/nala.ts renamed to packages/setup-apt/src/nala.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import { execRootSync } from "admina"
44
import { error, info } from "ci-log"
55
import { readFile, writeFile } from "fs/promises"
66
import { DownloaderHelper } from "node-downloader-helper"
7-
import { hasAptGet, hasNala, installAptPack, qualifiedNeededAptPackage } from "setup-apt"
87
import which from "which"
8+
import { hasAptGet, hasNala } from "./get-apt.js"
9+
import { installAptPack } from "./install.js"
10+
import { qualifiedNeededAptPackage } from "./qualify-install.js"
911

1012
let binDir: string | undefined
1113

12-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
13-
export async function setupNala(version: string, _setupDir: string, _arch: string) {
14+
export async function setupNala(version?: string) {
1415
if (!hasAptGet()) {
1516
return undefined
1617
}

src/tool.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { setupAptFast } from "setup-apt"
1+
import { setupAptFast, setupNala } from "setup-apt"
22
import { setupBrew } from "setup-brew"
33
import { setupBazel } from "./bazel/bazel.js"
44
import { setupCcache } from "./ccache/ccache.js"
@@ -23,7 +23,6 @@ import { setupClangFormat, setupClangTools, setupLLVM } from "./llvm/llvm.js"
2323
import { setupMake } from "./make/make.js"
2424
import { setupMeson } from "./meson/meson.js"
2525
import { setupMSVC } from "./msvc/msvc.js"
26-
import { setupNala } from "./nala/nala.js"
2726
import { setupNinja } from "./ninja/ninja.js"
2827
import { setupOpencppcoverage } from "./opencppcoverage/opencppcoverage.js"
2928
import { setupPowershell } from "./powershell/powershell.js"

0 commit comments

Comments
 (0)