@zairakai/js-dev-tools 3.19.0 → 3.21.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.
- package/.editorconfig +6 -72
- package/.gitlab/ci/parts/base.yml +95 -0
- package/.gitlab/ci/parts/publish.yml +156 -0
- package/.gitlab/ci/parts/quality.yml +161 -0
- package/.gitlab/ci/parts/security.yml +40 -0
- package/.gitlab/ci/parts/updates.yml +60 -0
- package/.gitlab/ci/pipeline-js-app.yml +19 -38
- package/.gitlab/ci/pipeline-js-package.yml +23 -528
- package/README.md +51 -6
- package/config/.markdownlintignore +9 -1
- package/config/.prettierignore +8 -0
- package/config/.stylelintignore +7 -0
- package/config/eslint.config.js +7 -1
- package/config/knip.config.js +2 -2
- package/package.json +33 -29
- package/scripts/build.sh +28 -28
- package/scripts/ci-quality.sh +6 -6
- package/scripts/config.sh +164 -148
- package/scripts/doctor.sh +12 -12
- package/scripts/eslint-fix.sh +8 -8
- package/scripts/eslint.sh +15 -15
- package/scripts/install-bats.sh +143 -146
- package/scripts/install-hooks.sh +108 -111
- package/scripts/install-markdownlint.sh +4 -4
- package/scripts/install-shellcheck.sh +135 -138
- package/scripts/knip.sh +7 -7
- package/scripts/markdownlint.sh +38 -38
- package/scripts/outdated.sh +30 -29
- package/scripts/prettier-fix.sh +13 -13
- package/scripts/prettier.sh +13 -13
- package/scripts/setup-project.sh +691 -629
- package/scripts/stylelint-fix.sh +17 -17
- package/scripts/stylelint.sh +18 -18
- package/scripts/test.sh +13 -11
- package/scripts/typecheck.sh +11 -11
- package/scripts/update-dependencies.mjs +68 -68
- package/scripts/validate-shellcheck.sh +18 -18
- package/stubs/githooks/commit-msg +18 -18
- package/stubs/githooks/pre-commit +19 -19
- package/stubs/githooks/pre-push +18 -18
- package/stubs/githooks/prepare-commit-msg +6 -6
- package/stubs/gitlab-ci/gitlab-ci.yml.stub +1 -1
- package/stubs/governance/CONTRIBUTING.md.stub +5 -3
- package/stubs/quality/eslint.config.js.stub +1 -1
- package/stubs/quality/knip.config.js.stub +1 -1
- package/stubs/style/prettier.config.js.stub +3 -3
- package/stubs/style/stylelint.config.js.stub +1 -1
- package/stubs/testing/vitest.config.js.stub +1 -1
package/scripts/config.sh
CHANGED
|
@@ -3,47 +3,51 @@
|
|
|
3
3
|
|
|
4
4
|
set -euo pipefail
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# PATH DETECTION
|
|
7
|
+
# ================
|
|
7
8
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
9
|
|
|
9
10
|
# Vendor context: node_modules/@zairakai/js-dev-tools/scripts/
|
|
10
11
|
# Dev context: npm/dev-tools/scripts/
|
|
11
12
|
if [[ "$SCRIPT_DIR" =~ /node_modules/@zairakai/js-dev-tools/scripts ]]; then
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../../.." && pwd)"
|
|
14
|
+
DEV_TOOLS_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
14
15
|
else
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
17
|
+
DEV_TOOLS_ROOT="$PROJECT_ROOT"
|
|
17
18
|
fi
|
|
18
19
|
|
|
19
20
|
export PROJECT_ROOT
|
|
20
21
|
export DEV_TOOLS_ROOT
|
|
21
22
|
|
|
22
|
-
#
|
|
23
|
+
# PACKAGE MANAGER DETECTION
|
|
24
|
+
# ================
|
|
23
25
|
detect_package_manager() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
if [[ -f "$PROJECT_ROOT/yarn.lock" ]] || [[ -f "$PROJECT_ROOT/.yarnrc.yml" ]]; then
|
|
27
|
+
echo "yarn"
|
|
28
|
+
else
|
|
29
|
+
echo "npm"
|
|
30
|
+
fi
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
PM="$(detect_package_manager)"
|
|
32
34
|
export PM
|
|
33
35
|
|
|
34
|
-
#
|
|
36
|
+
# PROJECT TYPE DETECTION
|
|
37
|
+
# ================
|
|
35
38
|
detect_project_type() {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
if [[ -f "${PROJECT_ROOT}/artisan" ]] && [[ -d "${PROJECT_ROOT}/resources/js" ]]; then
|
|
40
|
+
echo "laravel-app"
|
|
41
|
+
return 0
|
|
42
|
+
fi
|
|
43
|
+
echo "npm-package"
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
PROJECT_TYPE="$(detect_project_type)"
|
|
44
47
|
export PROJECT_TYPE
|
|
45
48
|
|
|
46
|
-
#
|
|
49
|
+
# DOCKER AUTO-DISPATCH
|
|
50
|
+
# ================
|
|
47
51
|
# Tool scripts that need a real Node runtime (eslint, prettier, stylelint, knip,
|
|
48
52
|
# tsc/vue-tsc, vitest, npm outdated) call maybe_dockerize right after sourcing
|
|
49
53
|
# this file. When a docker-compose stack is already running for this project,
|
|
@@ -51,7 +55,7 @@ export PROJECT_TYPE
|
|
|
51
55
|
# depending on whatever Node happens to be on the host.
|
|
52
56
|
#
|
|
53
57
|
# Utility scripts (doctor.sh, install-hooks.sh, git-*.sh, setup-project.sh) never
|
|
54
|
-
# call this
|
|
58
|
+
# call this - they inspect or act on the host on purpose and must keep doing so.
|
|
55
59
|
#
|
|
56
60
|
# Opt out with DEV_TOOLS_NO_DOCKER=true. Override target service/mount with
|
|
57
61
|
# DEV_TOOLS_NODE_SERVICE / DEV_TOOLS_NODE_SERVICE_MOUNT if a project's compose
|
|
@@ -59,44 +63,45 @@ export PROJECT_TYPE
|
|
|
59
63
|
DEV_TOOLS_DOCKER_ENV_VARS=(CI COVERAGE)
|
|
60
64
|
|
|
61
65
|
maybe_dockerize() {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
# Already running inside a container — nothing to dispatch.
|
|
66
|
-
[[ -f /.dockerenv ]] && return 0
|
|
66
|
+
local script_path="$1"
|
|
67
|
+
shift
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
# Already running inside a container - nothing to dispatch.
|
|
70
|
+
[[ -f /.dockerenv ]] && return 0
|
|
70
71
|
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
# Explicit opt-out.
|
|
73
|
+
[[ "${DEV_TOOLS_NO_DOCKER:-false}" == "true" ]] && return 0
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
# CI runners execute inside a single job image, not this dev compose stack.
|
|
76
|
+
[[ "${CI:-false}" == "true" || "${GITLAB_CI:-false}" == "true" ]] && return 0
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
command -v docker >/dev/null 2>&1 || return 0
|
|
79
|
+
[[ -f "${PROJECT_ROOT}/docker-compose.yml" ]] || return 0
|
|
79
80
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if ! (cd "$PROJECT_ROOT" && docker compose ps --status running --services 2>/dev/null | grep -qx "$service"); then
|
|
83
|
-
return 0
|
|
84
|
-
fi
|
|
85
|
-
|
|
86
|
-
local rel_script="${script_path#"${PROJECT_ROOT}"/}"
|
|
87
|
-
local env_flags=()
|
|
88
|
-
local var
|
|
89
|
-
for var in "${DEV_TOOLS_DOCKER_ENV_VARS[@]}"; do
|
|
90
|
-
[[ -n "${!var:-}" ]] && env_flags+=(-e "$var")
|
|
91
|
-
done
|
|
81
|
+
local service="${DEV_TOOLS_NODE_SERVICE:-node}"
|
|
82
|
+
local mount="${DEV_TOOLS_NODE_SERVICE_MOUNT:-/app}"
|
|
92
83
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
84
|
+
# Only dispatch when the target service is already running - never start
|
|
85
|
+
# it as a side effect of running a quality check.
|
|
86
|
+
if ! (cd "$PROJECT_ROOT" && docker compose ps --status running --services 2>/dev/null | grep -qx "$service"); then
|
|
87
|
+
return 0
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
local rel_script="${script_path#"${PROJECT_ROOT}"/}"
|
|
91
|
+
local env_flags=()
|
|
92
|
+
local var
|
|
93
|
+
for var in "${DEV_TOOLS_DOCKER_ENV_VARS[@]}"; do
|
|
94
|
+
[[ -n "${!var:-}" ]] && env_flags+=(-e "$var")
|
|
95
|
+
done
|
|
96
|
+
|
|
97
|
+
log_step "Dispatching to '${service}' container..."
|
|
98
|
+
cd "$PROJECT_ROOT"
|
|
99
|
+
exec docker compose exec -T "${env_flags[@]}" "$service" bash "${mount}/${rel_script}" "$@"
|
|
96
100
|
}
|
|
97
101
|
export -f maybe_dockerize
|
|
98
102
|
|
|
99
|
-
#
|
|
103
|
+
# BINARY PATHS
|
|
104
|
+
# ================
|
|
100
105
|
BIN_DIR="${PROJECT_ROOT}/node_modules/.bin"
|
|
101
106
|
export ESLINT_BIN="${BIN_DIR}/eslint"
|
|
102
107
|
export PRETTIER_BIN="${BIN_DIR}/prettier"
|
|
@@ -104,41 +109,43 @@ export STYLELINT_BIN="${BIN_DIR}/stylelint"
|
|
|
104
109
|
export VITEST_BIN="${BIN_DIR}/vitest"
|
|
105
110
|
export MARKDOWNLINT_BIN="${BIN_DIR}/markdownlint-cli2"
|
|
106
111
|
|
|
107
|
-
#
|
|
112
|
+
# CONFIG RESOLUTION
|
|
113
|
+
# ================
|
|
108
114
|
# Cascade: project root → config/dev-tools/ → config/ → bundled default
|
|
109
115
|
resolve_config() {
|
|
110
|
-
|
|
116
|
+
local filename="$1"
|
|
111
117
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
# 1. Project root (full override)
|
|
119
|
+
if [[ -f "${PROJECT_ROOT}/${filename}" ]]; then
|
|
120
|
+
echo "${PROJECT_ROOT}/${filename}"
|
|
121
|
+
return 0
|
|
122
|
+
fi
|
|
117
123
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
124
|
+
# 2. config/dev-tools/ (published - can extend bundled default)
|
|
125
|
+
if [[ -f "${PROJECT_ROOT}/config/dev-tools/${filename}" ]]; then
|
|
126
|
+
echo "${PROJECT_ROOT}/config/dev-tools/${filename}"
|
|
127
|
+
return 0
|
|
128
|
+
fi
|
|
123
129
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
# 3. config/ (local usage or internal package structure)
|
|
131
|
+
if [[ -f "${PROJECT_ROOT}/config/${filename}" ]]; then
|
|
132
|
+
echo "${PROJECT_ROOT}/config/${filename}"
|
|
133
|
+
return 0
|
|
134
|
+
fi
|
|
129
135
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
136
|
+
# 4. Bundled default in dev-tools package (fallback when in node_modules)
|
|
137
|
+
if [[ -f "${DEV_TOOLS_ROOT}/config/${filename}" ]]; then
|
|
138
|
+
echo "${DEV_TOOLS_ROOT}/config/${filename}"
|
|
139
|
+
return 0
|
|
140
|
+
fi
|
|
135
141
|
|
|
136
|
-
|
|
142
|
+
echo ""
|
|
137
143
|
}
|
|
138
144
|
|
|
139
145
|
export -f resolve_config
|
|
140
146
|
|
|
141
|
-
#
|
|
147
|
+
# COLORS
|
|
148
|
+
# ================
|
|
142
149
|
export RED='\033[0;31m'
|
|
143
150
|
export GREEN='\033[0;32m'
|
|
144
151
|
export YELLOW='\033[1;33m'
|
|
@@ -147,7 +154,8 @@ export CYAN='\033[0;36m'
|
|
|
147
154
|
export MAGENTA='\033[0;35m'
|
|
148
155
|
export NC='\033[0m'
|
|
149
156
|
|
|
150
|
-
#
|
|
157
|
+
# LOGGING
|
|
158
|
+
# ================
|
|
151
159
|
log_info() { echo -e "${CYAN}ℹ ${NC}$*"; }
|
|
152
160
|
log_success() { echo -e "${GREEN}✅ ${NC}$*"; }
|
|
153
161
|
log_warning() { echo -e "${YELLOW}⚠️ ${NC}$*"; }
|
|
@@ -162,26 +170,27 @@ export -f log_error
|
|
|
162
170
|
export -f log_step
|
|
163
171
|
export -f log_header
|
|
164
172
|
|
|
165
|
-
#
|
|
173
|
+
# BINARY CHECKS
|
|
174
|
+
# ================
|
|
166
175
|
ensure_bin() {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
176
|
+
local bin="$1"
|
|
177
|
+
local name="${2:-$(basename "$bin")}"
|
|
178
|
+
if [[ ! -f "$bin" ]]; then
|
|
179
|
+
log_error "${name} not found in node_modules/.bin/"
|
|
180
|
+
log_error "Run: ${PM} install"
|
|
181
|
+
return 1
|
|
182
|
+
fi
|
|
174
183
|
}
|
|
175
184
|
export -f ensure_bin
|
|
176
185
|
|
|
177
186
|
ensure_bin_optional() {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
187
|
+
local bin="$1"
|
|
188
|
+
local name="${2:-$(basename "$bin")}"
|
|
189
|
+
if [[ ! -f "$bin" ]]; then
|
|
190
|
+
log_warning "${name} not installed - skipping (optional)"
|
|
191
|
+
return 1
|
|
192
|
+
fi
|
|
193
|
+
return 0
|
|
185
194
|
}
|
|
186
195
|
export -f ensure_bin_optional
|
|
187
196
|
|
|
@@ -190,24 +199,25 @@ export -f ensure_bin_optional
|
|
|
190
199
|
# Variadic: accepts one or more glob patterns, returns success if ANY matches.
|
|
191
200
|
# Callers needing a brace-alternation pattern (e.g. *.{js,ts,vue}) must leave that
|
|
192
201
|
# portion unquoted at the call site so bash's brace expansion splits it into
|
|
193
|
-
# separate arguments BEFORE this function ever sees it
|
|
202
|
+
# separate arguments BEFORE this function ever sees it - brace expansion only
|
|
194
203
|
# applies to unquoted literal text, never to the contents of a variable, so a
|
|
195
204
|
# pattern like "**/*.{js,ts}" passed as a single quoted string is matched
|
|
196
205
|
# literally (and never matches a real file) instead of being expanded.
|
|
197
206
|
has_files() {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
+
local pattern
|
|
208
|
+
for pattern in "$@"; do
|
|
209
|
+
# SC2086: unquoted intentionally - we need word splitting + glob expansion via nullglob+globstar
|
|
210
|
+
# shellcheck disable=SC2086
|
|
211
|
+
if ( shopt -s nullglob globstar; set -- $pattern; [ $# -gt 0 ] ); then
|
|
212
|
+
return 0
|
|
213
|
+
fi
|
|
214
|
+
done
|
|
215
|
+
return 1
|
|
207
216
|
}
|
|
208
217
|
export -f has_files
|
|
209
218
|
|
|
210
|
-
#
|
|
219
|
+
# ERROR COUNTER
|
|
220
|
+
# ================
|
|
211
221
|
ERROR_COUNT=0
|
|
212
222
|
export ERROR_COUNT
|
|
213
223
|
init_error_counter() { ERROR_COUNT=0; }
|
|
@@ -215,14 +225,14 @@ increment_error_counter() { ERROR_COUNT=$((ERROR_COUNT + 1)); }
|
|
|
215
225
|
get_error_count() { echo "$ERROR_COUNT"; }
|
|
216
226
|
|
|
217
227
|
exit_with_error_count() {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
228
|
+
local name="${1:-Checks}"
|
|
229
|
+
if [[ $ERROR_COUNT -eq 0 ]]; then
|
|
230
|
+
log_header "✅ All ${name} Passed"
|
|
231
|
+
return 0
|
|
232
|
+
else
|
|
233
|
+
log_header "❌ ${ERROR_COUNT} ${name} Failed"
|
|
234
|
+
return 1
|
|
235
|
+
fi
|
|
226
236
|
}
|
|
227
237
|
|
|
228
238
|
export -f init_error_counter
|
|
@@ -231,61 +241,66 @@ export -f get_error_count
|
|
|
231
241
|
export -f exit_with_error_count
|
|
232
242
|
|
|
233
243
|
run_check() {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
+
local name="$1"
|
|
245
|
+
local cmd="$2"
|
|
246
|
+
log_info "Running: ${name}"
|
|
247
|
+
if eval "$cmd"; then
|
|
248
|
+
log_success "${name} passed"
|
|
249
|
+
else
|
|
250
|
+
log_error "${name} failed"
|
|
251
|
+
increment_error_counter
|
|
252
|
+
return 1
|
|
253
|
+
fi
|
|
244
254
|
}
|
|
245
255
|
|
|
246
|
-
#
|
|
256
|
+
# BACKUP
|
|
257
|
+
# ================
|
|
247
258
|
BACKUP_DIR=""
|
|
248
259
|
backup_file() {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
+
local file="$1"
|
|
261
|
+
local base="${2:-${PROJECT_ROOT}/.dev-tools-backup}"
|
|
262
|
+
[[ ! -f "$file" || -L "$file" ]] && return 1
|
|
263
|
+
if [[ -z "$BACKUP_DIR" ]]; then
|
|
264
|
+
BACKUP_DIR="${base}/$(date +%Y%m%d-%H%M%S)"
|
|
265
|
+
mkdir -p "$BACKUP_DIR"
|
|
266
|
+
fi
|
|
267
|
+
local rel="${file#"${PROJECT_ROOT}"/}"
|
|
268
|
+
local dest="${BACKUP_DIR}/${rel}"
|
|
269
|
+
mkdir -p "$(dirname "$dest")"
|
|
270
|
+
cp "$file" "$dest" 2>/dev/null
|
|
260
271
|
}
|
|
261
272
|
|
|
262
|
-
#
|
|
273
|
+
# HELPERS
|
|
274
|
+
# ================
|
|
263
275
|
command_exists() { command -v "$1" >/dev/null 2>&1; }
|
|
264
276
|
ensure_dir() {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
277
|
+
if [[ ! -d "$1" ]]; then
|
|
278
|
+
mkdir -p "$1"
|
|
279
|
+
log_step "Created directory: $1"
|
|
280
|
+
fi
|
|
269
281
|
}
|
|
270
282
|
|
|
271
|
-
#
|
|
283
|
+
# FILE PROTECTION (SHA-256)
|
|
284
|
+
# ================
|
|
272
285
|
file_hash() {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
286
|
+
local file="$1"
|
|
287
|
+
if command_exists sha256sum; then
|
|
288
|
+
sha256sum "$file" | cut -d' ' -f1
|
|
289
|
+
elif command_exists shasum; then
|
|
290
|
+
shasum -a 256 "$file" | cut -d' ' -f1
|
|
291
|
+
else
|
|
292
|
+
echo ""
|
|
293
|
+
fi
|
|
281
294
|
}
|
|
282
295
|
|
|
283
|
-
#
|
|
296
|
+
# ENVIRONMENT DETECTION
|
|
297
|
+
# ================
|
|
284
298
|
export IS_CI="${CI:-false}"
|
|
285
299
|
export IS_GITLAB_CI="${GITLAB_CI:-false}"
|
|
286
300
|
export IS_GITHUB_ACTIONS="${GITHUB_ACTIONS:-false}"
|
|
287
301
|
|
|
288
|
-
#
|
|
302
|
+
# TOOL CONFIG RESOLUTION
|
|
303
|
+
# ================
|
|
289
304
|
# Pre-resolved at startup so individual scripts don't call resolve_config themselves.
|
|
290
305
|
ESLINT_CONFIG="$(resolve_config "eslint.config.js")"
|
|
291
306
|
export ESLINT_CONFIG
|
|
@@ -311,10 +326,11 @@ export KNIP_CONFIG
|
|
|
311
326
|
TSUP_CONFIG="$(resolve_config "tsup.config.js")"
|
|
312
327
|
export TSUP_CONFIG
|
|
313
328
|
|
|
314
|
-
#
|
|
329
|
+
# VALIDATION
|
|
330
|
+
# ================
|
|
315
331
|
cd "$PROJECT_ROOT"
|
|
316
332
|
|
|
317
333
|
if [[ ! -d "${PROJECT_ROOT}/node_modules" ]]; then
|
|
318
|
-
|
|
319
|
-
|
|
334
|
+
log_error "Dependencies not installed. Run: ${PM} install"
|
|
335
|
+
exit 1
|
|
320
336
|
fi
|
package/scripts/doctor.sh
CHANGED
|
@@ -32,24 +32,24 @@ echo -e "${CYAN}Available Tools:${NC}"
|
|
|
32
32
|
echo ""
|
|
33
33
|
echo -e "${CYAN}CI/CD Detection:${NC}"
|
|
34
34
|
if [[ "$IS_CI" == "true" ]]; then
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
echo " ✅ Running in CI environment"
|
|
36
|
+
[[ "$IS_GITLAB_CI" == "true" ]] && echo " → Platform: GitLab CI"
|
|
37
|
+
[[ "$IS_GITHUB_ACTIONS" == "true" ]] && echo " → Platform: GitHub Actions"
|
|
38
38
|
else
|
|
39
|
-
|
|
39
|
+
echo " ℹ️ Local development environment"
|
|
40
40
|
fi
|
|
41
41
|
|
|
42
42
|
echo ""
|
|
43
43
|
echo -e "${CYAN}Configuration Files (resolved):${NC}"
|
|
44
44
|
|
|
45
45
|
show_config() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
local label="$1"
|
|
47
|
+
local value="$2"
|
|
48
|
+
if [[ -n "$value" ]] && [[ -f "$value" ]]; then
|
|
49
|
+
echo " ✅ ${label}: ${value#"$PROJECT_ROOT"/}"
|
|
50
|
+
else
|
|
51
|
+
echo " ℹ️ ${label}: Using defaults (no config file)"
|
|
52
|
+
fi
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
show_config "ESLint" "$ESLINT_CONFIG"
|
|
@@ -66,7 +66,7 @@ show_config "tsup" "$TSUP_CONFIG"
|
|
|
66
66
|
echo ""
|
|
67
67
|
echo -e "${CYAN}Configuration Fallback Order (all tools):${NC}"
|
|
68
68
|
echo " 1. {file} (project root override)"
|
|
69
|
-
echo " 2. config/dev-tools/{file} (published
|
|
69
|
+
echo " 2. config/dev-tools/{file} (published - can extend bundled default)"
|
|
70
70
|
echo " 3. config/{file} (legacy or intermediate)"
|
|
71
71
|
echo " 4. node_modules/@zairakai/js-dev-tools/config/{file} (bundled default)"
|
|
72
72
|
|
package/scripts/eslint-fix.sh
CHANGED
|
@@ -11,18 +11,18 @@ log_header "ESLint Fix"
|
|
|
11
11
|
ensure_bin "$ESLINT_BIN" "eslint" || exit 1
|
|
12
12
|
|
|
13
13
|
if [[ -n "$ESLINT_CONFIG" ]]; then
|
|
14
|
-
|
|
14
|
+
log_step "Using configuration: ${ESLINT_CONFIG#"$PROJECT_ROOT"/}"
|
|
15
15
|
fi
|
|
16
16
|
|
|
17
17
|
if [[ "$PROJECT_TYPE" == "laravel-app" ]]; then
|
|
18
|
-
|
|
18
|
+
LINT_TARGET="${LINT_TARGET:-resources/js/}"
|
|
19
19
|
else
|
|
20
|
-
|
|
20
|
+
LINT_TARGET="${LINT_TARGET:-src/}"
|
|
21
21
|
fi
|
|
22
22
|
|
|
23
23
|
log_step "Fixing: $LINT_TARGET"
|
|
24
24
|
|
|
25
|
-
# Normalize away any trailing slash before appending our own
|
|
25
|
+
# Normalize away any trailing slash before appending our own - LINT_TARGET can be
|
|
26
26
|
# "resources/js/", "src/" or "." (via override) depending on project type, and
|
|
27
27
|
# concatenating "." directly with "**/*.ext" produces the invalid glob
|
|
28
28
|
# ".**/*.ext" (no match ever).
|
|
@@ -31,17 +31,17 @@ LINT_TARGET_GLOB_BASE="${LINT_TARGET%/}/"
|
|
|
31
31
|
# Skip gracefully if no matching files exist.
|
|
32
32
|
# The brace portion is intentionally left unquoted so bash's brace expansion
|
|
33
33
|
# splits it into separate arguments before has_files() sees it (see has_files
|
|
34
|
-
# doc comment in config.sh
|
|
34
|
+
# doc comment in config.sh - brace expansion never applies to quoted text or
|
|
35
35
|
# to the contents of a variable).
|
|
36
36
|
if ! has_files "${PROJECT_ROOT}/${LINT_TARGET_GLOB_BASE}"**/*.{js,ts,vue,jsx,tsx}; then
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
log_info "No JS/TS files found in ${LINT_TARGET} - skipping"
|
|
38
|
+
exit 0
|
|
39
39
|
fi
|
|
40
40
|
|
|
41
41
|
ESLINT_ARGS=(--fix)
|
|
42
42
|
|
|
43
43
|
if [[ -n "$ESLINT_CONFIG" ]] && [[ "$ESLINT_CONFIG" != "${PROJECT_ROOT}/eslint.config.js" ]]; then
|
|
44
|
-
|
|
44
|
+
ESLINT_ARGS+=(--config "$ESLINT_CONFIG")
|
|
45
45
|
fi
|
|
46
46
|
|
|
47
47
|
"$ESLINT_BIN" "${ESLINT_ARGS[@]}" "$LINT_TARGET"
|
package/scripts/eslint.sh
CHANGED
|
@@ -11,28 +11,28 @@ log_header "ESLint Check"
|
|
|
11
11
|
ensure_bin "$ESLINT_BIN" "eslint" || exit 1
|
|
12
12
|
|
|
13
13
|
if [[ -n "$ESLINT_CONFIG" ]]; then
|
|
14
|
-
|
|
14
|
+
log_step "Using configuration: ${ESLINT_CONFIG#"$PROJECT_ROOT"/}"
|
|
15
15
|
else
|
|
16
|
-
|
|
16
|
+
log_warning "No ESLint configuration found - using ESLint defaults"
|
|
17
17
|
fi
|
|
18
18
|
|
|
19
19
|
# Lint target depends on project type (overridable via env)
|
|
20
20
|
if [[ "$PROJECT_TYPE" == "laravel-app" ]]; then
|
|
21
|
-
|
|
21
|
+
LINT_TARGET="${LINT_TARGET:-resources/js/}"
|
|
22
22
|
else
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
fi
|
|
23
|
+
# Default to src/, but fallback to . if src/ doesn't exist
|
|
24
|
+
if [[ -z "${LINT_TARGET:-}" ]]; then
|
|
25
|
+
if [[ -d "${PROJECT_ROOT}/src" ]]; then
|
|
26
|
+
LINT_TARGET="src/"
|
|
27
|
+
else
|
|
28
|
+
LINT_TARGET="."
|
|
30
29
|
fi
|
|
30
|
+
fi
|
|
31
31
|
fi
|
|
32
32
|
|
|
33
33
|
log_step "Checking: $LINT_TARGET"
|
|
34
34
|
|
|
35
|
-
# Normalize away any trailing slash before appending our own
|
|
35
|
+
# Normalize away any trailing slash before appending our own - LINT_TARGET can be
|
|
36
36
|
# "resources/js/", "src/" or "." depending on project type, and concatenating "."
|
|
37
37
|
# directly with "**/*.ext" produces the invalid glob ".**/*.ext" (no match ever).
|
|
38
38
|
LINT_TARGET_GLOB_BASE="${LINT_TARGET%/}/"
|
|
@@ -40,18 +40,18 @@ LINT_TARGET_GLOB_BASE="${LINT_TARGET%/}/"
|
|
|
40
40
|
# Skip gracefully if no matching files exist.
|
|
41
41
|
# The brace portion is intentionally left unquoted so bash's brace expansion
|
|
42
42
|
# splits it into separate arguments before has_files() sees it (see has_files
|
|
43
|
-
# doc comment in config.sh
|
|
43
|
+
# doc comment in config.sh - brace expansion never applies to quoted text or
|
|
44
44
|
# to the contents of a variable).
|
|
45
45
|
if ! has_files "${PROJECT_ROOT}/${LINT_TARGET_GLOB_BASE}"**/*.{js,ts,vue,jsx,tsx}; then
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
log_info "No JS/TS files found in ${LINT_TARGET} - skipping"
|
|
47
|
+
exit 0
|
|
48
48
|
fi
|
|
49
49
|
|
|
50
50
|
ESLINT_ARGS=()
|
|
51
51
|
|
|
52
52
|
# Only pass --config when the config is not at project root (ESLint 9 auto-discovers root)
|
|
53
53
|
if [[ -n "$ESLINT_CONFIG" ]] && [[ "$ESLINT_CONFIG" != "${PROJECT_ROOT}/eslint.config.js" ]]; then
|
|
54
|
-
|
|
54
|
+
ESLINT_ARGS+=(--config "$ESLINT_CONFIG")
|
|
55
55
|
fi
|
|
56
56
|
|
|
57
57
|
"$ESLINT_BIN" "${ESLINT_ARGS[@]}" "$LINT_TARGET"
|