@muverse/core 0.1.12 → 0.1.14

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.
@@ -1 +1 @@
1
- {"version":3,"file":"gradle-project-information.d.ts","sourceRoot":"","sources":["../../../src/adapters/gradle/gradle-project-information.ts"],"names":[],"mappings":"AAGA,OAAO,EAAU,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAgB9F;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAsClG;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,kBAAkB,EAAE,qBAAqB,GAAG,kBAAkB,CAuCnG"}
1
+ {"version":3,"file":"gradle-project-information.d.ts","sourceRoot":"","sources":["../../../src/adapters/gradle/gradle-project-information.ts"],"names":[],"mappings":"AAGA,OAAO,EAAU,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAiB9F;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAoDlG;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,kBAAkB,EAAE,qBAAqB,GAAG,kBAAkB,CA6CnG"}
@@ -3,6 +3,7 @@ import { createInitialVersion, parseSemVer } from '../../semver/index.js';
3
3
  import { exists } from '../../utils/file.js';
4
4
  import { fileURLToPath } from 'url';
5
5
  import { execa } from 'execa';
6
+ import fs from 'fs/promises';
6
7
  /**
7
8
  * Name of the Gradle wrapper script file.
8
9
  * Ensures consistent builds without requiring pre-installed Gradle.
@@ -47,8 +48,17 @@ export async function getRawProjectInformation(projectRoot) {
47
48
  if (result.exitCode !== 0) {
48
49
  throw new Error(`Gradle command failed with exit code ${result.exitCode}: ${result.stderr}`);
49
50
  }
51
+ const file = join(projectRoot, 'build', 'project-information.json');
52
+ // Verify that the output file was created
53
+ const fileExists = await exists(file);
54
+ if (!fileExists) {
55
+ throw new Error(`Expected output file not found at ${file}. ` +
56
+ `Ensure that the Gradle init script is correctly generating the project information.`);
57
+ }
58
+ // Read the output file content
59
+ const projectInformation = await fs.readFile(file, 'utf-8');
50
60
  // Parse JSON output from Gradle
51
- return JSON.parse(result.stdout.trim() || '{}');
61
+ return JSON.parse(projectInformation.trim() || '{}');
52
62
  }
53
63
  /**
54
64
  * Transforms raw project information into structured, queryable format.
@@ -62,23 +72,27 @@ export function getProjectInformation(projectInformation) {
62
72
  const modules = new Map();
63
73
  // Find root module by looking for the one with type 'root'
64
74
  let rootModule;
65
- for (const [moduleId, module] of Object.entries(projectInformation)) {
66
- if (module.type === 'root') {
75
+ for (const [moduleId, rawModule] of Object.entries(projectInformation)) {
76
+ if (rawModule.type === 'root') {
67
77
  rootModule = moduleId;
68
78
  }
69
79
  // Create normalized Module object
70
- modules.set(moduleId, {
80
+ const module = {
71
81
  id: moduleId,
72
- name: module.name,
73
- path: module.path,
74
- type: module.type,
75
- affectedModules: new Set(module.affectedModules),
82
+ name: rawModule.name,
83
+ path: rawModule.path,
84
+ type: rawModule.type,
85
+ affectedModules: new Set(rawModule.affectedModules),
76
86
  // Parse version if present, otherwise create initial version
77
- version: module.version === undefined ?
87
+ version: rawModule.version === undefined ?
78
88
  createInitialVersion() :
79
- parseSemVer(module.version),
80
- declaredVersion: module.declaredVersion,
81
- });
89
+ parseSemVer(rawModule.version),
90
+ declaredVersion: rawModule.declaredVersion,
91
+ };
92
+ if ('versionProperty' in rawModule) {
93
+ module['versionProperty'] = rawModule.versionProperty;
94
+ }
95
+ modules.set(moduleId, module);
82
96
  }
83
97
  // Validate that a root module was found
84
98
  if (!rootModule) {
@@ -25,6 +25,7 @@ gradle.rootProject {
25
25
  tasks.register("printProjectInformation") {
26
26
  group = "help"
27
27
  description = "Shows which subprojects are affected by changes (hierarchy + direct dependencies)."
28
+ notCompatibleWithConfigurationCache("uses project information at configuration time")
28
29
 
29
30
  // Capture hierarchy data at configuration time
30
31
  val hierarchyDepsProvider = provider {
@@ -58,7 +59,7 @@ gradle.rootProject {
58
59
  // Check regular dependencies
59
60
  config.dependencies.forEach { dep ->
60
61
  if (dep is ProjectDependency) {
61
- directDeps.add(dep.dependencyProject.path)
62
+ directDeps.add(dep.path)
62
63
  }
63
64
  }
64
65
 
@@ -83,7 +84,7 @@ gradle.rootProject {
83
84
 
84
85
  gradle.rootProject.allprojects.forEach { project ->
85
86
  val relativePath = gradle.rootProject.projectDir.toPath().relativize(project.projectDir.toPath()).toString()
86
- val path = if (relativePath.isEmpty()) "." else relativePath
87
+ val path = relativePath.ifEmpty { "." }
87
88
  val version = if (project.version == "unspecified") null else project.version
88
89
  val type = if (project == gradle.rootProject) "root" else "module"
89
90
  val versionProperty = project.qualifiedVersionProperty()
@@ -138,7 +139,17 @@ gradle.rootProject {
138
139
  .excludeNulls()
139
140
  .build()
140
141
 
141
- println(JsonOutput.prettyPrint(generator.toJson(result)))
142
+ val json = JsonOutput.prettyPrint(generator.toJson(result))
143
+
144
+ // Get output path from project property or use default
145
+ val outputPath = project.findProperty("projectInfoOutput") as? String
146
+ ?: "${layout.buildDirectory.asFile.get().path}/project-information.json"
147
+
148
+ val outputFile = file(outputPath)
149
+ outputFile.parentFile.mkdirs()
150
+ outputFile.writeText(json)
151
+
152
+ println("Project information written to: ${outputFile.absolutePath}")
142
153
  }
143
154
  }
144
155
 
@@ -47,7 +47,7 @@ export type RawModule = {
47
47
  readonly type: "module" | "root";
48
48
  /** Whether the version is explicitly declared in build configuration. */
49
49
  readonly declaredVersion: boolean;
50
- };
50
+ } & Record<string, unknown>;
51
51
  /**
52
52
  * Raw project structure information as extracted from the build system.
53
53
  * Maps module IDs to their raw module data.
@@ -1 +1 @@
1
- {"version":3,"file":"project-information.d.ts","sourceRoot":"","sources":["../../src/adapters/project-information.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE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C;IAEtB,6DAA6D;IAC7D,QAAQ,CAAC,eAAe,EAAE,MAAM,EAAE,CAAC;IAEnC,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IAEjC,yEAAyE;IACzE,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CACnC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5B;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muverse/core",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "Version Engine for Repo Semantic Evolution (Core Library)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",