@jetthai/cuora 1.1.427-qa.1 → 1.1.427
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/post-checkout +4 -8
- package/.husky/pre-commit +3 -1
- package/.husky/pre-push +2 -24
- package/CHANGELOG.md +0 -4
- package/package.json +1 -1
- package/scripts/auto-version.js +14 -16
- package/scripts/auto-version.sh +6 -10
- package/scripts/branch-auto-npm-publish.js +5 -7
- package/scripts/clean-tags.sh +11 -16
package/.husky/post-checkout
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
# post-checkout
|
|
2
|
-
# checkout_type
|
|
1
|
+
# post-checkout receives: prev_HEAD new_HEAD checkout_type
|
|
2
|
+
# checkout_type: 1 = branch checkout, 0 = file checkout
|
|
3
3
|
CHECKOUT_TYPE=$3
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# Only run on branch checkout, skip file checkout
|
|
6
6
|
[ "$CHECKOUT_TYPE" != "1" ] && exit 0
|
|
7
7
|
|
|
8
|
-
# 取得切換後的當前分支名稱
|
|
9
8
|
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
TARGET_BRANCHES="dev qa master"
|
|
10
|
+
TARGET_BRANCHES="dev qa"
|
|
13
11
|
match=0
|
|
14
12
|
for branch in $TARGET_BRANCHES; do
|
|
15
13
|
[ "$CURRENT_BRANCH" = "$branch" ] && match=1 && break
|
|
16
14
|
done
|
|
17
15
|
|
|
18
16
|
if [ "$match" = "1" ]; then
|
|
19
|
-
# 檢查本地是否有尚未推送的 commit,有的話跳過自動拉取(避免覆蓋本地變更)
|
|
20
17
|
LOCAL_AHEAD=$(git rev-list --count origin/"$CURRENT_BRANCH"..HEAD 2>/dev/null || echo 0)
|
|
21
18
|
if [ "$LOCAL_AHEAD" -gt 0 ]; then
|
|
22
19
|
echo "You have $LOCAL_AHEAD unpushed commit(s) on '$CURRENT_BRANCH'. Skipping auto-pull."
|
|
23
20
|
exit 0
|
|
24
21
|
fi
|
|
25
22
|
|
|
26
|
-
# 自動從遠端拉取最新程式碼(使用 rebase 保持線性歷史)
|
|
27
23
|
echo "Auto pulling '$CURRENT_BRANCH' from remote..."
|
|
28
24
|
git pull --rebase origin "$CURRENT_BRANCH" || {
|
|
29
25
|
echo "Failed to pull '$CURRENT_BRANCH'. Please resolve manually."
|
package/.husky/pre-commit
CHANGED
package/.husky/pre-push
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
IS_FORCE=false
|
|
4
|
-
while read local_ref local_sha remote_ref remote_sha; do
|
|
5
|
-
# 跳過新建分支或刪除分支的情況(sha 全為 0)
|
|
6
|
-
[ "$remote_sha" = "0000000000000000000000000000000000000000" ] && continue
|
|
7
|
-
[ "$local_sha" = "0000000000000000000000000000000000000000" ] && continue
|
|
8
|
-
# 若遠端 sha 不是本地 sha 的祖先,代表是 force push
|
|
9
|
-
if ! git merge-base --is-ancestor "$remote_sha" "$local_sha" 2>/dev/null; then
|
|
10
|
-
IS_FORCE=true
|
|
11
|
-
break
|
|
12
|
-
fi
|
|
13
|
-
done
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
. "$(dirname -- "$0")/_/husky.sh"
|
|
14
3
|
|
|
15
|
-
# 取得當前分支名稱
|
|
16
|
-
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
17
|
-
|
|
18
|
-
# 在 dev/qa 分支的 force push 跳過所有 pre-push hook(避免干擾強制推送)
|
|
19
|
-
if [ "$IS_FORCE" = true ] && { [ "$BRANCH" = "dev" ] || [ "$BRANCH" = "qa" ]; }; then
|
|
20
|
-
echo "Force push detected on $BRANCH, skipping pre-push hooks."
|
|
21
|
-
exit 0
|
|
22
|
-
fi
|
|
23
|
-
|
|
24
|
-
# 清理不合規的 tag(本地 + 遠端)
|
|
25
4
|
sh scripts/clean-tags.sh
|
|
26
|
-
# 自動升版並發布(僅 dev/qa 分支會實際執行,$1 為遠端名稱)
|
|
27
5
|
sh scripts/auto-version.sh "$1"
|
package/CHANGELOG.md
CHANGED
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
### [1.1.427-qa.1](https://github.com/jetthai/cuora-module/compare/v1.1.426...v1.1.427-qa.1) (2026-04-12)
|
|
6
|
-
|
|
7
|
-
### [1.1.427-qa.0](https://github.com/jetthai/cuora-module/compare/v1.1.427...v1.1.427-qa.0) (2026-04-12)
|
|
8
|
-
|
|
9
5
|
### [1.1.427](https://github.com/jetthai/cuora-module/compare/v1.1.426...v1.1.427) (2026-04-07)
|
|
10
6
|
|
|
11
7
|
### [1.1.426](https://github.com/jetthai/cuora-module/compare/v1.1.425...v1.1.426) (2026-03-31)
|
package/package.json
CHANGED
package/scripts/auto-version.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// dev/qa
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// Auto version bump for dev/qa branches
|
|
4
|
+
// Format: {master version}-{branch}.{number}
|
|
5
|
+
// Example: master=2.1.1, dev 5th push → 2.1.1-dev.5
|
|
6
6
|
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
7
|
+
// Called by auto-version.sh (pre-push hook)
|
|
8
|
+
// Outputs new version to stdout; silent exit if no change needed
|
|
9
9
|
|
|
10
10
|
import { execSync } from 'node:child_process'
|
|
11
11
|
import { readFileSync } from 'node:fs'
|
|
12
12
|
|
|
13
|
-
//
|
|
13
|
+
// Only run on dev / qa branches
|
|
14
14
|
const branch = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim()
|
|
15
15
|
|
|
16
16
|
if (branch !== 'dev' && branch !== 'qa') {
|
|
17
17
|
process.exit(0)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
//
|
|
20
|
+
// Get base version from origin/master, fallback to local master
|
|
21
21
|
let masterVersion
|
|
22
22
|
try {
|
|
23
23
|
masterVersion = JSON.parse(execSync('git show origin/master:package.json', { encoding: 'utf8' })).version
|
|
@@ -30,22 +30,21 @@ try {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
// 讀取當前 package.json 版號,組合 prerelease 前綴
|
|
34
33
|
const currentVersion = JSON.parse(readFileSync('package.json', 'utf8')).version
|
|
35
34
|
const prefix = `${masterVersion}-${branch}.`
|
|
36
35
|
let nextNum = 0
|
|
37
36
|
|
|
38
|
-
//
|
|
39
|
-
//
|
|
37
|
+
// Derive next number from current version
|
|
38
|
+
// e.g. currentVersion="2.1.1-dev.4" → nextNum=5
|
|
40
39
|
if (currentVersion.startsWith(prefix)) {
|
|
41
40
|
const num = parseInt(currentVersion.slice(prefix.length), 10)
|
|
42
41
|
if (!isNaN(num)) nextNum = num + 1
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
// → historyMax=4
|
|
44
|
+
// Scan git log for the highest number ever used with this prefix
|
|
45
|
+
// Prevents regression when merges overwrite currentVersion
|
|
46
|
+
// e.g. after merge currentVersion="2.0.9-dev.20", but history has "2.1.1-dev.4"
|
|
47
|
+
// → historyMax=4, nextNum=5 (instead of restarting from 0)
|
|
49
48
|
try {
|
|
50
49
|
const log = execSync(`git log ${branch} --pretty=%s --grep="^${masterVersion}-${branch}\\\\." -n 50`, {
|
|
51
50
|
encoding: 'utf8',
|
|
@@ -59,10 +58,9 @@ try {
|
|
|
59
58
|
|
|
60
59
|
const newVersion = `${prefix}${nextNum}`
|
|
61
60
|
|
|
62
|
-
//
|
|
61
|
+
// No change needed
|
|
63
62
|
if (currentVersion === newVersion) {
|
|
64
63
|
process.exit(0)
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
// 輸出新版號供 auto-version.sh 使用
|
|
68
66
|
console.log(newVersion)
|
package/scripts/auto-version.sh
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env sh
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
#
|
|
3
|
+
# Auto version bump on dev/qa branches
|
|
4
|
+
# Called from pre-push hook — receives remote name as $1
|
|
5
5
|
|
|
6
|
-
# 取得遠端名稱(未傳入則預設為 origin)
|
|
7
6
|
REMOTE=${1:-origin}
|
|
8
|
-
# 取得當前分支名稱
|
|
9
7
|
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
10
8
|
|
|
11
|
-
# 僅在 dev 或 qa 分支執行自動升版流程
|
|
12
9
|
if [ "$BRANCH" = "dev" ] || [ "$BRANCH" = "qa" ]; then
|
|
13
|
-
#
|
|
10
|
+
# Compute next prerelease version (scans git log to prevent regression)
|
|
14
11
|
NEXT_VERSION=$(node scripts/auto-version.js)
|
|
15
12
|
|
|
16
|
-
# 若版號無變化,跳過發布流程
|
|
17
13
|
if [ -z "$NEXT_VERSION" ]; then
|
|
18
14
|
echo "Version unchanged, skipping release."
|
|
19
15
|
exit 0
|
|
@@ -22,12 +18,12 @@ if [ "$BRANCH" = "dev" ] || [ "$BRANCH" = "qa" ]; then
|
|
|
22
18
|
echo "Branch: $BRANCH"
|
|
23
19
|
echo "Next version: $NEXT_VERSION"
|
|
24
20
|
|
|
25
|
-
#
|
|
21
|
+
# Bump version, update CHANGELOG, create commit + tag
|
|
26
22
|
npx standard-version --release-as "$NEXT_VERSION"
|
|
27
23
|
|
|
28
|
-
#
|
|
24
|
+
# Push + npm publish
|
|
29
25
|
node scripts/branch-auto-npm-publish.js "$REMOTE" "$BRANCH"
|
|
30
26
|
|
|
31
|
-
#
|
|
27
|
+
# Abort the original git push (scripts already pushed)
|
|
32
28
|
exit 1
|
|
33
29
|
fi
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
// 自動推送 commit + tag 並發布到 npm
|
|
2
|
-
// 由 auto-version.sh 呼叫,接收參數:remote(遠端名稱)、branch(分支名稱)
|
|
3
|
-
|
|
4
1
|
import { execSync } from 'node:child_process'
|
|
5
2
|
import { readFileSync } from 'node:fs'
|
|
6
3
|
|
|
7
|
-
// 取得遠端名稱與分支名稱(預設為 origin 和當前分支)
|
|
8
4
|
const remote = process.argv[2] || 'origin'
|
|
9
5
|
const branch = process.argv[3] || execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim()
|
|
10
6
|
|
|
11
|
-
// 讀取 package.json 中的版號(此時已被 standard-version 更新過)
|
|
12
7
|
const { version } = JSON.parse(readFileSync('package.json', 'utf8'))
|
|
13
8
|
|
|
14
9
|
console.log(`Branch: ${branch}`)
|
|
15
10
|
console.log(`Version: ${version}`)
|
|
16
11
|
|
|
17
|
-
//
|
|
12
|
+
// Pull remote changes before push (avoid rejection)
|
|
13
|
+
execSync(`git pull --rebase --no-verify ${remote} ${branch}`, { stdio: 'inherit' })
|
|
14
|
+
|
|
15
|
+
// Push commit and tags
|
|
18
16
|
execSync(`git push --no-verify --follow-tags ${remote} ${branch}`, { stdio: 'inherit' })
|
|
19
17
|
|
|
20
|
-
//
|
|
18
|
+
// Publish to npm with branch dist-tag
|
|
21
19
|
try {
|
|
22
20
|
execSync(`npm publish --tag ${branch}`, { stdio: 'inherit' })
|
|
23
21
|
console.log(`✅ npm publish succeeded: ${version} (tag: ${branch})`)
|
package/scripts/clean-tags.sh
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env sh
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
#
|
|
3
|
+
# Delete local and remote tags that do NOT match the compliant pattern
|
|
4
|
+
# Compliant pattern: v1.2.3 (e.g., v0.1.0, v1.12.123)
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
# 1.
|
|
8
|
-
# 2.
|
|
9
|
-
# 3.
|
|
6
|
+
# Deletion rules (any match triggers deletion):
|
|
7
|
+
# 1. Current branch is dev or qa
|
|
8
|
+
# 2. Tag's commit is not reachable from any branch
|
|
9
|
+
# 3. Tag's commit is already merged into master
|
|
10
10
|
PATTERN="^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"
|
|
11
11
|
|
|
12
|
-
# 取得當前分支名稱
|
|
13
12
|
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
14
13
|
|
|
15
|
-
#
|
|
14
|
+
# Find the latest tag (by creation date) regardless of format
|
|
16
15
|
LATEST_TAG=$(git tag -l --sort=-creatordate | head -n 1)
|
|
17
16
|
|
|
18
|
-
#
|
|
17
|
+
# Collect non-compliant tags
|
|
19
18
|
TAGS=$(git tag -l | grep -vE "$PATTERN")
|
|
20
19
|
|
|
21
|
-
# 若沒有不合規的 tag,直接結束
|
|
22
20
|
if [ -z "$TAGS" ]; then
|
|
23
21
|
echo "No non-compliant tags found."
|
|
24
22
|
exit 0
|
|
@@ -26,9 +24,7 @@ fi
|
|
|
26
24
|
|
|
27
25
|
echo "Latest tag (preserved): $LATEST_TAG"
|
|
28
26
|
|
|
29
|
-
# 逐一檢查每個不合規的 tag
|
|
30
27
|
for TAG in $TAGS; do
|
|
31
|
-
# 最新的 tag 一律跳過,避免誤刪正在使用的版本
|
|
32
28
|
if [ "$TAG" = "$LATEST_TAG" ]; then
|
|
33
29
|
echo "Skipping tag $TAG (latest tag)"
|
|
34
30
|
continue
|
|
@@ -37,13 +33,13 @@ for TAG in $TAGS; do
|
|
|
37
33
|
SHOULD_DELETE=false
|
|
38
34
|
REASON=""
|
|
39
35
|
|
|
40
|
-
#
|
|
36
|
+
# Rule 1: Current branch is dev or qa
|
|
41
37
|
if [ "$BRANCH" = "dev" ] || [ "$BRANCH" = "qa" ]; then
|
|
42
38
|
SHOULD_DELETE=true
|
|
43
39
|
REASON="on $BRANCH branch"
|
|
44
40
|
fi
|
|
45
41
|
|
|
46
|
-
#
|
|
42
|
+
# Rule 2: Tag's commit is not reachable from any branch
|
|
47
43
|
if [ "$SHOULD_DELETE" = false ]; then
|
|
48
44
|
BRANCHES=$(git branch -a --contains "$TAG" 2>/dev/null)
|
|
49
45
|
if [ -z "$BRANCHES" ]; then
|
|
@@ -52,7 +48,7 @@ for TAG in $TAGS; do
|
|
|
52
48
|
fi
|
|
53
49
|
fi
|
|
54
50
|
|
|
55
|
-
#
|
|
51
|
+
# Rule 3: Tag's commit is already merged into master
|
|
56
52
|
if [ "$SHOULD_DELETE" = false ]; then
|
|
57
53
|
if git merge-base --is-ancestor "$TAG" master 2>/dev/null; then
|
|
58
54
|
SHOULD_DELETE=true
|
|
@@ -60,7 +56,6 @@ for TAG in $TAGS; do
|
|
|
60
56
|
fi
|
|
61
57
|
fi
|
|
62
58
|
|
|
63
|
-
# 執行刪除:先刪遠端再刪本地,遠端刪除失敗不中斷流程
|
|
64
59
|
if [ "$SHOULD_DELETE" = true ]; then
|
|
65
60
|
echo "Deleting tag $TAG ($REASON)"
|
|
66
61
|
git push origin --delete "$TAG" --no-verify 2>/dev/null || true
|