discourse/lib/tasks/svg_icons.rake
David Taylor 80b9c280ba
DEV: Switch to pnpm for JS dependencies (#28671)
This will bring significant improvements to install speed & storage requirements. For information on how it may affect you, see https://meta.discourse.org/t/324521

This commit:
- removes the `yarn.lock` and replaces with `pnpm-lock.yaml`
- updates workspaces to pnpm format
- adjusts package dependencies to work with pnpm's stricter resolution strategy
- updates Rails app to load modules from more specific node_modules directories
- adds a `.pnpmfile` which automatically cleans up old yarn-managed `node_modules` directories
- updates various scripts to call `pnpm` instead of `yarn`
- updates patches to use pnpm's native patch system instead of patch-package
- adds a patch for licensee to support pnpm
2024-09-03 10:51:07 +01:00

34 lines
690 B
Ruby

# frozen_string_literal: true
def vendor_svgs
"#{Rails.root}/vendor/assets/svg-icons"
end
def library_src
"#{Rails.root}/node_modules"
end
task "svgicons:update" do
system("pnpm install", exception: true)
dependencies = [{ source: "@fortawesome/fontawesome-free/sprites", destination: "fontawesome" }]
start = Time.now
dependencies.each do |f|
src = "#{library_src}/#{f[:source]}/."
if f[:destination]
filename = f[:destination]
else
filename = f[:source].split("/").last
end
dest = "#{vendor_svgs}/#{filename}"
FileUtils.cp_r(src, dest)
end
STDERR.puts "Completed copying dependencies: #{(Time.now - start).round(2)} secs"
end