sonar-scan 1.0.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/LICENSE +21 -0
- package/README.md +31 -0
- package/bin/sonar-scanner +67 -0
- package/bin/sonar-scanner-debug +14 -0
- package/bin/sonar-scanner-debug.bat +13 -0
- package/bin/sonar-scanner.bat +91 -0
- package/conf/sonar-scanner.properties +9 -0
- package/index.js +26 -0
- package/lib/sonar-scanner-cli-3.1.0.1141.jar +0 -0
- package/package.json +27 -0
- package/postinstall.js +22 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 ionut88
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
sonar-scan
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
Wrap [SonarQube Scanner](https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner) as a node module.
|
|
5
|
+
|
|
6
|
+
# Installation
|
|
7
|
+
|
|
8
|
+
This plugin requires JAVA runtime installed
|
|
9
|
+
|
|
10
|
+
You can install sonar-scan as a development dependency and add it as a script property in your package.json.
|
|
11
|
+
|
|
12
|
+
```shell
|
|
13
|
+
npm i sonar-scan --save-dev
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"scripts": {
|
|
19
|
+
"sonar-scan": "node_modules/sonar-scan/bin/sonar-scanner"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```shell
|
|
25
|
+
npm run sonar-scan
|
|
26
|
+
```
|
|
27
|
+
# Forked from
|
|
28
|
+
|
|
29
|
+
https://github.com/bcaudan/node-sonar-scanner
|
|
30
|
+
|
|
31
|
+
This library is not updated currentlly for a few years but we need & support it
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
# SonarQube Scanner Startup Script for Unix
|
|
4
|
+
#
|
|
5
|
+
# Optional ENV vars:
|
|
6
|
+
# SONAR_SCANNER_OPTS - Parameters passed to the Java VM when running the SonarQube Scanner
|
|
7
|
+
# SONAR_SCANNER_DEBUG_OPTS - Extra parameters passed to the Java VM for debugging
|
|
8
|
+
# JAVA_HOME - Location of Java's installation
|
|
9
|
+
|
|
10
|
+
real_path () {
|
|
11
|
+
target=$1
|
|
12
|
+
|
|
13
|
+
(
|
|
14
|
+
while true; do
|
|
15
|
+
cd "$(dirname "$target")"
|
|
16
|
+
target=$(basename "$target")
|
|
17
|
+
test -L "$target" || break
|
|
18
|
+
target=$(readlink "$target")
|
|
19
|
+
done
|
|
20
|
+
|
|
21
|
+
echo "$(pwd -P)/$target"
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
script_path=$(real_path "$0")
|
|
26
|
+
sonar_scanner_home=$(dirname "$script_path")/..
|
|
27
|
+
|
|
28
|
+
# make it fully qualified
|
|
29
|
+
sonar_scanner_home=$(cd "$sonar_scanner_home" && pwd -P)
|
|
30
|
+
|
|
31
|
+
jar_file=$sonar_scanner_home/lib/sonar-scanner-cli-3.1.0.1141.jar
|
|
32
|
+
|
|
33
|
+
# check that sonar_scanner_home has been correctly set
|
|
34
|
+
if [ ! -f "$jar_file" ] ; then
|
|
35
|
+
echo "File does not exist: $jar_file"
|
|
36
|
+
echo "'$sonar_scanner_home' does not point to a valid installation directory: $sonar_scanner_home"
|
|
37
|
+
exit 1
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
use_embedded_jre=false
|
|
41
|
+
if [ "$use_embedded_jre" = true ]; then
|
|
42
|
+
export JAVA_HOME=$sonar_scanner_home/jre
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
if [ -n "$JAVA_HOME" ]
|
|
46
|
+
then
|
|
47
|
+
java_cmd="$JAVA_HOME/bin/java"
|
|
48
|
+
else
|
|
49
|
+
java_cmd="$(which java)"
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
project_home=$(pwd)
|
|
53
|
+
|
|
54
|
+
#echo "Info: Using sonar-scanner at $sonar_scanner_home"
|
|
55
|
+
#echo "Info: Using java at $java_cmd"
|
|
56
|
+
#echo "Info: Using classpath $jar_file"
|
|
57
|
+
#echo "Info: Using project $project_home"
|
|
58
|
+
|
|
59
|
+
exec "$java_cmd" \
|
|
60
|
+
-Djava.awt.headless=true \
|
|
61
|
+
$SONAR_SCANNER_OPTS \
|
|
62
|
+
$SONAR_SCANNER_DEBUG_OPTS \
|
|
63
|
+
-classpath "$jar_file" \
|
|
64
|
+
-Dscanner.home="$sonar_scanner_home" \
|
|
65
|
+
-Dproject.home="$project_home" \
|
|
66
|
+
org.sonarsource.scanner.cli.Main "$@"
|
|
67
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
# SonarQube Scanner Startup Script for Unix
|
|
4
|
+
#
|
|
5
|
+
# Optional ENV vars:
|
|
6
|
+
# SONAR_SCANNER_OPTS - parameters passed to the Java VM when running the SonarQube Scanner
|
|
7
|
+
# JAVA_HOME - Location of Java's installation
|
|
8
|
+
|
|
9
|
+
SONAR_SCANNER_DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
|
|
10
|
+
|
|
11
|
+
echo "Executing SonarQube Scanner in Debug Mode"
|
|
12
|
+
echo "SONAR_SCANNER_DEBUG_OPTS=\"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000\""
|
|
13
|
+
|
|
14
|
+
env SONAR_SCANNER_OPTS="$SONAR_SCANNER_OPTS" SONAR_SCANNER_DEBUG_OPTS="$SONAR_SCANNER_DEBUG_OPTS" "$(dirname "$0")"/sonar-scanner "$@"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
@REM SonarQube Scanner Startup Script for Windows
|
|
2
|
+
@REM
|
|
3
|
+
@REM Required ENV vars:
|
|
4
|
+
@REM JAVA_HOME - location of a JDK home dir
|
|
5
|
+
@REM
|
|
6
|
+
@REM Optional ENV vars:
|
|
7
|
+
@REM SONAR_SCANNER_OPTS - parameters passed to the Java VM when running the SonarQube Scanner
|
|
8
|
+
|
|
9
|
+
@setlocal
|
|
10
|
+
@set SONAR_SCANNER_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
|
11
|
+
echo "Executing SonarQube Scanner in Debug Mode"
|
|
12
|
+
echo "SONAR_SCANNER_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
|
|
13
|
+
@call "%~dp0"sonar-scanner.bat %*
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
@REM SonarQube Scanner Startup Script for Windows
|
|
2
|
+
@REM
|
|
3
|
+
@REM Required ENV vars:
|
|
4
|
+
@REM JAVA_HOME - location of a JDK home dir
|
|
5
|
+
@REM
|
|
6
|
+
@REM Optional ENV vars:
|
|
7
|
+
@REM SONAR_SCANNER_OPTS - parameters passed to the Java VM when running the SonarQube Scanner
|
|
8
|
+
|
|
9
|
+
@echo off
|
|
10
|
+
|
|
11
|
+
set ERROR_CODE=0
|
|
12
|
+
|
|
13
|
+
@REM set local scope for the variables with windows NT shell
|
|
14
|
+
@setlocal
|
|
15
|
+
|
|
16
|
+
set "scriptdir=%~dp0"
|
|
17
|
+
if #%scriptdir:~-1%# == #\# set scriptdir=%scriptdir:~0,-1%
|
|
18
|
+
set "SONAR_SCANNER_HOME=%scriptdir%\.."
|
|
19
|
+
|
|
20
|
+
@REM ==== START VALIDATION ====
|
|
21
|
+
@REM *** JAVA EXEC VALIDATION ***
|
|
22
|
+
|
|
23
|
+
set use_embedded_jre=false
|
|
24
|
+
if "%use_embedded_jre%" == "true" (
|
|
25
|
+
set "JAVA_HOME=%SONAR_SCANNER_HOME%\jre"
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
if not "%JAVA_HOME%" == "" goto foundJavaHome
|
|
29
|
+
|
|
30
|
+
for %%i in (java.exe) do set JAVA_EXEC=%%~$PATH:i
|
|
31
|
+
|
|
32
|
+
if not "%JAVA_EXEC%" == "" (
|
|
33
|
+
set JAVA_EXEC="%JAVA_EXEC%"
|
|
34
|
+
goto OkJava
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
if not "%JAVA_EXEC%" == "" goto OkJava
|
|
38
|
+
|
|
39
|
+
echo.
|
|
40
|
+
echo ERROR: JAVA_HOME not found in your environment, and no Java
|
|
41
|
+
echo executable present in the PATH.
|
|
42
|
+
echo Please set the JAVA_HOME variable in your environment to match the
|
|
43
|
+
echo location of your Java installation, or add "java.exe" to the PATH
|
|
44
|
+
echo.
|
|
45
|
+
goto error
|
|
46
|
+
|
|
47
|
+
:foundJavaHome
|
|
48
|
+
if EXIST "%JAVA_HOME%\bin\java.exe" goto foundJavaExeFromJavaHome
|
|
49
|
+
|
|
50
|
+
echo.
|
|
51
|
+
echo ERROR: JAVA_HOME exists but does not point to a valid Java home
|
|
52
|
+
echo folder. No "\bin\java.exe" file can be found there.
|
|
53
|
+
echo.
|
|
54
|
+
goto error
|
|
55
|
+
|
|
56
|
+
:foundJavaExeFromJavaHome
|
|
57
|
+
set JAVA_EXEC="%JAVA_HOME%\bin\java.exe"
|
|
58
|
+
|
|
59
|
+
:OkJava
|
|
60
|
+
goto run
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@REM ==== START RUN ====
|
|
64
|
+
:run
|
|
65
|
+
|
|
66
|
+
set PROJECT_HOME=%CD%
|
|
67
|
+
|
|
68
|
+
@REM remove trailing backslash, see https://groups.google.com/d/msg/sonarqube/wi7u-CyV_tc/3u9UKRmABQAJ
|
|
69
|
+
IF %PROJECT_HOME:~-1% == \ SET PROJECT_HOME=%PROJECT_HOME:~0,-1%
|
|
70
|
+
|
|
71
|
+
%JAVA_EXEC% -Djava.awt.headless=true %SONAR_SCANNER_DEBUG_OPTS% %SONAR_SCANNER_OPTS% -cp "%SONAR_SCANNER_HOME%\lib\sonar-scanner-cli-3.1.0.1141.jar" "-Dscanner.home=%SONAR_SCANNER_HOME%" "-Dproject.home=%PROJECT_HOME%" org.sonarsource.scanner.cli.Main %*
|
|
72
|
+
if ERRORLEVEL 1 goto error
|
|
73
|
+
goto end
|
|
74
|
+
|
|
75
|
+
:error
|
|
76
|
+
set ERROR_CODE=1
|
|
77
|
+
|
|
78
|
+
@REM ==== END EXECUTION ====
|
|
79
|
+
|
|
80
|
+
:end
|
|
81
|
+
@REM set local scope for the variables with windows NT shell
|
|
82
|
+
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
|
83
|
+
|
|
84
|
+
@REM see http://code-bear.com/bearlog/2007/06/01/getting-the-exit-code-from-a-batch-file-that-is-run-from-a-python-program/
|
|
85
|
+
goto exit
|
|
86
|
+
|
|
87
|
+
:returncode
|
|
88
|
+
exit /B %1
|
|
89
|
+
|
|
90
|
+
:exit
|
|
91
|
+
call :returncode %ERROR_CODE%
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#Configure here general information about the environment, such as SonarQube server connection details for example
|
|
2
|
+
#No information about specific project should appear here
|
|
3
|
+
|
|
4
|
+
#----- Default SonarQube server
|
|
5
|
+
#sonar.host.url=http://localhost:9000
|
|
6
|
+
|
|
7
|
+
#----- Default source code encoding
|
|
8
|
+
#sonar.sourceEncoding=UTF-8
|
|
9
|
+
|
package/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var child_process = require('child_process'),
|
|
6
|
+
path = require('path');
|
|
7
|
+
|
|
8
|
+
var args = process.argv.slice(2),
|
|
9
|
+
script = path.join(__dirname, 'bin', 'sonar-scanner'),
|
|
10
|
+
command;
|
|
11
|
+
|
|
12
|
+
if (process.platform === 'win32') {
|
|
13
|
+
command = 'cmd.exe';
|
|
14
|
+
args = ['/c', (script + '.bat')].concat(args);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
command = script;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var child = child_process.spawn(command, args, {
|
|
21
|
+
stdio: 'inherit'
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
child.on('close', function(code) {
|
|
25
|
+
process.exit(code);
|
|
26
|
+
});
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sonar-scan",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Wrap sonar-scan as a node module",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"node",
|
|
7
|
+
"sonar",
|
|
8
|
+
"scanner"
|
|
9
|
+
],
|
|
10
|
+
"main": "index.js",
|
|
11
|
+
"bin": {
|
|
12
|
+
"sonar-scanner": "index.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
16
|
+
"postinstall": "node postinstall.js"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/ionut88/sonar-scan"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/ionut88/sonar-scan/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/ionut88/sonar-scan",
|
|
26
|
+
"license": "MIT"
|
|
27
|
+
}
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var child_process = require('child_process'),
|
|
6
|
+
path = require('path');
|
|
7
|
+
|
|
8
|
+
if (process.platform === 'win32') {
|
|
9
|
+
process.exit(0);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
var script = path.join(__dirname, 'bin', 'sonar-scanner'),
|
|
13
|
+
command = 'chmod',
|
|
14
|
+
args = ['+x', script];
|
|
15
|
+
|
|
16
|
+
var child = child_process.spawn(command, args, {
|
|
17
|
+
stdio: 'inherit'
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
child.on('close', function(code) {
|
|
21
|
+
process.exit(code);
|
|
22
|
+
});
|