Click here to view the website hosted on Heroku.
Follow the steps below to get this repo running on your own machine!
Prerequisite: Download the IDE of your choice. A good choice is visual studio code, you can download it by visiting their website.
Steps
- open a terminal and
cdinto the location you wish to download this repo - clone the repo using:
git clone https://github.com/gavinvaske/the_recipe_book.git
- to run the application
cdinto the downloaded folder using:cd the_recipe_book
- Install Dependencies using:
npm install(if this command throws errors, see this wiki page
- Create a
.envfile in the root directory and populate it with all the variables found in.env.example(you'll need to replace all the 'TODO' valued variables. You'll need to decide the values they need to be.) - start the application using:
npm run start
- Start up react using
npm run react
- open a browser window and enter the url:
http://localhost:8080/
Any work done locally, must be added to a branch before being pushed, the steps below describe how to create a branch and push that branch to github
- Ensure you are on the
main branchAND that it is up to date with what is on github (NOTE: If an error occurs during these steps, runninggit stashBEFORE them may help, but beware what the command will do)
git checkout maingit pull
- checkout a new branch
git checkout -b your-super-cool-branch-name
- make any changes you need locally and then commit those to your branch
git add .git commit -m "maybe you changed the readme, or did something else? type a summary of what you did here"
- push your branch up to github
git push
- After pushing to github, you may encounter a build error. These build errors can be caused by Failing Tests OR linter errors. To see a human-readable reason for what went wrong, run the following command locally:
npm run verify. That command will run the linter and run the tests and tell you if which of those steps failed, and why. In the event that it is linter issues, you can run the commandnpm run fix-lintto automagically resolve many (not always every) linter issue. Then you will need to manually fix the remaining ones and go back through steps (2) and (3).
This project is a hybrid between two front end stacks.
- HTML/CSS/Javascript
- React/SCSS/Webpack/babel
Originally, this project was created using HTML/CSS/Javascript, but we are now in the process of migrating (at least new UI code) to React
All react code is found in ./application/react
To Run react locally, open two terminals.
In the first terminal, run npm run react, this will start a automatically-hot-reloading react compiler, as you make changes to react components, the react compiler will automatically hot-reload react for you.
In the second terminal, run npm run start, this will start the express.js server for you.
Thats it, happy reacting!
Note: If you ever run into issues where the react code is not automically reloading for you, following the following steps to "Hard Reset".
- Delete
.parcel-cachein the root directory (if one exists) - Quick the running processes in ALL open terminals (CTRL + C or the equivalent)
- Close vscode
- Restart your computer
- Start up everything as normal and cross your fingers
To run the e2e tests, use the following command (found in package.json):
npm run acceptance
These e2e tests occassionally require an environment variable. These must be setup in the file cypress.config.js, they cannot be pulled directly from an .env file.
To run the cypress tests in "headed" mode, modify the cypress:run command to be the following, and then run npm run acceptance:
...
"cypress:run": "cypress run --headed",
...
If you have many changes locally and you want to get rid of them ALL (but save them away just-in-case)
git stash
If you recently ran git stash but you now regret that decision and want the stuff back
git stash pop
A dependency called eslint is used in this repository. Its single purpose is to enforce code formatting (i.e. tabs should be 4 spaces, not 2) and simple coding best-practices (i.e. no unused variables).
These "lint rules" are then ran to analyze the code during the CI/CD build and if ANY lint rules are broken (i.e. a file contains used 2 spaces instead of 4 for its indentation), the entire build will be marked as failing.
You can run these "lint rules" against your code locally manually to see if you have broken any using the command npm run lint. That command will generate human-readable messages that tell you exactly whcih lint rules were broken and where. If that command runs and no text is displayed describing the errors, that means you don't have any 🎊.
This repo contains many tests which all live in the folder named test (pretty logical eh?). The tests in this folder mimick much of the application folder structure. To manually run all of the tests locally, execute the command npm run test. That command will then execute every test in the test folder, and give a human-readable-ish explaination of which tests failed or passed. If any tests fail, you will need to investigate which of your code changes caused the test to fail.
Below is a list of rules that must be followed regarding the storage of common data attributes in any database table this application uses:
- Date/Time Attributes: Any Date/Time attribute MUST be stored in UTC
- Duration Attributes: (i.e. 1.5 hours, 16 minutes, 32 seconds, etc) SHOULD be stored in seconds. This means that if you need to store 1.5 hours, you must convert it into seconds before storing it in the database. (Note: if you need a higher precision than seconds, figure that out on a case-by-case basis)
- Note: If this were a true enterprise system with more requirements, I would change this requirement to be milliseconds, microseconds, ect. But in this application, that is overkill, and up to 1 second of precision is all that is required
- Currency Attributes: Must be stored in cents. This application only deals with USD, and any dollar amount must be converted into pennies before it is stored in the database. The number of pennies MUST be an integer, floating point pennies are NOT allowed in the database.
- Ex: $109.74 must be stored in the database as 10974
- Percentage Attributes: Must be stored in floating point form.
- Ex: 30.35% must be stored in the database as 0.3035
See all available icons and example imports via these docs: https://react-icons.github.io/react-icons/icons/fa6/
This project uses the library react-icons for displaying icons. Specifically, we use the sub-pcakage of that library react-icons/fa6 ("(F)ont (A)wesome 6")