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
2 changes: 1 addition & 1 deletion .claude/skills/scaffold-game/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Run the chosen command from a test directory **outside this repo** (for example

```bash
cd /path/to/a/test/folder
node <path-to-this-repo>/dist/nf.js new --name demo --package-manager pnpm --language ts --strict --no-server --no-init-functions --skip-install --no-docker --no-git --no-git-remote
node <path-to-this-repo>/dist/nf.js new --name demo --package-manager pnpm --language ts --strict --no-server --skip-install --no-docker --no-git --no-git-remote
```

For a component/system inside an already-generated project, move into that project and install its dependencies first (`pnpm install`, which needs network access to npm): with `--skip-install`, `nf create` fails with `Cannot find package '@nanoforge-dev/config'`. Then use the `create` command (check its exact usage via `--help`, see step 2), for example:
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,10 @@ Used to create a new nanoforge project.
- `--no-strict` do not use strict mode.
- `--server` create a server.
- `--no-server` do not create a server.
- `--init-functions` initialize functions.
- `--no-init-functions` do not initialize functions.
- `--skip-install` skip installing dependencies.
- `--no-skip-install` do not skip installing dependencies.
- `--docker` generate docker files.
- `--no-docker` do not generate docker files.
- `--no-lint` do not generate lint files.
- `--no-agents` do not generate the `AGENTS.md` and `CLAUDE.md` files for AI coding agents.
- `--editor` add editor dependencies.
- `--git` generate a git repository.
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/commands/new.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ The "Default" column is the answer that is preselected when `nf new` asks the qu
| `--git` / `--no-git` | boolean | `true` | Run `git init` in the project. |
| `--git-remote <gitRemote>` / `--no-git-remote` | URL | none | Add this remote as `origin`. Only asked when git is on. `--no-git-remote` skips the question. |
| `--editor` | boolean | `false` | Add the `nf editor .` instructions to the generated README. |
| `--init-functions` / `--no-init-functions` | boolean | none | Accepted, but has no effect yet. |
| `--no-lint` | boolean | none | Accepted, but has no effect yet: `nf new` generates no lint files. |
| `--no-agents` | boolean | none | Don't add the `AGENTS.md` and `CLAUDE.md` files, which are added unless this flag is passed. |

`--init-functions`, `--no-init-functions` and `--no-lint` are deprecated: they never had an effect, they are no longer listed in the help, and `nf new` prints a warning when it gets one of them. They will be removed in the next major version.

## What it generates

Without a server:
Expand Down
1 change: 0 additions & 1 deletion docs/docs/schematics/project.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ schematics @nanoforge-dev/schematics:project --part=client --directory=apps/clie
| `hasServer` | `boolean` | `false` | Client only: add the `network` library, the `position` packet and the `position-sync` system, which takes the entity's position from the server. Without it the client has no network. |
| `docker` | `boolean` | `false` | Add a `Dockerfile` and a `.dockerignore`. Ignored when `workspace` is `true`: the workspace has its own. |
| `editor` | `boolean` | `false` | Add the `nf editor .` instructions to the README. |
| `initFunctions` | `boolean` | `false` | Accepted, but not used by the templates yet. |
| `libs` | `string[]` | `[]` | Accepted, but not written to `nanoforge.config.ts` yet. |
| `allowBuilds` | `string[]` | `[]` | Accepted, but not used yet: a standalone app always allows `bun` only. |
| `agents` | `boolean` | `true` | Add an `AGENTS.md` for AI coding agents (files, commands, ECS rules, network for a networked app) and a `CLAUDE.md` that imports it. |
Expand Down
8 changes: 3 additions & 5 deletions e2e/cli-help.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,16 @@ describe("nf new --help", () => {
expect(stdout).toContain("--package-manager");
expect(stdout).toContain("--strict");
expect(stdout).toContain("--server");
expect(stdout).toContain("--init-functions");
expect(stdout).toContain("--skip-install");
expect(stdout).toContain("--directory");
expect(stdout).toContain("--docker");
});

it("should not claim that --init-functions or --no-lint do something", async () => {
it("should not list the removed --init-functions and --no-lint options", 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");
expect(stdout).not.toContain("--init-functions");
expect(stdout).not.toContain("--no-lint");
});
});

Expand Down
5 changes: 0 additions & 5 deletions libs/schematics/src/libs/project/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@
"description": "Generate a Dockerfile for the project. Ignored when `workspace` is true - a project inside a workspace is built and run by the workspace's own Dockerfile instead.",
"default": false
},
"initFunctions": {
"type": "boolean",
"description": "Add init functions to the project",
"default": false
},
"hasServer": {
"type": "boolean",
"description": "Only meaningful when part is \"client\": whether the client talks to a companion server. True adds the network library, the position packet and the position-sync system, so the entity position comes from the server; false leaves the network out. A server project always simulates and broadcasts its own position, regardless of this flag.",
Expand Down
3 changes: 0 additions & 3 deletions src/action/actions/new.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
getNewAgentsInput,
getNewDockerOrAsk,
getNewLanguageInputOrAsk,
getNewLintInput,
getNewNameInputOrAsk,
getNewPackageManagerInputOrAsk,
getNewServerOrAsk,
Expand All @@ -34,7 +33,6 @@ interface NewValues {
multiplayer: boolean;
skipInstall: boolean;
docker: boolean;
lint: boolean;
agents: boolean;
editor: boolean;
git: boolean;
Expand Down Expand Up @@ -74,7 +72,6 @@ export class NewAction extends AbstractAction {
multiplayer: await getNewServerOrAsk(inputs),
skipInstall: await getNewSkipInstallOrAsk(inputs),
docker: await getNewDockerOrAsk(inputs),
lint: getNewLintInput(inputs),
agents: getNewAgentsInput(inputs),
editor: getEditorInput(inputs),
git: await getNewGitOrAsk(inputs),
Expand Down
64 changes: 64 additions & 0 deletions src/command/commands/new.command.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Command } from "commander";
import { describe, expect, it, vi } from "vitest";

import { type Input } from "@lib/input";

import { type AbstractAction } from "~/action/abstract.action";

import { NewCommand } from "./new.command";

const setup = () => {
const run = vi.fn().mockResolvedValue(undefined);
const program = new Command()
.exitOverride()
.configureOutput({ writeErr: () => undefined, writeOut: () => undefined });
new NewCommand({ run } as unknown as AbstractAction).load(program);
program.commands.forEach((command) => command.exitOverride());
const parse = (...args: string[]) => program.parseAsync(["new", ...args], { from: "user" });
return { run, program, parse };
};

describe("NewCommand", () => {
it.each(["--init-functions", "--no-init-functions", "--no-lint"])(
"still accepts the deprecated %s option, warns and ignores it",
async (flag) => {
const warn = vi.spyOn(console, "warn").mockImplementation(() => undefined);
const { run, parse } = setup();
await parse("--name", "demo", flag);

expect(run).toHaveBeenCalledOnce();
expect(warn).toHaveBeenCalledWith(expect.stringMatching(/^Warning: .*deprecated/));
const options = run.mock.calls[0]?.[1] as Input;
expect(options.has("lint")).toBe(false);
expect(options.has("initFunctions")).toBe(false);
warn.mockRestore();
},
);

it("does not warn when no deprecated option is passed", async () => {
const warn = vi.spyOn(console, "warn").mockImplementation(() => undefined);
await setup().parse("--name", "demo");

expect(warn).not.toHaveBeenCalled();
warn.mockRestore();
});

it("does not list the deprecated options in the help", () => {
const help = setup().program.commands[0]?.helpInformation() ?? "";
expect(help).not.toContain("--init-functions");
expect(help).not.toContain("--no-lint");
expect(help).toContain("--no-agents");
});

it("still runs the action without lint or initFunctions inputs", async () => {
const { run, parse } = setup();
await parse("--name", "demo", "--no-server", "--skip-install", "--no-git");

expect(run).toHaveBeenCalledOnce();
const options = run.mock.calls[0]?.[1] as Input;
expect(options.get("name")).toEqual({ value: "demo" });
expect(options.get("server")).toEqual({ value: false });
expect(options.has("lint")).toBe(false);
expect(options.has("initFunctions")).toBe(false);
});
});
24 changes: 17 additions & 7 deletions src/command/commands/new.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,26 @@ interface NewOptions {
language?: string;
strict?: boolean;
server?: boolean;
initFunctions?: boolean;
skipInstall?: boolean;
docker?: boolean;
lint?: boolean;
agents?: boolean;
editor?: boolean;
git?: boolean;
gitRemote?: string | false;
initFunctions?: boolean;
lint?: boolean;
}

// Kept hidden so scripts that still pass them don't break; they never had an effect.
const DEPRECATED_FLAGS = ["--init-functions", "--no-init-functions", "--no-lint"];

const warnDeprecated = (options: NewOptions) => {
if (options.initFunctions === undefined && options.lint !== false) return;
console.warn(
`Warning: ${DEPRECATED_FLAGS.join(", ")} are deprecated and have no effect. They will be removed in the next major version.`,
);
};

export class NewCommand extends AbstractCommand {
public load(program: Command) {
program
Expand Down Expand Up @@ -47,13 +57,10 @@ export class NewCommand extends AbstractCommand {
.option("--no-strict", "do not use strict mode")
.option("--server", "create a server")
.option("--no-server", "do not create a server")
.option("--init-functions", "accepted, but has no effect yet")
.option("--no-init-functions", "accepted, but has no effect yet")
.option("--skip-install", "skip installing dependencies")
.option("--no-skip-install", "do not skip installing dependencies")
.option("--docker", "generate docker files")
.option("--no-docker", "do not generate docker files")
.option("--no-lint", "accepted, but has no effect yet (nf new generates no lint files)")
.option("--no-agents", "do not generate AGENTS.md and CLAUDE.md files for AI coding agents")
.option("--editor", "add editor dependencies")
.option("--git", "generate git repository")
Expand All @@ -63,7 +70,12 @@ export class NewCommand extends AbstractCommand {
"setup git remote to git repository (required if --git is used)",
)
.option("--no-git-remote", "do not setup git remote to git repository")
.addOption(new Option("--init-functions").hideHelp())
.addOption(new Option("--no-init-functions").hideHelp())
.addOption(new Option("--no-lint").hideHelp())
.action(async (rawOptions: NewOptions) => {
warnDeprecated(rawOptions);

const options = AbstractCommand.mapToInput({
directory: rawOptions.directory,
name: rawOptions.name,
Expand All @@ -72,10 +84,8 @@ export class NewCommand extends AbstractCommand {
language: rawOptions.language,
strict: rawOptions.strict,
server: rawOptions.server,
initFunctions: rawOptions.initFunctions,
skipInstall: rawOptions.skipInstall,
docker: rawOptions.docker,
lint: rawOptions.lint,
agents: rawOptions.agents,
editor: rawOptions.editor,
git: rawOptions.git,
Expand Down
1 change: 0 additions & 1 deletion src/lib/input/inputs/new/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export * from "./agents.input";
export * from "./docker.input";
export * from "./language.input";
export * from "./lint.input";
export * from "./package-manager.input";
export * from "./server.input";
export * from "./skip-install.input";
Expand Down
20 changes: 0 additions & 20 deletions src/lib/input/inputs/new/lint.input.spec.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/lib/input/inputs/new/lint.input.ts

This file was deleted.