@zairakai/dev-tools 1.0.11
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 +86 -0
- package/.gitlab/ci/pipeline-js.yml +189 -0
- package/.gitlab/ci/pipeline-npm-package.yml +353 -0
- package/LICENSE +21 -0
- package/README.md +162 -0
- package/config/.markdownlint.json +7 -0
- package/config/.markdownlintignore +5 -0
- package/config/.prettierignore +10 -0
- package/config/.stylelintignore +7 -0
- package/config/eslint.config.js +191 -0
- package/config/prettier.config.js +121 -0
- package/config/stylelint.config.js +56 -0
- package/config/tsconfig.base.json +20 -0
- package/config/vitest.config.js +25 -0
- package/index.js +22 -0
- package/package.json +137 -0
- package/scripts/build.sh +54 -0
- package/scripts/ci-quality.sh +47 -0
- package/scripts/config.sh +193 -0
- package/scripts/eslint-fix.sh +34 -0
- package/scripts/eslint.sh +46 -0
- package/scripts/install-bats.sh +227 -0
- package/scripts/install-shellcheck.sh +232 -0
- package/scripts/knip.sh +33 -0
- package/scripts/markdownlint-fix.sh +8 -0
- package/scripts/markdownlint.sh +43 -0
- package/scripts/prettier-fix.sh +33 -0
- package/scripts/prettier.sh +34 -0
- package/scripts/setup-project.sh +702 -0
- package/scripts/stylelint-fix.sh +39 -0
- package/scripts/stylelint.sh +47 -0
- package/scripts/test.sh +43 -0
- package/scripts/typecheck.sh +35 -0
- package/scripts/validate-shellcheck.sh +70 -0
- package/stubs/eslint.config.js.stub +18 -0
- package/stubs/gitlab-ci.yml.stub +18 -0
- package/stubs/gitlab-pipeline-js.yml.stub +16 -0
- package/stubs/prettier.config.js.stub +16 -0
- package/stubs/stylelint.config.js.stub +17 -0
- package/stubs/tsconfig.json.stub +10 -0
- package/stubs/vitest.config.js.stub +18 -0
- package/tools/make/bats.mk +49 -0
- package/tools/make/code-style.mk +29 -0
- package/tools/make/core.mk +50 -0
- package/tools/make/help.mk +32 -0
- package/tools/make/markdownlint.mk +17 -0
- package/tools/make/quality.mk +20 -0
- package/tools/make/shellcheck.mk +14 -0
- package/tools/make/stylelint.mk +0 -0
- package/tools/make/test.mk +19 -0
- package/tools/make/typescript.mk +14 -0
- package/tools/make/variables.mk +35 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
|
+
# shellcheck disable=SC1091
|
|
6
|
+
source "$SCRIPT_DIR/config.sh"
|
|
7
|
+
|
|
8
|
+
log_header "Stylelint Fix"
|
|
9
|
+
|
|
10
|
+
ensure_bin_optional "$STYLELINT_BIN" "stylelint" || exit 0
|
|
11
|
+
|
|
12
|
+
STYLELINT_CONFIG="$(resolve_config "stylelint.config.js")"
|
|
13
|
+
STYLELINT_IGNORE="$(resolve_config ".stylelintignore")"
|
|
14
|
+
|
|
15
|
+
if [[ -n "$STYLELINT_CONFIG" ]]; then
|
|
16
|
+
log_step "Using configuration: ${STYLELINT_CONFIG#"$PROJECT_ROOT"/}"
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
if [[ "$PROJECT_TYPE" == "laravel-app" ]]; then
|
|
20
|
+
STYLELINT_TARGET="${STYLELINT_TARGET:-resources/**/*.scss}"
|
|
21
|
+
else
|
|
22
|
+
STYLELINT_TARGET="${STYLELINT_TARGET:-src/**/*.scss}"
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
log_step "Fixing: $STYLELINT_TARGET"
|
|
26
|
+
|
|
27
|
+
STYLELINT_ARGS=(--fix)
|
|
28
|
+
|
|
29
|
+
if [[ -n "$STYLELINT_CONFIG" ]] && [[ "$STYLELINT_CONFIG" != "${PROJECT_ROOT}/stylelint.config.js" ]]; then
|
|
30
|
+
STYLELINT_ARGS+=(--config "$STYLELINT_CONFIG")
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
if [[ -n "$STYLELINT_IGNORE" ]]; then
|
|
34
|
+
STYLELINT_ARGS+=(--ignore-path "$STYLELINT_IGNORE")
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
"$STYLELINT_BIN" "${STYLELINT_ARGS[@]}" "$STYLELINT_TARGET"
|
|
38
|
+
|
|
39
|
+
log_success "Stylelint fix applied"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
|
+
# shellcheck disable=SC1091
|
|
6
|
+
source "$SCRIPT_DIR/config.sh"
|
|
7
|
+
|
|
8
|
+
log_header "Stylelint Check"
|
|
9
|
+
|
|
10
|
+
# Stylelint is optional โ skip gracefully if not installed
|
|
11
|
+
ensure_bin_optional "$STYLELINT_BIN" "stylelint" || exit 0
|
|
12
|
+
|
|
13
|
+
STYLELINT_CONFIG="$(resolve_config "stylelint.config.js")"
|
|
14
|
+
STYLELINT_IGNORE="$(resolve_config ".stylelintignore")"
|
|
15
|
+
|
|
16
|
+
if [[ -n "$STYLELINT_CONFIG" ]]; then
|
|
17
|
+
log_step "Using configuration: ${STYLELINT_CONFIG#"$PROJECT_ROOT"/}"
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
# Lint target depends on project type (overridable via env)
|
|
21
|
+
if [[ "$PROJECT_TYPE" == "laravel-app" ]]; then
|
|
22
|
+
STYLELINT_TARGET="${STYLELINT_TARGET:-resources/**/*.scss}"
|
|
23
|
+
else
|
|
24
|
+
STYLELINT_TARGET="${STYLELINT_TARGET:-src/**/*.scss}"
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
log_step "Checking: $STYLELINT_TARGET"
|
|
28
|
+
|
|
29
|
+
# Skip gracefully if no matching files exist (stylelint v16 errors on empty glob)
|
|
30
|
+
if ! compgen -G "${PROJECT_ROOT}/${STYLELINT_TARGET}" > /dev/null 2>&1; then
|
|
31
|
+
log_info "No SCSS files found โ skipping"
|
|
32
|
+
exit 0
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
STYLELINT_ARGS=()
|
|
36
|
+
|
|
37
|
+
if [[ -n "$STYLELINT_CONFIG" ]] && [[ "$STYLELINT_CONFIG" != "${PROJECT_ROOT}/stylelint.config.js" ]]; then
|
|
38
|
+
STYLELINT_ARGS+=(--config "$STYLELINT_CONFIG")
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
if [[ -n "$STYLELINT_IGNORE" ]]; then
|
|
42
|
+
STYLELINT_ARGS+=(--ignore-path "$STYLELINT_IGNORE")
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
"$STYLELINT_BIN" "${STYLELINT_ARGS[@]}" "$STYLELINT_TARGET"
|
|
46
|
+
|
|
47
|
+
log_success "Stylelint check passed"
|
package/scripts/test.sh
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
|
+
# shellcheck disable=SC1091
|
|
6
|
+
source "$SCRIPT_DIR/config.sh"
|
|
7
|
+
|
|
8
|
+
log_header "Vitest Tests"
|
|
9
|
+
|
|
10
|
+
if ! ensure_bin_optional "$VITEST_BIN" "vitest"; then
|
|
11
|
+
log_warning "vitest not installed โ add it to devDependencies to run tests"
|
|
12
|
+
exit 0
|
|
13
|
+
fi
|
|
14
|
+
|
|
15
|
+
COVERAGE="${COVERAGE:-false}"
|
|
16
|
+
CI="${CI:-false}"
|
|
17
|
+
|
|
18
|
+
# CI mode: always run with coverage
|
|
19
|
+
if [[ "$CI" == "true" ]]; then
|
|
20
|
+
log_info "Running in CI mode (strict + coverage)"
|
|
21
|
+
COVERAGE="true"
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
# Resolve vitest config
|
|
25
|
+
VITEST_CONFIG="$(resolve_config "vitest.config.js")"
|
|
26
|
+
|
|
27
|
+
VITEST_ARGS=()
|
|
28
|
+
|
|
29
|
+
if [[ -n "$VITEST_CONFIG" ]]; then
|
|
30
|
+
log_step "Using configuration: ${VITEST_CONFIG#"$PROJECT_ROOT"/}"
|
|
31
|
+
VITEST_ARGS+=(--config "$VITEST_CONFIG")
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
if [[ "$COVERAGE" == "true" ]]; then
|
|
35
|
+
log_info "Running with coverage report"
|
|
36
|
+
ensure_dir "build/coverage"
|
|
37
|
+
ensure_dir "build/logs"
|
|
38
|
+
"$VITEST_BIN" run --coverage --passWithNoTests "${VITEST_ARGS[@]}"
|
|
39
|
+
else
|
|
40
|
+
"$VITEST_BIN" run --passWithNoTests "${VITEST_ARGS[@]}"
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
log_success "Tests passed"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# TypeScript Type Checking (tsc --noEmit)
|
|
4
|
+
# Validates types without emitting output files.
|
|
5
|
+
# Equivalent to PHPStan for TypeScript.
|
|
6
|
+
#
|
|
7
|
+
# Usage:
|
|
8
|
+
# bash scripts/typecheck.sh
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
set -euo pipefail
|
|
12
|
+
|
|
13
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
14
|
+
# shellcheck disable=SC1091
|
|
15
|
+
source "${SCRIPT_DIR}/config.sh"
|
|
16
|
+
|
|
17
|
+
TSC_BIN="${BIN_DIR}/tsc"
|
|
18
|
+
|
|
19
|
+
log_header "TypeScript Type Checking"
|
|
20
|
+
|
|
21
|
+
ensure_bin "$TSC_BIN" "tsc (typescript)"
|
|
22
|
+
|
|
23
|
+
if [[ ! -f "${PROJECT_ROOT}/tsconfig.json" ]]; then
|
|
24
|
+
log_error "No tsconfig.json found at project root"
|
|
25
|
+
log_info "Publish one with:"
|
|
26
|
+
log_info " bash node_modules/@zairakai/dev-tools/scripts/setup-project.sh --publish=tsconfig"
|
|
27
|
+
exit 1
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
log_info "Config: tsconfig.json"
|
|
31
|
+
log_info "Mode: --noEmit (type validation only)"
|
|
32
|
+
|
|
33
|
+
"$TSC_BIN" --noEmit
|
|
34
|
+
|
|
35
|
+
log_success "TypeScript type checking passed"
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# scripts/validate-shellcheck.sh
|
|
3
|
+
# Runs ShellCheck validation on all shell scripts (100% compliance required)
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
# bash scripts/validate-shellcheck.sh
|
|
7
|
+
#
|
|
8
|
+
# Environment Variables:
|
|
9
|
+
# SHELLCHECK_SEVERITY - Severity level (default: warning)
|
|
10
|
+
# SHELLCHECK_FORMAT - Output format (default: gcc)
|
|
11
|
+
|
|
12
|
+
set -euo pipefail
|
|
13
|
+
|
|
14
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
15
|
+
# shellcheck disable=SC1091
|
|
16
|
+
source "${SCRIPT_DIR}/config.sh"
|
|
17
|
+
|
|
18
|
+
SEVERITY="${SHELLCHECK_SEVERITY:-warning}"
|
|
19
|
+
FORMAT="${SHELLCHECK_FORMAT:-gcc}"
|
|
20
|
+
|
|
21
|
+
log_header "Running ShellCheck Validation"
|
|
22
|
+
log_info "Severity: ${SEVERITY}"
|
|
23
|
+
log_info "Format: ${FORMAT}"
|
|
24
|
+
|
|
25
|
+
if ! command_exists shellcheck; then
|
|
26
|
+
log_error "ShellCheck not found. Please install shellcheck."
|
|
27
|
+
log_info " Alpine: apk add shellcheck"
|
|
28
|
+
log_info " Debian/Ubuntu: apt-get install shellcheck"
|
|
29
|
+
log_info " macOS: brew install shellcheck"
|
|
30
|
+
exit 1
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
SHELLCHECK_VERSION="$(shellcheck --version | grep "version:" | awk '{print $2}')"
|
|
34
|
+
log_info "ShellCheck version: ${SHELLCHECK_VERSION}"
|
|
35
|
+
|
|
36
|
+
log_info "โ Finding shell scriptsโฆ"
|
|
37
|
+
|
|
38
|
+
mapfile -t SHELL_SCRIPTS < <(find . \( -name "*.sh" -o -name "*.bats" \) -type f ! -path "*/node_modules/*" ! -path "*/dist/*" ! -path "*/build/*")
|
|
39
|
+
|
|
40
|
+
SCRIPT_COUNT=${#SHELL_SCRIPTS[@]}
|
|
41
|
+
log_info "Found ${SCRIPT_COUNT} shell scripts"
|
|
42
|
+
|
|
43
|
+
if [[ ${SCRIPT_COUNT} -eq 0 ]]; then
|
|
44
|
+
log_warning "No shell scripts found"
|
|
45
|
+
exit 0
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
log_info "โ Running ShellCheck validationโฆ"
|
|
49
|
+
|
|
50
|
+
FAILED=0
|
|
51
|
+
TOTAL=0
|
|
52
|
+
|
|
53
|
+
for script in "${SHELL_SCRIPTS[@]}"; do
|
|
54
|
+
TOTAL=$((TOTAL + 1))
|
|
55
|
+
|
|
56
|
+
if shellcheck --severity="${SEVERITY}" --format="${FORMAT}" "${script}"; then
|
|
57
|
+
:
|
|
58
|
+
else
|
|
59
|
+
log_error " โ ${script} โ ShellCheck failed"
|
|
60
|
+
FAILED=$((FAILED + 1))
|
|
61
|
+
fi
|
|
62
|
+
done
|
|
63
|
+
|
|
64
|
+
if [[ ${FAILED} -eq 0 ]]; then
|
|
65
|
+
log_success "All ${TOTAL} scripts passed ShellCheck"
|
|
66
|
+
exit 0
|
|
67
|
+
else
|
|
68
|
+
log_error "${FAILED}/${TOTAL} scripts failed ShellCheck"
|
|
69
|
+
exit 1
|
|
70
|
+
fi
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project ESLint configuration.
|
|
3
|
+
* Extends the @zairakai/dev-tools base config โ customize as needed.
|
|
4
|
+
*
|
|
5
|
+
* Example of adding project-specific rules:
|
|
6
|
+
* export default [
|
|
7
|
+
* ...baseConfig,
|
|
8
|
+
* {
|
|
9
|
+
* rules: {
|
|
10
|
+
* 'no-console': 'warn',
|
|
11
|
+
* },
|
|
12
|
+
* },
|
|
13
|
+
* ]
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import baseConfig from '@zairakai/dev-tools/config/eslint.config.js'
|
|
17
|
+
|
|
18
|
+
export default [...baseConfig]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# .gitlab-ci.yml
|
|
2
|
+
# Generated by @zairakai/dev-tools setup-project.sh
|
|
3
|
+
# Inherits the full shared template โ only project-specific variables are defined here.
|
|
4
|
+
#
|
|
5
|
+
# To regenerate:
|
|
6
|
+
# bash node_modules/@zairakai/dev-tools/scripts/setup-project.sh --publish=gitlab-ci --force
|
|
7
|
+
|
|
8
|
+
include:
|
|
9
|
+
- project: 'zairakai/npm/dev-tools'
|
|
10
|
+
ref: v0.0.0
|
|
11
|
+
file: '.gitlab/ci/pipeline-npm-package.yml'
|
|
12
|
+
|
|
13
|
+
variables:
|
|
14
|
+
# Unique cache key for this project (update suffix when changing dependencies)
|
|
15
|
+
CACHE_KEY: "PACKAGE_CACHE_KEY"
|
|
16
|
+
|
|
17
|
+
# Full package name on npm (used in the GitLab release link)
|
|
18
|
+
NPM_PACKAGE_NAME: "PACKAGE_NPM_NAME"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# .gitlab/pipeline-js.yml
|
|
2
|
+
# JavaScript/Frontend CI jobs for this Laravel application.
|
|
3
|
+
# Generated by @zairakai/dev-tools setup-project.sh
|
|
4
|
+
# Included from .gitlab-ci.yml via: include: - local: '.gitlab/pipeline-js.yml'
|
|
5
|
+
#
|
|
6
|
+
# To regenerate:
|
|
7
|
+
# bash node_modules/@zairakai/dev-tools/scripts/setup-project.sh --publish=gitlab-ci --force
|
|
8
|
+
|
|
9
|
+
include:
|
|
10
|
+
- project: 'zairakai/npm/dev-tools'
|
|
11
|
+
ref: v0.0.0
|
|
12
|
+
file: '.gitlab/ci/pipeline-js.yml'
|
|
13
|
+
|
|
14
|
+
variables:
|
|
15
|
+
# Unique JS cache key for this project
|
|
16
|
+
CACHE_KEY: "PACKAGE_CACHE_KEY"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Prettier configuration.
|
|
3
|
+
* Extends the @zairakai/dev-tools base config โ customize as needed.
|
|
4
|
+
*
|
|
5
|
+
* Example of adding project-specific overrides:
|
|
6
|
+
* module.exports = {
|
|
7
|
+
* ...baseConfig,
|
|
8
|
+
* printWidth: 100,
|
|
9
|
+
* }
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const baseConfig = require('@zairakai/dev-tools/config/prettier.config.js')
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
...baseConfig,
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Stylelint configuration.
|
|
3
|
+
* Extends the @zairakai/dev-tools base config โ customize as needed.
|
|
4
|
+
*
|
|
5
|
+
* Example of adding project-specific rules:
|
|
6
|
+
* export default {
|
|
7
|
+
* ...baseConfig,
|
|
8
|
+
* rules: {
|
|
9
|
+
* ...baseConfig.rules,
|
|
10
|
+
* 'color-no-invalid-hex': true,
|
|
11
|
+
* },
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import baseConfig from '@zairakai/dev-tools/config/stylelint.config.js'
|
|
16
|
+
|
|
17
|
+
export default { ...baseConfig }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "@zairakai/dev-tools/config/tsconfig.base.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "dist",
|
|
6
|
+
"rootDir": "src"
|
|
7
|
+
},
|
|
8
|
+
"include": ["src/**/*"],
|
|
9
|
+
"exclude": ["node_modules", "dist", "build", "**/*.test.ts", "**/*.spec.ts"]
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Vitest configuration.
|
|
3
|
+
* Extends the @zairakai/dev-tools base config โ customize as needed.
|
|
4
|
+
*
|
|
5
|
+
* Example of adding project-specific settings (e.g. Vue plugin, jsdom):
|
|
6
|
+
* import vue from '@vitejs/plugin-vue'
|
|
7
|
+
* export default mergeConfig(baseConfig, defineConfig({
|
|
8
|
+
* plugins: [vue()],
|
|
9
|
+
* test: {
|
|
10
|
+
* environment: 'jsdom',
|
|
11
|
+
* },
|
|
12
|
+
* }))
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { defineConfig, mergeConfig } from 'vitest/config'
|
|
16
|
+
import baseConfig from '@zairakai/dev-tools/config/vitest.config.js'
|
|
17
|
+
|
|
18
|
+
export default mergeConfig(baseConfig, defineConfig({}))
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# BATS Testing Targets
|
|
2
|
+
# Shell script testing with Bash Automated Testing System
|
|
3
|
+
## โโ ๐งช Shell Script Testing โโ
|
|
4
|
+
|
|
5
|
+
.PHONY: bats
|
|
6
|
+
bats:: ## Run shell script tests (BATS)
|
|
7
|
+
@if [ ! -d tests/bats/unit ] && [ ! -d tests/bats/integration ]; then \
|
|
8
|
+
echo "โน๏ธ No BATS tests found โ skipping"; \
|
|
9
|
+
exit 0; \
|
|
10
|
+
fi
|
|
11
|
+
@if ! command -v bats &>/dev/null; then \
|
|
12
|
+
echo "โ BATS not installed - run: make install-bats"; \
|
|
13
|
+
exit 1; \
|
|
14
|
+
fi
|
|
15
|
+
@bats tests/bats/unit/*.bats tests/bats/integration/*.bats
|
|
16
|
+
|
|
17
|
+
.PHONY: bats-unit
|
|
18
|
+
bats-unit:: ## Run BATS unit tests
|
|
19
|
+
@if [ ! -d tests/bats/unit ]; then \
|
|
20
|
+
echo "โน๏ธ No BATS unit tests found โ skipping"; \
|
|
21
|
+
exit 0; \
|
|
22
|
+
fi
|
|
23
|
+
@if ! command -v bats &>/dev/null; then \
|
|
24
|
+
echo "โ BATS not installed - run: make install-bats"; \
|
|
25
|
+
exit 1; \
|
|
26
|
+
fi
|
|
27
|
+
@bats tests/bats/unit/*.bats
|
|
28
|
+
|
|
29
|
+
.PHONY: bats-integration
|
|
30
|
+
bats-integration:: ## Run BATS integration tests
|
|
31
|
+
@if [ ! -d tests/bats/integration ]; then \
|
|
32
|
+
echo "โน๏ธ No BATS integration tests found โ skipping"; \
|
|
33
|
+
exit 0; \
|
|
34
|
+
fi
|
|
35
|
+
@if ! command -v bats &>/dev/null; then \
|
|
36
|
+
echo "โ BATS not installed - run: make install-bats"; \
|
|
37
|
+
exit 1; \
|
|
38
|
+
fi
|
|
39
|
+
@bats tests/bats/integration/*.bats
|
|
40
|
+
|
|
41
|
+
.PHONY: test-all
|
|
42
|
+
test-all:: test bats ## Run all tests (JS + Shell)
|
|
43
|
+
@echo ""
|
|
44
|
+
@echo "โ
All tests passed"
|
|
45
|
+
|
|
46
|
+
##
|
|
47
|
+
.PHONY: install-bats
|
|
48
|
+
install-bats:: ## Install BATS framework
|
|
49
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/install-bats.sh
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# ESLint + Prettier Code Style Targets
|
|
2
|
+
|
|
3
|
+
## โโ ๐จ Code Style โโ
|
|
4
|
+
|
|
5
|
+
.PHONY: eslint
|
|
6
|
+
eslint: ## Check code style
|
|
7
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/eslint.sh
|
|
8
|
+
|
|
9
|
+
.PHONY: eslint-fix
|
|
10
|
+
eslint-fix: ## Fix code style automatically
|
|
11
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/eslint-fix.sh
|
|
12
|
+
|
|
13
|
+
##
|
|
14
|
+
.PHONY: prettier
|
|
15
|
+
prettier: ## Check formatting
|
|
16
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/prettier.sh
|
|
17
|
+
|
|
18
|
+
.PHONY: prettier-fix
|
|
19
|
+
prettier-fix: ## Fix formatting automatically
|
|
20
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/prettier-fix.sh
|
|
21
|
+
|
|
22
|
+
##
|
|
23
|
+
.PHONY: stylelint
|
|
24
|
+
stylelint: ## Check CSS/SCSS style
|
|
25
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/stylelint.sh
|
|
26
|
+
|
|
27
|
+
.PHONY: stylelint-fix
|
|
28
|
+
stylelint-fix: ## Fix CSS/SCSS style automatically
|
|
29
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/stylelint-fix.sh
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Core Makefile โ Zairakai NPM Dev Tools
|
|
2
|
+
# Aggregates all modular targets for JavaScript/TypeScript/Vue projects.
|
|
3
|
+
#
|
|
4
|
+
# Usage in a consumer project (Makefile):
|
|
5
|
+
# DEV_TOOLS_NPM := node_modules/@zairakai/dev-tools
|
|
6
|
+
# include $(DEV_TOOLS_NPM)/tools/make/core.mk
|
|
7
|
+
#
|
|
8
|
+
# Or generate via:
|
|
9
|
+
# bash node_modules/@zairakai/dev-tools/scripts/setup-project.sh --with-makefile
|
|
10
|
+
|
|
11
|
+
# Default goal (only if not already set by the project Makefile)
|
|
12
|
+
ifeq ($(origin .DEFAULT_GOAL), undefined)
|
|
13
|
+
.DEFAULT_GOAL := help
|
|
14
|
+
endif
|
|
15
|
+
|
|
16
|
+
SHELL := /bin/bash
|
|
17
|
+
|
|
18
|
+
# Resolve make files directory from the current MAKEFILE_LIST entry
|
|
19
|
+
NPM_DIRECTORY_TOOLS_MAKE_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
|
20
|
+
|
|
21
|
+
# Include variables first (paths, colors, project info)
|
|
22
|
+
include $(NPM_DIRECTORY_TOOLS_MAKE_DIR)variables.mk
|
|
23
|
+
|
|
24
|
+
# Include specialized make files in logical development workflow order:
|
|
25
|
+
# 1. Help system (discover available commands)
|
|
26
|
+
include $(NPM_DIRECTORY_TOOLS_MAKE_DIR)help.mk
|
|
27
|
+
|
|
28
|
+
# 4. Documentation linting (Markdown)
|
|
29
|
+
include $(NPM_DIRECTORY_TOOLS_MAKE_DIR)markdownlint.mk
|
|
30
|
+
|
|
31
|
+
# 5. ShellCheck validation
|
|
32
|
+
include $(NPM_DIRECTORY_TOOLS_MAKE_DIR)shellcheck.mk
|
|
33
|
+
|
|
34
|
+
# 2. Code style โ ESLint + Prettier
|
|
35
|
+
include $(NPM_DIRECTORY_TOOLS_MAKE_DIR)code-style.mk
|
|
36
|
+
|
|
37
|
+
# 3. CSS/SCSS โ Stylelint (optional)
|
|
38
|
+
include $(NPM_DIRECTORY_TOOLS_MAKE_DIR)stylelint.mk
|
|
39
|
+
|
|
40
|
+
# 8. TypeScript type checking and build
|
|
41
|
+
include $(NPM_DIRECTORY_TOOLS_MAKE_DIR)typescript.mk
|
|
42
|
+
|
|
43
|
+
# 6. Quality aggregation (combines all checks)
|
|
44
|
+
include $(NPM_DIRECTORY_TOOLS_MAKE_DIR)quality.mk
|
|
45
|
+
|
|
46
|
+
# 7. Testing (Vitest)
|
|
47
|
+
include $(NPM_DIRECTORY_TOOLS_MAKE_DIR)test.mk
|
|
48
|
+
|
|
49
|
+
# 9. BATS shell script testing
|
|
50
|
+
include $(NPM_DIRECTORY_TOOLS_MAKE_DIR)bats.mk
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Help target
|
|
2
|
+
|
|
3
|
+
## โโ ๐ Help โโ
|
|
4
|
+
|
|
5
|
+
.PHONY: help
|
|
6
|
+
help:: ## Show available commands
|
|
7
|
+
@echo ""
|
|
8
|
+
@printf "$(NPM_DIRECTORY_TOOLS_COLOR_HEADER_FG)$(NPM_DIRECTORY_TOOLS_COLOR_HEADER_BG)%*s$(NPM_DIRECTORY_TOOLS_COLOR_RESET)\n" $(NPM_DIRECTORY_TOOLS_HELP_WIDTH) ""
|
|
9
|
+
@printf "$(NPM_DIRECTORY_TOOLS_COLOR_HEADER_FG)$(NPM_DIRECTORY_TOOLS_COLOR_HEADER_BG) %-*s$(NPM_DIRECTORY_TOOLS_COLOR_RESET)\n" $$(($(NPM_DIRECTORY_TOOLS_HELP_WIDTH)-3)) "$(NPM_DIRECTORY_TOOLS_PROJECT_NAME) - Available Commands"
|
|
10
|
+
@printf "$(NPM_DIRECTORY_TOOLS_COLOR_HEADER_FG)$(NPM_DIRECTORY_TOOLS_COLOR_HEADER_BG)%*s$(NPM_DIRECTORY_TOOLS_COLOR_RESET)\n" $(NPM_DIRECTORY_TOOLS_HELP_WIDTH) ""
|
|
11
|
+
@echo ""
|
|
12
|
+
@grep -hE '(^[[:alnum:]_.-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) \
|
|
13
|
+
| awk 'BEGIN {FS=":.*?## "; color_section="$(NPM_DIRECTORY_TOOLS_COLOR_SECTION)"; color_target="$(NPM_DIRECTORY_TOOLS_COLOR_TARGET)"; color_reset="$(NPM_DIRECTORY_TOOLS_COLOR_RESET)"} \
|
|
14
|
+
/^##/ { \
|
|
15
|
+
gsub(/^##[[:space:]]*/, "", $$0); \
|
|
16
|
+
if ($$0 != "") { \
|
|
17
|
+
if (!seen_sections[$$0]++) { \
|
|
18
|
+
if (NR > 1) { printf "\n" } \
|
|
19
|
+
printf "%s%s%s\n", color_section, $$0, color_reset \
|
|
20
|
+
} \
|
|
21
|
+
} else { \
|
|
22
|
+
printf "\n" \
|
|
23
|
+
} \
|
|
24
|
+
next \
|
|
25
|
+
} \
|
|
26
|
+
!seen_targets[$$1]++ { printf " %s%-28s%s %s\n", color_target, $$1, color_reset, $$2 }'
|
|
27
|
+
@echo ""
|
|
28
|
+
@printf "$(NPM_DIRECTORY_TOOLS_COLOR_FOOTER_FG)$(NPM_DIRECTORY_TOOLS_COLOR_FOOTER_BG)%*s$(NPM_DIRECTORY_TOOLS_COLOR_RESET)\n" $(NPM_DIRECTORY_TOOLS_HELP_WIDTH) ""
|
|
29
|
+
@printf "$(NPM_DIRECTORY_TOOLS_COLOR_FOOTER_FG)$(NPM_DIRECTORY_TOOLS_COLOR_FOOTER_BG) Twitch: %-*s$(NPM_DIRECTORY_TOOLS_COLOR_RESET)\n" $$(($(NPM_DIRECTORY_TOOLS_HELP_WIDTH)-11)) "$(NPM_DIRECTORY_TOOLS_TWITCH_URL)"
|
|
30
|
+
@printf "$(NPM_DIRECTORY_TOOLS_COLOR_FOOTER_FG)$(NPM_DIRECTORY_TOOLS_COLOR_FOOTER_BG) GitLab: %-*s$(NPM_DIRECTORY_TOOLS_COLOR_RESET)\n" $$(($(NPM_DIRECTORY_TOOLS_HELP_WIDTH)-11)) "$(NPM_DIRECTORY_TOOLS_GITLAB_URL)"
|
|
31
|
+
@printf "$(NPM_DIRECTORY_TOOLS_COLOR_FOOTER_FG)$(NPM_DIRECTORY_TOOLS_COLOR_FOOTER_BG)%*s$(NPM_DIRECTORY_TOOLS_COLOR_RESET)\n" $(NPM_DIRECTORY_TOOLS_HELP_WIDTH) ""
|
|
32
|
+
@echo ""
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Markdownlint Targets
|
|
2
|
+
# Delegates to scripts/markdownlint.sh
|
|
3
|
+
|
|
4
|
+
## โโ ๐ Markdownlint (Documentation Linting) โโ
|
|
5
|
+
|
|
6
|
+
.PHONY: markdownlint
|
|
7
|
+
markdownlint: ## Validate Markdown documentation style and formatting
|
|
8
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/markdownlint.sh
|
|
9
|
+
|
|
10
|
+
.PHONY: markdownlint-fix
|
|
11
|
+
markdownlint-fix: ## Fix Markdown documentation issues automatically
|
|
12
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/markdownlint.sh --fix
|
|
13
|
+
|
|
14
|
+
##
|
|
15
|
+
.PHONY: install-markdownlint
|
|
16
|
+
install-markdownlint: ## Install Markdownlint
|
|
17
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/install-markdownlint.sh
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Quality Gate Targets
|
|
2
|
+
## โโ โ
Quality Gates โโ
|
|
3
|
+
|
|
4
|
+
.PHONY: quality
|
|
5
|
+
quality:: eslint prettier stylelint markdownlint shellcheck ## Run all quality checks
|
|
6
|
+
@echo "โ
All quality checks passed"
|
|
7
|
+
|
|
8
|
+
.PHONY: quality-fix
|
|
9
|
+
quality-fix:: eslint-fix prettier-fix stylelint-fix markdownlint-fix ## Auto-fix all fixable issues
|
|
10
|
+
@echo "โ
All auto-fixes applied"
|
|
11
|
+
|
|
12
|
+
.PHONY: quality-fast
|
|
13
|
+
quality-fast:: ## Run quality checks via aggregator script
|
|
14
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/ci-quality.sh
|
|
15
|
+
|
|
16
|
+
.PHONY: ci
|
|
17
|
+
ci:: quality test bats ## Full CI validation (quality + tests + BATS)
|
|
18
|
+
@echo ""
|
|
19
|
+
@echo "โ
CI validation passed"
|
|
20
|
+
@echo "๐ก If using TypeScript, also run: make typecheck"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# ShellCheck Targets
|
|
2
|
+
# Delegates to scripts/validate-shellcheck.sh
|
|
3
|
+
|
|
4
|
+
## โโ ๐ ShellCheck (Shell Script Validation) โโ
|
|
5
|
+
|
|
6
|
+
.PHONY: shellcheck
|
|
7
|
+
shellcheck: ## Validate shell scripts with ShellCheck (100% compliance required)
|
|
8
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/validate-shellcheck.sh
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
.PHONY: install-shellcheck
|
|
13
|
+
install-shellcheck: ## Install shellcheck
|
|
14
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/install-shellcheck.sh
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Vitest Testing Targets
|
|
2
|
+
# Delegates to scripts/test.sh with appropriate environment variables
|
|
3
|
+
## โโ ๐งช Testing โโ
|
|
4
|
+
|
|
5
|
+
.PHONY: test
|
|
6
|
+
test:: ## Run all tests (without coverage)
|
|
7
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/test.sh
|
|
8
|
+
|
|
9
|
+
.PHONY: test-coverage
|
|
10
|
+
test-coverage:: ## Run tests with coverage report
|
|
11
|
+
@COVERAGE=true bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/test.sh
|
|
12
|
+
|
|
13
|
+
.PHONY: test-watch
|
|
14
|
+
test-watch:: ## Run tests in watch mode
|
|
15
|
+
@$(NPM_DIRECTORY_TOOLS_PROJECT_ROOT)/node_modules/.bin/vitest
|
|
16
|
+
|
|
17
|
+
.PHONY: test-ci
|
|
18
|
+
test-ci:: ## Run tests in CI mode (strict + coverage)
|
|
19
|
+
@CI=true bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/test.sh
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
## โโ ๐งฉ Typescript โโ
|
|
2
|
+
|
|
3
|
+
.PHONY: typecheck
|
|
4
|
+
typecheck: ## Type-check TypeScript without emitting files (tsc --noEmit)
|
|
5
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/typecheck.sh
|
|
6
|
+
|
|
7
|
+
.PHONY: build
|
|
8
|
+
build: ## Transpile TypeScript to JavaScript (tsup preferred, tsc fallback)
|
|
9
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/build.sh
|
|
10
|
+
|
|
11
|
+
.PHONY: knip
|
|
12
|
+
knip: ## Find unused exports, files and dependencies (requires: npm install --save-dev knip)
|
|
13
|
+
@bash $(NPM_DIRECTORY_TOOLS_SCRIPTS_DIR)/knip.sh
|
|
14
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Variables - Zairakai NPM Dev Tools
|
|
2
|
+
# Shared configuration and styling
|
|
3
|
+
|
|
4
|
+
# Critical path detection โ works from any inclusion depth
|
|
5
|
+
NPM_DIRECTORY_TOOLS_MAKE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
|
6
|
+
NPM_DIRECTORY_TOOLS_PACKAGE_ROOT := $(abspath $(NPM_DIRECTORY_TOOLS_MAKE_DIR)../../)
|
|
7
|
+
NPM_DIRECTORY_TOOLS_SCRIPTS_DIR := $(NPM_DIRECTORY_TOOLS_PACKAGE_ROOT)/scripts
|
|
8
|
+
|
|
9
|
+
# Project root (caller context). Prefer $(shell pwd) over $(CURDIR).
|
|
10
|
+
NPM_DIRECTORY_TOOLS_PROJECT_ROOT ?= $(shell pwd)
|
|
11
|
+
|
|
12
|
+
# Project information (can be overridden in project Makefile BEFORE including core.mk)
|
|
13
|
+
NPM_DIRECTORY_TOOLS_PROJECT_NAME ?= Zairakai Project
|
|
14
|
+
NPM_DIRECTORY_TOOLS_TWITCH_URL ?= https://twitch.tv/zairakai
|
|
15
|
+
NPM_DIRECTORY_TOOLS_GITLAB_URL ?= https://gitlab.com/zairakai
|
|
16
|
+
|
|
17
|
+
# Help styling
|
|
18
|
+
NPM_DIRECTORY_TOOLS_HELP_WIDTH := 70
|
|
19
|
+
|
|
20
|
+
# ANSI Colors (only used in Make, not exported to scripts)
|
|
21
|
+
NPM_DIRECTORY_TOOLS_COLOR_RESET := \033[0m
|
|
22
|
+
NPM_DIRECTORY_TOOLS_COLOR_HEADER_BG := \033[46m
|
|
23
|
+
NPM_DIRECTORY_TOOLS_COLOR_HEADER_FG := \033[1;37m
|
|
24
|
+
NPM_DIRECTORY_TOOLS_COLOR_SECTION := \033[1;33m
|
|
25
|
+
NPM_DIRECTORY_TOOLS_COLOR_TARGET := \033[32m
|
|
26
|
+
NPM_DIRECTORY_TOOLS_COLOR_FOOTER_BG := \033[44m
|
|
27
|
+
NPM_DIRECTORY_TOOLS_COLOR_FOOTER_FG := \033[1;37m
|
|
28
|
+
|
|
29
|
+
# Export only what shell scripts need
|
|
30
|
+
export NPM_DIRECTORY_TOOLS_PROJECT_ROOT
|
|
31
|
+
export NPM_DIRECTORY_TOOLS_PACKAGE_ROOT
|
|
32
|
+
export NPM_DIRECTORY_TOOLS_SCRIPTS_DIR
|
|
33
|
+
export NPM_DIRECTORY_TOOLS_PROJECT_NAME
|
|
34
|
+
export NPM_DIRECTORY_TOOLS_TWITCH_URL
|
|
35
|
+
export NPM_DIRECTORY_TOOLS_GITLAB_URL
|