@versu/plugin-gradle 0.6.5 → 0.6.6

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/dist/constants.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /** Standard filename for Gradle project properties file ('gradle.properties'). */
2
- export const GRADLE_PROPERTIES_FILE = 'gradle.properties';
2
+ export const GRADLE_PROPERTIES_FILE = "gradle.properties";
3
3
  /** Standard filename for Gradle build script using Groovy DSL ('build.gradle'). */
4
- export const GRADLE_BUILD_FILE = 'build.gradle';
4
+ export const GRADLE_BUILD_FILE = "build.gradle";
5
5
  /** Standard filename for Gradle build script using Kotlin DSL ('build.gradle.kts'). */
6
- export const GRADLE_BUILD_KTS_FILE = 'build.gradle.kts';
6
+ export const GRADLE_BUILD_KTS_FILE = "build.gradle.kts";
7
7
  /** Standard filename for Gradle settings file using Groovy DSL ('settings.gradle'). */
8
- export const GRADLE_SETTINGS_FILE = 'settings.gradle';
8
+ export const GRADLE_SETTINGS_FILE = "settings.gradle";
9
9
  /** Standard filename for Gradle settings file using Kotlin DSL ('settings.gradle.kts'). */
10
- export const GRADLE_SETTINGS_KTS_FILE = 'settings.gradle.kts';
10
+ export const GRADLE_SETTINGS_KTS_FILE = "settings.gradle.kts";
11
11
  /** Unique identifier for the Gradle adapter ('gradle'). */
12
- export const GRADLE_ID = 'gradle';
12
+ export const GRADLE_ID = "gradle";
@@ -1,4 +1,4 @@
1
- import { ProjectInformation, RawProjectInformation } from '@versu/core';
1
+ import { ProjectInformation, RawProjectInformation } from "@versu/core";
2
2
  /**
3
3
  * Executes Gradle to collect raw project structure information.
4
4
  * Runs gradlew with init script to output JSON containing module hierarchy, versions, and dependencies.
@@ -1 +1 @@
1
- {"version":3,"file":"gradle-project-information.d.ts","sourceRoot":"","sources":["../src/gradle-project-information.ts"],"names":[],"mappings":"AAMA,OAAO,EAA0F,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAqHhK;;;;;;;GAOG;AACH,wBAAsB,wBAAwB,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAyEtH;AA2CD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,kBAAkB,EAAE,qBAAqB,GAAG,kBAAkB,CA6CnG"}
1
+ {"version":3,"file":"gradle-project-information.d.ts","sourceRoot":"","sources":["../src/gradle-project-information.ts"],"names":[],"mappings":"AAMA,OAAO,EAQL,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAwHrB;;;;;;;GAOG;AACH,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,qBAAqB,CAAC,CAoFhC;AA2CD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,kBAAkB,EAAE,qBAAqB,GACxC,kBAAkB,CA8CpB"}
@@ -1,20 +1,20 @@
1
- import path, { join } from 'path';
2
- import { fileURLToPath } from 'url';
3
- import { execa } from 'execa';
4
- import fs from 'fs/promises';
5
- import crypto from 'crypto';
6
- import fg from 'fast-glob';
7
- import { createInitialVersion, exists, logger, parseProperties, parseSemVer } from '@versu/core';
1
+ import path, { join } from "path";
2
+ import { fileURLToPath } from "url";
3
+ import { execa } from "execa";
4
+ import fs from "fs/promises";
5
+ import crypto from "crypto";
6
+ import fg from "fast-glob";
7
+ import { createInitialVersion, exists, logger, parseProperties, parseSemVer, } from "@versu/core";
8
8
  /**
9
9
  * Name of the Gradle wrapper script file.
10
10
  * Ensures consistent builds without requiring pre-installed Gradle.
11
11
  */
12
- const GRADLE_WRAPPER = 'gradlew';
12
+ const GRADLE_WRAPPER = "gradlew";
13
13
  /**
14
14
  * Relative path to the Gradle initialization script within the action.
15
15
  * Injected into Gradle to collect project structure information as JSON.
16
16
  */
17
- const GRADLE_INIT_SCRIPT = './init-project-information.gradle.kts';
17
+ const GRADLE_INIT_SCRIPT = "./init-project-information.gradle.kts";
18
18
  /**
19
19
  * Finds all Gradle build files recursively under the project root.
20
20
  * Searches for settings.gradle, settings.gradle.kts, build.gradle, and build.gradle.kts files.
@@ -23,15 +23,15 @@ const GRADLE_INIT_SCRIPT = './init-project-information.gradle.kts';
23
23
  */
24
24
  async function findGradleFiles(projectRoot) {
25
25
  const patterns = [
26
- '**/settings.gradle',
27
- '**/settings.gradle.kts',
28
- '**/build.gradle',
29
- '**/build.gradle.kts'
26
+ "**/settings.gradle",
27
+ "**/settings.gradle.kts",
28
+ "**/build.gradle",
29
+ "**/build.gradle.kts",
30
30
  ];
31
31
  const files = await fg(patterns, {
32
32
  cwd: projectRoot,
33
33
  absolute: false,
34
- ignore: ['**/node_modules/**', '**/build/**', '**/.gradle/**']
34
+ ignore: ["**/node_modules/**", "**/build/**", "**/.gradle/**"],
35
35
  });
36
36
  // Sort for consistent ordering
37
37
  return files.sort();
@@ -44,13 +44,13 @@ async function findGradleFiles(projectRoot) {
44
44
  */
45
45
  async function computeGradleFilesHash(projectRoot) {
46
46
  const files = await findGradleFiles(projectRoot);
47
- const hash = crypto.createHash('sha256');
47
+ const hash = crypto.createHash("sha256");
48
48
  for (const file of files) {
49
- const content = await fs.readFile(join(projectRoot, file), 'utf-8');
49
+ const content = await fs.readFile(join(projectRoot, file), "utf-8");
50
50
  hash.update(file); // Include file path for uniqueness
51
51
  hash.update(content);
52
52
  }
53
- return hash.digest('hex');
53
+ return hash.digest("hex");
54
54
  }
55
55
  /**
56
56
  * Executes the Gradle wrapper script to generate project information.
@@ -72,17 +72,17 @@ async function executeGradleScript(projectRoot, outputFile) {
72
72
  }
73
73
  // Prepare Gradle command arguments
74
74
  const args = [
75
- '--quiet', // Suppress non-error output for clean JSON
76
- '--console=plain', // Disable ANSI formatting
77
- '--init-script', // Inject initialization script
75
+ "--quiet", // Suppress non-error output for clean JSON
76
+ "--console=plain", // Disable ANSI formatting
77
+ "--init-script", // Inject initialization script
78
78
  initScriptPath,
79
- 'structure', // Custom task that outputs project structure
80
- `-PprojectInfoOutput=${outputFile}`
79
+ "structure", // Custom task that outputs project structure
80
+ `-PprojectInfoOutput=${outputFile}`,
81
81
  ];
82
82
  // Execute Gradle wrapper with the prepared arguments
83
83
  const result = await execa(gradlew, args, {
84
84
  cwd: projectRoot, // Run from project root
85
- reject: false // Handle non-zero exit codes ourselves
85
+ reject: false, // Handle non-zero exit codes ourselves
86
86
  });
87
87
  // Check for Gradle execution failure
88
88
  if (result.exitCode !== 0) {
@@ -110,7 +110,7 @@ export async function getRawProjectInformation(projectRoot, outputFile) {
110
110
  logger.info(`💾 Cached project information found at ${outputFile}. Validating cache...`);
111
111
  // Step 2: File exists, check cache validity
112
112
  try {
113
- const fileContent = await fs.readFile(outputFile, 'utf-8');
113
+ const fileContent = await fs.readFile(outputFile, "utf-8");
114
114
  const cachedData = JSON.parse(fileContent);
115
115
  // Step 2.1: Compare hashes
116
116
  if (cachedData.hash === currentHash) {
@@ -132,7 +132,7 @@ export async function getRawProjectInformation(projectRoot, outputFile) {
132
132
  }
133
133
  if (executeScript) {
134
134
  // Step 3: File doesn't exist or cache is invalid - execute Gradle script
135
- const outputFile = join(projectRoot, 'build', 'project-information.json');
135
+ const outputFile = join(projectRoot, "build", "project-information.json");
136
136
  await executeGradleScript(projectRoot, outputFile);
137
137
  // Verify that the output file was created
138
138
  const fileExistsAfterExec = await exists(outputFile);
@@ -141,14 +141,14 @@ export async function getRawProjectInformation(projectRoot, outputFile) {
141
141
  `Ensure that the Gradle init script is correctly generating the project information.`);
142
142
  }
143
143
  // Read the output file content
144
- const fileContent = await fs.readFile(outputFile, 'utf-8');
144
+ const fileContent = await fs.readFile(outputFile, "utf-8");
145
145
  // Parse JSON output from Gradle
146
- data = JSON.parse(fileContent.trim() || '{}');
146
+ data = JSON.parse(fileContent.trim() || "{}");
147
147
  }
148
148
  // Compute hash and save with cache information
149
149
  const cachedData = {
150
150
  hash: currentHash,
151
- data
151
+ data,
152
152
  };
153
153
  // Read gradle.properites and add version
154
154
  const projectInformation = await getInformationWithVersions(projectRoot, data);
@@ -156,7 +156,7 @@ export async function getRawProjectInformation(projectRoot, outputFile) {
156
156
  // Write back to file with hash for future cache validation
157
157
  const dirname = path.dirname(outputFile);
158
158
  await fs.mkdir(dirname, { recursive: true });
159
- await fs.writeFile(outputFile, JSON.stringify(cachedData, null, 2), 'utf-8');
159
+ await fs.writeFile(outputFile, JSON.stringify(cachedData, null, 2), "utf-8");
160
160
  }
161
161
  return projectInformation;
162
162
  }
@@ -167,7 +167,7 @@ export async function getRawProjectInformation(projectRoot, outputFile) {
167
167
  * @returns Promise resolving to augmented RawProjectInformation with versions
168
168
  */
169
169
  async function getInformationWithVersions(projectRoot, projectInformation) {
170
- const gradlePropertiesFile = join(projectRoot, 'gradle.properties');
170
+ const gradlePropertiesFile = join(projectRoot, "gradle.properties");
171
171
  const gradlePropertiesExists = await exists(gradlePropertiesFile);
172
172
  const result = {};
173
173
  let moduleVersions = new Map();
@@ -179,7 +179,7 @@ async function getInformationWithVersions(projectRoot, projectInformation) {
179
179
  result[moduleId] = {
180
180
  ...module,
181
181
  version: resultVersion,
182
- declaredVersion: resultVersion !== undefined
182
+ declaredVersion: resultVersion !== undefined,
183
183
  };
184
184
  }
185
185
  }
@@ -198,7 +198,7 @@ export function getProjectInformation(projectInformation) {
198
198
  // Find root module by looking for the one with type 'root'
199
199
  let rootModule;
200
200
  for (const [moduleId, rawModule] of Object.entries(projectInformation)) {
201
- if (rawModule.type === 'root') {
201
+ if (rawModule.type === "root") {
202
202
  rootModule = moduleId;
203
203
  }
204
204
  // Create normalized Module object
@@ -209,24 +209,24 @@ export function getProjectInformation(projectInformation) {
209
209
  type: rawModule.type,
210
210
  affectedModules: new Set(rawModule.affectedModules),
211
211
  // Parse version if present, otherwise create initial version
212
- version: rawModule.version === undefined ?
213
- createInitialVersion() :
214
- parseSemVer(rawModule.version),
212
+ version: rawModule.version === undefined
213
+ ? createInitialVersion()
214
+ : parseSemVer(rawModule.version),
215
215
  declaredVersion: rawModule.declaredVersion,
216
216
  };
217
- if ('versionProperty' in rawModule) {
218
- module['versionProperty'] = rawModule.versionProperty;
217
+ if ("versionProperty" in rawModule) {
218
+ module["versionProperty"] = rawModule.versionProperty;
219
219
  }
220
220
  modules.set(moduleId, module);
221
221
  }
222
222
  // Validate that a root module was found
223
223
  if (!rootModule) {
224
- throw new Error('No root module found in hierarchy. ' +
224
+ throw new Error("No root module found in hierarchy. " +
225
225
  'Every project hierarchy must contain exactly one module with type "root".');
226
226
  }
227
227
  return {
228
228
  moduleIds,
229
229
  modules,
230
- rootModule
230
+ rootModule,
231
231
  };
232
232
  }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { PluginContract } from "../../core/dist/plugins/plugin-loader.js";
1
+ import type { PluginContract } from "@versu/core";
2
2
  declare const gradlePlugin: PluginContract;
3
3
  export default gradlePlugin;
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAK1E,QAAA,MAAM,YAAY,EAAE,cAenB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKlD,QAAA,MAAM,YAAY,EAAE,cAenB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "0.6.5";
1
+ export declare const VERSION = "0.6.6";
2
2
  export declare const PACKAGE_NAME = "@versu/plugin-gradle";
3
3
  export declare const AUTHORS = "tvcsantos";
4
4
  //# sourceMappingURL=version.d.ts.map
@@ -1,5 +1,5 @@
1
1
  // This file is auto-generated. Do not edit manually.
2
2
  // Run 'npm run generate-version' to update this file.
3
- export const VERSION = "0.6.5";
3
+ export const VERSION = "0.6.6";
4
4
  export const PACKAGE_NAME = "@versu/plugin-gradle";
5
5
  export const AUTHORS = "tvcsantos";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versu/plugin-gradle",
3
- "version": "0.6.5",
3
+ "version": "0.6.6",
4
4
  "description": "VERSU Gradle Plugin",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -50,10 +50,10 @@
50
50
  "fast-glob": "^3.3.3"
51
51
  },
52
52
  "peerDependencies": {
53
- "@versu/core": "^0.6.5"
53
+ "@versu/core": "^0.6.6"
54
54
  },
55
55
  "devDependencies": {
56
- "@versu/core": "^0.6.5",
56
+ "@versu/core": "^0.6.6",
57
57
  "@types/node": "^20.19.23",
58
58
  "@types/semver": "^7.7.1",
59
59
  "@typescript-eslint/eslint-plugin": "^6.15.0",