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
This commit is contained in:
David Taylor 2024-09-03 10:51:07 +01:00 committed by GitHub
parent 9b4b5b5028
commit 80b9c280ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
56 changed files with 18609 additions and 13553 deletions

View File

@ -50,30 +50,16 @@ jobs:
run: |
gem install licensed
- name: Get yarn cache directory
id: yarn-cache-dir
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Yarn cache
uses: actions/cache@v4
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- name: Check RubyGems Licenses
if: ${{ !cancelled() }}
run: |
licensed cache
licensed status
- name: Yarn install
run: yarn install
- name: pnpm install
run: pnpm install
- name: Check Yarn Licenses
- name: Check JS Licenses
if: ${{ !cancelled() }}
run: |
yarn global add licensee
yarn global upgrade licensee
licensee --errors-only
pnpm licensee --errors-only

View File

@ -50,20 +50,8 @@ jobs:
bundle install --jobs 4
bundle clean
- name: Get yarn cache directory
id: yarn-cache-dir
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Yarn cache
uses: actions/cache@v4
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- name: Yarn install
run: yarn install --frozen-lockfile
- name: pnpm install
run: pnpm install --frozen-lockfile
- name: Rubocop
if: ${{ !cancelled() }}
@ -77,21 +65,21 @@ jobs:
- name: ESLint (core)
if: ${{ !cancelled() }}
run: yarn lint:js
run: pnpm lint:js
- name: ESLint (core plugins)
if: ${{ !cancelled() }}
run: yarn lint:js-plugins
run: pnpm lint:js-plugins
- name: Prettier
if: ${{ !cancelled() }}
run: |
yarn prettier -v
yarn lint:prettier
pnpm prettier -v
pnpm lint:prettier
- name: Ember template lint
if: ${{ !cancelled() }}
run: yarn lint:hbs
run: pnpm lint:hbs
- name: English locale lint (core)
if: ${{ !cancelled() }}

View File

@ -89,19 +89,8 @@ jobs:
bundle install --jobs $(($(nproc) - 1))
# don't call `bundle clean` clean, we need the gems for the migrations
- name: Get yarn cache directory
id: yarn-cache-dir
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Yarn cache
uses: actions/cache@v4
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Yarn install
run: yarn install --frozen-lockfile
- name: pnpm install
run: pnpm install --frozen-lockfile
- name: Fetch app state cache
uses: actions/cache@v4

View File

@ -124,19 +124,8 @@ jobs:
bundle install --jobs $(($(nproc) - 1))
bundle clean
- name: Get yarn cache directory
id: yarn-cache-dir
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Yarn cache
uses: actions/cache@v4
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-cachev2
- name: Yarn install
run: yarn install --frozen-lockfile
- name: pnpm install
run: pnpm install --frozen-lockfile
- name: Checkout official plugins
if: matrix.target == 'plugins'
@ -397,30 +386,19 @@ jobs:
git config --global user.email "ci@ci.invalid"
git config --global user.name "Discourse CI"
- name: Get yarn cache directory
id: yarn-cache-dir
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Yarn cache
uses: actions/cache@v4
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-cachev2
- name: Yarn install
run: yarn install --frozen-lockfile
- name: pnpm install
run: pnpm install --frozen-lockfile
- name: Ember Build
working-directory: ./app/assets/javascripts/discourse
run: |
mkdir /tmp/emberbuild
yarn ember build --environment=test -o /tmp/emberbuild
pnpm ember build --environment=test -o /tmp/emberbuild
- name: Core QUnit
working-directory: ./app/assets/javascripts/discourse
run: |
yarn ember exam --path /tmp/emberbuild --load-balance --parallel=$(($(nproc) / 2 + 1)) --launch "${{ env.TESTEM_BROWSER }}" --write-execution-file --random
pnpm ember exam --path /tmp/emberbuild --load-balance --parallel=$(($(nproc) / 2 + 1)) --launch "${{ env.TESTEM_BROWSER }}" --write-execution-file --random
timeout-minutes: 15
- uses: actions/upload-artifact@v4

1
.npmrc
View File

@ -1 +1,2 @@
engine-strict = true
auto-install-peers = false

16
.pnpmfile.cjs Normal file
View File

@ -0,0 +1,16 @@
const fs = require("fs");
const { execSync } = require("child_process");
if (fs.existsSync("node_modules/.yarn-integrity")) {
console.log(
"Detected yarn-managed node_modules. Performing one-time cleanup..."
);
// Delete entire contents of all node_modules directories
// But keep the directories themselves, in case they are volume mounts (e.g. in devcontainer)
execSync(
"find ./node_modules ./app/assets/javascripts/*/node_modules -mindepth 1 -maxdepth 1 -exec rm -rf {} +"
);
console.log("cleanup done");
}

View File

@ -16,7 +16,7 @@
"dependencies": {
"@babel/core": "^7.25.2",
"@ember/string": "^4.0.0",
"discourse-common": "1.0.0",
"discourse-common": "workspace:1.0.0",
"ember-cli-babel": "^8.2.0",
"ember-cli-htmlbars": "^6.3.0",
"ember-template-imports": "^4.1.1"
@ -43,9 +43,10 @@
},
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
},
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9"
},
"ember": {
"edition": "default"
}

View File

@ -244,7 +244,7 @@ module.exports = {
Discourse can't be run without a \`--proxy\` setting, because it needs a Rails application
to serve API requests. For example:
yarn run ember serve --proxy "http://localhost:3000"\n`);
pnpm ember serve --proxy "http://localhost:3000"\n`);
throw "--proxy argument is required";
}

View File

@ -26,7 +26,7 @@
},
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
}
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9" }
}

View File

@ -8,7 +8,7 @@
"keywords": [],
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
}
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9" }
}

View File

@ -12,7 +12,8 @@
"ember-auto-import": "^2.7.4",
"ember-cli-babel": "^8.2.0",
"ember-cli-htmlbars": "^6.3.0",
"ember-template-imports": "^4.1.1"
"ember-template-imports": "^4.1.1",
"truth-helpers": "workspace:1.0.0"
},
"devDependencies": {
"@types/jquery": "^3.5.30",
@ -22,7 +23,7 @@
},
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
}
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9" }
}

View File

@ -22,12 +22,13 @@
"@uppy/drop-target": "2.0.1",
"@uppy/utils": "5.4.3",
"@uppy/xhr-upload": "3.1.1",
"discourse-i18n": "workspace:1.0.0",
"ember-auto-import": "^2.7.4",
"ember-cli-babel": "^8.2.0",
"ember-cli-htmlbars": "^6.3.0",
"ember-resolver": "^12.0.1",
"handlebars": "^4.7.8",
"truth-helpers": "1.0.0"
"truth-helpers": "workspace:1.0.0"
},
"devDependencies": {
"@ember/optional-features": "^2.1.0",
@ -50,9 +51,10 @@
},
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
},
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9"
},
"ember": {
"edition": "default"
}

View File

@ -9,9 +9,10 @@
},
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
},
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9"
},
"exports": {
"./raw-handlebars-compiler": "./raw-handlebars-compiler.js"
}

View File

@ -22,9 +22,10 @@
},
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
},
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9"
},
"ember": {
"edition": "octane"
},

View File

@ -19,20 +19,25 @@
],
"dependencies": {
"@embroider/addon-shim": "^1.8.9",
"discourse-common": "1.0.0",
"discourse-common": "workspace:1.0.0",
"discourse-i18n": "workspace:1.0.0",
"ember-auto-import": "^2.7.4",
"markdown-it": "^14.0.0"
"markdown-it": "14.0.0",
"pretty-text": "workspace:1.0.0",
"truth-helpers": "workspace:1.0.0",
"xss": "^1.0.15"
},
"peerDependencies": {
"discourse-i18n": "1.0.0",
"pretty-text": "1.0.0",
"discourse-i18n": "workspace:1.0.0",
"pretty-text": "workspace:1.0.0",
"xss": "*"
},
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
},
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9"
},
"ember": {
"edition": "octane"
},

View File

@ -9,8 +9,9 @@
],
"dependencies": {
"@babel/core": "^7.25.2",
"deprecation-silencer": "1.0.0",
"discourse-widget-hbs": "1.0.0",
"deprecation-silencer": "workspace:1.0.0",
"discourse-hbr": "workspace:1.0.0",
"discourse-widget-hbs": "workspace:1.0.0",
"ember-cli-babel": "^8.2.0",
"ember-cli-htmlbars": "^6.3.0",
"ember-template-imports": "^4.1.1",
@ -22,9 +23,10 @@
},
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
},
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9"
},
"ember": {
"edition": "default"
}

View File

@ -40,9 +40,10 @@
},
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
},
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9"
},
"ember": {
"edition": "default"
}

View File

@ -12,8 +12,7 @@
"scripts": {
"build": "ember build",
"start": "ember serve",
"test": "ember test",
"postinstall": "../run-patch-package"
"test": "ember test"
},
"dependencies": {
"@discourse/ember-instantsearch": "^1.1.2",
@ -25,16 +24,16 @@
"@messageformat/runtime": "^3.0.1",
"ace-builds": "^1.36.2",
"decorator-transforms": "^2.0.0",
"discourse-hbr": "1.0.0",
"discourse-widget-hbs": "1.0.0",
"discourse-hbr": "workspace:1.0.0",
"discourse-widget-hbs": "workspace:1.0.0",
"ember-route-template": "^1.0.3",
"ember-source": "~5.5.0",
"ember-tracked-storage-polyfill": "^1.0.0",
"handlebars": "^4.7.8",
"highlight.js": "^11.10.0",
"immer": "^10.1.1",
"jspreadsheet-ce": "^4.13.4",
"morphlex": "^0.0.16",
"pretty-text": "1.0.0"
"pretty-text": "workspace:1.0.0"
},
"devDependencies": {
"@babel/core": "^7.25.2",
@ -48,6 +47,7 @@
"@ember/render-modifiers": "^2.1.0",
"@ember/string": "^4.0.0",
"@ember/test-helpers": "^4.0.2",
"@ember/test-waiters": "^3.1.0",
"@embroider/compat": "^3.6.1",
"@embroider/core": "^3.4.15",
"@embroider/macros": "^1.13.1",
@ -68,20 +68,20 @@
"@uppy/utils": "5.4.3",
"@uppy/xhr-upload": "3.1.1",
"a11y-dialog": "8.1.0",
"admin": "1.0.0",
"admin": "workspace:1.0.0",
"autosize": "^6.0.1",
"babel-import-util": "^3.0.0",
"babel-plugin-ember-template-compilation": "^2.2.5",
"bootstrap": "3.4.1",
"broccoli-asset-rev": "^3.0.0",
"custom-proxy": "1.0.0",
"custom-proxy": "workspace:1.0.0",
"deepmerge": "^4.3.1",
"deprecation-silencer": "1.0.0",
"dialog-holder": "1.0.0",
"discourse-common": "1.0.0",
"discourse-i18n": "1.0.0",
"discourse-markdown-it": "1.0.0",
"discourse-plugins": "1.0.0",
"deprecation-silencer": "workspace:1.0.0",
"dialog-holder": "workspace:1.0.0",
"discourse-common": "workspace:1.0.0",
"discourse-i18n": "workspace:1.0.0",
"discourse-markdown-it": "workspace:1.0.0",
"discourse-plugins": "workspace:1.0.0",
"ember-auto-import": "^2.7.4",
"ember-buffered-proxy": "^2.1.1",
"ember-cached-decorator-polyfill": "^1.0.2",
@ -91,7 +91,7 @@
"ember-cli-deprecation-workflow": "^3.0.2",
"ember-cli-htmlbars": "^6.3.0",
"ember-cli-inject-live-reload": "^2.1.0",
"ember-cli-progress-ci": "1.0.0",
"ember-cli-progress-ci": "workspace:1.0.0",
"ember-cli-sri": "^2.1.1",
"ember-cli-terser": "^4.0.2",
"ember-decorators": "^6.1.1",
@ -99,26 +99,30 @@
"ember-load-initializers": "^2.1.1",
"ember-modifier": "^4.2.0",
"ember-on-resize-modifier": "^2.0.2",
"ember-production-deprecations": "1.0.0",
"ember-production-deprecations": "workspace:1.0.0",
"ember-qunit": "^8.1.0",
"ember-source": "~5.5.0",
"ember-template-imports": "^4.1.1",
"ember-test-selectors": "^7.0.0",
"float-kit": "1.0.0",
"float-kit": "workspace:1.0.0",
"html-entities": "^2.5.2",
"imports-loader": "^5.0.0",
"jquery": "^3.7.1",
"js-yaml": "^4.1.0",
"jsuites": "^5.4.6",
"loader.js": "^4.7.0",
"make-plural": "^7.4.0",
"message-bus-client": "^4.3.8",
"pretender": "^3.4.7",
"qunit": "^2.22.0",
"qunit-dom": "^3.2.0",
"sass": "^1.77.7",
"select-kit": "1.0.0",
"select-kit": "workspace:1.0.0",
"sinon": "^18.0.0",
"source-map": "^0.7.4",
"terser": "^5.31.6",
"truth-helpers": "1.0.0",
"testem": "^3.10.1",
"truth-helpers": "workspace:1.0.0",
"util": "^0.12.5",
"virtual-dom": "^2.1.1",
"webpack": "^5.94.0",
@ -127,9 +131,10 @@
},
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
},
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9"
},
"ember": {
"edition": "octane"
}

View File

@ -18,7 +18,8 @@
"ember-auto-import": "^2.7.4",
"ember-cli-babel": "^8.2.0",
"ember-cli-htmlbars": "^6.3.0",
"ember-template-imports": "^4.1.1"
"ember-template-imports": "^4.1.1",
"truth-helpers": "workspace:1.0.0"
},
"devDependencies": {
"@ember/optional-features": "^2.1.0",
@ -42,9 +43,10 @@
},
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
},
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9"
},
"ember": {
"edition": "default"
}

View File

@ -15,10 +15,12 @@
},
"dependencies": {
"@babel/core": "^7.25.2",
"discourse-common": "1.0.0",
"discourse-common": "workspace:1.0.0",
"discourse-i18n": "workspace:1.0.0",
"ember-auto-import": "^2.7.4",
"ember-cli-babel": "^8.2.0",
"ember-cli-htmlbars": "^6.3.0"
"ember-cli-htmlbars": "^6.3.0",
"xss": "^1.0.15"
},
"devDependencies": {
"@ember/optional-features": "^2.1.0",
@ -42,9 +44,10 @@
},
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
},
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9"
},
"ember": {
"edition": "default"
}

View File

@ -1,16 +0,0 @@
#!/bin/bash
# We are seeing occasional flakes in `patch-package`, possibly caused by https://github.com/ds300/patch-package/issues/484
# This script will retry it three times before giving up.
# Longer-term we hope to upgrade to a package manager with built-in patch support.
for i in {1..3}; do
if [ $i -ne 1 ]; then
echo "patch-package failed... retry ($i/3)..."
fi
script_dir=$(dirname "$0")
yarn --silent --cwd "${script_dir}" patch-package && exit 0;
done
exit 1;

View File

@ -16,6 +16,7 @@
"dependencies": {
"@babel/core": "^7.25.2",
"@ember/string": "^4.0.0",
"discourse-i18n": "workspace:1.0.0",
"ember-auto-import": "^2.7.4",
"ember-cli-babel": "^8.2.0",
"ember-cli-htmlbars": "^6.3.0",
@ -43,9 +44,10 @@
},
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
},
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9"
},
"ember": {
"edition": "default"
}

View File

@ -55,7 +55,7 @@ esbuild
process: `{ "env": { "EMBER_ENV": "production" } }`,
},
external: ["fs", "path"],
entryPoints: ["./app/assets/javascripts/theme-transpiler/transpiler.js"],
entryPoints: ["./transpiler.js"],
plugins: [wasmPlugin],
})
.then(() => {});

View File

@ -11,8 +11,8 @@
"@zxing/text-encoding": "^0.9.0",
"babel-plugin-ember-template-compilation": "^2.2.5",
"content-tag": "^2.0.1",
"discourse-common": "1.0.0",
"discourse-widget-hbs": "1.0.0",
"discourse-common": "workspace:1.0.0",
"discourse-widget-hbs": "workspace:1.0.0",
"ember-cli-htmlbars": "^6.3.0",
"ember-source": "~5.5.0",
"ember-this-fallback": "^0.4.0",
@ -24,7 +24,7 @@
},
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
}
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9" }
}

View File

@ -23,9 +23,10 @@
},
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
},
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9"
},
"ember": {
"edition": "octane"
},

View File

@ -57,7 +57,12 @@ class ThemeSettingsMigrationsRunner
def self.loader_js_lib_content
@loader_js_lib_content ||=
File.read(File.join(Rails.root, "node_modules/loader.js/dist/loader/loader.js"))
File.read(
File.join(
Rails.root,
"app/assets/javascripts/discourse/node_modules/loader.js/dist/loader/loader.js",
),
)
end
def initialize(theme, limit: 100, timeout: 100, memory: 2.megabytes)

View File

@ -28,7 +28,7 @@
<meta name="discourse/config/environment" content="<%=u discourse_config_environment(testing: true) %>" />
<style>
<%= File.read("#{Rails.root}/node_modules/qunit/qunit/qunit.css").html_safe %>
<%= File.read("#{Rails.root}/app/assets/javascripts/discourse/node_modules/qunit/qunit/qunit.css").html_safe %>
</style>
<%= discourse_stylesheet_link_tag(:desktop, theme_id: nil) %>

View File

@ -117,8 +117,8 @@ docker run -d \
echo "Installing gems..."
"${SCRIPTPATH}/bundle" install
echo "Yarn install..."
"${SCRIPTPATH}/exec" yarn install --cwd app/assets/javascripts/discourse
echo "pnpm install..."
"${SCRIPTPATH}/exec" pnpm install
if [ "${initialize}" = "initialize" ]; then
echo "Migrating database..."

View File

@ -1,13 +1,12 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'pathname'
require "pathname"
RAILS_ROOT = File.expand_path("../../", Pathname.new(__FILE__).realpath)
PORT = ENV["UNICORN_PORT"] ||= "3000"
HOSTNAME = ENV["DISCOURSE_HOSTNAME"] ||= "127.0.0.1"
YARN_DIR = File.join(RAILS_ROOT, "app/assets/javascripts/discourse")
CUSTOM_ARGS = ["--try", "--test", "--build", "--unicorn", "-u", "--forward-host"]
CUSTOM_ARGS = %w[--try --test --build --unicorn -u --forward-host]
PROXY =
if ARGV.include?("--try")
"https://try.discourse.org"
@ -46,25 +45,25 @@ if ARGV.include?("-h") || ARGV.include?("--help")
puts "#{"--test".cyan} To run the test suite"
puts "#{"--unicorn, -u".cyan} To run a unicorn server as well"
puts "The rest of the arguments are passed to ember server per:", ""
exec "yarn -s --cwd #{YARN_DIR} run ember #{command} --help"
exec "pnpm ember #{command} --help"
end
args = ["-s", "--cwd", YARN_DIR, "run", "ember", command] + (ARGV - CUSTOM_ARGS)
args = ["--dir=app/assets/javascripts/discourse", "ember", command] + (ARGV - CUSTOM_ARGS)
if !args.include?("test") && !args.include?("build") && !args.include?("--proxy")
args << "--proxy"
args << PROXY
end
# 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
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
yarn_env = {
pnpm_env = {
"TERM" => "dumb", # simple output from ember-cli, so we can parse/forward it more easily
}
if ARGV.include?("--forward-host")
yarn_env["FORWARD_HOST"] = "true"
end
pnpm_env["FORWARD_HOST"] = "true" if ARGV.include?("--forward-host")
if ARGV.include?("-u") || ARGV.include?("--unicorn")
unicorn_env = { "DISCOURSE_PORT" => ENV["DISCOURSE_PORT"] || "4200" }
@ -72,12 +71,13 @@ if ARGV.include?("-u") || ARGV.include?("--unicorn")
ember_cli_pid = nil
Thread.new do
require 'open3'
Open3.popen2e(yarn_env, "yarn", *args.to_a.flatten) do |i, oe, t|
require "open3"
Open3.popen2e(pnpm_env, "pnpm", *args.to_a.flatten) do |i, oe, t|
ember_cli_pid = t.pid
puts "Ember CLI running on PID: #{ember_cli_pid}"
oe.each do |line|
if line.include?("\e[32m200\e") || line.include?("\e[36m304\e[0m") || line.include?("POST /message-bus")
if line.include?("\e[32m200\e") || line.include?("\e[36m304\e[0m") ||
line.include?("POST /message-bus")
# skip 200s and 304s and message bus
else
puts "[ember-cli] #{line}"
@ -102,5 +102,5 @@ if ARGV.include?("-u") || ARGV.include?("--unicorn")
Process.kill("TERM", ember_cli_pid)
end
else
exec(yarn_env, "yarn", *args.to_a.flatten)
exec(pnpm_env, "pnpm", *args.to_a.flatten)
end

View File

@ -1,3 +0,0 @@
#!/bin/sh
yarn --cwd "`dirname $0`"/../app/assets/javascripts/discourse "$@"

View File

@ -17,19 +17,19 @@ pre-commit:
prettier:
glob: "*.js"
include: "app/assets/javascripts|plugins/.+?/assets/javascripts"
run: yarn pprettier --list-different {staged_files}
run: pnpm pprettier --list-different {staged_files}
prettier-scss:
glob: "*.scss"
include: "app/assets/stylesheets|plugins/.+?/assets/stylesheets"
run: yarn pprettier --list-different {staged_files}
run: pnpm pprettier --list-different {staged_files}
eslint:
glob: "*.js"
include: "app/assets/javascripts|plugins/.+?/assets/javascripts"
run: yarn eslint -f compact --quiet {staged_files}
run: pnpm eslint -f compact --quiet {staged_files}
ember-template-lint:
glob: "*.hbs"
include: "app/assets/javascripts|plugins/.+?/assets/javascripts"
run: yarn run ember-template-lint {staged_files}
run: pnpm run ember-template-lint {staged_files}
yaml-syntax:
glob: "*.{yaml,yml}"
# database.yml is an erb file not a yaml file
@ -45,7 +45,7 @@ fix-staged:
prettier:
glob: "*.js"
include: "app/assets/javascripts|plugins/.+?/assets/javascripts"
run: yarn pprettier --write {staged_files}
run: pnpm pprettier --write {staged_files}
rubocop:
glob: "*.rb"
run: bundle exec rubocop --force-exclusion -A {staged_files}
@ -60,13 +60,13 @@ lints:
glob: "*.rb"
run: bundle exec rubocop --parallel
prettier:
run: yarn pprettier --list-different **/*.js
run: pnpm pprettier --list-different **/*.js
prettier-scss:
run: yarn pprettier --list-different **/*.scss
run: pnpm pprettier --list-different **/*.scss
eslint:
run: yarn eslint -f compact --quiet --ext .js .
run: pnpm eslint -f compact --quiet --ext .js .
ember-template-lint:
run: yarn run ember-template-lint .
run: pnpm run ember-template-lint .
yaml-syntax:
glob: "*.{yaml,yml}"
# database.yml is an erb file not a yaml file

View File

@ -66,7 +66,12 @@ class DiscourseJsProcessor
def self.build_theme_transpiler
FileUtils.rm_rf("tmp/theme-transpiler") # cleanup old files - remove after Jan 2025
Discourse::Utils.execute_command("node", "app/assets/javascripts/theme-transpiler/build.js")
Discourse::Utils.execute_command(
"pnpm",
"-C=app/assets/javascripts/theme-transpiler",
"node",
"build.js",
)
end
def self.build_production_theme_transpiler

View File

@ -41,7 +41,10 @@ class EmberCli < ActiveSupport::CurrentAttributes
def self.ember_version
@version ||=
begin
ember_source_package_raw = File.read("#{Rails.root}/node_modules/ember-source/package.json")
ember_source_package_raw =
File.read(
"#{Rails.root}/app/assets/javascripts/discourse/node_modules/ember-source/package.json",
)
JSON.parse(ember_source_package_raw)["version"]
end
end

View File

@ -1,7 +1,8 @@
# frozen_string_literal: true
module HighlightJs
HIGHLIGHTJS_DIR ||= "#{Rails.root}/node_modules/@highlightjs/cdn-assets/"
HIGHLIGHTJS_DIR ||=
"#{Rails.root}/app/assets/javascripts/discourse/node_modules/@highlightjs/cdn-assets/"
VERSION ||= 1 # bump to invalidate caches following core changes
def self.languages

View File

@ -66,12 +66,12 @@ module PrettyText
end
root_path = "#{Rails.root}/app/assets/javascripts"
node_modules = "#{Rails.root}/node_modules"
d_node_modules = "#{Rails.root}/app/assets/javascripts/discourse/node_modules"
md_node_modules = "#{Rails.root}/app/assets/javascripts/discourse-markdown-it/node_modules"
ctx.load("#{node_modules}/loader.js/dist/loader/loader.js")
ctx.load("#{d_node_modules}/loader.js/dist/loader/loader.js")
ctx.load("#{md_node_modules}/markdown-it/dist/markdown-it.js")
ctx.load("#{root_path}/handlebars-shim.js")
ctx.load("#{node_modules}/xss/dist/xss.js")
ctx.load("#{md_node_modules}/xss/dist/xss.js")
ctx.load("#{Rails.root}/lib/pretty_text/vendor-shims.js")
ctx_load_directory(

View File

@ -12,7 +12,7 @@ task "assets:precompile:build" do
raise "Unknown ember version '#{ember_version}'" if !%w[5].include?(ember_version)
compile_command = "CI=1 yarn --cwd app/assets/javascripts/discourse run ember build"
compile_command = "CI=1 pnpm --dir=app/assets/javascripts/discourse ember build"
heap_size_limit = check_node_heap_size_limit
@ -158,7 +158,7 @@ def compress_node(from, to)
base_source_map = assets_path + assets_additional_path
cmd = <<~SH
yarn terser '#{assets_path}/#{from}' -m -c -o '#{to_path}' --source-map "base='#{base_source_map}',root='#{source_map_root}',url='#{source_map_url}',includeSources=true"
pnpm terser '#{assets_path}/#{from}' -m -c -o '#{to_path}' --source-map "base='#{base_source_map}',root='#{source_map_root}',url='#{source_map_url}',includeSources=true"
SH
STDERR.puts cmd

View File

@ -147,7 +147,7 @@ task "docker:test" do
def run_or_fail_prettier(*patterns)
if patterns.any? { |p| Dir[p].any? }
patterns = patterns.map { |p| "'#{p}'" }.join(" ")
run_or_fail("yarn pprettier --list-different #{patterns}")
run_or_fail("pnpm pprettier --list-different #{patterns}")
else
puts "Skipping prettier. Pattern not found."
true
@ -156,12 +156,12 @@ task "docker:test" do
begin
@good = true
@good &&= run_or_fail("yarn install")
@good &&= run_or_fail("pnpm install")
unless ENV["SKIP_LINT"]
puts "Running linters/prettyfiers"
puts "eslint #{`yarn eslint -v`}"
puts "prettier #{`yarn prettier -v`}"
puts "eslint #{`pnpm eslint -v`}"
puts "prettier #{`pnpm prettier -v`}"
if ENV["SINGLE_PLUGIN"]
@good &&= run_or_fail("bundle exec rubocop --parallel plugins/#{ENV["SINGLE_PLUGIN"]}")
@ -171,7 +171,7 @@ task "docker:test" do
)
@good &&=
run_or_fail(
"yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern plugins/#{ENV["SINGLE_PLUGIN"]}",
"pnpm eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern plugins/#{ENV["SINGLE_PLUGIN"]}",
)
puts "Listing prettier offenses in #{ENV["SINGLE_PLUGIN"]}:"
@ -183,10 +183,10 @@ task "docker:test" do
else
@good &&= run_or_fail("bundle exec rake plugin:update_all") unless ENV["SKIP_PLUGINS"]
@good &&= run_or_fail("bundle exec rubocop --parallel") unless ENV["SKIP_CORE"]
@good &&= run_or_fail("yarn eslint app/assets/javascripts") unless ENV["SKIP_CORE"]
@good &&= run_or_fail("pnpm eslint app/assets/javascripts") unless ENV["SKIP_CORE"]
@good &&=
run_or_fail(
"yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern plugins",
"pnpm eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern plugins",
) unless ENV["SKIP_PLUGINS"]
@good &&=
@ -202,7 +202,7 @@ task "docker:test" do
puts "Listing prettier offenses in core:"
@good &&=
run_or_fail(
'yarn pprettier --list-different "app/assets/stylesheets/**/*.scss" "app/assets/javascripts/**/*.js"',
'pnpm pprettier --list-different "app/assets/stylesheets/**/*.scss" "app/assets/javascripts/**/*.js"',
)
end
@ -210,7 +210,7 @@ task "docker:test" do
puts "Listing prettier offenses in plugins:"
@good &&=
run_or_fail(
'yarn pprettier --list-different "plugins/**/assets/stylesheets/**/*.scss" "plugins/**/assets/javascripts/**/*.{js,es6}"',
'pnpm pprettier --list-different "plugins/**/assets/stylesheets/**/*.scss" "plugins/**/assets/javascripts/**/*.{js,es6}"',
)
end
end
@ -304,7 +304,7 @@ task "docker:test" do
unless ENV["SKIP_CORE"]
@good &&=
run_or_fail(
"cd app/assets/javascripts/discourse && CI=1 yarn ember exam --load-balance --parallel=#{qunit_concurrency} --random",
"cd app/assets/javascripts/discourse && CI=1 pnpm ember exam --load-balance --parallel=#{qunit_concurrency} --random",
)
end

View File

@ -46,7 +46,7 @@ def write_template(path, task_name, template)
File.write(output_path, "#{header}\n\n#{template}")
puts "#{basename} created"
system("yarn run prettier --write #{output_path}", exception: true)
system("pnpm prettier --write #{output_path}", exception: true)
puts "#{basename} prettified"
end
@ -59,7 +59,7 @@ def write_hbs_template(path, task_name, template)
basename = File.basename(path)
output_path = "#{Rails.root}/app/assets/javascripts/#{path}"
File.write(output_path, "#{header}\n#{template}")
system("yarn run prettier --write #{output_path}", exception: true)
system("pnpm prettier --write #{output_path}", exception: true)
puts "#{basename} created"
end
@ -204,7 +204,7 @@ end
task "javascript:update" => "clean_up" do
require "uglifier"
system("yarn install", exception: true)
system("pnpm install", exception: true)
versions = {}
start = Time.now

View File

@ -11,13 +11,13 @@ task "qunit:test", %i[timeout qunit_path filter] do |_, args|
abort err.message
end
unless system("command -v yarn >/dev/null;")
abort "Yarn is not installed. Download from https://yarnpkg.com/lang/en/docs/install/"
unless system("command -v pnpm >/dev/null;")
abort "pnpm is not installed. See https://pnpm.io/installation"
end
report_requests = ENV["REPORT_REQUESTS"] == "1"
system("yarn install", exception: true)
system("pnpm install", exception: true)
# ensure we have this port available
def port_available?(port)
@ -108,7 +108,7 @@ task "qunit:test", %i[timeout qunit_path filter] do |_, args|
# Bypass `ember test` - it only works properly for the `/tests` path.
# We have to trigger a `build` manually so that JS is available for rails to serve.
system(
"yarn",
"pnpm",
"ember",
"build",
chdir: "#{Rails.root}/app/assets/javascripts/discourse",
@ -124,10 +124,10 @@ task "qunit:test", %i[timeout qunit_path filter] do |_, args|
"#{qunit_path}?#{query}&testem=1"
end
cmd += %w[yarn testem ci -f testem.js]
cmd += %w[pnpm testem ci -f testem.js]
cmd += ["--parallel", parallel] if parallel
else
cmd += ["yarn", "ember", "exam", "--query", query]
cmd += ["pnpm", "ember", "exam", "--query", query]
cmd += ["--load-balance", "--parallel", parallel] if parallel
cmd += ["--filter", filter] if filter
cmd << "--write-execution-file" if ENV["QUNIT_WRITE_EXECUTION_FILE"]

View File

@ -10,7 +10,7 @@ task "smoke:test" do
abort err.message
end
system("yarn install", exception: true)
system("pnpm install", exception: true)
url = ENV["URL"]
if !url

View File

@ -9,7 +9,7 @@ def library_src
end
task "svgicons:update" do
system("yarn install", exception: true)
system("pnpm install", exception: true)
dependencies = [{ source: "@fortawesome/fontawesome-free/sprites", destination: "fontawesome" }]

View File

@ -5,33 +5,34 @@
"author": "Discourse",
"license": "GPL-2.0-only",
"devDependencies": {
"@babel/plugin-proposal-decorators": "^7.24.7",
"@discourse/lint-configs": "^1.3.9",
"@discourse/moment-timezone-names-translations": "^1.0.0",
"@fortawesome/fontawesome-free": "5.15.4",
"@glint/core": "^1.4.0",
"@glint/environment-ember-loose": "^1.4.0",
"@glint/environment-ember-template-imports": "^1.4.0",
"@glint/template": "^1.4.0",
"@glint/core": "^1.4.1-unstable.01b8deb",
"@glint/environment-ember-loose": "^1.4.1-unstable.01b8deb",
"@glint/environment-ember-template-imports": "^1.4.1-unstable.01b8deb",
"@glint/template": "^1.4.1-unstable.01b8deb",
"@mixer/parallel-prettier": "^2.0.3",
"@swc/core": "^1.7.21",
"chart.js": "3.5.1",
"chartjs-plugin-datalabels": "2.2.0",
"chrome-launcher": "^1.1.2",
"chrome-remote-interface": "^0.33.2",
"concurrently": "^8.2.2",
"ember-template-lint": "^5.13.0",
"ember-template-lint": "^6.0.0",
"esbuild": "^0.23.1",
"eslint": "^8.57.0",
"jsdoc": "^4.0.0",
"lefthook": "^1.7.14",
"licensee": "^10.0.0",
"lint-to-the-future": "^2.0.0",
"lint-to-the-future-ember-template": "^1.1.1",
"lint-to-the-future-eslint": "^2.0.1",
"magnific-popup": "1.1.0",
"moment": "2.30.1",
"moment-timezone": "0.5.45",
"patch-package": "^8.0.0",
"pikaday": "1.8.2",
"postinstall-postinstall": "^2.1.0",
"prettier": "^2.8.8",
"puppeteer-core": "^23.2.1",
"squoosh": "discourse/squoosh#dc9649d",
@ -48,39 +49,42 @@
"lint:js-plugins:fix": "eslint --fix ./plugins",
"lint:hbs": "ember-template-lint 'app/assets/javascripts/**/*.{gjs,hbs}' 'plugins/**/assets/javascripts/**/*.{gjs,hbs}' --no-error-on-unmatched-pattern",
"lint:hbs:fix": "ember-template-lint 'app/assets/javascripts/**/*.{gjs,hbs}' 'plugins/**/assets/javascripts/**/*.{gjs,hbs}' --no-error-on-unmatched-pattern --fix",
"lint:prettier": "yarn pprettier --list-different 'app/assets/stylesheets/**/*.scss' 'app/assets/javascripts/**/*.{js,gjs,hbs}' 'plugins/**/assets/stylesheets/**/*.scss' 'plugins/**/assets/javascripts/**/*.{js,gjs,hbs}'",
"lint:prettier:fix": "yarn prettier -w 'app/assets/stylesheets/**/*.scss' 'app/assets/javascripts/**/*.{js,gjs,hbs}' 'plugins/**/assets/stylesheets/**/*.scss' 'plugins/**/assets/javascripts/**/*.{js,gjs,hbs}'",
"lint:prettier": "pnpm pprettier --list-different 'app/assets/stylesheets/**/*.scss' 'app/assets/javascripts/**/*.{js,gjs,hbs}' 'plugins/**/assets/stylesheets/**/*.scss' 'plugins/**/assets/javascripts/**/*.{js,gjs,hbs}'",
"lint:prettier:fix": "pnpm prettier -w 'app/assets/stylesheets/**/*.scss' 'app/assets/javascripts/**/*.{js,gjs,hbs}' 'plugins/**/assets/stylesheets/**/*.scss' 'plugins/**/assets/javascripts/**/*.{js,gjs,hbs}'",
"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": "./app/assets/javascripts/run-patch-package && rm -rf app/assets/javascripts/node_modules"
},
"workspaces": [
"app/assets/javascripts/admin",
"app/assets/javascripts/custom-proxy",
"app/assets/javascripts/deprecation-silencer",
"app/assets/javascripts/dialog-holder",
"app/assets/javascripts/discourse",
"app/assets/javascripts/discourse-common",
"app/assets/javascripts/discourse-hbr",
"app/assets/javascripts/discourse-i18n",
"app/assets/javascripts/discourse-markdown-it",
"app/assets/javascripts/discourse-plugins",
"app/assets/javascripts/discourse-widget-hbs",
"app/assets/javascripts/ember-cli-progress-ci",
"app/assets/javascripts/ember-production-deprecations",
"app/assets/javascripts/float-kit",
"app/assets/javascripts/pretty-text",
"app/assets/javascripts/select-kit",
"app/assets/javascripts/theme-transpiler",
"app/assets/javascripts/truth-helpers"
],
"resolutions": {
"**/unset-value": "2.0.1"
"lint-progress": "pnpm lttf:output && npx html-pages ./lint-progress --no-cache",
"ember": "pnpm --dir=app/assets/javascripts/discourse ember"
},
"packageManager": "pnpm@9.9.0",
"engines": {
"node": ">= 18",
"npm": "please-use-yarn",
"yarn": ">= 1.21.1"
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9"
},
"pnpm": {
"patchedDependencies": {
"ember-this-fallback@0.4.0": "patches/ember-this-fallback@0.4.0.patch",
"babel-plugin-debug-macros@0.3.4": "patches/babel-plugin-debug-macros@0.3.4.patch",
"content-tag@2.0.1": "patches/content-tag@2.0.1.patch",
"decorator-transforms@2.0.0": "patches/decorator-transforms@2.0.0.patch",
"virtual-dom@2.1.1": "patches/virtual-dom@2.1.1.patch",
"licensee@10.0.0": "patches/licensee@10.0.0.patch"
},
"peerDependencyRules": {
"allowedVersions": {
"@discourse/lint-configs>eslint": "*",
"@discourse/lint-configs>prettier": "*",
"lint-to-the-future-eslint>eslint": "*",
"@mixer/parallel-prettier>prettier": "*",
"lint-to-the-future-ember-template>ember-template-lint": "*",
"ember-this-fallback>ember-source": "*"
},
"allowAny": ["@uppy/*"],
"ignoreMissing": [
"webpack"
]
}
}
}

View File

@ -1,7 +1,7 @@
diff --git a/node_modules/babel-plugin-debug-macros/src/utils/builder.js b/node_modules/babel-plugin-debug-macros/src/utils/builder.js
diff --git a/src/utils/builder.js b/src/utils/builder.js
index ea61084..e17eb68 100644
--- a/node_modules/babel-plugin-debug-macros/src/utils/builder.js
+++ b/node_modules/babel-plugin-debug-macros/src/utils/builder.js
--- a/src/utils/builder.js
+++ b/src/utils/builder.js
@@ -7,6 +7,7 @@ module.exports = class Builder {
this.global = options.global;
this.assertPredicateIndex = options.assertPredicateIndex;

View File

@ -1,7 +1,7 @@
diff --git a/node_modules/content-tag/pkg/standalone.js b/node_modules/content-tag/pkg/standalone.js
diff --git a/pkg/standalone.js b/pkg/standalone.js
index 7be08fc..35777bf 100644
--- a/node_modules/content-tag/pkg/standalone.js
+++ b/node_modules/content-tag/pkg/standalone.js
--- a/pkg/standalone.js
+++ b/pkg/standalone.js
@@ -1,7 +1,8 @@
-import init from "./standalone/content_tag.js";
+import { initSync } from "./standalone/content_tag.js";
@ -13,10 +13,10 @@ index 7be08fc..35777bf 100644
const defaultOptions = {
inline_source_map: false,
diff --git a/node_modules/content-tag/pkg/standalone/content_tag.js b/node_modules/content-tag/pkg/standalone/content_tag.js
diff --git a/pkg/standalone/content_tag.js b/pkg/standalone/content_tag.js
index aaefe00..bb20026 100644
--- a/node_modules/content-tag/pkg/standalone/content_tag.js
+++ b/node_modules/content-tag/pkg/standalone/content_tag.js
--- a/pkg/standalone/content_tag.js
+++ b/pkg/standalone/content_tag.js
@@ -20,6 +20,7 @@ function takeObject(idx) {
return ret;
}

View File

@ -1,7 +1,7 @@
diff --git a/node_modules/decorator-transforms/dist/index.js b/node_modules/decorator-transforms/dist/index.js
diff --git a/dist/index.js b/dist/index.js
index fce3aeb..c23d8e4 100644
--- a/node_modules/decorator-transforms/dist/index.js
+++ b/node_modules/decorator-transforms/dist/index.js
--- a/dist/index.js
+++ b/dist/index.js
@@ -4,10 +4,13 @@ import {
import "./chunk-CSAU5B4Q.js";

View File

@ -1,40 +0,0 @@
diff --git a/node_modules/ember-this-fallback/index.js b/node_modules/ember-this-fallback/index.js
index afa73eb..168bb16 100644
--- a/node_modules/ember-this-fallback/index.js
+++ b/node_modules/ember-this-fallback/index.js
@@ -8,7 +8,7 @@ module.exports = {
setupPreprocessorRegistry(type, registry) {
if (type === 'parent') {
- const options = getOptions(findHost(this));
+ const options = getOptions(this.parent); // findHost doesn't work for us - not sure why
registry.add('htmlbars-ast-plugin', this._buildPlugin(options));
}
},
diff --git a/node_modules/ember-this-fallback/lib/helpers/deprecations.js b/node_modules/ember-this-fallback/lib/helpers/deprecations.js
index 5a00c44..993e3cf 100644
--- a/node_modules/ember-this-fallback/lib/helpers/deprecations.js
+++ b/node_modules/ember-this-fallback/lib/helpers/deprecations.js
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.deprecationOptionsFor = void 0;
const assert_1 = __importDefault(require("../types/assert"));
const CURRENT_DEPRECATIONS = [
+ [
+ 'this-property-fallback',
{
- id: 'this-property-fallback',
+ id: 'ember-this-fallback.this-property-fallback', // Updating deprecation id so we can distinguish it from Ember's
until: 'n/a',
for: 'ember-this-fallback',
url: 'https://deprecations.emberjs.com/v3.x#toc_this-property-fallback',
@@ -15,8 +17,9 @@ const CURRENT_DEPRECATIONS = [
available: '0.2.0',
},
},
+ ]
];
-const DEPRECATION_OPTIONS_MAP = new Map(CURRENT_DEPRECATIONS.map((options) => [options.id, options]));
+const DEPRECATION_OPTIONS_MAP = new Map(CURRENT_DEPRECATIONS);
function deprecationOptionsFor(id) {
const options = DEPRECATION_OPTIONS_MAP.get(id);
(0, assert_1.default)(`expected to find DeprecationOptions for id=${id}`, options);

View File

@ -1,125 +0,0 @@
diff --git a/node_modules/ember-this-fallback/index.js b/node_modules/ember-this-fallback/index.js
index afa73eb..21e9411 100644
--- a/node_modules/ember-this-fallback/index.js
+++ b/node_modules/ember-this-fallback/index.js
@@ -17,15 +17,20 @@ module.exports = {
ThisFallbackPlugin.baseDir = () => __dirname;
ThisFallbackPlugin.cacheKey = () => 'ember-this-fallback';
- return {
+ let plugin = {
name: 'ember-this-fallback',
- parallelBabel: {
+ plugin: ThisFallbackPlugin(options),
+ };
+
+ if (!options.isTheme) {
+ plugin.parallelBabel = {
requireFile: __filename,
buildUsing: '_buildPlugin',
params: options,
- },
- plugin: ThisFallbackPlugin(options),
- };
+ };
+ }
+
+ return plugin;
},
};
diff --git a/node_modules/ember-this-fallback/lib/helpers/logger.js b/node_modules/ember-this-fallback/lib/helpers/logger.js
index b856edc..afb059a 100644
--- a/node_modules/ember-this-fallback/lib/helpers/logger.js
+++ b/node_modules/ember-this-fallback/lib/helpers/logger.js
@@ -1,12 +1,6 @@
"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
Object.defineProperty(exports, "__esModule", { value: true });
exports.noopLogger = void 0;
-const debug_1 = __importDefault(require("debug"));
-const winston_1 = require("winston");
-const winston_transport_1 = __importDefault(require("winston-transport"));
function noopLogger() {
return {
debug: noop,
@@ -15,53 +9,4 @@ function noopLogger() {
};
}
exports.noopLogger = noopLogger;
-function createLogger(namespace, label) {
- const debug = (0, debug_1.default)(namespace);
- class DebugTransport extends winston_transport_1.default {
- log(info, next) {
- debug(info[Symbol.for('message')]);
- next();
- }
- }
- return (0, winston_1.createLogger)({
- level: 'debug',
- transports: [
- new winston_1.transports.File({
- level: 'info',
- filename: `${namespace}.log`,
- format: winston_1.format.combine(joinLines(), winston_1.format.label({ label }), winston_1.format.timestamp(), winston_1.format.splat(), logFormatter),
- }),
- new DebugTransport({
- level: 'debug',
- format: winston_1.format.combine(joinLines(), winston_1.format.label({ label }), winston_1.format.timestamp(), winston_1.format.splat(), debugFormatter),
- }),
- ],
- });
-}
-exports.default = createLogger;
-const joinLines = (0, winston_1.format)((info) => {
- if (Array.isArray(info.message) &&
- info.message.every((m) => typeof m === 'string')) {
- info.message = joinLogLines(info.message);
- }
- return info;
-});
-const logFormatter = winston_1.format.printf((info) => {
- const { level, label, timestamp, message, loc } = info;
- return `${timestamp} [${level}] ${concatMessage(label, message, loc)}`;
-});
-const debugFormatter = winston_1.format.printf((info) => {
- const { label, message } = info;
- return concatMessage(label, message);
-});
-function concatMessage(label, message, loc) {
- if (loc) {
- const start = loc.startPosition;
- label += `:${start.line}:${start.column + 1}`;
- }
- return joinLogLines([label, message]);
-}
-function joinLogLines(lines) {
- return lines.join('\n\t');
-}
function noop() { }
diff --git a/node_modules/ember-this-fallback/lib/this-fallback-plugin.js b/node_modules/ember-this-fallback/lib/this-fallback-plugin.js
index be4a785..a8ee337 100644
--- a/node_modules/ember-this-fallback/lib/this-fallback-plugin.js
+++ b/node_modules/ember-this-fallback/lib/this-fallback-plugin.js
@@ -29,7 +29,7 @@ const syntax_1 = require("@glimmer/syntax");
const ast_1 = require("./helpers/ast");
const deprecations_1 = require("./helpers/deprecations");
const fallback_1 = require("./helpers/fallback");
-const logger_1 = __importStar(require("./helpers/logger"));
+const logger_1 = require("./helpers/logger");
const scope_stack_1 = __importStar(require("./helpers/scope-stack"));
const string_1 = require("./helpers/string");
const assert_1 = __importDefault(require("./types/assert"));
@@ -214,9 +214,7 @@ class NoopPlugin {
function buildThisFallbackPlugin({ enableLogging, }) {
return (env) => {
const name = 'ember-this-fallback';
- const logger = enableLogging
- ? (0, logger_1.default)(`${name}-plugin`, env.moduleName)
- : (0, logger_1.noopLogger)();
+ const logger = (0, logger_1.noopLogger)();
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (env.meta.jsutils) {
return new ThisFallbackPlugin(name, env, logger);

View File

@ -1,76 +0,0 @@
diff --git a/node_modules/ember-this-fallback/lib/this-fallback-plugin.js b/node_modules/ember-this-fallback/lib/this-fallback-plugin.js
index a8ee337..9b144de 100644
--- a/node_modules/ember-this-fallback/lib/this-fallback-plugin.js
+++ b/node_modules/ember-this-fallback/lib/this-fallback-plugin.js
@@ -60,9 +60,15 @@ class ThisFallbackPlugin {
handleBlock() {
return {
enter: (node) => {
+ if (this.env.strictMode) {
+ return;
+ }
this.scopeStack.push(node.blockParams);
},
exit: () => {
+ if (this.env.strictMode) {
+ return;
+ }
this.scopeStack.pop();
},
};
@@ -70,6 +76,9 @@ class ThisFallbackPlugin {
handleAttrNodes() {
return {
enter: (elementNode, elementPath) => {
+ if (this.env.strictMode) {
+ return;
+ }
const ambiguousHeads = new Map();
const blockParamName = (0, scope_stack_1.unusedNameLike)('maybeHelpers', this.scopeStack);
for (const attrNode of elementNode.attributes) {
@@ -119,6 +128,9 @@ class ThisFallbackPlugin {
return {
keys: {
params: (node) => {
+ if (this.env.strictMode) {
+ return;
+ }
const { scopeStack } = this;
node.params = node.params.map((expr) => {
if ((0, fallback_1.needsFallback)(expr, scopeStack)) {
@@ -131,6 +143,9 @@ class ThisFallbackPlugin {
});
},
hash: (node) => {
+ if (this.env.strictMode) {
+ return;
+ }
const { scopeStack } = this;
node.hash.pairs = node.hash.pairs.map((pair) => {
const { key, value: expr, loc } = pair;
@@ -149,6 +164,9 @@ class ThisFallbackPlugin {
handleMustache() {
return {
enter: (node, path) => {
+ if (this.env.strictMode) {
+ return;
+ }
// Alias node to n so that the type of `node` doesn't get narrowed,
// which prevents mutation
const n = node;
@@ -174,9 +192,15 @@ class ThisFallbackPlugin {
handleTemplate() {
return {
enter: (node) => {
+ if (this.env.strictMode) {
+ return;
+ }
this.logger.debug("before: '%s'", (0, string_1.squish)((0, syntax_1.print)(node)));
},
exit: (node, path) => {
+ if (this.env.strictMode) {
+ return;
+ }
this.logger.debug("after_: '%s'", (0, string_1.squish)((0, syntax_1.print)(node)));
if (this.scopeStack.size !== 1) {
throw new Error(`unbalanced ScopeStack push and pop, ScopeStack size is ${this.scopeStack.size}`);

View File

@ -0,0 +1,246 @@
diff --git a/index.js b/index.js
index afa73eb078e35af27adee52a6784f405d94a7de8..21e941140ef8ed04e5e8a21e555fb2c7bf478658 100644
--- a/index.js
+++ b/index.js
@@ -8,7 +8,7 @@ module.exports = {
setupPreprocessorRegistry(type, registry) {
if (type === 'parent') {
- const options = getOptions(findHost(this));
+ const options = getOptions(this.parent); // findHost doesn't work for us - not sure why
registry.add('htmlbars-ast-plugin', this._buildPlugin(options));
}
},
@@ -17,15 +17,20 @@ module.exports = {
ThisFallbackPlugin.baseDir = () => __dirname;
ThisFallbackPlugin.cacheKey = () => 'ember-this-fallback';
- return {
+ let plugin = {
name: 'ember-this-fallback',
- parallelBabel: {
+ plugin: ThisFallbackPlugin(options),
+ };
+
+ if (!options.isTheme) {
+ plugin.parallelBabel = {
requireFile: __filename,
buildUsing: '_buildPlugin',
params: options,
- },
- plugin: ThisFallbackPlugin(options),
- };
+ };
+ }
+
+ return plugin;
},
};
diff --git a/lib/helpers/deprecations.js b/lib/helpers/deprecations.js
index 5a00c44dc77ee3a4083e51f13e5d28dc07c343f9..7fc09ada1d6eb8376519cbc88cfc838dab64b4b0 100644
--- a/lib/helpers/deprecations.js
+++ b/lib/helpers/deprecations.js
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.deprecationOptionsFor = void 0;
const assert_1 = __importDefault(require("../types/assert"));
const CURRENT_DEPRECATIONS = [
+ [
+ 'this-property-fallback',
{
- id: 'this-property-fallback',
+ id: 'ember-this-fallback.this-property-fallback', // Updating deprecation id so we can distinguish it from Ember's
until: 'n/a',
for: 'ember-this-fallback',
url: 'https://deprecations.emberjs.com/v3.x#toc_this-property-fallback',
@@ -15,8 +17,9 @@ const CURRENT_DEPRECATIONS = [
available: '0.2.0',
},
},
+ ]
];
-const DEPRECATION_OPTIONS_MAP = new Map(CURRENT_DEPRECATIONS.map((options) => [options.id, options]));
+const DEPRECATION_OPTIONS_MAP = new Map(CURRENT_DEPRECATIONS);
function deprecationOptionsFor(id) {
const options = DEPRECATION_OPTIONS_MAP.get(id);
(0, assert_1.default)(`expected to find DeprecationOptions for id=${id}`, options);
diff --git a/lib/helpers/logger.js b/lib/helpers/logger.js
index b856edc0327902bbae4eb9875ed9034a50d2b3a2..afb059ac4925711ba1b70079f4f45c4c4f8fe027 100644
--- a/lib/helpers/logger.js
+++ b/lib/helpers/logger.js
@@ -1,12 +1,6 @@
"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
Object.defineProperty(exports, "__esModule", { value: true });
exports.noopLogger = void 0;
-const debug_1 = __importDefault(require("debug"));
-const winston_1 = require("winston");
-const winston_transport_1 = __importDefault(require("winston-transport"));
function noopLogger() {
return {
debug: noop,
@@ -15,53 +9,4 @@ function noopLogger() {
};
}
exports.noopLogger = noopLogger;
-function createLogger(namespace, label) {
- const debug = (0, debug_1.default)(namespace);
- class DebugTransport extends winston_transport_1.default {
- log(info, next) {
- debug(info[Symbol.for('message')]);
- next();
- }
- }
- return (0, winston_1.createLogger)({
- level: 'debug',
- transports: [
- new winston_1.transports.File({
- level: 'info',
- filename: `${namespace}.log`,
- format: winston_1.format.combine(joinLines(), winston_1.format.label({ label }), winston_1.format.timestamp(), winston_1.format.splat(), logFormatter),
- }),
- new DebugTransport({
- level: 'debug',
- format: winston_1.format.combine(joinLines(), winston_1.format.label({ label }), winston_1.format.timestamp(), winston_1.format.splat(), debugFormatter),
- }),
- ],
- });
-}
-exports.default = createLogger;
-const joinLines = (0, winston_1.format)((info) => {
- if (Array.isArray(info.message) &&
- info.message.every((m) => typeof m === 'string')) {
- info.message = joinLogLines(info.message);
- }
- return info;
-});
-const logFormatter = winston_1.format.printf((info) => {
- const { level, label, timestamp, message, loc } = info;
- return `${timestamp} [${level}] ${concatMessage(label, message, loc)}`;
-});
-const debugFormatter = winston_1.format.printf((info) => {
- const { label, message } = info;
- return concatMessage(label, message);
-});
-function concatMessage(label, message, loc) {
- if (loc) {
- const start = loc.startPosition;
- label += `:${start.line}:${start.column + 1}`;
- }
- return joinLogLines([label, message]);
-}
-function joinLogLines(lines) {
- return lines.join('\n\t');
-}
function noop() { }
diff --git a/lib/this-fallback-plugin.js b/lib/this-fallback-plugin.js
index be4a78543644b3810520773aa7b996a2f631888d..9b144de8f22935dd6440a0db6b52a52535064212 100644
--- a/lib/this-fallback-plugin.js
+++ b/lib/this-fallback-plugin.js
@@ -29,7 +29,7 @@ const syntax_1 = require("@glimmer/syntax");
const ast_1 = require("./helpers/ast");
const deprecations_1 = require("./helpers/deprecations");
const fallback_1 = require("./helpers/fallback");
-const logger_1 = __importStar(require("./helpers/logger"));
+const logger_1 = require("./helpers/logger");
const scope_stack_1 = __importStar(require("./helpers/scope-stack"));
const string_1 = require("./helpers/string");
const assert_1 = __importDefault(require("./types/assert"));
@@ -60,9 +60,15 @@ class ThisFallbackPlugin {
handleBlock() {
return {
enter: (node) => {
+ if (this.env.strictMode) {
+ return;
+ }
this.scopeStack.push(node.blockParams);
},
exit: () => {
+ if (this.env.strictMode) {
+ return;
+ }
this.scopeStack.pop();
},
};
@@ -70,6 +76,9 @@ class ThisFallbackPlugin {
handleAttrNodes() {
return {
enter: (elementNode, elementPath) => {
+ if (this.env.strictMode) {
+ return;
+ }
const ambiguousHeads = new Map();
const blockParamName = (0, scope_stack_1.unusedNameLike)('maybeHelpers', this.scopeStack);
for (const attrNode of elementNode.attributes) {
@@ -119,6 +128,9 @@ class ThisFallbackPlugin {
return {
keys: {
params: (node) => {
+ if (this.env.strictMode) {
+ return;
+ }
const { scopeStack } = this;
node.params = node.params.map((expr) => {
if ((0, fallback_1.needsFallback)(expr, scopeStack)) {
@@ -131,6 +143,9 @@ class ThisFallbackPlugin {
});
},
hash: (node) => {
+ if (this.env.strictMode) {
+ return;
+ }
const { scopeStack } = this;
node.hash.pairs = node.hash.pairs.map((pair) => {
const { key, value: expr, loc } = pair;
@@ -149,6 +164,9 @@ class ThisFallbackPlugin {
handleMustache() {
return {
enter: (node, path) => {
+ if (this.env.strictMode) {
+ return;
+ }
// Alias node to n so that the type of `node` doesn't get narrowed,
// which prevents mutation
const n = node;
@@ -174,9 +192,15 @@ class ThisFallbackPlugin {
handleTemplate() {
return {
enter: (node) => {
+ if (this.env.strictMode) {
+ return;
+ }
this.logger.debug("before: '%s'", (0, string_1.squish)((0, syntax_1.print)(node)));
},
exit: (node, path) => {
+ if (this.env.strictMode) {
+ return;
+ }
this.logger.debug("after_: '%s'", (0, string_1.squish)((0, syntax_1.print)(node)));
if (this.scopeStack.size !== 1) {
throw new Error(`unbalanced ScopeStack push and pop, ScopeStack size is ${this.scopeStack.size}`);
@@ -214,9 +238,7 @@ class NoopPlugin {
function buildThisFallbackPlugin({ enableLogging, }) {
return (env) => {
const name = 'ember-this-fallback';
- const logger = enableLogging
- ? (0, logger_1.default)(`${name}-plugin`, env.moduleName)
- : (0, logger_1.noopLogger)();
+ const logger = (0, logger_1.noopLogger)();
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (env.meta.jsutils) {
return new ThisFallbackPlugin(name, env, logger);
diff --git a/package.json b/package.json
index ef220e46d232cc90d6b90607e4e99f32d5679cf4..8c140dabda2cb2ef25b22a86bffb640df9124ec8 100644
--- a/package.json
+++ b/package.json
@@ -108,7 +108,7 @@
},
"peerDependencies": {
"ember-cli-htmlbars": "^6.2.0",
- "ember-source": "^3.28.11 || ^4.0.0"
+ "ember-source": "^3.28.11 || ^4.0.0 || ^5.0.0"
},
"engines": {
"node": "16.* || >= 18"

View File

@ -0,0 +1,13 @@
diff --git a/index.js b/index.js
index 0a0a91720146b84a4b61bd9ec4b573652c133940..064c93ca41b1bb3ffdd9e36a74105146fffb2a9c 100644
--- a/index.js
+++ b/index.js
@@ -38,7 +38,7 @@ function licensee (configuration, path, callback) {
.then(function (tree) {
var dependencies = Array.from(tree.inventory.values())
.filter(function (dependency) {
- return !dependency.isProjectRoot
+ return !dependency.isProjectRoot && dependency.package.name
})
if (configuration.filterPackages) {
dependencies = configuration.filterPackages(dependencies)

View File

@ -1,7 +1,7 @@
diff --git a/node_modules/virtual-dom/vtree/diff.js b/node_modules/virtual-dom/vtree/diff.js
diff --git a/vtree/diff.js b/vtree/diff.js
index b5bccbd..058d6b3 100644
--- a/node_modules/virtual-dom/vtree/diff.js
+++ b/node_modules/virtual-dom/vtree/diff.js
--- a/vtree/diff.js
+++ b/vtree/diff.js
@@ -311,6 +311,38 @@ function reorder(aChildren, bChildren) {
var inserts = []
var simulateItem

18047
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

19
pnpm-workspace.yaml Normal file
View File

@ -0,0 +1,19 @@
packages:
- "app/assets/javascripts/admin"
- "app/assets/javascripts/custom-proxy"
- "app/assets/javascripts/deprecation-silencer"
- "app/assets/javascripts/dialog-holder"
- "app/assets/javascripts/discourse"
- "app/assets/javascripts/discourse-common"
- "app/assets/javascripts/discourse-hbr"
- "app/assets/javascripts/discourse-i18n"
- "app/assets/javascripts/discourse-markdown-it"
- "app/assets/javascripts/discourse-plugins"
- "app/assets/javascripts/discourse-widget-hbs"
- "app/assets/javascripts/ember-cli-progress-ci"
- "app/assets/javascripts/ember-production-deprecations"
- "app/assets/javascripts/float-kit"
- "app/assets/javascripts/pretty-text"
- "app/assets/javascripts/select-kit"
- "app/assets/javascripts/theme-transpiler"
- "app/assets/javascripts/truth-helpers"

View File

@ -159,7 +159,11 @@ RSpec.describe DiscourseJsProcessor do
let(:mini_racer) do
ctx = MiniRacer::Context.new
ctx.eval(File.open("#{Rails.root}/node_modules/handlebars/dist/handlebars.js").read)
ctx.eval(
File.open(
"#{Rails.root}/app/assets/javascripts/discourse/node_modules/handlebars/dist/handlebars.js",
).read,
)
ctx.eval(helpers)
ctx
end

View File

@ -4,17 +4,17 @@ require "mini_racer"
RSpec.describe JsLocaleHelper do
let(:v8_ctx) do
node_modules = "#{Rails.root}/node_modules/"
discourse_node_modules = "#{Rails.root}/app/assets/javascripts/discourse/node_modules"
mf_runtime = "#{discourse_node_modules}/@messageformat/runtime"
transpiler = DiscourseJsProcessor::Transpiler.new
ctx = MiniRacer::Context.new
ctx.load("#{node_modules}/loader.js/dist/loader/loader.js")
ctx.load("#{discourse_node_modules}/loader.js/dist/loader/loader.js")
ctx.eval("var window = globalThis;")
{
"@messageformat/runtime/messages": "#{node_modules}/@messageformat/runtime/esm/messages.js",
"@messageformat/runtime": "#{node_modules}/@messageformat/runtime/esm/runtime.js",
"@messageformat/runtime/lib/cardinals":
"#{node_modules}/@messageformat/runtime/esm/cardinals.js",
"make-plural/cardinals": "#{node_modules}/make-plural/cardinals.mjs",
"@messageformat/runtime/messages": "#{mf_runtime}/esm/messages.js",
"@messageformat/runtime": "#{mf_runtime}/esm/runtime.js",
"@messageformat/runtime/lib/cardinals": "#{mf_runtime}/esm/cardinals.js",
"make-plural/cardinals": "#{discourse_node_modules}/make-plural/cardinals.mjs",
"discourse-i18n": "#{Rails.root}/app/assets/javascripts/discourse-i18n/src/index.js",
}.each do |module_name, path|
ctx.eval(transpiler.perform(File.read(path), "", module_name.to_s))

13016
yarn.lock

File diff suppressed because it is too large Load Diff