Add mainstream development commands to ObjectQL CLI#79
Conversation
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds mainstream framework-style development commands to the ObjectQL CLI, enhancing the developer experience with familiar command patterns inspired by Next.js and NestJS.
Changes:
- Added six new CLI commands:
dev,start,build,test,lint, andformat - Updated the
servecommand description to indicate it's an alias for backward compatibility - Added comprehensive test coverage for the new commands
- Updated CLI documentation with detailed usage instructions for all new commands
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/tools/cli/src/index.ts | Registers all six new commands with their options and aliases |
| packages/tools/cli/src/commands/dev.ts | Implements development server command with hot reload support |
| packages/tools/cli/src/commands/start.ts | Implements production server with config loading and graceful shutdown |
| packages/tools/cli/src/commands/build.ts | Implements build command for validation, type generation, and metadata copying |
| packages/tools/cli/src/commands/test.ts | Implements test runner with Jest auto-detection |
| packages/tools/cli/src/commands/lint.ts | Implements metadata validation with naming convention checks |
| packages/tools/cli/src/commands/format.ts | Implements YAML formatting with Prettier integration |
| packages/tools/cli/tests/commands.test.ts | Adds test coverage for build, lint, and format commands |
| packages/tools/cli/README.md | Documents all new commands with usage examples and options |
| console.log(chalk.gray(`Loading schema from: ${rootDir}`)); | ||
|
|
||
| // Try to load configuration | ||
| let config: any = null; |
There was a problem hiding this comment.
The variable config is typed as any, which bypasses TypeScript's type safety. Consider defining an interface in @objectql/types that represents the config structure, or use a more specific type based on the expected configuration schema.
There was a problem hiding this comment.
Fixed in de4fca8. Created a LoadedConfig interface that provides type safety while supporting flexible config formats (both datasource and datasources properties).
|
|
||
| // Validate each object | ||
| for (const obj of objects) { | ||
| const objectConfig = obj as any; |
There was a problem hiding this comment.
Using as any bypasses TypeScript's type safety. Since this is checking object definitions from the metadata, consider importing and using the appropriate type from @objectql/types (such as ObjectDefinition) instead of casting to any.
There was a problem hiding this comment.
Fixed in de4fca8. Now using ObjectConfig type from @objectql/types instead of casting to any.
| hasErrors = true; | ||
| } | ||
|
|
||
| const fieldConfig = field as any; |
There was a problem hiding this comment.
Using as any bypasses TypeScript's type safety. Consider importing the appropriate field type from @objectql/types instead of casting to any.
There was a problem hiding this comment.
Fixed in de4fca8. Now using FieldConfig type from @objectql/types instead of casting to any.
|
|
||
| // Format with Prettier - use dynamic import for better compatibility | ||
| try { | ||
| const prettier = await import('prettier'); |
There was a problem hiding this comment.
If Prettier is not installed as a dependency, this dynamic import will fail with an unclear error. Consider adding error handling with a helpful message instructing users to install Prettier if it's missing.
There was a problem hiding this comment.
This is already handled. The format command includes a try-catch block around the Prettier import that displays a clear error message: "❌ Prettier is not installed. Install it with: npm install --save-dev prettier" and exits gracefully when Prettier is missing.
…t operations, extract constants Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
|
@copilot fix |
- Use ObjectConfig and FieldConfig types in lint command - Create LoadedConfig interface for start command to handle flexible config formats - Maintain type safety while supporting both datasource and datasources config formats Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
|
@copilot fix |
Add Development Commands to ObjectQL CLI
This PR adds mainstream framework-style development commands to make ObjectQL more developer-friendly, following conventions from Next.js, NestJS, and other popular frameworks.
✅ Completed Implementation:
devcommand - development server with hot reload supportstartcommand - production server start with config loadingbuildcommand - validates, generates types, copies metadata to disttestcommand - run Jest tests for ObjectQL projectslintcommand - validate metadata files with detailed checksformatcommand - format metadata files with Prettier🆕 New Commands:
objectql dev- Development server (recommended)objectql start- Production serverobjectql build- Build for productionobjectql test- Run testsobjectql lint- Validate metadataobjectql format- Format YAML📝 Code Quality Improvements:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.