]> git.openstreetmap.org Git - chef.git/commitdiff
Switch to using nodesource repos for nodejs
authorTom Hughes <tom@compton.nu>
Tue, 22 Nov 2022 22:11:56 +0000 (22:11 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 22 Nov 2022 22:11:56 +0000 (22:11 +0000)
cookbooks/apt/recipes/nodesource.rb [new file with mode: 0644]
cookbooks/apt/recipes/yarn.rb [new file with mode: 0644]
cookbooks/nodejs/metadata.rb
cookbooks/nodejs/recipes/default.rb
cookbooks/nodejs/templates/default/yarn.erb [deleted file]
cookbooks/web/resources/rails_port.rb

diff --git a/cookbooks/apt/recipes/nodesource.rb b/cookbooks/apt/recipes/nodesource.rb
new file mode 100644 (file)
index 0000000..51bfa3c
--- /dev/null
@@ -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 (file)
index 0000000..ecb1c10
--- /dev/null
@@ -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
index 5cd33627c77dd7a64337bda994adc3377f1052bd..6285913540a9011b8c3d8e56a28326a1baf994c6 100644 (file)
@@ -6,3 +6,4 @@ description       "Installs and configures Node.js"
 
 version           "1.0.0"
 supports          "ubuntu"
+depends           "apt"
index 5f8ca526b4f6b0e491af932a1f2614576d13d377..1c610fe1b892d0ac9ec6bdd34b9e4bdb8c8c72a1 100644 (file)
 # 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 (file)
index ed0b15f..0000000
+++ /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 -%>
index 14a9c0bfb59ba4df2eef721214777b2c487c3d92..fbf4aeb0bdd7d4bbb114601ace58c7e336df454e 100644 (file)
@@ -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