-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Wouter Termont <woutermont@gmail.com>
- Loading branch information
1 parent
e3cdedb
commit 1f1a3d6
Showing
6 changed files
with
165 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
# Digita configuration repository | ||
|
||
Standard configuration of repos, packages etc. Easy to copy or inherit from. | ||
# Digita Configuration Repository | ||
|
||
This repository provides a standard configuration for repositories and packages, used internally at Digita to adopt a uniform clean coding environment. It contains the following configuration packages: | ||
|
||
- [`commitlint-config`](./packages/commitlint-config#readme) | ||
- [`eslint-config`](./packages/eslint-config#readme) | ||
- [`jest-config`](./packages/jest-config#readme) | ||
- [`lerna-config`](./packages/lerna-config#readme) | ||
- [`typescript-config`](./packages/typescript-config#readme) | ||
|
||
## Git hooks | ||
|
||
The Git hooks of this repository also serve as an instantly copyable base for new (mono)repos. We use Husky to share them via Git. Set it up by installing `husky` in the repo root and adding `husky install` as `postinstall` script to the root `package.json`. Then copy the `.husky` directory from this repo, and make sure to make the hooks themselves executable (e.g. `chmod a+x .husky/*`). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
# Digita Commitlint Configuration | ||
|
||
This package provides a shareable Commitlint configuration, used internally at Digita to adopt a uniform commit message style. | ||
|
||
## Installation | ||
|
||
In the root of your (mono)repo, install `@digita-ai/commitlint-config` as a development dependency. From NPM v7 onwards,, this will automatically add `@commitlint/cli` as a peer dependency as well (if you use an earlier version, install this yourself). Add the following `commitlint` object to the `package.json`. | ||
|
||
``` | ||
"commitlint": { | ||
"extends": [ | ||
"@digita-ai/commitlint-config" | ||
] | ||
} | ||
``` | ||
|
||
In a pre-commit git hook (e.g. with Husky), call `./node_modules/.bin/commitlint --edit $1`, or use Commitlint in any other way that fits your project. For an example of a git hook, check the `.husky/pre-commit` script of this repository. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
# Digita Jest Configuration | ||
|
||
This package provides a Jest preset configuration, used internally at Digita to adopt a uniform testing habit. | ||
|
||
## Installation | ||
|
||
In the root of your (mono)repo, install `@digita-ai/jest-config` as a development dependency. From NPM v7 onwards,, this will automatically add the following peer dependencies as well (if you use an earlier version, install these yourself). | ||
|
||
- `jest` | ||
- `@types/jest` | ||
- `jest-extended` | ||
- `jest-mock-extended` | ||
- `jest-coverage-thresholds-bumper` | ||
|
||
It will also suggest the following optional dependencies. | ||
|
||
- `@testing-library/jest-dom` | ||
- `jest-fetch-mock` | ||
|
||
When working in monorepo, install `jest` and `jest-coverage-thresholds-bumper` as development dependencies in each subrepo as well. | ||
|
||
In each `package.json`, add the following `jest` object. | ||
|
||
``` | ||
"jest": { | ||
"coverageThreshold": { | ||
"global": { | ||
"branches": 0, | ||
"functions": 0, | ||
"lines": 0, | ||
"statements": 0 | ||
} | ||
}, | ||
"displayName": "core", | ||
"preset": "@digita-ai/jest-config", | ||
"rootDir": "lib" | ||
} | ||
``` | ||
|
||
Coverage thresholds will automatically be raised when running tests. Optionally, you can tell Jest to look for tests in multiple directories by setting and extending the `"roots": [ "<rootDir>" ]` list. You can also switch testing environment between `node` and `jsdom` with `"testEnvironment": "node"`, and set configuration for these environments with `"testEnvironmentOptions": { /* ... */ }`. | ||
|
||
## Testing from the root of a monorepo | ||
|
||
When using git hooks in a monorepo, you might want to run Jest from the root `node_modules` of your repository, without having the test search for relative paths in the wrong place. To prevent this, add the following `jest` object to the root `package.json`, pointing to all packages where you wish to run Jest. | ||
|
||
``` | ||
"jest": { | ||
"preset": "@digita-ai/jest-config", | ||
"projects": [ | ||
"<rootDir>/packages/*/" | ||
] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
# Digita Lerna Configuration | ||
|
||
This package provides an extendable Lerna configuration, used internally at Digita to adopt a uniform monorepo setup. | ||
|
||
## Installation | ||
|
||
In the root of your (mono)repo, install `@digita-ai/lerna-config` as a development dependency. From NPM v7 onwards,, this will automatically add `lerna` as a peer dependency as well (if you use an earlier version, install this yourself). | ||
|
||
In the root `package.json`, add the following `lerna` object, with an initial version number. Lerna will find this and change it on each release. | ||
|
||
``` | ||
"lerna": { | ||
"extends": "@digita-ai/lerna-config", | ||
"version": "0.1.0" | ||
}, | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
# Digita Typescript Configuration | ||
|
||
This package provides a Typescript configurations, one for building and one for testing, used internally at Digita to adopt a uniform build mechanism. | ||
|
||
## Installation | ||
|
||
In the root of your (mono)repo, install `@digita-ai/typescript-config` as a development dependency. From NPM v7 onwards, this will automatically add the following peer dependencies as well (if you use an earlier version, install these yourself). | ||
|
||
- `typescript` | ||
- `@types/node` | ||
- `ts-node` | ||
|
||
Put the following in the `tsconfig.json` of your Typescript package(s). | ||
|
||
``` | ||
{ | ||
"extends": "@digita-ai/typescript-config/tsconfig.json", | ||
"compilerOptions": { | ||
"baseUrl": "./lib", | ||
"outDir": "./dist", | ||
"rootDir": "./lib", | ||
"module": "commonjs" | ||
} | ||
} | ||
``` | ||
|
||
Put the following in the `tsconfig.spec.json` of your Typescript package(s). | ||
|
||
``` | ||
{ | ||
"extends": "@digita-ai/typescript-config/tsconfig.spec.json", | ||
"compilerOptions": { | ||
"baseUrl": "./lib", | ||
"outDir": "./dist", | ||
"rootDir": "./lib", | ||
"module": "commonjs" | ||
} | ||
} | ||
``` | ||
|
||
In each of the above config files, change the `baseUrl` (base for relative imports), `outDir` (output directory for builds) and `rootDir` (root directory of source files) to the relevant paths (`rootDir` maps on `outDir` during build). Also set the `module` type to `commonjs` for Node.js packages or to the desired ECMAScript version (e.g. `es2020`) for browser packages. Overwrite any of the preset directives if needed. |