diff --git a/@commitlint/cli/package.json b/@commitlint/cli/package.json index 43dcbb0006..05913dc78c 100644 --- a/@commitlint/cli/package.json +++ b/@commitlint/cli/package.json @@ -48,6 +48,7 @@ "lodash.merge": "^4.6.2" }, "dependencies": { + "conventional-commits-parser": "^6.0.0", "@commitlint/format": "^19.3.0", "@commitlint/lint": "^19.2.2", "@commitlint/load": "^19.2.0", diff --git a/@commitlint/cli/src/cli.ts b/@commitlint/cli/src/cli.ts index b58c047be1..4416669de8 100644 --- a/@commitlint/cli/src/cli.ts +++ b/@commitlint/cli/src/cli.ts @@ -14,7 +14,7 @@ import type { QualifiedConfig, UserConfig, } from '@commitlint/types'; -import type {Options} from 'conventional-commits-parser'; +import type {ParserOptions} from 'conventional-commits-parser'; import {execa, type ExecaError} from 'execa'; import yargs, {type Arguments} from 'yargs'; @@ -263,7 +263,7 @@ async function main(args: MainArgs): Promise { file: flags.config, }); const parserOpts = selectParserOpts(loaded.parserPreset); - const opts: LintOptions & {parserOpts: Options} = { + const opts: LintOptions & {parserOpts: ParserOptions} = { parserOpts: {}, plugins: {}, ignores: [], diff --git a/@commitlint/config-conventional/package.json b/@commitlint/config-conventional/package.json index f1a29bc1ff..f6d4f4050a 100644 --- a/@commitlint/config-conventional/package.json +++ b/@commitlint/config-conventional/package.json @@ -40,7 +40,7 @@ }, "dependencies": { "@commitlint/types": "^19.0.3", - "conventional-changelog-conventionalcommits": "^7.0.2" + "conventional-changelog-conventionalcommits": "^8.0.0" }, "gitHead": "70f7f4688b51774e7ac5e40e896cdaa3f132b2bc" } diff --git a/@commitlint/load/fixtures/parser-preset-angular/package.json b/@commitlint/load/fixtures/parser-preset-angular/package.json index 5bc9d3e3a7..2641cb7ecd 100644 --- a/@commitlint/load/fixtures/parser-preset-angular/package.json +++ b/@commitlint/load/fixtures/parser-preset-angular/package.json @@ -2,6 +2,6 @@ "name": "parser-preset-angular", "version": "1.0.0", "devDependencies": { - "conventional-changelog-angular": "^7.0.0" + "conventional-changelog-angular": "^8.0.0" } } diff --git a/@commitlint/load/fixtures/parser-preset-conventional-without-factory/package.json b/@commitlint/load/fixtures/parser-preset-conventional-without-factory/package.json index 2c11da9498..506905c767 100644 --- a/@commitlint/load/fixtures/parser-preset-conventional-without-factory/package.json +++ b/@commitlint/load/fixtures/parser-preset-conventional-without-factory/package.json @@ -2,6 +2,6 @@ "name": "parser-preset-conventional-without-factory", "version": "1.0.0", "devDependencies": { - "conventional-changelog-conventionalcommits": "^7.0.2" + "conventional-changelog-conventionalcommits": "^8.0.0" } } diff --git a/@commitlint/load/fixtures/parser-preset-conventionalcommits/package.json b/@commitlint/load/fixtures/parser-preset-conventionalcommits/package.json index 5812d97c34..41094a1d4e 100644 --- a/@commitlint/load/fixtures/parser-preset-conventionalcommits/package.json +++ b/@commitlint/load/fixtures/parser-preset-conventionalcommits/package.json @@ -2,6 +2,6 @@ "name": "parser-preset-conventionalcommits", "version": "1.0.0", "devDependencies": { - "conventional-changelog-conventionalcommits": "^7.0.2" + "conventional-changelog-conventionalcommits": "^8.0.0" } } diff --git a/@commitlint/load/fixtures/recursive-parser-preset-conventional-atom/first-extended/second-extended/package.json b/@commitlint/load/fixtures/recursive-parser-preset-conventional-atom/first-extended/second-extended/package.json index c764557468..c990b8b3b3 100644 --- a/@commitlint/load/fixtures/recursive-parser-preset-conventional-atom/first-extended/second-extended/package.json +++ b/@commitlint/load/fixtures/recursive-parser-preset-conventional-atom/first-extended/second-extended/package.json @@ -2,6 +2,6 @@ "name": "@second-extend/recursive-parser-preset-conventional-atom", "version": "1.0.0", "devDependencies": { - "conventional-changelog-atom": "^2.0.3" + "conventional-changelog-atom": "^5.0.0" } } diff --git a/@commitlint/load/package.json b/@commitlint/load/package.json index b879333692..d0caee6f4d 100644 --- a/@commitlint/load/package.json +++ b/@commitlint/load/package.json @@ -41,7 +41,7 @@ "@types/lodash.merge": "^4.6.8", "@types/lodash.uniq": "^4.5.8", "@types/node": "^18.19.17", - "conventional-changelog-atom": "^4.0.0", + "conventional-changelog-atom": "^5.0.0", "typescript": "^5.2.2" }, "dependencies": { diff --git a/@commitlint/parse/package.json b/@commitlint/parse/package.json index 8116245883..810829d740 100644 --- a/@commitlint/parse/package.json +++ b/@commitlint/parse/package.json @@ -37,13 +37,12 @@ "license": "MIT", "devDependencies": { "@commitlint/test": "^19.0.0", - "@commitlint/utils": "^19.0.0", - "@types/conventional-commits-parser": "^5.0.0" + "@commitlint/utils": "^19.0.0" }, "dependencies": { "@commitlint/types": "^19.0.3", - "conventional-changelog-angular": "^7.0.0", - "conventional-commits-parser": "^5.0.0" + "conventional-changelog-angular": "^8.0.0", + "conventional-commits-parser": "^6.0.0" }, "gitHead": "70f7f4688b51774e7ac5e40e896cdaa3f132b2bc" } diff --git a/@commitlint/parse/src/index.ts b/@commitlint/parse/src/index.ts index 7490fc88ec..9e1ea1d358 100644 --- a/@commitlint/parse/src/index.ts +++ b/@commitlint/parse/src/index.ts @@ -1,13 +1,17 @@ +import { + type Commit, + type ParserOptions, + CommitParser, +} from 'conventional-commits-parser'; import type {Parser} from '@commitlint/types'; -import {type Commit, type Options, sync} from 'conventional-commits-parser'; // @ts-expect-error -- no typings import defaultChangelogOpts from 'conventional-changelog-angular'; export async function parse( message: string, - parser: Parser = sync, - parserOpts?: Options + parser?: Parser, + parserOpts?: ParserOptions ): Promise { const preset = await defaultChangelogOpts(); const defaultOpts = preset.parserOpts; @@ -16,7 +20,16 @@ export async function parse( fieldPattern: null, ...(parserOpts || {}), }; - const parsed = parser(message, opts) as Commit; + + let parsed; + + if (parser) { + parsed = parser(message, opts) as Commit; + } else { + const defaultParser = new CommitParser(opts); + parsed = defaultParser.parse(message) as Commit; + } + parsed.raw = message; return parsed; } diff --git a/@commitlint/rules/package.json b/@commitlint/rules/package.json index ab71cb693d..4af5e1b87a 100644 --- a/@commitlint/rules/package.json +++ b/@commitlint/rules/package.json @@ -39,7 +39,7 @@ "@commitlint/parse": "^19.0.3", "@commitlint/test": "^19.0.0", "@commitlint/utils": "^19.0.0", - "conventional-changelog-angular": "^7.0.0", + "conventional-changelog-angular": "^8.0.0", "glob": "^10.3.10" }, "dependencies": { diff --git a/@commitlint/types/package.json b/@commitlint/types/package.json index 8db462e0f5..764371f86e 100644 --- a/@commitlint/types/package.json +++ b/@commitlint/types/package.json @@ -29,7 +29,7 @@ }, "license": "MIT", "dependencies": { - "@types/conventional-commits-parser": "^5.0.0", + "conventional-commits-parser": "^6.0.0", "chalk": "^5.3.0" }, "devDependencies": { diff --git a/@commitlint/types/src/lint.ts b/@commitlint/types/src/lint.ts index 6e473e4b5c..48327341fd 100644 --- a/@commitlint/types/src/lint.ts +++ b/@commitlint/types/src/lint.ts @@ -1,4 +1,4 @@ -import type {Options} from 'conventional-commits-parser'; +import type {ParserOptions} from 'conventional-commits-parser'; import {IsIgnoredOptions} from './is-ignored.js'; import {PluginRecords} from './load.js'; import {RuleConfigSeverity, RuleConfigTuple} from './rules.js'; @@ -16,7 +16,7 @@ export interface LintOptions { /** Additional commits to ignore, defined by ignore matchers */ ignores?: IsIgnoredOptions['ignores']; /** The parser configuration to use when linting the commit */ - parserOpts?: Options; + parserOpts?: ParserOptions; plugins?: PluginRecords; helpUrl?: string; diff --git a/@commitlint/types/src/parse.ts b/@commitlint/types/src/parse.ts index 6b7a3a4c07..0a98af549c 100644 --- a/@commitlint/types/src/parse.ts +++ b/@commitlint/types/src/parse.ts @@ -1,3 +1,6 @@ -import type {Commit, Options} from 'conventional-commits-parser'; +import type {Commit, ParserOptions} from 'conventional-commits-parser'; -export type Parser = (message: string, options: Options) => Omit; +export type Parser = ( + message: string, + options: ParserOptions +) => Omit; diff --git a/yarn.lock b/yarn.lock index 1276147b11..10abd67814 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1912,13 +1912,6 @@ resolved "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz" integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A== -"@types/conventional-commits-parser@^5.0.0": - version "5.0.0" - resolved "https://registry.npmjs.org/@types/conventional-commits-parser/-/conventional-commits-parser-5.0.0.tgz#8c9d23e0b415b24b91626d07017303755d542dc8" - integrity sha512-loB369iXNmAZglwWATL+WRe+CRMmmBPtpolYzIebFaX4YA3x+BEfLqhUAV9WanycKI3TG1IMr5bMJDajDKLlUQ== - dependencies: - "@types/node" "*" - "@types/estree@1.0.5", "@types/estree@^1.0.0": version "1.0.5" resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" @@ -2492,7 +2485,7 @@ dependencies: argparse "^2.0.1" -JSONStream@^1.0.4, JSONStream@^1.3.5: +JSONStream@^1.0.4: version "1.3.5" resolved "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz" integrity sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ== @@ -3277,22 +3270,22 @@ conventional-changelog-angular@^5.0.12: compare-func "^2.0.0" q "^1.5.1" -conventional-changelog-angular@^7.0.0: - version "7.0.0" - resolved "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-7.0.0.tgz" - integrity sha512-ROjNchA9LgfNMTTFSIWPzebCwOGFdgkEq45EnvvrmSLvCtAw0HSmrCs7/ty+wAeYUZyNay0YMUNYFTRL72PkBQ== +conventional-changelog-angular@^8.0.0: + version "8.0.0" + resolved "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-8.0.0.tgz#5701386850f0e0c2e630b43ee7821d322d87e7a6" + integrity sha512-CLf+zr6St0wIxos4bmaKHRXWAcsCXrJU6F4VdNDrGRK3B8LDLKoX3zuMV5GhtbGkVR/LohZ6MT6im43vZLSjmA== dependencies: compare-func "^2.0.0" -conventional-changelog-atom@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/conventional-changelog-atom/-/conventional-changelog-atom-4.0.0.tgz" - integrity sha512-q2YtiN7rnT1TGwPTwjjBSIPIzDJCRE+XAUahWxnh+buKK99Kks4WLMHoexw38GXx9OUxAsrp44f9qXe5VEMYhw== +conventional-changelog-atom@^5.0.0: + version "5.0.0" + resolved "https://registry.npmjs.org/conventional-changelog-atom/-/conventional-changelog-atom-5.0.0.tgz#f3e06e06244bd0aef2e5f09ed590933d948e809c" + integrity sha512-WfzCaAvSCFPkznnLgLnfacRAzjgqjLUjvf3MftfsJzQdDICqkOOpcMtdJF3wTerxSpv2IAAjX8doM3Vozqle3g== -conventional-changelog-conventionalcommits@^7.0.2: - version "7.0.2" - resolved "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-7.0.2.tgz" - integrity sha512-NKXYmMR/Hr1DevQegFB4MwfM5Vv0m4UIxKZTTYuD98lpTknaZlSRrDOG4X7wIXpGkfsYxZTghUN+Qq+T0YQI7w== +conventional-changelog-conventionalcommits@^8.0.0: + version "8.0.0" + resolved "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-8.0.0.tgz#3fa2857c878701e7f0329db5a1257cb218f166fe" + integrity sha512-eOvlTO6OcySPyyyk8pKz2dP4jjElYunj9hn9/s0OB+gapTO8zwS9UQWrZ1pmF2hFs3vw1xhonOLGcGjy/zgsuA== dependencies: compare-func "^2.0.0" @@ -3361,15 +3354,12 @@ conventional-commits-parser@^3.2.0: split2 "^3.0.0" through2 "^4.0.0" -conventional-commits-parser@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-5.0.0.tgz" - integrity sha512-ZPMl0ZJbw74iS9LuX9YIAiW8pfM5p3yh2o/NbXHbkFuZzY5jvdi5jFycEOkmBW5H5I7nA+D6f3UcsCLP2vvSEA== +conventional-commits-parser@^6.0.0: + version "6.0.0" + resolved "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-6.0.0.tgz#74e3be5344d8cd99f7c3353da2efa1d1dd618061" + integrity sha512-TbsINLp48XeMXR8EvGjTnKGsZqBemisPoyWESlpRyR8lif0lcwzqz+NMtYSj1ooF/WYjSuu7wX0CtdeeMEQAmA== dependencies: - JSONStream "^1.3.5" - is-text-path "^2.0.0" - meow "^12.0.1" - split2 "^4.0.0" + meow "^13.0.0" conventional-recommended-bump@^6.1.0: version "6.1.0" @@ -5162,13 +5152,6 @@ is-text-path@^1.0.1: dependencies: text-extensions "^1.0.0" -is-text-path@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/is-text-path/-/is-text-path-2.0.0.tgz" - integrity sha512-+oDTluR6WEjdXEJMnC2z6A4FRwFoYuvShVVEGsS7ewc0UTi2QtAKMDJuL4BDEVt+5T7MjFo12RP8ghOM75oKJw== - dependencies: - text-extensions "^2.0.0" - is-typed-array@^1.1.10, is-typed-array@^1.1.12, is-typed-array@^1.1.9: version "1.1.12" resolved "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.12.tgz" @@ -5861,6 +5844,11 @@ meow@^12.0.1: resolved "https://registry.npmjs.org/meow/-/meow-12.1.1.tgz" integrity sha512-BhXM0Au22RwUneMPwSCnyhTOizdWoIEPU9sp0Aqa1PnDMR5Wv2FGXYDjuzJEIX+Eo2Rb8xuYe5jrnm5QowQFkw== +meow@^13.0.0: + version "13.2.0" + resolved "https://registry.npmjs.org/meow/-/meow-13.2.0.tgz#6b7d63f913f984063b3cc261b6e8800c4cd3474f" + integrity sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA== + meow@^8.0.0: version "8.1.2" resolved "https://registry.npmjs.org/meow/-/meow-8.1.2.tgz" @@ -7774,11 +7762,6 @@ text-extensions@^1.0.0: resolved "https://registry.npmjs.org/text-extensions/-/text-extensions-1.9.0.tgz" integrity sha512-wiBrwC1EhBelW12Zy26JeOUkQ5mRu+5o8rpsJk5+2t+Y5vE7e842qtZDQ2g1NpX/29HdyFeJ4nSIhI47ENSxlQ== -text-extensions@^2.0.0: - version "2.4.0" - resolved "https://registry.npmjs.org/text-extensions/-/text-extensions-2.4.0.tgz" - integrity sha512-te/NtwBwfiNRLf9Ijqx3T0nlqZiQ2XrrtBvu+cLL8ZRrGkO0NHTug8MYFKyoSrv/sHTaSKfilUkizV6XhxMJ3g== - text-table@^0.2.0: version "0.2.0" resolved "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"