mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
8f8a30c02c
* Refactor: Load UserTemplates from embedded yaml file * feat: add version field to UserTemplates * refactor: use shell script to fetch frontends * chore: add *-dist to .gitignore * refactor: rename to FrontendTemplates BREAKING CHANGE: This commit changes the `user_templates` filed in the communication json between backend and the admin-frontend. Keep user config.yml `user_template` filed.
41 lines
990 B
Bash
Executable File
41 lines
990 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")/..")"
|
|
TEMPLATES_FILE="$ROOT_DIR/service/singleton/frontend-templates.yaml"
|
|
|
|
download_and_extract() {
|
|
local repository="$1"
|
|
local version="$2"
|
|
local targetDir="$3"
|
|
local TMP_DIR
|
|
|
|
TMP_DIR="$(mktemp -d)"
|
|
|
|
echo "Downloading from repository: $repository, version: $version"
|
|
|
|
pushd "$TMP_DIR" || exit
|
|
|
|
curl -L -o "dist.zip" "$repository/releases/download/$version/dist.zip"
|
|
|
|
[ -e "$targetDir" ] && rm -r "$targetDir"
|
|
unzip -q dist.zip
|
|
mv dist "$targetDir"
|
|
|
|
rm "dist.zip"
|
|
popd || exit
|
|
}
|
|
|
|
count=$(yq eval '. | length' "$TEMPLATES_FILE")
|
|
|
|
for i in $(seq 0 $(("$count"-1))); do
|
|
path=$(yq -r ".[$i].path" "$TEMPLATES_FILE")
|
|
repository=$(yq -r ".[$i].repository" "$TEMPLATES_FILE")
|
|
version=$(yq -r ".[$i].version" "$TEMPLATES_FILE")
|
|
|
|
if [[ -n $path && -n $repository && -n $version ]]; then
|
|
download_and_extract "$repository" "$version" "$ROOT_DIR/cmd/dashboard/$path"
|
|
fi
|
|
done
|