2019-07-23 18:36:03 +00:00
|
|
|
|
# Getting Started
|
|
|
|
|
|
|
|
|
|
## Dependencies
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2020-10-15 19:15:34 +00:00
|
|
|
|
You'll need to have in your Mac the following dependencies installed, if you
|
|
|
|
|
don't want to use the provided Docker containers.
|
2019-07-23 18:36:03 +00:00
|
|
|
|
|
2019-08-09 18:06:34 +00:00
|
|
|
|
- Ruby `2.5.1`
|
|
|
|
|
- Rails `5.0.7.1`
|
|
|
|
|
- Node `11.12.0`
|
2019-07-23 18:36:03 +00:00
|
|
|
|
|
|
|
|
|
## Local Config
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
Instructions for running Development environment using macOS Catalina
|
|
|
|
|
|
|
|
|
|
### Initial steps
|
2019-08-09 18:06:34 +00:00
|
|
|
|
|
|
|
|
|
_Dependencies:_
|
2019-07-23 18:36:03 +00:00
|
|
|
|
|
2020-10-15 19:15:34 +00:00
|
|
|
|
Have a ruby version installed, you can learn more about how to use multiple
|
|
|
|
|
versions of Ruby installed in your computer with
|
|
|
|
|
[rbenv](https://github.com/rbenv/rbenv) or [rvm](https://rvm.io).
|
2019-07-23 18:36:03 +00:00
|
|
|
|
|
|
|
|
|
An instance of PostgresSQL running.
|
|
|
|
|
|
2019-08-09 18:06:34 +00:00
|
|
|
|
_Setting up secrets:_
|
2019-07-23 18:36:03 +00:00
|
|
|
|
|
2020-10-15 19:15:34 +00:00
|
|
|
|
Run `cp .env.template .env` to copy the provided template file for env
|
|
|
|
|
variables to create your own.
|
2019-07-23 18:36:03 +00:00
|
|
|
|
|
2020-10-15 19:15:34 +00:00
|
|
|
|
You'll need to provide a `DEVISE_SECRET_KEY` and `SECRET_TOKEN` which you can
|
|
|
|
|
obtain by running `bundle exec rake secret`.
|
2019-07-23 18:36:03 +00:00
|
|
|
|
|
2019-08-09 18:06:34 +00:00
|
|
|
|
Set the following secrets in your `.env` file with your _Stripe account_ information.
|
2019-07-23 18:36:03 +00:00
|
|
|
|
|
2019-08-09 18:06:34 +00:00
|
|
|
|
- `STRIPE_API_KEY` with your Stripe _private_ key.
|
|
|
|
|
- `STRIPE_API_PUBLIC` with your Stripe _public_ key.
|
2019-07-23 18:36:03 +00:00
|
|
|
|
|
2020-10-15 19:15:34 +00:00
|
|
|
|
The last secrets you'll need are related to AWS. You can learn how
|
|
|
|
|
to [create an S3 Bucket](https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html)
|
|
|
|
|
within the AWS Documentation, and to obtain your access and secret key, you
|
|
|
|
|
can [learn more here](https://aws.amazon.com/blogs/security/wheres-my-secret-access-key/).
|
2019-07-23 18:36:03 +00:00
|
|
|
|
|
2019-08-09 18:06:34 +00:00
|
|
|
|
- `S3_BUCKET_NAME`
|
|
|
|
|
- `AWS_ACCESS_KEY`
|
|
|
|
|
- `AWS_SECRET_ACCESS_KEY`
|
2019-07-23 18:36:03 +00:00
|
|
|
|
|
2019-08-09 18:06:34 +00:00
|
|
|
|
_Setting up the local database:_
|
2019-07-23 18:36:03 +00:00
|
|
|
|
|
2020-10-15 19:15:34 +00:00
|
|
|
|
Run `rake db:setup` to run all the db tasks within one command. This will
|
|
|
|
|
create the dbs for each environment, load the `structure.sql`, run
|
|
|
|
|
pending migrations and will also run the seed functionality.
|
2019-07-23 18:36:03 +00:00
|
|
|
|
|
2019-08-09 18:06:34 +00:00
|
|
|
|
---
|
2019-07-29 18:40:30 +00:00
|
|
|
|
|
|
|
|
|
**Known problems**
|
2020-10-15 19:15:34 +00:00
|
|
|
|
If you encounter `database doesnt exist in rake db create` after running
|
|
|
|
|
both `rake db:setup` and `rake db:create`, you'll need to comment out
|
|
|
|
|
the lines these lines at `pg_type_map.rb`
|
2019-08-09 18:06:34 +00:00
|
|
|
|
|
2020-10-15 19:15:34 +00:00
|
|
|
|
```ruby
|
2019-07-29 18:40:30 +00:00
|
|
|
|
Qx.config(type_map: PG::BasicTypeMapForResults.new(ActiveRecord::Base.connection.raw_connection))
|
|
|
|
|
Qx.execute("SET TIME ZONE utc")
|
|
|
|
|
```
|
|
|
|
|
|
2019-07-23 18:36:03 +00:00
|
|
|
|
### How to run
|
2019-08-09 18:06:34 +00:00
|
|
|
|
|
2020-10-15 19:15:34 +00:00
|
|
|
|
You'll need 2 consoles to run the project. One for the rails env and another
|
|
|
|
|
one to run the asset pipeline through [webpack](https://webpack.js.org),
|
|
|
|
|
since it's _not incorporated yet_ into the rails asset pipeline.
|
2019-07-23 18:36:03 +00:00
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# Console one (1)
|
|
|
|
|
bundle exec rails server
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# Console two (2)
|
2019-11-05 21:51:46 +00:00
|
|
|
|
yarn watch
|
2019-07-23 18:36:03 +00:00
|
|
|
|
# #### Notes ####
|
|
|
|
|
# If you get errors from running this command.
|
|
|
|
|
# You'll need to manually run the following commands.
|
|
|
|
|
npm run export-button-config
|
|
|
|
|
npm run export-i18n
|
|
|
|
|
npm run generate-api-js
|
|
|
|
|
# Now we're able to watch!
|
|
|
|
|
npx webpack --watch
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Testing
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
Run `bundle exec rspec` to run test suite.
|
2019-08-09 18:06:34 +00:00
|
|
|
|
|
|
|
|
|
## Formatting
|
|
|
|
|
|
2020-10-15 19:15:34 +00:00
|
|
|
|
We are using [Standard](https://github.com/testdouble/standard) that is a
|
|
|
|
|
wrapper on top of Rubocop with a predefined set of Rules. If you use VS Code
|
|
|
|
|
you will want to install
|
|
|
|
|
[vscode-ruby](https://marketplace.visualstudio.com/items?itemName=rebornix.Ruby)
|
|
|
|
|
extension and enable formatting on save.
|
2019-08-09 18:06:34 +00:00
|
|
|
|
|
|
|
|
|
To enable formatting on save add these lines to your `settings.json`.
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"[ruby]": {
|
|
|
|
|
"editor.formatOnSave": true
|
|
|
|
|
},
|
|
|
|
|
"ruby.lint": {
|
|
|
|
|
"rubocop": true
|
|
|
|
|
},
|
|
|
|
|
"ruby.format": "rubocop",
|
|
|
|
|
"editor.formatOnSaveTimeout": 5000
|
|
|
|
|
}
|
|
|
|
|
```
|