Repository navigation
Expand file tree
/
Copy pathbuild_studio_clientlibs.sh
More file actions
executable file
·151 lines (141 loc) · 5.24 KB
/
Copy pathbuild_studio_clientlibs.sh
File metadata and controls
executable file
·151 lines (141 loc) · 5.24 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env bash
# Build the two Studio browser bundles from mapped or pinned standalone source.
# Set STUDIO_CLIENTLIB_SKIP_TESTS=1 to build the bundles without running the ClientLib tests (image builds).
set -euo pipefail
skip_tests="${STUDIO_CLIENTLIB_SKIP_TESTS:-0}"
root="${1:-.}"
root="$(cd "$root" && pwd -P)"
if [[ -f "$root/studio/src/modules/Elsa.Studio.Workflows.Designer/ClientLib/package.json" ]]; then
studio="$root/studio/src"
elif [[ -f "$root/src/studio/modules/Elsa.Studio.Workflows.Designer/ClientLib/package.json" ]]; then
studio="$root/src/studio"
else
studio="$root/src"
fi
designer="$studio/modules/Elsa.Studio.Workflows.Designer"
dom="$studio/framework/Elsa.Studio.DomInterop"
# The BPMN designer contract and shared rules. It builds no browser asset of its own, and older pinned Studio sources
# predate it, so it is tested only where it exists.
bpmn_shared="$studio/modules/Elsa.Studio.Bpmn/ClientLib"
# The bpmn-js and X6 designers bundle the shared rules, so each is built only where they and it exist.
bpmn_js="$studio/modules/Elsa.Studio.Bpmn.BpmnJs"
bpmn_x6="$studio/modules/Elsa.Studio.Bpmn.X6"
locks="$(cd "$(dirname "${BASH_SOURCE[0]}")/consolidated-build/studio-clientlib-lockfiles" && pwd -P)"
for package in "$designer/ClientLib/package.json" "$dom/ClientLib/package.json"; do
if [[ ! -f "$package" ]]; then
echo "Missing consolidated Studio source: $package" >&2
exit 1
fi
done
node_major="$(node -p 'process.versions.node.split(".")[0]')"
if [[ "$node_major" != 22 ]]; then
echo "Studio ClientLib proof requires Node 22; found $(node --version)" >&2
exit 1
fi
clientlibs=("$designer/ClientLib:$locks/designer.package-lock.json" \
"$dom/ClientLib:$locks/dom-interop.package-lock.json")
if [[ -f "$bpmn_shared/package.json" ]]; then
clientlibs+=("$bpmn_shared:$locks/bpmn-shared.package-lock.json")
fi
if [[ -f "$bpmn_shared/package.json" && -f "$bpmn_js/ClientLib/package.json" ]]; then
clientlibs+=("$bpmn_js/ClientLib:$locks/bpmn-js.package-lock.json")
fi
if [[ -f "$bpmn_shared/package.json" && -f "$bpmn_x6/ClientLib/package.json" ]]; then
clientlibs+=("$bpmn_x6/ClientLib:$locks/bpmn-x6.package-lock.json")
fi
for entry in "${clientlibs[@]}"; do
clientlib="${entry%%:*}"
reviewed_lock="${entry#*:}"
checkout_lock="$clientlib/package-lock.json"
if [[ -L "$checkout_lock" ]]; then
echo "Studio package lockfile cannot be a symlink: $checkout_lock" >&2
exit 1
fi
if [[ -e "$checkout_lock" ]]; then
if ! cmp -s "$reviewed_lock" "$checkout_lock"; then
echo "Studio package lockfile differs from the reviewed lock: $checkout_lock" >&2
exit 1
fi
else
cp "$reviewed_lock" "$checkout_lock"
fi
done
assets=(
"$designer/wwwroot/designer.entry.js"
"$designer/wwwroot/react-designer.entry.js"
"$designer/wwwroot/designer.css"
"$dom/wwwroot/dom.entry.js"
"$dom/wwwroot/clipboard.entry.js"
"$dom/wwwroot/files.entry.js"
)
if [[ -f "$bpmn_shared/package.json" && -f "$bpmn_js/ClientLib/package.json" ]]; then
assets+=("$bpmn_js/wwwroot/bpmn-js-designer.js" "$bpmn_js/wwwroot/bpmn-js-designer.css")
fi
if [[ -f "$bpmn_shared/package.json" && -f "$bpmn_x6/ClientLib/package.json" ]]; then
assets+=("$bpmn_x6/wwwroot/x6-designer.js" "$bpmn_x6/wwwroot/x6-designer.css")
fi
for asset in "${assets[@]}"; do
if [[ -L "$asset" ]]; then
echo "Studio browser asset cannot be a symlink: $asset" >&2
exit 1
fi
if git -C "$root" ls-files --error-unmatch -- "${asset#"$root"/}" >/dev/null 2>&1; then
echo "Refusing to remove tracked Studio browser asset: $asset" >&2
exit 1
fi
if [[ -e "$asset" ]]; then
rm -- "$asset"
fi
done
dotnet restore "$designer/Elsa.Studio.Workflows.Designer.csproj"
(
cd "$designer/ClientLib"
npm ci --force
npm run check:generated
if [[ "$skip_tests" != 1 ]]; then
npm test
fi
npm run build
)
(
cd "$dom/ClientLib"
npm ci --force
npm run build
)
if [[ -f "$bpmn_shared/package.json" ]]; then
(
# The bpmn-js and X6 builds resolve the shared rules' dependencies from here, so install even without tests.
cd "$bpmn_shared"
npm ci --force
if [[ "$skip_tests" != 1 ]]; then
npm test
fi
)
fi
if [[ -f "$bpmn_shared/package.json" && -f "$bpmn_js/ClientLib/package.json" ]]; then
(
# The build also enforces the designer's size budget.
cd "$bpmn_js/ClientLib"
npm ci --force
npm run build
)
fi
if [[ -f "$bpmn_shared/package.json" && -f "$bpmn_x6/ClientLib/package.json" ]]; then
(
# The build also enforces the designer's size budget.
cd "$bpmn_x6/ClientLib"
npm ci --force
npm run build
)
fi
for asset in "${assets[@]}"; do
if [[ ! -s "$asset" ]]; then
echo "Studio ClientLib build omitted a required browser asset: $asset" >&2
exit 1
fi
done
if [[ "$skip_tests" == 1 ]]; then
echo "Studio ClientLib build passed (tests skipped): generated BPMN types, the Studio bundles and ${#assets[@]} required assets."
else
echo "Studio ClientLib proof passed: generated BPMN types, Designer tests, the Studio bundles and ${#assets[@]} required assets."
fi