mega-linter-runner 8.8.1-beta202507271954.0 → 8.8.1-beta202507280009.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 CHANGED
@@ -94,40 +94,53 @@ mega-linter-runner [OPTIONS] [FILES]
94
94
 
95
95
  The options are only related to mega-linter-runner. For MegaLinter options, please use a `.mega-linter.yml` [configuration file](#configuration)
96
96
 
97
- | Option | Description | Default |
98
- |------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|
99
- | `-p` <br/> `--path` | Directory containing the files to lint | current directory |
100
- | `-f` <br/> `--flavor` | Set this parameter to use a [MegaLinter flavor](https://megalinter.io/flavors/) | `all` |
101
- | `-d` <br/> `--image` | You can override the used docker image, including if it's on another docker registry | <!-- --> |
102
- | `-e` <br/> `--env` | Environment variables for MegaLinter, following format **'ENV_VAR_NAME=VALUE'** for a single value or **"'ENV_VAR_NAME=VALUE1,VALUE2'"** for a list of values<br/>Warning: Quotes are mandatory | <!-- --> |
103
- | `--fix` | Automatically apply formatting and fixes in your files | <!-- --> |
104
- | `-r` <br/> `--release` | Allows to override MegaLinter version used | `v5` |
105
- | `-h` <br/> `--help` | Show mega-linter-runner help | <!-- --> |
106
- | `-v` <br/> `--version` | Show mega-linter-runner version | <!-- --> |
107
- | `-i` <br/> `--install` | Generate MegaLinter configuration files | <!-- --> |
108
- | `--container-name` | Specify MegaLinter container name | <!-- --> |
109
- | `--remove-container` | Remove MegaLinter Docker container when done | <!-- --> |
97
+ | Option | Description | Default |
98
+ |---------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|
99
+ | `-p` <br/> `--path` | Directory containing the files to lint | current directory |
100
+ | `-f` <br/> `--flavor` | Set this parameter to use a [MegaLinter flavor](https://megalinter.io/flavors/) | `all` |
101
+ | `-d` <br/> `--image` | You can override the used docker image, including if it's on another docker registry | <!-- --> |
102
+ | `-e` <br/> `--env` | Environment variables for MegaLinter, following format **'ENV_VAR_NAME=VALUE'** for a single value or **"'ENV_VAR_NAME=VALUE1,VALUE2'"** for a list of values<br/>Warning: Quotes are mandatory | <!-- --> |
103
+ | `--fix` | Automatically apply formatting and fixes in your files | <!-- --> |
104
+ | `-r` <br/> `--release` | Allows to override MegaLinter version used | `v5` |
105
+ | `-h` <br/> `--help` | Show mega-linter-runner help | <!-- --> |
106
+ | `-v` <br/> `--version` | Show mega-linter-runner version | <!-- --> |
107
+ | `--container-engine` | Allows to specify a docker engine (`docker` or `podman`) | `docker` |
108
+ | `--container-name` | Specify MegaLinter container name | <!-- --> |
109
+ | `--remove-container` | Remove MegaLinter Docker container when done | <!-- --> |
110
+ | `-i` <br/> `--install` | Generate [MegaLinter local configuration](https://megalinter.io/beta/install-assisted/) files and CI/CD workflows | <!-- --> |
111
+ | `-i` <br/> `--upgrade` | Upgrade your MegaLinter configuration files to use the latest version | <!-- --> |
112
+ | `--custom-flavor-setup` | Initialize a new repository to generate a [custom flavor](https://megalinter.io/beta/custom-flavors/) | <!-- --> |
113
+ | `--custom-flavor-linters` | Comma-separated list of linter keys if using `--custom-flavor-setup` | <!-- --> |
110
114
 
111
115
  _You can also use `npx mega-linter-runner` if you do not want to install the package_
112
116
 
113
117
  ### Examples
114
118
 
115
119
  ```shell
120
+ # Run with all defaults
116
121
  mega-linter-runner
117
122
  ```
118
123
 
119
124
  ```shell
125
+ # Scan a folder and apply fixes
120
126
  mega-linter-runner -p myFolder --fix
121
127
  ```
122
128
 
123
129
  ```shell
130
+ # Send environment variables
124
131
  mega-linter-runner -r beta -e "'ENABLE=MARKDOWN,YAML'" -e 'SHOW_ELAPSED_TIME=true'
125
132
  ```
126
133
 
127
134
  ```shell
135
+ # Use python flavor beta version, only on some files
128
136
  mega-linter-runner --flavor python --release beta --filesonly path/to/my/file1.py another/path/to/a/file.js and/another/file.py
129
137
  ```
130
138
 
139
+ ```shell
140
+ # Use Podman as engine
141
+ mega-linter-runner --flavor documentation --container-engine podman
142
+ ```
143
+
131
144
  ## Configuration
132
145
 
133
146
  You can generate a ready-to-use [.mega-linter.yml configuration file](https://megalinter.io/configuration/) by running `npx mega-linter-runner --install` at the root of your repository
package/lib/options.js CHANGED
@@ -145,6 +145,13 @@ export const optionsDefinition = optionator.default({
145
145
  type: "String",
146
146
  description: "Specify MegaLinter container name",
147
147
  },
148
+ {
149
+ option: "container-engine",
150
+ alias: "",
151
+ type: "String",
152
+ default: "docker",
153
+ description: "Use docker or podman as container engine",
154
+ },
148
155
  {
149
156
  option: "remove-container",
150
157
  type: "Boolean",
package/lib/runner.js CHANGED
@@ -9,10 +9,11 @@ import { default as fs } from "fs-extra";
9
9
  import { MegaLinterUpgrader } from "./upgrade.js";
10
10
  import { CodeTotalRunner } from "./codetotal.js";
11
11
  import { DEFAULT_RELEASE } from "./config.js";
12
- import { createEnv} from "yeoman-environment";
12
+ import { createEnv } from "yeoman-environment";
13
13
  import { default as FindPackageJson } from "find-package-json";
14
14
 
15
15
  export class MegaLinterRunner {
16
+
16
17
  async run(options) {
17
18
  // Show help ( index or for an options)
18
19
  if (options.help) {
@@ -83,6 +84,10 @@ export class MegaLinterRunner {
83
84
  }
84
85
 
85
86
  // Build MegaLinter docker image name with flavor and release version
87
+ this.containerEngine = options.containerEngine || "docker";
88
+ if (this.containerEngine !== "docker" && this.containerEngine !== "podman") {
89
+ throw new Error(`Invalid container engine: ${this.containerEngine}. Supported engines are 'docker' and 'podman'.`);
90
+ }
86
91
  const release = options.release in ["stable"] ? DEFAULT_RELEASE : options.release;
87
92
  const dockerImageName =
88
93
  // v4 retrocompatibility >>
@@ -99,18 +104,26 @@ export class MegaLinterRunner {
99
104
  ? `megalinter/megalinter-${options.flavor}`
100
105
  : // << v5 retrocompatibility
101
106
  options.flavor === "all" || options.flavor == null
102
- ? "oxsecurity/megalinter"
103
- : `oxsecurity/megalinter-${options.flavor}`;
107
+ ? "ghcr.io/oxsecurity/megalinter"
108
+ : `ghcr.io/oxsecurity/megalinter-${options.flavor}`;
104
109
  this.checkPreviousVersion(release);
105
110
  const dockerImage = options.image || `${dockerImageName}:${release}`; // Docker image can be directly sent in options
106
111
 
107
112
  // Check for docker installation
108
- const whichPromise = which("docker");
113
+ const whichPromise = which(this.containerEngine);
109
114
  whichPromise.catch(() => {
110
- console.error(`
111
- ERROR: Docker engine has not been found on your system.
112
- - to run MegaLinter locally, please install docker desktop: https://www.docker.com/products/docker-desktop
113
- - to run docker on CI, use a base image containing docker engine`);
115
+ if (this.containerEngine === "podman") {
116
+ console.error(`
117
+ ERROR: Podman engine has not been found on your system.
118
+ - To run MegaLinter locally, please install Podman: https://podman.io/docs/installation
119
+ - To run Podman on CI, use a base image containing Podman engine`);
120
+ }
121
+ else {
122
+ console.error(`
123
+ ERROR: Docker engine has not been found on your system.
124
+ - to run MegaLinter locally, please install docker desktop: https://www.docker.com/products/docker-desktop
125
+ - to run docker on CI, use a base image containing docker engine`);
126
+ }
114
127
  });
115
128
 
116
129
  // Get platform to use with docker pull & run
@@ -126,7 +139,7 @@ ERROR: Docker engine has not been found on your system.
126
139
  "The next runs, it will be immediate (thanks to docker cache !)"
127
140
  );
128
141
  const spawnResPull = spawnSync(
129
- "docker",
142
+ this.containerEngine,
130
143
  ["pull", "--platform", imagePlatform, dockerImage],
131
144
  {
132
145
  detached: false,
@@ -153,7 +166,7 @@ ERROR: Docker engine has not been found on your system.
153
166
  // Build docker run options
154
167
  const lintPath = path.resolve(options.path || ".");
155
168
  const commandArgs = ["run", "--platform", imagePlatform];
156
- const removeContainer = options["removeContainer"] ? true: options["noRemoveContainer"] ? false: true ;
169
+ const removeContainer = options["removeContainer"] ? true : options["noRemoveContainer"] ? false : true;
157
170
  if (removeContainer) {
158
171
  commandArgs.push("--rm");
159
172
  }
@@ -190,13 +203,13 @@ ERROR: Docker engine has not been found on your system.
190
203
  commandArgs.push(dockerImage);
191
204
 
192
205
  // Call docker run
193
- console.log(`Command: docker ${commandArgs.join(" ")}`);
206
+ console.log(`Command: ${this.containerEngine} ${commandArgs.join(" ")}`);
194
207
  const spawnOptions = {
195
208
  env: Object.assign({}, process.env),
196
209
  stdio: "inherit",
197
210
  windowsHide: true,
198
211
  };
199
- const spawnRes = spawnSync("docker", commandArgs, spawnOptions);
212
+ const spawnRes = spawnSync(this.containerEngine, commandArgs, spawnOptions);
200
213
  // Output json if requested
201
214
  if (options.json === true) {
202
215
  const jsonOutputFile = path.join(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mega-linter-runner",
3
- "version": "8.8.1-beta202507271954.0",
3
+ "version": "8.8.1-beta202507280009.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/oxsecurity/megalinter.git"