Skip to content

Commit 4481860

Browse files
authored
Merge pull request #315 from aminya/warnings [skip ci]
2 parents 75454f9 + 867ce44 commit 4481860

File tree

11 files changed

+139
-33
lines changed

11 files changed

+139
-33
lines changed

cspell.config.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ words:
6666
- libstdc
6767
- libtinfo
6868
- liuli
69+
- mdimporterdir
6970
- memoizee
7071
- msbuild
7172
- msvc
@@ -92,6 +93,7 @@ words:
9293
- pwsh
9394
- pygments
9495
- pypy
96+
- qlplugindir
9597
- Sccache
9698
- setupcpp
9799
- setx

dist/legacy/setup-cpp.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.mjs

+1-1
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs.map

+1-1
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/**
2+
* The options for installing a package using brew
3+
*/
4+
export type BrewPackOptions = {
5+
/** Whether to overwrite the package if it already exists */
6+
overwrite?: boolean
7+
/** Whether to install the package as a cask */
8+
cask?: boolean
9+
/** Treat all named arguments as formulae */
10+
formula?: boolean
11+
/** If brewing fails, open an interactive debugging session */
12+
debug?: boolean
13+
/** Print install times for each package at the end of the run */
14+
"display-times"?: boolean
15+
/** Install formulae without checking for previously installed versions */
16+
force?: boolean
17+
/** Print the verification and post-install steps */
18+
verbose?: boolean
19+
/** Show what would be installed, but do not actually install anything */
20+
"dry-run"?: boolean
21+
/** Skip installing any dependencies of any kind */
22+
"ignore-dependencies"?: boolean
23+
/** Install the dependencies with specified options but do not install the formula itself */
24+
"only-dependencies"?: boolean
25+
/** Attempt to compile using the specified compiler */
26+
cc?: string
27+
/** Compile formula from source even if a bottle is provided */
28+
"build-from-source"?: boolean
29+
/** Install from a bottle if it exists */
30+
"force-bottle"?: boolean
31+
/** Install testing dependencies required to run brew test formula */
32+
"include-test"?: boolean
33+
/** Install the HEAD version */
34+
HEAD?: boolean
35+
/** Fetch the upstream repository to detect if the HEAD installation is outdated */
36+
"fetch-HEAD"?: boolean
37+
/** Retain the temporary files created during installation */
38+
"keep-tmp"?: boolean
39+
/** Generate debug symbols on build */
40+
"debug-symbols"?: boolean
41+
/** Prepare the formula for eventual bottling during installation */
42+
"build-bottle"?: boolean
43+
/** Install but skip any post-install steps */
44+
"skip-post-install"?: boolean
45+
/** Optimise bottles for the specified architecture */
46+
"bottle-arch"?: string
47+
/** Download and patch formula, then open a shell */
48+
interactive?: boolean
49+
/** Create a Git repository */
50+
git?: boolean
51+
/** Disable/enable linking of helper executables */
52+
binaries?: boolean
53+
/** Require all casks to have a checksum */
54+
"require-sha"?: boolean
55+
/** Disable/enable quarantining of downloads */
56+
quarantine?: boolean
57+
/** Adopt existing artifacts in the destination that are identical to those being installed */
58+
adopt?: boolean
59+
/** Skip installing cask dependencies */
60+
"skip-cask-deps"?: boolean
61+
/** Remove all files associated with a cask */
62+
zap?: boolean
63+
/** Target location for Applications */
64+
appdir?: string
65+
/** Target location for Keyboard Layouts */
66+
"keyboard-layoutdir"?: string
67+
/** Target location for Color Pickers */
68+
colorpickerdir?: string
69+
/** Target location for Preference Panes */
70+
prefpanedir?: string
71+
/** Target location for Quick Look Plugins */
72+
qlplugindir?: string
73+
/** Target location for Spotlight Plugins */
74+
mdimporterdir?: string
75+
/** Target location for Dictionaries */
76+
dictionarydir?: string
77+
/** Target location for Fonts */
78+
fontdir?: string
79+
/** Target location for Services */
80+
servicedir?: string
81+
/** Target location for Input Methods */
82+
"input-methoddir"?: string
83+
/** Target location for Internet Plugins */
84+
"internet-plugindir"?: string
85+
/** Target location for Audio Unit Plugins */
86+
"audio-unit-plugindir"?: string
87+
/** Target location for VST Plugins */
88+
"vst-plugindir"?: string
89+
/** Target location for VST3 Plugins */
90+
"vst3-plugindir"?: string
91+
/** Target location for Screen Savers */
92+
"screen-saverdir"?: string
93+
/** Comma-separated list of language codes to prefer for cask installation */
94+
language?: string
95+
/** Make some output more quiet */
96+
quiet?: boolean
97+
}

packages/setup-brew/src/install-pack.ts

+14-20
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,12 @@ import { info } from "ci-log"
33
import { execaSync } from "execa"
44
import which from "which"
55
import type { InstallationInfo } from "./InstallationInfo.js"
6+
import type { BrewPackOptions } from "./install-pack-options.js"
67
import { getBrewBinDir, setupBrew } from "./install.js"
78

89
/* eslint-disable require-atomic-updates */
910
let hasBrew = false
1011

11-
export type BrewPackOptions = {
12-
/** Whether to overwrite the package if it already exists */
13-
overwrite?: boolean
14-
/** Whether to install the package as a cask */
15-
cask?: boolean
16-
/** Extra args */
17-
args?: string[]
18-
}
19-
2012
/** A function that installs a package using brew
2113
*
2214
* @param name The name of the package
@@ -28,13 +20,13 @@ export type BrewPackOptions = {
2820
export async function installBrewPack(
2921
name: string,
3022
version?: string,
31-
givenOptions: BrewPackOptions = {},
23+
options: BrewPackOptions = {},
3224
): Promise<InstallationInfo> {
33-
const options = {
34-
overwrite: true,
35-
cask: false,
36-
args: [],
37-
...givenOptions,
25+
if (!("overwrite" in options)) {
26+
options.overwrite = true // default to true if not specified
27+
}
28+
if (options.cask) {
29+
options.overwrite = false // mutually exclusive with --overwrite
3830
}
3931

4032
info(`Installing ${name} ${version ?? ""} via brew`)
@@ -52,11 +44,13 @@ export async function installBrewPack(
5244
"install",
5345
(version !== undefined && version !== "") ? `${name}@${version}` : name,
5446
]
55-
if (options.overwrite) {
56-
args.push("--overwrite")
57-
}
58-
if (options.cask) {
59-
args.push("--cask")
47+
// Add options to args
48+
for (const [key, value] of Object.entries(options)) {
49+
if (typeof value === "boolean" && value) {
50+
args.push(`--${key}`)
51+
} else if (typeof value === "string") {
52+
args.push(`--${key}`, value)
53+
}
6054
}
6155

6256
// brew is not thread-safe

src/cpplint/cpplint.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ import { setupPipPack } from "../utils/setup/setupPipPack.js"
22

33
// eslint-disable-next-line @typescript-eslint/no-unused-vars
44
export function setupCpplint(version: string | undefined, _setupDir: string, _arch: string) {
5-
return setupPipPack("cpplint", version)
5+
return setupPipPack("cpplint", version, {
6+
pythonVersion: ">=3.8.0",
7+
})
68
}

src/doxygen/doxygen.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
7878
// try {
7979
// installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
8080
// } catch {
81-
const installationInfo = await installBrewPack("doxygen", undefined)
81+
const installationInfo = await installBrewPack("doxygen", undefined, {
82+
formula: true,
83+
})
8284
// }
8385

8486
// only install graphviz if the macOS version is greater than 11

src/python/python.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { dirname, join, parse as pathParse } from "path"
44
import { getExecOutput } from "@actions/exec"
55
import ciInfo from "ci-info"
66
const { GITHUB_ACTIONS } = ciInfo
7-
import { info, warning } from "ci-log"
7+
import { info, notice, warning } from "ci-log"
88
import { addPath } from "envosman"
99
import { execa } from "execa"
1010
import { readdir } from "fs/promises"
@@ -63,15 +63,15 @@ async function setupPipx(foundPython: string) {
6363
await execa(foundPython, ["-m", "pipx", "ensurepath"], { stdio: "inherit" })
6464
await setupVenv(foundPython)
6565
} catch (err) {
66-
warning(`Failed to install pipx: ${(err as Error).toString()}. Ignoring...`)
66+
notice(`Failed to install pipx: ${(err as Error).toString()}. Ignoring...`)
6767
}
6868
}
6969

7070
async function setupVenv(foundPython: string) {
7171
try {
7272
await setupPipPackWithPython(foundPython, "venv", undefined, { upgrade: false, usePipx: false })
7373
} catch (err) {
74-
warning(`Failed to install venv: ${(err as Error).toString()}. Ignoring...`)
74+
info(`Failed to install venv: ${(err as Error).toString()}. Ignoring...`)
7575
}
7676
}
7777

@@ -85,7 +85,7 @@ async function setupWheel(foundPython: string) {
8585
})
8686
await setupPipPackWithPython(foundPython, "wheel", undefined, { upgrade: false, isLibrary: true, usePipx: false })
8787
} catch (err) {
88-
warning(`Failed to install setuptools/wheel: ${(err as Error).toString()}. Ignoring...`)
88+
info(`Failed to install setuptools/wheel: ${(err as Error).toString()}. Ignoring...`)
8989
}
9090
}
9191

src/utils/setup/setupPipPack.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export type SetupPipPackOptions = {
3030
upgrade?: boolean
3131
/** Whether the package is a library */
3232
isLibrary?: boolean
33+
/** python version (e.g. >=3.8.0) */
34+
pythonVersion?: string
3335
}
3436

3537
/** A function that installs a package using pip */
@@ -38,7 +40,7 @@ export async function setupPipPack(
3840
version?: string,
3941
options: SetupPipPackOptions = {},
4042
): Promise<InstallationInfo> {
41-
return setupPipPackWithPython(await getPython(), name, version, options)
43+
return setupPipPackWithPython(await getPython(options.pythonVersion), name, version, options)
4244
}
4345

4446
export async function setupPipPackWithPython(
@@ -173,12 +175,15 @@ const getPipxBinDir = memoize(getPipxBinDir_, { promise: true })
173175
/* eslint-disable require-atomic-updates */
174176
let pythonBin: string | undefined
175177

176-
async function getPython(): Promise<string> {
178+
async function getPython(givenPythonVersion?: string): Promise<string> {
177179
if (pythonBin !== undefined) {
178180
return pythonBin
179181
}
180182

181-
pythonBin = (await setupPython(getVersion("python", undefined, await ubuntuVersion()), "", process.arch)).bin
183+
const pythonVersion = givenPythonVersion
184+
?? getVersion("python", undefined, await ubuntuVersion())
185+
186+
pythonBin = (await setupPython(pythonVersion, "", process.arch)).bin
182187
return pythonBin
183188
}
184189

@@ -277,6 +282,10 @@ export function setupPipPackSystem(name: string, addPythonPrefix = true) {
277282
return installAptPack([{ name: addPythonPrefix ? `python3-${name}` : name }])
278283
}
279284
} else if (process.platform === "darwin") {
285+
if (["venv"].includes(name)) {
286+
return null
287+
}
288+
280289
return installBrewPack(name)
281290
}
282291
return null

0 commit comments

Comments
 (0)