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

refactor: ♻️ Move prompt related entities to @prompt/domain #32

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

zhumeisongsong
Copy link
Owner

@zhumeisongsong zhumeisongsong commented Nov 14, 2024

related #22

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a README file for the prompt-domain library with setup and testing instructions.
    • Added a new project configuration for the prompt-domain library.
  • Bug Fixes

    • Updated Jest configuration to reflect the new naming convention and coverage directory.
  • Documentation

    • Removed outdated README files for user-prompt-log-entity and wellbeing-prompt-entity.
  • Chores

    • Consolidated path mappings in the TypeScript configuration for simplified module resolution.

Copy link

coderabbitai bot commented Nov 14, 2024

Walkthrough

This pull request introduces several changes to the prompt-domain library, including the creation of new configuration and documentation files, as well as the removal of outdated files related to the user-prompt-log-entity and wellbeing-prompt-entity. Key additions include a new README, ESLint configuration, Jest configuration, and project configuration files. Additionally, path mappings in the base TypeScript configuration have been updated to streamline module resolution. The changes reflect a restructuring of the library's components and documentation.

Changes

File Change Summary
libs/prompt/domain/README.md New file created with library description and testing instructions.
libs/prompt/domain/eslint.config.js New ESLint configuration file created, extending a base configuration.
libs/prompt/domain/jest.config.ts Updated Jest configuration: changed displayName, preset, and coverageDirectory.
libs/prompt/domain/project.json New project configuration added for prompt-domain.
libs/prompt/domain/src/index.ts New export added for user-prompt-log-entity.
libs/prompt/domain/tsconfig.json Updated extends property to a new relative path for TypeScript configuration.
libs/prompt/domain/tsconfig.lib.json Updated outDir property in compilerOptions.
libs/prompt/domain/tsconfig.spec.json Updated outDir property in compilerOptions.
libs/prompt/domain/user-prompt-log-entity/README.md File removed, eliminating documentation for this entity.
libs/prompt/domain/user-prompt-log-entity/eslint.config.js File removed, eliminating ESLint configuration for this entity.
libs/prompt/domain/user-prompt-log-entity/project.json File removed, eliminating project configuration for this entity.
libs/prompt/domain/user-prompt-log-entity/src/index.ts File removed, eliminating exports from this entity.
libs/prompt/domain/user-prompt-log-entity/tsconfig.spec.json File removed, eliminating TypeScript configuration for testing.
libs/prompt/domain/wellbeing-prompt-entity/README.md File removed, eliminating documentation for this entity.
libs/prompt/domain/wellbeing-prompt-entity/eslint.config.js File removed, eliminating ESLint configuration for this entity.
libs/prompt/domain/wellbeing-prompt-entity/jest.config.ts File removed, eliminating Jest configuration for this entity.
libs/prompt/domain/wellbeing-prompt-entity/project.json File removed, eliminating project configuration for this entity.
libs/prompt/domain/wellbeing-prompt-entity/tsconfig.json File removed, eliminating TypeScript configuration for this entity.
libs/prompt/domain/wellbeing-prompt-entity/tsconfig.lib.json File removed, eliminating TypeScript library configuration for this entity.
libs/user/domain/project.json Project name updated from "domain" to "user-domain" and comment updated.
tsconfig.base.json Updated paths property: removed mappings for @prompt/user-prompt-log-entity and @prompt/wellbeing-prompt-entity, added mapping for @prompt/domain.

Possibly related PRs

🐇 In the meadow, changes bloom,
A new README dispels the gloom.
With ESLint and Jest now in sight,
The prompt-domain shines so bright!
Old files gone, new paths to trace,
In this library, we find our place! 🌼


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

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
tsconfig.base.json (1)

19-19: LGTM! Path consolidation aligns with domain-driven design.

The consolidation of prompt-related entities under a single @prompt/domain path mapping is a good architectural decision that improves maintainability and follows domain-driven design principles.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3b7e7e2 and f538c74.

📒 Files selected for processing (21)
  • libs/prompt/domain/README.md (1 hunks)
  • libs/prompt/domain/eslint.config.js (1 hunks)
  • libs/prompt/domain/jest.config.ts (1 hunks)
  • libs/prompt/domain/project.json (1 hunks)
  • libs/prompt/domain/src/index.ts (1 hunks)
  • libs/prompt/domain/tsconfig.json (1 hunks)
  • libs/prompt/domain/tsconfig.lib.json (1 hunks)
  • libs/prompt/domain/tsconfig.spec.json (1 hunks)
  • libs/prompt/domain/user-prompt-log-entity/README.md (0 hunks)
  • libs/prompt/domain/user-prompt-log-entity/eslint.config.js (0 hunks)
  • libs/prompt/domain/user-prompt-log-entity/project.json (0 hunks)
  • libs/prompt/domain/user-prompt-log-entity/src/index.ts (0 hunks)
  • libs/prompt/domain/user-prompt-log-entity/tsconfig.spec.json (0 hunks)
  • libs/prompt/domain/wellbeing-prompt-entity/README.md (0 hunks)
  • libs/prompt/domain/wellbeing-prompt-entity/eslint.config.js (0 hunks)
  • libs/prompt/domain/wellbeing-prompt-entity/jest.config.ts (0 hunks)
  • libs/prompt/domain/wellbeing-prompt-entity/project.json (0 hunks)
  • libs/prompt/domain/wellbeing-prompt-entity/tsconfig.json (0 hunks)
  • libs/prompt/domain/wellbeing-prompt-entity/tsconfig.lib.json (0 hunks)
  • libs/user/domain/project.json (1 hunks)
  • tsconfig.base.json (1 hunks)
💤 Files with no reviewable changes (11)
  • libs/prompt/domain/user-prompt-log-entity/README.md
  • libs/prompt/domain/user-prompt-log-entity/eslint.config.js
  • libs/prompt/domain/user-prompt-log-entity/project.json
  • libs/prompt/domain/user-prompt-log-entity/src/index.ts
  • libs/prompt/domain/user-prompt-log-entity/tsconfig.spec.json
  • libs/prompt/domain/wellbeing-prompt-entity/README.md
  • libs/prompt/domain/wellbeing-prompt-entity/eslint.config.js
  • libs/prompt/domain/wellbeing-prompt-entity/jest.config.ts
  • libs/prompt/domain/wellbeing-prompt-entity/project.json
  • libs/prompt/domain/wellbeing-prompt-entity/tsconfig.json
  • libs/prompt/domain/wellbeing-prompt-entity/tsconfig.lib.json
✅ Files skipped from review due to trivial changes (6)
  • libs/prompt/domain/README.md
  • libs/prompt/domain/eslint.config.js
  • libs/prompt/domain/project.json
  • libs/prompt/domain/tsconfig.json
  • libs/prompt/domain/tsconfig.spec.json
  • libs/user/domain/project.json
🔇 Additional comments (5)
libs/prompt/domain/src/index.ts (1)

1-2: LGTM! Export statements are correctly structured.

The barrel exports align with the PR objective of consolidating prompt-related entities under @prompt/domain.

Let's verify the module structure and dependencies:

✅ Verification successful

Export statements are correctly implemented and modules exist

The verification confirms:

  • Both exported modules exist in the correct location
  • The interfaces are properly defined without circular dependencies
  • The module structure aligns with the PR objective of consolidating prompt-related entities
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the module structure and check for potential circular dependencies

# Check if the module exists at the specified path
echo "Checking if the module exists..."
fd -t f "user-prompt-log-entity.(ts|js)" libs/prompt/domain/src/lib

# Look for potential circular dependencies
echo "Checking for circular dependencies..."
rg -l "from.*@prompt/domain" libs/prompt/domain/src/lib

Length of output: 340


Script:

#!/bin/bash
# Let's verify the content of the user-prompt-log-entity.ts and check its imports
echo "Content of user-prompt-log-entity.ts:"
cat libs/prompt/domain/src/lib/user-prompt-log-entity.ts

echo -e "\nChecking imports in wellbeing-prompt-entity.ts for potential circular dependencies:"
cat libs/prompt/domain/src/lib/wellbeing-prompt-entity.ts

Length of output: 832

libs/prompt/domain/tsconfig.lib.json (1)

5-5: LGTM! Verify path resolution in the new structure.

The updated output directory path correctly points to the dist directory at the repository root, which aligns with the project restructuring.

Let's verify the path resolution works in the new structure:

✅ Verification successful

Path resolution is correct and consistent with other domain libraries

The outDir path "../../../dist/out-tsc" in libs/prompt/domain/tsconfig.lib.json is correct because:

  • It matches the path used in the parallel libs/user/domain/tsconfig.lib.json
  • The directory structure confirms three levels up from libs/prompt/domain/ reaches the root
  • It follows the same pattern as other domain libraries in the monorepo
  • Only the shallower libs/config uses "../../dist/out-tsc" due to its different nesting level
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and structure of the new project layout

# Check if we're in the expected project structure
fd -t d "prompt/domain" libs/

# Verify the path can be resolved from the current location
realpath --relative-to="$(pwd)/libs/prompt/domain" "$(pwd)/dist/out-tsc" | grep -q "^../../../dist/out-tsc$" && echo "Path resolution is correct" || echo "Path resolution is incorrect"

Length of output: 317


Script:

#!/bin/bash
# Let's try a different approach to verify the directory structure and path resolution

# Check if the project structure exists
ls -la libs/prompt/domain/

# Check the parent directories to verify relative path
ls -la libs/prompt/
ls -la libs/
ls -la ./

# Look for other tsconfig files to compare paths
find . -name "tsconfig*.json" -type f -exec grep -l "outDir" {} \;

Length of output: 3146


Script:

#!/bin/bash
# Let's check the outDir paths in other similar library configurations to verify consistency

# Check outDir in other library tsconfig.lib.json files
echo "=== libs/config/tsconfig.lib.json ==="
cat libs/config/tsconfig.lib.json

echo -e "\n=== libs/user/domain/tsconfig.lib.json ==="
cat libs/user/domain/tsconfig.lib.json

echo -e "\n=== libs/prompt/domain/tsconfig.lib.json ==="
cat libs/prompt/domain/tsconfig.lib.json

Length of output: 1241

libs/prompt/domain/jest.config.ts (2)

Line range hint 1-11: Verify test setup with the new configuration

The configuration looks complete with all necessary Jest properties. Let's ensure it works with the TypeScript setup.

#!/bin/bash
# Description: Verify TypeScript configuration for tests

# Check if tsconfig.spec.json exists in the prompt domain
fd --type f "tsconfig.spec.json" libs/prompt/domain/

# Verify test files exist
fd --type f --extension ts --extension spec.ts --extension test.ts libs/prompt/domain/

2-3: LGTM! Configuration paths and naming look correct.

The updated paths and display name align well with the new domain structure. The relative paths are consistent throughout the configuration.

Let's verify the Jest configuration paths are correct:

Also applies to: 9-9

✅ Verification successful

Jest configuration paths are correct and properly set up

The verification confirms:

  • The jest.preset.js exists at the repository root, validating the ../../../jest.preset.js path
  • The directory structure shows libs/prompt/domain/ exists at the correct level
  • The Jest configuration file is properly located at libs/prompt/domain/jest.config.ts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Jest preset file exists and the coverage directory structure is valid

# Check if the Jest preset file exists at the specified location
if [ -f "jest.preset.js" ]; then
    echo "Jest preset file found at repository root"
fi

# Verify the libs/prompt/domain directory structure
fd --type d --max-depth 3 "prompt" libs/

Length of output: 708


Script:

#!/bin/bash
# Let's verify the Jest configuration more thoroughly

# Check if jest.preset.js exists at the root
if [ -f "jest.preset.js" ]; then
    echo "=== Jest preset file content ==="
    cat jest.preset.js
fi

# Check the actual directory structure and related config files
echo -e "\n=== Directory structure ==="
fd --type d --max-depth 4 prompt libs/

echo -e "\n=== Related Jest configs ==="
fd jest.config.ts libs/prompt/

echo -e "\n=== TypeScript config ==="
fd tsconfig.json libs/prompt/domain/

Length of output: 615

tsconfig.base.json (1)

19-19: Verify updates to import statements across the codebase.

Since this change consolidates the paths from individual entity mappings to a single domain mapping, we should verify that all import statements have been updated accordingly.

✅ Verification successful

No import updates needed - path mapping is only referenced in tsconfig

The verification shows that the @prompt/domain path is only referenced in tsconfig.base.json and there are no actual imports using either the old paths (@prompt/user-prompt-log-entity, @prompt/wellbeing-prompt-entity) or the new path (@prompt/domain) in the codebase. This suggests this is a new path mapping being added to the configuration without any existing code dependencies to update.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining imports using the old paths that might need updating

echo "Checking for old import patterns..."
rg -l '@prompt/(user-prompt-log-entity|wellbeing-prompt-entity)' \
  --type ts \
  --type tsx \
  --type js \
  --type jsx

echo "Checking new import pattern usage..."
rg -l '@prompt/domain' \
  --type ts \
  --type tsx \
  --type js \
  --type jsx

Length of output: 393


Script:

#!/bin/bash
# Let's try with simpler ripgrep commands without file type filters
echo "Checking for old import patterns..."
rg -l '@prompt/(user-prompt-log-entity|wellbeing-prompt-entity)'

echo "Checking new import pattern usage..."
rg -l '@prompt/domain'

Length of output: 272


Script:

#!/bin/bash
# Let's check the actual content of files importing from @prompt paths
echo "Checking imports with context..."
rg -C 3 'from.*@prompt/' 

# Also check for require statements
echo "Checking require statements..."
rg -C 3 "require.*@prompt/"

Length of output: 202

Copy link

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant