forked from DeminMaxim/CodeStream
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.sh
More file actions
executable file
·128 lines (114 loc) · 2.85 KB
/
Copy pathutils.sh
File metadata and controls
executable file
·128 lines (114 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env bash
dirs=("vs" "vscode" "jb" "shared/ui" "shared/agent" "shared/util" "shared/build")
pushd () {
command pushd "$@" > /dev/null
}
popd () {
command popd "$@" > /dev/null
}
function compile_all () {
fails=()
for dir in "${dirs[@]}"; do
pushd "$dir" || continue
printf "\n%s: " "$dir"
npx tsc --noEmit
if [ $? -ne 0 ]; then
echo "🚨$dir: typescript fail"
fails+=("$dir")
else
echo "✅ passed"
fi
popd
done
if [ ${#fails[@]} -ne 0 ]; then
printf -v joined '%s, ' "${fails[@]}"
printf "\n🚨 Failed projects: "
echo "${joined%, }"
fi
}
function test () {
# shared/agent temporarily runs shared/utils tests until teamcity is updated
# pushd shared/utils
# npm run test
# popd
pushd shared/agent
npm run test-unit
popd
pushd shared/ui
npm run test
}
function show_version () {
for dir in "${dirs[@]}"; do
pushd "$dir" || continue
echo "$dir:"
devDep=$(cat package.json | jq ".devDependencies.${2}")
if [ "$devDep" = "null" ]; then
dep=$(cat package.json | jq ".dependencies.${2}")
echo $dep
else
echo $devDep
fi
popd
done
}
function explain_version () {
for dir in "${dirs[@]}"; do
pushd "$dir" || continue
echo "$dir:"
npm explain "$2" 2>/dev/null
if [ $? -ne 0 ]; then
echo "Not found"
fi
popd
done
}
function clean () {
cleanFiles=("node_modules" "jb/node_modules" "vscode/node_modules" "vs/node_modules" "shared/agent/node_modules" "shared/ui/node_modules" "shared/util/node_modules")
for path in "${cleanFiles[@]}"; do
if [ -d "$path" ]; then
echo "deleting $path"
rm -r -f "$path"
else
echo "skipping $path"
fi
done
}
function killEsbuild () {
pkill esbuild
pids=$(ps aux | grep esbuild.ts | grep -v grep | awk '{print $2}')
for pid in $pids; do
echo "killing $pid"
kill -9 "$pid"
done
}
function usage () {
echo "Usage: utils.sh <command>"
echo "Commands:"
echo " clean: remove node_modules from all projects"
echo " explainVersion <package>: explain the version of a package in all projects. Shows why a particular version is being used"
echo " showVersion <package>: briefly show the version of a package in all projects"
echo " test: run tests in all projects"
echo " compile: run typescript compiler (noEmit) on all projects"
echo " killEsbuild: kill all esbuild processes"
}
if [ "$1" = "" ]; then
usage
exit 1
fi
if [ "$1" = "clean" ]; then
clean
elif [ "$1" = "explainVersion" ]; then
explain_version "$@"
elif [ "$1" = "showVersion" ]; then
show_version "$@"
elif [ "$1" = "test" ]; then
test
elif [ "$1" = "compile" ]; then
compile_all "$@"
elif [ "$1" = "killEsbuild" ]; then
killEsbuild
else
printf "Invalid command %s\n\n" "$1"
usage
exit 1
fi