@@ -79,7 +79,7 @@ scan_directory() {
7979 # Note: For later troubleshooting, the output is also copied to a dedicated log file using "tee".
8080 # Note: Don't worry about the hardcoded version number. It will be updated by Renovate using a custom Manager.
8181 # Note: NODE_OPTIONS --max-old-space-size=4096 increases the memory for scanning larger projects
82- NODE_OPTIONS=
" ${NODE_OPTIONS} --max-old-space-size=${TYPESCRIPT_SCAN_HEAP_MEMORY} " npx --yes @jqassistant/
[email protected] .
1 " ${1} " --extension React
2>&1 | tee
" ${LOG_DIRECTORY} /jqassistant-typescript-scan-${directory_name } .log" >&2 82+ NODE_OPTIONS=
" ${NODE_OPTIONS} --max-old-space-size=${TYPESCRIPT_SCAN_HEAP_MEMORY} " npx --yes @jqassistant/
[email protected] .
0 " ${1} " --extension React
2>&1 | tee
" ${LOG_DIRECTORY} /jqassistant-typescript-scan-${source_directory_name } .log" >&2 8383 else
8484 echo " scanTypescript: Skipping scan of ${source_directory_name} (${progress_information} ) -----------------" >&2
8585 fi
@@ -110,48 +110,53 @@ is_valid_scan_result() {
110110 fi
111111}
112112
113- # Scan and analyze Artifacts when they were changed
114- changeDetectionHashFilePath= " ./ ${SOURCE_DIRECTORY} /typescriptFileChangeDetectionHashFile.txt "
115- changeDetectionReturnCode= $( source " ${SCRIPTS_DIR} /detectChangedFiles.sh " --readonly --hashfile " ${changeDetectionHashFilePath }" --paths " ./ ${SOURCE_DIRECTORY} " )
113+ mkdir -p " ./runtime/logs "
114+ LOG_DIRECTORY= " $( pwd ) /runtime/logs "
115+ echo " scanTypescript: LOG_DIRECTORY= ${LOG_DIRECTORY }" >&2
116116
117- if [ " ${changeDetectionReturnCode }" == " 0 " ] && [ " ${TYPESCRIPT_SCAN_CHANGE_DETECTION} " = true ] ; then
118- echo " scanTypescript: Files unchanged. Scan skipped. "
119- fi
117+ source_directories= $( find -L " ./ ${SOURCE_DIRECTORY }" -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0 -r -I {} echo {} )
118+ total_source_directories= $( echo " ${source_directories} " | wc -l | awk ' {print $1} ' )
119+ processed_source_directories=0
120120
121- if [ " ${changeDetectionReturnCode} " != " 0" ] || [ " ${TYPESCRIPT_SCAN_CHANGE_DETECTION} " = false ]; then
122- echo " scanTypescript: Detected change (${changeDetectionReturnCode} ). Scanning Typescript source using @jqassistant/ts-lce."
123-
124- mkdir -p " ./runtime/logs"
125- LOG_DIRECTORY=" $( pwd) /runtime/logs"
126- echo " scanTypescript: LOG_DIRECTORY=${LOG_DIRECTORY} " >&2
127-
128- source_directories=$( find -L " ./${SOURCE_DIRECTORY} " -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0 -r -I {} echo {} )
129- total_source_directories=$( echo " ${source_directories} " | wc -l | awk ' {print $1}' )
130- processed_source_directories=0
131-
132- for source_directory in ${source_directories} ; do
133- processed_source_directories=$(( processed_source_directories + 1 ))
134- progress_info_source_dirs=" ${processed_source_directories} /${total_source_directories} "
135- if scan_directory " ${source_directory} " " ${progress_info_source_dirs} " && is_valid_scan_result " ${source_directory} " ; then
136- continue # successful scan, proceed to next one.
137- fi
138-
139- echo " scanTypescript: Info: Unsuccessful source directory scan. Trying to scan all contained packages individually." >&2
140- contained_package_directories=$( find_directories_with_package_json_file " ${source_directory} " )
141- echo " scanTypescript: contained_package_directories:" >&2
142- echo " ${contained_package_directories} " >&2
143- total_package_directories=$( echo " ${contained_package_directories} " | wc -l | awk ' {print $1}' )
144- processed_package_directories=0
145-
146- for contained_package_directory in ${contained_package_directories} ; do
147- processed_package_directories=$(( processed_package_directories + 1 ))
148- progress_info_package_dirs=" ${progress_info_source_dirs} : ${processed_package_directories} /${total_package_directories} "
149- scan_directory " ${contained_package_directory} " " ${progress_info_package_dirs} "
150- done
121+ for source_directory in ${source_directories} ; do
122+ # Scan and analyze Artifacts when they were changed
123+ source_directory_name=$( basename " ${source_directory} " ) ;
124+ changeDetectionHashFilePath=" ./${SOURCE_DIRECTORY} /typescriptScanChangeDetection-${source_directory_name} .sha"
125+ changeDetectionReturnCode=$( source " ${SCRIPTS_DIR} /detectChangedFiles.sh" --readonly --hashfile " ${changeDetectionHashFilePath} " --paths " ${source_directory} " )
126+
127+ if [ " ${changeDetectionReturnCode} " == " 0" ] && [ " ${TYPESCRIPT_SCAN_CHANGE_DETECTION} " = true ]; then
128+ echo " scanTypescript: Files in ${source_directory} unchanged. Scan skipped."
129+ continue # skipping scan since it had already be done according to change detection.
130+ fi
131+
132+ # Debugging log for change detection. "scan_directory" already logs scanning and the source directory.
133+ # echo "scanTypescript: Detected change (${changeDetectionReturnCode}) in ${source_directory}. Scanning Typescript source using @jqassistant/ts-lce."
134+
135+ processed_source_directories=$(( processed_source_directories + 1 ))
136+ progress_info_source_dirs=" ${processed_source_directories} /${total_source_directories} "
137+ if scan_directory " ${source_directory} " " ${progress_info_source_dirs} " && is_valid_scan_result " ${source_directory} " ; then
138+ # The dry-run shouldn't write anything. Therefore, writing the change detection file is skipped regardless of TYPESCRIPT_SCAN_CHANGE_DETECTION.
139+ if [ " ${TYPESCRIPT_SCAN_DRY_RUN} " = false ] ; then
140+ changeDetectionReturnCode=$( source " ${SCRIPTS_DIR} /detectChangedFiles.sh" --hashfile " ${changeDetectionHashFilePath} " --paths " ${source_directory} " )
141+ fi
142+ continue # successful scan, proceed to next one.
143+ fi
144+
145+ echo " scanTypescript: Info: Unsuccessful or skipped source directory scan. Scan all contained packages individually." >&2
146+ contained_package_directories=$( find_directories_with_package_json_file " ${source_directory} " )
147+ echo " scanTypescript: contained_package_directories:" >&2
148+ echo " ${contained_package_directories} " >&2
149+ total_package_directories=$( echo " ${contained_package_directories} " | wc -l | awk ' {print $1}' )
150+ processed_package_directories=0
151+
152+ for contained_package_directory in ${contained_package_directories} ; do
153+ processed_package_directories=$(( processed_package_directories + 1 ))
154+ progress_info_package_dirs=" ${progress_info_source_dirs} : ${processed_package_directories} /${total_package_directories} "
155+ scan_directory " ${contained_package_directory} " " ${progress_info_package_dirs} "
151156 done
152157
153158 # The dry-run shouldn't write anything. Therefore, writing the change detection file is skipped regardless of TYPESCRIPT_SCAN_CHANGE_DETECTION.
154159 if [ " ${TYPESCRIPT_SCAN_DRY_RUN} " = false ] ; then
155- changeDetectionReturnCode=$( source " ${SCRIPTS_DIR} /detectChangedFiles.sh" --hashfile " ${changeDetectionHashFilePath} " --paths " ./ ${SOURCE_DIRECTORY }" )
160+ changeDetectionReturnCode=$( source " ${SCRIPTS_DIR} /detectChangedFiles.sh" --hashfile " ${changeDetectionHashFilePath} " --paths " ${source_directory }" )
156161 fi
157- fi
162+ done
0 commit comments