From: Tom Hughes Date: Tue, 22 Nov 2022 22:11:56 +0000 (+0000) Subject: Switch to using nodesource repos for nodejs X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/cfa0fe92774c9dfcf0a0085d7772319550066ed7 Switch to using nodesource repos for nodejs --- diff --git a/cookbooks/apt/recipes/nodesource.rb b/cookbooks/apt/recipes/nodesource.rb new file mode 100644 index 000000000..51bfa3c17 --- /dev/null +++ b/cookbooks/apt/recipes/nodesource.rb @@ -0,0 +1,26 @@ +# +# Cookbook:: apt +# Recipe:: nodesource +# +# Copyright:: 2022, Tom Hughes +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include_recipe "apt" + +apt_repository "nodesource" do + uri "https://deb.nodesource.com/node_18.x" + components ["main"] + key "1655A0AB68576280" +end diff --git a/cookbooks/apt/recipes/yarn.rb b/cookbooks/apt/recipes/yarn.rb new file mode 100644 index 000000000..ecb1c10e8 --- /dev/null +++ b/cookbooks/apt/recipes/yarn.rb @@ -0,0 +1,27 @@ +# +# Cookbook:: apt +# Recipe:: yarn +# +# Copyright:: 2022, Tom Hughes +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include_recipe "apt" + +apt_repository "yarn" do + uri "https://dl.yarnpkg.com/debian" + distribution "stable" + components ["main"] + key "23E7166788B63E1E" +end diff --git a/cookbooks/nodejs/metadata.rb b/cookbooks/nodejs/metadata.rb index 5cd33627c..628591354 100644 --- a/cookbooks/nodejs/metadata.rb +++ b/cookbooks/nodejs/metadata.rb @@ -6,3 +6,4 @@ description "Installs and configures Node.js" version "1.0.0" supports "ubuntu" +depends "apt" diff --git a/cookbooks/nodejs/recipes/default.rb b/cookbooks/nodejs/recipes/default.rb index 5f8ca526b..1c610fe1b 100644 --- a/cookbooks/nodejs/recipes/default.rb +++ b/cookbooks/nodejs/recipes/default.rb @@ -17,16 +17,16 @@ # limitations under the License. # +include_recipe "apt::nodesource" +include_recipe "apt::yarn" + +package %w[libnode72 npm yarnpkg] do + action :purge +end + package %w[ nodejs - npm + yarn g++ make ] - -template "/usr/local/bin/yarn" do - source "yarn.erb" - owner "root" - group "root" - mode "755" -end diff --git a/cookbooks/nodejs/templates/default/yarn.erb b/cookbooks/nodejs/templates/default/yarn.erb deleted file mode 100644 index ed0b15f04..000000000 --- a/cookbooks/nodejs/templates/default/yarn.erb +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -<% if node[:lsb][:release].to_f < 22.04 -%> -exec /usr/bin/yarnpkg --ignore-engines "$@" -<% else -%> -exec /usr/bin/yarnpkg "$@" -<% end -%> diff --git a/cookbooks/web/resources/rails_port.rb b/cookbooks/web/resources/rails_port.rb index 14a9c0bfb..fbf4aeb0b 100644 --- a/cookbooks/web/resources/rails_port.rb +++ b/cookbooks/web/resources/rails_port.rb @@ -405,10 +405,6 @@ action :create do only_if { new_resource.run_migrations } end - package "yarnpkg" do - only_if { new_resource.build_assets } - end - bundle_exec "#{rails_directory}/package.json" do action :nothing directory rails_directory