Add SvelteKit support to fedify init - #971
Conversation
Fedify already ships a SvelteKit integration package and example app, but `fedify init` couldn't scaffold one, so add a `sveltekit` option via `sv create`. fedify-dev#892 Assisted-by: Claude Code:claude-sonnet-5
👷 Deploy Preview for fedify-json-schema processing.
|
✅ Deploy Preview for fedify-json-schema canceled.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthrough
ChangesSvelteKit init support
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant FedifyInit
participant SvelteKitCLI
participant GeneratedApp
User->>FedifyInit: Select SvelteKit and package manager
FedifyInit->>SvelteKitCLI: Run the SvelteKit create command
SvelteKitCLI->>GeneratedApp: Create the project
FedifyInit->>GeneratedApp: Write the Fedify SvelteKit hook
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
2chanhaeng
left a comment
There was a problem hiding this comment.
Great work! This PR can merge to main if you fix few points. First, please update the dependencies using mise run update-init-deps.
| files: { | ||
| "src/hooks.server.ts": await readTemplate("sveltekit/hooks.server.ts"), | ||
| }, | ||
| tasks: getNodeBunDevToolTasks(pm), |
There was a problem hiding this comment.
vite does not inject environment variables from .env into process.env, which causes errors during testing using mysql. You can test it with mise test:init -w sveltekit -p pnpm -m mysql -k mysql --no-dry-run. Add dotenvx as a dependency and ensure that if the package manager is not Deno, the task is modified to dotenvx run -- <command>. For example, if dev: "vite dev" is automatically generated, it should be changed to dev: "dotenvx run -- vite dev".
df7e087 to
68d5a9a
Compare
Vite does not inject `.env` variables into `process.env`, so non-Deno SvelteKit projects failed during `mise test:init` runs that need KV/MQ connection settings (e.g. with `mysql`). Add `@dotenvx/dotenvx` as a dev dependency and wrap the `dev`/`build`/`preview` tasks with `dotenvx run --` for every non-Deno package manager. fedify-dev#892 Assisted-by: Claude Code:claude-sonnet-5
d7e7c77 to
4f016f6
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@CHANGES.md`:
- Line 180: Update the SvelteKit reference URL in the link definition from the
redirecting kit.svelte.dev address to https://svelte.dev/docs/kit, preserving
the existing SvelteKit link label and surrounding changelog content.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
60301b2 to
2ebf692
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/init/README.md`:
- Line 42: Update the SvelteKit link reference in the README to use the
SvelteKit documentation URL already established in CHANGES.md instead of the
generic Svelte homepage.
In `@packages/init/src/templates/sveltekit/hooks.server.ts.tpl`:
- Around line 1-7: Import $lib/logging in the generated hooks.server.ts template
before constructing the handle sequence, ensuring the logging configuration is
evaluated before fedifyHook(federation) runs. Keep the existing federation
import and handle composition unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: e1f1dcd4-0184-483d-926d-5caa63c7a133
📒 Files selected for processing (15)
CHANGES.mdchanges.d/init/sveltekit.mddocs/tutorial/microblog.mdpackages/init/README.mdpackages/init/src/const.tspackages/init/src/json/deps.jsonpackages/init/src/json/kv.jsonpackages/init/src/json/mq.jsonpackages/init/src/templates/sveltekit/hooks.server.ts.tplpackages/init/src/test/action.tspackages/init/src/test/lookup.tspackages/init/src/test/port.tspackages/init/src/types.tspackages/init/src/webframeworks/mod.tspackages/init/src/webframeworks/sveltekit.ts
| [Nitro]: https://nitro.build/ | ||
| [Nuxt]: https://nuxt.com/ | ||
| [SolidStart]: https://start.solidjs.com/ | ||
| [SvelteKit]: https://svelte.dev/ |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Point the SvelteKit reference to the SvelteKit documentation.
The current reference opens the generic Svelte homepage. Use the SvelteKit documentation URL already used in CHANGES.md.
Proposed fix
-[SvelteKit]: https://svelte.dev/
+[SvelteKit]: https://svelte.dev/docs/kit🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/init/README.md` at line 42, Update the SvelteKit link reference in
the README to use the SvelteKit documentation URL already established in
CHANGES.md instead of the generic Svelte homepage.
| import { fedifyHook } from "@fedify/sveltekit"; | ||
| import { sequence } from "@sveltejs/kit/hooks"; | ||
| import federation from "$lib/federation"; | ||
|
|
||
| export const handle = sequence( | ||
| fedifyHook(federation), | ||
| ); |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the SvelteKit server entry.
rg -n -C 3 'logging|federation|fedifyHook' \
packages/init/src/templates/sveltekit/hooks.server.ts.tpl
# Locate and inspect the template that generates src/lib/federation.ts.
fd -t f -g 'federation.ts.tpl' packages/init/src/templates -x \
rg -n -C 3 'logging|federation' {}Repository: fedify-dev/fedify
Length of output: 892
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== target template =="
cat -n packages/init/src/templates/sveltekit/hooks.server.ts.tpl
echo
echo "== federation template(s) =="
fd -t f -g 'federation.ts.tpl' packages/init/src/templates -x sh -c 'printf "\n--- %s ---\n" "$1"; cat -n "$1"' sh {}
echo
echo "== generate hook and logging references =="
rg -n -C 4 'logging|src/lib/logging|hooks\.server|federation\.ts.tpl' packages/init/src
echo
echo "== static init flow snippets =="
fd -t f 'sveltekit\.ts|hooks\.server\.ts\.tpl|federation\.ts\.tpl' packages/init/src -x sh -c 'echo "--- $1 linecount ---"; wc -l "$1"' sh {}Repository: fedify-dev/fedify
Length of output: 30074
Load LogTape in the SvelteKit server entry.
The generated src/lib/logging.ts is not imported by src/hooks.server.ts or the default src/lib/federation.ts, so the logging configuration is not evaluated. Import $lib/logging in packages/init/src/templates/sveltekit/hooks.server.ts.tpl before constructing handle.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/init/src/templates/sveltekit/hooks.server.ts.tpl` around lines 1 -
7, Import $lib/logging in the generated hooks.server.ts template before
constructing the handle sequence, ensuring the logging configuration is
evaluated before fedifyHook(federation) runs. Keep the existing federation
import and handle composition unchanged.
Summary
Fedify already has a SvelteKit integration package and an example app, but
fedify initcommand could not scaffold a SvelteKit project. Added a SvelteKit web framework option to@fedify/init.Assisted-by: Claude Code:claude-sonnet-5
Related issue
fedify init#892Changes
webframeworks/sveltekit.tswhich defines theWebFrameworkDescriptionand scaffolding command for SvelteKit.hooks.server.ts) that integrates Fedify into a SvelteKit app.@fedify/initREADME.md and a tutorial document to include SvelteKit support.denolookup test for SvelteKit, matching Astro, Nuxt and SolidStart, since Vite can't resolve@fedify/*packages that are only linked through Deno's local workspace links.Benefits
fedify init.Checklist
Did you write a regression test to reproduce the bug (if it's a bug fix)?Did you write some tests for this change (if it's a new feature)?mise teston your machine?