@koliveira15/nx-sonarqube
Advanced tools
Comparing version 1.0.4 to 1.1.101
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ { |
{ | ||
"name": "@koliveira15/nx-sonarqube", | ||
"description": "A Nx plugin that scans projects using SonarQube / SonarCloud.", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/koliveira15/nx-sonarqube.git" | ||
"url": "https://github.com/koliveira15/nx-sonarqube.git", | ||
"directory": "packages/nx-sonarqube" | ||
}, | ||
"version": "1.0.4", | ||
"main": "src/index.js", | ||
"version": "1.1.101", | ||
"main": "./src/index.js", | ||
"generators": "./generators.json", | ||
"executors": "./executors.json", | ||
"typings": "./src/index.d.ts", | ||
"peerDependencies": { | ||
"@nx/devkit": "16.7.4" | ||
}, | ||
"dependencies": { | ||
"sonarqube-scanner": "2.8.1", | ||
"@phenomnomnominal/tsquery": "5.0.0", | ||
"tslib": "2.3.0" | ||
"@phenomnomnominal/tsquery": "5.0.1", | ||
"sonarqube-scanner": "3.0.1", | ||
"tslib": "2.5.2" | ||
}, | ||
"peerDependencies": {} | ||
"type": "commonjs" | ||
} |
import { ScanExecutorSchema } from './schema'; | ||
import { ExecutorContext } from '@nrwl/devkit'; | ||
import { ExecutorContext } from '@nx/devkit'; | ||
export default function (options: ScanExecutorSchema, context: ExecutorContext): Promise<{ | ||
success: boolean; | ||
}>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const sonarQubeScanner = require("sonarqube-scanner"); | ||
const devkit_1 = require("@nrwl/devkit"); | ||
const tsquery_1 = require("@phenomnomnominal/tsquery"); | ||
const fs_1 = require("fs"); | ||
const child_process_1 = require("child_process"); | ||
const devkit_1 = require("@nx/devkit"); | ||
const utils_1 = require("./utils/utils"); | ||
function default_1(options, context) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
let success = true; | ||
yield scanner(options, context).catch((e) => { | ||
yield (0, utils_1.scanner)(options, context).catch((e) => { | ||
devkit_1.logger.error(`The SonarQube scan failed for project '${context.projectName}'. Error: ${e}`); | ||
@@ -22,83 +19,2 @@ success = false; | ||
exports.default = default_1; | ||
function determinePaths(options, context) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const sources = []; | ||
const lcovPaths = []; | ||
const graph = yield (0, devkit_1.createProjectGraphAsync)(); | ||
const targets = graph.dependencies[context.projectName].filter((project) => (options.skipImplicitDeps | ||
? project.type === devkit_1.DependencyType.static | ||
: project.type === devkit_1.DependencyType.static || | ||
project.type === devkit_1.DependencyType.implicit) && | ||
!project.target.includes('npm:')); | ||
targets.push({ | ||
type: devkit_1.DependencyType.static, | ||
target: context.projectName, | ||
source: context.projectName, | ||
}); | ||
targets.forEach((target) => { | ||
const projectConfig = context.workspace.projects[target.target]; | ||
const testTarget = projectConfig.targets.test; | ||
sources.push(projectConfig.sourceRoot); | ||
if (testTarget) { | ||
if (testTarget.options.jestConfig) { | ||
const jestConfigPath = projectConfig.targets.test.options.jestConfig; | ||
const jestConfig = (0, fs_1.readFileSync)(jestConfigPath, 'utf-8'); | ||
const ast = tsquery_1.tsquery.ast(jestConfig); | ||
const nodes = (0, tsquery_1.tsquery)(ast, 'Identifier[name="coverageDirectory"] ~ StringLiteral', { visitAllChildren: true }); | ||
if (nodes.length) { | ||
lcovPaths.push((0, devkit_1.joinPathFragments)(nodes[0] | ||
.getText() | ||
.replace(new RegExp(/'/g), '') | ||
.replace(/^(?:\.\.\/)+/, ''), 'lcov.info')); | ||
} | ||
else { | ||
devkit_1.logger.warn(`Skipping ${context.projectName} as it does not have a coverageDirectory in ${jestConfigPath}`); | ||
} | ||
} | ||
else { | ||
devkit_1.logger.warn(`Skipping ${context.projectName} as it does not have a jestConfig`); | ||
} | ||
} | ||
else { | ||
devkit_1.logger.warn(`Skipping ${context.projectName} as it does not have a test target`); | ||
} | ||
}); | ||
return Promise.resolve({ | ||
lcovPaths: lcovPaths.join(','), | ||
sources: sources.join(','), | ||
}); | ||
}); | ||
} | ||
function scanner(options, context) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const paths = yield determinePaths(options, context); | ||
devkit_1.logger.log(`Included sources: ${paths.sources}`); | ||
if (!options.qualityGate) | ||
devkit_1.logger.warn(`Skipping quality gate check`); | ||
sonarQubeScanner({ | ||
serverUrl: options.hostUrl, | ||
options: { | ||
'sonar.branch.name': options.branches | ||
? (0, child_process_1.execSync)('git rev-parse --abbrev-ref HEAD').toString() | ||
: '', | ||
'sonar.exclusions': options.exclusions, | ||
'sonar.javascript.lcov.reportPaths': paths.lcovPaths, | ||
'sonar.language': 'ts', | ||
'sonar.login': options.login, | ||
'sonar.organization': options.organization, | ||
'sonar.password': options.password, | ||
'sonar.projectKey': options.projectKey, | ||
'sonar.projectName': options.projectName, | ||
'sonar.projectVersion': options.projectVersion, | ||
'sonar.qualitygate.timeout': options.qualityGateTimeout, | ||
'sonar.qualitygate.wait': String(options.qualityGate), | ||
'sonar.scm.provider': 'git', | ||
'sonar.sources': paths.sources, | ||
'sonar.sourceEncoding': 'UTF-8', | ||
'sonar.typescript.tsconfigPath': 'tsconfig.base.json', | ||
'sonar.verbose': 'true', | ||
}, | ||
}); | ||
}); | ||
} | ||
//# sourceMappingURL=executor.js.map |
@@ -6,5 +6,3 @@ export interface ScanExecutorSchema { | ||
exclusions?: string; | ||
login?: string; | ||
organization?: string; | ||
password?: string; | ||
projectName?: string; | ||
@@ -15,2 +13,6 @@ projectVersion?: string; | ||
skipImplicitDeps?: boolean; | ||
testInclusions?: string; | ||
tsConfig?: string; | ||
verbose?: boolean; | ||
extra?: { [option: string]: string }; | ||
} |
{ | ||
"version": 2, | ||
"outputCapture": "direct-nodejs", | ||
"$schema": "http://json-schema.org/schema", | ||
"cli": "nx", | ||
"title": "SonarQube Scanner Executor", | ||
@@ -26,6 +27,2 @@ "description": "Scans and uploads test coverage based on SonarQube options (https://docs.sonarqube.org/latest/analysis/analysis-parameters/)", | ||
}, | ||
"login": { | ||
"description": "The authentication token or login of a SonarQube user with either Execute Analysis permission on the project or Global Execute Analysis permission.", | ||
"type": "string" | ||
}, | ||
"organization": { | ||
@@ -35,6 +32,2 @@ "description": "Sonar organization", | ||
}, | ||
"password": { | ||
"description": "If you're using an authentication token, leave this blank. If you're using a login, this is the password that goes with your sonar.login username.", | ||
"type": "string" | ||
}, | ||
"projectName": { | ||
@@ -62,2 +55,17 @@ "description": "Name of the project that will be displayed on the web interface.", | ||
"default": false | ||
}, | ||
"testInclusions": { | ||
"description": "Comma-delimited list of test file path patterns to be included in analysis. When set, only test files matching the paths set here will be included in analysis", | ||
"type": "string", | ||
"default": "**/*.spec.ts" | ||
}, | ||
"tsConfig": { | ||
"description": "Path to tsconfig.json", | ||
"type": "string", | ||
"default": "tsconfig.base.json" | ||
}, | ||
"verbose": { | ||
"description": "Add more detail to both client and server-side analysis logs", | ||
"type": "boolean", | ||
"default": false | ||
} | ||
@@ -64,0 +72,0 @@ }, |
@@ -1,3 +0,3 @@ | ||
import { Tree } from '@nrwl/devkit'; | ||
import { Tree } from '@nx/devkit'; | ||
import { NxSonarqubeGeneratorSchema } from './schema'; | ||
export default function (tree: Tree, options: NxSonarqubeGeneratorSchema): Promise<void>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const devkit_1 = require("@nrwl/devkit"); | ||
const devkit_1 = require("@nx/devkit"); | ||
function default_1(tree, options) { | ||
@@ -21,3 +21,3 @@ return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
if (!gitIgnore.includes('.scannerwork')) { | ||
gitIgnore += '\n.scannerwork'; | ||
gitIgnore += '\n# Sonar\n.scannerwork'; | ||
tree.write(ignoreFile, gitIgnore); | ||
@@ -28,12 +28,16 @@ } | ||
function updateTargetDefaults(tree) { | ||
const nxJsonConfiguration = (0, devkit_1.readNxJson)(); | ||
const hasSonar = Object.keys(nxJsonConfiguration.targetDefaults).find((key) => key === 'sonar'); | ||
if (!hasSonar) { | ||
(0, devkit_1.updateJson)(tree, 'nx.json', (json) => { | ||
(0, devkit_1.updateJson)(tree, 'nx.json', (json) => { | ||
const nxJsonConfiguration = (0, devkit_1.readNxJson)(tree); | ||
if (!nxJsonConfiguration.targetDefaults.sonar) { | ||
json.targetDefaults.sonar = { | ||
dependsOn: ['^test', 'test'], | ||
}; | ||
return json; | ||
}); | ||
} | ||
} | ||
if (!nxJsonConfiguration.targetDefaults.test) { | ||
json.targetDefaults.test = { | ||
dependsOn: ['^test'], | ||
}; | ||
} | ||
return json; | ||
}); | ||
} | ||
@@ -48,6 +52,3 @@ function updateProjectConfig(tree, options) { | ||
executor: '@koliveira15/nx-sonarqube:scan', | ||
options: { | ||
hostUrl: options.hostUrl, | ||
projectKey: options.projectKey, | ||
}, | ||
options: Object.assign({}, options), | ||
}; | ||
@@ -54,0 +55,0 @@ (0, devkit_1.updateProjectConfiguration)(tree, options.name, projectConfiguration); |
@@ -6,2 +6,12 @@ export interface NxSonarqubeGeneratorSchema { | ||
skipTargetDefaults?: boolean; | ||
branches?: boolean; | ||
exclusions?: string; | ||
login?: string; | ||
organization?: string; | ||
password?: string; | ||
projectName?: string; | ||
projectVersion?: string; | ||
qualityGate?: boolean; | ||
qualityGateTimeout?: string; | ||
skipImplicitDeps?: boolean; | ||
} |
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"cli": "nx", | ||
"$id": "NxSonarqube", | ||
@@ -31,2 +30,46 @@ "title": "", | ||
"default": false | ||
}, | ||
"branches": { | ||
"description": "Include branch name in analysis", | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"exclusions": { | ||
"description": "Files to exclude from coverage", | ||
"type": "string" | ||
}, | ||
"login": { | ||
"description": "The authentication token or login of a SonarQube user with either Execute Analysis permission on the project or Global Execute Analysis permission.", | ||
"type": "string" | ||
}, | ||
"organization": { | ||
"description": "Sonar organization", | ||
"type": "string" | ||
}, | ||
"password": { | ||
"description": "If you're using an authentication token, leave this blank. If you're using a login, this is the password that goes with your sonar.login username.", | ||
"type": "string" | ||
}, | ||
"projectName": { | ||
"description": "Name of the project that will be displayed on the web interface.", | ||
"type": "string" | ||
}, | ||
"projectVersion": { | ||
"description": "The project version.", | ||
"type": "string" | ||
}, | ||
"qualityGate": { | ||
"description": "Forces the analysis step to poll the SonarQube instance and wait for the Quality Gate status.", | ||
"type": "boolean", | ||
"default": true | ||
}, | ||
"qualityGateTimeout": { | ||
"description": "Sets the number of seconds that the scanner should wait for a report to be processed.", | ||
"type": "string", | ||
"default": "300" | ||
}, | ||
"skipImplicitDeps": { | ||
"description": "Skips adding implicit dependencies to the project graph analysis", | ||
"type": "boolean", | ||
"default": false | ||
} | ||
@@ -33,0 +76,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Unpopular package
QualityThis package is not very popular.
Found 1 instance in 1 package
28121
20
500
0
4
5
2
+ Added@jest/schemas@29.6.3(transitive)
+ Added@nrwl/devkit@16.7.4(transitive)
+ Added@nrwl/tao@17.3.2(transitive)
+ Added@nx/devkit@16.7.4(transitive)
+ Added@nx/nx-darwin-arm64@17.3.2(transitive)
+ Added@nx/nx-darwin-x64@17.3.2(transitive)
+ Added@nx/nx-freebsd-x64@17.3.2(transitive)
+ Added@nx/nx-linux-arm-gnueabihf@17.3.2(transitive)
+ Added@nx/nx-linux-arm64-gnu@17.3.2(transitive)
+ Added@nx/nx-linux-arm64-musl@17.3.2(transitive)
+ Added@nx/nx-linux-x64-gnu@17.3.2(transitive)
+ Added@nx/nx-linux-x64-musl@17.3.2(transitive)
+ Added@nx/nx-win32-arm64-msvc@17.3.2(transitive)
+ Added@nx/nx-win32-x64-msvc@17.3.2(transitive)
+ Added@phenomnomnominal/tsquery@5.0.1(transitive)
+ Added@sinclair/typebox@0.27.8(transitive)
+ Added@yarnpkg/lockfile@1.1.0(transitive)
+ Added@yarnpkg/parsers@3.0.0-rc.46(transitive)
+ Added@zkochan/js-yaml@0.0.6(transitive)
+ Addedagent-base@6.0.2(transitive)
+ Addedansi-colors@4.1.3(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.05.2.0(transitive)
+ Addedargparse@1.0.102.0.1(transitive)
+ Addedasync@3.2.6(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaxios@1.7.9(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbl@4.1.0(transitive)
+ Addedbrace-expansion@1.1.112.0.1(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcli-cursor@3.1.0(transitive)
+ Addedcli-spinners@2.6.1(transitive)
+ Addedcliui@8.0.1(transitive)
+ Addedclone@1.0.4(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addeddefaults@1.0.4(transitive)
+ Addeddefine-lazy-prop@2.0.0(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addeddiff-sequences@29.6.3(transitive)
+ Addeddotenv@16.3.2(transitive)
+ Addeddotenv-expand@10.0.0(transitive)
+ Addedduplexer@0.1.2(transitive)
+ Addedejs@3.1.10(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedenquirer@2.3.6(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedfancy-log@2.0.0(transitive)
+ Addedfigures@3.2.0(transitive)
+ Addedfilelist@1.0.4(transitive)
+ Addedflat@5.0.2(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedform-data@4.0.1(transitive)
+ Addedfs-extra@11.3.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedhttps-proxy-agent@5.0.1(transitive)
+ Addedignore@5.3.2(transitive)
+ Addedis-docker@2.2.1(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedis-interactive@1.0.0(transitive)
+ Addedis-unicode-supported@0.1.0(transitive)
+ Addedis-wsl@2.2.0(transitive)
+ Addedjake@10.9.2(transitive)
+ Addedjest-diff@29.7.0(transitive)
+ Addedjest-get-type@29.6.3(transitive)
+ Addedjs-yaml@3.14.14.1.0(transitive)
+ Addedjson5@2.2.3(transitive)
+ Addedjsonc-parser@3.2.0(transitive)
+ Addedjsonfile@6.1.0(transitive)
+ Addedlines-and-columns@2.0.4(transitive)
+ Addedlog-symbols@4.1.0(transitive)
+ Addedlru-cache@6.0.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addedminimatch@3.1.25.1.69.0.3(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedms@2.1.3(transitive)
+ Addednode-downloader-helper@2.1.9(transitive)
+ Addednode-machine-id@1.1.12(transitive)
+ Addednpm-run-path@4.0.1(transitive)
+ Addednx@17.3.2(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedopen@8.4.2(transitive)
+ Addedora@5.3.0(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedpretty-format@29.7.0(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
+ Addedreact-is@18.3.1(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedrestore-cursor@3.1.0(transitive)
+ Addedsemver@7.5.3(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedsonarqube-scanner@3.0.1(transitive)
+ Addedsprintf-js@1.0.3(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedstrong-log-transformer@2.1.0(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedtar-stream@2.2.0(transitive)
+ Addedtmp@0.2.3(transitive)
+ Addedtsconfig-paths@4.2.0(transitive)
+ Addedtslib@2.5.2(transitive)
+ Addedtypescript@5.7.3(transitive)
+ Addeduniversalify@2.0.1(transitive)
+ Addedwcwidth@1.0.1(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyallist@4.0.0(transitive)
+ Addedyargs@17.7.2(transitive)
+ Addedyargs-parser@21.1.1(transitive)
- Removed@phenomnomnominal/tsquery@5.0.0(transitive)
- Removedansi-gray@0.1.1(transitive)
- Removedansi-wrap@0.1.0(transitive)
- Removedcaw@2.0.1(transitive)
- Removedconfig-chain@1.1.13(transitive)
- Removedcontent-disposition@0.5.4(transitive)
- Removeddecompress-response@3.3.0(transitive)
- Removeddownload@6.2.5(transitive)
- Removedduplexer3@0.1.5(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedext-list@2.2.2(transitive)
- Removedext-name@5.0.0(transitive)
- Removedextend@3.0.2(transitive)
- Removedfancy-log@1.3.3(transitive)
- Removedfilename-reserved-regex@2.0.0(transitive)
- Removedfilenamify@2.1.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-proxy@2.1.0(transitive)
- Removedget-stream@3.0.0(transitive)
- Removedgot@7.1.0(transitive)
- Removedhas-symbol-support-x@1.4.2(transitive)
- Removedhas-to-string-tag-x@1.4.1(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedini@1.3.8(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.16.1(transitive)
- Removedis-object@1.0.2(transitive)
- Removedis-plain-obj@1.1.0(transitive)
- Removedis-retry-allowed@1.2.0(transitive)
- Removedisurl@1.0.0(transitive)
- Removedload-json-file@2.0.0(transitive)
- Removedlodash.get@4.4.2(transitive)
- Removedlodash.uniq@4.5.0(transitive)
- Removedlowercase-keys@1.0.1(transitive)
- Removedmime-db@1.53.0(transitive)
- Removedmimic-response@1.0.1(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removednpm-conf@1.1.3(transitive)
- Removedp-cancelable@0.3.0(transitive)
- Removedp-event@1.3.0(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedp-timeout@1.2.1(transitive)
- Removedparse-json@2.2.0(transitive)
- Removedparse-node-version@1.0.1(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@2.0.0(transitive)
- Removedprepend-http@1.0.4(transitive)
- Removedproto-list@1.2.4(transitive)
- Removedread-pkg@2.0.0(transitive)
- Removedresolve@1.22.10(transitive)
- Removedsemver@5.7.2(transitive)
- Removedsonarqube-scanner@2.8.1(transitive)
- Removedsort-keys@1.1.2(transitive)
- Removedsort-keys-length@1.0.1(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.21(transitive)
- Removedstrip-outer@1.0.1(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedtime-stamp@1.1.0(transitive)
- Removedtimed-out@4.0.1(transitive)
- Removedtrim-repeated@1.0.0(transitive)
- Removedtslib@2.3.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtypescript@4.9.5(transitive)
- Removedurl-parse-lax@1.0.0(transitive)
- Removedurl-to-options@1.0.1(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
Updatedsonarqube-scanner@3.0.1
Updatedtslib@2.5.2