code-foundry 0.2.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.
- package/.githooks/pre-commit +2 -64
- package/.github/licenses/MIT.txt +21 -0
- package/.github/scripts/init-repo.sh +10 -0
- package/.github/scripts/pre-commit.sh +67 -0
- package/.github/scripts/sync-template.sh +56 -0
- package/.github/template.yml +1 -0
- package/.github/template.yml.example +1 -0
- package/.github/workflows/release-pr.yml +19 -6
- package/CHANGELOG.md +14 -0
- package/README.md +21 -2
- package/package.json +1 -1
- package/src/cli.mjs +10 -0
package/.githooks/pre-commit
CHANGED
|
@@ -1,67 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
set -euo pipefail
|
|
3
3
|
|
|
4
|
-
git
|
|
5
|
-
|
|
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,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) CURRENT_YEAR PROJECT_OWNER
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -13,6 +13,8 @@ package_manager="${REPO_FOUNDRY_PACKAGE_MANAGER:-auto}"
|
|
|
13
13
|
bootstrap=true
|
|
14
14
|
release_type="${REPO_FOUNDRY_RELEASE_TYPE:-auto}"
|
|
15
15
|
npm_publish="${REPO_FOUNDRY_NPM_PUBLISH:-false}"
|
|
16
|
+
license="${REPO_FOUNDRY_LICENSE:-agpl-3.0-or-later}"
|
|
17
|
+
license_file="${REPO_FOUNDRY_LICENSE_FILE:-}"
|
|
16
18
|
tool_dir=""
|
|
17
19
|
|
|
18
20
|
cleanup() {
|
|
@@ -35,6 +37,8 @@ Options:
|
|
|
35
37
|
ci,codeql,security,test,draft-pr,release-pr,release,dependabot
|
|
36
38
|
--package-manager NAME auto, bun, pnpm, yarn, or npm
|
|
37
39
|
--release-type NAME auto, node, python, rust, or simple
|
|
40
|
+
--license NAME agpl-3.0-or-later, mit, preserve, or none
|
|
41
|
+
--license-file PATH Use an exact custom license file
|
|
38
42
|
--npm-publish Enable npm publication in the release workflow
|
|
39
43
|
--dry-run Preview changes without writing files
|
|
40
44
|
--prune Remove disabled standard workflows (never custom workflows)
|
|
@@ -58,6 +62,8 @@ while [ "$#" -gt 0 ]; do
|
|
|
58
62
|
--features) features="${2:?missing feature list}"; shift 2 ;;
|
|
59
63
|
--package-manager) package_manager="${2:?missing package manager}"; shift 2 ;;
|
|
60
64
|
--release-type) release_type="${2:?missing release type}"; shift 2 ;;
|
|
65
|
+
--license) license="${2:?missing license}"; shift 2 ;;
|
|
66
|
+
--license-file) license_file="${2:?missing license file}"; shift 2 ;;
|
|
61
67
|
--npm-publish) npm_publish=true; shift ;;
|
|
62
68
|
--dry-run) dry_run=true; shift ;;
|
|
63
69
|
--prune) prune=true; shift ;;
|
|
@@ -99,7 +105,9 @@ sync_args=(
|
|
|
99
105
|
--languages "$languages"
|
|
100
106
|
--features "$features"
|
|
101
107
|
--package-manager "$package_manager"
|
|
108
|
+
--license "$license"
|
|
102
109
|
)
|
|
110
|
+
if [ -n "$license_file" ]; then sync_args+=(--license-file "$license_file"); fi
|
|
103
111
|
if [ "$dry_run" = true ]; then sync_args+=(--check); else sync_args+=(--apply); fi
|
|
104
112
|
if [ "$prune" = true ]; then sync_args+=(--prune); fi
|
|
105
113
|
bash "$sync_script" "${sync_args[@]}"
|
|
@@ -117,6 +125,7 @@ features="$(awk -F': ' '/^features:/ {print $2; exit}' .github/template.yml 2>/d
|
|
|
117
125
|
package_manager="$(awk -F': ' '/^package_manager:/ {print $2; exit}' .github/template.yml 2>/dev/null || true)"
|
|
118
126
|
release_type="$(awk -F': ' '/^release_type:/ {print $2; exit}' .github/template.yml 2>/dev/null || true)"
|
|
119
127
|
npm_publish="$(awk -F': ' '/^npm_publish:/ {print $2; exit}' .github/template.yml 2>/dev/null || true)"
|
|
128
|
+
license="$(awk -F': ' '/^license:/ {print $2; exit}' .github/template.yml 2>/dev/null || true)"
|
|
120
129
|
{
|
|
121
130
|
printf 'version: 1\n'
|
|
122
131
|
if [ -n "$template_ref" ]; then
|
|
@@ -128,6 +137,7 @@ npm_publish="$(awk -F': ' '/^npm_publish:/ {print $2; exit}' .github/template.ym
|
|
|
128
137
|
printf 'package_manager: %s\n' "$package_manager"
|
|
129
138
|
printf 'release_type: %s\n' "$release_type"
|
|
130
139
|
printf 'npm_publish: %s\n' "$npm_publish"
|
|
140
|
+
printf 'license: %s\n' "$license"
|
|
131
141
|
} > .github/template.yml
|
|
132
142
|
|
|
133
143
|
if [ "$bootstrap" = false ]; then
|
|
@@ -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
|
|
@@ -13,6 +13,8 @@ Options:
|
|
|
13
13
|
--languages LIST auto or comma-separated: typescript,rust,python,solidity
|
|
14
14
|
--features LIST all or comma-separated standard features
|
|
15
15
|
--package-manager NAME auto, bun, pnpm, yarn, or npm
|
|
16
|
+
--license NAME preserve, agpl-3.0-or-later, mit, or none
|
|
17
|
+
--license-file PATH Use an exact custom license file
|
|
16
18
|
--check Preview changes (default)
|
|
17
19
|
--apply Apply changes
|
|
18
20
|
--prune Remove disabled standard workflows
|
|
@@ -39,10 +41,14 @@ package_manager_set=false
|
|
|
39
41
|
template_ref=""
|
|
40
42
|
release_type="${REPO_FOUNDRY_RELEASE_TYPE:-auto}"
|
|
41
43
|
npm_publish="${REPO_FOUNDRY_NPM_PUBLISH:-false}"
|
|
44
|
+
license="${REPO_FOUNDRY_LICENSE:-preserve}"
|
|
45
|
+
license_file="${REPO_FOUNDRY_LICENSE_FILE:-}"
|
|
42
46
|
release_type_set=false
|
|
43
47
|
npm_publish_set=false
|
|
48
|
+
license_set=false
|
|
44
49
|
[ -n "${REPO_FOUNDRY_RELEASE_TYPE:-}" ] && release_type_set=true
|
|
45
50
|
[ -n "${REPO_FOUNDRY_NPM_PUBLISH:-}" ] && npm_publish_set=true
|
|
51
|
+
[ -n "${REPO_FOUNDRY_LICENSE:-}" ] && license_set=true
|
|
46
52
|
node_version="24.18.0"
|
|
47
53
|
bun_version="1.3.14"
|
|
48
54
|
python_version="3.13"
|
|
@@ -96,6 +102,8 @@ while [ "$#" -gt 0 ]; do
|
|
|
96
102
|
--languages) languages="${2:?missing language list}"; languages_set=true; shift 2 ;;
|
|
97
103
|
--features) features="${2:?missing feature list}"; features_set=true; shift 2 ;;
|
|
98
104
|
--package-manager) package_manager="${2:?missing package manager}"; package_manager_set=true; shift 2 ;;
|
|
105
|
+
--license) license="${2:?missing license}"; license_set=true; shift 2 ;;
|
|
106
|
+
--license-file) license_file="${2:?missing license file}"; shift 2 ;;
|
|
99
107
|
--check) mode="check"; shift ;;
|
|
100
108
|
--apply) mode="apply"; shift ;;
|
|
101
109
|
--prune) prune=true; shift ;;
|
|
@@ -130,6 +138,10 @@ if [ -f .github/template.yml ]; then
|
|
|
130
138
|
configured_npm_publish="$(awk -F': ' '/^npm_publish:/ {print $2; exit}' .github/template.yml)"
|
|
131
139
|
[ -n "$configured_npm_publish" ] && npm_publish="$configured_npm_publish"
|
|
132
140
|
fi
|
|
141
|
+
if [ "$license_set" != true ]; then
|
|
142
|
+
configured_license="$(awk -F': ' '/^license:/ {print $2; exit}' .github/template.yml)"
|
|
143
|
+
[ -n "$configured_license" ] && license="$configured_license"
|
|
144
|
+
fi
|
|
133
145
|
fi
|
|
134
146
|
[ -n "$package_manager" ] || package_manager=auto
|
|
135
147
|
case "$package_manager" in
|
|
@@ -146,6 +158,11 @@ contains_word "$valid_release_types" "$release_type" || {
|
|
|
146
158
|
printf 'Unsupported release type: %s\n' "$release_type" >&2
|
|
147
159
|
exit 2
|
|
148
160
|
}
|
|
161
|
+
case "$license" in
|
|
162
|
+
preserve|agpl-3.0-or-later|mit|custom|none) ;;
|
|
163
|
+
*) printf 'Unsupported license: %s\n' "$license" >&2; exit 2 ;;
|
|
164
|
+
esac
|
|
165
|
+
[ -z "$license_file" ] || license=custom
|
|
149
166
|
|
|
150
167
|
if [ -d "$source" ] && [ -f "$source/.github/scripts/sync-template.sh" ]; then
|
|
151
168
|
template_root="$source"
|
|
@@ -213,6 +230,7 @@ files=(
|
|
|
213
230
|
.github/scripts/doctor.sh
|
|
214
231
|
.github/scripts/security.sh
|
|
215
232
|
.github/scripts/sitecustomize.py
|
|
233
|
+
.github/scripts/pre-commit.sh
|
|
216
234
|
.github/scripts/sync-template.sh
|
|
217
235
|
.github/scripts/init-repo.sh
|
|
218
236
|
.github/scripts/sync-codeowners.sh
|
|
@@ -276,6 +294,12 @@ for file in "${files[@]}"; do
|
|
|
276
294
|
echo "Template file missing: $file" >&2
|
|
277
295
|
exit 1
|
|
278
296
|
fi
|
|
297
|
+
if { [ "$file" = LICENSE ] || [ "$file" = NOTICE ]; } && [ "$license" = preserve ] && [ -f "$file" ]; then
|
|
298
|
+
continue
|
|
299
|
+
fi
|
|
300
|
+
if { [ "$file" = LICENSE ] || [ "$file" = NOTICE ]; } && [ "$license" = none ]; then
|
|
301
|
+
continue
|
|
302
|
+
fi
|
|
279
303
|
if [ "$file" = .github/CODEOWNERS ] && [ -f "$file" ]; then
|
|
280
304
|
continue
|
|
281
305
|
fi
|
|
@@ -315,6 +339,37 @@ for file in "${files[@]}"; do
|
|
|
315
339
|
fi
|
|
316
340
|
done
|
|
317
341
|
|
|
342
|
+
write_license() {
|
|
343
|
+
local owner license_source
|
|
344
|
+
[ "$license" != preserve ] || return 0
|
|
345
|
+
[ "$license" != none ] || return 0
|
|
346
|
+
if [ -n "$license_file" ]; then
|
|
347
|
+
[ -f "$license_file" ] || { printf 'License file not found: %s\n' "$license_file" >&2; exit 1; }
|
|
348
|
+
license_source="$license_file"
|
|
349
|
+
else
|
|
350
|
+
case "$license" in
|
|
351
|
+
agpl-3.0-or-later) license_source="$template_root/LICENSE" ;;
|
|
352
|
+
mit) license_source="$template_root/.github/licenses/MIT.txt" ;;
|
|
353
|
+
esac
|
|
354
|
+
[ -f "$license_source" ] || { printf 'License template missing: %s\n' "$license_source" >&2; exit 1; }
|
|
355
|
+
fi
|
|
356
|
+
changed=$((changed + 1))
|
|
357
|
+
if [ "$mode" = check ]; then
|
|
358
|
+
printf 'Would generate LICENSE (%s)\n' "$license"
|
|
359
|
+
return
|
|
360
|
+
fi
|
|
361
|
+
owner="${REPO_FOUNDRY_LICENSE_OWNER:-$(git config user.name 2>/dev/null || true)}"
|
|
362
|
+
[ -n "$owner" ] || owner="Project contributors"
|
|
363
|
+
sed "s/PROJECT_OWNER/$owner/g; s/CURRENT_YEAR/$(date +%Y)/g" "$license_source" > LICENSE
|
|
364
|
+
{
|
|
365
|
+
printf 'Copyright (C) %s %s\n\n' "$(date +%Y)" "$owner"
|
|
366
|
+
printf 'This repository is distributed under %s.\n' "$license"
|
|
367
|
+
} > NOTICE
|
|
368
|
+
printf 'Generated LICENSE and NOTICE for %s.\n' "$license"
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
write_license
|
|
372
|
+
|
|
318
373
|
# Release Please owns changelog updates after initialization. Preserve an
|
|
319
374
|
# existing project history, but give new repositories the expected file.
|
|
320
375
|
if [ ! -f CHANGELOG.md ]; then
|
|
@@ -458,6 +513,7 @@ if [ "$mode" = "apply" ]; then
|
|
|
458
513
|
fi
|
|
459
514
|
printf 'release_type: %s\n' "$release_type"
|
|
460
515
|
printf 'npm_publish: %s\n' "$npm_publish"
|
|
516
|
+
printf 'license: %s\n' "$license"
|
|
461
517
|
} > .github/template.yml
|
|
462
518
|
fi
|
|
463
519
|
|
package/.github/template.yml
CHANGED
|
@@ -51,24 +51,37 @@ jobs:
|
|
|
51
51
|
COMMITS='- No commits found since main.'
|
|
52
52
|
fi
|
|
53
53
|
|
|
54
|
+
if [ "$TOTAL_COMMITS" -eq 1 ]; then
|
|
55
|
+
CHANGE_LABEL=change
|
|
56
|
+
else
|
|
57
|
+
CHANGE_LABEL=changes
|
|
58
|
+
fi
|
|
59
|
+
|
|
54
60
|
cat > "$BODY_FILE" <<EOF
|
|
55
|
-
##
|
|
61
|
+
## Environment promotion
|
|
62
|
+
|
|
63
|
+
Promote the validated \`staging\` environment into \`main\`.
|
|
64
|
+
This is a deployment-promotion PR, not the version-release PR.
|
|
56
65
|
|
|
57
|
-
|
|
66
|
+
- **Source:** \`staging\`
|
|
67
|
+
- **Target:** \`main\`
|
|
68
|
+
- **Changes:** $TOTAL_COMMITS $CHANGE_LABEL
|
|
69
|
+
- **Created:** $DATE
|
|
58
70
|
|
|
59
|
-
###
|
|
71
|
+
### Commit summary
|
|
60
72
|
|
|
61
73
|
$COMMITS
|
|
62
74
|
|
|
63
75
|
### Validation
|
|
64
76
|
|
|
65
|
-
- CI
|
|
66
|
-
-
|
|
77
|
+
- Required CI, test, security, and CodeQL checks must pass before merge.
|
|
78
|
+
- Merge with **rebase** to preserve the linear Conventional Commit history.
|
|
79
|
+
- After merge, Release Please opens a separate versioned release PR with the changelog.
|
|
67
80
|
EOF
|
|
68
81
|
|
|
69
82
|
gh pr create \
|
|
70
83
|
--repo "$GITHUB_REPOSITORY" \
|
|
71
84
|
--base main \
|
|
72
85
|
--head staging \
|
|
73
|
-
--title "
|
|
86
|
+
--title "Promote staging -> main ($DATE)" \
|
|
74
87
|
--body-file "$BODY_FILE"
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
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
|
+
|
|
10
|
+
## [0.3.0](https://github.com/0xPlayerOne/code-foundry/compare/v0.2.0...v0.3.0) (2026-07-28)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **init:** add configurable license generation ([6ea7d93](https://github.com/0xPlayerOne/code-foundry/commit/6ea7d93637620bbb2f46475eeba4789d8a3b580c))
|
|
16
|
+
|
|
3
17
|
## [0.2.0](https://github.com/0xPlayerOne/code-foundry/compare/v0.1.4...v0.2.0) (2026-07-28)
|
|
4
18
|
|
|
5
19
|
|
package/README.md
CHANGED
|
@@ -28,6 +28,22 @@ npx code-foundry init \
|
|
|
28
28
|
Use `code-foundry sync` to update an existing repository and
|
|
29
29
|
`code-foundry doctor` to validate it. Add `--dry-run` to preview changes.
|
|
30
30
|
|
|
31
|
+
Choose the license during initialization without editing generated files:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx code-foundry init --license mit
|
|
35
|
+
npx code-foundry init --license agpl-3.0-or-later
|
|
36
|
+
npx code-foundry init --license-file ./legal/LICENSE.txt
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Initialization defaults to AGPL for new repositories. Synchronization defaults
|
|
40
|
+
to `--license preserve`, so an existing repository's license is never replaced
|
|
41
|
+
unless you explicitly select a license or provide `--license-file`.
|
|
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
|
+
|
|
31
47
|
## Setup
|
|
32
48
|
|
|
33
49
|
1. Install [mise](https://mise.jdx.dev/).
|
|
@@ -36,10 +52,13 @@ Use `code-foundry sync` to update an existing repository and
|
|
|
36
52
|
|
|
37
53
|
## Applying the baseline to an existing repository
|
|
38
54
|
|
|
39
|
-
Run the
|
|
55
|
+
Run the package entrypoint from the repository root. It updates shared
|
|
56
|
+
workflows, GitHub forms, hooks, policy files, and tool configuration while
|
|
57
|
+
preserving the repository's README, `.mise.toml` selections, extra workflows,
|
|
58
|
+
licenses, and application code.
|
|
40
59
|
|
|
41
60
|
```bash
|
|
42
|
-
|
|
61
|
+
npx code-foundry init
|
|
43
62
|
```
|
|
44
63
|
|
|
45
64
|
Use `bash .github/scripts/sync-template.sh --source ... --check` to preview differences. For local template development, pass the template checkout as `--source` and `--ref staging`.
|
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -23,6 +23,8 @@ Init/sync options:
|
|
|
23
23
|
--features LIST all or ci,codeql,security,test,draft-pr,release-pr,release,dependabot
|
|
24
24
|
--package-manager NAME auto, bun, pnpm, yarn, or npm
|
|
25
25
|
--release-type NAME auto, node, python, rust, simple, or none
|
|
26
|
+
--license NAME agpl-3.0-or-later, mit, preserve, or none
|
|
27
|
+
--license-file PATH Use an exact custom license file
|
|
26
28
|
--npm-publish Enable npm publication in the release workflow
|
|
27
29
|
--dry-run Preview changes without writing files
|
|
28
30
|
--prune Remove disabled standard workflows
|
|
@@ -47,6 +49,8 @@ function parseArgs(argv) {
|
|
|
47
49
|
features: process.env.REPO_FOUNDRY_FEATURES || 'all',
|
|
48
50
|
packageManager: process.env.REPO_FOUNDRY_PACKAGE_MANAGER || 'auto',
|
|
49
51
|
releaseType: process.env.REPO_FOUNDRY_RELEASE_TYPE || 'auto',
|
|
52
|
+
license: process.env.REPO_FOUNDRY_LICENSE || (command === 'init' ? 'agpl-3.0-or-later' : 'preserve'),
|
|
53
|
+
licenseFile: process.env.REPO_FOUNDRY_LICENSE_FILE || '',
|
|
50
54
|
npmPublish: process.env.REPO_FOUNDRY_NPM_PUBLISH === 'true',
|
|
51
55
|
languagesSet: false,
|
|
52
56
|
featuresSet: false,
|
|
@@ -64,6 +68,8 @@ function parseArgs(argv) {
|
|
|
64
68
|
['--features', 'features'],
|
|
65
69
|
['--package-manager', 'packageManager'],
|
|
66
70
|
['--release-type', 'releaseType'],
|
|
71
|
+
['--license', 'license'],
|
|
72
|
+
['--license-file', 'licenseFile'],
|
|
67
73
|
])
|
|
68
74
|
|
|
69
75
|
while (argv.length) {
|
|
@@ -107,6 +113,8 @@ function main() {
|
|
|
107
113
|
const { command, options } = parseArgs(process.argv.slice(2))
|
|
108
114
|
const target = resolve(options.target)
|
|
109
115
|
const common = ['--source', options.source, '--ref', options.ref]
|
|
116
|
+
common.push('--license', options.license)
|
|
117
|
+
if (options.licenseFile) common.push('--license-file', options.licenseFile)
|
|
110
118
|
if (options.languagesSet) common.push('--languages', options.languages)
|
|
111
119
|
if (options.featuresSet) common.push('--features', options.features)
|
|
112
120
|
if (options.prune) common.push('--prune')
|
|
@@ -122,7 +130,9 @@ function main() {
|
|
|
122
130
|
'--features', options.features,
|
|
123
131
|
'--package-manager', options.packageManager,
|
|
124
132
|
'--release-type', options.releaseType,
|
|
133
|
+
'--license', options.license,
|
|
125
134
|
]
|
|
135
|
+
if (options.licenseFile) initArgs.push('--license-file', options.licenseFile)
|
|
126
136
|
if (options.protection) initArgs.push('--protection')
|
|
127
137
|
if (options.dryRun) initArgs.push('--dry-run')
|
|
128
138
|
if (options.prune) initArgs.push('--prune')
|