@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
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TOML-based version source provider for Cargo.toml and pyproject.toml.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { VersionSourceProvider } from './provider';
|
|
7
|
+
/**
|
|
8
|
+
* Reads and writes version strings from TOML manifest files.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Uses targeted regex replacement for writes to preserve file formatting,
|
|
12
|
+
* comments, and whitespace. Supports standard section headers, dotted keys,
|
|
13
|
+
* and inline table syntax.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
* @since 0.3.0
|
|
17
|
+
*/
|
|
18
|
+
export declare class TomlVersionSource implements VersionSourceProvider {
|
|
19
|
+
/** Human-readable provider name. */
|
|
20
|
+
readonly name: string;
|
|
21
|
+
/** Filename of the TOML manifest (e.g. `'Cargo.toml'`). */
|
|
22
|
+
readonly manifestFile: string;
|
|
23
|
+
/** Dotted key path to the version field within the TOML document. */
|
|
24
|
+
private readonly versionPath;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new TOML version source.
|
|
27
|
+
*
|
|
28
|
+
* @param manifestFile - TOML manifest filename.
|
|
29
|
+
* @param versionPath - Dotted key path to the version field.
|
|
30
|
+
*/
|
|
31
|
+
constructor(manifestFile?: string, versionPath?: string);
|
|
32
|
+
/**
|
|
33
|
+
* Returns `true` when the manifest file exists in `cwd`.
|
|
34
|
+
*
|
|
35
|
+
* @param cwd - Project directory to check.
|
|
36
|
+
* @returns Whether the manifest file exists.
|
|
37
|
+
*/
|
|
38
|
+
exists(cwd: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Reads the version string from the TOML manifest.
|
|
41
|
+
*
|
|
42
|
+
* @param cwd - Project directory containing the manifest.
|
|
43
|
+
* @returns The version string extracted from the manifest.
|
|
44
|
+
*/
|
|
45
|
+
getVersion(cwd: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Writes a version string to the TOML manifest, preserving formatting.
|
|
48
|
+
*
|
|
49
|
+
* @param version - Version string to write.
|
|
50
|
+
* @param cwd - Project directory containing the manifest.
|
|
51
|
+
*/
|
|
52
|
+
setVersion(version: string, cwd: string): void;
|
|
53
|
+
/**
|
|
54
|
+
* Splits the dotted version path into a TOML section name and key name.
|
|
55
|
+
*
|
|
56
|
+
* @returns An object with `section` and `key` components.
|
|
57
|
+
*/
|
|
58
|
+
private getSectionKey;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=toml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toml.d.ts","sourceRoot":"","sources":["../../src/sources/toml.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGxD;;;;;;;;;;GAUG;AACH,qBAAa,iBAAkB,YAAW,qBAAqB;IAC7D,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,2DAA2D;IAC3D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B,qEAAqE;IACrE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC;;;;;OAKG;gBACS,YAAY,GAAE,MAAqB,EAAE,WAAW,GAAE,MAA0B;IAMxF;;;;;OAKG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B;;;;;OAKG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAiB/B;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAiB9C;;;;OAIG;IACH,OAAO,CAAC,aAAa;CAUtB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for version source providers.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Traverses a nested object using a dotted key path.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* Walks each segment of the dotted path in order, returning `undefined` as
|
|
11
|
+
* soon as a missing or non-object segment is encountered.
|
|
12
|
+
*
|
|
13
|
+
* @param obj - Object to traverse.
|
|
14
|
+
* @param dotPath - Dot-separated key path (e.g. `'package.version'`).
|
|
15
|
+
* @returns The value at the path, or `undefined` if any segment is missing.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { getNestedValue } from './utils';
|
|
20
|
+
*
|
|
21
|
+
* const obj = { package: { version: '1.0.0' } };
|
|
22
|
+
* const version = getNestedValue(obj, 'package.version'); // '1.0.0'
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
* @since 0.3.0
|
|
27
|
+
*/
|
|
28
|
+
export declare function getNestedValue(obj: Record<string, unknown>, dotPath: string): unknown;
|
|
29
|
+
/**
|
|
30
|
+
* Sets a value at a dotted key path, throwing if intermediate segments are missing.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Traverses each intermediate segment and throws when a segment is missing or
|
|
34
|
+
* not an object. The final key is created or overwritten.
|
|
35
|
+
*
|
|
36
|
+
* @param obj - Object to mutate.
|
|
37
|
+
* @param dotPath - Dot-separated key path.
|
|
38
|
+
* @param value - Value to set at the final key.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { setNestedValue } from './utils';
|
|
43
|
+
*
|
|
44
|
+
* const obj = { package: { version: '1.0.0' } };
|
|
45
|
+
* setNestedValue(obj, 'package.version', '2.0.0');
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
* @since 0.3.0
|
|
50
|
+
*/
|
|
51
|
+
export declare function setNestedValue(obj: Record<string, unknown>, dotPath: string, value: unknown): void;
|
|
52
|
+
/**
|
|
53
|
+
* Escapes special regex characters in a string for safe use in `new RegExp()`.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* Prefixes every character that has special meaning in a regular expression
|
|
57
|
+
* with a backslash so the resulting string matches literally.
|
|
58
|
+
*
|
|
59
|
+
* @param value - Raw string to escape.
|
|
60
|
+
* @returns The escaped string safe for embedding in a `RegExp` constructor.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { escapeRegExp } from './utils';
|
|
65
|
+
*
|
|
66
|
+
* const escaped = escapeRegExp('file.txt'); // 'file\\.txt'
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
70
|
+
* @since 0.3.0
|
|
71
|
+
*/
|
|
72
|
+
export declare function escapeRegExp(value: string): string;
|
|
73
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/sources/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CASrF;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,GACb,IAAI,CAWN;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain text VERSION file provider.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { VersionSourceProvider } from './provider';
|
|
7
|
+
/**
|
|
8
|
+
* Reads and writes version strings from a plain text VERSION file.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* The file is expected to contain only the version string, optionally
|
|
12
|
+
* followed by a trailing newline. Binary files and empty files are
|
|
13
|
+
* rejected with a descriptive error.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
* @since 0.3.0
|
|
17
|
+
*/
|
|
18
|
+
export declare class VersionFileSource implements VersionSourceProvider {
|
|
19
|
+
/** Human-readable provider name. */
|
|
20
|
+
readonly name: string;
|
|
21
|
+
/** Filename of the version file (e.g. `'VERSION'`). */
|
|
22
|
+
readonly manifestFile: string;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new plain text version file source.
|
|
25
|
+
*
|
|
26
|
+
* @param manifestFile - Version filename.
|
|
27
|
+
*/
|
|
28
|
+
constructor(manifestFile?: string);
|
|
29
|
+
/**
|
|
30
|
+
* Returns `true` when the version file exists in `cwd`.
|
|
31
|
+
*
|
|
32
|
+
* @param cwd - Project directory to check.
|
|
33
|
+
* @returns Whether the version file exists.
|
|
34
|
+
*/
|
|
35
|
+
exists(cwd: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Reads the version string from the plain text version file.
|
|
38
|
+
*
|
|
39
|
+
* @param cwd - Project directory containing the version file.
|
|
40
|
+
* @returns The version string from the first line of the file.
|
|
41
|
+
*/
|
|
42
|
+
getVersion(cwd: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Writes a version string to the plain text version file.
|
|
45
|
+
*
|
|
46
|
+
* @param version - Version string to write.
|
|
47
|
+
* @param cwd - Project directory containing the version file.
|
|
48
|
+
*/
|
|
49
|
+
setVersion(version: string, cwd: string): void;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=version-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-file.d.ts","sourceRoot":"","sources":["../../src/sources/version-file.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;;;;;;;;;GAUG;AACH,qBAAa,iBAAkB,YAAW,qBAAqB;IAC7D,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,uDAAuD;IACvD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B;;;;OAIG;gBACS,YAAY,GAAE,MAAkB;IAK5C;;;;;OAKG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B;;;;;OAKG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAsB/B;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;CAO/C"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YAML-based version source provider for pubspec.yaml and similar manifests.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { VersionSourceProvider } from './provider';
|
|
7
|
+
/**
|
|
8
|
+
* Reads and writes version strings from YAML manifest files.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Supports dotted key paths (e.g. `'flutter.version'`) for nested values.
|
|
12
|
+
* Uses targeted regex replacement for writes to preserve comments and formatting.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
* @since 0.3.0
|
|
16
|
+
*/
|
|
17
|
+
export declare class YamlVersionSource implements VersionSourceProvider {
|
|
18
|
+
/** Human-readable provider name. */
|
|
19
|
+
readonly name: string;
|
|
20
|
+
/** Filename of the YAML manifest (e.g. `'pubspec.yaml'`). */
|
|
21
|
+
readonly manifestFile: string;
|
|
22
|
+
/** Dotted key path to the version field within the YAML document. */
|
|
23
|
+
private readonly versionKey;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new YAML version source.
|
|
26
|
+
*
|
|
27
|
+
* @param manifestFile - YAML manifest filename.
|
|
28
|
+
* @param versionKey - Dotted key path to the version field.
|
|
29
|
+
*/
|
|
30
|
+
constructor(manifestFile?: string, versionKey?: string);
|
|
31
|
+
/**
|
|
32
|
+
* Returns `true` when the manifest file exists in `cwd`.
|
|
33
|
+
*
|
|
34
|
+
* @param cwd - Project directory to check.
|
|
35
|
+
* @returns Whether the manifest file exists.
|
|
36
|
+
*/
|
|
37
|
+
exists(cwd: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Reads the version string from the YAML manifest.
|
|
40
|
+
*
|
|
41
|
+
* @param cwd - Project directory containing the manifest.
|
|
42
|
+
* @returns The version string extracted from the manifest.
|
|
43
|
+
*/
|
|
44
|
+
getVersion(cwd: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Writes a version string to the YAML manifest, preserving formatting.
|
|
47
|
+
*
|
|
48
|
+
* @param version - Version string to write.
|
|
49
|
+
* @param cwd - Project directory containing the manifest.
|
|
50
|
+
*/
|
|
51
|
+
setVersion(version: string, cwd: string): void;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=yaml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../src/sources/yaml.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGxD;;;;;;;;;GASG;AACH,qBAAa,iBAAkB,YAAW,qBAAqB;IAC7D,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,6DAA6D;IAC7D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B,qEAAqE;IACrE,OAAO,C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,wBAAgB,aAAa,CAC3B,MAAM,EAAE,kBAAkB,EAC1B,GAAG,GAAE,MAAsB,GAC1B;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAwD1D;AA8DD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,MAAsB,GAC1B;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CA6BnD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,GAAE,MAAsB,GAAG,MAAM,CAwBtF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -12,13 +12,99 @@
|
|
|
12
12
|
*/
|
|
13
13
|
export type VersioningType = 'semver' | 'calver';
|
|
14
14
|
/**
|
|
15
|
-
* Supported
|
|
15
|
+
* Supported manifest source types for version extraction.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
* @since 0.3.0
|
|
19
|
+
* @forgeIgnore E020
|
|
20
|
+
*/
|
|
21
|
+
export type ManifestSourceType = 'auto' | 'package.json' | 'composer.json' | 'Cargo.toml' | 'pyproject.toml' | 'pubspec.yaml' | 'pom.xml' | 'VERSION' | 'git-tag' | 'custom';
|
|
22
|
+
/**
|
|
23
|
+
* Configures the version source manifest.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
* @since 0.3.0
|
|
27
|
+
* @forgeIgnore E020
|
|
28
|
+
*/
|
|
29
|
+
export interface ManifestConfig {
|
|
30
|
+
/**
|
|
31
|
+
* Manifest file to read the version from.
|
|
32
|
+
*
|
|
33
|
+
* Use `'auto'` for file-existence detection or a specific filename.
|
|
34
|
+
*
|
|
35
|
+
* @defaultValue 'auto'
|
|
36
|
+
*/
|
|
37
|
+
source: ManifestSourceType;
|
|
38
|
+
/**
|
|
39
|
+
* Dotted key path to the version field within the manifest.
|
|
40
|
+
*
|
|
41
|
+
* For example `'version'` for package.json, `'package.version'` for Cargo.toml,
|
|
42
|
+
* or `'project.version'` for pyproject.toml.
|
|
43
|
+
*
|
|
44
|
+
* @defaultValue undefined (uses the provider's built-in default)
|
|
45
|
+
*/
|
|
46
|
+
path?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Regex pattern to extract the version from source-code manifests.
|
|
49
|
+
*
|
|
50
|
+
* Capture group 1 must contain the version string.
|
|
51
|
+
*
|
|
52
|
+
* @defaultValue undefined
|
|
53
|
+
*/
|
|
54
|
+
regex?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Valid CalVer token names for building format strings.
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
* @since 0.3.0
|
|
61
|
+
* @forgeIgnore E020
|
|
62
|
+
*/
|
|
63
|
+
export type CalVerToken = 'YYYY' | 'YY' | '0Y' | 'MM' | 'M' | '0M' | 'WW' | '0W' | 'DD' | 'D' | '0D' | 'MICRO' | 'PATCH';
|
|
64
|
+
/**
|
|
65
|
+
* A CalVer format string composed of dot-separated tokens.
|
|
66
|
+
*
|
|
67
|
+
* @remarks
|
|
68
|
+
* Any dot-separated combination of valid {@link CalVerToken} values is accepted.
|
|
69
|
+
* Common examples: `'YYYY.MM.MICRO'`, `'YY.0M.MICRO'`, `'YYYY.0M.0D'`, `'YYYY.MM.DD.MICRO'`.
|
|
70
|
+
*
|
|
71
|
+
* `MICRO` and `PATCH` are interchangeable — both represent a 0-based incrementing counter.
|
|
72
|
+
* The CalVer specification (calver.org) uses `MICRO`; `PATCH` is accepted as a SemVer-familiar alias.
|
|
16
73
|
*
|
|
17
74
|
* @public
|
|
18
75
|
* @since 0.1.0
|
|
19
76
|
* @forgeIgnore E020
|
|
20
77
|
*/
|
|
21
|
-
export type CalVerFormat =
|
|
78
|
+
export type CalVerFormat = string & {
|
|
79
|
+
readonly __calverFormat?: never;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Configures scheme-level validation rules applied regardless of versioning type.
|
|
83
|
+
*
|
|
84
|
+
* @public
|
|
85
|
+
* @since 0.3.0
|
|
86
|
+
* @forgeIgnore E020
|
|
87
|
+
*/
|
|
88
|
+
export interface SchemeRules {
|
|
89
|
+
/**
|
|
90
|
+
* Maximum number of numeric segments before a warning is emitted.
|
|
91
|
+
*
|
|
92
|
+
* Convention is 3 (e.g., `YYYY.MM.MICRO`). Formats with 4+ segments
|
|
93
|
+
* (e.g., `YYYY.0M.0D.MICRO`) are valid but trigger a warning.
|
|
94
|
+
*
|
|
95
|
+
* @defaultValue 3
|
|
96
|
+
*/
|
|
97
|
+
maxNumericSegments: number;
|
|
98
|
+
/**
|
|
99
|
+
* Allowed pre-release modifier tags.
|
|
100
|
+
*
|
|
101
|
+
* When set, version modifiers (e.g., `-alpha`, `-rc1`) are validated
|
|
102
|
+
* against this whitelist. An empty array disallows all modifiers.
|
|
103
|
+
*
|
|
104
|
+
* @defaultValue ['dev', 'alpha', 'beta', 'rc']
|
|
105
|
+
*/
|
|
106
|
+
allowedModifiers: string[];
|
|
107
|
+
}
|
|
22
108
|
/**
|
|
23
109
|
* Configures CalVer validation rules.
|
|
24
110
|
*
|
|
@@ -37,6 +123,12 @@ export interface CalVerConfig {
|
|
|
37
123
|
* @defaultValue true
|
|
38
124
|
*/
|
|
39
125
|
preventFutureDates: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Enforces that week tokens (WW/0W) cannot be mixed with month/day tokens.
|
|
128
|
+
*
|
|
129
|
+
* @defaultValue true
|
|
130
|
+
*/
|
|
131
|
+
strictMutualExclusion?: boolean;
|
|
40
132
|
}
|
|
41
133
|
/**
|
|
42
134
|
* Describes a search-and-replace pattern used during version synchronization.
|
|
@@ -161,6 +253,12 @@ export interface VersioningConfig {
|
|
|
161
253
|
* Versioning strategy used for the project.
|
|
162
254
|
*/
|
|
163
255
|
type: VersioningType;
|
|
256
|
+
/**
|
|
257
|
+
* Scheme-level validation rules applied regardless of versioning type.
|
|
258
|
+
*
|
|
259
|
+
* @defaultValue `{ maxNumericSegments: 3, allowedModifiers: ['dev', 'alpha', 'beta', 'rc'] }`
|
|
260
|
+
*/
|
|
261
|
+
schemeRules?: SchemeRules;
|
|
164
262
|
/**
|
|
165
263
|
* CalVer-specific settings when `type` is `'calver'`.
|
|
166
264
|
*
|
|
@@ -180,6 +278,12 @@ export interface VersionGuardConfig {
|
|
|
180
278
|
* Active versioning settings.
|
|
181
279
|
*/
|
|
182
280
|
versioning: VersioningConfig;
|
|
281
|
+
/**
|
|
282
|
+
* Version source manifest settings.
|
|
283
|
+
*
|
|
284
|
+
* @defaultValue `{ source: 'auto' }`
|
|
285
|
+
*/
|
|
286
|
+
manifest: ManifestConfig;
|
|
183
287
|
/**
|
|
184
288
|
* Synchronization settings for mirrored version strings.
|
|
185
289
|
*/
|
|
@@ -197,6 +301,29 @@ export interface VersionGuardConfig {
|
|
|
197
301
|
*/
|
|
198
302
|
ignore: string[];
|
|
199
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Extracts the CalVer config from a VersionGuard config, throwing if missing.
|
|
306
|
+
*
|
|
307
|
+
* @remarks
|
|
308
|
+
* This is a convenience helper that validates the `calver` block exists
|
|
309
|
+
* before returning it. Use this instead of accessing `config.versioning.calver`
|
|
310
|
+
* directly to get a clear error when the config is misconfigured.
|
|
311
|
+
*
|
|
312
|
+
* @param config - The full VersionGuard configuration object.
|
|
313
|
+
* @returns The validated CalVer configuration.
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* ```ts
|
|
317
|
+
* import { getCalVerConfig } from './types';
|
|
318
|
+
*
|
|
319
|
+
* const calver = getCalVerConfig(config);
|
|
320
|
+
* console.log(calver.format); // 'YYYY.MM.DD'
|
|
321
|
+
* ```
|
|
322
|
+
*
|
|
323
|
+
* @public
|
|
324
|
+
* @since 0.3.0
|
|
325
|
+
*/
|
|
326
|
+
export declare function getCalVerConfig(config: VersionGuardConfig): CalVerConfig;
|
|
200
327
|
/**
|
|
201
328
|
* Parsed semantic version components.
|
|
202
329
|
*
|
|
@@ -247,7 +374,7 @@ export interface CalVer {
|
|
|
247
374
|
*/
|
|
248
375
|
year: number;
|
|
249
376
|
/**
|
|
250
|
-
* Month value
|
|
377
|
+
* Month or week value (1-12 for months, 1-53 for weeks).
|
|
251
378
|
*/
|
|
252
379
|
month: number;
|
|
253
380
|
/**
|
|
@@ -257,11 +384,17 @@ export interface CalVer {
|
|
|
257
384
|
*/
|
|
258
385
|
day?: number;
|
|
259
386
|
/**
|
|
260
|
-
*
|
|
387
|
+
* Micro/patch counter when the selected format includes a counter token.
|
|
261
388
|
*
|
|
262
389
|
* @defaultValue undefined
|
|
263
390
|
*/
|
|
264
391
|
patch?: number;
|
|
392
|
+
/**
|
|
393
|
+
* Pre-release modifier string (e.g., `'alpha'`, `'rc1'`, `'dev'`).
|
|
394
|
+
*
|
|
395
|
+
* @defaultValue undefined
|
|
396
|
+
*/
|
|
397
|
+
modifier?: string;
|
|
265
398
|
/**
|
|
266
399
|
* Source format used to interpret the raw string.
|
|
267
400
|
*/
|
|
@@ -475,7 +608,7 @@ export interface DoctorReport {
|
|
|
475
608
|
*/
|
|
476
609
|
ready: boolean;
|
|
477
610
|
/**
|
|
478
|
-
* Package version resolved from
|
|
611
|
+
* Package version resolved from the configured manifest source.
|
|
479
612
|
*/
|
|
480
613
|
version: string;
|
|
481
614
|
/**
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,MAAM,
|
|
1
|
+
{"version":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GAOG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codluv/versionguard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Strict versioning enforcement for SemVer and CalVer with git hooks, changelog validation, and file sync from package.json",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -64,10 +64,12 @@
|
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
+
"@clack/prompts": "^1.1.0",
|
|
67
68
|
"chalk": "^5.6.2",
|
|
68
69
|
"commander": "^12.0.0",
|
|
69
70
|
"glob": "^10.3.0",
|
|
70
|
-
"js-yaml": "^4.1.0"
|
|
71
|
+
"js-yaml": "^4.1.0",
|
|
72
|
+
"smol-toml": "^1.6.1"
|
|
71
73
|
},
|
|
72
74
|
"devDependencies": {
|
|
73
75
|
"@biomejs/biome": "^2.2.4",
|