JsBattle Docs

Monorepo

Rationale

There are a number of potential advantages to a monorepo over individual repositories:

Tooling

The repository is managed by Lerna. Most important operations handler by Lerna are:

Adding new package

Follow those steps to add new monorepo package

  1. Create npm package:
mkdir packages/PackageName
cd packages/PackageName
npm init -y
  1. Update package.json. Update version and other required fields:
{
  "name": "PackageName",
  "version": "2.7.1",
  "license": "MIT"
  ...
}
  1. Add npm-scripts (replace placeholders by real scripts):
  "scripts": {
    "clean": "echo \"Error: no clean script specified\" && exit 1",
    "lint": "echo \"Error: no lint script specified\" && exit 1",
    "build": "echo \"Error: no build script specified\" && exit 1",
    "test": "echo \"Error: no test script specified\" && exit 1"
  }
}
  1. (Optional) Add dependencies on other packages to package.json. Remember to add package name to bundledDependencies to avoid missing dependecy error during npm install (private packages must be bundled because they are not published to NPM repository).
{
  ...
  "dependencies": {
    "AnotherPackageName": "*"
  },
  "bundledDependencies": [
    "AnotherPackageName"
  ]
}
  1. Link all internal dependencies by running lerna bootstrap

  2. Update sonar config at sonar-project.properties:

...
sonar.modules=jsbattle,...,packageName
...
packageName.sonar.projectName=packageName
packageName.sonar.sources=src
packageName.sonar.projectBaseDir=packages/packageName
  1. Update the docs at packages/jsbattle-docs/docs/dev_guide/dev_process/structure.md

Managing Monorepo

All common operation can be done from root directory of the project by calling proper npm script (npm run scriptName). Check package.json for more details. Some examples are:

All bulk actions on multiple packages are done in the order that resolves dependencies properly. Releasing process from the repo is described here. Further information can be found in Lerna Documentation.