@zairakai/js-dev-tools 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab/ci/pipeline-js-package.yml +3 -0
- package/package.json +1 -1
- package/scripts/build.sh +17 -12
- package/scripts/setup-project.sh +67 -0
|
@@ -41,6 +41,7 @@ include:
|
|
|
41
41
|
workflow:
|
|
42
42
|
rules:
|
|
43
43
|
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/
|
|
44
|
+
- if: $CI_PIPELINE_SOURCE == "schedule"
|
|
44
45
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_MERGE_REQUEST_ID
|
|
45
46
|
- if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop"
|
|
46
47
|
- if: $CI_COMMIT_REF_NAME =~ /^feature\// || $CI_COMMIT_REF_NAME =~ /^fix\// || $CI_COMMIT_REF_NAME =~ /^hotfix\//
|
|
@@ -240,6 +241,8 @@ js:quality:bats:
|
|
|
240
241
|
js:quality:outdated:
|
|
241
242
|
<<: *job_node
|
|
242
243
|
stage: quality
|
|
244
|
+
rules:
|
|
245
|
+
- if: $CI_PIPELINE_SOURCE == "schedule"
|
|
243
246
|
script:
|
|
244
247
|
- bash "$DEV_TOOLS_SCRIPTS/outdated.sh"
|
|
245
248
|
artifacts:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zairakai/js-dev-tools",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "The unified and centralized development toolkit for JavaScript/TypeScript projects - ESLint, Prettier, Stylelint, Knip, Vitest, Git Hooks, and GitLab CI pipeline templates",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dev-tools",
|
package/scripts/build.sh
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
#
|
|
3
|
-
#
|
|
4
|
-
# Compiles TypeScript to JavaScript for distribution.
|
|
5
|
-
#
|
|
3
|
+
# Build script for npm packages.
|
|
6
4
|
# Supports (in order of preference):
|
|
7
|
-
# 1.
|
|
8
|
-
# 2.
|
|
5
|
+
# 1. Vite — detected via vite.config.ts / vite.config.js (runs npm run build)
|
|
6
|
+
# 2. tsup — fast, esbuild-based bundler (recommended for pure TS packages)
|
|
7
|
+
# 3. tsc — official TypeScript compiler
|
|
9
8
|
#
|
|
10
9
|
# Usage:
|
|
11
10
|
# bash scripts/build.sh
|
|
12
11
|
#
|
|
13
12
|
# Recommendation:
|
|
14
|
-
# Use
|
|
15
|
-
# Use
|
|
13
|
+
# Use Vite for Vue component libraries (vite.config.ts present)
|
|
14
|
+
# Use tsup for pure TypeScript packages: npm install --save-dev tsup
|
|
15
|
+
# Use tsc for simple transpilation: npm install --save-dev typescript
|
|
16
16
|
#
|
|
17
17
|
|
|
18
18
|
set -euo pipefail
|
|
@@ -24,9 +24,14 @@ source "${SCRIPT_DIR}/config.sh"
|
|
|
24
24
|
TSUP_BIN="${BIN_DIR}/tsup"
|
|
25
25
|
TSC_BIN="${BIN_DIR}/tsc"
|
|
26
26
|
|
|
27
|
-
log_header "
|
|
27
|
+
log_header "Build"
|
|
28
|
+
|
|
29
|
+
if [[ -f "${PROJECT_ROOT}/vite.config.ts" ]] || [[ -f "${PROJECT_ROOT}/vite.config.js" ]]; then
|
|
30
|
+
log_info "Builder: Vite (vite.config detected — running npm run build)"
|
|
31
|
+
npm run build
|
|
32
|
+
log_success "Build complete — output in dist/"
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
elif [[ -f "$TSUP_BIN" ]]; then
|
|
30
35
|
log_info "Builder: tsup (fast, esbuild-based)"
|
|
31
36
|
if [[ -n "$TSUP_CONFIG" ]]; then
|
|
32
37
|
"$TSUP_BIN" --config "$TSUP_CONFIG"
|
|
@@ -50,9 +55,9 @@ elif [[ -f "$TSC_BIN" ]]; then
|
|
|
50
55
|
log_success "Build complete"
|
|
51
56
|
|
|
52
57
|
else
|
|
53
|
-
log_error "No
|
|
58
|
+
log_error "No builder found. Expected one of: vite.config.ts, tsup, tsc"
|
|
54
59
|
log_info "Install one of:"
|
|
55
|
-
log_info " npm install --save-dev tsup (recommended for
|
|
56
|
-
log_info " npm install --save-dev typescript (for
|
|
60
|
+
log_info " npm install --save-dev tsup (recommended for pure TS packages)"
|
|
61
|
+
log_info " npm install --save-dev typescript (for simple transpilation)"
|
|
57
62
|
exit 1
|
|
58
63
|
fi
|
package/scripts/setup-project.sh
CHANGED
|
@@ -633,6 +633,70 @@ do_publish() {
|
|
|
633
633
|
done
|
|
634
634
|
}
|
|
635
635
|
|
|
636
|
+
# ============================================================================
|
|
637
|
+
# GitLab CI — Ref Synchronizer
|
|
638
|
+
# Mirrors GitlabCiSynchronizer.php from laravel-dev-tools.
|
|
639
|
+
# Runs on every postinstall (npm install / npm update).
|
|
640
|
+
# Reads the installed version of @zairakai/js-dev-tools and updates the
|
|
641
|
+
# ref: in the project's .gitlab-ci.yml if it is out of sync.
|
|
642
|
+
# ============================================================================
|
|
643
|
+
|
|
644
|
+
sync_gitlab_ci_ref() {
|
|
645
|
+
local gitlab_ci="${PROJECT_ROOT}/.gitlab-ci.yml"
|
|
646
|
+
local gitlab_project="zairakai/npm-packages/js-dev-tools"
|
|
647
|
+
|
|
648
|
+
[[ -f "$gitlab_ci" ]] || return 0
|
|
649
|
+
grep -qF "$gitlab_project" "$gitlab_ci" || return 0
|
|
650
|
+
|
|
651
|
+
# Resolve installed version from the package's own package.json
|
|
652
|
+
local installed_version
|
|
653
|
+
installed_version="$(node -e "try{const p=require('${DEV_TOOLS_ROOT}/package.json');console.log('v'+(p.version||'').replace(/^v/,''))}catch(e){}" 2>/dev/null || echo "")"
|
|
654
|
+
|
|
655
|
+
[[ -n "$installed_version" ]] || return 0
|
|
656
|
+
|
|
657
|
+
# Extract the current ref: value inside the js-dev-tools include block
|
|
658
|
+
local in_block=false found_project=false current_ref=""
|
|
659
|
+
while IFS= read -r line; do
|
|
660
|
+
local trimmed="${line#"${line%%[![:space:]]*}"}" # ltrim
|
|
661
|
+
|
|
662
|
+
if [[ "$trimmed" == "include:" ]]; then
|
|
663
|
+
in_block=true
|
|
664
|
+
continue
|
|
665
|
+
fi
|
|
666
|
+
|
|
667
|
+
if [[ "$in_block" == true ]]; then
|
|
668
|
+
# Exit block on non-indented, non-list line
|
|
669
|
+
if [[ -n "$trimmed" ]] && [[ "$line" != " "* ]] && [[ "$line" != "-"* ]]; then
|
|
670
|
+
in_block=false
|
|
671
|
+
found_project=false
|
|
672
|
+
fi
|
|
673
|
+
|
|
674
|
+
if [[ "$found_project" == false ]] && [[ "$trimmed" == *"$gitlab_project"* ]]; then
|
|
675
|
+
found_project=true
|
|
676
|
+
continue
|
|
677
|
+
fi
|
|
678
|
+
|
|
679
|
+
if [[ "$found_project" == true ]] && [[ "$trimmed" == ref:* ]]; then
|
|
680
|
+
current_ref="${trimmed#ref:}"
|
|
681
|
+
current_ref="${current_ref#"${current_ref%%[![:space:]]*}"}" # ltrim
|
|
682
|
+
current_ref="${current_ref//\'/}"
|
|
683
|
+
current_ref="${current_ref//\"/}"
|
|
684
|
+
break
|
|
685
|
+
fi
|
|
686
|
+
fi
|
|
687
|
+
done < "$gitlab_ci"
|
|
688
|
+
|
|
689
|
+
[[ -n "$current_ref" ]] || return 0
|
|
690
|
+
[[ "$current_ref" != "$installed_version" ]] || return 0
|
|
691
|
+
|
|
692
|
+
# Auto-fix: replace the ref
|
|
693
|
+
if sed -i "s|ref: ${current_ref}|ref: ${installed_version}|" "$gitlab_ci"; then
|
|
694
|
+
echo " dev-tools: .gitlab-ci.yml ref ${current_ref} → ${installed_version}"
|
|
695
|
+
else
|
|
696
|
+
echo " dev-tools: WARNING — could not update .gitlab-ci.yml ref (manual fix needed)" >&2
|
|
697
|
+
fi
|
|
698
|
+
}
|
|
699
|
+
|
|
636
700
|
# ============================================================================
|
|
637
701
|
# Makefile Setup
|
|
638
702
|
# ============================================================================
|
|
@@ -789,6 +853,9 @@ setup_project() {
|
|
|
789
853
|
"config/dev-tools/eslint.config.js"
|
|
790
854
|
fi
|
|
791
855
|
|
|
856
|
+
# ─── GitLab CI ref sync ───────────────────────────────────────────────────
|
|
857
|
+
sync_gitlab_ci_ref
|
|
858
|
+
|
|
792
859
|
# ─── Summary ─────────────────────────────────────────────────────────────
|
|
793
860
|
if [[ "$SILENT_MODE" == "true" ]]; then
|
|
794
861
|
check_optional_deps
|