From a2ec3c10872a331ba3e52ad868d1f5f7e3dbb886 Mon Sep 17 00:00:00 2001 From: "E. S." Date: Thu, 15 May 2025 20:33:36 +0300 Subject: [PATCH] deploy: fix --- deploy/static.sh | 5 ++++- deploy/util/gen_runtime_config.php | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/deploy/static.sh b/deploy/static.sh index fd502e4..21087c8 100755 --- a/deploy/static.sh +++ b/deploy/static.sh @@ -25,5 +25,8 @@ done for project in ic foreignone; 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 --commit-hash "$(git rev-parse --short=8 HEAD)" > "$OUTPUT_ROOT_DIR/config-runtime.php" || die "gen_runtime_config failed" + $PHP "$SCRIPT_DIR"/util/gen_runtime_config.php \ + --app-root "$OUTPUT_ROOT_DIR" \ + --commit-hash "$(git rev-parse --short=8 HEAD)" \ + > "$OUTPUT_ROOT_DIR/config-runtime.php" || die "gen_runtime_config failed" done diff --git a/deploy/util/gen_runtime_config.php b/deploy/util/gen_runtime_config.php index a1877e2..ff9c045 100644 --- a/deploy/util/gen_runtime_config.php +++ b/deploy/util/gen_runtime_config.php @@ -4,18 +4,23 @@ require __DIR__.'/../../src/init.php'; $commit_hash = null; +$app_root = null; for ($i = 1; $i < $argc; $i++) { switch ($argv[$i]) { case '--commit-hash': $commit_hash = $argv[++$i] ?? usage('missing value for --commit-hash'); break; + case '--app-root': + $app_root = $argv[++$i] ?? usage('missing value for --app-root'); + break; + default: usage("unknown option {$argv[$i]}"); } } -if (is_null($commit_hash)) +if (is_null($commit_hash) || is_null($app_root)) usage(); $hashes = [ @@ -25,7 +30,7 @@ $hashes = [ foreach (['ic', 'foreignone'] as $project) { foreach (['js', 'css'] as $type) { - $dist_dir = APP_ROOT.'/public/'.$project.'/dist-'.$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"); @@ -49,7 +54,7 @@ function usage(string $msg = ''): never { if ($msg !== '') fwrite(STDERR, "error: {$msg}\n"); $script = $GLOBALS['argv'][0]; - fwrite(STDERR, "usage: {$script} --commit-hash HASH\n"); + fwrite(STDERR, "usage: {$script} --commit-hash HASH --app-root APP_ROOT\n"); exit(1); }