0. Preface

If you want to learn and study CabloyJS or contribute PR, you can directly clone the CabloyJS source codes from GitHub

0. Prerequisites

Before cloning and running the CabloyJS source codes, make sure you have some prerequisites ready

0. Install Lerna

  1. 1$ sudo npm i -g lerna

1. Clone Cabloy Repository

  1. 1$ mkdir cabloy-lerna
  2. 2$ cd cabloy-lerna
  3. 3$ git clone https://github.com/zhennann/cabloy.git

2. Install Dependencies

  1. 1$ cd cabloy
  2. 2$ lerna bootstrap

Take notice: Use lerna bootstrap to install project dependencies, not npm install

3. Copy config files at Front

  1. 1$ cp -r src/front/_config src/front/config

4. Copy config files at Backend

  1. 1$ cp -r src/backend/_config src/backend/config

5. Configure Redis

Cluster now becomes the first class citizen of CabloyJS. In other words, the CabloyJS project is ready to be deployed in a clustered environment

The cluster feature of CabloyJS is designed based on Redis. Therefore, the connection configuration information of Redis needs to be set

Take notice: Use the default configuration, and just confirm whether the host and port parameters meet the actual values

6. Configure MySQL

CabloyJS provides three runtime environments. Therefore, it is necessary to set up the database connection configuration of the three runtime environments separately

Take notice: Use the default configuration, and just confirm whether the host, port, user and password parameters meet the actual values

7. Unit-Test

  1. 1$ npm run test:backend

CabloyJS recommends a test-driven development mode. By test-driven, you can lock in the results of development, and when there are code changes, you can find problems as soon as possible, so as to solve problems

In addition, the database architecture changes frequently during the development stage, when only one unit test command is needed to take effect, which means that the old test database is always deleted and a new test database is created automatically

8. Run

Start backend service

  1. 1$ npm run dev:backend

Start frontend service

  1. 1$ npm run dev:front

9. Enjoy

Appendix 1. Docker Compose

There is a docker-compose.yml configuration file in the root directory of the project. If you have installed the docker compose environment, you can start all services of CabloyJS with only one command, including Redis, MySQL, Nginx and CabloyJS backend service

  1. 1$ cp -r src/front/_config src/front/config
  2. 2$ cp -r src/backend/_config src/backend/config
  1. 1$ sudo docker-compose build
  2. 2$ sudo docker-compose up

Appendix 2. Test Suites/Modules

Test suites/modules Contains a large number of test-cases and kitchen-sink, and continues to add more content. It is not only convenient to quickly learn all aspects of knowledge points of CabloyJS, but also convenient to quickly start the actual business development

  1. 1# install suite test-party
  2. 2$ npm run cli :store:sync test-party
  3. 3# install module test-note
  4. 4$ npm run cli :store:sync test-note
  5. 5# install module test-flow
  6. 6$ npm run cli :store:sync test-flow

Appendix 3. Update

  • Update Cabloy
  1. 1# pull the new codes
  2. 2$ git pull
  3. 3# reinstall dependencies
  4. 4$ lerna bootstrap
  • Update Test Suites/Modules

Since third-party suites/modules are located in the source code directory {project}/src/suite-vendor and {project}/src/module-vendor, separate commands are required to update them

  1. 1$ npm run cli :store:sync

Appendix 4. Disable login verification code for development