Skip to content

Move packages #23135

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Move packages #23135

wants to merge 5 commits into from

Conversation

daniellockyer
Copy link
Member

fix https://linear.app/ghost/issue/ENG-2381/post-events

  • this commit moves the lib code and tests to the core folder so we can colocate code in one place rather than splitting it out across packages, which increases the cognitive load and overhead

Copy link
Contributor

coderabbitai bot commented May 1, 2025

"""

Walkthrough

This change removes the standalone @tryghost/link-replacer, @tryghost/member-attribution, @tryghost/members-offers, @tryghost/tiers, and @tryghost/members-offers packages from the repository. All related package files, entry points, documentation, ESLint configurations, and tests for these packages are deleted. Code throughout the core application is updated to replace imports from these external packages with local relative imports pointing to their new locations within the core codebase. Docker and Docker Compose configurations are updated to stop copying and mounting these packages. Type annotations and JSDoc comments are adjusted to reference the new local paths. Tests and service files are updated to use the new import paths, and minor assertion style changes are made in test files. The consolidation removes the package boundaries, making these modules internal to the core application.

Possibly related PRs

  • TryGhost/Ghost#22917: Refactors by removing external package dependencies such as @tryghost/member-attribution and @tryghost/tiers and replacing them with local relative imports, similar to this PR’s consolidation approach.
  • TryGhost/Ghost#23132: Moves the @tryghost/member-events package into the core folder and updates imports, reflecting the same consolidation approach used in this PR.
  • TryGhost/Ghost#22914: Removes volume mounts and external package imports for several Ghost packages, consolidating them into the core codebase, akin to the changes in this PR.

Suggested labels

migration


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8208fb8 and 04a298e.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (23)
  • .docker/Dockerfile (0 hunks)
  • compose.yml (1 hunks)
  • ghost/core/core/server/services/members/members-api/services/PaymentsService.js (8 hunks)
  • ghost/core/core/server/services/offers/OfferBookshelfRepository.js (6 hunks)
  • ghost/core/core/server/services/offers/service.js (1 hunks)
  • ghost/core/package.json (3 hunks)
  • ghost/core/test/unit/server/services/offers/application/UniqueChecker.test.js (1 hunks)
  • ghost/core/test/unit/server/services/offers/domain/models/Offer.test.js (1 hunks)
  • ghost/core/test/unit/server/services/offers/domain/models/OfferAmount.test.js (1 hunks)
  • ghost/core/test/unit/server/services/offers/domain/models/OfferCadence.test.js (1 hunks)
  • ghost/core/test/unit/server/services/offers/domain/models/OfferCode.test.js (1 hunks)
  • ghost/core/test/unit/server/services/offers/domain/models/OfferCurrency.test.js (1 hunks)
  • ghost/core/test/unit/server/services/offers/domain/models/OfferDescription.test.js (1 hunks)
  • ghost/core/test/unit/server/services/offers/domain/models/OfferDuration.test.js (1 hunks)
  • ghost/core/test/unit/server/services/offers/domain/models/OfferName.test.js (1 hunks)
  • ghost/core/test/unit/server/services/offers/domain/models/OfferStatus.test.js (1 hunks)
  • ghost/core/test/unit/server/services/offers/domain/models/OfferTitle.test.js (1 hunks)
  • ghost/core/test/unit/server/services/offers/domain/models/OfferType.test.js (1 hunks)
  • ghost/offers/.eslintrc.js (0 hunks)
  • ghost/offers/index.js (0 hunks)
  • ghost/offers/package.json (0 hunks)
  • ghost/offers/test/.eslintrc.js (0 hunks)
  • ghost/offers/test/hello.test.js (0 hunks)
💤 Files with no reviewable changes (6)
  • ghost/offers/test/.eslintrc.js
  • ghost/offers/index.js
  • .docker/Dockerfile
  • ghost/offers/.eslintrc.js
  • ghost/offers/test/hello.test.js
  • ghost/offers/package.json
✅ Files skipped from review due to trivial changes (14)
  • ghost/core/core/server/services/offers/service.js
  • ghost/core/test/unit/server/services/offers/domain/models/OfferCode.test.js
  • ghost/core/test/unit/server/services/offers/domain/models/OfferStatus.test.js
  • ghost/core/test/unit/server/services/offers/domain/models/Offer.test.js
  • ghost/core/test/unit/server/services/offers/domain/models/OfferDuration.test.js
  • ghost/core/test/unit/server/services/offers/domain/models/OfferDescription.test.js
  • ghost/core/test/unit/server/services/offers/domain/models/OfferTitle.test.js
  • ghost/core/test/unit/server/services/offers/domain/models/OfferName.test.js
  • ghost/core/test/unit/server/services/offers/domain/models/OfferCadence.test.js
  • ghost/core/test/unit/server/services/offers/domain/models/OfferType.test.js
  • ghost/core/test/unit/server/services/offers/domain/models/OfferCurrency.test.js
  • ghost/core/test/unit/server/services/offers/domain/models/OfferAmount.test.js
  • ghost/core/test/unit/server/services/offers/application/UniqueChecker.test.js
  • ghost/core/core/server/services/offers/OfferBookshelfRepository.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • ghost/core/package.json
  • compose.yml
  • ghost/core/core/server/services/members/members-api/services/PaymentsService.js
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Database tests (Node 22.13.1, mysql8)
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Comments-UI tests
  • GitHub Check: Unit tests (Node 22.13.1)
  • GitHub Check: Admin-X Settings tests
  • GitHub Check: Unit tests (Node 20.11.1)
  • GitHub Check: Lint
  • GitHub Check: Admin tests - Chrome
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • 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.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🧹 Nitpick comments (1)
ghost/core/core/shared/events/index.js (1)

15-23: Export new post-related events from shared index.
The index.js now includes exports for PostDeletedEvent and all bulk post event classes. Confirm that each event file (e.g., PostsBulkAddTagsEvent.js) defines a named export matching the property used here (.PostsBulkAddTagsEvent). If any module exports a default, adjust it to a named export for compatibility.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7ddcc6d and 052422b.

📒 Files selected for processing (13)
  • .docker/Dockerfile (0 hunks)
  • compose.yml (0 hunks)
  • ghost/core/core/server/services/Users.js (1 hunks)
  • ghost/core/core/server/services/posts/PostsService.js (1 hunks)
  • ghost/core/core/shared/events/index.js (1 hunks)
  • ghost/core/package.json (0 hunks)
  • ghost/core/test/unit/shared/events/post-events.test.ts (1 hunks)
  • ghost/post-events/.eslintrc.js (0 hunks)
  • ghost/post-events/README.md (0 hunks)
  • ghost/post-events/package.json (0 hunks)
  • ghost/post-events/src/index.ts (0 hunks)
  • ghost/post-events/test/.eslintrc.js (0 hunks)
  • ghost/post-events/tsconfig.json (0 hunks)
💤 Files with no reviewable changes (9)
  • ghost/post-events/README.md
  • ghost/core/package.json
  • .docker/Dockerfile
  • ghost/post-events/tsconfig.json
  • compose.yml
  • ghost/post-events/test/.eslintrc.js
  • ghost/post-events/.eslintrc.js
  • ghost/post-events/package.json
  • ghost/post-events/src/index.ts
🧰 Additional context used
🧬 Code Graph Analysis (3)
ghost/core/core/server/services/Users.js (1)
ghost/core/core/server/services/posts/PostsService.js (2)
  • require (2-2)
  • require (8-15)
ghost/core/core/server/services/posts/PostsService.js (1)
ghost/core/core/server/services/Users.js (2)
  • require (8-8)
  • require (10-10)
ghost/core/core/shared/events/index.js (10)
ghost/core/core/server/services/Users.js (2)
  • require (8-8)
  • require (10-10)
ghost/core/core/server/services/posts/PostsService.js (2)
  • require (2-2)
  • require (8-15)
ghost/core/core/frontend/services/sitemap/SiteMapManager.js (1)
  • require (2-2)
ghost/core/core/server/services/VerificationTrigger.js (1)
  • require (3-3)
ghost/core/core/server/services/members-events/EventStorage.js (1)
  • require (1-1)
ghost/core/core/frontend/web/site.js (2)
  • require (5-5)
  • require (19-19)
ghost/core/core/server/services/comments/CommentsService.js (1)
  • require (3-3)
ghost/core/core/server/services/staff/StaffService.js (1)
  • require (1-1)
ghost/core/core/server/services/members-events/LastSeenAtUpdater.js (3)
  • require (1-1)
  • require (3-3)
  • require (4-4)
ghost/core/core/server/services/url/Resources.js (1)
  • require (4-4)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Unit tests (Node 22.13.1)
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Unit tests (Node 20.11.1)
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 22.13.1, mysql8)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: i18n
  • GitHub Check: Lint
🔇 Additional comments (3)
ghost/core/core/server/services/Users.js (1)

10-10: Correct import path for post events.
The import of PostsBulkAddTagsEvent has been updated to use the local shared events module (../../shared/events) instead of the external @tryghost/post-events package. The relative path is correct given the file’s location (server/services), and it aligns with changes in other service files.

ghost/core/core/server/services/posts/PostsService.js (1)

15-15: Align event imports to local shared module.
Redirecting event imports to ../../../shared/events ensures the post event classes are sourced from the consolidated core codebase. The relative path is accurate for the posts subdirectory and matches the structure used in Users.js.

ghost/core/test/unit/shared/events/post-events.test.ts (1)

3-9: Update test imports to local event files.
The test now imports each post event class directly from its specific file under core/shared/events, replacing grouped imports from the removed package. The relative paths (e.g., ../../../../core/shared/events/PostsBulkAddTagsEvent) correctly resolve from the test directory. This maintains test coverage without altering test logic.

fix https://linear.app/ghost/issue/ENG-2382/member-attribution

- this commit moves the lib code and tests to the core folder so we can
  colocate code in one place rather than splitting it out across
  packages, which increases the cognitive load and overhead
@daniellockyer daniellockyer changed the title Moved @tryghost/post-events to core folder Move packages May 5, 2025
fix https://linear.app/ghost/issue/ENG-2383/tiers

- this commit moves the lib code and tests to the core folder so we can
  colocate code in one place rather than splitting it out across
  packages, which increases the cognitive load and overhead
fix https://linear.app/ghost/issue/ENG-2384/link-replacer

- this commit moves the lib code and tests to the core folder so we can
  colocate code in one place rather than splitting it out across
  packages, which increases the cognitive load and overhead
Copy link

codecov bot commented May 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.83%. Comparing base (dc0c405) to head (ff52629).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #23135      +/-   ##
==========================================
- Coverage   71.84%   71.83%   -0.01%     
==========================================
  Files        1435     1435              
  Lines       99367    99333      -34     
  Branches    12201    12199       -2     
==========================================
- Hits        71388    71354      -34     
  Misses      26989    26989              
  Partials      990      990              
Flag Coverage Δ
admin-tests 48.56% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

fix https://linear.app/ghost/issue/ENG-2385/offers

- this commit moves the lib code and tests to the core folder so we can
  colocate code in one place rather than splitting it out across
  packages, which increases the cognitive load and overhead
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.

2 participants