code-foundry 0.22.2 → 0.23.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/.github/actions/setup/action.yml +8 -9
- package/.github/code-foundry.yml +1 -2
- package/.github/code-foundry.yml.example +2 -2
- package/.github/scripts/bootstrap.sh +1 -0
- package/.github/scripts/changed-files.sh +1 -1
- package/.github/scripts/ci.sh +0 -1
- package/.github/scripts/codeql-languages.sh +0 -1
- package/.github/scripts/doctor.sh +0 -1
- package/.github/scripts/init-repo.sh +1 -22
- package/.github/scripts/profile.sh +1 -3
- package/.github/scripts/security.sh +0 -1
- package/.github/scripts/sync-protection.sh +0 -1
- package/.github/scripts/sync-template.sh +4 -27
- package/.github/workflows/reusable-release.yml +0 -1
- package/CHANGELOG.md +7 -0
- package/README.md +10 -31
- package/docs/CONFIGURATION.md +29 -64
- package/docs/INITIALIZATION.md +25 -50
- package/docs/WORKFLOWS.md +2 -1
- package/package.json +1 -1
- package/src/cli.mjs +24 -130
|
@@ -206,7 +206,6 @@ runs:
|
|
|
206
206
|
javascript_package_manager=none
|
|
207
207
|
configured_package_manager=""
|
|
208
208
|
config_file=.github/code-foundry.yml
|
|
209
|
-
[ -f "$config_file" ] || config_file=.github/template.yml
|
|
210
209
|
if [ -f "$config_file" ]; then
|
|
211
210
|
configured_package_manager="$(awk -F': ' '/^package_manager:/ {print $2; exit}' "$config_file")"
|
|
212
211
|
fi
|
|
@@ -389,7 +388,7 @@ runs:
|
|
|
389
388
|
if [ "$javascript" = true ] && task_language_needed javascript; then
|
|
390
389
|
add_configured_tool node
|
|
391
390
|
if { [ -f bun.lock ] || [ -f bun.lockb ] ||
|
|
392
|
-
config_file=.github/code-foundry.yml;
|
|
391
|
+
config_file=.github/code-foundry.yml; awk -F': ' '/^package_manager:/ {print $2; exit}' "$config_file" 2>/dev/null | grep -qx bun; }; then
|
|
393
392
|
add_configured_tool bun
|
|
394
393
|
fi
|
|
395
394
|
fi
|
|
@@ -403,7 +402,7 @@ runs:
|
|
|
403
402
|
javascript)
|
|
404
403
|
configured_tool node && mise_tools+=(node)
|
|
405
404
|
if { [ -f bun.lock ] || [ -f bun.lockb ] ||
|
|
406
|
-
config_file=.github/code-foundry.yml;
|
|
405
|
+
config_file=.github/code-foundry.yml; awk -F': ' '/^package_manager:/ {print $2; exit}' "$config_file" 2>/dev/null | grep -qx bun; } && configured_tool bun; then
|
|
407
406
|
mise_tools+=(bun)
|
|
408
407
|
fi
|
|
409
408
|
;;
|
|
@@ -451,12 +450,12 @@ runs:
|
|
|
451
450
|
(inputs.cache-installed == 'true' ||
|
|
452
451
|
steps.profile.outputs.javascript_package_manager == 'pnpm' ||
|
|
453
452
|
steps.profile.outputs.javascript_package_manager == 'yarn') &&
|
|
454
|
-
hashFiles('**/package.json', '**/bun.lock', '**/bun.lockb', '**/pnpm-lock.yaml', '**/yarn.lock', '**/package-lock.json', '**/.npmrc', '**/.yarnrc*', '**/.pnpmfile.cjs', '.github/code-foundry.yml', '.
|
|
453
|
+
hashFiles('**/package.json', '**/bun.lock', '**/bun.lockb', '**/pnpm-lock.yaml', '**/yarn.lock', '**/package-lock.json', '**/.npmrc', '**/.yarnrc*', '**/.pnpmfile.cjs', '.github/code-foundry.yml', '.mise.toml', 'mise.lock') != ''
|
|
455
454
|
uses: actions/cache/restore@v5
|
|
456
455
|
with:
|
|
457
456
|
path: |
|
|
458
457
|
**/node_modules
|
|
459
|
-
key: ${{ runner.os }}-javascript-installed-v3-${{ hashFiles('**/package.json', '**/bun.lock', '**/bun.lockb', '**/pnpm-lock.yaml', '**/yarn.lock', '**/package-lock.json', '**/.npmrc', '**/.yarnrc*', '**/.pnpmfile.cjs', '.github/code-foundry.yml', '.
|
|
458
|
+
key: ${{ runner.os }}-javascript-installed-v3-${{ hashFiles('**/package.json', '**/bun.lock', '**/bun.lockb', '**/pnpm-lock.yaml', '**/yarn.lock', '**/package-lock.json', '**/.npmrc', '**/.yarnrc*', '**/.pnpmfile.cjs', '.github/code-foundry.yml', '.mise.toml', 'mise.lock') }}
|
|
460
459
|
- name: Restore Bun dependencies
|
|
461
460
|
id: javascript-bun-cache-restore
|
|
462
461
|
if: >-
|
|
@@ -465,12 +464,12 @@ runs:
|
|
|
465
464
|
inputs.cache-installed != 'false' &&
|
|
466
465
|
steps.profile.outputs.javascript_dependencies == 'true' &&
|
|
467
466
|
steps.profile.outputs.javascript_package_manager == 'bun' &&
|
|
468
|
-
hashFiles('**/package.json', '**/bun.lock', '**/bun.lockb', '**/.npmrc', '.github/code-foundry.yml', '.
|
|
467
|
+
hashFiles('**/package.json', '**/bun.lock', '**/bun.lockb', '**/.npmrc', '.github/code-foundry.yml', '.mise.toml', 'mise.lock') != ''
|
|
469
468
|
uses: actions/cache/restore@v5
|
|
470
469
|
with:
|
|
471
470
|
path: |
|
|
472
471
|
**/node_modules
|
|
473
|
-
key: ${{ runner.os }}-javascript-installed-v4-bun-${{ hashFiles('**/package.json', '**/bun.lock', '**/bun.lockb', '**/.npmrc', '.github/code-foundry.yml', '.
|
|
472
|
+
key: ${{ runner.os }}-javascript-installed-v4-bun-${{ hashFiles('**/package.json', '**/bun.lock', '**/bun.lockb', '**/.npmrc', '.github/code-foundry.yml', '.mise.toml', 'mise.lock') }}
|
|
474
473
|
- name: Detect Bun dependencies
|
|
475
474
|
id: javascript-bun-dependencies
|
|
476
475
|
if: >-
|
|
@@ -737,7 +736,7 @@ runs:
|
|
|
737
736
|
with:
|
|
738
737
|
path: |
|
|
739
738
|
**/node_modules
|
|
740
|
-
key: ${{ runner.os }}-javascript-installed-v4-bun-${{ hashFiles('**/package.json', '**/bun.lock', '**/bun.lockb', '**/.npmrc', '.github/code-foundry.yml', '.
|
|
739
|
+
key: ${{ runner.os }}-javascript-installed-v4-bun-${{ hashFiles('**/package.json', '**/bun.lock', '**/bun.lockb', '**/.npmrc', '.github/code-foundry.yml', '.mise.toml', 'mise.lock') }}
|
|
741
740
|
- name: Save installed JavaScript dependencies
|
|
742
741
|
if: >-
|
|
743
742
|
inputs.cache-save == 'true' &&
|
|
@@ -753,7 +752,7 @@ runs:
|
|
|
753
752
|
with:
|
|
754
753
|
path: |
|
|
755
754
|
**/node_modules
|
|
756
|
-
key: ${{ runner.os }}-javascript-installed-v3-${{ hashFiles('**/package.json', '**/bun.lock', '**/bun.lockb', '**/pnpm-lock.yaml', '**/yarn.lock', '**/package-lock.json', '**/.npmrc', '**/.yarnrc*', '**/.pnpmfile.cjs', '.github/code-foundry.yml', '.
|
|
755
|
+
key: ${{ runner.os }}-javascript-installed-v3-${{ hashFiles('**/package.json', '**/bun.lock', '**/bun.lockb', '**/pnpm-lock.yaml', '**/yarn.lock', '**/package-lock.json', '**/.npmrc', '**/.yarnrc*', '**/.pnpmfile.cjs', '.github/code-foundry.yml', '.mise.toml', 'mise.lock') }}
|
|
757
756
|
- name: Save JavaScript packages
|
|
758
757
|
if: >-
|
|
759
758
|
inputs.cache-save == 'true' &&
|
package/.github/code-foundry.yml
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
# Canonical Code Foundry repository configuration.
|
|
2
2
|
version: 1
|
|
3
|
-
template: code-foundry@latest
|
|
4
3
|
profile: auto
|
|
5
4
|
languages: typescript
|
|
6
5
|
features: all
|
|
7
6
|
package_manager: bun
|
|
8
7
|
runtime_repository: 0xPlayerOne/code-foundry
|
|
9
|
-
runtime_ref: v0.22.
|
|
8
|
+
runtime_ref: v0.22.2
|
|
10
9
|
release_type: node
|
|
11
10
|
npm_publish: true
|
|
12
11
|
license: agpl-3.0-or-later
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
1
|
+
# `npx code-foundry init` creates this file automatically. Edit it and run
|
|
2
|
+
# `npx code-foundry sync` whenever you want to change the baseline.
|
|
3
3
|
# Omitted keys use automatic detection and the standard defaults. See
|
|
4
4
|
# docs/CONFIGURATION.md for the complete visual reference.
|
|
5
5
|
|
|
@@ -4,6 +4,7 @@ set -euo pipefail
|
|
|
4
4
|
git config core.hooksPath .githooks
|
|
5
5
|
|
|
6
6
|
if command -v mise >/dev/null 2>&1; then
|
|
7
|
+
mise trust --yes .mise.toml >/dev/null 2>&1 || true
|
|
7
8
|
if [ -f .mise.toml ] && [ ! -f mise.lock ]; then
|
|
8
9
|
if MISE_TRUSTED_CONFIG_PATHS="$PWD" mise lock >/dev/null 2>&1; then
|
|
9
10
|
printf '%s\n' 'Initialized mise.lock for deterministic CI tool installs.'
|
|
@@ -72,7 +72,7 @@ repo_foundry_pr_dependencies_unchanged() {
|
|
|
72
72
|
while IFS= read -r file; do
|
|
73
73
|
case "$file" in
|
|
74
74
|
.github/workflows/security.yml|.github/scripts/security.sh|.github/scripts/changed-files.sh|\
|
|
75
|
-
.github/actions/setup/action.yml|.github/code-foundry.yml|.
|
|
75
|
+
.github/actions/setup/action.yml|.github/code-foundry.yml|.mise.toml|mise.lock|\
|
|
76
76
|
.github/security-audit-allowlist.txt)
|
|
77
77
|
return 1
|
|
78
78
|
;;
|
package/.github/scripts/ci.sh
CHANGED
|
@@ -95,7 +95,6 @@ package_manager() {
|
|
|
95
95
|
configured="$(bash .github/scripts/profile.sh get package_manager 2>/dev/null || true)"
|
|
96
96
|
else
|
|
97
97
|
config_file=.github/code-foundry.yml
|
|
98
|
-
[ -f "$config_file" ] || config_file=.github/template.yml
|
|
99
98
|
if [ -f "$config_file" ]; then
|
|
100
99
|
configured="$(awk -F': ' '/^package_manager:/ {print $2; exit}' "$config_file")"
|
|
101
100
|
fi
|
|
@@ -27,7 +27,6 @@ if [ -x .github/scripts/profile.sh ]; then
|
|
|
27
27
|
configured="$(bash .github/scripts/profile.sh get languages 2>/dev/null || true)"
|
|
28
28
|
else
|
|
29
29
|
config_file=.github/code-foundry.yml
|
|
30
|
-
[ -f "$config_file" ] || config_file=.github/template.yml
|
|
31
30
|
if [ -f "$config_file" ]; then
|
|
32
31
|
configured="$(awk -F': ' '/^languages:/ {print $2; exit}' "$config_file")"
|
|
33
32
|
fi
|
|
@@ -5,7 +5,6 @@ errors=0
|
|
|
5
5
|
|
|
6
6
|
configured_features="all"
|
|
7
7
|
config_file=.github/code-foundry.yml
|
|
8
|
-
[ -f "$config_file" ] || config_file=.github/template.yml
|
|
9
8
|
if [ -f "$config_file" ]; then
|
|
10
9
|
configured_features="$(awk -F': ' '/^features:/ {print $2; exit}' "$config_file")"
|
|
11
10
|
[ -n "$configured_features" ] || configured_features="all"
|
|
@@ -3,7 +3,6 @@ set -euo pipefail
|
|
|
3
3
|
|
|
4
4
|
source="${REPO_FOUNDRY_SOURCE:-https://github.com/${GITHUB_REPOSITORY_OWNER:-OWNER}/code-foundry.git}"
|
|
5
5
|
ref="main"
|
|
6
|
-
config_file="${REPO_FOUNDRY_CONFIG:-}"
|
|
7
6
|
profile="${REPO_FOUNDRY_PROFILE:-auto}"
|
|
8
7
|
protection=false
|
|
9
8
|
dry_run=false
|
|
@@ -67,7 +66,6 @@ Initialize or synchronize a repository from the shared baseline.
|
|
|
67
66
|
Options:
|
|
68
67
|
--source PATH_OR_URL Template source (default: REPO_FOUNDRY_SOURCE or GitHub owner)
|
|
69
68
|
--ref REF Template branch or tag (default: main)
|
|
70
|
-
--config PATH Use a .github/code-foundry.yml configuration file
|
|
71
69
|
--profile NAME auto, application, monorepo, or minimal
|
|
72
70
|
--languages LIST auto or comma-separated: typescript,rust,python,solidity
|
|
73
71
|
--features LIST all or comma-separated optional features:
|
|
@@ -97,7 +95,6 @@ while [ "$#" -gt 0 ]; do
|
|
|
97
95
|
case "$1" in
|
|
98
96
|
--source) source="${2:?missing source path or URL}"; shift 2 ;;
|
|
99
97
|
--ref) ref="${2:?missing ref}"; shift 2 ;;
|
|
100
|
-
--config) config_file="${2:?missing config path}"; shift 2 ;;
|
|
101
98
|
--profile) profile="${2:?missing profile}"; profile_set=true; shift 2 ;;
|
|
102
99
|
--languages) languages="${2:?missing language list}"; languages_set=true; shift 2 ;;
|
|
103
100
|
--features) features="${2:?missing feature list}"; features_set=true; shift 2 ;;
|
|
@@ -121,16 +118,7 @@ while [ "$#" -gt 0 ]; do
|
|
|
121
118
|
esac
|
|
122
119
|
done
|
|
123
120
|
|
|
124
|
-
if [ -n "$config_file" ]; then
|
|
125
|
-
[ -f "$config_file" ] || { printf 'Configuration file not found: %s\n' "$config_file" >&2; exit 1; }
|
|
126
|
-
mkdir -p .github
|
|
127
|
-
if [ "$(cd -- "$(dirname -- "$config_file")" && pwd)/$(basename -- "$config_file")" != "$(pwd)/.github/code-foundry.yml" ]; then
|
|
128
|
-
cp "$config_file" .github/code-foundry.yml
|
|
129
|
-
fi
|
|
130
|
-
fi
|
|
131
|
-
|
|
132
121
|
config_path=.github/code-foundry.yml
|
|
133
|
-
[ -f "$config_path" ] || config_path=.github/template.yml
|
|
134
122
|
if [ -f "$config_path" ]; then
|
|
135
123
|
config_value() {
|
|
136
124
|
awk -F': ' -v key="$1" '$1 == key { value=$2; sub(/[[:space:]]+#.*/, "", value); gsub(/^[[:space:]]+|[[:space:]]+$/, "", value); print value; exit }' "$config_path"
|
|
@@ -210,7 +198,7 @@ if [ -n "$license_file" ]; then sync_args+=(--license-file "$license_file"); fi
|
|
|
210
198
|
if [ "$dry_run" = true ]; then sync_args+=(--check); else sync_args+=(--apply); fi
|
|
211
199
|
if [ "$prune" = true ]; then sync_args+=(--prune); fi
|
|
212
200
|
if [ "$force" = true ]; then sync_args+=(--force); fi
|
|
213
|
-
bash "$sync_script" "${sync_args[@]}"
|
|
201
|
+
REPO_FOUNDRY_INIT=true bash "$sync_script" "${sync_args[@]}"
|
|
214
202
|
|
|
215
203
|
if [ "$dry_run" = true ]; then
|
|
216
204
|
printf '%s\n' 'Dry run complete; no files were changed.'
|
|
@@ -221,7 +209,6 @@ mkdir -p .github
|
|
|
221
209
|
config_value() {
|
|
222
210
|
awk -F': ' -v key="$1" '$1 == key { value=$2; sub(/[[:space:]]+#.*/, "", value); gsub(/^[[:space:]]+|[[:space:]]+$/, "", value); print value; exit }' .github/code-foundry.yml
|
|
223
211
|
}
|
|
224
|
-
template_ref="$(config_value template 2>/dev/null || true)"
|
|
225
212
|
profile="$(config_value profile 2>/dev/null || true)"
|
|
226
213
|
languages="$(config_value languages 2>/dev/null || true)"
|
|
227
214
|
features="$(config_value features 2>/dev/null || true)"
|
|
@@ -233,9 +220,6 @@ npm_publish="$(config_value npm_publish 2>/dev/null || true)"
|
|
|
233
220
|
license="$(config_value license 2>/dev/null || true)"
|
|
234
221
|
{
|
|
235
222
|
printf 'version: 1\n'
|
|
236
|
-
if [ -n "$template_ref" ]; then
|
|
237
|
-
printf 'template: %s\n' "$template_ref"
|
|
238
|
-
fi
|
|
239
223
|
printf 'profile: %s\n' "$profile"
|
|
240
224
|
printf 'languages: %s\n' "$languages"
|
|
241
225
|
printf 'features: %s\n' "$features"
|
|
@@ -263,11 +247,6 @@ license="$(config_value license 2>/dev/null || true)"
|
|
|
263
247
|
printf 'turbo_remote: %s\n' "$turbo_remote"
|
|
264
248
|
} > .github/code-foundry.yml
|
|
265
249
|
|
|
266
|
-
if [ "$config_path" = .github/template.yml ] && [ -f .github/template.yml ]; then
|
|
267
|
-
rm .github/template.yml
|
|
268
|
-
printf '%s\n' 'Migrated .github/template.yml to .github/code-foundry.yml.'
|
|
269
|
-
fi
|
|
270
|
-
|
|
271
250
|
if [ "$bootstrap" = false ]; then
|
|
272
251
|
printf '%s\n' 'Bootstrap skipped.'
|
|
273
252
|
exit 0
|
|
@@ -3,8 +3,7 @@ set -euo pipefail
|
|
|
3
3
|
|
|
4
4
|
# Resolve repository settings with this precedence:
|
|
5
5
|
# explicit REPO_FOUNDRY_* values (CLI callers can export them), then
|
|
6
|
-
# .github/code-foundry.yml, then detected defaults.
|
|
7
|
-
# .github/template.yml is accepted during migration.
|
|
6
|
+
# .github/code-foundry.yml, then detected defaults.
|
|
8
7
|
|
|
9
8
|
root="${REPO_FOUNDRY_ROOT:-$PWD}"
|
|
10
9
|
command="detect"
|
|
@@ -33,7 +32,6 @@ done
|
|
|
33
32
|
|
|
34
33
|
cd "$root"
|
|
35
34
|
template_file=.github/code-foundry.yml
|
|
36
|
-
[ -f "$template_file" ] || template_file=.github/template.yml
|
|
37
35
|
|
|
38
36
|
config_value() {
|
|
39
37
|
local key="$1"
|
|
@@ -107,7 +107,6 @@ package_manager() {
|
|
|
107
107
|
configured="$(bash .github/scripts/profile.sh get package_manager 2>/dev/null || true)"
|
|
108
108
|
else
|
|
109
109
|
config_file=.github/code-foundry.yml
|
|
110
|
-
[ -f "$config_file" ] || config_file=.github/template.yml
|
|
111
110
|
if [ -f "$config_file" ]; then
|
|
112
111
|
configured="$(awk -F': ' '/^package_manager:/ {print $2; exit}' "$config_file")"
|
|
113
112
|
fi
|
|
@@ -8,7 +8,6 @@ configured_features="all"
|
|
|
8
8
|
configured_languages="auto"
|
|
9
9
|
|
|
10
10
|
config_file=.github/code-foundry.yml
|
|
11
|
-
[ -f "$config_file" ] || config_file=.github/template.yml
|
|
12
11
|
if [ -f "$config_file" ]; then
|
|
13
12
|
configured_features="$(awk -F': ' '/^features:/ {print $2; exit}' "$config_file")"
|
|
14
13
|
configured_languages="$(awk -F': ' '/^languages:/ {print $2; exit}' "$config_file")"
|
|
@@ -13,7 +13,6 @@ 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
|
-
--config PATH Use a .github/code-foundry.yml configuration file
|
|
17
16
|
--runtime-repository OWNER/REPO Reusable workflow runtime repository
|
|
18
17
|
--runtime-ref REF Reusable workflow runtime tag or branch
|
|
19
18
|
--license NAME preserve, agpl-3.0-or-later, mit, or none
|
|
@@ -28,7 +27,6 @@ EOF
|
|
|
28
27
|
source_ref="main"
|
|
29
28
|
mode="check"
|
|
30
29
|
source=""
|
|
31
|
-
config_file="${REPO_FOUNDRY_CONFIG:-}"
|
|
32
30
|
temp_dir=""
|
|
33
31
|
profile="${REPO_FOUNDRY_PROFILE:-auto}"
|
|
34
32
|
languages="${REPO_FOUNDRY_LANGUAGES:-auto}"
|
|
@@ -51,7 +49,6 @@ runtime_repository_set=false
|
|
|
51
49
|
[ -n "${REPO_FOUNDRY_RUNTIME_REPOSITORY:-}" ] && runtime_repository_set=true
|
|
52
50
|
runtime_ref_set=false
|
|
53
51
|
[ -n "${REPO_FOUNDRY_RUNTIME_REF:-}" ] && runtime_ref_set=true
|
|
54
|
-
template_ref=""
|
|
55
52
|
release_type="${REPO_FOUNDRY_RELEASE_TYPE:-auto}"
|
|
56
53
|
npm_publish="${REPO_FOUNDRY_NPM_PUBLISH:-false}"
|
|
57
54
|
prune_standard="${REPO_FOUNDRY_PRUNE_STANDARD:-false}"
|
|
@@ -127,7 +124,6 @@ while [ "$#" -gt 0 ]; do
|
|
|
127
124
|
case "$1" in
|
|
128
125
|
--source) source="${2:?missing source path or URL}"; shift 2 ;;
|
|
129
126
|
--ref) source_ref="${2:?missing ref}"; shift 2 ;;
|
|
130
|
-
--config) config_file="${2:?missing config path}"; shift 2 ;;
|
|
131
127
|
--profile) profile="${2:?missing profile}"; profile_set=true; shift 2 ;;
|
|
132
128
|
--languages) languages="${2:?missing language list}"; languages_set=true; shift 2 ;;
|
|
133
129
|
--features) features="${2:?missing feature list}"; features_set=true; shift 2 ;;
|
|
@@ -146,15 +142,11 @@ while [ "$#" -gt 0 ]; do
|
|
|
146
142
|
done
|
|
147
143
|
|
|
148
144
|
[ -n "$source" ] || { usage >&2; exit 2; }
|
|
149
|
-
if [ -n "$config_file" ]; then
|
|
150
|
-
[ -f "$config_file" ] || { printf 'Configuration file not found: %s\n' "$config_file" >&2; exit 1; }
|
|
151
|
-
mkdir -p .github
|
|
152
|
-
if [ "$(cd -- "$(dirname -- "$config_file")" && pwd)/$(basename -- "$config_file")" != "$(pwd)/.github/code-foundry.yml" ]; then
|
|
153
|
-
cp "$config_file" .github/code-foundry.yml
|
|
154
|
-
fi
|
|
155
|
-
fi
|
|
156
145
|
config_path=.github/code-foundry.yml
|
|
157
|
-
[ -f "$config_path" ] ||
|
|
146
|
+
[ -f "$config_path" ] || [ "${REPO_FOUNDRY_INIT:-false}" = true ] || {
|
|
147
|
+
printf '%s\n' 'Missing .github/code-foundry.yml; run `npx code-foundry init` first.' >&2
|
|
148
|
+
exit 1
|
|
149
|
+
}
|
|
158
150
|
if [ -f "$config_path" ]; then
|
|
159
151
|
config_value() {
|
|
160
152
|
awk -F': ' -v key="$1" '$1 == key { value=$2; sub(/[[:space:]]+#.*/, "", value); gsub(/^[[:space:]]+|[[:space:]]+$/, "", value); print value; exit }' "$config_path"
|
|
@@ -180,7 +172,6 @@ if [ -f "$config_path" ]; then
|
|
|
180
172
|
if [ "$runtime_ref_set" = false ]; then
|
|
181
173
|
runtime_ref="$(config_value runtime_ref)"
|
|
182
174
|
fi
|
|
183
|
-
template_ref="$(config_value template)"
|
|
184
175
|
if [ "$release_type_set" != true ]; then
|
|
185
176
|
configured_release_type="$(config_value release_type)"
|
|
186
177
|
[ -n "$configured_release_type" ] && release_type="$configured_release_type"
|
|
@@ -280,7 +271,6 @@ fi
|
|
|
280
271
|
# Prefer an explicit CLI/environment value, then the target's saved contract,
|
|
281
272
|
# then the source template's contract, and finally the stable public runtime.
|
|
282
273
|
source_config="$template_root/.github/code-foundry.yml"
|
|
283
|
-
[ -f "$source_config" ] || source_config="$template_root/.github/template.yml"
|
|
284
274
|
if [ -z "$runtime_ref" ] && [ -f "$source_config" ]; then
|
|
285
275
|
runtime_ref="$(awk -F': ' '/^runtime_ref:/ {print $2; exit}' "$source_config")"
|
|
286
276
|
fi
|
|
@@ -311,11 +301,6 @@ if [ -f "$template_root/.github/scripts/profile.sh" ]; then
|
|
|
311
301
|
npm_publish="$(printf '%s\n' "$profile_output" | awk -F= '$1 == "npm_publish" {print substr($0, index($0, "=") + 1)}')"
|
|
312
302
|
fi
|
|
313
303
|
|
|
314
|
-
if [ -f "$template_root/package.json" ]; then
|
|
315
|
-
template_version="$(awk -F'"' '/"version"[[:space:]]*:/ {print $4; exit}' "$template_root/package.json")"
|
|
316
|
-
[ -n "$template_version" ] && template_ref="code-foundry@$template_version"
|
|
317
|
-
fi
|
|
318
|
-
|
|
319
304
|
files=(
|
|
320
305
|
.editorconfig
|
|
321
306
|
.gitattributes
|
|
@@ -472,7 +457,6 @@ done
|
|
|
472
457
|
source_runtime_repository=""
|
|
473
458
|
source_runtime_ref=""
|
|
474
459
|
source_config="$template_root/.github/code-foundry.yml"
|
|
475
|
-
[ -f "$source_config" ] || source_config="$template_root/.github/template.yml"
|
|
476
460
|
if [ -f "$source_config" ]; then
|
|
477
461
|
source_runtime_repository="$(awk -F': ' '/^runtime_repository:/ {print $2; exit}' "$source_config")"
|
|
478
462
|
source_runtime_ref="$(awk -F': ' '/^runtime_ref:/ {print $2; exit}' "$source_config")"
|
|
@@ -671,9 +655,6 @@ if [ "$mode" = "apply" ]; then
|
|
|
671
655
|
mkdir -p .github
|
|
672
656
|
{
|
|
673
657
|
printf 'version: 1\n'
|
|
674
|
-
if [ -n "$template_ref" ]; then
|
|
675
|
-
printf 'template: %s\n' "$template_ref"
|
|
676
|
-
fi
|
|
677
658
|
printf 'profile: %s\n' "$profile"
|
|
678
659
|
printf 'languages: %s\n' "$languages"
|
|
679
660
|
printf 'features: %s\n' "$features"
|
|
@@ -702,10 +683,6 @@ if [ "$mode" = "apply" ]; then
|
|
|
702
683
|
printf 'license_file: %s\n' "$license_file"
|
|
703
684
|
fi
|
|
704
685
|
} > .github/code-foundry.yml
|
|
705
|
-
if [ "$config_path" = .github/template.yml ] && [ -f .github/template.yml ]; then
|
|
706
|
-
rm .github/template.yml
|
|
707
|
-
printf '%s\n' 'Migrated .github/template.yml to .github/code-foundry.yml.'
|
|
708
|
-
fi
|
|
709
686
|
fi
|
|
710
687
|
|
|
711
688
|
if [ "$prune" = true ]; then
|
|
@@ -48,7 +48,6 @@ jobs:
|
|
|
48
48
|
npm_publish="$(bash .github/scripts/profile.sh get npm_publish)"
|
|
49
49
|
else
|
|
50
50
|
config_file=.github/code-foundry.yml
|
|
51
|
-
[ -f "$config_file" ] || config_file=.github/template.yml
|
|
52
51
|
release_type="$(awk -F': ' '/^release_type:/ {print $2; exit}' "$config_file" 2>/dev/null || true)"
|
|
53
52
|
npm_publish="$(awk -F': ' '/^npm_publish:/ {print $2; exit}' "$config_file" 2>/dev/null || true)"
|
|
54
53
|
fi
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.23.0](https://github.com/0xPlayerOne/code-foundry/compare/v0.22.2...v0.23.0) (2026-07-28)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* simplify initialization and synchronization ([9f4643e](https://github.com/0xPlayerOne/code-foundry/commit/9f4643e854a262eb923a4fe84ddb986c3f1bdf77))
|
|
9
|
+
|
|
3
10
|
## [0.22.2](https://github.com/0xPlayerOne/code-foundry/compare/v0.22.1...v0.22.2) (2026-07-28)
|
|
4
11
|
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -18,25 +18,20 @@ Run this from the root of a repository:
|
|
|
18
18
|
npx code-foundry init
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Initialization is repository-aware. It detects supported languages, package
|
|
22
|
+
manager, profile, release strategy, and required mise tools, then writes the
|
|
23
|
+
resolved choices to `.github/code-foundry.yml`.
|
|
22
24
|
|
|
23
25
|
```bash
|
|
24
|
-
#
|
|
25
|
-
npx code-foundry
|
|
26
|
-
|
|
27
|
-
# Choose a license
|
|
28
|
-
npx code-foundry init --license mit
|
|
29
|
-
|
|
30
|
-
# Preview without changing files
|
|
31
|
-
npx code-foundry init --dry-run
|
|
26
|
+
# Review or change the generated configuration, then render it
|
|
27
|
+
npx code-foundry sync
|
|
32
28
|
```
|
|
33
29
|
|
|
34
30
|
For an existing installation, use `npx code-foundry sync`. Run
|
|
35
31
|
`npx code-foundry doctor` to inspect the resulting repository configuration.
|
|
36
32
|
|
|
37
|
-
If `.github/code-foundry.yml` already exists,
|
|
38
|
-
|
|
39
|
-
file, run `npx code-foundry sync` to render the selected configuration.
|
|
33
|
+
If `.github/code-foundry.yml` already exists, `init` uses it as the repository
|
|
34
|
+
contract. For normal updates, edit that file and run `npx code-foundry sync`.
|
|
40
35
|
|
|
41
36
|
## What it installs
|
|
42
37
|
|
|
@@ -56,31 +51,15 @@ preserved and can coexist with the standard baseline.
|
|
|
56
51
|
|
|
57
52
|
## Configuration
|
|
58
53
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
```text
|
|
62
|
-
--profile auto|application|monorepo|minimal
|
|
63
|
-
--languages auto|typescript,rust,python,solidity
|
|
64
|
-
--features all|ci,codeql,security,test,draft-pr,release-pr,release,dependabot
|
|
65
|
-
--package-manager auto|bun|pnpm|yarn|npm
|
|
66
|
-
--runtime-repository OWNER/REPO
|
|
67
|
-
--runtime-ref TAG_OR_BRANCH
|
|
68
|
-
--release-type auto|node|python|rust|simple|none
|
|
69
|
-
--license agpl-3.0-or-later|mit|preserve|none
|
|
70
|
-
--license-file PATH
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
The selected profile is saved in `.github/code-foundry.yml`. Explicit flags take
|
|
74
|
-
precedence over `REPO_FOUNDRY_*` environment/repository variables, which take
|
|
75
|
-
precedence over that file and automatic detection. See
|
|
54
|
+
The generated configuration is the one place to control the baseline. See
|
|
76
55
|
[Configuration reference](docs/CONFIGURATION.md) for the visual configuration
|
|
77
56
|
guide and [Initialization and synchronization](docs/INITIALIZATION.md) for
|
|
78
|
-
the
|
|
57
|
+
the two-command workflow.
|
|
79
58
|
|
|
80
59
|
New repositories default to AGPL-3.0-or-later. Synchronization preserves an
|
|
81
60
|
existing license unless a replacement is explicitly selected. Authored
|
|
82
61
|
documentation, application files, custom workflows, and existing `.mise.toml`
|
|
83
|
-
files are preserved by default
|
|
62
|
+
files are preserved by default.
|
|
84
63
|
|
|
85
64
|
## Workflow model
|
|
86
65
|
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
# Configuration reference
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
Initialize from it with:
|
|
3
|
+
Code Foundry has one repository-owned control plane: `.github/code-foundry.yml`.
|
|
5
4
|
|
|
6
5
|
```bash
|
|
7
|
-
npx code-foundry init
|
|
6
|
+
npx code-foundry init
|
|
8
7
|
```
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
and custom workflows remain protected.
|
|
9
|
+
Initialization detects the repository and writes a fully resolved configuration.
|
|
10
|
+
Edit that file directly, then run `npx code-foundry sync`.
|
|
13
11
|
|
|
14
12
|
## Configuration flow
|
|
15
13
|
|
|
16
14
|
```text
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
repository manifests and source
|
|
16
|
+
|
|
|
17
|
+
v
|
|
18
|
+
.github/code-foundry.yml
|
|
19
|
+
|
|
|
20
|
+
+--> mise and environment setup
|
|
21
|
+
+--> standard workflow callers
|
|
22
|
+
+--> runtime repository and version
|
|
23
|
+
+--> release, license, cache, and coverage policy
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## Core settings
|
|
@@ -28,60 +28,25 @@ code-foundry.yml
|
|
|
28
28
|
| Key | Values | Purpose |
|
|
29
29
|
| --- | --- | --- |
|
|
30
30
|
| `profile` | `auto`, `application`, `monorepo`, `minimal` | Repository shape |
|
|
31
|
-
| `languages` |
|
|
32
|
-
| `package_manager` | `
|
|
33
|
-
| `features` | `all` or
|
|
34
|
-
| `prune_standard` | `true` or `false` | Remove disabled standard callers
|
|
35
|
-
| `runtime_repository` | `OWNER/REPO`
|
|
31
|
+
| `languages` | detected list | TypeScript, Rust, Python, Solidity |
|
|
32
|
+
| `package_manager` | `bun`, `pnpm`, `yarn`, `npm`, `none` | JavaScript setup |
|
|
33
|
+
| `features` | `all` or a list | Standard workflow callers |
|
|
34
|
+
| `prune_standard` | `true` or `false` | Remove disabled standard callers |
|
|
35
|
+
| `runtime_repository` | `OWNER/REPO` | Reusable workflow source |
|
|
36
36
|
| `runtime_ref` | tag or branch | Reusable workflow version |
|
|
37
|
-
| `release_type` | `
|
|
37
|
+
| `release_type` | `node`, `python`, `rust`, `simple`, `none` | Release strategy |
|
|
38
38
|
| `npm_publish` | `true` or `false` | Opt into npm publication |
|
|
39
|
-
| `license` | license name, `preserve`, `none` | License
|
|
40
|
-
| `
|
|
39
|
+
| `license` | license name, `preserve`, `none` | License policy |
|
|
40
|
+
| `runner` fields | GitHub runner names | Per-workflow runner policy |
|
|
41
41
|
|
|
42
|
-
Supported
|
|
43
|
-
|
|
44
|
-
`release`, and `dependabot`.
|
|
42
|
+
Supported features are `ci`, `codeql`, `security`, `test`, `draft-pr`,
|
|
43
|
+
`release-pr`, `release`, and `dependabot`.
|
|
45
44
|
|
|
46
|
-
##
|
|
45
|
+
## Editing workflow
|
|
47
46
|
|
|
48
|
-
|
|
47
|
+
`init` creates the file and renders the baseline. `sync` reads the file and
|
|
48
|
+
refreshes standard files from the configured runtime. Generated callers are
|
|
49
|
+
short and replaceable; custom workflows and project documentation are kept.
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
| `runner` | `ubuntu-latest` | Shared fallback |
|
|
53
|
-
| `unit_runner` | `ubuntu-slim` | Unit tests |
|
|
54
|
-
| `ci_runner` | `ubuntu-latest` | Format, lint, type-check, build |
|
|
55
|
-
| `test_runner` | `ubuntu-latest` | Integration, E2E, smoke |
|
|
56
|
-
| `security_runner` | `ubuntu-slim` | Profile and dependency security jobs |
|
|
57
|
-
| `codeql_runner` | `ubuntu-latest` | CodeQL detection and analyzers |
|
|
58
|
-
| `pr_runner` | `ubuntu-slim` | Draft and Release PR automation |
|
|
59
|
-
| `release_runner` | `ubuntu-slim` | Release and package publication |
|
|
60
|
-
|
|
61
|
-
Use the full runner for native toolchains, browsers, or measured dependency
|
|
62
|
-
workloads. Use `ubuntu-slim` for lightweight orchestration and small projects.
|
|
63
|
-
|
|
64
|
-
## Performance and quality
|
|
65
|
-
|
|
66
|
-
| Key | Default | Purpose |
|
|
67
|
-
| --- | --- | --- |
|
|
68
|
-
| `cache_packages` | `auto` | Package-store caching policy |
|
|
69
|
-
| `cache_build` | `auto` | Build-cache policy |
|
|
70
|
-
| `coverage_minimum` | `80` | Shared Bun/Python coverage target |
|
|
71
|
-
| `turbo_remote` | `auto` | Turborepo remote-cache policy |
|
|
72
|
-
|
|
73
|
-
Turborepo remote caching still requires the repository secret `TURBO_TOKEN` and
|
|
74
|
-
the variable `TURBO_TEAM`; the file controls policy, not credentials.
|
|
75
|
-
|
|
76
|
-
## Precedence
|
|
77
|
-
|
|
78
|
-
The resolved value order is:
|
|
79
|
-
|
|
80
|
-
```text
|
|
81
|
-
explicit CLI flag -> REPO_FOUNDRY_* variable -> code-foundry.yml -> detection/default
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Use variables for temporary CI overrides. Keep durable repository policy in
|
|
85
|
-
`.github/code-foundry.yml` so humans and agents have one discoverable source of
|
|
86
|
-
truth. The example file is a commented starter guide; it is intentionally not
|
|
87
|
-
a second generated configuration.
|
|
51
|
+
The generated configuration includes all defaults so humans and agents can
|
|
52
|
+
understand the repository without memorizing flags or environment variables.
|
package/docs/INITIALIZATION.md
CHANGED
|
@@ -1,67 +1,42 @@
|
|
|
1
1
|
# Initialization and synchronization
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## The two-command workflow
|
|
4
4
|
|
|
5
|
-
Run
|
|
5
|
+
Run these commands from a repository root:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npx code-foundry init
|
|
9
|
-
npx code-foundry sync
|
|
8
|
+
npx code-foundry init
|
|
9
|
+
npx code-foundry sync
|
|
10
10
|
npx code-foundry doctor
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
`init` detects supported languages, package manager, repository profile,
|
|
14
|
+
release strategy, mise tools, and standard features. It writes the resolved
|
|
15
|
+
choices to `.github/code-foundry.yml`, initializes the local environment, and
|
|
16
|
+
renders the standard baseline.
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
The file is copied to `.github/code-foundry.yml`, normalized, and used to render
|
|
22
|
-
the standard callers. Later edits can be applied with `npx code-foundry sync`.
|
|
23
|
-
|
|
24
|
-
Use `--dry-run` to preview changes. Use `--no-bootstrap` when the repository is
|
|
25
|
-
being initialized in CI or on a machine without mise. Run
|
|
26
|
-
`bash .github/scripts/bootstrap.sh` later to install tools, enable hooks, and
|
|
27
|
-
run the repository doctor.
|
|
28
|
-
|
|
29
|
-
## Profiles and features
|
|
18
|
+
After reviewing or editing the configuration, run `sync` to apply it. Sync can
|
|
19
|
+
be run at any time to pull in a newer runtime configured by `runtime_ref`.
|
|
30
20
|
|
|
31
|
-
|
|
32
|
-
`--languages auto` detects them from manifests and source files. Profiles are
|
|
33
|
-
`auto`, `application`, `monorepo`, and `minimal`.
|
|
21
|
+
## Detection
|
|
34
22
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
Supported languages are TypeScript, Rust, Python, and Solidity. Detection uses
|
|
24
|
+
manifests, lockfiles, source extensions, workspace metadata, and existing
|
|
25
|
+
project scripts. The generated values are explicit, so later syncs are stable
|
|
26
|
+
until a maintainer changes the file.
|
|
39
27
|
|
|
40
28
|
## Runtime selection
|
|
41
29
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
npx code-foundry init \
|
|
48
|
-
--runtime-repository OWNER/REPO \
|
|
49
|
-
--runtime-ref v1.2.3
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Both values are persisted in `.github/code-foundry.yml` and rendered into the
|
|
53
|
-
standard callers. `REPO_FOUNDRY_RUNTIME_REPOSITORY` and
|
|
54
|
-
`REPO_FOUNDRY_RUNTIME_REF` provide equivalent environment/repository-variable
|
|
55
|
-
overrides.
|
|
30
|
+
Workflow callers use `runtime_repository` and `runtime_ref` from
|
|
31
|
+
`.github/code-foundry.yml`. Change those values directly for a fork or staged
|
|
32
|
+
runtime, then run sync.
|
|
56
33
|
|
|
57
|
-
##
|
|
34
|
+
## Preservation rules
|
|
58
35
|
|
|
59
|
-
|
|
60
|
-
`.mise.toml` selections,
|
|
61
|
-
|
|
62
|
-
file is explicitly selected. Use `--force` only when intentionally refreshing
|
|
63
|
-
protected standard documents.
|
|
36
|
+
Sync updates standard Code Foundry files only. It preserves application code,
|
|
37
|
+
authored documentation, existing `.mise.toml` selections, and custom workflows
|
|
38
|
+
such as deployment, search, Slither, or monitoring workflows.
|
|
64
39
|
|
|
65
|
-
The
|
|
66
|
-
|
|
67
|
-
|
|
40
|
+
The environment bootstrap installs or reuses mise-managed tools, enables the
|
|
41
|
+
repository hooks, and runs the repository doctor. Re-run
|
|
42
|
+
`bash .github/scripts/bootstrap.sh` if local tools need to be repaired.
|
package/docs/WORKFLOWS.md
CHANGED
|
@@ -58,7 +58,8 @@ Use the initializer's protection helper after reviewing the repository's
|
|
|
58
58
|
enabled features:
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
|
-
|
|
61
|
+
Use the repository's GitHub settings or the maintainer's branch-protection
|
|
62
|
+
automation to apply required checks after initialization.
|
|
62
63
|
```
|
|
63
64
|
|
|
64
65
|
Keep strict status checks, linear history, and conversation resolution enabled.
|
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -10,31 +10,19 @@ const packageRoot = resolve(fileURLToPath(new URL('..', import.meta.url)))
|
|
|
10
10
|
const usage = `code-foundry — initialize and maintain agent-ready repositories
|
|
11
11
|
|
|
12
12
|
Usage:
|
|
13
|
-
code-foundry init [
|
|
14
|
-
code-foundry sync [
|
|
15
|
-
code-foundry doctor [--target PATH]
|
|
13
|
+
npx code-foundry init [--target PATH]
|
|
14
|
+
npx code-foundry sync [--target PATH]
|
|
15
|
+
npx code-foundry doctor [--target PATH]
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
--
|
|
23
|
-
--
|
|
24
|
-
--
|
|
25
|
-
|
|
26
|
-
--runtime-repository OWNER/REPO Reusable workflow runtime repository
|
|
27
|
-
--runtime-ref REF Reusable workflow runtime tag or branch
|
|
28
|
-
--release-type NAME auto, node, python, rust, simple, or none
|
|
29
|
-
--license NAME agpl-3.0-or-later, mit, preserve, or none
|
|
30
|
-
--license-file PATH Use an exact custom license file
|
|
31
|
-
--npm-publish Enable npm publication in the release workflow
|
|
32
|
-
--dry-run Preview changes without writing files
|
|
33
|
-
--force Replace protected standard docs/templates
|
|
34
|
-
--prune Remove disabled standard workflows
|
|
35
|
-
--protection Synchronize main branch protections (init only)
|
|
36
|
-
--no-bootstrap Skip mise/hooks/doctor bootstrap after init
|
|
37
|
-
-h, --help Show this help
|
|
17
|
+
The repository configuration lives in .github/code-foundry.yml.
|
|
18
|
+
init detects the repository, creates that file, and renders the baseline.
|
|
19
|
+
sync reads it and refreshes standard files from the configured runtime.
|
|
20
|
+
|
|
21
|
+
Options:
|
|
22
|
+
--target PATH Repository directory (default: current directory)
|
|
23
|
+
--dry-run Preview changes without writing files
|
|
24
|
+
--force Replace protected standard documents
|
|
25
|
+
-h, --help Show this help
|
|
38
26
|
`
|
|
39
27
|
|
|
40
28
|
function fail(message) {
|
|
@@ -44,55 +32,7 @@ function fail(message) {
|
|
|
44
32
|
|
|
45
33
|
function parseArgs(argv) {
|
|
46
34
|
const command = argv[0] && !argv[0].startsWith('-') ? argv.shift() : 'init'
|
|
47
|
-
const options = {
|
|
48
|
-
target: process.cwd(),
|
|
49
|
-
source: packageRoot,
|
|
50
|
-
ref: 'main',
|
|
51
|
-
config: process.env.REPO_FOUNDRY_CONFIG || '',
|
|
52
|
-
profile: process.env.REPO_FOUNDRY_PROFILE || 'auto',
|
|
53
|
-
languages: process.env.REPO_FOUNDRY_LANGUAGES || 'auto',
|
|
54
|
-
features: process.env.REPO_FOUNDRY_FEATURES || 'all',
|
|
55
|
-
packageManager: process.env.REPO_FOUNDRY_PACKAGE_MANAGER || 'auto',
|
|
56
|
-
// Leave this empty unless the caller explicitly selects a runtime. The
|
|
57
|
-
// initializer can then derive the runtime from --source, which keeps
|
|
58
|
-
// organization forks plug-and-play.
|
|
59
|
-
runtimeRepository: process.env.REPO_FOUNDRY_RUNTIME_REPOSITORY || '',
|
|
60
|
-
runtimeRef: process.env.REPO_FOUNDRY_RUNTIME_REF || '',
|
|
61
|
-
releaseType: process.env.REPO_FOUNDRY_RELEASE_TYPE || 'auto',
|
|
62
|
-
license: process.env.REPO_FOUNDRY_LICENSE || (command === 'init' ? 'agpl-3.0-or-later' : 'preserve'),
|
|
63
|
-
licenseFile: process.env.REPO_FOUNDRY_LICENSE_FILE || '',
|
|
64
|
-
npmPublish: process.env.REPO_FOUNDRY_NPM_PUBLISH === 'true',
|
|
65
|
-
languagesSet: false,
|
|
66
|
-
featuresSet: false,
|
|
67
|
-
profileSet: Boolean(process.env.REPO_FOUNDRY_PROFILE),
|
|
68
|
-
packageManagerSet: Boolean(process.env.REPO_FOUNDRY_PACKAGE_MANAGER),
|
|
69
|
-
runtimeRepositorySet: Boolean(process.env.REPO_FOUNDRY_RUNTIME_REPOSITORY),
|
|
70
|
-
runtimeRefSet: Boolean(process.env.REPO_FOUNDRY_RUNTIME_REF),
|
|
71
|
-
releaseTypeSet: Boolean(process.env.REPO_FOUNDRY_RELEASE_TYPE),
|
|
72
|
-
licenseSet: Boolean(process.env.REPO_FOUNDRY_LICENSE),
|
|
73
|
-
licenseFileSet: Boolean(process.env.REPO_FOUNDRY_LICENSE_FILE),
|
|
74
|
-
npmPublishSet: Boolean(process.env.REPO_FOUNDRY_NPM_PUBLISH),
|
|
75
|
-
dryRun: false,
|
|
76
|
-
prune: false,
|
|
77
|
-
force: false,
|
|
78
|
-
protection: false,
|
|
79
|
-
bootstrap: true,
|
|
80
|
-
}
|
|
81
|
-
const values = new Map([
|
|
82
|
-
['--target', 'target'],
|
|
83
|
-
['--source', 'source'],
|
|
84
|
-
['--ref', 'ref'],
|
|
85
|
-
['--config', 'config'],
|
|
86
|
-
['--profile', 'profile'],
|
|
87
|
-
['--languages', 'languages'],
|
|
88
|
-
['--features', 'features'],
|
|
89
|
-
['--package-manager', 'packageManager'],
|
|
90
|
-
['--runtime-repository', 'runtimeRepository'],
|
|
91
|
-
['--runtime-ref', 'runtimeRef'],
|
|
92
|
-
['--release-type', 'releaseType'],
|
|
93
|
-
['--license', 'license'],
|
|
94
|
-
['--license-file', 'licenseFile'],
|
|
95
|
-
])
|
|
35
|
+
const options = { target: process.cwd(), dryRun: false, force: false }
|
|
96
36
|
|
|
97
37
|
while (argv.length) {
|
|
98
38
|
const arg = argv.shift()
|
|
@@ -100,28 +40,13 @@ function parseArgs(argv) {
|
|
|
100
40
|
console.log(usage)
|
|
101
41
|
process.exit(0)
|
|
102
42
|
}
|
|
103
|
-
if (
|
|
43
|
+
if (arg === '--target') {
|
|
104
44
|
const value = argv.shift()
|
|
105
|
-
if (!value || value.startsWith('-')) fail(
|
|
106
|
-
options
|
|
107
|
-
|
|
108
|
-
if (arg === '--features') options.featuresSet = true
|
|
109
|
-
if (arg === '--profile') options.profileSet = true
|
|
110
|
-
if (arg === '--package-manager') options.packageManagerSet = true
|
|
111
|
-
if (arg === '--runtime-repository') options.runtimeRepositorySet = true
|
|
112
|
-
if (arg === '--runtime-ref') options.runtimeRefSet = true
|
|
113
|
-
if (arg === '--release-type') options.releaseTypeSet = true
|
|
114
|
-
if (arg === '--license') options.licenseSet = true
|
|
115
|
-
if (arg === '--license-file') options.licenseFileSet = true
|
|
116
|
-
continue
|
|
117
|
-
}
|
|
118
|
-
if (arg === '--dry-run') options.dryRun = true
|
|
45
|
+
if (!value || value.startsWith('-')) fail('--target requires a path')
|
|
46
|
+
options.target = value
|
|
47
|
+
} else if (arg === '--dry-run') options.dryRun = true
|
|
119
48
|
else if (arg === '--force') options.force = true
|
|
120
|
-
else
|
|
121
|
-
else if (arg === '--protection') options.protection = true
|
|
122
|
-
else if (arg === '--no-bootstrap') options.bootstrap = false
|
|
123
|
-
else if (arg === '--npm-publish') { options.npmPublish = true; options.npmPublishSet = true }
|
|
124
|
-
else fail(`unknown option: ${arg}`)
|
|
49
|
+
else fail(`unknown option: ${arg}; run --help for the supported options`)
|
|
125
50
|
}
|
|
126
51
|
|
|
127
52
|
return { command, options }
|
|
@@ -142,51 +67,20 @@ function run(script, args, target) {
|
|
|
142
67
|
function main() {
|
|
143
68
|
const { command, options } = parseArgs(process.argv.slice(2))
|
|
144
69
|
const target = resolve(options.target)
|
|
145
|
-
const common = ['--source',
|
|
146
|
-
if (options.config) common.push('--config', options.config)
|
|
147
|
-
if (options.profileSet) common.push('--profile', options.profile)
|
|
148
|
-
if (options.languagesSet) common.push('--languages', options.languages)
|
|
149
|
-
if (options.featuresSet) common.push('--features', options.features)
|
|
150
|
-
if (options.packageManagerSet) common.push('--package-manager', options.packageManager)
|
|
151
|
-
if (options.runtimeRepositorySet) common.push('--runtime-repository', options.runtimeRepository)
|
|
152
|
-
if (options.runtimeRefSet) common.push('--runtime-ref', options.runtimeRef)
|
|
153
|
-
if (options.releaseTypeSet) common.push('--release-type', options.releaseType)
|
|
154
|
-
if (options.licenseSet) common.push('--license', options.license)
|
|
155
|
-
if (options.licenseFileSet && options.licenseFile) common.push('--license-file', options.licenseFile)
|
|
156
|
-
if (options.prune) common.push('--prune')
|
|
157
|
-
if (options.force) common.push('--force')
|
|
70
|
+
const common = ['--source', packageRoot, '--ref', 'main']
|
|
158
71
|
if (options.dryRun) common.push('--check')
|
|
159
72
|
else common.push('--apply')
|
|
73
|
+
if (options.force) common.push('--force')
|
|
160
74
|
|
|
161
75
|
if (command === 'init') {
|
|
162
|
-
const initArgs = [
|
|
163
|
-
'--source', options.source,
|
|
164
|
-
'--ref', options.ref,
|
|
165
|
-
]
|
|
166
|
-
if (options.profileSet) initArgs.push('--profile', options.profile)
|
|
167
|
-
if (options.languagesSet) initArgs.push('--languages', options.languages)
|
|
168
|
-
if (options.featuresSet) initArgs.push('--features', options.features)
|
|
169
|
-
if (options.packageManagerSet) initArgs.push('--package-manager', options.packageManager)
|
|
170
|
-
if (options.releaseTypeSet) initArgs.push('--release-type', options.releaseType)
|
|
171
|
-
if (options.licenseSet) initArgs.push('--license', options.license)
|
|
172
|
-
if (options.config) initArgs.push('--config', options.config)
|
|
173
|
-
if (options.runtimeRepositorySet) initArgs.push('--runtime-repository', options.runtimeRepository)
|
|
174
|
-
if (options.runtimeRefSet) initArgs.push('--runtime-ref', options.runtimeRef)
|
|
175
|
-
if (options.licenseFileSet && options.licenseFile) initArgs.push('--license-file', options.licenseFile)
|
|
176
|
-
if (options.protection) initArgs.push('--protection')
|
|
76
|
+
const initArgs = ['--source', packageRoot, '--ref', 'main']
|
|
177
77
|
if (options.dryRun) initArgs.push('--dry-run')
|
|
178
|
-
if (options.prune) initArgs.push('--prune')
|
|
179
78
|
if (options.force) initArgs.push('--force')
|
|
180
|
-
if (options.npmPublishSet && options.npmPublish) initArgs.push('--npm-publish')
|
|
181
|
-
if (!options.bootstrap) initArgs.push('--no-bootstrap')
|
|
182
79
|
run('init-repo.sh', initArgs, target)
|
|
183
|
-
} else if (command === 'sync') {
|
|
184
|
-
run('sync-template.sh', common, target)
|
|
185
|
-
} else if (command === 'doctor') {
|
|
186
|
-
run('doctor.sh', [], target)
|
|
187
|
-
} else {
|
|
188
|
-
fail(`unknown command: ${command}`)
|
|
189
80
|
}
|
|
81
|
+
else if (command === 'sync') run('sync-template.sh', common, target)
|
|
82
|
+
else if (command === 'doctor') run('doctor.sh', [], target)
|
|
83
|
+
else fail(`unknown command: ${command}`)
|
|
190
84
|
}
|
|
191
85
|
|
|
192
86
|
main()
|