diff --git a/.rubocop.yml b/.rubocop.yml index eceff9a33ce..e7ff55ffed8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -9,7 +9,7 @@ Rails: AllCops: Exclude: - db/migrate/20131014135042_katello_tables.rb - - engines/bastion_katello/node_modules/**/* + - engines/*/node_modules/**/* - engines/bastion_katello/bastion-*/**/* - engines/bastion_katello/vendor/assets/dev-components/**/* - engines/bastion_katello/Rakefile diff --git a/engines/bastion/README.md b/engines/bastion/README.md index be32fda72c8..5310b9e3dd2 100644 --- a/engines/bastion/README.md +++ b/engines/bastion/README.md @@ -32,16 +32,18 @@ BASTION_MODULES.push('myModuleName'); ### Plugin Development ### -Bastion supplies a common set of testing and development using Grunt. These Grunt based tasks have been wrapped in Rake to make them more familiar to a Rails developer. To setup your development environment, from your plugin's checkout: +Bastion supplies a common set of testing and development using Grunt. To setup your development environment, from your plugin's checkout: ``` -rake bastion:setup +sudo npm install -g grunt-cli +npm install +npm install ../bastion/ ``` To run your plugin's tests and lint them: ``` -rake bastion:ci +grunt ci ``` ### Basics of Adding a New Entity ### @@ -188,13 +190,14 @@ Open the file, and add the following lines (with empty lines above and below for To setup a development environment, clone the repository or your fork of the repository. From the git checkout, setup the required development dependencies by running: ``` -rake bastion:setup +sudo npm install -g grunt-cli +npm install ``` After making changes, tests and linting can be run via: ``` -rake bastion:ci +grunt ci ``` ### Dependencies ### diff --git a/engines/bastion/Rakefile b/engines/bastion/Rakefile deleted file mode 100644 index 51016e44a9b..00000000000 --- a/engines/bastion/Rakefile +++ /dev/null @@ -1,60 +0,0 @@ -require 'open3' -require 'bastion/engine' - -namespace :bastion do - - desc 'Run linting and tests for the plugin' - task 'ci' do - success = grunt('ci') - exit!(1) if !success - end - - desc 'Run any grunt task by specifying the argument' - task 'grunt', [:task] do |task, args| - success = grunt(args[:task]) - exit!(1) if !success - end - - desc 'Setup development environment' - task 'setup' do - puts "Setting up development environment" - - setup_npm - end - -end - -def grunt(command) - syscall("grunt #{command}") -end - -def bastion_core? - Dir.pwd.split('/').last == 'bastion' -end - -def setup_npm - syscall('sudo yum install -y nodejs npm') if !system('rpm -q nodejs') || !system('rpm -q npm') - syscall('sudo npm -g install grunt-cli bower yo phantomjs') - - puts "Installing NPM dependencies" - syscall("npm install #{Bastion::Engine.root}") if !bastion_core? - syscall("npm install") if File.exist?('package.json') - syscall("bower install") if bastion_core? -end - -def syscall(*cmd) - Open3.popen3(*cmd) do |stdin, stdout, stderr, thread| - - # read each stream from a new thread - { :out => stdout, :err => stderr }.each do |key, stream| - Thread.new do - until (raw_line = stream.gets).nil? do - puts raw_line - end - end - end - - thread.join # don't exit until the external process is done - thread.value.success? - end -end diff --git a/engines/bastion/config/routes.rb b/engines/bastion/config/routes.rb index 8b63f51551f..3f62e871d3a 100644 --- a/engines/bastion/config/routes.rb +++ b/engines/bastion/config/routes.rb @@ -1,7 +1,5 @@ Foreman::Application.routes.draw do - class BastionPagesConstraint - def matches?(request) pages.include?(request.params[:bastion_page]) end @@ -9,15 +7,13 @@ def matches?(request) private def pages - pages = Bastion.plugins.collect { |name, plugin| plugin[:pages] } + pages = Bastion.plugins.collect { |_name, plugin| plugin[:pages] } pages.flatten end - end scope :module => :bastion do get '/:bastion_page/(*path)', :to => "bastion#index", constraints: BastionPagesConstraint.new get '/bastion/(*path)', :to => "bastion#index_ie" end - end diff --git a/engines/bastion/lib/bastion.rb b/engines/bastion/lib/bastion.rb index e7ede1e99b7..b00f9bef6c6 100644 --- a/engines/bastion/lib/bastion.rb +++ b/engines/bastion/lib/bastion.rb @@ -4,9 +4,9 @@ require File.expand_path('bastion/engine', File.dirname(__FILE__)) +#rubocop:disable Style/ClassVars module Bastion - - @@plugins = {}; + @@plugins = {} def self.plugins @@plugins @@ -23,7 +23,7 @@ def self.config 'relativeUrlRoot' => url_root ? url_root + '/' : '/' } - Bastion.plugins.each do |name, plugin| + Bastion.plugins.each do |_name, plugin| base_config.merge!(plugin[:config]) if plugin[:config] end @@ -33,5 +33,4 @@ def self.config def self.localization_path(locale) "bastion/angular-i18n/angular-locale_#{locale}.js" end - end diff --git a/engines/bastion/lib/bastion/engine.rb b/engines/bastion/lib/bastion/engine.rb index 0d39b08e378..eafeefd6f9c 100644 --- a/engines/bastion/lib/bastion/engine.rb +++ b/engines/bastion/lib/bastion/engine.rb @@ -2,7 +2,6 @@ module Bastion class Engine < ::Rails::Engine - isolate_namespace Bastion initializer 'bastion.assets_dispatcher', :before => :build_middleware_stack do |app| @@ -18,13 +17,13 @@ class Engine < ::Rails::Engine app.config.assets.paths << "#{Bastion::Engine.root}/vendor/assets/stylesheets/bastion" end - initializer "bastion.configure_assets", :group => :all do |app| + initializer "bastion.configure_assets", :group => :all do |_app| SETTINGS[:bastion] = {:assets => {}} if SETTINGS[:bastion].nil? SETTINGS[:bastion][:assets] = {} if SETTINGS[:bastion][:assets].nil? SETTINGS[:bastion][:assets][:precompile] = [ 'bastion/bastion.css', - 'bastion/bastion.js', + 'bastion/bastion.js' ] locale_files = Dir.glob("#{Bastion::Engine.root}/vendor/assets/javascripts/#{Bastion.localization_path("*")}") @@ -42,16 +41,5 @@ class Engine < ::Rails::Engine initializer "angular_templates", :group => :all do |app| app.config.angular_templates.ignore_prefix = %w([bastion]*\/+) end - - initializer 'bastion.register_plugin', :before => :finisher_hook do - Foreman::Plugin.register :bastion do - requires_foreman '>= 1.15' - end - end - - rake_tasks do - load "#{Bastion::Engine.root}/Rakefile" - end - end end diff --git a/engines/bastion/lib/bastion/version.rb b/engines/bastion/lib/bastion/version.rb index 903bfd504c3..76237681074 100644 --- a/engines/bastion/lib/bastion/version.rb +++ b/engines/bastion/lib/bastion/version.rb @@ -1,3 +1,3 @@ module Bastion - VERSION = "6.1.22" + VERSION = "6.1.22".freeze end diff --git a/engines/bastion_katello/README.md b/engines/bastion_katello/README.md index 5b00c4dbd62..6aab5cd4f3d 100644 --- a/engines/bastion_katello/README.md +++ b/engines/bastion_katello/README.md @@ -4,5 +4,19 @@ Bastion is a single page AngularJS based web client for the Katello server. This All URLs are relative to the application root, `/content-hosts` and `/content_views`, for example, are able to be bookmarked, and work with the browser's back button. The only real difference, as far as the user is concerned, is that the application is much quicker between Bastion "page loads" since only the HTML needed to render the next page is loaded instead of the entire page. +# Running tests: + +``` +cd ./engines/bastion_katello +sudo npm update -g grunt-cli +npm install +npm install ../bastion/ +``` + +``` +grunt ci +``` + + ## Contributing ## We welcome contributions, please see the Bastion [developer guide](https://github.com/Katello/bastion/blob/master/README.md). diff --git a/engines/bastion_katello/lib/bastion_katello.rb b/engines/bastion_katello/lib/bastion_katello.rb index ee6ee0c3ced..4de21e6324f 100644 --- a/engines/bastion_katello/lib/bastion_katello.rb +++ b/engines/bastion_katello/lib/bastion_katello.rb @@ -1,5 +1,4 @@ require File.expand_path("bastion_katello/engine", File.dirname(__FILE__)) -require 'bastion' module BastionKatello end diff --git a/engines/bastion_katello/package.json b/engines/bastion_katello/package.json index e732431cb90..ba649fe1827 100644 --- a/engines/bastion_katello/package.json +++ b/engines/bastion_katello/package.json @@ -1,4 +1,7 @@ { "name": "bastion_katello", - "version": "1.0.0" + "version": "1.0.0", + "dependencies": { + "bastion": "file:../bastion" + } } diff --git a/katello.gemspec b/katello.gemspec index d4d59c34d79..d55373a32bc 100644 --- a/katello.gemspec +++ b/katello.gemspec @@ -16,6 +16,8 @@ Gem::Specification.new do |gem| gem.files = Dir["{app,webpack,vendor,lib,db,ca,config,locale}/**/*"] + ['LICENSE.txt', 'README.md', 'package.json'] + gem.files += Dir["engines/bastion/{app,vendor,lib,config}/**/*"] + gem.files += Dir["engines/bastion/{README.md}"] gem.files += Dir["engines/bastion_katello/{app,vendor,lib,config}/**/*"] gem.files += Dir["engines/bastion_katello/{README.md}"] gem.files -= ["lib/katello/tasks/annotate_scenarios.rake"] @@ -43,7 +45,8 @@ Gem::Specification.new do |gem| # UI gem.add_dependency "deface", '>= 1.0.2', '< 2.0.0' - gem.add_dependency "bastion", ">= 6.1.22", "< 7.0.0" + gem.add_dependency "angular-rails-templates", "~> 1.0.2" + gem.add_development_dependency "uglifier" # Testing gem.add_development_dependency "factory_bot_rails", "~> 4.5" diff --git a/lib/katello.rb b/lib/katello.rb index 7d0472f4a9e..ef8a535e2d5 100644 --- a/lib/katello.rb +++ b/lib/katello.rb @@ -21,6 +21,7 @@ lib_foreman = File.expand_path('lib/foreman', Rails.root) require lib_foreman if Dir.exist?(lib_foreman) +require File.expand_path("../engines/bastion/lib/bastion", File.dirname(__FILE__)) require File.expand_path("../engines/bastion_katello/lib/bastion_katello", File.dirname(__FILE__)) require "monkeys/anemone" diff --git a/lib/katello/plugin.rb b/lib/katello/plugin.rb index 5863496d2b8..912172519cb 100644 --- a/lib/katello/plugin.rb +++ b/lib/katello/plugin.rb @@ -350,6 +350,9 @@ def find_katello_assets(args = {}) precompile = [ 'katello/katello.css', 'katello/containers/container.css', + 'bastion/bastion.css', + 'bastion/bastion.js', + /bastion\S+.(?:svg|eot|woff|ttf)$/, 'bastion_katello/bastion_katello.css', 'bastion_katello/bastion_katello.js', /bastion_katello\S+.(?:svg|eot|woff|ttf)$/