Skip to content

fix(schematics): drop the -r option and move the templates to engine 3 packets - #336

Merged
Exeloo merged 5 commits into
mainfrom
fix/new-project-templates
Nov 22, 2026
Merged

Exeloo merged 5 commits into
mainfrom
fix/new-project-templates

Conversation

@Exeloo

@Exeloo Exeloo commented Nov 22, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Closes #297
Closes #305

Fixes the projects nf new generates, found while verifying the tester ATP:

  • Workspace scripts: nf dev -r / nf build -r / nf start -r become nf dev / nf build / nf start (the CLI has no -r; at a workspace root these already run every app). The README rows, sentence and the -r warnings in the docs are gone.
  • Single-player client: the network library, its import and its dependency are only generated for a server, or a client with hasServer. A solo game no longer loads a network it never uses.
  • Multiplayer: the systems move from the removed ctx.network.tcp API to engine 3 packets:
src/packets/position.packet.ts   definePacket<{ x, y }>("position", { validate })   # server, or client with hasServer
server move-2d.system            ctx.network.packets.sendToAll(PositionPacket, { x, y })
client position-sync.system      ctx.network.packets.read(PositionPacket).at(-1)?.data

validate drops anything that isn't two numbers, so the template teaches the safe pattern for packets a server receives. The packet stays on the default reliable channel: an unreliable one needs UDP/WebRTC, and a starter game should keep working where UDP is blocked.

How do you test this PR?

  • Before: a generated workspace fails on npm run dev with unknown option '-r'; the multiplayer server crashes on its first tick (ctx.network.tcp is undefined).
    After: nf new --server with the built CLI, in TypeScript and in JavaScript: npm run build succeeds, npm start serves it, and the red circle moves in Chrome (position synced from the server).
  • libs/schematics e2e: 154/154 pass, including new tests:
    • the workspace scripts equal nf dev / nf build / nf start, and the README has no -r;
    • a client without a server has no network dependency, import or packet file;
    • a client with a server has NetworkClientLibrary, the dependency and the packet;
    • the packet file is generated for the server and the hasServer client.
  • pnpm run lint passes at the root and in libs/schematics. The pre-push hook ran build, lint, and unit and e2e tests: all pass.
  • The JS template's validate type-checks with tsc --allowJs --checkJs --strict.

Merge danger

Door: two-way (templates only; existing projects are untouched).
Blast radius: small. @nanoforge-dev/schematics, used at runtime by @nanoforge-dev/cli only. It reaches users with the next CLI release; nothing deploys on merge.

Follow-up issues

Quality gate

Check Result Notes
Docs Updated new.mdx, workspace.mdx, project.mdx, build-and-deploy.mdx, schema.json, generated READMEs and AGENTS.md
Correctness Pass 2 rounds; Minors fixed in 5583b1b and 74f54d6
Performance Pass The unreliable-channel suggestion was declined (needs UDP; see above)
Accessibility N/A (no UI or terminal output changed)
Security Pass Its Minor (validate the packet) is fixed
Style Pass lint: pass

@github-actions github-actions Bot added documentation Improvements or additions to documentation lib:schematics Related to the @nanoforge-dev/schematics library labels Nov 22, 2026
@Exeloo
Exeloo merged commit 3d7ac71 into main Nov 22, 2026
2 checks passed
@Exeloo
Exeloo deleted the fix/new-project-templates branch November 22, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation lib:schematics Related to the @nanoforge-dev/schematics library

Projects

None yet

1 participant