Skip to content

refactor: ucd-files impl#56

Merged
luxass merged 9 commits intomainfrom
luxass/06-14-refactor-ucd-files-impl
Jun 14, 2025
Merged

refactor: ucd-files impl#56
luxass merged 9 commits intomainfrom
luxass/06-14-refactor-ucd-files-impl

Conversation

@luxass
Copy link
Member

@luxass luxass commented Jun 14, 2025

This PR refactors the entire UCD Files part of the utils package.

Summary by CodeRabbit

  • Refactor

    • Simplified Unicode file handling by restructuring modules and extracting logic into dedicated files for improved organization.
  • New Features

    • Added recursive directory reading support in the filesystem adapter.
    • Introduced functions to mirror and validate Unicode Character Database files with flexible filtering and configuration options.
  • Tests

    • Added comprehensive tests for the filesystem adapter and Unicode file validation.
    • Updated and streamlined test suites for improved coverage and maintainability.
  • Chores

    • Updated metadata to reflect internal refactoring and version changes.

@changeset-bot
Copy link

changeset-bot bot commented Jun 14, 2025

🦋 Changeset detected

Latest commit: 1bc63d6

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 14, 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 13 minutes and 2 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 ef300d3 and 1bc63d6.

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

Walkthrough

This change refactors the Unicode Character Database (UCD) file utilities by extracting mirroring, validation, and filesystem adapter logic into dedicated modules. It updates the FSAdapter interface, introduces new test suites for the refactored modules, and restructures exports to use a barrel pattern. Previous inline implementations are replaced by imports from the new modular files.

Changes

File(s) Change Summary
.changeset/silent-suits-guess.md Added changeset documenting a minor version update for @ucdjs/utils due to refactor of ucd-files.
packages/utils/src/types.ts Updated FSAdapter interface: readdir now accepts optional recursive boolean parameter.
packages/utils/src/ucd-files.ts Removed all inline logic and types; now re-exports from new modular files (fs-adapter, mirror, validate).
packages/utils/src/ucd-files/fs-adapter.ts New module: Implements createDefaultFSAdapter with async filesystem operations, including recursive readdir.
packages/utils/src/ucd-files/internal.ts New module: Internal utilities for mirroring Unicode version files, including recursive download and filtering.
packages/utils/src/ucd-files/mirror.ts New module: Implements mirrorUCDFiles with options, error handling, and result typing.
packages/utils/src/ucd-files/validate.ts New module: Implements validateUCDFiles with options, error handling, and result typing.
packages/utils/test/ucd-files/fs-adapter.test.ts New test: Verifies createDefaultFSAdapter functionality and error handling.
packages/utils/test/ucd-files/mirror.test.ts Removed FSAdapter and validateUCDFiles tests; updated imports for mirror tests.
packages/utils/test/ucd-files/validate.test.ts New test: Comprehensive tests for validateUCDFiles covering patterns, errors, and edge cases.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MirrorModule as mirrorUCDFiles
    participant Internal as internal_mirrorUnicodeVersion
    participant FS as FSAdapter
    participant API as Unicode Proxy API

    User->>MirrorModule: mirrorUCDFiles(options)
    MirrorModule->>API: Fetch file list for each version
    MirrorModule->>Internal: internal_mirrorUnicodeVersion(version, options)
    Internal->>FS: Ensure output directory
    Internal->>API: Download filtered files
    API-->>Internal: Return file data
    Internal->>FS: Write files to disk
    Internal-->>MirrorModule: Return files/errors
    MirrorModule-->>User: Return MirrorResult
Loading
sequenceDiagram
    participant User
    participant ValidateModule as validateUCDFiles
    participant FS as FSAdapter
    participant API as Unicode Proxy API

    User->>ValidateModule: validateUCDFiles(version, options)
    ValidateModule->>API: Fetch expected file list
    ValidateModule->>FS: Read local directory (recursive)
    ValidateModule->>ValidateModule: Compare local files to expected
    ValidateModule-->>User: Return missingFiles, notRequiredFiles
Loading

Possibly related PRs

  • ucdjs/ucd#53: Refactored ucd-files by extracting and reorganizing mirroring, validation, and filesystem adapter logic—directly continued and restructured in this PR.
  • ucdjs/ucd#50: Introduced the initial FSAdapter interface and a stub for mirrorUCDFiles; this PR builds upon that foundation with full implementation and refactoring.
  • ucdjs/ucd#47: Moved the UnicodeVersionFile type to an external package, which is now used and re-exported in the reorganized modules.

Poem

🐇
In burrows deep, I hop and weave,
Refactored code I now achieve!
UCD files, once all in one,
Split apart—my work is done.
Mirror, validate, and test anew,
Fresh modules for the world to view!
🗂️✨

✨ 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 14, 2025
Copy link
Member Author

luxass commented Jun 14, 2025

@luxass
Copy link
Member Author

luxass commented Jun 14, 2025

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 14, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

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

6-9: Doc-comment is stale – adapter now implements more than readFile

The JSDoc still states “it only implements the readFile method” but the object now exposes six methods.
Update the description to avoid confusion for consumers and future maintainers.

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

24-35: Prefer vi.resetAllMocks() after dynamic import

After importing the spied readFile, subsequent tests could receive residual mock state.
Calling vi.resetAllMocks() (or reading the mock inside beforeEach) keeps isolation tight.

.changeset/silent-suits-guess.md (1)

5-5: Consider expanding the changeset summary

A one-line “refactor ucd-files” note gives little context for consumers scanning the changelog.
Briefly list the extracted modules (fs-adapter, mirror, validate) or the new recursive readdir feature so downstream users understand the impact.

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

185-192: Mock readdir signature should accept recursive

mirrorUCDFiles may invoke fs.readdir(path, true).
Define the mock as (path, _recursive?) => … to avoid unexpected TypeError once the function is fixed:

- readdir: vi.fn().mockResolvedValue([]),
+ readdir: vi.fn().mockResolvedValue([]) as unknown as FSAdapter["readdir"],

(Or use vi.fn<FSAdapter["readdir"]>().)
This keeps the mock type-safe and forward-compatible.

packages/utils/src/ucd-files/validate.ts (1)

56-69: JSDoc parameter list is out of sync.

@param tags should describe both version and options, otherwise typedoc/ESLint complain (see static-analysis hint).

🧰 Tools
🪛 GitHub Check: build

[warning] 56-56:
Expected @param names to be "version, options". Got "options"

packages/utils/src/ucd-files/mirror.ts (1)

73-80: Unconditionally instantiating a default FS adapter is wasteful.

await createDefaultFSAdapter() runs even when the caller already supplied options.fs, incurring an unnecessary dynamic import("node:fs/promises").

-  fs: await createDefaultFSAdapter(),
+  fs: options.fs ?? await createDefaultFSAdapter(),

A small optimisation, but worthwhile inside tight loops or serverless functions.

packages/utils/src/ucd-files/internal.ts (1)

135-161: Potentially overwhelming concurrency when mirroring many files.

All fetches are fired in parallel; mirroring a full Unicode version (~700 files) can hammer the proxy and consume memory.
Consider throttling with p-limit / a simple semaphore.

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

249-270: Spy expectation misses the recursive argument

FSAdapter.readdir was updated to accept a second recursive parameter.
The implementation calls:

readdir(path, true)

but the assertion only expects the path. Align the test:

-expect(mockFs.readdir).toHaveBeenCalledWith(`${testdirPath}/v16.0.0`);
+expect(mockFs.readdir).toHaveBeenCalledWith(
+  `${testdirPath}/v16.0.0`,
+  true
+);

(or use expect.any(Boolean) if you don’t want to couple to the exact flag).
This fixes the CI failure reported at line 269.

🧰 Tools
🪛 GitHub Check: build

[failure] 269-269: packages/utils/test/ucd-files/validate.test.ts > validateUCDFiles > configuration options > should use custom filesystem adapter
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

[
"/home/runner/work/ucd/ucd/.vitest-testdirs/vitest-validate-configuration-options-should-use-custom-filesystem-adapter/v16.0.0",

  • true,
    ]

Number of calls: 1

❯ packages/utils/test/ucd-files/validate.test.ts:269:30

🪛 GitHub Actions: CI

[error] 269-269: Test failure: expected 'spy' to be called with arguments [ Array(1) ] in 'should use custom filesystem adapter'

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fb78397 and a156247.

📒 Files selected for processing (10)
  • .changeset/silent-suits-guess.md (1 hunks)
  • packages/utils/src/types.ts (1 hunks)
  • packages/utils/src/ucd-files.ts (1 hunks)
  • packages/utils/src/ucd-files/fs-adapter.ts (1 hunks)
  • packages/utils/src/ucd-files/internal.ts (1 hunks)
  • packages/utils/src/ucd-files/mirror.ts (1 hunks)
  • packages/utils/src/ucd-files/validate.ts (1 hunks)
  • packages/utils/test/ucd-files/fs-adapter.test.ts (1 hunks)
  • packages/utils/test/ucd-files/mirror.test.ts (1 hunks)
  • packages/utils/test/ucd-files/validate.test.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
packages/utils/src/ucd-files/mirror.ts (3)
packages/utils/src/types.ts (1)
  • FSAdapter (5-12)
packages/utils/src/ucd-files/fs-adapter.ts (1)
  • createDefaultFSAdapter (13-58)
packages/utils/src/ucd-files/internal.ts (1)
  • internal_mirrorUnicodeVersion (14-87)
packages/utils/test/ucd-files/fs-adapter.test.ts (1)
packages/utils/src/ucd-files/fs-adapter.ts (2)
  • createDefaultFSAdapter (13-58)
  • readFile (18-20)
packages/utils/src/ucd-files/validate.ts (3)
packages/utils/src/types.ts (1)
  • FSAdapter (5-12)
packages/utils/src/ucd-files/fs-adapter.ts (1)
  • createDefaultFSAdapter (13-58)
packages/utils/src/ucd-files/internal.ts (1)
  • internal__flattenFilePaths (191-205)
🪛 GitHub Check: build
packages/utils/test/ucd-files/validate.test.ts

[failure] 481-481: packages/utils/test/ucd-files/validate.test.ts > validateUCDFiles > edge cases > should handle empty file list from API
AssertionError: expected [] to include 'SomeFile.txt'
❯ packages/utils/test/ucd-files/validate.test.ts:481:39


[failure] 269-269: packages/utils/test/ucd-files/validate.test.ts > validateUCDFiles > configuration options > should use custom filesystem adapter
AssertionError: expected "spy" to be called with arguments: [ Array(1) ]

Received:

1st spy call:

[
"/home/runner/work/ucd/ucd/.vitest-testdirs/vitest-validate-configuration-options-should-use-custom-filesystem-adapter/v16.0.0",

  • true,
    ]

Number of calls: 1

❯ packages/utils/test/ucd-files/validate.test.ts:269:30


[failure] 108-108: packages/utils/test/ucd-files/validate.test.ts > validateUCDFiles > basic validation functionality > should identify extra files that are not required
AssertionError: expected [] to include 'ExtraFile.txt'
❯ packages/utils/test/ucd-files/validate.test.ts:108:39

packages/utils/src/ucd-files/validate.ts

[warning] 56-56:
Expected @param names to be "version, options". Got "options"

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

[error] 108-108: Test failure: expected [] to include 'ExtraFile.txt' in 'should identify extra files that are not required'


[error] 269-269: Test failure: expected 'spy' to be called with arguments [ Array(1) ] in 'should use custom filesystem adapter'


[error] 481-481: Test failure: expected [] to include 'SomeFile.txt' in 'should handle empty file list from API'

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
🔇 Additional comments (1)
packages/utils/src/ucd-files.ts (1)

1-10: Barrel re-exports look clean.

No issues spotted.

@luxass luxass changed the base branch from luxass/06-14-feat-add-validateucdfiles-function-and-update-fsadapter-interface-with-exists-and-readdir-methods to graphite-base/56 June 14, 2025 05:09
@luxass luxass force-pushed the luxass/06-14-refactor-ucd-files-impl branch 2 times, most recently from 9b767d9 to b7ed1db Compare June 14, 2025 05:10
@luxass luxass changed the base branch from graphite-base/56 to main June 14, 2025 05:10
@luxass luxass force-pushed the luxass/06-14-refactor-ucd-files-impl branch from b7ed1db to ef300d3 Compare June 14, 2025 05:10
@codecov
Copy link

codecov bot commented Jun 14, 2025

Codecov Report

Attention: Patch coverage is 91.31737% with 29 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/utils/src/ucd-files/fs-adapter.ts 68.88% 14 Missing ⚠️
packages/utils/src/ucd-files/internal.ts 91.71% 13 Missing ⚠️
packages/utils/src/ucd-files/validate.ts 97.10% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

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

🔭 Outside diff range comments (2)
packages/utils/test/ucd-files/mirror.test.ts (2)

206-208: ⚠️ Potential issue

mkdir expectation uses a v prefix that no other assertion relies on – likely a mismatch with the actual implementation

All other assertions in this suite expect paths like 16.0.0/UnicodeData.txt (no v prefix).
Expecting the adapter to be called with ${testdirPath}/v16.0.0 is therefore inconsistent and will turn into a false-negative if mirrorUCDFiles correctly mirrors to <basePath>/<version>.

-expect(mockFs.mkdir).toHaveBeenCalledWith(`${testdirPath}/v16.0.0`, { recursive: true });
+expect(mockFs.mkdir).toHaveBeenCalledWith(`${testdirPath}/16.0.0`, { recursive: true });

406-409: ⚠️ Potential issue

Stubbed file download returns JSON instead of plain text

mirrorUCDFiles presumably writes the raw file contents. Returning JSON here (HttpResponse.json(...)) yields a Content-Type: application/json response and a stringified body, which is an unrealistic contract and could mask encoding bugs.

-["GET https://unicode-proxy.ucdjs.dev/16.0.0/ucd/level1/level2/level3/deep-file.txt", () => {
-  return HttpResponse.json({ name: "deep-file.txt", path: "deep-file.txt" });
-}],
+["GET https://unicode-proxy.ucdjs.dev/16.0.0/ucd/level1/level2/level3/deep-file.txt", () =>
+  new HttpResponse("dummy-file-content"),
+],
♻️ Duplicate comments (3)
packages/utils/src/ucd-files/fs-adapter.ts (1)

47-50: ⚠️ Potential issue

readdir still relies on a non-existent recursive option – implement real recursion.

fs.promises.readdir silently ignores the recursive flag on every currently-released Node.js version (≤ v22).
Callers will believe they received a deep listing while in fact only one level is returned, breaking validateUCDFiles and anything else that depends on it.

-      async readdir(dirPath, recursive = false) {
-        return fsModule.readdir(dirPath, {
-          recursive,
-        });
-      },
+      async readdir(dirPath, recursive = false) {
+        if (!recursive) {
+          // Shallow case stays cheap.
+          return fsModule.readdir(dirPath);
+        }
+
+        const out: string[] = [];
+        const stack: string[] = [dirPath];
+
+        while (stack.length) {
+          const current = stack.pop()!;
+          const entries = await fsModule.readdir(current, { withFileTypes: true });
+          for (const entry of entries) {
+            const full = `${current}/${entry.name}`;
+            if (entry.isDirectory()) {
+              stack.push(full);
+            } else {
+              out.push(path.relative(dirPath, full));
+            }
+          }
+        }
+        return out;
+      },

Don’t forget to cover the recursive branch in unit tests.

packages/utils/src/ucd-files/internal.ts (1)

8-9: ⚠️ Potential issue

Download host is still hard-wired – apiUrl / client setting is ignored for file downloads.

Even though the high-level API allows a custom apiUrl, actual file bytes are always fetched from https://unicode-proxy.ucdjs.dev. This is the same issue flagged earlier; it prevents users from mirroring from self-hosted endpoints or during tests.

Expose the base URL as an argument (e.g. pass it through mirrorOptions) or reuse the already-configured REST client’s base to keep list & file fetches consistent.

Also applies to: 139-140

packages/utils/src/ucd-files/validate.ts (1)

142-147: 🛠️ Refactor suggestion

Catching everything and returning empty results hides real failures.

The function now swallows all errors again and reports “no problems” ([]). Callers lose any context, and CI cannot fail on genuine issues.

Either re-throw the enriched error or return { missingFiles, notRequiredFiles, error }.

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

56-69: JSDoc parameter mismatch.

@param lists options.version etc., but the actual function signature is (version, options). Update the comment or the tags to avoid TS/ESDoc tooling warnings.

🧰 Tools
🪛 GitHub Check: build

[warning] 56-56:
Expected @param names to be "version, options". Got "options"

packages/utils/test/ucd-files/validate.test.ts (2)

42-46: Factor the API URL into a shared helper to reduce duplication

The literal
"GET https://unicode-api.luxass.dev/api/v1/unicode-files/16.0.0"
is repeated in almost every test. Centralising the base URL (e.g. const DEFAULT_API = "https://unicode-api.luxass.dev" or a tiny mockUnicodeFiles(version, payload) helper) will:

  • make future URL changes trivial,
  • eliminate typo-risk,
  • shorten individual test cases.

No functional impact, just tidier & easier to maintain.


155-159: Redundant assertion

expect(result.missingFiles).not.toContain("emojis/emoji-data.txt") is implied by the immediate toEqual([]) that follows. Dropping the first line tightens the test without losing coverage.

-// Should not include emoji files in missing files since they're filtered out
-expect(result.missingFiles).not.toContain("emojis/emoji-data.txt");
-expect(result.missingFiles).toEqual([]);
+expect(result.missingFiles).toEqual([]);
packages/utils/test/ucd-files/mirror.test.ts (1)

185-193: Custom FSAdapter mocks are incomplete – add missing methods to avoid runtime failures

mirrorUCDFiles may invoke additional adapter methods such as stat, unlink, or chmod. Any un-mocked call will throw TypeError: fn is not a function and cause brittle, misleading failures when the implementation evolves.

Recommend defining the adapter with full coverage or using vi.fn() & Proxy to auto-stub unknown keys.

Also applies to: 308-315

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a156247 and ef300d3.

📒 Files selected for processing (10)
  • .changeset/silent-suits-guess.md (1 hunks)
  • packages/utils/src/types.ts (1 hunks)
  • packages/utils/src/ucd-files.ts (1 hunks)
  • packages/utils/src/ucd-files/fs-adapter.ts (1 hunks)
  • packages/utils/src/ucd-files/internal.ts (1 hunks)
  • packages/utils/src/ucd-files/mirror.ts (1 hunks)
  • packages/utils/src/ucd-files/validate.ts (1 hunks)
  • packages/utils/test/ucd-files/fs-adapter.test.ts (1 hunks)
  • packages/utils/test/ucd-files/mirror.test.ts (1 hunks)
  • packages/utils/test/ucd-files/validate.test.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • .changeset/silent-suits-guess.md
  • packages/utils/src/types.ts
  • packages/utils/test/ucd-files/fs-adapter.test.ts
  • packages/utils/src/ucd-files/mirror.ts
🧰 Additional context used
🧠 Learnings (1)
packages/utils/src/ucd-files/fs-adapter.ts (1)
Learnt from: luxass
PR: ucdjs/ucd#6
File: packages/cli/src/cmd/codegen/fields.ts:68-82
Timestamp: 2025-05-04T11:52:22.858Z
Learning: User prefers to address the issue with Node.js API compatibility (`Dirent.parentPath` not being part of Node's API and the `recursive: true` option for `readdir` being only available in Node 21+) in a separate PR rather than the current one.
🧬 Code Graph Analysis (1)
packages/utils/src/ucd-files/validate.ts (3)
packages/utils/src/types.ts (1)
  • FSAdapter (5-12)
packages/utils/src/ucd-files/fs-adapter.ts (1)
  • createDefaultFSAdapter (13-58)
packages/utils/src/ucd-files/internal.ts (1)
  • internal__flattenFilePaths (191-205)
🪛 GitHub Check: codecov/patch
packages/utils/src/ucd-files/internal.ts

[warning] 143-149: packages/utils/src/ucd-files/internal.ts#L143-L149
Added lines #L143 - L149 were not covered by tests


[warning] 155-160: packages/utils/src/ucd-files/internal.ts#L155-L160
Added lines #L155 - L160 were not covered by tests

packages/utils/src/ucd-files/fs-adapter.ts

[warning] 28-31: packages/utils/src/ucd-files/fs-adapter.ts#L28-L31
Added lines #L28 - L31 were not covered by tests


[warning] 37-46: packages/utils/src/ucd-files/fs-adapter.ts#L37-L46
Added lines #L37 - L46 were not covered by tests

packages/utils/src/ucd-files/validate.ts

[warning] 87-88: packages/utils/src/ucd-files/validate.ts#L87-L88
Added lines #L87 - L88 were not covered by tests

🪛 GitHub Check: build
packages/utils/src/ucd-files/validate.ts

[warning] 56-56:
Expected @param names to be "version, options". Got "options"

🔇 Additional comments (2)
packages/utils/src/ucd-files.ts (1)

1-9: Barrel file looks good.

Re-exports are clean and maintain original public surface.

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

47-52: Network calls for file downloads are not mocked – tests may hit the real network

Each test only stubs the file-list endpoint (…/unicode-files/<version>).
mirrorUCDFiles subsequently downloads every individual file (e.g. …/unicode-proxy.ucdjs.dev/<version>/ucd/<path>).
Without corresponding mocks Vitest will attempt real HTTP requests, making the suite flaky and dramatically slower offline/CI.

Consider adding a catch-all MSW handler or explicit mocks for the per-file URLs, e.g.:

mockFetch([
  // existing list mock …
  ['GET https://unicode-proxy.ucdjs.dev/**', () => new HttpResponse('file', { status: 200 })],
]);

Also applies to: 69-78, 95-100, 114-119, 134-139, 160-165, 185-193, 213-219, 340-344

@luxass luxass merged commit 03d6643 into main Jun 14, 2025
3 checks passed
@luxass luxass deleted the luxass/06-14-refactor-ucd-files-impl branch June 14, 2025 05:25
@coderabbitai coderabbitai bot mentioned this pull request Jun 15, 2025
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