DEV: Switch default Ember version to 5 (#25203)

https://meta.discourse.org/t/287211
This commit is contained in:
David Taylor 2024-01-10 12:12:36 +00:00 committed by GitHub
parent 627415eb21
commit 7a8cbf8422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 30 deletions

View File

@ -32,14 +32,14 @@ jobs:
node -e '
const version = require("ember-source/package.json").version;
console.log("Ember version is", version);
if(version.split(".")[0] !== "3"){
console.log(`Ember has unexpectedly been upgraded to version ${version}. If this is intentional, remove this github workflow.`);
if(version.split(".")[0] !== "5"){
console.log(`Ember has unexpectedly been downgraded to version ${version}. If this is intentional, remove this github workflow.`);
process.exit(1);
}
'
- name: Upgrade ember
- name: Downgrade ember
run: |
script/switch_ember_version 5
script/switch_ember_version 3
cd app/assets/javascripts/discourse
yarn install
- name: "Check upgraded version"
@ -48,19 +48,19 @@ jobs:
node -e '
const version = require("ember-source/package.json").version;
console.log("Ember version is", version);
if(version.split(".")[0] !== "5"){
console.log(`Expected Ember 5, but found ${version}`);
if(version.split(".")[0] !== "3"){
console.log(`Expected Ember 3, but found ${version}`);
process.exit(1);
}
'
- name: "Revert ember upgrade"
- name: "Revert ember downgrade"
run: |
script/switch_ember_version 3
script/switch_ember_version 5
- name: "Ensure no diff"
run: |
if [ ! -z "$(git status --porcelain)" ]; then
echo "Working directory was not clean after upgrading/downgrading ember. Perhaps a lockfile is out-of-date. Run this command to re-sync:"
echo " script/regen_ember_5_lockfile"
echo " script/regen_ember_3_lockfile"
echo
echo "Current diff:"
echo "---------------------------------------------"

View File

@ -20,11 +20,11 @@ jobs:
run: |
# Dependabot gets confused by the symlinks and dumps the updated lockfile in the root of the repo.
# Let's move it back to the correct location.
if [[ -f yarn-ember3.lock ]]; then
mv yarn-ember3.lock app/assets/javascripts/yarn-ember3.lock
if [[ -f yarn-ember5.lock ]]; then
mv yarn-ember5.lock app/assets/javascripts/yarn-ember5.lock
fi
- name: Update ember5 lockfile
run: script/regen_ember_5_lockfile
- name: Update ember3 lockfile
run: script/regen_ember_3_lockfile
- name: Push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -109,10 +109,6 @@ jobs:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-cachev2
- name: Upgrade Ember
if: matrix.updated_ember == true
run: script/switch_ember_version 5
- name: Yarn install
run: yarn install --frozen-lockfile
@ -369,9 +365,9 @@ jobs:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-cachev2
- name: Upgrade Ember
if: matrix.updated_ember == true
run: script/switch_ember_version 5
- name: Downgrade Ember
if: matrix.updated_ember == false
run: script/switch_ember_version 3
- name: Yarn install
working-directory: ./app/assets/javascripts/discourse

View File

@ -1 +1 @@
package-ember3.json
package-ember5.json

View File

@ -1 +1 @@
yarn-ember3.lock
yarn-ember5.lock

View File

@ -62,7 +62,7 @@ end
system(
"script/switch_ember_version",
ENV["EMBER_VERSION"] || "3",
ENV["EMBER_VERSION"] || "5",
exception: true,
chdir: RAILS_ROOT,
)

View File

@ -8,12 +8,12 @@ end
task "assets:precompile:build" do
if ENV["SKIP_EMBER_CLI_COMPILE"] != "1"
ember_version = ENV["EMBER_VERSION"] || "3"
ember_version = ENV["EMBER_VERSION"] || "5"
raise "Unknown ember version '#{ember_version}'" if !%w[3 5].include?(ember_version)
if ENV["EMBER_VERSION"] == "5"
puts "Upgrading to Ember 5..."
if ember_version == "3"
puts "Downgrading to Ember 3..."
system("script/switch_ember_version", ember_version, exception: true, chdir: Rails.root)
system("yarn install", exception: true, chdir: "app/assets/javascripts/discourse")
end

View File

@ -5,12 +5,12 @@ require "fileutils"
# rubocop:disable Discourse/NoChdir
Dir.chdir("#{__dir__}/../app/assets/javascripts") do
FileUtils.rm("yarn-ember5.lock")
FileUtils.cp("yarn-ember3.lock", "yarn-ember5.lock")
FileUtils.rm("yarn-ember3.lock")
FileUtils.cp("yarn-ember5.lock", "yarn-ember3.lock")
system("#{__dir__}/switch_ember_version", "5", exception: true)
system("#{__dir__}/switch_ember_version", "3", exception: true)
system "yarn install", exception: true
system("#{__dir__}/switch_ember_version", "3", exception: true)
system("#{__dir__}/switch_ember_version", "5", exception: true)
end