diff --git a/.circleci/deprecated-check.js b/.circleci/deprecated-check.js new file mode 100644 index 0000000..b3df766 --- /dev/null +++ b/.circleci/deprecated-check.js @@ -0,0 +1,98 @@ +const { spawnSync } = require('child_process'); + +function execCommandSync(command) { + const [cmd, ...args] = command.split(' '); // Split command into executable and arguments + const result = spawnSync(cmd, args, { encoding: 'utf-8', shell: false }); + + if (result.error) { + throw result.error; // Handle system errors + } + if (result.status !== 0) { + throw new Error(result.stderr || `Command failed with exit code ${result.status}`); + } + return result.stdout; +} + +const dependenciesMap = new Map(); +const regex = /(?:@[\w-]+\/)?[\w.-]{1,100}@\d{1,10}\.\d{1,10}\.\d{1,10}(?:[-+][\w.-]{1,50})?/g; + +function checkDependencySync(dependency) { + if (dependenciesMap.has(dependency)) return; + try { + const output = execCommandSync(`npm view ${dependency}`); + if (output.includes('DEPRECATED')) { + dependenciesMap.set(dependency, 'DEPRECATED'); + } else { + dependenciesMap.set(dependency, 'active'); + } + } catch (error) { + dependenciesMap.set(dependency, 'UNKNOWN'); + } +} + +function processLinesSync(lines) { + for (const line of lines) { + const trimmedLine = line.trim(); + const matches = trimmedLine.matchAll(regex); + + for (const match of matches) { + const dependency = match[0]; + checkDependencySync(dependency); + } + } +} + +function checkDependenciesSync(command) { + try { + const stdout = execCommandSync(command); + const lines = stdout.trim().split('\n'); + processLinesSync(lines); + } catch (error) { + + const errorLines = error.toString().trim().split('\n'); + processLinesSync(errorLines); // Process error lines as well + } +} + +function runDependencyCheckSync() { + console.log('Checking dependencies at root level...'); + checkDependenciesSync('npm ls'); + + let deprecatedFound = false; + let counter = 0; + dependenciesMap.forEach((status, dependency) => { + if (status === 'DEPRECATED') { + counter++; + deprecatedFound = true; + console.log(`${counter}. ${dependency} ${status}`); + } + }); + + if (deprecatedFound) { + console.log('\x1b[31mWARNING!! Deprecated results found at root level.\n\x1b[0m'); + } else { + console.log('\x1b[32mSUCCESS: No deprecated packages found at root level! Congos!!\n\x1b[0m'); + } + + console.log('Checking all dependencies (including transitive)...'); + checkDependenciesSync('npm ls --all'); + + deprecatedFound = false; + counter = 0; + dependenciesMap.forEach((status, dependency) => { + if (status === 'DEPRECATED') { + counter++; + deprecatedFound = true; + console.log(`${counter}. ${dependency} ${status}`); + } + }); + + if (deprecatedFound) { + console.log('\x1b[31mWARNING!! Deprecated results found in dependencies.\n\x1b[0m'); + } else { + console.log('\x1b[32mSUCCESS: No deprecated packages found! Congos!!\x1b[0m'); + } + +} + +runDependencyCheckSync(); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index f9c8bd2..ba69afd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,7 +40,7 @@ "sinon": "21.0.0", "standard": "17.1.2", "standard-version": "^9.5.0", - "tap-spec": "^5.0.0", + "tap-mocha-reporter": "^5.0.4", "tap-xunit": "2.4.1", "tape": "5.9.0", "tapes": "4.1.0" @@ -1622,6 +1622,16 @@ "node": ">= 8" } }, + "node_modules/@npmcli/package-json": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-1.0.1.tgz", + "integrity": "sha512-y6jnu76E9C23osz8gEMBayZmaZ69vFOIk8vR1FJL/wbEJ54+9aVG9rLTjQKSXfgYZEr50nw1txBBFfBZZe+bYg==", + "dev": true, + "license": "ISC", + "dependencies": { + "json-parse-even-better-errors": "^2.3.1" + } + }, "node_modules/@opentelemetry/api": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz", @@ -3392,8 +3402,7 @@ "dev": true, "license": "ISC", "dependencies": { - "compare-func": "^2.0.0", - "q": "^1.5.1" + "compare-func": "^2.0.0" }, "engines": { "node": ">=10" @@ -3440,8 +3449,7 @@ "license": "ISC", "dependencies": { "compare-func": "^2.0.0", - "lodash": "^4.17.15", - "q": "^1.5.1" + "lodash": "^4.17.15" }, "engines": { "node": ">=10" @@ -3464,7 +3472,6 @@ "git-semver-tags": "^4.1.1", "lodash": "^4.17.15", "normalize-package-data": "^3.0.0", - "q": "^1.5.1", "read-pkg": "^3.0.0", "read-pkg-up": "^3.0.0", "through2": "^4.0.0" @@ -3532,8 +3539,7 @@ "dev": true, "license": "ISC", "dependencies": { - "compare-func": "^2.0.0", - "q": "^1.5.1" + "compare-func": "^2.0.0" }, "engines": { "node": ">=10" @@ -3631,8 +3637,7 @@ "conventional-commits-parser": "^3.2.0", "git-raw-commits": "^2.0.8", "git-semver-tags": "^4.1.1", - "meow": "^8.0.0", - "q": "^1.5.1" + "meow": "^8.0.0" }, "bin": { "conventional-recommended-bump": "cli.js" @@ -6738,16 +6743,12 @@ "integrity": "sha512-jobE6S923cLuf5BPG6Jf+oLBRkPzv2RPp0dwOHcWwj/t9FwV/t9hyZ46kpT3Q5DHn9iFNmGhrcmmFUBqyjoTQg==", "license": "MIT", "dependencies": { - "chalk": "^1.1.1", - "commander": "^2.9.0", - "debug": "^2.2.0", - "event-stream": "3.3.4", - "form-data": "3.0.0", - "fs-readfile-promise": "^2.0.1", - "fs-writefile-promise": "^1.0.3", - "har-validator": "^5.0.0", - "pinkie-promise": "^2.0.0", - "stringify-object": "^3.3.0" + "chalk": "^4.1.2", + "event-stream": "4.0.1", + "form-data": "4.0.0", + "har-schema": "^2.0.0", + "stringify-object": "3.3.0", + "yargs": "^17.4.0" }, "bin": { "httpsnippet": "bin/httpsnippet" @@ -6771,7 +6772,10 @@ "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", "license": "MIT", "engines": { - "node": ">=0.10.0" + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, "node_modules/httpsnippet/node_modules/chalk": { @@ -6780,14 +6784,14 @@ "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==", "license": "MIT", "dependencies": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" } }, "node_modules/httpsnippet/node_modules/debug": { @@ -6805,7 +6809,7 @@ "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "license": "MIT", "engines": { - "node": ">=0.8.0" + "node": ">=7.0.0" } }, "node_modules/httpsnippet/node_modules/event-stream": { @@ -6861,7 +6865,7 @@ "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", "license": "MIT", "dependencies": { - "ansi-regex": "^2.0.0" + "has-flag": "^4.0.0" }, "engines": { "node": ">=0.10.0" @@ -8863,6 +8867,26 @@ "node": ">= 6" } }, + "node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minipass/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true, + "license": "ISC" + }, "node_modules/mkdirp": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz", @@ -12741,6 +12765,7 @@ "dev": true, "license": "ISC", "dependencies": { + "@npmcli/package-json": "^1.0.1", "chalk": "^2.4.2", "conventional-changelog": "3.1.25", "conventional-changelog-config-spec": "2.1.0", @@ -12753,7 +12778,6 @@ "find-up": "^5.0.0", "git-semver-tags": "^4.0.0", "semver": "^7.1.1", - "stringify-package": "^1.0.1", "yargs": "^16.0.0" }, "bin": { @@ -13203,20 +13227,27 @@ "node": ">= 6" } }, - "node_modules/tap-out": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tap-out/-/tap-out-2.1.0.tgz", - "integrity": "sha512-LJE+TBoVbOWhwdz4+FQk40nmbIuxJLqaGvj3WauQw3NYYU5TdjoV3C0x/yq37YAvVyi+oeBXmWnxWSjJ7IEyUw==", + "node_modules/tap-mocha-reporter": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/tap-mocha-reporter/-/tap-mocha-reporter-5.0.4.tgz", + "integrity": "sha512-J+YMO8B7lq1O6Zxd/jeuG27vJ+Y4tLiRMKPSb7KR6FVh86k3Rq1TwYc2GKPyIjCbzzdMdReh3Vfz9L5cg1Z2Bw==", "dev": true, "license": "MIT", "dependencies": { - "re-emitter": "1.1.3", - "readable-stream": "2.2.9", - "split": "1.0.0", - "trim": "0.0.1" + "color-support": "^1.1.0", + "debug": "^4.1.1", + "diff": "^4.0.1", + "escape-string-regexp": "^2.0.0", + "glob": "^7.0.5", + "tap-parser": "^11.0.0", + "tap-yaml": "^1.0.0", + "unicode-length": "^2.0.2" }, "bin": { - "tap-out": "bin/cmd.js" + "tap-mocha-reporter": "index.js" + }, + "engines": { + "node": ">= 8" } }, "node_modules/tap-out/node_modules/process-nextick-args": { @@ -13259,17 +13290,25 @@ "through": "2" }, "engines": { - "node": "*" + "node": ">=8" } }, - "node_modules/tap-out/node_modules/string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "node_modules/tap-mocha-reporter/node_modules/tap-parser": { + "version": "11.0.2", + "resolved": "https://registry.npmjs.org/tap-parser/-/tap-parser-11.0.2.tgz", + "integrity": "sha512-6qGlC956rcORw+fg7Fv1iCRAY8/bU9UabUAhs3mXRH6eRmVZcNPLheSXCYaVaYeSwx5xa/1HXZb1537YSvwDZg==", "dev": true, "license": "MIT", "dependencies": { - "safe-buffer": "~5.1.0" + "events-to-array": "^1.0.1", + "minipass": "^3.1.6", + "tap-yaml": "^1.0.0" + }, + "bin": { + "tap-parser": "bin/cmd.js" + }, + "engines": { + "node": ">= 8" } }, "node_modules/tap-parser": { @@ -13460,6 +13499,26 @@ "xtend": "~4.0.1" } }, + "node_modules/tap-yaml": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/tap-yaml/-/tap-yaml-1.0.2.tgz", + "integrity": "sha512-GegASpuqBnRNdT1U+yuUPZ8rEU64pL35WPBpCISWwff4dErS2/438barz7WFJl4Nzh3Y05tfPidZnH+GaV1wMg==", + "dev": true, + "license": "ISC", + "dependencies": { + "yaml": "^1.10.2" + } + }, + "node_modules/tap-yaml/node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">= 6" + } + }, "node_modules/tape": { "version": "5.9.0", "resolved": "https://registry.npmjs.org/tape/-/tape-5.9.0.tgz", @@ -13750,13 +13809,6 @@ "random-poly-fill": "^1.0.1" } }, - "node_modules/trim": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.3.tgz", - "integrity": "sha512-h82ywcYhHK7veeelXrCScdH7HkWfbIT1D/CgYO+nmDarz3SGNssVBMws6jU16Ga60AJCRAvPV6w6RLuNerQqjg==", - "deprecated": "Use String.prototype.trim() instead", - "dev": true - }, "node_modules/trim-newlines": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz", diff --git a/package.json b/package.json index dba1446..83ada3f 100644 --- a/package.json +++ b/package.json @@ -31,9 +31,9 @@ ], "scripts": { "test": "npm run test:unit", - "test:unit": "npx tape 'test/unit/**/*.test.js' | tap-spec", + "test:unit": "npx tape 'test/unit/**/*.test.js' | tap-mocha-reporter spec", "test:xunit": "npx tape 'test/unit/**/**.test.js' | tap-xunit > ./test/results/xunit.xml", - "test:coverage": "npx nyc tapes -- 'test/unit/**/*.test.js' | tap-spec; nyc report ---reporter=text", + "test:coverage": "npx nyc tapes -- 'test/unit/**/*.test.js' | tap-mocha-reporter spec; nyc report ---reporter=text", "test:coverage-check": "npm run test:coverage && nyc check-coverage", "test:functional": "echo 'No functional tests defined'", "test:integration": "echo 'No integration tests defined'", @@ -83,7 +83,7 @@ "sinon": "21.0.0", "standard": "17.1.2", "standard-version": "^9.5.0", - "tap-spec": "^5.0.0", + "tap-mocha-reporter": "^5.0.4", "tap-xunit": "2.4.1", "tape": "5.9.0", "tapes": "4.1.0"