BaseUX Commands
BaseUX provides a powerful command-line interface (CLI) to streamline your development workflow. This guide covers all available commands, with special focus on the entity generation system.
Command Overview
BaseUX CLI provides the following commands:
| Command | Description |
|---|---|
bux new <project-name> | Create a new BaseUX project |
bux g entity <entity-name> [fields] | Generate a new entity with CRUD operations |
bux start or bux s | Start the BaseUX application server |
bux update | Update framework core components |
bux upgrade | Upgrade the BaseUX CLI tool |
bux version | Display version information |
Once installed, the BaseUX CLI is accessible via the bux command globally and provides all the functionality needed for project scaffolding and development.
Creating a New Project
To create a new BaseUX project:
bux new my-appThis command:
- Creates a new project directory
- Installs all necessary dependencies
- Sets up the initial project structure
- Initializes Git repository
Start Application Server
BaseUX provides a command to start the application server:
bux start
# or the shorthand
bux sOptions:
--hot-reload,-r: Enable hot reloading using air--docs,-d: Generate Swagger documentation??
Examples:
# Start the server normally
bux start
# Start with hot reloading
bux start -r
# Start with Swagger documentation
bux start -d
# Start with both hot reloading and Swagger docs
bux start -r -dEntity Generation
The entity generation system is one of BaseUX's most powerful features. It creates a complete set of files for managing a data entity with full CRUD operations.
Basic Entity Generation
bux g posts title:string content:text publishedAt:datetimeThis command generates:
- A complete entity structure in
structures/posts/ - TypeScript models with validation
- API services for CRUD operations
- Pinia store for state management
- UI components (grid, table, modals)
- Pages for listing and detail views
Available Field Types
When defining entity fields, you can use the following types:
| Type | Description | Example |
|---|---|---|
string | Text field | title:string |
text | Longer text field | content:text |
number | Numeric field | count:number |
boolean | True/false field | isPublished:boolean |
date | Date field | createdAt:date |
datetime | Date with time | publishedAt:datetime |
email | Email field | contact:email |
password | Password field | password:password |
url | URL field | website:url |
select | Dropdown selection | status:select:draft,published,archived |
relation | Entity relation | author:relation:users |
Field Options
You can add options to fields using the following syntax:
fieldName:type:option1,option2Common options include:
required: Field is requiredunique: Field must be uniquemin:X: Minimum value/lengthmax:X: Maximum value/lengthdefault:X: Default value
Example:
bux g entity products name:string:required,min:3 price:number:required,min:0 category:select:electronics,clothing,food:default:electronicsRelation Fields
To create relations between entities:
bux g entity comments content:text:required post:relation:posts user:relation:usersThis creates a comments entity with relations to both posts and users entities.
Component Generation
Generate a new component:
bux g component UserProfileThis creates:
app/components/UserProfile.vue
Composable Generation
Generate a custom composable:
bux g composable useAuthThis creates:
app/composables/useAuth.ts
Service Generation
Generate a new service:
bux g service notificationThis creates:
app/services/notificationService.ts
Store Generation
Generate a new Pinia store:
bux g store settingsThis creates:
app/stores/settingsStore.ts
Running Your Project
After generating entities, you can run your project using the bux run command, which executes bun run <subcommand> for any subcommand:
# Start the development server
bux run dev
# Build for production
bux run build
# Generate static files
bux run generate
# Start the production server
bux run previewThis approach is more straightforward and flexible, as it works with any script defined in your package.json file.
You can also use Bun directly if you prefer:
bun run dev
bun run build
bun run generate
bun run previewNote: BaseUX provides both scaffolding tools and convenient wrappers around common development commands.
Update Framework Components
To update the framework core components:
bux updateThis command updates the core components of your BaseUX application without affecting your custom code.
Upgrade CLI Tool
To upgrade the BaseUX CLI tool itself:
bux upgradeThis ensures you have the latest version of the BaseUX command-line interface.
Version Information
To display version information about your BaseUX installation:
bux versionThis shows the current version of the BaseUX CLI and its components.
Advanced Usage
Custom Templates
BaseUX allows you to create custom templates for generation:
- Create a
templatesdirectory in your project - Add template files with the
.tmplextension - Use the
--templateflag to specify your custom template
bux g productExtending Entities
You can extend existing entities:
bux g entity products --extendThis will preserve your custom modifications while updating the base structure.