diff --git a/.rubocop.yml b/.rubocop.yml index 4420a6b76..c33b2835f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -109,6 +109,9 @@ Layout/EmptyLinesAroundModuleBody: Description: "Keeps track of empty lines around module bodies." Enabled: false +Layout/MultilineMethodCallIndentation: + EnforcedStyle: indented_relative_to_receiver + Style/MultilineBlockChain: Description: 'Avoid multi-line chains of blocks.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks' @@ -226,3 +229,9 @@ Lint/AmbiguousBlockAssociation: Exclude: - "**/*_spec.rb" - "**/*_examples.rb" + +# Special exceptions + +Style/HashSyntax: + Exclude: + - "**/*.rake" diff --git a/Rakefile b/Rakefile index 9e4caa9ae..e633ef71c 100755 --- a/Rakefile +++ b/Rakefile @@ -2,6 +2,6 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.expand_path('config/application', __dir__) +require_relative 'config/application' Zammad::Application.load_tasks diff --git a/lib/tasks/bootstrap.rake b/lib/tasks/bootstrap.rake new file mode 100644 index 000000000..7b3f7df87 --- /dev/null +++ b/lib/tasks/bootstrap.rake @@ -0,0 +1,27 @@ +namespace :bs do + desc 'Bootstrap the application' + task :init => %i[db:create db:migrate db:seed] do + run_auto_wizard + end + + desc 'Reset the application to its initial state' + task :reset => %i[db:reset] do + flush_cache_and_logs + run_auto_wizard + end +end + +APP_CACHE = Dir.glob(Rails.root.join('tmp', 'cache*')) +SERVER_LOG = Rails.root.join('log', Rails.env) +AUTO_WIZARD = { source: Rails.root.join('contrib', 'auto_wizard_test.json'), + destination: Rails.root.join('auto_wizard.json') }.freeze + +def flush_cache_and_logs + FileUtils.rm_rf(APP_CACHE) + File.write(SERVER_LOG, '') +end + +def run_auto_wizard + FileUtils.ln(AUTO_WIZARD[:source], AUTO_WIZARD[:destination], force: true) + system('rails runner "AutoWizard.setup"') +end