Skip to content

feat: add shared package#212

Merged
luxass merged 11 commits intomainfrom
shared-package
Aug 22, 2025
Merged

feat: add shared package#212
luxass merged 11 commits intomainfrom
shared-package

Conversation

@luxass
Copy link
Member

@luxass luxass commented Aug 22, 2025

🔗 Linked issue

#210

📚 Description

Summary by CodeRabbit

  • New Features
    • Introduced a new shared utilities package for common path filtering, JSON parsing, and file path helpers.
  • Refactor
    • Migrated consumers from the old utilities package to the new shared package.
    • Streamlined the original utilities package to focus on stable, user-facing helpers (breaking: several prior exports were removed).
  • Documentation
    • Added README for the shared utilities package with usage examples.
  • Tests
    • Added and updated tests to cover shared utilities and revised imports.
  • Chores
    • Updated labels, tooling configs, and internal dependencies; minor version bumps.

luxass added 10 commits August 22, 2025 04:28
This package will contain more internal util functions.
* Introduced new label configuration for the `shared` package in the GitHub Actions labeler.
* This allows for better automation and organization of pull requests related to the shared package.
* Moved the `@ucdjs/utils` path below `@ucdjs/shared` for better organization.
* Ensured all utility packages are grouped together for clarity.
* Changed dependency reference in `package.json` and `pnpm-lock.yaml` to reflect the new shared package.
* Ensures consistency across the project by using the updated package structure.
* The `safeJsonParse` function has been removed from the utils package and re-exported from the shared package.
* This change centralizes the JSON parsing utility, promoting code reuse across packages.
- Deleted the flatten.ts utility function and its associated tests.
- Updated index.ts to remove the export of flattenFilePaths and added a new internal function for logging.
- Removed filter.test.ts and flatten.test.ts as they are no longer needed.
- Adjusted index.test.ts to test the new internal logging function.
- Updated tsdown.config.ts to remove unnecessary entry.
- Updated pnpm-lock.yaml to reflect changes in dependencies, replacing @ucdjs/fetch with @ucdjs/shared.
…@ucdjs/shared`

* Updated imports in multiple files to use the shared package for `flattenFilePaths`.
* This change promotes consistency and centralizes utility functions in the shared package.
@changeset-bot
Copy link

changeset-bot bot commented Aug 22, 2025

🦋 Changeset detected

Latest commit: b280007

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

This PR includes changesets to release 5 packages
Name Type
@ucdjs/utils Minor
@ucdjs/fs-bridge Minor
@ucdjs/ucd-store Minor
@ucdjs/shared Minor
@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 Aug 22, 2025

Walkthrough

Introduces a new internal package @ucdjs/shared, migrates utilities from @ucdjs/utils to it, updates imports across fs-bridge and ucd-store, adjusts tooling aliases, and modifies @ucdjs/utils to re-export from @ucdjs/shared while removing prior local implementations and adding a new internal_bingbong function.

Changes

Cohort / File(s) Summary
Changesets
/.changeset/beige-dogs-roll.md, /.changeset/khaki-plums-return.md, /.changeset/tangy-days-wait.md
Add changesets: breaking change for @ucdjs/utils (most exports removed/moved), introduce @ucdjs/shared, bump @ucdjs/fs-bridge and @ucdjs/ucd-store minor versions.
Repo meta: labels
/.github/labeler.yml
Add label mapping for pkg: shared targeting packages/shared/**.
Shared package: scaffolding
/packages/shared/package.json, /packages/shared/LICENSE, /packages/shared/README.md, /packages/shared/eslint.config.js, /packages/shared/tsconfig.json, /packages/shared/tsconfig.build.json, /packages/shared/tsdown.config.ts, /packages/shared/turbo.json
Add new internal package @ucdjs/shared with build config, linting, license, docs, and publish setup.
Shared package: source and tests
/packages/shared/src/index.ts, /packages/shared/src/json.ts, /packages/shared/src/filter.ts, /packages/shared/src/flatten.ts, /packages/shared/test/json.test.ts
Implement and export safeJsonParse, re-export path filter and flatten utilities, update example imports, and add tests for safeJsonParse.
fs-bridge: dependency and tests
/packages/fs-bridge/package.json, /packages/fs-bridge/test/bridges/http.test.ts, /packages/fs-bridge/test/bridges/node.test.ts
Add devDependency on @ucdjs/shared; update test imports of flattenFilePaths to @ucdjs/shared.
ucd-store: dependency, sources, tests
/packages/ucd-store/package.json, /packages/ucd-store/src/internal/files.ts, /packages/ucd-store/src/store.ts, /packages/ucd-store/test/file-operations.test.ts
Replace dependency on @ucdjs/utils with @ucdjs/shared; update imports for flattenFilePaths, createPathFilter, PathFilter, and safeJsonParse.
utils: exports, deps, tests, build
/packages/utils/package.json, /packages/utils/src/index.ts, /packages/utils/test/index.test.ts, /packages/utils/tsdown.config.ts
Consolidate deps to @ucdjs/shared; remove local exports (safeJsonParse, path filter, flatten) and re-export from @ucdjs/shared; add internal_bingbong function and test; drop extra tsdown entry.
Tooling: TS paths
/tooling/tsconfig/base.json
Add path alias for @ucdjs/shared; reorganize utility aliases section.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as App/Tests
  participant Store as @ucdjs/ucd-store
  participant Shared as @ucdjs/shared
  note over Shared: New internal package

  App->>Store: import { createPathFilter, flattenFilePaths, safeJsonParse }
  Store->>Shared: uses createPathFilter / flattenFilePaths / safeJsonParse
  Shared-->>Store: returns utilities
  Store-->>App: functions operate as before (sources migrated)

  par Utils package
    participant Utils as @ucdjs/utils
    App->>Utils: import { createPathFilter, PRECONFIGURED_FILTERS }
    Utils->>Shared: re-export from @ucdjs/shared
    App->>Utils: call internal_bingbong()
    Utils-->>App: logs "Bing Bong"
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

In shared burrow, tools now reside,
Hop from utils to a cozier side.
Flatten the trails, parse with care,
Filters sift files through tidy air.
Bing bong echoes—console’s song,
This bunny approves: the move is strong. 🥕✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch shared-package

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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: ucd-store Changes related to the UCD Store package. pkg: utils Changes related to the Utils package. pkg: fs-bridge Changes related to the FS Bridge package. labels Aug 22, 2025
@luxass luxass marked this pull request as ready for review August 22, 2025 02:47
Copilot AI review requested due to automatic review settings August 22, 2025 02:47
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 introduces a new @ucdjs/shared package to consolidate internal utilities and restructures the existing @ucdjs/utils package to focus on user-facing functionality. The change implements better separation between internal and external utilities within the UCD monorepo.

  • Creates a new @ucdjs/shared package containing internal utilities like safeJsonParse, path filtering, and file flattening functions
  • Migrates internal dependencies from @ucdjs/utils to @ucdjs/shared across multiple packages
  • Removes most utility functions from @ucdjs/utils, keeping only a minimal public interface

Reviewed Changes

Copilot reviewed 29 out of 32 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/shared/* Complete new package setup with utilities moved from @ucdjs/utils
packages/utils/* Simplified to only export from @ucdjs/shared and added test placeholder
packages/ucd-store/* Updated imports to use @ucdjs/shared instead of @ucdjs/utils
packages/fs-bridge/* Updated test imports to use @ucdjs/shared
tooling/tsconfig/base.json Added path mapping for new @ucdjs/shared package
.changeset/* Changelog entries documenting the package restructuring
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

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

@github-actions
Copy link
Contributor

Preview Deployment for Web

The Web worker has been deployed successfully.

Preview URL: https://preview.ucdjs.dev

This preview was built from commit b280007


🤖 This comment will be updated automatically when you push new commits to this PR.

@github-actions
Copy link
Contributor

Preview Deployment for Api

The Api worker has been deployed successfully.

Preview URL: https://preview.api.ucdjs.dev

This preview was built from commit b280007


🤖 This comment will be updated automatically when you push new commits to this PR.

@codecov
Copy link

codecov bot commented Aug 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 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: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/shared/src/filter.ts (1)

1-160: Minor cleanup after migration to @ucdjs/shared

All code imports have been updated to pull createPathFilter, flattenFilePaths, etc., from @ucdjs/shared, and only packages/shared retains a runtime dependency on picomatch. A couple of housekeeping tasks remain:

  • packages/utils/README.md (around lines 22 and 51)
    • Change both

    import { createPathFilter } from "@ucdjs/utils";  

    to

    import { createPathFilter } from "@ucdjs/shared";  
  • packages/fetch/package.json
    • Remove the unused devDependency on

    "@types/picomatch": ""  

    since only packages/shared needs Picomatch types now.

🧹 Nitpick comments (22)
packages/shared/LICENSE (1)

1-22: MIT license text looks good; minor nit on year format.

Content matches the standard MIT template. Consider using a single year or a year range with a hyphen (e.g., "2025–present") to align with common conventions, though what you have is legally fine.

packages/shared/src/filter.ts (5)

18-25: Freeze PRECONFIGURED_FILTERS at runtime.

You already use as const for type-level immutability. Freezing at runtime prevents accidental mutation in consumers.

Apply:

-export const PRECONFIGURED_FILTERS = {
+export const PRECONFIGURED_FILTERS = Object.freeze({
   /** Excludes files containing "Test" in their name (e.g., DataTest.txt, TestFile.js) */
   EXCLUDE_TEST_FILES: "!**/*Test*",
   /** Excludes ReadMe.txt files from any directory */
   EXCLUDE_README_FILES: "!**/ReadMe.txt",
   /** Excludes all HTML files */
   EXCLUDE_HTML_FILES: "!**/*.html",
-} as const;
+} as const);

27-33: Separate internal predicate type from public function type for clarity.

PathFilterFn exposes an optional extraFilters arg, but internal__createFilterFunction returns a 1‑arg predicate. This is type-safe today, yet making the distinction explicit improves readability and prevents future refactors from passing extraFilters into the internal function by mistake.

Apply:

 type PathFilterFn = (path: string, extraFilters?: string[]) => boolean;
 
+// Internal, pure matcher that never handles `extraFilters`
+type PathPredicate = (path: string) => boolean;
+
 export interface PathFilter extends PathFilterFn {
   extend: (additionalFilters: string[]) => void;
   patterns: () => string[];
 }
@@
-function internal__createFilterFunction(filters: string[], options: FilterOptions): PathFilterFn {
+function internal__createFilterFunction(filters: string[], options: FilterOptions): PathPredicate {
   if (filters.length === 0) {
     return () => true;
   }

Also applies to: 111-115


50-56: Clarify “ALL files are included” note.

Given default exclusions for .zip/.pdf, consider rephrasing to “All files are included by default, subject to default exclusions” to avoid confusion.


68-76: Minor doc nit: remove unnecessary escapes in glob examples.

In TS strings you don’t need to escape forward slashes. Using !**/*.test.*, !**/node_modules/**, !**/dist/** reads cleaner.

Example:

-const srcFilter = createPathFilter(['src/**', '!**\/*.test.*']);
+const srcFilter = createPathFilter(['src/**', '!**/*.test.*']);
@@
-const excludeFilter = createPathFilter(['!**\/node_modules/**', '!**\/dist/**']);
+const excludeFilter = createPathFilter(['!**/node_modules/**', '!**/dist/**']);

Also applies to: 74-78


90-97: Optional: avoid recomputing matchers for per-call extraFilters via a tiny cache.

Each call with extraFilters rebuilds a new filter, which can be hot in loops. If this path is exercised frequently, cache by a stable key of extraFilters for the life of this filter instance.

Sketch:

  • Keep a Map<string, PathFilter> keyed by extraFilters.join('\u0000').
  • Return cached function when available.

I can send a concrete diff if you want this optimization.

packages/shared/turbo.json (1)

1-15: Turbo config is fine; consider wiring build graph.

Optionally add dependsOn: ["^build"] so this package rebuilds when upstream libs change, and declare typecheck inputs/outputs to maximize caching.

Example:

   "tasks": {
     "build": {
+      "dependsOn": ["^build"],
       "outputs": ["dist/**"]
     },
     "dev": {
       "persistent": false
     },
     "typecheck": {
+      "inputs": ["tsconfig.json", "tsconfig.build.json", "src/**/*.ts"],
       "outputs": [".cache/tsbuildinfo.json"]
     }
   }
packages/shared/src/flatten.ts (1)

35-37: Guard against missing children on directory nodes.
If a directory node lacks children, flattenFilePaths(file.children, fullPath) will throw due to the array check at Line 26. Defaulting to [] improves robustness without changing behavior for well-formed inputs.

Apply this diff:

-    if (file.type === "directory") {
-      paths.push(...flattenFilePaths(file.children, fullPath));
+    if (file.type === "directory") {
+      paths.push(...flattenFilePaths(file.children ?? [], fullPath));
.changeset/beige-dogs-roll.md (1)

5-9: Add a concise migration map for removed utilities

Include a short list mapping moved exports to their new import paths (e.g., safeJsonParse, flattenFilePaths → @ucdjs/shared) to ease upgrades and reduce churn for downstreams.

I can generate a migration snippet by scanning exports in utils/shared and drafting the before/after import table. Want me to add that?

packages/shared/src/json.ts (1)

1-16: Avoid console side-effects in a low-level parse utility

Library code should not emit console noise by default; it can leak details and makes consumers’ logs noisy. Return null silently and let callers decide how to log/handle.

Apply this diff:

 export function safeJsonParse<T>(content: string): T | null {
   try {
     return JSON.parse(content) as T;
-  } catch (err) {
-    console.error("[safeJsonParse] Failed to parse JSON:", err);
-    return null;
-  }
+  } catch {
+    return null;
+  }
 }

Optional follow-up for stronger type-safety (no breaking change required): add a validator-based variant so callers can enforce runtime shape.

// New helper (can live alongside safeJsonParse)
export function safeJsonParseWith<T>(
  content: string,
  refine: (v: unknown) => v is T
): T | null {
  try {
    const v = JSON.parse(content) as unknown;
    return refine(v) ? v : null;
  } catch {
    return null;
  }
}
packages/shared/package.json (4)

21-27: Harden exports to include types via conditional exports (modern ESM).

Current exports expose only JS; consumers relying on "exports" won't get types unless they also read the top-level "types" field. Adding a "types" condition improves DX and aligns with TS resolver behavior.

Apply:

-  "exports": {
-    ".": "./dist/index.js",
-    "./package.json": "./package.json"
-  },
+  "exports": {
+    ".": {
+      "types": "./dist/index.d.ts",
+      "import": "./dist/index.js",
+      "default": "./dist/index.js"
+    },
+    "./package.json": "./package.json"
+  },

28-30: Whitelist README and LICENSE in published files.

With "files" set, npm will usually still include README and LICENSE, but being explicit avoids surprises and makes publint happier.

   "files": [
-    "dist"
+    "dist",
+    "README.md",
+    "LICENSE"
   ],

34-40: Ensure builds exist on publish.

Add a prepack to build and run publint before publishing. This prevents publishing an empty package when "dist" isn't checked in.

   "scripts": {
     "build": "tsdown --tsconfig=./tsconfig.build.json",
     "dev": "tsdown --watch",
     "clean": "git clean -xdf dist node_modules",
     "lint": "eslint .",
-    "typecheck": "tsc --noEmit"
+    "typecheck": "tsc --noEmit",
+    "prepack": "pnpm run build && publint"
   },

28-33: Enable tree-shaking hints.

Mark package as side-effect free for bundlers.

   "files": [
     "dist",
     "README.md",
     "LICENSE"
   ],
+  "sideEffects": false,
   "engines": {
     "node": ">=22.17"
   },
packages/shared/README.md (3)

7-7: Correct package description to avoid implying fs-bridge implementations live here.

Shared contains utilities; fs bridges live in @ucdjs/fs-bridge.

-A collection of utility functions and filesystem bridge implementations for the UCD project.
+A collection of shared utilities for the UCD project.

15-59: Consider documenting other exported utilities (flattenFilePaths, safeJsonParse).

Quick stubs improve discoverability and help downstream maintainers migrate from @ucdjs/utils.

If you want, I can open a follow-up PR to add docs with examples and edge cases.


61-65: Clarify preconfigured filter semantics with examples.

Minor wording tweaks reduce ambiguity, especially around case and file variants.

-Available filters:
-- `EXCLUDE_TEST_FILES`: Excludes files containing "Test" in their name
-- `EXCLUDE_README_FILES`: Excludes ReadMe.txt files
-- `EXCLUDE_HTML_FILES`: Excludes all HTML files
+Available filters (examples):
+- `EXCLUDE_TEST_FILES`: Excludes common test files (e.g., `**/*.test.*`, files under `__tests__/`).
+- `EXCLUDE_README_FILES`: Excludes README files (e.g., `ReadMe.txt`, `README.md`).
+- `EXCLUDE_HTML_FILES`: Excludes `**/*.html` files.

Please confirm these examples match the actual patterns in packages/shared/src/filter.ts; adjust if they differ.

packages/utils/test/index.test.ts (1)

4-12: Simplify the test and harden cleanup.

No need for dynamic import here; also assert the call count and always restore the spy.

Apply this diff:

-describe("bing bong internal", () => {
-  it("should log 'Bing Bong'", async () => {
-    const consoleSpy = vi.spyOn(console, "log").mockImplementation(() => {});
-
-    const { internal_bingbong } = await import("../src/index").then((m) => m);
-
-    internal_bingbong();
-
-    expect(consoleSpy).toHaveBeenCalledWith("Bing Bong");
-    consoleSpy.mockRestore();
-  });
-});
+describe("bing bong internal", () => {
+  it("should log 'Bing Bong'", () => {
+    const consoleSpy = vi.spyOn(console, "log").mockImplementation(() => undefined);
+    try {
+      // Prefer static import at top of file if you don’t switch to a private module path.
+      // eslint-disable-next-line @typescript-eslint/no-var-requires
+      const { internal_bingbong } = require("../src/_internal");
+      internal_bingbong();
+      expect(consoleSpy).toHaveBeenCalledTimes(1);
+      expect(consoleSpy).toHaveBeenCalledWith("Bing Bong");
+    } finally {
+      consoleSpy.mockRestore();
+    }
+  });
+});
packages/shared/test/json.test.ts (3)

6-6: Prefer single-quoted JS strings for JSON literals to avoid escaping noise.

This improves readability and reduces escape clutter.

-    const validJson = "{\"name\":\"test\",\"value\":123}";
+    const validJson = '{"name":"test","value":123}';
@@
-    const validJson = "[1,2,3,\"test\"]";
+    const validJson = '[1,2,3,"test"]';
@@
-    const invalidJson = "{name:\"test\",value:123}"; // missing quotes around property names
+    const invalidJson = '{name:"test",value:123}'; // missing quotes around property names
@@
-    const incompleteJson = "{\"name\":\"test\",";
+    const incompleteJson = '{"name":"test",';
@@
-    const nestedJson = "{\"user\":{\"name\":\"test\",\"id\":123},\"active\":true}";
+    const nestedJson = '{"user":{"name":"test","id":123},"active":true}';

Also applies to: 12-12, 18-18, 24-24, 30-30


1-4: Silence noisy console.error in tests and assert it in failure cases.

safeJsonParse logs on parse failures; spy to keep test output clean and optionally assert the error path.

-import { describe, expect, it } from "vitest";
+import { describe, expect, it, vi } from "vitest";
@@
 describe("safeJsonParse", () => {
+  let errorSpy: ReturnType<typeof vi.spyOn>;
+  beforeEach(() => {
+    errorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
+  });
+  afterEach(() => {
+    errorSpy.mockRestore();
+  });
@@
   it("should return null for invalid JSON", () => {
     const invalidJson = '{name:"test",value:123}'; // missing quotes around property names
     const result = safeJsonParse(invalidJson);
     expect(result).toBeNull();
+    expect(errorSpy).toHaveBeenCalled();
   });
@@
   it("should return null for incomplete JSON", () => {
     const incompleteJson = '{"name":"test",';
     const result = safeJsonParse(incompleteJson);
     expect(result).toBeNull();
+    expect(errorSpy).toHaveBeenCalled();
   });

Also applies to: 17-21, 23-27


2-2: Prefer using the published package entry in shared tests

In packages/shared/test/json.test.ts (line 2), you’re importing the module under test directly from source:

import { safeJsonParse } from "../src/index";

• Since your tsconfig (tooling/tsconfig/base.json) already maps "@ucdjs/shared" to packages/shared/src/index.ts, you can instead write:

import { safeJsonParse } from "@ucdjs/shared";

This approach exercises the package’s export map and will catch any regressions in your published surface.
• If these tests are meant as strict unit tests of internal implementation details, keeping the relative import is fine; otherwise, switching to the alias import is recommended.

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

4-8: Tighten lint disables and add an explicit return type for clarity.

Use a scoped lint disable for console and declare the return type; drop the broad rule disable.

-// eslint-disable-next-line ts/explicit-function-return-type
-export function internal_bingbong() {
-  // eslint-disable-next-line no-console
-  console.log("Bing Bong");
-}
+/**
+ * @internal simple diagnostic hook used in tests
+ */
+export function internal_bingbong(): void {
+  // eslint-disable-next-line no-console
+  console.log("Bing Bong");
+}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cb415e8 and b280007.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (29)
  • .changeset/beige-dogs-roll.md (1 hunks)
  • .changeset/khaki-plums-return.md (1 hunks)
  • .changeset/tangy-days-wait.md (1 hunks)
  • .github/labeler.yml (1 hunks)
  • packages/fs-bridge/package.json (1 hunks)
  • packages/fs-bridge/test/bridges/http.test.ts (1 hunks)
  • packages/fs-bridge/test/bridges/node.test.ts (1 hunks)
  • packages/shared/LICENSE (1 hunks)
  • packages/shared/README.md (1 hunks)
  • packages/shared/eslint.config.js (1 hunks)
  • packages/shared/package.json (1 hunks)
  • packages/shared/src/filter.ts (2 hunks)
  • packages/shared/src/flatten.ts (1 hunks)
  • packages/shared/src/index.ts (1 hunks)
  • packages/shared/src/json.ts (1 hunks)
  • packages/shared/test/json.test.ts (1 hunks)
  • packages/shared/tsconfig.build.json (1 hunks)
  • packages/shared/tsconfig.json (1 hunks)
  • packages/shared/tsdown.config.ts (1 hunks)
  • packages/shared/turbo.json (1 hunks)
  • packages/ucd-store/package.json (1 hunks)
  • packages/ucd-store/src/internal/files.ts (1 hunks)
  • packages/ucd-store/src/store.ts (2 hunks)
  • packages/ucd-store/test/file-operations.test.ts (1 hunks)
  • packages/utils/package.json (1 hunks)
  • packages/utils/src/index.ts (1 hunks)
  • packages/utils/test/index.test.ts (1 hunks)
  • packages/utils/tsdown.config.ts (0 hunks)
  • tooling/tsconfig/base.json (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/utils/tsdown.config.ts
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: luxass
PR: ucdjs/ucd#131
File: tooling/eslint-plugin/package.json:0-0
Timestamp: 2025-07-20T05:37:40.565Z
Learning: In the ucdjs/ucd project, internal tooling packages (private packages in the tooling/ directory) export TypeScript files directly without requiring a build step, unlike published packages which use tsdown to build and export from ./dist/. Examples include ucdjs/tsdown-config and ucdjs/eslint-plugin.
📚 Learning: 2025-06-29T11:20:13.668Z
Learnt from: luxass
PR: ucdjs/ucd#87
File: packages/worker-shared/tsconfig.build.json:1-4
Timestamp: 2025-06-29T11:20:13.668Z
Learning: In the ucdjs/ucd project, the packages use tsdown instead of tsc for building libraries. The tsconfig.build.json files are primarily for IDE experience and type checking, not for direct compilation, so including "test" directories in these configs doesn't affect build output.

Applied to files:

  • packages/shared/tsconfig.build.json
  • packages/fs-bridge/package.json
  • packages/utils/package.json
  • packages/shared/tsconfig.json
  • packages/shared/tsdown.config.ts
  • tooling/tsconfig/base.json
📚 Learning: 2025-07-20T05:37:40.565Z
Learnt from: luxass
PR: ucdjs/ucd#131
File: tooling/eslint-plugin/package.json:0-0
Timestamp: 2025-07-20T05:37:40.565Z
Learning: In the ucdjs/ucd project, internal tooling packages (private packages in the tooling/ directory) export TypeScript files directly without requiring a build step, unlike published packages which use tsdown to build and export from ./dist/. Examples include ucdjs/tsdown-config and ucdjs/eslint-plugin.

Applied to files:

  • packages/shared/tsconfig.build.json
  • packages/ucd-store/package.json
  • packages/fs-bridge/package.json
  • packages/utils/package.json
  • packages/shared/tsconfig.json
  • packages/shared/tsdown.config.ts
  • tooling/tsconfig/base.json
  • packages/ucd-store/src/store.ts
  • packages/shared/package.json
📚 Learning: 2025-06-09T05:10:32.105Z
Learnt from: luxass
PR: ucdjs/ucd#45
File: packages/ucd-store/src/download.ts:24-24
Timestamp: 2025-06-09T05:10:32.105Z
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.

Applied to files:

  • packages/ucd-store/package.json
  • packages/shared/src/flatten.ts
  • packages/ucd-store/test/file-operations.test.ts
  • packages/shared/src/filter.ts
  • packages/shared/README.md
  • packages/ucd-store/src/store.ts
  • packages/ucd-store/src/internal/files.ts
  • packages/utils/src/index.ts
📚 Learning: 2025-06-14T05:20:20.149Z
Learnt from: luxass
PR: ucdjs/ucd#56
File: packages/utils/src/ucd-files/validate.ts:115-130
Timestamp: 2025-06-14T05:20:20.149Z
Learning: Node.js 22 supports the `recursive` option in `fs.readdir()` (introduced in Node.js 18.17.0), which returns a flattened string array of all descendant files and directories when `recursive: true` is passed.

Applied to files:

  • packages/shared/src/flatten.ts
📚 Learning: 2025-07-13T09:23:43.820Z
Learnt from: luxass
PR: ucdjs/ucd#107
File: apps/api/src/routes/v1_files.ts:18-32
Timestamp: 2025-07-13T09:23:43.820Z
Learning: UNICODE_STABLE_VERSION from luxass/unicode-utils-new refers to a specific Unicode version string (not a dynamic value), and the validation logic in the files API correctly checks the normalized version (after "latest" substitution) against UNICODE_VERSION_METADATA rather than the mappedVersion from resolveUCDVersion().

Applied to files:

  • packages/ucd-store/test/file-operations.test.ts
🧬 Code graph analysis (4)
packages/shared/test/json.test.ts (2)
packages/shared/src/index.ts (1)
  • safeJsonParse (4-4)
packages/shared/src/json.ts (1)
  • safeJsonParse (9-16)
packages/shared/tsdown.config.ts (1)
tooling/tsdown-config/src/factory.ts (1)
  • createTsdownConfig (25-31)
packages/shared/src/json.ts (1)
packages/shared/src/index.ts (1)
  • safeJsonParse (4-4)
packages/utils/test/index.test.ts (1)
packages/utils/src/index.ts (1)
  • internal_bingbong (5-8)
🪛 LanguageTool
packages/shared/README.md

[grammar] ~61-~61: There might be a mistake here.
Context: ...E_HTML_FILES ]); ``` Available filters: - EXCLUDE_TEST_FILES: Excludes files containing "Test" in th...

(QB_NEW_EN)


[grammar] ~62-~62: There might be a mistake here.
Context: ...es files containing "Test" in their name - EXCLUDE_README_FILES: Excludes ReadMe.txt files - `EXCLUDE_H...

(QB_NEW_EN)


[grammar] ~63-~63: There might be a mistake here.
Context: ...README_FILES: Excludes ReadMe.txt files - EXCLUDE_HTML_FILES`: Excludes all HTML files ## 📄 License...

(QB_NEW_EN)


[grammar] ~66-~66: There might be a mistake here.
Context: ...: Excludes all HTML files ## 📄 License Published under MIT License....

(QB_NEW_EN)

🪛 Biome (2.1.2)
tooling/tsconfig/base.json

[error] 15-15: Expected a property but instead found '// utility packages'.

Expected a property here.

(parse)


[error] 16-16: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 16-16: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 16-16: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 16-16: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 17-17: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 17-17: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 17-17: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)

🔇 Additional comments (20)
packages/shared/tsconfig.json (1)

1-5: TS config aligns with repo conventions.

Extends the shared base, includes src and tests, and excludes dist. Matches prior learnings about tsdown handling builds. No issues.

packages/shared/tsconfig.build.json (1)

1-5: Build-time tsconfig is minimal and correct.

Extends base.build, scopes to src, excludes dist. This fits the tsdown workflow where tsc is for types/IDE. LGTM.

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

137-148: Confirm case-insensitive matching is intended across platforms.

nocase: true makes matches case-insensitive even on case-sensitive filesystems. If patterns like *.TXT should not match file.txt on POSIX, consider making this configurable (defaulting to current behavior for backward compatibility).

Would you like a PR option (e.g., FilterOptions.picomatch?: picomatch.Options) to override matcher flags? I can wire that in without breaking changes.

packages/shared/src/flatten.ts (1)

13-13: Docs: example import updated to @ucdjs/shared — looks good.
Matches the new package split and will help consumers migrate smoothly.

packages/ucd-store/package.json (1)

51-51: Verification complete: no lingering @ucdjs/utils imports
Ran rg -n --type=ts -C2 -g 'packages/ucd-store/**' -P '\@ucdjs/utils' against the ucd-store directory; no matches were found. The switch to @ucdjs/shared is safe to merge.

packages/fs-bridge/package.json (1)

52-52: @ucdjs/shared devDependency usage is correct

The verification shows that:

  • No runtime code under packages/fs-bridge/src/ imports @ucdjs/shared.
  • All usages are confined to test files:
    • packages/fs-bridge/test/bridges/node.test.ts
    • packages/fs-bridge/test/bridges/http.test.ts

Since @ucdjs/shared is only used in tests, keeping it as a devDependency is appropriate.

.github/labeler.yml (1)

35-37: Label “pkg: shared” added — good coverage for the new package.
Keeps triage consistent with other package labels.

packages/shared/eslint.config.js (1)

1-7: LGTM on flat ESLint config wiring

Config matches the repo’s flat-config style and correctly sets { type: "lib", pnpm: true }. No issues found.

packages/shared/tsdown.config.ts (2)

1-7: Config is correct and explicit entry is fine

createTsdownConfig with an explicit entry of ./src/index.ts aligns with tsdown defaults and the shared package surface.


1-7: Exports configuration verified – no changes required

– packages/shared/package.json correctly points its main, module, types, and exports entries at ./dist/….
– tsdown.config.ts’s entry: ["./src/index.ts"] is correct and will produce the expected dist/index.js and dist/index.d.ts.

No further adjustments needed here.

.changeset/tangy-days-wait.md (1)

1-12: LGTM: clear introduction of the internal shared package

Messaging is crisp about internal status and scope. No changes requested.

packages/shared/package.json (1)

31-33: Consistent Node engine requirement across packages
The Node.js engine floor is set to “>=22.17” in every package that specifies an engines.node field—from the root package.json through packages/shared and all other published packages. No outliers were identified. You can leave the engines spec in packages/shared/package.json as-is.

packages/fs-bridge/test/bridges/http.test.ts (1)

3-3: Import source migration verified – no stale imports detected.
A repository-wide search across .ts, .tsx, .js, .mjs, and .cjs files for any imports of flattenFilePaths, safeJsonParse, or createPathFilter from @ucdjs/utils returned no results. The new import from @ucdjs/shared is the sole reference. Changes are approved.

packages/ucd-store/test/file-operations.test.ts (1)

5-5: Approve migration of file-operations tests to @ucdjs/shared

  • Verified that running the provided ripgrep command returns no remaining imports of flattenFilePaths, safeJsonParse, or createPathFilter from @ucdjs/utils anywhere under packages/ucd-store/.
  • All tests now consistently import these utilities from @ucdjs/shared, matching the intended migration with no behavioral changes.
packages/fs-bridge/test/bridges/node.test.ts (1)

1-1: LGTM: updated import path to @ucdjs/shared.

No other changes; tests still read cleanly.

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

3-3: Dependency & Export Wiring for @ucdjs/shared Verified

  • In packages/ucd-store/package.json, @ucdjs/shared is declared as a runtime dependency ("workspace:*").
  • In packages/shared/src/index.ts, flattenFilePaths is correctly re-exported.
  • In tooling/tsconfig/base.json, the path alias "@ucdjs/shared": ["./packages/shared/src/index.ts"] is present.

All wiring checks out—approving the changes.

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

4-4: No residual @ucdjs/utils imports; @ucdjs/shared exports validated

Verification steps completed successfully:

  • Searched throughout packages/ucd-store for any imports from “@ucdjs/utils”—no matches were found.
  • Confirmed in packages/shared/src/index.ts that
    • createPathFilter is exported (line 1)
    • flattenFilePaths is exported (line 3)
    • safeJsonParse is exported (line 4)

All three utilities are properly provided by @ucdjs/shared, and there are no remaining stragglers from @ucdjs/utils. You can proceed with the consolidation as planned.

packages/utils/package.json (1)

42-43: Release hygiene confirmed for @ucdjs/utils

Verified that packages/utils/src/index.ts now simply re-exports the exact same public symbols—createPathFilter, PRECONFIGURED_FILTERS, FilterOptions, and PathFilter—from @ucdjs/shared, and that the existing export function internal_bingbong() remains unchanged. The API surface has neither added nor removed exports.

A patch-level changeset for @ucdjs/utils is present (see .changeset/curly-states-pick.md), so release hygiene is satisfied and no further version bump is required.

packages/shared/src/index.ts (1)

1-4: Public API surface looks good.

Type-only exports are correctly separated; value exports are minimal and focused. No issues spotted.

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

1-2: Check backwards-compatibility of removed utils exports

We searched the monorepo and confirmed:

  • No internal code imports flattenFilePaths or safeJsonParse from @ucdjs/utils.
  • These utilities are consumed directly from @ucdjs/shared elsewhere (e.g. ucd-store, fs-bridge).
  • The utils package is currently at version 0.1.0 (pre-1.0).

Removing the direct exports of flattenFilePaths and safeJsonParse from @ucdjs/utils will not break internal packages, but will break any external consumers who imported them from @ucdjs/utils. You have two paths forward:

• If you intend to maintain a stable public API until a 1.0.0 release, add these pass-through exports now:

 export { createPathFilter, PRECONFIGURED_FILTERS } from "@ucdjs/shared";
 export type { FilterOptions, PathFilter } from "@ucdjs/shared";
+export { flattenFilePaths, safeJsonParse } from "@ucdjs/shared";

• Otherwise, treat this as a breaking change: document it in your CHANGELOG, bump utils to 1.0.0, and remove the exports.

Please verify whether any downstream projects rely on these exports and decide on the appropriate semver strategy.

@luxass luxass merged commit d0e1fb9 into main Aug 22, 2025
10 checks passed
@luxass luxass deleted the shared-package branch August 22, 2025 03:06
@luxass luxass mentioned this pull request Aug 22, 2025
@coderabbitai coderabbitai bot mentioned this pull request Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: fs-bridge Changes related to the FS Bridge 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.

1 participant