Repository navigation
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·63 lines (51 loc) · 1.66 KB
/
Copy pathdocker-entrypoint.sh
File metadata and controls
executable file
·63 lines (51 loc) · 1.66 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
#!/usr/bin/env sh
set -e
executeOclifCommand() {
command_with_params=$1
# shellcheck disable=SC2086
(cd "$target_dir" && node --no-warnings /fablo/bin/run.mjs $command_with_params)
}
formatGeneratedFiles() {
# Additional script and yaml formatting
#
# Why? Generated output may contain some additional whitespaces or the formatting
# might not be ideal. Keeping those whitespaces, however, might be useful
# in templates to improve the brevity. That's why we need additional formatting.
# Since the templates should obey good practices, we don't use linters here
# (i.e. shellcheck and yamllint).
echo "Formatting generated files"
shfmt -i=2 -l -w "$target_dir" >/dev/null
for yaml in "$target_dir"/**/*.yaml; do
# the expansion failed, no yaml files found
if [ "$yaml" = "$target_dir/**/*.yaml" ]; then
break
fi
# remove trailing spaces
sed --in-place 's/[ \t]*$//' "$yaml"
# remove duplicated empty/blank lines
content="$(awk -v RS= -v ORS='\n\n' '1' "$yaml")"
echo "$content" >"$yaml"
done
}
target_dir="/network/workspace"
oclif_command=${1:-setup-network}
# Map old yeoman command format to oclif format
case "$oclif_command" in
"Fablo:setup-network"|"fablo:setup-network")
oclif_command="setup-network"
;;
esac
# Build command with all arguments (mapped command + remaining args)
# Replace first argument with mapped command, then pass all args
if [ $# -gt 0 ]; then
shift
set -- "$oclif_command" "$@"
else
set -- "$oclif_command"
fi
command_with_args="$*"
# Execute the command
executeOclifCommand "$command_with_args"
if echo "$oclif_command" | grep -q "setup-network"; then
formatGeneratedFiles
fi