code-foundry 0.3.0 → 0.4.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.
@@ -1,67 +1,5 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- git diff --cached --check
5
- changed=$(git diff --cached --name-only)
6
-
7
- has_script() {
8
- [ -f package.json ] && node -e 'const p=require("./package.json"); process.exit(p.scripts?.[process.argv[1]] ? 0 : 1)' "$1"
9
- }
10
-
11
- package_manager() {
12
- if [ -f bun.lock ] || [ -f bun.lockb ]; then echo bun
13
- elif [ -f pnpm-lock.yaml ]; then echo pnpm
14
- elif [ -f yarn.lock ]; then echo yarn
15
- else echo npm
16
- fi
17
- }
18
-
19
- run_lint_staged() {
20
- if ! has_script lint-staged; then return 1; fi
21
- case "$(package_manager)" in
22
- bun) bun run lint-staged ;;
23
- pnpm) corepack pnpm run lint-staged ;;
24
- yarn) corepack yarn run lint-staged ;;
25
- npm) npm run lint-staged ;;
26
- esac
27
- }
28
-
29
- if printf '%s\n' "$changed" | grep -Eq '\.(js|jsx|ts|tsx|json|md|mdx|yml|yaml)$'; then
30
- if ! run_lint_staged; then
31
- bash .github/scripts/ci.sh format
32
- bash .github/scripts/ci.sh lint
33
- fi
34
- fi
35
-
36
- if printf '%s\n' "$changed" | grep -Eq '\.rs$|(^|/)Cargo\.toml$'; then
37
- cargo fmt --check
38
- cargo clippy --all-targets -- -D warnings
39
- fi
40
-
41
- python_files=()
42
- python_config=false
43
- while IFS= read -r file; do
44
- case "$file" in
45
- *.py)
46
- [ -f "$file" ] && python_files+=("$file")
47
- ;;
48
- pyproject.toml|requirements.txt|requirements-dev.txt)
49
- python_config=true
50
- ;;
51
- esac
52
- done <<< "$changed"
53
-
54
- if [ "$python_config" = true ] || [ "${#python_files[@]}" -gt 0 ]; then
55
- ruff_targets=(.)
56
- [ "$python_config" = true ] || ruff_targets=("${python_files[@]}")
57
- if [ -x .venv/bin/ruff ]; then
58
- .venv/bin/ruff format --check "${ruff_targets[@]}"
59
- .venv/bin/ruff check "${ruff_targets[@]}"
60
- elif command -v ruff >/dev/null 2>&1; then
61
- ruff format --check "${ruff_targets[@]}"
62
- ruff check "${ruff_targets[@]}"
63
- else
64
- echo "Python files changed but Ruff is not installed; run the template setup first." >&2
65
- exit 1
66
- fi
67
- fi
4
+ repo_root="$(git rev-parse --show-toplevel)"
5
+ exec bash "$repo_root/.github/scripts/pre-commit.sh" "$@"
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ git diff --cached --check
5
+ changed=$(git diff --cached --name-only)
6
+
7
+ has_script() {
8
+ [ -f package.json ] && node -e 'const p=require("./package.json"); process.exit(p.scripts?.[process.argv[1]] ? 0 : 1)' "$1"
9
+ }
10
+
11
+ package_manager() {
12
+ if [ -f bun.lock ] || [ -f bun.lockb ]; then echo bun
13
+ elif [ -f pnpm-lock.yaml ]; then echo pnpm
14
+ elif [ -f yarn.lock ]; then echo yarn
15
+ else echo npm
16
+ fi
17
+ }
18
+
19
+ run_lint_staged() {
20
+ if ! has_script lint-staged; then return 1; fi
21
+ case "$(package_manager)" in
22
+ bun) bun run lint-staged ;;
23
+ pnpm) corepack pnpm run lint-staged ;;
24
+ yarn) corepack yarn run lint-staged ;;
25
+ npm) npm run lint-staged ;;
26
+ esac
27
+ }
28
+
29
+ if printf '%s\n' "$changed" | grep -Eq '\.(js|jsx|ts|tsx|json|md|mdx|yml|yaml)$'; then
30
+ if ! run_lint_staged; then
31
+ bash .github/scripts/ci.sh format
32
+ bash .github/scripts/ci.sh lint
33
+ fi
34
+ fi
35
+
36
+ if printf '%s\n' "$changed" | grep -Eq '\.rs$|(^|/)Cargo\.toml$'; then
37
+ cargo fmt --check
38
+ cargo clippy --all-targets -- -D warnings
39
+ fi
40
+
41
+ python_files=()
42
+ python_config=false
43
+ while IFS= read -r file; do
44
+ case "$file" in
45
+ *.py)
46
+ [ -f "$file" ] && python_files+=("$file")
47
+ ;;
48
+ pyproject.toml|requirements.txt|requirements-dev.txt)
49
+ python_config=true
50
+ ;;
51
+ esac
52
+ done <<< "$changed"
53
+
54
+ if [ "$python_config" = true ] || [ "${#python_files[@]}" -gt 0 ]; then
55
+ ruff_targets=(.)
56
+ [ "$python_config" = true ] || ruff_targets=("${python_files[@]}")
57
+ if [ -x .venv/bin/ruff ]; then
58
+ .venv/bin/ruff format --check "${ruff_targets[@]}"
59
+ .venv/bin/ruff check "${ruff_targets[@]}"
60
+ elif command -v ruff >/dev/null 2>&1; then
61
+ ruff format --check "${ruff_targets[@]}"
62
+ ruff check "${ruff_targets[@]}"
63
+ else
64
+ echo "Python files changed but Ruff is not installed; run the template setup first." >&2
65
+ exit 1
66
+ fi
67
+ fi
@@ -159,9 +159,10 @@ contains_word "$valid_release_types" "$release_type" || {
159
159
  exit 2
160
160
  }
161
161
  case "$license" in
162
- preserve|agpl-3.0-or-later|mit|none) ;;
162
+ preserve|agpl-3.0-or-later|mit|custom|none) ;;
163
163
  *) printf 'Unsupported license: %s\n' "$license" >&2; exit 2 ;;
164
164
  esac
165
+ [ -z "$license_file" ] || license=custom
165
166
 
166
167
  if [ -d "$source" ] && [ -f "$source/.github/scripts/sync-template.sh" ]; then
167
168
  template_root="$source"
@@ -229,6 +230,7 @@ files=(
229
230
  .github/scripts/doctor.sh
230
231
  .github/scripts/security.sh
231
232
  .github/scripts/sitecustomize.py
233
+ .github/scripts/pre-commit.sh
232
234
  .github/scripts/sync-template.sh
233
235
  .github/scripts/init-repo.sh
234
236
  .github/scripts/sync-codeowners.sh
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.0](https://github.com/0xPlayerOne/code-foundry/compare/v0.3.0...v0.4.0) (2026-07-28)
4
+
5
+
6
+ ### Features
7
+
8
+ * **hooks:** centralize generated pre-commit runtime ([8e8111c](https://github.com/0xPlayerOne/code-foundry/commit/8e8111c1b1b95fcb356fe1b1366e369393cbf946))
9
+
3
10
  ## [0.3.0](https://github.com/0xPlayerOne/code-foundry/compare/v0.2.0...v0.3.0) (2026-07-28)
4
11
 
5
12
 
package/README.md CHANGED
@@ -40,6 +40,10 @@ Initialization defaults to AGPL for new repositories. Synchronization defaults
40
40
  to `--license preserve`, so an existing repository's license is never replaced
41
41
  unless you explicitly select a license or provide `--license-file`.
42
42
 
43
+ The generated Git hook is intentionally a small launcher. It points at the
44
+ package-managed `.github/scripts/pre-commit.sh`, so repositories do not need to
45
+ maintain a second copy of the language-aware hook logic.
46
+
43
47
  ## Setup
44
48
 
45
49
  1. Install [mise](https://mise.jdx.dev/).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-foundry",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "A fast, language-aware repository factory for agent-ready workflows, testing, security, and release automation.",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-or-later",