1.git clone https://github.com/NJIT-CS490-SP21/project2-jp75
pip install Flask
npm install
Flask-Cors==3.0.10
Flask-SocketIO==5.0.1
Flask-SQLAlchemy==2.1
psycopg2
yapf==0.30.0
pylint==2.4.4
npm install --save-dev --save-exact prettier
pip install -r requirements.txt
-this could be done to match all files that I have to ensure it will run
- Run
echo "DANGEROUSLY_DISABLE_HOST_CHECK=true" > .env.development.local
in the project directory
- type heroku login -i to login to heroku
- type heroku create (Create a new heroku app)
- heroku addons:create heroku-postgresql:hobby-dev (add a DB)
- heroku config (check your env vars)
- Create a .env and put the info inside with the below string
- DATABASE_URL='set the URL what we got from heroku config'
- Run command in terminal (in your project directory):
python app.py
- Run command in another terminal,
cd
into the project directory, and runnpm run start
- Preview web page in browser '/'
- navigate to Tests/unmocked and drag the file to the same level as app.py
- run the unit_tests.py file to see that tests pass.(You could add some tests if further wanting to test)
- put file back in unmocked and do the same with mocked.
- navigate to src folder and look for App.test.js
- in order to test this open up a terminal and change into the directory of the project
- type in
npm test App.test.js
and you will be able to see that all tests pass. (add more tests if you want)
- Type in
pylint app.py
and see that all linting errors are fixed - Type in
npx eslint src/App.js
to see airbnb eslint satisfied - Type in
npx eslint src/board.js
to see that meets satisfied as well
- Make sure you don't have any heroku files saved by typing
git remote -v
- If there is already a heroku app type
git remote rm heroku
- Create a new heroku app
- Add python buildpack
heroku buildpacks:add --index 1 heroku/python
or add it on herokus website - Add nodejs buildpack:
heroku buildpacks:add --index 1 heroku/nodejs
or add it on herokus website - Push to Heroku:
git push heroku main
if you want to put it in your main branch
- Files have been formatted already, but if you want to reformat them type
yapf -i app.py
to format the python file - To format .js files type in
npx prettier --write src/App.js
. Do this for all .js files (This gave me an issue trying to work with airbn eslint)
- I had an issue trying to run certain unmocked tests. If I had more time I would definitely put time into understanding the concepts. One that I was having issues mocking was filter_by(). I'm assuming if I were to do something like this with patch('models.Joined.query') as mocked_query: and usee another defined function to mock up the filter than I could get this done, but was having issues getting it to work.
- I had some issues trying to make some test cases using jest. One issue that I couldn't resolve, but wish I had more time to figure out was tring to get my rest button to work by getByText. It kept giving me an error I think because my code wasn't in the format that get the text. I'm assuming my html code wasn't seperated in funtions, or I should've done that, but instead I made divs and put code inside not really keeping track of where I put everything. I learned that it's important to keep track of where your code is going.
- I had an issue trying to run unmock tests on my db in unittests.py. The issue I had with this was that it wouldn't see if the user was already in the database. I'm assuming I wasn't writing the right code to mock the filterBy(). The way I solved this was by moving that filterBy() outside of my mtehod and got it to work without the filterBy() in the function.
- I had an issue trying to get airbnb to work. The way I wen't about it was to follow that github file explaining how to go about it and finally got it to work. I amde a .eslintrc file and put "extends": ["airbnb", "airbnb/hooks"] which seemed to get it to work. THis then gave me 200+ errors that I was confused over and wasn't sure if I was doing it right. I was hving trouble trying to get certain errors to go away, and ended up googling a lot to get things to work right. Some things that I had to change were changing ++ to += 1 insead all "" nedded to be changed to '',etc. This took me over 3 hours to figure it out, but I finally did and learned a lot.