diff --git a/Gemfile.tt b/Gemfile.tt
deleted file mode 100644
index 950a4ea..0000000
--- a/Gemfile.tt
+++ /dev/null
@@ -1,53 +0,0 @@
-source "https://rubygems.org"
-git_source(:github) { |repo| "https://github.com/#{repo}.git" }
-
-ruby "<%= RUBY_VERSION %>"
-
-gem "active_type"
-<%= gemfile_entry "bcrypt", force: true -%>
-<%= gemfile_entry "bootsnap" -%>
-<%= gemfile_entry "cssbundling-rails" unless install_vite? -%>
-<%= gemfile_entry "importmap-rails" unless install_vite? -%>
-<%= gemfile_entry "jsbundling-rails" unless install_vite? -%>
-<%= gemfile_entry "pg" -%>
-gem "pgcli-rails"
-<%= gemfile_entry "puma" -%>
-gem "rack-canonical-host"
-gem "rails", "~> <%= Rails.version[/\d+\.\d+\.\d+/] %>"
-<%= gemfile_entry "sprockets-rails" -%>
-<%= gemfile_entry "stimulus-rails" -%>
-<%= gemfile_entry "turbo-rails" -%>
-<%= %Q{gem "vite_rails"\n} if install_vite? -%>
-
-group :production do
- gem "postmark-rails"
- gem "sidekiq"
-end
-
-group :development do
- gem "amazing_print"
- gem "annotate"
- gem "brakeman", require: false
- gem "bundler-audit", require: false
- gem "letter_opener"
- gem "rubocop", require: false
- gem "rubocop-minitest", require: false
- gem "rubocop-performance", require: false
- gem "rubocop-rails", require: false
- <%= gemfile_entry "web-console" -%>
-end
-
-group :development, :test do
- gem "byebug"
- gem "dotenv-rails"
- gem "launchy"
-end
-
-group :test do
- <%= gemfile_entry "capybara" -%>
- gem "minitest-ci", require: false
- <%= gemfile_entry "selenium-webdriver" -%>
- gem "shoulda-context"
- gem "shoulda-matchers"
- <%= gemfile_entry "webdrivers" -%>
-end
diff --git a/app/frontend/stylesheets/index.scss b/app/frontend/stylesheets/index.scss
deleted file mode 100644
index 419a3f3..0000000
--- a/app/frontend/stylesheets/index.scss
+++ /dev/null
@@ -1,6 +0,0 @@
-@import "@picocss/pico";
-
-// Uncomment this to disable Pico's responsive sizing and instead respect the user's browser font size setting
-// :root {
-// --font-size: revert;
-// }
diff --git a/app/template.rb b/app/template.rb
deleted file mode 100644
index 19e421f..0000000
--- a/app/template.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-copy_file "app/controllers/home_controller.rb"
-copy_file "app/controllers/concerns/basic_auth.rb"
-copy_file "app/helpers/layout_helper.rb"
-
-insert_into_file "app/controllers/application_controller.rb", after: /^class ApplicationController.*\n/ do
- <<-RUBY
- include BasicAuth
- RUBY
-end
-
-File.rename "app/views/layouts/application.html.erb", "app/views/layouts/base.html.erb"
-
-prepend_to_file "app/views/layouts/base.html.erb", <<~ERB
-<%# The "base" layout contains boilerplate common to *all* views. %>
-
-ERB
-
-insert_into_file "app/views/layouts/base.html.erb", <<-ERB, after: "
"
-
-
-
-ERB
-
-gsub_file "app/views/layouts/base.html.erb", %r{^\s*.*}, <<-ERB
-
- <%= strip_tags(yield(:title)) + " – " if content_for?(:title) %>
- #{app_const_base.titleize}
-
- <%# Specifies the default name of home screen bookmark in iOS %>
-
-ERB
-
-insert_into_file "app/views/layouts/base.html.erb", <<-ERB.rstrip, before: %r{^\s*}
- <%= yield(:head) %>
-ERB
-
-if install_vite?
- gsub_file "app/views/layouts/base.html.erb", /^.*<%= stylesheet_link_tag.*$/, ""
- gsub_file "app/views/layouts/base.html.erb",
- /vite_javascript_tag 'application' %>/,
- 'vite_javascript_tag "application", "data-turbo-track": "reload" %>'
-else
- insert_into_file "app/views/layouts/base.html.erb", <<-ERB, before: /^.*<%= stylesheet_link_tag.*$/
-
- ERB
-end
-
-copy_file "app/views/layouts/application.html.erb"
-copy_file "app/views/shared/_flash.html.erb"
-copy_file "app/views/home/index.html.erb"
diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb
deleted file mode 100644
index cd258d0..0000000
--- a/app/views/home/index.html.erb
+++ /dev/null
@@ -1,2 +0,0 @@
-<% provide(:title, "Home") %>
-Find me in app/views/home/index.html.erb
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
deleted file mode 100644
index 92ce4a7..0000000
--- a/app/views/layouts/application.html.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-<%# The "application" layout is the default layout. It extends "base" %>
-<%# to include things like header, footer, and alerts that are common %>
-<%# to most (but not all) views. %>
-
-
- <%= render("shared/flash") %>
- <%= yield %>
-
-
-<% parent_layout "base" %>
diff --git a/app/views/shared/_flash.html.erb b/app/views/shared/_flash.html.erb
deleted file mode 100644
index 7bc7220..0000000
--- a/app/views/shared/_flash.html.erb
+++ /dev/null
@@ -1,9 +0,0 @@
-<%# Notice %>
-<% if flash[:notice].present? %>
- <%= flash[:notice] %>
-<% end %>
-
-<%# Alert %>
-<% if flash[:alert].present? %>
- <%= flash[:alert] %>
-<% end %>
diff --git a/circleci/config.yml.tt b/circleci/config.yml.tt
deleted file mode 100644
index 2038d18..0000000
--- a/circleci/config.yml.tt
+++ /dev/null
@@ -1,100 +0,0 @@
-version: 2.1
-
-orbs:
- browser-tools: circleci/browser-tools@1.2.5
- node: circleci/node@5.0.2
- ruby: circleci/ruby@1.6.0
-
-executors:
- ruby:
- docker:
- - image: cimg/ruby:<%= RUBY_VERSION %>-browsers
- environment:
- PGHOST: 127.0.0.1
- PGUSER: postgres
- PGPASS: postgres
- RAILS_ENV: test
- - image: cimg/postgres:14.2
- environment:
- POSTGRES_USER: postgres
- POSTGRES_PASSWORD: postgres
-
-commands:
- install_node_dependencies:
- steps:
- - node/install:
- install-yarn: true
- - node/install-packages:
- pkg-manager: yarn
- set_up_database:
- steps:
- - run:
- name: Set Up Database
- command: bundle exec rake db:create db:schema:load
-
-jobs:
- static_analysis:
- executor: ruby
- steps:
- - checkout
- - ruby/install-deps
- - install_node_dependencies
- - run:
- name: Run Overcommit
- command: |
- gem install overcommit --no-document
- git config --local user.name "Circle CI"
- git config --local user.email ci@example.com
- overcommit --sign
- overcommit --run
-
- security_audits:
- executor: ruby
- steps:
- - checkout
- - ruby/install-deps
- - run:
- name: Brakeman
- command: bundle exec brakeman --exit-on-warn --no-progress --color --output /dev/stdout
- - run:
- name: Bundle Audit
- command: bundle exec bundle-audit check --update -v
-
- test:
- executor: ruby
- steps:
- - checkout
- - ruby/install-deps
- - set_up_database
- - run:
- name: Run Tests
- command: bundle exec rake test TESTOPTS="--ci-dir=./reports"
- - store_test_results:
- path: ./reports
-
- test_system:
- executor: ruby
- steps:
- - browser-tools/install-chrome
- - browser-tools/install-chromedriver
- - checkout
- - ruby/install-deps
- - install_node_dependencies
- - set_up_database
- - run:
- name: Run System Tests
- command: bundle exec rake test:system TESTOPTS="--ci-dir=./reports"
- - store_test_results:
- path: ./reports
- - store_artifacts:
- path: ./tmp/screenshots
- destination: screenshots
-
-workflows:
- version: 2
- commit-workflow:
- jobs:
- - static_analysis
- - security_audits
- - test
- - test_system
diff --git a/circleci/template.rb b/circleci/template.rb
deleted file mode 100644
index 950050b..0000000
--- a/circleci/template.rb
+++ /dev/null
@@ -1 +0,0 @@
-template "circleci/config.yml.tt", ".circleci/config.yml"
diff --git a/lite/Gemfile.tt b/lite/Gemfile.tt
new file mode 100644
index 0000000..4daca4d
--- /dev/null
+++ b/lite/Gemfile.tt
@@ -0,0 +1,53 @@
+source "https://rubygems.org"
+git_source(:github) { |repo| "https://github.com/#{repo}.git" }
+
+ruby "<%= RUBY_VERSION %>"
+
+<%= gemfile_entry "active_type" -%> # make any class quack like ActiveRecord
+<%= gemfile_entry "bcrypt", force: true -%>
+<%= gemfile_entry "bootsnap" -%>
+<%= gemfile_entry "cssbundling-rails" -%>
+<%= gemfile_entry "importmap-rails" -%>
+<%= gemfile_entry "jsbundling-rails" -%>
+<%= gemfile_entry "pg" -%>
+gem "pgcli-rails"
+<%= gemfile_entry "puma" -%>
+gem "rack-canonical-host"
+gem "rails", "~> <%= Rails.version[/\d+\.\d+\.\d+/] %>"
+<%= gemfile_entry "sprockets-rails" -%>
+<%= gemfile_entry "stimulus-rails" -%>
+<%= gemfile_entry "turbo-rails" -%>
+gem "bulma-rails" # good compromise CSS framework https://github.com/joshuajansen/bulma-rails https://bulma.io
+gem "haml-rails", "~> 2.0" # haml instead of erb for layouts, views and partials
+
+group :production do
+ gem "postmark-rails" # best email service https://postmarkapp.com/
+ gem "sidekiq" # background jobs
+end
+
+group :development do
+ gem "amazing_print"
+ gem "annotate" # model annotations https://github.com/ctran/annotate_models
+ gem "brakeman", require: false
+ gem "bundler-audit", require: false # security checks
+ gem "flay", require: false # structural similarities analyzer https://github.com/seattlerb/flay
+ gem "letter_opener" # don't send emails when working locally display them https://github.com/ryanb/letter_opener
+ gem "rubocop", require: false
+ gem "rubocop-rspec", require: false
+ gem "rubocop-performance", require: false
+ gem "rubocop-rails", require: false
+ <%= gemfile_entry "web-console" -%> # web debug
+end
+
+group :development, :test do
+ gem "byebug" # console debug https://github.com/deivid-rodriguez/byebug#byebugs-commands
+ gem "dotenv-rails"
+ gem "launchy" # hepler for testing https://github.com/copiousfreetime/launchy
+end
+
+group :test do
+ <%= gemfile_entry "capybara" -%>
+ <%= gemfile_entry "selenium-webdriver" -%>
+ gem "rspec-rails"
+ <%= gemfile_entry "webdrivers" -%>
+end
diff --git a/LICENSE b/lite/LICENSE
similarity index 100%
rename from LICENSE
rename to lite/LICENSE
diff --git a/Procfile b/lite/Procfile
similarity index 100%
rename from Procfile
rename to lite/Procfile
diff --git a/README.md b/lite/README.md
similarity index 94%
rename from README.md
rename to lite/README.md
index 59dd6fc..756686b 100644
--- a/README.md
+++ b/lite/README.md
@@ -1,7 +1,5 @@
# mattbrictson/rails-template
-[![Circle](https://circleci.com/gh/mattbrictson/rails-template/tree/main.svg?style=shield)](https://app.circleci.com/pipelines/github/mattbrictson/rails-template?branch=main)
-
## Description
This is the application template that I recommend for Rails 7 projects. I've assembled this template over the years to include best-practices, tweaks, documentation, and personal preferences, while still generally adhering to the "Rails way".
@@ -96,7 +94,7 @@ If you don't specify `--javascript vite`, then this template will use the standa
* Security
* [brakeman][] and [bundler-audit][] – detect security vulnerabilities
* Testing
- * [shoulda][] – shortcuts for common ActiveRecord tests
+ * [rspec][] – shortcuts for common ActiveRecord tests
#### Postmark
@@ -123,13 +121,11 @@ Rails generators are very lightly documented; what you’ll find is that most of
[annotate]:https://github.com/ctran/annotate_models
[amazing_print]:https://github.com/amazing-print/amazing_print
[rubocop]:https://github.com/bbatsov/rubocop
-[pico]:https://picocss.com
+[pico]:https://bulma.io
[Postmark]:http://postmarkapp.com
[postmark-rails]:http://www.rubydoc.info/gems/postmark-rails/0.12.0
[brakeman]:https://github.com/presidentbeef/brakeman
[bundler-audit]:https://github.com/rubysec/bundler-audit
-[shoulda]:https://github.com/thoughtbot/shoulda
[application templates]:http://guides.rubyonrails.org/generators.html#application-templates
[template.rb]: template.rb
[thor]: https://github.com/erikhuda/thor
-[vite]: https://vite-ruby.netlify.app
diff --git a/README.md.tt b/lite/README.md.tt
similarity index 70%
rename from README.md.tt
rename to lite/README.md.tt
index 82943f6..4585766 100644
--- a/README.md.tt
+++ b/lite/README.md.tt
@@ -10,12 +10,11 @@ This README describes the purpose of this repository and how to set up a develop
This project requires:
-* Ruby <%= RUBY_VERSION %>, preferably managed using [rbenv][]
-* PostgreSQL must be installed and accepting connections
+* Ruby <%= RUBY_VERSION %>, preferably managed using [asdf][https://asdf-vm.com/]
+* [Docker](https://docs.docker.com/get-docker/) must be installed and running
+* Docker Compose must be installed (within docker or not)
-On a Mac, you can obtain all of the above packages using [Homebrew][].
-
-If you need help setting up a Ruby development environment, check out this [Rails OS X Setup Guide](https://mattbrictson.com/rails-osx-setup-guide).
+If you need help setting up a Ruby development environment, check out this [Ruby Devstation OS X Setup script](https://git.imfiny.com/OpenSource/setup).
## Getting started
@@ -30,8 +29,9 @@ Run the `bin/setup` script. This script will:
### Run it!
-1. Run `bin/rake` to run all tests and lint checks.
-2. Start the app with `yarn start`
+1. Start Redis and PostgreSQL databases as containers `docker-compose up -d`
+2. Run `bin/rake` to run all tests and lint checks.
+3. Start the app with `yarn start`
Access the app at .
diff --git a/Rakefile.rb b/lite/Rakefile.rb
similarity index 100%
rename from Rakefile.rb
rename to lite/Rakefile.rb
diff --git a/app/controllers/concerns/basic_auth.rb b/lite/app/controllers/concerns/basic_auth.rb
similarity index 100%
rename from app/controllers/concerns/basic_auth.rb
rename to lite/app/controllers/concerns/basic_auth.rb
diff --git a/app/controllers/home_controller.rb b/lite/app/controllers/home_controller.rb
similarity index 100%
rename from app/controllers/home_controller.rb
rename to lite/app/controllers/home_controller.rb
diff --git a/lite/app/frontend/stylesheets/index.scss b/lite/app/frontend/stylesheets/index.scss
new file mode 100644
index 0000000..badad5a
--- /dev/null
+++ b/lite/app/frontend/stylesheets/index.scss
@@ -0,0 +1 @@
+@import "bulma";
diff --git a/app/frontend/template.rb b/lite/app/frontend/template.rb
similarity index 100%
rename from app/frontend/template.rb
rename to lite/app/frontend/template.rb
diff --git a/app/helpers/layout_helper.rb b/lite/app/helpers/layout_helper.rb
similarity index 100%
rename from app/helpers/layout_helper.rb
rename to lite/app/helpers/layout_helper.rb
diff --git a/lite/app/template.rb b/lite/app/template.rb
new file mode 100644
index 0000000..2f221b0
--- /dev/null
+++ b/lite/app/template.rb
@@ -0,0 +1,24 @@
+copy_file "app/controllers/home_controller.rb"
+copy_file "app/controllers/concerns/basic_auth.rb"
+copy_file "app/helpers/layout_helper.rb"
+
+insert_into_file "app/controllers/application_controller.rb", after: /^class ApplicationController.*\n/ do
+ <<-RUBY
+ include BasicAuth
+ RUBY
+end
+
+File.rename "app/views/layouts/application.html.erb", "app/views/layouts/application.html.erb.old"
+run_with_clean_bundler_env "rails generate haml:application_layout convert"
+
+copy_file "app/views/layouts/application.haml"
+
+gsub_file "app/views/layouts/application.haml", "%title", <<-HAML
+%title
+ = strip_tags(yield(:title)) + " – " if content_for?(:title)
+ #{app_const_base.titleize}
+ %meta{:content => "#{app_const_base.titleize}", :name => "apple-mobile-web-app-title"}
+HAML
+
+copy_file "app/views/shared/_flash.haml"
+copy_file "app/views/home/index.haml"
diff --git a/lite/app/views/home/index.haml b/lite/app/views/home/index.haml
new file mode 100644
index 0000000..4225636
--- /dev/null
+++ b/lite/app/views/home/index.haml
@@ -0,0 +1,2 @@
+- provide(:title, "Home")
+%p Find me in app/views/home/index.haml
\ No newline at end of file
diff --git a/lite/app/views/layouts/application.haml b/lite/app/views/layouts/application.haml
new file mode 100644
index 0000000..3ddee6e
--- /dev/null
+++ b/lite/app/views/layouts/application.haml
@@ -0,0 +1,10 @@
+!!!
+%html
+ %head
+ %title
+
+ %body
+ %section.section
+ .container
+ = render("shared/flash")
+ = yield
diff --git a/lite/app/views/shared/_flash.haml b/lite/app/views/shared/_flash.haml
new file mode 100644
index 0000000..999812f
--- /dev/null
+++ b/lite/app/views/shared/_flash.haml
@@ -0,0 +1,6 @@
+-# Notice
+- if flash[:notice].present?
+ .alert.alert-success= flash[:notice]
+-# Alert
+- if flash[:alert].present?
+ .alert.alert-danger= flash[:alert]
\ No newline at end of file
diff --git a/bin/setup b/lite/bin/setup
similarity index 100%
rename from bin/setup
rename to lite/bin/setup
diff --git a/bin/template.rb b/lite/bin/template.rb
similarity index 100%
rename from bin/template.rb
rename to lite/bin/template.rb
diff --git a/config.ru.rb b/lite/config.ru.rb
similarity index 100%
rename from config.ru.rb
rename to lite/config.ru.rb
diff --git a/config/application.rb b/lite/config/application.rb
similarity index 100%
rename from config/application.rb
rename to lite/config/application.rb
diff --git a/config/database.yml.tt b/lite/config/database.yml.tt
similarity index 82%
rename from config/database.yml.tt
rename to lite/config/database.yml.tt
index 11abcd4..c455d46 100644
--- a/config/database.yml.tt
+++ b/lite/config/database.yml.tt
@@ -2,6 +2,10 @@ default: &default
adapter: postgresql
encoding: unicode
pool: <%%= [5, *ENV.values_at("RAILS_MAX_THREADS", "SIDEKIQ_CONCURRENCY")].map(&:to_i).max %>
+ host: 0.0.0.0
+ port: 5432
+ username: postgres
+ password: postgres
development:
<<: *default
diff --git a/config/environments/development.rb b/lite/config/environments/development.rb
similarity index 100%
rename from config/environments/development.rb
rename to lite/config/environments/development.rb
diff --git a/config/environments/production.rb b/lite/config/environments/production.rb
similarity index 100%
rename from config/environments/production.rb
rename to lite/config/environments/production.rb
diff --git a/config/environments/test.rb b/lite/config/environments/test.rb
similarity index 100%
rename from config/environments/test.rb
rename to lite/config/environments/test.rb
diff --git a/config/initializers/generators.rb b/lite/config/initializers/generators.rb
similarity index 100%
rename from config/initializers/generators.rb
rename to lite/config/initializers/generators.rb
diff --git a/config/initializers/rotate_log.rb b/lite/config/initializers/rotate_log.rb
similarity index 100%
rename from config/initializers/rotate_log.rb
rename to lite/config/initializers/rotate_log.rb
diff --git a/config/initializers/sidekiq.rb b/lite/config/initializers/sidekiq.rb
similarity index 100%
rename from config/initializers/sidekiq.rb
rename to lite/config/initializers/sidekiq.rb
diff --git a/config/initializers/version.rb b/lite/config/initializers/version.rb
similarity index 100%
rename from config/initializers/version.rb
rename to lite/config/initializers/version.rb
diff --git a/config/sidekiq.yml b/lite/config/sidekiq.yml
similarity index 100%
rename from config/sidekiq.yml
rename to lite/config/sidekiq.yml
diff --git a/config/template.rb b/lite/config/template.rb
similarity index 100%
rename from config/template.rb
rename to lite/config/template.rb
diff --git a/lite/docker-compose.yml b/lite/docker-compose.yml
new file mode 100644
index 0000000..aeaae80
--- /dev/null
+++ b/lite/docker-compose.yml
@@ -0,0 +1,18 @@
+version: "3.7"
+services:
+ redis:
+ image: redis:6.2
+ ports:
+ - "6379:6379"
+ postgres:
+ image: postgres:13.2
+ ports:
+ - "5432:5432"
+ environment:
+ - POSTGRES_PASSWORD=postgres
+ - POSTGRES_USER=postgres
+ volumes:
+ - data-postgres:/var/lib/postgresql/data
+volumes:
+ data-postgres:
+ driver: local
diff --git a/editorconfig b/lite/editorconfig
similarity index 100%
rename from editorconfig
rename to lite/editorconfig
diff --git a/eslintrc.js b/lite/eslintrc.js
similarity index 100%
rename from eslintrc.js
rename to lite/eslintrc.js
diff --git a/example.env.tt b/lite/example.env.tt
similarity index 100%
rename from example.env.tt
rename to lite/example.env.tt
diff --git a/lib/puma/plugin/open.rb b/lite/lib/puma/plugin/open.rb
similarity index 100%
rename from lib/puma/plugin/open.rb
rename to lite/lib/puma/plugin/open.rb
diff --git a/lib/tasks/auto_annotate_models.rake b/lite/lib/tasks/auto_annotate_models.rake
similarity index 100%
rename from lib/tasks/auto_annotate_models.rake
rename to lite/lib/tasks/auto_annotate_models.rake
diff --git a/lib/template.rb b/lite/lib/template.rb
similarity index 100%
rename from lib/template.rb
rename to lite/lib/template.rb
diff --git a/overcommit.yml b/lite/overcommit.yml
similarity index 100%
rename from overcommit.yml
rename to lite/overcommit.yml
diff --git a/package.json b/lite/package.json
similarity index 100%
rename from package.json
rename to lite/package.json
diff --git a/prettierrc.js b/lite/prettierrc.js
similarity index 100%
rename from prettierrc.js
rename to lite/prettierrc.js
diff --git a/rubocop.yml.tt b/lite/rubocop.yml.tt
similarity index 88%
rename from rubocop.yml.tt
rename to lite/rubocop.yml.tt
index eb2ac05..1bfdc7d 100644
--- a/rubocop.yml.tt
+++ b/lite/rubocop.yml.tt
@@ -1,5 +1,5 @@
require:
- - rubocop-minitest
+ - rubocop-rspec
- rubocop-performance
- rubocop-rails
@@ -28,27 +28,27 @@ Layout/LineLength:
- "config/initializers/content_security_policy.rb"
Layout/SpaceAroundEqualsInParameterDefault:
- EnforcedStyle: no_space
+ EnforcedStyle: space
Metrics/AbcSize:
Max: 20
Exclude:
- - "test/**/*"
+ - "rspec/**/*"
Metrics/BlockLength:
Exclude:
- "config/**/*"
- - "test/**/*"
+ - "rspec/**/*"
Metrics/ClassLength:
Exclude:
- - "test/**/*"
+ - "rspec/**/*"
Metrics/MethodLength:
Max: 18
Exclude:
- "db/migrate/*"
- - "test/**/*"
+ - "rspec/**/*"
Naming/MemoizedInstanceVariableName:
EnforcedStyleForLeadingUnderscores: optional
@@ -76,19 +76,19 @@ Style/BarePercentLiterals:
EnforcedStyle: percent_q
Style/ClassAndModuleChildren:
- Enabled: false
+ Enabled: nested
Style/Documentation:
- Enabled: false
+ Enabled: true
Style/DoubleNegation:
Enabled: false
Style/EmptyMethod:
- Enabled: false
+ Enabled: true
Style/FrozenStringLiteralComment:
- Enabled: false
+ Enabled: true
Style/NumericPredicate:
Enabled: false
diff --git a/ruby-version.tt b/lite/ruby-version.tt
similarity index 100%
rename from ruby-version.tt
rename to lite/ruby-version.tt
diff --git a/lite/semaphore/semaphore.yml.tt b/lite/semaphore/semaphore.yml.tt
new file mode 100644
index 0000000..4fda40e
--- /dev/null
+++ b/lite/semaphore/semaphore.yml.tt
@@ -0,0 +1,90 @@
+# .semaphore/semaphore.yml
+version: v1.0
+name: Rails project
+agent:
+ machine:
+ type: e1-standard-2
+ os_image: ubuntu2004
+blocks:
+ - name: Setup
+ dependencies: []
+ task:
+ jobs:
+ - name: bundle
+ commands:
+ - sem-version ruby <%= RUBY_VERSION[/\d+\.\d+/] %>
+ - sem-version node 16.15.0
+ - checkout
+ - cache restore
+ - bundle install
+ - cache store
+ - name: Code scanning
+ dependencies:
+ - Setup
+ task:
+ jobs:
+ - name: check style + security
+ commands:
+ - sem-version ruby 2.7.5
+ - sem-version node 16.15.0
+ - checkout
+ - cache restore
+ - bundle install
+ - cache store
+ - bundle exec rubocop
+ - bundle exec brakeman
+ - bundle exec flay
+ - name: Unit tests
+ dependencies:
+ - Code scanning
+ task:
+ prologue:
+ commands:
+ - sem-version ruby 2.7.5
+ - sem-version node 16.15.0
+ - checkout
+ - cache restore
+ - bundle install
+ - cache store
+ - sem-service start postgres
+ - 'bundle exec rake db:setup'
+ jobs:
+ - name: RSpec - model tests
+ commands:
+ - bundle exec rspec spec/models
+ - name: RSpec - controller tests
+ commands:
+ - bundle exec rspec spec/controllers
+ epilogue:
+ always:
+ commands:
+ - "[[ -f junit.xml ]] && test-results publish --name \"🧪 Unit tests\" junit.xml"
+ - name: Integration tests
+ dependencies:
+ - Unit tests
+ task:
+ prologue:
+ commands:
+ - sem-version ruby 2.7.5
+ - sem-version node 16.15.0
+ - checkout
+ - cache restore
+ - bundle install
+ - cache store
+ jobs:
+ - name: RSpec - feature specs
+ commands:
+ - sem-service start postgres
+ - 'bundle exec rake db:setup'
+ - bundle exec rspec spec/features
+ epilogue:
+ always:
+ commands:
+ - "[[ -f junit.xml ]] && test-results publish --name \"🏗️ Integration tests\" junit.xml"
+
+after_pipeline:
+ task:
+ jobs:
+ - name: Publish Results
+ commands:
+ - test-results gen-pipeline-report
\ No newline at end of file
diff --git a/lite/semaphore/template.rb b/lite/semaphore/template.rb
new file mode 100644
index 0000000..14786f5
--- /dev/null
+++ b/lite/semaphore/template.rb
@@ -0,0 +1 @@
+template "semaphore/semaphore.yml.tt", ".semaphore/semaphore.yml"
diff --git a/stylelintrc.js b/lite/stylelintrc.js
similarity index 100%
rename from stylelintrc.js
rename to lite/stylelintrc.js
diff --git a/template.rb b/lite/template.rb
similarity index 91%
rename from template.rb
rename to lite/template.rb
index 336783a..6fbe2eb 100644
--- a/template.rb
+++ b/lite/template.rb
@@ -8,13 +8,6 @@ def apply_template!
assert_postgresql
add_template_repository_to_source_path
- if install_vite?
- self.options = options.merge(
- css: nil,
- skip_asset_pipeline: true
- )
- end
-
template "Gemfile.tt", force: true
template "README.md.tt", force: true
@@ -27,11 +20,12 @@ def apply_template!
copy_file "Procfile"
copy_file "package.json"
+ copy_file "docker-compose.yml"
apply "Rakefile.rb"
apply "config.ru.rb"
apply "bin/template.rb"
- apply "circleci/template.rb"
+ apply "semaphore/template.rb"
apply "config/template.rb"
apply "lib/template.rb"
apply "test/template.rb"
@@ -46,13 +40,9 @@ def apply_template!
/.env.development
/.env.*local
IGNORE
-
- if install_vite?
- File.rename("app/javascript", "app/frontend") if File.exist?("app/javascript")
- run_with_clean_bundler_env "bundle exec vite install"
- run "yarn add sass @picocss/pico"
- apply "app/frontend/template.rb"
- end
+ run_with_clean_bundler_env "rails generate rspec:install"
+ append_to_file "spec/spec_helper.rb", "require 'capybara_helper'"
+ append_to_file "spec/spec_helper.rb", "require 'mailer_helper'"
apply "app/template.rb"
@@ -132,8 +122,8 @@ def assert_valid_options
skip_bundle: false,
skip_git: false,
skip_system_test: false,
- skip_test: false,
- skip_test_unit: false,
+ skip_test: true,
+ skip_test_unit: true,
edge: false
}
valid_options.each do |key, expected|
@@ -213,6 +203,7 @@ end
def create_database_and_initial_migration
return if Dir["db/migrate/**/*.rb"].any?
+ run "docker-compose up -d"
run_with_clean_bundler_env "bin/rails db:create"
run_with_clean_bundler_env "bin/rails generate migration initial_migration"
end
@@ -223,7 +214,6 @@ def add_yarn_start_script
run_with_clean_bundler_env "yarn add --dev concurrently"
procs = ["'bin/rails s -b 0.0.0.0'"]
- procs << "'bin/vite dev'" if File.exist?("bin/vite")
procs << "bin/webpack-dev-server" if File.exist?("bin/webpack-dev-server")
add_package_json_script(start: "concurrently --raw --kill-others-on-fail #{procs.join(" ")}")
@@ -246,8 +236,8 @@ def add_yarn_lint_and_run_fix
add_package_json_script("lint": "npm-run-all -c lint:*")
add_package_json_script("lint:js": "eslint 'app/{components,frontend,javascript}/**/*.{js,jsx}'")
add_package_json_script("lint:css": "stylelint 'app/{components,frontend,assets/stylesheets}/**/*.{css,scss}'")
- run_with_clean_bundler_env "yarn lint:js --fix"
- run_with_clean_bundler_env "yarn lint:css --fix"
+ #run_with_clean_bundler_env "yarn lint:js --fix"
+ #run_with_clean_bundler_env "yarn lint:css --fix"
end
def add_package_json_script(scripts)
@@ -256,7 +246,4 @@ def add_package_json_script(scripts)
end
end
-def install_vite?
- options[:javascript] == "vite"
-end
apply_template!
diff --git a/test/support/capybara.rb b/lite/test/spec/capybara_helper.rb
similarity index 100%
rename from test/support/capybara.rb
rename to lite/test/spec/capybara_helper.rb
diff --git a/test/support/mailer.rb b/lite/test/spec/mailer_helper.rb
similarity index 100%
rename from test/support/mailer.rb
rename to lite/test/spec/mailer_helper.rb
diff --git a/test/system/layout_helper_test.rb b/lite/test/system/layout_helper_test.rb
similarity index 100%
rename from test/system/layout_helper_test.rb
rename to lite/test/system/layout_helper_test.rb
diff --git a/lite/test/template.rb b/lite/test/template.rb
new file mode 100644
index 0000000..89c9a84
--- /dev/null
+++ b/lite/test/template.rb
@@ -0,0 +1,18 @@
+copy_file "test/spec/capybara_helper.rb"
+copy_file "test/spec/mailer_helper.rb"
+empty_directory_with_keep_file "spec/mailers"
+empty_directory_with_keep_file "spec/unit"
+empty_directory_with_keep_file "spec/requests"
+
+# gsub_file "test/application_system_test_case.rb", /^ driven_by :selenium.*$/, <<~RUBY
+# driven_by :selenium,
+# using: (ENV["DISABLE_HEADLESS_CHROME"].present? ? :chrome : :headless_chrome),
+# screen_size: [1400, 1400] do |options|
+# options.add_argument("no-sandbox")
+# end
+
+# def setup
+# Capybara.server = :puma, { Silent: true }
+# super
+# end
+# RUBY
diff --git a/test/test_helper.rb b/lite/test/test_helper.rb
similarity index 67%
rename from test/test_helper.rb
rename to lite/test/test_helper.rb
index cee865b..ef60b45 100644
--- a/test/test_helper.rb
+++ b/lite/test/test_helper.rb
@@ -1,5 +1,3 @@
-# This has to come first
-require_relative "./support/rails"
# Load everything else from test/support
Dir[File.expand_path("support/**/*.rb", __dir__)].sort.each { |rb| require(rb) }
diff --git a/test/support/circleci.rb b/test/support/circleci.rb
deleted file mode 100644
index 97c93a9..0000000
--- a/test/support/circleci.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-# Generate XML test reports that can be parsed by CircleCI
-require "minitest/ci" if ENV["CIRCLECI"]
diff --git a/test/support/rails.rb b/test/support/rails.rb
deleted file mode 100644
index a161a04..0000000
--- a/test/support/rails.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-ENV["RAILS_ENV"] ||= "test"
-require_relative "../../config/environment"
-require "rails/test_help"
-
-class ActiveSupport::TestCase
- # Run tests in parallel with specified workers
- parallelize(workers: :number_of_processors)
-
- # Setup all fixtures in test/fixtures/*.yml for all tests in alpha order.
- fixtures :all
-end
diff --git a/test/support/shoulda_matchers.rb b/test/support/shoulda_matchers.rb
deleted file mode 100644
index 5086d5f..0000000
--- a/test/support/shoulda_matchers.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-Shoulda::Matchers.configure do |config|
- config.integrate do |with|
- with.test_framework :minitest
- with.library :rails
- end
-end
diff --git a/test/template.rb b/test/template.rb
deleted file mode 100644
index d1e531d..0000000
--- a/test/template.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-copy_file "test/test_helper.rb", force: true
-copy_file "test/support/capybara.rb"
-copy_file "test/support/circleci.rb"
-copy_file "test/support/mailer.rb"
-copy_file "test/support/rails.rb"
-copy_file "test/support/shoulda_matchers.rb"
-copy_file "test/system/layout_helper_test.rb"
-empty_directory_with_keep_file "test/mailers"
-empty_directory_with_keep_file "test/unit"
-empty_directory_with_keep_file "test/unit/lib"
-empty_directory_with_keep_file "test/unit/lib/tasks"
-
-gsub_file "test/application_system_test_case.rb", /^ driven_by :selenium.*$/, <<~RUBY
- driven_by :selenium,
- using: (ENV["DISABLE_HEADLESS_CHROME"].present? ? :chrome : :headless_chrome),
- screen_size: [1400, 1400] do |options|
- options.add_argument("no-sandbox")
- end
-
- def setup
- Capybara.server = :puma, { Silent: true }
- super
- end
-RUBY