@zairakai/js-dev-tools 3.20.0 → 3.22.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.
Files changed (53) hide show
  1. package/.editorconfig +11 -72
  2. package/.gitlab/ci/parts/base.yml +95 -0
  3. package/.gitlab/ci/parts/publish.yml +156 -0
  4. package/.gitlab/ci/parts/quality.yml +161 -0
  5. package/.gitlab/ci/parts/security.yml +40 -0
  6. package/.gitlab/ci/parts/updates.yml +60 -0
  7. package/.gitlab/ci/pipeline-js-app.yml +19 -38
  8. package/.gitlab/ci/pipeline-js-package.yml +23 -528
  9. package/README.md +92 -11
  10. package/config/.markdownlintignore +8 -1
  11. package/config/.prettierignore +13 -0
  12. package/config/.stylelintignore +13 -3
  13. package/config/eslint.config.js +7 -1
  14. package/config/knip.config.js +7 -3
  15. package/config/stylelint.config.js +1 -0
  16. package/package.json +46 -29
  17. package/scripts/build.sh +28 -28
  18. package/scripts/ci-quality.sh +6 -6
  19. package/scripts/config.sh +164 -148
  20. package/scripts/doctor.sh +12 -12
  21. package/scripts/eslint-fix.sh +8 -8
  22. package/scripts/eslint.sh +15 -15
  23. package/scripts/install-bats.sh +143 -146
  24. package/scripts/install-hooks.sh +108 -111
  25. package/scripts/install-markdownlint.sh +4 -4
  26. package/scripts/install-shellcheck.sh +135 -138
  27. package/scripts/knip.sh +7 -7
  28. package/scripts/markdownlint.sh +38 -38
  29. package/scripts/outdated.sh +30 -29
  30. package/scripts/prettier-fix.sh +13 -13
  31. package/scripts/prettier.sh +13 -13
  32. package/scripts/setup-project.sh +691 -629
  33. package/scripts/stylelint-fix.sh +26 -19
  34. package/scripts/stylelint.sh +27 -20
  35. package/scripts/test.sh +13 -11
  36. package/scripts/typecheck.sh +11 -11
  37. package/scripts/update-dependencies.mjs +552 -181
  38. package/scripts/validate-shellcheck.sh +18 -18
  39. package/stubs/githooks/commit-msg +24 -21
  40. package/stubs/githooks/pre-commit +19 -19
  41. package/stubs/githooks/pre-push +18 -18
  42. package/stubs/githooks/prepare-commit-msg +6 -6
  43. package/stubs/gitlab-ci/gitlab-ci.yml.stub +1 -1
  44. package/stubs/governance/CONTRIBUTING.md.stub +5 -3
  45. package/stubs/quality/eslint.config.js.stub +1 -1
  46. package/stubs/quality/knip.config.js.stub +1 -1
  47. package/stubs/style/prettier.config.js.stub +3 -3
  48. package/stubs/style/stylelint.config.js.stub +8 -1
  49. package/stubs/testing/vitest.config.js.stub +1 -1
  50. package/tools/make/bats.mk +3 -3
  51. package/tools/make/core.mk +3 -3
  52. package/tools/make/quality.mk +2 -1
  53. package/tools/make/variables.mk +1 -1
@@ -22,43 +22,40 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
22
22
  # shellcheck disable=SC1091
23
23
  source "${SCRIPT_DIR}/config.sh"
24
24
 
25
- # ============================================================================
26
- # CI Mode Detection — delegates to IS_CI exported by config.sh
27
- # ============================================================================
25
+ # CI Mode Detection - delegates to IS_CI exported by config.sh
26
+ # ================
28
27
  CI_MODE="$IS_CI"
29
28
 
30
- # ============================================================================
31
29
  # Publishable configs registry
30
+ # ================
32
31
  # Format: [key]="source_relative_to_dev_tools|target_relative_to_project|group"
33
- # Note: gitlab-ci has a special handler (auto-detects project type) — not in this registry.
34
- # ============================================================================
32
+ # Note: gitlab-ci has a special handler (auto-detects project type) - not in this registry.
35
33
 
36
34
  declare -A PUBLISHABLE=(
37
- ["eslint"]="stubs/quality/eslint.config.js.stub|config/dev-tools/eslint.config.js|quality"
38
- ["knip"]="stubs/quality/knip.config.js.stub|config/dev-tools/knip.config.js|quality"
39
- ["prettier"]="stubs/style/prettier.config.js.stub|config/dev-tools/prettier.config.js|style"
40
- ["stylelint"]="stubs/style/stylelint.config.js.stub|config/dev-tools/stylelint.config.js|style"
41
- ["prettierignore"]="config/.prettierignore|config/dev-tools/.prettierignore|style"
42
- ["stylelintignore"]="config/.stylelintignore|config/dev-tools/.stylelintignore|style"
43
- ["markdownlint"]="config/.markdownlint.json|config/dev-tools/.markdownlint.json|style"
44
- ["markdownlintignore"]="config/.markdownlintignore|config/dev-tools/.markdownlintignore|style"
45
- ["vitest"]="stubs/testing/vitest.config.js.stub|config/dev-tools/vitest.config.js|testing"
46
- ["tsconfig"]="stubs/typescript/tsconfig.json.stub|tsconfig.json|typescript"
35
+ ["eslint"]="stubs/quality/eslint.config.js.stub|config/dev-tools/eslint.config.js|quality"
36
+ ["knip"]="stubs/quality/knip.config.js.stub|config/dev-tools/knip.config.js|quality"
37
+ ["prettier"]="stubs/style/prettier.config.js.stub|config/dev-tools/prettier.config.js|style"
38
+ ["stylelint"]="stubs/style/stylelint.config.js.stub|config/dev-tools/stylelint.config.js|style"
39
+ ["prettierignore"]="config/.prettierignore|config/dev-tools/.prettierignore|style"
40
+ ["stylelintignore"]="config/.stylelintignore|config/dev-tools/.stylelintignore|style"
41
+ ["markdownlint"]="config/.markdownlint.json|config/dev-tools/.markdownlint.json|style"
42
+ ["markdownlintignore"]="config/.markdownlintignore|config/dev-tools/.markdownlintignore|style"
43
+ ["vitest"]="stubs/testing/vitest.config.js.stub|config/dev-tools/vitest.config.js|testing"
44
+ ["tsconfig"]="stubs/typescript/tsconfig.json.stub|tsconfig.json|typescript"
47
45
  )
48
46
 
49
47
  declare -A PUBLISH_GROUPS=(
50
- ["quality"]="eslint knip"
51
- ["style"]="prettier stylelint prettierignore stylelintignore markdownlint markdownlintignore"
52
- ["testing"]="vitest"
53
- ["typescript"]="tsconfig"
54
- ["hooks"]="hooks"
55
- ["governance"]="governance"
56
- ["all"]="eslint knip prettier stylelint prettierignore stylelintignore markdownlint markdownlintignore vitest tsconfig hooks"
48
+ ["quality"]="eslint knip"
49
+ ["style"]="prettier stylelint prettierignore stylelintignore markdownlint markdownlintignore"
50
+ ["testing"]="vitest"
51
+ ["typescript"]="tsconfig"
52
+ ["hooks"]="hooks"
53
+ ["governance"]="governance"
54
+ ["all"]="eslint knip prettier stylelint prettierignore stylelintignore markdownlint markdownlintignore vitest tsconfig hooks"
57
55
  )
58
56
 
59
- # ============================================================================
60
57
  # Argument Parsing
61
- # ============================================================================
58
+ # ================
62
59
 
63
60
  FORCE_OVERWRITE=false
64
61
  SILENT_MODE=false
@@ -66,135 +63,132 @@ PUBLISH_TARGET=""
66
63
  WITH_MAKEFILE=false
67
64
 
68
65
  for arg in "$@"; do
69
- case "$arg" in
70
- --force|-f) FORCE_OVERWRITE=true ;;
71
- --silent|-s) SILENT_MODE=true ;;
72
- --with-makefile) WITH_MAKEFILE=true ;;
73
- --publish) PUBLISH_TARGET="all" ;;
74
- --publish=*) PUBLISH_TARGET="${arg#--publish=}" ;;
75
- --help|-h)
76
- echo ""
77
- echo "Usage: bash setup-project.sh [options]"
78
- echo ""
79
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
80
- echo " Options"
81
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
82
- echo " (no options) Normal setup (Makefile + .editorconfig + eslint baseline)"
83
- echo " --publish Publish ALL configs to config/dev-tools/"
84
- echo " --publish=<group> Publish a config group"
85
- echo " --publish=<key> Publish a specific config"
86
- echo " --with-makefile Generate or inject Makefile"
87
- echo " --force, -f Overwrite existing files"
88
- echo " --silent, -s Suppress output (for postinstall)"
89
- echo " --help, -h Show this help"
90
- echo ""
91
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
92
- echo " Groups (--publish=<group>)"
93
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
94
- echo " quality eslint"
95
- echo " style prettier, stylelint, markdownlint, .prettierignore, .stylelintignore, .markdownlintignore"
96
- echo " testing vitest"
97
- echo " typescript tsconfig"
98
- echo " all all configs (except gitlab-ci)"
99
- echo ""
100
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
101
- echo " Specific configs (--publish=<key>)"
102
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
103
- echo " eslint → config/dev-tools/eslint.config.js"
104
- echo " prettier → config/dev-tools/prettier.config.js"
105
- echo " stylelint → config/dev-tools/stylelint.config.js"
106
- echo " prettierignore → config/dev-tools/.prettierignore"
107
- echo " stylelintignore → config/dev-tools/.stylelintignore"
108
- echo " markdownlint → config/dev-tools/.markdownlint.json"
109
- echo " markdownlintignore → config/dev-tools/.markdownlintignore"
110
- echo " vitest → config/dev-tools/vitest.config.js"
111
- echo " tsconfig → tsconfig.json (extends bundled base)"
112
- echo " gitlab-ci → auto-detect: .gitlab-ci.yml or .gitlab/pipeline-js-app.yml"
113
- echo " governance → SECURITY.md, CONTRIBUTING.md, CODE_OF_CONDUCT.md"
114
- echo ""
115
- exit 0
116
- ;;
117
- *)
118
- echo "ERROR: Unknown option: $arg" >&2
119
- echo "Use --help for usage information" >&2
120
- exit 1
121
- ;;
122
- esac
66
+ case "$arg" in
67
+ --force|-f) FORCE_OVERWRITE=true ;;
68
+ --silent|-s) SILENT_MODE=true ;;
69
+ --with-makefile) WITH_MAKEFILE=true ;;
70
+ --publish) PUBLISH_TARGET="all" ;;
71
+ --publish=*) PUBLISH_TARGET="${arg#--publish=}" ;;
72
+ --help|-h)
73
+ echo ""
74
+ echo "Usage: bash setup-project.sh [options]"
75
+ echo ""
76
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
77
+ echo " Options"
78
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
79
+ echo " (no options) Normal setup (Makefile + .editorconfig + eslint baseline)"
80
+ echo " --publish Publish ALL configs to config/dev-tools/"
81
+ echo " --publish=<group> Publish a config group"
82
+ echo " --publish=<key> Publish a specific config"
83
+ echo " --with-makefile Generate or inject Makefile"
84
+ echo " --force, -f Overwrite existing files"
85
+ echo " --silent, -s Suppress output (for postinstall)"
86
+ echo " --help, -h Show this help"
87
+ echo ""
88
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
89
+ echo " Groups (--publish=<group>)"
90
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
91
+ echo " quality eslint"
92
+ echo " style prettier, stylelint, markdownlint, .prettierignore, .stylelintignore, .markdownlintignore"
93
+ echo " testing vitest"
94
+ echo " typescript tsconfig"
95
+ echo " all all configs (except gitlab-ci)"
96
+ echo ""
97
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
98
+ echo " Specific configs (--publish=<key>)"
99
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
100
+ echo " eslint → config/dev-tools/eslint.config.js"
101
+ echo " prettier → config/dev-tools/prettier.config.js"
102
+ echo " stylelint → config/dev-tools/stylelint.config.js"
103
+ echo " prettierignore → config/dev-tools/.prettierignore"
104
+ echo " stylelintignore → config/dev-tools/.stylelintignore"
105
+ echo " markdownlint → config/dev-tools/.markdownlint.json"
106
+ echo " markdownlintignore → config/dev-tools/.markdownlintignore"
107
+ echo " vitest → config/dev-tools/vitest.config.js"
108
+ echo " tsconfig → tsconfig.json (extends bundled base)"
109
+ echo " gitlab-ci → auto-detect: .gitlab-ci.yml or .gitlab/pipeline-js-app.yml"
110
+ echo " governance → SECURITY.md, CONTRIBUTING.md, CODE_OF_CONDUCT.md"
111
+ echo ""
112
+ exit 0
113
+ ;;
114
+ *)
115
+ echo "ERROR: Unknown option: $arg" >&2
116
+ echo "Use --help for usage information" >&2
117
+ exit 1
118
+ ;;
119
+ esac
123
120
  done
124
121
 
125
- # ============================================================================
126
122
  # Silent Mode Override
127
- # ============================================================================
123
+ # ================
128
124
 
129
125
  if [[ "$SILENT_MODE" == "true" ]]; then
130
- log_header() { :; }
131
- log_step() { :; }
132
- log_info() { :; }
133
- log_success() { :; }
134
- log_warning() { :; }
126
+ log_header() { :; }
127
+ log_step() { :; }
128
+ log_info() { :; }
129
+ log_success() { :; }
130
+ log_warning() { :; }
135
131
  fi
136
132
 
137
- # ============================================================================
138
133
  # Optional Dependencies Check
139
- # Runs after setup — shows informative messages even in silent mode (postinstall)
140
- # ============================================================================
134
+ # ================
135
+ # Runs after setup - shows informative messages even in silent mode (postinstall)
141
136
 
142
137
  check_optional_deps() {
143
- local -a missing=()
144
-
145
- # zod — runtime type validation (validates API responses / form inputs at runtime)
146
- [[ ! -d "${PROJECT_ROOT}/node_modules/zod" ]] \
147
- && missing+=("zod|Runtime type validation for JS/Vue (validates API responses, forms)|${PM} install zod")
148
-
149
- # typescript — enables make typecheck and make build
150
- [[ ! -d "${PROJECT_ROOT}/node_modules/typescript" ]] \
151
- && missing+=("typescript|TypeScript compiler — enables make typecheck + make build|${PM} install --save-dev typescript")
152
-
153
- # tsup — fast TS bundler (recommended for npm packages to publish)
154
- [[ ! -d "${PROJECT_ROOT}/node_modules/tsup" ]] \
155
- && missing+=("tsup|Fast TypeScript bundler for npm packages (esbuild-based)|${PM} install --save-dev tsup")
156
-
157
- # knip — unused exports, files and dependencies detector
158
- [[ ! -d "${PROJECT_ROOT}/node_modules/knip" ]] \
159
- && missing+=("knip|Unused exports and dependencies detector (make knip)|${PM} install --save-dev knip")
160
-
161
- [[ ${#missing[@]} -eq 0 ]] && return 0
162
-
163
- if [[ "$SILENT_MODE" == "true" ]]; then
164
- echo ""
165
- echo " ┌─ @zairakai/js-dev-tools — optional packages not installed ─┐"
166
- for entry in "${missing[@]}"; do
167
- local pkg="${entry%%|*}"
168
- local rest="${entry#*|}"
169
- local install_cmd="${rest#*|}"
170
- printf " │ %-12s %s\n" "${pkg}" "${install_cmd}"
171
- done
172
- echo " └─ Run: bash setup-project.sh (without --silent) for details ┘"
173
- echo ""
174
- return 0
175
- fi
138
+ local -a missing=()
139
+
140
+ # zod - runtime type validation (validates API responses / form inputs at runtime)
141
+ [[ ! -d "${PROJECT_ROOT}/node_modules/zod" ]] \
142
+ && missing+=("zod|Runtime type validation for JS/Vue (validates API responses, forms)|${PM} install zod")
143
+
144
+ # typescript - enables make typecheck and make build
145
+ [[ ! -d "${PROJECT_ROOT}/node_modules/typescript" ]] \
146
+ && missing+=("typescript|TypeScript compiler - enables make typecheck + make build|${PM} install --save-dev typescript")
147
+
148
+ # tsup - fast TS bundler (recommended for npm packages to publish)
149
+ [[ ! -d "${PROJECT_ROOT}/node_modules/tsup" ]] \
150
+ && missing+=("tsup|Fast TypeScript bundler for npm packages (esbuild-based)|${PM} install --save-dev tsup")
151
+
152
+ # knip - unused exports, files and dependencies detector
153
+ [[ ! -d "${PROJECT_ROOT}/node_modules/knip" ]] \
154
+ && missing+=("knip|Unused exports and dependencies detector (make knip)|${PM} install --save-dev knip")
155
+
156
+ [[ ${#missing[@]} -eq 0 ]] && return 0
176
157
 
158
+ if [[ "$SILENT_MODE" == "true" ]]; then
177
159
  echo ""
178
- echo -e "${YELLOW}┌──────────────────────────────────────────────────────┐${NC}"
179
- echo -e "${YELLOW}│${NC} ${YELLOW}Recommended Optional Packages${NC} ${YELLOW}│${NC}"
180
- echo -e "${YELLOW}├──────────────────────────────────────────────────────┤${NC}"
160
+ echo " ┌─ @zairakai/js-dev-tools - optional packages not installed ─┐"
181
161
  for entry in "${missing[@]}"; do
182
- local pkg="${entry%%|*}"
183
- local rest="${entry#*|}"
184
- local reason="${rest%%|*}"
185
- local install_cmd="${rest#*|}"
186
- echo -e "${YELLOW}│${NC} ${CYAN}${pkg}${NC}"
187
- echo -e "${YELLOW}│${NC} ${reason}"
188
- echo -e "${YELLOW}│${NC} ${GREEN}${install_cmd}${NC}"
189
- echo -e "${YELLOW}│${NC}"
162
+ local pkg="${entry%%|*}"
163
+ local rest="${entry#*|}"
164
+ local install_cmd="${rest#*|}"
165
+ printf " │ %-12s %s\n" "${pkg}" "${install_cmd}"
190
166
  done
191
- echo -e "${YELLOW}└──────────────────────────────────────────────────────┘${NC}"
167
+ echo " └─ Run: bash setup-project.sh (without --silent) for details ┘"
192
168
  echo ""
169
+ return 0
170
+ fi
171
+
172
+ echo ""
173
+ echo -e "${YELLOW}┌──────────────────────────────────────────────────────┐${NC}"
174
+ echo -e "${YELLOW}│${NC} ${YELLOW}Recommended Optional Packages${NC} ${YELLOW}│${NC}"
175
+ echo -e "${YELLOW}├──────────────────────────────────────────────────────┤${NC}"
176
+ for entry in "${missing[@]}"; do
177
+ local pkg="${entry%%|*}"
178
+ local rest="${entry#*|}"
179
+ local reason="${rest%%|*}"
180
+ local install_cmd="${rest#*|}"
181
+ echo -e "${YELLOW}│${NC} ${CYAN}${pkg}${NC}"
182
+ echo -e "${YELLOW}│${NC} ${reason}"
183
+ echo -e "${YELLOW}│${NC} ${GREEN}${install_cmd}${NC}"
184
+ echo -e "${YELLOW}│${NC}"
185
+ done
186
+ echo -e "${YELLOW}└──────────────────────────────────────────────────────┘${NC}"
187
+ echo ""
193
188
  }
194
189
 
195
- # ============================================================================
196
190
  # Result Tracking
197
- # ============================================================================
191
+ # ================
198
192
 
199
193
  declare -a CREATED_FILES=()
200
194
  declare -a SKIPPED_FILES=()
@@ -206,269 +200,264 @@ track_skipped() { SKIPPED_FILES+=("$1"); }
206
200
  track_backed_up() { BACKED_UP_FILES+=("$1"); }
207
201
  track_published() { PUBLISHED_FILES+=("$1"); }
208
202
 
209
- # ============================================================================
210
203
  # File Helpers
211
- # ============================================================================
204
+ # ================
212
205
 
213
206
  # Publish a config to config/dev-tools/ (user-facing, hash-protected)
214
207
  publish_file() {
215
- local source="$1"
216
- local target="$2"
217
- local name="$3"
218
-
219
- if [[ ! -f "$source" ]]; then
220
- log_warning "Source not found for ${name}: ${source#"$DEV_TOOLS_ROOT"/}"
221
- return 0
222
- fi
223
-
224
- if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" != "true" ]]; then
225
- local src_hash tgt_hash
226
- src_hash="$(file_hash "$source")"
227
- tgt_hash="$(file_hash "$target")"
228
-
229
- if [[ -n "$src_hash" ]] && [[ "$src_hash" == "$tgt_hash" ]]; then
230
- cp "$source" "$target"
231
- track_published "${name} → ${target#"$PROJECT_ROOT"/} (refreshed)"
232
- else
233
- track_skipped "$name"
234
- log_info "Skipping modified: ${name} (use --force to overwrite)"
235
- fi
236
- return 0
208
+ local source="$1"
209
+ local target="$2"
210
+ local name="$3"
211
+
212
+ if [[ ! -f "$source" ]]; then
213
+ log_warning "Source not found for ${name}: ${source#"$DEV_TOOLS_ROOT"/}"
214
+ return 0
215
+ fi
216
+
217
+ if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" != "true" ]]; then
218
+ local src_hash tgt_hash
219
+ src_hash="$(file_hash "$source")"
220
+ tgt_hash="$(file_hash "$target")"
221
+
222
+ if [[ -n "$src_hash" ]] && [[ "$src_hash" == "$tgt_hash" ]]; then
223
+ cp "$source" "$target"
224
+ track_published "${name} → ${target#"$PROJECT_ROOT"/} (refreshed)"
225
+ else
226
+ track_skipped "$name"
227
+ log_info "Skipping modified: ${name} (use --force to overwrite)"
237
228
  fi
229
+ return 0
230
+ fi
238
231
 
239
- if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" == "true" ]]; then
240
- if backup_file "$target" 2>/dev/null; then
241
- track_backed_up "$name"
242
- fi
232
+ if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" == "true" ]]; then
233
+ if backup_file "$target" 2>/dev/null; then
234
+ track_backed_up "$name"
243
235
  fi
236
+ fi
244
237
 
245
- mkdir -p "$(dirname "$target")"
246
- cp "$source" "$target"
247
- track_published "${name} → ${target#"$PROJECT_ROOT"/}"
248
- log_success "Published: ${name} → ${target#"$PROJECT_ROOT"/}"
238
+ mkdir -p "$(dirname "$target")"
239
+ cp "$source" "$target"
240
+ track_published "${name} → ${target#"$PROJECT_ROOT"/}"
241
+ log_success "Published: ${name} → ${target#"$PROJECT_ROOT"/}"
249
242
  }
250
243
 
251
244
  # Copy file for standard setup (skips if exists unless --force or CI)
252
245
  setup_file() {
253
- local source="$1"
254
- local target="$2"
255
- local name="$3"
256
-
257
- # In js-dev-tools itself the source and the target are the same file: removing the target would delete the source
258
- if [[ "$source" -ef "$target" ]]; then
259
- track_skipped "$name"
260
- return 0
246
+ local source="$1"
247
+ local target="$2"
248
+ local name="$3"
249
+
250
+ # In js-dev-tools itself the source and the target are the same file: removing the target would delete the source
251
+ if [[ "$source" -ef "$target" ]]; then
252
+ track_skipped "$name"
253
+ return 0
254
+ fi
255
+
256
+ if [[ "$CI_MODE" == "true" ]] || [[ "$FORCE_OVERWRITE" == "true" ]]; then
257
+ if [[ -f "$target" ]] && [[ ! -L "$target" ]] && [[ "$CI_MODE" != "true" ]]; then
258
+ if backup_file "$target" 2>/dev/null; then
259
+ track_backed_up "$name"
260
+ fi
261
261
  fi
262
-
263
- if [[ "$CI_MODE" == "true" ]] || [[ "$FORCE_OVERWRITE" == "true" ]]; then
264
- if [[ -f "$target" ]] && [[ ! -L "$target" ]] && [[ "$CI_MODE" != "true" ]]; then
265
- if backup_file "$target" 2>/dev/null; then
266
- track_backed_up "$name"
267
- fi
268
- fi
269
- rm -f "$target" 2>/dev/null || true
270
- mkdir -p "$(dirname "$target")"
271
- if cp "$source" "$target" 2>/dev/null; then
272
- track_created "$name"
273
- log_success "Created: $name"
274
- fi
275
- else
276
- if [[ -f "$target" ]] || [[ -L "$target" ]]; then
277
- track_skipped "$name"
278
- return 0
279
- fi
280
- mkdir -p "$(dirname "$target")"
281
- if cp "$source" "$target" 2>/dev/null; then
282
- track_created "$name"
283
- log_success "Created: $name"
284
- fi
262
+ rm -f "$target" 2>/dev/null || true
263
+ mkdir -p "$(dirname "$target")"
264
+ if cp "$source" "$target" 2>/dev/null; then
265
+ track_created "$name"
266
+ log_success "Created: $name"
267
+ fi
268
+ else
269
+ if [[ -f "$target" ]] || [[ -L "$target" ]]; then
270
+ track_skipped "$name"
271
+ return 0
285
272
  fi
273
+ mkdir -p "$(dirname "$target")"
274
+ if cp "$source" "$target" 2>/dev/null; then
275
+ track_created "$name"
276
+ log_success "Created: $name"
277
+ fi
278
+ fi
286
279
  }
287
280
 
288
- # ============================================================================
289
281
  # Governance Files Publisher
282
+ # ================
290
283
  # Publishes SECURITY.md, CONTRIBUTING.md, CODE_OF_CONDUCT.md to project root.
291
284
  # Replaces PACKAGE_GITLAB_ISSUES with the actual GitLab issues URL.
292
285
  # Hash-protected: skips files modified by the user (use --force to overwrite).
293
- # Not included in "all" — requires explicit opt-in (--publish=governance).
294
- # ============================================================================
286
+ # Not included in "all" - requires explicit opt-in (--publish=governance).
295
287
 
296
288
  publish_governance_file() {
297
- local source="$1"
298
- local target="$2"
299
- local name="$3"
300
- local issues_url="$4"
301
-
302
- if [[ ! -f "$source" ]]; then
303
- log_warning "Stub not found: stubs/governance/${name}"
304
- return 0
305
- fi
306
-
307
- # Process placeholders into a temp file for hash comparison and copy
308
- local processed
309
- processed="$(mktemp)"
310
- sed "s|PACKAGE_GITLAB_ISSUES|${issues_url}|g" "$source" > "$processed"
311
-
312
- if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" != "true" ]]; then
313
- local src_hash tgt_hash
314
- src_hash="$(file_hash "$processed")"
315
- tgt_hash="$(file_hash "$target")"
316
-
317
- if [[ -n "$src_hash" ]] && [[ "$src_hash" == "$tgt_hash" ]]; then
318
- cp "$processed" "$target"
319
- track_published "${name} (refreshed)"
320
- else
321
- track_skipped "$name"
322
- log_info "Skipping modified: ${name} (use --force to overwrite)"
323
- fi
324
- rm -f "$processed"
325
- return 0
326
- fi
327
-
328
- if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" == "true" ]]; then
329
- backup_file "$target" 2>/dev/null || true
330
- track_backed_up "$name"
289
+ local source="$1"
290
+ local target="$2"
291
+ local name="$3"
292
+ local issues_url="$4"
293
+
294
+ if [[ ! -f "$source" ]]; then
295
+ log_warning "Stub not found: stubs/governance/${name}"
296
+ return 0
297
+ fi
298
+
299
+ # Process placeholders into a temp file for hash comparison and copy
300
+ local processed
301
+ processed="$(mktemp)"
302
+ sed "s|PACKAGE_GITLAB_ISSUES|${issues_url}|g" "$source" > "$processed"
303
+
304
+ if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" != "true" ]]; then
305
+ local src_hash tgt_hash
306
+ src_hash="$(file_hash "$processed")"
307
+ tgt_hash="$(file_hash "$target")"
308
+
309
+ if [[ -n "$src_hash" ]] && [[ "$src_hash" == "$tgt_hash" ]]; then
310
+ cp "$processed" "$target"
311
+ track_published "${name} (refreshed)"
312
+ else
313
+ track_skipped "$name"
314
+ log_info "Skipping modified: ${name} (use --force to overwrite)"
331
315
  fi
332
-
333
- cp "$processed" "$target"
334
316
  rm -f "$processed"
335
- track_published "$name"
336
- log_success "Published: ${name}"
317
+ return 0
318
+ fi
319
+
320
+ if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" == "true" ]]; then
321
+ backup_file "$target" 2>/dev/null || true
322
+ track_backed_up "$name"
323
+ fi
324
+
325
+ cp "$processed" "$target"
326
+ rm -f "$processed"
327
+ track_published "$name"
328
+ log_success "Published: ${name}"
337
329
  }
338
330
 
339
331
  publish_governance_files() {
340
- local pkg_name
341
- pkg_name="$(node -e "try{const p=require('${PROJECT_ROOT}/package.json');console.log(p.name||'')}catch(e){}" 2>/dev/null || echo "")"
332
+ local pkg_name
333
+ pkg_name="$(node -e "try{const p=require('${PROJECT_ROOT}/package.json');console.log(p.name||'')}catch(e){}" 2>/dev/null || echo "")"
342
334
 
343
- local pkg_short="${pkg_name##*/}" # strip scope: @zairakai/js-dev-tools → dev-tools
344
- local issues_url="https://gitlab.com/zairakai/npm-packages/${pkg_short}/-/issues"
335
+ local pkg_short="${pkg_name##*/}" # strip scope: @zairakai/js-dev-tools → dev-tools
336
+ local issues_url="https://gitlab.com/zairakai/npm-packages/${pkg_short}/-/issues"
345
337
 
346
- local -a docs=("SECURITY.md" "CONTRIBUTING.md" "CODE_OF_CONDUCT.md")
338
+ local -a docs=("SECURITY.md" "CONTRIBUTING.md" "CODE_OF_CONDUCT.md")
347
339
 
348
- for filename in "${docs[@]}"; do
349
- publish_governance_file \
350
- "${DEV_TOOLS_ROOT}/stubs/governance/${filename}.stub" \
351
- "${PROJECT_ROOT}/${filename}" \
352
- "$filename" \
353
- "$issues_url"
354
- done
340
+ for filename in "${docs[@]}"; do
341
+ publish_governance_file \
342
+ "${DEV_TOOLS_ROOT}/stubs/governance/${filename}.stub" \
343
+ "${PROJECT_ROOT}/${filename}" \
344
+ "$filename" \
345
+ "$issues_url"
346
+ done
355
347
  }
356
348
 
357
- # ============================================================================
358
- # GitLab CI — Placeholder Replacement Helper
359
- # ============================================================================
349
+ # GitLab CI - Placeholder Replacement Helper
350
+ # ================
360
351
 
361
352
  # Extract package name and derive cache key from package.json
362
353
  get_package_info() {
363
- local pkg_name pkg_cache_key
354
+ local pkg_name pkg_cache_key
364
355
 
365
- pkg_name="$(node -e "try{const p=require('${PROJECT_ROOT}/package.json');console.log(p.name||'')}catch(e){}" 2>/dev/null || echo "")"
366
- pkg_cache_key="${pkg_name##*/}" # strip scope: @org/my-pkg → my-pkg
367
- pkg_cache_key="${pkg_cache_key}-v1"
356
+ pkg_name="$(node -e "try{const p=require('${PROJECT_ROOT}/package.json');console.log(p.name||'')}catch(e){}" 2>/dev/null || echo "")"
357
+ pkg_cache_key="${pkg_name##*/}" # strip scope: @org/my-pkg → my-pkg
358
+ pkg_cache_key="${pkg_cache_key}-v2"
368
359
 
369
- echo "${pkg_name}|${pkg_cache_key}"
360
+ echo "${pkg_name}|${pkg_cache_key}"
370
361
  }
371
362
 
372
363
  # Replace placeholders in a published GitLab CI file
373
364
  replace_gitlab_ci_placeholders() {
374
- local target="$1"
375
- local pkg_info
376
- pkg_info="$(get_package_info)"
365
+ local target="$1"
366
+ local pkg_info
367
+ pkg_info="$(get_package_info)"
377
368
 
378
- local pkg_name="${pkg_info%%|*}"
379
- local pkg_cache_key="${pkg_info#*|}"
369
+ local pkg_name="${pkg_info%%|*}"
370
+ local pkg_cache_key="${pkg_info#*|}"
380
371
 
381
- # Get current version of @zairakai/js-dev-tools
382
- local dev_tools_version
383
- dev_tools_version="$(node -e "try{const p=require('${DEV_TOOLS_ROOT}/package.json');console.log(p.version||'0.0.0')}catch(e){}" 2>/dev/null || echo "0.0.0")"
372
+ # Get current version of @zairakai/js-dev-tools
373
+ local dev_tools_version
374
+ dev_tools_version="$(node -e "try{const p=require('${DEV_TOOLS_ROOT}/package.json');console.log(p.version||'0.0.0')}catch(e){}" 2>/dev/null || echo "0.0.0")"
384
375
 
385
- if [[ -n "$pkg_name" ]]; then
386
- sed -i "s|PACKAGE_NPM_NAME|${pkg_name}|g" "$target"
387
- sed -i "s|PACKAGE_CACHE_KEY|${pkg_cache_key}|g" "$target"
388
- fi
376
+ if [[ -n "$pkg_name" ]]; then
377
+ sed -i "s|PACKAGE_NPM_NAME|${pkg_name}|g" "$target"
378
+ sed -i "s|PACKAGE_CACHE_KEY|${pkg_cache_key}|g" "$target"
379
+ fi
389
380
 
390
- if [[ -n "$dev_tools_version" ]]; then
391
- sed -i "s|ref: 0\.0\.0|ref: ${dev_tools_version}|g" "$target"
392
- fi
381
+ if [[ -n "$dev_tools_version" ]]; then
382
+ sed -i "s|ref: 0\.0\.0|ref: ${dev_tools_version}|g" "$target"
383
+ fi
393
384
  }
394
385
 
395
- # ============================================================================
396
- # GitLab CI — NPM Package (.gitlab-ci.yml)
397
- # ============================================================================
386
+ # GitLab CI - NPM Package (.gitlab-ci.yml)
387
+ # ================
398
388
 
399
389
  publish_gitlab_ci_npm() {
400
- local source="${DEV_TOOLS_ROOT}/stubs/gitlab-ci/gitlab-ci.yml.stub"
401
- local target="${PROJECT_ROOT}/.gitlab-ci.yml"
402
- local name="gitlab-ci"
390
+ local source="${DEV_TOOLS_ROOT}/stubs/gitlab-ci/gitlab-ci.yml.stub"
391
+ local target="${PROJECT_ROOT}/.gitlab-ci.yml"
392
+ local name="gitlab-ci"
403
393
 
404
- if [[ ! -f "$source" ]]; then
405
- log_warning "Stub not found: stubs/gitlab-ci/gitlab-ci.yml.stub"
406
- return 0
407
- fi
394
+ if [[ ! -f "$source" ]]; then
395
+ log_warning "Stub not found: stubs/gitlab-ci/gitlab-ci.yml.stub"
396
+ return 0
397
+ fi
408
398
 
409
- if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" != "true" ]]; then
410
- track_skipped "$name"
411
- log_info "Already exists: .gitlab-ci.yml (use --force to overwrite)"
412
- return 0
413
- fi
399
+ if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" != "true" ]]; then
400
+ track_skipped "$name"
401
+ log_info "Already exists: .gitlab-ci.yml (use --force to overwrite)"
402
+ return 0
403
+ fi
414
404
 
415
- if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" == "true" ]]; then
416
- if backup_file "$target" 2>/dev/null; then
417
- track_backed_up ".gitlab-ci.yml"
418
- fi
405
+ if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" == "true" ]]; then
406
+ if backup_file "$target" 2>/dev/null; then
407
+ track_backed_up ".gitlab-ci.yml"
419
408
  fi
409
+ fi
420
410
 
421
- cp "$source" "$target"
422
- replace_gitlab_ci_placeholders "$target"
411
+ cp "$source" "$target"
412
+ replace_gitlab_ci_placeholders "$target"
423
413
 
424
- track_published ".gitlab-ci.yml"
425
- log_success "Published: .gitlab-ci.yml"
426
- log_info "ref: 0.0.0 will be updated automatically on: ${PM} update @zairakai/js-dev-tools"
414
+ track_published ".gitlab-ci.yml"
415
+ log_success "Published: .gitlab-ci.yml"
416
+ log_info "ref: 0.0.0 will be updated automatically on: ${PM} update @zairakai/js-dev-tools"
427
417
  }
428
418
 
429
- # ============================================================================
430
- # GitLab CI — Laravel App (.gitlab/pipeline-js-app.yml + inject .gitlab-ci.yml)
431
- # ============================================================================
419
+ # GitLab CI - Laravel App (.gitlab/pipeline-js-app.yml + inject .gitlab-ci.yml)
420
+ # ================
432
421
 
433
422
  # Publish .gitlab/pipeline-js-app.yml (the JS pipeline fragment)
434
423
  publish_gitlab_pipeline_js() {
435
- local source="${DEV_TOOLS_ROOT}/stubs/gitlab-ci/gitlab-pipeline-js-app.yml.stub"
436
- local target="${PROJECT_ROOT}/.gitlab/pipeline-js-app.yml"
437
- local name="gitlab/pipeline-js-app.yml"
424
+ local source="${DEV_TOOLS_ROOT}/stubs/gitlab-ci/gitlab-pipeline-js-app.yml.stub"
425
+ local target="${PROJECT_ROOT}/.gitlab/pipeline-js-app.yml"
426
+ local name="gitlab/pipeline-js-app.yml"
438
427
 
439
- if [[ ! -f "$source" ]]; then
440
- log_warning "Stub not found: stubs/gitlab-ci/gitlab-pipeline-js-app.yml.stub"
441
- return 0
442
- fi
428
+ if [[ ! -f "$source" ]]; then
429
+ log_warning "Stub not found: stubs/gitlab-ci/gitlab-pipeline-js-app.yml.stub"
430
+ return 0
431
+ fi
443
432
 
444
- if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" != "true" ]]; then
445
- track_skipped "$name"
446
- log_info "Already exists: .gitlab/pipeline-js-app.yml (use --force to overwrite)"
447
- return 0
448
- fi
433
+ if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" != "true" ]]; then
434
+ track_skipped "$name"
435
+ log_info "Already exists: .gitlab/pipeline-js-app.yml (use --force to overwrite)"
436
+ return 0
437
+ fi
449
438
 
450
- if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" == "true" ]]; then
451
- if backup_file "$target" 2>/dev/null; then
452
- track_backed_up ".gitlab/pipeline-js-app.yml"
453
- fi
439
+ if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" == "true" ]]; then
440
+ if backup_file "$target" 2>/dev/null; then
441
+ track_backed_up ".gitlab/pipeline-js-app.yml"
454
442
  fi
443
+ fi
455
444
 
456
- mkdir -p "${PROJECT_ROOT}/.gitlab"
457
- cp "$source" "$target"
458
- replace_gitlab_ci_placeholders "$target"
445
+ mkdir -p "${PROJECT_ROOT}/.gitlab"
446
+ cp "$source" "$target"
447
+ replace_gitlab_ci_placeholders "$target"
459
448
 
460
- track_published ".gitlab/pipeline-js-app.yml"
461
- log_success "Published: .gitlab/pipeline-js-app.yml"
449
+ track_published ".gitlab/pipeline-js-app.yml"
450
+ log_success "Published: .gitlab/pipeline-js-app.yml"
462
451
  }
463
452
 
464
453
  # Inject the local pipeline-js-app.yml include into .gitlab-ci.yml (or create it)
465
454
  inject_or_create_gitlab_ci() {
466
- local target="${PROJECT_ROOT}/.gitlab-ci.yml"
467
- local marker="# @zairakai/js-dev-tools — JS"
455
+ local target="${PROJECT_ROOT}/.gitlab-ci.yml"
456
+ local marker="# @zairakai/js-dev-tools - JS"
468
457
 
469
- if [[ ! -f "$target" ]]; then
470
- # No .gitlab-ci.yml yet — create a minimal one
471
- cat > "$target" << 'GITLAB_EOF'
458
+ if [[ ! -f "$target" ]]; then
459
+ # No .gitlab-ci.yml yet - create a minimal one
460
+ cat > "$target" << 'GITLAB_EOF'
472
461
  # .gitlab-ci.yml
473
462
  # Generated by @zairakai/js-dev-tools setup-project.sh
474
463
  # To regenerate:
@@ -478,242 +467,312 @@ include:
478
467
  # JavaScript/frontend pipeline:
479
468
  - local: '.gitlab/pipeline-js-app.yml'
480
469
 
481
- # @zairakai/js-dev-tools — JS ────────────────────────────────────────────────────
470
+ # @zairakai/js-dev-tools - JS ────────────────────────────────────────────────────
482
471
  GITLAB_EOF
483
- track_created ".gitlab-ci.yml"
484
- log_success "Created: .gitlab-ci.yml (includes .gitlab/pipeline-js-app.yml)"
485
- return 0
486
- fi
472
+ track_created ".gitlab-ci.yml"
473
+ log_success "Created: .gitlab-ci.yml (includes .gitlab/pipeline-js-app.yml)"
474
+ return 0
475
+ fi
487
476
 
488
- # .gitlab-ci.yml exists — check if already injected
489
- if grep -qF "$marker" "$target" 2>/dev/null; then
490
- log_info ".gitlab-ci.yml already includes pipeline-js-app.yml — skipping"
491
- track_skipped ".gitlab-ci.yml (already injected)"
492
- return 0
493
- fi
477
+ # .gitlab-ci.yml exists - check if already injected
478
+ if grep -qF "$marker" "$target" 2>/dev/null; then
479
+ log_info ".gitlab-ci.yml already includes pipeline-js-app.yml - skipping"
480
+ track_skipped ".gitlab-ci.yml (already injected)"
481
+ return 0
482
+ fi
494
483
 
495
- log_info "Existing .gitlab-ci.yml detected — injecting pipeline-js-app.yml include"
484
+ log_info "Existing .gitlab-ci.yml detected - injecting pipeline-js-app.yml include"
496
485
 
497
- if [[ "$FORCE_OVERWRITE" == "true" ]]; then
498
- if backup_file "$target" 2>/dev/null; then
499
- track_backed_up ".gitlab-ci.yml"
500
- fi
486
+ if [[ "$FORCE_OVERWRITE" == "true" ]]; then
487
+ if backup_file "$target" 2>/dev/null; then
488
+ track_backed_up ".gitlab-ci.yml"
501
489
  fi
490
+ fi
502
491
 
503
- cat >> "$target" << 'INJECT_EOF'
492
+ cat >> "$target" << 'INJECT_EOF'
504
493
 
505
- # @zairakai/js-dev-tools — JS ────────────────────────────────────────────────────
494
+ # @zairakai/js-dev-tools - JS ────────────────────────────────────────────────────
506
495
  # Injected by: bash node_modules/@zairakai/js-dev-tools/scripts/setup-project.sh --publish=gitlab-ci
507
496
  # Adds JavaScript quality and test jobs.
508
497
  include:
509
498
  - local: '.gitlab/pipeline-js-app.yml'
510
499
  INJECT_EOF
511
500
 
512
- track_created ".gitlab-ci.yml (injected)"
513
- log_success "Injected pipeline-js-app.yml include into .gitlab-ci.yml"
501
+ track_created ".gitlab-ci.yml (injected)"
502
+ log_success "Injected pipeline-js-app.yml include into .gitlab-ci.yml"
514
503
  }
515
504
 
516
505
  publish_gitlab_ci_laravel() {
517
- publish_gitlab_pipeline_js
518
- inject_or_create_gitlab_ci
506
+ publish_gitlab_pipeline_js
507
+ inject_or_create_gitlab_ci
519
508
  }
520
509
 
521
- # ============================================================================
522
- # Git Hooks — Install into .git/hooks
523
- # ============================================================================
510
+ # Git Hooks - Install into .git/hooks
511
+ # ================
524
512
 
525
513
  publish_hooks() {
526
- local installer="${DEV_TOOLS_ROOT}/scripts/install-hooks.sh"
514
+ local installer="${DEV_TOOLS_ROOT}/scripts/install-hooks.sh"
527
515
 
528
- if [[ ! -f "$installer" ]]; then
529
- log_warning "Hooks installer not found: scripts/install-hooks.sh"
530
- return 0
531
- fi
516
+ if [[ ! -f "$installer" ]]; then
517
+ log_warning "Hooks installer not found: scripts/install-hooks.sh"
518
+ return 0
519
+ fi
532
520
 
533
- log_info "Git hooks detected → installing hooks via scripts/install-hooks.sh"
534
- bash "$installer" --install
521
+ log_info "Git hooks detected → installing hooks via scripts/install-hooks.sh"
522
+ bash "$installer" --install
535
523
  }
536
524
 
537
- # ============================================================================
538
525
  # Publish Logic
539
- # ============================================================================
526
+ # ================
540
527
 
541
528
  resolve_publish_keys() {
542
- local target="$1"
543
-
544
- # Special handlers — not in PUBLISHABLE
545
- if [[ "$target" == "gitlab-ci" || "$target" == "hooks" ]]; then
546
- echo "$target"
547
- return 0
548
- fi
549
-
550
- if [[ -n "${PUBLISH_GROUPS[$target]:-}" ]]; then
551
- echo "${PUBLISH_GROUPS[$target]}"
552
- return 0
553
- fi
554
-
555
- if [[ -n "${PUBLISHABLE[$target]:-}" ]]; then
556
- echo "$target"
557
- return 0
558
- fi
559
-
560
- log_error "Unknown publish target: '${target}'"
561
- echo "" >&2
562
- echo "Valid groups: ${!PUBLISH_GROUPS[*]}" >&2
563
- echo "Valid configs: ${!PUBLISHABLE[*]} gitlab-ci hooks" >&2
564
- echo "Run --help for details" >&2
565
- exit 1
529
+ local target="$1"
530
+
531
+ # Special handlers - not in PUBLISHABLE
532
+ if [[ "$target" == "gitlab-ci" || "$target" == "hooks" ]]; then
533
+ echo "$target"
534
+ return 0
535
+ fi
536
+
537
+ if [[ -n "${PUBLISH_GROUPS[$target]:-}" ]]; then
538
+ echo "${PUBLISH_GROUPS[$target]}"
539
+ return 0
540
+ fi
541
+
542
+ if [[ -n "${PUBLISHABLE[$target]:-}" ]]; then
543
+ echo "$target"
544
+ return 0
545
+ fi
546
+
547
+ log_error "Unknown publish target: '${target}'"
548
+ echo "" >&2
549
+ echo "Valid groups: ${!PUBLISH_GROUPS[*]}" >&2
550
+ echo "Valid configs: ${!PUBLISHABLE[*]} gitlab-ci hooks" >&2
551
+ echo "Run --help for details" >&2
552
+ exit 1
566
553
  }
567
554
 
568
555
  # Dispatch --publish=gitlab-ci based on detected project type.
569
556
  # When laravel-dev-tools is present, delegates to it so the fullstack stub
570
557
  # (single source of truth in laravel-dev-tools) is used automatically.
571
558
  publish_gitlab_ci() {
572
- if [[ "$PROJECT_TYPE" == "laravel-app" ]]; then
573
- local laravel_setup="${PROJECT_ROOT}/vendor/zairakai/laravel-dev-tools/scripts/setup-package.sh"
574
- if [[ -f "$laravel_setup" ]]; then
575
- log_info "laravel-dev-tools detected → delegating gitlab-ci publish (fullstack)"
576
- local extra_args=()
577
- [[ "$FORCE_OVERWRITE" == "true" ]] && extra_args+=("--force")
578
- [[ "$SILENT_MODE" == "true" ]] && extra_args+=("--silent")
579
- bash "$laravel_setup" --publish=gitlab-ci "${extra_args[@]}"
580
- return 0
581
- fi
582
- log_info "Project type: laravel-app → publishing .gitlab/pipeline-js-app.yml"
583
- publish_gitlab_ci_laravel
584
- else
585
- log_info "Project type: npm-package → publishing .gitlab-ci.yml"
586
- publish_gitlab_ci_npm
587
- fi
559
+ if [[ "$PROJECT_TYPE" == "laravel-app" ]]; then
560
+ local laravel_setup="${PROJECT_ROOT}/vendor/zairakai/laravel-dev-tools/scripts/setup-package.sh"
561
+ if [[ -f "$laravel_setup" ]]; then
562
+ log_info "laravel-dev-tools detected → delegating gitlab-ci publish (fullstack)"
563
+ local extra_args=()
564
+ [[ "$FORCE_OVERWRITE" == "true" ]] && extra_args+=("--force")
565
+ [[ "$SILENT_MODE" == "true" ]] && extra_args+=("--silent")
566
+ bash "$laravel_setup" --publish=gitlab-ci "${extra_args[@]}"
567
+ return 0
568
+ fi
569
+ log_info "Project type: laravel-app → publishing .gitlab/pipeline-js-app.yml"
570
+ publish_gitlab_ci_laravel
571
+ else
572
+ log_info "Project type: npm-package → publishing .gitlab-ci.yml"
573
+ publish_gitlab_ci_npm
574
+ fi
575
+ }
576
+
577
+ # Root bridges for IDEs and editor extensions
578
+ # ================
579
+ # Editor extensions look for the config of a tool at the root of the project, in
580
+ # the folder of the edited file and its parents, never in config/dev-tools/.
581
+ # A bridge is a one-line file that re-exports the published config. It holds no
582
+ # rule of its own, and is created only when the project has no config of that
583
+ # tool yet. The commands of the project (make, npm scripts) keep using
584
+ # config/dev-tools/ directly: the bridge is a convenience for the editor.
585
+
586
+ create_root_bridge() {
587
+ local key="$1"
588
+ local bridge="${key}.config.mjs"
589
+ local published="config/dev-tools/${key}.config.js"
590
+ local existing=false
591
+ local pattern
592
+
593
+ case "$key" in
594
+ eslint) pattern="eslint.config.js eslint.config.mjs eslint.config.cjs eslint.config.ts eslint.config.mts eslint.config.cts" ;;
595
+ prettier) pattern="prettier.config.js prettier.config.mjs prettier.config.cjs prettier.config.ts .prettierrc .prettierrc.json .prettierrc.yaml .prettierrc.yml .prettierrc.js .prettierrc.mjs .prettierrc.cjs" ;;
596
+ stylelint) pattern="stylelint.config.js stylelint.config.mjs stylelint.config.cjs .stylelintrc .stylelintrc.json .stylelintrc.yaml .stylelintrc.yml .stylelintrc.js .stylelintrc.mjs .stylelintrc.cjs" ;;
597
+ # A vite.config.* is read by Vitest when there is no vitest.config.*: the bridge would replace it
598
+ vitest) pattern="vitest.config.js vitest.config.mjs vitest.config.cjs vitest.config.ts vitest.workspace.js vitest.workspace.ts vite.config.js vite.config.mjs vite.config.cjs vite.config.ts" ;;
599
+ *) return 0 ;;
600
+ esac
601
+
602
+ local name
603
+ for name in $pattern; do
604
+ [[ -f "${PROJECT_ROOT}/${name}" ]] && existing=true
605
+ done
606
+
607
+ if [[ "$existing" == "true" ]] || [[ ! -f "${PROJECT_ROOT}/${published}" ]]; then
608
+ return 0
609
+ fi
610
+
611
+ printf "// Bridge for editor extensions: the rules live in %s\nexport { default } from './%s'\n" "$published" "$published" > "${PROJECT_ROOT}/${bridge}"
612
+ track_created "${bridge} (root - re-exports ${published})"
613
+ log_success "Created: ${bridge} → re-exports ${published}"
614
+ }
615
+
616
+ # Root copies of the ignore files
617
+ # ================
618
+ # An ignore file cannot extend another file, and npm does not publish symbolic
619
+ # links: the root gets a copy of the file published in config/dev-tools/. It is
620
+ # created only when the project has none, --force refreshes it.
621
+
622
+ copy_root_ignore() {
623
+ local key="$1"
624
+ local name
625
+
626
+ case "$key" in
627
+ prettierignore) name=".prettierignore" ;;
628
+ stylelintignore) name=".stylelintignore" ;;
629
+ markdownlintignore) name=".markdownlintignore" ;;
630
+ *) return 0 ;;
631
+ esac
632
+
633
+ local source="${PROJECT_ROOT}/config/dev-tools/${name}"
634
+ local target="${PROJECT_ROOT}/${name}"
635
+
636
+ [[ -f "$source" ]] || return 0
637
+ if [[ -f "$target" ]] && [[ "$FORCE_OVERWRITE" != "true" ]]; then
638
+ return 0
639
+ fi
640
+
641
+ cp "$source" "$target"
642
+ track_created "${name} (root - copy of config/dev-tools/${name})"
643
+ log_success "Created: ${name} → copy of config/dev-tools/${name}"
588
644
  }
589
645
 
590
646
  do_publish() {
591
- local -a keys
592
- read -ra keys <<< "$(resolve_publish_keys "$PUBLISH_TARGET")"
593
-
594
- log_header "Publishing Dev Tools Configs"
595
-
596
- for key in "${keys[@]}"; do
597
- # Dispatch special handler — project-type aware
598
- if [[ "$key" == "gitlab-ci" ]]; then
599
- publish_gitlab_ci
600
- continue
601
- fi
602
-
603
- # Dispatch special handler — git hooks
604
- if [[ "$key" == "hooks" ]]; then
605
- publish_hooks
606
- continue
607
- fi
608
-
609
- # Dispatch special handler — governance files
610
- if [[ "$key" == "governance" ]]; then
611
- publish_governance_files
612
- continue
613
- fi
614
-
615
- local entry="${PUBLISHABLE[$key]:-}"
616
- [[ -z "$entry" ]] && continue
617
-
618
- local source_rel="${entry%%|*}"
619
- local rest="${entry#*|}"
620
- local target_rel="${rest%%|*}"
621
-
622
- publish_file \
623
- "${DEV_TOOLS_ROOT}/${source_rel}" \
624
- "${PROJECT_ROOT}/${target_rel}" \
625
- "$key"
626
-
627
- # After publishing markdownlint config to config/dev-tools/, also create a root
628
- # .markdownlint.json that extends it — IDEs and editor extensions look at root.
629
- if [[ "$key" == "markdownlint" ]]; then
630
- local root_markdownlint="${PROJECT_ROOT}/.markdownlint.json"
631
- local root_content='{"extends":"./config/dev-tools/.markdownlint.json"}'
632
-
633
- if [[ ! -f "$root_markdownlint" ]]; then
634
- echo "$root_content" > "$root_markdownlint"
635
- track_created ".markdownlint.json (root — extends config/dev-tools/)"
636
- log_success "Created: .markdownlint.json → extends config/dev-tools/.markdownlint.json"
637
- fi
638
- fi
639
- done
647
+ local -a keys
648
+ read -ra keys <<< "$(resolve_publish_keys "$PUBLISH_TARGET")"
649
+
650
+ log_header "Publishing Dev Tools Configs"
651
+
652
+ for key in "${keys[@]}"; do
653
+ # Dispatch special handler - project-type aware
654
+ if [[ "$key" == "gitlab-ci" ]]; then
655
+ publish_gitlab_ci
656
+ continue
657
+ fi
658
+
659
+ # Dispatch special handler - git hooks
660
+ if [[ "$key" == "hooks" ]]; then
661
+ publish_hooks
662
+ continue
663
+ fi
664
+
665
+ # Dispatch special handler - governance files
666
+ if [[ "$key" == "governance" ]]; then
667
+ publish_governance_files
668
+ continue
669
+ fi
670
+
671
+ local entry="${PUBLISHABLE[$key]:-}"
672
+ [[ -z "$entry" ]] && continue
673
+
674
+ local source_rel="${entry%%|*}"
675
+ local rest="${entry#*|}"
676
+ local target_rel="${rest%%|*}"
677
+
678
+ publish_file \
679
+ "${DEV_TOOLS_ROOT}/${source_rel}" \
680
+ "${PROJECT_ROOT}/${target_rel}" \
681
+ "$key"
682
+
683
+ # Editor extensions look at the root: thin files for the tools whose config is a
684
+ # JavaScript file, and copies of the ignore files (they cannot extend a file).
685
+ create_root_bridge "$key"
686
+ copy_root_ignore "$key"
687
+
688
+ # After publishing markdownlint config to config/dev-tools/, also create a root
689
+ # .markdownlint.json that extends it - IDEs and editor extensions look at root.
690
+ if [[ "$key" == "markdownlint" ]]; then
691
+ local root_markdownlint="${PROJECT_ROOT}/.markdownlint.json"
692
+ local root_content='{"extends":"./config/dev-tools/.markdownlint.json"}'
693
+
694
+ if [[ ! -f "$root_markdownlint" ]]; then
695
+ echo "$root_content" > "$root_markdownlint"
696
+ track_created ".markdownlint.json (root - extends config/dev-tools/)"
697
+ log_success "Created: .markdownlint.json → extends config/dev-tools/.markdownlint.json"
698
+ fi
699
+ fi
700
+ done
640
701
  }
641
702
 
642
- # ============================================================================
643
- # GitLab CI — Ref Synchronizer
703
+ # GitLab CI - Ref Synchronizer
704
+ # ================
644
705
  # Mirrors GitlabCiSynchronizer.php from laravel-dev-tools.
645
706
  # Runs on every postinstall (npm install / npm update).
646
707
  # Reads the installed version of @zairakai/js-dev-tools and updates the
647
708
  # ref: in the project's .gitlab-ci.yml if it is out of sync.
648
- # ============================================================================
649
709
 
650
710
  sync_gitlab_ci_ref() {
651
- local gitlab_ci="${PROJECT_ROOT}/.gitlab-ci.yml"
652
- local gitlab_project="zairakai/npm-packages/js-dev-tools"
653
-
654
- [[ -f "$gitlab_ci" ]] || return 0
655
- grep -qF "$gitlab_project" "$gitlab_ci" || return 0
656
-
657
- # Resolve installed version from the package's own package.json
658
- local installed_version
659
- installed_version="$(node -e "try{const p=require('${DEV_TOOLS_ROOT}/package.json');console.log((p.version||'').replace(/^v/,''))}catch(e){}" 2>/dev/null || echo "")"
660
-
661
- [[ -n "$installed_version" ]] || return 0
662
-
663
- # Extract the current ref: value inside the js-dev-tools include block
664
- local in_block=false found_project=false current_ref=""
665
- while IFS= read -r line; do
666
- local trimmed="${line#"${line%%[![:space:]]*}"}" # ltrim
667
-
668
- if [[ "$trimmed" == "include:" ]]; then
669
- in_block=true
670
- continue
671
- fi
672
-
673
- if [[ "$in_block" == true ]]; then
674
- # Exit block on non-indented, non-list line
675
- if [[ -n "$trimmed" ]] && [[ "$line" != " "* ]] && [[ "$line" != "-"* ]]; then
676
- in_block=false
677
- found_project=false
678
- fi
679
-
680
- if [[ "$found_project" == false ]] && [[ "$trimmed" == *"$gitlab_project"* ]]; then
681
- found_project=true
682
- continue
683
- fi
684
-
685
- if [[ "$found_project" == true ]] && [[ "$trimmed" == ref:* ]]; then
686
- current_ref="${trimmed#ref:}"
687
- current_ref="${current_ref#"${current_ref%%[![:space:]]*}"}" # ltrim
688
- current_ref="${current_ref//\'/}"
689
- current_ref="${current_ref//\"/}"
690
- break
691
- fi
692
- fi
693
- done < "$gitlab_ci"
694
-
695
- [[ -n "$current_ref" ]] || return 0
696
- [[ "$current_ref" != "$installed_version" ]] || return 0
697
-
698
- # Auto-fix: replace the ref
699
- if sed -i "s|ref: ${current_ref}|ref: ${installed_version}|" "$gitlab_ci"; then
700
- echo " dev-tools: .gitlab-ci.yml ref ${current_ref} → ${installed_version}"
701
- else
702
- echo " dev-tools: WARNING — could not update .gitlab-ci.yml ref (manual fix needed)" >&2
703
- fi
711
+ local gitlab_ci="${PROJECT_ROOT}/.gitlab-ci.yml"
712
+ local gitlab_project="zairakai/npm-packages/js-dev-tools"
713
+
714
+ [[ -f "$gitlab_ci" ]] || return 0
715
+ grep -qF "$gitlab_project" "$gitlab_ci" || return 0
716
+
717
+ # Resolve installed version from the package's own package.json
718
+ local installed_version
719
+ installed_version="$(node -e "try{const p=require('${DEV_TOOLS_ROOT}/package.json');console.log((p.version||'').replace(/^v/,''))}catch(e){}" 2>/dev/null || echo "")"
720
+
721
+ [[ -n "$installed_version" ]] || return 0
722
+
723
+ # Extract the current ref: value inside the js-dev-tools include block
724
+ local in_block=false found_project=false current_ref=""
725
+ while IFS= read -r line; do
726
+ local trimmed="${line#"${line%%[![:space:]]*}"}" # ltrim
727
+
728
+ if [[ "$trimmed" == "include:" ]]; then
729
+ in_block=true
730
+ continue
731
+ fi
732
+
733
+ if [[ "$in_block" == true ]]; then
734
+ # Exit block on non-indented, non-list line
735
+ if [[ -n "$trimmed" ]] && [[ "$line" != " "* ]] && [[ "$line" != "-"* ]]; then
736
+ in_block=false
737
+ found_project=false
738
+ fi
739
+
740
+ if [[ "$found_project" == false ]] && [[ "$trimmed" == *"$gitlab_project"* ]]; then
741
+ found_project=true
742
+ continue
743
+ fi
744
+
745
+ if [[ "$found_project" == true ]] && [[ "$trimmed" == ref:* ]]; then
746
+ current_ref="${trimmed#ref:}"
747
+ current_ref="${current_ref#"${current_ref%%[![:space:]]*}"}" # ltrim
748
+ current_ref="${current_ref//\'/}"
749
+ current_ref="${current_ref//\"/}"
750
+ break
751
+ fi
752
+ fi
753
+ done < "$gitlab_ci"
754
+
755
+ [[ -n "$current_ref" ]] || return 0
756
+ [[ "$current_ref" != "$installed_version" ]] || return 0
757
+
758
+ # Auto-fix: replace the ref
759
+ if sed -i "s|ref: ${current_ref}|ref: ${installed_version}|" "$gitlab_ci"; then
760
+ echo " dev-tools: .gitlab-ci.yml ref ${current_ref} → ${installed_version}"
761
+ else
762
+ echo " dev-tools: WARNING - could not update .gitlab-ci.yml ref (manual fix needed)" >&2
763
+ fi
704
764
  }
705
765
 
706
- # ============================================================================
707
766
  # Makefile Setup
708
- # ============================================================================
767
+ # ================
709
768
 
710
769
  generate_makefile() {
711
- local target="${PROJECT_ROOT}/Makefile"
712
- local package_name
770
+ local target="${PROJECT_ROOT}/Makefile"
771
+ local package_name
713
772
 
714
- package_name="$(node -e "try{const p=require('${PROJECT_ROOT}/package.json');console.log(p.name||'')}catch(e){}" 2>/dev/null || echo "")"
773
+ package_name="$(node -e "try{const p=require('${PROJECT_ROOT}/package.json');console.log(p.name||'')}catch(e){}" 2>/dev/null || echo "")"
715
774
 
716
- cat > "$target" << 'MAKEFILE_EOF'
775
+ cat > "$target" << 'MAKEFILE_EOF'
717
776
  # Makefile
718
777
  # Generated by @zairakai/js-dev-tools setup-project.sh
719
778
  # Run `make help` to see available commands.
@@ -723,36 +782,37 @@ generate_makefile() {
723
782
 
724
783
  MAKEFILE_EOF
725
784
 
726
- if [[ -n "$package_name" ]]; then
727
- echo "NPM_DIRECTORY_TOOLS_PROJECT_NAME := \"${package_name}\"" >> "$target"
728
- echo "" >> "$target"
729
- fi
785
+ if [[ -n "$package_name" ]]; then
786
+ echo "NPM_DIRECTORY_TOOLS_PROJECT_NAME := \"${package_name}\"" >> "$target"
787
+ echo "" >> "$target"
788
+ fi
730
789
 
731
- cat >> "$target" << 'MAKEFILE_EOF'
790
+ cat >> "$target" << 'MAKEFILE_EOF'
732
791
  DEV_TOOLS_NPM := node_modules/@zairakai/js-dev-tools
733
792
 
734
793
  include $(DEV_TOOLS_NPM)/tools/make/core.mk
735
794
  MAKEFILE_EOF
736
795
 
737
- track_created "Makefile"
738
- log_success "Created: Makefile"
796
+ track_created "Makefile"
797
+ log_success "Created: Makefile"
739
798
  }
740
799
 
741
800
  inject_makefile() {
742
- local target="${PROJECT_ROOT}/Makefile"
743
- local marker="# @zairakai/js-dev-tools"
801
+ local target="${PROJECT_ROOT}/Makefile"
802
+ local marker="# @zairakai/js-dev-tools"
744
803
 
745
- if grep -qF "$marker" "$target" 2>/dev/null; then
746
- log_info "Makefile already includes @zairakai/js-dev-tools — skipping"
747
- track_skipped "Makefile (already injected)"
748
- return 0
749
- fi
804
+ if grep -qF "$marker" "$target" 2>/dev/null; then
805
+ log_info "Makefile already includes @zairakai/js-dev-tools - skipping"
806
+ track_skipped "Makefile (already injected)"
807
+ return 0
808
+ fi
750
809
 
751
- log_info "Existing Makefile detected — injecting @zairakai/js-dev-tools includes"
810
+ log_info "Existing Makefile detected - injecting @zairakai/js-dev-tools includes"
752
811
 
753
- cat >> "$target" << 'INJECT_EOF'
812
+ cat >> "$target" << 'INJECT_EOF'
754
813
 
755
- # ─── @zairakai/js-dev-tools ─────────────────────────────────────────────────────
814
+ # @zairakai/js-dev-tools
815
+ # ================
756
816
  # Injected by: bash node_modules/@zairakai/js-dev-tools/scripts/setup-project.sh --with-makefile
757
817
  # Provides: eslint, prettier, stylelint, markdownlint, shellcheck, typecheck, build, knip, test, quality, bats targets
758
818
  DEV_TOOLS_NPM := node_modules/@zairakai/js-dev-tools
@@ -768,135 +828,137 @@ DEV_TOOLS_NPM := node_modules/@zairakai/js-dev-tools
768
828
  -include $(DEV_TOOLS_NPM)/tools/make/bats.mk
769
829
  INJECT_EOF
770
830
 
771
- track_created "Makefile (injected)"
772
- log_success "Injected @zairakai/js-dev-tools targets into existing Makefile"
773
- log_info "Note: 'make help' will show JS targets alongside your existing targets"
831
+ track_created "Makefile (injected)"
832
+ log_success "Injected @zairakai/js-dev-tools targets into existing Makefile"
833
+ log_info "Note: 'make help' will show JS targets alongside your existing targets"
774
834
  }
775
835
 
776
836
  setup_makefile() {
777
- local target="${PROJECT_ROOT}/Makefile"
837
+ local target="${PROJECT_ROOT}/Makefile"
778
838
 
779
- if [[ -f "$target" ]]; then
780
- inject_makefile
781
- else
782
- generate_makefile
783
- fi
839
+ if [[ -f "$target" ]]; then
840
+ inject_makefile
841
+ else
842
+ generate_makefile
843
+ fi
784
844
  }
785
845
 
786
- # ============================================================================
787
846
  # Main Setup
788
- # ============================================================================
847
+ # ================
789
848
 
790
849
  setup_project() {
791
- [[ "$SILENT_MODE" != "true" ]] && {
792
- echo ""
793
- echo -e "${MAGENTA}📦 NPM Dev Tools Setup${NC}"
794
- echo -e "${CYAN}Type:${NC} ${PROJECT_TYPE} | ${CYAN}Package manager:${NC} ${PM}"
795
- echo ""
796
- }
797
-
798
- # ─── Publish mode ────────────────────────────────────────────────────────
799
- if [[ -n "$PUBLISH_TARGET" ]]; then
800
- do_publish
801
-
802
- [[ "$WITH_MAKEFILE" == "true" ]] && setup_makefile
803
-
804
- echo ""
805
- echo -e "${MAGENTA}┌────────────────────────────────────────┐${NC}"
806
- echo -e "${MAGENTA}│${NC} ${GREEN}Publish Complete${NC} ${MAGENTA}│${NC}"
807
- echo -e "${MAGENTA}├────────────────────────────────────────┤${NC}"
808
-
809
- for f in "${PUBLISHED_FILES[@]}"; do
810
- echo -e "${MAGENTA}│${NC} ${GREEN}✓${NC} ${f}"
811
- done
812
-
813
- if [[ ${#CREATED_FILES[@]} -gt 0 ]]; then
814
- for f in "${CREATED_FILES[@]}"; do
815
- echo -e "${MAGENTA}│${NC} ${GREEN}✓${NC} ${f}"
816
- done
817
- fi
818
-
819
- if [[ ${#SKIPPED_FILES[@]} -gt 0 ]]; then
820
- echo -e "${MAGENTA}│${NC} ${YELLOW}○ Skipped (modified):${NC} ${SKIPPED_FILES[*]}"
821
- echo -e "${MAGENTA}│${NC} ${YELLOW}→ Use --force to overwrite${NC}"
822
- fi
823
-
824
- if [[ ${#BACKED_UP_FILES[@]} -gt 0 ]]; then
825
- echo -e "${MAGENTA}│${NC} ${CYAN}↩ Backed up:${NC} ${BACKED_UP_FILES[*]}"
826
- echo -e "${MAGENTA}│${NC} ${CYAN}→ ${BACKUP_DIR}${NC}"
827
- fi
828
-
829
- echo -e "${MAGENTA}├────────────────────────────────────────┤${NC}"
830
- echo -e "${MAGENTA}│${NC} ${CYAN}Edit configs in:${NC} config/dev-tools/"
831
- echo -e "${MAGENTA}│${NC} ${CYAN}Help:${NC} bash setup-project.sh --help"
832
- echo -e "${MAGENTA}└────────────────────────────────────────┘${NC}"
833
- echo ""
834
- exit 0
835
- fi
836
-
837
- # ─── Normal setup ────────────────────────────────────────────────────────
838
-
839
- ensure_dir "${PROJECT_ROOT}/config/dev-tools"
840
-
841
- if [[ "$PROJECT_TYPE" == "laravel-app" ]] \
842
- && [[ -f "${PROJECT_ROOT}/vendor/zairakai/laravel-dev-tools/scripts/setup-package.sh" ]]; then
843
- log_info "Laravel app detected — delegating setup to laravel-dev-tools (full-stack)"
844
- extra_args=()
845
- [[ "$FORCE_OVERWRITE" == "true" ]] && extra_args+=("--force")
846
- [[ "$SILENT_MODE" == "true" ]] && extra_args+=("--silent")
847
- bash "${PROJECT_ROOT}/vendor/zairakai/laravel-dev-tools/scripts/setup-package.sh" --fullstack "${extra_args[@]}"
848
- else
849
- if [[ "$WITH_MAKEFILE" == "true" ]] || [[ ! -f "${PROJECT_ROOT}/Makefile" ]]; then
850
- setup_makefile
851
- fi
852
-
853
- # .editorconfig (always copied - needed by IDEs)
854
- setup_file "${DEV_TOOLS_ROOT}/.editorconfig" "${PROJECT_ROOT}/.editorconfig" ".editorconfig"
855
-
856
- # ESLint baseline (published config only)
857
- setup_file "${DEV_TOOLS_ROOT}/stubs/quality/eslint.config.js.stub" \
858
- "${PROJECT_ROOT}/config/dev-tools/eslint.config.js" \
859
- "config/dev-tools/eslint.config.js"
860
- fi
850
+ [[ "$SILENT_MODE" != "true" ]] && {
851
+ echo ""
852
+ echo -e "${MAGENTA}📦 NPM Dev Tools Setup${NC}"
853
+ echo -e "${CYAN}Type:${NC} ${PROJECT_TYPE} | ${CYAN}Package manager:${NC} ${PM}"
854
+ echo ""
855
+ }
861
856
 
862
- # ─── GitLab CI ref sync ───────────────────────────────────────────────────
863
- sync_gitlab_ci_ref
857
+ # Publish mode
858
+ # ================
859
+ if [[ -n "$PUBLISH_TARGET" ]]; then
860
+ do_publish
864
861
 
865
- # ─── Summary ─────────────────────────────────────────────────────────────
866
- if [[ "$SILENT_MODE" == "true" ]]; then
867
- check_optional_deps
868
- [[ ${#CREATED_FILES[@]} -eq 0 ]] && exit 0
869
- fi
862
+ [[ "$WITH_MAKEFILE" == "true" ]] && setup_makefile
870
863
 
871
864
  echo ""
872
865
  echo -e "${MAGENTA}┌────────────────────────────────────────┐${NC}"
873
- echo -e "${MAGENTA}│${NC} ${GREEN}Setup Complete${NC} ${MAGENTA}│${NC}"
866
+ echo -e "${MAGENTA}│${NC} ${GREEN}Publish Complete${NC} ${MAGENTA}│${NC}"
874
867
  echo -e "${MAGENTA}├────────────────────────────────────────┤${NC}"
875
868
 
869
+ for f in "${PUBLISHED_FILES[@]}"; do
870
+ echo -e "${MAGENTA}│${NC} ${GREEN}✓${NC} ${f}"
871
+ done
872
+
876
873
  if [[ ${#CREATED_FILES[@]} -gt 0 ]]; then
877
- echo -e "${MAGENTA}│${NC} ${GREEN}✓ Created:${NC} ${CREATED_FILES[*]}"
874
+ for f in "${CREATED_FILES[@]}"; do
875
+ echo -e "${MAGENTA}│${NC} ${GREEN}✓${NC} ${f}"
876
+ done
878
877
  fi
879
878
 
880
879
  if [[ ${#SKIPPED_FILES[@]} -gt 0 ]]; then
881
- echo -e "${MAGENTA}│${NC} ${YELLOW}○ Skipped:${NC} ${SKIPPED_FILES[*]}"
880
+ echo -e "${MAGENTA}│${NC} ${YELLOW}○ Skipped (modified):${NC} ${SKIPPED_FILES[*]}"
881
+ echo -e "${MAGENTA}│${NC} ${YELLOW}→ Use --force to overwrite${NC}"
882
882
  fi
883
883
 
884
884
  if [[ ${#BACKED_UP_FILES[@]} -gt 0 ]]; then
885
- echo -e "${MAGENTA}│${NC} ${CYAN}↩ Backed up:${NC} ${BACKED_UP_FILES[*]}"
886
- echo -e "${MAGENTA}│${NC} ${CYAN}→ ${BACKUP_DIR}${NC}"
885
+ echo -e "${MAGENTA}│${NC} ${CYAN}↩ Backed up:${NC} ${BACKED_UP_FILES[*]}"
886
+ echo -e "${MAGENTA}│${NC} ${CYAN}→ ${BACKUP_DIR}${NC}"
887
887
  fi
888
888
 
889
889
  echo -e "${MAGENTA}├────────────────────────────────────────┤${NC}"
890
- echo -e "${MAGENTA}│${NC} ${CYAN}Type:${NC} ${PROJECT_TYPE} | ${CYAN}PM:${NC} ${PM}"
891
- echo -e "${MAGENTA}│${NC} ${CYAN}Publish configs:${NC} bash setup-project.sh --publish"
892
- echo -e "${MAGENTA}│${NC} ${CYAN}Run:${NC} make help"
890
+ echo -e "${MAGENTA}│${NC} ${CYAN}Edit configs in:${NC} config/dev-tools/"
891
+ echo -e "${MAGENTA}│${NC} ${CYAN}Help:${NC} bash setup-project.sh --help"
893
892
  echo -e "${MAGENTA}└────────────────────────────────────────┘${NC}"
894
-
893
+ echo ""
894
+ exit 0
895
+ fi
896
+
897
+ # Normal setup
898
+ # ================
899
+
900
+ ensure_dir "${PROJECT_ROOT}/config/dev-tools"
901
+
902
+ if [[ "$PROJECT_TYPE" == "laravel-app" ]] \
903
+ && [[ -f "${PROJECT_ROOT}/vendor/zairakai/laravel-dev-tools/scripts/setup-package.sh" ]]; then
904
+ log_info "Laravel app detected - delegating setup to laravel-dev-tools (full-stack)"
905
+ extra_args=()
906
+ [[ "$FORCE_OVERWRITE" == "true" ]] && extra_args+=("--force")
907
+ [[ "$SILENT_MODE" == "true" ]] && extra_args+=("--silent")
908
+ bash "${PROJECT_ROOT}/vendor/zairakai/laravel-dev-tools/scripts/setup-package.sh" --fullstack "${extra_args[@]}"
909
+ else
910
+ if [[ "$WITH_MAKEFILE" == "true" ]] || [[ ! -f "${PROJECT_ROOT}/Makefile" ]]; then
911
+ setup_makefile
912
+ fi
913
+
914
+ # .editorconfig (always copied - needed by IDEs)
915
+ setup_file "${DEV_TOOLS_ROOT}/.editorconfig" "${PROJECT_ROOT}/.editorconfig" ".editorconfig"
916
+
917
+ # ESLint baseline (published config only)
918
+ setup_file "${DEV_TOOLS_ROOT}/stubs/quality/eslint.config.js.stub" \
919
+ "${PROJECT_ROOT}/config/dev-tools/eslint.config.js" \
920
+ "config/dev-tools/eslint.config.js"
921
+ fi
922
+
923
+ # GitLab CI ref sync
924
+ # ================
925
+ sync_gitlab_ci_ref
926
+
927
+ # Summary
928
+ # ================
929
+ if [[ "$SILENT_MODE" == "true" ]]; then
895
930
  check_optional_deps
931
+ [[ ${#CREATED_FILES[@]} -eq 0 ]] && exit 0
932
+ fi
933
+
934
+ echo ""
935
+ echo -e "${MAGENTA}┌────────────────────────────────────────┐${NC}"
936
+ echo -e "${MAGENTA}│${NC} ${GREEN}Setup Complete${NC} ${MAGENTA}│${NC}"
937
+ echo -e "${MAGENTA}├────────────────────────────────────────┤${NC}"
938
+
939
+ if [[ ${#CREATED_FILES[@]} -gt 0 ]]; then
940
+ echo -e "${MAGENTA}│${NC} ${GREEN}✓ Created:${NC} ${CREATED_FILES[*]}"
941
+ fi
942
+
943
+ if [[ ${#SKIPPED_FILES[@]} -gt 0 ]]; then
944
+ echo -e "${MAGENTA}│${NC} ${YELLOW}○ Skipped:${NC} ${SKIPPED_FILES[*]}"
945
+ fi
946
+
947
+ if [[ ${#BACKED_UP_FILES[@]} -gt 0 ]]; then
948
+ echo -e "${MAGENTA}│${NC} ${CYAN}↩ Backed up:${NC} ${BACKED_UP_FILES[*]}"
949
+ echo -e "${MAGENTA}│${NC} ${CYAN}→ ${BACKUP_DIR}${NC}"
950
+ fi
951
+
952
+ echo -e "${MAGENTA}├────────────────────────────────────────┤${NC}"
953
+ echo -e "${MAGENTA}│${NC} ${CYAN}Type:${NC} ${PROJECT_TYPE} | ${CYAN}PM:${NC} ${PM}"
954
+ echo -e "${MAGENTA}│${NC} ${CYAN}Publish configs:${NC} bash setup-project.sh --publish"
955
+ echo -e "${MAGENTA}│${NC} ${CYAN}Run:${NC} make help"
956
+ echo -e "${MAGENTA}└────────────────────────────────────────┘${NC}"
957
+
958
+ check_optional_deps
896
959
  }
897
960
 
898
- # ============================================================================
899
961
  # Execute
900
- # ============================================================================
962
+ # ================
901
963
 
902
964
  setup_project