@codluv/versionguard 0.3.0 → 0.5.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 +66 -22
- package/dist/calver.d.ts.map +1 -1
- package/dist/changelog.d.ts +52 -0
- package/dist/changelog.d.ts.map +1 -1
- package/dist/chunks/{index-BrZJDWya.js → index-CwOyEn5L.js} +904 -176
- package/dist/chunks/index-CwOyEn5L.js.map +1 -0
- package/dist/ckm/engine.d.ts +92 -0
- package/dist/ckm/engine.d.ts.map +1 -0
- package/dist/ckm/index.d.ts +32 -0
- package/dist/ckm/index.d.ts.map +1 -0
- package/dist/ckm/types.d.ts +168 -0
- package/dist/ckm/types.d.ts.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1333 -27
- 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 +6 -1
- 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 +14 -7
- package/dist/hooks.d.ts.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -32
- package/dist/init-wizard.d.ts +68 -0
- package/dist/init-wizard.d.ts.map +1 -0
- package/dist/project-root.d.ts +74 -0
- package/dist/project-root.d.ts.map +1 -0
- package/dist/project.d.ts +23 -2
- package/dist/project.d.ts.map +1 -1
- package/dist/sources/git-tag.d.ts +29 -0
- package/dist/sources/git-tag.d.ts.map +1 -1
- package/dist/sources/json.d.ts +31 -0
- package/dist/sources/json.d.ts.map +1 -1
- package/dist/sources/regex.d.ts +30 -0
- package/dist/sources/regex.d.ts.map +1 -1
- package/dist/sources/resolve.d.ts +27 -8
- package/dist/sources/resolve.d.ts.map +1 -1
- package/dist/sources/toml.d.ts +36 -1
- package/dist/sources/toml.d.ts.map +1 -1
- package/dist/sources/utils.d.ts +73 -0
- package/dist/sources/utils.d.ts.map +1 -0
- package/dist/sources/version-file.d.ts +28 -1
- package/dist/sources/version-file.d.ts.map +1 -1
- package/dist/sources/yaml.d.ts +29 -0
- package/dist/sources/yaml.d.ts.map +1 -1
- package/dist/tag/index.d.ts.map +1 -1
- package/dist/types.d.ts +89 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/chunks/index-BrZJDWya.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "node:child_process";
|
|
2
2
|
import "node:path";
|
|
3
|
-
import { G, J, R, T, V, Y,
|
|
3
|
+
import { G, J, R, T, V, Y, q, x, y, z, A, B, C, D, c, p, E, j, t, k, F, m, H, n, w, I, K, f, g, L, b, e, M, d, N, h, O, a, l, P, r, Q, s, S, U, W, u, v, X, Z, _ } from "./chunks/index-CwOyEn5L.js";
|
|
4
4
|
export {
|
|
5
5
|
G as GitTagSource,
|
|
6
6
|
J as JsonVersionSource,
|
|
@@ -8,44 +8,50 @@ export {
|
|
|
8
8
|
T as TomlVersionSource,
|
|
9
9
|
V as VersionFileSource,
|
|
10
10
|
Y as YamlVersionSource,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
j as
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
11
|
+
q as areHooksInstalled,
|
|
12
|
+
x as calver,
|
|
13
|
+
y as canBump,
|
|
14
|
+
z as checkEnforceHooksPolicy,
|
|
15
|
+
A as checkHardcodedVersions,
|
|
16
|
+
B as checkHookIntegrity,
|
|
17
|
+
C as checkHooksPathOverride,
|
|
18
|
+
D as checkHuskyBypass,
|
|
19
|
+
c as createCkmEngine,
|
|
20
|
+
p as createTag,
|
|
21
|
+
E as detectManifests,
|
|
22
|
+
j as doctor,
|
|
23
|
+
t as findProjectRoot,
|
|
24
|
+
k as fixAll,
|
|
25
|
+
F as fixChangelog,
|
|
26
|
+
m as fixChangesetMangling,
|
|
27
|
+
H as fixPackageVersion,
|
|
28
|
+
n as fixSyncIssues,
|
|
29
|
+
w as formatNotProjectError,
|
|
30
|
+
I as getAllTags,
|
|
31
|
+
K as getCalVerConfig,
|
|
32
|
+
f as getChangelogFeedback,
|
|
28
33
|
g as getConfig,
|
|
29
|
-
|
|
34
|
+
L as getLatestTag,
|
|
30
35
|
b as getPackageVersion,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
e as getSyncFeedback,
|
|
37
|
+
M as getTagFeedback,
|
|
38
|
+
d as getVersionFeedback,
|
|
39
|
+
N as getVersionSource,
|
|
35
40
|
h as handlePostTag,
|
|
36
|
-
|
|
41
|
+
O as initConfig,
|
|
37
42
|
a as installHooks,
|
|
38
|
-
|
|
43
|
+
l as isChangesetMangled,
|
|
44
|
+
P as resolveVersionSource,
|
|
39
45
|
r as runGuardChecks,
|
|
40
|
-
|
|
46
|
+
Q as semver,
|
|
41
47
|
s as suggestNextVersion,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
S as suggestTagMessage,
|
|
49
|
+
U as sync,
|
|
50
|
+
W as syncVersion,
|
|
45
51
|
u as uninstallHooks,
|
|
46
52
|
v as validate,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
X as validateChangelog,
|
|
54
|
+
Z as validateTagForPush,
|
|
55
|
+
_ as validateVersion
|
|
50
56
|
};
|
|
51
57
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive setup wizard and headless init for VersionGuard.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Options for headless (non-interactive) initialization.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
* @since 0.3.0
|
|
11
|
+
*/
|
|
12
|
+
export interface InitOptions {
|
|
13
|
+
/** Working directory path. */
|
|
14
|
+
cwd: string;
|
|
15
|
+
/** Versioning type (semver or calver). */
|
|
16
|
+
type?: 'semver' | 'calver';
|
|
17
|
+
/** CalVer format string. */
|
|
18
|
+
format?: string;
|
|
19
|
+
/** Manifest source type. */
|
|
20
|
+
manifest?: string;
|
|
21
|
+
/** Whether to install git hooks. */
|
|
22
|
+
hooks?: boolean;
|
|
23
|
+
/** Whether to enable changelog validation. */
|
|
24
|
+
changelog?: boolean;
|
|
25
|
+
/** Accept defaults without prompting. */
|
|
26
|
+
yes?: boolean;
|
|
27
|
+
/** Overwrite existing config. */
|
|
28
|
+
force?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Runs the interactive setup wizard.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* Walks the user through versioning type, CalVer format, manifest source,
|
|
35
|
+
* git hooks, and changelog configuration. Writes `.versionguard.yml` when done.
|
|
36
|
+
*
|
|
37
|
+
* @param cwd - Project directory to initialize.
|
|
38
|
+
* @returns The path to the created config file, or `null` if cancelled.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const configPath = await runWizard(process.cwd());
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
* @since 0.3.0
|
|
47
|
+
*/
|
|
48
|
+
export declare function runWizard(cwd: string): Promise<string | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Initializes VersionGuard non-interactively using CLI flags.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* When `--yes` is passed, all defaults are used without prompting.
|
|
54
|
+
* Individual flags override specific defaults.
|
|
55
|
+
*
|
|
56
|
+
* @param options - Headless initialization options.
|
|
57
|
+
* @returns The path to the created config file.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const configPath = runHeadless({ cwd: process.cwd(), type: 'calver', format: 'YYYY.M.MICRO' });
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @public
|
|
65
|
+
* @since 0.3.0
|
|
66
|
+
*/
|
|
67
|
+
export declare function runHeadless(options: InitOptions): string;
|
|
68
|
+
//# sourceMappingURL=init-wizard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-wizard.d.ts","sourceRoot":"","sources":["../src/init-wizard.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,0CAA0C;IAC1C,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC3B,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yCAAyC;IACzC,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,iCAAiC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA+EnE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAiBxD"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project root detection and boundary validation.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Result of project root detection.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
* @since 0.4.0
|
|
11
|
+
*/
|
|
12
|
+
export interface ProjectRootResult {
|
|
13
|
+
/** Whether a project root was found. */
|
|
14
|
+
found: boolean;
|
|
15
|
+
/** The resolved project root directory, or the original cwd if not found. */
|
|
16
|
+
root: string;
|
|
17
|
+
/** Which marker file was found. */
|
|
18
|
+
marker?: string;
|
|
19
|
+
/** Whether the directory has a VersionGuard config. */
|
|
20
|
+
hasConfig: boolean;
|
|
21
|
+
/** Whether the directory is inside a git repository. */
|
|
22
|
+
hasGit: boolean;
|
|
23
|
+
/** Whether a version manifest file exists. */
|
|
24
|
+
hasManifest: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Walks up from `startDir` to find the nearest project root.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* Checks for VersionGuard config files first, then `.git`, then manifest files.
|
|
31
|
+
* Stops at the filesystem root if nothing is found.
|
|
32
|
+
*
|
|
33
|
+
* @param startDir - Directory to start searching from.
|
|
34
|
+
* @returns Detection result with the project root path and what was found.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { findProjectRoot } from 'versionguard';
|
|
39
|
+
*
|
|
40
|
+
* const result = findProjectRoot(process.cwd());
|
|
41
|
+
* if (!result.found) {
|
|
42
|
+
* console.log('Not in a project directory');
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @public
|
|
47
|
+
* @since 0.4.0
|
|
48
|
+
*/
|
|
49
|
+
export declare function findProjectRoot(startDir: string): ProjectRootResult;
|
|
50
|
+
/**
|
|
51
|
+
* Formats a helpful error message when a command can't find a project.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* The message includes actionable hints such as running `versionguard init` or
|
|
55
|
+
* changing to a project root directory. Useful for CLI commands that require a
|
|
56
|
+
* VersionGuard-enabled project.
|
|
57
|
+
*
|
|
58
|
+
* @param cwd - The directory that was checked.
|
|
59
|
+
* @param command - The command that was attempted.
|
|
60
|
+
* @returns A formatted, helpful error message.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { formatNotProjectError } from 'versionguard';
|
|
65
|
+
*
|
|
66
|
+
* const msg = formatNotProjectError('/tmp/empty', 'validate');
|
|
67
|
+
* console.error(msg);
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @public
|
|
71
|
+
* @since 0.4.0
|
|
72
|
+
*/
|
|
73
|
+
export declare function formatNotProjectError(cwd: string, command: string): string;
|
|
74
|
+
//# sourceMappingURL=project-root.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-root.d.ts","sourceRoot":"","sources":["../src/project-root.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwBH;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,wCAAwC;IACxC,KAAK,EAAE,OAAO,CAAC;IACf,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,SAAS,EAAE,OAAO,CAAC;IACnB,wDAAwD;IACxD,MAAM,EAAE,OAAO,CAAC;IAChB,8CAA8C;IAC9C,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAkCnE;AA2BD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAe1E"}
|
package/dist/project.d.ts
CHANGED
|
@@ -125,7 +125,11 @@ export declare function writePackageJson(pkg: PackageJson, cwd?: string): void;
|
|
|
125
125
|
* ```ts
|
|
126
126
|
* import { getPackageVersion } from 'versionguard';
|
|
127
127
|
*
|
|
128
|
+
* // Read from package.json (legacy fallback)
|
|
128
129
|
* const version = getPackageVersion(process.cwd());
|
|
130
|
+
*
|
|
131
|
+
* // Read from a configured manifest source
|
|
132
|
+
* const versionAlt = getPackageVersion(process.cwd(), { source: 'Cargo.toml' });
|
|
129
133
|
* ```
|
|
130
134
|
*/
|
|
131
135
|
export declare function getPackageVersion(cwd?: string, manifest?: ManifestConfig): string;
|
|
@@ -149,19 +153,36 @@ export declare function getPackageVersion(cwd?: string, manifest?: ManifestConfi
|
|
|
149
153
|
* ```ts
|
|
150
154
|
* import { setPackageVersion } from 'versionguard';
|
|
151
155
|
*
|
|
156
|
+
* // Write to package.json (legacy fallback)
|
|
152
157
|
* setPackageVersion('1.2.3', process.cwd());
|
|
158
|
+
*
|
|
159
|
+
* // Write to a configured manifest source
|
|
160
|
+
* setPackageVersion('1.2.3', process.cwd(), { source: 'Cargo.toml' });
|
|
153
161
|
* ```
|
|
154
162
|
*/
|
|
155
163
|
export declare function setPackageVersion(version: string, cwd?: string, manifest?: ManifestConfig): void;
|
|
156
164
|
/**
|
|
157
165
|
* Resolves the version source provider for a project.
|
|
158
166
|
*
|
|
159
|
-
* @
|
|
160
|
-
*
|
|
167
|
+
* @remarks
|
|
168
|
+
* Delegates to `resolveVersionSource` to create the appropriate provider
|
|
169
|
+
* for the configured manifest type. Use this when you need direct access
|
|
170
|
+
* to the provider's `exists`, `getVersion`, and `setVersion` methods.
|
|
161
171
|
*
|
|
162
172
|
* @param manifest - Manifest configuration.
|
|
163
173
|
* @param cwd - Project directory.
|
|
164
174
|
* @returns The resolved provider instance.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* import { getVersionSource } from 'versionguard';
|
|
179
|
+
*
|
|
180
|
+
* const source = getVersionSource({ source: 'package.json' }, process.cwd());
|
|
181
|
+
* const version = source.getVersion(process.cwd());
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* @public
|
|
185
|
+
* @since 0.3.0
|
|
165
186
|
*/
|
|
166
187
|
export declare function getVersionSource(manifest: ManifestConfig, cwd?: string): VersionSourceProvider;
|
|
167
188
|
//# sourceMappingURL=project.d.ts.map
|
package/dist/project.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GACxB,OAAO,GACP,IAAI,GACJ,MAAM,GACN,MAAM,GACN,gBAAgB,GAChB,iBAAiB,CAAC;AAEtB;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACjC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,GAAE,MAAsB,GAAG,MAAM,CAEtE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAsB,GAAG,WAAW,CAQxE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,GAAE,MAAsB,GAAG,IAAI,CAEpF;AAED
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GACxB,OAAO,GACP,IAAI,GACJ,MAAM,GACN,MAAM,GACN,gBAAgB,GAChB,iBAAiB,CAAC;AAEtB;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACjC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,GAAE,MAAsB,GAAG,MAAM,CAEtE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAsB,GAAG,WAAW,CAQxE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,GAAE,MAAsB,GAAG,IAAI,CAEpF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAsB,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,MAAM,CAchG;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,MAAsB,EAC3B,QAAQ,CAAC,EAAE,cAAc,GACxB,IAAI,CAWN;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,cAAc,EACxB,GAAG,GAAE,MAAsB,GAC1B,qBAAqB,CAEvB"}
|
|
@@ -7,17 +7,46 @@ import type { VersionSourceProvider } from './provider';
|
|
|
7
7
|
/**
|
|
8
8
|
* Reads version from the latest Git tag. Writing creates a new annotated tag.
|
|
9
9
|
*
|
|
10
|
+
* @remarks
|
|
10
11
|
* This provider is used for languages where the version is determined
|
|
11
12
|
* entirely by Git tags (Go, Swift, PHP/Packagist).
|
|
12
13
|
*
|
|
14
|
+
* The tag prefix (`v` by default) is auto-detected from existing tags
|
|
15
|
+
* when writing, so projects using unprefixed tags (e.g. `1.0.0`) stay
|
|
16
|
+
* consistent.
|
|
17
|
+
*
|
|
13
18
|
* @public
|
|
14
19
|
* @since 0.3.0
|
|
15
20
|
*/
|
|
16
21
|
export declare class GitTagSource implements VersionSourceProvider {
|
|
22
|
+
/** Human-readable provider name. */
|
|
17
23
|
readonly name = "git-tag";
|
|
24
|
+
/** Empty string since git-tag has no manifest file. */
|
|
18
25
|
readonly manifestFile = "";
|
|
26
|
+
/**
|
|
27
|
+
* Returns `true` when `cwd` is inside a Git repository.
|
|
28
|
+
*
|
|
29
|
+
* @param cwd - Project directory to check.
|
|
30
|
+
* @returns Whether a Git repository is found.
|
|
31
|
+
*/
|
|
19
32
|
exists(cwd: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Reads the version string from the latest Git tag.
|
|
35
|
+
*
|
|
36
|
+
* @param cwd - Project directory containing the Git repository.
|
|
37
|
+
* @returns The version string extracted from the latest version tag.
|
|
38
|
+
*/
|
|
20
39
|
getVersion(cwd: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new annotated Git tag for the given version.
|
|
42
|
+
*
|
|
43
|
+
* @param version - Version string to tag.
|
|
44
|
+
* @param cwd - Project directory containing the Git repository.
|
|
45
|
+
*/
|
|
21
46
|
setVersion(version: string, cwd: string): void;
|
|
47
|
+
/** Try version-like tag patterns, fall back to any tag. */
|
|
48
|
+
private describeVersionTag;
|
|
49
|
+
/** Detect whether existing tags use a `v` prefix or not. */
|
|
50
|
+
private detectPrefix;
|
|
22
51
|
}
|
|
23
52
|
//# sourceMappingURL=git-tag.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-tag.d.ts","sourceRoot":"","sources":["../../src/sources/git-tag.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD
|
|
1
|
+
{"version":3,"file":"git-tag.d.ts","sourceRoot":"","sources":["../../src/sources/git-tag.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,qBAAa,YAAa,YAAW,qBAAqB;IACxD,oCAAoC;IACpC,QAAQ,CAAC,IAAI,aAAa;IAE1B,uDAAuD;IACvD,QAAQ,CAAC,YAAY,MAAM;IAE3B;;;;;OAKG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAY5B;;;;;OAKG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAU/B;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAU9C,2DAA2D;IAC3D,OAAO,CAAC,kBAAkB;IAwB1B,4DAA4D;IAC5D,OAAO,CAAC,YAAY;CASrB"}
|
package/dist/sources/json.d.ts
CHANGED
|
@@ -7,16 +7,47 @@ import type { VersionSourceProvider } from './provider';
|
|
|
7
7
|
/**
|
|
8
8
|
* Reads and writes version strings from JSON manifest files.
|
|
9
9
|
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Supports dotted key paths for nested version fields and preserves the
|
|
12
|
+
* original indentation style when writing back to disk.
|
|
13
|
+
*
|
|
10
14
|
* @public
|
|
11
15
|
* @since 0.3.0
|
|
12
16
|
*/
|
|
13
17
|
export declare class JsonVersionSource implements VersionSourceProvider {
|
|
18
|
+
/** Human-readable provider name. */
|
|
14
19
|
readonly name: string;
|
|
20
|
+
/** Filename of the JSON manifest (e.g. `'package.json'`). */
|
|
15
21
|
readonly manifestFile: string;
|
|
22
|
+
/** Dotted key path to the version field within the JSON document. */
|
|
16
23
|
private readonly versionPath;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new JSON version source.
|
|
26
|
+
*
|
|
27
|
+
* @param manifestFile - JSON manifest filename.
|
|
28
|
+
* @param versionPath - Dotted key path to the version field.
|
|
29
|
+
*/
|
|
17
30
|
constructor(manifestFile?: string, versionPath?: 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
|
+
*/
|
|
18
37
|
exists(cwd: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Reads the version string from the JSON manifest.
|
|
40
|
+
*
|
|
41
|
+
* @param cwd - Project directory containing the manifest.
|
|
42
|
+
* @returns The version string extracted from the manifest.
|
|
43
|
+
*/
|
|
19
44
|
getVersion(cwd: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Writes a version string to the JSON manifest, preserving indentation.
|
|
47
|
+
*
|
|
48
|
+
* @param version - Version string to write.
|
|
49
|
+
* @param cwd - Project directory containing the manifest.
|
|
50
|
+
*/
|
|
20
51
|
setVersion(version: string, cwd: string): void;
|
|
21
52
|
}
|
|
22
53
|
//# sourceMappingURL=json.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/sources/json.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/sources/json.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,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,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC;;;;;OAKG;gBACS,YAAY,GAAE,MAAuB,EAAE,WAAW,GAAE,MAAkB;IAMlF;;;;;OAKG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B;;;;;OAKG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAgB/B;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;CAe/C"}
|
package/dist/sources/regex.d.ts
CHANGED
|
@@ -9,18 +9,48 @@ import type { VersionSourceProvider } from './provider';
|
|
|
9
9
|
/**
|
|
10
10
|
* Reads and writes version strings using regex extraction from source files.
|
|
11
11
|
*
|
|
12
|
+
* @remarks
|
|
12
13
|
* Capture group 1 of the provided regex must match the version string.
|
|
14
|
+
* Uses position-based replacement to avoid wrong-match corruption when
|
|
15
|
+
* writing back to disk.
|
|
13
16
|
*
|
|
14
17
|
* @public
|
|
15
18
|
* @since 0.3.0
|
|
16
19
|
*/
|
|
17
20
|
export declare class RegexVersionSource implements VersionSourceProvider {
|
|
21
|
+
/** Human-readable provider name. */
|
|
18
22
|
readonly name: string;
|
|
23
|
+
/** Filename of the source manifest (e.g. `'setup.py'`). */
|
|
19
24
|
readonly manifestFile: string;
|
|
25
|
+
/** Compiled regex used to locate the version string. */
|
|
20
26
|
private readonly versionRegex;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new regex version source.
|
|
29
|
+
*
|
|
30
|
+
* @param manifestFile - Source manifest filename.
|
|
31
|
+
* @param versionRegex - Regex string with at least one capture group for the version.
|
|
32
|
+
*/
|
|
21
33
|
constructor(manifestFile: string, versionRegex: string);
|
|
34
|
+
/**
|
|
35
|
+
* Returns `true` when the manifest file exists in `cwd`.
|
|
36
|
+
*
|
|
37
|
+
* @param cwd - Project directory to check.
|
|
38
|
+
* @returns Whether the manifest file exists.
|
|
39
|
+
*/
|
|
22
40
|
exists(cwd: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Reads the version string from the source manifest using regex extraction.
|
|
43
|
+
*
|
|
44
|
+
* @param cwd - Project directory containing the manifest.
|
|
45
|
+
* @returns The version string captured by group 1 of the regex.
|
|
46
|
+
*/
|
|
23
47
|
getVersion(cwd: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Writes a version string to the source manifest using position-based replacement.
|
|
50
|
+
*
|
|
51
|
+
* @param version - Version string to write.
|
|
52
|
+
* @param cwd - Project directory containing the manifest.
|
|
53
|
+
*/
|
|
24
54
|
setVersion(version: string, cwd: string): void;
|
|
25
55
|
}
|
|
26
56
|
//# sourceMappingURL=regex.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regex.d.ts","sourceRoot":"","sources":["../../src/sources/regex.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD
|
|
1
|
+
{"version":3,"file":"regex.d.ts","sourceRoot":"","sources":["../../src/sources/regex.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;;;;;;;;;GAUG;AACH,qBAAa,kBAAmB,YAAW,qBAAqB;IAC9D,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,2DAA2D;IAC3D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B,wDAAwD;IACxD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IAEtC;;;;;OAKG;gBACS,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAiBtD;;;;;OAKG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B;;;;;OAKG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAgB/B;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;CAoB/C"}
|
|
@@ -8,28 +8,47 @@ import type { VersionSourceProvider } from './provider';
|
|
|
8
8
|
/**
|
|
9
9
|
* Resolves the version source provider for a project.
|
|
10
10
|
*
|
|
11
|
+
* @remarks
|
|
11
12
|
* When `source` is `'auto'`, scans the project directory for known manifest
|
|
12
|
-
* files and returns the first match.
|
|
13
|
-
* is
|
|
14
|
-
*
|
|
15
|
-
* @public
|
|
16
|
-
* @since 0.3.0
|
|
13
|
+
* files and returns the first match. Throws with helpful guidance if no
|
|
14
|
+
* supported manifest is found.
|
|
17
15
|
*
|
|
18
16
|
* @param config - Manifest configuration from `.versionguard.yml`.
|
|
19
17
|
* @param cwd - Project directory to scan.
|
|
20
18
|
* @returns The resolved version source provider.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { resolveVersionSource } from './resolve';
|
|
23
|
+
*
|
|
24
|
+
* const provider = resolveVersionSource({ source: 'auto' }, process.cwd());
|
|
25
|
+
* const version = provider.getVersion(process.cwd());
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
* @since 0.3.0
|
|
21
30
|
*/
|
|
22
31
|
export declare function resolveVersionSource(config: ManifestConfig, cwd?: string): VersionSourceProvider;
|
|
23
32
|
/**
|
|
24
33
|
* Detects all manifest files present in a project directory.
|
|
25
34
|
*
|
|
35
|
+
* @remarks
|
|
26
36
|
* Useful for polyglot projects that may have multiple version sources.
|
|
27
|
-
*
|
|
28
|
-
* @public
|
|
29
|
-
* @since 0.3.0
|
|
37
|
+
* Scans the detection table in priority order and returns all matches.
|
|
30
38
|
*
|
|
31
39
|
* @param cwd - Project directory to scan.
|
|
32
40
|
* @returns Array of detected manifest source types.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* import { detectManifests } from './resolve';
|
|
45
|
+
*
|
|
46
|
+
* const manifests = detectManifests(process.cwd());
|
|
47
|
+
* // ['package.json', 'Cargo.toml']
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
* @since 0.3.0
|
|
33
52
|
*/
|
|
34
53
|
export declare function detectManifests(cwd?: string): ManifestSourceType[];
|
|
35
54
|
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/sources/resolve.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAiIxD
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/sources/resolve.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAiIxD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,cAAc,EACtB,GAAG,GAAE,MAAsB,GAC1B,qBAAqB,CAoBvB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAsB,GAAG,kBAAkB,EAAE,CAWjF"}
|
package/dist/sources/toml.d.ts
CHANGED
|
@@ -7,19 +7,54 @@ import type { VersionSourceProvider } from './provider';
|
|
|
7
7
|
/**
|
|
8
8
|
* Reads and writes version strings from TOML manifest files.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
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.
|
|
11
14
|
*
|
|
12
15
|
* @public
|
|
13
16
|
* @since 0.3.0
|
|
14
17
|
*/
|
|
15
18
|
export declare class TomlVersionSource implements VersionSourceProvider {
|
|
19
|
+
/** Human-readable provider name. */
|
|
16
20
|
readonly name: string;
|
|
21
|
+
/** Filename of the TOML manifest (e.g. `'Cargo.toml'`). */
|
|
17
22
|
readonly manifestFile: string;
|
|
23
|
+
/** Dotted key path to the version field within the TOML document. */
|
|
18
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
|
+
*/
|
|
19
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
|
+
*/
|
|
20
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
|
+
*/
|
|
21
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
|
+
*/
|
|
22
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
|
+
*/
|
|
23
58
|
private getSectionKey;
|
|
24
59
|
}
|
|
25
60
|
//# sourceMappingURL=toml.d.ts.map
|
|
@@ -1 +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;
|
|
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"}
|