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
3 changes: 2 additions & 1 deletion docs/content/docs/v2/agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ src/Inventory/Shared/InventoryTypes.luau -> ReplicatedStorage/Shared/Inventory

- `rogen build` overwrites the `*.project.json` each config writes: put changes in the config, or in the `template` it merges into.
- The `syncDir` (`out`, `dist`) is compiler output: edit the sources in the root directories.
- Add a place with `rogen init <name> --json` rather than by hand: it writes the place's config and the extra files Darklua or roblox-ts need for it. Make every edit in its `nextSteps.setup`, such as roblox-ts's `include`.

For tags and variants (`Foo.mock.luau`), marker files, suffixes, `.meta.json`, extra configs and CLI flags, read https://rogen-playfully.vercel.app/docs/v2.
````

The snippet covers the mistakes an agent makes on its own. The rest it can look up when a build prints a diagnostic, since every diagnostic names what to change.

A tool that drives Rogen can read `--json` from `build`, `where` and `list` instead of parsing text: see [JSON output](/docs/v2/cli#json-output).
A tool that drives Rogen can read `--json` from `build`, `where`, `list` and `init` instead of parsing text: see [JSON output](/docs/v2/cli#json-output).
21 changes: 20 additions & 1 deletion docs/content/docs/v2/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ Writes a starting `<name>.rogen.json`, or `default.rogen.json` when bare. It det

In a terminal it asks first, and pressing Enter at every question writes what a non-interactive `init` writes. On a first run it asks whether you're setting up one place or several; with folders in `places/` it sets up several, writing one config per place that extends `default`. When `default.rogen.json` already exists, it asks what to add: a **place**, a **variant** of default, or a separate config.

Without a terminal it takes those same defaults, so beside an existing `default.rogen.json`, `rogen init lobby` adds the place `lobby` with its code in `places/lobby`, and a bare `rogen init` fails, since a place needs a name. A variant is one line to write yourself: `{ "extends": "./default.rogen.json" }`. With `--json` it never asks either, and prints what it wrote and the next steps as data (see [JSON output](#init---json)).

Answers are checked where they're typed: root directories may not nest or repeat, and a roblox-ts project takes one. It never overwrites, and never touches `.gitignore` or editor settings. When a hand-written project file such as `default.project.json` exists, which a build would replace, `init` copies it to `template.project.json` first, so its name, properties and packages carry over.

It ends with the next steps: the long-running commands to run side by side (the compiler watcher, `rogen watch`, `rojo serve`), one `darklua process` per root directory with Darklua, and where to add routes and tags.
Expand Down Expand Up @@ -136,7 +138,7 @@ Turns a tag off. Repeatable. It is the capital of `-t`, the way `ssh -t` and `ss

### `--json`

`build`, `where` and `list`. Prints one JSON document on stdout instead of text, for a program to read. See [JSON output](#json-output).
`build`, `where`, `list` and `init`. Prints one JSON document on stdout instead of text, for a program to read. See [JSON output](#json-output).

### Global options

Expand Down Expand Up @@ -203,6 +205,23 @@ An array with one entry per config and path, in the order the text form prints t

`routeMatch` is `folder`, `marker`, `separator`, `capital` or `fallback`. Each of `tags` is `{ "tag": "mock", "form": "capital" }`, where `form` is `folder`, `marker`, `separator` or `capital`.

### `init --json`

```json
{
"files": ["/repo/lobby.rogen.json", "/repo/tsconfig.lobby.json"],
"notes": [],
"nextSteps": {
"setup": ["Add \"include\": [\"src\"] to tsconfig.json, so its own build leaves out the place folders."],
"run": ["rbxtsc -w -p tsconfig.lobby.json --rojo lobby.project.json", "rogen watch lobby", "rojo serve lobby.project.json"],
"darklua": [],
"edits": ["Add tags under \"tags\" in lobby.rogen.json to swap in variants like Analytics.mock.ts."]
}
}
```

`files` lists what was written, in order. `notes` are what `init` said before writing, such as a hand-written project file kept as the template. `nextSteps` groups what to do next: `setup` holds one-time edits to make before anything runs, `run` the long-running commands that each need a terminal, `darklua` the commands that process code into the sync dir, and `edits` pointers to what to change in the written files. When a write fails, the document is `{ "files": [...], "error": "..." }`, listing the files written before it.

### `list --json`

An object keyed by the config file's absolute path. Each value has `extends` (the parents, nearest first) and `diagnostics`, and for a config that resolved, `name`, `rootDirs`, `commonRoot`, `routes`, `tags`, `exclude`, `template`, `syncDir` and `outFile`. Unset `template`, `syncDir` and `commonRoot` are `null`. A config with errors has only `extends` and `diagnostics`, the other configs are still printed, and the exit code is 1.
Expand Down
5 changes: 3 additions & 2 deletions docs/content/docs/v2/setups/multi-place.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ Keep shared code in `src`, and each place's own code in `places/<name>`.

Starting fresh, run `rogen init` and pick **Several places that share code**; with folders already in `places/`, that's the default. It asks the usual questions for the shared config, then the place names, and writes one config per place.

To add a place later, run `rogen init` again in a terminal and pick **A place**. It asks for the place's name and folder (`places/lobby` by default). Nothing else is asked: language, Darklua, routes and packages come from the existing project.
To add a place later, run `rogen init` again in a terminal and pick **A place**. It asks for the place's name and folder (`places/lobby` by default). Nothing else is asked: language, Darklua, routes and packages come from the existing project. Without a terminal, or with `--no-input`, `rogen init lobby` takes those defaults and adds the place without asking, which is how a script or a coding agent adds one:

```bash
rogen init
rogen init # in a terminal, then pick A place
rogen init lobby --no-input # without asking
```

A place folder may not overlap the shared root directories, and `init` never edits an existing file. What it writes depends on the toolchain:
Expand Down
3 changes: 3 additions & 0 deletions e2e/cases/commands/help-for-command/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ stdout:
Arguments:
name The config to write. Defaults to default.

Options:
--json Print one JSON document instead of text.

Global options:
-h, --help Print help.
-v, --version Print the version.
Expand Down
6 changes: 6 additions & 0 deletions e2e/cases/init/add-place-darklua-no-input/case.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"steps": [
["init", "lobby"],
["build", "--all"]
]
}
83 changes: 83 additions & 0 deletions e2e/cases/init/add-place-darklua-no-input/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
$ rogen init lobby
exit 0
stdout:
rogen init
Created lobby.rogen.json.
Created lobby-sync.rogen.json.
Next steps
Run each in its own terminal:
rogen watch lobby lobby-sync
rojo serve lobby-sync.project.json
rojo sourcemap lobby.project.json --output sourcemap.json --watch
Have Darklua process your code into the sync dir:
darklua process src dist/lobby/src
darklua process places/lobby dist/lobby/places/lobby
Add tags under "tags" in lobby.rogen.json to swap in variants like Analytics.mock.luau.
Wrote 2 files.

$ rogen build --all
exit 0
stdout:
rogen build · default, lobby-sync, lobby, sync
default
default.project.json · wrote
lobby-sync
lobby-sync.project.json · wrote
lobby
lobby.project.json · wrote
sync
sync.project.json · wrote
Built 4 configs.

written:
default.project.json
lobby-sync.project.json
lobby-sync.rogen.json
lobby.project.json
lobby.rogen.json
sync.project.json

lobby-sync.rogen.json:
{
"$schema": "https://ldgerrits.github.io/rogen/schema/2/rogen.json",
"extends": "./lobby.rogen.json",
"syncDir": "dist/lobby"
}

lobby.rogen.json:
{
"$schema": "https://ldgerrits.github.io/rogen/schema/2/rogen.json",
"extends": "./default.rogen.json",
"rootDirs": [
"src",
"places/lobby"
]
}

$ rojo sourcemap default.project.json
project: DataModel
ServerScriptService: ServerScriptService
Combat: Folder
Damage: ModuleScript <- src/Combat/Server/Damage.luau

$ rojo sourcemap lobby-sync.project.json
project: DataModel
ServerScriptService: ServerScriptService
Combat: Folder
Damage: ModuleScript <- dist/lobby/src/Combat/Server/Damage.luau
Lobby: Folder
Greeter: ModuleScript <- dist/lobby/places/lobby/Lobby/Server/Greeter.luau

$ rojo sourcemap lobby.project.json
project: DataModel
ServerScriptService: ServerScriptService
Combat: Folder
Damage: ModuleScript <- src/Combat/Server/Damage.luau
Lobby: Folder
Greeter: ModuleScript <- places/lobby/Lobby/Server/Greeter.luau

$ rojo sourcemap sync.project.json
project: DataModel
ServerScriptService: ServerScriptService
Combat: Folder
Damage: ModuleScript <- dist/Combat/Server/Damage.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://ldgerrits.github.io/rogen/schema/2/rogen.json",
"rootDirs": [
"src"
],
"routes": {
"Server": "ServerScriptService",
"Client": "StarterPlayer/StarterPlayerScripts",
"Shared": "ReplicatedStorage/Shared",
"*": "ReplicatedStorage/Shared"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://ldgerrits.github.io/rogen/schema/2/rogen.json",
"extends": "./default.rogen.json",
"syncDir": "dist"
}
6 changes: 6 additions & 0 deletions e2e/cases/init/add-place-no-input/case.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"steps": [
["init", "lobby"],
["build", "default", "lobby"]
]
}
58 changes: 58 additions & 0 deletions e2e/cases/init/add-place-no-input/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
$ rogen init lobby
exit 0
stdout:
rogen init
Created lobby.rogen.json.
Next steps
Run each in its own terminal:
rogen watch lobby
rojo serve lobby.project.json
Add tags under "tags" in lobby.rogen.json to swap in variants like Analytics.mock.luau.
Wrote 1 file.

$ rogen build default lobby
exit 0
stdout:
rogen build · default, lobby
default
default.project.json · wrote
lobby
lobby.project.json · wrote
Built 2 configs.

written:
default.project.json
lobby.project.json
lobby.rogen.json

lobby.rogen.json:
{
"$schema": "https://ldgerrits.github.io/rogen/schema/2/rogen.json",
"extends": "./default.rogen.json",
"rootDirs": [
"src",
"places/lobby"
]
}

$ rojo sourcemap default.project.json
project: DataModel
ReplicatedStorage: ReplicatedStorage
Shared: Folder
Combat: Folder
Types: ModuleScript <- src/Combat/Types.luau
ServerScriptService: ServerScriptService
Combat: Folder
Damage: ModuleScript <- src/Combat/Server/Damage.luau

$ rojo sourcemap lobby.project.json
project: DataModel
ReplicatedStorage: ReplicatedStorage
Shared: Folder
Combat: Folder
Types: ModuleScript <- src/Combat/Types.luau
ServerScriptService: ServerScriptService
Combat: Folder
Damage: ModuleScript <- src/Combat/Server/Damage.luau
Lobby: Folder
Greeter: ModuleScript <- places/lobby/Lobby/Server/Greeter.luau
12 changes: 12 additions & 0 deletions e2e/cases/init/add-place-no-input/project/default.rogen.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://rogen.dev/schema/2/rogen.json",
"rootDirs": [
"src"
],
"routes": {
"Server": "ServerScriptService",
"Client": "StarterPlayer/StarterPlayerScripts",
"Shared": "ReplicatedStorage/Shared",
"*": "ReplicatedStorage/Shared"
}
}
Empty file.
Empty file.
6 changes: 6 additions & 0 deletions e2e/cases/init/add-place-roblox-ts-no-input/case.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"steps": [
["init", "lobby"],
["build", "--all"]
]
}
57 changes: 57 additions & 0 deletions e2e/cases/init/add-place-roblox-ts-no-input/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
$ rogen init lobby
exit 0
stdout:
rogen init
Created lobby.rogen.json.
Created tsconfig.lobby.json.
Next steps
Add "include": ["src"] to tsconfig.json, so its own build leaves out the place folders.
Run each in its own terminal:
rbxtsc -w -p tsconfig.lobby.json --rojo lobby.project.json
rogen watch lobby
rojo serve lobby.project.json
Add tags under "tags" in lobby.rogen.json to swap in variants like Analytics.mock.ts.
Wrote 2 files.

$ rogen build --all
exit 0
stdout:
rogen build · default, lobby
default
default.project.json · wrote
lobby
lobby.project.json · wrote
Built 2 configs.

written:
default.project.json
lobby.project.json
lobby.rogen.json
tsconfig.lobby.json

lobby.rogen.json:
{
"$schema": "https://ldgerrits.github.io/rogen/schema/2/rogen.json",
"extends": "./default.rogen.json",
"rootDirs": [
"src",
"places/lobby"
],
"syncDir": "out/lobby"
}

$ rojo sourcemap default.project.json
project: DataModel
ReplicatedStorage: ReplicatedStorage
ServerScriptService: ServerScriptService
Combat: Folder
Damage: ModuleScript <- out/Combat/Server/Damage.luau

$ rojo sourcemap lobby.project.json
project: DataModel
ReplicatedStorage: ReplicatedStorage
ServerScriptService: ServerScriptService
Combat: Folder
Damage: ModuleScript <- out/lobby/src/Combat/Server/Damage.luau
Lobby: Folder
Greeter: ModuleScript <- out/lobby/places/lobby/Lobby/Server/Greeter.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://rogen.dev/schema/2/rogen.json",
"rootDirs": [
"src"
],
"routes": {
"server": "ServerScriptService",
"client": "StarterPlayer/StarterPlayerScripts",
"shared": "ReplicatedStorage/shared",
"*": "ReplicatedStorage/shared"
},
"template": "template.project.json",
"syncDir": "out"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "project",
"tree": {
"$className": "DataModel",
"ReplicatedStorage": {
"rbxts_include": {
"$path": {
"optional": "include"
},
"node_modules": {
"$className": "Folder",
"@rbxts": {
"$path": {
"optional": "node_modules/@rbxts"
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 1 addition & 1 deletion e2e/cases/init/already-exists-error/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ stdout:
rogen init
init failed.
stderr:
default.rogen.json - error: this config already exists. Delete it to write a new one.
default.rogen.json - error: this config already exists. To add a place beside it, run 'rogen init <name>'.
7 changes: 7 additions & 0 deletions e2e/cases/init/init-json/case.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"steps": [
["init", "--json"],
["init", "--json"]
],
"rojo": false
}
Loading
Loading