File yarn-use-local-cache.patch of Package discourse
Index: discourse/package.json
===================================================================
--- discourse.orig/package.json
+++ discourse/package.json
@@ -52,7 +52,7 @@
"lttf:ignore": "lint-to-the-future ignore",
"lttf:output": "lint-to-the-future output -o ./lint-progress/",
"lint-progress": "yarn lttf:output && npx html-pages ./lint-progress --no-cache",
- "postinstall": "yarn --cwd app/assets/javascripts $(node -e 'const argv = JSON.parse(process.env.npm_config_argv).original; const passthrough = [`--frozen-lockfile`, `-s`].filter(arg => argv.includes(arg)); console.log(passthrough.join(` `));')"
+ "postinstall": "yarn --cwd app/assets/javascripts --production --cache-folder ../../../../vendor/cache/yarn/ $(node -e 'const argv = JSON.parse(process.env.npm_config_argv).original; const passthrough = [`--frozen-lockfile`, `-s`].filter(arg => argv.includes(arg)); console.log(passthrough.join(` `));')"
},
"engines": {
"node": "16.* || >= 18",
Index: discourse/bin/ember-cli
===================================================================
--- discourse.orig/bin/ember-cli
+++ discourse/bin/ember-cli
@@ -68,7 +68,7 @@ system(
)
# Running yarn install in the root directory will also run it for YARN_DIR via a post-install hook
-exit 1 if !system "yarn", "-s", "install", "--cwd", RAILS_ROOT
+exit 1 if !system "yarn", "-s", "install", "--production", "--cache-folder", "vendor/cache/yarn/", "--cwd", RAILS_ROOT
yarn_env = {}
if ARGV.include?("--forward-host")
Index: discourse/lib/tasks/javascript.rake
===================================================================
--- discourse.orig/lib/tasks/javascript.rake
+++ discourse/lib/tasks/javascript.rake
@@ -203,7 +203,7 @@ end
task "javascript:update" => "clean_up" do
require "uglifier"
- yarn = system("yarn install")
+ yarn = system("yarn install --production --cache-folder vendor/cache/yarn/")
abort('Unable to run "yarn install"') unless yarn
versions = {}
Index: discourse/lib/tasks/svg_icons.rake
===================================================================
--- discourse.orig/lib/tasks/svg_icons.rake
+++ discourse/lib/tasks/svg_icons.rake
@@ -9,7 +9,7 @@ def library_src
end
task "svgicons:update" do
- yarn = system("yarn install")
+ yarn = system("yarn install --production --cache-folder vendor/cache/yarn/")
abort('Unable to run "yarn install"') unless yarn
dependencies = [{ source: "@fortawesome/fontawesome-free/sprites", destination: "fontawesome" }]