@zairakai/js-dev-tools 1.2.4 → 1.3.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zairakai/js-dev-tools",
3
- "version": "1.2.4",
3
+ "version": "1.3.1",
4
4
  "description": "The unified and centralized development toolkit for JavaScript/TypeScript projects - ESLint, Prettier, Stylelint, Knip, Vitest, Git Hooks, and GitLab CI pipeline templates",
5
5
  "keywords": [
6
6
  "dev-tools",
@@ -15,11 +15,10 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15
15
  source "${SCRIPT_DIR}/config.sh"
16
16
 
17
17
  TSC_BIN="${BIN_DIR}/tsc"
18
+ VUE_TSC_BIN="${BIN_DIR}/vue-tsc"
18
19
 
19
20
  log_header "TypeScript Type Checking"
20
21
 
21
- ensure_bin "$TSC_BIN" "tsc (typescript)"
22
-
23
22
  if [[ ! -f "${PROJECT_ROOT}/tsconfig.json" ]]; then
24
23
  log_error "No tsconfig.json found at project root"
25
24
  log_info "Publish one with:"
@@ -30,12 +29,20 @@ fi
30
29
  log_info "Config: tsconfig.json"
31
30
  log_info "Mode: --noEmit (type validation only)"
32
31
 
33
- # Skip gracefully if no .ts files are found
34
- if ! has_files "${PROJECT_ROOT}/**/*.ts" && ! has_files "${PROJECT_ROOT}/**/*.tsx"; then
35
- log_info "No TypeScript files found — skipping"
32
+ # Skip gracefully if no .ts/.vue files are found
33
+ if ! has_files "${PROJECT_ROOT}/**/*.ts" && ! has_files "${PROJECT_ROOT}/**/*.tsx" && ! has_files "${PROJECT_ROOT}/**/*.vue"; then
34
+ log_info "No TypeScript or Vue files found — skipping"
36
35
  exit 0
37
36
  fi
38
37
 
39
- "$TSC_BIN" --noEmit
38
+ # Prefer vue-tsc when available (handles .vue SFC imports correctly)
39
+ if [[ -x "$VUE_TSC_BIN" ]]; then
40
+ log_info "Checker: vue-tsc (Vue SFC support)"
41
+ "$VUE_TSC_BIN" --noEmit
42
+ else
43
+ ensure_bin "$TSC_BIN" "tsc (typescript)"
44
+ log_info "Checker: tsc"
45
+ "$TSC_BIN" --noEmit
46
+ fi
40
47
 
41
48
  log_success "TypeScript type checking passed"
@@ -52,5 +52,8 @@ include $(NPM_DIRECTORY_TOOLS_MAKE_DIR)test.mk
52
52
  # 10. BATS shell script testing
53
53
  include $(NPM_DIRECTORY_TOOLS_MAKE_DIR)bats.mk
54
54
 
55
- # 11. Utilities (git, npm)
55
+ # 11. Utilities (npm, maintenance)
56
56
  include $(NPM_DIRECTORY_TOOLS_MAKE_DIR)utils.mk
57
+
58
+ # 12. Shared utilities (git, hooks, doctor)
59
+ include $(NPM_DIRECTORY_TOOLS_MAKE_DIR)utils-shared.mk
@@ -0,0 +1,24 @@
1
+ # Shared Utility Targets
2
+ # Targets duplicated across PHP and JS toolchains
3
+
4
+ ## —— 🧰 Utils ——
5
+ .PHONY: doctor
6
+ doctor: ## Run environment diagnostics
7
+ @bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/doctor.sh
8
+
9
+ ## —— 🌿 Git ——
10
+ .PHONY: install-hooks
11
+ install-hooks: ## Install git hooks into .git/hooks
12
+ @bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/install-hooks.sh
13
+
14
+ .PHONY: git-update
15
+ git-update: ## Fast-forward all local branches that track a remote
16
+ @bash $(NPM_DIRECTORY_TOOLS_PACKAGE_ROOT)/tools/scripts/git-update.sh
17
+
18
+ .PHONY: git-cleanup
19
+ git-cleanup: ## Remove local branches whose remote tracking branch no longer exists
20
+ @bash $(NPM_DIRECTORY_TOOLS_PACKAGE_ROOT)/tools/scripts/git-cleanup.sh
21
+
22
+ .PHONY: git-rebase
23
+ git-rebase: ## Rebase the current branch to the selected one
24
+ @bash $(NPM_DIRECTORY_TOOLS_TOOLS_SCRIPTS_DIR)/git-rebase.sh
@@ -23,22 +23,6 @@ package-validate: ## Validate package.json and lockfile sync
23
23
  @$(NPM_DIRECTORY_TOOLS_PROJECT_ROOT)/node_modules/.bin/sort-package-json --check package.json
24
24
 
25
25
  ## —— 🧰 Utils ——
26
- .PHONY: doctor
27
- doctor: ## Run environment diagnostics
28
- @bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/doctor.sh
29
-
30
26
  .PHONY: outdated
31
27
  outdated: ## Check for outdated npm dependencies
32
28
  @bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/outdated.sh
33
-
34
- .PHONY: install-hooks
35
- install-hooks: ## Install git hooks into .git/hooks
36
- @bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/install-hooks.sh
37
-
38
- .PHONY: git-update
39
- git-update: ## Fast-forward all local branches that track a remote
40
- @bash $(NPM_DIRECTORY_TOOLS_PACKAGE_ROOT)/tools/scripts/git-update.sh
41
-
42
- .PHONY: git-cleanup
43
- git-cleanup: ## Remove local branches whose remote tracking branch no longer exists
44
- @bash $(NPM_DIRECTORY_TOOLS_PACKAGE_ROOT)/tools/scripts/git-cleanup.sh
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ echo ""
5
+ echo "==== Interactive Rebase ===="
6
+ echo ""
7
+
8
+ # Ensure on branch
9
+ current_branch=$(git symbolic-ref --short HEAD 2>/dev/null || true)
10
+
11
+ if [ -z "$current_branch" ]; then
12
+ echo "Detached HEAD. Abort."
13
+ exit 1
14
+ fi
15
+
16
+ # Check clean working tree
17
+ if ! git diff-index --quiet HEAD --; then
18
+ echo "Working tree dirty. Commit or stash first."
19
+ exit 1
20
+ fi
21
+
22
+ echo "Current branch : $current_branch"
23
+ echo ""
24
+
25
+ # Fetch latest remotes
26
+ git fetch --all --prune
27
+
28
+ # Build branch list
29
+ mapfile -t local_branches < <(git for-each-ref --format='%(refname:short)' refs/heads/)
30
+ mapfile -t remote_branches < <(git for-each-ref --format='%(refname:short)' refs/remotes/origin/)
31
+
32
+ echo "Select branch to rebase onto:"
33
+ echo ""
34
+
35
+ index=1
36
+
37
+ # Display local branches
38
+ echo "---- Local branches ----"
39
+ for branch in "${local_branches[@]}"; do
40
+ echo "[$index] $branch"
41
+ ((index++))
42
+ done
43
+
44
+ # Display remote branches
45
+ echo ""
46
+ echo "---- Remote branches (origin) ----"
47
+ for branch in "${remote_branches[@]}"; do
48
+ echo "[$index] $branch"
49
+ ((index++))
50
+ done
51
+
52
+ echo ""
53
+
54
+ # Read user choice
55
+ read -rp "Enter number: " choice
56
+
57
+ # Validate input
58
+ if ! [[ "$choice" =~ ^[0-9]+$ ]]; then
59
+ echo "Invalid input."
60
+ exit 1
61
+ fi
62
+
63
+ # Resolve selected branch
64
+ total_local=${#local_branches[@]}
65
+
66
+ if (( choice <= total_local )); then
67
+ target_branch="${local_branches[$((choice-1))]}"
68
+ else
69
+ target_branch="${remote_branches[$((choice-total_local-1))]}"
70
+ fi
71
+
72
+ # Prevent rebasing onto itself
73
+ if [ "$target_branch" = "$current_branch" ]; then
74
+ echo "Cannot rebase onto the same branch."
75
+ exit 1
76
+ fi
77
+
78
+ echo ""
79
+ echo "Rebasing '$current_branch' onto '$target_branch'..."
80
+ echo ""
81
+
82
+ # Rebase
83
+ if git rebase "$target_branch"; then
84
+ echo ""
85
+ echo "==== Rebase OK ===="
86
+ echo ""
87
+
88
+ read -rp "Force push now? [y/N] " -n 1
89
+ echo ""
90
+
91
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
92
+ git push --force-with-lease
93
+ echo "Push completed."
94
+ else
95
+ echo "Push skipped."
96
+ fi
97
+
98
+ else
99
+ echo ""
100
+ echo "==== Conflict ===="
101
+ echo "Resolve conflicts, then:"
102
+ echo " git rebase --continue"
103
+ echo ""
104
+ echo "Or abort:"
105
+ echo " git rebase --abort"
106
+ exit 1
107
+ fi