Skip to content

Commit d760c29

Browse files
Copilothuangyiirene
andcommitted
Update CLI README with comprehensive documentation for new dev commands
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent 714b4fd commit d760c29

File tree

1 file changed

+156
-0
lines changed

1 file changed

+156
-0
lines changed

packages/tools/cli/README.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,164 @@ fields:
433433
434434
### Development Tools
435435
436+
#### `dev` (alias: `d`)
437+
438+
Start development server with hot reload support. This is the recommended command for local development.
439+
440+
```bash
441+
# Start development server (port 3000)
442+
objectql dev
443+
444+
# Specify options
445+
objectql dev --dir ./src --port 8080
446+
447+
# Disable file watching
448+
objectql dev --no-watch
449+
```
450+
451+
The development server provides:
452+
- **Swagger UI**: `http://localhost:<port>/swagger` - Interactive API documentation
453+
- **API Endpoint**: `http://localhost:<port>/` - Main API endpoint
454+
- **OpenAPI Spec**: `http://localhost:<port>/openapi.json` - Machine-readable API spec
455+
456+
**Options:**
457+
- `-p, --port <number>` - Port to listen on [default: "3000"]
458+
- `-d, --dir <path>` - Directory containing schema [default: "."]
459+
- `--no-watch` - Disable file watching (future feature)
460+
461+
#### `start`
462+
463+
Start production server. Loads configuration from `objectql.config.ts/js` if available.
464+
465+
```bash
466+
# Start production server
467+
objectql start
468+
469+
# Specify options
470+
objectql start --port 8080 --dir ./dist
471+
472+
# Use custom config file
473+
objectql start --config ./config/production.config.ts
474+
```
475+
476+
**Options:**
477+
- `-p, --port <number>` - Port to listen on [default: "3000"]
478+
- `-d, --dir <path>` - Directory containing schema [default: "."]
479+
- `-c, --config <path>` - Path to objectql.config.ts/js
480+
481+
**Environment Variables:**
482+
- `DATABASE_FILE` - Path to SQLite database file (default: "./objectql.db")
483+
484+
#### `build` (alias: `b`)
485+
486+
Build project and prepare for production deployment. Validates metadata, generates TypeScript types, and copies files to dist folder.
487+
488+
```bash
489+
# Build project
490+
objectql build
491+
492+
# Build with custom output directory
493+
objectql build --output ./build
494+
495+
# Build without type generation
496+
objectql build --no-types
497+
498+
# Build without validation
499+
objectql build --no-validate
500+
```
501+
502+
**Options:**
503+
- `-d, --dir <path>` - Source directory [default: "."]
504+
- `-o, --output <path>` - Output directory [default: "./dist"]
505+
- `--no-types` - Skip TypeScript type generation
506+
- `--no-validate` - Skip metadata validation
507+
508+
**Build Steps:**
509+
1. Validates all metadata files
510+
2. Generates TypeScript type definitions (if enabled)
511+
3. Copies all metadata files (.yml) to dist folder
512+
513+
#### `test` (alias: `t`)
514+
515+
Run tests for the ObjectQL project. Automatically detects and runs Jest tests if configured.
516+
517+
```bash
518+
# Run all tests
519+
objectql test
520+
521+
# Run tests in watch mode
522+
objectql test --watch
523+
524+
# Run tests with coverage report
525+
objectql test --coverage
526+
527+
# Specify project directory
528+
objectql test --dir ./src
529+
```
530+
531+
**Options:**
532+
- `-d, --dir <path>` - Project directory [default: "."]
533+
- `-w, --watch` - Watch mode (re-run tests on file changes)
534+
- `--coverage` - Generate coverage report
535+
536+
**Requirements:**
537+
- Jest must be installed and configured in package.json
538+
- Falls back to `npm test` if Jest is not detected
539+
540+
#### `lint` (alias: `l`)
541+
542+
Validate metadata files for correctness and best practices.
543+
544+
```bash
545+
# Lint all metadata files
546+
objectql lint
547+
548+
# Lint specific directory
549+
objectql lint --dir ./src/objects
550+
551+
# Auto-fix issues (future feature)
552+
objectql lint --fix
553+
```
554+
555+
**Options:**
556+
- `-d, --dir <path>` - Directory to lint [default: "."]
557+
- `--fix` - Automatically fix issues (future feature)
558+
559+
**Validation Rules:**
560+
- Object and field names must be lowercase with underscores
561+
- All objects should have labels
562+
- All fields should have labels
563+
- No empty objects (objects must have at least one field)
564+
565+
#### `format` (alias: `fmt`)
566+
567+
Format metadata files using Prettier for consistent styling.
568+
569+
```bash
570+
# Format all YAML files
571+
objectql format
572+
573+
# Format specific directory
574+
objectql format --dir ./src
575+
576+
# Check formatting without modifying files
577+
objectql format --check
578+
```
579+
580+
**Options:**
581+
- `-d, --dir <path>` - Directory to format [default: "."]
582+
- `--check` - Check if files are formatted without modifying them
583+
584+
**Formatting Rules:**
585+
- Uses Prettier with YAML parser
586+
- Print width: 80 characters
587+
- Tab width: 2 spaces
588+
- Single quotes for strings
589+
436590
#### `serve` (alias: `s`)
437591

592+
*Note: This is an alias for the `dev` command, kept for backwards compatibility. Use `objectql dev` for new projects.*
593+
438594
Start a lightweight development server with an in-memory database. Perfect for rapid prototyping without setting up a backend project.
439595

440596
```bash

0 commit comments

Comments
 (0)