Skip to content

stop exporting internal modules#40

Merged
ryoppippi merged 4 commits intomainfrom
internal
Jun 8, 2025
Merged

stop exporting internal modules#40
ryoppippi merged 4 commits intomainfrom
internal

Conversation

@ryoppippi
Copy link
Owner

This pull request focuses on restructuring the codebase by introducing the .internal.ts suffix for files intended for internal use and updating references accordingly. Additionally, it removes the utils export from package.json. These changes aim to improve code organization and clarify the separation between public and internal modules.

Code restructuring: .internal.ts suffix for internal modules

  • Renamed src/shared-args.ts to src/shared-args.internal.ts and updated all references to sharedCommandConfig and sharedArgs in src/commands/daily.ts, src/commands/mcp.ts, src/commands/monthly.ts, and src/commands/session.ts. [1] [2] [3] [4]
  • Renamed src/utils.test.ts to src/utils.internal.test.ts and updated the imports in the renamed file.
  • Updated imports for CostMode, SortOrder, CostModes, and dateSchema to use types.internal.ts instead of types.ts in multiple files (src/data-loader.ts, src/mcp.ts, src/shared-args.internal.ts). [1] [2] [3] [4]

Configuration updates

  • Modified tsdown.config.ts to exclude both .test.ts and .internal.ts files from the build output.

Removal of unused exports

  • Removed the utils export from package.json, as it is now considered an internal module.

@ryoppippi ryoppippi requested a review from Copilot June 8, 2025 13:38
Copy link
Contributor

@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.

Hello @ryoppippi, 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!

Summary of Changes

Hello! Gemini here, ready to provide a summary of this pull request to help everyone quickly understand the changes. This PR, authored by ryoppippi, focuses on improving the code structure by explicitly marking internal modules and preventing them from being exported. This is achieved by introducing a .internal.ts suffix for files intended for internal use, updating all references to these files throughout the codebase, and modifying the build configuration to exclude these internal files. Additionally, the utils export is removed from package.json, reinforcing its status as an internal module.

Highlights

  • Code Restructuring with .internal.ts: Files intended for internal use, such as src/shared-args.ts and src/utils.test.ts, have been renamed to include the .internal.ts suffix (e.g., src/shared-args.internal.ts). This provides a clear visual indicator of their internal nature.
  • Import Path Updates: All files that previously imported from the renamed or now-internal modules have been updated to use the new .internal.ts paths. This includes updates in command files (daily.ts, mcp.ts, monthly.ts, session.ts), data loading (data-loader.ts), and the MCP server implementation (mcp.ts). Imports for types and shared arguments are now pointing to their respective .internal.ts files.
  • Build Configuration Update: The tsdown.config.ts file has been updated to exclude all files ending with .test.ts or .internal.ts from the build output. This ensures that internal implementation details and test files are not included in the final distribution.
  • Removed Package Export: The ./utils export has been removed from the exports field in package.json. This explicitly prevents external consumers from importing modules from the utils path, as it is now considered an internal part of the package.

Changelog

Click here to see the changelog
  • package.json
    • Removed the ./utils export from the exports field (line 25).
  • src/commands/daily.ts
    • Updated import path for sharedCommandConfig from ../shared-args.ts to ../shared-args.internal.ts (line 13).
    • Updated import path for formatCurrency and formatNumber from ../utils.ts to ../utils.internal.ts (line 14).
  • src/commands/mcp.ts
    • Updated import path for sharedArgs from ../shared-args.ts to ../shared-args.internal.ts (line 4).
  • src/commands/monthly.ts
    • Updated import path for sharedCommandConfig from ../shared-args.ts to ../shared-args.internal.ts (line 13).
    • Updated import path for formatCurrency and formatNumber from ../utils.ts to ../utils.internal.ts (line 14).
  • src/commands/session.ts
    • Updated import path for sharedCommandConfig from ../shared-args.ts to ../shared-args.internal.ts (line 13).
    • Updated import path for formatCurrency and formatNumber from ../utils.ts to ../utils.internal.ts (line 14).
  • src/data-loader.ts
    • Updated import path for CostMode and SortOrder types from ./types.ts to ./types.internal.ts (line 1).
  • src/mcp.ts
    • Updated import path for CostMode type from ./types to ./types.internal.ts (line 2).
    • Updated import path for CostModes and dateSchema from ./types to ./types.internal.ts (line 12).
  • src/shared-args.ts -> src/shared-args.internal.ts
    • File renamed from src/shared-args.ts to src/shared-args.internal.ts.
    • Updated import path for CostMode and SortOrder types from ./types to ./types.internal.ts (line 2).
    • Updated import path for CostModes, dateSchema, and SortOrders from ./types to ./types.internal.ts (line 5).
  • src/utils.test.ts -> src/utils.internal.test.ts
    • File renamed from src/utils.test.ts to src/utils.internal.test.ts.
    • Updated import path for formatCurrency and formatNumber from ./utils.ts to ./utils.internal.ts (line 2).
  • tsdown.config.ts
    • Updated the entry glob pattern to exclude files matching **/*.{test,internal}.ts, replacing specific exclusions for types.ts, shared-args.ts, and **/*.test.ts (line 6).
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jun 8, 2025

Open in StackBlitz

npm i https://pkg.pr.new/ryoppippi/ccusage@40

commit: 7e3c3bb

@ryoppippi ryoppippi merged commit 098b73a into main Jun 8, 2025
12 checks passed
@ryoppippi ryoppippi deleted the internal branch June 8, 2025 13:38
Copy link
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 restructures the codebase to clearly separate public and internal modules, updates build configuration, and removes an unused export.

  • Renames and marks internal modules with .internal.ts suffix, updating all imports accordingly
  • Updates tsdown.config.ts to exclude both .internal.ts and .test.ts files from build output
  • Removes the now-internal utils export from package.json

Reviewed Changes

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

Show a summary per file
File Description
tsdown.config.ts Updated glob to exclude .internal.ts and .test.ts
src/utils.internal.test.ts Adjusted test import to use .internal.ts utilities
src/shared-args.internal.ts Switched imports to reference types.internal.ts
src/mcp.ts Switched imports to use types.internal.ts
src/data-loader.ts Switched types import to types.internal.ts
src/commands/session.ts Updated imports for internal shared-args and utils
src/commands/monthly.ts Updated imports for internal shared-args and utils
src/commands/mcp.ts Updated import to use internal shared-args
src/commands/daily.ts Updated imports for internal shared-args and utils
package.json Removed public utils export

Copy link
Contributor

@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 effectively restructures the codebase to delineate internal modules using the .internal.ts suffix and updates the build configuration accordingly. The changes are clear, consistent, and well-described, leading to improved code organization and a more explicit public API.

Key positive aspects:

  • Clear Convention: The introduction and consistent use of the .internal.ts suffix make the visibility of modules immediately apparent.
  • Build Configuration: The update to tsdown.config.ts to exclude *.internal.ts and *.test.ts files using a simplified glob pattern (!./src/**/*.{test,internal}.ts) is a clean way to ensure these internal modules are not part of the distributed package.
  • API Surface Reduction: Removing the utils export from package.json and ensuring internal modules are not bundled correctly reduces the public API surface, aligning with the goal of better encapsulation.
  • Consistency: All file renames and import path updates have been applied consistently across the affected files.

The changes significantly enhance the maintainability and clarity of the codebase by making a clear distinction between public and internal components. Well done!

Summary of Findings

  • Code Quality and Refactoring: No issues of medium, high, or critical severity were identified in this pull request. The refactoring to introduce an .internal.ts convention for internal modules has been executed thoroughly and correctly. This improves code organization and clearly defines the public API of the package.
  • Build Configuration: The tsdown.config.ts changes correctly and succinctly ensure that new internal modules (and test files) are excluded from the build output. This is crucial for achieving the PR's goal of not exporting internal modules.

Merge Readiness

The pull request is in excellent shape and appears ready for merging. The changes are well-implemented and achieve the stated goals of improving code organization and clarifying the separation between public and internal modules. As a language model, I am not authorized to approve pull requests, so please ensure it undergoes the standard review and approval process by authorized team members.

ryoppippi added a commit that referenced this pull request Jun 22, 2025
stop exporting internal modules
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