Skip to content

Conversation

@PrabothCharith
Copy link
Owner

This pull request introduces Orval integration as an optional feature in the Next.js CLI scaffold generator. Users can now choose to initialize Orval for API code generation during project setup. The implementation includes prompt updates, project scaffolding logic, and the necessary template for Orval configuration.

Feature: Orval Integration

  • Added orval as a boolean option in the ProjectConfig interface and included it in the initial prompt options. [1] [2]
  • Updated the CLI prompt flow to ask users if they want to initialize Orval for API generation.
  • Implemented setupOrval function in scaffold.ts to install the Orval dev dependency, generate an orval.config.ts file, and add a gen script to package.json. [1] [2]
  • Added the Orval configuration template in src/templates/orval.ts.
  • Imported the Orval template in the project scaffolding logic.

Other

  • Bumped the CLI version from 2.0.0 to 2.1.0 in package.json to reflect the new feature.

@PrabothCharith PrabothCharith self-assigned this Jan 3, 2026
Copilot AI review requested due to automatic review settings January 3, 2026 17:34
@PrabothCharith PrabothCharith added the enhancement New feature or request label Jan 3, 2026
@github-project-automation github-project-automation bot moved this to Backlog in nxt-gen-cli Jan 3, 2026
@PrabothCharith PrabothCharith moved this from Backlog to In progress in nxt-gen-cli Jan 3, 2026
@PrabothCharith PrabothCharith moved this from In progress to Done in nxt-gen-cli Jan 3, 2026
@PrabothCharith PrabothCharith changed the title Development Orval integration | Development Jan 3, 2026
@PrabothCharith PrabothCharith merged commit 38c8356 into main Jan 3, 2026
2 checks passed
Copy link

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 pull request adds Orval integration as an optional feature to the Next.js CLI scaffold generator, allowing users to set up API code generation during project initialization. The implementation includes configuration prompts, project scaffolding logic, and an Orval configuration template.

  • Added Orval as a configurable option in the project setup prompts
  • Implemented automated Orval setup including package installation, config file generation, and package.json script creation
  • Version bumped from 2.0.0 to 2.1.0 to reflect the new feature

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/templates/orval.ts Adds Orval configuration template with react-query client and axios mutator setup
src/scaffold.ts Implements setupOrval function and integrates it into the scaffolding workflow; includes code formatting improvements
src/prompts.ts Adds orval boolean option to ProjectConfig interface and includes it in the interactive prompt flow
package.json Bumps CLI version from 2.0.0 to 2.1.0
package-lock.json Updates lockfile version to match package.json
.gitignore Refines test directory ignore patterns (unrelated to Orval feature)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

override: {
mutator: {
path: './src/lib/axios.ts',
name: 'backendApi',
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The mutator name 'backendApi' does not match the actual export name from the axios client. The axios client template exports 'api', not 'backendApi'. This will cause Orval to fail when trying to use the mutator. Update the name to 'api' to match the axios client export.

Suggested change
name: 'backendApi',
name: 'api',

Copilot uses AI. Check for mistakes.
Comment on lines +1009 to +1012
await fs.writeFile(
path.join(projectPath, "orval.config.ts"),
orvalConfig
);
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The setupOrval function doesn't ensure that the target directories exist before writing files. While the root project directory exists, the function should call fs.ensureDir for the directories that will contain generated files (e.g., './src/lib/api'). This follows the pattern used in other setup functions like setupAxios (line 560) and setupForms (lines 970, 973).

Copilot uses AI. Check for mistakes.
input: 'http://localhost:3000/api/json',
output: {
target: './src/lib/api/generated.ts',
client: 'react-query',
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The Orval configuration specifies 'react-query' as the client, but there's no check to ensure that React Query is actually configured in the project. This could lead to generated code that depends on @tanstack/react-query when it's not installed. Consider either documenting this dependency requirement in the prompt message or adding a conditional check to warn users if they enable Orval without React Query.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants