Use release-it plugin to bump version in sonar-project.properties
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 26 Oct 2022 18:45:34 +0000 (20:45 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 26 Oct 2022 18:45:34 +0000 (20:45 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
.release-it.json
package-lock.json
package.json
src/scripts/updateSonarProps.sh [deleted file]

index c6dd7dd3d1d140a7007ebfb4df24099c740b10b2..7151d7731e9934d3e4df570d59360b3bdbf552f4 100644 (file)
     "release": true,
     "releaseName": "Version ${version}"
   },
+  "plugins": {
+    "@release-it/bumper": {
+      "out": ["sonar-project.properties"]
+    }
+  },
   "hooks": {
-    "after:bump": "npx auto-changelog --commit-limit false --package --template https://raw.githubusercontent.com/release-it/release-it/master/templates/keepachangelog.hbs && npm run sonar:properties"
+    "after:bump": "npx auto-changelog --commit-limit false --package --template https://raw.githubusercontent.com/release-it/release-it/master/templates/keepachangelog.hbs"
   }
 }
index 6d0fd8aea013eecc76bed717debc2f35124322fc..a4b5c2b4abbaf303897718bb9c34ed9fa6e36d66 100644 (file)
@@ -34,6 +34,7 @@
       "devDependencies": {
         "@istanbuljs/nyc-config-typescript": "^1.0.2",
         "@mikro-orm/cli": "^5.4.2",
+        "@release-it/bumper": "^4.0.0",
         "@rollup/plugin-json": "^5.0.1",
         "@types/mocha": "^10.0.0",
         "@types/mochawesome": "^6.2.1",
         "node": ">=12"
       }
     },
+    "node_modules/@release-it/bumper": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/@release-it/bumper/-/bumper-4.0.0.tgz",
+      "integrity": "sha512-DswMVRuWNeeuDPd8DNpMhuHjqxnwOi5A+v9CTrbAQ7/1K+VOGUGItS4ekjWfb1qBvJw/ouiAinBo9ckjtnhktA==",
+      "dev": true,
+      "dependencies": {
+        "@iarna/toml": "^2.2.5",
+        "detect-indent": "^7.0.0",
+        "fast-glob": "^3.2.7",
+        "ini": "^3.0.0",
+        "js-yaml": "^4.1.0",
+        "lodash.castarray": "^4.4.0",
+        "lodash.get": "^4.4.2",
+        "lodash.set": "^4.3.2",
+        "semver": "^7.3.7"
+      },
+      "engines": {
+        "node": ">=14"
+      },
+      "peerDependencies": {
+        "release-it": "^15.0.0-esm.4"
+      }
+    },
+    "node_modules/@release-it/bumper/node_modules/ini": {
+      "version": "3.0.1",
+      "resolved": "https://registry.npmjs.org/ini/-/ini-3.0.1.tgz",
+      "integrity": "sha512-it4HyVAUTKBc6m8e1iXWvXSTdndF7HbdN713+kvLrymxTaU4AUBWrJ4vEooP+V7fexnVD3LKcBshjGGPefSMUQ==",
+      "dev": true,
+      "engines": {
+        "node": "^12.13.0 || ^14.15.0 || >=16.0.0"
+      }
+    },
     "node_modules/@rollup/plugin-json": {
       "version": "5.0.1",
       "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-5.0.1.tgz",
         "minimalistic-assert": "^1.0.0"
       }
     },
+    "node_modules/detect-indent": {
+      "version": "7.0.1",
+      "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-7.0.1.tgz",
+      "integrity": "sha512-Mc7QhQ8s+cLrnUfU/Ji94vG/r8M26m8f++vyres4ZoojaRDpZ1eSIh/EpzLNwlWuvzSZ3UbDFspjFvTDXe6e/g==",
+      "dev": true,
+      "engines": {
+        "node": ">=12.20"
+      }
+    },
     "node_modules/detect-libc": {
       "version": "2.0.1",
       "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.1.tgz",
       "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
       "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
     },
+    "node_modules/lodash.castarray": {
+      "version": "4.4.0",
+      "resolved": "https://registry.npmjs.org/lodash.castarray/-/lodash.castarray-4.4.0.tgz",
+      "integrity": "sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==",
+      "dev": true
+    },
     "node_modules/lodash.chunk": {
       "version": "4.2.0",
       "resolved": "https://registry.npmjs.org/lodash.chunk/-/lodash.chunk-4.2.0.tgz",
       "integrity": "sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==",
       "dev": true
     },
+    "node_modules/lodash.get": {
+      "version": "4.4.2",
+      "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
+      "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==",
+      "dev": true
+    },
     "node_modules/lodash.isempty": {
       "version": "4.4.0",
       "resolved": "https://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz",
       "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
       "dev": true
     },
+    "node_modules/lodash.set": {
+      "version": "4.3.2",
+      "resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz",
+      "integrity": "sha512-4hNPN5jlm/N/HLMCO43v8BXKq9Z7QdAGc/VGrRD61w8gN9g/6jF9A4L1pbUgBLCffi0w9VsXfTOij5x8iTyFvg==",
+      "dev": true
+    },
     "node_modules/log-symbols": {
       "version": "4.1.0",
       "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz",
         "config-chain": "^1.1.11"
       }
     },
+    "@release-it/bumper": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/@release-it/bumper/-/bumper-4.0.0.tgz",
+      "integrity": "sha512-DswMVRuWNeeuDPd8DNpMhuHjqxnwOi5A+v9CTrbAQ7/1K+VOGUGItS4ekjWfb1qBvJw/ouiAinBo9ckjtnhktA==",
+      "dev": true,
+      "requires": {
+        "@iarna/toml": "^2.2.5",
+        "detect-indent": "^7.0.0",
+        "fast-glob": "^3.2.7",
+        "ini": "^3.0.0",
+        "js-yaml": "^4.1.0",
+        "lodash.castarray": "^4.4.0",
+        "lodash.get": "^4.4.2",
+        "lodash.set": "^4.3.2",
+        "semver": "^7.3.7"
+      },
+      "dependencies": {
+        "ini": {
+          "version": "3.0.1",
+          "resolved": "https://registry.npmjs.org/ini/-/ini-3.0.1.tgz",
+          "integrity": "sha512-it4HyVAUTKBc6m8e1iXWvXSTdndF7HbdN713+kvLrymxTaU4AUBWrJ4vEooP+V7fexnVD3LKcBshjGGPefSMUQ==",
+          "dev": true
+        }
+      }
+    },
     "@rollup/plugin-json": {
       "version": "5.0.1",
       "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-5.0.1.tgz",
         "minimalistic-assert": "^1.0.0"
       }
     },
+    "detect-indent": {
+      "version": "7.0.1",
+      "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-7.0.1.tgz",
+      "integrity": "sha512-Mc7QhQ8s+cLrnUfU/Ji94vG/r8M26m8f++vyres4ZoojaRDpZ1eSIh/EpzLNwlWuvzSZ3UbDFspjFvTDXe6e/g==",
+      "dev": true
+    },
     "detect-libc": {
       "version": "2.0.1",
       "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.1.tgz",
       "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
       "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
     },
+    "lodash.castarray": {
+      "version": "4.4.0",
+      "resolved": "https://registry.npmjs.org/lodash.castarray/-/lodash.castarray-4.4.0.tgz",
+      "integrity": "sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==",
+      "dev": true
+    },
     "lodash.chunk": {
       "version": "4.2.0",
       "resolved": "https://registry.npmjs.org/lodash.chunk/-/lodash.chunk-4.2.0.tgz",
       "integrity": "sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==",
       "dev": true
     },
+    "lodash.get": {
+      "version": "4.4.2",
+      "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
+      "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==",
+      "dev": true
+    },
     "lodash.isempty": {
       "version": "4.4.0",
       "resolved": "https://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz",
       "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
       "dev": true
     },
+    "lodash.set": {
+      "version": "4.3.2",
+      "resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz",
+      "integrity": "sha512-4hNPN5jlm/N/HLMCO43v8BXKq9Z7QdAGc/VGrRD61w8gN9g/6jF9A4L1pbUgBLCffi0w9VsXfTOij5x8iTyFvg==",
+      "dev": true
+    },
     "log-symbols": {
       "version": "4.1.0",
       "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz",
index 47de546539469e915be7bf92cecccd9c3db67d4d..c42a5571b4751f8a6618e6f8fe58eb40e5ae05a2 100644 (file)
@@ -69,7 +69,6 @@
     "git:sdiff": "git diff && git submodule foreach 'git diff'",
     "git:supdate": "git submodule update --remote --recursive --merge",
     "git:spush": "git push --recurse-submodules=on-demand",
-    "sonar:properties": "./src/scripts/updateSonarProps.sh",
     "release": "release-it"
   },
   "dependencies": {
   "devDependencies": {
     "@istanbuljs/nyc-config-typescript": "^1.0.2",
     "@mikro-orm/cli": "^5.4.2",
+    "@release-it/bumper": "^4.0.0",
     "@rollup/plugin-json": "^5.0.1",
     "@types/mocha": "^10.0.0",
     "@types/mochawesome": "^6.2.1",
diff --git a/src/scripts/updateSonarProps.sh b/src/scripts/updateSonarProps.sh
deleted file mode 100755 (executable)
index d29ed6a..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/env bash
-#title          : updateSonarProps.sh
-#description    :
-# This script parses the project's name and version from its package.json and automagically
-# updates the version and package name in the SonarQube configuration properties file.
-# It can be used as a pre step before running the sonar-scanner command
-#
-#prerequisites  : NodeJS based project with package.json, sonar*.properties file in the cwd
-#author         : Christian-André Giehl <christian@emailbrief.de>
-#modified by    : Daniel Duarte <danieldd.ar@gmail.com>
-#date           : 20180220
-#version        : 1.1
-#usage          : sh updateSonarProps.sh
-#==============================================================================
-echo "Updating the SonarQube properties..."
-
-# Get the project name from package.json
-PACKAGE_NAME=$(cat package.json \
-  | grep name \
-  | head -1 \
-  | awk -F: '{ print $2 }' \
-  | sed 's/[",]//g' \
-  | tr -d '[[:space:]]')
-echo "Project: ${PACKAGE_NAME}"
-
-# Get the version from package.json
-PACKAGE_VERSION=$(cat package.json \
-  | grep version \
-  | head -1 \
-  | awk -F: '{ print $2 }' \
-  | sed 's/[",]//g' \
-  | tr -d '[[:space:]]')
-echo "Version: ${PACKAGE_VERSION}"
-
-# Get the Sonar properties file
-SONAR_FILE=$(find . -iname sonar*.properties -type f)
-echo "Sonar file: ${SONAR_FILE}"
-
-SED_EXTRA_OPTS="-i.bak"
-
-# Update the version
-REPLACE='^sonar.projectVersion=.*$'
-WITH="sonar.projectVersion=${PACKAGE_VERSION}"
-sed $SED_EXTRA_OPTS -e "s/${REPLACE}/${WITH}/g" ${SONAR_FILE}
-
-# Update the project name
-REPLACE='^sonar.projectName=.*$'
-WITH="sonar.projectName=${PACKAGE_NAME}"
-sed $SED_EXTRA_OPTS -e "s/${REPLACE}/${WITH}/g" ${SONAR_FILE}