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
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { asciiArt } from "../../lib/ascii.js";
|
|
2
2
|
import Generator from 'yeoman-generator';
|
|
3
|
-
import {
|
|
4
|
-
import c from
|
|
3
|
+
import { execFileSync } from "child_process";
|
|
4
|
+
import c from "../../lib/colors.js";
|
|
5
5
|
import fs from "fs"
|
|
6
6
|
import { load as yamlLoad } from "js-yaml";
|
|
7
7
|
|
|
8
|
+
function gitOutput(args) {
|
|
9
|
+
return execFileSync("git", args, { encoding: "utf8" }).trim();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getFirstRemoteFetchUrl() {
|
|
13
|
+
const remoteNames = gitOutput(["remote"]).split(/\r?\n/).filter(Boolean);
|
|
14
|
+
if (remoteNames.length === 0) {
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
return gitOutput(["remote", "get-url", remoteNames[0]]);
|
|
18
|
+
}
|
|
19
|
+
|
|
8
20
|
export default class GeneratorMegaLinter extends Generator {
|
|
9
21
|
async prompting() {
|
|
10
22
|
console.log(asciiArt());
|
|
@@ -14,9 +26,7 @@ When you don't know what option to select, please use default values`
|
|
|
14
26
|
));
|
|
15
27
|
|
|
16
28
|
// Verify that the repo name contains "megalinter-custom-flavor"
|
|
17
|
-
|
|
18
|
-
const remote = await git.getRemotes(true);
|
|
19
|
-
if (!remote[0].refs.fetch.includes("megalinter-custom-flavor")) {
|
|
29
|
+
if (!getFirstRemoteFetchUrl().includes("megalinter-custom-flavor")) {
|
|
20
30
|
const errorMessage = `
|
|
21
31
|
ERROR: This generator must be run in a repository whose name includes 'megalinter-custom-flavor'
|
|
22
32
|
Example: 'megalinter-custom-flavor-python-light'
|
|
@@ -111,12 +121,15 @@ Example: 'megalinter-custom-flavor-python-light'
|
|
|
111
121
|
return `- [${linter}](${linterUrl})`;
|
|
112
122
|
}).join("\n");
|
|
113
123
|
// Custom flavor author is git username
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
124
|
+
let author = "";
|
|
125
|
+
try {
|
|
126
|
+
author = gitOutput(["config", "user.name"]);
|
|
127
|
+
} catch {
|
|
128
|
+
// user.name not set in git config: leave author empty
|
|
129
|
+
}
|
|
130
|
+
this.customFlavorAuthor = author;
|
|
117
131
|
// Get remote repo
|
|
118
|
-
const
|
|
119
|
-
const remoteUrl = remote[0].refs.fetch;
|
|
132
|
+
const remoteUrl = getFirstRemoteFetchUrl();
|
|
120
133
|
|
|
121
134
|
// Handle both HTTPS and SSH git origins
|
|
122
135
|
let repoPath, repoUrl;
|
package/lib/codetotal.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { spawnSync, spawn } from "child_process";
|
|
2
|
-
import { default as c } from
|
|
3
|
-
import { default as fs } from "fs
|
|
2
|
+
import { default as c } from "./colors.js";
|
|
3
|
+
import { default as fs } from "fs";
|
|
4
4
|
import * as https from 'https';
|
|
5
5
|
import { default as open } from 'open';
|
|
6
6
|
import * as path from "path";
|
|
7
|
-
import which from "which";
|
|
7
|
+
import { which } from "./which.js";
|
|
8
8
|
import { asciiArtCodeTotal } from "./ascii.js";
|
|
9
9
|
|
|
10
10
|
export class CodeTotalRunner {
|
package/lib/colors.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Minimal replacement of the chalk dependency, based on node:util styleText
|
|
2
|
+
import { styleText } from "util";
|
|
3
|
+
|
|
4
|
+
const style = (format) => (text) => styleText(format, String(text));
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
red: style("red"),
|
|
8
|
+
green: style("green"),
|
|
9
|
+
yellow: style("yellow"),
|
|
10
|
+
cyan: style("cyan"),
|
|
11
|
+
grey: style("grey"),
|
|
12
|
+
bold: style("bold"),
|
|
13
|
+
blueBright: style("blueBright"),
|
|
14
|
+
whiteBright: style("whiteBright"),
|
|
15
|
+
bgGray: style("bgGray"),
|
|
16
|
+
};
|
package/lib/list-vars.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { default as fs } from "fs
|
|
1
|
+
import { default as fs } from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
3
|
import { dirname } from "path";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
@@ -14,7 +14,7 @@ function loadVars() {
|
|
|
14
14
|
`Bundled variables file not found at ${VARS_FILE}. Re-run \`make megalinter-build\` to regenerate it.`,
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
|
-
return fs.
|
|
17
|
+
return JSON.parse(fs.readFileSync(VARS_FILE, "utf8"));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function matches(variable, pattern) {
|