/carol

Primary LanguageJavaScript

Quotatis Single Page Application

Master: Scrutinizer Code Quality Code Coverage Build Status Dependencies:

Version: 1.7.0

1. Requirements

Node.js, Docker

2. Getting Started

If it's not done yet, please install Node.js and Yarn.

Clone the project from github and open a command prompt in the project directory.

Install all the project's dependencies:

yarn

Edit you /etc/hosts file and add the following line:

127.0.0.1 carol-fr-dev.qarx.io carol-es-dev.qarx.io carol-co-uk-dev.qarx.io api-dev.qarx.io

Start the development server (changes will now update live in browser)

yarn start

Open your browser and got to https://carol-fr-dev.qarx.io:4433

Carol will be connected to the Sandy API running in the QA environment.

3. CSS integration

We use web components and atomic-design principles coupled to styled-components to design our application.

To avoid mistakes and errors in your css syntax you must run :

yarn run lint:css

If you got CssSyntaxError using css function from styled-components and all seems good for you, it's probably linked to this issue in stylelint package.

4. Functional tests

In order to run functional tests, first start the mocks:

yarn start:mocks

This will start the simulado server, prime it and then run the server side rendering server using the mocks environment.

After that, you are ready to run the functional tests:

yarn cucumber

5. Getting Started with docker

When the QA environment is not enough and you want to be run sandy locally on a particular branch, you will want to install the docker environment.

Follow the instructions on the Sandy README

docker-compose up -d # don't forget to change the ENV var for the enviroment (develoment / qa / production)

Using docker toolbox

When the native docker integration on Mac or Windows is not fast enough, you may want to look at Docker Toolboxhttps://www.docker.com/products/docker-toolbox).

Docker toolbox uses an underlying VM whose default IP address is 192.168.99.100, so you'll need to update you /etc/hosts file as explained below.

If you decide to run carol fully inside docker and you use docker toolbox, you will have to change your /etc/hosts to look like this:

192.168.99.100 carol-fr-dev.qarx.io carol-es-dev.qarx.io carol-co-uk-dev.qarx.io api-dev.qarx.io

Otherwise to run carol outside with docker toolbox, your /etc/hosts should contain the following lines:

127.0.0.1 carol-fr-dev.qarx.io carol-es-dev.qarx.io carol-co-uk-dev.qarx.io
192.168.99.100  api-dev.qarx.io

Using docker for dora but running carol locally

Carol start in docker is painfully slow on MacOS and Windows. In case you want to run carol locally but connected to carol running inside docker, run the following command:

NODE_ENV=outsideDocker yarn start

6. Testing as in production

Useful when trying to reproduce a production issue locally or after a refactoring to make sure it will work in prod.

Temporarily edit your config to remove assetPath and locales nodes (under the production node) so that they default to the local values.

Then run the following commands

NODE_ENV=production yarn build
NODE_ENV=production PORT=8080 yarn start

7. Deployment

In order to deploy into pre-production for the SPA you will have to push to the branch develop. Travis will be able to build the docker container, run the tests than deploy to kubernetes using the last develop build.

The production run on Node.js with Express.js and deployed with ansible.

8. Environments

name description
production production environment
qa QA environment
development running locally connected to dora's QA
outsideDocker running locally connected to dora in docker
insideDocker running in docker connected to dora in docker
mocks mocks environment to run functional tests
travis travis environment to run functional tests

9. Storybook

All Atoms of the project are in Storybook

yarn storybook

Open your http://localhost:9001

10. Changelog

To produce the changelog for a sprint, run the following:

Usage: yarn run -s changelog <sprint number>

You will be asked for your JIRA email and password first and it will then produce the contents of the changelog.

11. To run the app on your mobile

Start CAROL on http on a separate port

SSL_ENABLED=false PORT=4444 yarn start

Then install ngrok and create an external url by running:

ngrok http --host-header=carol-fr-dev.qarx.io 4444

On your mobile, go to the forwarding URL that is printed in the console (e.g. https://97ee6e5c.ngrok.io)