feat: introduce setup-brew package

This commit is contained in:
Amin Yahyaabadi 2024-08-23 15:20:37 -07:00
parent 20b8aaf39f
commit f2d212e7ec
No known key found for this signature in database
GPG Key ID: F52AF77F636088F0
44 changed files with 340 additions and 82 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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -36,7 +36,9 @@
"copy.matchers": "run-p copy.matchers.legacy copy.matchers.actions", "copy.matchers": "run-p copy.matchers.legacy copy.matchers.actions",
"copy.matchers.legacy": "shx cp ./src/gcc/gcc_matcher.json ./dist/legacy/ && shx cp ./src/msvc/msvc_matcher.json ./dist/legacy/ && shx cp ./src/python/python_matcher.json ./dist/legacy/ && shx cp ./src/llvm/llvm_matcher.json ./dist/legacy/", "copy.matchers.legacy": "shx cp ./src/gcc/gcc_matcher.json ./dist/legacy/ && shx cp ./src/msvc/msvc_matcher.json ./dist/legacy/ && shx cp ./src/python/python_matcher.json ./dist/legacy/ && shx cp ./src/llvm/llvm_matcher.json ./dist/legacy/",
"copy.matchers.actions": "shx cp ./src/gcc/gcc_matcher.json ./dist/actions/ && shx cp ./src/msvc/msvc_matcher.json ./dist/actions/ && shx cp ./src/python/python_matcher.json ./dist/actions/ && shx cp ./src/llvm/llvm_matcher.json ./dist/actions/", "copy.matchers.actions": "shx cp ./src/gcc/gcc_matcher.json ./dist/actions/ && shx cp ./src/msvc/msvc_matcher.json ./dist/actions/ && shx cp ./src/python/python_matcher.json ./dist/actions/ && shx cp ./src/llvm/llvm_matcher.json ./dist/actions/",
"dev": "cross-env NODE_ENV=development parcel watch", "dev.parcel": "cross-env NODE_ENV=development parcel watch",
"dev.packages": "turbo dev",
"dev": "run-p dev.packages dev.parcel",
"docs": "shx rm -rf packages/*/README.md && pnpm -r exec readme --path ../../dev/readme/template.md -y && pnpm -r exec ts-readme", "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", "format": "run-s lint.dprint",
"lint": "turbo lint && run-p --aggregate-output --continue-on-error lint.**", "lint": "turbo lint && run-p --aggregate-output --continue-on-error lint.**",
@ -114,6 +116,7 @@
"retry-as-promised": "^7.0.4", "retry-as-promised": "^7.0.4",
"semver": "7.6.3", "semver": "7.6.3",
"setup-python": "github:aminya/setup-python#a783db655c6e40317e2c0c96f9d162d9c9f4a751", "setup-python": "github:aminya/setup-python#a783db655c6e40317e2c0c96f9d162d9c9f4a751",
"setup-brew": "workspace:*",
"shx": "0.3.4", "shx": "0.3.4",
"simple-update-notifier": "^2.0.0", "simple-update-notifier": "^2.0.0",
"terser-config-atomic": "^1.0.0", "terser-config-atomic": "^1.0.0",
@ -157,6 +160,7 @@
"retry-as-promised", "retry-as-promised",
"semver", "semver",
"setup-apt", "setup-apt",
"setup-brew",
"setup-python", "setup-python",
"simple-update-notifier", "simple-update-notifier",
"time-delta", "time-delta",

View File

@ -1,6 +1,8 @@
<h1 align="center">ci-log</h1> <h1 align="center">ci-log</h1>
<p> <p>
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" /> <a href="https://www.npmjs.com/package/ci-log" target="_blank">
<img alt="Version" src="https://img.shields.io/npm/v/ci-log.svg">
</a>
<a href="#" target="_blank"> <a href="#" target="_blank">
<img alt="License: Apache--2.0" src="https://img.shields.io/badge/License-Apache--2.0-yellow.svg" /> <img alt="License: Apache--2.0" src="https://img.shields.io/badge/License-Apache--2.0-yellow.svg" />
</a> </a>

View File

@ -10,6 +10,7 @@
"source": "./src/index.ts", "source": "./src/index.ts",
"scripts": { "scripts": {
"build": "tsc --pretty", "build": "tsc --pretty",
"dev": "tsc --watch --pretty",
"lint.tsc": "tsc --noEmit --pretty", "lint.tsc": "tsc --noEmit --pretty",
"lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix", "lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix",
"prepublishOnly": "pnpm run build" "prepublishOnly": "pnpm run build"

View File

@ -1,6 +1,8 @@
<h1 align="center">envosman</h1> <h1 align="center">envosman</h1>
<p> <p>
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" /> <a href="https://www.npmjs.com/package/envosman" target="_blank">
<img alt="Version" src="https://img.shields.io/npm/v/envosman.svg">
</a>
<img src="https://img.shields.io/badge/node-%3E%3D12-blue.svg" /> <img src="https://img.shields.io/badge/node-%3E%3D12-blue.svg" />
<a href="#" target="_blank"> <a href="#" target="_blank">
<img alt="License: Apache--2.0" src="https://img.shields.io/badge/License-Apache--2.0-yellow.svg" /> <img alt="License: Apache--2.0" src="https://img.shields.io/badge/License-Apache--2.0-yellow.svg" />
@ -23,6 +25,8 @@ npm install --save envosman
### `RcOptions` (type) ### `RcOptions` (type)
Options for adding an rc file
### `sourceRCInRc` (variable) ### `sourceRCInRc` (variable)
handles adding conditions to source rc file from .bashrc and .profile handles adding conditions to source rc file from .bashrc and .profile
@ -48,6 +52,8 @@ Escape a string for use in a shell command
### `AddEnvOptions` (type) ### `AddEnvOptions` (type)
The options for adding an environment variable
### `addEnv` (function) ### `addEnv` (function)
Add an environment variable. Add an environment variable.
@ -62,6 +68,10 @@ This function is cross-platforms and works in all the local or CI systems.
**returns:** Promise<void> **returns:** Promise<void>
### `AddPathOptions` (type)
The options for adding a PATH variable
### `addPath` (function) ### `addPath` (function)
Add a path to the PATH environment variable. Add a path to the PATH environment variable.

View File

@ -10,6 +10,7 @@
"source": "./src/index.ts", "source": "./src/index.ts",
"scripts": { "scripts": {
"build": "tsc --pretty", "build": "tsc --pretty",
"dev": "tsc --watch --pretty",
"lint.tsc": "tsc --noEmit --pretty", "lint.tsc": "tsc --noEmit --pretty",
"lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix", "lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix",
"prepublishOnly": "pnpm run build" "prepublishOnly": "pnpm run build"

View File

@ -10,7 +10,7 @@ const { appendFile } = promises
/** /**
* The options for adding a PATH variable * The options for adding a PATH variable
*/ */
type AddPathOptions = { export type AddPathOptions = {
/** /**
* The path to the RC file that the PATH variables should be added to. * The path to the RC file that the PATH variables should be added to.
*/ */

View File

@ -1,6 +1,8 @@
<h1 align="center">exec-powershell</h1> <h1 align="center">exec-powershell</h1>
<p> <p>
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" /> <a href="https://www.npmjs.com/package/exec-powershell" target="_blank">
<img alt="Version" src="https://img.shields.io/npm/v/exec-powershell.svg">
</a>
<a href="#" target="_blank"> <a href="#" target="_blank">
<img alt="License: Apache--2.0" src="https://img.shields.io/badge/License-Apache--2.0-yellow.svg" /> <img alt="License: Apache--2.0" src="https://img.shields.io/badge/License-Apache--2.0-yellow.svg" />
</a> </a>

View File

@ -10,6 +10,7 @@
"source": "./src/index.ts", "source": "./src/index.ts",
"scripts": { "scripts": {
"build": "tsc --pretty", "build": "tsc --pretty",
"dev": "tsc --watch --pretty",
"lint.tsc": "tsc --noEmit --pretty", "lint.tsc": "tsc --noEmit --pretty",
"lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix", "lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix",
"prepublishOnly": "pnpm run build" "prepublishOnly": "pnpm run build"

View File

@ -1,6 +1,8 @@
<h1 align="center">setup-apt</h1> <h1 align="center">setup-apt</h1>
<p> <p>
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" /> <a href="https://www.npmjs.com/package/setup-apt" target="_blank">
<img alt="Version" src="https://img.shields.io/npm/v/setup-apt.svg">
</a>
<img src="https://img.shields.io/badge/node-%3E%3D12-blue.svg" /> <img src="https://img.shields.io/badge/node-%3E%3D12-blue.svg" />
<a href="#" target="_blank"> <a href="#" target="_blank">
<img alt="License: Apache--2.0" src="https://img.shields.io/badge/License-Apache--2.0-yellow.svg" /> <img alt="License: Apache--2.0" src="https://img.shields.io/badge/License-Apache--2.0-yellow.svg" />

View File

@ -10,6 +10,7 @@
"source": "./src/index.ts", "source": "./src/index.ts",
"scripts": { "scripts": {
"build": "tsc --pretty", "build": "tsc --pretty",
"dev": "tsc --watch --pretty",
"lint.tsc": "tsc --noEmit --pretty", "lint.tsc": "tsc --noEmit --pretty",
"lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix", "lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix",
"prepublishOnly": "pnpm run build" "prepublishOnly": "pnpm run build"

View File

@ -0,0 +1,3 @@
{
"extends": "../../.eslintrc.json"
}

View File

@ -0,0 +1,65 @@
<h1 align="center">setup-brew</h1>
<p>
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" />
<img src="https://img.shields.io/badge/node-%3E%3D12-blue.svg" />
<a href="#" target="_blank">
<img alt="License: Apache--2.0" src="https://img.shields.io/badge/License-Apache--2.0-yellow.svg" />
</a>
</p>
> Setup brew and brew packages
## Install
```sh
npm install --save setup-brew
```
## Usage
<!-- INSERT GENERATED DOCS START -->
### `InstallationInfo` (type)
The information about an installation result
### `SetupBrewOptions` (type)
### `setupBrew` (function)
**Parameters:**
- options (`SetupBrewOptions`)
**returns:** Promise<InstallationInfo>
### `getBrewBinDir` (function)
Get the path where brew is installed
**returns:** "/opt/homebrew/bin/" | "/usr/local/bin/" | "/home/linuxbrew/.linuxbrew/bin/"
### `BrewPackOptions` (type)
### `installBrewPack` (function)
A function that installs a package using brew
**Parameters:**
- name (`string`)
- version (`string`)
- givenOptions (`BrewPackOptions`)
**returns:** Promise<InstallationInfo>
<!-- INSERT GENERATED DOCS END -->
## 🤝 Contributing
You can sponsor my work here:
https://github.com/sponsors/aminya
Pull requests, issues and feature requests are welcome.
See the [Contributing guide](https://github.com/aminya/setup-cpp/blob/master/CONTRIBUTING.md).

View File

@ -0,0 +1,45 @@
import { join } from "path"
import spawn from "cross-spawn"
import { pathExists } from "path-exists"
import { addExeExt } from "patha"
import which from "which"
import { setupBrew } from "../src/index.js"
jest.setTimeout(300000)
describe("setup-brew", () => {
if (process.platform === "win32") {
it.skip("should setup brew", () => {})
return
}
it("should setup brew", async () => {
const installInfo = await setupBrew()
await testBin("brew", ["--version"], installInfo?.binDir)
})
})
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

@ -0,0 +1,4 @@
{
"extends": "../tsconfig.json",
"include": ["**/*.ts"]
}

View File

@ -0,0 +1,51 @@
{
"name": "setup-brew",
"version": "1.0.0",
"description": "Setup brew and brew packages",
"repository": "https://github.com/aminya/setup-cpp",
"homepage": "https://github.com/aminya/setup-cpp/tree/master/packages/setup-brew",
"license": "Apache-2.0",
"author": "Amin Yahyaabadi",
"main": "./dist/index.js",
"source": "./src/index.ts",
"scripts": {
"build": "tsc --pretty",
"dev": "tsc --watch --pretty",
"lint.tsc": "tsc --noEmit --pretty",
"lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix",
"prepublishOnly": "pnpm run build"
},
"dependencies": {
"@types/node": "^12",
"ci-log": "workspace:*",
"envosman": "workspace:*",
"which": "4.0.0",
"execa": "^7.2.0",
"setup-apt": "workspace:*",
"node-downloader-helper": "2.1.9"
},
"devDependencies": {
"path-exists": "5.0.0",
"patha": "0.4.1"
},
"engines": {
"node": ">=12"
},
"keywords": [
"setup",
"brew",
"install",
"brew-install",
"cask",
"formula",
"package",
"setup-brew",
"repositories",
"macos",
"homebrew",
"linuxbrew",
"osx",
"linux",
"ubuntu"
]
}

View File

@ -0,0 +1,12 @@
/**
* The information about an installation result
*/
export type InstallationInfo = {
/** The install dir of the package (Defaults to `undefined`) */
installDir?: string
/** The bin dir of the package (Defaults to `/usr/bin`) */
binDir: string
/** The bin path of the package (Defaults to `undefined`) */
bin?: string
}

View File

@ -0,0 +1,2 @@
export * from "./install-pack.js"
export * from "./install.js"

View File

@ -1,14 +1,14 @@
import { join } from "path"
import { info } from "ci-log"
/* eslint-disable require-atomic-updates */ /* eslint-disable require-atomic-updates */
import { info } from "@actions/core"
import { execaSync } from "execa" import { execaSync } from "execa"
import { join } from "patha"
import which from "which" import which from "which"
import { getBrewBinDir, setupBrew } from "../../brew/brew.js" import type { InstallationInfo } from "./InstallationInfo.js"
import type { InstallationInfo } from "./setupBin.js" import { getBrewBinDir, setupBrew } from "./install.js"
let hasBrew = false let hasBrew = false
type BrewPackOptions = { export type BrewPackOptions = {
/** Whether to overwrite the package if it already exists */ /** Whether to overwrite the package if it already exists */
overwrite?: boolean overwrite?: boolean
/** Whether to install the package as a cask */ /** Whether to install the package as a cask */
@ -18,7 +18,7 @@ type BrewPackOptions = {
} }
/** A function that installs a package using brew */ /** A function that installs a package using brew */
export async function setupBrewPack( export async function installBrewPack(
name: string, name: string,
version?: string, version?: string,
givenOptions: BrewPackOptions = {}, givenOptions: BrewPackOptions = {},
@ -33,7 +33,7 @@ export async function setupBrewPack(
info(`Installing ${name} ${version ?? ""} via brew`) info(`Installing ${name} ${version ?? ""} via brew`)
if (!hasBrew || which.sync("brew", { nothrow: true }) === null) { if (!hasBrew || which.sync("brew", { nothrow: true }) === null) {
await setupBrew("", "", process.arch) await setupBrew()
hasBrew = true hasBrew = true
} }

View File

@ -1,17 +1,27 @@
import { tmpdir } from "os" import { tmpdir } from "os"
import { addPath } from "envosman" import { dirname } from "path"
import { type AddPathOptions, addPath } from "envosman"
import { execaSync } from "execa" import { execaSync } from "execa"
import { DownloaderHelper } from "node-downloader-helper" import { DownloaderHelper } from "node-downloader-helper"
import { dirname } from "patha"
import { installAptPack } from "setup-apt" import { installAptPack } from "setup-apt"
import which from "which" import which from "which"
import { rcOptions } from "../cli-options.js" import type { InstallationInfo } from "./InstallationInfo.js"
/* eslint-disable require-atomic-updates */ /* eslint-disable require-atomic-updates */
let binDir: string | undefined let binDir: string | undefined
// eslint-disable-next-line @typescript-eslint/no-unused-vars export type SetupBrewOptions = {
export async function setupBrew(_version: string, _setupDir: string, _arch: string) { /** Options for adding the brew path to the rc file */
rcOptions?: AddPathOptions
/** (Unsupported option) The version of brew to install */
version?: never
/** (Unsupported option) The directory where brew should be installed */
setupDir?: never
/** (Unsupported option) The architecture of the system */
arch?: never
}
export async function setupBrew(options: SetupBrewOptions = {}): Promise<InstallationInfo | undefined> {
// brew is only available on darwin and linux // brew is only available on darwin and linux
if (!["darwin", "linux"].includes(process.platform)) { if (!["darwin", "linux"].includes(process.platform)) {
return undefined return undefined
@ -49,7 +59,7 @@ export async function setupBrew(_version: string, _setupDir: string, _arch: stri
// add the bin directory to the PATH // add the bin directory to the PATH
binDir = getBrewBinDir() binDir = getBrewBinDir()
await addPath(binDir, rcOptions) await addPath(binDir, options.rcOptions)
return { binDir } return { binDir }
} }

View File

@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"noEmit": false,
"allowImportingTsExtensions": false
},
"include": ["./src"]
}

View File

@ -1,6 +1,8 @@
<h1 align="center">untildify-user</h1> <h1 align="center">untildify-user</h1>
<p> <p>
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" /> <a href="https://www.npmjs.com/package/untildify-user" target="_blank">
<img alt="Version" src="https://img.shields.io/npm/v/untildify-user.svg">
</a>
<a href="#" target="_blank"> <a href="#" target="_blank">
<img alt="License: Apache--2.0" src="https://img.shields.io/badge/License-Apache--2.0-yellow.svg" /> <img alt="License: Apache--2.0" src="https://img.shields.io/badge/License-Apache--2.0-yellow.svg" />
</a> </a>

View File

@ -10,6 +10,7 @@
"source": "./src/index.ts", "source": "./src/index.ts",
"scripts": { "scripts": {
"build": "tsc --pretty", "build": "tsc --pretty",
"dev": "tsc --watch --pretty",
"lint.tsc": "tsc --noEmit --pretty", "lint.tsc": "tsc --noEmit --pretty",
"lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix", "lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix",
"prepublishOnly": "pnpm run build" "prepublishOnly": "pnpm run build"

View File

@ -182,6 +182,9 @@ importers:
setup-apt: setup-apt:
specifier: workspace:* specifier: workspace:*
version: link:packages/setup-apt version: link:packages/setup-apt
setup-brew:
specifier: workspace:*
version: link:packages/setup-brew
setup-python: setup-python:
specifier: github:aminya/setup-python#a783db655c6e40317e2c0c96f9d162d9c9f4a751 specifier: github:aminya/setup-python#a783db655c6e40317e2c0c96f9d162d9c9f4a751
version: https://codeload.github.com/aminya/setup-python/tar.gz/a783db655c6e40317e2c0c96f9d162d9c9f4a751(encoding@0.1.13) version: https://codeload.github.com/aminya/setup-python/tar.gz/a783db655c6e40317e2c0c96f9d162d9c9f4a751(encoding@0.1.13)
@ -319,6 +322,37 @@ importers:
specifier: 4.0.0 specifier: 4.0.0
version: 4.0.0 version: 4.0.0
packages/setup-brew:
dependencies:
'@types/node':
specifier: ^12
version: 12.20.55
ci-log:
specifier: workspace:*
version: link:../ci-log
envosman:
specifier: workspace:*
version: link:../envosman
execa:
specifier: ^7.2.0
version: 7.2.0
node-downloader-helper:
specifier: 2.1.9
version: 2.1.9
setup-apt:
specifier: workspace:*
version: link:../setup-apt
which:
specifier: 4.0.0
version: 4.0.0
devDependencies:
path-exists:
specifier: 5.0.0
version: 5.0.0
patha:
specifier: 0.4.1
version: 0.4.1
packages/untildify-user: packages/untildify-user:
dependencies: dependencies:
admina: admina:

View File

@ -1,9 +1,9 @@
import { execRootSync } from "admina" import { execRootSync } from "admina"
import { addAptKeyViaDownload, installAptPack } from "setup-apt" import { addAptKeyViaDownload, installAptPack } from "setup-apt"
import { installBrewPack } from "setup-brew"
import { hasDnf } from "../utils/env/hasDnf.js" import { hasDnf } from "../utils/env/hasDnf.js"
import { isArch } from "../utils/env/isArch.js" import { isArch } from "../utils/env/isArch.js"
import { isUbuntu } from "../utils/env/isUbuntu.js" import { isUbuntu } from "../utils/env/isUbuntu.js"
import { setupBrewPack } from "../utils/setup/setupBrewPack.js"
import { setupChocoPack } from "../utils/setup/setupChocoPack.js" import { setupChocoPack } from "../utils/setup/setupChocoPack.js"
import { setupDnfPack } from "../utils/setup/setupDnfPack.js" import { setupDnfPack } from "../utils/setup/setupDnfPack.js"
@ -16,7 +16,7 @@ export async function setupBazel(version: string, _setupDir: string, _arch: stri
} }
case "darwin": { case "darwin": {
// install bazelisk because it contains both // install bazelisk because it contains both
return setupBrewPack("bazelisk", version) return installBrewPack("bazelisk", version)
} }
case "linux": { case "linux": {
if (isArch()) { if (isArch()) {

View File

@ -1,14 +0,0 @@
import { testBin } from "../../utils/tests/test-helpers.js"
import { setupBrew } from "../brew.js"
jest.setTimeout(300000)
describe("setup-brew", () => {
if (process.platform === "win32") {
it.skip("should setup brew", () => {})
return
}
it("should setup brew", async () => {
const installInfo = await setupBrew("", "", process.arch)
await testBin("brew", ["--version"], installInfo?.binDir)
})
})

View File

@ -1,8 +1,8 @@
import { installAptPack } from "setup-apt" import { installAptPack } from "setup-apt"
import { installBrewPack } from "setup-brew"
import { hasDnf } from "../utils/env/hasDnf.js" import { hasDnf } from "../utils/env/hasDnf.js"
import { isArch } from "../utils/env/isArch.js" import { isArch } from "../utils/env/isArch.js"
import { isUbuntu } from "../utils/env/isUbuntu.js" import { isUbuntu } from "../utils/env/isUbuntu.js"
import { setupBrewPack } from "../utils/setup/setupBrewPack.js"
import { setupChocoPack } from "../utils/setup/setupChocoPack.js" import { setupChocoPack } from "../utils/setup/setupChocoPack.js"
import { setupDnfPack } from "../utils/setup/setupDnfPack.js" import { setupDnfPack } from "../utils/setup/setupDnfPack.js"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js" import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
@ -14,7 +14,7 @@ export function setupCcache(version: string, _setupDir: string, _arch: string) {
return setupChocoPack("ccache", version) return setupChocoPack("ccache", version)
} }
case "darwin": { case "darwin": {
return setupBrewPack("ccache", version) return installBrewPack("ccache", version)
} }
case "linux": { case "linux": {
if (isArch()) { if (isArch()) {

View File

@ -1,10 +1,10 @@
import { addPath } from "envosman" import { addPath } from "envosman"
import { installAptPack } from "setup-apt" import { installAptPack } from "setup-apt"
import { installBrewPack } from "setup-brew"
import { rcOptions } from "../cli-options.js" import { rcOptions } from "../cli-options.js"
import { hasDnf } from "../utils/env/hasDnf.js" import { hasDnf } from "../utils/env/hasDnf.js"
import { isArch } from "../utils/env/isArch.js" import { isArch } from "../utils/env/isArch.js"
import { isUbuntu } from "../utils/env/isUbuntu.js" import { isUbuntu } from "../utils/env/isUbuntu.js"
import { setupBrewPack } from "../utils/setup/setupBrewPack.js"
import { setupChocoPack } from "../utils/setup/setupChocoPack.js" import { setupChocoPack } from "../utils/setup/setupChocoPack.js"
import { setupDnfPack } from "../utils/setup/setupDnfPack.js" import { setupDnfPack } from "../utils/setup/setupDnfPack.js"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js" import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
@ -18,7 +18,7 @@ export async function setupCppcheck(version: string | undefined, _setupDir: stri
return { binDir } return { binDir }
} }
case "darwin": { case "darwin": {
return setupBrewPack("cppcheck", version) return installBrewPack("cppcheck", version)
} }
case "linux": { case "linux": {
if (isArch()) { if (isArch()) {

View File

@ -2,9 +2,9 @@ import { info, notice } from "ci-log"
import { addPath } from "envosman" import { addPath } from "envosman"
import { addExeExt, join } from "patha" import { addExeExt, join } from "patha"
import { installAptPack } from "setup-apt" import { installAptPack } from "setup-apt"
import { installBrewPack } from "setup-brew"
import { setupGraphviz } from "../graphviz/graphviz.js" import { setupGraphviz } from "../graphviz/graphviz.js"
import { type InstallationInfo, type PackageInfo, setupBin } from "../utils/setup/setupBin.js" import { type InstallationInfo, type PackageInfo, setupBin } from "../utils/setup/setupBin.js"
import { setupBrewPack } from "../utils/setup/setupBrewPack.js"
import { setupChocoPack } from "../utils/setup/setupChocoPack.js" import { setupChocoPack } from "../utils/setup/setupChocoPack.js"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js" import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
import { getVersion } from "../versions/versions.js" import { getVersion } from "../versions/versions.js"
@ -77,7 +77,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
// try { // try {
// installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch) // installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
// } catch { // } catch {
const installationInfo = await setupBrewPack("doxygen", undefined) const installationInfo = await installBrewPack("doxygen", undefined)
// } // }
// only install graphviz if the macOS version is greater than 11 // only install graphviz if the macOS version is greater than 11

View File

@ -8,6 +8,7 @@ import { addExeExt, join } from "patha"
import semverCoerce from "semver/functions/coerce" import semverCoerce from "semver/functions/coerce"
import semverMajor from "semver/functions/major" import semverMajor from "semver/functions/major"
import { addUpdateAlternativesToRc, installAptPack } from "setup-apt" import { addUpdateAlternativesToRc, installAptPack } from "setup-apt"
import { installBrewPack } from "setup-brew"
import { rcOptions } from "../cli-options.js" import { rcOptions } from "../cli-options.js"
import { setupMacOSSDK } from "../macos-sdk/macos-sdk.js" import { setupMacOSSDK } from "../macos-sdk/macos-sdk.js"
import { hasDnf } from "../utils/env/hasDnf.js" import { hasDnf } from "../utils/env/hasDnf.js"
@ -15,7 +16,6 @@ import { isArch } from "../utils/env/isArch.js"
import { isUbuntu } from "../utils/env/isUbuntu.js" import { isUbuntu } from "../utils/env/isUbuntu.js"
import { extract7Zip } from "../utils/setup/extract.js" import { extract7Zip } from "../utils/setup/extract.js"
import { type InstallationInfo, type PackageInfo, setupBin } from "../utils/setup/setupBin.js" import { type InstallationInfo, type PackageInfo, setupBin } from "../utils/setup/setupBin.js"
import { setupBrewPack } from "../utils/setup/setupBrewPack.js"
import { setupChocoPack } from "../utils/setup/setupChocoPack.js" import { setupChocoPack } from "../utils/setup/setupChocoPack.js"
import { setupDnfPack } from "../utils/setup/setupDnfPack.js" import { setupDnfPack } from "../utils/setup/setupDnfPack.js"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js" import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
@ -96,7 +96,7 @@ export async function setupGcc(version: string, setupDir: string, arch: string,
break break
} }
case "darwin": { case "darwin": {
installationInfo = await setupBrewPack("gcc", version) installationInfo = await installBrewPack("gcc", version)
break break
} }
case "linux": { case "linux": {

View File

@ -1,11 +1,11 @@
import { addPath } from "envosman" import { addPath } from "envosman"
import { installAptPack } from "setup-apt" import { installAptPack } from "setup-apt"
import { installBrewPack } from "setup-brew"
import { rcOptions } from "../cli-options.js" import { rcOptions } from "../cli-options.js"
import { hasDnf } from "../utils/env/hasDnf.js" import { hasDnf } from "../utils/env/hasDnf.js"
import { isArch } from "../utils/env/isArch.js" import { isArch } from "../utils/env/isArch.js"
import { isUbuntu } from "../utils/env/isUbuntu.js" import { isUbuntu } from "../utils/env/isUbuntu.js"
import type { InstallationInfo } from "../utils/setup/setupBin.js" import type { InstallationInfo } from "../utils/setup/setupBin.js"
import { setupBrewPack } from "../utils/setup/setupBrewPack.js"
import { setupChocoPack } from "../utils/setup/setupChocoPack.js" import { setupChocoPack } from "../utils/setup/setupChocoPack.js"
import { setupDnfPack } from "../utils/setup/setupDnfPack.js" import { setupDnfPack } from "../utils/setup/setupDnfPack.js"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js" import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
@ -18,7 +18,7 @@ export async function setupGraphviz(version: string, _setupDir: string, _arch: s
return activateGraphviz() return activateGraphviz()
} }
case "darwin": { case "darwin": {
return setupBrewPack("graphviz", version) return installBrewPack("graphviz", version)
} }
case "linux": { case "linux": {
if (isArch()) { if (isArch()) {

View File

@ -2,7 +2,8 @@ import { endGroup, startGroup } from "@actions/core"
import { error } from "ci-log" import { error } from "ci-log"
import pTimeout from "p-timeout" import pTimeout from "p-timeout"
import { join } from "patha" import { join } from "patha"
import { getSuccessMessage } from "./cli-options.js" import { setupBrew } from "setup-brew"
import { getSuccessMessage, rcOptions } from "./cli-options.js"
import { type ToolName, setups } from "./tool.js" import { type ToolName, setups } from "./tool.js"
import type { InstallationInfo } from "./utils/setup/setupBin.js" import type { InstallationInfo } from "./utils/setup/setupBin.js"
import { setupVCVarsall } from "./vcvarsall/vcvarsall.js" import { setupVCVarsall } from "./vcvarsall/vcvarsall.js"
@ -54,15 +55,20 @@ async function installToolImpl(
if (tool === "vcvarsall") { if (tool === "vcvarsall") {
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
await setupVCVarsall(getVersion(tool, version, osVersion), undefined, arch, undefined, undefined, false, false) await setupVCVarsall(getVersion(tool, version, osVersion), undefined, arch, undefined, undefined, false, false)
} else if (tool === "brew") {
// eslint-disable no-await-in-loop
installationInfo = await setupBrew({ rcOptions })
} else { } else {
// get the setup function
const setupFunction = setups[tool]
// the tool installation directory (for the functions that ue it) // the tool installation directory (for the functions that ue it)
const setupDir = join(setupCppDir, hasLLVM ? "llvm" : tool) const setupDir = join(setupCppDir, hasLLVM ? "llvm" : tool)
// eslint-disable-next-line no-await-in-loop const setupVersion = getVersion(tool, version, osVersion)
installationInfo = await setupFunction(getVersion(tool, version, osVersion), setupDir, arch)
// get the setup function
const setupFunction = setups[tool]
// eslint-disable no-await-in-loop
installationInfo = await setupFunction(setupVersion, setupDir, arch)
} }
// preparing a report string // preparing a report string
successMessages.push(getSuccessMessage(tool, installationInfo)) successMessages.push(getSuccessMessage(tool, installationInfo))

View File

@ -1,10 +1,10 @@
import { addPath } from "envosman" import { addPath } from "envosman"
import { installAptPack } from "setup-apt" import { installAptPack } from "setup-apt"
import { installBrewPack } from "setup-brew"
import { rcOptions } from "../cli-options.js" import { rcOptions } from "../cli-options.js"
import { hasDnf } from "../utils/env/hasDnf.js" import { hasDnf } from "../utils/env/hasDnf.js"
import { isArch } from "../utils/env/isArch.js" import { isArch } from "../utils/env/isArch.js"
import { isUbuntu } from "../utils/env/isUbuntu.js" import { isUbuntu } from "../utils/env/isUbuntu.js"
import { setupBrewPack } from "../utils/setup/setupBrewPack.js"
import { setupChocoPack } from "../utils/setup/setupChocoPack.js" import { setupChocoPack } from "../utils/setup/setupChocoPack.js"
import { setupDnfPack } from "../utils/setup/setupDnfPack.js" import { setupDnfPack } from "../utils/setup/setupDnfPack.js"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js" import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
@ -16,7 +16,7 @@ export async function setupMake(version: string, _setupDir: string, _arch: strin
return setupChocoPack("make", version) return setupChocoPack("make", version)
} }
case "darwin": { case "darwin": {
await setupBrewPack("make", version) await installBrewPack("make", version)
await addPath("/usr/local/opt/make/libexec/gnubin", rcOptions) await addPath("/usr/local/opt/make/libexec/gnubin", rcOptions)
return { binDir: "/usr/local/opt/make/libexec/gnubin" } return { binDir: "/usr/local/opt/make/libexec/gnubin" }
} }

View File

@ -3,13 +3,13 @@ import { error } from "ci-log"
import { addPath } from "envosman" import { addPath } from "envosman"
import { addExeExt } from "patha" import { addExeExt } from "patha"
import { installAptPack } from "setup-apt" import { installAptPack } from "setup-apt"
import { installBrewPack } from "setup-brew"
import { rcOptions } from "../cli-options.js" import { rcOptions } from "../cli-options.js"
import { hasDnf } from "../utils/env/hasDnf.js" import { hasDnf } from "../utils/env/hasDnf.js"
import { isArch } from "../utils/env/isArch.js" import { isArch } from "../utils/env/isArch.js"
import { isUbuntu } from "../utils/env/isUbuntu.js" import { isUbuntu } from "../utils/env/isUbuntu.js"
import { ubuntuVersion } from "../utils/env/ubuntu_version.js" import { ubuntuVersion } from "../utils/env/ubuntu_version.js"
import { type PackageInfo, setupBin } from "../utils/setup/setupBin.js" import { type PackageInfo, setupBin } from "../utils/setup/setupBin.js"
import { setupBrewPack } from "../utils/setup/setupBrewPack.js"
import { setupChocoPack } from "../utils/setup/setupChocoPack.js" import { setupChocoPack } from "../utils/setup/setupChocoPack.js"
import { setupDnfPack } from "../utils/setup/setupDnfPack.js" import { setupDnfPack } from "../utils/setup/setupDnfPack.js"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js" import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
@ -79,7 +79,7 @@ export async function setupPowershellSystem(version: string | undefined, _setupD
return { binDir } return { binDir }
} }
case "darwin": { case "darwin": {
return setupBrewPack("powershell", version, { cask: true, overwrite: false }) return installBrewPack("powershell", version, { cask: true, overwrite: false })
} }
case "linux": { case "linux": {
if (isArch()) { if (isArch()) {

View File

@ -11,13 +11,13 @@ import memoize from "micro-memoize"
import { pathExists } from "path-exists" import { pathExists } from "path-exists"
import { addExeExt, dirname, join } from "patha" import { addExeExt, dirname, join } from "patha"
import { installAptPack } from "setup-apt" import { installAptPack } from "setup-apt"
import { installBrewPack } from "setup-brew"
import which from "which" import which from "which"
import { rcOptions } from "../cli-options.js" import { rcOptions } from "../cli-options.js"
import { hasDnf } from "../utils/env/hasDnf.js" import { hasDnf } from "../utils/env/hasDnf.js"
import { isArch } from "../utils/env/isArch.js" import { isArch } from "../utils/env/isArch.js"
import { isUbuntu } from "../utils/env/isUbuntu.js" import { isUbuntu } from "../utils/env/isUbuntu.js"
import type { InstallationInfo } from "../utils/setup/setupBin.js" import type { InstallationInfo } from "../utils/setup/setupBin.js"
import { setupBrewPack } from "../utils/setup/setupBrewPack.js"
import { setupChocoPack } from "../utils/setup/setupChocoPack.js" import { setupChocoPack } from "../utils/setup/setupChocoPack.js"
import { setupDnfPack } from "../utils/setup/setupDnfPack.js" import { setupDnfPack } from "../utils/setup/setupDnfPack.js"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js" import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
@ -140,7 +140,7 @@ async function setupPythonSystem(setupDir: string, version: string) {
break break
} }
case "darwin": { case "darwin": {
installInfo = await setupBrewPack("python3", version) installInfo = await installBrewPack("python3", version)
// add the python and pip binaries to the path // add the python and pip binaries to the path
const brewPythonPrefix: { const brewPythonPrefix: {
stdout: string stdout: string

View File

@ -1,4 +1,4 @@
import { setupBrewPack } from "../utils/setup/setupBrewPack.js" import { installBrewPack } from "setup-brew"
import { setupChocoPack } from "../utils/setup/setupChocoPack.js" import { setupChocoPack } from "../utils/setup/setupChocoPack.js"
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
@ -9,7 +9,7 @@ export function setupSccache(version: string, _setupDir: string, _arch: string)
} }
case "linux": case "linux":
case "darwin": { case "darwin": {
return setupBrewPack("sccache", version) return installBrewPack("sccache", version)
} }
default: { default: {
throw new Error("Unsupported platform") throw new Error("Unsupported platform")

View File

@ -1,8 +1,8 @@
import { installAptPack } from "setup-apt" import { installAptPack } from "setup-apt"
import { installBrewPack } from "setup-brew"
import { hasDnf } from "../utils/env/hasDnf.js" import { hasDnf } from "../utils/env/hasDnf.js"
import { isArch } from "../utils/env/isArch.js" import { isArch } from "../utils/env/isArch.js"
import { isUbuntu } from "../utils/env/isUbuntu.js" import { isUbuntu } from "../utils/env/isUbuntu.js"
import { setupBrewPack } from "../utils/setup/setupBrewPack.js"
import { setupChocoPack } from "../utils/setup/setupChocoPack.js" import { setupChocoPack } from "../utils/setup/setupChocoPack.js"
import { setupDnfPack } from "../utils/setup/setupDnfPack.js" import { setupDnfPack } from "../utils/setup/setupDnfPack.js"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js" import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
@ -14,7 +14,7 @@ export function setupSevenZip(version: string, _setupDir: string, _arch: string)
return setupChocoPack("7zip", version) return setupChocoPack("7zip", version)
} }
case "darwin": { case "darwin": {
return setupBrewPack("p7zip", version) return installBrewPack("p7zip", version)
} }
case "linux": { case "linux": {
if (isArch()) { if (isArch()) {

View File

@ -1,5 +1,5 @@
import { setupBrew } from "setup-brew"
import { setupBazel } from "./bazel/bazel.js" import { setupBazel } from "./bazel/bazel.js"
import { setupBrew } from "./brew/brew.js"
import { setupCcache } from "./ccache/ccache.js" import { setupCcache } from "./ccache/ccache.js"
import { setupChocolatey } from "./chocolatey/chocolatey.js" import { setupChocolatey } from "./chocolatey/chocolatey.js"
import { setupCmake } from "./cmake/cmake.js" import { setupCmake } from "./cmake/cmake.js"
@ -65,5 +65,5 @@ export const tools = Object.keys(setups) as Array<ToolName>
/** The possible inputs to the program */ /** The possible inputs to the program */
export type Inputs = keyof typeof setups | "compiler" | "architecture" | "timeout" export type Inputs = keyof typeof setups | "compiler" | "architecture" | "timeout"
/** an array of possible inputs */ /** An array of possible inputs */
export const inputs: Array<Inputs> = ["compiler", "architecture", "timeout", ...tools] export const inputs: Array<Inputs> = ["compiler", "architecture", "timeout", ...tools]

View File

@ -6,6 +6,10 @@
"dependsOn": ["^build"], "dependsOn": ["^build"],
"outputs": ["dist/"] "outputs": ["dist/"]
}, },
"dev": {
"persistent": true,
"cache": false
},
"lint.tsc": { "lint.tsc": {
"dependsOn": ["build", "^lint.tsc"] "dependsOn": ["build", "^lint.tsc"]
}, },