11#! /usr/bin/env bash
22
33# Downloads the given version of a Typescript project from a git repository using git clone.
4- # The cloned project is then moved into the "source" directory of the current analysis directory
5- # where its dependencies are installed by the given package manager.
6- # After scanning it with jQAssistant's Typescript Plugin, the resulting JSON will be moved into the "artifacts/typescript" directory.
4+ # The cloned project is then moved into the "source" directory of the current analysis directory.
75
86# Command line options:
97# --url Git clone URL (optional, default = skip clone)
108# --version Version of the project
119# --tag Tag to switch to after "git clone" (optional, default = version)
1210# --project Name of the project/repository (optional, default = clone url file name without .git extension)
13- # --packageManager One of "npm", "pnpm" or "yarn". (optional, default = "npm")
1411
1512# Note: This script is meant to be started within the temporary analysis directory (e.g. "temp/AnalysisName/")
1613
@@ -29,7 +26,6 @@ usage() {
2926 echo " [ --tag <git-tag-for-that-version> (default=version) \\ ]"
3027 echo " [ --url <git-clone-url> (default=skip clone)] \\ "
3128 echo " [ --project <name-of-the-project> (default=url file name) \\ ]"
32- echo " [ --packageManager <npm/pnpm/yarn> (default=npm) ]"
3329 echo " Example: $0 \\ "
3430 echo " --url https://github.com/ant-design/ant-design.git \\ "
3531 echo " --version 5.19.3"
@@ -41,7 +37,6 @@ cloneUrl=""
4137projectName=" "
4238projectVersion=" "
4339projectTag=" "
44- packageManager=" npm"
4540
4641# Parse command line options
4742while [[ $# -gt 0 ]]; do
@@ -65,10 +60,6 @@ while [[ $# -gt 0 ]]; do
6560 projectTag=" ${value} "
6661 shift
6762 ;;
68- --packageManager)
69- packageManager=" ${value} "
70- shift
71- ;;
7263 * )
7364 echo " downloadTypescriptProject Error: Unknown option: ${key} "
7465 usage
@@ -108,49 +99,10 @@ if [ -z "${projectTag}" ]; then
10899 projectTag=" ${projectVersion} "
109100fi
110101
111- case " ${packageManager} " in
112- npm|pnpm|yarn)
113- echo " downloadTypescriptProject Using package manager ${packageManager} "
114- ;;
115- * )
116- echo " downloadTypescriptProject Error: Unknown package manager: ${packageManager} "
117- usage
118- ;;
119- esac
120-
121- if ! command -v " ${packageManager} " & > /dev/null ; then
122- echo " downloadTypescriptProject Error: Package manager ${packageManager} could not be found"
123- exit 1
124- fi
125-
126- if ! command -v " npx" & > /dev/null ; then
127- echo " downloadTypescriptProject Error: Command npx not found. It's needed to execute npm packages."
128- exit 1
129- fi
130-
131102echo " downloadTypescriptProject: cloneUrl: ${cloneUrl} "
132103echo " downloadTypescriptProject: projectName: ${projectName} "
133104echo " downloadTypescriptProject: projectVersion: ${projectVersion} "
134105echo " downloadTypescriptProject: projectTag: ${projectTag} "
135- echo " downloadTypescriptProject: packageManager: ${packageManager} "
136-
137- usePackageManagerToInstallDependencies () {
138- echo " downloadTypescriptProject: Installing dependencies using ${packageManager} ..."
139- case " ${packageManager} " in
140- npm)
141- # npm ci is not sufficient for projects like "ant-design" that rely on generating the package-lock
142- # Even if this is not standard, this is an acceptable solution since it is only used to prepare scanning.
143- # The same applies to "--force" which shouldn't be done normally.
144- npm install --ignore-scripts --force --verbose || exit
145- ;;
146- pnpm)
147- pnpm install --frozen-lockfile || exit
148- ;;
149- yarn)
150- yarn install --frozen-lockfile --ignore-scripts --non-interactive --verbose || exit
151- ;;
152- esac
153- }
154106
155107# Create runtime logs directory if it hasn't existed yet
156108mkdir -p ./runtime/logs
@@ -172,9 +124,4 @@ if [ ! -d "${fullSourceDirectory}" ]; then # source doesn't exist
172124else
173125 # Source already exists. Cloning not necessary.
174126 echo " downloadTypescriptProject: Source already exists. Skip cloning ${cloneUrl} "
175- fi
176-
177- (
178- cd " ${fullSourceDirectory} " || exit
179- usePackageManagerToInstallDependencies
180- )
127+ fi
0 commit comments