Add @monito
to list of registries.
@monito:registry=https://npm.pkg.github.com
Install package.
yarn add @monito/technical-stats
Configure package.json
to run cli tool
// package.json
{
...
"generate:stats": generate-stats.js
...
}
// generate-stats.js
const { cli } = require('@monito/technical-stats')
cli(__dirname, 'output') // second parameter is optional, if undefined, it will output in the __dirname folder
Add .env
file containing Github token.
TECHNICAL_STATS_GITHUB_TOKEN=
Configure goals.
// stats.config.js
const { pluginTypescript } = require('@monito/technical-stats')
module.exports = {
organization: 'monito',
plugins: {
pluginTypescript,
},
goals: [
{
name: 'Typescript Strict',
description: 'Should use a strict Typescript config',
check({ typescript }) {
if (!typescript.tsconfig) {
return { status: 'skip' }
}
const value = typescript.tsconfig.compilerOptions.strict
return {
status: value === true ? 'pass' : 'fail',
value
}
},
}
}
Run stats generation
yarn generate:stats
Open report.html
to see the results.
We welcome issues to and pull requests against this repository!
There is a target in the package.json
allowing to trigger the service-stats
CLI:
yarn cli:test
The prerequisites are:
- copy
.env.template
to.env
, and add your Github token. - create a
stats.config.js
in the./cli
directory
Sample of stats.config.js
:
const { circleci, docker, github, typescript } = require('../runner/plugins')
module.exports = {
organization: 'monito',
plugins: {
circleci,
docker,
github,
typescript,
},
checkAchieved(percentage) {
const value = percentage
const status = value >= 80 ? 'pass' : value >= 50 ? 'warn' : 'fail'
return {
status,
value,
}
},
goals: [
{
name: 'My check',
description: 'a check against the repository',
check({ circleci }) {
const value = circleci.version
return {
status: value === 2.1 ? 'pass' : 'warn',
value,
}
},
},
],
}
See the Config type
Reports are going to be created in the ./output
directory