Commands Reference
Complete reference for all Reldens CLI commands.
CLI Binaries
The project provides three main CLI entry points:
- reldens - Main command router (bin/reldens-commands.js)
- reldens-generate - Data generation tool (bin/generate.js)
- reldens-import - Data import tool (bin/import.js)
Development & Building
# Run tests
npm test
# Or with filters
node tests/manager.js --filter="test-name" --break-on-error
# Build theme styles
reldens buildCss [theme-name]
# Build client HTML
reldens buildClient [theme-name]
# Build both styles and client
reldens buildSkeleton
# Complete rebuild from scratch
reldens fullRebuild
Theme & Asset Management
# Install default theme
reldens installDefaultTheme
# Copy assets to dist folder
reldens copyAssetsToDist
# Copy default assets to dist/assets
reldens copyDefaultAssets
# Copy default theme to project
reldens copyDefaultTheme
# Copy the reldens theme plugins (node_modules/reldens/theme/plugins) into the project theme/plugins
reldens copyPackage
# Copy the reldens admin theme (node_modules/reldens/theme/admin) into the project theme/admin
reldens copyAdmin
# Copy the project theme/admin css and js folders into dist/css and dist/js
reldens copyAdminFiles
# Copy the project theme/admin/assets folder into dist/assets
reldens copyAdminAssetsToDist
# Delete and recreate dist folder
reldens resetDist
# Delete dist folder only
reldens removeDist
Every command that is not test, help, generateEntities, createAdmin or resetPassword runs the ThemeManager (lib/game/server/theme-manager.js) method with the same name, without arguments (Commander.execute() calls this.themeManager[this.command]()). Commander.validateThemeManagerCommand() (bin/commander.js) only rejects execute and the names that are not ThemeManager methods:
if('execute' === this.command || 'function' !== typeof this.themeManager[this.command]){
Logger.error('Invalid command:', this.command);
return false;
}
The second argument selects the project theme (reldens buildClient my-theme), default when it is omitted.
Database & Entities
# Generate entities from database schema
reldens generateEntities [--override] [--prismaClientPath=path]
# Direct entity generation with connection arguments (bypasses .env):
npx reldens-storage generateEntities --user=reldens --pass=reldens --database=reldens --driver=knex
How reldens generateEntities works:
- It reads the project root .env (RELDENS_DB_* and RELDENS_STORAGE_DRIVER, knex by default).
- It spawns node <@reldens/storage>/bin/reldens-storage.js generateEntities with the --user, --pass, --host, --port, --database, --driver and --client arguments taken from it (RELDENS_DB_CLIENT=mysql2 is sent as mysql for Prisma).
- It also forwards RELDENS_PRISMA_ADAPTER and RELDENS_PRISMA_ADAPTER_CLASS as --prismaAdapter= and --prismaAdapterClass=, plus --override and --prismaClientPath= when they are passed to the command.
- Generated entities are placed in the generated-entities/ directory, models under generated-entities/models/[driver]/.
See Entities Generation for the full regeneration workflow.
Optional Storage Drivers
Knex is bundled with @reldens/storage. The other drivers are only available when their packages are installed in the project:
npm install kysely
npm install drizzle-orm
npm install objection@3.1.5
npm install @mikro-orm/core@7.2.0 @mikro-orm/mysql@7.2.0
npm install prisma @prisma/client @prisma/adapter-mariadb
These are the packages the web installer installs itself for the selected driver when its "Allow installer to run npm install for missing packages" checkbox is checked (driversPackages in lib/game/server/installer/packages-installation.js, see the Installer Guide).
Set RELDENS_STORAGE_DRIVER to the driver key (kysely, drizzle, objection-js, mikro-orm, prisma) and run reldens generateEntities --override to generate the models for it.
Prisma-Specific Commands
IMPORTANT: Prisma requires a separate client generation step before entities can be generated.
# Step 1: Generate Prisma schema and client from existing database
# This introspects the database and creates prisma/schema.prisma + prisma/client/
npx reldens-storage-prisma --host=localhost --port=3306 --user=reldens --password=reldens --database=reldens --clientOutputPath=./client
# Step 2: Generate Reldens entities using Prisma driver
npx reldens-storage generateEntities --user=reldens --pass=reldens --database=reldens --driver=prisma
Full parameter list for reldens-storage-prisma:
- --host - Database host (required)
- --port - Database port (required)
- --user - Database username (required)
- --password - Database password (required)
- --database - Database name (required)
- --clientOutputPath - Output path for the Prisma client, relative to the schema path (default: ./client)
- --prismaSchemaPath - Path for the schema.prisma file (default: ./prisma)
Prisma workflow (running from the project root)
- Make sure the project root holds the .env with your database credentials (npx reldens copyEnvFile copies the sample when it is missing).
- Run npx reldens-storage-prisma to generate prisma/schema.prisma and prisma/client/. It introspects the MySQL database and creates the Prisma schema.
- Run npx reldens-storage generateEntities --driver=prisma to generate Reldens entities, or use npx reldens generateEntities --override to read the credentials and the Prisma adapter (RELDENS_PRISMA_ADAPTER, RELDENS_PRISMA_ADAPTER_CLASS) from .env automatically.
- Set RELDENS_STORAGE_DRIVER=prisma in your .env file to use Prisma at runtime.
Note: RELDENS_DB_CLIENT=mysql2 is automatically normalized to mysql when RELDENS_STORAGE_DRIVER=prisma because Prisma does not support the mysql2:// URL scheme.
Environment variables for Prisma:
RELDENS_STORAGE_DRIVER=prisma
RELDENS_DB_URL=mysql://user:password@host:port/database
RELDENS_PRISMA_ADAPTER=@prisma/adapter-mariadb
RELDENS_PRISMA_ADAPTER_CLASS=PrismaMariaDb
Installation & Setup
# Create base project skeleton: installs the reldens package when it is missing, overwrites index.js, updates
# package.json, copies the default theme when the project theme is missing, resets dist and runs fullRebuild
# The created project package.json has no start script, start the project with: node .
reldens createApp
# Update the project package.json: sets alias.process and targets.main to false for the bundler, it does not add a
# start script to an existing package.json (only a missing package.json is created from the reldens
# data-package.json template)
reldens updatePackageJson
# Install skeleton: overwrites index.js, runs copyServerFiles, resets dist and runs fullRebuild
reldens installSkeleton
# Copy .env.dist template (only when .env does not exist)
reldens copyEnvFile
# Copy knexfile.js template (only when knexfile.js does not exist)
reldens copyKnexFile
# Copy .gitignore.dist template (only when .gitignore does not exist)
reldens copyGitignoreFile
# Copy index.js template (only when index.js does not exist)
reldens copyIndex
# Copy the .env, knexfile.js, .gitignore and index.js templates into the project
reldens copyServerFiles
# Build the web installer from the reldens package into the project install folder
reldens buildInstaller
# Copy all default files for fullRebuild
reldens copyNew
# Show all available commands
reldens help
# Test file system access
reldens test
See Server, Client Build and Assets for the project files each of these commands overwrites.
Data Generation Tools
# Generate game data (via reldens-generate)
# Generate player XP per level
reldens-generate players-experience-per-level [data-file.json]
# Generate monster XP per level
reldens-generate monsters-experience-per-level [data-file.json] [players-levels-file.json]
# Generate attributes per level
reldens-generate attributes-per-level [data-file.json]
# Generate maps with various loaders
# Loaders: LayerElementsObjectLoader, LayerElementsCompositeLoader, MultipleByLoaderGenerator,
# MultipleWithAssociationsByLoaderGenerator
reldens-generate maps [map-data-file.json] [loader-name]
# Data import (via reldens-import)
# Import game data, valid types: objects, players-experience-per-level, attributes-per-level, class-paths,
# maps, skills
reldens-import [data-type] [theme-name] [data-file.json]
See Generators and Imports for the full per-generator reference.
User Management Commands
# Create admin user
reldens createAdmin --user=username --pass=password --email=email@example.com
# Creates an admin user with role_id from the server/admin/roleId config (99 in the basic config, code fallback: 1)
# Validates the email format and the password minimum length
# Password is automatically encrypted using PBKDF2 SHA-512
# Reset user password
reldens resetPassword --user=username --pass=newpassword
# Resets password for existing user
# Validates the password minimum length
# Password is automatically encrypted
# Works for any user (admin or regular)
# Examples:
reldens createAdmin --user=admin --pass=SecurePass123 --email=admin@yourgame.com
reldens resetPassword --user=someuser --pass=NewSecurePass456
Implementation Details
- Service classes: CreateAdmin and ResetPassword in lib/users/server/.
- Both receive serverManager in their constructor (following the importer pattern).
- Services return a boolean result with an error property for failure details.
- createAdmin uses the existing usersRepository.create() with role_id and the admin origin in userData.
- resetPassword uses usersRepository.loadOneBy() and updateById().
- Admin role ID comes from config server/admin/roleId (99 in reldens-basic-config-v4.0.0.sql, code fallback: 1).
- Email validation via sc.validateInput(email, 'email') from @reldens/utils.
- Commands initialize ServerManager automatically from .env (pattern from bin/import.js).
- Password encryption uses Encryptor from @reldens/server-utils (100k iterations, SHA-512).
- Both check the password with PasswordPolicy (lib/users/password-policy.js) before encrypting it and fail with "The password must have at least N characters." when it is shorter. The minimum length comes from the client/players/password/minimumLength config (3 in the basic config), falling back to server/security/passwordMinimumLength, which is filled from RELDENS_PASSWORD_MINIMUM_LENGTH (default: 3).
static fetchMinimumLength(configManager)
{
return Number(configManager.getWithoutLogs(
'client/players/password/minimumLength',
configManager.getWithoutLogs('server/security/passwordMinimumLength', 3)
));
}
Related Documentation
- Installation - First-time setup commands.
- Customize your game - Theme rebuild commands.
- Environment Variables - All RELDENS_* environment variables.
- Entities Generation - Regenerating entities after a schema change.
- Storage Architecture - Storage drivers and entity loading.
- Server, Client Build and Assets - What the build and copy commands do.
- Installer Guide - Web installer and optional driver packages.
- Generators and Imports - Data generation and import commands in detail.
reldens