-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
156 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# `cli` | ||
|
||
> TODO: description | ||
## Usage | ||
|
||
``` | ||
const cli = require('cli'); | ||
// TODO: DEMONSTRATE API | ||
``` |
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,36 @@ | ||
{ | ||
"name": "@xus/cli-plugin-command-commit-lint", | ||
"version": "0.0.1", | ||
"description": "xus cli plugin command-commit-lint", | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"keywords": [ | ||
"cli", | ||
"commit-lint" | ||
], | ||
"author": "guo.xu <xuguo@outlook.it>", | ||
"homepage": "https://github.com/xus-code/bundle-tools/tree/master/packages/cli#readme", | ||
"license": "MIT", | ||
"files": [ | ||
"dist" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/xus-code/bundle-tools.git" | ||
}, | ||
"scripts": { | ||
"dev:cl": "tsc --watch", | ||
"build:cl": "tsc" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/xus-code/bundle-tools/issues" | ||
}, | ||
"dependencies": { | ||
"@xus/cli": "^0.0.1", | ||
"chalk": "^4.1.0", | ||
"fs-extra": "^9.1.0" | ||
}, | ||
"devDependencies": { | ||
"@types/fs-extra": "^9.0.6" | ||
} | ||
} |
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,4 @@ | ||
export const HuskyGitParamsEnv = 'HUSKY_GIT_PARAMS' | ||
|
||
export const commitRE = /^(revert: )?(fix|feat|docs|perf|test|types|style|build|chore|refactor|ci|wip|breaking change)(\(.+\))?: .{1,50}/ | ||
export const mergeRE = /Merge / |
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,52 @@ | ||
import type { IPluginAPI } from '@xus/cli' | ||
import { HuskyGitParamsEnv, commitRE, mergeRE } from './constants' | ||
import { readFileSync } from 'fs-extra' | ||
import chalk from 'chalk' | ||
|
||
export default function (api: IPluginAPI): void { | ||
api.registerCommand( | ||
'commit-lint', | ||
{ | ||
usage: 'xus commit-lint', | ||
desc: 'help you to validate commit message' | ||
}, | ||
() => { | ||
const gitParams = api.EnvManager.getEnv(HuskyGitParamsEnv) | ||
if (gitParams) { | ||
const commitMsg = readFileSync(gitParams, 'utf-8').trim() | ||
if (!commitRE.test(commitMsg) && !mergeRE.test(commitMsg)) { | ||
console.info(`invalid commit message: | ||
"${chalk.red(commitMsg)}". | ||
Proper commit message format is required for automated changelog generation. | ||
Examples: | ||
- fix(Button): incorrect style | ||
- feat(Button): incorrect style | ||
- docs(Button): fix typo | ||
Allowed Types: | ||
- fix (修复bug) | ||
- feat (新特性) | ||
- docs (文档相关) | ||
- perf (性能优化) | ||
- test (测试相关) | ||
- types (ts类型相关) | ||
- build (打包构建相关) | ||
- chore (其他类型) | ||
- ci (CI/CD相关) | ||
- wip (开发中间态) | ||
- refactor (代码重构) | ||
- breaking change (重大变更) | ||
- Merge branch 'foo' into 'bar' (分支合并) | ||
`) | ||
process.exit(1) | ||
} | ||
} | ||
console.log(chalk.red(`no HUSKY_GIT_PARAMS`)) | ||
process.exit(1) | ||
} | ||
) | ||
} |
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,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "./dist" | ||
}, | ||
"extends": "../../tsconfig.json", | ||
"include": ["./src/**/*"] | ||
} |
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
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
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