New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

npm-groovy-lint

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-groovy-lint - npm Package Compare versions

Comparing version

to
5.1.0

# Changelog
## [5.1.0] 2020-06-04
- Install Java 8 using node-jre in case java version found is higher than Java 11 (CodeNarc compatibility is Java 8 to 11)
## [5.0.3] 2020-05-30

@@ -4,0 +8,0 @@

@@ -26,2 +26,4 @@ // Call CodeNarc by server or java

codeNarcServer: {
minimumJavaVersion: 1.8,
maximumJavaVersion: 11.99,
mainClass: "com.nvuillam.CodeNarcServer",

@@ -31,2 +33,4 @@ classPath: "java/CodeNarcServer.jar:java/*"

codeNarcJava: {
minimumJavaVersion: 1.8,
maximumJavaVersion: 11.99,
mainClass: "org.codenarc.CodeNarc",

@@ -83,3 +87,3 @@ classPath:

(startServerTried === false,
e.code && ["ECONNREFUSED", "ETIMEDOUT"].includes(e.code) && ["unknown", "running"].includes(this.serverStatus)) // running is here in case the Server auto-killed itself at its expiration time
e.code && ["ECONNREFUSED", "ETIMEDOUT"].includes(e.code) && ["unknown", "running"].includes(this.serverStatus)) // running is here in case the Server auto-killed itself at its expiration time
) {

@@ -86,0 +90,0 @@ if ((await this.startCodeNarcServer()) && this.serverStatus === "running") {

@@ -0,0 +0,0 @@ #! /usr/bin/env node

@@ -13,2 +13,3 @@ #! /usr/bin/env node

minimumJavaVersion = 1.8;
maximumJavaVersion;
rootPath = __dirname;

@@ -31,2 +32,3 @@

this.minimumJavaVersion = opts.minimumJavaVersion || this.minimumJavaVersion;
this.maximumJavaVersion = opts.maximumJavaVersion || this.maximumJavaVersion;
this.rootPath = opts.rootPath || this.rootPath;

@@ -38,6 +40,6 @@ this.javaCallerSupportDir = `${os.homedir() + path.sep}.java-caller`;

async initialize() {
if (globalThis.NPM_GROOVY_LINT_IS_INITIALIZED !== true) {
if (globalThis.NPM_JAVA_CALLER_IS_INITIALIZED !== true) {
this.embeddedJavaDir = await this.getEmbeddedJavaDir();
await this.manageJavaInstall();
globalThis.NPM_GROOVY_LINT_IS_INITIALIZED = true;
globalThis.NPM_JAVA_CALLER_IS_INITIALIZED = true;
}

@@ -144,8 +146,5 @@ }

const pathBefore = process.env["PATH"];
if (process.env["JAVA_HOME"]) {
process.env["PATH"].includes(process.env["JAVA_HOME"])
? process.env["PATH"]
: `${process.env["JAVA_HOME"] + path.sep}bin${path.delimiter}${process.env["PATH"]}`;
} else {
this.embeddedJavaDir = await this.getEmbeddedJavaDir();
this.embeddedJavaDir = await this.getEmbeddedJavaDir();
// Use java-caller downloaded java
if (await fse.exists(this.embeddedJavaDir)) {
process.env["PATH"] = process.env["PATH"].includes(this.embeddedJavaDir)

@@ -155,2 +154,10 @@ ? process.env["PATH"]

}
// If java home is set, but not jdk or jre, add it in PATH
else if (process.env["JAVA_HOME"] &&
!process.env["PATH"].includes('jdk') &&
!process.env["PATH"].includes('jre')) {
process.env["PATH"] = process.env["PATH"].includes(process.env["JAVA_HOME"])
? process.env["PATH"]
: `${process.env["JAVA_HOME"] + path.sep}bin${path.delimiter}${process.env["PATH"]}`;
}
if (pathBefore !== process.env["PATH"]) {

@@ -161,13 +168,24 @@ debug("New PATH value: " + process.env["PATH"]);

// Install node-jre if the found java version is not matching the requirements
async manageJavaInstall() {
const javaVersion = await this.getJavaVersion();
if (javaVersion === false || javaVersion < 1.8 || process.env["JAVA_CALLER_USE_NODE_JRE"]) {
if (!(await fse.exists(this.javaCallerSupportDir))) {
await fse.mkdir(this.javaCallerSupportDir);
}
var packageJson = `${this.javaCallerSupportDir + path.sep}package.json`;
if (
javaVersion === false ||
javaVersion < this.minimumJavaVersion ||
(this.maximumJavaVersion && javaVersion > this.maximumJavaVersion) ||
process.env["JAVA_CALLER_USE_NODE_JRE"]
) {
// Create a directory for installing node-jre and ensure it contains a dummy package.json
await fse.ensureDir(this.javaCallerSupportDir, { mode: "0777" });
const packageJson = `${this.javaCallerSupportDir + path.sep}package.json`;
if (!(await fse.exists(packageJson))) {
await fse.writeFile(packageJson, JSON.stringify({ name: "java-caller-support", version: "1.0.0" }), "utf8");
}
// Install node-jre if necessary
if (!(await fse.exists(this.embeddedJavaDir))) {
console.log(
`Java between ${this.minimumJavaVersion} and ${this.maximumJavaVersion} is required ${
javaVersion ? "(" + javaVersion + " found)" : ""
}`
);
console.log(`Installing/Updating JRE in ${this.javaCallerSupportDir}...`);

@@ -178,5 +196,6 @@ const { stdout, stderr } = await exec("npm install node-jre --save", { cwd: this.javaCallerSupportDir });

}
// Update environment
await this.addJavaInPath();
const installedVersion = await this.getJavaVersion();
console.log(`Installed Java version: ${installedVersion}`);
console.log(`Using Java version ${installedVersion}`);
}

@@ -215,4 +234,4 @@ }

async getEmbeddedJavaDir(force = false) {
if ((this.embeddedJavaDir || globalThis.NPM_GROOVY_LINT_EMBEDDED_JAVA_DIR) && force === false) {
this.embeddedJavaDir = this.embeddedJavaDir || globalThis.NPM_GROOVY_LINT_EMBEDDED_JAVA_DIR;
if ((this.embeddedJavaDir || globalThis.NPM_JAVA_CALLER_EMBEDDED_JAVA_DIR) && force === false) {
this.embeddedJavaDir = this.embeddedJavaDir || globalThis.NPM_JAVA_CALLER_EMBEDDED_JAVA_DIR;
return this.embeddedJavaDir;

@@ -219,0 +238,0 @@ }

#! /usr/bin/env node
"use strict";
const NpmGroovyLint = require("../../groovy-lint.js");
console.log("npm run test initialized");

@@ -10,1 +12,16 @@ // Activate debug log if we are in debug mode

}
// Reinitialize java-caller cache
globalThis.NPM_JAVA_CALLER_IS_INITIALIZED = false;
// Kill server if alreaady running
(async () => {
try {
await new NpmGroovyLint({
killserver: true,
"no-insight": true,
verbose: true
}).run();
} catch (err) {
console.error("Error while killing running server");
}
})();
{
"name": "npm-groovy-lint",
"version": "5.0.3",
"version": "5.1.0",
"description": "Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -329,2 +329,6 @@ # NPM GROOVY LINT (+ Format & Auto-fix)

## [5.1.0] 2020-06-04
- Install Java 8 using node-jre in case java version found is higher than Java 11 (CodeNarc compatibility is Java 8 to 11)
### [5.0.3] 2020-05-30

@@ -331,0 +335,0 @@