From c591c2ea7660d6403d6b8ba4dd66e187ff3bc3fd Mon Sep 17 00:00:00 2001 From: Exelo Date: Mon, 23 Nov 2026 02:30:34 +0100 Subject: [PATCH 1/3] fix(editor): build the example plugin before the e2e run --- AGENTS.md | 2 +- apps/editor/e2e/prepare-workspace.mjs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 48bc212..4f7f93f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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 `/.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. diff --git a/apps/editor/e2e/prepare-workspace.mjs b/apps/editor/e2e/prepare-workspace.mjs index eed2b21..a04fe25 100644 --- a/apps/editor/e2e/prepare-workspace.mjs +++ b/apps/editor/e2e/prepare-workspace.mjs @@ -66,6 +66,14 @@ execFileSync('node', ['build.mjs'], { cwd: join(import.meta.dirname, '../../../tooling/example-theme'), stdio: 'ignore', }); +/** + * 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', +}); const registry = { '@acme/badge/1.0.0/nanoforge.manifest.json': JSON.stringify({ From 9a06a9b7c9494a5dbc7824da7da53d3f5c9b6652 Mon Sep 17 00:00:00 2001 From: Exelo Date: Mon, 23 Nov 2026 02:31:10 +0100 Subject: [PATCH 2/3] fix(editor): stop pnpm examples following symlinks and copying hidden folders --- AGENTS.md | 2 +- scripts/examples.mjs | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 4f7f93f..912a10d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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 (`/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/`, 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/`, 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). diff --git a/scripts/examples.mjs b/scripts/examples.mjs index 681ab92..4222810 100644 --- a/scripts/examples.mjs +++ b/scripts/examples.mjs @@ -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 `). 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 ] [--games a,b | --all] [--engine ] * @@ -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'; @@ -31,14 +32,20 @@ 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')), + (entry) => + entry.isDirectory() && + !entry.name.startsWith('.') && + existsSync(join(folder, entry.name, 'package.json')), ) .map((entry) => ({ name: entry.name, group, path: join(folder, entry.name) })); }); @@ -129,10 +136,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 From 5940fa778bbeff22342cb27aa6b6b8a05940173f Mon Sep 17 00:00:00 2001 From: Exelo Date: Mon, 23 Nov 2026 09:02:01 +0100 Subject: [PATCH 3/3] fix(editor): show example build errors in the e2e prep and warn on symlinked games --- apps/editor/e2e/prepare-workspace.mjs | 4 ++-- scripts/examples.mjs | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/editor/e2e/prepare-workspace.mjs b/apps/editor/e2e/prepare-workspace.mjs index a04fe25..0be65e1 100644 --- a/apps/editor/e2e/prepare-workspace.mjs +++ b/apps/editor/e2e/prepare-workspace.mjs @@ -64,7 +64,7 @@ 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 @@ -72,7 +72,7 @@ execFileSync('node', ['build.mjs'], { */ execFileSync('pnpm', ['run', 'build'], { cwd: join(import.meta.dirname, '../../../tooling/example-plugin'), - stdio: 'ignore', + stdio: ['ignore', 'ignore', 'inherit'], }); const registry = { diff --git a/scripts/examples.mjs b/scripts/examples.mjs index 4222810..34b8646 100644 --- a/scripts/examples.mjs +++ b/scripts/examples.mjs @@ -41,12 +41,14 @@ const examplesOf = (checkout) => const folder = join(checkout, group); if (!existsSync(folder)) return []; return readdirSync(folder, { withFileTypes: true }) - .filter( - (entry) => + .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')), - ) + existsSync(join(folder, entry.name, 'package.json')) + ); + }) .map((entry) => ({ name: entry.name, group, path: join(folder, entry.name) })); });