Repository navigation
feat: Add -d/--directory option to serverpod generate command - #4131
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughThis PR adds a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
Co-authored-by: SandPod <[email protected]>
Co-authored-by: SandPod <[email protected]>
|
@copilot Please add a test for this in |
Co-authored-by: SandPod <[email protected]>
Added E2E tests in
All tests are passing. (5f2dd90) Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/serverpod_cli_e2e_test/test/generate_with_directory_test.dart (1)
73-80: Remove unnecessarykill()call on already-completed process.The process's exit code is already awaited in the
setUp(line 66), so the process has completed by the timetearDownruns. Callingkill()on a completed process is unnecessary.Apply this diff:
tearDown(() async { - createProcess.kill(); // Clean up the created project var projectDir = Directory(path.join(tempPath, projectName)); if (projectDir.existsSync()) { projectDir.deleteSync(recursive: true); } });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
tests/serverpod_cli_e2e_test/test/generate_with_directory_test.dart(1 hunks)tools/serverpod_cli/lib/src/commands/generate.dart(3 hunks)tools/serverpod_cli/test/integration/generate/generate_with_directory_test.dart(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.dart
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.dart: Format all Dart code usingdart format .before committing
Code must pass Dart analyzer in strict mode (util/run_tests_analyze or melos lint_strict)
Use descriptive variable and function names
Files:
tools/serverpod_cli/lib/src/commands/generate.darttools/serverpod_cli/test/integration/generate/generate_with_directory_test.darttests/serverpod_cli_e2e_test/test/generate_with_directory_test.dart
**/lib/**/*.dart
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Remove unnecessary comments from production code
Files:
tools/serverpod_cli/lib/src/commands/generate.dart
**/*_test.dart
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*_test.dart: Write test descriptions using the Given/When/Then pattern
Organize tests with passing/success cases first, group related cases using group(), then follow with error cases
Files:
tools/serverpod_cli/test/integration/generate/generate_with_directory_test.darttests/serverpod_cli_e2e_test/test/generate_with_directory_test.dart
🧠 Learnings (6)
📓 Common learnings
Learnt from: tp
Repo: serverpod/serverpod PR: 3917
File: modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/analysis_options.yaml:3-6
Timestamp: 2025-08-25T19:46:58.073Z
Learning: In Serverpod, test tool paths like `test/integration/test_tools/serverpod_test_tools.dart` are configured per project in the "generator.yaml" file and managed by a generator system, so they don't need to be updated manually across all files at once.
📚 Learning: 2025-08-25T19:46:58.073Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3917
File: modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/analysis_options.yaml:3-6
Timestamp: 2025-08-25T19:46:58.073Z
Learning: In Serverpod, test tool paths like `test/integration/test_tools/serverpod_test_tools.dart` are configured per project in the "generator.yaml" file and managed by a generator system, so they don't need to be updated manually across all files at once.
Applied to files:
tools/serverpod_cli/lib/src/commands/generate.darttools/serverpod_cli/test/integration/generate/generate_with_directory_test.darttests/serverpod_cli_e2e_test/test/generate_with_directory_test.dart
📚 Learning: 2025-10-15T11:44:29.873Z
Learnt from: CR
Repo: serverpod/serverpod PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-15T11:44:29.873Z
Learning: Applies to **/*_test.dart : Organize tests with passing/success cases first, group related cases using group(), then follow with error cases
Applied to files:
tools/serverpod_cli/test/integration/generate/generate_with_directory_test.darttests/serverpod_cli_e2e_test/test/generate_with_directory_test.dart
📚 Learning: 2025-07-02T16:07:50.947Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3747
File: modules/new_serverpod_auth/serverpod_auth_migration/serverpod_auth_migration_server/lib/src/business/migrating_email_endpoint_base.dart:4-4
Timestamp: 2025-07-02T16:07:50.947Z
Learning: In Serverpod, tp prefers importing the full package (e.g., 'package:serverpod_auth_migration_server/serverpod_auth_migration_server.dart') as a baseline rather than using smaller local imports, even within the same package where it might be considered a "self-import".
Applied to files:
tools/serverpod_cli/test/integration/generate/generate_with_directory_test.darttests/serverpod_cli_e2e_test/test/generate_with_directory_test.dart
📚 Learning: 2025-06-27T08:39:36.440Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3721
File: util/pub_get_all:0-0
Timestamp: 2025-06-27T08:39:36.440Z
Learning: In the Serverpod project, `dart pub get` commands work fine on Flutter packages both locally and in CI environments, even when the package has `flutter: sdk: flutter` dependencies in pubspec.yaml. The technical constraint of Flutter SDK dependencies causing `dart pub` failures may not apply in all environments or recent Dart versions.
Applied to files:
tools/serverpod_cli/test/integration/generate/generate_with_directory_test.darttests/serverpod_cli_e2e_test/test/generate_with_directory_test.dart
📚 Learning: 2025-10-15T11:44:29.873Z
Learnt from: CR
Repo: serverpod/serverpod PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-15T11:44:29.873Z
Learning: Applies to **/*_test.dart : Write test descriptions using the Given/When/Then pattern
Applied to files:
tests/serverpod_cli_e2e_test/test/generate_with_directory_test.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: Migration e2e tests (3.29.0)
- GitHub Check: Migration e2e tests (3.29.0)
- GitHub Check: Migration e2e tests (3.29.0)
- GitHub Check: Migration e2e tests (3.29.0)
- GitHub Check: Migration e2e tests (3.29.0)
- GitHub Check: Migration e2e tests (3.29.0)
- GitHub Check: Migration e2e tests (3.29.0)
- GitHub Check: Migration e2e tests (3.29.0)
- GitHub Check: Migration e2e tests (3.29.0)
- GitHub Check: Migration e2e tests (3.29.0)
🔇 Additional comments (7)
tests/serverpod_cli_e2e_test/test/generate_with_directory_test.dart (1)
43-266: Well-structured E2E tests with good coverage.The test suite properly follows the Given/When/Then pattern and organizes tests with passing cases first, then error cases. The tests provide comprehensive coverage of absolute paths, relative paths, and error scenarios for the new
-doption.tools/serverpod_cli/lib/src/commands/generate.dart (4)
28-34: Clean implementation of the directory option.The new
directoryoption is well-defined with appropriate defaults, short flag, and clear help text. The empty string default allows the existing behavior (current directory) to be preserved.
56-60: LGTM!The directory parameter is correctly extracted from the command configuration and passed to
GeneratorConfig.load().
66-69: Correct path resolution for server pubspec file.The updated path construction using
config.serverPackageDirectoryPathPartsproperly resolves the pubspec.yaml location relative to the server package directory, supporting the new directory option.
97-100: Consistent path resolution for pubspec.lock.The path construction mirrors the approach used for pubspec.yaml, ensuring consistent behavior for both files when using the directory option.
tools/serverpod_cli/test/integration/generate/generate_with_directory_test.dart (2)
12-27: Well-structured error case test.The test properly validates the error handling when
GeneratorConfig.loadis called with a non-existent directory, using Given/When/Then pattern and checking both exception type and message.
29-63: Comprehensive validation of missing dependency scenario.The test creates a realistic setup with server and client directories containing pubspec files without Serverpod dependencies, then properly validates the exception type and error message.
nielsenko
left a comment
There was a problem hiding this comment.
Some comments on the test setup, but most importantly I believe the error message needs to reference the directory passed with -d/--directory.
Adds directory specification to
serverpod generate, enabling code generation from any location without changing working directory. Useful for monorepo setups and CI/CD pipelines.Changes
--directory/-dparameter toGenerateOptionenum with empty string defaultconfig.serverPackageDirectoryPathPartsinstead of relative paths for consistency when directory is specifiedGeneratorConfig.load(), which already supported this parameterTesting
tools/serverpod_cli/test/integration/generate/for error handling scenariostests/serverpod_cli_e2e_test/test/generate_with_directory_test.dartthat validate:-doption-doptionUsage
Fixes #4095
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Summary by CodeRabbit
New Features
-ddirectory option to the generate command, enabling code generation from custom project directoriesTests