@codluv/versionguard 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 kryptobaseddev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,357 @@
1
+ # VersionGuard
2
+
3
+ Strict version governance for TypeScript and Node.js projects.
4
+
5
+ VersionGuard keeps `package.json`, changelog entries, git tags, and configured version references in sync so humans and LLM agents stop shipping messy release state.
6
+
7
+ ## Why it exists
8
+
9
+ Versioning breaks in the same places over and over:
10
+
11
+ - versions get hardcoded across docs and source files
12
+ - changelog entries are forgotten
13
+ - tags drift from the package version
14
+ - SemVer and CalVer rules get bent under pressure
15
+ - agents take shortcuts and leave the repo in an invalid release state
16
+
17
+ VersionGuard turns those into enforceable checks with repair-oriented feedback.
18
+
19
+ ## What it does
20
+
21
+ - validates SemVer and CalVer formats strictly
22
+ - keeps configured files synced from `package.json`
23
+ - detects version mismatches in scanned files
24
+ - validates Keep a Changelog structure and required release entries
25
+ - installs git hooks for `pre-commit`, `pre-push`, and `post-tag`
26
+ - provides CLI commands for validation, sync, bumps, and tagging
27
+ - refuses unsafe tagging when hooks are required or the worktree is dirty
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ npm install -D @codluv/versionguard
33
+ npx versionguard init
34
+ npx versionguard hooks install
35
+ ```
36
+
37
+ That gives you:
38
+
39
+ - a `.versionguard.yml` config file
40
+ - managed git hooks
41
+ - a repo-local version policy built around `package.json`
42
+
43
+ ## Quick start
44
+
45
+ Run a basic version check:
46
+
47
+ ```bash
48
+ npx versionguard check
49
+ ```
50
+
51
+ Run full repository validation:
52
+
53
+ ```bash
54
+ npx versionguard validate
55
+ ```
56
+
57
+ For CI or agent workflows:
58
+
59
+ ```bash
60
+ npx versionguard validate --json
61
+ ```
62
+
63
+ Sync configured files back to the package version:
64
+
65
+ ```bash
66
+ npx versionguard sync
67
+ ```
68
+
69
+ Repair common issues automatically:
70
+
71
+ ```bash
72
+ npx versionguard fix
73
+ ```
74
+
75
+ ## Example output
76
+
77
+ Valid version:
78
+
79
+ ```text
80
+ Current version: 1.2.3
81
+ Versioning type: semver
82
+
83
+ ✓ Version is valid
84
+ ```
85
+
86
+ Invalid version with actionable guidance:
87
+
88
+ ```text
89
+ Current version: v1.0.0
90
+ Versioning type: semver
91
+
92
+ ✗ Version has issues:
93
+
94
+ ✗ Version should not start with 'v': v1.0.0
95
+
96
+ How to fix:
97
+ → Remove the 'v' prefix
98
+ Run: npm version 1.0.0
99
+ ```
100
+
101
+ ## Configuration
102
+
103
+ VersionGuard uses a single YAML config file.
104
+
105
+ Example:
106
+
107
+ ```yaml
108
+ versioning:
109
+ type: semver
110
+
111
+ # Enable this block when using calver
112
+ # calver:
113
+ # format: "YYYY.MM.PATCH"
114
+ # preventFutureDates: true
115
+
116
+ sync:
117
+ files:
118
+ - "README.md"
119
+ - "CHANGELOG.md"
120
+ patterns:
121
+ - regex: '(version\s*[=:]\s*["'])(.+?)(["'])'
122
+ template: '$1{{version}}$3'
123
+ - regex: '(##\s*\[)(.+?)(\])'
124
+ template: '$1{{version}}$3'
125
+
126
+ changelog:
127
+ enabled: true
128
+ file: "CHANGELOG.md"
129
+ strict: true
130
+ requireEntry: true
131
+
132
+ git:
133
+ hooks:
134
+ pre-commit: true
135
+ pre-push: true
136
+ post-tag: true
137
+ enforceHooks: true
138
+
139
+ ignore:
140
+ - "node_modules/**"
141
+ - "dist/**"
142
+ - ".git/**"
143
+ - "*.lock"
144
+ ```
145
+
146
+ ## Supported versioning modes
147
+
148
+ ### SemVer
149
+
150
+ VersionGuard supports strict semantic version validation with:
151
+
152
+ - `MAJOR.MINOR.PATCH`
153
+ - prerelease metadata such as `1.2.3-alpha.1`
154
+ - build metadata such as `1.2.3+build.5`
155
+ - precedence comparison and increment helpers
156
+
157
+ ### CalVer
158
+
159
+ Supported formats currently include:
160
+
161
+ - `YYYY.MM.DD`
162
+ - `YYYY.MM.PATCH`
163
+ - `YY.M.PATCH`
164
+ - `YYYY.0M.0D`
165
+
166
+ CalVer validation can reject future-dated versions when enabled.
167
+
168
+ ## Commands
169
+
170
+ | Command | Description |
171
+ | --- | --- |
172
+ | `versionguard init` | Create `.versionguard.yml` in the current project |
173
+ | `versionguard check` | Validate the current version with actionable feedback |
174
+ | `versionguard validate` | Run version, sync, and changelog validation |
175
+ | `versionguard doctor` | Report repository readiness in one pass |
176
+ | `versionguard fix` | Apply deterministic fixes for common drift |
177
+ | `versionguard sync` | Update configured files to match `package.json` |
178
+ | `versionguard bump` | Suggest the next version and optionally apply it |
179
+ | `versionguard tag [version]` | Create an annotated release tag safely |
180
+ | `versionguard hooks install` | Install managed git hooks |
181
+ | `versionguard hooks uninstall` | Remove managed git hooks |
182
+ | `versionguard hooks status` | Check whether hooks are installed |
183
+
184
+ ## Git hook behavior
185
+
186
+ VersionGuard can install these hooks:
187
+
188
+ - `pre-commit`
189
+ - `pre-push`
190
+ - `post-tag`
191
+
192
+ When `git.enforceHooks` is enabled, release tagging also expects managed hooks to be present.
193
+
194
+ ## Doctor command
195
+
196
+ Use `doctor` when you want a one-pass readiness report before releasing:
197
+
198
+ ```bash
199
+ npx versionguard doctor
200
+ ```
201
+
202
+ For CI or agent workflows:
203
+
204
+ ```bash
205
+ npx versionguard doctor --json
206
+ ```
207
+
208
+ It reports:
209
+
210
+ - current package version
211
+ - version validity
212
+ - sync status
213
+ - changelog readiness
214
+ - hook installation state
215
+ - worktree cleanliness
216
+
217
+ ## Validate JSON output
218
+
219
+ Use `validate --json` when you need machine-readable validation output:
220
+
221
+ ```bash
222
+ npx versionguard validate --json
223
+ ```
224
+
225
+ The JSON payload includes:
226
+
227
+ - `valid`
228
+ - `version`
229
+ - `versionValid`
230
+ - `syncValid`
231
+ - `changelogValid`
232
+ - `errors`
233
+ - `hook`
234
+ - `postTag`
235
+
236
+ ## Tagging behavior
237
+
238
+ `versionguard tag` is intentionally strict.
239
+
240
+ It can refuse to proceed when:
241
+
242
+ - hooks are required but not installed
243
+ - the working tree is dirty
244
+ - the requested tag already exists
245
+ - the package version or changelog state is invalid
246
+ - synced files are out of date
247
+
248
+ That keeps release tags from becoming a bypass around normal validation.
249
+
250
+ ## Typical workflows
251
+
252
+ ### Validate before committing
253
+
254
+ ```bash
255
+ npx versionguard validate
256
+ ```
257
+
258
+ ### Repair drift after a manual version change
259
+
260
+ ```bash
261
+ npm version patch
262
+ npx versionguard fix
263
+ ```
264
+
265
+ ### Suggest and apply the next version
266
+
267
+ ```bash
268
+ npx versionguard bump --apply
269
+ ```
270
+
271
+ ### Create a release tag safely
272
+
273
+ ```bash
274
+ npx versionguard tag 1.2.3 -m "Release 1.2.3"
275
+ ```
276
+
277
+ ## Development
278
+
279
+ This repository uses a modern ESM toolchain:
280
+
281
+ - Vite for builds
282
+ - Vitest for tests
283
+ - Biome for formatting and baseline linting
284
+ - ESLint for semantic TypeScript linting
285
+
286
+ Useful commands:
287
+
288
+ ```bash
289
+ npm run lint
290
+ npm test
291
+ npm run build
292
+ ```
293
+
294
+ Forge commands:
295
+
296
+ ```bash
297
+ npm run forge:check
298
+ npm run forge:test
299
+ npm run forge:build
300
+ npm run forge:doctor
301
+ ```
302
+
303
+ Initialize or refresh Forge scaffolding:
304
+
305
+ ```bash
306
+ npm run forge:docs:init
307
+ ```
308
+
309
+ Run a single test file:
310
+
311
+ ```bash
312
+ npx vitest run src/__tests__/semver.test.ts
313
+ ```
314
+
315
+ Run a single test by name:
316
+
317
+ ```bash
318
+ npx vitest run src/__tests__/calver.test.ts -t "increments patch-based versions"
319
+ ```
320
+
321
+ ## Docs
322
+
323
+ - Product vision: `docs/VISION.md`
324
+ - Verified feature ledger and roadmap: `docs/FEATURES.md`
325
+ - Agent guidance for contributors: `AGENTS.md`
326
+
327
+ ## Forge
328
+
329
+ This repo is set up with `@forge-ts/cli` and a project config in `forge-ts.config.ts`.
330
+
331
+ Useful commands:
332
+
333
+ ```bash
334
+ npm run forge:check
335
+ npm run forge:test
336
+ npm run forge:build
337
+ npm run forge:doctor
338
+ ```
339
+
340
+ Current status:
341
+
342
+ - Forge is installed and initialized
343
+ - `forge-ts check` currently reports significant TSDoc debt
344
+ - generated documentation artifacts are written into `docs/`
345
+
346
+ Recommended workflow:
347
+
348
+ ```bash
349
+ npm run forge:check
350
+ npm run forge:build
351
+ ```
352
+
353
+ Then fix TSDoc issues in the order reported by Forge.
354
+
355
+ ## License
356
+
357
+ MIT
@@ -0,0 +1,245 @@
1
+ /**
2
+ * Calendar version parsing, formatting, and comparison helpers.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import type { CalVer, CalVerFormat, ValidationResult } from './types';
7
+ /**
8
+ * Parsed token layout for a supported CalVer format string.
9
+ *
10
+ * @public
11
+ * @since 0.1.0
12
+ * @forgeIgnore E020
13
+ */
14
+ export interface ParsedCalVerFormat {
15
+ /**
16
+ * Year token captured from the format string.
17
+ */
18
+ year: 'YYYY' | 'YY';
19
+ /**
20
+ * Month token captured from the format string.
21
+ */
22
+ month: 'MM' | 'M' | '0M';
23
+ /**
24
+ * Day token captured from the format string when present.
25
+ *
26
+ * @defaultValue undefined
27
+ */
28
+ day?: 'DD' | 'D' | '0D';
29
+ /**
30
+ * Patch token captured from the format string when present.
31
+ *
32
+ * @defaultValue undefined
33
+ */
34
+ patch?: 'PATCH';
35
+ }
36
+ /**
37
+ * Breaks a CalVer format string into its component tokens.
38
+ *
39
+ * @remarks
40
+ * This helper is used internally by parsing, formatting, and version generation helpers
41
+ * to decide which date parts or patch counters are present in a given CalVer layout.
42
+ *
43
+ * @param calverFormat - Format string to inspect.
44
+ * @returns The parsed token definition for the requested format.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * import { parseFormat } from 'versionguard';
49
+ *
50
+ * parseFormat('YYYY.MM.PATCH');
51
+ * // => { year: 'YYYY', month: 'MM', patch: 'PATCH' }
52
+ * ```
53
+ *
54
+ * @public
55
+ * @since 0.1.0
56
+ */
57
+ export declare function parseFormat(calverFormat: CalVerFormat): ParsedCalVerFormat;
58
+ /**
59
+ * Builds a regular expression that matches a supported CalVer format.
60
+ *
61
+ * @remarks
62
+ * The returned regular expression is anchored to the start and end of the string so it can
63
+ * be used directly for strict validation of a complete version value.
64
+ *
65
+ * @param calverFormat - Format string to convert into a regular expression.
66
+ * @returns A strict regular expression for the supplied CalVer format.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * import { getRegexForFormat } from 'versionguard';
71
+ *
72
+ * getRegexForFormat('YYYY.0M.0D').test('2026.03.21');
73
+ * // => true
74
+ * ```
75
+ *
76
+ * @public
77
+ * @since 0.1.0
78
+ */
79
+ export declare function getRegexForFormat(calverFormat: CalVerFormat): RegExp;
80
+ /**
81
+ * Parses a CalVer string using the supplied format.
82
+ *
83
+ * @remarks
84
+ * The parser returns `null` when the string does not structurally match the requested format.
85
+ * It does not enforce range rules such as future-date rejection; use {@link validate} for that.
86
+ *
87
+ * @param version - Version string to parse.
88
+ * @param calverFormat - Format expected for the version string.
89
+ * @returns Parsed CalVer components, or `null` when the string does not match the format.
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * import { parse } from 'versionguard';
94
+ *
95
+ * parse('2026.03.21', 'YYYY.0M.0D')?.month;
96
+ * // => 3
97
+ * ```
98
+ *
99
+ * @see {@link validate} to apply date-range and future-date validation.
100
+ * @public
101
+ * @since 0.1.0
102
+ */
103
+ export declare function parse(version: string, calverFormat: CalVerFormat): CalVer | null;
104
+ /**
105
+ * Validates a CalVer string against formatting and date rules.
106
+ *
107
+ * @remarks
108
+ * Validation checks the requested CalVer format, month and day ranges, and optionally rejects
109
+ * future dates relative to the current system date.
110
+ *
111
+ * @param version - Version string to validate.
112
+ * @param calverFormat - Format expected for the version string.
113
+ * @param preventFutureDates - Whether future dates should be reported as errors.
114
+ * @returns A validation result containing any discovered errors and the parsed version on success.
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * import { validate } from 'versionguard';
119
+ *
120
+ * validate('2026.03.21', 'YYYY.0M.0D', false).valid;
121
+ * // => true
122
+ * ```
123
+ *
124
+ * @public
125
+ * @since 0.1.0
126
+ */
127
+ export declare function validate(version: string, calverFormat: CalVerFormat, preventFutureDates?: boolean): ValidationResult;
128
+ /**
129
+ * Formats a parsed CalVer object back into a version string.
130
+ *
131
+ * @remarks
132
+ * Missing `day` and `patch` values fall back to `1` and `0` respectively when the selected
133
+ * format requires those tokens.
134
+ *
135
+ * @param version - Parsed CalVer value to serialize.
136
+ * @returns The formatted CalVer string.
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * import { format } from 'versionguard';
141
+ *
142
+ * const version = { year: 2026, month: 3, day: 21, format: 'YYYY.0M.0D', raw: '2026.03.21' };
143
+ *
144
+ * format(version);
145
+ * // => '2026.03.21'
146
+ * ```
147
+ *
148
+ * @public
149
+ * @since 0.1.0
150
+ */
151
+ export declare function format(version: CalVer): string;
152
+ /**
153
+ * Creates the current CalVer string for a format.
154
+ *
155
+ * @remarks
156
+ * This helper derives its values from the provided date and initializes any patch token to `0`.
157
+ * It is useful for generating a same-day baseline before incrementing patch-based formats.
158
+ *
159
+ * @param calverFormat - Format to generate.
160
+ * @param now - Date used as the source for year, month, and day values.
161
+ * @returns The current version string for the requested format.
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * import { getCurrentVersion } from 'versionguard';
166
+ *
167
+ * getCurrentVersion('YYYY.MM.PATCH', new Date('2026-03-21T00:00:00Z'));
168
+ * // => '2026.3.0'
169
+ * ```
170
+ *
171
+ * @public
172
+ * @since 0.1.0
173
+ */
174
+ export declare function getCurrentVersion(calverFormat: CalVerFormat, now?: Date): string;
175
+ /**
176
+ * Compares two CalVer strings using a shared format.
177
+ *
178
+ * @remarks
179
+ * Comparison is performed component-by-component in year, month, day, then patch order.
180
+ * Missing day and patch values are treated as `0` during comparison.
181
+ *
182
+ * @param a - Left-hand version string.
183
+ * @param b - Right-hand version string.
184
+ * @param calverFormat - Format used to parse both versions.
185
+ * @returns `1` when `a` is greater, `-1` when `b` is greater, or `0` when they are equal.
186
+ *
187
+ * @example
188
+ * ```ts
189
+ * import { compare } from 'versionguard';
190
+ *
191
+ * compare('2026.03.2', '2026.03.1', 'YYYY.MM.PATCH');
192
+ * // => 1
193
+ * ```
194
+ *
195
+ * @public
196
+ * @since 0.1.0
197
+ */
198
+ export declare function compare(a: string, b: string, calverFormat: CalVerFormat): number;
199
+ /**
200
+ * Increments a CalVer string.
201
+ *
202
+ * @remarks
203
+ * Patch-based formats increment the existing patch number. Formats without a patch token are
204
+ * promoted to a patch-based output by appending `.PATCH` semantics with an initial value of `0`.
205
+ *
206
+ * @param version - Current version string.
207
+ * @param calverFormat - Format used to parse the current version.
208
+ * @returns The next version string.
209
+ *
210
+ * @example
211
+ * ```ts
212
+ * import { increment } from 'versionguard';
213
+ *
214
+ * increment('2026.03.1', 'YYYY.MM.PATCH');
215
+ * // => '2026.3.2'
216
+ * ```
217
+ *
218
+ * @public
219
+ * @since 0.1.0
220
+ */
221
+ export declare function increment(version: string, calverFormat: CalVerFormat): string;
222
+ /**
223
+ * Returns the most likely next CalVer candidates.
224
+ *
225
+ * @remarks
226
+ * The first candidate is the version derived from the current date. The second candidate is the
227
+ * incremented form of the supplied current version.
228
+ *
229
+ * @param currentVersion - Existing project version.
230
+ * @param calverFormat - Format used to generate both candidates.
231
+ * @returns Two candidate version strings ordered as current-date then incremented version.
232
+ *
233
+ * @example
234
+ * ```ts
235
+ * import { getNextVersions } from 'versionguard';
236
+ *
237
+ * getNextVersions('2026.03.1', 'YYYY.MM.PATCH').length;
238
+ * // => 2
239
+ * ```
240
+ *
241
+ * @public
242
+ * @since 0.1.0
243
+ */
244
+ export declare function getNextVersions(currentVersion: string, calverFormat: CalVerFormat): string[];
245
+ //# sourceMappingURL=calver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calver.d.ts","sourceRoot":"","sources":["../src/calver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAmB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEvF;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpB;;OAEG;IACH,KAAK,EAAE,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC;IAEzB;;;;OAIG;IACH,GAAG,CAAC,EAAE,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC;IAExB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,YAAY,GAAG,kBAAkB,CAkB1E;AAuBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAIpE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,CAmChF;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,YAAY,EAC1B,kBAAkB,GAAE,OAAc,GACjC,gBAAgB,CA0ElB;AAcD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAa9C;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,GAAE,IAAiB,GAAG,MAAM,CAkB5F;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,MAAM,CAiBhF;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,MAAM,CAsB7E;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,MAAM,EAAE,CAE5F"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Describes the outcome of validating a changelog file.
3
+ *
4
+ * @public
5
+ * @since 0.1.0
6
+ * @forgeIgnore E020
7
+ */
8
+ export interface ChangelogValidationResult {
9
+ /**
10
+ * Indicates whether the changelog satisfies all requested checks.
11
+ */
12
+ valid: boolean;
13
+ /**
14
+ * Human-readable validation errors.
15
+ */
16
+ errors: string[];
17
+ /**
18
+ * Indicates whether the changelog contains an entry for the requested version.
19
+ */
20
+ hasEntryForVersion: boolean;
21
+ }
22
+ /**
23
+ * Validates a changelog file for release readiness.
24
+ *
25
+ * @public
26
+ * @since 0.1.0
27
+ * @remarks
28
+ * The validator checks for a top-level changelog heading, an `[Unreleased]`
29
+ * section, and optionally a dated entry for the requested version.
30
+ *
31
+ * @param changelogPath - Path to the changelog file.
32
+ * @param version - Version that must be present in the changelog.
33
+ * @param strict - Whether to require compare links and dated release headings.
34
+ * @param requireEntry - Whether the requested version must already have an entry.
35
+ * @returns The result of validating the changelog file.
36
+ * @example
37
+ * ```ts
38
+ * import { validateChangelog } from 'versionguard';
39
+ *
40
+ * const result = validateChangelog('CHANGELOG.md', '1.2.0', true, true);
41
+ * ```
42
+ */
43
+ export declare function validateChangelog(changelogPath: string, version: string, strict?: boolean, requireEntry?: boolean): ChangelogValidationResult;
44
+ /**
45
+ * Gets the most recent released version from a changelog.
46
+ *
47
+ * @public
48
+ * @since 0.1.0
49
+ * @remarks
50
+ * The `[Unreleased]` section is skipped so the first concrete version heading is
51
+ * treated as the latest release.
52
+ *
53
+ * @param changelogPath - Path to the changelog file.
54
+ * @returns The latest released version, or `null` when no release entry exists.
55
+ * @example
56
+ * ```ts
57
+ * import { getLatestVersion } from 'versionguard';
58
+ *
59
+ * const latest = getLatestVersion('CHANGELOG.md');
60
+ * ```
61
+ */
62
+ export declare function getLatestVersion(changelogPath: string): string | null;
63
+ /**
64
+ * Inserts a new version entry beneath the `[Unreleased]` section.
65
+ *
66
+ * @public
67
+ * @since 0.1.0
68
+ * @remarks
69
+ * If the changelog already contains the requested version, no changes are made.
70
+ * The inserted entry includes a starter `Added` subsection for follow-up edits.
71
+ *
72
+ * @param changelogPath - Path to the changelog file.
73
+ * @param version - Version to add.
74
+ * @param date - Release date to write in `YYYY-MM-DD` format.
75
+ * @example
76
+ * ```ts
77
+ * import { addVersionEntry } from 'versionguard';
78
+ *
79
+ * addVersionEntry('CHANGELOG.md', '1.2.0', '2026-03-21');
80
+ * ```
81
+ */
82
+ export declare function addVersionEntry(changelogPath: string, version: string, date?: string): void;
83
+ //# sourceMappingURL=changelog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changelog.d.ts","sourceRoot":"","sources":["../src/changelog.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;OAEG;IACH,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAID;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,OAAc,EACtB,YAAY,GAAE,OAAc,GAC3B,yBAAyB,CAgD3B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQrE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAC7B,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,MAA8C,GACnD,IAAI,CAmBN"}