feat: download versioned templates for slug init #128

Merged
erik merged 1 commit from feat/task-e3121ddd-remote-template-init into main 2026-06-07 19:11:22 -05:00
Owner

Summary

Make installed slug init work without a repo-local template/site by downloading a versioned template asset from Forgejo releases, while keeping local template behavior for repo development.

Task

Task: #task-e3121ddd

Changes

  • Added slug init --help with init-specific usage and template source options.
  • Added --template-url and --template-dir to slug init.
  • Added default remote template download URL based on the CLI package version.
  • Added tarball download/extraction for remote template assets.
  • Added scripts/package-site-template.mjs to produce slugkit-site-template-v<version>.tgz from template/site while excluding runtime artifacts.
  • Updated the release workflow to package the template tarball and upload/replace it as a Forgejo release asset.
  • Added tests for init help, local template override, remote template init, default versioned URL behavior, and template packaging exclusions.

Testing

  • Unit tests added/updated
  • Manual testing performed
  • npm run test --workspace @evcraddock/slug -- commands.test.ts template-package-script.test.ts
  • node scripts/package-site-template.mjs 0.1.2 <tmp-dir>
  • npm run lint
  • npm run build
  • npm test
  • ./scripts/pre-pr.sh

Checklist

  • ./scripts/pre-pr.sh passes
  • Documentation updated (if needed)
  • No unrelated changes included
## Summary Make installed `slug init` work without a repo-local `template/site` by downloading a versioned template asset from Forgejo releases, while keeping local template behavior for repo development. ## Task Task: #task-e3121ddd ## Changes - Added `slug init --help` with init-specific usage and template source options. - Added `--template-url` and `--template-dir` to `slug init`. - Added default remote template download URL based on the CLI package version. - Added tarball download/extraction for remote template assets. - Added `scripts/package-site-template.mjs` to produce `slugkit-site-template-v<version>.tgz` from `template/site` while excluding runtime artifacts. - Updated the release workflow to package the template tarball and upload/replace it as a Forgejo release asset. - Added tests for init help, local template override, remote template init, default versioned URL behavior, and template packaging exclusions. ## Testing - [x] Unit tests added/updated - [x] Manual testing performed - `npm run test --workspace @evcraddock/slug -- commands.test.ts template-package-script.test.ts` - `node scripts/package-site-template.mjs 0.1.2 <tmp-dir>` - `npm run lint` - `npm run build` - `npm test` - `./scripts/pre-pr.sh` ## Checklist - [x] `./scripts/pre-pr.sh` passes - [x] Documentation updated (if needed) - [x] No unrelated changes included
feat: download versioned templates for slug init
All checks were successful
CI / build-lint-test (pull_request) Successful in 1m38s
d91ea50d70
Task: #task-e3121ddd
Author
Owner

Review summary

Approved. The PR implements versioned remote template downloads for installed slug init, preserves repo-local template initialization, and updates release automation to attach a reproducible template tarball asset.

Acceptance criteria

  • slug init ./site --name site --site-title "Site" works when installed and no repo-local template/site is available — covered by default remote-template test with templateSiteDirectory: null, mocked fetch, and matching extracted template copy.
  • Release workflow publishes a versioned template tarball asset — workflow now packages template/site and uploads/replaces slugkit-site-template-v<version>.tgz on the Forgejo release.
  • Default template download URL is versioned and reproducible — URL uses CLI package version and the v<version>/slugkit-site-template-v<version>.tgz release asset path.
  • Local repo development initializes from local template/site without network — local finder is preserved ahead of default remote download; explicit --template-dir coverage added.
  • Generated sites contain copied template source and do not depend on the Slugkit repo after initialization — remote and local init tests assert copied template files exist in the target site.
  • Tests cover remote-template init behavior and local-template fallback/override behavior — commands tests cover help, explicit local dir, explicit URL, and default remote URL; packaging-script tests cover asset creation/exclusions.

Quality checks

  • Scope alignment: OK; changes are limited to CLI init/template packaging/release docs.
  • Code quality: OK; template source resolution is explicit and keeps local override, custom URL/dir, and default remote behavior separated.
  • Tests: OK; new logic has focused coverage plus full suite/pre-PR evidence.
  • Security: OK; custom template URL is explicit, protocols are constrained to HTTP(S), and runtime artifacts/secrets are excluded from packaged templates.
  • Documentation: OK; CLI README and release docs describe template asset behavior.

Blocking issues

None.

Warnings

None.

Verdict

Approved. Stop at the human merge approval gate.

## Review summary Approved. The PR implements versioned remote template downloads for installed `slug init`, preserves repo-local template initialization, and updates release automation to attach a reproducible template tarball asset. ## Acceptance criteria - [x] `slug init ./site --name site --site-title "Site"` works when installed and no repo-local `template/site` is available — covered by default remote-template test with `templateSiteDirectory: null`, mocked fetch, and matching extracted template copy. - [x] Release workflow publishes a versioned template tarball asset — workflow now packages `template/site` and uploads/replaces `slugkit-site-template-v<version>.tgz` on the Forgejo release. - [x] Default template download URL is versioned and reproducible — URL uses CLI package version and the `v<version>/slugkit-site-template-v<version>.tgz` release asset path. - [x] Local repo development initializes from local `template/site` without network — local finder is preserved ahead of default remote download; explicit `--template-dir` coverage added. - [x] Generated sites contain copied template source and do not depend on the Slugkit repo after initialization — remote and local init tests assert copied template files exist in the target site. - [x] Tests cover remote-template init behavior and local-template fallback/override behavior — commands tests cover help, explicit local dir, explicit URL, and default remote URL; packaging-script tests cover asset creation/exclusions. ## Quality checks - Scope alignment: OK; changes are limited to CLI init/template packaging/release docs. - Code quality: OK; template source resolution is explicit and keeps local override, custom URL/dir, and default remote behavior separated. - Tests: OK; new logic has focused coverage plus full suite/pre-PR evidence. - Security: OK; custom template URL is explicit, protocols are constrained to HTTP(S), and runtime artifacts/secrets are excluded from packaged templates. - Documentation: OK; CLI README and release docs describe template asset behavior. ## Blocking issues None. ## Warnings None. ## Verdict Approved. Stop at the human merge approval gate.
erik merged commit a124b8bba4 into main 2026-06-07 19:11:22 -05:00
erik deleted branch feat/task-e3121ddd-remote-template-init 2026-06-07 19:11:22 -05:00
Sign in to join this conversation.
No description provided.