Chapter | Description |
---|---|
Setup | How to set up the project |
Deployment | How to deploy the frontend |
Structure | How to structure your code, aka what is in which folder |
What doesn't work and needs refactoring | Rundown of which parts of the system needs reworking or rewriting |
Testing | How to test the frontend |
- Git commandline tools - Downloads available here
- NodeJS v12 - Find the relevant version here
- yarn -
npm install -g yarn
- firebase-tools -
npm install -g firebase-tools
- Google cloud SDK @ latest - Instructions available here
- NVM - Node version manager for windows. Allows you to install and manage node installations on the fly.
Make sure you're in the webapp folder when running yarn commands. PS We're using react-scripts, so check out the Create React App page for further information.
Before you can run the development server or create a build, you need to get the environment variables for the application.
These variables are found in the .env.production.enc
and the .env.development.enc
.
You need to log in to the gcloud tool. Running gcloud auth login
, setting the correct project or creating a config for the project is out of scope of this readme,
but have a look at gcloud config configurations
command for that.
The following commands can be used to decrypt the files.
- production -
gcloud kms decrypt --plaintext-file=.env.production --ciphertext-file=.env.production.enc --key=react-env-vars --keyring=cloud-build --location=global
- development -
gcloud kms decrypt --plaintext-file=.env.development --ciphertext-file=.env.development.enc --key=react-env-vars --keyring=cloud-build --location=global
The following commands can be used to encrypt the files.
- production -
gcloud kms encrypt --plaintext-file=.env.production --ciphertext-file=.env.production.enc --key=react-env-vars --keyring=cloud-build --location=global
- development -
gcloud kms encrypt --plaintext-file=.env.development --ciphertext-file=.env.development.enc --key=react-env-vars --keyring=cloud-build --location=global
yarn install
- Installs all relevant packages needed for building the webapp.
yarn start
or, if windows:yarn winStart
- Runs the app in development mode.
Open http://localhost:3000 to view it in the browser.
yarn build
- Builds the app for production to thebuild
folder. It correctly bundles React in production mode and optimizes the build for the best performance.yarn build:dev
- Builds the app with development settings for deployment to the dev-site.yarn build:ci
- Build the app without hooking intoprebuild
andbuild
to skip linting. Used by the CI-tool.yarn compile:ci
- Runs compilation of the app using the typescript compiler. Used by the CI-tool.
Checks that all files follow the rules set in .eslintrc.js
and .prettierrc.js
regarding formatting.
Running this is recommended before every push to branch.
It is also possible to run this whenever files are saved, as long as the IDE knows it should run this project's ESLint.
yarn lint
- Runs eslint with the provided configuration and attempts to rectify fixable linting errors.yarn lint:ci
- Runs eslint with the provided configuration and outputs the results to file. Used by the CI-tool.
yarn test:firestore
- Runs the firebase emulators to execute firestore rule tests using mochayarn test:fireestore:no:emulators
- Runs the defined firestore rule tests using mocha, without firing up emulators. This is used for writing tests that require you to examine the data in firestore before/after the test run.yarn test:firestore:dev
- Runs the firebase emulators to execute watched firestore rules with mocha. Useful for developing tests on the fly.firebase emulators:start
- Starts up the firebase emulators, useful for watching data change in tests. Can be used with the--only
-flag to specify a single emulator to start e.gfirebase emulators:start --only firestore
firebase serve
- Serves up the build folder after running eitheryarn build
oryarn build:dev
. This command is no longer recommended by firebase, instead usefirebase emulators:start
firebase emulators:start
- Is currently the recommended way of serving the result ofyarn build
oryarn build:dev
. Use this to verify that the build works as it should.
This will deploy the webapp, functions and firestore setup to the Firebase hosting environment.
- Login to firebase:
firebase login
The following command will set the correct firebase project, build and deploy the webapp
- Switch firebase project:
firebase use dev
- Build webapp:
yarn build:dev
- Deploy webapp:
firebase deploy
The following command will set the correct firebase project, build and deploy the webapp
- Switch firebase project:
firebase use prod
- Build webapp:
yarn build
- Deploy webapp:
firebase deploy
see Wiki
Folder name | What lies there |
---|---|
components | legacy components, updated components were mostly moved to our storybook repo |
containers | no structure, whatever didn't fit in components went to the container folder. |
contexts | all of the context files |
hooks | custom hooks |
libraries | for bigger npm packages or libraries. Only CKEditor lies there for now |
models | some typescript models moved from containers |
molecules | ATOM part of folders |
organisms | components that contain multiple molecules and atoms |
templates | templates for pages that need same setup and "look". For example all components that appear in "create new" should have title, padding and width in the same place and have the same size |
pages | the usual, a page is the component with all functionality that appears for the user |
utils | utils |
In settings there is "make new style/lag ny stil". This does not work for our customer.
Our customers often do not get messages with the code to log in with 2FA, leaving them stuck and unable to log in.
If you have a bulletin that is active and press the button to "make a draft" it does something... It should take you to the same bulletin but now on the draft page, but instead, it just reloads.
When you come to the "innhold" step in the "create new" bulletin you can see that the page is not very user-friendly.
The thing that usually gets left out is functionality given by the side menu. If you go to a bulletin through there you can get summary of the bulletin, regardless if it's a draft or not.
The 2FA is often forgotten, and it seems that it isn't working properly, so it needs to be checked out.
This project uses cypress for testing. There is only one test so far. If "create new" needs testing, it is recommended to use component testing, since end-to-end tests tend to crash. This seems like memory issue, so if you want to make end-to-end tests in this project use firefox or something that is not Chrome.