Skip to content

feat(cli): add wgc grpc-service list-templates & init#2033

Merged
jensneuse merged 10 commits intomainfrom
jens/eng-7572
Jul 10, 2025
Merged

feat(cli): add wgc grpc-service list-templates & init#2033
jensneuse merged 10 commits intomainfrom
jens/eng-7572

Conversation

@jensneuse
Copy link
Copy Markdown
Member

@jensneuse jensneuse commented Jul 9, 2025

Summary by CodeRabbit

  • New Features

    • Added CLI commands to scaffold new gRPC service projects from predefined templates and to list available templates.
    • Improved output directory handling by automatically creating directories when generating projects.
  • Chores

    • Added new dependencies to support template fetching and project scaffolding.

@jensneuse jensneuse requested review from a team, JivusAyrus, StarpTech and endigma as code owners July 9, 2025 19:11
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 9, 2025

Warning

Rate limit exceeded

@jensneuse has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 21 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between e9db120 and 52066b0.

📒 Files selected for processing (1)
  • cli/src/commands/grpc-service/commands/init.ts (1 hunks)

Walkthrough

The changes introduce two new CLI commands under grpc-service: init, which scaffolds a gRPC service project from a template, and list-templates, which lists available templates from a GitHub repository. Supporting dependencies (@octokit/rest, fs-extra, tar, and their type definitions) are added to cli/package.json. The new commands are registered in the CLI. Additionally, the generate command is updated to create the output directory if it does not exist. The related test is updated to reflect this new behavior.

Changes

Files/Paths Change Summary
cli/package.json Added dependencies @octokit/rest, fs-extra, tar and devDependencies @types/fs-extra, @types/tar.
cli/src/commands/grpc-service/commands/init.ts Added new init command to scaffold gRPC service projects from templates.
cli/src/commands/grpc-service/commands/list-templates.ts Added new list-templates command to fetch and display available gRPC service templates.
cli/src/commands/grpc-service/index.ts Registered new init and list-templates commands under the grpc-service CLI command.
cli/src/commands/grpc-service/commands/generate.ts Updated generate command to create output directory if it does not exist before proceeding.
cli/test/grpc-service.test.ts Updated test to expect creation of output directory and files instead of failure when directory does not exist.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 9, 2025

Router image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-e26822aaad147e77eab9cb251bc2727390743fd7

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (1)
cli/src/commands/grpc-service/commands/init.ts (1)

33-54: Consider extracting template validation logic.

The template existence check and error handling could be extracted into a reusable function, especially since it shares logic with the list-templates command.

Consider creating a shared utility module for GitHub API interactions to reduce code duplication between init.ts and list-templates.ts. This would centralize error handling and type safety improvements.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d53e9d6 and 395f7b5.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • cli/package.json (3 hunks)
  • cli/src/commands/grpc-service/commands/init.ts (1 hunks)
  • cli/src/commands/grpc-service/commands/list-templates.ts (1 hunks)
  • cli/src/commands/grpc-service/index.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
cli/src/commands/grpc-service/commands/init.ts (3)
cli/src/commands/grpc-service/index.ts (1)
  • opts (7-15)
cli/src/core/types/types.ts (1)
  • BaseCommandOptions (8-10)
cli/src/commands/grpc-service/commands/list-templates.ts (1)
  • fetchAvailableTemplates (7-16)
cli/src/commands/grpc-service/commands/list-templates.ts (1)
cli/src/core/types/types.ts (1)
  • BaseCommandOptions (8-10)
⏰ 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). (14)
  • GitHub Check: build_push_image
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: integration_test (./telemetry)
  • GitHub Check: image_scan
  • GitHub Check: integration_test (./events)
  • GitHub Check: build_test
  • GitHub Check: build_test
  • GitHub Check: build_test
  • GitHub Check: build_test
  • GitHub Check: build_push_image
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: build_push_image
  • GitHub Check: build_test
🔇 Additional comments (2)
cli/package.json (1)

57-57: Dependency Version and Vulnerability Check Completed

  • degit@^2.8.4 is the latest stable release (versions 2.8.0–2.8.4).
  • node-fetch@^3.3.2 is the latest stable release (next tags are all 4.0.0-beta).
  • @types/degit@^2.8.6 is the latest release.
  • No known vulnerabilities were reported for these packages in the npm registry.
    To perform a full audit, add a lockfile (npm install --package-lock-only) and rerun npm audit.

Files reviewed:

  • cli/package.json (lines 57, 69, 88)
cli/src/commands/grpc-service/index.ts (1)

4-5: LGTM! Clean command registration.

The new commands are properly imported and registered following the existing pattern used for generateCommand.

Also applies to: 11-12

Comment thread cli/src/commands/grpc-service/commands/list-templates.ts Outdated
Comment thread cli/src/commands/grpc-service/commands/list-templates.ts
Comment thread cli/src/commands/grpc-service/commands/init.ts Outdated
Comment thread cli/src/commands/grpc-service/commands/init.ts
Comment thread cli/src/commands/grpc-service/commands/init.ts
Comment thread cli/src/commands/grpc-service/commands/init.ts Outdated
Comment thread cli/src/commands/grpc-service/commands/init.ts Outdated
@jensneuse jensneuse requested a review from StarpTech July 10, 2025 07:57
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (2)
cli/src/commands/grpc-service/commands/init.ts (2)

14-22: Improve type safety and error handling for template validation.

This function still has the same issues mentioned in previous reviews: no error handling, no timeout, and poor type safety.


104-115: Potential race condition in directory validation.

This code has the same race condition issue mentioned in previous reviews between checking directory existence and creating/validating it.

🧹 Nitpick comments (1)
cli/src/commands/grpc-service/commands/init.ts (1)

24-24: Improve parameter type safety.

The spinner parameter should be properly typed instead of using any.

-async function downloadAndExtractTemplate(template: string, outputDir: string, spinner: any) {
+async function downloadAndExtractTemplate(template: string, outputDir: string, spinner: ReturnType<typeof Spinner>) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 395f7b5 and 21a7256.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • cli/package.json (5 hunks)
  • cli/src/commands/grpc-service/commands/init.ts (1 hunks)
  • cli/src/commands/grpc-service/commands/list-templates.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • cli/package.json
  • cli/src/commands/grpc-service/commands/list-templates.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
cli/src/commands/grpc-service/commands/init.ts (3)
cli/src/commands/grpc-service/index.ts (1)
  • opts (7-15)
cli/src/core/types/types.ts (1)
  • BaseCommandOptions (8-10)
cli/src/commands/grpc-service/commands/list-templates.ts (1)
  • fetchAvailableTemplates (7-22)
⏰ 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). (14)
  • GitHub Check: build_push_image
  • GitHub Check: integration_test (./events)
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: image_scan
  • GitHub Check: integration_test (./telemetry)
  • GitHub Check: build_test
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: build_test
  • GitHub Check: build_test
  • GitHub Check: build_push_image
  • GitHub Check: build_test
  • GitHub Check: build_test
  • GitHub Check: build_push_image

Comment thread cli/src/commands/grpc-service/commands/init.ts Outdated
Comment thread cli/src/commands/grpc-service/commands/init.ts
Comment thread cli/src/commands/grpc-service/commands/init.ts Outdated
Comment thread cli/src/commands/grpc-service/commands/init.ts Outdated
Comment thread cli/src/commands/grpc-service/commands/init.ts Outdated
@endigma endigma closed this Jul 10, 2025
@endigma endigma deleted the jens/eng-7572 branch July 10, 2025 08:57
@endigma endigma restored the jens/eng-7572 branch July 10, 2025 08:57
@endigma endigma reopened this Jul 10, 2025
@endigma
Copy link
Copy Markdown
Member

endigma commented Jul 10, 2025

Psychotic git tooling my bad

@StarpTech
Copy link
Copy Markdown
Contributor

LGTM after addressing the comments about error handling.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
cli/src/commands/grpc-service/commands/generate.ts (1)

41-44: Approve the enhanced directory handling with a minor consideration

The change from failing immediately to automatically creating the output directory is a significant UX improvement. The logic is sound and the recursive: true option handles nested directory creation properly.

However, consider the potential race condition between existsSync() and mkdir(). While unlikely in typical CLI usage, the current implementation could theoretically fail if another process creates the directory between the check and creation attempt.

Consider this more robust approach that eliminates the race condition:

-    // Ensure output directory exists
-    if (!existsSync(options.output)) {
-      await mkdir(options.output, { recursive: true });
-    }
+    // Ensure output directory exists
+    await mkdir(options.output, { recursive: true });

The recursive: true option with mkdir is idempotent and won't throw an error if the directory already exists, making the existsSync check unnecessary.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13b7eb1 and 6de3061.

📒 Files selected for processing (2)
  • cli/src/commands/grpc-service/commands/generate.ts (2 hunks)
  • cli/src/commands/grpc-service/commands/init.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cli/src/commands/grpc-service/commands/init.ts
⏰ 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). (14)
  • GitHub Check: integration_test (./events)
  • GitHub Check: build_push_image
  • GitHub Check: integration_test (./telemetry)
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: image_scan
  • GitHub Check: build_test
  • GitHub Check: build_test
  • GitHub Check: build_test
  • GitHub Check: build_push_image
  • GitHub Check: build_test
  • GitHub Check: build_push_image
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: build_test
  • GitHub Check: Analyze (go)
🔇 Additional comments (1)
cli/src/commands/grpc-service/commands/generate.ts (1)

1-1: LGTM: Clean import optimization

The import changes correctly add the required mkdir function while removing the unused dirname import. This aligns with the new directory creation functionality.

Also applies to: 3-3

@jensneuse jensneuse requested a review from endigma July 10, 2025 09:23
Copy link
Copy Markdown
Contributor

@StarpTech StarpTech left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread cli/src/commands/grpc-service/commands/init.ts Outdated
Comment thread cli/src/commands/grpc-service/commands/init.ts Outdated
jensneuse and others added 3 commits July 10, 2025 11:48
Co-authored-by: endigma <endigma@mailcat.ca>
Co-authored-by: endigma <endigma@mailcat.ca>
@jensneuse jensneuse merged commit c053643 into main Jul 10, 2025
43 checks passed
@jensneuse jensneuse deleted the jens/eng-7572 branch July 10, 2025 11:02
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