Skip to content

Commit 1fbdd54

Browse files
z825316969youncccat
andauthored
E2E test && perfect symbol rule (#7)
* [Add::rules] add breakChangeSymbol rules * [Feat::rules] docking plugins to the config of commitlint * [Chore::relues] break change symbol rule add parameters * [Add::rules] add breakChangeSymbol rules * [Feat::rules] docking plugins to the config of commitlint * [Chore::relues] break change symbol rule add parameters * [WIP] add breakChangeSymbol rule (#2) * [Add::rules] add breakChangeSymbol rules * [Feat::rules] docking plugins to the config of commitlint Co-authored-by: youncccat <[email protected]> * [Feat] add utils for using $ to exec * [Test::e2e] e2e test case Co-authored-by: youncccat <[email protected]>
1 parent 519dded commit 1fbdd54

File tree

7 files changed

+220
-74
lines changed

7 files changed

+220
-74
lines changed

packages/commitlint-config-wizardoc/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const config: UserConfig = {
2323
},
2424
...plugins,
2525
rules: {
26-
"break-change-prefix": [2, "always"],
26+
"break-change-prefix": [2, "always", "#"],
2727
"footer-leading-blank": [1, "always"],
2828
"header-max-length": [2, "always", 72],
2929
"subject-full-stop": [2, "never", "."],
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import { BREAK_CHANGE_SYMBOL } from "./constants";
2-
import { Commit, Rule, RuleOutcome } from "@commitlint/types";
2+
import { Commit, RuleOutcome, RuleConfigCondition } from "@commitlint/types";
33

44
export type WithSymbol<T> = T & {
55
symbol: string;
66
};
77

88
export type CommitWithSymbol = WithSymbol<Commit>;
99

10-
export const breakChangeSymbolRule = (walkData: Commit): RuleOutcome => {
10+
export const breakChangeSymbolRule = (
11+
walkData: Commit,
12+
_when?: RuleConfigCondition,
13+
value: string = BREAK_CHANGE_SYMBOL
14+
): RuleOutcome => {
1115
const { symbol } = walkData as CommitWithSymbol;
12-
const isRuleValid = !symbol || symbol === BREAK_CHANGE_SYMBOL;
16+
const isRuleValid = !symbol || symbol === value;
1317

1418
return [
1519
isRuleValid,
16-
`break change must be symbol with "${BREAK_CHANGE_SYMBOL}" e.g: ${BREAK_CHANGE_SYMBOL}[Type::scope] subject`,
20+
`break change must be symbol with "${value}" e.g: ${value}[Type::scope] subject`,
1721
];
1822
};

packages/commitlint-wizardoc-e2e-tests/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
"main": "index.js",
55
"license": "MIT",
66
"devDependencies": {
7-
"zx": "^1.12.0"
7+
"@types/shelljs": "^0.8.8"
88
},
99
"dependencies": {
10-
"commitlint-config-wizardoc": "^1.0.0"
10+
"commitlint-config-wizardoc": "^1.0.0",
11+
"shelljs": "^0.8.4"
1112
}
1213
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
2+
import { $ } from "../utils/shell";
3+
4+
const SUCCESS_SIGNAL = 0;
5+
6+
describe("commitlintPluginRuleTests", () => {
7+
const successfulCase = "![Add::scope] subject";
8+
9+
it("success provided commitlint config", () => {
10+
const res = $`echo "${successfulCase}" | npx commitlint`;
11+
12+
expect(res.code).toEqual(SUCCESS_SIGNAL);
13+
});
14+
15+
it("success provided commitlint config", () => {
16+
const res = $`echo "${successfulCase}" | npx commitlint`;
17+
18+
expect(res.code).toEqual(SUCCESS_SIGNAL);
19+
});
20+
21+
it("type fail provided commitlint config", () => {
22+
const res = $`echo ![add::scope] subject | npx commitlint`;
23+
24+
expect(res.code).not.toEqual(SUCCESS_SIGNAL);
25+
});
26+
27+
it("scope fail provided commitlint config", () => {
28+
const res = $`echo @[add@scope] subjectFail | npx commitlint`;
29+
30+
expect(res.code).not.toEqual(SUCCESS_SIGNAL);
31+
});
32+
33+
it("symbol fail provided commitlint config", () => {
34+
const res = $`echo @[add::scope] subject | npx commitlint`;
35+
36+
expect(res.code).not.toEqual(SUCCESS_SIGNAL);
37+
});
38+
39+
it("subject fail provided commitlint config", () => {
40+
const res = $`echo @[add::scope] subject_fail | npx commitlint`;
41+
42+
expect(res.code).not.toEqual(SUCCESS_SIGNAL);
43+
});
44+
45+
it("subject fail provided commitlint config", () => {
46+
const res = $`echo @[add::scope] subjectFail | npx commitlint`;
47+
48+
expect(res.code).not.toEqual(SUCCESS_SIGNAL);
49+
});
50+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { exec } from "shelljs";
2+
3+
export const $ = (pieces: TemplateStringsArray, ...args: unknown[]) =>
4+
exec(pieces.reduce((pre, cur, i) => pre + cur + ((args ?? [])[i] ?? ""), ""));

packages/commitlint-wizardoc-e2e-tests/yarn.lock

Lines changed: 152 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,79 +2,165 @@
22
# yarn lockfile v1
33

44

5-
"@types/node@^15.3":
6-
"integrity" "sha512-7EIraBEyRHEe7CH+Fm1XvgqU6uwZN8Q7jppJGcqjROMT29qhAuuOxYB1uEY5UMYQKEmA5D+5tBnhdaPXSsLONA=="
7-
"resolved" "https://registry.npmjs.org/@types/node/-/node-15.6.1.tgz"
8-
"version" "15.6.1"
9-
10-
"ansi-styles@^4.1.0":
11-
"integrity" "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="
12-
"resolved" "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz"
13-
"version" "4.3.0"
5+
"@types/glob@*":
6+
version "7.1.3"
7+
resolved "https://registry.npmjs.org/@types/glob/-/glob-7.1.3.tgz#e6ba80f36b7daad2c685acd9266382e68985c183"
8+
integrity sha512-SEYeGAIQIQX8NN6LDKprLjbrd5dARM5EXsd8GI/A5l0apYI1fGMWgPHSe4ZKL4eozlAyI+doUE9XbYS4xCkQ1w==
149
dependencies:
15-
"color-convert" "^2.0.1"
10+
"@types/minimatch" "*"
11+
"@types/node" "*"
1612

17-
"chalk@^4.1.1":
18-
"integrity" "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg=="
19-
"resolved" "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz"
20-
"version" "4.1.1"
13+
"@types/minimatch@*":
14+
version "3.0.4"
15+
resolved "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.4.tgz#f0ec25dbf2f0e4b18647313ac031134ca5b24b21"
16+
integrity sha512-1z8k4wzFnNjVK/tlxvrWuK5WMt6mydWWP7+zvH5eFep4oj+UkrfiJTRtjCeBXNpwaA/FYqqtb4/QS4ianFpIRA==
17+
18+
"@types/node@*":
19+
version "15.6.1"
20+
resolved "https://registry.npmjs.org/@types/node/-/node-15.6.1.tgz#32d43390d5c62c5b6ec486a9bc9c59544de39a08"
21+
integrity sha512-7EIraBEyRHEe7CH+Fm1XvgqU6uwZN8Q7jppJGcqjROMT29qhAuuOxYB1uEY5UMYQKEmA5D+5tBnhdaPXSsLONA==
22+
23+
"@types/shelljs@^0.8.8":
24+
version "0.8.8"
25+
resolved "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.8.8.tgz#e439c69929b88a2c8123c1a55e09eb708315addf"
26+
integrity sha512-lD3LWdg6j8r0VRBFahJVaxoW0SIcswxKaFUrmKl33RJVeeoNYQAz4uqCJ5Z6v4oIBOsC5GozX+I5SorIKiTcQA==
27+
dependencies:
28+
"@types/glob" "*"
29+
"@types/node" "*"
30+
31+
balanced-match@^1.0.0:
32+
version "1.0.2"
33+
resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
34+
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
35+
36+
brace-expansion@^1.1.7:
37+
version "1.1.11"
38+
resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
39+
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
40+
dependencies:
41+
balanced-match "^1.0.0"
42+
concat-map "0.0.1"
43+
44+
commitlint-config-wizardoc@^1.0.0:
45+
version "1.0.0"
46+
resolved "https://registry.npmjs.org/commitlint-config-wizardoc/-/commitlint-config-wizardoc-1.0.0.tgz#d8f4372b75667ee8b553f1b6fa6eed9553e42a93"
47+
integrity sha512-ecOER5XBrTZVVIzRyXfGQMoe8C4OQevP4lYFK/HwB5jhFgCAX1TXiASYQLwgq4iU1hQcHMBc2inHVitVqRadHA==
2148
dependencies:
22-
"ansi-styles" "^4.1.0"
23-
"supports-color" "^7.1.0"
49+
commitlint-plugin-wizardoc-rules "^1.0.0"
2450

25-
"color-convert@^2.0.1":
26-
"integrity" "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ=="
27-
"resolved" "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz"
28-
"version" "2.0.1"
51+
commitlint-plugin-wizardoc-rules@^1.0.0:
52+
version "1.0.0"
53+
resolved "https://registry.npmjs.org/commitlint-plugin-wizardoc-rules/-/commitlint-plugin-wizardoc-rules-1.0.0.tgz#3f6e8a42d42b31c7897a91bc224b85132768324b"
54+
integrity sha512-V7NT3egc4LXBYeNtKnYYFtCAb8/3vlea9xNlky4r41HUHC9mx5w6mnKe7NQAucllkLGyYDL/FRt51UiyujrYPg==
55+
56+
57+
version "0.0.1"
58+
resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
59+
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
60+
61+
fs.realpath@^1.0.0:
62+
version "1.0.0"
63+
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
64+
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
65+
66+
function-bind@^1.1.1:
67+
version "1.1.1"
68+
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
69+
integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==
70+
71+
glob@^7.0.0:
72+
version "7.1.7"
73+
resolved "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90"
74+
integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==
2975
dependencies:
30-
"color-name" "~1.1.4"
31-
32-
"color-name@~1.1.4":
33-
"integrity" "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
34-
"resolved" "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz"
35-
"version" "1.1.4"
36-
37-
"has-flag@^4.0.0":
38-
"integrity" "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
39-
"resolved" "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz"
40-
"version" "4.0.0"
41-
42-
"isexe@^2.0.0":
43-
"integrity" "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA="
44-
"resolved" "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz"
45-
"version" "2.0.0"
46-
47-
"node-fetch@^2.6.1":
48-
"integrity" "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
49-
"resolved" "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz"
50-
"version" "2.6.1"
51-
52-
"shq@^1.0.2":
53-
"integrity" "sha512-8AvNyHL75DHlkbLmzF7nzTzT2F0qEfSewwxHjH79Ww8S+hGpIZVlf8b0TcdOwv4HqIkOVBInu9n+wqhUSl9Wag=="
54-
"resolved" "https://registry.npmjs.org/shq/-/shq-1.0.2.tgz"
55-
"version" "1.0.2"
56-
57-
"supports-color@^7.1.0":
58-
"integrity" "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw=="
59-
"resolved" "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz"
60-
"version" "7.2.0"
76+
fs.realpath "^1.0.0"
77+
inflight "^1.0.4"
78+
inherits "2"
79+
minimatch "^3.0.4"
80+
once "^1.3.0"
81+
path-is-absolute "^1.0.0"
82+
83+
has@^1.0.3:
84+
version "1.0.3"
85+
resolved "https://registry.npmjs.org/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796"
86+
integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==
6187
dependencies:
62-
"has-flag" "^4.0.0"
88+
function-bind "^1.1.1"
6389

64-
"which@^2.0.2":
65-
"integrity" "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA=="
66-
"resolved" "https://registry.npmjs.org/which/-/which-2.0.2.tgz"
67-
"version" "2.0.2"
90+
inflight@^1.0.4:
91+
version "1.0.6"
92+
resolved "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
93+
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
6894
dependencies:
69-
"isexe" "^2.0.0"
95+
once "^1.3.0"
96+
wrappy "1"
97+
98+
inherits@2:
99+
version "2.0.4"
100+
resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
101+
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
102+
103+
interpret@^1.0.0:
104+
version "1.4.0"
105+
resolved "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e"
106+
integrity sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==
70107

71-
"zx@^1.12.0":
72-
"integrity" "sha512-JvZxN3QTnZIUF5p9YVpqc/wm6Ghc5yVQd/p53KC0nnSK3RUfeuGMRrOnxJ5c4R4iYwY5F65i4e3BU59JD6svBw=="
73-
"resolved" "https://registry.npmjs.org/zx/-/zx-1.12.0.tgz"
74-
"version" "1.12.0"
108+
is-core-module@^2.2.0:
109+
version "2.4.0"
110+
resolved "https://registry.npmjs.org/is-core-module/-/is-core-module-2.4.0.tgz#8e9fc8e15027b011418026e98f0e6f4d86305cc1"
111+
integrity sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==
75112
dependencies:
76-
"@types/node" "^15.3"
77-
"chalk" "^4.1.1"
78-
"node-fetch" "^2.6.1"
79-
"shq" "^1.0.2"
80-
"which" "^2.0.2"
113+
has "^1.0.3"
114+
115+
minimatch@^3.0.4:
116+
version "3.0.4"
117+
resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
118+
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
119+
dependencies:
120+
brace-expansion "^1.1.7"
121+
122+
once@^1.3.0:
123+
version "1.4.0"
124+
resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
125+
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
126+
dependencies:
127+
wrappy "1"
128+
129+
path-is-absolute@^1.0.0:
130+
version "1.0.1"
131+
resolved "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
132+
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
133+
134+
path-parse@^1.0.6:
135+
version "1.0.7"
136+
resolved "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
137+
integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==
138+
139+
rechoir@^0.6.2:
140+
version "0.6.2"
141+
resolved "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
142+
integrity sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=
143+
dependencies:
144+
resolve "^1.1.6"
145+
146+
resolve@^1.1.6:
147+
version "1.20.0"
148+
resolved "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
149+
integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==
150+
dependencies:
151+
is-core-module "^2.2.0"
152+
path-parse "^1.0.6"
153+
154+
shelljs@^0.8.4:
155+
version "0.8.4"
156+
resolved "https://registry.npmjs.org/shelljs/-/shelljs-0.8.4.tgz#de7684feeb767f8716b326078a8a00875890e3c2"
157+
integrity sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==
158+
dependencies:
159+
glob "^7.0.0"
160+
interpret "^1.0.0"
161+
rechoir "^0.6.2"
162+
163+
wrappy@1:
164+
version "1.0.2"
165+
resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
166+
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=

tsconfig.base.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"declaration": true,
99
"skipLibCheck": true,
1010
"skipDefaultLibCheck": true,
11-
"allowSyntheticDefaultImports": true
11+
"allowSyntheticDefaultImports": true,
12+
"esModuleInterop": true
1213
}
1314
}

0 commit comments

Comments
 (0)