Skip to content

refactor(cli): add resolver utils#173

Merged
fengmk2 merged 1 commit intomainfrom
09-21-refactor_cli_add_resolve_helper
Sep 22, 2025
Merged

refactor(cli): add resolver utils#173
fengmk2 merged 1 commit intomainfrom
09-21-refactor_cli_add_resolve_helper

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Sep 21, 2025

TL;DR

Refactored CLI utilities and added command help message tests.

What changed?

  • Created a new utils.ts file with common utility functions for resolving binaries and default environment variables
  • Refactored all command modules (lib, fmt, lint, test, doc, vite) to use the new utility functions
  • Added snapshot tests for command help messages
  • Improved semver version replacement in test utilities to handle more patterns
  • Added new test files for command helper functionality

How to test?

  1. Run the CLI commands with -h flag to verify help messages are displayed correctly:
    vite lib -h
    vite fmt -h
    vite lint -h
    vite build -h
    vite test -h
    
  2. Run the snapshot tests to ensure command help messages are captured correctly

Why make this change?

This change improves code maintainability by reducing duplication across command modules. The common utility functions centralize binary resolution and environment variable handling, making the codebase more DRY. The added tests for command help messages ensure that CLI documentation remains accurate and consistent as the project evolves.

@fengmk2 fengmk2 changed the title refactor(cli): add resolve helper refactor(cli): add resolver utils Sep 21, 2025
@fengmk2 fengmk2 self-assigned this Sep 21, 2025
@fengmk2 fengmk2 marked this pull request as ready for review September 21, 2025 10:14
@fengmk2 fengmk2 force-pushed the 09-21-refactor_cli_add_resolve_helper branch from 8f99646 to cec41db Compare September 21, 2025 10:20
@fengmk2 fengmk2 force-pushed the 09-21-feat_add_vite_doc_command branch from c0706b3 to 6d50162 Compare September 21, 2025 10:20
@fengmk2 fengmk2 requested a review from Copilot September 21, 2025 10:33
Copy link
Copy Markdown
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 refactors CLI utilities by extracting common functionality into a shared utils module and adds comprehensive test coverage for command help messages.

  • Created centralized utility functions for binary resolution and environment variable defaults
  • Refactored all command modules to use the shared utilities, reducing code duplication
  • Added snapshot tests for CLI command help messages to ensure documentation consistency

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/tools/src/utils.ts Enhanced semver replacement regex to handle more version patterns
packages/tools/src/tests/utils.spec.ts Added test cases for new semver pattern matching
packages/tools/src/tests/snapshots/utils.spec.ts.snap Updated snapshots to reflect improved semver replacement
packages/cli/src/utils.ts New utility module with shared resolver and environment defaults
packages/cli/src/vite.ts Refactored to use shared utilities, removing duplicate resolver code
packages/cli/src/test.ts Refactored to use shared utilities and environment defaults
packages/cli/src/lint.ts Refactored to use shared utilities and environment defaults
packages/cli/src/lib.ts Refactored to use shared utilities and environment defaults
packages/cli/src/fmt.ts Refactored to use shared utilities and environment defaults
packages/cli/src/doc.ts Refactored to use shared utilities and environment defaults
packages/cli/snap-tests/command-lib/snap.txt Updated snapshot to use normalized semver format
packages/cli/snap-tests/command-helper/* New test suite for comprehensive CLI help message validation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Brooooooklyn
Copy link
Copy Markdown
Member

cursor review

Comment thread packages/cli/src/utils.ts
@Brooooooklyn
Copy link
Copy Markdown
Member

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

Codex Review: Here are some suggestions.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment thread packages/cli/src/utils.ts
@fengmk2 fengmk2 force-pushed the 09-21-refactor_cli_add_resolve_helper branch from cec41db to 49ae39d Compare September 21, 2025 12:46
@graphite-app graphite-app Bot changed the base branch from 09-21-feat_add_vite_doc_command to graphite-base/173 September 21, 2025 14:56
@fengmk2 fengmk2 force-pushed the 09-21-refactor_cli_add_resolve_helper branch from 49ae39d to b07e3fb Compare September 21, 2025 14:56
@fengmk2 fengmk2 changed the base branch from graphite-base/173 to 09-21-feat_add_vite_doc_command September 21, 2025 14:56
@fengmk2 fengmk2 force-pushed the 09-21-refactor_cli_add_resolve_helper branch from b07e3fb to a2d6fd5 Compare September 21, 2025 14:57
@fengmk2 fengmk2 force-pushed the 09-21-feat_add_vite_doc_command branch from 903c927 to 991d11a Compare September 21, 2025 14:57
@fengmk2 fengmk2 force-pushed the 09-21-refactor_cli_add_resolve_helper branch from a2d6fd5 to 24d7cac Compare September 21, 2025 15:00
@fengmk2 fengmk2 force-pushed the 09-21-feat_add_vite_doc_command branch from 991d11a to 4a12f74 Compare September 21, 2025 15:00
@fengmk2 fengmk2 force-pushed the 09-21-refactor_cli_add_resolve_helper branch from 24d7cac to bb8c75a Compare September 22, 2025 01:13
@fengmk2 fengmk2 force-pushed the 09-21-feat_add_vite_doc_command branch from 4a12f74 to a6a2966 Compare September 22, 2025 01:13
@graphite-app graphite-app Bot changed the base branch from 09-21-feat_add_vite_doc_command to graphite-base/173 September 22, 2025 01:23
@fengmk2 fengmk2 force-pushed the 09-21-refactor_cli_add_resolve_helper branch from bb8c75a to 92f8ff4 Compare September 22, 2025 01:37
@graphite-app graphite-app Bot changed the base branch from graphite-base/173 to main September 22, 2025 01:38
@fengmk2 fengmk2 force-pushed the 09-21-refactor_cli_add_resolve_helper branch from 92f8ff4 to cb238c4 Compare September 22, 2025 01:38
@fengmk2 fengmk2 merged commit b412f6e into main Sep 22, 2025
8 of 9 checks passed
Copy link
Copy Markdown
Member Author

fengmk2 commented Sep 22, 2025

Merge activity

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.

4 participants