@versu/core 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.
Files changed (117) hide show
  1. package/README.md +241 -0
  2. package/dist/adapters/gradle/constants.d.ts +13 -0
  3. package/dist/adapters/gradle/constants.d.ts.map +1 -0
  4. package/dist/adapters/gradle/constants.js +12 -0
  5. package/dist/adapters/gradle/gradle-project-information.d.ts +19 -0
  6. package/dist/adapters/gradle/gradle-project-information.d.ts.map +1 -0
  7. package/dist/adapters/gradle/gradle-project-information.js +233 -0
  8. package/dist/adapters/gradle/init-project-information.gradle.kts +163 -0
  9. package/dist/adapters/gradle/services/gradle-adapter-identifier.d.ts +21 -0
  10. package/dist/adapters/gradle/services/gradle-adapter-identifier.d.ts.map +1 -0
  11. package/dist/adapters/gradle/services/gradle-adapter-identifier.js +44 -0
  12. package/dist/adapters/gradle/services/gradle-module-detector.d.ts +19 -0
  13. package/dist/adapters/gradle/services/gradle-module-detector.d.ts.map +1 -0
  14. package/dist/adapters/gradle/services/gradle-module-detector.js +28 -0
  15. package/dist/adapters/gradle/services/gradle-module-system-factory.d.ts +26 -0
  16. package/dist/adapters/gradle/services/gradle-module-system-factory.d.ts.map +1 -0
  17. package/dist/adapters/gradle/services/gradle-module-system-factory.js +29 -0
  18. package/dist/adapters/gradle/services/gradle-version-update-strategy.d.ts +23 -0
  19. package/dist/adapters/gradle/services/gradle-version-update-strategy.d.ts.map +1 -0
  20. package/dist/adapters/gradle/services/gradle-version-update-strategy.js +38 -0
  21. package/dist/adapters/project-information.d.ts +62 -0
  22. package/dist/adapters/project-information.d.ts.map +1 -0
  23. package/dist/adapters/project-information.js +1 -0
  24. package/dist/changelog/index.d.ts +14 -0
  25. package/dist/changelog/index.d.ts.map +1 -0
  26. package/dist/changelog/index.js +132 -0
  27. package/dist/config/index.d.ts +122 -0
  28. package/dist/config/index.d.ts.map +1 -0
  29. package/dist/config/index.js +117 -0
  30. package/dist/factories/adapter-identifier-registry.d.ts +12 -0
  31. package/dist/factories/adapter-identifier-registry.d.ts.map +1 -0
  32. package/dist/factories/adapter-identifier-registry.js +24 -0
  33. package/dist/factories/module-system-factory.d.ts +10 -0
  34. package/dist/factories/module-system-factory.d.ts.map +1 -0
  35. package/dist/factories/module-system-factory.js +18 -0
  36. package/dist/git/index.d.ts +355 -0
  37. package/dist/git/index.d.ts.map +1 -0
  38. package/dist/git/index.js +702 -0
  39. package/dist/index.d.ts +23 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +22 -0
  42. package/dist/semver/index.d.ts +86 -0
  43. package/dist/semver/index.d.ts.map +1 -0
  44. package/dist/semver/index.js +186 -0
  45. package/dist/services/adapter-identifier-registry.d.ts +38 -0
  46. package/dist/services/adapter-identifier-registry.d.ts.map +1 -0
  47. package/dist/services/adapter-identifier-registry.js +59 -0
  48. package/dist/services/adapter-identifier.d.ts +31 -0
  49. package/dist/services/adapter-identifier.d.ts.map +1 -0
  50. package/dist/services/adapter-identifier.js +1 -0
  51. package/dist/services/adapter-metadata-provider.d.ts +51 -0
  52. package/dist/services/adapter-metadata-provider.d.ts.map +1 -0
  53. package/dist/services/adapter-metadata-provider.js +66 -0
  54. package/dist/services/changelog-generator.d.ts +16 -0
  55. package/dist/services/changelog-generator.d.ts.map +1 -0
  56. package/dist/services/changelog-generator.js +28 -0
  57. package/dist/services/commit-analyzer.d.ts +47 -0
  58. package/dist/services/commit-analyzer.d.ts.map +1 -0
  59. package/dist/services/commit-analyzer.js +89 -0
  60. package/dist/services/configuration-loader.d.ts +23 -0
  61. package/dist/services/configuration-loader.d.ts.map +1 -0
  62. package/dist/services/configuration-loader.js +79 -0
  63. package/dist/services/configuration-validator.d.ts +16 -0
  64. package/dist/services/configuration-validator.d.ts.map +1 -0
  65. package/dist/services/configuration-validator.js +24 -0
  66. package/dist/services/git-operations.d.ts +16 -0
  67. package/dist/services/git-operations.d.ts.map +1 -0
  68. package/dist/services/git-operations.js +89 -0
  69. package/dist/services/module-detector.d.ts +24 -0
  70. package/dist/services/module-detector.d.ts.map +1 -0
  71. package/dist/services/module-detector.js +1 -0
  72. package/dist/services/module-registry.d.ts +45 -0
  73. package/dist/services/module-registry.d.ts.map +1 -0
  74. package/dist/services/module-registry.js +57 -0
  75. package/dist/services/module-system-factory.d.ts +27 -0
  76. package/dist/services/module-system-factory.d.ts.map +1 -0
  77. package/dist/services/module-system-factory.js +1 -0
  78. package/dist/services/version-applier.d.ts +26 -0
  79. package/dist/services/version-applier.d.ts.map +1 -0
  80. package/dist/services/version-applier.js +63 -0
  81. package/dist/services/version-bumper.d.ts +159 -0
  82. package/dist/services/version-bumper.d.ts.map +1 -0
  83. package/dist/services/version-bumper.js +291 -0
  84. package/dist/services/version-manager.d.ts +68 -0
  85. package/dist/services/version-manager.d.ts.map +1 -0
  86. package/dist/services/version-manager.js +94 -0
  87. package/dist/services/version-update-strategy.d.ts +18 -0
  88. package/dist/services/version-update-strategy.d.ts.map +1 -0
  89. package/dist/services/version-update-strategy.js +1 -0
  90. package/dist/services/versu-runner.d.ts +46 -0
  91. package/dist/services/versu-runner.d.ts.map +1 -0
  92. package/dist/services/versu-runner.js +188 -0
  93. package/dist/utils/banner.d.ts +2 -0
  94. package/dist/utils/banner.d.ts.map +1 -0
  95. package/dist/utils/banner.js +12 -0
  96. package/dist/utils/commits.d.ts +12 -0
  97. package/dist/utils/commits.d.ts.map +1 -0
  98. package/dist/utils/commits.js +24 -0
  99. package/dist/utils/file.d.ts +7 -0
  100. package/dist/utils/file.d.ts.map +1 -0
  101. package/dist/utils/file.js +19 -0
  102. package/dist/utils/index.d.ts +6 -0
  103. package/dist/utils/index.d.ts.map +1 -0
  104. package/dist/utils/index.js +5 -0
  105. package/dist/utils/logger.d.ts +14 -0
  106. package/dist/utils/logger.d.ts.map +1 -0
  107. package/dist/utils/logger.js +22 -0
  108. package/dist/utils/properties.d.ts +24 -0
  109. package/dist/utils/properties.d.ts.map +1 -0
  110. package/dist/utils/properties.js +94 -0
  111. package/dist/utils/version.d.ts +3 -0
  112. package/dist/utils/version.d.ts.map +1 -0
  113. package/dist/utils/version.js +4 -0
  114. package/dist/utils/versioning.d.ts +9 -0
  115. package/dist/utils/versioning.d.ts.map +1 -0
  116. package/dist/utils/versioning.js +20 -0
  117. package/package.json +73 -0
@@ -0,0 +1,122 @@
1
+ import { z } from "zod";
2
+ import { BumpType } from "../semver/index.js";
3
+ import { Commit } from "conventional-commits-parser";
4
+ /**
5
+ * Zod schema for DependencyRules configuration.
6
+ * Validates that dependency cascade rules use valid bump types.
7
+ */
8
+ declare const dependencyRulesSchema: z.ZodObject<{
9
+ onMajorOfDependency: z.ZodEnum<{
10
+ major: "major";
11
+ minor: "minor";
12
+ patch: "patch";
13
+ none: "none";
14
+ }>;
15
+ onMinorOfDependency: z.ZodEnum<{
16
+ major: "major";
17
+ minor: "minor";
18
+ patch: "patch";
19
+ none: "none";
20
+ }>;
21
+ onPatchOfDependency: z.ZodEnum<{
22
+ major: "major";
23
+ minor: "minor";
24
+ patch: "patch";
25
+ none: "none";
26
+ }>;
27
+ }, z.core.$strip>;
28
+ /**
29
+ * Zod schema for NodeJSConfig configuration.
30
+ * Validates Node.js-specific settings.
31
+ */
32
+ declare const nodeJSConfigSchema: z.ZodObject<{
33
+ versionSource: z.ZodArray<z.ZodLiteral<"package.json">>;
34
+ updatePackageLock: z.ZodBoolean;
35
+ }, z.core.$strip>;
36
+ /**
37
+ * Zod schema for the main Config object.
38
+ * This schema is used by ConfigurationValidator to ensure type-safe
39
+ * configuration with detailed error messages for invalid configurations.
40
+ */
41
+ export declare const configSchema: z.ZodObject<{
42
+ defaultBump: z.ZodEnum<{
43
+ major: "major";
44
+ minor: "minor";
45
+ patch: "patch";
46
+ none: "none";
47
+ }>;
48
+ commitTypes: z.ZodRecord<z.ZodString, z.ZodEnum<{
49
+ major: "major";
50
+ minor: "minor";
51
+ patch: "patch";
52
+ none: "none";
53
+ ignore: "ignore";
54
+ }>>;
55
+ dependencyRules: z.ZodObject<{
56
+ onMajorOfDependency: z.ZodEnum<{
57
+ major: "major";
58
+ minor: "minor";
59
+ patch: "patch";
60
+ none: "none";
61
+ }>;
62
+ onMinorOfDependency: z.ZodEnum<{
63
+ major: "major";
64
+ minor: "minor";
65
+ patch: "patch";
66
+ none: "none";
67
+ }>;
68
+ onPatchOfDependency: z.ZodEnum<{
69
+ major: "major";
70
+ minor: "minor";
71
+ patch: "patch";
72
+ none: "none";
73
+ }>;
74
+ }, z.core.$strip>;
75
+ nodejs: z.ZodOptional<z.ZodObject<{
76
+ versionSource: z.ZodArray<z.ZodLiteral<"package.json">>;
77
+ updatePackageLock: z.ZodBoolean;
78
+ }, z.core.$strip>>;
79
+ }, z.core.$strip>;
80
+ /**
81
+ * Configuration for VERSU version bumping behavior.
82
+ * Controls commit type handling, dependency cascade rules, and adapter-specific settings.
83
+ */
84
+ export type Config = z.infer<typeof configSchema>;
85
+ /**
86
+ * Rules for propagating version changes through dependency relationships.
87
+ * Defines how a module should be bumped when its dependencies change.
88
+ */
89
+ export type DependencyRules = z.infer<typeof dependencyRulesSchema>;
90
+ /**
91
+ * Configuration for Node.js/npm projects.
92
+ */
93
+ export type NodeJSConfig = z.infer<typeof nodeJSConfigSchema>;
94
+ /**
95
+ * Default VERSU configuration following Conventional Commits specification.
96
+ * Maps common commit types to semantic version bumps and defines dependency cascade rules.
97
+ */
98
+ export declare const DEFAULT_CONFIG: Config;
99
+ /**
100
+ * Determines the bump type for a commit based on its type and breaking change flag.
101
+ * @param commit - The commit to evaluate
102
+ * @param config - Configuration containing commit type mappings
103
+ * @returns The bump type to apply ('major', 'minor', 'patch', or 'none')
104
+ */
105
+ export declare function getBumpTypeForCommit(commit: Commit, config: Config): BumpType;
106
+ /**
107
+ * Determines how a module should be bumped when one of its dependencies changes.
108
+ * Uses dependency cascade rules from configuration to propagate version changes.
109
+ * @param dependencyBumpType - The bump type applied to the dependency
110
+ * @param config - Configuration containing dependency cascade rules
111
+ * @returns The bump type to apply to the dependent module
112
+ */
113
+ export declare function getDependencyBumpType(dependencyBumpType: BumpType, config: Config): BumpType;
114
+ /**
115
+ * Retrieves adapter-specific configuration from the main config object.
116
+ * @param config - The main configuration object
117
+ * @param adapterName - The name of the adapter configuration to retrieve
118
+ * @returns The adapter-specific configuration, or undefined if not present
119
+ */
120
+ export declare function getAdapterConfig<T extends keyof Config>(config: Config, adapterName: T): Config[T];
121
+ export {};
122
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAqBrD;;;GAGG;AACH,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;iBAIzB,CAAC;AAEH;;;GAGG;AACH,QAAA,MAAM,kBAAkB;;;iBAGtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKvB,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAElD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,MAmB5B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CAe7E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,kBAAkB,EAAE,QAAQ,EAC5B,MAAM,EAAE,MAAM,GACb,QAAQ,CAaV;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,MAAM,EACrD,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,CAAC,GACb,MAAM,CAAC,CAAC,CAAC,CAEX"}
@@ -0,0 +1,117 @@
1
+ import { z } from "zod";
2
+ import { isBreakingCommit } from "../git/index.js";
3
+ /**
4
+ * Zod schema for BumpType values.
5
+ * Used for validation in configuration files.
6
+ */
7
+ const bumpTypeSchema = z.enum(["major", "minor", "patch", "none"]);
8
+ /**
9
+ * Zod schema for BumpType or 'ignore' values.
10
+ * Used for commit type mappings where 'ignore' is allowed.
11
+ */
12
+ const bumpTypeOrIgnoreSchema = z.enum([
13
+ "major",
14
+ "minor",
15
+ "patch",
16
+ "none",
17
+ "ignore",
18
+ ]);
19
+ /**
20
+ * Zod schema for DependencyRules configuration.
21
+ * Validates that dependency cascade rules use valid bump types.
22
+ */
23
+ const dependencyRulesSchema = z.object({
24
+ onMajorOfDependency: bumpTypeSchema,
25
+ onMinorOfDependency: bumpTypeSchema,
26
+ onPatchOfDependency: bumpTypeSchema,
27
+ });
28
+ /**
29
+ * Zod schema for NodeJSConfig configuration.
30
+ * Validates Node.js-specific settings.
31
+ */
32
+ const nodeJSConfigSchema = z.object({
33
+ versionSource: z.array(z.literal("package.json")),
34
+ updatePackageLock: z.boolean(),
35
+ });
36
+ /**
37
+ * Zod schema for the main Config object.
38
+ * This schema is used by ConfigurationValidator to ensure type-safe
39
+ * configuration with detailed error messages for invalid configurations.
40
+ */
41
+ export const configSchema = z.object({
42
+ defaultBump: bumpTypeSchema,
43
+ commitTypes: z.record(z.string(), bumpTypeOrIgnoreSchema),
44
+ dependencyRules: dependencyRulesSchema,
45
+ nodejs: nodeJSConfigSchema.optional(),
46
+ });
47
+ /**
48
+ * Default VERSU configuration following Conventional Commits specification.
49
+ * Maps common commit types to semantic version bumps and defines dependency cascade rules.
50
+ */
51
+ export const DEFAULT_CONFIG = {
52
+ defaultBump: "patch",
53
+ commitTypes: {
54
+ feat: "minor",
55
+ fix: "patch",
56
+ perf: "patch",
57
+ refactor: "patch",
58
+ docs: "ignore",
59
+ test: "ignore",
60
+ chore: "ignore",
61
+ style: "ignore",
62
+ ci: "ignore",
63
+ build: "ignore",
64
+ },
65
+ dependencyRules: {
66
+ onMajorOfDependency: "major",
67
+ onMinorOfDependency: "minor",
68
+ onPatchOfDependency: "patch",
69
+ },
70
+ };
71
+ /**
72
+ * Determines the bump type for a commit based on its type and breaking change flag.
73
+ * @param commit - The commit to evaluate
74
+ * @param config - Configuration containing commit type mappings
75
+ * @returns The bump type to apply ('major', 'minor', 'patch', or 'none')
76
+ */
77
+ export function getBumpTypeForCommit(commit, config) {
78
+ const isBreaking = isBreakingCommit(commit);
79
+ if (isBreaking) {
80
+ return "major";
81
+ }
82
+ const commitType = commit.type || "unknown";
83
+ const configuredBump = config.commitTypes[commitType];
84
+ if (configuredBump === "ignore") {
85
+ return "none";
86
+ }
87
+ return configuredBump || config.defaultBump;
88
+ }
89
+ /**
90
+ * Determines how a module should be bumped when one of its dependencies changes.
91
+ * Uses dependency cascade rules from configuration to propagate version changes.
92
+ * @param dependencyBumpType - The bump type applied to the dependency
93
+ * @param config - Configuration containing dependency cascade rules
94
+ * @returns The bump type to apply to the dependent module
95
+ */
96
+ export function getDependencyBumpType(dependencyBumpType, config) {
97
+ const rules = config.dependencyRules;
98
+ switch (dependencyBumpType) {
99
+ case "major":
100
+ return rules.onMajorOfDependency;
101
+ case "minor":
102
+ return rules.onMinorOfDependency;
103
+ case "patch":
104
+ return rules.onPatchOfDependency;
105
+ default:
106
+ return "none";
107
+ }
108
+ }
109
+ /**
110
+ * Retrieves adapter-specific configuration from the main config object.
111
+ * @param config - The main configuration object
112
+ * @param adapterName - The name of the adapter configuration to retrieve
113
+ * @returns The adapter-specific configuration, or undefined if not present
114
+ */
115
+ export function getAdapterConfig(config, adapterName) {
116
+ return config[adapterName];
117
+ }
@@ -0,0 +1,12 @@
1
+ import { AdapterIdentifierRegistry } from "../services/adapter-identifier-registry.js";
2
+ /**
3
+ * Creates and configures the global adapter identifier registry.
4
+ *
5
+ * @returns Configured {@link AdapterIdentifierRegistry} with all available adapters
6
+ *
7
+ * @remarks
8
+ * Central point for registering all supported project adapters.
9
+ * To add a new adapter, implement {@link AdapterIdentifier} and add it to the array.
10
+ */
11
+ export declare function createAdapterIdentifierRegistry(): AdapterIdentifierRegistry;
12
+ //# sourceMappingURL=adapter-identifier-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-identifier-registry.d.ts","sourceRoot":"","sources":["../../src/factories/adapter-identifier-registry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAEvF;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,IAAI,yBAAyB,CAc3E"}
@@ -0,0 +1,24 @@
1
+ import { GradleAdapterIdentifier } from "../adapters/gradle/services/gradle-adapter-identifier.js";
2
+ import { AdapterIdentifierRegistry } from "../services/adapter-identifier-registry.js";
3
+ /**
4
+ * Creates and configures the global adapter identifier registry.
5
+ *
6
+ * @returns Configured {@link AdapterIdentifierRegistry} with all available adapters
7
+ *
8
+ * @remarks
9
+ * Central point for registering all supported project adapters.
10
+ * To add a new adapter, implement {@link AdapterIdentifier} and add it to the array.
11
+ */
12
+ export function createAdapterIdentifierRegistry() {
13
+ // Array of all registered adapter identifiers
14
+ // Order matters: first matching adapter is selected during auto-detection
15
+ const identifiers = [
16
+ new GradleAdapterIdentifier(),
17
+ // Add future adapter identifiers here as they are implemented:
18
+ // new MavenAdapterIdentifier(),
19
+ // new NodeJSAdapterIdentifier(),
20
+ // new PythonAdapterIdentifier(),
21
+ ];
22
+ // Create and return the registry with all registered identifiers
23
+ return new AdapterIdentifierRegistry(identifiers);
24
+ }
@@ -0,0 +1,10 @@
1
+ import { ModuleSystemFactory } from "../services/module-system-factory.js";
2
+ /**
3
+ * Creates the appropriate module system factory for a given adapter.
4
+ * @param adapterName - The identifier of the build system adapter (e.g., 'gradle', 'maven', 'npm')
5
+ * @param repoRoot - The absolute path to the repository root directory
6
+ * @returns A ModuleSystemFactory instance configured for the specified adapter
7
+ * @throws {Error} If the adapter name is not recognized or supported
8
+ */
9
+ export declare function createModuleSystemFactory(adapterName: string, repoRoot: string): ModuleSystemFactory;
10
+ //# sourceMappingURL=module-system-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-system-factory.d.ts","sourceRoot":"","sources":["../../src/factories/module-system-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAI3E;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,mBAAmB,CASrB"}
@@ -0,0 +1,18 @@
1
+ import { GradleModuleSystemFactory } from "../adapters/gradle/services/gradle-module-system-factory.js";
2
+ import { GRADLE_ID } from "../adapters/gradle/constants.js";
3
+ /**
4
+ * Creates the appropriate module system factory for a given adapter.
5
+ * @param adapterName - The identifier of the build system adapter (e.g., 'gradle', 'maven', 'npm')
6
+ * @param repoRoot - The absolute path to the repository root directory
7
+ * @returns A ModuleSystemFactory instance configured for the specified adapter
8
+ * @throws {Error} If the adapter name is not recognized or supported
9
+ */
10
+ export function createModuleSystemFactory(adapterName, repoRoot) {
11
+ // Normalize adapter name to lowercase for case-insensitive matching
12
+ switch (adapterName.toLowerCase()) {
13
+ case GRADLE_ID:
14
+ return new GradleModuleSystemFactory(repoRoot);
15
+ default:
16
+ throw new Error(`Unsupported adapter: ${adapterName}`);
17
+ }
18
+ }
@@ -0,0 +1,355 @@
1
+ /**
2
+ * Git operations module for VERSU version management.
3
+ * Provides interfaces for commit analysis, tagging, and conventional commit parsing.
4
+ * Supports monorepo and multi-module projects with module-specific tag management.
5
+ */
6
+ import { Commit } from "conventional-commits-parser";
7
+ import { Module } from "../index.js";
8
+ /**
9
+ * Represents a parsed git tag with extracted module and version metadata.
10
+ * Supports module tags (moduleName@version) and general tags (v{version}).
11
+ */
12
+ export type GitTag = {
13
+ /** The full tag name as it appears in git (e.g., 'core@1.0.0', 'v2.0.0') */
14
+ readonly name: string;
15
+ /** The full SHA-1 commit hash that this tag points to */
16
+ readonly hash: string;
17
+ /**
18
+ * The module name extracted from the tag (e.g., 'core' from 'core@1.0.0').
19
+ * Undefined for general tags or unparseable tag names.
20
+ */
21
+ readonly module?: string;
22
+ /**
23
+ * The semantic version extracted from the tag (e.g., '1.0.0' from 'core@1.0.0' or 'v1.0.0').
24
+ * Undefined for unparseable tag names.
25
+ */
26
+ readonly version?: string;
27
+ };
28
+ /**
29
+ * Configuration options for executing git operations.
30
+ * @property cwd - Working directory for git commands (defaults to process.cwd())
31
+ */
32
+ export type GitOptions = {
33
+ /**
34
+ * The working directory in which to execute git commands.
35
+ * Must be inside a git repository or a subdirectory of one.
36
+ * Defaults to `process.cwd()` if not specified.
37
+ */
38
+ readonly cwd?: string;
39
+ };
40
+ /**
41
+ * Represents a parsed git commit following the Conventional Commits specification.
42
+ * Extracts type, scope, breaking changes, and descriptive content for version bumping.
43
+ */
44
+ export type CommitInfo = {
45
+ /** The full SHA-1 commit hash (40 hexadecimal characters) */
46
+ readonly hash: string;
47
+ /**
48
+ * The commit type indicating the nature of the change.
49
+ * Common values: 'feat', 'fix', 'docs', 'chore', 'refactor', 'test', 'unknown'.
50
+ * Used to determine version bump strategy.
51
+ */
52
+ readonly type: string;
53
+ /**
54
+ * Optional scope providing additional context about what was changed.
55
+ * Examples: 'api', 'core', 'ui', 'auth'.
56
+ * Not used for version bumping but useful for changelog organization.
57
+ */
58
+ readonly scope?: string;
59
+ /**
60
+ * The commit subject line without type and scope prefix.
61
+ * Should be a concise description of the change.
62
+ */
63
+ readonly subject: string;
64
+ /**
65
+ * The full commit body text, if present.
66
+ * May contain detailed explanations, breaking change descriptions, and footer metadata.
67
+ */
68
+ readonly body?: string;
69
+ /**
70
+ * Whether this commit introduces breaking changes.
71
+ * Detected from 'BREAKING CHANGE:' footer or '!' suffix in commit message.
72
+ * When true, always triggers a major version bump.
73
+ */
74
+ readonly breaking: boolean;
75
+ /**
76
+ * Optional module name if the commit is specific to a module in a monorepo.
77
+ * Not currently extracted by the parser but reserved for future use.
78
+ */
79
+ readonly module?: string;
80
+ readonly parsed?: Commit;
81
+ };
82
+ /**
83
+ * Retrieves all commits for a module since its last release tag.
84
+ * Handles monorepo and single-repo scenarios with path filtering.
85
+ * @param projectInfo - Module information including path and type
86
+ * @param options - Git operation options
87
+ * @param excludePaths - Paths to exclude using git pathspec syntax
88
+ * @returns Promise resolving to array of parsed commits (oldest to newest)
89
+ */
90
+ export declare function getCommitsSinceLastTag(projectInfo: Module, options?: GitOptions, excludePaths?: string[]): Promise<{
91
+ commits: Commit[];
92
+ lastTag: string | null;
93
+ }>;
94
+ /**
95
+ * Retrieves commits within a specific git revision range with path filtering.
96
+ * Uses git's native pathspec syntax for efficient filtering in monorepos.
97
+ * @param range - Git revision range (e.g., 'tag1..tag2', 'tag..HEAD', or '' for all)
98
+ * @param pathFilter - Optional path to filter commits (use '.' for root)
99
+ * @param options - Git operation options
100
+ * @param excludePaths - Paths to exclude using ':(exclude)path' syntax
101
+ * @returns Promise resolving to array of parsed commits (oldest to newest)
102
+ */
103
+ export declare function getCommitsInRange(range: string, pathFilter?: string, options?: GitOptions, excludePaths?: string[]): Promise<Commit[]>;
104
+ export declare function isBreakingCommit(commit: Commit): boolean;
105
+ /**
106
+ * Finds the most recent git tag for a specific module with fallback to general tags.
107
+ * Searches module-specific tags first (moduleName@*), then falls back to general tags.
108
+ * @param projectInfo - Module information for tag pattern construction
109
+ * @param options - Git operation options
110
+ * @returns Most recent tag name or null if no tags exist
111
+ */
112
+ export declare function getLastTagForModule(projectInfo: Module, options?: GitOptions): Promise<string | null>;
113
+ /**
114
+ * Retrieves all git tags in the repository with parsed metadata.
115
+ * Returns array with tag name, commit hash, and parsed module/version information.
116
+ * @param options - Git operation options
117
+ * @returns Promise resolving to array of GitTag objects (empty array if no tags exist)
118
+ */
119
+ export declare function getAllTags(options?: GitOptions): Promise<GitTag[]>;
120
+ /**
121
+ * Creates an annotated git tag at the current HEAD commit.
122
+ * Annotated tags include tagger metadata, date, message, and can be GPG signed.
123
+ * @param tagName - The tag name (e.g., 'core@1.0.0' or 'v1.0.0'). Must not already exist
124
+ * @param message - The annotation message for the tag
125
+ * @param options - Git operation options
126
+ * @returns Promise that resolves when the tag is successfully created
127
+ * @throws {Error} If tag creation fails (tag exists, invalid name, etc.)
128
+ */
129
+ export declare function createTag(tagName: string, message: string, options?: GitOptions): Promise<void>;
130
+ /**
131
+ * Pushes all local tags to the configured remote repository.
132
+ * Only pushes tags that don't exist on remote. Does NOT push commits.
133
+ * @param options - Git operation options
134
+ * @returns Promise that resolves when all tags are successfully pushed
135
+ * @throws {Error} If push fails (no remote, authentication, network, conflicts, etc.)
136
+ */
137
+ export declare function pushTags(options?: GitOptions): Promise<void>;
138
+ /**
139
+ * Checks if the git working directory is clean (no uncommitted changes).
140
+ * Uses `git status --porcelain` to detect modified, staged, deleted, or untracked files.
141
+ * @param options - Git operation options
142
+ * @returns Promise resolving to true if clean, false if there are changes or on error
143
+ */
144
+ export declare function isWorkingDirectoryClean(options?: GitOptions): Promise<boolean>;
145
+ /**
146
+ * Retrieves the name of the currently checked out git branch.
147
+ *
148
+ * This function returns the active branch name, which is useful for:
149
+ * - Conditional logic based on branch (e.g., only release from 'main')
150
+ * - CI/CD branch-specific workflows
151
+ * - Logging and debugging
152
+ * - Branch validation before operations
153
+ *
154
+ * Returns empty string if in detached HEAD state.
155
+ * @param options - Git operation options
156
+ * @returns Promise resolving to the current branch name (empty string if detached HEAD)
157
+ * @throws {Error} If git command fails
158
+ */
159
+ export declare function getCurrentBranch(options?: GitOptions): Promise<string>;
160
+ /**
161
+ * Retrieves the abbreviated (short) SHA-1 hash of the current HEAD commit.
162
+ *
163
+ * This function returns a shortened version of the commit hash (typically 7 characters),
164
+ * which is:
165
+ * - Human-readable and easier to reference
166
+ * - Suitable for build metadata in semantic versions
167
+ * - Commonly used in CI/CD for build identification
168
+ * - Still unique enough for most repositories
169
+ *
170
+ * The short SHA is git's default abbreviated format and balances uniqueness with brevity.
171
+ *
172
+ * @param options - Git operation options, primarily for specifying working directory.
173
+ *
174
+ * @returns Promise resolving to the abbreviated commit SHA.
175
+ * Typically 7 characters (e.g., 'abc1234').
176
+ * Length may vary based on repository size to ensure uniqueness.
177
+ *
178
+ * @throws {Error} If git command fails:
179
+ * - Not in a git repository
180
+ * - No commits exist (empty repository)
181
+ * - Permissions issues
182
+ */
183
+ export declare function getCurrentCommitShortSha(options?: GitOptions): Promise<string>;
184
+ /**
185
+ * Stages all changed files in the working directory for the next commit.
186
+ *
187
+ * This function executes `git add .` which stages:
188
+ * - All modified tracked files
189
+ * - All new untracked files
190
+ * - All deleted files
191
+ *
192
+ * **Warning**: This stages **everything** in the working directory. Use with caution
193
+ * in interactive environments. For selective staging, use git commands directly.
194
+ *
195
+ * @param options - Git operation options, primarily for specifying working directory.
196
+ *
197
+ * @returns Promise that resolves when all files are successfully staged.
198
+ *
199
+ * @throws {Error} If git add command fails:
200
+ * - Not in a git repository
201
+ * - Permissions issues
202
+ * - Invalid .gitignore patterns
203
+ */
204
+ export declare function addChangedFiles(options?: GitOptions): Promise<void>;
205
+ /**
206
+ * Creates a git commit with the specified message using currently staged changes.
207
+ * Files must be staged first (via `git add`). Follows Conventional Commits format.
208
+ * @param message - The commit message (e.g., 'feat: description', 'fix: description')
209
+ * @param options - Git operation options
210
+ * @returns Promise that resolves when commit is created
211
+ * @throws {Error} If commit fails (no staged changes, no git user, empty message, etc.)
212
+ */
213
+ export declare function commitChanges(message: string, options?: GitOptions): Promise<void>;
214
+ /**
215
+ * Pushes local commits to the remote repository.
216
+ *
217
+ * This function uploads all commits from the current branch that don't exist
218
+ * on the remote. It uses `git push` without arguments, which:
219
+ * - Pushes the current branch to its configured upstream
220
+ * - Only pushes commits (use `pushTags()` for tags)
221
+ * - Requires network access and authentication
222
+ *
223
+ * @param options - Git operation options, primarily for specifying working directory.
224
+ *
225
+ * @returns Promise that resolves when commits are successfully pushed.
226
+ *
227
+ * @throws {Error} If push fails:
228
+ * - No remote configured
229
+ * - No upstream branch set
230
+ * - Authentication failure
231
+ * - Network issues
232
+ * - Remote rejects (e.g., force push needed, protected branch)
233
+ */
234
+ export declare function pushCommits(options?: GitOptions): Promise<void>;
235
+ /**
236
+ * Checks if there are any changes in the working directory or staging area.
237
+ *
238
+ * This function is similar to `isWorkingDirectoryClean()` but returns the opposite
239
+ * boolean value. It's useful when you want to check if there's work to commit.
240
+ *
241
+ * Uses `git status --porcelain` to detect:
242
+ * - Modified tracked files
243
+ * - New untracked files
244
+ * - Deleted files
245
+ * - Staged changes
246
+ *
247
+ * @param options - Git operation options, primarily for specifying working directory.
248
+ *
249
+ * @returns Promise resolving to:
250
+ * - `true`: There are changes (modified, staged, untracked files)
251
+ * - `false`: Working directory is clean OR git command failed
252
+ *
253
+ * @throws {Error} If git status command fails.
254
+ * Unlike `isWorkingDirectoryClean()`, this function throws on errors.
255
+ */
256
+ export declare function hasChangesToCommit(options?: GitOptions): Promise<boolean>;
257
+ export declare function getCurrentRepoUrl(options?: GitOptions): Promise<string>;
258
+ /**
259
+ * Parses a git repository URL (SSH or HTTP/HTTPS) and extracts its components.
260
+ *
261
+ * Supports multiple URL formats:
262
+ * - SSH: `git@github.com:owner/repo.git`
263
+ * - HTTPS: `https://github.com/owner/repo.git`
264
+ * - HTTP: `http://github.com/owner/repo.git`
265
+ *
266
+ * @param repoUrl - The repository URL to parse
267
+ * @returns Object containing host, owner, and repo name
268
+ * @throws {Error} If URL format is invalid or cannot be parsed
269
+ * @internal
270
+ */
271
+ export declare function parseRepoUrl(repoUrl: string): {
272
+ host: string;
273
+ owner: string;
274
+ repo: string;
275
+ };
276
+ /**
277
+ * Retrieves the current repository URL and converts it to HTTPS format.
278
+ *
279
+ * This function is useful for:
280
+ * - Generating consistent HTTPS URLs for documentation
281
+ * - Creating web links to the repository
282
+ * - CI/CD systems that prefer HTTPS over SSH
283
+ *
284
+ * Converts SSH URLs (git@github.com:owner/repo.git) to HTTPS format
285
+ * (https://github.com/owner/repo.git).
286
+ *
287
+ * @param options - Git operation options, primarily for specifying working directory.
288
+ *
289
+ * @returns Promise resolving to the repository URL in HTTPS format.
290
+ *
291
+ * @throws {Error} If:
292
+ * - Unable to get remote URL
293
+ * - URL format is invalid
294
+ * - Not in a git repository
295
+ */
296
+ export declare function getRepoUrlAsHttps(options?: GitOptions): Promise<string>;
297
+ /**
298
+ * Extracts the hostname from the current repository's remote URL.
299
+ *
300
+ * Returns the hosting service domain (e.g., 'github.com', 'gitlab.com',
301
+ * 'bitbucket.org', or custom Git server hostname).
302
+ *
303
+ * Supports both SSH and HTTP/HTTPS URL formats.
304
+ *
305
+ * @param options - Git operation options, primarily for specifying working directory.
306
+ *
307
+ * @returns Promise resolving to the repository host (e.g., 'github.com').
308
+ *
309
+ * @throws {Error} If:
310
+ * - Unable to get remote URL
311
+ * - URL format is invalid
312
+ * - Not in a git repository
313
+ */
314
+ export declare function getRepoHost(options?: GitOptions): Promise<string>;
315
+ /**
316
+ * Extracts the repository owner/organization name from the current repository's remote URL.
317
+ *
318
+ * Returns the account or organization that owns the repository.
319
+ * For example:
320
+ * - `git@github.com:microsoft/vscode.git` → 'microsoft'
321
+ * - `https://github.com/facebook/react.git` → 'facebook'
322
+ *
323
+ * Supports both SSH and HTTP/HTTPS URL formats.
324
+ *
325
+ * @param options - Git operation options, primarily for specifying working directory.
326
+ *
327
+ * @returns Promise resolving to the repository owner name.
328
+ *
329
+ * @throws {Error} If:
330
+ * - Unable to get remote URL
331
+ * - URL format is invalid
332
+ * - Not in a git repository
333
+ */
334
+ export declare function getRepoOwner(options?: GitOptions): Promise<string>;
335
+ /**
336
+ * Extracts the repository name from the current repository's remote URL.
337
+ *
338
+ * Returns the name of the repository without the owner prefix or .git suffix.
339
+ * For example:
340
+ * - `git@github.com:microsoft/vscode.git` → 'vscode'
341
+ * - `https://github.com/facebook/react.git` → 'react'
342
+ *
343
+ * Supports both SSH and HTTP/HTTPS URL formats.
344
+ *
345
+ * @param options - Git operation options, primarily for specifying working directory.
346
+ *
347
+ * @returns Promise resolving to the repository name.
348
+ *
349
+ * @throws {Error} If:
350
+ * - Unable to get remote URL
351
+ * - URL format is invalid
352
+ * - Not in a git repository
353
+ */
354
+ export declare function getRepoName(options?: GitOptions): Promise<string>;
355
+ //# sourceMappingURL=index.d.ts.map