Skip to content

Commit 90ba224

Browse files
committed
📦 feat(commit-type): extract commit-type package
1 parent a55ba89 commit 90ba224

File tree

11 files changed

+92
-21
lines changed

11 files changed

+92
-21
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@
2525
| ---------------------------------------------- | ------------------------------------------ | ------------------------------------- |
2626
| [commitlint-plugin-gitmoji](./packages/plugin) | [![NPM version][plugin-image]][plugin-url] | commitlint plugin to add gitmoji rule |
2727
| [@gitmoji/parser-opts](./packages/parser-opts) | [![NPM version][parser-image]][parser-url] | parser opts of gitmoji styles commit |
28+
| [@gitmoji/commit-type](./packages/commit-type) | [![NPM version][type-image]][type-url] | gitmoji commit type |
2829

2930
<!-- npm url -->
3031

3132
[parser-image]: http://img.shields.io/npm/v/@gitmoji/parser-opts.svg?style=flat-square&color=deepgreen&label=latest
3233
[parser-url]: http://npmjs.org/package/@gitmoji/parser-opts
34+
[type-image]: http://img.shields.io/npm/v/@gitmoji/commit-type.svg?style=flat-square&color=deepgreen&label=latest
35+
[type-url]: http://npmjs.org/package/@gitmoji/commit-type
3336

3437
## About this Repo
3538

jest.config.base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
moduleNameMapper: {
88
'commitlint-plugin-gitmoji': '<rootDir>/packages/plugin/src',
99
'@gitmoji/parser-opts': '<rootDir>/packages/parser-opts/src',
10+
'@gitmoji/commit-type': '<rootDir>/packages/commit-type/src',
1011
},
1112
rootDir: path.resolve(__dirname, '.'),
1213
};

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
"ts-node": "^9.1.1",
5353
"typescript": "^4.1.3",
5454
"conventional-changelog-gitmoji-config": "^1.0.0",
55-
"conventional-changelog-core": "^3.2.2",
56-
"@types/conventional-changelog": "^3.1.0",
57-
"conventional-changelog": "^3.1.24"
55+
"@types/conventional-changelog": "^3.1.0"
5856
}
5957
}

packages/commit-type/.fatherrc.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
entry: 'src/index.ts',
3+
cjs: 'babel',
4+
target: 'node',
5+
};

packages/commit-type/package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "@gitmoji/commit-type",
3+
"version": "1.0.0",
4+
"description": "gitmoji commit type",
5+
"author": "arvinxx <arvinx@foxmail.com>",
6+
"homepage": "https://github.com/arvinxx/commit-gitmoji/tree/master/packages/commit-type",
7+
"license": "MIT",
8+
"main": "lib/index.js",
9+
"files": [
10+
"lib",
11+
"src"
12+
],
13+
"scripts": {
14+
"build": "father-build"
15+
},
16+
"publishConfig": {
17+
"access": "public",
18+
"registry": "https://registry.npmjs.org/"
19+
},
20+
"repository": {
21+
"type": "git",
22+
"url": "git+https://github.com/arvinxx/commit-gitmoji.git"
23+
},
24+
"bugs": {
25+
"url": "https://github.com/arvinxx/commit-gitmoji/issues"
26+
}
27+
}

packages/commit-type/src/index.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export type CommitTypes =
2+
| 'build'
3+
| 'ci'
4+
| 'docs'
5+
| 'feat'
6+
| 'fix'
7+
| 'perf'
8+
| 'refactor'
9+
| 'revert'
10+
| 'style'
11+
| 'test'
12+
| 'chore';
13+
14+
const types: CommitTypes[] = [
15+
'build',
16+
'ci',
17+
'docs',
18+
'feat',
19+
'fix',
20+
'perf',
21+
'refactor',
22+
'revert',
23+
'style',
24+
'test',
25+
'chore',
26+
];
27+
28+
module.exports = types;
29+
export default types;

packages/commit-type/tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"include": ["src"],
4+
"compilerOptions": {
5+
"module": "CommonJS",
6+
"target": "es5",
7+
"sourceMap": true,
8+
"moduleResolution": "Node",
9+
"lib": ["ES2020"],
10+
"esModuleInterop": true,
11+
"declaration": true
12+
}
13+
}

packages/config/.fatherrc.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
module.exports = {
22
entry: 'src/index.ts',
33
cjs: 'babel',
4-
pkgs: ['commitlint-plugin-gitmoji', '@gitmoji/parser-opts'],
4+
pkgs: [
5+
'commitlint-plugin-gitmoji',
6+
'@gitmoji/parser-opts',
7+
'@gitmoji/commit-type',
8+
],
59
};

packages/config/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"author": "Arvin Xu <arvinx@foxmail.com>",
3535
"license": "MIT",
3636
"dependencies": {
37-
"@gitmoji/parser-opts": "^1.0.0",
37+
"@gitmoji/parser-opts": "^1.1.0",
38+
"@gitmoji/commit-type": "^1.0.0",
3839
"commitlint-plugin-gitmoji": "^2.0.0"
3940
}
4041
}

packages/config/src/index.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,15 @@ import type { LintOptions, QualifiedRules } from '@commitlint/types';
33

44
import gitmojiPlugin from 'commitlint-plugin-gitmoji';
55
import gitmojiParserOpts from '@gitmoji/parser-opts';
6+
import commitTypes from '@gitmoji/commit-type';
67

78
const { Error } = RuleConfigSeverity;
8-
const types = [
9-
'build',
10-
'ci',
11-
'docs',
12-
'feat',
13-
'fix',
14-
'perf',
15-
'refactor',
16-
'revert',
17-
'style',
18-
'test',
19-
'chore',
20-
];
219

2210
const rules: QualifiedRules = {
11+
// gitmoji 规则
2312
'start-with-gitmoji': [Error, 'always'],
24-
// 使用 Angular 的类型说明
25-
'type-enum': [Error, 'always', types],
13+
// 使用 Angular 的类型
14+
'type-enum': [Error, 'always', commitTypes],
2615
// 内容以空行开始
2716
'body-leading-blank': [Error, 'always'],
2817
// 结尾以空行开始

0 commit comments

Comments
 (0)