-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrun.sh
executable file
·173 lines (139 loc) · 4.51 KB
/
run.sh
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/usr/bin/env bash
# This script is intended to be run through run.sh (https://run.jotaen.net)
PUML_OPTIONS='-Tsvg'
DS_PUML_URL='https://github.com/johthor/DomainStory-PlantUML'
LOG_LEVEL="${LOG_LEVEL:-info}"
PROJECT_ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
strContains() { case $1 in *$2* ) return 0;; *) return 1;; esac ;}
puml::convert() {
fileName="$1"
outputDir="$2"
if strContains "$fileName" "DARK_MODE"; then
echo "Converting $fileName in dark mode to directory $outputDir"
plantuml "$PUML_OPTIONS" -o "$PROJECT_ROOT/$outputDir" -darkmode -DPUML_MODE=dark "$fileName"
else
echo "Converting $fileName in light mode to directory $outputDir"
plantuml "$PUML_OPTIONS" -o "$PROJECT_ROOT/$outputDir" "$fileName"
fi
}
# Compile split source files into one PUML file
run::compile() {
{
cat src/header.iuml
echo ''
cat src/utilities.iuml
echo ''
cat src/storyLayout.iuml
echo ''
cat src/styling.iuml
echo ''
cat src/theming.iuml
echo ''
cat src/state.iuml
echo ''
cat src/actors.iuml
echo ''
cat src/objects.iuml
echo ''
cat src/boundaries.iuml
echo ''
cat src/activities.iuml
echo ''
cat src/notes.iuml
echo ''
cat src/helper.iuml
} > domainStory.puml
}
# Convert all samples and assets
run::convertAssets() {
set -e
for asset in docs/puml/*.puml; do
puml::convert "$asset" docs/assets
done
for sample in samples/*.puml; do
puml::convert "$sample" docs/assets
done
puml::convert test/puml/styling/theme-bluegray.puml docs/assets
}
run::compare() {
magick compare -metric MAE \
"$1" \
"$2" \
null: 2>&1
}
run::compareImages() {
source ./test/lib/testUtils.sh
export SHARNESS_TEST_DIRECTORY="$PROJECT_ROOT/test"
compareImages "diagrams/$1" .svg
}
run::computeDiff() {
source ./test/lib/testUtils.sh
export SHARNESS_TEST_DIRECTORY="$PROJECT_ROOT/test"
computeDiff "diagrams/$1" .svg
}
# Run tests in ./test
run::test() {
set -e
mkdir -p test/lib
if [ ! -f test/lib/plantuml.version ]
then
tag=$(curl -s https://api.github.com/repos/plantuml/plantuml/releases/latest | jq -r '.tag_name')
echo "$tag" > test/lib/plantuml.version
fi
if [ ! -f test/lib/plantuml.jar ]
then
version=$(cat test/lib/plantuml.version)
curl "https://github.com/plantuml/plantuml/releases/download/${version}/plantuml-${version#v}.jar" -L -o test/lib/plantuml.jar
fi
chmod +x test/testSuite.sh
cd test
./testSuite.sh
}
# Clean tests in ./test
run::test-clean() {
set -e
chmod +x test/testSuite.sh
cd test
./testSuite.sh clean
}
# Bake the next release version
run::bakeRelease() {
version="$1"
versionName="${2:-'Next Version'}"
pathToStdLib="${3:-"$PROJECT_ROOT/../plantuml-stdlib"}"
domainStoryDir="$pathToStdLib/stdlib/DomainStory"
echo "Next Release $versionName with version $version will be baked into $domainStoryDir"
# Update DomainStoryVersion
sed -i .bak -E "s/'' Version: .+/'' Version: $version/" "$PROJECT_ROOT/domainStory.puml"
sed -i .bak -E "s/\!global \\\$DomainStoryVersion = \".+\"/\!global \\\$DomainStoryVersion = \"$version\"/" "$PROJECT_ROOT/domainStory.puml"
# Update Changelog
sed -i .bak -E "s/## \[Unreleased\] - t.b.d./## \[Unreleased\] - t.b.d.\n\n\n## $versionName \[$version\] - $(date +'%Y-%m-%d')/" "$PROJECT_ROOT/CHANGELOG.md"
sed -i .bak -E "s/\[Unreleased\]: https:\/\/github.com\/johthor\/DomainStory-PlantUML\/compare\/v.+\.\.\.HEAD/\
\[Unreleased\]: https:\/\/github.com\/johthor\/DomainStory-PlantUML\/compare\/v$version\.\.\.HEAD\n\
\[$version\]: https:\/\/github.com\/johthor\/DomainStory-PlantUML\/releases\/tag\/v$version/" "$PROJECT_ROOT/CHANGELOG.md"
# Update StdLib README file
sed -i .bak -E "s/version: .+/version: $version/" "$domainStoryDir/README.md"
# Copy over relevant PUML files into StdLib
cp "$PROJECT_ROOT/domainStory.puml" "$domainStoryDir"
}
run::processFileDark() {
directory=$(dirname "$1")
fileName=$(basename "$1" .puml)
fileBase="$directory/$fileName"
plantuml -Tsvg -darkmode -DPUML_MODE=dark -DLOG_LEVEL=debug "$1"
mv "$fileBase.svg" scrapbook/darkmode/
}
run::preprocessFile() {
directory=$(dirname "$1")
fileName=$(basename "$1" .puml)
fileBase="$directory/$fileName"
plantuml -DLOG_LEVEL="$LOG_LEVEL" -preproc "$1"
sed -e 's/^[ ]*//' "$fileBase.preproc" > scrapbook/preprocessed/"$fileName.preproc.puml"
rm "$fileBase.preproc"
}
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
cmd="$1"
shift
echo "Running task run::$cmd"
"run::$cmd" "$@"
fi