Skip to content

refactor: move filter functionality from ucd-store to utils package#49

Merged
luxass merged 3 commits intomainfrom
luxass/refactor-move-filter-functionality-from-ucd-store-to-utils-package
Jun 9, 2025
Merged

refactor: move filter functionality from ucd-store to utils package#49
luxass merged 3 commits intomainfrom
luxass/refactor-move-filter-functionality-from-ucd-store-to-utils-package

Conversation

@luxass
Copy link
Member

@luxass luxass commented Jun 9, 2025

This PR partially resolves #48

Summary by CodeRabbit

  • New Features
    • Improved modularity by relocating filter-related functionality to a shared utilities package.
  • Documentation
    • Enhanced code documentation with clearer import examples for filter utilities.
  • Chores
    • Updated and reorganized package dependencies to reflect changes in shared functionality.

@changeset-bot
Copy link

changeset-bot bot commented Jun 9, 2025

🦋 Changeset detected

Latest commit: d761237

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@ucdjs/utils Minor
@ucdjs/ucd-store Patch
@ucdjs/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 9, 2025

Walkthrough

This change relocates filter-related functionality, including createPathFilter and PRECONFIGURED_FILTERS, from the @ucdjs/ucd-store package to the @ucdjs/utils package. Dependencies on picomatch are also moved accordingly. All relevant imports, exports, and tests are updated to reflect this new structure, with no changes to logic.

Changes

Files/Paths Change Summary
packages/ucd-store/src/*.ts, packages/cli/src/cmd/download.ts, packages/ucd-store/test/remote.test.ts Updated imports of filter-related functions/types to reference @ucdjs/utils instead of local or @ucdjs/ucd-store exports.
packages/ucd-store/src/index.ts Removed exports of createPathFilter and PRECONFIGURED_FILTERS.
packages/utils/src/index.ts Added exports for createPathFilter, PRECONFIGURED_FILTERS, FilterFn, and FilterOptions.
packages/utils/src/filter.ts Updated documentation to clarify import usage.
packages/ucd-store/package.json Removed picomatch and its type definitions from dependencies.
packages/utils/package.json Added picomatch and its type definitions to dependencies.
.changeset/kind-brooms-drum.md Documented the package version bumps and the relocation of filter functionality.

Sequence Diagram(s)

sequenceDiagram
    participant CLI
    participant UCD-Store
    participant Utils

    CLI->>Utils: import PRECONFIGURED_FILTERS
    UCD-Store->>Utils: import createPathFilter, FilterFn
    UCD-Store->>Utils: import PRECONFIGURED_FILTERS
    UCD-Store-->>Utils: uses filter functions/types from utils
Loading

Assessment against linked issues

Objective Addressed Explanation
Move download functions to utils library (#48) Only filter-related code was moved; download functions remain in ucd-store.
Must support the FS Adapter, filtering, and graceful errors (#48) No evidence of changes to download logic or error handling; only filter code was moved.
Should be as minimal as possible (#48) The change is minimal for filter relocation, but does not address the download function move.
Filtering consistency between API and local (#48) No changes observed to filtering logic, only relocation; unclear if API/local consistency addressed.

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Documentation addition for import example (packages/utils/src/filter.ts) This is a documentation update, not related to the objectives about moving download/filter code.

Possibly related PRs

Poem

In a warren of code, the filters did roam,
Now they’ve hopped to utils, their brand-new home.
Picomatch in tow, with patterns to parse,
The store feels lighter, the utils more sparse.
Rabbits rejoice as the imports align—
Cleaner and neater, the code does shine!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/ucd-store/src/local.ts

Oops! Something went wrong! :(

ESLint: 9.28.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

packages/cli/src/cmd/download.ts

Oops! Something went wrong! :(

ESLint: 9.28.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

packages/ucd-store/src/remote.ts

Oops! Something went wrong! :(

ESLint: 9.28.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

  • 4 others

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3ba7f0e and d761237.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • .changeset/kind-brooms-drum.md (1 hunks)
  • packages/cli/src/cmd/download.ts (1 hunks)
  • packages/ucd-store/package.json (0 hunks)
  • packages/ucd-store/src/download.ts (1 hunks)
  • packages/ucd-store/src/index.ts (0 hunks)
  • packages/ucd-store/src/local.ts (1 hunks)
  • packages/ucd-store/src/remote.ts (1 hunks)
  • packages/ucd-store/test/remote.test.ts (1 hunks)
  • packages/utils/package.json (1 hunks)
  • packages/utils/src/filter.ts (1 hunks)
  • packages/utils/src/index.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • packages/ucd-store/package.json
  • packages/ucd-store/src/index.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/cli/src/cmd/download.ts
🚧 Files skipped from review as they are similar to previous changes (8)
  • packages/utils/package.json
  • packages/ucd-store/src/local.ts
  • packages/utils/src/filter.ts
  • packages/ucd-store/src/remote.ts
  • packages/ucd-store/test/remote.test.ts
  • packages/ucd-store/src/download.ts
  • .changeset/kind-brooms-drum.md
  • packages/utils/src/index.ts
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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 github-actions bot added pkg: cli Changes related to the CLI package. pkg: ucd-store Changes related to the UCD Store package. pkg: utils Changes related to the Utils package. labels Jun 9, 2025
Copy link
Member Author

luxass commented Jun 9, 2025

@codecov
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@luxass luxass marked this pull request as ready for review June 9, 2025 10:45
Copy link
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 (2)
.changeset/kind-brooms-drum.md (1)

7-7: Fix grammatical error in changeset description.

The apostrophe in "filter's" is incorrect. It should be "filters" (plural) not possessive.

Apply this diff:

-move filter's to utils pkg
+move filters to utils pkg
packages/utils/src/index.ts (1)

18-19: Expose filter utilities and types
Exporting createPathFilter, PRECONFIGURED_FILTERS, FilterFn, and FilterOptions centralizes your filtering API. Ensure that the implementations in filter.ts come with thorough unit tests in this package.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b66bca6 and 3ba7f0e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • .changeset/kind-brooms-drum.md (1 hunks)
  • packages/cli/src/cmd/download.ts (1 hunks)
  • packages/ucd-store/package.json (0 hunks)
  • packages/ucd-store/src/download.ts (1 hunks)
  • packages/ucd-store/src/index.ts (0 hunks)
  • packages/ucd-store/src/local.ts (1 hunks)
  • packages/ucd-store/src/remote.ts (1 hunks)
  • packages/ucd-store/test/fs-interface.test.ts (1 hunks)
  • packages/ucd-store/test/remote.test.ts (1 hunks)
  • packages/utils/package.json (1 hunks)
  • packages/utils/src/filter.ts (1 hunks)
  • packages/utils/src/index.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • packages/ucd-store/package.json
  • packages/ucd-store/src/index.ts
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: luxass
PR: ucdjs/ucd#45
File: packages/ucd-store/src/download.ts:24-24
Timestamp: 2025-06-09T05:10:32.074Z
Learning: In the ucd-store package refactor, picomatch was moved from direct usage in download.ts to internal usage within the createPathFilter function in filter.ts. The pattern format is still picomatch-compatible, so JSDoc comments referencing picomatch pattern format remain correct.
packages/ucd-store/src/remote.ts (1)
Learnt from: luxass
PR: ucdjs/ucd#45
File: packages/ucd-store/src/download.ts:24-24
Timestamp: 2025-06-09T05:10:32.074Z
Learning: In the ucd-store package refactor, picomatch was moved from direct usage in download.ts to internal usage within the createPathFilter function in filter.ts. The pattern format is still picomatch-compatible, so JSDoc comments referencing picomatch pattern format remain correct.
packages/ucd-store/src/local.ts (1)
Learnt from: luxass
PR: ucdjs/ucd#45
File: packages/ucd-store/src/download.ts:24-24
Timestamp: 2025-06-09T05:10:32.074Z
Learning: In the ucd-store package refactor, picomatch was moved from direct usage in download.ts to internal usage within the createPathFilter function in filter.ts. The pattern format is still picomatch-compatible, so JSDoc comments referencing picomatch pattern format remain correct.
packages/ucd-store/src/download.ts (1)
Learnt from: luxass
PR: ucdjs/ucd#45
File: packages/ucd-store/src/download.ts:24-24
Timestamp: 2025-06-09T05:10:32.074Z
Learning: In the ucd-store package refactor, picomatch was moved from direct usage in download.ts to internal usage within the createPathFilter function in filter.ts. The pattern format is still picomatch-compatible, so JSDoc comments referencing picomatch pattern format remain correct.
🔇 Additional comments (9)
packages/ucd-store/src/remote.ts (1)

5-5: LGTM! Clean refactoring of import source.

The import source change from "./filter" to "@ucdjs/utils" is consistent with moving filter functionality to a shared utils package. The functionality remains identical.

packages/ucd-store/test/remote.test.ts (1)

5-5: LGTM! Test import updated consistently with refactoring.

The import source change for PRECONFIGURED_FILTERS from "@ucdjs/ucd-store" to "@ucdjs/utils" aligns with the filter functionality relocation. Test logic remains unaffected.

packages/ucd-store/src/download.ts (1)

4-4: LGTM! Import refactoring maintains functionality and documentation accuracy.

The import source change from "./filter" to "@ucdjs/utils" is consistent with the filter functionality migration. The JSDoc comments referencing picomatch format remain accurate since createPathFilter continues to use picomatch internally.

packages/ucd-store/src/local.ts (1)

6-6:

Details

✅ Verification successful

LGTM! Final import update completes the refactoring.

The import source change from "./filter" to "@ucdjs/utils" completes the consistent migration of filter functionality to the utils package. All functionality is preserved.

Let me verify that the dependency migration is complete:


🏁 Script executed:

#!/bin/bash
# Description: Verify the filter functionality migration is complete
# Expected: No remaining references to local filter imports, picomatch dependency moved to utils

echo "=== Checking for remaining local filter imports ==="
rg -n "from [\"']\.\/filter[\"']" --type ts

echo -e "\n=== Checking package.json dependencies ==="
echo "ucd-store package.json:"
cat packages/ucd-store/package.json | jq '.dependencies.picomatch // empty'

echo -e "\nutils package.json:"
cat packages/utils/package.json | jq '.dependencies.picomatch // empty'

echo -e "\n=== Verifying utils package exports filter functionality ==="
cat packages/utils/src/index.ts | rg -A 5 -B 5 "(createPathFilter|PRECONFIGURED_FILTERS|FilterFn)"

Length of output: 1095


Migration Verified: Filter functionality migration complete

  • No remaining imports from ./filter in packages/ucd-store/src/local.ts or elsewhere.
  • packages/ucd-store/package.json no longer lists picomatch as a dependency.
  • packages/utils/package.json correctly depends on picomatch.
  • packages/utils/src/index.ts exports createPathFilter and FilterFn from ./filter, preserving all functionality.

LGTM! Approving these refactoring changes.

packages/utils/src/filter.ts (1)

29-30: Good documentation improvement!

Adding the import statement to the example clarifies how to use the function after it was moved to the utils package. This helps users understand the correct import path.

packages/cli/src/cmd/download.ts (1)

6-7: Import changes look correct for the refactoring.

The separation is appropriate - PRECONFIGURED_FILTERS now comes from @ucdjs/utils while the download function remains in @ucdjs/ucd-store. This aligns with the goal of moving filter-related utilities to the utils package.

packages/ucd-store/test/fs-interface.test.ts (1)

24-33: Verify if this mocking change is related to the filter refactoring.

This change from static to dynamic mocking for fs-extra appears unrelated to moving filter functionality from ucd-store to utils package. While the implementation looks correct, it seems like it might belong in a separate PR focused on test improvements.

Can you clarify if this mocking strategy change is necessary for the filter refactoring or if it's an unrelated improvement that was bundled with this PR?

packages/utils/package.json (2)

38-40: Add picomatch runtime dependency
Including picomatch here is necessary to support the relocated filter logic in this package.


43-43: Add TypeScript definitions for picomatch
Providing @types/picomatch ensures proper typing support for the new dependency during development and type checks.

@luxass luxass force-pushed the luxass/refactor-move-filter-functionality-from-ucd-store-to-utils-package branch from 3ba7f0e to d761237 Compare June 9, 2025 13:22
Copy link
Member Author

luxass commented Jun 9, 2025

Merge activity

  • Jun 9, 2:35 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 9, 2:35 PM UTC: @luxass merged this pull request with Graphite.

@luxass luxass merged commit 6bcef71 into main Jun 9, 2025
6 checks passed
@luxass luxass deleted the luxass/refactor-move-filter-functionality-from-ucd-store-to-utils-package branch June 9, 2025 14:35
@coderabbitai coderabbitai bot mentioned this pull request Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: cli Changes related to the CLI package. pkg: ucd-store Changes related to the UCD Store package. pkg: utils Changes related to the Utils package.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

move download functions to utils library

1 participant