Class: Kowl::DotfilesGenerator
- Inherits:
-
Generators::Base
- Object
- Rails::Generators::Base
- Generators::Base
- Kowl::DotfilesGenerator
- Defined in:
- lib/kowl/generators/dotfiles_generator.rb
Instance Method Summary collapse
-
#copy_dotfiles ⇒ Object
Copy basic application linter dotfiles to the applications ROOT_PATH.
-
#copy_js_dotfiles ⇒ Object
Copy JS dotfiles for linterers over the applications ROOT_PATH.
-
#pryrc ⇒ Object
Generate a basic pry config file for the application.
-
#setup_application_dotfiles ⇒ Object
Setup Rubocop and ERD dotfiles for the application.
-
#setup_aptfile ⇒ Object
Generate an Aptfile for the application based on it’s specific requirements (for Debian/Ubuntu).
-
#setup_brewfile ⇒ Object
Generate a Brewfile for the application based on it’s specific requirerments (for macOS).
-
#setup_env_file ⇒ Object
Setup .env file for the application, which makes it easier to use this config with docker-compose as well Note: An .env file is setup instead of an .env.docker file because of the way env_file works with docker-compose => At the moment, when running a build with docker-compose if an env_file is anything other than .env the variables won’t be consumed by the container build process.
-
#setup_linter_dotfiles ⇒ Object
Setup application dotfiles for the applications specific template_engine [Erb, Slim, HAML].
Methods inherited from Generators::Base
default_source_root, source_paths
Methods included from Docker
#alpine_docker_dependencies, #app_js_volumes, #app_volumes, #db_volumes, #debian_database_dependencies, #debian_docker_dependencies, #docker_app_command, #docker_compose_database_string, #docker_databases, #docker_depends_on, #docker_port_watcher, #docker_redis_service, #docker_sidekiq_service, #docker_variables, #docker_volumes, #docker_webpacker_service, #dockerfile_database_args, #dockerfile_migration_snip, #js_volumes, #mysql_volumes, #postgresql_volumes, #redis_volumes
Methods included from Actions
#add_extension_routes, #add_package, #append_to_file, #database_route, #dev_config, #dup_file, #file_exists?, #mailer_gems, #mailer_route, #mk_dir, #move_file, #pry_gems, #rails_cmd, #remove_dir, #remove_file, #remove_gem, #replace_string_in_file, #robocop_test_engine, #sidekiq_route, #template_linter_gems
Instance Method Details
#copy_dotfiles ⇒ Object
Copy basic application linter dotfiles to the applications ROOT_PATH
24 25 26 27 28 |
# File 'lib/kowl/generators/dotfiles_generator.rb', line 24 def copy_dotfiles files = %w[codeclimate.yml coffeelint.json coffeelintignore dockerignore editorconfig fasterer.yml foreman gitattributes mailmap nvmrc rspec scss-lint.yml simplecov slugignore yamllint] files.reject! { |e| e =~ /dockerignore/ } if [:skip_docker] files.map { |dotfile| copy_file dotfile, ".#{dotfile}" } end |
#copy_js_dotfiles ⇒ Object
Copy JS dotfiles for linterers over the applications ROOT_PATH
31 32 33 34 35 36 |
# File 'lib/kowl/generators/dotfiles_generator.rb', line 31 def copy_js_dotfiles return if [:skip_javascript] js_files = %w[eslintignore eslintrc.js jsbeautifyrc jshintrc prettierignore prettierrc.js yarnclean] js_files.map { |dotfile| copy_file dotfile, ".#{dotfile}" } end |
#pryrc ⇒ Object
Generate a basic pry config file for the application
69 70 71 |
# File 'lib/kowl/generators/dotfiles_generator.rb', line 69 def pryrc copy_file('pryrc', '.pryrc') unless [:skip_pry] end |
#setup_application_dotfiles ⇒ Object
Setup Rubocop and ERD dotfiles for the application
39 40 41 42 43 |
# File 'lib/kowl/generators/dotfiles_generator.rb', line 39 def setup_application_dotfiles files = %w[erdconfig rubocop.yml] files.reject! { |e| e =~ /erdconfig/ } if [:skip_erd] files.map { |dotfile| template "#{dotfile}.tt", ".#{dotfile}" } end |
#setup_aptfile ⇒ Object
Generate an Aptfile for the application based on it’s specific requirements (for Debian/Ubuntu)
56 57 58 |
# File 'lib/kowl/generators/dotfiles_generator.rb', line 56 def setup_aptfile template 'Aptfile.tt', 'Aptfile' end |
#setup_brewfile ⇒ Object
Generate a Brewfile for the application based on it’s specific requirerments (for macOS)
51 52 53 |
# File 'lib/kowl/generators/dotfiles_generator.rb', line 51 def setup_brewfile template 'Brewfile.tt', 'Brewfile' end |
#setup_env_file ⇒ Object
Setup .env file for the application, which makes it easier to use this config with docker-compose as well Note: An .env file is setup instead of an .env.docker file because of the way env_file works with docker-compose
> At the moment, when running a build with docker-compose if an env_file is anything other than .env the variables won’t be consumed by the container build process
63 64 65 66 |
# File 'lib/kowl/generators/dotfiles_generator.rb', line 63 def setup_env_file %w[development staging production test].map { |env| template 'env.tt', ".env.#{env}", env: env } template 'env.tt', '.env', env: 'docker' unless [:skip_docker] end |
#setup_linter_dotfiles ⇒ Object
Setup application dotfiles for the applications specific template_engine [Erb, Slim, HAML]
46 47 48 |
# File 'lib/kowl/generators/dotfiles_generator.rb', line 46 def setup_linter_dotfiles copy_file "#{[:template_engine]}-lint.yml", ".#{[:template_engine]}-lint.yml" end |