From af8f869de870b02a8eb0dc8e259287907d9415a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ko=CC=88nig?= Date: Wed, 23 Sep 2026 10:31:53 +0200 Subject: [PATCH] fix(server): stop telling generated projects to link the framework via yalc `lt server create` writes README.md from `nest-server-starter/README.md.ejs`. Its "Test & debug the NestServer package" section still described yalc and `npm run watch`, a way nest-server-starter dropped long ago. In vendor mode the section was meaningless, not merely stale: there is no `@lenne.tech/nest-server` package to link, the core lives in `src/core/`. - npm mode names only the starter's `link:nest-server` / `unlink:nest-server` scripts. Their names are stable, their implementation is being ported to Node, so the README says nothing about how they work. - vendor mode points at `src/core/VENDOR.md`, the modification policy and the update / contribute commands instead. - `setupServer` passes `vendor` into the template. `lt fullstack init` does not render this template and is unaffected. Co-Authored-By: Claude Opus 5.5 (1M context) --- __tests__/server-readme-template.test.ts | 37 +++++++++++++++++++ src/extensions/server.ts | 2 +- .../nest-server-starter/README.md.ejs | 19 +++++++--- 3 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 __tests__/server-readme-template.test.ts diff --git a/__tests__/server-readme-template.test.ts b/__tests__/server-readme-template.test.ts new file mode 100644 index 0000000..d145cbc --- /dev/null +++ b/__tests__/server-readme-template.test.ts @@ -0,0 +1,37 @@ +import { render } from 'ejs'; +import { readFileSync } from 'fs'; +import { join } from 'path'; + +/** + * The README `lt server create` writes into every standalone API project. + * + * It used to describe linking the framework via yalc and `npm run watch`, a way + * nest-server-starter dropped long ago. In vendor mode the section was not + * merely stale but meaningless: there is no `@lenne.tech/nest-server` package to + * link, the core lives in `src/core/`. The npm variant names only the starter's + * script names, which are stable, and never their implementation, which is not. + */ +describe('nest-server-starter README template', () => { + const template = readFileSync(join(__dirname, '..', 'src/templates/nest-server-starter/README.md.ejs'), 'utf-8'); + const readme = (vendor: boolean) => render(template, { props: { description: 'd', name: 'demo', vendor } }); + + it('npm mode: links through the starter scripts, no yalc', () => { + const out = readme(false); + expect(out).toContain('pnpm run link:nest-server'); + expect(out).toContain('pnpm run unlink:nest-server'); + expect(out).not.toMatch(/yalc|npm run watch/); + expect(out).not.toContain('VENDOR.md'); + }); + + it('vendor mode: points at src/core/ and VENDOR.md, offers nothing to link', () => { + const out = readme(true); + expect(out).toContain('src/core/VENDOR.md'); + expect(out).not.toMatch(/link:nest-server|yalc|npm run watch/); + }); + + it('setupServer passes the framework mode into the template', () => { + const source = readFileSync(join(__dirname, '..', 'src/extensions/server.ts'), 'utf-8'); + const call = source.slice(source.lastIndexOf('template.generate(', source.indexOf("'nest-server-starter/README.md.ejs'"))); + expect(call.slice(0, call.indexOf('});'))).toMatch(/vendor:\s*frameworkMode === 'vendor'/); + }); +}); diff --git a/src/extensions/server.ts b/src/extensions/server.ts index 814957a..10acd16 100644 --- a/src/extensions/server.ts +++ b/src/extensions/server.ts @@ -762,7 +762,7 @@ export class Server { if (!experimental) { // Generate README await template.generate({ - props: { description, name }, + props: { description, name, vendor: frameworkMode === 'vendor' }, target: `${dest}/README.md`, template: 'nest-server-starter/README.md.ejs', }); diff --git a/src/templates/nest-server-starter/README.md.ejs b/src/templates/nest-server-starter/README.md.ejs index 74cebdd..1bfaa9b 100755 --- a/src/templates/nest-server-starter/README.md.ejs +++ b/src/templates/nest-server-starter/README.md.ejs @@ -91,14 +91,21 @@ JavaScript file: src/main.ts see [Debug.run.xml](.run/Debug.run.xml) -## Test & debug the NestServer package in this project -Use [yalc](https://github.com/wclr/yalc) to include the NestJS server in the project. +<% if (props.vendor) { -%> +## Working on the framework core +This project runs in vendor mode: the `@lenne.tech/nest-server` core is part of the source tree under `src/core/`, not an npm package, so there is nothing to link. + +- Read `src/core/VENDOR.md` first. It records the upstream baseline and every local change to the core. +- Put project-specific code outside `src/core/`: extend, inherit from or override the core, never patch it for one project. +- Pull in upstream changes with `/lt-dev:backend:update-nest-server-core`, and propose generally useful core fixes upstream with `/lt-dev:backend:contribute-nest-server-core`. -1. clone [NestServer](https://github.com/lenneTech/nest-server): `git clone https://github.com/lenneTech/nest-server.git` -2. go to the nest-server folder (`cd nest-server`), install the packages via `npm i` and start the nest server in watch & yalc mode: `npm run watch` -3. link the nest server live package to this project via `npm run link:nest-server` and start the server: `npm start` -4. unlink the nest-server live package and use the normal package again when you are done: `npm run unlink:nest-server` +<% } else { -%> +## Test & debug the NestServer package in this project +1. Clone [NestServer](https://github.com/lenneTech/nest-server): `git clone https://github.com/lenneTech/nest-server.git` +2. Link it into this project with `pnpm run link:nest-server` and start the server: `pnpm start` +3. Switch back to the published package when you are done: `pnpm run unlink:nest-server` +<% } -%> ## Deployment with deploy.party This project is prepared for deployment with deploy.party.