@zairakai/js-dev-tools 1.2.3 → 1.3.0

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.
@@ -29,7 +29,7 @@
29
29
  # variables:
30
30
  # CACHE_KEY: "dev-tools-v1"
31
31
  # NPM_PACKAGE_NAME: "@zairakai/js-dev-tools"
32
- # DEV_TOOLS_SCRIPTS: "scripts"
32
+ # JS_DEV_TOOLS_SCRIPTS: "scripts"
33
33
  # ================================
34
34
 
35
35
  include:
@@ -71,7 +71,7 @@ variables:
71
71
  # Paths to dev-tools scripts.
72
72
  # Consumer projects do NOT need to override these.
73
73
  # dev-tools itself overrides them in its own .gitlab-ci.yml.
74
- DEV_TOOLS_SCRIPTS: "node_modules/@zairakai/js-dev-tools/scripts"
74
+ JS_DEV_TOOLS_SCRIPTS: "node_modules/@zairakai/js-dev-tools/scripts"
75
75
 
76
76
  # ── NODE ──────────────────────────────────────────────────────────────────
77
77
  NODE_VERSION: "22"
@@ -163,7 +163,7 @@ js:validate:markdownlint:
163
163
  stage: validate
164
164
  image: ${NODE_IMAGE}
165
165
  script:
166
- - bash "$DEV_TOOLS_SCRIPTS/markdownlint.sh"
166
+ - bash "$JS_DEV_TOOLS_SCRIPTS/markdownlint.sh"
167
167
 
168
168
  js:validate:shellcheck:
169
169
  <<: *base_job
@@ -174,7 +174,7 @@ js:validate:shellcheck:
174
174
  script:
175
175
  - |
176
176
  if [[ -d scripts/ ]]; then
177
- bash "$DEV_TOOLS_SCRIPTS/validate-shellcheck.sh"
177
+ bash "$JS_DEV_TOOLS_SCRIPTS/validate-shellcheck.sh"
178
178
  else
179
179
  echo "No scripts/ directory found — skipping ShellCheck"
180
180
  fi
@@ -186,7 +186,7 @@ js:quality:lint:
186
186
  <<: *job_node
187
187
  stage: quality
188
188
  script:
189
- - bash "$DEV_TOOLS_SCRIPTS/eslint.sh"
189
+ - bash "$JS_DEV_TOOLS_SCRIPTS/eslint.sh"
190
190
  artifacts:
191
191
  reports:
192
192
  junit: build/reports/eslint.xml
@@ -199,13 +199,13 @@ js:quality:format:
199
199
  <<: *job_node
200
200
  stage: quality
201
201
  script:
202
- - bash "$DEV_TOOLS_SCRIPTS/prettier.sh"
202
+ - bash "$JS_DEV_TOOLS_SCRIPTS/prettier.sh"
203
203
 
204
204
  js:quality:stylelint:
205
205
  <<: *job_node
206
206
  stage: quality
207
207
  script:
208
- - bash "$DEV_TOOLS_SCRIPTS/stylelint.sh"
208
+ - bash "$JS_DEV_TOOLS_SCRIPTS/stylelint.sh"
209
209
 
210
210
  js:quality:typecheck:
211
211
  <<: *job_node
@@ -213,7 +213,7 @@ js:quality:typecheck:
213
213
  script:
214
214
  - |
215
215
  if [ -f tsconfig.json ] && [ -f node_modules/.bin/tsc ]; then
216
- bash "$DEV_TOOLS_SCRIPTS/typecheck.sh"
216
+ bash "$JS_DEV_TOOLS_SCRIPTS/typecheck.sh"
217
217
  else
218
218
  echo "TypeScript not configured — skipping (add tsconfig.json + typescript to devDependencies)"
219
219
  fi
@@ -222,7 +222,7 @@ js:quality:knip:
222
222
  <<: *job_node
223
223
  stage: quality
224
224
  script:
225
- - bash "$DEV_TOOLS_SCRIPTS/knip.sh"
225
+ - bash "$JS_DEV_TOOLS_SCRIPTS/knip.sh"
226
226
 
227
227
  js:quality:bats:
228
228
  <<: [*base_job, *cache_node]
@@ -244,7 +244,7 @@ js:quality:outdated:
244
244
  rules:
245
245
  - if: $CI_PIPELINE_SOURCE == "schedule"
246
246
  script:
247
- - bash "$DEV_TOOLS_SCRIPTS/outdated.sh"
247
+ - bash "$JS_DEV_TOOLS_SCRIPTS/outdated.sh"
248
248
  artifacts:
249
249
  paths:
250
250
  - build/reports/npm-outdated.json
@@ -259,7 +259,7 @@ js:test:
259
259
  stage: test
260
260
  image: ${NODE_TEST_IMAGE}
261
261
  script:
262
- - CI=true bash "$DEV_TOOLS_SCRIPTS/test.sh"
262
+ - CI=true bash "$JS_DEV_TOOLS_SCRIPTS/test.sh"
263
263
  coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
264
264
  artifacts:
265
265
  reports:
@@ -281,7 +281,7 @@ js:build:
281
281
  script:
282
282
  - |
283
283
  if { [ -f node_modules/.bin/tsup ] || [ -f node_modules/.bin/tsc ]; } && [ -f tsconfig.json ]; then
284
- bash "$DEV_TOOLS_SCRIPTS/build.sh"
284
+ bash "$JS_DEV_TOOLS_SCRIPTS/build.sh"
285
285
  else
286
286
  echo "No TypeScript builder configured — skipping (install tsup or typescript)"
287
287
  fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zairakai/js-dev-tools",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
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",
@@ -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