@codluv/versionguard 0.2.0 → 0.4.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/calver.d.ts +65 -22
- package/dist/calver.d.ts.map +1 -1
- package/dist/chunks/{index-BwE_OaV3.js → index-B3R60bYJ.js} +913 -138
- package/dist/chunks/index-B3R60bYJ.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +258 -22
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/feedback/index.d.ts +1 -1
- package/dist/feedback/index.d.ts.map +1 -1
- package/dist/fix/index.d.ts +7 -2
- package/dist/fix/index.d.ts.map +1 -1
- package/dist/guard.d.ts +45 -1
- package/dist/guard.d.ts.map +1 -1
- package/dist/hooks.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -23
- package/dist/init-wizard.d.ts +49 -0
- package/dist/init-wizard.d.ts.map +1 -0
- package/dist/project.d.ts +54 -10
- package/dist/project.d.ts.map +1 -1
- package/dist/sources/git-tag.d.ts +52 -0
- package/dist/sources/git-tag.d.ts.map +1 -0
- package/dist/sources/index.d.ts +15 -0
- package/dist/sources/index.d.ts.map +1 -0
- package/dist/sources/json.d.ts +53 -0
- package/dist/sources/json.d.ts.map +1 -0
- package/dist/sources/provider.d.ts +25 -0
- package/dist/sources/provider.d.ts.map +1 -0
- package/dist/sources/regex.d.ts +56 -0
- package/dist/sources/regex.d.ts.map +1 -0
- package/dist/sources/resolve.d.ts +54 -0
- package/dist/sources/resolve.d.ts.map +1 -0
- package/dist/sources/toml.d.ts +60 -0
- package/dist/sources/toml.d.ts.map +1 -0
- package/dist/sources/utils.d.ts +73 -0
- package/dist/sources/utils.d.ts.map +1 -0
- package/dist/sources/version-file.d.ts +51 -0
- package/dist/sources/version-file.d.ts.map +1 -0
- package/dist/sources/yaml.d.ts +53 -0
- package/dist/sources/yaml.d.ts.map +1 -0
- package/dist/tag/index.d.ts.map +1 -1
- package/dist/types.d.ts +138 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -2
- package/dist/chunks/index-BwE_OaV3.js.map +0 -1
package/dist/calver.d.ts
CHANGED
|
@@ -1,9 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Calendar version parsing, formatting, and comparison helpers.
|
|
3
3
|
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Supports the full calver.org specification with all standard tokens:
|
|
6
|
+
* Year (`YYYY`, `YY`, `0Y`), Month (`MM`, `M`, `0M`), Week (`WW`, `0W`),
|
|
7
|
+
* Day (`DD`, `D`, `0D`), and Counter (`MICRO`/`PATCH`).
|
|
8
|
+
*
|
|
9
|
+
* `MICRO` is the CalVer-standard name for the counter segment.
|
|
10
|
+
* `PATCH` is accepted as a SemVer-familiar alias and behaves identically.
|
|
11
|
+
*
|
|
4
12
|
* @packageDocumentation
|
|
5
13
|
*/
|
|
6
|
-
import type { CalVer, CalVerFormat, ValidationResult } from './types';
|
|
14
|
+
import type { CalVer, CalVerFormat, SchemeRules, ValidationResult } from './types';
|
|
15
|
+
/**
|
|
16
|
+
* Validates that a CalVer format string is composed of valid tokens
|
|
17
|
+
* and follows structural rules.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Structural rules enforced:
|
|
21
|
+
* - Must have at least 2 segments
|
|
22
|
+
* - First segment must be a year token
|
|
23
|
+
* - Week tokens and Month/Day tokens are mutually exclusive
|
|
24
|
+
* - Counter (MICRO/PATCH) can only appear as the last segment
|
|
25
|
+
*
|
|
26
|
+
* @param formatStr - Format string to validate.
|
|
27
|
+
* @returns `true` when the format is valid.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { isValidCalVerFormat } from 'versionguard';
|
|
32
|
+
*
|
|
33
|
+
* isValidCalVerFormat('YYYY.MM.MICRO'); // true
|
|
34
|
+
* isValidCalVerFormat('INVALID'); // false
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
* @since 0.3.0
|
|
39
|
+
*/
|
|
40
|
+
export declare function isValidCalVerFormat(formatStr: string): formatStr is CalVerFormat;
|
|
7
41
|
/**
|
|
8
42
|
* Parsed token layout for a supported CalVer format string.
|
|
9
43
|
*
|
|
@@ -15,11 +49,19 @@ export interface ParsedCalVerFormat {
|
|
|
15
49
|
/**
|
|
16
50
|
* Year token captured from the format string.
|
|
17
51
|
*/
|
|
18
|
-
year: 'YYYY' | 'YY';
|
|
52
|
+
year: 'YYYY' | 'YY' | '0Y';
|
|
53
|
+
/**
|
|
54
|
+
* Month token captured from the format string when present.
|
|
55
|
+
*
|
|
56
|
+
* @defaultValue undefined
|
|
57
|
+
*/
|
|
58
|
+
month?: 'MM' | 'M' | '0M';
|
|
19
59
|
/**
|
|
20
|
-
*
|
|
60
|
+
* Week token captured from the format string when present.
|
|
61
|
+
*
|
|
62
|
+
* @defaultValue undefined
|
|
21
63
|
*/
|
|
22
|
-
|
|
64
|
+
week?: 'WW' | '0W';
|
|
23
65
|
/**
|
|
24
66
|
* Day token captured from the format string when present.
|
|
25
67
|
*
|
|
@@ -27,18 +69,19 @@ export interface ParsedCalVerFormat {
|
|
|
27
69
|
*/
|
|
28
70
|
day?: 'DD' | 'D' | '0D';
|
|
29
71
|
/**
|
|
30
|
-
*
|
|
72
|
+
* Counter token captured from the format string when present.
|
|
73
|
+
* Both `MICRO` and `PATCH` map to the same numeric counter.
|
|
31
74
|
*
|
|
32
75
|
* @defaultValue undefined
|
|
33
76
|
*/
|
|
34
|
-
|
|
77
|
+
counter?: 'MICRO' | 'PATCH';
|
|
35
78
|
}
|
|
36
79
|
/**
|
|
37
80
|
* Breaks a CalVer format string into its component tokens.
|
|
38
81
|
*
|
|
39
82
|
* @remarks
|
|
40
83
|
* This helper is used internally by parsing, formatting, and version generation helpers
|
|
41
|
-
* to decide which date parts or
|
|
84
|
+
* to decide which date parts or counters are present in a given CalVer layout.
|
|
42
85
|
*
|
|
43
86
|
* @param calverFormat - Format string to inspect.
|
|
44
87
|
* @returns The parsed token definition for the requested format.
|
|
@@ -47,8 +90,8 @@ export interface ParsedCalVerFormat {
|
|
|
47
90
|
* ```ts
|
|
48
91
|
* import { parseFormat } from 'versionguard';
|
|
49
92
|
*
|
|
50
|
-
* parseFormat('YYYY.MM.
|
|
51
|
-
* // => { year: 'YYYY', month: 'MM',
|
|
93
|
+
* parseFormat('YYYY.MM.MICRO');
|
|
94
|
+
* // => { year: 'YYYY', month: 'MM', counter: 'MICRO' }
|
|
52
95
|
* ```
|
|
53
96
|
*
|
|
54
97
|
* @public
|
|
@@ -92,7 +135,7 @@ export declare function getRegexForFormat(calverFormat: CalVerFormat): RegExp;
|
|
|
92
135
|
* ```ts
|
|
93
136
|
* import { parse } from 'versionguard';
|
|
94
137
|
*
|
|
95
|
-
* parse('2026.
|
|
138
|
+
* parse('2026.3.0', 'YYYY.M.MICRO')?.month;
|
|
96
139
|
* // => 3
|
|
97
140
|
* ```
|
|
98
141
|
*
|
|
@@ -117,14 +160,14 @@ export declare function parse(version: string, calverFormat: CalVerFormat): CalV
|
|
|
117
160
|
* ```ts
|
|
118
161
|
* import { validate } from 'versionguard';
|
|
119
162
|
*
|
|
120
|
-
* validate('2026.
|
|
163
|
+
* validate('2026.3.0', 'YYYY.M.MICRO', false).valid;
|
|
121
164
|
* // => true
|
|
122
165
|
* ```
|
|
123
166
|
*
|
|
124
167
|
* @public
|
|
125
168
|
* @since 0.1.0
|
|
126
169
|
*/
|
|
127
|
-
export declare function validate(version: string, calverFormat: CalVerFormat, preventFutureDates?: boolean): ValidationResult;
|
|
170
|
+
export declare function validate(version: string, calverFormat: CalVerFormat, preventFutureDates?: boolean, schemeRules?: SchemeRules): ValidationResult;
|
|
128
171
|
/**
|
|
129
172
|
* Formats a parsed CalVer object back into a version string.
|
|
130
173
|
*
|
|
@@ -153,8 +196,8 @@ export declare function format(version: CalVer): string;
|
|
|
153
196
|
* Creates the current CalVer string for a format.
|
|
154
197
|
*
|
|
155
198
|
* @remarks
|
|
156
|
-
* This helper derives its values from the provided date and initializes any
|
|
157
|
-
* It is useful for generating a same-day baseline before incrementing
|
|
199
|
+
* This helper derives its values from the provided date and initializes any counter to `0`.
|
|
200
|
+
* It is useful for generating a same-day baseline before incrementing counter-based formats.
|
|
158
201
|
*
|
|
159
202
|
* @param calverFormat - Format to generate.
|
|
160
203
|
* @param now - Date used as the source for year, month, and day values.
|
|
@@ -164,7 +207,7 @@ export declare function format(version: CalVer): string;
|
|
|
164
207
|
* ```ts
|
|
165
208
|
* import { getCurrentVersion } from 'versionguard';
|
|
166
209
|
*
|
|
167
|
-
* getCurrentVersion('YYYY.
|
|
210
|
+
* getCurrentVersion('YYYY.M.MICRO', new Date('2026-03-21T00:00:00Z'));
|
|
168
211
|
* // => '2026.3.0'
|
|
169
212
|
* ```
|
|
170
213
|
*
|
|
@@ -176,8 +219,8 @@ export declare function getCurrentVersion(calverFormat: CalVerFormat, now?: Date
|
|
|
176
219
|
* Compares two CalVer strings using a shared format.
|
|
177
220
|
*
|
|
178
221
|
* @remarks
|
|
179
|
-
* Comparison is performed component-by-component in year, month, day, then
|
|
180
|
-
* Missing day and
|
|
222
|
+
* Comparison is performed component-by-component in year, month, day, then counter order.
|
|
223
|
+
* Missing day and counter values are treated as `0` during comparison.
|
|
181
224
|
*
|
|
182
225
|
* @param a - Left-hand version string.
|
|
183
226
|
* @param b - Right-hand version string.
|
|
@@ -188,7 +231,7 @@ export declare function getCurrentVersion(calverFormat: CalVerFormat, now?: Date
|
|
|
188
231
|
* ```ts
|
|
189
232
|
* import { compare } from 'versionguard';
|
|
190
233
|
*
|
|
191
|
-
* compare('2026.
|
|
234
|
+
* compare('2026.3.2', '2026.3.1', 'YYYY.M.MICRO');
|
|
192
235
|
* // => 1
|
|
193
236
|
* ```
|
|
194
237
|
*
|
|
@@ -200,8 +243,8 @@ export declare function compare(a: string, b: string, calverFormat: CalVerFormat
|
|
|
200
243
|
* Increments a CalVer string.
|
|
201
244
|
*
|
|
202
245
|
* @remarks
|
|
203
|
-
*
|
|
204
|
-
* promoted to a
|
|
246
|
+
* Counter-based formats increment the existing counter. Formats without a counter are
|
|
247
|
+
* promoted to a counter-based output by appending `.MICRO` with an initial value of `0`.
|
|
205
248
|
*
|
|
206
249
|
* @param version - Current version string.
|
|
207
250
|
* @param calverFormat - Format used to parse the current version.
|
|
@@ -211,7 +254,7 @@ export declare function compare(a: string, b: string, calverFormat: CalVerFormat
|
|
|
211
254
|
* ```ts
|
|
212
255
|
* import { increment } from 'versionguard';
|
|
213
256
|
*
|
|
214
|
-
* increment('2026.
|
|
257
|
+
* increment('2026.3.1', 'YYYY.M.MICRO');
|
|
215
258
|
* // => '2026.3.2'
|
|
216
259
|
* ```
|
|
217
260
|
*
|
|
@@ -234,7 +277,7 @@ export declare function increment(version: string, calverFormat: CalVerFormat):
|
|
|
234
277
|
* ```ts
|
|
235
278
|
* import { getNextVersions } from 'versionguard';
|
|
236
279
|
*
|
|
237
|
-
* getNextVersions('2026.
|
|
280
|
+
* getNextVersions('2026.3.1', 'YYYY.M.MICRO').length;
|
|
238
281
|
* // => 2
|
|
239
282
|
* ```
|
|
240
283
|
*
|
package/dist/calver.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calver.d.ts","sourceRoot":"","sources":["../src/calver.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"calver.d.ts","sourceRoot":"","sources":["../src/calver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EAEZ,WAAW,EAEX,gBAAgB,EACjB,MAAM,SAAS,CAAC;AA8BjB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,IAAI,YAAY,CAoBhF;AAED;;;;;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