relizy 1.9.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { LogLevel } from '@maz-ui/node';
2
2
  import { LanguageModel, CallSettings } from 'ai';
3
- import { RawGitCommit, GitCommit, ChangelogConfig as ChangelogConfig$1, SemverBumpType } from 'changelogen';
3
+ import { GitCommit, RawGitCommit, ChangelogConfig as ChangelogConfig$1, SemverBumpType, Reference as Reference$1 } from 'changelogen';
4
4
  import { ReleaseType } from 'semver';
5
5
  import { DeepPartial } from '@maz-ui/utils/ts-helpers/DeepPartial';
6
6
  import * as _slack_web_api from '@slack/web-api';
@@ -53,6 +53,7 @@ declare function getDefaultConfig(): {
53
53
  };
54
54
  scopeMap: {};
55
55
  release: Required<ReleaseConfig>;
56
+ commitlint: Required<Omit<CommitlintConfig, "helpUrl">> & Pick<CommitlintConfig, "helpUrl">;
56
57
  social: {
57
58
  twitter: {
58
59
  enabled: false;
@@ -137,6 +138,331 @@ declare function writeChangelogToFile({ cwd, pkg, changelog, dryRun, }: {
137
138
  dryRun: boolean;
138
139
  }): void;
139
140
 
141
+ /**
142
+ * Title of the changelog section of a commit type, `undefined` when the commits
143
+ * of this type never appear in the changelog.
144
+ */
145
+ declare function getChangelogTitle(type: string, config: ResolvedRelizyConfig): string | undefined;
146
+ /**
147
+ * The commit as written in the CHANGELOG.md files by relizy: a section with the
148
+ * commit and its body. `undefined` when the commit does not appear in the changelog.
149
+ */
150
+ declare function renderChangelogEntry(commit: GitCommit, config: ResolvedRelizyConfig): string | undefined;
151
+ /**
152
+ * Checks a changelog entry the way the release would: returns the problems that
153
+ * would make the formatting of the CHANGELOG.md files fail.
154
+ */
155
+ interface ChangelogLinter {
156
+ name: 'eslint' | 'oxc';
157
+ lint: (markdown: string) => Promise<string[]>;
158
+ }
159
+ /**
160
+ * The linter of the changelog entries of a project. With `auto`, its ESLint when
161
+ * it lints the CHANGELOG.md files, otherwise a syntax check of the code blocks
162
+ * with oxc. Loaded once per cwd and choice.
163
+ */
164
+ declare function getChangelogLinter(cwd: string, choice?: CommitlintCodeBlocksLinter): Promise<ChangelogLinter>;
165
+
166
+ /** Character git uses for the comment lines of the edited messages */
167
+ declare function getCommentChar(cwd: string): string;
168
+ /**
169
+ * Path of the message of the commit being created: the file given to the
170
+ * `commit-msg` hook, `.git/COMMIT_EDITMSG` by default.
171
+ */
172
+ declare function getCommitMessageFile(file: string | undefined, cwd: string): string;
173
+ /** The message of the commit being created */
174
+ declare function readCommitMessageFile(file: string | undefined, cwd: string): string;
175
+ /** Files staged for the commit being created, relative to the repository root */
176
+ declare function getStagedFiles(cwd: string): string[];
177
+ interface RangeCommit {
178
+ hash: string;
179
+ message: string;
180
+ files: string[];
181
+ }
182
+ /**
183
+ * Commits reachable from `to` and not from `from`, oldest first, with their
184
+ * full message and changed files. Every commit up to `to` without `from`.
185
+ */
186
+ declare function getCommitsInRange({ from, to, cwd }: {
187
+ from?: string;
188
+ to?: string;
189
+ cwd: string;
190
+ }): RangeCommit[];
191
+ /**
192
+ * Makes sure the start of the range is in the local history: in a shallow
193
+ * clone of the CI, the history and the tags are fetched. Throws a helpful
194
+ * error when it is still missing.
195
+ */
196
+ declare function assertRefAvailable(ref: string, cwd: string): void;
197
+ interface PullRequestTitle {
198
+ title: string;
199
+ /** `pull request` on GitHub, `merge request` on GitLab */
200
+ kind: 'pull request' | 'merge request';
201
+ }
202
+ /**
203
+ * Title of the pull/merge request of the CI run, which becomes the commit
204
+ * message of a squash merge. The draft markers of GitLab are removed.
205
+ */
206
+ declare function getPullRequestTitle(): PullRequestTitle | undefined;
207
+ interface DefaultRangeStart {
208
+ from?: string;
209
+ /** Why this start was chosen, for the logs */
210
+ reason: string;
211
+ }
212
+ /**
213
+ * Start of the commits to lint when `--from` is not given: the merge-base with
214
+ * the target branch of the pull/merge request in GitHub Actions and GitLab CI,
215
+ * otherwise the last tag, otherwise the whole history.
216
+ */
217
+ declare function resolveDefaultRangeStart({ cwd, logLevel }: {
218
+ cwd: string;
219
+ logLevel?: LogLevel;
220
+ }): Promise<DefaultRangeStart>;
221
+ interface InstalledHook {
222
+ path: string;
223
+ status: 'created' | 'replaced' | 'unchanged';
224
+ }
225
+ /**
226
+ * Write the `commit-msg` hook running `relizy commitlint`: in `.husky/` when
227
+ * husky is set up, otherwise in the hooks directory of git. An existing hook is
228
+ * only replaced with `force`.
229
+ */
230
+ declare function installCommitMsgHook({ cwd, force }: {
231
+ cwd: string;
232
+ force?: boolean;
233
+ }): InstalledHook;
234
+
235
+ /**
236
+ * A commit message split into its parts, before any conventional parsing.
237
+ */
238
+ interface CommitMessageParts {
239
+ /** Full message, comments removed, trailing blank lines trimmed */
240
+ raw: string;
241
+ header: string;
242
+ body: string;
243
+ footer: string;
244
+ /** Whether a blank line separates the header from the rest of the message */
245
+ hasLeadingBlank: boolean;
246
+ }
247
+ /**
248
+ * Remove what git strips from a message edited in the editor: the comment lines
249
+ * and everything after the scissors line of `git commit --verbose`.
250
+ */
251
+ declare function stripGitComments(message: string, commentChar?: string): string;
252
+ /**
253
+ * Split a message into header, body and footer. The footer is the last
254
+ * paragraph when it starts with a `Token: value` line: as in Conventional
255
+ * Commits, a footer value can continue on the next lines.
256
+ */
257
+ declare function splitCommitMessage(message: string): CommitMessageParts;
258
+ /**
259
+ * Whether a message must not be linted: merge commits, autosquash commits and
260
+ * the release commits of relizy (`defaultIgnores`), and the `ignores` of the config.
261
+ */
262
+ declare function isIgnoredCommitMessage(message: string, config: ResolvedRelizyConfig): boolean;
263
+
264
+ /**
265
+ * A workspace package as seen by the commit linter.
266
+ */
267
+ interface WorkspacePackage {
268
+ /** Name from the package.json, e.g. `@maz-ui/nuxt` */
269
+ name: string;
270
+ /** Path relative to the repository root, POSIX separators, e.g. `packages/nuxt` */
271
+ path: string;
272
+ /** Scopes designating the package: short name, full name and folder name */
273
+ scopes: string[];
274
+ }
275
+ /**
276
+ * Package globs declared by the tools of the monorepo: the `workspaces` of the
277
+ * package.json (npm, yarn, bun, and Turborepo or Nx on top of them),
278
+ * `pnpm-workspace.yaml`, `lerna.json`, `rush.json` and the `workspace` of `deno.json`.
279
+ */
280
+ declare function getPackageManagerWorkspaces(cwd: string): string[];
281
+ /**
282
+ * Packages of the monorepo, private ones included: a commit can touch a package
283
+ * that is never published. Besides `monorepo.packages`, the workspace of the
284
+ * package manager and `commitlint.packages` add the directories that relizy
285
+ * does not release (e.g. apps). `monorepo.ignored` is not applied: an ignored
286
+ * package is released by another config, it is still a valid scope.
287
+ * Empty in standalone mode without them.
288
+ */
289
+ declare function getWorkspacePackages(config: ResolvedRelizyConfig): WorkspacePackage[];
290
+ /**
291
+ * Scopes allowed by the config: the workspace packages, the `scopeMap` keys and
292
+ * `commitlint.scopes`. `undefined` when any scope is allowed (standalone mode
293
+ * without an explicit list).
294
+ */
295
+ declare function getAllowedScopes(config: ResolvedRelizyConfig, packages: WorkspacePackage[]): string[] | undefined;
296
+ /** Names of the packages containing at least one of the files */
297
+ declare function getPackagesOfFiles(files: string[], packages: WorkspacePackage[]): string[];
298
+ /** The package designated by a scope, if any */
299
+ declare function findPackageByScope(scope: string, packages: WorkspacePackage[]): WorkspacePackage | undefined;
300
+
301
+ type RuleSeverity = 'error' | 'warn' | 'off';
302
+ /**
303
+ * What a rule receives to check a commit.
304
+ */
305
+ interface RuleContext {
306
+ config: ResolvedRelizyConfig;
307
+ commit: CommitlintCommit;
308
+ parts: CommitMessageParts;
309
+ /** The commit as parsed by relizy, `undefined` when the header is not a conventional commit */
310
+ gitCommit?: GitCommit;
311
+ packages: WorkspacePackage[];
312
+ /** `undefined` when any scope is allowed */
313
+ allowedScopes?: string[];
314
+ /** Configured value of the rule, or its default value */
315
+ value: unknown;
316
+ }
317
+ /** A problem found by a rule: what is wrong, and how to fix it */
318
+ interface RuleProblem {
319
+ message: string;
320
+ fix?: string;
321
+ }
322
+ interface RuleDefinition {
323
+ severity: RuleSeverity;
324
+ value?: unknown;
325
+ /** Only run on conventional commits */
326
+ conventionalOnly?: boolean;
327
+ check: (context: RuleContext) => RuleProblem[] | Promise<RuleProblem[]>;
328
+ }
329
+ /**
330
+ * `type(scope)!: subject`, lowercase type, a space after the colon. Extra spaces
331
+ * are accepted: the changelog trims them.
332
+ */
333
+ declare const STRICT_HEADER_PATTERN: RegExp;
334
+ /**
335
+ * The built-in rules, with their default severity and value.
336
+ */
337
+ declare const BUILT_IN_RULES: Record<CommitlintRuleName, RuleDefinition>;
338
+ interface NormalizedRuleConfig {
339
+ severity: RuleSeverity;
340
+ /** `undefined` when the config sets no value */
341
+ value?: unknown;
342
+ }
343
+ /**
344
+ * `'error'`, `['error', value]` or a commitlint tuple `[2, 'always', value]`.
345
+ */
346
+ declare function normalizeRuleConfig(name: string, config: CommitlintRuleConfig | undefined): NormalizedRuleConfig | undefined;
347
+
348
+ /** Documentation of the built-in rules */
349
+ declare const COMMITLINT_RULES_URL = "https://relizy.dev/commitlint/rules";
350
+ interface CommitlintProblem {
351
+ rule: string;
352
+ severity: Exclude<RuleSeverity, 'off'>;
353
+ /** What is wrong */
354
+ message: string;
355
+ /** How to fix it */
356
+ fix?: string;
357
+ /** Documentation of the rule (built-in rules only) */
358
+ url?: string;
359
+ }
360
+ interface CommitlintSuggestion {
361
+ /** The header with the safe fixes applied */
362
+ header: string;
363
+ /** Rules still failing with the suggested header */
364
+ remainingRules: string[];
365
+ }
366
+ interface CommitlintResult {
367
+ commit: CommitlintCommit;
368
+ /** Ignored commits (merge, fixup, release...) are not linted */
369
+ ignored: boolean;
370
+ /** No error (warnings allowed) */
371
+ valid: boolean;
372
+ problems: CommitlintProblem[];
373
+ /** Title of the changelog section of the commit, `undefined` when it does not appear in the changelog */
374
+ changelogTitle?: string;
375
+ /** The commit as parsed by relizy, `undefined` when the header is not a conventional commit */
376
+ gitCommit?: GitCommit;
377
+ /** A fixed header, when some errors of the header can be fixed safely */
378
+ suggestion?: CommitlintSuggestion;
379
+ }
380
+ interface LintCommitMessageOptions {
381
+ config: ResolvedRelizyConfig;
382
+ /** Changed files of the commit, relative to the repository root */
383
+ files?: string[];
384
+ hash?: string;
385
+ /** Workspace packages, read from the config when not given */
386
+ packages?: WorkspacePackage[];
387
+ /**
388
+ * Suggest a fixed header
389
+ * @default true
390
+ */
391
+ suggest?: boolean;
392
+ }
393
+ /**
394
+ * Lint a commit message with the relizy config: the same parser and types as the
395
+ * release, the workspace packages for the scopes, the changelog rendering for the body.
396
+ */
397
+ declare function lintCommitMessage(message: string, options: LintCommitMessageOptions): Promise<CommitlintResult>;
398
+
399
+ interface ReportEntry {
400
+ result: CommitlintResult;
401
+ /** Printed before the header: the short hash, or "MR title" / "PR title" */
402
+ label?: string;
403
+ /** Changelog entry of the commit, printed with `--preview` */
404
+ preview?: string;
405
+ }
406
+ interface CommitlintReport {
407
+ /** `edit`: the commit being created, `message`: a given message, `range`: commits of the history */
408
+ mode: 'edit' | 'message' | 'range';
409
+ entries: ReportEntry[];
410
+ /** Start of the linted range */
411
+ from?: string;
412
+ /** Kind of the linted pull/merge request title */
413
+ titleKind?: PullRequestTitle['kind'];
414
+ /** File of the message being created, in `edit` mode */
415
+ messageFile?: string;
416
+ helpUrl?: string;
417
+ }
418
+ interface CommitlintSummary {
419
+ errorCount: number;
420
+ warningCount: number;
421
+ }
422
+ declare function summarizeResults(results: CommitlintResult[]): CommitlintSummary;
423
+ /**
424
+ * Colors in a terminal and in the CI logs, which render them. Never for a
425
+ * program reading the output (e.g. an AI agent), nor with `NO_COLOR`.
426
+ */
427
+ declare function shouldUseColors(stream?: {
428
+ isTTY?: boolean;
429
+ }): boolean;
430
+ /** `minor bump, 🚀 Enhancements` */
431
+ declare function formatReleaseEffect(result: CommitlintResult): string;
432
+ /**
433
+ * Lines printed for a linted commit: one line when it is valid without
434
+ * warning, otherwise its header, each problem with how to fix it, and the
435
+ * suggested header.
436
+ */
437
+ declare function formatCommitResult(result: CommitlintResult, { label, colors }?: {
438
+ label?: string;
439
+ colors?: boolean;
440
+ }): string[];
441
+ /**
442
+ * How to fix the invalid commits and title, depending on where they were
443
+ * linted. The commands to run start with `$ `, so they are never wrapped.
444
+ */
445
+ declare function formatHowToFix(report: CommitlintReport): string[];
446
+ /**
447
+ * The text report: each commit, then a summary with the verdict, the
448
+ * documentation of the failing rules, the help URL and how to fix.
449
+ */
450
+ declare function formatTextReport(report: CommitlintReport, { colors, quiet }?: {
451
+ colors?: boolean;
452
+ /** Only print the commits with problems, and the summary */
453
+ quiet?: boolean;
454
+ }): string[];
455
+ /**
456
+ * The JSON report, stable for programs and AI agents: every commit with its
457
+ * effect on the release, its problems and how to fix them.
458
+ */
459
+ declare function formatJsonReport(report: CommitlintReport): string;
460
+ /**
461
+ * GitHub Actions annotations of the problems, displayed on the job summary
462
+ * and the pull request.
463
+ */
464
+ declare function formatGithubAnnotations(report: CommitlintReport): string[];
465
+
140
466
  /**
141
467
  * Get workspace dependencies of a package (only dependencies and peerDependencies, not devDependencies)
142
468
  */
@@ -661,6 +987,11 @@ declare function getPackages({ config, suffix, force, includeAll, dryRun, }: {
661
987
  includeAll?: boolean;
662
988
  dryRun?: boolean;
663
989
  }): Promise<PackageBase[]>;
990
+ declare function isAllowedCommit({ commit, type, changelog, }: {
991
+ commit: GitCommit;
992
+ type?: ConfigType;
993
+ changelog: boolean;
994
+ }): boolean;
664
995
  declare function getPackageCommits({ pkg, from, to, config, changelog, dryRun, }: {
665
996
  pkg: ReadPackage;
666
997
  from: string;
@@ -2355,6 +2686,216 @@ type HookConfig = {
2355
2686
  changelog: string;
2356
2687
  }) => string | void | null | undefined | Promise<string | void | null | undefined>;
2357
2688
  };
2689
+ /**
2690
+ * Severity of a commitlint rule: `error` (or `2`) fails the check, `warn` (or `1`)
2691
+ * reports without failing, `off` (or `0`) disables the rule.
2692
+ */
2693
+ type CommitlintRuleLevel = 'error' | 'warn' | 'off' | 0 | 1 | 2;
2694
+ /**
2695
+ * Configuration of a commitlint rule: a level, a level and a value (ESLint style),
2696
+ * or a commitlint tuple `[level, 'always', value]` to ease migrations.
2697
+ * A rule without value accepts the commitlint tuple `[level, 'always']`.
2698
+ */
2699
+ type CommitlintRuleConfig<Value = unknown> = CommitlintRuleLevel | readonly [CommitlintRuleLevel] | readonly [CommitlintRuleLevel, [Value] extends [never] ? 'always' | 'never' : Value] | readonly [CommitlintRuleLevel, 'always' | 'never', Value];
2700
+ /**
2701
+ * The built-in rules of `relizy commitlint`, with the type of their value
2702
+ * (`never` when the rule has no value).
2703
+ * @see https://relizy.dev/commitlint/rules
2704
+ */
2705
+ interface CommitlintBuiltInRules {
2706
+ /**
2707
+ * The header follows `type(scope)!: subject`.
2708
+ * @default 'error'
2709
+ */
2710
+ 'header-format': never;
2711
+ /**
2712
+ * Maximum length of the header.
2713
+ * @default ['error', 500]
2714
+ */
2715
+ 'header-max-length': number;
2716
+ /**
2717
+ * The type is one of the relizy `types`, or one of the extra types given as value.
2718
+ * @default 'error'
2719
+ */
2720
+ 'type-enum': string[];
2721
+ /**
2722
+ * The scope is a workspace package, a `scopeMap` key or one of `commitlint.scopes`.
2723
+ * @default 'error'
2724
+ */
2725
+ 'scope-enum': never;
2726
+ /**
2727
+ * The scope is required (`'always'`), forbidden (`'never'`), or required on
2728
+ * the commits bumping a version (`'when-bumping'`).
2729
+ * @default ['off', 'always']
2730
+ */
2731
+ 'scope-required': 'always' | 'never' | 'when-bumping';
2732
+ /**
2733
+ * The scope designates a package touched by the commit.
2734
+ * @default 'warn'
2735
+ */
2736
+ 'scope-matches-files': never;
2737
+ /**
2738
+ * The subject starts with a lowercase letter. Off by default: the changelog
2739
+ * capitalizes the subject anyway.
2740
+ * @default 'off'
2741
+ */
2742
+ 'subject-case': never;
2743
+ /**
2744
+ * The subject does not end with a period.
2745
+ * @default 'error'
2746
+ */
2747
+ 'subject-full-stop': never;
2748
+ /**
2749
+ * The subject describes the change, with a minimum of words or characters.
2750
+ * @default ['error', { minWords: 2, minLength: 15 }]
2751
+ */
2752
+ 'subject-meaningful': {
2753
+ minWords?: number;
2754
+ minLength?: number;
2755
+ };
2756
+ /**
2757
+ * A blank line separates the header from the body.
2758
+ * @default 'error'
2759
+ */
2760
+ 'body-leading-blank': never;
2761
+ /**
2762
+ * The body has no markdown headings, which would break the changelog.
2763
+ * @default 'error'
2764
+ */
2765
+ 'body-no-headings': never;
2766
+ /**
2767
+ * The markdown of the body is valid: code blocks closed, links with a URL.
2768
+ * @default 'error'
2769
+ */
2770
+ 'body-markdown': never;
2771
+ /**
2772
+ * The commit, rendered as in the changelogs, passes the lint of the changelogs.
2773
+ * @default 'error'
2774
+ */
2775
+ 'body-changelog-lint': never;
2776
+ /**
2777
+ * A breaking change is only declared with `!` in the header or a `BREAKING CHANGE:`
2778
+ * footer, as relizy bumps the major version wherever `breaking change:` appears.
2779
+ * @default 'error'
2780
+ */
2781
+ 'body-breaking-change': never;
2782
+ /**
2783
+ * Breaking changes are not allowed.
2784
+ * @default 'off'
2785
+ */
2786
+ 'no-breaking': never;
2787
+ }
2788
+ type CommitlintRuleName = keyof CommitlintBuiltInRules;
2789
+ /**
2790
+ * Configuration of the built-in rules, typed per rule, and of the custom rules.
2791
+ */
2792
+ type CommitlintRulesConfig = {
2793
+ [Name in keyof CommitlintBuiltInRules]?: CommitlintRuleConfig<CommitlintBuiltInRules[Name]>;
2794
+ } & Record<string, CommitlintRuleConfig>;
2795
+ /**
2796
+ * A commit message parsed by `relizy commitlint`, with the commitlint field names,
2797
+ * enriched with what relizy knows about the commit.
2798
+ */
2799
+ interface CommitlintCommit {
2800
+ /** Full message, comments removed */
2801
+ raw: string;
2802
+ /** First line of the message */
2803
+ header: string;
2804
+ /** Text between the header and the footer */
2805
+ body: string;
2806
+ /** Trailing block of `Token: value` lines (`BREAKING CHANGE:`, `Closes #12`...) */
2807
+ footer: string;
2808
+ /** Type, empty when the header is not a conventional commit */
2809
+ type: string;
2810
+ /** Scope, as written in the header */
2811
+ scope: string;
2812
+ /** Description of the header, as written */
2813
+ subject: string;
2814
+ /** Breaking change as detected by relizy (`!` or `breaking change:` in the body) */
2815
+ isBreaking: boolean;
2816
+ /** Version bump the commit triggers, computed by relizy from `types` */
2817
+ bump?: SemverBumpType;
2818
+ /** Pull request, issue and hash references found by relizy */
2819
+ references: Reference$1[];
2820
+ /** Changed files (staged files, or the files of the commit in a range), when known */
2821
+ files?: string[];
2822
+ /** Names of the workspace packages touched by `files` */
2823
+ packages?: string[];
2824
+ /** Hash of the commit, when linting a range */
2825
+ hash?: string;
2826
+ }
2827
+ interface CommitlintCustomRuleContext {
2828
+ /** Value configured for the rule (`['error', value]`) */
2829
+ value: unknown;
2830
+ /** Resolved relizy config */
2831
+ config: ResolvedRelizyConfig;
2832
+ }
2833
+ /**
2834
+ * A rule written as a function. Returns `true` when the commit is valid, an
2835
+ * error message (or `false`) otherwise, or a commitlint-style `[valid, message?]`
2836
+ * tuple so `commitlint-plugin-function-rules` rules can be copied as is.
2837
+ */
2838
+ type CommitlintCustomRule = (commit: CommitlintCommit, context: CommitlintCustomRuleContext) => CommitlintCustomRuleOutcome | Promise<CommitlintCustomRuleOutcome>;
2839
+ type CommitlintCustomRuleOutcome = boolean | string | [boolean, string?];
2840
+ /**
2841
+ * Tool checking the code blocks of the commit bodies (`body-changelog-lint`):
2842
+ * - `auto`: the ESLint of the project when it lints the CHANGELOG.md files, otherwise `oxc`;
2843
+ * - `eslint`: the ESLint of the project, an error when it does not lint the CHANGELOG.md files;
2844
+ * - `oxc`: a syntax check of the JavaScript, TypeScript and JSON code blocks.
2845
+ */
2846
+ type CommitlintCodeBlocksLinter = 'auto' | 'eslint' | 'oxc';
2847
+ interface CommitlintConfig {
2848
+ /**
2849
+ * Glob patterns of directories to treat as workspace packages for the scopes,
2850
+ * in addition to `monorepo.packages`, e.g. apps that are never released.
2851
+ * @example ['apps/*']
2852
+ */
2853
+ packages?: string[];
2854
+ /**
2855
+ * Scopes allowed in addition to the workspace packages (short name, full name
2856
+ * or folder) and the `scopeMap` keys. In standalone mode, scopes are free
2857
+ * unless this list is set.
2858
+ * @example ['ci', 'deps', 'release']
2859
+ */
2860
+ scopes?: string[];
2861
+ /**
2862
+ * Level and value of the built-in and custom rules.
2863
+ * @example { 'header-max-length': ['error', 200], 'scope-required': ['error', 'when-bumping'] }
2864
+ */
2865
+ rules?: CommitlintRulesConfig;
2866
+ /**
2867
+ * Rules written as functions, keyed by name. Their level is set in `rules`
2868
+ * and defaults to `error`.
2869
+ */
2870
+ customRules?: Record<string, CommitlintCustomRule>;
2871
+ /**
2872
+ * Messages to ignore, in addition to the default ones: a regular expression
2873
+ * tested against the header, or a function receiving the raw message.
2874
+ */
2875
+ ignores?: Array<RegExp | ((message: string) => boolean)>;
2876
+ /**
2877
+ * Ignore merge commits, `fixup!`, `squash!` and `amend!` commits, and the
2878
+ * release commits of relizy.
2879
+ * @default true
2880
+ */
2881
+ defaultIgnores?: boolean;
2882
+ /**
2883
+ * In the CI of a pull/merge request, also lint its title, which becomes the
2884
+ * commit message of a squash merge. Overridden by `--title` and `--no-title`.
2885
+ * @default false
2886
+ */
2887
+ title?: boolean;
2888
+ /**
2889
+ * Tool checking the code blocks of the commit bodies, rendered as in the
2890
+ * changelogs (`body-changelog-lint`).
2891
+ * @default 'auto'
2892
+ */
2893
+ codeBlocksLinter?: CommitlintCodeBlocksLinter;
2894
+ /**
2895
+ * URL printed with the errors, e.g. the commit guidelines of the team.
2896
+ */
2897
+ helpUrl?: string;
2898
+ }
2358
2899
  /**
2359
2900
  * Relizy configuration
2360
2901
  * @see https://relizy.dev/config/overview
@@ -2431,6 +2972,11 @@ interface RelizyConfig extends Partial<Omit<ChangelogConfig$1, 'output' | 'templ
2431
2972
  * Hooks config
2432
2973
  */
2433
2974
  hooks?: HookConfig;
2975
+ /**
2976
+ * Commit message linter (`relizy commitlint`) config
2977
+ * @see https://relizy.dev/commitlint/
2978
+ */
2979
+ commitlint?: CommitlintConfig;
2434
2980
  /**
2435
2981
  * Set log level
2436
2982
  * @default 'default'
@@ -2465,6 +3011,62 @@ declare function bump(options?: Partial<BumpOptions>): Promise<BumpResult>;
2465
3011
 
2466
3012
  declare function changelog(options?: Partial<ChangelogOptions>): Promise<void>;
2467
3013
 
3014
+ interface CommitlintOptions {
3015
+ /**
3016
+ * Lint the message of the commit being created: the file given to the
3017
+ * `commit-msg` hook, or `.git/COMMIT_EDITMSG` when `true`.
3018
+ */
3019
+ edit?: string | boolean;
3020
+ /** Lint this message */
3021
+ message?: string;
3022
+ /**
3023
+ * Lint the commits after this ref. Defaults to the merge-base with the target
3024
+ * branch of the pull/merge request in CI, otherwise the last tag.
3025
+ */
3026
+ from?: string;
3027
+ /**
3028
+ * Last commit of the range
3029
+ * @default 'HEAD'
3030
+ */
3031
+ to?: string;
3032
+ /**
3033
+ * In the CI of a pull/merge request, also lint its title, which becomes the
3034
+ * commit message of a squash merge
3035
+ * @default config.commitlint.title
3036
+ */
3037
+ title?: boolean;
3038
+ /** Print the changelog entry of each commit */
3039
+ preview?: boolean;
3040
+ /**
3041
+ * `text` for people (colors in a terminal or a CI), `json` for programs and AI agents
3042
+ * @default 'text'
3043
+ */
3044
+ format?: 'text' | 'json';
3045
+ /** In the text format, only print the commits with problems, and the summary */
3046
+ quiet?: boolean;
3047
+ /** Write the `commit-msg` hook instead of linting */
3048
+ install?: boolean;
3049
+ /** Replace an existing `commit-msg` hook with `install` */
3050
+ force?: boolean;
3051
+ /** Custom config file name (e.g. `relizy.standalone` for `relizy.standalone.config.ts`) */
3052
+ configName?: string;
3053
+ logLevel?: LogLevel;
3054
+ /** Pre-loaded config */
3055
+ config?: ResolvedRelizyConfig;
3056
+ }
3057
+ interface CommitlintRunResult extends CommitlintSummary {
3058
+ results: CommitlintResult[];
3059
+ /** The linted commits and how to fix them, unset with `install` */
3060
+ report?: CommitlintReport;
3061
+ /** Set when the hook was installed */
3062
+ hook?: InstalledHook;
3063
+ }
3064
+ /**
3065
+ * Lint commit messages with the relizy config: the commit being created
3066
+ * (`edit`), a message, or a range of commits. Errors make `errorCount` positive.
3067
+ */
3068
+ declare function commitlint(options?: CommitlintOptions): Promise<CommitlintRunResult>;
3069
+
2468
3070
  interface PrCommentOptions {
2469
3071
  prNumber?: number;
2470
3072
  dryRun?: boolean;
@@ -2542,5 +3144,5 @@ declare function socialSafetyCheck({ config }: {
2542
3144
  }): Promise<void>;
2543
3145
  declare function social(options?: Partial<SocialOptions>): Promise<SocialResult>;
2544
3146
 
2545
- export { NEW_PACKAGE_MARKER, PR_COMMENT_MARKER, SLACK_HEADER_MAX_LENGTH, SLACK_MAX_BLOCKS, SLACK_RICH_TEXT_BLOCK_MAX_LENGTH, SLACK_RICH_TEXT_MESSAGE_MAX_LENGTH, SLACK_SECTION_MAX_LENGTH, SLACK_SUMMARY_MAX_LENGTH, assertBranchUpToDateWithRemote, assertReleaseTagsAvailable, buildChangelogBody, buildCommentBody, buildCompareLink, buildContributors, buildReleaseSummary, bump, capReleaseTypeForZeroMajor, changelog, checkGitStatusIfDirty, collectContributorNames, collectPackageBumps, confirmBump, createCommitAndTags, createGitlabRelease, defineConfig, detectGitProvider, detectPackageManager, detectPullRequest, determinePublishTag, determineReleaseType, determineSemverChange, executeBuildCmd, executeFormatCmd, executeHook, expandPackagesToBumpWithDependents, extractChangelogSummary, extractVersionFromPackageTag, extractVersionFromRepoTag, extractVersionFromTag, fetchGitTags, filterOutPrivatePackages, filterPrivatePackagesUnlessIncluded, findGitHubPR, findGitLabMR, findReachableCommitBySubject, formatChangelogForSlack, formatPackagesForSlack, formatSlackMessage, formatTweetMessage, generateChangelog, generateMarkDown, getAuthCommand, getBumpedIndependentPackages, getBumpedPackageIndependently, getCIName, getCanaryVersion, getCommitChangedFiles, getCommitSubject, getCurrentGitBranch, getCurrentGitRef, getDefaultConfig, getDependentsOf, getFirstCommit, getGitDiff, getGitStatus, getGitUpstream, getIndependentTag, getLastPackageTag, getLastRepoTag, getLastStableTag, getLastTag, getModifiedReleaseFilePatterns, getNewPackageCompareBase, getNpmRegistry, getPackageCommits, getPackageDependencies, getPackageNewVersion, getPackages, getPackagesOrBumpedPackages, getPackagesToPublishInIndependentMode, getPackagesToPublishInSelectiveMode, getPreid, getReleaseTagNames, getReleaseUrl, getRootPackage, getShortCommitSha, getSlackToken, getSlackWebhookUrl, getTwitterCredentials, github, gitlab, globDirsAbsolute, hasLernaJson, isAncestor, isBumpedPackage, isChangedPreid, isCommitOnlyInIgnoredPackages, isGraduating, isGraduatingToStableBetweenVersion, isInCI, isPrerelease, isPrereleaseReleaseType, isStableReleaseType, isTagVersionCompatibleWithCurrent, isVersionAlreadyPublishedError, isVersionPublished, listTags, loadRelizyConfig, markdownToSlackMrkdwn, markdownToSlackRichText, mergeTypes, parseChangelogMarkdown, parseGitRemoteUrl, postPrComment, postReleaseToSlack, postReleaseToTwitter, prComment, providerRelease, providerReleaseSafetyCheck, publish, publishPackage, publishSafetyCheck, pushCommitAndTags, pushTagForce, readPackageJson, readPackages, reconcileFromTag, redactSecrets, release, resetRewrittenTagCache, resolveAllConfiguredRegistryTargets, resolveIgnoredPackagePaths, resolveRegistryTargetsForPackage, resolveRegistryTargetsForPackages, resolveSlackPostMaxLength, resolveTags, retagAnnotatedLocal, richTextToPlainText, rollbackModifiedFiles, shouldFilterPrereleaseTags, sliceSlackText, social, socialSafetyCheck, tagExists, topologicalSort, tryPostPrComment, updateLernaVersion, withRegistryNpmrc, writeChangelogToFile, writeVersion };
2546
- export type { AIConfig, AIExtraGuidelines, AIPromptTarget, AIProviderName, AISocialConfig, AISystemPromptOverrides, AITargetConfig, AiSdkProviderOptions, BumpConfig, BumpOptions, BumpResult, BumpResultFalsy, BumpResultTruthy, ChangelogConfig, ChangelogInclude, ChangelogOptions, ClaudeCodeProviderOptions, ConfigType, GitProvider, GitUpstream, GitlabRelease, GitlabReleaseResponse, HookConfig, HookStep, HookType, MonorepoConfig, OnRewrittenTag, PackageBase, PackageBumpEntry, PackageManager, PostedRelease, PrCommentConfig, PrCommentMode, PrCommentOptions, PrCommentStatus, ProviderReleaseOptions, ProviderReleaseResult, PublishConfig, PublishOptions, PublishResponse, PullRequestInfo, ReadPackage, Reference, RegistryTarget, ReleaseConfig, ReleaseContext, ReleaseOptions, RelizyConfig, RepoConfig, ResolvedConfig, ResolvedRelizyConfig, ResolvedTags, ResolvedTwitterCredentials, RootPackage, SlackChangelogFormat, SlackCredentials, SlackOptions, SlackPackageEntry, SlackRichTextBlock, SlackRichTextElement, SlackRichTextInline, SlackRichTextLink, SlackRichTextList, SlackRichTextPreformatted, SlackRichTextQuote, SlackRichTextSection, SlackRichTextStyle, SlackRichTextText, SlackSocialConfig, SocialConfig, SocialNetworkResult, SocialOptions, SocialResult, Step, TemplatesConfig, TokensConfig, TwitterCredentials, TwitterOptions, TwitterSocialConfig, VersionMode };
3147
+ export { BUILT_IN_RULES, COMMITLINT_RULES_URL, NEW_PACKAGE_MARKER, PR_COMMENT_MARKER, SLACK_HEADER_MAX_LENGTH, SLACK_MAX_BLOCKS, SLACK_RICH_TEXT_BLOCK_MAX_LENGTH, SLACK_RICH_TEXT_MESSAGE_MAX_LENGTH, SLACK_SECTION_MAX_LENGTH, SLACK_SUMMARY_MAX_LENGTH, STRICT_HEADER_PATTERN, assertBranchUpToDateWithRemote, assertRefAvailable, assertReleaseTagsAvailable, buildChangelogBody, buildCommentBody, buildCompareLink, buildContributors, buildReleaseSummary, bump, capReleaseTypeForZeroMajor, changelog, checkGitStatusIfDirty, collectContributorNames, collectPackageBumps, commitlint, confirmBump, createCommitAndTags, createGitlabRelease, defineConfig, detectGitProvider, detectPackageManager, detectPullRequest, determinePublishTag, determineReleaseType, determineSemverChange, executeBuildCmd, executeFormatCmd, executeHook, expandPackagesToBumpWithDependents, extractChangelogSummary, extractVersionFromPackageTag, extractVersionFromRepoTag, extractVersionFromTag, fetchGitTags, filterOutPrivatePackages, filterPrivatePackagesUnlessIncluded, findGitHubPR, findGitLabMR, findPackageByScope, findReachableCommitBySubject, formatChangelogForSlack, formatCommitResult, formatGithubAnnotations, formatHowToFix, formatJsonReport, formatPackagesForSlack, formatReleaseEffect, formatSlackMessage, formatTextReport, formatTweetMessage, generateChangelog, generateMarkDown, getAllowedScopes, getAuthCommand, getBumpedIndependentPackages, getBumpedPackageIndependently, getCIName, getCanaryVersion, getChangelogLinter, getChangelogTitle, getCommentChar, getCommitChangedFiles, getCommitMessageFile, getCommitSubject, getCommitsInRange, getCurrentGitBranch, getCurrentGitRef, getDefaultConfig, getDependentsOf, getFirstCommit, getGitDiff, getGitStatus, getGitUpstream, getIndependentTag, getLastPackageTag, getLastRepoTag, getLastStableTag, getLastTag, getModifiedReleaseFilePatterns, getNewPackageCompareBase, getNpmRegistry, getPackageCommits, getPackageDependencies, getPackageManagerWorkspaces, getPackageNewVersion, getPackages, getPackagesOfFiles, getPackagesOrBumpedPackages, getPackagesToPublishInIndependentMode, getPackagesToPublishInSelectiveMode, getPreid, getPullRequestTitle, getReleaseTagNames, getReleaseUrl, getRootPackage, getShortCommitSha, getSlackToken, getSlackWebhookUrl, getStagedFiles, getTwitterCredentials, getWorkspacePackages, github, gitlab, globDirsAbsolute, hasLernaJson, installCommitMsgHook, isAllowedCommit, isAncestor, isBumpedPackage, isChangedPreid, isCommitOnlyInIgnoredPackages, isGraduating, isGraduatingToStableBetweenVersion, isIgnoredCommitMessage, isInCI, isPrerelease, isPrereleaseReleaseType, isStableReleaseType, isTagVersionCompatibleWithCurrent, isVersionAlreadyPublishedError, isVersionPublished, lintCommitMessage, listTags, loadRelizyConfig, markdownToSlackMrkdwn, markdownToSlackRichText, mergeTypes, normalizeRuleConfig, parseChangelogMarkdown, parseGitRemoteUrl, postPrComment, postReleaseToSlack, postReleaseToTwitter, prComment, providerRelease, providerReleaseSafetyCheck, publish, publishPackage, publishSafetyCheck, pushCommitAndTags, pushTagForce, readCommitMessageFile, readPackageJson, readPackages, reconcileFromTag, redactSecrets, release, renderChangelogEntry, resetRewrittenTagCache, resolveAllConfiguredRegistryTargets, resolveDefaultRangeStart, resolveIgnoredPackagePaths, resolveRegistryTargetsForPackage, resolveRegistryTargetsForPackages, resolveSlackPostMaxLength, resolveTags, retagAnnotatedLocal, richTextToPlainText, rollbackModifiedFiles, shouldFilterPrereleaseTags, shouldUseColors, sliceSlackText, social, socialSafetyCheck, splitCommitMessage, stripGitComments, summarizeResults, tagExists, topologicalSort, tryPostPrComment, updateLernaVersion, withRegistryNpmrc, writeChangelogToFile, writeVersion };
3148
+ export type { AIConfig, AIExtraGuidelines, AIPromptTarget, AIProviderName, AISocialConfig, AISystemPromptOverrides, AITargetConfig, AiSdkProviderOptions, BumpConfig, BumpOptions, BumpResult, BumpResultFalsy, BumpResultTruthy, ChangelogConfig, ChangelogInclude, ChangelogLinter, ChangelogOptions, ClaudeCodeProviderOptions, CommitMessageParts, CommitlintBuiltInRules, CommitlintCodeBlocksLinter, CommitlintCommit, CommitlintConfig, CommitlintCustomRule, CommitlintCustomRuleContext, CommitlintCustomRuleOutcome, CommitlintOptions, CommitlintProblem, CommitlintReport, CommitlintResult, CommitlintRuleConfig, CommitlintRuleLevel, CommitlintRuleName, CommitlintRulesConfig, CommitlintRunResult, CommitlintSuggestion, CommitlintSummary, ConfigType, DefaultRangeStart, GitProvider, GitUpstream, GitlabRelease, GitlabReleaseResponse, HookConfig, HookStep, HookType, InstalledHook, LintCommitMessageOptions, MonorepoConfig, NormalizedRuleConfig, OnRewrittenTag, PackageBase, PackageBumpEntry, PackageManager, PostedRelease, PrCommentConfig, PrCommentMode, PrCommentOptions, PrCommentStatus, ProviderReleaseOptions, ProviderReleaseResult, PublishConfig, PublishOptions, PublishResponse, PullRequestInfo, PullRequestTitle, RangeCommit, ReadPackage, Reference, RegistryTarget, ReleaseConfig, ReleaseContext, ReleaseOptions, RelizyConfig, RepoConfig, ReportEntry, ResolvedConfig, ResolvedRelizyConfig, ResolvedTags, ResolvedTwitterCredentials, RootPackage, RuleContext, RuleDefinition, RuleProblem, RuleSeverity, SlackChangelogFormat, SlackCredentials, SlackOptions, SlackPackageEntry, SlackRichTextBlock, SlackRichTextElement, SlackRichTextInline, SlackRichTextLink, SlackRichTextList, SlackRichTextPreformatted, SlackRichTextQuote, SlackRichTextSection, SlackRichTextStyle, SlackRichTextText, SlackSocialConfig, SocialConfig, SocialNetworkResult, SocialOptions, SocialResult, Step, TemplatesConfig, TokensConfig, TwitterCredentials, TwitterOptions, TwitterSocialConfig, VersionMode, WorkspacePackage };