Skip to content

Commit 62036a9

Browse files
committed
feat: move the apt-fast installer to setup-apt package
1 parent 350b16f commit 62036a9

27 files changed

+181
-160
lines changed

dist/legacy/assets/proxy-agent-8TMZ-BeU.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/assets/proxy-agent-C54PwHVe.js.map renamed to dist/legacy/assets/proxy-agent-8TMZ-BeU.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/legacy/assets/proxy-agent-C54PwHVe.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

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/assets/proxy-agent-BmRoX2ZW.mjs

Lines changed: 0 additions & 2 deletions
This file was deleted.

dist/modern/assets/proxy-agent-BoAwJO67.mjs

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.

dist/modern/assets/proxy-agent-BmRoX2ZW.mjs.map renamed to dist/modern/assets/proxy-agent-BoAwJO67.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.

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: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { join } from "path"
2+
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"
7+
import { hasAptGet, setupAptFast } from "../src/index.js"
8+
9+
jest.setTimeout(300000)
10+
describe("setup-apt-fast", () => {
11+
if (!hasAptGet()) {
12+
test.skip("should setup apt-fast", () => {})
13+
return
14+
}
15+
it("should setup apt-fast", async () => {
16+
const installInfo = await setupAptFast("", "", process.arch)
17+
await testBin("apt-fast", ["--version"], installInfo?.binDir)
18+
})
19+
20+
afterAll(() => {
21+
// remove apt-fast to run the rest of the tests with apt-get
22+
execRootSync("apt-get", ["remove", "-y", "apt-fast"])
23+
})
24+
})
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+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"include": ["**/*.ts"]
4+
}

packages/setup-apt/jest.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import jestConfig from "../../jest.config.mjs"
2+
export default jestConfig

packages/setup-apt/package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,21 @@
1919
"dev": "tsc --watch --pretty",
2020
"lint.tsc": "tsc --noEmit --pretty",
2121
"lint.eslint": "eslint '**/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml}' --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix",
22-
"prepublishOnly": "pnpm run build"
22+
"prepublishOnly": "pnpm run build",
23+
"test": "jest --coverage"
2324
},
2425
"dependencies": {
2526
"@types/node": "22.15.3",
2627
"admina": "^1.0.1",
2728
"ci-info": "^4.0.0",
28-
"path-exists": "^5.0.0",
2929
"ci-log": "workspace:*",
3030
"envosman": "workspace:*",
31-
"which": "4.0.0",
32-
"execa": "7.2.0",
3331
"escape-string-regexp": "^5.0.0",
32+
"execa": "7.2.0",
33+
"memoizee": "^0.4.17",
3434
"node-downloader-helper": "2.1.9",
35-
"memoizee": "^0.4.17"
35+
"path-exists": "^5.0.0",
36+
"which": "4.0.0"
3637
},
3738
"engines": {
3839
"node": ">=12"
@@ -56,6 +57,8 @@
5657
],
5758
"devDependencies": {
5859
"@types/memoizee": "0.4.11",
59-
"@types/which": "~3.0.4"
60+
"@types/which": "~3.0.4",
61+
"cross-spawn": "^7.0.6",
62+
"patha": "^0.4.1"
6063
}
6164
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { execRootSync } from "admina"
44
import { error } from "ci-log"
55
import { readFile, writeFile } from "fs/promises"
66
import { DownloaderHelper } from "node-downloader-helper"
7-
import { hasAptGet, installAptPack } from "setup-apt"
87
import which from "which"
8+
import { hasAptGet } from "./get-apt.js"
9+
import { installAptPack } from "./install.js"
910

1011
let binDir: string | undefined
1112

packages/setup-apt/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from "./alternatives.js"
2+
export * from "./apt-fast.js"
23
export * from "./apt-key.js"
34
export * from "./apt-repository.js"
45
export * from "./apt-timeout.js"

0 commit comments

Comments
 (0)