diff --git a/package-lock.json b/package-lock.json index 7b0f168..0684bf8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@phenomnomnominal/tsquery": "6.1.3", "@swc/helpers": "0.5.15", "astro": "4.3.5", - "sonarqube-scanner": "3.1.0", + "sonarqube-scanner": "4.2.5", "tslib": "2.8.1" }, "devDependencies": { @@ -9104,8 +9104,7 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "dev": true + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/at-least-node": { "version": "1.0.0", @@ -9182,7 +9181,6 @@ "version": "1.7.7", "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", - "dev": true, "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", @@ -9201,8 +9199,7 @@ "node_modules/b4a": { "version": "1.6.6", "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.6.tgz", - "integrity": "sha512-5Tk1HLk6b6ctmjIkAcU/Ujv/1WqiDl0F0JdRCR80VsOcUlHcu7pWeWRlOqQLHfDEsVx9YH/aif5AG4ehoCtTmg==", - "optional": true + "integrity": "sha512-5Tk1HLk6b6ctmjIkAcU/Ujv/1WqiDl0F0JdRCR80VsOcUlHcu7pWeWRlOqQLHfDEsVx9YH/aif5AG4ehoCtTmg==" }, "node_modules/babel-jest": { "version": "29.7.0", @@ -10486,15 +10483,6 @@ "simple-swizzle": "^0.2.2" } }, - "node_modules/color-support": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", - "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", - "license": "ISC", - "bin": { - "color-support": "bin.js" - } - }, "node_modules/colord": { "version": "2.9.3", "resolved": "https://registry.npmjs.org/colord/-/colord-2.9.3.tgz", @@ -10524,7 +10512,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "dependencies": { "delayed-stream": "~1.0.0" }, @@ -11473,7 +11460,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "dev": true, "engines": { "node": ">=0.4.0" } @@ -13156,18 +13142,6 @@ "node >=0.6.0" ] }, - "node_modules/fancy-log": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-2.0.0.tgz", - "integrity": "sha512-9CzxZbACXMUXW13tS0tI8XsGGmxWzO2DmYrGuBJOJ8k8q2K7hwfJA5qHjuPPe8wtsco33YR9wc+Rlr5wYFvhSA==", - "license": "MIT", - "dependencies": { - "color-support": "^1.1.3" - }, - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -13177,8 +13151,7 @@ "node_modules/fast-fifo": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz", - "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==", - "optional": true + "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==" }, "node_modules/fast-glob": { "version": "3.2.7", @@ -13626,7 +13599,6 @@ "version": "1.15.9", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", - "dev": true, "funding": [ { "type": "individual", @@ -13799,7 +13771,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", - "dev": true, "license": "MIT", "dependencies": { "asynckit": "^0.4.0", @@ -14668,6 +14639,15 @@ "safe-buffer": "~5.1.0" } }, + "node_modules/hpagent": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/hpagent/-/hpagent-1.2.0.tgz", + "integrity": "sha512-A91dYTeIB6NoXG+PxTQpCCDDnfHsW9kc06Lvpu1TEe9gnd6ZFeiBoRO9JvzEv6xK7EX97/dUE8g/vBMTqTS3CA==", + "license": "MIT", + "engines": { + "node": ">=14" + } + }, "node_modules/html-encoding-sniffer": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz", @@ -16285,6 +16265,18 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/jest-sonar-reporter": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/jest-sonar-reporter/-/jest-sonar-reporter-2.0.0.tgz", + "integrity": "sha512-ZervDCgEX5gdUbdtWsjdipLN3bKJwpxbvhkYNXTAYvAckCihobSLr9OT/IuyNIRT1EZMDDwR6DroWtrq+IL64w==", + "license": "MIT", + "dependencies": { + "xml": "^1.0.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/jest-util": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", @@ -16574,7 +16566,6 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, "dependencies": { "universalify": "^2.0.0" }, @@ -19036,7 +19027,6 @@ "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "dev": true, "engines": { "node": ">= 0.6" } @@ -19045,7 +19035,6 @@ "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dev": true, "dependencies": { "mime-db": "1.52.0" }, @@ -19382,18 +19371,6 @@ "integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==", "optional": true }, - "node_modules/node-downloader-helper": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/node-downloader-helper/-/node-downloader-helper-2.1.9.tgz", - "integrity": "sha512-FSvAol2Z8UP191sZtsUZwHIN0eGoGue3uEXGdWIH5228e9KH1YHXT7fN8Oa33UGf+FbqGTQg3sJfrRGzmVCaJA==", - "license": "MIT", - "bin": { - "ndh": "bin/ndh" - }, - "engines": { - "node": ">=14.18" - } - }, "node_modules/node-fetch": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", @@ -19440,7 +19417,6 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", "integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==", - "dev": true, "license": "(BSD-3-Clause OR GPL-2.0)", "engines": { "node": ">= 6.13.0" @@ -21283,15 +21259,6 @@ "integrity": "sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q==", "dev": true }, - "node_modules/progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "license": "MIT", - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/prompts": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", @@ -21304,6 +21271,15 @@ "node": ">= 6" } }, + "node_modules/properties-file": { + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/properties-file/-/properties-file-3.5.4.tgz", + "integrity": "sha512-OGQPWZ4j9ENDKBl+wUHqNtzayGF5sLlVcmjcqEMUUHeCbUSggDndii+kjcBDPj3GQvqYB9sUEc4siX36wx4glw==", + "license": "MIT", + "engines": { + "node": "*" + } + }, "node_modules/property-expr": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/property-expr/-/property-expr-2.0.6.tgz", @@ -21336,7 +21312,6 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", - "dev": true, "license": "MIT" }, "node_modules/prr": { @@ -21443,8 +21418,7 @@ "node_modules/queue-tick": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/queue-tick/-/queue-tick-1.0.1.tgz", - "integrity": "sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==", - "optional": true + "integrity": "sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==" }, "node_modules/quick-format-unescaped": { "version": "4.0.4", @@ -23462,64 +23436,63 @@ } }, "node_modules/sonarqube-scanner": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/sonarqube-scanner/-/sonarqube-scanner-3.1.0.tgz", - "integrity": "sha512-7CspErch2pVwFrC9aM7NminyI0+OQmFz0V5IHJtC7FLM0cbKA2MnlsvfGfqZekqxMmxbWcybZ/izou4nQh9nMQ==", - "license": "LGPL-3.0", - "dependencies": { - "adm-zip": "^0.5.10", - "fancy-log": "^2.0.0", - "https-proxy-agent": "^7.0.1", - "mkdirp": "^3.0.1", - "node-downloader-helper": "^2.1.9", - "progress": "^2.0.3", - "slugify": "^1.6.6" + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/sonarqube-scanner/-/sonarqube-scanner-4.2.5.tgz", + "integrity": "sha512-7Hs8Or1ZmgzIh4DLavRVlmrKfoQo+x6DFr7Aw3BnMRswlflalObKKJrj10/A2J2bfYd7iqkt1DXeIoTXNJrCkg==", + "license": "LGPL-3.0-only", + "dependencies": { + "adm-zip": "0.5.12", + "axios": "1.7.7", + "commander": "12.0.0", + "fs-extra": "11.2.0", + "hpagent": "1.2.0", + "jest-sonar-reporter": "2.0.0", + "node-forge": "^1.3.1", + "properties-file": "3.5.4", + "proxy-from-env": "^1.1.0", + "semver": "7.6.0", + "slugify": "1.6.6", + "tar-stream": "3.1.7" }, "bin": { - "sonar-scanner": "src/bin/sonar-scanner" + "sonar-scanner": "bin/sonar-scanner" }, "engines": { - "node": ">= 14" + "node": ">= 18" } }, - "node_modules/sonarqube-scanner/node_modules/agent-base": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", - "integrity": "sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==", + "node_modules/sonarqube-scanner/node_modules/commander": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-12.0.0.tgz", + "integrity": "sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA==", "license": "MIT", - "dependencies": { - "debug": "^4.3.4" - }, "engines": { - "node": ">= 14" + "node": ">=18" } }, - "node_modules/sonarqube-scanner/node_modules/https-proxy-agent": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz", - "integrity": "sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw==", + "node_modules/sonarqube-scanner/node_modules/fs-extra": { + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz", + "integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==", "license": "MIT", "dependencies": { - "agent-base": "^7.0.2", - "debug": "4" + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" }, "engines": { - "node": ">= 14" + "node": ">=14.14" } }, - "node_modules/sonarqube-scanner/node_modules/mkdirp": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz", - "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==", + "node_modules/sonarqube-scanner/node_modules/tar-stream": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.7.tgz", + "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", "license": "MIT", - "bin": { - "mkdirp": "dist/cjs/src/bin.js" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" + "dependencies": { + "b4a": "^1.6.4", + "fast-fifo": "^1.2.0", + "streamx": "^2.15.0" } }, "node_modules/sonic-boom": { @@ -23866,7 +23839,6 @@ "version": "2.15.8", "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.15.8.tgz", "integrity": "sha512-6pwMeMY/SuISiRsuS8TeIrAzyFbG5gGPHFQsYjUr/pbBadaL1PCWmzKw+CHZSwainfvcF6Si6cVLq4XTEwswFQ==", - "optional": true, "dependencies": { "fast-fifo": "^1.1.0", "queue-tick": "^1.0.1" @@ -25323,7 +25295,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true, "engines": { "node": ">= 10.0.0" } @@ -26988,6 +26959,12 @@ } } }, + "node_modules/xml": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", + "integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==", + "license": "MIT" + }, "node_modules/xml-name-validator": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz", diff --git a/package.json b/package.json index 42dae9c..1bbb494 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@phenomnomnominal/tsquery": "6.1.3", "@swc/helpers": "0.5.15", "astro": "4.3.5", - "sonarqube-scanner": "3.1.0", + "sonarqube-scanner": "4.2.5", "tslib": "2.8.1" }, "optionalDependencies": { diff --git a/packages/nx-sonarqube/package.json b/packages/nx-sonarqube/package.json index f8b3a32..997d570 100644 --- a/packages/nx-sonarqube/package.json +++ b/packages/nx-sonarqube/package.json @@ -14,7 +14,7 @@ "peerDependencies": { "@nx/devkit": ">= 16 < 21", "@phenomnomnominal/tsquery": "6.1.3", - "sonarqube-scanner": ">= 3.1.0 < 4", + "sonarqube-scanner": ">= 4.2.5 < 5", "nx": ">= 16 < 21", "tslib": ">= 2.3.0 < 3" } diff --git a/packages/nx-sonarqube/src/executors/scan/executor-crystal.spec.ts b/packages/nx-sonarqube/src/executors/scan/executor-crystal.spec.ts index 1a90290..bc9b951 100644 --- a/packages/nx-sonarqube/src/executors/scan/executor-crystal.spec.ts +++ b/packages/nx-sonarqube/src/executors/scan/executor-crystal.spec.ts @@ -226,7 +226,7 @@ describe('Scan Executor - Crystal', (): void => { it('should scan project and dependencies', async () => { jest.spyOn(fs, 'readFileSync').mockReturnValue(jestConfig); - sonarQubeScanner.mockResolvedValue(true); + jest.spyOn(sonarQubeScanner, 'scan').mockResolvedValue(); const output = await sonarScanExecutor( { diff --git a/packages/nx-sonarqube/src/executors/scan/executor-jest.spec.ts b/packages/nx-sonarqube/src/executors/scan/executor-jest.spec.ts index a5a055e..6485ea9 100644 --- a/packages/nx-sonarqube/src/executors/scan/executor-jest.spec.ts +++ b/packages/nx-sonarqube/src/executors/scan/executor-jest.spec.ts @@ -229,7 +229,7 @@ describe('Scan Executor', (): void => { it('should scan project and dependencies & skip projects with no test target', async () => { jest.spyOn(fs, 'readFileSync').mockReturnValue(jestConfig); - sonarQubeScanner.mockResolvedValue(true); + jest.spyOn(sonarQubeScanner, 'scan').mockResolvedValue(); const newContext = { ...context }; newContext.projectsConfigurations.projects['app1'].targets = {}; @@ -246,7 +246,7 @@ describe('Scan Executor', (): void => { }); it('should skip dependency if jest.config.ts does not exist', async () => { - sonarQubeScanner.mockResolvedValue(true); + jest.spyOn(sonarQubeScanner, 'scan').mockResolvedValue(); jest.spyOn(fs, 'readFileSync').mockReturnValue(jestConfig); jest.spyOn(fs, 'existsSync').mockReturnValue(false); @@ -263,7 +263,7 @@ describe('Scan Executor', (): void => { it('should scan project and dependencies & skip projects with no jestConfig', async () => { jest.spyOn(fs, 'readFileSync').mockReturnValue(jestConfig); - sonarQubeScanner.mockResolvedValue(true); + jest.spyOn(sonarQubeScanner, 'scan').mockResolvedValue(); const newContext = { ...context }; newContext.projectsConfigurations.projects['app1'].targets.test.options = {}; @@ -282,7 +282,7 @@ describe('Scan Executor', (): void => { it('should scan project and dependencies & skip projects with no coverageDirectory', async () => { jest.spyOn(fs, 'readFileSync').mockReturnValue(''); - sonarQubeScanner.mockResolvedValue(true); + jest.spyOn(sonarQubeScanner, 'scan').mockResolvedValue(); const output = await sonarScanExecutor( { @@ -297,7 +297,7 @@ describe('Scan Executor', (): void => { it('should error on sonar scanner issue', async () => { jest.spyOn(fs, 'readFileSync').mockReturnValue(jestConfig); - sonarQubeScanner.async.mockImplementation(() => { + jest.spyOn(sonarQubeScanner, 'scan').mockImplementation(() => { throw new Error(); }); diff --git a/packages/nx-sonarqube/src/executors/scan/executor-vite.spec.ts b/packages/nx-sonarqube/src/executors/scan/executor-vite.spec.ts index 76c7df9..59d2424 100644 --- a/packages/nx-sonarqube/src/executors/scan/executor-vite.spec.ts +++ b/packages/nx-sonarqube/src/executors/scan/executor-vite.spec.ts @@ -220,7 +220,7 @@ describe('Scan Executor', (): void => { it('should scan project and dependencies & skip projects with no test target', async () => { jest.spyOn(fs, 'existsSync').mockReturnValue(true) jest.spyOn(fs, 'readFileSync').mockReturnValue(viteConfig); - sonarQubeScanner.mockResolvedValue(true); + jest.spyOn(sonarQubeScanner, 'scan').mockResolvedValue(); const newContext = { ...context }; newContext.projectsConfigurations.projects['app1'].targets = {}; @@ -238,7 +238,7 @@ describe('Scan Executor', (): void => { it('should scan project and dependencies & skip projects with no vitest config', async () => { jest.spyOn(fs, 'existsSync').mockReturnValue(true) jest.spyOn(fs, 'readFileSync').mockReturnValue(viteConfig); - sonarQubeScanner.mockResolvedValue(true); + jest.spyOn(sonarQubeScanner, 'scan').mockResolvedValue(); const newContext = { ...context }; newContext.projectsConfigurations.projects['app1'].targets.test.options = {}; @@ -256,7 +256,7 @@ describe('Scan Executor', (): void => { it('should scan project and dependencies & skip projects with no reportsDirectory', async () => { jest.spyOn(fs, 'existsSync').mockReturnValue(true) jest.spyOn(fs, 'readFileSync').mockReturnValue(viteConfig) - sonarQubeScanner.mockResolvedValue(true); + jest.spyOn(sonarQubeScanner, 'scan').mockResolvedValue(); const newContext = { ...context }; newContext.projectsConfigurations.projects['app1'].targets.test.options = { @@ -275,7 +275,7 @@ describe('Scan Executor', (): void => { it('should scan project and dependencies & skip projects with no vite config file', async () => { jest.spyOn(fs, 'existsSync').mockReturnValue(false) - sonarQubeScanner.mockResolvedValue(true); + jest.spyOn(sonarQubeScanner, 'scan').mockResolvedValue(); const newContext = { ...context }; newContext.projectsConfigurations.projects['app1'].targets.test.options = { @@ -305,7 +305,7 @@ describe('Scan Executor', (): void => { }), ); `) - sonarQubeScanner.mockResolvedValue(true); + jest.spyOn(sonarQubeScanner, 'scan').mockResolvedValue(); const newContext = { ...context }; newContext.projectsConfigurations.projects['app1'].targets.test.options = { @@ -325,7 +325,7 @@ describe('Scan Executor', (): void => { it('should error on sonar scanner issue', async () => { jest.spyOn(fs, 'existsSync').mockReturnValue(true) jest.spyOn(fs, 'readFileSync').mockReturnValue(viteConfig) - sonarQubeScanner.async.mockImplementation(() => { + jest.spyOn(sonarQubeScanner, 'scan').mockImplementation(() => { throw new Error(); }); diff --git a/packages/nx-sonarqube/src/executors/scan/executor.spec.ts b/packages/nx-sonarqube/src/executors/scan/executor.spec.ts index e0622c2..bb5b611 100644 --- a/packages/nx-sonarqube/src/executors/scan/executor.spec.ts +++ b/packages/nx-sonarqube/src/executors/scan/executor.spec.ts @@ -233,7 +233,7 @@ describe('Scan Executor', (): void => { it('should scan project and dependencies', async () => { jest.spyOn(fs, 'readFileSync').mockReturnValue(jestConfig); - sonarQubeScanner.mockResolvedValue(true); + jest.spyOn(sonarQubeScanner, 'scan').mockResolvedValue(); const output = await sonarScanExecutor( { @@ -250,7 +250,7 @@ describe('Scan Executor', (): void => { it('should scan project and dependencies with branch name', async () => { jest.spyOn(fs, 'readFileSync').mockReturnValue(jestConfig); - sonarQubeScanner.mockResolvedValue(true); + jest.spyOn(sonarQubeScanner, 'scan').mockResolvedValue(); const output = await sonarScanExecutor( { @@ -265,7 +265,7 @@ describe('Scan Executor', (): void => { it('should scan project and dependencies & skip projects with no test target', async () => { jest.spyOn(fs, 'readFileSync').mockReturnValue(jestConfig); - sonarQubeScanner.mockResolvedValue(true); + jest.spyOn(sonarQubeScanner, 'scan').mockResolvedValue(); const newContext = { ...context }; newContext.projectsConfigurations.projects['app1'].targets = {}; @@ -287,7 +287,7 @@ describe('Scan Executor', (): void => { ).mockImplementation(() => { return {}; }); - sonarQubeScanner.async.mockResolvedValue(true); + jest.spyOn(sonarQubeScanner, 'scan').mockResolvedValue(); process.env['SONAR_BRANCH'] = 'main'; process.env['SONAR_LOG_LEVEL_EXTENDED'] = 'DEBUG'; process.env['SONAR_VERBOSE'] = 'true'; diff --git a/packages/nx-sonarqube/src/executors/scan/utils/utils.ts b/packages/nx-sonarqube/src/executors/scan/utils/utils.ts index 942b83b..cccf20f 100644 --- a/packages/nx-sonarqube/src/executors/scan/utils/utils.ts +++ b/packages/nx-sonarqube/src/executors/scan/utils/utils.ts @@ -216,7 +216,7 @@ export async function determinePaths( export async function scanner( options: ScanExecutorSchema, context: ExecutorContext -): Promise<{ success: boolean }> { +): Promise<{ success: void }> { const paths = await determinePaths(options, context); logger.log(`Included sources paths: ${paths.sources}`); @@ -230,7 +230,7 @@ export async function scanner( paths.sources, paths.lcovPaths ); - const success = await sonarQubeScanner.async({ + const success = await sonarQubeScanner.scan({ serverUrl: options.hostUrl, options: scannerOptions, }); diff --git a/packages/nx-sonarqube/src/generators/config/generator.spec.ts b/packages/nx-sonarqube/src/generators/config/generator.spec.ts index 54e06de..3e35c9a 100644 --- a/packages/nx-sonarqube/src/generators/config/generator.spec.ts +++ b/packages/nx-sonarqube/src/generators/config/generator.spec.ts @@ -9,6 +9,9 @@ import { import sonarQubeConfigGenerator from './generator'; import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; +// temporary mock until Jest 30. Issue: https://github.com/nrwl/nx/issues/26387#issuecomment-2191174250 +jest.mock('prettier', () => null); + describe('Configuration generator', () => { let tree: Tree;