1+ # joinByString is a utility function to join an array of strings with a separator string
2+ function joinByString() {
3+ local separator=" $1 "
4+ shift
5+ local first=" $1 "
6+ shift
7+ printf " %s" " $first " " ${@/#/ $separator } "
8+ }
9+
10+ # isPackagePublished is a utility function to check if a package is published
11+ # This will only work for the latest version of the package
12+ # Can only be called inside the top level function since directory needs to be changed
13+ function isPackagePublished() {
14+ local package=$1
15+ local version=$2
16+
17+ poetry search $package | grep " $package ($version )"
18+ local exit_code=$?
19+
20+ if [ " $exit_code " -eq " 0" ]; then
21+ return 0
22+ else
23+ return 1
24+ fi
25+ }
26+
127function patchVersion() {
228 local package=$1
329 local version=$2
@@ -24,15 +50,14 @@ function patchVersion() {
2450
2551 if [ " ${# deps[@]} " -ne " 0" ]; then # -ne is integer inequality
2652 if [ " ${deps[0]} " != " " ]; then # != is string inequality
27- for dep in " ${deps[@]} " ; do
28- poetry add $dep @$version
29- local addDepResult=$?
30- if [ " $addDepResult " -ne " 0" ]; then
31- echo " Failed to add $dep @$version to $package "
32- cd $pwd
33- return 1
34- fi
35- done
53+ patchedDeps=" $( joinByString " @$version " " ${deps[@]} " ) @$version "
54+ poetry add $patchedDeps
55+ local addDepsResult=$?
56+ if [ " $addDepsResult " -ne " 0" ]; then
57+ echo " Failed to add $patchedDeps to $package "
58+ cd $pwd
59+ return 1
60+ fi
3661 fi
3762 fi
3863
@@ -44,7 +69,7 @@ function patchVersion() {
4469 return 1
4570 fi
4671
47- poetry install
72+ poetry install --no-root
4873 local installResult=$?
4974 if [ " $installResult " -ne " 0" ]; then
5075 echo " Failed to install $package "
@@ -84,22 +109,6 @@ function publishPackage() {
84109 cd $pwd
85110}
86111
87- # This will only work for the latest version of the package
88- # Can only be called inside the top level function since directory needs to be changed
89- function isPackagePublished() {
90- local package=$1
91- local version=$2
92-
93- poetry search $package | grep " $package ($version )"
94- local exit_code=$?
95-
96- if [ " $exit_code " -eq " 0" ]; then
97- return 0
98- else
99- return 1
100- fi
101- }
102-
103112function waitForPackagePublish() {
104113 local package=$1
105114 local version=$2
@@ -131,7 +140,6 @@ function waitForPackagePublish() {
131140 fi
132141}
133142
134-
135143# Patching Verion of polywrap-msgpack
136144echo " Patching Version of polywrap-msgpack to $1 "
137145patchVersion polywrap-msgpack $1
0 commit comments