diff --git a/.docker/Dockerfile b/.docker/Dockerfile index d7fb992e5aa..1d27885cfc0 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -79,17 +79,13 @@ COPY ghost/email-service/package.json ghost/email-service/package.json COPY ghost/html-to-plaintext/package.json ghost/html-to-plaintext/package.json COPY ghost/i18n/package.json ghost/i18n/package.json COPY ghost/job-manager/package.json ghost/job-manager/package.json -COPY ghost/link-replacer/package.json ghost/link-replacer/package.json -COPY ghost/member-attribution/package.json ghost/member-attribution/package.json COPY ghost/members-csv/package.json ghost/members-csv/package.json COPY ghost/mw-error-handler/package.json ghost/mw-error-handler/package.json COPY ghost/mw-vhost/package.json ghost/mw-vhost/package.json -COPY ghost/offers/package.json ghost/offers/package.json COPY ghost/post-events/package.json ghost/post-events/package.json COPY ghost/post-revisions/package.json ghost/post-revisions/package.json COPY ghost/prometheus-metrics/package.json ghost/prometheus-metrics/package.json COPY ghost/security/package.json ghost/security/package.json -COPY ghost/tiers/package.json ghost/tiers/package.json COPY ghost/webmentions/package.json ghost/webmentions/package.json ## Install dependencies diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba5b56920de..89c79744233 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -486,7 +486,7 @@ jobs: - run: yarn nx affected -t test:unit --base=${{ needs.job_setup.outputs.BASE_COMMIT }} - uses: actions/upload-artifact@v4 - if: startsWith(matrix.node, '18') + if: startsWith(matrix.node, '20') with: name: unit-coverage path: ghost/*/coverage/cobertura-coverage.xml @@ -582,7 +582,7 @@ jobs: echo "test_time=$(($endTime-$startTime))" >> $GITHUB_ENV - uses: actions/upload-artifact@v4 - if: startsWith(matrix.node, '18') && contains(matrix.env.DB, 'mysql') + if: startsWith(matrix.node, '20') && contains(matrix.env.DB, 'mysql') with: name: e2e-coverage path: | diff --git a/compose.yml b/compose.yml index 5162209b9b9..292beb6bddf 100644 --- a/compose.yml +++ b/compose.yml @@ -19,17 +19,13 @@ x-service-template: &service-template - node_modules_ghost_html-to-plaintext:/home/ghost/ghost/html-to-plaintext/node_modules:delegated - node_modules_ghost_i18n:/home/ghost/ghost/i18n/node_modules:delegated - node_modules_ghost_job-manager:/home/ghost/ghost/job-manager/node_modules:delegated - - node_modules_ghost_link-replacer:/home/ghost/ghost/link-replacer/node_modules:delegated - - node_modules_ghost_member-attribution:/home/ghost/ghost/member-attribution/node_modules:delegated - node_modules_ghost_members-csv:/home/ghost/ghost/members-csv/node_modules:delegated - node_modules_ghost_mw-error-handler:/home/ghost/ghost/mw-error-handler/node_modules:delegated - node_modules_ghost_mw-vhost:/home/ghost/ghost/mw-vhost/node_modules:delegated - - node_modules_ghost_offers:/home/ghost/ghost/offers/node_modules:delegated - node_modules_ghost_post-events:/home/ghost/ghost/post-events/node_modules:delegated - node_modules_ghost_post-revisions:/home/ghost/ghost/post-revisions/node_modules:delegated - node_modules_ghost_prometheus-metrics:/home/ghost/ghost/prometheus-metrics/node_modules:delegated - node_modules_ghost_security:/home/ghost/ghost/security/node_modules:delegated - - node_modules_ghost_tiers:/home/ghost/ghost/tiers/node_modules:delegated - node_modules_ghost_webmentions:/home/ghost/ghost/webmentions/node_modules:delegated - node_modules_apps_admin-x-activitypub:/home/ghost/apps/admin-x-activitypub/node_modules:delegated - node_modules_apps_admin-x-design-system:/home/ghost/apps/admin-x-design-system/node_modules:delegated @@ -189,17 +185,13 @@ volumes: node_modules_ghost_html-to-plaintext: {} node_modules_ghost_i18n: {} node_modules_ghost_job-manager: {} - node_modules_ghost_link-replacer: {} - node_modules_ghost_member-attribution: {} node_modules_ghost_members-csv: {} node_modules_ghost_mw-error-handler: {} node_modules_ghost_mw-vhost: {} - node_modules_ghost_offers: {} node_modules_ghost_post-events: {} node_modules_ghost_post-revisions: {} node_modules_ghost_prometheus-metrics: {} node_modules_ghost_security: {} - node_modules_ghost_tiers: {} node_modules_ghost_webmentions: {} node_modules_apps_admin-x-activitypub: {} node_modules_apps_admin-x-design-system: {} diff --git a/ghost/core/core/server/services/email-service/EmailServiceWrapper.js b/ghost/core/core/server/services/email-service/EmailServiceWrapper.js index 401ff9d62a6..91be63f5e2d 100644 --- a/ghost/core/core/server/services/email-service/EmailServiceWrapper.js +++ b/ghost/core/core/server/services/email-service/EmailServiceWrapper.js @@ -34,7 +34,7 @@ class EmailServiceWrapper { const lexicalLib = require('../../lib/lexical'); const urlUtils = require('../../../shared/url-utils'); const memberAttribution = require('../member-attribution'); - const linkReplacer = require('@tryghost/link-replacer'); + const linkReplacer = require('../lib/link-replacer'); const linkTracking = require('../link-tracking'); const audienceFeedback = require('../audience-feedback'); const storageUtils = require('../../adapters/storage/utils'); diff --git a/ghost/link-replacer/lib/link-replacer.js b/ghost/core/core/server/services/lib/link-replacer.js similarity index 97% rename from ghost/link-replacer/lib/link-replacer.js rename to ghost/core/core/server/services/lib/link-replacer.js index 1d5cdb4869d..44ea918d73e 100644 --- a/ghost/link-replacer/lib/link-replacer.js +++ b/ghost/core/core/server/services/lib/link-replacer.js @@ -2,7 +2,7 @@ class LinkReplacer { /** * Replaces the links in the provided HTML * @param {string} html - * @param {(url: URL, originalPath: string): Promise} replaceLink + * @param {(url: URL, originalPath: string) => Promise} replaceLink * @param {object} options * @param {string} [options.base] If you want to replace relative links, this will replace them to an absolute link and call the replaceLink method too * @returns {Promise} diff --git a/ghost/member-attribution/lib/AttributionBuilder.js b/ghost/core/core/server/services/member-attribution/AttributionBuilder.js similarity index 100% rename from ghost/member-attribution/lib/AttributionBuilder.js rename to ghost/core/core/server/services/member-attribution/AttributionBuilder.js diff --git a/ghost/member-attribution/lib/MemberAttributionService.js b/ghost/core/core/server/services/member-attribution/MemberAttributionService.js similarity index 100% rename from ghost/member-attribution/lib/MemberAttributionService.js rename to ghost/core/core/server/services/member-attribution/MemberAttributionService.js diff --git a/ghost/member-attribution/lib/OutboundLinkTagger.js b/ghost/core/core/server/services/member-attribution/OutboundLinkTagger.js similarity index 98% rename from ghost/member-attribution/lib/OutboundLinkTagger.js rename to ghost/core/core/server/services/member-attribution/OutboundLinkTagger.js index 671e84c0ef2..34d5ea0b222 100644 --- a/ghost/member-attribution/lib/OutboundLinkTagger.js +++ b/ghost/core/core/server/services/member-attribution/OutboundLinkTagger.js @@ -1,5 +1,5 @@ const {slugify} = require('@tryghost/string'); -const LinkReplacer = require('@tryghost/link-replacer'); +const LinkReplacer = require('../lib/link-replacer'); const blockedReferrerDomains = [ // Facebook has some restrictions on the 'ref' attribute (max 15 chars + restricted character set) that breaks links if we add ?ref=longer-string diff --git a/ghost/member-attribution/lib/ReferrerTranslator.js b/ghost/core/core/server/services/member-attribution/ReferrerTranslator.js similarity index 100% rename from ghost/member-attribution/lib/ReferrerTranslator.js rename to ghost/core/core/server/services/member-attribution/ReferrerTranslator.js diff --git a/ghost/member-attribution/lib/UrlHistory.js b/ghost/core/core/server/services/member-attribution/UrlHistory.js similarity index 100% rename from ghost/member-attribution/lib/UrlHistory.js rename to ghost/core/core/server/services/member-attribution/UrlHistory.js diff --git a/ghost/member-attribution/lib/UrlTranslator.js b/ghost/core/core/server/services/member-attribution/UrlTranslator.js similarity index 100% rename from ghost/member-attribution/lib/UrlTranslator.js rename to ghost/core/core/server/services/member-attribution/UrlTranslator.js diff --git a/ghost/core/core/server/services/member-attribution/index.js b/ghost/core/core/server/services/member-attribution/index.js index 597fd919b10..dcc7fa88cc3 100644 --- a/ghost/core/core/server/services/member-attribution/index.js +++ b/ghost/core/core/server/services/member-attribution/index.js @@ -11,9 +11,11 @@ class MemberAttributionServiceWrapper { } // Wire up all the dependencies - const { - MemberAttributionService, UrlTranslator, ReferrerTranslator, AttributionBuilder, OutboundLinkTagger - } = require('@tryghost/member-attribution'); + const MemberAttributionService = require('./MemberAttributionService'); + const UrlTranslator = require('./UrlTranslator'); + const ReferrerTranslator = require('./ReferrerTranslator'); + const AttributionBuilder = require('./AttributionBuilder'); + const OutboundLinkTagger = require('./OutboundLinkTagger'); const models = require('../../models'); const urlTranslator = new UrlTranslator({ diff --git a/ghost/core/core/server/services/members/importer/MembersCSVImporter.js b/ghost/core/core/server/services/members/importer/MembersCSVImporter.js index f4dc988ce24..8ca12aae9bc 100644 --- a/ghost/core/core/server/services/members/importer/MembersCSVImporter.js +++ b/ghost/core/core/server/services/members/importer/MembersCSVImporter.js @@ -33,8 +33,8 @@ const DEFAULT_CSV_HEADER_MAPPING = { * @property {string} storagePath - The path to store CSV's in before importing * @property {Function} getTimezone - function returning currently configured timezone * @property {() => Object} getMembersRepository - member model access instance for data access and manipulation - * @property {() => Promise} getDefaultTier - async function returning default Member Tier - * @property {(string) => Promise} getTierByName - async function returning Member Tier by name + * @property {() => Promise} getDefaultTier - async function returning default Member Tier + * @property {(string) => Promise} getTierByName - async function returning Member Tier by name * @property {Function} sendEmail - function sending an email * @property {(string) => boolean} isSet - Method checking if specific feature is enabled * @property {({job, offloaded, name}) => void} addJob - Method registering an async job diff --git a/ghost/core/core/server/services/members/members-api/services/PaymentsService.js b/ghost/core/core/server/services/members/members-api/services/PaymentsService.js index 7f19fbfa5cf..83c209725e9 100644 --- a/ghost/core/core/server/services/members/members-api/services/PaymentsService.js +++ b/ghost/core/core/server/services/members/members-api/services/PaymentsService.js @@ -1,15 +1,17 @@ const logging = require('@tryghost/logging'); const DomainEvents = require('@tryghost/domain-events'); -const {TierCreatedEvent, TierPriceChangeEvent, TierNameChangeEvent} = require('@tryghost/tiers'); -const OfferCreatedEvent = require('@tryghost/members-offers').events.OfferCreatedEvent; +const TierCreatedEvent = require('../../../../../../core/server/services/tiers/TierCreatedEvent'); +const TierPriceChangeEvent = require('../../../../../../core/server/services/tiers/TierPriceChangeEvent'); +const TierNameChangeEvent = require('../../../../../../core/server/services/tiers/TierNameChangeEvent'); +const OfferCreatedEvent = require('../../../../../../core/server/services/offers/domain/events/OfferCreatedEvent'); const {BadRequestError} = require('@tryghost/errors'); class PaymentsService { /** * @param {object} deps * @param {import('bookshelf').Model} deps.Offer - * @param {import('@tryghost/members-offers/lib/application/OffersAPI')} deps.offersAPI - * @param {import('@tryghost/members-stripe-service/lib/StripeAPI')} deps.stripeAPIService + * @param {import('../../../offers/application/OffersAPI')} deps.offersAPI + * @param {import('../../../stripe/StripeAPI')} deps.stripeAPIService * @param {{get(key: string): any}} deps.settingsCache */ constructor(deps) { @@ -55,7 +57,7 @@ class PaymentsService { /** * @param {object} params - * @param {Tier} params.tier + * @param {import('../../../tiers/Tier')} params.tier * @param {Tier.Cadence} params.cadence * @param {Offer} [params.offer] * @param {Member} [params.member] @@ -127,7 +129,7 @@ class PaymentsService { if (member && isAuthenticated) { customer = await this.getCustomerForMember(member); } - + const data = { priceId: (await this.getPriceForDonations()).id, metadata, @@ -135,7 +137,7 @@ class PaymentsService { cancelUrl: cancelUrl, customer, customerEmail: !customer && email ? email : null, - personalNote: personalNote + personalNote: personalNote }; @@ -181,7 +183,7 @@ class PaymentsService { } /** - * @param {import('@tryghost/tiers').Tier} tier + * @param {import('../../../tiers/Tier')} tier * @returns {Promise<{id: string}>} */ async getProductForTier(tier) { @@ -209,7 +211,7 @@ class PaymentsService { } /** - * @param {import('@tryghost/tiers').Tier} tier + * @param {import('../../../tiers/Tier')} tier * @returns {Promise} */ async createProductForTier(tier) { @@ -222,7 +224,7 @@ class PaymentsService { } /** - * @param {import('@tryghost/tiers').Tier} tier + * @param {import('../../../tiers/Tier')} tier * @returns {Promise} */ async updateNameForTierProducts(tier) { @@ -396,7 +398,7 @@ class PaymentsService { } /** - * @param {import('@tryghost/tiers').Tier} tier + * @param {import('../../../tiers/Tier')} tier * @param {'month'|'year'} cadence * @returns {Promise<{id: string}>} */ @@ -440,7 +442,7 @@ class PaymentsService { } /** - * @param {import('@tryghost/tiers').Tier} tier + * @param {import('../../../tiers/Tier')} tier * @param {'month'|'year'} cadence * @returns {Promise} */ diff --git a/ghost/core/core/server/services/offers/OfferBookshelfRepository.js b/ghost/core/core/server/services/offers/OfferBookshelfRepository.js index 5d43a010395..50927ba8d8d 100644 --- a/ghost/core/core/server/services/offers/OfferBookshelfRepository.js +++ b/ghost/core/core/server/services/offers/OfferBookshelfRepository.js @@ -1,7 +1,7 @@ const {flowRight} = require('lodash'); const {mapKeyValues, mapQuery} = require('@tryghost/mongo-utils'); const DomainEvents = require('@tryghost/domain-events'); -const {Offer} = require('@tryghost/members-offers'); +const Offer = require('./domain/models/Offer'); const sentry = require('../../../shared/sentry'); const logger = require('@tryghost/logging'); @@ -93,7 +93,7 @@ class OfferBookshelfRepository { * @private * @param {import('bookshelf').Model} model * @param {BaseOptions} options - * @returns {Promise} + * @returns {Promise} */ async mapToOffer(model, options) { const json = model.toJSON(); @@ -140,7 +140,7 @@ class OfferBookshelfRepository { /** * @param {string} id * @param {BaseOptions} [options] - * @returns {Promise} + * @returns {Promise} */ async getById(id, options) { const model = await this.OfferModel.findOne({id}, { @@ -158,7 +158,7 @@ class OfferBookshelfRepository { /** * @param {string} id stripe_coupon_id * @param {BaseOptions} [options] - * @returns {Promise} + * @returns {Promise} */ async getByStripeCouponId(id, options) { const model = await this.OfferModel.findOne({stripe_coupon_id: id}, { @@ -175,7 +175,7 @@ class OfferBookshelfRepository { /** * @param {ListOptions} options - * @returns {Promise} + * @returns {Promise} */ async getAll(options) { const models = await this.OfferModel.findAll({ @@ -194,7 +194,7 @@ class OfferBookshelfRepository { } /** - * @param {import('@tryghost/members-offers').Offer} offer + * @param {import('./domain/models/Offer')} offer * @param {BaseOptions} [options] * @returns {Promise} */ diff --git a/ghost/offers/lib/OffersModule.js b/ghost/core/core/server/services/offers/OffersModule.js similarity index 100% rename from ghost/offers/lib/OffersModule.js rename to ghost/core/core/server/services/offers/OffersModule.js diff --git a/ghost/offers/lib/application/OfferMapper.js b/ghost/core/core/server/services/offers/application/OfferMapper.js similarity index 100% rename from ghost/offers/lib/application/OfferMapper.js rename to ghost/core/core/server/services/offers/application/OfferMapper.js diff --git a/ghost/offers/lib/application/OffersAPI.js b/ghost/core/core/server/services/offers/application/OffersAPI.js similarity index 100% rename from ghost/offers/lib/application/OffersAPI.js rename to ghost/core/core/server/services/offers/application/OffersAPI.js diff --git a/ghost/offers/lib/application/UniqueChecker.js b/ghost/core/core/server/services/offers/application/UniqueChecker.js similarity index 100% rename from ghost/offers/lib/application/UniqueChecker.js rename to ghost/core/core/server/services/offers/application/UniqueChecker.js diff --git a/ghost/offers/lib/domain/errors/index.js b/ghost/core/core/server/services/offers/domain/errors/index.js similarity index 100% rename from ghost/offers/lib/domain/errors/index.js rename to ghost/core/core/server/services/offers/domain/errors/index.js diff --git a/ghost/offers/lib/domain/events/OfferCodeChangeEvent.js b/ghost/core/core/server/services/offers/domain/events/OfferCodeChangeEvent.js similarity index 100% rename from ghost/offers/lib/domain/events/OfferCodeChangeEvent.js rename to ghost/core/core/server/services/offers/domain/events/OfferCodeChangeEvent.js diff --git a/ghost/offers/lib/domain/events/OfferCreatedEvent.js b/ghost/core/core/server/services/offers/domain/events/OfferCreatedEvent.js similarity index 100% rename from ghost/offers/lib/domain/events/OfferCreatedEvent.js rename to ghost/core/core/server/services/offers/domain/events/OfferCreatedEvent.js diff --git a/ghost/offers/lib/domain/models/Offer.js b/ghost/core/core/server/services/offers/domain/models/Offer.js similarity index 100% rename from ghost/offers/lib/domain/models/Offer.js rename to ghost/core/core/server/services/offers/domain/models/Offer.js diff --git a/ghost/offers/lib/domain/models/OfferAmount.js b/ghost/core/core/server/services/offers/domain/models/OfferAmount.js similarity index 100% rename from ghost/offers/lib/domain/models/OfferAmount.js rename to ghost/core/core/server/services/offers/domain/models/OfferAmount.js diff --git a/ghost/offers/lib/domain/models/OfferCadence.js b/ghost/core/core/server/services/offers/domain/models/OfferCadence.js similarity index 100% rename from ghost/offers/lib/domain/models/OfferCadence.js rename to ghost/core/core/server/services/offers/domain/models/OfferCadence.js diff --git a/ghost/offers/lib/domain/models/OfferCode.js b/ghost/core/core/server/services/offers/domain/models/OfferCode.js similarity index 100% rename from ghost/offers/lib/domain/models/OfferCode.js rename to ghost/core/core/server/services/offers/domain/models/OfferCode.js diff --git a/ghost/offers/lib/domain/models/OfferCreatedAt.js b/ghost/core/core/server/services/offers/domain/models/OfferCreatedAt.js similarity index 100% rename from ghost/offers/lib/domain/models/OfferCreatedAt.js rename to ghost/core/core/server/services/offers/domain/models/OfferCreatedAt.js diff --git a/ghost/offers/lib/domain/models/OfferCurrency.js b/ghost/core/core/server/services/offers/domain/models/OfferCurrency.js similarity index 100% rename from ghost/offers/lib/domain/models/OfferCurrency.js rename to ghost/core/core/server/services/offers/domain/models/OfferCurrency.js diff --git a/ghost/offers/lib/domain/models/OfferDescription.js b/ghost/core/core/server/services/offers/domain/models/OfferDescription.js similarity index 100% rename from ghost/offers/lib/domain/models/OfferDescription.js rename to ghost/core/core/server/services/offers/domain/models/OfferDescription.js diff --git a/ghost/offers/lib/domain/models/OfferDuration.js b/ghost/core/core/server/services/offers/domain/models/OfferDuration.js similarity index 100% rename from ghost/offers/lib/domain/models/OfferDuration.js rename to ghost/core/core/server/services/offers/domain/models/OfferDuration.js diff --git a/ghost/offers/lib/domain/models/OfferName.js b/ghost/core/core/server/services/offers/domain/models/OfferName.js similarity index 100% rename from ghost/offers/lib/domain/models/OfferName.js rename to ghost/core/core/server/services/offers/domain/models/OfferName.js diff --git a/ghost/offers/lib/domain/models/OfferStatus.js b/ghost/core/core/server/services/offers/domain/models/OfferStatus.js similarity index 100% rename from ghost/offers/lib/domain/models/OfferStatus.js rename to ghost/core/core/server/services/offers/domain/models/OfferStatus.js diff --git a/ghost/offers/lib/domain/models/OfferTitle.js b/ghost/core/core/server/services/offers/domain/models/OfferTitle.js similarity index 100% rename from ghost/offers/lib/domain/models/OfferTitle.js rename to ghost/core/core/server/services/offers/domain/models/OfferTitle.js diff --git a/ghost/offers/lib/domain/models/OfferType.js b/ghost/core/core/server/services/offers/domain/models/OfferType.js similarity index 100% rename from ghost/offers/lib/domain/models/OfferType.js rename to ghost/core/core/server/services/offers/domain/models/OfferType.js diff --git a/ghost/offers/lib/domain/models/shared/ValueObject.js b/ghost/core/core/server/services/offers/domain/models/shared/ValueObject.js similarity index 100% rename from ghost/offers/lib/domain/models/shared/ValueObject.js rename to ghost/core/core/server/services/offers/domain/models/shared/ValueObject.js diff --git a/ghost/core/core/server/services/offers/service.js b/ghost/core/core/server/services/offers/service.js index d5cd66ab34e..d8adf66f232 100644 --- a/ghost/core/core/server/services/offers/service.js +++ b/ghost/core/core/server/services/offers/service.js @@ -1,10 +1,9 @@ -const OffersModule = require('@tryghost/members-offers'); - const DynamicRedirectManager = require('../lib/DynamicRedirectManager'); const config = require('../../../shared/config'); const urlUtils = require('../../../shared/url-utils'); const models = require('../../models'); const OfferBookshelfRepository = require('./OfferBookshelfRepository'); +const OffersModule = require('./OffersModule'); let redirectManager; diff --git a/ghost/tiers/lib/InMemoryTierRepository.js b/ghost/core/core/server/services/tiers/InMemoryTierRepository.js similarity index 100% rename from ghost/tiers/lib/InMemoryTierRepository.js rename to ghost/core/core/server/services/tiers/InMemoryTierRepository.js diff --git a/ghost/tiers/lib/Tier.js b/ghost/core/core/server/services/tiers/Tier.js similarity index 100% rename from ghost/tiers/lib/Tier.js rename to ghost/core/core/server/services/tiers/Tier.js diff --git a/ghost/tiers/lib/TierActivatedEvent.js b/ghost/core/core/server/services/tiers/TierActivatedEvent.js similarity index 94% rename from ghost/tiers/lib/TierActivatedEvent.js rename to ghost/core/core/server/services/tiers/TierActivatedEvent.js index 18b717118bf..76d49d81217 100644 --- a/ghost/tiers/lib/TierActivatedEvent.js +++ b/ghost/core/core/server/services/tiers/TierActivatedEvent.js @@ -1,6 +1,6 @@ /** * @typedef {object} TierActivatedEventData - * @prop {Tier} tier + * @prop {import('./Tier')} tier */ class TierActivatedEvent { diff --git a/ghost/tiers/lib/TierArchivedEvent.js b/ghost/core/core/server/services/tiers/TierArchivedEvent.js similarity index 94% rename from ghost/tiers/lib/TierArchivedEvent.js rename to ghost/core/core/server/services/tiers/TierArchivedEvent.js index e2a74cba4ec..35bf69bc4e6 100644 --- a/ghost/tiers/lib/TierArchivedEvent.js +++ b/ghost/core/core/server/services/tiers/TierArchivedEvent.js @@ -1,6 +1,6 @@ /** * @typedef {object} TierArchivedEventData - * @prop {Tier} tier + * @prop {import('./Tier')} tier */ class TierArchivedEvent { diff --git a/ghost/tiers/lib/TierCreatedEvent.js b/ghost/core/core/server/services/tiers/TierCreatedEvent.js similarity index 94% rename from ghost/tiers/lib/TierCreatedEvent.js rename to ghost/core/core/server/services/tiers/TierCreatedEvent.js index 112226295ca..851319cb95c 100644 --- a/ghost/tiers/lib/TierCreatedEvent.js +++ b/ghost/core/core/server/services/tiers/TierCreatedEvent.js @@ -1,6 +1,6 @@ /** * @typedef {object} TierCreatedEventData - * @prop {Tier} tier + * @prop {import('./Tier')} tier */ class TierCreatedEvent { diff --git a/ghost/tiers/lib/TierNameChangeEvent.js b/ghost/core/core/server/services/tiers/TierNameChangeEvent.js similarity index 94% rename from ghost/tiers/lib/TierNameChangeEvent.js rename to ghost/core/core/server/services/tiers/TierNameChangeEvent.js index a03bb282357..21dc191fa1b 100644 --- a/ghost/tiers/lib/TierNameChangeEvent.js +++ b/ghost/core/core/server/services/tiers/TierNameChangeEvent.js @@ -1,6 +1,6 @@ /** * @typedef {object} TierNameChangeEventData - * @prop {Tier} tier + * @prop {import('./Tier')} tier */ class TierNameChangeEvent { diff --git a/ghost/tiers/lib/TierPriceChangeEvent.js b/ghost/core/core/server/services/tiers/TierPriceChangeEvent.js similarity index 94% rename from ghost/tiers/lib/TierPriceChangeEvent.js rename to ghost/core/core/server/services/tiers/TierPriceChangeEvent.js index b373ead7a57..c7d3ff4eb43 100644 --- a/ghost/tiers/lib/TierPriceChangeEvent.js +++ b/ghost/core/core/server/services/tiers/TierPriceChangeEvent.js @@ -1,6 +1,6 @@ /** * @typedef {object} TierPriceChangeEventData - * @prop {Tier} tier + * @prop {import('./Tier')} tier */ class TierPriceChangeEvent { diff --git a/ghost/core/core/server/services/tiers/TierRepository.js b/ghost/core/core/server/services/tiers/TierRepository.js index 12012a854b5..9260b875119 100644 --- a/ghost/core/core/server/services/tiers/TierRepository.js +++ b/ghost/core/core/server/services/tiers/TierRepository.js @@ -1,15 +1,15 @@ -const {Tier} = require('@tryghost/tiers'); +const Tier = require('./Tier'); const nql = require('@tryghost/nql'); /** - * @typedef {import('@tryghost/tiers/lib/TiersAPI').ITierRepository} ITierRepository + * @typedef {import('./TiersAPI').ITierRepository} ITierRepository */ /** * @implements {ITierRepository} */ module.exports = class TierRepository { - /** @type {import('@tryghost/tiers/lib/Tier')[]} */ + /** @type {import('./Tier')[]} */ #store = []; /** @type {Object.} */ #ids = {}; @@ -44,7 +44,7 @@ module.exports = class TierRepository { } /** - * @param {import('@tryghost/tiers/lib/Tier')} tier + * @param {import('./Tier')} tier * @returns {any} */ toPrimitive(tier) { @@ -83,7 +83,7 @@ module.exports = class TierRepository { /** * @param {object} [options] * @param {string} [options.filter] - * @returns {Promise} + * @returns {Promise} */ async getAll(options = {}) { const filter = nql(); @@ -97,7 +97,7 @@ module.exports = class TierRepository { /** * @param {import('bson-objectid').default} id - * @returns {Promise} + * @returns {Promise} */ async getById(id) { const found = this.#store.find((item) => { @@ -112,7 +112,7 @@ module.exports = class TierRepository { } /** - * @param {import('@tryghost/tiers/lib/Tier')} tier + * @param {import('./Tier')} tier * @returns {Promise} */ async save(tier) { diff --git a/ghost/tiers/lib/TiersAPI.js b/ghost/core/core/server/services/tiers/TiersAPI.js similarity index 100% rename from ghost/tiers/lib/TiersAPI.js rename to ghost/core/core/server/services/tiers/TiersAPI.js diff --git a/ghost/core/core/server/services/tiers/service.js b/ghost/core/core/server/services/tiers/service.js index e7deb4d7bdd..e31d34ba472 100644 --- a/ghost/core/core/server/services/tiers/service.js +++ b/ghost/core/core/server/services/tiers/service.js @@ -5,7 +5,7 @@ class TiersServiceWrapper { return; } - const {TiersAPI} = require('@tryghost/tiers'); + const TiersAPI = require('./TiersAPI'); const DomainEvents = require('@tryghost/domain-events'); const models = require('../../models'); diff --git a/ghost/core/package.json b/ghost/core/package.json index b089f84facd..e1e9024beb0 100644 --- a/ghost/core/package.json +++ b/ghost/core/package.json @@ -98,11 +98,8 @@ "@tryghost/kg-lexical-html-renderer": "1.3.5", "@tryghost/kg-mobiledoc-html-renderer": "7.1.1", "@tryghost/limit-service": "1.2.15", - "@tryghost/link-replacer": "0.0.0", "@tryghost/logging": "2.4.21", - "@tryghost/member-attribution": "0.0.0", "@tryghost/members-csv": "0.0.0", - "@tryghost/members-offers": "0.0.0", "@tryghost/metrics": "1.0.37", "@tryghost/mw-error-handler": "0.0.0", "@tryghost/mw-vhost": "0.0.0", @@ -113,12 +110,12 @@ "@tryghost/pretty-cli": "1.2.46", "@tryghost/prometheus-metrics": "0.0.0", "@tryghost/promise": "0.3.14", + "@tryghost/referrer-parser": "0.1.1", "@tryghost/request": "1.0.10", "@tryghost/root-utils": "0.3.32", "@tryghost/security": "0.0.0", "@tryghost/social-urls": "0.1.47", "@tryghost/string": "0.2.13", - "@tryghost/tiers": "0.0.0", "@tryghost/tpl": "0.1.34", "@tryghost/url-utils": "4.4.9", "@tryghost/validator": "0.2.16", @@ -148,6 +145,7 @@ "date-fns": "2.30.0", "dompurify": "3.2.5", "downsize": "0.0.8", + "entities": "4.5.0", "express": "4.21.2", "express-brute": "1.0.1", "express-hbs": "2.5.0", @@ -165,6 +163,7 @@ "gscan": "4.48.0", "handlebars": "4.7.8", "html-to-text": "5.1.1", + "html5parser": "2.0.2", "human-number": "2.0.4", "iconv-lite": "0.6.3", "image-size": "1.2.1", diff --git a/ghost/link-replacer/test/LinkReplacer.test.js b/ghost/core/test/unit/server/services/lib/LinkReplacer.test.js similarity index 96% rename from ghost/link-replacer/test/LinkReplacer.test.js rename to ghost/core/test/unit/server/services/lib/LinkReplacer.test.js index 2528009da47..83f8cb34c88 100644 --- a/ghost/link-replacer/test/LinkReplacer.test.js +++ b/ghost/core/test/unit/server/services/lib/LinkReplacer.test.js @@ -1,5 +1,5 @@ const assert = require('assert/strict'); -const linkReplacer = require('../lib/link-replacer'); +const linkReplacer = require('../../../../../core/server/services/lib/link-replacer'); const html5parser = require('html5parser'); const sinon = require('sinon'); @@ -8,10 +8,6 @@ describe('LinkReplacementService', function () { sinon.restore(); }); - it('exported', function () { - assert.equal(require('../index'), linkReplacer); - }); - describe('replace', function () { it('Can replace to URL', async function () { const html = 'link'; diff --git a/ghost/link-replacer/test/fixtures/example-post.html b/ghost/core/test/unit/server/services/lib/fixtures/example-post.html similarity index 100% rename from ghost/link-replacer/test/fixtures/example-post.html rename to ghost/core/test/unit/server/services/lib/fixtures/example-post.html diff --git a/ghost/member-attribution/test/attribution.test.js b/ghost/core/test/unit/server/services/member-attribution/attribution.test.js similarity index 97% rename from ghost/member-attribution/test/attribution.test.js rename to ghost/core/test/unit/server/services/member-attribution/attribution.test.js index e0af6d4c556..a6c537bf15b 100644 --- a/ghost/member-attribution/test/attribution.test.js +++ b/ghost/core/test/unit/server/services/member-attribution/attribution.test.js @@ -1,7 +1,7 @@ -require('should'); +const should = require('should'); -const UrlHistory = require('../lib/UrlHistory'); -const AttributionBuilder = require('../lib/AttributionBuilder'); +const UrlHistory = require('../../../../../core/server/services/member-attribution/UrlHistory'); +const AttributionBuilder = require('../../../../../core/server/services/member-attribution/AttributionBuilder'); describe('AttributionBuilder', function () { let attributionBuilder; diff --git a/ghost/member-attribution/test/history.test.js b/ghost/core/test/unit/server/services/member-attribution/history.test.js similarity index 95% rename from ghost/member-attribution/test/history.test.js rename to ghost/core/test/unit/server/services/member-attribution/history.test.js index 4ddb864559f..d9493ec7a65 100644 --- a/ghost/member-attribution/test/history.test.js +++ b/ghost/core/test/unit/server/services/member-attribution/history.test.js @@ -1,6 +1,6 @@ -require('should'); +const should = require('should'); -const UrlHistory = require('../lib/UrlHistory'); +const UrlHistory = require('../../../../../core/server/services/member-attribution/UrlHistory'); describe('UrlHistory', function () { it('sets history to empty array if invalid', function () { diff --git a/ghost/member-attribution/test/outbound-link-tagger.test.js b/ghost/core/test/unit/server/services/member-attribution/outbound-link-tagger.test.js similarity index 98% rename from ghost/member-attribution/test/outbound-link-tagger.test.js rename to ghost/core/test/unit/server/services/member-attribution/outbound-link-tagger.test.js index fcb3143b75d..a870c6a6be6 100644 --- a/ghost/member-attribution/test/outbound-link-tagger.test.js +++ b/ghost/core/test/unit/server/services/member-attribution/outbound-link-tagger.test.js @@ -1,5 +1,7 @@ -const {OutboundLinkTagger} = require('../'); const assert = require('assert/strict'); +const should = require('should'); + +const OutboundLinkTagger = require('../../../../../core/server/services/member-attribution/OutboundLinkTagger'); describe('OutboundLinkTagger', function () { describe('Constructor', function () { diff --git a/ghost/member-attribution/test/referrer-translator.test.js b/ghost/core/test/unit/server/services/member-attribution/referrer-translator.test.js similarity index 98% rename from ghost/member-attribution/test/referrer-translator.test.js rename to ghost/core/test/unit/server/services/member-attribution/referrer-translator.test.js index bb98713185e..c7450725c3a 100644 --- a/ghost/member-attribution/test/referrer-translator.test.js +++ b/ghost/core/test/unit/server/services/member-attribution/referrer-translator.test.js @@ -1,6 +1,6 @@ -require('should'); +const should = require('should'); -const ReferrerTranslator = require('../lib/ReferrerTranslator'); +const ReferrerTranslator = require('../../../../../core/server/services/member-attribution/ReferrerTranslator'); describe('ReferrerTranslator', function () { describe('Constructor', function () { diff --git a/ghost/member-attribution/test/service.test.js b/ghost/core/test/unit/server/services/member-attribution/service.test.js similarity index 98% rename from ghost/member-attribution/test/service.test.js rename to ghost/core/test/unit/server/services/member-attribution/service.test.js index 5a66ea52294..251c5f78e3c 100644 --- a/ghost/member-attribution/test/service.test.js +++ b/ghost/core/test/unit/server/services/member-attribution/service.test.js @@ -1,6 +1,6 @@ -require('should'); +const should = require('should'); -const MemberAttributionService = require('../lib/MemberAttributionService'); +const MemberAttributionService = require('../../../../../core/server/services/member-attribution/MemberAttributionService'); describe('MemberAttributionService', function () { describe('Constructor', function () { diff --git a/ghost/member-attribution/test/url-translator.test.js b/ghost/core/test/unit/server/services/member-attribution/url-translator.test.js similarity index 98% rename from ghost/member-attribution/test/url-translator.test.js rename to ghost/core/test/unit/server/services/member-attribution/url-translator.test.js index 3794ebca24e..02d1f6327d7 100644 --- a/ghost/member-attribution/test/url-translator.test.js +++ b/ghost/core/test/unit/server/services/member-attribution/url-translator.test.js @@ -1,6 +1,6 @@ -require('should'); +const should = require('should'); -const UrlTranslator = require('../lib/UrlTranslator'); +const UrlTranslator = require('../../../../../core/server/services/member-attribution/UrlTranslator'); const models = { Post: { diff --git a/ghost/core/test/unit/server/services/members/importer/MembersCSVImporter.test.js b/ghost/core/test/unit/server/services/members/importer/MembersCSVImporter.test.js index cd8826c4e30..ce6378879bc 100644 --- a/ghost/core/test/unit/server/services/members/importer/MembersCSVImporter.test.js +++ b/ghost/core/test/unit/server/services/members/importer/MembersCSVImporter.test.js @@ -1,6 +1,6 @@ require('should'); -const Tier = require('@tryghost/tiers/lib/Tier'); +const Tier = require('../../../../../../core/server/services/tiers/Tier'); const ObjectID = require('bson-objectid').default; const assert = require('assert/strict'); const fs = require('fs-extra'); diff --git a/ghost/core/test/unit/server/services/members/members-api/services/payments.test.js b/ghost/core/test/unit/server/services/members/members-api/services/payments.test.js index d9125a12df4..fd3eb67ce69 100644 --- a/ghost/core/test/unit/server/services/members/members-api/services/payments.test.js +++ b/ghost/core/test/unit/server/services/members/members-api/services/payments.test.js @@ -1,7 +1,8 @@ const assert = require('assert/strict'); const sinon = require('sinon'); -const knex = require('knex'); -const {Tier} = require('@tryghost/tiers'); +const knex = require('knex').default; + +const Tier = require('../../../../../../../core/server/services/tiers/Tier'); const PaymentsService = require('../../../../../../../core/server/services/members/members-api/services/PaymentsService'); diff --git a/ghost/offers/test/lib/application/UniqueChecker.test.js b/ghost/core/test/unit/server/services/offers/application/UniqueChecker.test.js similarity index 94% rename from ghost/offers/test/lib/application/UniqueChecker.test.js rename to ghost/core/test/unit/server/services/offers/application/UniqueChecker.test.js index 7399e8f6b56..a4c57855c3f 100644 --- a/ghost/offers/test/lib/application/UniqueChecker.test.js +++ b/ghost/core/test/unit/server/services/offers/application/UniqueChecker.test.js @@ -1,6 +1,6 @@ const sinon = require('sinon'); const should = require('should'); -const UniqueChecker = require('../../../lib/application/UniqueChecker'); +const UniqueChecker = require('../../../../../../core/server/services/offers/application/UniqueChecker'); describe('UniqueChecker', function () { describe('#isUniqueCode', function () { diff --git a/ghost/offers/test/lib/domain/models/Offer.test.js b/ghost/core/test/unit/server/services/offers/domain/models/Offer.test.js similarity index 97% rename from ghost/offers/test/lib/domain/models/Offer.test.js rename to ghost/core/test/unit/server/services/offers/domain/models/Offer.test.js index 89655dcb058..23bf01fa83a 100644 --- a/ghost/offers/test/lib/domain/models/Offer.test.js +++ b/ghost/core/test/unit/server/services/offers/domain/models/Offer.test.js @@ -1,9 +1,9 @@ const should = require('should'); const ObjectID = require('bson-objectid').default; -const errors = require('../../../../lib/domain/errors'); -const Offer = require('../../../../lib/domain/models/Offer'); -const OfferName = require('../../../../lib/domain/models/OfferName'); -const OfferCode = require('../../../../lib/domain/models/OfferCode'); +const errors = require('../../../../../../../core/server/services/offers/domain/errors'); +const Offer = require('../../../../../../../core/server/services/offers/domain/models/Offer'); +const OfferName = require('../../../../../../../core/server/services/offers/domain/models/OfferName'); +const OfferCode = require('../../../../../../../core/server/services/offers/domain/models/OfferCode'); function createUniqueChecker(dupe) { return { diff --git a/ghost/offers/test/lib/domain/models/OfferAmount.test.js b/ghost/core/test/unit/server/services/offers/domain/models/OfferAmount.test.js similarity index 98% rename from ghost/offers/test/lib/domain/models/OfferAmount.test.js rename to ghost/core/test/unit/server/services/offers/domain/models/OfferAmount.test.js index bc89700a3fd..bfdcb1695c9 100644 --- a/ghost/offers/test/lib/domain/models/OfferAmount.test.js +++ b/ghost/core/test/unit/server/services/offers/domain/models/OfferAmount.test.js @@ -1,4 +1,6 @@ -const {OfferPercentageAmount, OfferFixedAmount, OfferTrialAmount} = require('../../../../lib/domain/models/OfferAmount'); +const should = require('should'); + +const {OfferPercentageAmount, OfferFixedAmount, OfferTrialAmount} = require('../../../../../../../core/server/services/offers/domain/models/OfferAmount'); describe('OfferAmount', function () { describe('OfferPercentageAmount', function () { diff --git a/ghost/offers/test/lib/domain/models/OfferCadence.test.js b/ghost/core/test/unit/server/services/offers/domain/models/OfferCadence.test.js similarity index 90% rename from ghost/offers/test/lib/domain/models/OfferCadence.test.js rename to ghost/core/test/unit/server/services/offers/domain/models/OfferCadence.test.js index 48f12d32973..9e0be39003d 100644 --- a/ghost/offers/test/lib/domain/models/OfferCadence.test.js +++ b/ghost/core/test/unit/server/services/offers/domain/models/OfferCadence.test.js @@ -1,4 +1,6 @@ -const OfferCadence = require('../../../../lib/domain/models/OfferCadence'); +const should = require('should'); + +const OfferCadence = require('../../../../../../../core/server/services/offers/domain/models/OfferCadence'); describe('OfferCadence', function () { describe('OfferCadence.create factory', function () { diff --git a/ghost/offers/test/lib/domain/models/OfferCode.test.js b/ghost/core/test/unit/server/services/offers/domain/models/OfferCode.test.js similarity index 92% rename from ghost/offers/test/lib/domain/models/OfferCode.test.js rename to ghost/core/test/unit/server/services/offers/domain/models/OfferCode.test.js index 8ac1d8ed0ae..1b9f67d8d9d 100644 --- a/ghost/offers/test/lib/domain/models/OfferCode.test.js +++ b/ghost/core/test/unit/server/services/offers/domain/models/OfferCode.test.js @@ -1,4 +1,6 @@ -const OfferCode = require('../../../../lib/domain/models/OfferCode'); +const should = require('should'); + +const OfferCode = require('../../../../../../../core/server/services/offers/domain/models/OfferCode'); describe('OfferCode', function () { describe('OfferCode.create factory', function () { diff --git a/ghost/offers/test/lib/domain/models/OfferCurrency.test.js b/ghost/core/test/unit/server/services/offers/domain/models/OfferCurrency.test.js similarity index 94% rename from ghost/offers/test/lib/domain/models/OfferCurrency.test.js rename to ghost/core/test/unit/server/services/offers/domain/models/OfferCurrency.test.js index 58f67b4290c..033f80f638e 100644 --- a/ghost/offers/test/lib/domain/models/OfferCurrency.test.js +++ b/ghost/core/test/unit/server/services/offers/domain/models/OfferCurrency.test.js @@ -1,4 +1,6 @@ -const OfferCurrency = require('../../../../lib/domain/models/OfferCurrency'); +const should = require('should'); + +const OfferCurrency = require('../../../../../../../core/server/services/offers/domain/models/OfferCurrency'); describe('OfferCurrency', function () { describe('OfferCurrency.create factory', function () { diff --git a/ghost/offers/test/lib/domain/models/OfferDescription.test.js b/ghost/core/test/unit/server/services/offers/domain/models/OfferDescription.test.js similarity index 93% rename from ghost/offers/test/lib/domain/models/OfferDescription.test.js rename to ghost/core/test/unit/server/services/offers/domain/models/OfferDescription.test.js index dcf31fe83fb..263781c8289 100644 --- a/ghost/offers/test/lib/domain/models/OfferDescription.test.js +++ b/ghost/core/test/unit/server/services/offers/domain/models/OfferDescription.test.js @@ -1,4 +1,6 @@ -const OfferDescription = require('../../../../lib/domain/models/OfferDescription'); +const should = require('should'); + +const OfferDescription = require('../../../../../../../core/server/services/offers/domain/models/OfferDescription'); describe('OfferDescription', function () { describe('OfferDescription.create factory', function () { diff --git a/ghost/offers/test/lib/domain/models/OfferDuration.test.js b/ghost/core/test/unit/server/services/offers/domain/models/OfferDuration.test.js similarity index 94% rename from ghost/offers/test/lib/domain/models/OfferDuration.test.js rename to ghost/core/test/unit/server/services/offers/domain/models/OfferDuration.test.js index f8aba18aef2..5106e8cc1f6 100644 --- a/ghost/offers/test/lib/domain/models/OfferDuration.test.js +++ b/ghost/core/test/unit/server/services/offers/domain/models/OfferDuration.test.js @@ -1,4 +1,6 @@ -const OfferDuration = require('../../../../lib/domain/models/OfferDuration'); +const should = require('should'); + +const OfferDuration = require('../../../../../../../core/server/services/offers/domain/models/OfferDuration'); describe('OfferDuration', function () { describe('OfferDuration.create factory', function () { diff --git a/ghost/offers/test/lib/domain/models/OfferName.test.js b/ghost/core/test/unit/server/services/offers/domain/models/OfferName.test.js similarity index 94% rename from ghost/offers/test/lib/domain/models/OfferName.test.js rename to ghost/core/test/unit/server/services/offers/domain/models/OfferName.test.js index 6d1a39d69fa..967fa6c6fc9 100644 --- a/ghost/offers/test/lib/domain/models/OfferName.test.js +++ b/ghost/core/test/unit/server/services/offers/domain/models/OfferName.test.js @@ -1,4 +1,6 @@ -const OfferName = require('../../../../lib/domain/models/OfferName'); +const should = require('should'); + +const OfferName = require('../../../../../../../core/server/services/offers/domain/models/OfferName'); describe('OfferName', function () { describe('OfferName.create factory', function () { diff --git a/ghost/offers/test/lib/domain/models/OfferStatus.test.js b/ghost/core/test/unit/server/services/offers/domain/models/OfferStatus.test.js similarity index 86% rename from ghost/offers/test/lib/domain/models/OfferStatus.test.js rename to ghost/core/test/unit/server/services/offers/domain/models/OfferStatus.test.js index 77f74158029..d1c63a581f9 100644 --- a/ghost/offers/test/lib/domain/models/OfferStatus.test.js +++ b/ghost/core/test/unit/server/services/offers/domain/models/OfferStatus.test.js @@ -1,4 +1,6 @@ -const OfferStatus = require('../../../../lib/domain/models/OfferStatus'); +const should = require('should'); + +const OfferStatus = require('../../../../../../../core/server/services/offers/domain/models/OfferStatus'); describe('OfferStatus', function () { describe('OfferStatus.create factory', function () { diff --git a/ghost/offers/test/lib/domain/models/OfferTitle.test.js b/ghost/core/test/unit/server/services/offers/domain/models/OfferTitle.test.js similarity index 93% rename from ghost/offers/test/lib/domain/models/OfferTitle.test.js rename to ghost/core/test/unit/server/services/offers/domain/models/OfferTitle.test.js index 02ce1d8c10d..973f892c8da 100644 --- a/ghost/offers/test/lib/domain/models/OfferTitle.test.js +++ b/ghost/core/test/unit/server/services/offers/domain/models/OfferTitle.test.js @@ -1,4 +1,6 @@ -const OfferTitle = require('../../../../lib/domain/models/OfferTitle'); +const should = require('should'); + +const OfferTitle = require('../../../../../../../core/server/services/offers/domain/models/OfferTitle'); describe('OfferTitle', function () { describe('OfferTitle.create factory', function () { diff --git a/ghost/offers/test/lib/domain/models/OfferType.test.js b/ghost/core/test/unit/server/services/offers/domain/models/OfferType.test.js similarity index 92% rename from ghost/offers/test/lib/domain/models/OfferType.test.js rename to ghost/core/test/unit/server/services/offers/domain/models/OfferType.test.js index 7e92f29c80f..31beb1848b4 100644 --- a/ghost/offers/test/lib/domain/models/OfferType.test.js +++ b/ghost/core/test/unit/server/services/offers/domain/models/OfferType.test.js @@ -1,4 +1,6 @@ -const OfferType = require('../../../../lib/domain/models/OfferType'); +const should = require('should'); + +const OfferType = require('../../../../../../../core/server/services/offers/domain/models/OfferType'); describe('OfferType', function () { describe('OfferType.create factory', function () { diff --git a/ghost/tiers/test/Tier.test.js b/ghost/core/test/unit/server/services/tiers/Tier.test.js similarity index 93% rename from ghost/tiers/test/Tier.test.js rename to ghost/core/test/unit/server/services/tiers/Tier.test.js index 5a7a47ded2f..77cf950feea 100644 --- a/ghost/tiers/test/Tier.test.js +++ b/ghost/core/test/unit/server/services/tiers/Tier.test.js @@ -1,10 +1,10 @@ const assert = require('assert/strict'); -const ObjectID = require('bson-objectid'); -const Tier = require('../lib/Tier'); -const TierActivatedEvent = require('../lib/TierActivatedEvent'); -const TierArchivedEvent = require('../lib/TierArchivedEvent'); -const TierNameChangeEvent = require('../lib/TierNameChangeEvent'); -const TierPriceChangeEvent = require('../lib/TierPriceChangeEvent'); +const ObjectID = require('bson-objectid').default; +const Tier = require('../../../../../core/server/services/tiers/Tier'); +const TierActivatedEvent = require('../../../../../core/server/services/tiers/TierActivatedEvent'); +const TierArchivedEvent = require('../../../../../core/server/services/tiers/TierArchivedEvent'); +const TierNameChangeEvent = require('../../../../../core/server/services/tiers/TierNameChangeEvent'); +const TierPriceChangeEvent = require('../../../../../core/server/services/tiers/TierPriceChangeEvent'); async function assertError(fn, checkError) { let error; diff --git a/ghost/core/test/unit/server/services/tiers/TierRepository.test.js b/ghost/core/test/unit/server/services/tiers/TierRepository.test.js index 1aad4068a04..f7f1b94f51f 100644 --- a/ghost/core/test/unit/server/services/tiers/TierRepository.test.js +++ b/ghost/core/test/unit/server/services/tiers/TierRepository.test.js @@ -2,7 +2,7 @@ const assert = require('assert/strict'); const sinon = require('sinon'); const {Product: ProductModel} = require('../../../../../core/server/models/product'); const TierRepository = require('../../../../../core/server/services/tiers/TierRepository'); -const {Tier} = require('@tryghost/tiers'); +const Tier = require('../../../../../core/server/services/tiers/Tier'); describe('TierRepository', function () { after(function () { diff --git a/ghost/tiers/test/TiersAPI.test.js b/ghost/core/test/unit/server/services/tiers/TiersAPI.test.js similarity index 92% rename from ghost/tiers/test/TiersAPI.test.js rename to ghost/core/test/unit/server/services/tiers/TiersAPI.test.js index 4dab87d5db0..732312cd790 100644 --- a/ghost/tiers/test/TiersAPI.test.js +++ b/ghost/core/test/unit/server/services/tiers/TiersAPI.test.js @@ -1,6 +1,7 @@ const assert = require('assert/strict'); -const TiersAPI = require('../lib/TiersAPI'); -const InMemoryTierRepository = require('../lib/InMemoryTierRepository'); + +const TiersAPI = require('../../../../../core/server/services/tiers/TiersAPI'); +const InMemoryTierRepository = require('../../../../../core/server/services/tiers/InMemoryTierRepository'); describe('TiersAPI', function () { /** @type {TiersAPI.ITierRepository} */ diff --git a/ghost/email-service/test/email-renderer.test.js b/ghost/email-service/test/email-renderer.test.js index 738b023a8c7..341deeca906 100644 --- a/ghost/email-service/test/email-renderer.test.js +++ b/ghost/email-service/test/email-renderer.test.js @@ -2,7 +2,7 @@ const {EmailRenderer} = require('../'); const assert = require('assert/strict'); const cheerio = require('cheerio'); const {createModel, createModelClass} = require('./utils'); -const linkReplacer = require('@tryghost/link-replacer'); +const linkReplacer = require('../../core/core/server/services/lib/link-replacer'); const sinon = require('sinon'); const logging = require('@tryghost/logging'); const {HtmlValidate} = require('html-validate'); @@ -2701,7 +2701,7 @@ describe('Email renderer', function () { beforeEach(function () { renderedPost = '

Lexical Test

'; labsEnabled = true; // TODO: odd default because it means we're testing the unused email-customization template - + postUrl = 'http://example.com'; customSettings = { locale: 'fr', diff --git a/ghost/link-replacer/.eslintrc.js b/ghost/link-replacer/.eslintrc.js deleted file mode 100644 index c9c1bcb5226..00000000000 --- a/ghost/link-replacer/.eslintrc.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - plugins: ['ghost'], - extends: [ - 'plugin:ghost/node' - ] -}; diff --git a/ghost/link-replacer/README.md b/ghost/link-replacer/README.md deleted file mode 100644 index 53507d11392..00000000000 --- a/ghost/link-replacer/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# Link Replacement - -Replace links in a HTML string to add attribution and link tracking - - -## Usage - - -## Develop - -This is a monorepo package. - -Follow the instructions for the top-level repo. -1. `git clone` this repo & `cd` into it as usual -2. Run `yarn` to install top-level dependencies. - - - -## Test - -- `yarn lint` run just eslint -- `yarn test` run lint and tests - diff --git a/ghost/link-replacer/index.js b/ghost/link-replacer/index.js deleted file mode 100644 index fea9668ac4a..00000000000 --- a/ghost/link-replacer/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./lib/link-replacer'); diff --git a/ghost/link-replacer/package.json b/ghost/link-replacer/package.json deleted file mode 100644 index 96356f2a22f..00000000000 --- a/ghost/link-replacer/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "@tryghost/link-replacer", - "version": "0.0.0", - "repository": "https://github.com/TryGhost/Ghost/tree/main/packages/link-replacer", - "author": "Ghost Foundation", - "private": true, - "main": "index.js", - "scripts": { - "dev": "echo \"Implement me!\"", - "test:unit": "NODE_ENV=testing c8 --all --check-coverage --100 --reporter text --reporter cobertura -- mocha --reporter dot './test/**/*.test.js'", - "test": "yarn test:unit", - "lint:code": "eslint *.js lib/ --ext .js --cache", - "lint": "yarn lint:code && yarn lint:test", - "lint:test": "eslint -c test/.eslintrc.js test/ --ext .js --cache" - }, - "files": [ - "index.js", - "lib" - ], - "devDependencies": { - "@probe.gl/bench": "4.1.0", - "c8": "8.0.1", - "mocha": "10.8.2", - "should": "13.2.3", - "sinon": "15.2.0" - }, - "dependencies": { - "entities": "4.5.0", - "html5parser": "2.0.2" - } -} diff --git a/ghost/link-replacer/test/.eslintrc.js b/ghost/link-replacer/test/.eslintrc.js deleted file mode 100644 index 829b601eb0a..00000000000 --- a/ghost/link-replacer/test/.eslintrc.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - plugins: ['ghost'], - extends: [ - 'plugin:ghost/test' - ] -}; diff --git a/ghost/link-replacer/test/benchmark.js b/ghost/link-replacer/test/benchmark.js deleted file mode 100644 index bc9ffb15322..00000000000 --- a/ghost/link-replacer/test/benchmark.js +++ /dev/null @@ -1,14 +0,0 @@ -const {readFileSync} = require('node:fs'); -const {Bench} = require('@probe.gl/bench'); -const linkReplacer = require('../lib/link-replacer'); -const linkReplacerNew = require('../lib/link-replacer-new'); - -// load html from file in ./fixtures/example-post.html -const html = readFileSync('./test/fixtures/example-post.html', {encoding: 'utf8', flag: 'r'}); - -const bench = new Bench() - .group('LinkReplacer') - .addAsync('cheerio', () => linkReplacer.replace(html, () => new URL('https://google.com/test-dir?test-query'))) - .addAsync('html5parser', () => linkReplacerNew.replace(html, () => new URL('https://google.com/test-dir?test-query'))); - -bench.run(); diff --git a/ghost/member-attribution/.eslintrc.js b/ghost/member-attribution/.eslintrc.js deleted file mode 100644 index c9c1bcb5226..00000000000 --- a/ghost/member-attribution/.eslintrc.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - plugins: ['ghost'], - extends: [ - 'plugin:ghost/node' - ] -}; diff --git a/ghost/member-attribution/README.md b/ghost/member-attribution/README.md deleted file mode 100644 index e42b1f12cc5..00000000000 --- a/ghost/member-attribution/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Member Attribution - - -## Usage - - -## Develop - -This is a monorepo package. - -Follow the instructions for the top-level repo. -1. `git clone` this repo & `cd` into it as usual -2. Run `yarn` to install top-level dependencies. - - - -## Test - -- `yarn lint` run just eslint -- `yarn test` run lint and tests - diff --git a/ghost/member-attribution/index.js b/ghost/member-attribution/index.js deleted file mode 100644 index c23928eb606..00000000000 --- a/ghost/member-attribution/index.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - MemberAttributionService: require('./lib/MemberAttributionService'), - AttributionBuilder: require('./lib/AttributionBuilder'), - UrlTranslator: require('./lib/UrlTranslator'), - ReferrerTranslator: require('./lib/ReferrerTranslator'), - OutboundLinkTagger: require('./lib/OutboundLinkTagger') -}; diff --git a/ghost/member-attribution/package.json b/ghost/member-attribution/package.json deleted file mode 100644 index e363408e93a..00000000000 --- a/ghost/member-attribution/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "@tryghost/member-attribution", - "version": "0.0.0", - "repository": "https://github.com/TryGhost/Ghost/tree/main/packages/member-attribution", - "author": "Ghost Foundation", - "private": true, - "main": "index.js", - "scripts": { - "dev": "echo \"Implement me!\"", - "test:unit": "NODE_ENV=testing c8 --all --check-coverage --reporter text --reporter cobertura -- mocha --reporter dot './test/**/*.test.js'", - "test": "yarn test:unit", - "lint:code": "eslint *.js lib/ --ext .js --cache", - "lint": "yarn lint:code && yarn lint:test", - "lint:test": "eslint -c test/.eslintrc.js test/ --ext .js --cache" - }, - "devDependencies": { - "c8": "8.0.1", - "mocha": "10.8.2", - "should": "13.2.3", - "sinon": "15.2.0" - }, - "dependencies": { - "@tryghost/domain-events": "0.0.0", - "@tryghost/referrer-parser": "0.1.1", - "@tryghost/string": "0.2.13" - } -} diff --git a/ghost/member-attribution/test/.eslintrc.js b/ghost/member-attribution/test/.eslintrc.js deleted file mode 100644 index 829b601eb0a..00000000000 --- a/ghost/member-attribution/test/.eslintrc.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - plugins: ['ghost'], - extends: [ - 'plugin:ghost/test' - ] -}; diff --git a/ghost/offers/.eslintrc.js b/ghost/offers/.eslintrc.js deleted file mode 100644 index c9c1bcb5226..00000000000 --- a/ghost/offers/.eslintrc.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - plugins: ['ghost'], - extends: [ - 'plugin:ghost/node' - ] -}; diff --git a/ghost/offers/index.js b/ghost/offers/index.js deleted file mode 100644 index d6e7e149553..00000000000 --- a/ghost/offers/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./lib/OffersModule'); diff --git a/ghost/offers/package.json b/ghost/offers/package.json deleted file mode 100644 index 71059e50b87..00000000000 --- a/ghost/offers/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "@tryghost/members-offers", - "version": "0.0.0", - "private": true, - "author": "Ghost Foundation", - "license": "MIT", - "main": "index.js", - "scripts": { - "dev": "echo \"Implement me!\"", - "test:unit": "NODE_ENV=testing c8 --all --reporter text --reporter cobertura -- mocha --reporter dot './test/**/*.test.js'", - "test": "yarn test:unit", - "lint:code": "eslint *.js lib/ --ext .js --cache", - "lint": "yarn lint:code && yarn lint:test", - "lint:test": "eslint -c test/.eslintrc.js test/ --ext .js --cache" - }, - "files": [ - "index.js", - "lib" - ], - "devDependencies": { - "bson-objectid": "2.0.4", - "c8": "8.0.1", - "mocha": "10.8.2", - "should": "13.2.3", - "sinon": "15.2.0" - }, - "dependencies": { - "@tryghost/domain-events": "0.0.0", - "@tryghost/errors": "1.3.7", - "@tryghost/mongo-utils": "0.6.2", - "@tryghost/string": "0.2.13", - "lodash": "4.17.21" - } -} diff --git a/ghost/offers/test/.eslintrc.js b/ghost/offers/test/.eslintrc.js deleted file mode 100644 index 829b601eb0a..00000000000 --- a/ghost/offers/test/.eslintrc.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - plugins: ['ghost'], - extends: [ - 'plugin:ghost/test' - ] -}; diff --git a/ghost/offers/test/hello.test.js b/ghost/offers/test/hello.test.js deleted file mode 100644 index 0c7be687323..00000000000 --- a/ghost/offers/test/hello.test.js +++ /dev/null @@ -1,10 +0,0 @@ -// Switch these lines once there are useful utils -// const testUtils = require('./utils'); -require('should'); - -describe('Hello world', function () { - it('Runs a test', function () { - // TODO: Write me! - 'hello'.should.eql('hello'); - }); -}); diff --git a/ghost/tiers/.eslintrc.js b/ghost/tiers/.eslintrc.js deleted file mode 100644 index c9c1bcb5226..00000000000 --- a/ghost/tiers/.eslintrc.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - plugins: ['ghost'], - extends: [ - 'plugin:ghost/node' - ] -}; diff --git a/ghost/tiers/README.md b/ghost/tiers/README.md deleted file mode 100644 index c3eb735197e..00000000000 --- a/ghost/tiers/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# Tiers - -' - - -## Usage - - -## Develop - -This is a monorepo package. - -Follow the instructions for the top-level repo. -1. `git clone` this repo & `cd` into it as usual -2. Run `yarn` to install top-level dependencies. - - - -## Test - -- `yarn lint` run just eslint -- `yarn test` run lint and tests - diff --git a/ghost/tiers/index.js b/ghost/tiers/index.js deleted file mode 100644 index 09c61e1de4d..00000000000 --- a/ghost/tiers/index.js +++ /dev/null @@ -1,16 +0,0 @@ -const TierActivatedEvent = require('./lib/TierActivatedEvent'); -const TierArchivedEvent = require('./lib/TierArchivedEvent'); -const TierCreatedEvent = require('./lib/TierCreatedEvent'); -const TierNameChangeEvent = require('./lib/TierNameChangeEvent'); -const TierPriceChangeEvent = require('./lib/TierPriceChangeEvent'); - -module.exports = { - Tier: require('./lib/Tier'), - TiersAPI: require('./lib/TiersAPI'), - InMemoryTierRepository: require('./lib/InMemoryTierRepository'), - TierActivatedEvent, - TierArchivedEvent, - TierCreatedEvent, - TierNameChangeEvent, - TierPriceChangeEvent -}; diff --git a/ghost/tiers/package.json b/ghost/tiers/package.json deleted file mode 100644 index 1f7fe8de9e0..00000000000 --- a/ghost/tiers/package.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "@tryghost/tiers", - "version": "0.0.0", - "repository": "https://github.com/TryGhost/Ghost/tree/main/packages/tiers", - "author": "Ghost Foundation", - "private": true, - "main": "index.js", - "scripts": { - "dev": "echo \"Implement me!\"", - "test:unit": "NODE_ENV=testing c8 --all --check-coverage --reporter text --reporter cobertura -- mocha --reporter dot './test/**/*.test.js'", - "test": "yarn test:unit", - "lint:code": "eslint *.js lib/ --ext .js --cache", - "lint": "yarn lint:code && yarn lint:test", - "lint:test": "eslint -c test/.eslintrc.js test/ --ext .js --cache" - }, - "files": [ - "index.js", - "lib" - ], - "devDependencies": { - "c8": "8.0.1", - "mocha": "10.8.2" - }, - "dependencies": { - "@tryghost/errors": "1.3.7", - "@tryghost/string": "0.2.13", - "@tryghost/tpl": "0.1.34", - "bson-objectid": "2.0.4" - } -} diff --git a/ghost/tiers/test/.eslintrc.js b/ghost/tiers/test/.eslintrc.js deleted file mode 100644 index 829b601eb0a..00000000000 --- a/ghost/tiers/test/.eslintrc.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - plugins: ['ghost'], - extends: [ - 'plugin:ghost/test' - ] -}; diff --git a/ghost/tiers/test/index.test.js b/ghost/tiers/test/index.test.js deleted file mode 100644 index 7a5b0c169de..00000000000 --- a/ghost/tiers/test/index.test.js +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert/strict'); -const { - Tier, - TiersAPI, - InMemoryTierRepository -} = require('../index'); - -describe('index.js', function () { - it('Exports Tier', function () { - assert(Tier === require('../lib/Tier')); - }); - it('Exports TiersAPI', function () { - assert(TiersAPI === require('../lib/TiersAPI')); - }); - it('Exports InMemoryTierRepository', function () { - assert(InMemoryTierRepository === require('../lib/InMemoryTierRepository')); - }); -}); diff --git a/yarn.lock b/yarn.lock index 7ddef449f91..0a567a958ec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4270,25 +4270,6 @@ resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f" integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A== -"@probe.gl/bench@4.1.0": - version "4.1.0" - resolved "https://registry.yarnpkg.com/@probe.gl/bench/-/bench-4.1.0.tgz#2a0d1aa58f21874fdfb9cf49b3268cc0c169c773" - integrity sha512-4Jb1B1NHXDayWGzz4oHs3IgymdBq2AVzMUlcE428lELFqGP7nnRMqeGR/PmwElCqvYLJE39Av4QK8E64lUw/cA== - dependencies: - "@probe.gl/log" "4.1.0" - -"@probe.gl/env@4.1.0": - version "4.1.0" - resolved "https://registry.yarnpkg.com/@probe.gl/env/-/env-4.1.0.tgz#c2af9030a8711f2d98590850aa47a5f58feef211" - integrity sha512-5ac2Jm2K72VCs4eSMsM7ykVRrV47w32xOGMvcgqn8vQdEMF9PRXyBGYEV9YbqRKWNKpNKmQJVi4AHM/fkCxs9w== - -"@probe.gl/log@4.1.0": - version "4.1.0" - resolved "https://registry.yarnpkg.com/@probe.gl/log/-/log-4.1.0.tgz#b5501f96e3aa7f04c75a9800431314d46911cb98" - integrity sha512-r4gRReNY6f+OZEMgfWEXrAE2qJEt8rX0HsDJQXUBMoc+5H47bdB7f/5HBHAmapK8UydwPKL9wCDoS22rJ0yq7Q== - dependencies: - "@probe.gl/env" "4.1.0" - "@radix-ui/number@1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@radix-ui/number/-/number-1.0.1.tgz#644161a3557f46ed38a042acf4a770e826021674" @@ -7520,7 +7501,7 @@ debug "^4.3.3" lodash "^4.17.21" -"@tryghost/mongo-utils@0.6.2", "@tryghost/mongo-utils@^0.6.2": +"@tryghost/mongo-utils@^0.6.2": version "0.6.2" resolved "https://registry.yarnpkg.com/@tryghost/mongo-utils/-/mongo-utils-0.6.2.tgz#18af1e057aad6876cb7ff61f817df4e90d8055bf" integrity sha512-ewXYg2/EOYNc/ko5zwfvxskYfyLOVjMOPGgRLODJf3jLp9iXK9nfLHOrnAO4Jeh9CLzHm84aWUMaRIFH/XQULg==