diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dbef889b..88070a949 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [Unreleased] +- Support Node.js on ARM builds (https://github.com/heroku/heroku-buildpack-ruby/pull/1499) ## [v280] - 2024-10-08 diff --git a/lib/language_pack/helpers/node_installer.rb b/lib/language_pack/helpers/node_installer.rb index 16e7eb9d9..218d1c8b3 100644 --- a/lib/language_pack/helpers/node_installer.rb +++ b/lib/language_pack/helpers/node_installer.rb @@ -1,15 +1,15 @@ class LanguagePack::Helpers::NodeInstaller attr_reader :version - def initialize - nodebin = LanguagePack::Helpers::Nodebin.node_lts + def initialize(arch: ) + nodebin = LanguagePack::Helpers::Nodebin.node_lts(arch: arch) @version = nodebin["number"] @url = nodebin["url"] @fetcher = LanguagePack::Fetcher.new("") end def binary_path - node_folder(@version) + File.basename(@url).delete_suffix(".tar.gz") end def install @@ -27,9 +27,4 @@ def install FileUtils.mv("#{dir}/#{node_bin}", ".") end end - - private - def node_folder(version) - "node-v#{version}-linux-x64" - end end diff --git a/lib/language_pack/helpers/nodebin.rb b/lib/language_pack/helpers/nodebin.rb index 1a5c194f9..7632e8366 100644 --- a/lib/language_pack/helpers/nodebin.rb +++ b/lib/language_pack/helpers/nodebin.rb @@ -4,10 +4,11 @@ class LanguagePack::Helpers::Nodebin NODE_VERSION = "20.9.0" YARN_VERSION = "1.22.19" - def self.hardcoded_node_lts + def self.hardcoded_node_lts(arch: ) + arch = "x64" if arch == "amd64" { "number" => NODE_VERSION, - "url" => "https://heroku-nodebin.s3.us-east-1.amazonaws.com/node/release/linux-x64/node-v#{NODE_VERSION}-linux-x64.tar.gz" + "url" => "https://nodejs.org/download/release/v#{NODE_VERSION}/node-v#{NODE_VERSION}-linux-#{arch}.tar.gz", } end @@ -18,8 +19,8 @@ def self.hardcoded_yarn } end - def self.node_lts - hardcoded_node_lts + def self.node_lts(arch: ) + hardcoded_node_lts(arch: arch) end def self.yarn diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index ced465dc4..65612d7b5 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -34,7 +34,7 @@ def bundler def initialize(*args) super(*args) - @node_installer = LanguagePack::Helpers::NodeInstaller.new + @node_installer = LanguagePack::Helpers::NodeInstaller.new(arch: @arch) @yarn_installer = LanguagePack::Helpers::YarnInstaller.new end diff --git a/spec/helpers/node_installer_spec.rb b/spec/helpers/node_installer_spec.rb index dff419669..3ba393bb2 100644 --- a/spec/helpers/node_installer_spec.rb +++ b/spec/helpers/node_installer_spec.rb @@ -2,13 +2,15 @@ describe LanguagePack::Helpers::NodeInstaller do describe "#install" do - it "should extract a node binary" do - Dir.mktmpdir do |dir| - Dir.chdir(dir) do - installer = LanguagePack::Helpers::NodeInstaller.new - installer.install + LanguagePack::Base::KNOWN_ARCHITECTURES.each do |arch| + it "should extract a node binary on #{arch}" do + Dir.mktmpdir do |dir| + Dir.chdir(dir) do + installer = LanguagePack::Helpers::NodeInstaller.new(arch: "arm64") + installer.install - expect(File.exist?("node")).to be(true) + expect(File.exist?("node")).to be(true) + end end end end