From f029196bbbc88a196e6bbf20ca063f3287845df6 Mon Sep 17 00:00:00 2001 From: youncccat <1306036576@qq.com> Date: Fri, 28 May 2021 00:36:53 +0800 Subject: [PATCH 1/2] [Feat::deps] link wizardoc to config package --- packages/commitlint-wizardoc-e2e-tests/.commitlintrc.js | 4 +--- packages/commitlint-wizardoc-e2e-tests/package.json | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/commitlint-wizardoc-e2e-tests/.commitlintrc.js b/packages/commitlint-wizardoc-e2e-tests/.commitlintrc.js index 43dc2de..c558d7e 100644 --- a/packages/commitlint-wizardoc-e2e-tests/.commitlintrc.js +++ b/packages/commitlint-wizardoc-e2e-tests/.commitlintrc.js @@ -1,5 +1,3 @@ -const config = require('../commitlint-config-wizardoc/dist/index') - module.exports = { - extends: ["./../commitlint-config-wizardoc/dist/index"] + extends: ["wizardoc"] } \ No newline at end of file diff --git a/packages/commitlint-wizardoc-e2e-tests/package.json b/packages/commitlint-wizardoc-e2e-tests/package.json index ea8bd8f..176b5a3 100644 --- a/packages/commitlint-wizardoc-e2e-tests/package.json +++ b/packages/commitlint-wizardoc-e2e-tests/package.json @@ -5,5 +5,8 @@ "license": "MIT", "devDependencies": { "zx": "^1.12.0" + }, + "dependencies": { + "commitlint-config-wizardoc": "^1.0.0" } } From 9787f7033e79dcf50be9d1d5889b4bde590aa1a7 Mon Sep 17 00:00:00 2001 From: youncccat <1306036576@qq.com> Date: Fri, 28 May 2021 00:38:06 +0800 Subject: [PATCH 2/2] [Test::config] add test case for config generator --- .gitignore | 3 +- package.json | 1 + .../dist/index.d.ts | 3 - .../commitlint-config-wizardoc/dist/index.js | 30 ---------- .../commitlint-config-wizardoc/package.json | 2 - .../commitlint-config-wizardoc/src/config.ts | 34 +++++++++++ .../commitlint-config-wizardoc/src/index.ts | 35 +----------- .../src/types/index.test.ts | 8 +++ yarn.lock | 56 +++++++++++++++++++ 9 files changed, 102 insertions(+), 70 deletions(-) delete mode 100644 packages/commitlint-config-wizardoc/dist/index.d.ts delete mode 100644 packages/commitlint-config-wizardoc/dist/index.js create mode 100644 packages/commitlint-config-wizardoc/src/config.ts create mode 100644 packages/commitlint-config-wizardoc/src/types/index.test.ts diff --git a/.gitignore b/.gitignore index f742898..0cba56e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ node_modules packages/**/node_modules # dist -dist \ No newline at end of file +dist +packages/**/dist \ No newline at end of file diff --git a/package.json b/package.json index 7d19c92..b5f6fe4 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "devDependencies": { "@commitlint/cli": "^12.1.4", "@commitlint/config-conventional": "^12.1.4", + "@types/jest": "^26.0.23", "jest": "^27.0.1", "jest-config": "^27.0.1", "lerna": "^4.0.0", diff --git a/packages/commitlint-config-wizardoc/dist/index.d.ts b/packages/commitlint-config-wizardoc/dist/index.d.ts deleted file mode 100644 index 0263d7f..0000000 --- a/packages/commitlint-config-wizardoc/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { UserConfig } from "@commitlint/types"; -declare const config: UserConfig; -export = config; diff --git a/packages/commitlint-config-wizardoc/dist/index.js b/packages/commitlint-config-wizardoc/dist/index.js deleted file mode 100644 index e47155e..0000000 --- a/packages/commitlint-config-wizardoc/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict"; -const constants_1 = require("./constants"); -const enum_1 = require("./utils/enum"); -const config = { - parserPreset: { - name: "", - path: "", - parserOpts: { - headerPattern: constants_1.CONVERSION_MATCH_REGEX, - headerCorrespondence: [ - constants_1.LexicalElement.TYPE, - constants_1.LexicalElement.SCOPE, - constants_1.LexicalElement.SUBJECT, - ], - }, - }, - rules: { - // 'subject-exclamation-mark': [2, 'never'], - "footer-leading-blank": [1, "always"], - "header-max-length": [2, "always", 72], - // 'scope-case': [2, 'always', 'lower-case'], - "subject-case": [2, "never", ["upper-case"]], - // 'subject-empty': [2, 'never'], - "subject-full-stop": [2, "never", "."], - "type-empty": [2, "never"], - "scope-empty": [1, "never"], - "type-enum": [2, "always", enum_1.enumerateValues(constants_1.CommitType)], - }, -}; -module.exports = config; diff --git a/packages/commitlint-config-wizardoc/package.json b/packages/commitlint-config-wizardoc/package.json index c21f8fe..e652bc1 100644 --- a/packages/commitlint-config-wizardoc/package.json +++ b/packages/commitlint-config-wizardoc/package.json @@ -7,8 +7,6 @@ "compile": "tsc" }, "devDependencies": { - "@commitlint/config-conventional": "^12.1.4", - "@commitlint/parse": "^12.1.4", "@commitlint/types": "^12.1.4" }, "dependencies": {} diff --git a/packages/commitlint-config-wizardoc/src/config.ts b/packages/commitlint-config-wizardoc/src/config.ts new file mode 100644 index 0000000..574a4d8 --- /dev/null +++ b/packages/commitlint-config-wizardoc/src/config.ts @@ -0,0 +1,34 @@ +import { + LexicalElement, + CommitType, + CONVERSION_MATCH_REGEX, +} from "./constants"; +import { UserConfig } from "@commitlint/types"; +import { enumerateValues } from "./utils/enum"; + +export const config: UserConfig = { + parserPreset: { + name: "", + path: "", + parserOpts: { + headerPattern: CONVERSION_MATCH_REGEX, + headerCorrespondence: [ + LexicalElement.TYPE, + LexicalElement.SCOPE, + LexicalElement.SUBJECT, + ], + }, + }, + rules: { + // 'subject-exclamation-mark': [2, 'never'], + "footer-leading-blank": [1, "always"], + "header-max-length": [2, "always", 72], + // 'scope-case': [2, 'always', 'lower-case'], + "subject-case": [2, "never", ["upper-case"] as any], + // 'subject-empty': [2, 'never'], + "subject-full-stop": [2, "never", "."], + "type-empty": [2, "never"], + "scope-empty": [1, "never"], + "type-enum": [2, "always", enumerateValues(CommitType)], + }, +}; diff --git a/packages/commitlint-config-wizardoc/src/index.ts b/packages/commitlint-config-wizardoc/src/index.ts index 466a785..43ebcfb 100644 --- a/packages/commitlint-config-wizardoc/src/index.ts +++ b/packages/commitlint-config-wizardoc/src/index.ts @@ -1,36 +1,3 @@ -import { - LexicalElement, - CommitType, - CONVERSION_MATCH_REGEX, -} from "./constants"; -import { UserConfig } from "@commitlint/types"; -import { enumerateValues } from "./utils/enum"; - -const config: UserConfig = { - parserPreset: { - name: "", - path: "", - parserOpts: { - headerPattern: CONVERSION_MATCH_REGEX, - headerCorrespondence: [ - LexicalElement.TYPE, - LexicalElement.SCOPE, - LexicalElement.SUBJECT, - ], - }, - }, - rules: { - // 'subject-exclamation-mark': [2, 'never'], - "footer-leading-blank": [1, "always"], - "header-max-length": [2, "always", 72], - // 'scope-case': [2, 'always', 'lower-case'], - "subject-case": [2, "never", ["upper-case"] as any], - // 'subject-empty': [2, 'never'], - "subject-full-stop": [2, "never", "."], - "type-empty": [2, "never"], - "scope-empty": [1, "never"], - "type-enum": [2, "always", enumerateValues(CommitType)], - }, -}; +import { config } from "./config"; export = config; diff --git a/packages/commitlint-config-wizardoc/src/types/index.test.ts b/packages/commitlint-config-wizardoc/src/types/index.test.ts new file mode 100644 index 0000000..bf78f2b --- /dev/null +++ b/packages/commitlint-config-wizardoc/src/types/index.test.ts @@ -0,0 +1,8 @@ +import { config } from "../config"; + +describe("validate config structure", () => { + it("should return a correct config", () => { + expect(config).toHaveProperty("rules"); + expect(config).toHaveProperty("parserPreset"); + }); +}); diff --git a/yarn.lock b/yarn.lock index 8cfcb7e..c3cec69 100644 --- a/yarn.lock +++ b/yarn.lock @@ -606,6 +606,17 @@ source-map "^0.6.1" write-file-atomic "^3.0.0" +"@jest/types@^26.6.2": + version "26.6.2" + resolved "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz#bef5a532030e1d88a2f5a6d933f84e97226ed48e" + integrity sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ== + dependencies: + "@types/istanbul-lib-coverage" "^2.0.0" + "@types/istanbul-reports" "^3.0.0" + "@types/node" "*" + "@types/yargs" "^15.0.0" + chalk "^4.0.0" + "@jest/types@^27.0.1": version "27.0.1" resolved "https://registry.npmjs.org/@jest/types/-/types-27.0.1.tgz" @@ -1551,6 +1562,14 @@ dependencies: "@types/istanbul-lib-report" "*" +"@types/jest@^26.0.23": + version "26.0.23" + resolved "https://registry.npmjs.org/@types/jest/-/jest-26.0.23.tgz#a1b7eab3c503b80451d019efb588ec63522ee4e7" + integrity sha512-ZHLmWMJ9jJ9PTiT58juykZpL7KjwJywFN3Rr2pTSkyQfydf/rk22yS7W8p5DaVUMQ2BQC7oYiU3FjbTM/mYrOA== + dependencies: + jest-diff "^26.0.0" + pretty-format "^26.0.0" + "@types/minimatch@^3.0.3": version "3.0.4" resolved "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.4.tgz" @@ -1591,6 +1610,13 @@ resolved "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-20.2.0.tgz" integrity sha512-37RSHht+gzzgYeobbG+KWryeAW8J33Nhr69cjTqSYymXVZEN9NbRYWoYlRtDhHKPVT1FyNKwaTPC1NynKZpzRA== +"@types/yargs@^15.0.0": + version "15.0.13" + resolved "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.13.tgz#34f7fec8b389d7f3c1fd08026a5763e072d3c6dc" + integrity sha512-kQ5JNTrbDv3Rp5X2n/iUu37IJBDU2gsZ5R/g1/KHOOEc5IKfUFjXT6DENPGduh08I/pamwtEq4oul7gUqKTQDQ== + dependencies: + "@types/yargs-parser" "*" + "@types/yargs@^16.0.0": version "16.0.3" resolved "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.3.tgz" @@ -2517,6 +2543,11 @@ dezalgo@^1.0.0: asap "^2.0.0" wrappy "1" +diff-sequences@^26.6.2: + version "26.6.2" + resolved "https://registry.npmjs.org/diff-sequences/-/diff-sequences-26.6.2.tgz#48ba99157de1923412eed41db6b6d4aa9ca7c0b1" + integrity sha512-Mv/TDa3nZ9sbc5soK+OoA74BsS3mL37yixCvUAQkiuA4Wz6YtwP/K47n2rv2ovzHZvoiQeA5FTQOschKkEwB0Q== + diff-sequences@^27.0.1: version "27.0.1" resolved "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.0.1.tgz" @@ -3643,6 +3674,16 @@ jest-config@^27.0.1: micromatch "^4.0.4" pretty-format "^27.0.1" +jest-diff@^26.0.0: + version "26.6.2" + resolved "https://registry.npmjs.org/jest-diff/-/jest-diff-26.6.2.tgz#1aa7468b52c3a68d7d5c5fdcdfcd5e49bd164394" + integrity sha512-6m+9Z3Gv9wN0WFVasqjCL/06+EFCMTqDEUl/b87HYK2rAPTyfz4ZIuSlPhY51PIQRWx5TaxeF1qmXKe9gfN3sA== + dependencies: + chalk "^4.0.0" + diff-sequences "^26.6.2" + jest-get-type "^26.3.0" + pretty-format "^26.6.2" + jest-diff@^27.0.1: version "27.0.1" resolved "https://registry.npmjs.org/jest-diff/-/jest-diff-27.0.1.tgz" @@ -3696,6 +3737,11 @@ jest-environment-node@^27.0.1: jest-mock "^27.0.1" jest-util "^27.0.1" +jest-get-type@^26.3.0: + version "26.3.0" + resolved "https://registry.npmjs.org/jest-get-type/-/jest-get-type-26.3.0.tgz#e97dc3c3f53c2b406ca7afaed4493b1d099199e0" + integrity sha512-TpfaviN1R2pQWkIihlfEanwOXK0zcxrKEE4MlU6Tn7keoXdN6/3gK/xl0yEh8DOunn5pOVGKf8hB4R9gVh04ig== + jest-get-type@^27.0.1: version "27.0.1" resolved "https://registry.npmjs.org/jest-get-type/-/jest-get-type-27.0.1.tgz" @@ -5149,6 +5195,16 @@ prelude-ls@~1.1.2: resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= +pretty-format@^26.0.0, pretty-format@^26.6.2: + version "26.6.2" + resolved "https://registry.npmjs.org/pretty-format/-/pretty-format-26.6.2.tgz#e35c2705f14cb7fe2fe94fa078345b444120fc93" + integrity sha512-7AeGuCYNGmycyQbCqd/3PWH4eOoX/OiCa0uphp57NVTeAGdJGaAliecxwBDHYQCIvrW7aDBZCYeNTP/WX69mkg== + dependencies: + "@jest/types" "^26.6.2" + ansi-regex "^5.0.0" + ansi-styles "^4.0.0" + react-is "^17.0.1" + pretty-format@^27.0.1: version "27.0.1" resolved "https://registry.npmjs.org/pretty-format/-/pretty-format-27.0.1.tgz"