Skip to content

Commit

Permalink
ci: configure commitlint with commitizen
Browse files Browse the repository at this point in the history
Add commitlint to ensure correct conventional commits via commit message hook.
Configure it based on Angular conventional commits.
Configure commitizen to suggest types & scopes interactively.
Ignore commits that start with WIP/wip.

resolves #7
  • Loading branch information
twittwer committed May 2, 2020
1 parent 32f5cea commit bfb6921
Show file tree
Hide file tree
Showing 8 changed files with 1,475 additions and 110 deletions.
34 changes: 34 additions & 0 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
extends: ['@commitlint/config-angular'],
rules: {
'type-enum': [
2,
'always',
[
// Minor
'feat',
// Patch
'build',
'docs',
'fix',
'perf',
'refactor',
// None
'chore',
'ci',
'revert',
'test',
],
],
'scope-empty': [0],
'scope-enum': [
2,
'always',
// prettier-ignore
[
'compodoc'
],
],
},
ignores: [message => message.toLowerCase().startsWith('wip')],
};
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# nxTools

[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
[![commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

> Workspace for Nx Plugins.
Expand Down
4 changes: 3 additions & 1 deletion libs/compodoc/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# compodoc

[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
[![commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

> Nx Plugin to integrate the generation of documentation with [Compodoc](https://compodoc.app/) in the [Nx workflow](https://nx.dev/angular).
Expand Down
24 changes: 24 additions & 0 deletions libs/compodoc/src/schematics/ng-add/ng-add-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,27 @@ export function moveToDevDependencies(packageName: string): Rule {
return packageJson;
});
}

export function addCacheableOperation(operation: string): Rule {
return updateJsonInTree('nx.json', nxJson => {
if (
!nxJson.tasksRunnerOptions?.default?.runner ||
!Array.isArray(
nxJson.tasksRunnerOptions?.default?.options?.cacheableOperations,
)
) {
return nxJson;
}

const isAlreadyCached = nxJson.tasksRunnerOptions.default.options.cacheableOperations.includes(
operation,
);
if (!isAlreadyCached) {
nxJson.tasksRunnerOptions.default.options.cacheableOperations.push(
operation,
);
}

return nxJson;
});
}
8 changes: 6 additions & 2 deletions libs/compodoc/src/schematics/ng-add/schematic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { chain, Rule } from '@angular-devkit/schematics';
import { installDependencies, moveToDevDependencies } from './ng-add-utils';
import {
addCacheableOperation,
installDependencies,
moveToDevDependencies,
} from './ng-add-utils';

// TODO: Evaluate the best option for plugin dependency on compodoc
// - defined a wildcard version (`*`)
Expand All @@ -15,6 +19,6 @@ export default function(): Rule {
},
}),
moveToDevDependencies('@twittwer/compodoc'), // is eventually added to the dependencies by the ng-add command
// TODO: add `compodoc` to `cacheableOperations` in `nx.json`
addCacheableOperation('compodoc'),
]);
}
Loading

0 comments on commit bfb6921

Please sign in to comment.