@codluv/versionguard 0.4.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.
@@ -10,13 +10,22 @@
10
10
  * @since 0.3.0
11
11
  */
12
12
  export interface InitOptions {
13
+ /** Working directory path. */
13
14
  cwd: string;
15
+ /** Versioning type (semver or calver). */
14
16
  type?: 'semver' | 'calver';
17
+ /** CalVer format string. */
15
18
  format?: string;
19
+ /** Manifest source type. */
16
20
  manifest?: string;
21
+ /** Whether to install git hooks. */
17
22
  hooks?: boolean;
23
+ /** Whether to enable changelog validation. */
18
24
  changelog?: boolean;
25
+ /** Accept defaults without prompting. */
19
26
  yes?: boolean;
27
+ /** Overwrite existing config. */
28
+ force?: boolean;
20
29
  }
21
30
  /**
22
31
  * Runs the interactive setup wizard.
@@ -28,6 +37,11 @@ export interface InitOptions {
28
37
  * @param cwd - Project directory to initialize.
29
38
  * @returns The path to the created config file, or `null` if cancelled.
30
39
  *
40
+ * @example
41
+ * ```ts
42
+ * const configPath = await runWizard(process.cwd());
43
+ * ```
44
+ *
31
45
  * @public
32
46
  * @since 0.3.0
33
47
  */
@@ -42,6 +56,11 @@ export declare function runWizard(cwd: string): Promise<string | null>;
42
56
  * @param options - Headless initialization options.
43
57
  * @returns The path to the created config file.
44
58
  *
59
+ * @example
60
+ * ```ts
61
+ * const configPath = runHeadless({ cwd: process.cwd(), type: 'calver', format: 'YYYY.M.MICRO' });
62
+ * ```
63
+ *
45
64
  * @public
46
65
  * @since 0.3.0
47
66
  */
@@ -1 +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,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA+EnE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAexD"}
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codluv/versionguard",
3
- "version": "0.4.0",
3
+ "version": "0.5.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",
@@ -76,7 +76,7 @@
76
76
  "@changesets/changelog-github": "^0.6.0",
77
77
  "@changesets/cli": "^2.30.0",
78
78
  "@eslint/js": "^9.37.0",
79
- "@forge-ts/cli": "0.19.4",
79
+ "@forge-ts/cli": "^0.21.1",
80
80
  "@types/js-yaml": "^4.0.9",
81
81
  "@types/node": "^24.6.0",
82
82
  "@vitest/coverage-v8": "^4.0.7",