code-foundry 0.2.0 → 0.3.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.
@@ -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
@@ -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,10 @@ 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|none) ;;
163
+ *) printf 'Unsupported license: %s\n' "$license" >&2; exit 2 ;;
164
+ esac
149
165
 
150
166
  if [ -d "$source" ] && [ -f "$source/.github/scripts/sync-template.sh" ]; then
151
167
  template_root="$source"
@@ -276,6 +292,12 @@ for file in "${files[@]}"; do
276
292
  echo "Template file missing: $file" >&2
277
293
  exit 1
278
294
  fi
295
+ if { [ "$file" = LICENSE ] || [ "$file" = NOTICE ]; } && [ "$license" = preserve ] && [ -f "$file" ]; then
296
+ continue
297
+ fi
298
+ if { [ "$file" = LICENSE ] || [ "$file" = NOTICE ]; } && [ "$license" = none ]; then
299
+ continue
300
+ fi
279
301
  if [ "$file" = .github/CODEOWNERS ] && [ -f "$file" ]; then
280
302
  continue
281
303
  fi
@@ -315,6 +337,37 @@ for file in "${files[@]}"; do
315
337
  fi
316
338
  done
317
339
 
340
+ write_license() {
341
+ local owner license_source
342
+ [ "$license" != preserve ] || return 0
343
+ [ "$license" != none ] || return 0
344
+ if [ -n "$license_file" ]; then
345
+ [ -f "$license_file" ] || { printf 'License file not found: %s\n' "$license_file" >&2; exit 1; }
346
+ license_source="$license_file"
347
+ else
348
+ case "$license" in
349
+ agpl-3.0-or-later) license_source="$template_root/LICENSE" ;;
350
+ mit) license_source="$template_root/.github/licenses/MIT.txt" ;;
351
+ esac
352
+ [ -f "$license_source" ] || { printf 'License template missing: %s\n' "$license_source" >&2; exit 1; }
353
+ fi
354
+ changed=$((changed + 1))
355
+ if [ "$mode" = check ]; then
356
+ printf 'Would generate LICENSE (%s)\n' "$license"
357
+ return
358
+ fi
359
+ owner="${REPO_FOUNDRY_LICENSE_OWNER:-$(git config user.name 2>/dev/null || true)}"
360
+ [ -n "$owner" ] || owner="Project contributors"
361
+ sed "s/PROJECT_OWNER/$owner/g; s/CURRENT_YEAR/$(date +%Y)/g" "$license_source" > LICENSE
362
+ {
363
+ printf 'Copyright (C) %s %s\n\n' "$(date +%Y)" "$owner"
364
+ printf 'This repository is distributed under %s.\n' "$license"
365
+ } > NOTICE
366
+ printf 'Generated LICENSE and NOTICE for %s.\n' "$license"
367
+ }
368
+
369
+ write_license
370
+
318
371
  # Release Please owns changelog updates after initialization. Preserve an
319
372
  # existing project history, but give new repositories the expected file.
320
373
  if [ ! -f CHANGELOG.md ]; then
@@ -458,6 +511,7 @@ if [ "$mode" = "apply" ]; then
458
511
  fi
459
512
  printf 'release_type: %s\n' "$release_type"
460
513
  printf 'npm_publish: %s\n' "$npm_publish"
514
+ printf 'license: %s\n' "$license"
461
515
  } > .github/template.yml
462
516
  fi
463
517
 
@@ -6,6 +6,7 @@ features: all
6
6
  package_manager: bun
7
7
  release_type: node
8
8
  npm_publish: true
9
+ license: agpl-3.0-or-later
9
10
  runner: ubuntu-latest
10
11
  unit_runner: ubuntu-slim
11
12
  cache_packages: auto
@@ -7,6 +7,7 @@ features: all
7
7
  package_manager: auto
8
8
  release_type: auto
9
9
  npm_publish: false
10
+ license: preserve
10
11
  runner: ubuntu-latest
11
12
  unit_runner: ubuntu-slim
12
13
  cache_packages: auto
@@ -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
- ## Release summary
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
- Automated release PR from \`staging\` into \`main\` created on $DATE.
66
+ - **Source:** \`staging\`
67
+ - **Target:** \`main\`
68
+ - **Changes:** $TOTAL_COMMITS $CHANGE_LABEL
69
+ - **Created:** $DATE
58
70
 
59
- ### Changes since main
71
+ ### Commit summary
60
72
 
61
73
  $COMMITS
62
74
 
63
75
  ### Validation
64
76
 
65
- - CI and security checks must pass before merge.
66
- - Review migrations, configuration changes, and rollback notes.
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 "Release: staging -> main ($DATE)" \
86
+ --title "Promote staging -> main ($DATE)" \
74
87
  --body-file "$BODY_FILE"
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.0](https://github.com/0xPlayerOne/code-foundry/compare/v0.2.0...v0.3.0) (2026-07-28)
4
+
5
+
6
+ ### Features
7
+
8
+ * **init:** add configurable license generation ([6ea7d93](https://github.com/0xPlayerOne/code-foundry/commit/6ea7d93637620bbb2f46475eeba4789d8a3b580c))
9
+
3
10
  ## [0.2.0](https://github.com/0xPlayerOne/code-foundry/compare/v0.1.4...v0.2.0) (2026-07-28)
4
11
 
5
12
 
package/README.md CHANGED
@@ -28,6 +28,18 @@ 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
+
31
43
  ## Setup
32
44
 
33
45
  1. Install [mise](https://mise.jdx.dev/).
@@ -36,10 +48,13 @@ Use `code-foundry sync` to update an existing repository and
36
48
 
37
49
  ## Applying the baseline to an existing repository
38
50
 
39
- Run the sync script from the repository root. It updates shared workflows, GitHub forms, hooks, policy files, and tool configuration while preserving the repository's README, `.mise.toml` selections, extra workflows, and application code.
51
+ Run the package entrypoint from the repository root. It updates shared
52
+ workflows, GitHub forms, hooks, policy files, and tool configuration while
53
+ preserving the repository's README, `.mise.toml` selections, extra workflows,
54
+ licenses, and application code.
40
55
 
41
56
  ```bash
42
- bash .github/scripts/init-repo.sh
57
+ npx code-foundry init
43
58
  ```
44
59
 
45
60
  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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-foundry",
3
- "version": "0.2.0",
3
+ "version": "0.3.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",
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')