Skip to content
Open
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
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pnpm e2e:last-failure # error-context.md of the last failed test, its last fra
- The nightly run (`scripts/nightly.sh`, from the cloud-iac nightly image) builds the editor with the example plugin and theme, then runs `apps/editor/playwright.nightly.config.ts`: Chromium only, the system one from `PLAYWRIGHT_LAUNCH_OPTIONS_EXECUTABLE_PATH`, no engine (the game tests skip).
- `E2E_REQUIRE_ENGINE=1` (CI) fails the run when the `game`, `my-first-game` or `breakout` copy is missing, instead of skipping their tests. Without `NANOFORGE_ENGINE`/`NANOFORGE_CLI`, the e2e prep uses `.engine/` when `pnpm setup:engine` made it, else `../engine`.
- The e2e games are test fixtures, never the engine's examples: `game` is `packages/server-core/test/fixtures/game` (the engine's pong-network example at 3.0.0, frozen, without its unit test) and `breakout` is `plugins/scene/test/fixtures/breakout`. Their `node_modules` are links to those of the engine's own e2e game (`<engine>/e2e/game`, root and `apps/*`), plus the engine libraries they use that it lacks (`network` at the game root, `scene` and `editor-lib` in breakout's client). An engine older than 3.0.0 has no `@nanoforge-dev/input/controller`, which `game` imports.
- **`pnpm examples`** (`scripts/examples.mjs`): the checkout is `--from`, else `NANOFORGE_EXAMPLES`, else `../examples`, asked for in a terminal when none is found. Examples are the folders of its `basics/`, `demos/` and `games/` that hold a `package.json`. It copies (never links) the chosen ones into `.examples/<name>`, replacing a previous copy, without `node_modules`, `dist` and `.nanoforge`, then runs `pnpm install` in the copy. A copy with no `pnpm-workspace.yaml` gets one (`apps/*`, `libs/*`): without it, pnpm 12 installs it as a project of the editor's workspace and writes the editor's `pnpm-lock.yaml` (it ignores `--ignore-workspace`). `--engine`/`NANOFORGE_ENGINE` then links the engine checkout's libraries over the installed ones. Without a terminal, pass `--games` or `--all`.
- **`pnpm examples`** (`scripts/examples.mjs`): the checkout is `--from`, else `NANOFORGE_EXAMPLES`, else `../examples`, asked for in a terminal when none is found. Examples are the folders of its `basics/`, `demos/` and `games/` that hold a `package.json`, except hidden ones (a `.data` game would replace `pnpm example`'s data folder). It copies (never links) the chosen ones into `.examples/<name>`, replacing a previous copy, without `node_modules`, `dist`, `.nanoforge` and symlinks (left out with a warning, never followed), then runs `pnpm install` in the copy. A copy with no `pnpm-workspace.yaml` gets one (`apps/*`, `libs/*`): without it, pnpm 12 installs it as a project of the editor's workspace and writes the editor's `pnpm-lock.yaml` (it ignores `--ignore-workspace`). `--engine`/`NANOFORGE_ENGINE` then links the engine checkout's libraries over the installed ones. Without a terminal, pass `--games` or `--all`.
- `apps/editor/test/examples/editor-native.spec.ts` (in `pnpm test`) runs the ECS and scene analyzers over every game in `.examples/`, and fails on what the editor can't model: analyzer problems, code-only entities, components or systems that resolve to no item, components that can't be edited, files of `components/` or `systems/` that hold no item. It is skipped when `.examples/` holds no game.
- Without `NANOFORGE_ENGINE`, the tests that play the game (runtime, the viewport's "while playing", some code-editor tests) are **skipped**, not failed. Check the skipped count.
- `NANOFORGE_CLI` (a built CLI checkout) is linked into the played game as its own CLI. Without it, the console test skips its source-map check (the game's published CLI writes no source maps).
Expand Down Expand Up @@ -255,7 +255,7 @@ Everything in our registry has a `nanoforge.manifest.json` and a name `@scope/na
- A test that writes `.nanoforge/plugins` or `nf_modules` in the pong copy must remove them (`afterEach`, see `e2e/project-plugins.spec.ts`).
- The e2e server reads its registry from `<workspace>/.registry` (`REGISTRY_DIR`, written by `prepare-workspace.mjs`). A test that publishes a version there, installs a user plugin (`.data/plugins`) or a package (`nanoforge.packages*.json`, `tsconfig.json` paths) puts everything back (see `e2e/marketplace.spec.ts`).
- `nanoforge.manifest.json` is a build input of turbo (it was not until 2026-10-01: a manifest-only change kept the old bundle).
- After changing a plugin manifest, rebuild it: `tooling/example-plugin` is not rebuilt by the editor build filter (`pnpm --filter @nanoforge-dev/editor-example-plugin build`).
- After changing a plugin manifest, rebuild it. `tooling/example-plugin` is not in the editor build filter: `e2e/prepare-workspace.mjs` builds it (and the example theme) at the start of each e2e run.
- **Installing folders and the file watcher:** a folder that appears through a rename is missed by the server's watcher (its content never reaches the client's file list, so the catalog does not see a new package). `installItem` writes files in place, the manifest last.
- **API features:** nothing of the NanoForge API beyond sign-in and projects is called unless listed in `API_FEATURES` (`settings`, `registry`). The real API (`../api`, read-only for us) has a registry (`../api/docs/registry.md`, the source of truth: align `docs/api/registry.md` with it, and `libs/registry` in the CLI repository) and no settings yet.
- **Account plugin list:** `plugins.account` is an account setting, and a local editor's account document lives on its own machine (no sign-in): the list does not travel between machines yet. Don't describe it as cross-machine.
Expand Down
10 changes: 9 additions & 1 deletion apps/editor/e2e/prepare-workspace.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,15 @@ for (const [path, content] of Object.entries(files)) {
/** The example theme has no code: its build copies its manifest and icons into dist/. */
execFileSync('node', ['build.mjs'], {
cwd: join(import.meta.dirname, '../../../tooling/example-theme'),
stdio: 'ignore',
stdio: ['ignore', 'ignore', 'inherit'],
});
/**
* The example plugin (`@acme/hello`) is a dev plugin of every run, but the editor build filter
* leaves it out: built here, so a fresh worktree has it and a changed manifest is picked up.
*/
execFileSync('pnpm', ['run', 'build'], {
cwd: join(import.meta.dirname, '../../../tooling/example-plugin'),
stdio: ['ignore', 'ignore', 'inherit'],
});

const registry = {
Expand Down
30 changes: 22 additions & 8 deletions scripts/examples.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* `pnpm examples`: copies games of a local checkout of the examples repository into `.examples/`
* (ignored by git, outside the pnpm workspace), then installs each copy's own dependencies, so the
* editor can be tried on them (`pnpm example <name>`). The checkout is never written to: a copy
* replaces the previous copy of the same game, without its `node_modules`, `dist` and `.nanoforge`.
* replaces the previous copy of the same game, without its `node_modules`, `dist`, `.nanoforge` and
* symlinks (left out, never followed).
*
* pnpm examples [--from <checkout>] [--games a,b | --all] [--engine <engine checkout>]
*
Expand All @@ -14,7 +15,7 @@
* place of the published ones the copy installed.
*/
import { execFileSync } from 'node:child_process';
import { cpSync, existsSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
import { cpSync, existsSync, lstatSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
import { basename, join, resolve } from 'node:path';
import { parseArgs } from 'node:util';

Expand All @@ -31,15 +32,23 @@ const fail = (message) => {
process.exit(1);
};

/** The examples of a checkout: the folders of its groups that hold a `package.json`. */
/**
* The examples of a checkout: the folders of its groups that hold a `package.json`. A hidden folder
* is never one: its copy could replace `.examples/.data`, the data folder of `pnpm example`.
*/
const examplesOf = (checkout) =>
GROUPS.flatMap((group) => {
const folder = join(checkout, group);
if (!existsSync(folder)) return [];
return readdirSync(folder, { withFileTypes: true })
.filter(
(entry) => entry.isDirectory() && existsSync(join(folder, entry.name, 'package.json')),
)
.filter((entry) => {
if (entry.isSymbolicLink()) console.warn(`Skipped ${group}/${entry.name}: a symlink.`);
return (
entry.isDirectory() &&
!entry.name.startsWith('.') &&
existsSync(join(folder, entry.name, 'package.json'))
);
})
.map((entry) => ({ name: entry.name, group, path: join(folder, entry.name) }));
});

Expand Down Expand Up @@ -129,10 +138,15 @@ for (const example of chosen) {
const copy = join(COPIES, example.name);
console.log(`\n${example.group}/${example.name} → ${copy}`);
rmSync(copy, { recursive: true, force: true });
/** A symlink is left out, never followed: it could point out of the game, or to a parent. */
cpSync(example.path, copy, {
recursive: true,
dereference: true,
filter: (path) => !SKIPPED.has(basename(path)),
filter: (path) => {
if (SKIPPED.has(basename(path))) return false;
if (!lstatSync(path).isSymbolicLink()) return true;
console.warn(` skipped symlink ${path.slice(example.path.length + 1)}`);
return false;
},
});
/**
* A copy without a pnpm workspace of its own would join the editor's and change its lockfile
Expand Down
Loading