A platform for community discussion. Free, open, simple.
DEV: Make `bin/ember-cli` boot more efficient (#35547)
David Taylorecb5f7b9102c
diff --git a/bin/ember-cli b/bin/ember-cliindex 8a8dce56186..84f03f2a62d 100755--- a/bin/ember-cli+++ b/bin/ember-cli@@ -55,12 +55,23 @@ if !args.include?("test") && !args.include?("build") && !args.include?("--proxy"args << PROXYend-if !system "pnpm", "--dir=#{RAILS_ROOT}", "install"- abort "pnpm is not installed. run `npm install -g pnpm`" if !system("command -v pnpm >/dev/null;")- exit 1-end+node_modules_outdated =+ begin+ File.read("node_modules/.pnpm/lock.yaml") != File.read("pnpm-lock.yaml")+ rescue ERRNO::ENOENT+ true+ end++if node_modules_outdated+ puts "[bin/ember-cli] Detected outdated or missing node_modules. Running pnpm install..."-system "pnpm", "playwright", "install", "--no-shell", "chromium", exception: true+ if !system "pnpm", "--dir=#{RAILS_ROOT}", "install"+ if !system("command -v pnpm >/dev/null;")+ abort "pnpm is not installed. run `npm install -g pnpm`"+ end+ exit 1+ end+endpnpm_env = {"TERM" => "dumb", # simple output from ember-cli, so we can parse/forward it more easilydiff --git a/package.json b/package.jsonindex 625557881a3..58510038c65 100644--- a/package.json+++ b/package.json@@ -47,7 +47,8 @@"lttf:ignore": "lint-to-the-future ignore","lttf:output": "lint-to-the-future output -o ./lint-progress/","lint-progress": "pnpm lttf:output && npx html-pages ./lint-progress --no-cache",- "ember": "pnpm --dir=app/assets/javascripts/discourse ember"+ "ember": "pnpm --dir=app/assets/javascripts/discourse ember",+ "playwright-install": "playwright install --no-shell chromium"},"engines": {"node": ">= 20",diff --git a/spec/rails_helper.rb b/spec/rails_helper.rbindex 70697ae7fa7..666d7a710b1 100644--- a/spec/rails_helper.rb+++ b/spec/rails_helper.rb@@ -553,6 +553,19 @@ RSpec.configure do |config|Capybara::Playwright::Node.prepend(CapybaraPlaywrightNodePatch)Capybara::Playwright::Browser.prepend(CapybaraPlaywrightBrowserPatch)+ module PlaywrightErrorPatch+ def message+ msg = super+ if msg.include?("Please run the following command to download new browsers:")+ replacement = "pnpm playwright-install"+ msg.sub("playwright install".ljust(replacement.size), replacement)+ else+ msg+ end+ end+ end+ Playwright::Error.prepend(PlaywrightErrorPatch)+config.after(:each, type: :system) do |example|# If test passed, but we had a capybara finder timeout, raise it nowif example.exception.nil? &&@@ -930,7 +943,7 @@ RSpec.configure do |config|endend- $playwright_logger.logs.each do |log|+ $playwright_logger&.logs&.each do |log|next if log[:level] != "WARNING"deprecation_id = log[:message][/\[deprecation id: ([^\]]+)\]/, 1]next if deprecation_id.nil?