From 67ac1b4ff419a4f323f59fde385c59c98a982d7d Mon Sep 17 00:00:00 2001 From: JohT <7671054+JohT@users.noreply.github.com> Date: Sat, 27 Jul 2024 10:45:15 +0200 Subject: [PATCH 1/5] Create the import directory if its missing --- scripts/importGit.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/importGit.sh b/scripts/importGit.sh index 0e33c3d7a..ebadeca94 100755 --- a/scripts/importGit.sh +++ b/scripts/importGit.sh @@ -140,6 +140,9 @@ postAggregatedGitLogImport() { execute_cypher "${GIT_LOG_CYPHER_DIR}/Set_number_of_aggregated_git_commits.cypher" } +# Create import directory in case it doesn't exist. +mkdir -p "${IMPORT_DIRECTORY}" + # Internal constants NEO4J_FULL_IMPORT_DIRECTORY=$(cd "${IMPORT_DIRECTORY}"; pwd) From f4aef0111ef9d1889ab486b0abc9bc00477c7f36 Mon Sep 17 00:00:00 2001 From: JohT <7671054+JohT@users.noreply.github.com> Date: Sat, 27 Jul 2024 10:46:13 +0200 Subject: [PATCH 2/5] Add jQAssistant npm plugin to the configuration --- scripts/configuration/template-neo4jv4-jqassistant.yaml | 8 +++++++- scripts/configuration/template-neo4jv5-jqassistant.yaml | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/configuration/template-neo4jv4-jqassistant.yaml b/scripts/configuration/template-neo4jv4-jqassistant.yaml index db74300ce..aec6ecd04 100644 --- a/scripts/configuration/template-neo4jv4-jqassistant.yaml +++ b/scripts/configuration/template-neo4jv4-jqassistant.yaml @@ -26,7 +26,13 @@ jqassistant: # version: # classifier: # type: - + plugins: + - group-id: org.jqassistant.plugin.typescript + artifact-id: jqassistant-typescript-plugin + version: 1.0.0-RC1 + - group-id: org.jqassistant.plugin + artifact-id: jqassistant-npm-plugin + version: 2.0.0 # The store configuration store: # URI of the database to connect to. Supported URI schemes are 'file' for embedded databases and 'bolt' for connecting to a running Neo4j instance (3.x+), e.g. diff --git a/scripts/configuration/template-neo4jv5-jqassistant.yaml b/scripts/configuration/template-neo4jv5-jqassistant.yaml index 71a890079..e58357a34 100644 --- a/scripts/configuration/template-neo4jv5-jqassistant.yaml +++ b/scripts/configuration/template-neo4jv5-jqassistant.yaml @@ -30,7 +30,10 @@ jqassistant: - group-id: org.jqassistant.plugin.typescript artifact-id: jqassistant-typescript-plugin version: 1.0.0-RC1 - + - group-id: org.jqassistant.plugin + artifact-id: jqassistant-npm-plugin + version: 2.0.0 + # The store configuration store: # URI of the database to connect to. Supported URI schemes are 'file' for embedded databases and 'bolt' for connecting to a running Neo4j instance (3.x+), e.g. From 6eb4fb25f46a18405d52a9fd5bc979d0267f2f27 Mon Sep 17 00:00:00 2001 From: JohT <7671054+JohT@users.noreply.github.com> Date: Sat, 27 Jul 2024 20:28:55 +0200 Subject: [PATCH 3/5] Support npm package.json file scan --- scripts/copyPackageJsonFiles.sh | 33 +++++++++++++++++++++++++++++++++ scripts/resetAndScanChanged.sh | 5 ++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100755 scripts/copyPackageJsonFiles.sh diff --git a/scripts/copyPackageJsonFiles.sh b/scripts/copyPackageJsonFiles.sh new file mode 100755 index 000000000..0646a0fc0 --- /dev/null +++ b/scripts/copyPackageJsonFiles.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# Copies all package.json files inside the source directory into the artifacts/npm-package-json directory. +# It retains the original folder structure where the package.json files were in. + +# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands) +set -o errexit -o pipefail + +# Overrideable Defaults +ARTIFACTS_DIRECTORY=${ARTIFACTS_DIRECTORY:-"artifacts"} +SOURCE_DIRECTORY=${SOURCE_DIRECTORY:-"source"} +NPM_PACKAGE_JSON_ARTIFACTS_DIRECTORY=${NPM_PACKAGE_JSON_ARTIFACTS_DIRECTORY:-"npm-package-json"} # Subdirectory of "artifacts" containing the npm package.json files to scan + +# Check if the repository is actually a git repository +if [ ! -d "${SOURCE_DIRECTORY}" ]; then + echo "copyPackageJsonFiles: No ${SOURCE_DIRECTORY} directory. Skipping copy of package.json files." + return 0 +fi + +( + cd "./${SOURCE_DIRECTORY}" + + echo "copyPackageJsonFiles: Existing package.json files will be copied from from ${SOURCE_DIRECTORY} to ../${ARTIFACTS_DIRECTORY}/${NPM_PACKAGE_JSON_ARTIFACTS_DIRECTORY}" + + for file in $( find . -path ./node_modules -prune -o -name 'package.json' -print0 | xargs -0 -r -I {}); do + fileDirectory=$(dirname "${file}") + targetDirectory="../${ARTIFACTS_DIRECTORY}/${NPM_PACKAGE_JSON_ARTIFACTS_DIRECTORY}/${fileDirectory}" + # echo "copyPackageJsonFiles: Copying ${file} to ${targetDirectory}" + + mkdir -p "${targetDirectory}" + cp "${file}" "${targetDirectory}" + done +) \ No newline at end of file diff --git a/scripts/resetAndScanChanged.sh b/scripts/resetAndScanChanged.sh index 61577197e..033d92204 100755 --- a/scripts/resetAndScanChanged.sh +++ b/scripts/resetAndScanChanged.sh @@ -4,7 +4,7 @@ # Note: "resetAndScan" expects jQAssistant to be installed in the "tools" directory. -# Requires resetAndScan.sh +# Requires resetAndScan.sh, copyPackageJsonFiles.sh # Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands) set -o errexit -o pipefail @@ -16,6 +16,9 @@ set -o errexit -o pipefail SCRIPTS_DIR=${SCRIPTS_DIR:-$( CDPATH=. cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P )} # Repository directory containing the shell scripts echo "resetAndScanChanged SCRIPTS_DIR=${SCRIPTS_DIR}" +# Copy +source "${SCRIPTS_DIR}/copyPackageJsonFiles.sh" + # Scan and analyze Artifacts when they were changed changeDetectionReturnCode=$( source "${SCRIPTS_DIR}/detectChangedArtifacts.sh" --readonly) if [[ "${changeDetectionReturnCode}" == "0" ]] ; then From 17f75eb062c647dec9fcb3eb34e260cc9faf49cb Mon Sep 17 00:00:00 2001 From: JohT <7671054+JohT@users.noreply.github.com> Date: Sat, 27 Jul 2024 20:31:47 +0200 Subject: [PATCH 4/5] Fix npm package.json scan error by removing the author. Workaround can be removed when https://github.com/jqassistant-plugin/jqassistant-npm-plugin/issues/5 is fixed. --- scripts/copyPackageJsonFiles.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/copyPackageJsonFiles.sh b/scripts/copyPackageJsonFiles.sh index 0646a0fc0..98fa8fe5d 100755 --- a/scripts/copyPackageJsonFiles.sh +++ b/scripts/copyPackageJsonFiles.sh @@ -3,6 +3,8 @@ # Copies all package.json files inside the source directory into the artifacts/npm-package-json directory. # It retains the original folder structure where the package.json files were in. +# This script "jq" ( https://stedolan.github.io/jq ). + # Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands) set -o errexit -o pipefail @@ -21,6 +23,7 @@ fi cd "./${SOURCE_DIRECTORY}" echo "copyPackageJsonFiles: Existing package.json files will be copied from from ${SOURCE_DIRECTORY} to ../${ARTIFACTS_DIRECTORY}/${NPM_PACKAGE_JSON_ARTIFACTS_DIRECTORY}" + echo "copyPackageJsonFiles: Author will be removed as workaround for https://github.com/jqassistant-plugin/jqassistant-npm-plugin/issues/5" for file in $( find . -path ./node_modules -prune -o -name 'package.json' -print0 | xargs -0 -r -I {}); do fileDirectory=$(dirname "${file}") @@ -29,5 +32,11 @@ fi mkdir -p "${targetDirectory}" cp "${file}" "${targetDirectory}" + + # Workaround until the following issue is resolved: + # https://github.com/jqassistant-plugin/jqassistant-npm-plugin/issues/5 + fileName=$(basename "${file}") + jq 'del(.author)' "${targetDirectory}/${fileName}" > "${targetDirectory}/${fileName}.edited" + jq 'del(.contributors)' "${targetDirectory}/${fileName}.edited" > "${targetDirectory}/${fileName}" done ) \ No newline at end of file From 4ce0389c45fd4a48ea330b459fbf30c7e3a164e9 Mon Sep 17 00:00:00 2001 From: JohT <7671054+JohT@users.noreply.github.com> Date: Sat, 27 Jul 2024 20:56:27 +0200 Subject: [PATCH 5/5] Use pinned version for jQAssistant Typescript npm package --- renovate.json | 12 ++++++++++++ scripts/downloader/downloadTypescriptProject.sh | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/renovate.json b/renovate.json index 416e2a0b0..27dce8c95 100644 --- a/renovate.json +++ b/renovate.json @@ -116,6 +116,18 @@ "depNameTemplate": "jQAssistant/jqa-commandline-tool", "datasourceTemplate": "github-tags", "extractVersionTemplate": "^REL-?(?.*?)$" + }, + { + "fileMatch": [ + "^scripts\/profiles\/Neo4jv5\\.sh$", + "^scripts\/profiles\/Default\\.sh$", + "^scripts\/[^\/]*\\.sh$" + ], + "matchStrings": [ + "npx --yes @jqassistant/ts-lce@?(?.*?)" + ], + "depNameTemplate": "jqassistant-plugin/jqassistant-typescript-plugin", + "datasourceTemplate": "github-tags" } ] } diff --git a/scripts/downloader/downloadTypescriptProject.sh b/scripts/downloader/downloadTypescriptProject.sh index 32c655141..2b7bee283 100755 --- a/scripts/downloader/downloadTypescriptProject.sh +++ b/scripts/downloader/downloadTypescriptProject.sh @@ -161,7 +161,7 @@ fi cd "${fullSourceDirectory}" || exit usePackageManagerToInstallDependencies echo "downloadTypescriptProject: Scanning Typescript source using @jqassistant/ts-lce..." - npx --yes @jqassistant/ts-lce >"./../../runtime/logs/jqassistant-typescript-scan-${projectName}.log" 2>&1 || exit + npx --yes @jqassistant/ts-lce@1.2.0 >"./../../runtime/logs/jqassistant-typescript-scan-${projectName}.log" 2>&1 || exit ) echo "downloadTypescriptProject: Moving scanned results into the artifacts/typescript directory..." mkdir -p artifacts/typescript