@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.
@@ -0,0 +1,140 @@
1
+ import type { VersionGuardConfig } from '../types';
2
+ /**
3
+ * Auto-fix helpers for package versions, synced files, and changelog entries.
4
+ *
5
+ * @packageDocumentation
6
+ * @public
7
+ */
8
+ /**
9
+ * Fix entry point exports for auto-remediation helpers.
10
+ *
11
+ * @packageDocumentation
12
+ * @public
13
+ * @since 0.1.0
14
+ * @forgeIgnore E020
15
+ */
16
+ export interface FixResult {
17
+ /**
18
+ * Indicates whether the operation changed repository state.
19
+ */
20
+ fixed: boolean;
21
+ /**
22
+ * Human-readable description of the fix attempt.
23
+ */
24
+ message: string;
25
+ /**
26
+ * Absolute path to the file that was updated, when applicable.
27
+ *
28
+ * @defaultValue `undefined`
29
+ */
30
+ file?: string;
31
+ }
32
+ /**
33
+ * Updates the `package.json` version field when needed.
34
+ *
35
+ * @public
36
+ * @since 0.1.0
37
+ * @remarks
38
+ * This helper writes the target version only when `package.json` exists and the
39
+ * current version differs from the requested value.
40
+ *
41
+ * @param targetVersion - Version that should be written to `package.json`.
42
+ * @param cwd - Repository directory containing `package.json`.
43
+ * @returns The result of the package version fix attempt.
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const result = fixPackageVersion('1.2.3', process.cwd());
48
+ * console.log(result.fixed);
49
+ * ```
50
+ */
51
+ export declare function fixPackageVersion(targetVersion: string, cwd?: string): FixResult;
52
+ /**
53
+ * Synchronizes configured files to the package version.
54
+ *
55
+ * @public
56
+ * @since 0.1.0
57
+ * @remarks
58
+ * This helper uses the configured sync targets to update version strings across
59
+ * the repository and reports only the files that changed.
60
+ *
61
+ * @param config - Loaded VersionGuard configuration.
62
+ * @param cwd - Repository directory to synchronize.
63
+ * @returns A list of per-file sync results.
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * const results = fixSyncIssues(config, process.cwd());
68
+ * console.log(results.length);
69
+ * ```
70
+ */
71
+ export declare function fixSyncIssues(config: VersionGuardConfig, cwd?: string): FixResult[];
72
+ /**
73
+ * Ensures the changelog contains an entry for a version.
74
+ *
75
+ * @public
76
+ * @since 0.1.0
77
+ * @remarks
78
+ * When the changelog file does not exist, this helper creates a starter changelog.
79
+ * Otherwise it appends a new version entry only when one is missing.
80
+ *
81
+ * @param version - Version that should appear in the changelog.
82
+ * @param config - Loaded VersionGuard configuration.
83
+ * @param cwd - Repository directory containing the changelog file.
84
+ * @returns The result of the changelog fix attempt.
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * const result = fixChangelog('1.2.3', config, process.cwd());
89
+ * console.log(result.message);
90
+ * ```
91
+ */
92
+ export declare function fixChangelog(version: string, config: VersionGuardConfig, cwd?: string): FixResult;
93
+ /**
94
+ * Runs all configured auto-fix operations.
95
+ *
96
+ * @public
97
+ * @since 0.1.0
98
+ * @remarks
99
+ * This helper optionally updates the package version first, then synchronizes
100
+ * configured files, and finally updates the changelog when changelog support is
101
+ * enabled.
102
+ *
103
+ * @param config - Loaded VersionGuard configuration.
104
+ * @param targetVersion - Optional version to apply before running other fixes.
105
+ * @param cwd - Repository directory where fixes should run.
106
+ * @returns Ordered results describing every fix step that ran.
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * const results = fixAll(config, '1.2.3', process.cwd());
111
+ * console.log(results.some((result) => result.fixed));
112
+ * ```
113
+ */
114
+ export declare function fixAll(config: VersionGuardConfig, targetVersion?: string, cwd?: string): FixResult[];
115
+ /**
116
+ * Suggests candidate next versions for a release.
117
+ *
118
+ * @public
119
+ * @since 0.1.0
120
+ * @remarks
121
+ * The suggestions depend on the configured versioning mode. SemVer returns one or
122
+ * more bump options, while CalVer suggests the current date-based version and an
123
+ * incremented same-day release.
124
+ *
125
+ * @param currentVersion - Current package version.
126
+ * @param config - Loaded VersionGuard configuration.
127
+ * @param changeType - Preferred bump type, or `auto` to include common options.
128
+ * @returns Candidate versions paired with the reason for each suggestion.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const suggestions = suggestNextVersion('1.2.3', config, 'minor');
133
+ * console.log(suggestions[0]?.version);
134
+ * ```
135
+ */
136
+ export declare function suggestNextVersion(currentVersion: string, config: VersionGuardConfig, changeType?: 'major' | 'minor' | 'patch' | 'auto'): {
137
+ version: string;
138
+ reason: string;
139
+ }[];
140
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fix/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAgB,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEjE;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,GAAE,MAAsB,GAAG,SAAS,CAqB/F;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,kBAAkB,EAC1B,GAAG,GAAE,MAAsB,GAC1B,SAAS,EAAE,CAeb;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,kBAAkB,EAC1B,GAAG,GAAE,MAAsB,GAC1B,SAAS,CA0BX;AA6BD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,MAAM,CACpB,MAAM,EAAE,kBAAkB,EAC1B,aAAa,CAAC,EAAE,MAAM,EACtB,GAAG,GAAE,MAAsB,GAC1B,SAAS,EAAE,CAmBb;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,kBAAkB,EAC1B,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAChD;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,CA2CvC"}
@@ -0,0 +1,98 @@
1
+ import type { GitConfig } from './types';
2
+ declare const HOOK_NAMES: readonly ["pre-commit", "pre-push", "post-tag"];
3
+ /**
4
+ * Installs VersionGuard-managed Git hooks in a repository.
5
+ *
6
+ * @public
7
+ * @since 0.1.0
8
+ * @remarks
9
+ * Only hooks enabled in `config.hooks` are written. Each installed hook runs
10
+ * `versionguard validate` for its corresponding hook name.
11
+ *
12
+ * @param config - Git configuration that selects which hooks to install.
13
+ * @param cwd - Repository directory where hooks should be installed.
14
+ * @example
15
+ * ```ts
16
+ * import { getDefaultConfig, installHooks } from 'versionguard';
17
+ *
18
+ * installHooks(getDefaultConfig().git, process.cwd());
19
+ * ```
20
+ */
21
+ export declare function installHooks(config: GitConfig, cwd?: string): void;
22
+ /**
23
+ * Removes VersionGuard-managed Git hooks from a repository.
24
+ *
25
+ * @public
26
+ * @since 0.1.0
27
+ * @remarks
28
+ * Only hook files containing `versionguard` are removed so unrelated custom
29
+ * hooks are left untouched.
30
+ *
31
+ * @param cwd - Repository directory whose hooks should be cleaned up.
32
+ * @example
33
+ * ```ts
34
+ * import { uninstallHooks } from 'versionguard';
35
+ *
36
+ * uninstallHooks(process.cwd());
37
+ * ```
38
+ */
39
+ export declare function uninstallHooks(cwd?: string): void;
40
+ /**
41
+ * Finds the nearest `.git` directory by walking up from a starting directory.
42
+ *
43
+ * @public
44
+ * @since 0.1.0
45
+ * @remarks
46
+ * This only resolves `.git` directories and returns `null` when the search
47
+ * reaches the filesystem root without finding a repository.
48
+ *
49
+ * @param cwd - Directory to start searching from.
50
+ * @returns The resolved `.git` directory path, or `null` when none is found.
51
+ * @example
52
+ * ```ts
53
+ * import { findGitDir } from 'versionguard';
54
+ *
55
+ * const gitDir = findGitDir(process.cwd());
56
+ * ```
57
+ */
58
+ export declare function findGitDir(cwd: string): string | null;
59
+ /**
60
+ * Checks whether all VersionGuard-managed hooks are installed.
61
+ *
62
+ * @public
63
+ * @since 0.1.0
64
+ * @remarks
65
+ * A hook counts as installed only when the file exists and contains the
66
+ * `versionguard` invocation written by this package.
67
+ *
68
+ * @param cwd - Repository directory to inspect.
69
+ * @returns `true` when every managed hook is installed.
70
+ * @example
71
+ * ```ts
72
+ * import { areHooksInstalled } from 'versionguard';
73
+ *
74
+ * const installed = areHooksInstalled(process.cwd());
75
+ * ```
76
+ */
77
+ export declare function areHooksInstalled(cwd?: string): boolean;
78
+ /**
79
+ * Generates the shell script content for a Git hook.
80
+ *
81
+ * @public
82
+ * @since 0.1.0
83
+ * @remarks
84
+ * The generated script delegates to `npx versionguard validate` and exits with
85
+ * the validation status code.
86
+ *
87
+ * @param hookName - Name of the Git hook to generate.
88
+ * @returns Executable shell script contents for the hook.
89
+ * @example
90
+ * ```ts
91
+ * import { generateHookScript } from 'versionguard';
92
+ *
93
+ * const script = generateHookScript('pre-commit');
94
+ * ```
95
+ */
96
+ export declare function generateHookScript(hookName: (typeof HOOK_NAMES)[number]): string;
97
+ export {};
98
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,QAAA,MAAM,UAAU,iDAAkD,CAAC;AAEnE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,GAAE,MAAsB,GAAG,IAAI,CAejF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAsB,GAAG,IAAI,CAahE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAerD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAUtE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,CAUhF"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Public API for VersionGuard.
3
+ *
4
+ * @packageDocumentation
5
+ * @public
6
+ */
7
+ import type { DoctorReport, FullValidationResult, ValidationResult, VersionGuardConfig } from './types';
8
+ export * as calver from './calver';
9
+ export { validateChangelog } from './changelog';
10
+ export { getConfig, initConfig } from './config';
11
+ export * from './feedback';
12
+ export * from './fix';
13
+ export { areHooksInstalled, installHooks, uninstallHooks } from './hooks';
14
+ export { getPackageVersion } from './project';
15
+ export * as semver from './semver';
16
+ export { checkHardcodedVersions, syncVersion } from './sync';
17
+ export * from './tag';
18
+ export * from './types';
19
+ /**
20
+ * Validates a version string against the active versioning strategy.
21
+ *
22
+ * @public
23
+ * @since 0.1.0
24
+ * @remarks
25
+ * This helper dispatches to SemVer or CalVer validation based on
26
+ * `config.versioning.type`.
27
+ *
28
+ * @param version - Version string to validate.
29
+ * @param config - VersionGuard configuration that selects the validation rules.
30
+ * @returns The validation result for the provided version.
31
+ * @example
32
+ * ```ts
33
+ * import { getDefaultConfig, validateVersion } from 'versionguard';
34
+ *
35
+ * const result = validateVersion('1.2.3', getDefaultConfig());
36
+ * ```
37
+ */
38
+ export declare function validateVersion(version: string, config: VersionGuardConfig): ValidationResult;
39
+ /**
40
+ * Validates the current project state against the supplied configuration.
41
+ *
42
+ * @public
43
+ * @since 0.1.0
44
+ * @remarks
45
+ * This reads the package version from `package.json`, validates the version
46
+ * format, checks synchronized files, and optionally validates the changelog.
47
+ *
48
+ * @param config - VersionGuard configuration to apply.
49
+ * @param cwd - Project directory to inspect.
50
+ * @returns A full validation report for the project rooted at `cwd`.
51
+ * @example
52
+ * ```ts
53
+ * import { getDefaultConfig, validate } from 'versionguard';
54
+ *
55
+ * const result = validate(getDefaultConfig(), process.cwd());
56
+ * ```
57
+ */
58
+ export declare function validate(config: VersionGuardConfig, cwd?: string): FullValidationResult;
59
+ /**
60
+ * Runs an extended readiness check for a project.
61
+ *
62
+ * @public
63
+ * @since 0.1.0
64
+ * @remarks
65
+ * In addition to `validate`, this inspects Git state so callers can determine
66
+ * whether hooks are installed and the worktree is clean.
67
+ *
68
+ * @param config - VersionGuard configuration to apply.
69
+ * @param cwd - Project directory to inspect.
70
+ * @returns A readiness report that includes validation and Git diagnostics.
71
+ * @example
72
+ * ```ts
73
+ * import { doctor, getDefaultConfig } from 'versionguard';
74
+ *
75
+ * const report = doctor(getDefaultConfig(), process.cwd());
76
+ * ```
77
+ */
78
+ export declare function doctor(config: VersionGuardConfig, cwd?: string): DoctorReport;
79
+ /**
80
+ * Synchronizes configured files to the current package version.
81
+ *
82
+ * @public
83
+ * @since 0.1.0
84
+ * @remarks
85
+ * This reads the version from `package.json` and rewrites configured files
86
+ * using the sync patterns defined in the VersionGuard config.
87
+ *
88
+ * @param config - VersionGuard configuration containing sync rules.
89
+ * @param cwd - Project directory whose files should be synchronized.
90
+ * @example
91
+ * ```ts
92
+ * import { getDefaultConfig, sync } from 'versionguard';
93
+ *
94
+ * sync(getDefaultConfig(), process.cwd());
95
+ * ```
96
+ */
97
+ export declare function sync(config: VersionGuardConfig, cwd?: string): void;
98
+ /**
99
+ * Determines whether a project can move from one version to another.
100
+ *
101
+ * @public
102
+ * @since 0.1.0
103
+ * @remarks
104
+ * Both the current and proposed versions must validate against the configured
105
+ * versioning scheme, and the new version must compare greater than the current
106
+ * version.
107
+ *
108
+ * @param currentVersion - Version currently in use.
109
+ * @param newVersion - Proposed next version.
110
+ * @param config - VersionGuard configuration that defines version rules.
111
+ * @returns An object indicating whether the bump is allowed and why it failed.
112
+ * @example
113
+ * ```ts
114
+ * import { canBump, getDefaultConfig } from 'versionguard';
115
+ *
116
+ * const result = canBump('1.2.3', '1.3.0', getDefaultConfig());
117
+ * ```
118
+ */
119
+ export declare function canBump(currentVersion: string, newVersion: string, config: VersionGuardConfig): {
120
+ canBump: boolean;
121
+ error?: string;
122
+ };
123
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,OAAO,KAAK,EAEV,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACjD,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC7D,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AAExB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAG,gBAAgB,CAO7F;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,kBAAkB,EAC1B,GAAG,GAAE,MAAsB,GAC1B,oBAAoB,CAwDtB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,kBAAkB,EAAE,GAAG,GAAE,MAAsB,GAAG,YAAY,CA0B5F;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,kBAAkB,EAAE,GAAG,GAAE,MAAsB,GAAG,IAAI,CAGlF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,OAAO,CACrB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,kBAAkB,GACzB;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAqCtC"}
package/dist/index.js ADDED
@@ -0,0 +1,37 @@
1
+ import "node:child_process";
2
+ import "node:path";
3
+ import { n, o, p, q, l, e, f, r, t, j, w, d, g, x, a, c, y, b, h, i, m, z, s, A, B, C, u, v, D, E, F } from "./chunks/index-DPBYoIRi.js";
4
+ export {
5
+ n as areHooksInstalled,
6
+ o as calver,
7
+ p as canBump,
8
+ q as checkHardcodedVersions,
9
+ l as createTag,
10
+ e as doctor,
11
+ f as fixAll,
12
+ r as fixChangelog,
13
+ t as fixPackageVersion,
14
+ j as fixSyncIssues,
15
+ w as getAllTags,
16
+ d as getChangelogFeedback,
17
+ g as getConfig,
18
+ x as getLatestTag,
19
+ a as getPackageVersion,
20
+ c as getSyncFeedback,
21
+ y as getTagFeedback,
22
+ b as getVersionFeedback,
23
+ h as handlePostTag,
24
+ i as initConfig,
25
+ m as installHooks,
26
+ z as semver,
27
+ s as suggestNextVersion,
28
+ A as suggestTagMessage,
29
+ B as sync,
30
+ C as syncVersion,
31
+ u as uninstallHooks,
32
+ v as validate,
33
+ D as validateChangelog,
34
+ E as validateTagForPush,
35
+ F as validateVersion
36
+ };
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * JSON-compatible scalar, array, or object value used by package metadata.
3
+ *
4
+ * @public
5
+ * @since 0.1.0
6
+ * @forgeIgnore E020
7
+ */
8
+ export type PackageJsonValue = boolean | null | number | string | PackageJsonArray | PackageJsonObject;
9
+ /**
10
+ * Recursive array type used for arbitrary JSON-compatible package values.
11
+ *
12
+ * @public
13
+ * @since 0.1.0
14
+ * @forgeIgnore E020
15
+ */
16
+ export type PackageJsonArray = PackageJsonValue[];
17
+ /**
18
+ * Recursive object type used for arbitrary JSON-compatible package values.
19
+ *
20
+ * @public
21
+ * @since 0.1.0
22
+ * @forgeIgnore E020
23
+ */
24
+ export interface PackageJsonObject {
25
+ [key: string]: PackageJsonValue;
26
+ }
27
+ /**
28
+ * Minimal shape of a `package.json` document used by VersionGuard.
29
+ *
30
+ * @public
31
+ * @since 0.1.0
32
+ * @forgeIgnore E020
33
+ */
34
+ export interface PackageJson {
35
+ /**
36
+ * Package name.
37
+ *
38
+ * @defaultValue `undefined`
39
+ */
40
+ name?: string;
41
+ /**
42
+ * Package version string.
43
+ *
44
+ * @defaultValue `undefined`
45
+ */
46
+ version?: string;
47
+ [key: string]: PackageJsonValue | undefined;
48
+ }
49
+ /**
50
+ * Gets the `package.json` path for a project directory.
51
+ *
52
+ * @public
53
+ * @since 0.1.0
54
+ * @remarks
55
+ * This is a convenience helper used by the package read and write helpers.
56
+ *
57
+ * @param cwd - Project directory containing `package.json`.
58
+ * @returns The resolved `package.json` path.
59
+ * @example
60
+ * ```ts
61
+ * import { getPackageJsonPath } from 'versionguard';
62
+ *
63
+ * const packagePath = getPackageJsonPath(process.cwd());
64
+ * ```
65
+ */
66
+ export declare function getPackageJsonPath(cwd?: string): string;
67
+ /**
68
+ * Reads and parses a project's `package.json` file.
69
+ *
70
+ * @public
71
+ * @since 0.1.0
72
+ * @remarks
73
+ * An error is thrown when `package.json` does not exist in the requested
74
+ * directory.
75
+ *
76
+ * @param cwd - Project directory containing `package.json`.
77
+ * @returns The parsed `package.json` document.
78
+ * @example
79
+ * ```ts
80
+ * import { readPackageJson } from 'versionguard';
81
+ *
82
+ * const pkg = readPackageJson(process.cwd());
83
+ * ```
84
+ */
85
+ export declare function readPackageJson(cwd?: string): PackageJson;
86
+ /**
87
+ * Writes a `package.json` document back to disk.
88
+ *
89
+ * @public
90
+ * @since 0.1.0
91
+ * @remarks
92
+ * Output is formatted with two-space indentation and always ends with a
93
+ * trailing newline.
94
+ *
95
+ * @param pkg - Parsed `package.json` data to write.
96
+ * @param cwd - Project directory containing `package.json`.
97
+ * @example
98
+ * ```ts
99
+ * import { readPackageJson, writePackageJson } from 'versionguard';
100
+ *
101
+ * const pkg = readPackageJson(process.cwd());
102
+ * writePackageJson(pkg, process.cwd());
103
+ * ```
104
+ */
105
+ export declare function writePackageJson(pkg: PackageJson, cwd?: string): void;
106
+ /**
107
+ * Gets the version string from `package.json`.
108
+ *
109
+ * @public
110
+ * @since 0.1.0
111
+ * @remarks
112
+ * This throws when the file exists but does not contain a non-empty `version`
113
+ * field.
114
+ *
115
+ * @param cwd - Project directory containing `package.json`.
116
+ * @returns The package version string.
117
+ * @example
118
+ * ```ts
119
+ * import { getPackageVersion } from 'versionguard';
120
+ *
121
+ * const version = getPackageVersion(process.cwd());
122
+ * ```
123
+ */
124
+ export declare function getPackageVersion(cwd?: string): string;
125
+ /**
126
+ * Sets the version field in `package.json`.
127
+ *
128
+ * @public
129
+ * @since 0.1.0
130
+ * @remarks
131
+ * The existing document is read, the `version` field is replaced, and the full
132
+ * file is written back to disk.
133
+ *
134
+ * @param version - Version string to persist.
135
+ * @param cwd - Project directory containing `package.json`.
136
+ * @example
137
+ * ```ts
138
+ * import { setPackageVersion } from 'versionguard';
139
+ *
140
+ * setPackageVersion('1.2.3', process.cwd());
141
+ * ```
142
+ */
143
+ export declare function setPackageVersion(version: string, cwd?: string): void;
144
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAGA;;;;;;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;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAsB,GAAG,MAAM,CAQrE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,GAAE,MAAsB,GAAG,IAAI,CAIpF"}