mega-linter-runner 10.0.0 → 10.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 +128 -117
- package/generators/mega-linter-custom-flavor/index.js +23 -10
- package/lib/codetotal.js +3 -3
- package/lib/colors.js +16 -0
- package/lib/list-vars.js +2 -2
- package/lib/megalinter-vars.json +2178 -69
- package/lib/ox-setup.js +0 -1
- package/lib/runner.js +16 -11
- package/lib/upgrade.js +4 -4
- package/lib/upload-dashboards.js +2 -2
- package/lib/which.js +24 -0
- package/package.json +2 -10
package/lib/ox-setup.js
CHANGED
package/lib/runner.js
CHANGED
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
import { expandEnvEntries } from "./env-parser.js";
|
|
7
7
|
import { listVars } from "./list-vars.js";
|
|
8
8
|
import { spawnSync } from "child_process";
|
|
9
|
-
import { default as c } from "
|
|
9
|
+
import { default as c } from "./colors.js";
|
|
10
10
|
import * as path from "path";
|
|
11
11
|
import { dirname } from "path";
|
|
12
12
|
import { fileURLToPath } from "url";
|
|
13
13
|
import os from "os";
|
|
14
|
-
import which from "which";
|
|
15
|
-
import { default as fs } from "fs
|
|
14
|
+
import { which } from "./which.js";
|
|
15
|
+
import { default as fs } from "fs";
|
|
16
16
|
import { MegaLinterUpgrader } from "./upgrade.js";
|
|
17
17
|
import { CodeTotalRunner } from "./codetotal.js";
|
|
18
18
|
import {
|
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
import prompts from "prompts";
|
|
23
23
|
import { DEFAULT_RELEASE } from "./config.js";
|
|
24
24
|
import { createEnv } from "yeoman-environment";
|
|
25
|
-
import { default as FindPackageJson } from "find-package-json";
|
|
26
25
|
import { load as yamlLoad } from "js-yaml";
|
|
27
26
|
|
|
28
27
|
function isSElinuxOn() {
|
|
@@ -62,8 +61,12 @@ export class MegaLinterRunner {
|
|
|
62
61
|
let v = process.env.npm_package_version;
|
|
63
62
|
if (!v) {
|
|
64
63
|
try {
|
|
65
|
-
const
|
|
66
|
-
|
|
64
|
+
const packageJsonFile = path.join(
|
|
65
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
66
|
+
"..",
|
|
67
|
+
"package.json"
|
|
68
|
+
);
|
|
69
|
+
v = JSON.parse(fs.readFileSync(packageJsonFile, "utf8")).version;
|
|
67
70
|
} catch (e) {
|
|
68
71
|
v = "error";
|
|
69
72
|
}
|
|
@@ -265,7 +268,7 @@ export class MegaLinterRunner {
|
|
|
265
268
|
const envVarsFromDotenv = [];
|
|
266
269
|
let emptyEnvFile = null;
|
|
267
270
|
if (fs.existsSync(dotenvPath)) {
|
|
268
|
-
const dotenvContent = await fs.readFile(dotenvPath, "utf8");
|
|
271
|
+
const dotenvContent = await fs.promises.readFile(dotenvPath, "utf8");
|
|
269
272
|
dotenvContent.split(/\r?\n/).forEach((line) => {
|
|
270
273
|
const trimmedLine = line.trim();
|
|
271
274
|
if (!trimmedLine || trimmedLine.startsWith("#")) {
|
|
@@ -282,9 +285,9 @@ export class MegaLinterRunner {
|
|
|
282
285
|
}
|
|
283
286
|
envVarsFromDotenv.push(`${key}=${value}`);
|
|
284
287
|
});
|
|
285
|
-
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "megalinter-"));
|
|
288
|
+
const tmpDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "megalinter-"));
|
|
286
289
|
emptyEnvFile = path.join(tmpDir, "empty.env");
|
|
287
|
-
await fs.writeFile(emptyEnvFile, "");
|
|
290
|
+
await fs.promises.writeFile(emptyEnvFile, "");
|
|
288
291
|
}
|
|
289
292
|
const commandArgs = ["run", "--platform", imagePlatform];
|
|
290
293
|
const removeContainer = options["removeContainer"] ? true : options["noRemoveContainer"] ? false : true;
|
|
@@ -417,7 +420,7 @@ export class MegaLinterRunner {
|
|
|
417
420
|
options.prerun === true ? "prerun-report.json" : "mega-linter-report.json"
|
|
418
421
|
);
|
|
419
422
|
if (fs.existsSync(jsonOutputFile)) {
|
|
420
|
-
const jsonRaw = await fs.readFile(jsonOutputFile, "utf8");
|
|
423
|
+
const jsonRaw = await fs.promises.readFile(jsonOutputFile, "utf8");
|
|
421
424
|
console.log(JSON.stringify(JSON.parse(jsonRaw)));
|
|
422
425
|
}
|
|
423
426
|
}
|
|
@@ -580,7 +583,9 @@ export class MegaLinterRunner {
|
|
|
580
583
|
for (const target of targets) {
|
|
581
584
|
const targetPath = path.join(baseDir, target);
|
|
582
585
|
if (fs.existsSync(targetPath)) {
|
|
583
|
-
fs.
|
|
586
|
+
fs.cpSync(targetPath, `${targetPath}.megalinter-setup.bak`, {
|
|
587
|
+
recursive: true,
|
|
588
|
+
});
|
|
584
589
|
backedUp.push(target);
|
|
585
590
|
}
|
|
586
591
|
}
|
package/lib/upgrade.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { glob } from "glob";
|
|
2
|
-
import { default as fs } from "fs
|
|
2
|
+
import { default as fs } from "fs";
|
|
3
3
|
import * as path from "path";
|
|
4
|
-
import { default as c } from
|
|
4
|
+
import { default as c } from "./colors.js";
|
|
5
5
|
import prompts from "prompts";
|
|
6
6
|
import { OXSecuritySetup } from "./ox-setup.js";
|
|
7
7
|
import { asciiArt } from "./ascii.js";
|
|
@@ -679,7 +679,7 @@ jobs:
|
|
|
679
679
|
let updatedFiles = 0;
|
|
680
680
|
for (const file of allFiles) {
|
|
681
681
|
console.log(c.grey("Processing file " + file));
|
|
682
|
-
const initialFileContent = await fs.readFile(file, "utf8");
|
|
682
|
+
const initialFileContent = await fs.promises.readFile(file, "utf8");
|
|
683
683
|
let updatedFileContent = initialFileContent.slice();
|
|
684
684
|
for (const replacementItem of this.replacements) {
|
|
685
685
|
const newFileContent = updatedFileContent.replace(
|
|
@@ -695,7 +695,7 @@ jobs:
|
|
|
695
695
|
}
|
|
696
696
|
}
|
|
697
697
|
if (updatedFileContent !== initialFileContent) {
|
|
698
|
-
await fs.writeFile(file, updatedFileContent);
|
|
698
|
+
await fs.promises.writeFile(file, updatedFileContent);
|
|
699
699
|
console.log(c.cyan(`UPDATED: ${file}`));
|
|
700
700
|
updatedFiles++;
|
|
701
701
|
}
|
package/lib/upload-dashboards.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* MEGALINTER_DASHBOARDS_DIR is defined).
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import fs from "fs
|
|
9
|
+
import fs from "fs";
|
|
10
10
|
import path from "path";
|
|
11
11
|
|
|
12
12
|
const DASHBOARDS_BASE_URL =
|
|
@@ -53,7 +53,7 @@ export class DashboardUploader {
|
|
|
53
53
|
async readDashboardFile(relativePath) {
|
|
54
54
|
const localDir = this.env.MEGALINTER_DASHBOARDS_DIR;
|
|
55
55
|
if (localDir) {
|
|
56
|
-
return await fs.readFile(path.join(localDir, relativePath), "utf8");
|
|
56
|
+
return await fs.promises.readFile(path.join(localDir, relativePath), "utf8");
|
|
57
57
|
}
|
|
58
58
|
const response = await fetch(`${DASHBOARDS_BASE_URL}/${relativePath}`);
|
|
59
59
|
if (!response.ok) {
|
package/lib/which.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Minimal replacement of the which dependency: resolve a command against PATH
|
|
2
|
+
import { constants as fsConstants } from "fs";
|
|
3
|
+
import { access } from "fs/promises";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
|
|
6
|
+
export async function which(command) {
|
|
7
|
+
const isWindows = process.platform === "win32";
|
|
8
|
+
const extensions = isWindows
|
|
9
|
+
? (process.env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";")
|
|
10
|
+
: [""];
|
|
11
|
+
const directories = (process.env.PATH || "").split(path.delimiter).filter(Boolean);
|
|
12
|
+
for (const directory of directories) {
|
|
13
|
+
for (const extension of extensions) {
|
|
14
|
+
const candidate = path.join(directory, command + extension);
|
|
15
|
+
try {
|
|
16
|
+
await access(candidate, isWindows ? fsConstants.F_OK : fsConstants.X_OK);
|
|
17
|
+
return candidate;
|
|
18
|
+
} catch {
|
|
19
|
+
// Not found here: try next candidate
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
throw new Error(`Command not found in PATH: ${command}`);
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mega-linter-runner",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.1.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/oxsecurity/megalinter.git"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"generators"
|
|
14
14
|
],
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
16
|
+
"node": ">=22.0.0"
|
|
17
17
|
},
|
|
18
18
|
"bin": {
|
|
19
19
|
"mega-linter-runner": "lib/index.js"
|
|
@@ -82,23 +82,15 @@
|
|
|
82
82
|
"author": "Nicolas Vuillamy",
|
|
83
83
|
"license": "MIT",
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"chalk": "^6.0.0",
|
|
86
|
-
"find-package-json": "^1.2.0",
|
|
87
|
-
"fs-extra": "^11.1.1",
|
|
88
85
|
"glob": "^13.0.0",
|
|
89
86
|
"js-yaml": "^5.2.2",
|
|
90
|
-
"mem-fs": "^4.0.0",
|
|
91
87
|
"open": "^11.0.0",
|
|
92
88
|
"optionator": "^0.9.3",
|
|
93
89
|
"prompts": "^2.4.2",
|
|
94
|
-
"simple-git": "^3.28.0",
|
|
95
|
-
"uuid": "^14.0.0",
|
|
96
|
-
"which": "^7.0.0",
|
|
97
90
|
"yeoman-environment": "^6.0.0",
|
|
98
91
|
"yeoman-generator": "^8.0.0"
|
|
99
92
|
},
|
|
100
93
|
"devDependencies": {
|
|
101
|
-
"assert": "^2.1.0",
|
|
102
94
|
"eslint": "^10.0.0",
|
|
103
95
|
"mocha": "^11.0.0"
|
|
104
96
|
},
|