Skip to content

Commit acb86d7

Browse files
authored
Merge pull request Homebrew#251828 from Homebrew/chronograf-source-build
chronograf: source build wherever possible
2 parents 20bd338 + 87b8700 commit acb86d7

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

Formula/c/chronograf.rb

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,35 @@ class Chronograf < Formula
1717
end
1818

1919
depends_on "go" => :build
20-
depends_on "node" => :build
20+
# Avoid C++20 from Node 23+ until "@parcel/watcher >= 2.2.0" for "node-addon-api >= 4"
21+
# Issue ref: https://github.com/nodejs/node-addon-api/issues/1007
22+
depends_on "node@22" => :build
23+
depends_on "python-setuptools" => :build
2124
depends_on "yarn" => :build
2225
depends_on "influxdb"
2326
depends_on "kapacitor"
2427

2528
def install
26-
# Fix build with latest node: https://github.com/influxdata/chronograf/issues/6040
27-
system "yarn", "upgrade", "nan@^2.13.2", "--dev", "--ignore-scripts"
29+
# Check if workarounds can be removed
30+
if build.stable?
31+
yarn_lock = File.read("yarn.lock")
32+
33+
# distutils usage removed in https://github.com/nodejs/node-gyp/commit/707927cd579205ef2b4b17e61c1cce24c056b452
34+
node_gyp_version = Version.new(yarn_lock[%r{/node-gyp[._-]v?(\d+(?:\.\d+)+)\.t}i, 1])
35+
odie "Remove `python-setuptools` dependency!" if node_gyp_version >= 10
36+
37+
# node 22 (V8 12) fix in https://github.com/nodejs/nan/commit/1b630ddb3412cde35b64513662b440f9fd71e1ff
38+
nan_version = Version.new(yarn_lock[%r{/nan[._-]v?(\d+(?:\.\d+)+)\.t}i, 1])
39+
odie "Remove `nan` resolution workaround!" if nan_version >= "2.19.0"
40+
end
41+
42+
# Workaround to build with newer node until `nan` dependency is updated
43+
# https://github.com/influxdata/chronograf/issues/6040
44+
package_json = JSON.parse(File.read("package.json"))
45+
(package_json["resolutions"] ||= {})["nan"] = "2.23.0"
46+
File.write("package.json", JSON.pretty_generate(package_json))
47+
48+
ENV["npm_config_build_from_source"] = "true"
2849
ENV.deparallelize
2950
system "make"
3051
bin.install "chronograf"

0 commit comments

Comments
 (0)