@zairakai/js-dev-tools 3.20.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 +28 -25
- 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/setup-project.sh
CHANGED
|
@@ -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
|
-
#
|
|
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)
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
#
|
|
140
|
-
#
|
|
134
|
+
# ================
|
|
135
|
+
# Runs after setup - shows informative messages even in silent mode (postinstall)
|
|
141
136
|
|
|
142
137
|
check_optional_deps() {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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 -
|
|
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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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 -
|
|
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
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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
|
-
|
|
240
|
-
|
|
241
|
-
|
|
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
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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"
|
|
294
|
-
# ============================================================================
|
|
286
|
+
# Not included in "all" - requires explicit opt-in (--publish=governance).
|
|
295
287
|
|
|
296
288
|
publish_governance_file() {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
-
|
|
336
|
-
|
|
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
|
-
|
|
341
|
-
|
|
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
|
-
|
|
344
|
-
|
|
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
|
-
|
|
338
|
+
local -a docs=("SECURITY.md" "CONTRIBUTING.md" "CODE_OF_CONDUCT.md")
|
|
347
339
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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
|
-
#
|
|
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
|
-
|
|
354
|
+
local pkg_name pkg_cache_key
|
|
364
355
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
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
|
-
|
|
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
|
-
|
|
375
|
-
|
|
376
|
-
|
|
365
|
+
local target="$1"
|
|
366
|
+
local pkg_info
|
|
367
|
+
pkg_info="$(get_package_info)"
|
|
377
368
|
|
|
378
|
-
|
|
379
|
-
|
|
369
|
+
local pkg_name="${pkg_info%%|*}"
|
|
370
|
+
local pkg_cache_key="${pkg_info#*|}"
|
|
380
371
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
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
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
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
|
-
|
|
391
|
-
|
|
392
|
-
|
|
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
|
-
#
|
|
397
|
-
# ============================================================================
|
|
386
|
+
# GitLab CI - NPM Package (.gitlab-ci.yml)
|
|
387
|
+
# ================
|
|
398
388
|
|
|
399
389
|
publish_gitlab_ci_npm() {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
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
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
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
|
-
|
|
416
|
-
|
|
417
|
-
|
|
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
|
-
|
|
422
|
-
|
|
411
|
+
cp "$source" "$target"
|
|
412
|
+
replace_gitlab_ci_placeholders "$target"
|
|
423
413
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
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
|
-
#
|
|
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
|
-
|
|
436
|
-
|
|
437
|
-
|
|
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
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
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
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
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
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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
|
-
|
|
457
|
-
|
|
458
|
-
|
|
445
|
+
mkdir -p "${PROJECT_ROOT}/.gitlab"
|
|
446
|
+
cp "$source" "$target"
|
|
447
|
+
replace_gitlab_ci_placeholders "$target"
|
|
459
448
|
|
|
460
|
-
|
|
461
|
-
|
|
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
|
-
|
|
467
|
-
|
|
455
|
+
local target="${PROJECT_ROOT}/.gitlab-ci.yml"
|
|
456
|
+
local marker="# @zairakai/js-dev-tools - JS"
|
|
468
457
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
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
|
|
470
|
+
# @zairakai/js-dev-tools - JS ────────────────────────────────────────────────────
|
|
482
471
|
GITLAB_EOF
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
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
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
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
|
-
|
|
484
|
+
log_info "Existing .gitlab-ci.yml detected - injecting pipeline-js-app.yml include"
|
|
496
485
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
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
|
-
|
|
492
|
+
cat >> "$target" << 'INJECT_EOF'
|
|
504
493
|
|
|
505
|
-
# @zairakai/js-dev-tools
|
|
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
|
-
|
|
513
|
-
|
|
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
|
-
|
|
518
|
-
|
|
506
|
+
publish_gitlab_pipeline_js
|
|
507
|
+
inject_or_create_gitlab_ci
|
|
519
508
|
}
|
|
520
509
|
|
|
521
|
-
#
|
|
522
|
-
#
|
|
523
|
-
# ============================================================================
|
|
510
|
+
# Git Hooks - Install into .git/hooks
|
|
511
|
+
# ================
|
|
524
512
|
|
|
525
513
|
publish_hooks() {
|
|
526
|
-
|
|
514
|
+
local installer="${DEV_TOOLS_ROOT}/scripts/install-hooks.sh"
|
|
527
515
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
516
|
+
if [[ ! -f "$installer" ]]; then
|
|
517
|
+
log_warning "Hooks installer not found: scripts/install-hooks.sh"
|
|
518
|
+
return 0
|
|
519
|
+
fi
|
|
532
520
|
|
|
533
|
-
|
|
534
|
-
|
|
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
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
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
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
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
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
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
|
-
#
|
|
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
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
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
|
-
|
|
712
|
-
|
|
770
|
+
local target="${PROJECT_ROOT}/Makefile"
|
|
771
|
+
local package_name
|
|
713
772
|
|
|
714
|
-
|
|
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
|
-
|
|
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
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
785
|
+
if [[ -n "$package_name" ]]; then
|
|
786
|
+
echo "NPM_DIRECTORY_TOOLS_PROJECT_NAME := \"${package_name}\"" >> "$target"
|
|
787
|
+
echo "" >> "$target"
|
|
788
|
+
fi
|
|
730
789
|
|
|
731
|
-
|
|
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
|
-
|
|
738
|
-
|
|
796
|
+
track_created "Makefile"
|
|
797
|
+
log_success "Created: Makefile"
|
|
739
798
|
}
|
|
740
799
|
|
|
741
800
|
inject_makefile() {
|
|
742
|
-
|
|
743
|
-
|
|
801
|
+
local target="${PROJECT_ROOT}/Makefile"
|
|
802
|
+
local marker="# @zairakai/js-dev-tools"
|
|
744
803
|
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
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
|
-
|
|
810
|
+
log_info "Existing Makefile detected - injecting @zairakai/js-dev-tools includes"
|
|
752
811
|
|
|
753
|
-
|
|
812
|
+
cat >> "$target" << 'INJECT_EOF'
|
|
754
813
|
|
|
755
|
-
#
|
|
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
|
-
|
|
772
|
-
|
|
773
|
-
|
|
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
|
-
|
|
837
|
+
local target="${PROJECT_ROOT}/Makefile"
|
|
778
838
|
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
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
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
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
|
-
|
|
863
|
-
|
|
857
|
+
# Publish mode
|
|
858
|
+
# ================
|
|
859
|
+
if [[ -n "$PUBLISH_TARGET" ]]; then
|
|
860
|
+
do_publish
|
|
864
861
|
|
|
865
|
-
|
|
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}
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
886
|
-
|
|
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}
|
|
891
|
-
echo -e "${MAGENTA}│${NC} ${CYAN}
|
|
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
|