Skip to content

feat(cli): support custom config path via -c/--config option#3

Open
bshy522 wants to merge 1 commit intoevaijs:mainfrom
bshy522:feat/customize-config-path
Open

feat(cli): support custom config path via -c/--config option#3
bshy522 wants to merge 1 commit intoevaijs:mainfrom
bshy522:feat/customize-config-path

Conversation

@bshy522
Copy link

@bshy522 bshy522 commented Mar 16, 2026

This PR adds support for a custom configuration file path using the -c or --config option in both ev dev and ev build commands.

Key changes:

  • Added -c, --config <path> option to CLI.
  • Updated loadConfig to handle explicit paths and provide better testability.
  • Added comprehensive tests for configuration loading.
  • Updated documentation.

Closes #FIXME

@vercel
Copy link

vercel bot commented Mar 16, 2026

Someone is attempting to deploy a commit to the utooland Team on Vercel.

A member of the Team first needs to authorize it.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the CLI's flexibility by introducing a mechanism to specify custom configuration file paths for ev dev and ev build commands. This allows users to manage their project configurations more dynamically, moving beyond the default ev.config.ts in the project root. The underlying configuration loading logic has been robustly refactored and thoroughly tested to ensure reliable operation across various scenarios.

Highlights

  • Custom Config Path Option: Added a new -c or --config option to both ev dev and ev build commands, allowing users to specify a custom path for their configuration file.
  • Refactored Configuration Loading: The loadConfig utility function was refactored to support explicit configuration file paths, improve testability through dependency injection, and handle different file types (e.g., TypeScript).
  • Enhanced Test Coverage: Comprehensive unit tests were introduced for the loadConfig function, covering scenarios such as loading default configs, explicit relative and absolute paths, and error handling for missing files.
  • Updated Documentation: The README.md file was updated to document the new -c/--config option, including examples for its usage with both relative and absolute paths.
Changelog
  • packages/cli/README.md
    • Added documentation for the new -c, --config <path> option for both ev dev and ev build commands.
    • Included examples demonstrating how to use relative and absolute paths for custom configuration files.
  • packages/cli/src/index.ts
    • Modified resolveWebpackConfig to accept an optional configPath parameter.
    • Updated the dev command to include the -c, --config <path> option and pass its value to resolveWebpackConfig.
    • Updated the build command to include the -c, --config <path> option and pass its value to resolveWebpackConfig.
    • Added logging to indicate whether a custom config file or default configuration is being used.
  • packages/cli/src/load-config.ts
    • Introduced pathToFileURL import for module loading.
    • Defined TS_CONFIG_EXTENSIONS set for TypeScript file extensions.
    • Added LoadConfigDependencies type for testability.
    • Created importConfigModule to handle module imports.
    • Implemented shouldUseTsLoader to check if a TS loader is needed.
    • Developed resolveConfigPath to determine the correct config file path based on cwd and an optional explicit configPath.
    • Refactored loadConfig to utilize resolveConfigPath, handle explicit config paths, and incorporate dependency injection for ensureTsLoader and importModule.
    • Added error handling for non-existent explicit config files.
  • packages/cli/tests/load-config.test.ts
    • Added a new test file for loadConfig functionality.
    • Included setup and teardown for temporary directories used in tests.
    • Wrote tests for loading default config files.
    • Added tests for loading explicit relative config paths.
    • Implemented tests for loading explicit absolute config paths.
    • Included a test to verify error handling when an explicit config path does not exist.
    • Added a test to ensure the TypeScript loader is correctly prepared before importing TS config files, using mocked dependencies.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a valuable feature for specifying a custom configuration path. The implementation is solid, with good test coverage and documentation updates. I have one suggestion to improve the accuracy of the configuration path logging, which involves a minor refactoring to pass the resolved path from loadConfig back to the caller. This will make the CLI output more precise and the related code cleaner.

Comment on lines +136 to 148
async function resolveWebpackConfig(cwd: string, configPath?: string) {
const { loadConfig } = await import("./load-config.js");
const evjsConfig = await loadConfig(cwd);
const evjsConfig = await loadConfig(cwd, configPath);

const { createWebpackConfig } = await import("./create-webpack-config.js");
logger.info`Using ${evjsConfig ? "ev.config.ts" : "zero-config defaults"}`;
if (configPath) {
logger.info`Using config: ${path.relative(cwd, path.resolve(cwd, configPath))}`;
} else {
logger.info`Using ${evjsConfig ? "ev.config.ts" : "zero-config defaults"}`;
}
const webpackConfig = createWebpackConfig(evjsConfig, cwd);

return { evjsConfig, webpackConfig };

Choose a reason for hiding this comment

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

medium

The logging for the configuration file path can be made more accurate. When no --config option is passed and a default configuration file like ev.config.js is used, the log message incorrectly states "Using ev.config.ts".

To fix this, loadConfig could return the resolved path along with the configuration object. resolveWebpackConfig can then use this path for a consistently accurate log message.

For example, you could change loadConfig in packages/cli/src/load-config.ts to return Promise<{ config: EvConfig; path: string } | undefined>.

With that change, resolveWebpackConfig can be simplified as follows:

async function resolveWebpackConfig(cwd: string, configPath?: string) {
  const { loadConfig } = await import("./load-config.js");
  const configResult = await loadConfig(cwd, configPath);
  const evjsConfig = configResult?.config;

  const { createWebpackConfig } = await import("./create-webpack-config.js");
  if (configResult) {
    logger.info`Using config: ${path.relative(cwd, configResult.path)}`;
  } else {
    logger.info`Using zero-config defaults`;
  }
  const webpackConfig = createWebpackConfig(evjsConfig, cwd);

  return { evjsConfig, webpackConfig };
}

@bshy522 bshy522 force-pushed the feat/customize-config-path branch from 756d54c to 0256c67 Compare March 16, 2026 06:54
@bshy522 bshy522 force-pushed the feat/customize-config-path branch from 0256c67 to 63bf0f5 Compare March 16, 2026 06:56
@bshy522 bshy522 marked this pull request as ready for review March 16, 2026 07:00
@vercel
Copy link

vercel bot commented Mar 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
v0-evjs Error Error Mar 16, 2026 7:16am

Request Review

@bshy522 bshy522 marked this pull request as draft March 16, 2026 07:33
@bshy522 bshy522 marked this pull request as ready for review March 16, 2026 07:33
const TS_CONFIG_EXTENSIONS = new Set([".ts", ".mts", ".cts"]);

type LoadConfigDependencies = {
ensureTsLoader?: () => Promise<void>;
Copy link
Contributor

Choose a reason for hiding this comment

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

ensureTsLoader 是哪里来的?怎么用?

@xusd320
Copy link
Contributor

xusd320 commented Mar 16, 2026

我感觉不太可能存在 config 写在项目之外的场景,我们并不是 tsc 这类工具

@bshy522
Copy link
Author

bshy522 commented Mar 16, 2026

我感觉不太可能存在 config 写在项目之外的场景,我们并不是 tsc 这类工具

也不是写在项目外,就是不是默认的名字。可以理解为写了两个配置文件这种场景

@xusd320
Copy link
Contributor

xusd320 commented Mar 16, 2026

现阶段不会考虑多配置支持,主要是没想到什么场景会需要。目前的计划参考 Roadmap https://github.com/evaijs/evjs/blob/main/ROADMAP.md

xusd320 added a commit that referenced this pull request Mar 17, 2026
- Root AGENT.md: release workflow uses GitHub releases, add mutation args convention
- Runtime AGENT.md: add mutation args rule (#3) to common mistakes
- query.ts: void → undefined per biome lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants