You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds .cmd script equivalents for autobuild.sh, index-files.sh, and
pre-finalize.sh scripts -- with the (unverified) intention being that
the CDS extractor should be able to run on Linux, Mac, or Windows.
Migrates most of the `index-files` script logic from shell script to
javascript.
Adds a `package.json` file to assist with managing dependencies for
the new `extractors/cds/tools/index-files.js` script.
echo node executable is required (in PATH) to run the 'index-files.js' script. Please install Node.js and try again.
11
+
exit /b 2
12
+
)
13
+
14
+
where npm >nul2>nul
15
+
if%ERRORLEVEL%neq0 (
16
+
echo npm executable is required (in PATH) to install the dependencies for the 'index-files.js' script.
17
+
exit /b 3
18
+
)
19
+
20
+
set"_response_file_path=%~1"
21
+
22
+
echo Checking response file for CDS files to index
23
+
24
+
ifnotexist"%_response_file_path%" (
25
+
echo 'codeql database index-files --language cds' command terminated early as response file '%_response_file_path%' does not exist or is empty. This is because no CDS files were selected or found.
26
+
exit /b 0
27
+
)
28
+
29
+
echo Installing node package dependencies and running the 'index-files.js' script
console.log(`'codeql database index-files --language cds' terminated early as response file '${responseFile}' does not exist. This is because no CDS files were selected or found.`);
13
+
process.exit(0);
14
+
}
15
+
16
+
if(statSync(responseFile).size===0){
17
+
console.log(`'codeql database index-files --language cds' terminated early as response file '${responseFile}' is empty. This is because no CDS files were selected or found.`);
consterrorMessage=`Could not compile the file ${cdsFile}.\nReported error(s):\n\`\`\`\n${stderrTruncated}\n\`\`\``;
59
+
console.log(errorMessage);
60
+
execSync(`${process.env.CODEQL_DIST}/codeql database add-diagnostic --extractor-name cds --ready-for-status-page --source-id cds/compilation-failure --source-name "Failure to compile one or more SAP CAP CDS files" --severity error --markdown-message "${errorMessage}" --file-path "${cdsFile}" "${process.env.CODEQL_EXTRACTOR_CDS_WIP_DATABASE}"`);
echo"codeql database index-files --language cds terminated early as response file '$response_file' does not exist. This is because no CDS files were selected or found."
13
-
exit 0
5
+
if [ $#-ne 1 ]
6
+
then
7
+
echo"Usage: $0 <response_file_path>"
8
+
exit 1
14
9
fi
15
10
16
-
# If the response_file is empty, terminate
17
-
if [ !-s"$response_file" ];then
18
-
echo"codeql database index-files --language cds terminated early as response file '$response_file' is empty. This is because no CDS files were selected or found."
19
-
exit0
11
+
if!command -v node > /dev/null
12
+
then
13
+
echo"node executable is required (in PATH) to run the 'index-files.js' script. Please install Node.js and try again."
14
+
exit2
20
15
fi
21
16
22
-
# Determine if we have the cds command available, and if not, install the cds development kit
23
-
# in the appropriate directories
24
-
if!command -v cds &> /dev/null
17
+
if!command -v npm > /dev/null
25
18
then
26
-
echo"Pre-installing cds compiler"
27
-
28
-
# Find all the directories containing a package.json with a dependency on @sap/cds, where
29
-
# the directory contains at least one of the files listed in the response file (e.g. the
30
-
# cds files we want to extract).
31
-
#
32
-
# We then install the cds development kit (@sap/cds-dk) in each directory, which makes the
33
-
# `cds` command usable from the npx command within that directory.
34
-
#
35
-
# Nested package.json files simply cause the package to be installed in the parent node_modules
36
-
# directory.
37
-
#
38
-
# We also ensure we skip node_modules, as we can end up in a recursive loop
error_message=$'Could not compile the file '"$cds_file"$'.\nReported error(s):\n```\n'"$stderr_truncated"$'\n```'
58
-
echo"$error_message"
59
-
# Log an error diagnostic which appears on the status page
60
-
"$CODEQL_DIST/codeql" database add-diagnostic --extractor-name cds --ready-for-status-page --source-id cds/compilation-failure --source-name "Failure to compile one or more SAP CAP CDS files" --severity error --markdown-message "$error_message" --file-path "$cds_file""$CODEQL_EXTRACTOR_CDS_WIP_DATABASE"
61
-
fi
62
-
done<"$response_file"
25
+
echo"Checking response file for CDS files to index"
63
26
64
-
# Check if the JS extractor variables are set, and set them if not
65
-
if [ -z"${CODEQL_EXTRACTOR_JAVASCRIPT_ROOT:-}" ];then
# Terminate early if the _response_file_path doesn't exist or is empty,
28
+
# which indicates that no CDS files were selected or found.
29
+
if [ !-f"$_response_file_path" ] || [ !-s"$_response_file_path" ]
30
+
then
31
+
echo"'codeql database index-files --language cds' command terminated early as response file '$_response_file_path' does not exist or is empty. This is because no CDS files were selected or found."
32
+
# Exit without error to avoid failing any calling (javascript)
33
+
# extractor, and llow the tool the report the lack of coverage
0 commit comments