@muverse/core 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.
- package/README.md +22 -0
- package/dist/adapters/gradle/constants.d.ts +13 -0
- package/dist/adapters/gradle/constants.d.ts.map +1 -0
- package/dist/adapters/gradle/constants.js +12 -0
- package/dist/adapters/gradle/gradle-project-information.d.ts +18 -0
- package/dist/adapters/gradle/gradle-project-information.d.ts.map +1 -0
- package/dist/adapters/gradle/gradle-project-information.js +93 -0
- package/dist/adapters/gradle/gradle-properties.d.ts +15 -0
- package/dist/adapters/gradle/gradle-properties.d.ts.map +1 -0
- package/dist/adapters/gradle/gradle-properties.js +46 -0
- package/dist/adapters/gradle/init-project-information.gradle.kts +143 -0
- package/dist/adapters/gradle/services/gradle-adapter-identifier.d.ts +21 -0
- package/dist/adapters/gradle/services/gradle-adapter-identifier.d.ts.map +1 -0
- package/dist/adapters/gradle/services/gradle-adapter-identifier.js +44 -0
- package/dist/adapters/gradle/services/gradle-module-detector.d.ts +18 -0
- package/dist/adapters/gradle/services/gradle-module-detector.d.ts.map +1 -0
- package/dist/adapters/gradle/services/gradle-module-detector.js +26 -0
- package/dist/adapters/gradle/services/gradle-module-system-factory.d.ts +23 -0
- package/dist/adapters/gradle/services/gradle-module-system-factory.d.ts.map +1 -0
- package/dist/adapters/gradle/services/gradle-module-system-factory.js +27 -0
- package/dist/adapters/gradle/services/gradle-version-update-strategy.d.ts +21 -0
- package/dist/adapters/gradle/services/gradle-version-update-strategy.d.ts.map +1 -0
- package/dist/adapters/gradle/services/gradle-version-update-strategy.js +36 -0
- package/dist/adapters/project-information.d.ts +58 -0
- package/dist/adapters/project-information.d.ts.map +1 -0
- package/dist/adapters/project-information.js +1 -0
- package/dist/changelog/index.d.ts +27 -0
- package/dist/changelog/index.d.ts.map +1 -0
- package/dist/changelog/index.js +204 -0
- package/dist/config/index.d.ts +122 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +115 -0
- package/dist/factories/adapter-identifier-registry.d.ts +12 -0
- package/dist/factories/adapter-identifier-registry.d.ts.map +1 -0
- package/dist/factories/adapter-identifier-registry.js +24 -0
- package/dist/factories/module-system-factory.d.ts +10 -0
- package/dist/factories/module-system-factory.d.ts.map +1 -0
- package/dist/factories/module-system-factory.js +18 -0
- package/dist/git/index.d.ts +253 -0
- package/dist/git/index.d.ts.map +1 -0
- package/dist/git/index.js +581 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/semver/index.d.ts +85 -0
- package/dist/semver/index.d.ts.map +1 -0
- package/dist/semver/index.js +176 -0
- package/dist/services/adapter-identifier-registry.d.ts +38 -0
- package/dist/services/adapter-identifier-registry.d.ts.map +1 -0
- package/dist/services/adapter-identifier-registry.js +59 -0
- package/dist/services/adapter-identifier.d.ts +31 -0
- package/dist/services/adapter-identifier.d.ts.map +1 -0
- package/dist/services/adapter-identifier.js +1 -0
- package/dist/services/adapter-metadata-provider.d.ts +51 -0
- package/dist/services/adapter-metadata-provider.d.ts.map +1 -0
- package/dist/services/adapter-metadata-provider.js +66 -0
- package/dist/services/changelog-generator.d.ts +13 -0
- package/dist/services/changelog-generator.d.ts.map +1 -0
- package/dist/services/changelog-generator.js +26 -0
- package/dist/services/commit-analyzer.d.ts +44 -0
- package/dist/services/commit-analyzer.d.ts.map +1 -0
- package/dist/services/commit-analyzer.js +86 -0
- package/dist/services/configuration-loader.d.ts +23 -0
- package/dist/services/configuration-loader.d.ts.map +1 -0
- package/dist/services/configuration-loader.js +79 -0
- package/dist/services/configuration-validator.d.ts +16 -0
- package/dist/services/configuration-validator.d.ts.map +1 -0
- package/dist/services/configuration-validator.js +24 -0
- package/dist/services/git-operations.d.ts +16 -0
- package/dist/services/git-operations.d.ts.map +1 -0
- package/dist/services/git-operations.js +89 -0
- package/dist/services/module-detector.d.ts +24 -0
- package/dist/services/module-detector.d.ts.map +1 -0
- package/dist/services/module-detector.js +1 -0
- package/dist/services/module-registry.d.ts +45 -0
- package/dist/services/module-registry.d.ts.map +1 -0
- package/dist/services/module-registry.js +57 -0
- package/dist/services/module-system-factory.d.ts +24 -0
- package/dist/services/module-system-factory.d.ts.map +1 -0
- package/dist/services/module-system-factory.js +1 -0
- package/dist/services/verse-runner.d.ts +45 -0
- package/dist/services/verse-runner.d.ts.map +1 -0
- package/dist/services/verse-runner.js +182 -0
- package/dist/services/version-applier.d.ts +26 -0
- package/dist/services/version-applier.d.ts.map +1 -0
- package/dist/services/version-applier.js +63 -0
- package/dist/services/version-bumper.d.ts +156 -0
- package/dist/services/version-bumper.d.ts.map +1 -0
- package/dist/services/version-bumper.js +291 -0
- package/dist/services/version-manager.d.ts +68 -0
- package/dist/services/version-manager.d.ts.map +1 -0
- package/dist/services/version-manager.js +94 -0
- package/dist/services/version-update-strategy.d.ts +18 -0
- package/dist/services/version-update-strategy.d.ts.map +1 -0
- package/dist/services/version-update-strategy.js +1 -0
- package/dist/utils/banner.d.ts +2 -0
- package/dist/utils/banner.d.ts.map +1 -0
- package/dist/utils/banner.js +8 -0
- package/dist/utils/commits.d.ts +12 -0
- package/dist/utils/commits.d.ts.map +1 -0
- package/dist/utils/commits.js +24 -0
- package/dist/utils/file.d.ts +7 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +19 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +22 -0
- package/dist/utils/properties.d.ts +16 -0
- package/dist/utils/properties.d.ts.map +1 -0
- package/dist/utils/properties.js +62 -0
- package/dist/utils/versioning.d.ts +8 -0
- package/dist/utils/versioning.d.ts.map +1 -0
- package/dist/utils/versioning.js +17 -0
- package/package.json +70 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { logger } from "../utils/logger.js";
|
|
2
|
+
import { getCommitsSinceLastTag } from "../git/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Analyzes git commits for each module, preventing double-counting in hierarchical structures.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Filters out child module commits from parent modules to ensure each commit is counted
|
|
8
|
+
* only in the most specific module it affects.
|
|
9
|
+
*/
|
|
10
|
+
export class CommitAnalyzer {
|
|
11
|
+
moduleRegistry;
|
|
12
|
+
repoRoot;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new CommitAnalyzer.
|
|
15
|
+
*
|
|
16
|
+
* @param moduleRegistry - Registry with all discovered modules
|
|
17
|
+
* @param repoRoot - Absolute path to repository root
|
|
18
|
+
*/
|
|
19
|
+
constructor(moduleRegistry, repoRoot) {
|
|
20
|
+
this.moduleRegistry = moduleRegistry;
|
|
21
|
+
this.repoRoot = repoRoot;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Analyzes commits since the last release for all modules.
|
|
25
|
+
*
|
|
26
|
+
* @returns Map of module ID to array of {@link CommitInfo} objects
|
|
27
|
+
* @throws {Error} If git operations fail
|
|
28
|
+
*/
|
|
29
|
+
async analyzeCommitsSinceLastRelease() {
|
|
30
|
+
logger.info("📝 Analyzing commits since last release...");
|
|
31
|
+
const moduleCommits = new Map();
|
|
32
|
+
// Iterate through all registered modules
|
|
33
|
+
for (const [projectId, projectInfo] of this.moduleRegistry.getModules()) {
|
|
34
|
+
// Find child module paths to exclude from this module's commits
|
|
35
|
+
// This prevents double-counting commits in the module hierarchy
|
|
36
|
+
const childModulePaths = this.findChildModulePaths(projectInfo.path, projectId);
|
|
37
|
+
// Retrieve commits for this module, excluding child modules
|
|
38
|
+
const commits = await getCommitsSinceLastTag(projectInfo.path, projectInfo.name, projectInfo.type, { cwd: this.repoRoot }, childModulePaths);
|
|
39
|
+
// Store commits for this module
|
|
40
|
+
moduleCommits.set(projectId, commits);
|
|
41
|
+
// Log exclusions for debugging
|
|
42
|
+
if (childModulePaths.length > 0) {
|
|
43
|
+
logger.debug(`🔍 Module ${projectInfo.id} excludes ${childModulePaths.length} child module(s): ${childModulePaths.join(", ")}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Calculate and log summary statistics
|
|
47
|
+
const totalCommits = Array.from(moduleCommits.values()).reduce((sum, commits) => sum + commits.length, 0);
|
|
48
|
+
logger.info(`📊 Analyzed ${totalCommits} commits across ${moduleCommits.size} modules`);
|
|
49
|
+
return moduleCommits;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Finds all child module paths for exclusion during commit analysis.
|
|
53
|
+
*
|
|
54
|
+
* @param modulePath - Parent module path
|
|
55
|
+
* @param moduleId - Parent module ID
|
|
56
|
+
* @returns Array of child module paths
|
|
57
|
+
*/
|
|
58
|
+
findChildModulePaths(modulePath, moduleId) {
|
|
59
|
+
const childPaths = [];
|
|
60
|
+
// Iterate through all modules to find children
|
|
61
|
+
for (const [otherId, otherInfo] of this.moduleRegistry.getModules()) {
|
|
62
|
+
// Skip the module itself
|
|
63
|
+
if (otherId !== moduleId &&
|
|
64
|
+
this.isChildPath(otherInfo.path, modulePath)) {
|
|
65
|
+
childPaths.push(otherInfo.path);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return childPaths;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Checks if a path is a child subdirectory of a parent path.
|
|
72
|
+
*
|
|
73
|
+
* @param childPath - Path to test
|
|
74
|
+
* @param parentPath - Potential parent path
|
|
75
|
+
* @returns `true` if childPath is a subdirectory of parentPath
|
|
76
|
+
*/
|
|
77
|
+
isChildPath(childPath, parentPath) {
|
|
78
|
+
// Special handling for root path - it's the parent of all non-root paths
|
|
79
|
+
if (parentPath === ".") {
|
|
80
|
+
return childPath !== ".";
|
|
81
|
+
}
|
|
82
|
+
// Check if child path starts with parent path followed by a path separator
|
|
83
|
+
// This ensures 'core/api' is a child of 'core', but 'core2' is not
|
|
84
|
+
return childPath.startsWith(parentPath + "/");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Config } from "../config/index.js";
|
|
2
|
+
import { ConfigurationValidator } from "./configuration-validator.js";
|
|
3
|
+
/**
|
|
4
|
+
* Loads and merges μVERSE configuration from various sources (.muverserc, muverse.config.js, package.json).
|
|
5
|
+
* Uses cosmiconfig for auto-discovery and merges user config with defaults.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ConfigurationLoader {
|
|
8
|
+
private readonly configurationValidator;
|
|
9
|
+
private readonly explorer;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new configuration loader.
|
|
12
|
+
* @param configurationValidator - Validator to ensure configuration integrity
|
|
13
|
+
*/
|
|
14
|
+
constructor(configurationValidator: ConfigurationValidator);
|
|
15
|
+
/**
|
|
16
|
+
* Loads and validates the μVERSE configuration.
|
|
17
|
+
* @param repoRoot - Absolute path to the repository root directory
|
|
18
|
+
* @returns A promise that resolves to the fully merged and validated configuration
|
|
19
|
+
* @throws {Error} If configuration loading or validation fails
|
|
20
|
+
*/
|
|
21
|
+
load(repoRoot: string): Promise<Config>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=configuration-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration-loader.d.ts","sourceRoot":"","sources":["../../src/services/configuration-loader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAkB,MAAM,oBAAoB,CAAC;AAG5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE;;;GAGG;AACH,qBAAa,mBAAmB;IAOlB,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IANnD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiB;IAE1C;;;OAGG;gBAC0B,sBAAsB,EAAE,sBAAsB;IAK3E;;;;;OAKG;IACG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAiC9C"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { logger } from "../utils/logger.js";
|
|
2
|
+
import { DEFAULT_CONFIG } from "../config/index.js";
|
|
3
|
+
import { cosmiconfig } from "cosmiconfig";
|
|
4
|
+
import deepmerge from "deepmerge";
|
|
5
|
+
/**
|
|
6
|
+
* Loads and merges μVERSE configuration from various sources (.muverserc, muverse.config.js, package.json).
|
|
7
|
+
* Uses cosmiconfig for auto-discovery and merges user config with defaults.
|
|
8
|
+
*/
|
|
9
|
+
export class ConfigurationLoader {
|
|
10
|
+
configurationValidator;
|
|
11
|
+
explorer;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new configuration loader.
|
|
14
|
+
* @param configurationValidator - Validator to ensure configuration integrity
|
|
15
|
+
*/
|
|
16
|
+
constructor(configurationValidator) {
|
|
17
|
+
this.configurationValidator = configurationValidator;
|
|
18
|
+
// Initialize cosmiconfig explorer once for reuse across multiple loads
|
|
19
|
+
this.explorer = cosmiconfig("muverse");
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Loads and validates the μVERSE configuration.
|
|
23
|
+
* @param repoRoot - Absolute path to the repository root directory
|
|
24
|
+
* @returns A promise that resolves to the fully merged and validated configuration
|
|
25
|
+
* @throws {Error} If configuration loading or validation fails
|
|
26
|
+
*/
|
|
27
|
+
async load(repoRoot) {
|
|
28
|
+
try {
|
|
29
|
+
logger.info(`🔍 Searching for μVERSE configuration...`);
|
|
30
|
+
// Search for config in standard locations
|
|
31
|
+
const result = await this.explorer.search(repoRoot);
|
|
32
|
+
let config;
|
|
33
|
+
if (result?.config) {
|
|
34
|
+
// Configuration found - merge, validate, and use it
|
|
35
|
+
const configSource = result.filepath
|
|
36
|
+
? `from ${result.filepath}`
|
|
37
|
+
: "from package.json";
|
|
38
|
+
logger.info(`📋 Configuration loaded ${configSource}`);
|
|
39
|
+
const userConfig = result.config;
|
|
40
|
+
const validatedConfig = mergeWithDefaults(userConfig);
|
|
41
|
+
config = this.configurationValidator.validate(validatedConfig);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// No configuration found - use defaults
|
|
45
|
+
logger.info(`No configuration found, using defaults`);
|
|
46
|
+
config = DEFAULT_CONFIG;
|
|
47
|
+
}
|
|
48
|
+
logger.info(`✅ Configuration loaded successfully`);
|
|
49
|
+
return config;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
// Wrap any errors with context for better debugging
|
|
53
|
+
throw new Error(`Failed to load configuration: ${error}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Custom array merge strategy for deepmerge.
|
|
59
|
+
* Replaces target array with source array instead of concatenating.
|
|
60
|
+
*/
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
+
const replaceArrayMerge = (_target, source) => source;
|
|
63
|
+
/**
|
|
64
|
+
* Deepmerge options for merging user configuration with defaults.
|
|
65
|
+
* Configures array replacement instead of concatenation.
|
|
66
|
+
*/
|
|
67
|
+
const defaultMergeOptions = {
|
|
68
|
+
arrayMerge: replaceArrayMerge,
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Merges user configuration with default configuration.
|
|
72
|
+
* User values take precedence over defaults. Arrays are replaced entirely rather than concatenated.
|
|
73
|
+
* @param userConfig - User-provided configuration to merge with defaults
|
|
74
|
+
* @returns Merged configuration with user values overriding defaults
|
|
75
|
+
*/
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
|
+
function mergeWithDefaults(userConfig) {
|
|
78
|
+
return deepmerge(DEFAULT_CONFIG, userConfig, defaultMergeOptions);
|
|
79
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Config } from "../config/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Validates μVERSE configuration against Zod schema for type safety and correctness.
|
|
4
|
+
* Ensures all configuration values conform to expected types and constraints,
|
|
5
|
+
* providing detailed error messages for any validation failures.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ConfigurationValidator {
|
|
8
|
+
/**
|
|
9
|
+
* Validates configuration against the schema and returns the validated result.
|
|
10
|
+
* @param config - Configuration object to validate
|
|
11
|
+
* @returns Validated and typed configuration object
|
|
12
|
+
* @throws {Error} If validation fails, with detailed error information
|
|
13
|
+
*/
|
|
14
|
+
validate(config: unknown): Config;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=configuration-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration-validator.d.ts","sourceRoot":"","sources":["../../src/services/configuration-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE/D;;;;GAIG;AACH,qBAAa,sBAAsB;IACjC;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM;CAUlC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { configSchema } from "../config/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Validates μVERSE configuration against Zod schema for type safety and correctness.
|
|
4
|
+
* Ensures all configuration values conform to expected types and constraints,
|
|
5
|
+
* providing detailed error messages for any validation failures.
|
|
6
|
+
*/
|
|
7
|
+
export class ConfigurationValidator {
|
|
8
|
+
/**
|
|
9
|
+
* Validates configuration against the schema and returns the validated result.
|
|
10
|
+
* @param config - Configuration object to validate
|
|
11
|
+
* @returns Validated and typed configuration object
|
|
12
|
+
* @throws {Error} If validation fails, with detailed error information
|
|
13
|
+
*/
|
|
14
|
+
validate(config) {
|
|
15
|
+
const result = configSchema.safeParse(config);
|
|
16
|
+
if (!result.success) {
|
|
17
|
+
const errors = result.error.issues
|
|
18
|
+
.map((e) => `${e.path.join(".")}: ${e.message}`)
|
|
19
|
+
.join(", ");
|
|
20
|
+
throw new Error(`Configuration validation failed: ${errors}`);
|
|
21
|
+
}
|
|
22
|
+
return result.data;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ModuleChangeResult } from "./version-applier.js";
|
|
2
|
+
export type GitOperationsOptions = {
|
|
3
|
+
pushChanges: boolean;
|
|
4
|
+
pushTags: boolean;
|
|
5
|
+
repoRoot: string;
|
|
6
|
+
dryRun: boolean;
|
|
7
|
+
isTemporaryVersion: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare class GitOperations {
|
|
10
|
+
private readonly options;
|
|
11
|
+
constructor(options: GitOperationsOptions);
|
|
12
|
+
commitAndPushChanges(moduleChangeResults: ModuleChangeResult[]): Promise<void>;
|
|
13
|
+
createAndPushTags(moduleChangeResults: ModuleChangeResult[]): Promise<string[]>;
|
|
14
|
+
private createCommitMessage;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=git-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-operations.d.ts","sourceRoot":"","sources":["../../src/services/git-operations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAU1D,MAAM,MAAM,oBAAoB,GAAG;IACjC,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,oBAAoB;IAEpD,oBAAoB,CACxB,mBAAmB,EAAE,kBAAkB,EAAE,GACxC,OAAO,CAAC,IAAI,CAAC;IA6CV,iBAAiB,CACrB,mBAAmB,EAAE,kBAAkB,EAAE,GACxC,OAAO,CAAC,MAAM,EAAE,CAAC;IAwDpB,OAAO,CAAC,mBAAmB;CAS5B"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { logger } from "../utils/logger.js";
|
|
2
|
+
import { addChangedFiles, commitChanges, pushCommits, hasChangesToCommit, createTag, pushTags, } from "../git/index.js";
|
|
3
|
+
export class GitOperations {
|
|
4
|
+
options;
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.options = options;
|
|
7
|
+
}
|
|
8
|
+
async commitAndPushChanges(moduleChangeResults) {
|
|
9
|
+
if (!this.options.pushChanges) {
|
|
10
|
+
logger.info("📦 Skipping commit and push (disabled by push-changes input)");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (this.options.dryRun) {
|
|
14
|
+
const commitMessage = this.createCommitMessage(moduleChangeResults);
|
|
15
|
+
logger.info(`📦 Dry run mode - would commit and push: ${commitMessage}`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
logger.info("📦 Committing and pushing changes...");
|
|
19
|
+
try {
|
|
20
|
+
// Add all changed files to staging area
|
|
21
|
+
await addChangedFiles({ cwd: this.options.repoRoot });
|
|
22
|
+
// Check if there are any changes to commit
|
|
23
|
+
const hasChanges = await hasChangesToCommit({
|
|
24
|
+
cwd: this.options.repoRoot,
|
|
25
|
+
});
|
|
26
|
+
if (hasChanges) {
|
|
27
|
+
// Create commit message
|
|
28
|
+
const commitMessage = this.createCommitMessage(moduleChangeResults);
|
|
29
|
+
// Commit changes
|
|
30
|
+
await commitChanges(commitMessage, { cwd: this.options.repoRoot });
|
|
31
|
+
logger.info(` Committed changes: ${commitMessage}`);
|
|
32
|
+
// Push commits to remote
|
|
33
|
+
await pushCommits({ cwd: this.options.repoRoot });
|
|
34
|
+
logger.info(" Pushed commits to remote");
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
logger.info(" No changes to commit");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
logger.warning(`Failed to commit and push changes: ${error}`);
|
|
42
|
+
// Continue execution - don't fail the entire process if git operations fail
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async createAndPushTags(moduleChangeResults) {
|
|
46
|
+
const createdTags = [];
|
|
47
|
+
if (this.options.isTemporaryVersion) {
|
|
48
|
+
logger.info("🏷️ Skipping tag creation and push (temporary version enabled)");
|
|
49
|
+
return createdTags;
|
|
50
|
+
}
|
|
51
|
+
const disabledBy = [
|
|
52
|
+
this.options.dryRun && "dry-run",
|
|
53
|
+
!this.options.pushTags && "push-tags",
|
|
54
|
+
!this.options.pushChanges && "push-changes",
|
|
55
|
+
]
|
|
56
|
+
.filter(Boolean)
|
|
57
|
+
.join(", ");
|
|
58
|
+
logger.info("🔍 Filtering modules with declared versions...");
|
|
59
|
+
const modulesWithDeclaredVersions = moduleChangeResults.filter((change) => change.declaredVersion);
|
|
60
|
+
if (disabledBy) {
|
|
61
|
+
logger.info(`🏷️ Skipping tag creation and push (disabled by ${disabledBy} input(s))`);
|
|
62
|
+
for (const change of modulesWithDeclaredVersions) {
|
|
63
|
+
const tagName = `${change.name}@${change.to}`;
|
|
64
|
+
createdTags.push(tagName);
|
|
65
|
+
logger.info(` Would create tag: ${tagName}`);
|
|
66
|
+
}
|
|
67
|
+
return createdTags;
|
|
68
|
+
}
|
|
69
|
+
logger.info("🏷️ Creating tags...");
|
|
70
|
+
for (const change of modulesWithDeclaredVersions) {
|
|
71
|
+
const tagName = `${change.name}@${change.to}`;
|
|
72
|
+
const message = `Release ${change.name} v${change.to}`;
|
|
73
|
+
createTag(tagName, message, { cwd: this.options.repoRoot });
|
|
74
|
+
createdTags.push(tagName);
|
|
75
|
+
logger.info(` Created tag: ${tagName}`);
|
|
76
|
+
}
|
|
77
|
+
// Push tags
|
|
78
|
+
logger.info("📤 Pushing tags...");
|
|
79
|
+
pushTags({ cwd: this.options.repoRoot });
|
|
80
|
+
logger.info(`✅ Pushed ${createdTags.length} tags to remote`);
|
|
81
|
+
return createdTags;
|
|
82
|
+
}
|
|
83
|
+
createCommitMessage(moduleChangeResults) {
|
|
84
|
+
const moduleNames = moduleChangeResults.map((change) => change.name);
|
|
85
|
+
return moduleNames.length === 1
|
|
86
|
+
? `chore(release): ${moduleNames[0]} ${moduleChangeResults[0].to}`
|
|
87
|
+
: `chore(release): update ${moduleNames.length} modules`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ModuleRegistry } from "./module-registry.js";
|
|
2
|
+
/**
|
|
3
|
+
* Interface for detecting modules in a multi-module repository.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Transforms repository file structure into a structured {@link ModuleRegistry}.
|
|
7
|
+
* Different implementations exist for different build systems (Gradle, Maven, npm).
|
|
8
|
+
* Created by {@link ModuleSystemFactory}.
|
|
9
|
+
*/
|
|
10
|
+
export interface ModuleDetector {
|
|
11
|
+
/**
|
|
12
|
+
* The absolute path to the repository root directory.
|
|
13
|
+
* Used for resolving module paths and executing build commands.
|
|
14
|
+
*/
|
|
15
|
+
readonly repoRoot: string;
|
|
16
|
+
/**
|
|
17
|
+
* Detects all modules in the repository and returns a populated module registry.
|
|
18
|
+
*
|
|
19
|
+
* @returns Promise resolving to {@link ModuleRegistry} with all discovered modules
|
|
20
|
+
* @throws {Error} If repository is invalid, build files are missing, or detection fails
|
|
21
|
+
*/
|
|
22
|
+
detect(): Promise<ModuleRegistry>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=module-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-detector.d.ts","sourceRoot":"","sources":["../../src/services/module-detector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;;;;OAKG;IACH,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Module, ProjectInformation } from "../adapters/project-information.js";
|
|
2
|
+
/**
|
|
3
|
+
* Registry for managing module hierarchy and metadata.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Wraps {@link ProjectInformation} with a clean API for querying module data.
|
|
7
|
+
* Provides fast O(1) lookup by module ID.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ModuleRegistry {
|
|
10
|
+
private readonly projectInformation;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new ModuleRegistry.
|
|
13
|
+
*
|
|
14
|
+
* @param projectInformation - Complete project structure with all discovered modules
|
|
15
|
+
*/
|
|
16
|
+
constructor(projectInformation: ProjectInformation);
|
|
17
|
+
/**
|
|
18
|
+
* Gets all module IDs in the project.
|
|
19
|
+
*
|
|
20
|
+
* @returns Array of module ID strings
|
|
21
|
+
*/
|
|
22
|
+
getModuleIds(): string[];
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves module information by ID.
|
|
25
|
+
*
|
|
26
|
+
* @param moduleId - Module identifier (e.g., `':'`, `':core'`)
|
|
27
|
+
* @returns Module object with metadata
|
|
28
|
+
* @throws {Error} If module ID doesn't exist
|
|
29
|
+
*/
|
|
30
|
+
getModule(moduleId: string): Module;
|
|
31
|
+
/**
|
|
32
|
+
* Checks if a module with the given ID exists.
|
|
33
|
+
*
|
|
34
|
+
* @param moduleId - Module identifier to check
|
|
35
|
+
* @returns `true` if module exists, `false` otherwise
|
|
36
|
+
*/
|
|
37
|
+
hasModule(moduleId: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Gets all modules as a readonly map.
|
|
40
|
+
*
|
|
41
|
+
* @returns Readonly map of module ID to {@link Module}
|
|
42
|
+
*/
|
|
43
|
+
getModules(): ReadonlyMap<string, Module>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=module-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-registry.d.ts","sourceRoot":"","sources":["../../src/services/module-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAEhF;;;;;;GAMG;AACH,qBAAa,cAAc;IAMb,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IAL/C;;;;OAIG;gBAC0B,kBAAkB,EAAE,kBAAkB;IAEnE;;;;OAIG;IACH,YAAY,IAAI,MAAM,EAAE;IAIxB;;;;;;OAMG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAQnC;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIpC;;;;OAIG;IACH,UAAU,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC;CAG1C"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry for managing module hierarchy and metadata.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Wraps {@link ProjectInformation} with a clean API for querying module data.
|
|
6
|
+
* Provides fast O(1) lookup by module ID.
|
|
7
|
+
*/
|
|
8
|
+
export class ModuleRegistry {
|
|
9
|
+
projectInformation;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new ModuleRegistry.
|
|
12
|
+
*
|
|
13
|
+
* @param projectInformation - Complete project structure with all discovered modules
|
|
14
|
+
*/
|
|
15
|
+
constructor(projectInformation) {
|
|
16
|
+
this.projectInformation = projectInformation;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Gets all module IDs in the project.
|
|
20
|
+
*
|
|
21
|
+
* @returns Array of module ID strings
|
|
22
|
+
*/
|
|
23
|
+
getModuleIds() {
|
|
24
|
+
return this.projectInformation.moduleIds;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves module information by ID.
|
|
28
|
+
*
|
|
29
|
+
* @param moduleId - Module identifier (e.g., `':'`, `':core'`)
|
|
30
|
+
* @returns Module object with metadata
|
|
31
|
+
* @throws {Error} If module ID doesn't exist
|
|
32
|
+
*/
|
|
33
|
+
getModule(moduleId) {
|
|
34
|
+
const projectInfo = this.projectInformation.modules.get(moduleId);
|
|
35
|
+
if (!projectInfo) {
|
|
36
|
+
throw new Error(`Module ${moduleId} not found`);
|
|
37
|
+
}
|
|
38
|
+
return projectInfo;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Checks if a module with the given ID exists.
|
|
42
|
+
*
|
|
43
|
+
* @param moduleId - Module identifier to check
|
|
44
|
+
* @returns `true` if module exists, `false` otherwise
|
|
45
|
+
*/
|
|
46
|
+
hasModule(moduleId) {
|
|
47
|
+
return this.projectInformation.modules.has(moduleId);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets all modules as a readonly map.
|
|
51
|
+
*
|
|
52
|
+
* @returns Readonly map of module ID to {@link Module}
|
|
53
|
+
*/
|
|
54
|
+
getModules() {
|
|
55
|
+
return this.projectInformation.modules;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ModuleDetector } from "./module-detector.js";
|
|
2
|
+
import { VersionUpdateStrategy } from "./version-update-strategy.js";
|
|
3
|
+
/**
|
|
4
|
+
* Factory for creating build system-specific module components.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Implements the Abstract Factory pattern. Each build system (Gradle, Maven, npm)
|
|
8
|
+
* provides its own implementation to create compatible detector and strategy instances.
|
|
9
|
+
*/
|
|
10
|
+
export interface ModuleSystemFactory {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a module detector for discovering modules.
|
|
13
|
+
*
|
|
14
|
+
* @returns {@link ModuleDetector} configured for this build system
|
|
15
|
+
*/
|
|
16
|
+
createDetector(): ModuleDetector;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a version update strategy for writing versions to build files.
|
|
19
|
+
*
|
|
20
|
+
* @returns {@link VersionUpdateStrategy} configured for this build system
|
|
21
|
+
*/
|
|
22
|
+
createVersionUpdateStrategy(): VersionUpdateStrategy;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=module-system-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-system-factory.d.ts","sourceRoot":"","sources":["../../src/services/module-system-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,cAAc,IAAI,cAAc,CAAC;IAEjC;;;;OAIG;IACH,2BAA2B,IAAI,qBAAqB,CAAC;CACtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ModuleChangeResult } from "./version-applier.js";
|
|
2
|
+
import { Module } from "../adapters/project-information.js";
|
|
3
|
+
export type RunnerOptions = {
|
|
4
|
+
readonly repoRoot: string;
|
|
5
|
+
readonly adapter?: string;
|
|
6
|
+
readonly dryRun: boolean;
|
|
7
|
+
readonly pushTags: boolean;
|
|
8
|
+
readonly prereleaseMode: boolean;
|
|
9
|
+
readonly prereleaseId: string;
|
|
10
|
+
readonly bumpUnchanged: boolean;
|
|
11
|
+
readonly addBuildMetadata: boolean;
|
|
12
|
+
readonly timestampVersions: boolean;
|
|
13
|
+
readonly appendSnapshot: boolean;
|
|
14
|
+
readonly pushChanges: boolean;
|
|
15
|
+
readonly generateChangelog: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type RunnerResult = {
|
|
18
|
+
readonly bumped: boolean;
|
|
19
|
+
readonly discoveredModules: Array<Module>;
|
|
20
|
+
readonly changedModules: Array<ModuleChangeResult>;
|
|
21
|
+
readonly createdTags: string[];
|
|
22
|
+
readonly changelogPaths: string[];
|
|
23
|
+
};
|
|
24
|
+
export declare class VerseRunner {
|
|
25
|
+
private moduleSystemFactory;
|
|
26
|
+
private moduleRegistry;
|
|
27
|
+
private versionManager;
|
|
28
|
+
private config;
|
|
29
|
+
private adapter;
|
|
30
|
+
private options;
|
|
31
|
+
private configurationLoader;
|
|
32
|
+
private commitAnalyzer;
|
|
33
|
+
private versionBumper;
|
|
34
|
+
private versionApplier;
|
|
35
|
+
private changelogGenerator;
|
|
36
|
+
private gitOperations;
|
|
37
|
+
private adapterIdentifierRegistry;
|
|
38
|
+
private adapterMetadataProvider;
|
|
39
|
+
constructor(options: RunnerOptions);
|
|
40
|
+
private logStartupInfo;
|
|
41
|
+
private logShutdownInfo;
|
|
42
|
+
run(): Promise<RunnerResult>;
|
|
43
|
+
private doRun;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=verse-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verse-runner.d.ts","sourceRoot":"","sources":["../../src/services/verse-runner.ts"],"names":[],"mappings":"AAYA,OAAO,EAGL,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAO9B,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAI5D,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1C,QAAQ,CAAC,cAAc,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACnD,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;CACnC,CAAC;AAEF,qBAAa,WAAW;IACtB,OAAO,CAAC,mBAAmB,CAAuB;IAClD,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,OAAO,CAAgB;IAG/B,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,aAAa,CAAiB;IACtC,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,aAAa,CAAiB;IACtC,OAAO,CAAC,yBAAyB,CAA4B;IAC7D,OAAO,CAAC,uBAAuB,CAA0B;gBAE7C,OAAO,EAAE,aAAa;IAsBlC,OAAO,CAAC,cAAc;IAsBtB,OAAO,CAAC,eAAe;IAgCjB,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC;YAYpB,KAAK;CAkIpB"}
|