Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions __tests__/server-readme-template.test.ts
Original file line number Diff line number Diff line change
@@ -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'/);
});
});
2 changes: 1 addition & 1 deletion src/extensions/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
Expand Down
19 changes: 13 additions & 6 deletions src/templates/nest-server-starter/README.md.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading