Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discourse: 3.1.0 -> 3.2.1 #10

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
diff --git a/app/assets/javascripts/discourse/package.json b/app/assets/javascripts/discourse/package.json
index 9e4533d2..e57f8a5f 100644
index 72ef171cdc..24c7942e8c 100644
--- a/app/assets/javascripts/discourse/package.json
+++ b/app/assets/javascripts/discourse/package.json
@@ -14,7 +14,7 @@
@@ -13,7 +13,7 @@
"build": "ember build",
"start": "ember serve",
"test": "ember test",
- "postinstall": "yarn --silent --cwd .. patch-package"
- "postinstall": "../run-patch-package"
+ "postinstall": "patch-package"
},
"dependencies": {
"@babel/core": "^7.21.4",
"@glimmer/syntax": "^0.84.3",
18 changes: 9 additions & 9 deletions pkgs/servers/web-apps/discourse/assets_rake_command.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake
index 68b5db61ac..d460b5753e 100644
index 9608297789..5487490915 100644
--- a/lib/tasks/assets.rake
+++ b/lib/tasks/assets.rake
@@ -19,7 +19,7 @@ task 'assets:precompile:before' do

if only_assets_precompile_remaining
# Using exec to free up Rails app memory during ember build
- exec "#{compile_command} && EMBER_CLI_COMPILE_DONE=1 bin/rake assets:precompile"
+ exec "#{compile_command} && EMBER_CLI_COMPILE_DONE=1 bundle exec rake assets:precompile"
@@ -36,7 +36,7 @@ task "assets:precompile:build" do
if only_ember_precompile_build_remaining
exec "#{compile_command}"
elsif only_assets_precompile_remaining
- exec "#{compile_command} && SKIP_EMBER_CLI_COMPILE=1 bin/rake assets:precompile"
+ exec "#{compile_command} && SKIP_EMBER_CLI_COMPILE=1 bundle exec rake assets:precompile"
else
system compile_command
end
system compile_command, exception: true
EmberCli.clear_cache!
75 changes: 43 additions & 32 deletions pkgs/servers/web-apps/discourse/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@
}@args:

let
version = "3.1.0";
version = "3.2.1";

src = fetchFromGitHub {
owner = "discourse";
repo = "discourse";
rev = "v${version}";
sha256 = "sha256-Iv7VSnK8nZDpmIwIRPedSWlftABKuMOQ4MXDGpjuWrY=";
sha256 = "sha256-bvCXJIJOrIak+/aaUYoripT/+A8Dnl3uqhNEnbDknJE=";
};

ruby = ruby_3_2;
Expand All @@ -65,6 +65,7 @@ let
gnutar
git
brotli
nodejs_18

# Misc required system utils
which
Expand Down Expand Up @@ -200,19 +201,22 @@ let
pname = "discourse-assets";
inherit version src;

yarnDevOfflineCache = fetchYarnDeps {
yarnLock = src + "/yarn.lock";
sha256 = "sha256-0s8c2V8Wl3f5kL1OIn2ps6hL7CUQD5+LJm+9LYHc+W0=";
};

yarnOfflineCache = fetchYarnDeps {
yarnLock = src + "/app/assets/javascripts/yarn.lock";
sha256 = "0sclrv3303dgg3r08dwhd1yvi3pvlnvnikn300vjsh6c71fnzhnj";
yarnLock = src + "/app/assets/javascripts/yarn-ember5.lock";
sha256 = "0ggh7g4678ik9m5bczr6kdirmspqh2i7nc0b92jdsmy7s4syy5b4";
};

nativeBuildInputs = runtimeDeps ++ [
postgresql
redis
nodePackages.uglify-js
terser
nodePackages.patch-package
yarn
nodejs_18
jq
moreutils
prefetch-yarn-deps
Expand All @@ -234,13 +238,14 @@ let
# assets precompilation task.
./assets_rake_command.patch

# `app/assets/javascripts/discourse/package.json`'s postinstall
# hook tries to call `../node_modules/.bin/patch-package`, which
# hasn't been `patchShebangs`-ed yet. So instead we just use
# `patch-package` from `nativeBuildInputs`.
./asserts_patch-package_from_path.patch
# Little does he know, so he decided there is no need to generate the
# theme-transpiler over and over again. Which at the same time allows the removal
# of javascript devDependencies from the runtime environment.
./prebuild-theme-transpiler.patch
];

RAILS_ENV = "production";

# We have to set up an environment that is close enough to
# production ready or the assets:precompile task refuses to
# run. This means that Redis and PostgreSQL has to be running and
Expand All @@ -249,26 +254,31 @@ let
# Yarn wants a real home directory to write cache, config, etc to
export HOME=$NIX_BUILD_TOP/fake_home

# Make yarn install packages from our offline cache, not the registry
yarn config --offline set yarn-offline-mirror $yarnOfflineCache
yarn_install() {
local offlineCache=$1 yarnLock=$2

# Fixup "resolved"-entries in yarn.lock to match our offline cache
fixup-yarn-lock app/assets/javascripts/yarn.lock
# Make yarn install packages from our offline cache, not the registry
yarn config --offline set yarn-offline-mirror $offlineCache

export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
# Fixup "resolved"-entries in yarn.lock to match our offline cache
fixup-yarn-lock $yarnLock

# Install while ignoring hook scripts
yarn --offline --ignore-scripts --cwd $(dirname $yarnLock) install
}

find app/assets/javascripts -name package.json -print0 \
| xargs -0 -I {} bash -c "jq 'del(.scripts.postinstall)' -r <{} | sponge {}"
yarn install --offline --cwd app/assets/javascripts/discourse
# Install devDependencies for generating the theme-transpiler executed as
# dependent task assets:precompile:theme_transpiler before db:migrate
yarn_install $yarnDevOfflineCache yarn.lock

patchShebangs app/assets/javascripts/node_modules/
# Install the runtime dependencies
yarn_install $yarnOfflineCache app/assets/javascripts/yarn-ember5.lock

# Run `patch-package` AFTER the corresponding shebang inside `.bin/patch-package`
# got patched. Otherwise this will fail with
# /bin/sh: line 1: /build/source/app/assets/javascripts/node_modules/.bin/patch-package: cannot execute: required file not found
pushd app/assets/javascripts &>/dev/null
yarn run patch-package
popd &>/dev/null
# Patch before running postinstall hook script
patchShebangs --build app/assets/javascripts
yarn --offline --cwd app/assets/javascripts run postinstall

export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt

redis-server >/dev/null &

Expand All @@ -286,14 +296,8 @@ let
psql 'discourse' -tAc "CREATE EXTENSION IF NOT EXISTS pg_trgm"
psql 'discourse' -tAc "CREATE EXTENSION IF NOT EXISTS hstore"

# Create a temporary home dir to stop bundler from complaining
mkdir $NIX_BUILD_TOP/tmp_home
export HOME=$NIX_BUILD_TOP/tmp_home

${lib.concatMapStringsSep "\n" (p: "ln -sf ${p} plugins/${p.pluginName or ""}") plugins}

export RAILS_ENV=production

bundle exec rake db:migrate >/dev/null
chmod -R +w tmp
'';
Expand Down Expand Up @@ -352,6 +356,11 @@ let

# Make sure the notification email setting applies
./notification_email.patch

# Little does he know, so he decided there is no need to generate the
# theme-transpiler over and over again. Which at the same time allows the removal
# of javascript devDependencies from the runtime environment.
./prebuild-theme-transpiler.patch
];

postPatch = ''
Expand All @@ -363,6 +372,8 @@ let
sed -Ei "s,(\.\./)+(lib|app)/,$out/share/discourse/\2/," {} \;
find config -maxdepth 1 -type f -name "*.rb" -execdir \
sed -Ei "s,require_relative (\"|')([[:alnum:]].*)(\"|'),require_relative '$out/share/discourse/config/\2'," {} \;

cp ${./yarn.lock} yarn.lock
'';

buildPhase = ''
Expand Down
21 changes: 21 additions & 0 deletions pkgs/servers/web-apps/discourse/prebuild-theme-transpiler.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/lib/discourse_js_processor.rb b/lib/discourse_js_processor.rb
index 26d142fa4d..6040aba6f4 100644
--- a/lib/discourse_js_processor.rb
+++ b/lib/discourse_js_processor.rb
@@ -68,7 +68,7 @@ class DiscourseJsProcessor
TRANSPILER_PATH =
(
if Rails.env.production?
- "tmp/theme-transpiler.js"
+ "app/assets/javascripts/theme-transpiler.js"
else
"tmp/theme-transpiler/#{Process.pid}.js"
end
@@ -87,6 +87,6 @@ class DiscourseJsProcessor
"node",
"app/assets/javascripts/theme-transpiler/build.js",
TRANSPILER_PATH,
- )
+ ) if !Rails.env.production? or !File.file?(TRANSPILER_PATH)
TRANSPILER_PATH
end
49 changes: 21 additions & 28 deletions pkgs/servers/web-apps/discourse/rubyEnv/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,14 @@ source "https://rubygems.org"

gem "bootsnap", require: false, platform: :mri

def rails_master?
ENV["RAILS_MASTER"] == "1"
end

if rails_master?
gem "arel", git: "https://github.com/rails/arel.git"
gem "rails", git: "https://github.com/rails/rails.git"
else
# NOTE: Until rubygems gives us optional dependencies we are stuck with this needing to be explicit
# this allows us to include the bits of rails we use without pieces we do not.
#
# To issue a rails update bump the version number here
rails_version = "7.0.5.1"
gem "actionmailer", rails_version
gem "actionpack", rails_version
gem "actionview", rails_version
gem "activemodel", rails_version
gem "activerecord", rails_version
gem "activesupport", rails_version
gem "railties", rails_version
gem "sprockets-rails"
end
gem "actionmailer", "< 7.1"
gem "actionpack", "< 7.1"
gem "actionview", "< 7.1"
gem "activemodel", "< 7.1"
gem "activerecord", "< 7.1"
gem "activesupport", "< 7.1"
gem "railties", "< 7.1"
gem "sprockets-rails"

gem "json"

Expand Down Expand Up @@ -141,10 +127,11 @@ group :test do
gem "fakeweb", require: false
gem "minitest", require: false
gem "simplecov", require: false
gem "selenium-webdriver", require: false
gem "selenium-webdriver", "~> 4.14", require: false
gem "selenium-devtools", require: false
gem "test-prof"
gem "webdrivers", require: false
gem "rails-dom-testing", require: false
gem "minio_runner", require: false
end

group :test, :development do
Expand All @@ -158,7 +145,7 @@ group :test, :development do

gem "rspec-rails"

gem "shoulda-matchers", require: false, github: "thoughtbot/shoulda-matchers"
gem "shoulda-matchers", require: false
gem "rspec-html-matchers"
gem "byebug", require: ENV["RM_INFO"].nil?, platform: :mri
gem "rubocop-discourse", require: false
Expand Down Expand Up @@ -209,7 +196,9 @@ gem "rack-mini-profiler", require: ["enable_rails_patches"]

gem "unicorn", require: false, platform: :ruby
gem "puma", require: false

gem "rbtrace", require: false, platform: :mri

gem "gc_tracer", require: false, platform: :mri

# required for feed importing and embedding
Expand All @@ -228,9 +217,8 @@ gem "logstash-event", require: false
gem "logstash-logger", require: false
gem "logster"

# These are forks of sassc and sassc-rails with dart-sass support
gem "dartsass-ruby"
gem "dartsass-sprockets"
# A fork of sassc with dart-sass support
gem "sassc-embedded"

gem "rotp", require: false

Expand Down Expand Up @@ -259,6 +247,11 @@ if ENV["IMPORT"] == "1"
gem "parallel", require: false
end

group :generic_import, optional: true do
gem "sqlite3"
gem "redcarpet"
end

gem "web-push"
gem "colored2", require: false
gem "maxminddb"
Expand Down
Loading