From 73ef6ac422521ee86b8194757cdca4a1e8893362 Mon Sep 17 00:00:00 2001 From: baldo Date: Mon, 11 Jul 2022 12:13:06 +0200 Subject: [PATCH] Fix deployment: No more symlinks in dist. --- bin/dist-fix-symlinks.sh | 27 +++++++++++++++++++++++++++ package.json | 2 +- publish.sh | 4 ++-- 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100755 bin/dist-fix-symlinks.sh diff --git a/bin/dist-fix-symlinks.sh b/bin/dist-fix-symlinks.sh new file mode 100755 index 0000000..abb4e9a --- /dev/null +++ b/bin/dist-fix-symlinks.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +echo "Fixing symlinks in dist:" + +if [[ ! -d "dist" ]]; then + echo " Error: Directory dist does not exist." + exit 1 +fi + +cd dist + +find . -type l | while read symlink; do + target=$(readlink -e "$symlink") + if [[ -z "$target" ]] || [[ ! -f "$target" ]]; then + echo " Could not resolve symlink in dist: $symlink" + exit 1 + fi + + echo " $symlink" + rsync "$target" "$symlink" -az --copy-links +done + +echo "Done" diff --git a/package.json b/package.json index 3bcb793..3a9af00 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "test": "yarn run server:test", "build": "yarn run server:build && grunt build && rsync -avzL --exclude='*/__mocks__/' --exclude='*.test.*' server-build/ dist/server/", "clean": "rm -rf server-build/ && grunt clean", - "dist": "yarn run clean && yarn run build && yarn run test", + "dist": "yarn run clean && yarn run build && ./bin/dist-fix-symlinks.sh && yarn run test", "client:serve": "grunt serve", "server:test": "jest --config=jest.server.config.js", "server:build": "tsc -b server && ln -sfv ../../server/db/patches ./server-build/db/ && ln -sfv ../server/templates ./server-build/ && ln -sfv ../server/mailTemplates ./server-build/", diff --git a/publish.sh b/publish.sh index fa93db9..1d96885 100755 --- a/publish.sh +++ b/publish.sh @@ -22,7 +22,7 @@ function confirm() { done } -cd $(dirname $0) +cd "$(dirname "${BASH_SOURCE[0]}")" version=$(grep '^ *"version": *"[^"]*" *, *$' package.json | cut -d '"' -f4) @@ -44,5 +44,5 @@ if confirm "Continue publishing?"; then yarn run dist cd dist - npm publish + yarn publish --new-version "$version" fi