Skip to content

Commit

Permalink
feat(none): 增加 commit 校验
Browse files Browse the repository at this point in the history
  • Loading branch information
Maidang1 committed Sep 24, 2024
1 parent 4033586 commit 7870a99
Show file tree
Hide file tree
Showing 6 changed files with 2,365 additions and 2,377 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/commit-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Commit Lint

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "18"
cache: "pnpm"

- name: Install dependencies
run: pnpm install

- name: Run commitlint
run: npx commitlint --from=HEAD~1
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no-install commitlint --edit "$1"
Empty file added .husky/pre-commit
Empty file.
41 changes: 41 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const pc = require("picocolors");

const scoreRule = (parsed) => {
const validScores = ["js-plugins", "rust-plugins", "all", "none"];
const isValid = validScores.includes(parsed.scope);

return [
isValid,
`current scope is ${pc.yellow(parsed.scope)}, ${pc.green(
"because we need the right scope to do CI dispatch"
)} .Mark ${pc.yellowBright(
"js-plugins"
)} if you need to change the ${pc.yellowBright("js package")}.
Mark ${pc.yellowBright(
"rust-plugins"
)} if you need to change the ${pc.yellowBright(
"rust package"
)} mark ${pc.yellowBright("all")} if you have ${pc.yellowBright(
"both"
)} and ${pc.yellowBright("none if you don't need to send packages")}`,
];
};

module.exports = {
rules: {
// "scope-enum": [2, "always", ["js-plugins", "rust-plugins", "all", "none"]],
"score-rule": [2, "always"],
"type-enum": [
2,
"always",
["feat", "fix", "docs", "style", "refactor", "perf", "test", "chore"],
],
},
plugins: [
{
rules: {
"score-rule": scoreRule,
},
},
],
};
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
"description": "The collections of farm plugins",
"packageManager": "[email protected]",
"scripts": {
"release": "npx changeset && npx changeset version"
"release": "npx changeset && npx changeset version",
"prepare": "husky"
},
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": {
"@changesets/cli": "^2.27.7",
"@farmfe/plugin-tools": "latest"
"@farmfe/plugin-tools": "latest",
"commitlint": "^19.5.0",
"husky": "^9.1.6",
"picocolors": "^1.1.0"
}
}
Loading

0 comments on commit 7870a99

Please sign in to comment.