Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions scripts/sync-templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

set -e # bail on errors
GLOB=$1
IS_CI="${CI:-false}"
BASE=$(pwd)
COMMIT_MESSAGE=$(git log -1 --pretty=%B)

for folder in $GLOB; do
[ -d "$folder" ] || continue
cd $BASE
cd "$BASE"

if [ -n "$(git status --porcelain)" ]; then
git add .
Expand All @@ -23,17 +22,17 @@ for folder in $GLOB; do
# clone, delete files in the clone, and copy (new) files over
# this handles file deletions, additions, and changes seamlessly
# note: redirect output to dev/null to avoid any possibility of leaking token
git clone --quiet --depth 1 [email protected]:shadcn/${NAME}.git $CLONE_DIR > /dev/null
cd $CLONE_DIR
git clone --quiet --depth 1 [email protected]:shadcn/${NAME}.git "$CLONE_DIR" > /dev/null
cd "$CLONE_DIR"
find . | grep -v ".git" | grep -v "^\.*$" | xargs rm -rf # delete all files (to handle deletions in monorepo)
cp -r $BASE/$folder/. .
cp -r "$BASE/$folder/." .

if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "$COMMIT_MESSAGE"
git push origin main
fi

cd $BASE
rm -rf $CLONE_DIR
cd "$BASE"
rm -rf "$CLONE_DIR"
done