Package Scripts - HelpRefugees/project-flamingo GitHub Wiki
We have provided a lot of developer automation for common tasks using the
"scripts"
section in the
package.json
.
Below is a guide to some of the scripts you may find yourself using.
Development
-
yarn install:all
: install all of the client and server dependencies. -
yarn client ...
: run the provided command in theclient
directory, e.g.yarn client add [whatever]
allows you to install a new client dependency. -
yarn dev
: runs the app in development mode, where changes to the client or server code will cause a reload. This usesnodemon
to watch the server files and thecreate-react-app
server for the client. In this mode you can visit the client at http://localhost:4200 and any requests will be proxied to the server (running on port 3000). Note that the browser will reload automatically if the client code changes, but you have to refresh the page manually to see changes in the server code. This also runs the Zapier spy. -
yarn test:client:watch
: watches the code in theclient
directory and re-runs the appropriate unit and integration tests whenever anything changes. -
yarn test:scripts:watch
: as above but for thescripts
directory. -
yarn test:server:watch
: as above but for theserver
directory. -
yarn e2e:dev
: runs the end-to-end tests (see below) against the development mode of the application. -
yarn cypress:dev
: opens the Cypress UI and targets the development mode app, allowing you to see exactly what's happening in the end-to-end tests. -
yarn mm migrate
: apply the migrations specified inserver/migrations
to the local database (or the database specified with theDATABASE_URL
environment variable). -
yarn mm create [name]
: create a new migration file; seemongodb-migrations
for details.
Testing
-
yarn lint
: checks all JavaScript code against the project style rules using ESLint and uses Flow to type-check the client code. You can also runlint:fix
to automatically fix simple errors. -
yarn test
: runs the unit and integration tests for the client, script and server code. -
yarn test:cover
: runs all of the unit and integration tests and generates code coverage reports. -
yarn e2e
: runs the end-to-end tests, simulating a user interacting with the application in a browser, using Cypress. By default this runs against the app in production mode, on port 3000. -
yarn e2e:ci
: simultaneously starts the app in production mode (on port 3100 to avoid any conflicts) and runs the end-to-end tests against it, after waiting for the app to start. This also runs the Zapier spy. -
yarn ship
: runs linting, flow checking, unit and integration testing and the end-to-end CI test. This is executed byhusky
when you try to push your git commits to a remote, as a final check that everything works correctly*.
Deployment
yarn start
: runs the app in the production mode, by building the React app, copying the resulting files over to the Express app'sstatic/
directory, then starting the Express app. You can then visit the application at http://localhost:3000 (or whatever port you specify with thePORT
environment variable). Note that this will not start the Zapier spy, so you need to provide anEMAIL_WEBHOOK
if you want to test the password reset.
Other
-
yarn zapier
: runs the Zapier spy (seee2e/fixtures/zapierSpy.js
), which accepts any POST request to/
and stores the request bodies for later recovery via the/_calls
endpoint. This is used by thedev
ande2e:ci
scripts to allow testing of the password reset flow. -
yarn generate-reports
: each implementing partner gets a new report to fill in every month, created by this script. In production we're using PCF Scheduler to run this task on the first of every month, but you can also run this locally for testing (it will only generate one report per implementing partner per month, even if you run it more than once). -
yarn hash-password [password]
: usesbcrypt
to create a hashed version of the supplied password to store in the database. -
yarn send-due-emails
: sends emails to anyone whose report is due in the next week, via the specifiedEMAIL_WEBHOOK
.
* If you're making non-code changes, e.g. updating the documentation, you can
include [ci skip]
in the commit message to skip the Travis build and use the
--no-verify
flag to git push
to skip the Husky hook.