From 2004f350a7a2793cec7fa3cea7c0c7592ee4ab88 Mon Sep 17 00:00:00 2001 From: Youngteac Hong Date: Thu, 25 Jul 2024 18:19:27 +0900 Subject: [PATCH] Add update:examples script --- package.json | 1 + build_examples.sh => scripts/update-examples.sh | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) rename build_examples.sh => scripts/update-examples.sh (51%) diff --git a/package.json b/package.json index bae221358..8341530ca 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "test:ci": "vitest run --coverage", "test:yorkie.dev": "TEST_RPC_ADDR=https://api.yorkie.dev vitest run --coverage", "lint": "eslint . --fix --max-warnings=0 --ext .ts", + "update:examples": "./scripts/update-examples.sh", "prepare": "npm run build" }, "engines": { diff --git a/build_examples.sh b/scripts/update-examples.sh similarity index 51% rename from build_examples.sh rename to scripts/update-examples.sh index 5af530a23..aea7dc03c 100755 --- a/build_examples.sh +++ b/scripts/update-examples.sh @@ -1,29 +1,30 @@ #!/bin/bash -# 버전을 입력받기 +# Get the version of yorkie-js-sdk read -p "Enter the yorkie-js-sdk version: " version -# examples 폴더로 이동 +# Change the directory to the examples folder cd examples -# 모든 예제 폴더들에 대해 반복 +# Loop through all example folders for dir in */; do - # 디렉토리인지 확인하고 dist 폴더는 제외 + # Check if it is a directory and exclude the dist folder + echo $dir if [ -d "$dir" ] && [ "$dir" != "dist/" ]; then - # 예제 폴더로 이동 + # Move to the example folder cd "$dir" - # npm i와 npm run build 실행 + # Execute npm i and npm run build npm i "yorkie-js-sdk@$version" && npm run build - # 실행 결과 확인 + # Check the result of the execution if [ $? -ne 0 ]; then echo "Error occurred in $dir" else echo "$dir build succeeded" fi - # 원래 디렉토리로 돌아오기 + # Move back to the examples folder cd .. fi done