@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.
@@ -1,29 +1,25 @@
1
- # post-checkout hook 接收參數:prev_HEAD new_HEAD checkout_type
2
- # checkout_type:1 = 切換分支,0 = 切換檔案
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
- # 僅針對 dev、qa、master 這三個目標分支執行自動拉取
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
@@ -1,2 +1,4 @@
1
- # 提交前自動格式化程式碼(Prettier),並將格式化後的變更加入暫存區
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
2
4
  npm run format && git add .
package/.husky/pre-push CHANGED
@@ -1,27 +1,5 @@
1
- # 從 stdin 偵測是否為 force push(非 fast-forward)
2
- # pre-push hook 會收到:<local_ref> <local_sha> <remote_ref> <remote_sha>
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.427-qa.1",
3
+ "version": "1.1.427",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -1,23 +1,23 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // dev/qa 分支自動計算下一個 prerelease 版號
4
- // 版號格式:{master 版號}-{分支名}.{遞增編號}
5
- // 範例:master=2.1.1,dev 第 5 次推送 → 2.1.1-dev.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
- // 由 auto-version.sh(pre-push hook)呼叫
8
- // 將新版號輸出至 stdout;若版號無需變更則靜默結束
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
- // 取得當前分支,僅在 dev/qa 分支執行
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
- // 從 origin/master 取得基礎版號,若失敗則退而使用本地 master
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
- // 例如 currentVersion="2.1.1-dev.4" → nextNum=5
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
- // 掃描 git log 找出該前綴歷史上使用過的最大編號
46
- // 防止合併後版號回退(merge 可能覆寫 currentVersion)
47
- // 例如:合併後 currentVersion="2.0.9-dev.20",但歷史中存在 "2.1.1-dev.4"
48
- // → historyMax=4,nextNum=5(而非從 0 重新開始)
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)
@@ -1,19 +1,15 @@
1
1
  #!/usr/bin/env sh
2
2
 
3
- # 在 dev/qa 分支自動升版並發布
4
- # 由 pre-push hook 呼叫,$1 為遠端名稱(預設 origin)
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
- # 透過 Node 腳本計算下一個 prerelease 版號(會掃描 git log 避免版號回退)
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
- # 使用 standard-version 升版:更新 package.json 版號、產生 CHANGELOG、建立 commit + tag
21
+ # Bump version, update CHANGELOG, create commit + tag
26
22
  npx standard-version --release-as "$NEXT_VERSION"
27
23
 
28
- # 推送到遠端並執行 npm publish
24
+ # Push + npm publish
29
25
  node scripts/branch-auto-npm-publish.js "$REMOTE" "$BRANCH"
30
26
 
31
- # 以 exit 1 中斷原本的 git push(因為上面的腳本已經完成推送了)
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
- // 推送 commit 與 tag 到遠端(--no-verify 避免觸發 pre-push hook 造成無限迴圈)
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
- // 發布到 npm,使用分支名稱作為 dist-tag(例如 npm install @jetthai/cuora@dev)
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})`)
@@ -1,24 +1,22 @@
1
1
  #!/usr/bin/env sh
2
2
 
3
- # 清理不符合規範的 git tag(本地 + 遠端)
4
- # 合規格式:v1.2.3(例如 v0.1.0、v1.12.123)
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. 當前分支為 dev 或 qa
8
- # 2. 該 tag 所指向的 commit 不屬於任何分支(孤立 commit)
9
- # 3. 該 tag 所指向的 commit 已被合併進 master
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
- # 取得最新的 tag(依建立時間排序),無論格式是否合規都會保留
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
- # 篩選出所有不符合合規格式的 tag
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
- # 規則 1:當前在 dev 或 qa 分支,直接刪除所有不合規 tag
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
- # 規則 2:該 tag 的 commit 不屬於任何分支(孤立的 commit)
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
- # 規則 3:該 tag 的 commit 已合併進 master(代表該 tag 已無保留必要)
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