Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change!: split entry points into client / node #156

Merged
merged 3 commits into from
Jan 20, 2025

Conversation

enzonotario
Copy link
Owner

Description

Copy link

vercel bot commented Jan 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
vitepress-openapi ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 20, 2025 7:26pm

Copy link
Contributor

coderabbitai bot commented Jan 17, 2025

Walkthrough

The pull request introduces a restructuring of the vitepress-openapi package, focusing on modularizing the library's imports and exports. The changes primarily involve shifting import paths from vitepress-openapi to vitepress-openapi/client, updating build configurations, and introducing new optional parameters for OpenAPI instance creation. The modifications affect multiple files across documentation, source code, and configuration, aiming to provide more granular and flexible module imports.

Changes

File/Path Change Summary
package.json Updated exports and main/module fields to support new client-specific exports.
vite.config.ts Modified library build configuration with multiple entry points and dynamic file naming.
src/client.ts New file introducing enhanced app integration with OpenAPI and internationalization support.
Multiple documentation files Updated import statements from vitepress-openapi to vitepress-openapi/client.
src/composables/useOpenapi.ts, src/composables/usePaths.ts Added optional defaultTag and defaultTagDescription parameters.
src/lib/prepareOpenAPI/generateMissingTags.ts, src/lib/prepareOpenAPI/prepareOpenAPI.ts Updated functions to handle new tag-related parameters.
docs/.vitepress/config.mts, docs/.vitepress/theme/components/sandbox/Sandbox.vue, docs/.vitepress/theme/components/theme/ThemeConfig.vue, docs/.vitepress/theme/components/theme/ThemeConfigPopover.vue, docs/.vitepress/theme/index.ts, docs/composables/usePlayground.md, docs/composables/useTheme.md, docs/customizations/i18n.md, docs/customizations/operation-badges.md, docs/customizations/parts/code-samples-example.md, docs/customizations/parts/operation-badges-example.md, docs/customizations/parts/operation-tags-slot-example.md, docs/examples/[exampleSlug].md, docs/guide/getting-started.md, docs/sidebar/sidebar-items.md, docs/tests/[testSlug].md Various updates to import paths for useTheme, useOpenapi, and related components from vitepress-openapi to vitepress-openapi/client.
src/lib/createOpenApiInstance.ts Modified createOpenApiInstance to accept new optional parameters.
src/lib/prepareOpenAPI/generateMissingTags.ts Updated to accept an object parameter including spec, defaultTag, and defaultTagDescription.
src/lib/prepareOpenAPI/prepareOpenAPI.ts Changed to accept an object parameter instead of a single spec argument.
src/composables/useSidebar.ts Removed calls to useTheme and useOpenapi, encapsulated OpenAPI instance initialization.
src/index.ts Removed multiple imports, interfaces, and constants related to theme enhancement.

Sequence Diagram

sequenceDiagram
    participant App as Application
    participant Client as vitepress-openapi/client
    participant OpenAPI as OpenAPI Instance
    participant Theme as Theme Configuration

    App->>Client: Import modules
    Client->>OpenAPI: Create instance with optional defaults
    Client->>Theme: Initialize configuration
    Theme-->>Client: Return theme settings
    Client->>App: Provide enhanced functionality
Loading

Possibly related PRs


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1230a27 and 4f0e369.

📒 Files selected for processing (1)
  • package.json (2 hunks)
🔇 Additional comments (2)
package.json (2)

43-44: LGTM! Improved development workflow.

The script changes improve the development workflow by:

  1. Ensuring the dev server runs from the correct directory
  2. Building the main package before building docs

20-25: LGTM! Export configuration properly separates client and node entry points.

The export configuration correctly implements the split between client and node entry points, with proper type definitions for each.

Let's verify the type definition files exist:


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

Copy link

pkg-pr-new bot commented Jan 17, 2025

Open in Stackblitz

npm i https://pkg.pr.new/vitepress-openapi@156

commit: 4f0e369

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5a9bfce and d35a75e.

📒 Files selected for processing (27)
  • docs/.vitepress/config.mts (1 hunks)
  • docs/.vitepress/theme/components/sandbox/Sandbox.vue (1 hunks)
  • docs/.vitepress/theme/components/theme/ThemeConfig.vue (1 hunks)
  • docs/.vitepress/theme/components/theme/ThemeConfigPopover.vue (0 hunks)
  • docs/.vitepress/theme/index.ts (1 hunks)
  • docs/composables/usePlayground.md (1 hunks)
  • docs/composables/useTheme.md (1 hunks)
  • docs/customizations/i18n.md (2 hunks)
  • docs/customizations/operation-badges.md (1 hunks)
  • docs/customizations/parts/code-samples-example.md (1 hunks)
  • docs/customizations/parts/operation-badges-example.md (1 hunks)
  • docs/customizations/parts/operation-tags-slot-example.md (1 hunks)
  • docs/examples/[exampleSlug].md (1 hunks)
  • docs/guide/getting-started.md (7 hunks)
  • docs/sidebar/sidebar-items.md (3 hunks)
  • docs/tests/[testSlug].md (1 hunks)
  • package.json (1 hunks)
  • src/client.ts (1 hunks)
  • src/composables/useOpenapi.ts (1 hunks)
  • src/composables/usePaths.ts (1 hunks)
  • src/composables/useSidebar.ts (7 hunks)
  • src/index.ts (0 hunks)
  • src/lib/createOpenApiInstance.ts (1 hunks)
  • src/lib/prepareOpenAPI/generateMissingTags.ts (2 hunks)
  • src/lib/prepareOpenAPI/prepareOpenAPI.ts (2 hunks)
  • test/lib/prepareOpenAPI/generateMissingTags.test.ts (5 hunks)
  • vite.config.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • docs/.vitepress/theme/components/theme/ThemeConfigPopover.vue
  • src/index.ts
🔇 Additional comments (27)
src/lib/createOpenApiInstance.ts (1)

8-15: LGTM!

The addition of optional parameters defaultTag and defaultTagDescription enhances the configurability of createOpenApiInstance. Implementation looks correct.

vite.config.ts (1)

11-14: Verify the entry point paths and their exports.

The split into client/node entry points looks good, but we should ensure that each entry point exports the correct modules.

✅ Verification successful

Entry point exports are properly separated and aligned with their purposes

The client bundle exports UI-related composables and code generation utilities, while the node bundle focuses on core functionality and navigation. The shared OpenApi class is correctly exported in both bundles.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check exports in both entry points
echo "Checking client exports..."
ast-grep --pattern 'export { $$$ }' src/client.ts

echo "Checking node exports..."
ast-grep --pattern 'export { $$$ }' src/index.ts

Length of output: 1183

docs/.vitepress/theme/index.ts (1)

1-1: Verify all import paths are updated consistently.

The import path has been updated to use the new client subpath. We should verify that all other imports in the codebase are updated consistently.

✅ Verification successful

Import path update verified - no other imports found

The import in docs/.vitepress/theme/index.ts is the only instance of importing from vitepress-openapi in the codebase. No consistency issues to address.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find any remaining direct imports that need updating
rg "from 'vitepress-openapi'" --type ts

Length of output: 47


Script:

#!/bin/bash
# Search for any mention of vitepress-openapi package
rg "vitepress-openapi" --type ts -A 1

# Also search for any import statements in the docs directory
fd . docs -e ts -x grep -l "import.*from.*vitepress-openapi"

Length of output: 287

src/composables/usePaths.ts (2)

7-8: LGTM! Good use of optional parameters.

The new parameters are properly typed and maintain backward compatibility.

Also applies to: 11-12


14-21: Verify error handling for invalid tag values.

The OpenApi initialization looks good, but we should ensure proper error handling for invalid tag values.

src/lib/prepareOpenAPI/generateMissingTags.ts (1)

3-11: Good refactoring to remove theme dependency.

The function signature change improves maintainability by removing the theme dependency and providing explicit parameters.

src/lib/prepareOpenAPI/prepareOpenAPI.ts (2)

6-14: LGTM! Well-structured parameter object pattern.

The change to use a parameter object pattern with optional parameters improves the function's extensibility while maintaining backward compatibility.


31-31: LGTM! Consistent parameter passing.

The update to generateMissingTags call correctly passes all parameters from the new signature.

test/lib/prepareOpenAPI/generateMissingTags.test.ts (1)

13-13: LGTM! Tests updated consistently.

All test cases have been properly updated to use the new parameter object pattern while maintaining comprehensive coverage of functionality.

Also applies to: 27-27, 40-40, 60-60, 72-72

src/composables/useOpenapi.ts (1)

50-54: LGTM! Proper integration with theme configuration.

The update correctly passes optional parameters from the theme configuration while maintaining type safety.

docs/.vitepress/theme/components/sandbox/Sandbox.vue (1)

4-4: Verify consistent import path updates across the codebase.

The import path has been updated to use the new client entry point.

Let's verify that all client-side imports have been consistently updated:

✅ Verification successful

Import paths are correctly organized based on functionality

The import paths are consistently used across the codebase with a clear separation:

  • vitepress-openapi/client for UI components and client-side functionality
  • vitepress-openapi for server-side and data operations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining imports from the old path
rg "from 'vitepress-openapi'" --type ts --type vue

# Search for new client imports to ensure consistency
rg "from 'vitepress-openapi/client'" --type ts --type vue

Length of output: 180


Script:

#!/bin/bash
# Search for any imports from vitepress-openapi with surrounding context
echo "=== Old import pattern ==="
rg -A 2 "from ['\"](vitepress-openapi)['\"]"

echo -e "\n=== New client import pattern ==="
rg -A 2 "from ['\"](vitepress-openapi/client)['\"]"

echo -e "\n=== Any other vitepress-openapi imports ==="
rg -A 2 "from ['\"](vitepress-openapi/.*)['\"]"

Length of output: 10036

docs/.vitepress/config.mts (1)

240-247: LGTM! Proper alias configuration for the new client entry point.

The conditional alias configuration correctly handles both production and development environments, with proper path resolution for the new client module.

Let's verify the path resolution:

✅ Verification successful

✅ Path resolution verified - both entry points exist

The alias configuration correctly maps to existing files:

  • src/index.ts for main entry point
  • src/client.ts for client entry point
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the existence of client entry point and its imports
fd -t f "index.(ts|js|mts|mjs)" src/
fd -t f "client.(ts|js|mts|mjs)" src/

Length of output: 424

docs/.vitepress/theme/components/theme/ThemeConfig.vue (1)

2-2: LGTM! Proper import from the new client entry point.

The import statement has been correctly updated to use the new client module, consolidating related imports from the same path.

docs/customizations/parts/operation-badges-example.md (1)

3-3: LGTM! Consistent import path update.

The import statement has been correctly updated to use the new client module, maintaining consistency with other files.

docs/customizations/parts/operation-tags-slot-example.md (1)

3-3: LGTM! Consistent import path update with proper consolidation.

The import statement has been correctly updated to use the new client module, consolidating related imports from the same path.

docs/tests/[testSlug].md (1)

10-10: Verify the new client import path.

The import path change aligns with the module split objective.

Let's verify the new import path exists:

✅ Verification successful

Import path verification successful

The useTheme import from 'vitepress-openapi/client' is correctly configured and exported from the client entry point.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the client module exports useTheme
rg -l "export.*useTheme" "src/client.ts"

Length of output: 54


Script:

#!/bin/bash
# Check the actual export of useTheme
rg "export.*useTheme" "src/client.ts" -A 2

Length of output: 177

docs/examples/[exampleSlug].md (1)

10-10: LGTM! Import path change is consistent.

The update to use the client module is consistent with the module split strategy.

docs/composables/usePlayground.md (1)

8-8: Documentation accurately reflects new import path.

The example code has been properly updated to use the new client module path.

Verify the usePlayground export:

✅ Verification successful

Export chain verified: usePlayground is correctly exported and documented

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the client module exports usePlayground
rg -l "export.*usePlayground" "src/client.ts"

Length of output: 59


Script:

#!/bin/bash
# Check the actual export statement and implementation
rg "export.*usePlayground" "src/client.ts" -A 5

Length of output: 391


Script:

#!/bin/bash
# Verify source file exists and exports usePlayground
rg "export.*function usePlayground" "src/composables/usePlayground.ts" -A 1

Length of output: 199

docs/customizations/parts/code-samples-example.md (1)

3-3: Verify multiple exports from client module.

The import combines multiple functions from the client module.

Verify both exports exist in client module:

✅ Verification successful

Both exports are correctly available from the client module

Both useTheme and generateCodeSample functions are properly exported through the client module, making the import statement valid.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify both functions are exported from client
rg -l "export.*\{.*generateCodeSample.*useTheme" "src/client.ts"

Length of output: 64


Script:

#!/bin/bash
# Search for individual exports and definitions
echo "=== Searching for useTheme ==="
rg "export.*useTheme" -A 2
ast-grep --pattern "export function useTheme"

echo -e "\n=== Searching for generateCodeSample ==="
rg "export.*generateCodeSample" -A 2
ast-grep --pattern "export function generateCodeSample"

echo -e "\n=== Searching for potential re-exports from client.ts ==="
rg "export.*from" src/client.ts

Length of output: 3011

docs/customizations/operation-badges.md (1)

44-44: Verify comprehensive client module exports.

The import includes core functionality (theme, useTheme) and localization support.

Verify all required exports exist:

✅ Verification successful

All required exports are available in the client module

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the client module exports all required elements
rg -l "export.*\{.*locales.*theme.*useTheme" "src/client.ts"

Length of output: 60


Script:

#!/bin/bash
# Search for individual exports
echo "=== Searching for locales export ==="
rg "export.*locales" -A 2

echo "=== Searching for theme export ==="
rg "export.*theme" -A 2

echo "=== Searching for useTheme export ==="
rg "export.*useTheme" -A 2

# Use ast-grep to find export declarations
echo "=== AST-based export search ==="
ast-grep --pattern 'export { $$ }'

Length of output: 1088

package.json (1)

29-30: Verify compatibility with build tools

The main/module fields now point to node-specific builds. Ensure this doesn't affect build tools or bundlers that rely on these fields.

docs/customizations/i18n.md (1)

12-12: Import path updated correctly

The import statement has been properly updated to use the new client submodule.

docs/sidebar/sidebar-items.md (1)

23-23: Import paths consistently updated

All import statements have been correctly updated to use the new client submodule across multiple examples.

Also applies to: 63-63, 103-103

docs/guide/getting-started.md (3)

61-61: Documentation updated for new module structure

Import statements in the basic setup examples have been correctly updated to use the client submodule.

Also applies to: 76-76


104-105: Enhanced configuration example with openapi instance

The documentation now correctly shows how to use the useOpenapi composable with the new module structure.

Also applies to: 129-130


286-286: Markdown examples updated consistently

Import statements in markdown examples have been properly updated to use the client submodule.

Also applies to: 308-308

docs/composables/useTheme.md (1)

8-8: Import path updated with maintained documentation

The import statement has been properly updated while preserving the detailed documentation of theme configuration options.

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

♻️ Duplicate comments (3)
src/lib/prepareOpenAPI/generateMissingTags.ts (1)

31-31: 🧹 Nitpick (assertive)

Consider adding validation for defaultTagDescription

While the implementation is correct, consider adding validation to ensure defaultTagDescription is a string.

-      description: defaultTagDescription,
+      description: typeof defaultTagDescription === 'string' ? defaultTagDescription : '',
src/client.ts (1)

34-34: 🧹 Nitpick (assertive)

Avoid using 'any' type for the 'i18n' instance.

Using any defeats the purpose of TypeScript's type checking. Consider properly typing the i18n instance.

Apply this diff:

-        const i18n: any = VueI18n.createI18n({
+        const i18n = VueI18n.createI18n({
src/composables/useSidebar.ts (1)

58-59: 🧹 Nitpick (assertive)

Enhance the error message when OpenAPI spec is missing.

Provide a more descriptive error message to help developers understand the issue and how to fix it.

Apply this diff:

          if (!spec) {
-           throw new Error('OpenAPI spec is not provided.')
+           throw new Error('OpenAPI specification is required but was not provided to useSidebar(). Please provide a valid spec.')
          }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d35a75e and f3c984d.

📒 Files selected for processing (27)
  • docs/.vitepress/config.mts (1 hunks)
  • docs/.vitepress/theme/components/sandbox/Sandbox.vue (1 hunks)
  • docs/.vitepress/theme/components/theme/ThemeConfig.vue (1 hunks)
  • docs/.vitepress/theme/components/theme/ThemeConfigPopover.vue (0 hunks)
  • docs/.vitepress/theme/index.ts (1 hunks)
  • docs/composables/usePlayground.md (1 hunks)
  • docs/composables/useTheme.md (1 hunks)
  • docs/customizations/i18n.md (2 hunks)
  • docs/customizations/operation-badges.md (1 hunks)
  • docs/customizations/parts/code-samples-example.md (1 hunks)
  • docs/customizations/parts/operation-badges-example.md (1 hunks)
  • docs/customizations/parts/operation-tags-slot-example.md (1 hunks)
  • docs/examples/[exampleSlug].md (1 hunks)
  • docs/guide/getting-started.md (7 hunks)
  • docs/sidebar/sidebar-items.md (3 hunks)
  • docs/tests/[testSlug].md (1 hunks)
  • package.json (1 hunks)
  • src/client.ts (1 hunks)
  • src/composables/useOpenapi.ts (1 hunks)
  • src/composables/usePaths.ts (1 hunks)
  • src/composables/useSidebar.ts (7 hunks)
  • src/index.ts (0 hunks)
  • src/lib/createOpenApiInstance.ts (1 hunks)
  • src/lib/prepareOpenAPI/generateMissingTags.ts (2 hunks)
  • src/lib/prepareOpenAPI/prepareOpenAPI.ts (2 hunks)
  • test/lib/prepareOpenAPI/generateMissingTags.test.ts (5 hunks)
  • vite.config.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • src/index.ts
  • docs/.vitepress/theme/components/theme/ThemeConfigPopover.vue
🔇 Additional comments (22)
src/lib/createOpenApiInstance.ts (2)

15-17: LGTM: Parameters properly forwarded

The parameters are correctly forwarded to prepareOpenAPI while maintaining the original spec in the return value.


8-9: Breaking change: New optional parameters added

The addition of defaultTag and defaultTagDescription parameters is a breaking change that needs to be documented in the changelog and migration guide.

Please ensure all consumers of this function are updated to handle these new parameters. Let's verify the usage:

Also applies to: 12-13

src/composables/usePaths.ts (1)

7-8: LGTM: Consistent parameter handling

The optional parameters match the pattern established in createOpenApiInstance, maintaining consistency across the codebase.

Also applies to: 11-12

src/lib/prepareOpenAPI/generateMissingTags.ts (1)

3-11: LGTM: Well-structured parameter object

The function signature change to use an object parameter with defaults is a good practice for maintainability.

src/lib/prepareOpenAPI/prepareOpenAPI.ts (2)

6-14: LGTM: Consistent parameter structure

The parameter structure matches the pattern used in other files, maintaining consistency across the codebase.


31-31: 🧹 Nitpick (assertive)

Consider destructuring parameters

The parameter passing could be simplified for better readability.

-    spec = generateMissingTags({ spec, defaultTag, defaultTagDescription })
+    spec = generateMissingTags({ spec, defaultTag, defaultTagDescription })

Likely invalid or redundant comment.

vite.config.ts (1)

16-16: Document the breaking change in output file naming convention.

The change in the output file naming pattern from vitepress-openapi.${format}.js to vitepress-openapi.${entryName}.${format}.js is a breaking change that needs to be documented. Please make sure to:

  • Add documentation about the output file naming convention in the getting started guide.
  • Document this as a breaking change if upgrading from a previous version.
  • Include migration steps if users directly reference these files.

Run the following script to check if the documentation includes the new output file naming convention and mentions the breaking change:

#!/bin/bash
# Description: Check for documentation of the new output file naming convention and breaking changes.

# Search for mentions of the new file naming convention in markdown files.
fd -e md | xargs rg 'vitepress-openapi\.\{entryName\}\.\{format\}\.js'

# Search for mentions of breaking changes or migration guides.
fd -e md | xargs rg -i 'breaking changes|migration guide|upgrade instructions'
docs/.vitepress/theme/components/theme/ThemeConfig.vue (1)

2-2: LGTM! Imports consolidated correctly.

The imports have been properly consolidated and updated to use the new client-specific module path.

docs/customizations/parts/operation-badges-example.md (1)

3-3: LGTM! Documentation example updated correctly.

The import path has been properly updated in the documentation example, maintaining consistency with the new package structure.

docs/tests/[testSlug].md (1)

10-10: Verify the breaking change impact on consumers.

The import path change from 'vitepress-openapi' to 'vitepress-openapi/client' represents a breaking change that will require updates from package consumers.

✅ Verification successful

Import path change is correctly implemented

The import path change for useTheme to 'vitepress-openapi/client' is consistent across the codebase. The remaining imports from 'vitepress-openapi' are for a different function (usePaths) and appear to be intentionally using the main package path.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining old import paths that need updating
rg "from 'vitepress-openapi'" -g '!node_modules'

Length of output: 364

docs/examples/[exampleSlug].md (1)

10-10: Import path change is consistent.

The update to import from 'vitepress-openapi/client' maintains consistency with the new package structure.

docs/composables/usePlayground.md (1)

8-8: Documentation is up to date.

The example code correctly demonstrates the new import path from 'vitepress-openapi/client'.

docs/customizations/operation-badges.md (1)

44-44: LGTM! Import statement correctly updated.

The import path has been updated to use the new client module, which aligns with the breaking change of splitting entry points.

docs/customizations/i18n.md (1)

12-12: LGTM! Import statements correctly updated.

The import paths have been consistently updated to use the new client module throughout the file.

Also applies to: 47-47

package.json (1)

29-30: LGTM! Main and module fields updated consistently.

The main and module fields have been updated to point to the node build, which is consistent with the new entry points structure.

docs/sidebar/sidebar-items.md (1)

23-23: LGTM! Import statements correctly updated.

All import statements have been consistently updated to use the new client module throughout the documentation.

Also applies to: 63-63, 103-103

docs/.vitepress/config.mts (1)

240-247: LGTM! Development aliases configured correctly.

The Vite configuration properly handles module resolution:

  • Adds development-only aliases for both client and root package
  • Maintains clean production builds without aliases
docs/guide/getting-started.md (4)

61-61: LGTM: Import path updated correctly

The import path has been updated to use the new client-specific entry point.


76-76: LGTM: TypeScript import path updated correctly

The TypeScript version of the import statement has been correctly updated.


104-105: LGTM: Import statements consolidated and updated

The import statements have been properly consolidated and updated to use the new client entry point.


129-130: LGTM: TypeScript imports updated correctly

The TypeScript version of the imports has been properly updated to use the new client entry point.

docs/composables/useTheme.md (1)

8-8: LGTM: Import path updated correctly

The import path has been properly updated to use the new client entry point.

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)
docs/customizations/parts/code-samples-example.md (1)

Line range hint 31-48: Consider extracting Bruno request generation logic.

The generateBruRequest function could be moved to a separate utility file for better maintainability and potential reuse.

🧰 Tools
🪛 Markdownlint (0.37.0)

1-1: Element: script
Inline HTML

(MD033, no-inline-html)


1-1: null
First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

docs/guide/getting-started.md (1)

Line range hint 44-44: Document the breaking change in the Usage section.

Consider adding a note about the entry point split to help users understand and adapt to this breaking change.

Add this note at the beginning of the Usage section:

 ## Usage
+
+> **Breaking Change**: As of version 0.0.3-alpha.57, vitepress-openapi has split its entry points into `client` and `node` modules. The examples below use the new `client` entry point.
 
 In your `.vitepress/theme/index.[js,ts]`, import the theme and the CSS file.
♻️ Duplicate comments (4)
src/composables/useSidebar.ts (1)

59-59: 🧹 Nitpick (assertive)

Enhance the error message when OpenAPI spec is missing

Provide a more descriptive error message to help developers understand the issue and how to fix it.

Apply this diff to improve the error message:

          if (!spec) {
-            throw new Error('OpenAPI spec is not provided.')
+            throw new Error('OpenAPI specification is required but was not provided to useSidebar(). Please provide a valid spec.')
          }
src/composables/usePaths.ts (1)

14-21: 🧹 Nitpick (assertive)

Simplify the prepareOpenAPI function call

The nested object creation can be simplified for improved readability by destructuring the parameters into a single object.

Apply this diff to simplify the code:

      const openapi = OpenApi({
        spec,
-       transformedSpec: prepareOpenAPI({
-         spec,
-         defaultTag,
-         defaultTagDescription,
-       }),
+       transformedSpec: prepareOpenAPI({ spec, defaultTag, defaultTagDescription }),
      })
src/client.ts (1)

34-34: 🛠️ Refactor suggestion

Avoid using 'any' type for the 'i18n' instance.

Using any defeats the purpose of TypeScript's type checking. Consider properly typing the i18n instance to enhance type safety.

Apply this diff to fix the issue:

- const i18n: any = VueI18n.createI18n({
+ const i18n = VueI18n.createI18n({
vite.config.ts (1)

16-16: ⚠️ Potential issue

Document the breaking change in output file naming convention.

The change in the output file naming pattern from vitepress-openapi.${format}.js to vitepress-openapi.${entryName}.${format}.js is a breaking change that needs to be documented. Please update the documentation to inform users about the new file naming convention and provide migration steps if necessary.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f3c984d and f45f99a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (27)
  • docs/.vitepress/config.mts (2 hunks)
  • docs/.vitepress/theme/components/sandbox/Sandbox.vue (1 hunks)
  • docs/.vitepress/theme/components/theme/ThemeConfig.vue (1 hunks)
  • docs/.vitepress/theme/components/theme/ThemeConfigPopover.vue (0 hunks)
  • docs/.vitepress/theme/index.ts (1 hunks)
  • docs/composables/usePlayground.md (1 hunks)
  • docs/composables/useTheme.md (1 hunks)
  • docs/customizations/i18n.md (2 hunks)
  • docs/customizations/operation-badges.md (1 hunks)
  • docs/customizations/parts/code-samples-example.md (1 hunks)
  • docs/customizations/parts/operation-badges-example.md (1 hunks)
  • docs/customizations/parts/operation-tags-slot-example.md (1 hunks)
  • docs/examples/[exampleSlug].md (1 hunks)
  • docs/guide/getting-started.md (7 hunks)
  • docs/sidebar/sidebar-items.md (3 hunks)
  • docs/tests/[testSlug].md (1 hunks)
  • package.json (3 hunks)
  • src/client.ts (1 hunks)
  • src/composables/useOpenapi.ts (1 hunks)
  • src/composables/usePaths.ts (1 hunks)
  • src/composables/useSidebar.ts (7 hunks)
  • src/index.ts (0 hunks)
  • src/lib/createOpenApiInstance.ts (1 hunks)
  • src/lib/prepareOpenAPI/generateMissingTags.ts (2 hunks)
  • src/lib/prepareOpenAPI/prepareOpenAPI.ts (2 hunks)
  • test/lib/prepareOpenAPI/generateMissingTags.test.ts (5 hunks)
  • vite.config.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • docs/.vitepress/theme/components/theme/ThemeConfigPopover.vue
  • src/index.ts
🔇 Additional comments (25)
src/lib/createOpenApiInstance.ts (1)

8-13: Extension of functionality with optional parameters

The addition of defaultTag and defaultTagDescription parameters enhances the flexibility of createOpenApiInstance. The implementation correctly updates the function signature and passes the parameters to prepareOpenAPI.

src/lib/prepareOpenAPI/generateMissingTags.ts (2)

3-11: LGTM! Parameter restructuring improves extensibility.

The change to use an object parameter with optional fields makes the function more maintainable and easier to extend in the future.


31-31: Consider adding validation for defaultTagDescription.

While the implementation is correct, consider adding validation to ensure defaultTagDescription is a string.

-      description: defaultTagDescription,
+      description: typeof defaultTagDescription === 'string' ? defaultTagDescription : '',
src/lib/prepareOpenAPI/prepareOpenAPI.ts (1)

31-31: LGTM! Proper parameter forwarding.

The parameters are correctly forwarded to generateMissingTags, maintaining type safety.

src/composables/useOpenapi.ts (1)

50-54: LGTM! Consider documenting the new parameters.

The implementation looks good with proper optional chaining for the new parameters. Consider adding JSDoc comments to document the purpose and expected values of defaultTag and defaultTagDescription.

   function addSchema({ id, spec, config }: { id: string, spec: OpenAPI.Document, config?: PartialUseThemeConfig }) {
+    /**
+     * Creates an OpenAPI instance with optional default tag configuration
+     * @param {Object} options
+     * @param {OpenAPI.Document} options.spec - The OpenAPI specification
+     * @param {string} [options.defaultTag] - Default tag for operations without tags
+     * @param {string} [options.defaultTagDescription] - Description for the default tag
+     */
     const openapi = createOpenApiInstance({
test/lib/prepareOpenAPI/generateMissingTags.test.ts (1)

76-94: LGTM! Good test coverage for new parameters.

The new test case properly validates the custom default tag functionality, ensuring the new parameters work as expected.

docs/sidebar/sidebar-items.md (1)

Line range hint 1-150: Well-structured documentation with comprehensive examples.

The documentation effectively demonstrates the usage of sidebar functionality with:

  • Clear code examples for each use case
  • Interactive previews using sandbox iframes
  • Well-documented optional parameters
  • Visual grid layout for better readability
docs/.vitepress/theme/components/sandbox/Sandbox.vue (1)

4-4: Ensure all import paths are consistently updated across the codebase.

While the import path for useTheme has been correctly updated to vitepress-openapi/client in this file, there may be other files that still import directly from vitepress-openapi. To maintain consistency and prevent potential issues, please verify that all import paths have been updated.

Run the following script to identify any remaining imports that need to be updated:

docs/.vitepress/config.mts (3)

3-3: LGTM! Added i18n plugin import.

The addition of the Vue i18n plugin aligns with the internationalization requirements.


242-243: LGTM! Updated module resolution for split architecture.

The alias configuration correctly maps:

  • vitepress-openapi/client to the client entry point
  • vitepress-openapi to the main entry point

246-250: LGTM! Configured i18n plugin with SSR support.

The Vue i18n plugin is properly configured with SSR enabled.

docs/.vitepress/theme/components/theme/ThemeConfig.vue (1)

2-2: LGTM! Updated import to use client module.

Correctly imports client-side utilities from the new vitepress-openapi/client path.

docs/customizations/parts/operation-badges-example.md (2)

3-3: LGTM! Updated import to use client module.

Correctly imports useTheme from the new client-specific path.


3-3: Documentation updates needed for import paths.

Several documentation files still need to be updated with the new import paths.

docs/customizations/parts/operation-tags-slot-example.md (1)

3-3: LGTM! Updated imports to use client module.

Correctly imports both DEFAULT_OPERATION_SLOTS and useTheme from the new client-specific path.

docs/tests/[testSlug].md (1)

10-10: Import path change looks good.

The updated import path aligns with the new package structure, properly importing from the client entry point.

docs/examples/[exampleSlug].md (1)

10-10: Import path change looks good.

The updated import path aligns with the new package structure, properly importing from the client entry point.

docs/.vitepress/theme/index.ts (1)

1-1: Consider documenting the migration path.

Multiple imports are affected in this core theme file. Since this represents a breaking change, consider:

  1. Adding a migration guide
  2. Documenting the new package structure
  3. Explaining the rationale for client/node split
docs/customizations/parts/code-samples-example.md (1)

3-3: Import path change looks good.

The updated import path aligns with the new package structure, properly importing from the client entry point.

docs/customizations/operation-badges.md (1)

44-44: LGTM! Import path correctly updated.

The import statement has been properly updated to use the new client entry point.

docs/customizations/i18n.md (1)

12-12: LGTM! Import paths correctly updated.

Both import statements have been properly updated to use the new client entry point.

Also applies to: 47-47

package.json (2)

20-25: LGTM! Entry points correctly split into node/client.

The package exports have been properly configured to support separate node and client entry points.


67-67: Verify compatibility with vue-i18n major version update.

The vue-i18n package has been updated from v9 to v11, which is a major version bump. Additionally, a new @intlify/unplugin-vue-i18n dependency has been added.

Run this script to check for breaking changes:

Also applies to: 94-94

✅ Verification successful

The upgrade to vue-i18n v11 is safe

The codebase already uses the recommended Composition API mode and doesn't use any deprecated or removed features. The configuration in src/client.ts is future-proof, and the @intlify/unplugin-vue-i18n v6.0.3 is compatible with vue-i18n v11.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check vue-i18n changelog for breaking changes
gh api graphql -f query='
{
  repository(owner: "intlify", name: "vue-i18n-next") {
    releases(first: 5, orderBy: {field: CREATED_AT, direction: DESC}) {
      nodes {
        tagName
        description
      }
    }
  }
}'

Length of output: 7840


Script:

#!/bin/bash
# Check for v-t directive and tc/tc$ usage
echo "Checking for v-t directive usage..."
rg "v-t" -t vue

echo -e "\nChecking for tc/\$tc usage..."
rg "\btc\s*\(|\$tc\s*\(" -t vue -t js -t ts

echo -e "\nChecking for Legacy API mode patterns..."
rg "new VueI18n|createI18n\s*\(\s*\{[^}]*legacy:\s*true" -t js -t ts

echo -e "\nChecking unplugin-vue-i18n version compatibility..."
rg '"@intlify/unplugin-vue-i18n":\s*"[^"]*"' package.json

Length of output: 661


Script:

#!/bin/bash
# Find i18n config and vue files
echo "Finding relevant files..."
fd -e vue -e js -e ts

echo -e "\nChecking for v-t directive usage..."
rg "v-t" -g '*.vue'

echo -e "\nChecking for tc/\$tc usage..."
rg "\btc\s*\(|\$tc\s*\(" -g '*.{vue,js,ts}'

echo -e "\nChecking for Legacy API mode patterns..."
rg "createI18n.*legacy.*true" -g '*.{js,ts}'

echo -e "\nChecking i18n configuration..."
rg "createI18n" -g '*.{js,ts}' -A 5

Length of output: 6675

docs/guide/getting-started.md (1)

61-61: LGTM! Import paths correctly updated.

All import statements have been properly updated to use the new client entry point.

Also applies to: 76-76, 104-105, 129-130, 219-219, 286-286, 308-308

docs/composables/useTheme.md (1)

8-8: LGTM! Import path correctly updated.

The import statement has been properly updated to use the new client entry point.

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

🔭 Outside diff range comments (1)
docs/.vitepress/theme/components/sandbox/SandboxPreviewSidebar.vue (1)

Line range hint 24-61: Consider memoizing sidebar generation

The sidebar generation logic could benefit from memoization to avoid unnecessary recalculations when the spec hasn't changed.

Consider using Vue's computed properties or a memoization helper:

+import { computed } from 'vue'
+
+const sidebarItems = computed(() => {
+  if (sandboxData.sidebarItemsType.value === 'itemsByPaths') {
+    return sidebar.itemsByPaths({
+      linkPrefix: '#',
+      depth: sandboxData.sidebarItemsDepth.value,
+      collapsible: sandboxData.sidebarItemsCollapsible.value,
+    })
+  }
+  if (sandboxData.sidebarItemsType.value === 'itemsByTags') {
+    return sidebar.itemsByTags({
+      linkPrefix: '#',
+    })
+  }
+  return sidebar.generateSidebarGroups({
+    linkPrefix: '#',
+  })
+})
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f45f99a and 1230a27.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (15)
  • docs/.vitepress/config.mts (1 hunks)
  • docs/.vitepress/theme/components/sandbox/Sandbox.vue (1 hunks)
  • docs/.vitepress/theme/components/sandbox/SandboxEditor.vue (1 hunks)
  • docs/.vitepress/theme/components/sandbox/SandboxPreview.vue (1 hunks)
  • docs/.vitepress/theme/components/sandbox/SandboxPreviewSidebar.vue (1 hunks)
  • docs/.vitepress/theme/components/vitepress/VPDocAsideOutline.vue (1 hunks)
  • docs/.vitepress/theme/components/vitepress/VPSwitchAppearance.vue (1 hunks)
  • docs/.vitepress/theme/index.ts (1 hunks)
  • docs/.vitepress/theme/style.css (1 hunks)
  • docs/package.json (1 hunks)
  • docs/pages.ts (1 hunks)
  • docs/tailwind.config.js (1 hunks)
  • package.json (2 hunks)
  • pnpm-workspace.yaml (1 hunks)
  • tailwind.config.js (0 hunks)
💤 Files with no reviewable changes (1)
  • tailwind.config.js
🔇 Additional comments (17)
docs/.vitepress/theme/components/vitepress/VPDocAsideOutline.vue (1)

10-10: LGTM! Type safety improvement

The explicit type import for SandboxData enhances type safety and makes the component's dependencies clearer.

docs/.vitepress/theme/components/sandbox/SandboxEditor.vue (1)

5-5: 🧹 Nitpick (assertive)

LGTM! Consider enhancing error handling

The explicit type import for SandboxData improves type safety. However, the error handling could be enhanced to provide better user feedback.

Consider adding a user-friendly error notification instead of just logging to console:

    sandboxData.spec.value = parsed
  } catch (error) {
-    console.warn('Invalid JSON')
+    sandboxData.error.value = 'Invalid JSON: Please check your syntax'
  } finally {

Likely invalid or redundant comment.

docs/.vitepress/theme/components/sandbox/SandboxPreviewSidebar.vue (1)

7-7: LGTM! Type safety improvement

The explicit type import for SandboxData enhances type safety and maintains consistency with other components.

docs/tailwind.config.js (1)

1-15: LGTM! Well-structured Tailwind configuration.

The configuration correctly sets up Tailwind CSS for the VitePress theme, with proper content paths and plugin integration.

docs/.vitepress/theme/components/sandbox/Sandbox.vue (1)

4-4: Import path updated correctly.

The import path change aligns with the new package structure, maintaining the same functionality while properly utilizing the client-specific module.

pnpm-workspace.yaml (1)

1-2: LGTM! Docs directory properly integrated into workspace.

Adding docs to the workspace packages enables proper isolation and dependency management.

docs/.vitepress/theme/style.css (1)

1-3: LGTM! Standard Tailwind directives properly implemented.

The required Tailwind CSS directives are correctly included to enable styling functionality.

docs/.vitepress/theme/index.ts (2)

1-1: LGTM! Import path updated to use the new client entry point.

The change aligns with the PR objective of splitting entry points.


6-7: LGTM! Added required CSS imports.

The CSS imports ensure proper styling of components.

docs/.vitepress/theme/components/vitepress/VPSwitchAppearance.vue (1)

4-4: LGTM! Import order improved.

The change improves code organization by grouping external imports first.

docs/package.json (2)

19-19: LGTM! Using workspace dependency for vitepress-openapi.

The workspace dependency ensures the documentation uses the local package during development.


25-36: Verify compatibility of dependency versions.

Several dependencies have versions beyond my knowledge cutoff date (April 2024). Please ensure these versions are compatible and don't contain known vulnerabilities.

docs/pages.ts (1)

4-24: LGTM! Simplified spec file paths.

The changes improve consistency by:

  • Removing redundant './docs/' prefix
  • Using consistent './public/' directory references
package.json (2)

20-28: LGTM! Properly configured dual entry points.

The exports field correctly defines:

  • Node entry point as the default export
  • Client entry point under the '/client' subpath
  • Proper type definitions for both entry points

45-46: LGTM! Updated dev scripts for documentation.

The scripts properly handle the workspace setup for documentation development and building.

docs/.vitepress/theme/components/sandbox/SandboxPreview.vue (1)

5-5: Consider using a more stable import path.

The import path vitepress/dist/client/theme-default/composables/outline.js is implementation-specific and might break across different VitePress versions. Consider using a more stable public API if available.

Let's check if there's a more stable public API available:

docs/.vitepress/config.mts (1)

2-2: Verify the impact of removed path resolution.

The removal of the path resolution alias might affect how the package is resolved during development. Please ensure that the package exports in package.json are properly configured to handle both production and development environments.

Let's verify the package exports configuration:

@enzonotario enzonotario merged commit c43a71c into develop Jan 20, 2025
8 checks passed
@enzonotario enzonotario deleted the feature/client-node-entries branch January 23, 2025 13:59
@coderabbitai coderabbitai bot mentioned this pull request Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant