2014-10-23 11:11:39 +02:00
|
|
|
#-- copyright
|
2020-01-15 11:31:26 +01:00
|
|
|
# OpenProject is an open source project management software.
|
2024-07-30 13:42:36 +02:00
|
|
|
# Copyright (C) the OpenProject GmbH
|
2014-10-23 11:11:39 +02:00
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
|
# modify it under the terms of the GNU General Public License version 3.
|
|
|
|
|
#
|
|
|
|
|
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
2021-01-13 17:47:45 +01:00
|
|
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
2014-10-23 11:11:39 +02:00
|
|
|
# Copyright (C) 2010-2013 the ChiliProject Team
|
|
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
#
|
2021-09-02 21:49:06 +02:00
|
|
|
# See COPYRIGHT and LICENSE files for more details.
|
2014-10-23 11:11:39 +02:00
|
|
|
#++
|
|
|
|
|
|
2018-06-01 10:30:48 +02:00
|
|
|
require "open_project/assets"
|
2014-10-23 11:11:39 +02:00
|
|
|
|
2018-06-01 10:30:48 +02:00
|
|
|
# The ng build task must run before assets:environment task.
|
2014-10-23 11:11:39 +02:00
|
|
|
# Otherwise Sprockets cannot find the files that webpack produces.
|
|
|
|
|
Rake::Task["assets:precompile"]
|
|
|
|
|
.clear_prerequisites
|
2020-07-09 11:02:43 +02:00
|
|
|
.enhance(%w[assets:compile_environment assets:prepare_op])
|
2014-10-23 11:11:39 +02:00
|
|
|
|
|
|
|
|
namespace :assets do
|
|
|
|
|
# In this task, set prerequisites for the assets:precompile task
|
2016-07-13 15:22:26 +02:00
|
|
|
task compile_environment: :prepare_op do
|
2021-07-21 11:26:31 -04:00
|
|
|
# Turn the yarn:install task into a noop.
|
2020-12-14 08:52:29 +01:00
|
|
|
Rake::Task["yarn:install"]
|
|
|
|
|
.clear
|
|
|
|
|
|
2014-10-23 11:11:39 +02:00
|
|
|
Rake::Task["assets:environment"].invoke
|
|
|
|
|
end
|
|
|
|
|
|
2018-06-01 10:30:48 +02:00
|
|
|
desc "Prepare locales and angular assets"
|
2021-02-11 16:02:18 +01:00
|
|
|
task prepare_op: %i[export_locales angular]
|
2016-07-13 15:22:26 +02:00
|
|
|
|
2014-10-23 11:11:39 +02:00
|
|
|
desc "Compile assets with webpack"
|
2018-06-01 10:30:48 +02:00
|
|
|
task :angular do
|
2019-05-23 10:57:47 +02:00
|
|
|
# We skip angular compilation if backend was requested
|
|
|
|
|
# but frontend was not explicitly set
|
|
|
|
|
if ENV["RECOMPILE_RAILS_ASSETS"] == "true" && ENV["RECOMPILE_ANGULAR_ASSETS"] != "true"
|
|
|
|
|
next
|
|
|
|
|
end
|
|
|
|
|
|
2018-06-01 10:30:48 +02:00
|
|
|
OpenProject::Assets.clear!
|
|
|
|
|
|
2019-05-23 10:57:47 +02:00
|
|
|
puts "Linking frontend plugins"
|
|
|
|
|
Rake::Task["openproject:plugins:register_frontend"].invoke
|
|
|
|
|
|
2018-06-20 08:26:24 +02:00
|
|
|
puts "Building angular frontend"
|
2014-11-26 13:46:52 +01:00
|
|
|
Dir.chdir Rails.root.join("frontend") do
|
2025-08-20 13:32:27 +02:00
|
|
|
sh("npm run build") do |ok, res|
|
2018-06-20 08:57:33 +02:00
|
|
|
raise "Failed to compile angular frontend: #{res.exitstatus}" if !ok
|
2018-06-20 08:26:24 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-11-12 15:05:03 +01:00
|
|
|
Rake::Task["assets:rebuild_manifest"].invoke
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
desc "Write angular assets manifest"
|
|
|
|
|
task :rebuild_manifest do
|
2018-06-01 10:30:48 +02:00
|
|
|
puts "Writing angular assets manifest"
|
|
|
|
|
OpenProject::Assets.rebuild_manifest!
|
2014-10-23 11:11:39 +02:00
|
|
|
end
|
|
|
|
|
|
2016-07-13 08:49:19 +02:00
|
|
|
desc "Export frontend locale files"
|
2023-07-26 17:33:53 +02:00
|
|
|
task export_locales: :environment do
|
2023-07-19 08:42:45 +02:00
|
|
|
puts "Exporting I18n.js locales"
|
|
|
|
|
time = Benchmark.realtime do
|
|
|
|
|
I18nJS.call(config_file: Rails.root.join("config/i18n.yml"))
|
2023-07-18 21:39:33 +02:00
|
|
|
end
|
2023-07-19 08:42:45 +02:00
|
|
|
puts "=> Done in #{time.round(2)}s"
|
2023-07-18 21:39:33 +02:00
|
|
|
end
|
2014-10-23 11:11:39 +02:00
|
|
|
end
|