Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ec56fd8
fix(cli): show the build output in nf dev
Exeloo Nov 22, 2026
373b9ea
fix(schematics): stop disabling esmoduleinterop in the tsconfig templ…
Exeloo Nov 22, 2026
43b50d6
fix(schematics): git-ignore dist in the project template
Exeloo Nov 22, 2026
e06e065
fix(schematics): print the resolved engine version in the generated a…
Exeloo Nov 22, 2026
6091ca9
fix(cli): silence the dotenv banner in nf start
Exeloo Nov 22, 2026
3f1b418
fix(cli): color the nf editor url with ansis
Exeloo Nov 22, 2026
2a7ddcb
fix(cli): point error suggestions at options that exist
Exeloo Nov 22, 2026
6ac1d6f
fix(cli): hide stack traces and check the nf new choices
Exeloo Nov 22, 2026
0b13dc9
fix(cli): check the nf start port before starting the loader
Exeloo Nov 22, 2026
0b2eb05
fix(cli): warn when nf start finds no build
Exeloo Nov 22, 2026
9c549fd
fix(cli): say in nf new --help that --init-functions and --no-lint do…
Exeloo Nov 22, 2026
ac04ba5
fix(cli): fix typos and nanoforge casing in the help texts
Exeloo Nov 22, 2026
47e59bf
fix(cli): reject component and system names that give no identifier
Exeloo Nov 22, 2026
8d8cf05
fix(cli): name the missing option instead of prompting without a term…
Exeloo Nov 22, 2026
8706182
docs(schematics): add the publish step to the plugin template readme
Exeloo Nov 22, 2026
a051707
docs(cli): fix stale and wrong passages in the cli docs
Exeloo Nov 22, 2026
391a034
docs(cli): say commands never prompt without a terminal
Exeloo Nov 22, 2026
c40b548
fix(cli): stop nf start when no build is found
Exeloo Nov 22, 2026
46ccdad
docs(cli): name the new port error and the api key variable for ci
Exeloo Nov 22, 2026
172ef67
style(cli): wrap long comments, keep the name pattern at the top and …
Exeloo Nov 22, 2026
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
11 changes: 6 additions & 5 deletions docs/docs/commands/create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ For a component or a system, run it in a `client` or `server` app (the `-d` fold
`nanoforge.config.ts` decides the part and the language: a component created in a server app is a
server component. In a workspace, point `-d` at the app (`-d apps/server`), not at the root.

Without a terminal, a missing `--name` stops the command with
`--name is required when not running in a terminal.`

## Usage

```bash
Expand Down Expand Up @@ -79,11 +82,6 @@ When it is done, `nf create plugin` prints how to load the plugin in the editor:
`DEV_PLUGINS=<plugin folder> nf editor <project>`. The editor reloads the plugin when its build
changes. The [first plugin guide](/docs/editor/plugins/create-your-first-plugin) goes further.

<Note>
No published editor reads `DEV_PLUGINS` yet: the latest release, 0.1.4, doesn't. This plugin
development loop needs a newer editor release.
</Note>

## Common errors

- **`Cannot run 'create' at a workspace root ('<folder>').`** Point `-d` at an app:
Expand All @@ -95,4 +93,7 @@ changes. The [first plugin guide](/docs/editor/plugins/create-your-first-plugin)
- **`'<folder>' already exists and is not empty.`** The plugin folder exists. Choose another one
with `--path`.
- **`'<template>' is not a plugin template.`** Use `--template panel` or `--template theme`.
- **`Invalid argument 'name'. Expected: letters, digits, '-' and '_', starting with a letter`.** A
component or system name becomes a class or function name: `2d sprite` or `bad!` can't. Use
`sprite-2d`.
- **`"<name>" is not a plugin name.`** Use `@scope/name` in lowercase, for example `@acme/counter`.
7 changes: 4 additions & 3 deletions docs/docs/commands/dev.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ description: Run your game while you work, with rebuild and reload on change
your project's package manager:

- [`nf build --watch`](./build): builds every app, then rebuilds an app when a file changes in the
folder of its entry file (`src/` by default). Its output is hidden.
folder of its entry file (`src/` by default). Its output, build errors included, shows in the
terminal.
- [`nf start --watch`](./start): serves the game. The page reloads when the client build changes,
and the server restarts when the server build changes.

Expand Down Expand Up @@ -49,8 +50,8 @@ nf dev -d ./games/space

## Common errors

- **A build error doesn't show.** The build output is hidden in `nf dev`. Run `nf build` to see
the error.
- **The game stops updating.** A rebuild failed: its error is in the terminal, above the `nf start`
lines. Fix it and save again.
- **An asset change doesn't show.** The build watches only the folder of the entry file. A change
in `assets/` alone doesn't start a rebuild: save a file in `src/` (every rebuild copies the
assets again), or restart `nf dev`.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/commands/editor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ DEV_PLUGINS=$PWD/score-board nf editor ./my-game

## Common errors

- **`Invalid editor port: <port>`.** The port must be a whole number from 1 to 65535.
- **`Invalid argument 'port'`.** The port must be a whole number from 1 to 65535.
- **The browser doesn't open.** The editor didn't answer within 30 seconds, or you ran it without
a `[path]`. Open the printed URL yourself.
- **The port is already used.** Pass another `--port`.
2 changes: 2 additions & 0 deletions docs/docs/commands/install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ nf add [names...] [options]
| `-d, --directory <directory>` | path | `.` | Project folder. |
| `-l, --lib` | boolean | `false` | Install npm libraries with the package manager instead of registry packages. |

With `--lib` and no terminal, pass the names: `nf install` doesn't prompt for them.

The `--server` option is gone: registry packages go to `nf_modules`, for the client and the server.

## Examples
Expand Down
2 changes: 2 additions & 0 deletions docs/docs/commands/new.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ description: Create a new NanoForge project

`nf new` creates a NanoForge project, installs its dependencies, and can set up a git repository.
It asks a question for each choice. Give the answer as a flag to skip that question.
Without a terminal (CI, a script), it asks nothing: a missing answer stops it with
`<option> is required when not running in a terminal.`, so pass every choice as a flag.

- **Without a server** (the default), the project is one client app at the root of its folder.
- **With a server** (`--server`), the project is a workspace: a root `nanoforge.config.ts` that
Expand Down
15 changes: 10 additions & 5 deletions docs/docs/commands/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,16 @@ code 1. For example, outside a project:
🙀 Build failed!
Configuration file not found at path: nanoforge.config.ts.

💡 Suggestion: Please run 'nf new' or provide a valid --config path.
💡 Suggestion: Run the command from a project folder, pass it with -d, or run 'nf new'.
```

Run the command from the project folder, or pass that folder with `-d`. The "--config" in the
suggestion is outdated: only `-d` sets where the configuration is read.

An unknown command prints `Invalid command: <name>` and exits with code 1. An unknown option
prints `error: unknown option '<option>'`.
prints `error: unknown option '<option>'`, and a value outside an option's choices (such as
`nf new --language rust`) prints `error: option '<option>' argument '<value>' is invalid`.

Commands that ask questions (`nf new`, `nf create`, `nf login`, `nf install`) never prompt when
stdin is not a terminal (CI, a script): they stop with `<option> is required when not running in a
terminal.`, so pass the option.

An unexpected error prints its message only. Set `NF_DEBUG=1` to see its stack trace, for
example in a bug report: `NF_DEBUG=1 nf build`.
6 changes: 4 additions & 2 deletions docs/docs/commands/registry.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ nf login
nf login --local --api-key "$NF_REGISTRY_KEY"
```

Without a terminal, pass `--api-key` from an environment variable, as above: the command doesn't
prompt, and a key typed in the command stays in the shell history.

`nf login` asks the registry who the key belongs to (`/registry/-/whoami`). If the registry refuses
the key, `nf login` fails with `The registry refused the key (<code>)` and saves nothing.

Expand Down Expand Up @@ -90,8 +93,7 @@ nf logout --local
| `contents` | no | What the package holds (`kind`, `path`, `export`…), shown in catalogs; `nf publish` packs only these paths. |

The registry checks the rest (`contents`, `include`, `engines`, `npmDependencies`…) when you
publish: its reference is the API's
[registry documentation](https://github.com/NanoForge-dev/API/blob/main/docs/registry.md).
publish.

## publish

Expand Down
4 changes: 4 additions & 0 deletions docs/docs/commands/start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,13 @@ nf start --client-dir build/client --server-dir build/server
- **The client fails to start with `--cert` and `--key`.** Check that both paths are absolute.
- **The page shows `Storage issue: The game must be hosted with SSL (HTTPS)...`.** You opened the
game on an address that isn't `localhost` over HTTP. Use HTTPS (see above).
- **`No build found at <folder>`.** The build folder doesn't exist, and `nf start` stops: run
`nf build` first, or use `nf dev`. `--watch` skips this check.
- **The page shows `Could not find main function`, or the server logs `No main.js found`.** There
is no `main.js` in the build folder: run `nf build` first, and check that the entry file is
named `main.ts`.
- **The port is already used.** Pass another `--port`, or stop the other process.
- **`Invalid argument 'port'. Expected: an integer from 1 to 65535`.** `--port` (or `port` in the
client config) is not a port number: nothing was started.

More browser-side problems are in the [loader troubleshooting](/docs/loader/overview#troubleshooting).
2 changes: 1 addition & 1 deletion docs/docs/schematics/component.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ schematics @nanoforge-dev/schematics:component --part=client --name=health
| Option | Type | Default | Description |
| ----------- | ---------------------- | --------- | ------------------------------------------------------------------------------------ |
| `name` | `string` | `example` | Component name. `health` gives the class `HealthComponent` in `health.component.ts`. |
| `part` | `"client" \| "server"` | required | Picks the package the manifest type is imported from (see the warning below). |
| `part` | `"client" \| "server"` | required | Required, but the generated file is the same for both. |
| `directory` | `string` | `.` | Folder to write to. |
| `language` | `"ts" \| "js"` | `ts` | `.ts` or `.js` file. |

Expand Down
3 changes: 1 addition & 2 deletions docs/docs/schematics/plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ DEV_PLUGINS=$PWD nf editor ../my-game
```

For a theme, run `node build.mjs --watch` instead of `pnpm dev`, then choose the theme in
_Settings › Editor › Appearance_. No published editor reads `DEV_PLUGINS` yet (the latest release is 0.1.4): this loop needs a newer
editor release.
_Settings › Editor › Appearance_.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/schematics/system.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ schematics @nanoforge-dev/schematics:system --part=client --name=movement
| Option | Type | Default | Description |
| ----------- | ---------------------- | --------- | ------------------------------------------------------------------------------------ |
| `name` | `string` | `example` | System name. `movement` gives the function `movementSystem` in `movement.system.ts`. |
| `part` | `"client" \| "server"` | required | Picks the package the types are imported from (see the warning below). |
| `part` | `"client" \| "server"` | required | Required. Only the JS file uses it, in a JSDoc comment. |
| `directory` | `string` | `.` | Folder to write to. |
| `language` | `"ts" \| "js"` | `ts` | `.ts` or `.js` file. |

Expand Down
5 changes: 3 additions & 2 deletions docs/guides/components-and-systems.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ them from the registry.
nf create system --name regen
```

It writes `src/systems/regen.system.ts`, with a `regenSystem` function. Fix the import the
same way, and replace `ExampleComponent` with your component:
It writes `src/systems/regen.system.ts`, with a `regenSystem` function. It imports
`ExampleComponent` from `../components/example.component`, a file `nf new` doesn't create:
replace that import and `ExampleComponent` with your component:

```ts src/systems/regen.system.ts
import type { Context } from "@nanoforge-dev/common";
Expand Down
27 changes: 27 additions & 0 deletions e2e/cli-create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,33 @@ describe("nf create (error cases)", () => {
const { exitCode } = await runCli(["create", "invalid-type", "--name", "test", "-d", appDir]);
expect(exitCode).not.toBe(0);
});

it("should name the missing --name instead of prompting without a terminal", async () => {
const appDir = resolve(tmpDir, "create-js/create-js-app");
const { exitCode, stdout, stderr } = await runCli(["create", "component", "-d", appDir], {
stdinData: "",
});

expect(exitCode).toBe(1);
expect(stderr).toContain("--name is required when not running in a terminal.");
expect(stdout).not.toContain("What is the name");
});

it("should reject a name that gives no valid identifier", async () => {
const appDir = resolve(tmpDir, "create-js/create-js-app");
const { exitCode, stderr } = await runCli([
"create",
"component",
"--name",
"2d sprite",
"-d",
appDir,
]);

expect(exitCode).toBe(1);
expect(stderr).toContain("Invalid argument 'name'");
expect(existsSync(resolve(appDir, "src/components/2d-sprite.component.js"))).toBe(false);
});
});

describe("nf create plugin", () => {
Expand Down
10 changes: 9 additions & 1 deletion e2e/cli-help.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("nf new --help", () => {
const { stdout, exitCode } = await runCli(["new", "--help"]);

expect(exitCode).toBe(0);
expect(stdout).toContain("create a new nanoforge project");
expect(stdout).toContain("create a new NanoForge project");
expect(stdout).toContain("--name");
expect(stdout).toContain("--language");
expect(stdout).toContain("--package-manager");
Expand All @@ -47,6 +47,14 @@ describe("nf new --help", () => {
expect(stdout).toContain("--directory");
expect(stdout).toContain("--docker");
});

it("should not claim that --init-functions or --no-lint do something", async () => {
const { stdout } = await runCli(["new", "--help"]);

expect(stdout).not.toContain("initialize functions");
expect(stdout).not.toContain("do not generate lint files");
expect(stdout).toContain("has no effect yet");
});
});

describe("nf build --help", () => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/cli-login.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("nf login --help", () => {
const { stdout, exitCode } = await runCli(["login", "--help"]);

expect(exitCode).toBe(0);
expect(stdout).toContain("login to Nanoforge registry");
expect(stdout).toContain("login to the NanoForge registry");
expect(stdout).toContain("--directory");
expect(stdout).toContain("--local");
expect(stdout).toContain("--api-key");
Expand Down
2 changes: 1 addition & 1 deletion e2e/cli-logout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("nf logout --help", () => {
const { stdout, exitCode } = await runCli(["logout", "--help"]);

expect(exitCode).toBe(0);
expect(stdout).toContain("logout from Nanoforge registry");
expect(stdout).toContain("logout from the NanoForge registry");
expect(stdout).toContain("--directory");
expect(stdout).toContain("--local");
});
Expand Down
10 changes: 10 additions & 0 deletions e2e/cli-new.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,13 @@ describe("nf new (with typescript with docker option)", () => {
expect(existsSync(resolve(appDir, ".dockerignore"))).toBe(true);
});
});

describe("nf new without a terminal", () => {
it("should name the missing option instead of exiting silently", async () => {
const { exitCode, stdout, stderr } = await runCli(["new"], { cwd: tmpDir, stdinData: "" });

expect(exitCode).toBe(1);
expect(stderr).toContain("--name is required when not running in a terminal.");
expect(stdout).not.toContain("What is the name");
});
});
2 changes: 1 addition & 1 deletion e2e/cli-publish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("nf publish --help", () => {
const { stdout, exitCode } = await runCli(["publish", "--help"]);

expect(exitCode).toBe(0);
expect(stdout).toContain("publish package to Nanoforge registry");
expect(stdout).toContain("publish a package to the NanoForge registry");
expect(stdout).toContain("--directory");
expect(stdout).toContain("--dry-run");
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/cli-unpublish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe("nf unpublish --help", () => {
const { stdout, exitCode } = await runCli(["unpublish", "--help"]);

expect(exitCode).toBe(0);
expect(stdout).toContain("unpublish package to Nanoforge registry");
expect(stdout).toContain("unpublish a package from the NanoForge registry");
expect(stdout).toContain("--directory");
});
});
Expand Down
8 changes: 8 additions & 0 deletions libs/schematics/src/libs/plugin/files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@ The <%= title %> panel opens in the bottom right dock. _View › Panels › <%=

Build it (`pnpm build`), then copy `dist/` to `~/.nanoforge/editor/plugins/<%= name %>` (every project) or to `<project>/.nanoforge/plugins/<%= name %>` (that project).

## Publish it

The build writes the plugin and its manifest to `dist/`: publish that folder to the NanoForge registry (run `nf login` first).

```sh
pnpm build && nf publish -d dist
```

The plugin authoring guide has the rest: the manifest, the SDK, extension points, settings, history.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ alone, run `<%= nf %> build -d apps/<%= part %>` at the root.
<% } %>
<% if (workspace && packageManager === "npm") { %>Add a package with `npm install <package> -w apps/<%= part %>` at the workspace root.<% } else { %>Add a package with `<%= add %> <package>` in this folder.<% } %>

The `@nanoforge-dev/*` packages are on `^2`. The online docs follow the engine's development
The `@nanoforge-dev/*` packages are on `<%= engineVersion %>`. The online docs follow the engine's development
branch and can describe APIs that the installed release lacks: the installed types
(`@nanoforge-dev/<package>/dist` in `node_modules`) are the reference.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ web_modules/
# Compilation directories
.nanoforge/client
.nanoforge/server
dist/

# API key written by nf login --local
.nanoforgerc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ alone, run `<%= nf %> build -d apps/<%= part %>` at the root.
<% } %>
<% if (workspace && packageManager === "npm") { %>Add a package with `npm install <package> -w apps/<%= part %>` at the workspace root.<% } else { %>Add a package with `<%= add %> <package>` in this folder.<% } %>

The `@nanoforge-dev/*` packages are on `^2`. The online docs follow the engine's development
The `@nanoforge-dev/*` packages are on `<%= engineVersion %>`. The online docs follow the engine's development
branch and can describe APIs that the installed release lacks: the installed types
(`@nanoforge-dev/<package>/dist` in `node_modules`) are the reference.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ web_modules/
# Compilation directories
.nanoforge/client
.nanoforge/server
dist/

# API key written by nf login --local
.nanoforgerc
2 changes: 1 addition & 1 deletion libs/schematics/src/libs/project/files/ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

// Interop Constraints
"allowSyntheticDefaultImports": true,
"esModuleInterop": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

// Interop Constraints
"allowSyntheticDefaultImports": true,
"esModuleInterop": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,

Expand Down
45 changes: 45 additions & 0 deletions src/action/actions/dev.action.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { resolve } from "path";
import { beforeEach, describe, expect, it, vi } from "vitest";

import { type Input } from "@lib/input";
import { PackageManagerFactory } from "@lib/package-manager";

import { DevAction } from "./dev.action";

vi.mock("@lib/package-manager", () => ({
PackageManagerFactory: { find: vi.fn() },
}));

const GAME = resolve("game");

const createInput = (entries: [string, any][]): Input =>
new Map(entries.map(([key, value]) => [key, { value }]));

describe("DevAction", () => {
const runDev = vi.fn().mockResolvedValue(true);

beforeEach(() => {
vi.clearAllMocks();
vi.mocked(PackageManagerFactory.find).mockResolvedValue({ runDev } as any);
});

it("runs build and start in watch mode with their output shown, not collected", async () => {
await new DevAction().handle(new Map(), createInput([["directory", GAME]]));

expect(runDev).toHaveBeenCalledWith(GAME, "nf", {}, ["build", "--watch"], false);
expect(runDev).toHaveBeenCalledWith(GAME, "nf", {}, ["start", "--watch"], false);
});

it("passes --editor to the build only", async () => {
await new DevAction().handle(
new Map(),
createInput([
["directory", GAME],
["editor", true],
]),
);

expect(runDev).toHaveBeenCalledWith(GAME, "nf", {}, ["build", "--watch", "--editor"], false);
expect(runDev).toHaveBeenCalledWith(GAME, "nf", {}, ["start", "--watch"], false);
});
});
Loading