1
1
#! /usr/bin/env bash
2
2
3
3
# 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.
7
5
8
6
# Command line options:
9
7
# --url Git clone URL (optional, default = skip clone)
10
8
# --version Version of the project
11
9
# --tag Tag to switch to after "git clone" (optional, default = version)
12
10
# --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")
14
11
15
12
# Note: This script is meant to be started within the temporary analysis directory (e.g. "temp/AnalysisName/")
16
13
@@ -29,7 +26,6 @@ usage() {
29
26
echo " [ --tag <git-tag-for-that-version> (default=version) \\ ]"
30
27
echo " [ --url <git-clone-url> (default=skip clone)] \\ "
31
28
echo " [ --project <name-of-the-project> (default=url file name) \\ ]"
32
- echo " [ --packageManager <npm/pnpm/yarn> (default=npm) ]"
33
29
echo " Example: $0 \\ "
34
30
echo " --url https://github.com/ant-design/ant-design.git \\ "
35
31
echo " --version 5.19.3"
@@ -41,7 +37,6 @@ cloneUrl=""
41
37
projectName=" "
42
38
projectVersion=" "
43
39
projectTag=" "
44
- packageManager=" npm"
45
40
46
41
# Parse command line options
47
42
while [[ $# -gt 0 ]]; do
@@ -65,10 +60,6 @@ while [[ $# -gt 0 ]]; do
65
60
projectTag=" ${value} "
66
61
shift
67
62
;;
68
- --packageManager)
69
- packageManager=" ${value} "
70
- shift
71
- ;;
72
63
* )
73
64
echo " downloadTypescriptProject Error: Unknown option: ${key} "
74
65
usage
@@ -108,49 +99,10 @@ if [ -z "${projectTag}" ]; then
108
99
projectTag=" ${projectVersion} "
109
100
fi
110
101
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
-
131
102
echo " downloadTypescriptProject: cloneUrl: ${cloneUrl} "
132
103
echo " downloadTypescriptProject: projectName: ${projectName} "
133
104
echo " downloadTypescriptProject: projectVersion: ${projectVersion} "
134
105
echo " 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
- }
154
106
155
107
# Create runtime logs directory if it hasn't existed yet
156
108
mkdir -p ./runtime/logs
@@ -172,9 +124,4 @@ if [ ! -d "${fullSourceDirectory}" ]; then # source doesn't exist
172
124
else
173
125
# Source already exists. Cloning not necessary.
174
126
echo " downloadTypescriptProject: Source already exists. Skip cloning ${cloneUrl} "
175
- fi
176
-
177
- (
178
- cd " ${fullSourceDirectory} " || exit
179
- usePackageManagerToInstallDependencies
180
- )
127
+ fi
0 commit comments