diff --git a/README.md b/README.md index 20ac95c656..fc4e76a935 100644 --- a/README.md +++ b/README.md @@ -112,22 +112,6 @@ If you are using Ubuntu on WSL and receive the following message when trying to ...check out the instructions on [installing google-chrome and chromedriver for WSL Ubuntu](https://github.com/rubyforgood/casa/blob/main/doc/WSL_SETUP.md#google-chrome). -**Installing Packages** -1. `cd casa/` -1. `bundle install` install ruby dependencies. -1. `yarn` install javascript dependencies. - -**Database Setup** -1. `bin/rails db:setup` create schema - requires running local postgres, with a role created for whatever user you're running rails as -1. `bin/rails db:seed:replant` generates test data (can be rerun to regenerate test data) - -**Compile Assets** -1. `yarn build` compile javascript -  `yarn build:dev` to auto recompile for when you edit js files -3. `yarn build:css` compile css -  `yarn build:css:dev` to auto recompile for when you edit sass files - ### Platform Specific Installation Instructions - [Docker](doc/DOCKER.md) - [Linux](doc/LINUX_SETUP.md) @@ -144,7 +128,9 @@ If you are using Ubuntu on WSL and receive the following message when trying to 1. Install imagemagick to see images locally. Instructions: https://imagemagick.org/script/download.php ## Running the App / Verifying Installation -1. `bin/rails server` or `bin/rails s` to start the local webserver +1. `cd casa/` +1. Run `bin/setup` +1. Run `bin/dev` and visit http://localhost:3000/ to see the app running. **Logging in with seed users** @@ -175,6 +161,9 @@ If you have trouble running tests, check out CI scripts in [`.github/workflows/` Test coverage is run by simplecov on all builds and aggregated by CodeClimate **Cleaning up before you pull request** + +Run `bin/lint` to run all linters and fix issues. This will run: + 1. `bundle exec standardrb --fix` auto-fix Ruby linting issues [more linter info](https://github.com/testdouble/standard) 1. `bundle exec erblint --lint-all --autocorrect` [ERB linter](https://github.com/Shopify/erb-lint) 1. `yarn lint:fix` to run the [JS linter](https://standardjs.com/index.html) and fix issues diff --git a/bin/lint b/bin/lint new file mode 100755 index 0000000000..d82099237e --- /dev/null +++ b/bin/lint @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +bundle exec standardrb --fix --format progress +bundle exec erblint --lint-all --autocorrect +yarn lint:fix +echo "Linting Factories" +rails factory_bot:lint diff --git a/bin/setup b/bin/setup index 4f0b54a810..553ce9c808 100755 --- a/bin/setup +++ b/bin/setup @@ -1,8 +1,8 @@ #!/usr/bin/env ruby -require "fileutils" +require 'fileutils' # path to your application root. -APP_ROOT = File.expand_path("..", __dir__) +APP_ROOT = File.expand_path('..', __dir__) def system!(*args) system(*args, exception: true) || abort("\n== Command #{args} failed ==") @@ -12,27 +12,49 @@ FileUtils.chdir APP_ROOT do # This script is a way to set up or update your development environment automatically. # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. + expected_ruby_version = `cat .ruby-version`.chomp + current_ruby_version = `ruby -v`.chomp + unless current_ruby_version.include?(expected_ruby_version) + puts "Ruby version must be #{expected_ruby_version}. You are on #{current_ruby_version}" + exit + end - puts "== Installing dependencies ==" - system! "gem install bundler --conservative" - system("bundle check") || system!("bundle install") + puts "\n== Installing dependencies ==" + system! 'gem install foreman' + system! 'gem install bundler --conservative' + system!('bundle update --bundler --verbose') + system!('bundle check') || system!('bundle install') - # puts "\n== Copying sample files ==" - # unless File.exist?("config/database.yml") - # FileUtils.cp "config/database.yml.sample", "config/database.yml" + # puts '\n== Copying sample files ==' + # unless File.exist?('config/database.yml') + # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' # end unless File.exist?('.env') - puts '== Setup .env file from .env.example ==' + puts "\n== Setup .env file from .env.example ==" system!('cp .env.example .env') end puts "\n== Preparing database ==" - system! "bin/rails db:prepare" + puts '⚠️ If you use docker to run postgres, make sure your database is running ⚠️' + system! 'bin/rails db:reset' + system! 'bin/rails db:test:prepare' puts "\n== Removing old logs and tempfiles ==" - system! "bin/rails log:clear tmp:clear" + system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" - system! "bin/rails restart" + system! 'bin/rails restart' + + puts "\n== Running post-deployment tasks ==" + system! 'bin/rake after_party:run' + + puts "\n== Installing yarn packages ==" + system!('yarn') || abort('install yarn and try again') + + puts "\n==Building assets ==" + system!('yarn build') + system!('yarn build:css') + + puts "\n== Done ==" end diff --git a/bin/update b/bin/update index 5468f738b0..6c14918469 100755 --- a/bin/update +++ b/bin/update @@ -32,4 +32,10 @@ chdir APP_ROOT do puts "\n== Restarting application server ==" system! 'bin/rails restart' + + puts "\n==Building assets ==" + system!('yarn build') + system!('yarn build:css') + + puts "\n== Done ==" end