Skip to content

feat: implement mirrorUCDFiles#53

Merged
luxass merged 13 commits intomainfrom
luxass/06-09-feat-implement-mirrorucdfiles
Jun 13, 2025
Merged

feat: implement mirrorUCDFiles#53
luxass merged 13 commits intomainfrom
luxass/06-09-feat-implement-mirrorucdfiles

Conversation

@luxass
Copy link
Member

@luxass luxass commented Jun 9, 2025

This PR implements the mirrorUCDFiles so it now can download files, and return the files located, downloaded files, errors and whether or not it is success or not.

Summary by CodeRabbit

  • New Features

    • Introduced the ability to mirror Unicode Character Database (UCD) files for specified Unicode versions, with options for filtering files and customizing the file system and API source.
    • Added new file system operations for creating directories and writing files as part of the Unicode file mirroring process.
  • Tests

    • Expanded test coverage for Unicode file mirroring, including various success, error, and edge case scenarios.

@changeset-bot
Copy link

changeset-bot bot commented Jun 9, 2025

🦋 Changeset detected

Latest commit: a1465f7

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

Warning

Rate limit exceeded

@luxass has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 32 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 8cd9a4c and a1465f7.

📒 Files selected for processing (2)
  • packages/utils/src/ucd-files.ts (3 hunks)
  • packages/utils/test/ucd-files.test.ts (1 hunks)

Walkthrough

This change adds two new dependencies and extends the filesystem adapter interface with directory and file writing methods. It implements a new function to mirror Unicode Character Database files for specified versions with filtering and flexible filesystem support. Extensive tests cover functionality, filtering, error handling, and integration.

Changes

File(s) Change Summary
packages/utils/package.json Added dependencies: @luxass/unicode-utils-new, defu (both "catalog:prod").
packages/utils/src/types.ts Extended FSAdapter interface with async methods: mkdir, ensureDir, and writeFile; added type imports.
packages/utils/src/ucd-files.ts Added mirrorUCDFiles function, MirrorOptions, MirrorResult types; implemented recursive file mirroring with filtering and error reporting; added default FS adapter methods.
packages/utils/test/ucd-files.test.ts Expanded tests for FS adapter methods and mirrorUCDFiles covering success, filtering, errors, and filesystem integration.
.changeset/pretty-buckets-shine.md Added changeset documenting the new mirrorUCDFiles feature and minor version bump for @ucdjs/utils.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant mirrorUCDFiles
    participant FSAdapter
    participant UnicodeAPI

    Caller->>mirrorUCDFiles: Provide MirrorOptions
    mirrorUCDFiles->>UnicodeAPI: Fetch file list for each version
    UnicodeAPI-->>mirrorUCDFiles: Return file entries
    mirrorUCDFiles->>FSAdapter: mkdir/ensureDir for target directories
    mirrorUCDFiles->>UnicodeAPI: Download each filtered file
    UnicodeAPI-->>mirrorUCDFiles: Return file content
    mirrorUCDFiles->>FSAdapter: writeFile for each file
    mirrorUCDFiles-->>Caller: Return MirrorResult (success/errors)
Loading

Possibly related PRs

Poem

In the warren's codey light,
Unicode files take flight,
Mirrored neat from far and near,
Into folders, crystal clear.
Errors caught and tests abound—
Hopping joy in code is found!
🐇✨

✨ 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 the pkg: utils Changes related to the Utils package. label Jun 9, 2025
Copy link
Member Author

luxass commented Jun 9, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codecov
Copy link

codecov bot commented Jun 11, 2025

Codecov Report

Attention: Patch coverage is 92.57642% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/utils/src/ucd-files.ts 92.57% 17 Missing ⚠️

📢 Thoughts on this report? Let us know!

@luxass luxass marked this pull request as ready for review June 13, 2025 03:44
@luxass luxass requested a review from Copilot June 13, 2025 03:46
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 implements the mirrorUCDFiles feature to download Unicode Character Database files for specified versions while providing detailed error handling and file filtering.

  • Implements mirrorUCDFiles and helper functions, including recursive directory processing.
  • Extends FSAdapter interface and updates dependencies and tests to support the new functionality.

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

File Description
packages/utils/src/ucd-files.ts Implements mirrorUCDFiles, internal mirroring logic and file filtering.
packages/utils/src/types.ts Updates FSAdapter interface with additional filesystem method definitions.
packages/utils/package.json Adds new dependencies for Unicode utilities and configuration merging.
.changeset/pretty-buckets-shine.md Adds a changelog entry for the mirrorUCDFiles feature.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

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: 3

🧹 Nitpick comments (1)
packages/utils/src/ucd-files.ts (1)

328-333: Doc-block is outdated

The comment claims the adapter “only implements the readFile method”, but the implementation now includes mkdir, ensureDir, writeFile. Please update to avoid confusion.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7db3bad and febe7ab.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • packages/utils/package.json (1 hunks)
  • packages/utils/src/types.ts (1 hunks)
  • packages/utils/src/ucd-files.ts (3 hunks)
  • packages/utils/test/ucd-files.test.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/utils/src/ucd-files.ts (1)
packages/utils/src/types.ts (1)
  • FSAdapter (5-10)
🪛 GitHub Check: build
packages/utils/test/ucd-files.test.ts

[failure] 1-1:
'path' is defined but never used

🪛 GitHub Actions: CI
packages/utils/test/ucd-files.test.ts

[error] 1-1: ESLint: 'path' is defined but never used. (unused-imports/no-unused-imports)

🔇 Additional comments (3)
packages/utils/package.json (1)

40-44: Check availability of “catalog:prod” refs

New deps use the custom catalog: protocol. Confirm they resolve correctly in all environments (CI, prod registry).

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

7-10: Interface now mandates four methods – update all custom adapters

FSAdapter requires mkdir, ensureDir, and writeFile. Any existing custom adapter implementations (including those in tests) must be updated, otherwise runtime errors will surface when the stricter typing is bypassed (see mirrorUCDFiles).

packages/utils/test/ucd-files.test.ts (1)

223-245: Test adapter violates interface – hides production bug

The mocked adapter supplies only readFile & mkdir, yet the interface (and real code) also call ensureDir & writeFile. Tests pass because the implementation silently swaps in the default adapter (see earlier issue). Update the mock to include the full surface and re-run tests after fixing the propagation bug.

@luxass luxass merged commit 1c33b13 into main Jun 13, 2025
4 checks passed
@luxass luxass deleted the luxass/06-09-feat-implement-mirrorucdfiles branch June 13, 2025 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: utils Changes related to the Utils package.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant