From 6e3a5c59d2cedd84af8ab6c1165fc9c4c918a9de Mon Sep 17 00:00:00 2001 From: "E. S." Date: Sun, 18 May 2025 00:42:00 +0300 Subject: [PATCH] deploy: some fixes, and delete old unused static regen scripts --- deploy/deploy.sh | 1 + deploy/static.sh | 37 ------------ deploy/static_incremental.sh | 1 + deploy/util/detect_changes.sh | 2 + deploy/util/gen_runtime_config.php | 91 ------------------------------ 5 files changed, 4 insertions(+), 128 deletions(-) delete mode 100755 deploy/static.sh delete mode 100755 deploy/util/gen_runtime_config.php diff --git a/deploy/deploy.sh b/deploy/deploy.sh index 3014693..464c081 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -6,6 +6,7 @@ die() { } set -e +set -x if ! command -v yq >/dev/null 2>&1; then die "yq is not installed. Please install yq to parse YAML files." diff --git a/deploy/static.sh b/deploy/static.sh deleted file mode 100755 index 51649af..0000000 --- a/deploy/static.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -die() { - >&2 echo "error: $*" - exit 1 -} - -set -e - -if ! command -v yq >/dev/null 2>&1; then - die "yq is not installed. Please install yq to parse YAML files." -fi - -PHP="$(which php)" -SCRIPT_DIR=$(cd "$(dirname "$(readlink -f "$0")")" && pwd) -APP_DIR="$(realpath "$SCRIPT_DIR/../")" -OUTPUT_ROOT_DIR= - -while [ $# -gt 0 ]; do - case $1 in - -o) OUTPUT_ROOT_DIR="$2"; shift ;; - -h) usage ;; - *) die "unexpected argument: $1" ;; - esac - shift -done -[ -z "$OUTPUT_ROOT_DIR" ] && die "you must specify output directory" - -PROJECTS=$("$SCRIPT_DIR"/util/get_projects.sh "$APP_DIR/config.yaml") -for project in $PROJECTS; do - "$SCRIPT_DIR"/util/build_css.sh -i "$APP_DIR/public/$project/scss" -o "$OUTPUT_ROOT_DIR/public/$project/dist-css" || die "build_css failed" - "$SCRIPT_DIR"/util/build_js.sh -i "$APP_DIR/public/common/js" -o "$OUTPUT_ROOT_DIR/public/$project/dist-js" || die "build_js failed" - $PHP "$SCRIPT_DIR"/util/gen_runtime_config.php \ - --app-root "$OUTPUT_ROOT_DIR" \ - --commit-hash "$(git rev-parse HEAD)" \ - > "$OUTPUT_ROOT_DIR/config-runtime.php" || die "gen_runtime_config failed" -done diff --git a/deploy/static_incremental.sh b/deploy/static_incremental.sh index 0c887a1..c9af015 100755 --- a/deploy/static_incremental.sh +++ b/deploy/static_incremental.sh @@ -6,6 +6,7 @@ die() { } set -e +set -x PHP="$(which php)" SCRIPT_DIR=$(cd "$(dirname "$(readlink -f "$0")")" && pwd) diff --git a/deploy/util/detect_changes.sh b/deploy/util/detect_changes.sh index c2e7342..b20fce0 100755 --- a/deploy/util/detect_changes.sh +++ b/deploy/util/detect_changes.sh @@ -54,6 +54,8 @@ if [ -z "$PREV_COMMIT" ]; then exit 0 fi +cd "$APP_DIR" + # Check if common files have changed common_changed=$(git diff --name-only "$PREV_COMMIT" "$CURR_COMMIT" -- "$APP_DIR/public/common") if [ -n "$common_changed" ]; then diff --git a/deploy/util/gen_runtime_config.php b/deploy/util/gen_runtime_config.php deleted file mode 100755 index a0777b1..0000000 --- a/deploy/util/gen_runtime_config.php +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env php - $commit_hash, - 'assets' => [] -]; - -foreach ($config['projects'] as $project) { - foreach (['js', 'css'] as $type) { - $dist_dir = $app_root.'/public/'.$project.'/dist-'.$type; - $entries = glob_recursive($dist_dir.'/*.'.$type); - if (empty($entries)) { - fwrite(STDERR, "warning: no files found in $dist_dir\n"); - continue; - } - foreach ($entries as $file) { - $hashes['assets'][$project][$type.'/'.basename($file)] = [ - 'integrity' => [] - ]; - foreach (\engine\skin\FeaturedSkin::RESOURCE_INTEGRITY_HASHES as $hash_type) { - $hashes['assets'][$project][$type.'/'.basename($file)]['integrity'][$hash_type] = base64_encode(hash_file($hash_type, $file, true)); - } - } - } -} - -echo "