Skip to content

Commit 703d752

Browse files
committed
chore: add script to update core version
1 parent 7edecce commit 703d752

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ packages/**/.nyc_output/
66

77
scripts/reports
88
scripts/allure-report
9+
package-info.json

scripts/update-core-version.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
3+
# sh scripts/update-core-version.sh
4+
5+
# 將 npm info 輸出到 JSON 文件
6+
npm info @coolwallet/core --json > package-info.json
7+
8+
time_data=$(grep -o '"1\.[0-9]\+\.[0-9]\+[^"]*": "[^"]*"' package-info.json)
9+
10+
# 確認 time_data 是否有內容
11+
if [ -z "$time_data" ]; then
12+
echo "No versions found in time_data."
13+
exit 1
14+
fi
15+
16+
echo "Time data:"
17+
echo "$time_data"
18+
19+
# 提取所有版本和時間,並按時間排序,取出最新的版本
20+
latest_version=$(echo "$time_data" | grep -o '"1\.[0-9]\+\.[0-9][^"]*": "[^"]*"' | sort -t '"' -k 4,4r | head -n 1)
21+
echo "latest_version: $latest_version"
22+
23+
# 輸出最新版本
24+
if [ -n "$latest_version" ]; then
25+
final_version=$(echo "$latest_version" | sed 's/":.*//;s/"//g')
26+
echo "Latest version: $final_version"
27+
else
28+
echo "No version found."
29+
fi
30+
31+
# 組出要執行的 command
32+
command="npm install @coolwallet/core@$final_version --save-peer"
33+
echo "command: $command"
34+
35+
IGNORE_SCOPES=(
36+
--ignore @coolwallet/core
37+
--ignore @coolwallet/transport-react-native-ble
38+
--ignore tester
39+
--ignore @coolwallet/testing-library
40+
--ignore @coolwallet/template
41+
)
42+
# 執行 lerna command
43+
npx lerna exec $IGNORE_SCOPES -- $command

0 commit comments

Comments
 (0)