BigW Consortium Gitlab

Commit e6529879 by Mike Greiling

ensure rake tasks produce helpful error messages for node dependency issues

parent b36542e1
unless Rails.env.production?
desc "GitLab | Run ESLint"
task :eslint do
system("yarn", "run", "eslint")
task eslint: ['yarn:check'] do
sh "yarn run eslint" do |ok, res|
abort('rake eslint failed') unless ok
end
end
end
namespace :gitlab do
namespace :assets do
desc 'GitLab | Assets | Compile all frontend assets'
task :compile do
Rake::Task['assets:precompile'].invoke
Rake::Task['webpack:compile'].invoke
Rake::Task['gitlab:assets:fix_urls'].invoke
end
task compile: [
'yarn:check',
'assets:precompile',
'webpack:compile',
'gitlab:assets:fix_urls'
]
desc 'GitLab | Assets | Clean up old compiled frontend assets'
task :clean do
Rake::Task['assets:clean'].invoke
end
task clean: ['assets:clean']
desc 'GitLab | Assets | Remove all compiled frontend assets'
task :purge do
Rake::Task['assets:clobber'].invoke
end
task purge: ['assets:clobber']
desc 'GitLab | Assets | Uninstall frontend dependencies'
task purge_modules: ['yarn:clobber']
desc 'GitLab | Assets | Fix all absolute url references in CSS'
task :fix_urls do
......
unless Rails.env.production?
Rake::Task['karma'].clear if Rake::Task.task_defined?('karma')
namespace :karma do
desc 'GitLab | Karma | Generate fixtures for JavaScript tests'
RSpec::Core::RakeTask.new(:fixtures) do |t|
......@@ -10,7 +8,7 @@ unless Rails.env.production?
end
desc 'GitLab | Karma | Run JavaScript tests'
task :tests do
task tests: ['yarn:check'] do
sh "yarn run karma" do |ok, res|
abort('rake karma:tests failed') unless ok
end
......@@ -18,8 +16,5 @@ unless Rails.env.production?
end
desc 'GitLab | Karma | Shortcut for karma:fixtures and karma:tests'
task :karma do
Rake::Task['karma:fixtures'].invoke
Rake::Task['karma:tests'].invoke
end
task karma: ['karma:fixtures', 'karma:tests']
end
namespace :yarn do
desc 'Ensure Yarn is installed'
task :available do
unless system('yarn --version', out: File::NULL)
warn(
'Error: Yarn executable was not detected in the system.'.color(:red),
'Download Yarn at https://yarnpkg.com/en/docs/install'.color(:green)
)
abort
end
end
desc 'Ensure Node dependencies are installed'
task check: ['yarn:available'] do
unless system('yarn check --ignore-engines', out: File::NULL)
warn(
'Error: You have unmet dependencies. (`yarn check` command failed)'.color(:red),
'Run `yarn install` to install missing modules.'.color(:green)
)
abort
end
end
desc 'Install Node dependencies with Yarn'
task install: ['yarn:available'] do
unless system('yarn install --force --pure-lockfile --ignore-engines')
abort 'Error: Unable to install node modules.'.color(:red)
end
end
desc 'Remove Node dependencies'
task :clobber do
warn 'Purging ./node_modules directory'.color(:red)
FileUtils.rm_rf 'node_modules'
end
end
desc 'Install Node dependencies with Yarn'
task yarn: ['yarn:install']
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment