From 180c59913bec1401e4706b403f3098b3258cf3a5 Mon Sep 17 00:00:00 2001 From: "Vipul Gupta (@vipulgupta2048)" Date: Wed, 8 Nov 2023 22:12:02 +0530 Subject: [PATCH] Add dedupe commands to commit hook Change-type: patch Signed-off-by: Vipul Gupta (@vipulgupta2048) --- automation/test-lock-deduplicated.sh | 19 ++++++------------- npm-shrinkwrap.json | 24 ++++++++++++------------ package.json | 2 +- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/automation/test-lock-deduplicated.sh b/automation/test-lock-deduplicated.sh index b0353976..a369758d 100755 --- a/automation/test-lock-deduplicated.sh +++ b/automation/test-lock-deduplicated.sh @@ -2,19 +2,12 @@ set -e -cp npm-shrinkwrap.json npm-shrinkwrap.json.old -npm i -npm dedupe -npm i - -if ! diff -q npm-shrinkwrap.json npm-shrinkwrap.json.old > /dev/null; then +if npm dedupe --dry-run | grep "remove"; then + cp npm-shrinkwrap.json npm-shrinkwrap.json.old + npm dedupe + diff npm-shrinkwrap.json.old npm-shrinkwrap.json; rm npm-shrinkwrap.json.old echo "** npm-shrinkwrap.json was not deduplicated or not fully committed - FAIL **"; - echo "** This can usually be fixed with: **"; - echo "** git checkout master -- npm-shrinkwrap.json **"; - echo "** rm -rf node_modules **"; - echo "** npm install && npm dedupe && npm install **"; + echo "** Please run 'npm ci', followed by 'npm dedupe' **"; exit 1; -fi - -rm npm-shrinkwrap.json.old +fi \ No newline at end of file diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index e572cf82..bda59df1 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -3285,9 +3285,9 @@ } }, "node_modules/@types/js-yaml": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.8.tgz", - "integrity": "sha512-m6jnPk1VhlYRiLFm3f8X9Uep761f+CK8mHyS65LutH2OhmBF0BeMEjHgg05usH8PLZMWWc/BUR9RPmkvpWnyRA==", + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz", + "integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==", "dev": true }, "node_modules/@types/json-schema": { @@ -3408,9 +3408,9 @@ } }, "node_modules/@types/node": { - "version": "18.18.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.8.tgz", - "integrity": "sha512-OLGBaaK5V3VRBS1bAkMVP2/W9B+H8meUfl866OrMNQqt7wDgdpWPp5o6gmIc9pB+lIQHSq4ZL8ypeH1vPxcPaQ==", + "version": "18.18.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.9.tgz", + "integrity": "sha512-0f5klcuImLnG4Qreu9hPj/rEfFq6YRc5n2mAjSsH+ec/mJL+3voBH0+8T7o8RpFjH7ovc+TRsL/c7OYIQsPTfQ==", "dependencies": { "undici-types": "~5.26.4" } @@ -26710,9 +26710,9 @@ } }, "@types/js-yaml": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.8.tgz", - "integrity": "sha512-m6jnPk1VhlYRiLFm3f8X9Uep761f+CK8mHyS65LutH2OhmBF0BeMEjHgg05usH8PLZMWWc/BUR9RPmkvpWnyRA==", + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz", + "integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==", "dev": true }, "@types/json-schema": { @@ -26832,9 +26832,9 @@ } }, "@types/node": { - "version": "18.18.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.8.tgz", - "integrity": "sha512-OLGBaaK5V3VRBS1bAkMVP2/W9B+H8meUfl866OrMNQqt7wDgdpWPp5o6gmIc9pB+lIQHSq4ZL8ypeH1vPxcPaQ==", + "version": "18.18.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.9.tgz", + "integrity": "sha512-0f5klcuImLnG4Qreu9hPj/rEfFq6YRc5n2mAjSsH+ec/mJL+3voBH0+8T7o8RpFjH7ovc+TRsL/c7OYIQsPTfQ==", "requires": { "undici-types": "~5.26.4" } diff --git a/package.json b/package.json index b17a5bbb..d7973c01 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,7 @@ }, "husky": { "hooks": { - "pre-commit": "node automation/check-npm-version.js && ts-node automation/check-doc.ts" + "pre-commit": "node automation/check-npm-version.js && ts-node automation/check-doc.ts && npm run test:shrinkwrap" } }, "oclif": {