feat: sync httpdns sdk/platform updates without large binaries
This commit is contained in:
@@ -1,4 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
function verify_components_bundle() {
|
||||
local file_path="$1"
|
||||
if [ ! -f "$file_path" ]; then
|
||||
echo "[error] components.js not found: $file_path"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local file_size
|
||||
file_size=$(wc -c < "$file_path")
|
||||
if [ "$file_size" -lt 100000 ]; then
|
||||
echo "[error] components.js looks too small ($file_size bytes), generate likely failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! grep -q 'Vue.component("csrf-token"' "$file_path"; then
|
||||
echo "[error] components.js missing csrf-token component, generate likely failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "verify components.js: ok ($file_size bytes)"
|
||||
return 0
|
||||
}
|
||||
|
||||
function build() {
|
||||
ROOT=$(dirname "$0")
|
||||
@@ -58,7 +82,7 @@ function build() {
|
||||
|
||||
# generate files
|
||||
echo "generating files ..."
|
||||
env CGO_ENABLED=0 go run -tags $TAG "$ROOT"/../cmd/edge-admin/main.go generate
|
||||
env TEAROOT="$ROOT" CGO_ENABLED=0 go run -tags "$TAG" "$ROOT"/../cmd/edge-admin/main.go generate
|
||||
if [ "$(which uglifyjs)" ]; then
|
||||
echo "compress to component.js ..."
|
||||
uglifyjs --compress --mangle -- "${JS_ROOT}"/components.src.js > "${JS_ROOT}"/components.js
|
||||
@@ -69,6 +93,8 @@ function build() {
|
||||
cp "${JS_ROOT}"/utils.js "${JS_ROOT}"/utils.min.js
|
||||
fi
|
||||
|
||||
verify_components_bundle "${JS_ROOT}/components.js"
|
||||
|
||||
# create dir & copy files
|
||||
echo "copying ..."
|
||||
if [ ! -d "$DIST" ]; then
|
||||
|
||||
@@ -1,22 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
JS_ROOT=../web/public/js
|
||||
ROOT=$(cd "$(dirname "$0")" && pwd)
|
||||
JS_ROOT="$ROOT"/../web/public/js
|
||||
|
||||
function verify_components_bundle() {
|
||||
local file_path="$1"
|
||||
if [ ! -f "$file_path" ]; then
|
||||
echo "[error] components.js not found: $file_path"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local file_size
|
||||
file_size=$(wc -c < "$file_path")
|
||||
if [ "$file_size" -lt 100000 ]; then
|
||||
echo "[error] components.js looks too small ($file_size bytes), generate likely failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! grep -q 'Vue.component("csrf-token"' "$file_path"; then
|
||||
echo "[error] components.js missing csrf-token component, generate likely failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "verify components.js: ok ($file_size bytes)"
|
||||
return 0
|
||||
}
|
||||
|
||||
echo "generating component.src.js ..."
|
||||
env CGO_ENABLED=0 go run -tags=community ../cmd/edge-admin/main.go generate
|
||||
env TEAROOT="$ROOT" CGO_ENABLED=0 go run -tags=community "$ROOT"/../cmd/edge-admin/main.go generate
|
||||
|
||||
if [ "$(which uglifyjs)" ]; then
|
||||
echo "compress to component.js ..."
|
||||
uglifyjs --compress --mangle -- ${JS_ROOT}/components.src.js > ${JS_ROOT}/components.js
|
||||
uglifyjs --compress --mangle -- "${JS_ROOT}"/components.src.js > "${JS_ROOT}"/components.js
|
||||
|
||||
echo "compress to utils.min.js ..."
|
||||
uglifyjs --compress --mangle -- ${JS_ROOT}/utils.js > ${JS_ROOT}/utils.min.js
|
||||
uglifyjs --compress --mangle -- "${JS_ROOT}"/utils.js > "${JS_ROOT}"/utils.min.js
|
||||
else
|
||||
echo "copy to component.js ..."
|
||||
cp ${JS_ROOT}/components.src.js ${JS_ROOT}/components.js
|
||||
cp "${JS_ROOT}"/components.src.js "${JS_ROOT}"/components.js
|
||||
|
||||
echo "copy to utils.min.js ..."
|
||||
cp ${JS_ROOT}/utils.js ${JS_ROOT}/utils.min.js
|
||||
cp "${JS_ROOT}"/utils.js "${JS_ROOT}"/utils.min.js
|
||||
fi
|
||||
|
||||
echo "ok"
|
||||
verify_components_bundle "${JS_ROOT}/components.js"
|
||||
|
||||
echo "ok"
|
||||
|
||||
Reference in New Issue
Block a user