Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 15, 2026

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:

  • Add dev command - development server with hot reload support
  • Add start command - production server start with config loading
  • Add build command - validates, generates types, copies metadata to dist
  • Add test command - run Jest tests for ObjectQL projects
  • Add lint command - validate metadata files with detailed checks
  • Add format command - format metadata files with Prettier
  • Update CLI index.ts to register all new commands
  • Fix TypeScript compilation errors
  • Add comprehensive tests (14 passed, 3 skipped)
  • Update CLI README with full documentation
  • Manually test all commands successfully
  • Address all code review feedback
  • Replace 'any' types with proper types from @objectql/types

🆕 New Commands:

  1. objectql dev - Development server (recommended)
  2. objectql start - Production server
  3. objectql build - Build for production
  4. objectql test - Run tests
  5. objectql lint - Validate metadata
  6. objectql format - Format YAML

📝 Code Quality Improvements:

  • ✅ Proper TypeScript types: ObjectConfig, FieldConfig, LoadedConfig
  • ✅ Type-safe config handling while supporting flexible formats
  • ✅ Consistent ES6 imports throughout
  • ✅ Proper error handling for edge cases
  • ✅ All tests passing (14/17, 3 skipped due to Jest/Prettier compatibility)
Original prompt

在一个objectql项目文件夹,我应该可以通过Cli命令启动服务端,按照主流框架,帮我考虑其他的开发命令


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@huangyiirene huangyiirene requested a review from Copilot January 15, 2026 01:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and format
  • Updated the serve command 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;
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in de4fca8. Now using ObjectConfig type from @objectql/types instead of casting to any.

hasErrors = true;
}

const fieldConfig = field as any;
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using as any bypasses TypeScript's type safety. Consider importing the appropriate field type from @objectql/types instead of casting to any.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 <[email protected]>
Copilot AI changed the title [WIP] Add CLI commands to start ObjectQL server Add mainstream development commands to ObjectQL CLI Jan 15, 2026
Copilot AI requested a review from huangyiirene January 15, 2026 01:37
@huangyiirene
Copy link
Contributor

@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 <[email protected]>
@hotlong
Copy link
Contributor

hotlong commented Jan 15, 2026

@copilot fix

@hotlong hotlong marked this pull request as ready for review January 15, 2026 01:50
@hotlong hotlong merged commit 6a10f1e into main Jan 15, 2026
7 of 8 checks passed
Copy link
Contributor Author

Copilot AI commented Jan 15, 2026

@copilot fix

All previous review feedback has been addressed in commit de4fca8. The build passes successfully and all tests are passing (14/17, with 3 skipped due to Jest/Prettier compatibility). Could you please clarify what specific issue needs to be fixed?

@hotlong hotlong deleted the copilot/add-cli-commands-for-objectql branch January 15, 2026 01:51
Copilot AI requested a review from hotlong January 15, 2026 01:51
Copilot stopped work on behalf of hotlong due to an error January 15, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants