@mavonengine/cli 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +138 -1
- package/dist/{chunk-7UZYGMGO.js → chunk-3VVGSO5T.js} +7 -1
- package/dist/{chunk-IIWBECVS.js → chunk-5YUDR7ZR.js} +1 -1
- package/dist/{docs-S2SWFUIL.js → docs-T42UVONR.js} +2 -2
- package/dist/index.js +1546 -66
- package/dist/{server-AC5LBJ6A.js → server-JSUVROT5.js} +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -140,6 +140,28 @@ A plugin offers files with `"publish": "<directory>"` under `mavonengine` in its
|
|
|
140
140
|
| `--cwd <dir>` | current directory | Where to start looking for the project |
|
|
141
141
|
| `--force` | | Replace the files you have with the plugin's |
|
|
142
142
|
|
|
143
|
+
## `mavonengine make:plugin`
|
|
144
|
+
|
|
145
|
+
Creates a plugin inside the project you are in, ready to load:
|
|
146
|
+
|
|
147
|
+
```sh
|
|
148
|
+
npx @mavonengine/cli make:plugin forest
|
|
149
|
+
npx @mavonengine/cli make:plugin @acme/forest --target server
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
It writes `plugins/<name>/` (without the scope) with a `package.json` that has the [`mavonengine` manifest](#writing-a-plugin), `src/client.ts` and/or `src/server.ts` with every hook stubbed, a `tsconfig.json` and a README. Then it adds `plugins/*` to the `workspaces` in `package.json` (pnpm gets a `link:` dependency instead), adds the plugin to `mavonengine.json` and runs the package manager's install, which links it into `node_modules`.
|
|
153
|
+
|
|
154
|
+
The manifest points at the TypeScript sources, so there is no build step: Vite compiles the client entry and Node 24 strips the types of the server entry. That means the server entry takes only syntax Node can strip (no `enum`s or parameter properties) and imports its own files with `.ts` extensions, which the generated `tsconfig.json` enforces. The client reloads when its entry changes; restart the game server for changes to the server entry. To publish the plugin to npm later, build it to `dist/` like the [first-party plugins](https://github.com/MavonEngine/Core/tree/main/packages/plugins) and point the manifest there.
|
|
155
|
+
|
|
156
|
+
It refuses a name that is already in `mavonengine.json`, installed, or a directory that exists, and never overwrites a file.
|
|
157
|
+
|
|
158
|
+
| Option | Default | |
|
|
159
|
+
| --- | --- | --- |
|
|
160
|
+
| `--target <side>` | `both` | `client`, `server` or `both` |
|
|
161
|
+
| `--cwd <dir>` | current directory | Where to start looking for the project |
|
|
162
|
+
| `--no-register` | | Leave `mavonengine.json` alone |
|
|
163
|
+
| `--no-install` | | Don't run the package manager to link it |
|
|
164
|
+
|
|
143
165
|
## `mavonengine build`
|
|
144
166
|
|
|
145
167
|
Runs the project's `build` script, then lists what each plugin put into the release. Plugin assets are copied into the client's output under `plugins/<package>/`. Only the shared ones and those of the prefabs in `mavonengine.json` are copied. The client skips loading the others, so a release never requests a file it doesn't contain.
|
|
@@ -152,6 +174,89 @@ npx @mavonengine/cli build
|
|
|
152
174
|
| --- | --- | --- |
|
|
153
175
|
| `--cwd <dir>` | current directory | Where to start looking for the project |
|
|
154
176
|
|
|
177
|
+
## `mavonengine doctor`
|
|
178
|
+
|
|
179
|
+
Checks the project you are in and says what to do about what it finds. It changes nothing.
|
|
180
|
+
|
|
181
|
+
```sh
|
|
182
|
+
npx @mavonengine/cli doctor
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
MavonEngine project at ~/games/my-game (npm, @mavonengine/core 0.0.25)
|
|
187
|
+
|
|
188
|
+
Environment
|
|
189
|
+
✓ Node 24.4.0 needs >=24
|
|
190
|
+
✓ @mavonengine/cli 0.0.6
|
|
191
|
+
i @mavonengine/core 0.0.25 0.0.26 is out
|
|
192
|
+
|
|
193
|
+
mavonengine.json
|
|
194
|
+
✓ mavonengine.json 2 plugins
|
|
195
|
+
✗ appUrl "mygame.com" is not an http(s) URL
|
|
196
|
+
→ e.g. "appUrl": "https://mygame.com"
|
|
197
|
+
|
|
198
|
+
Plugins
|
|
199
|
+
✓ @mavonengine/chat 0.0.3 core >=0.0.22
|
|
200
|
+
✗ @mavonengine/auth 0.2.0 made for @mavonengine/core >=0.0.26, the project has 0.0.25
|
|
201
|
+
→ mavonengine install @mavonengine/auth@0.1.1
|
|
202
|
+
|
|
203
|
+
2 errors, 0 warnings
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
- **Environment**: the Node version, against what the CLI and the installed `@mavonengine/core` need. Then each `@mavonengine/*` package in `package.json`: whether it is installed and matches the range there (or `npm install` is due), and whether a newer one is out.
|
|
207
|
+
- **mavonengine.json**: whether it can be read, an `appUrl` that isn't an http(s) URL, a `database`, `auth` or `notifications` that names a plugin that isn't in `plugins` or is turned off, entries of the wrong shape, and settings it doesn't know (typos).
|
|
208
|
+
- **Migrations**: the [`upgrade`](#mavonengine-upgrade) migrations the project's core has that the project hasn't had yet.
|
|
209
|
+
- **Plugins**: each plugin in `mavonengine.json` must be installed, a MavonEngine plugin, and built (its entries exist). It also needs the assets of the prefabs in use, and has to be made for the project's core. A plugin's supported core is `engine` in its `mavonengine` field, or else its `@mavonengine/core` peer dependency. When a plugin doesn't fit, doctor looks through the versions published on npm for the newest one that does and names it. A plugin that is installed but not in `mavonengine.json` is pointed out too.
|
|
210
|
+
|
|
211
|
+
The game server and the Vite plugin also check `engine` when they load plugins. A plugin made for another core still loads, with a warning that points here.
|
|
212
|
+
|
|
213
|
+
Version lookups go to the npm registry (`npm_config_registry` when set, else registry.npmjs.org) and send it the names of the project's `@mavonengine/*` packages and plugins. `--offline` leaves that out. When the registry can't be reached, that is one warning and the rest is checked anyway.
|
|
214
|
+
|
|
215
|
+
The exit code is 1 when something is wrong (✗), 0 otherwise. With `--strict` warnings (!) fail too, notes (i) never do. `--json` prints the findings for CI and scripts.
|
|
216
|
+
|
|
217
|
+
| Option | Default | |
|
|
218
|
+
| --- | --- | --- |
|
|
219
|
+
| `--offline` | | Don't ask the npm registry |
|
|
220
|
+
| `--strict` | | Fail on warnings too |
|
|
221
|
+
| `--json` | | Print the findings as JSON |
|
|
222
|
+
| `--cwd <dir>` | current directory | Where to start looking for the project |
|
|
223
|
+
|
|
224
|
+
## `mavonengine upgrade`
|
|
225
|
+
|
|
226
|
+
Moves the project to the latest `@mavonengine/core`, with plugins that work with it, then makes the changes to the project's files that the new core needs.
|
|
227
|
+
|
|
228
|
+
```sh
|
|
229
|
+
npx @mavonengine/cli upgrade --dry-run # see what would happen
|
|
230
|
+
npx @mavonengine/cli upgrade
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
1. **Packages.** `@mavonengine/core` goes to its latest version on the npm registry, or to `--to <version>`. Each plugin goes to its newest version whose `engine` range takes that core. The other `@mavonengine/*` packages go to their newest version whose `@mavonengine/core` peer range takes it. Packages are never moved down, and packages from `file:`, git or another source are left alone. When a plugin has no version for the new core, the upgrade stops before installing anything: pick an older core with `--to`, remove the plugin, or pass `--force`. The packages are installed with the project's package manager. Each stays in `dependencies` or `devDependencies`, and pinned versions stay pinned.
|
|
234
|
+
2. **Migrations.** These come from the core that is now installed, so the new core decides what to migrate. Each one is shown as a diff before anything is written. Applied migrations are recorded in `migrations` in `mavonengine.json` and never offered again, even when you undo one on purpose. When a migration adds a dependency, the package manager installs it.
|
|
235
|
+
3. **Doctor.** [`mavonengine doctor`](#mavonengine-doctor) checks the result, and the exit code is doctor's.
|
|
236
|
+
|
|
237
|
+
| Migration | What it changes |
|
|
238
|
+
| --- | --- |
|
|
239
|
+
| `0.0.22-dev-script` | `npm run dev` starts `mavonengine dev`. The old `dev` script becomes `dev:server`, and `@mavonengine/cli` becomes a dev dependency |
|
|
240
|
+
| `0.0.25-app-name-title` | `index.html`'s `<title>` becomes `%MAVONENGINE_APP_NAME%`. The title it had becomes `appName` in `mavonengine.json`, so the tab still says the same |
|
|
241
|
+
|
|
242
|
+
The upgrade asks before installing and before writing; `--yes` skips both questions, and without a terminal `--yes` is required. It won't start with uncommitted changes in git, so its changes can be reviewed and undone on their own; `--allow-dirty` overrides that. After installing packages yourself, `--only-migrations` runs only steps 2 and 3.
|
|
243
|
+
|
|
244
|
+
| Option | Default | |
|
|
245
|
+
| --- | --- | --- |
|
|
246
|
+
| `--to <version>` | latest | The `@mavonengine/core` version to move to |
|
|
247
|
+
| `--only-migrations` | | Leave the packages alone |
|
|
248
|
+
| `--dry-run` | | Show what would happen, change nothing |
|
|
249
|
+
| `-y`, `--yes` | | Don't ask |
|
|
250
|
+
| `--force` | | Upgrade even when a plugin has no version for the new core |
|
|
251
|
+
| `--allow-dirty` | | Start with uncommitted changes |
|
|
252
|
+
| `--cwd <dir>` | current directory | Where to start looking for the project |
|
|
253
|
+
|
|
254
|
+
### Writing a migration
|
|
255
|
+
|
|
256
|
+
Migrations are in `packages/core/src/Migrations/migrations.ts`, oldest first. Each has an `id` of `<since>-<name>` that never changes once released, the first core version it is for (`since`), and a one-line `description`. `applies` says whether the project still needs it, and `run` changes the project. Both read and write only through `ctx.files`, so the change can be shown before it is written. A migration must leave a project it has already run on alone.
|
|
257
|
+
|
|
258
|
+
A CI check (`.github/workflows/migrations.yml`, running `scripts/check-migrations.mjs`) asks for a migration when a pull request changes the multiplayer template's project files. It watches the `package.json` files (scripts, workspaces, and which dependencies there are, but not their versions, which every release bumps), the config files and `client/index.html`. Game code, the README and the lockfile don't count. The check passes when the pull request adds a migration, or when its description says `[no migration]` because existing projects don't need the change.
|
|
259
|
+
|
|
155
260
|
## `mavonengine dashboard`
|
|
156
261
|
|
|
157
262
|
A live terminal dashboard for a running game server, built with [hqtui](https://github.com/profullstack/hqtui). For the same dashboard in a browser, behind a login, see the [`@mavonengine/http-monitoring`](https://github.com/MavonEngine/Core/tree/main/packages/plugins/http-monitoring) plugin.
|
|
@@ -322,7 +427,7 @@ To let `compare_entity` match your own player with the server's, set `game.local
|
|
|
322
427
|
|
|
323
428
|
## Writing a plugin
|
|
324
429
|
|
|
325
|
-
A plugin is an npm package with a `mavonengine` field in its `package.json`:
|
|
430
|
+
[`mavonengine make:plugin`](#mavonengine-makeplugin) sets one up in your project. A plugin is an npm package with a `mavonengine` field in its `package.json`:
|
|
326
431
|
|
|
327
432
|
```json
|
|
328
433
|
{
|
|
@@ -401,6 +506,38 @@ export default defineServerPlugin({
|
|
|
401
506
|
|
|
402
507
|
A plugin that takes the token some other way, such as the password of a login, checks it with `ctx.adminToken.matches(candidate)`, without ever seeing the token.
|
|
403
508
|
|
|
509
|
+
### Admin panel pages
|
|
510
|
+
|
|
511
|
+
The game server serves an admin panel at `/admin/`: one layout with a sidebar, behind a login that takes the [admin token](#admin-token) as the password (any user name). The engine adds Overview, Routes and Plugins pages. A plugin adds its own with `ctx.admin.page()`, and it shows up in the sidebar under **Plugins**, with the links it gives listed below it:
|
|
512
|
+
|
|
513
|
+
```ts
|
|
514
|
+
export default defineServerPlugin({
|
|
515
|
+
http(app, ctx) {
|
|
516
|
+
ctx.admin.page({
|
|
517
|
+
path: 'chat', // /admin/chat/
|
|
518
|
+
label: 'Chat',
|
|
519
|
+
icon: 'chat', // dashboard, activity, routes, plugin, database, users, logs, settings, chart, mail, chat, bell or lock
|
|
520
|
+
children: [
|
|
521
|
+
{ label: 'Live', href: '#live' }, // an anchor on the page
|
|
522
|
+
{ label: 'Mutes', href: 'mutes', render: () => '<p>…</p>' }, // a sub page, /admin/chat/mutes/
|
|
523
|
+
],
|
|
524
|
+
render: req => ({
|
|
525
|
+
html: '<div class="adm-page">…</div>',
|
|
526
|
+
styles: [ctx.admin.url('chat/style.css')],
|
|
527
|
+
scripts: [ctx.admin.url('chat/app.js')],
|
|
528
|
+
}),
|
|
529
|
+
})
|
|
530
|
+
|
|
531
|
+
// Every route under the panel's path is behind its login already
|
|
532
|
+
app.get(ctx.admin.url('chat/api/messages'), (_req, res) => res.json({ messages: [] }))
|
|
533
|
+
},
|
|
534
|
+
})
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
The page's HTML goes into the layout as is: escape whatever came from players with `escapeHtml()` from `@mavonengine/core/Networking/Server/Admin/AdminPanel`. Inline scripts are blocked by the page's Content-Security-Policy, so ship script files. The layout's colors are CSS custom properties (`--surface`, `--border`, `--primary`, …), and it has helpers for pages: `adm-page`, `adm-cards`, `adm-card`, `adm-table`, `adm-badge`. `ctx.admin.addLogin((user, password) => …)` lets more people log in than whoever has the token, such as the users of an htpasswd file.
|
|
538
|
+
|
|
539
|
+
Without an admin token the panel only answers localhost, and in production it stays off until the server has a token or a plugin added a login. Move it with `admin: { path: '/ops' }` in the server's options, or turn it off with `admin: { enabled: false }`.
|
|
540
|
+
|
|
404
541
|
### Authenticating players
|
|
405
542
|
|
|
406
543
|
An auth plugin decides who may connect, before a client gets a player. [`@mavonengine/auth`](https://github.com/MavonEngine/Core/tree/main/packages/plugins/auth) is one, with accounts, passwords and sessions; write your own for anything else. Its client entry gives the token the game connects with, and its server entry's `authorize()` checks it:
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
|
+
};
|
|
2
7
|
|
|
3
8
|
// package.json
|
|
4
|
-
var version = "0.0.
|
|
9
|
+
var version = "0.0.7";
|
|
5
10
|
|
|
6
11
|
// src/mcp/config.ts
|
|
7
12
|
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
@@ -37,6 +42,7 @@ function writeMcpConfig(dir) {
|
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
export {
|
|
45
|
+
__export,
|
|
40
46
|
version,
|
|
41
47
|
DEFAULT_DOCS_URL,
|
|
42
48
|
MCP_CONFIG_FILE,
|