From 44f18b5a8986935728f7147d6f506dd1376fd594 Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Mon, 14 Oct 2024 14:56:09 +0200 Subject: [PATCH 01/12] Added support for Adobe Commerce for Algolia. --- .changeset/clever-fireants-reply.md | 6 ++++++ .../algolia-products/mesh/algoliaHitToMagentoProduct.ts | 1 + .../schema-ac/AlgoliaProductRecommendations.graphqls | 7 +++++++ 3 files changed, 14 insertions(+) create mode 100644 .changeset/clever-fireants-reply.md create mode 100644 packages/algolia-recommend/schema-ac/AlgoliaProductRecommendations.graphqls diff --git a/.changeset/clever-fireants-reply.md b/.changeset/clever-fireants-reply.md new file mode 100644 index 0000000000..6b7d96b771 --- /dev/null +++ b/.changeset/clever-fireants-reply.md @@ -0,0 +1,6 @@ +--- +'@graphcommerce/algolia-recommend': patch +'@graphcommerce/algolia-products': patch +--- + +Added support for Adobe Commerce for Algolia. diff --git a/packages/algolia-products/mesh/algoliaHitToMagentoProduct.ts b/packages/algolia-products/mesh/algoliaHitToMagentoProduct.ts index af5b7ed9dd..92a6e2f12c 100644 --- a/packages/algolia-products/mesh/algoliaHitToMagentoProduct.ts +++ b/packages/algolia-products/mesh/algoliaHitToMagentoProduct.ts @@ -155,6 +155,7 @@ export function algoliaHitToMagentoProduct( } return { + staged: false, redirect_code: 0, __typename: algoliaTypeToTypename[type_id as keyof typeof algoliaTypeToTypename], uid: btoa(objectID), diff --git a/packages/algolia-recommend/schema-ac/AlgoliaProductRecommendations.graphqls b/packages/algolia-recommend/schema-ac/AlgoliaProductRecommendations.graphqls new file mode 100644 index 0000000000..c79e0e067c --- /dev/null +++ b/packages/algolia-recommend/schema-ac/AlgoliaProductRecommendations.graphqls @@ -0,0 +1,7 @@ +type GiftCardProduct implements ProductInterface { + algolia_looking_similar(input: AlgoliaLookingSimilarInput): [ProductInterface] + algolia_frequently_bought_together( + input: AlgoliaFrequentlyBoughtTogetherInput + ): [ProductInterface] + algolia_related_products(input: AlgoliaRelatedProductsInput): [ProductInterface] +} From 858f775e1ac1e25352e67fdfc1c6475d623040c6 Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Mon, 14 Oct 2024 15:26:00 +0200 Subject: [PATCH 02/12] Added support for Adobe Commerce --- .../ProductListItems/productListRenderer.tsx | 8 +++--- packages/adobe-commerce/README.md | 1 + .../graphql/GiftCardCartItem.graphql | 5 ++++ packages/adobe-commerce/package.json | 25 +++++++++++++++++++ packages/cli/src/bin/mesh.ts | 14 ++++++++--- yarn.lock | 20 +++++++++++++++ 6 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 packages/adobe-commerce/README.md create mode 100644 packages/adobe-commerce/graphql/GiftCardCartItem.graphql create mode 100644 packages/adobe-commerce/package.json diff --git a/examples/magento-graphcms/components/ProductListItems/productListRenderer.tsx b/examples/magento-graphcms/components/ProductListItems/productListRenderer.tsx index fd705e8cec..9b66316ee7 100644 --- a/examples/magento-graphcms/components/ProductListItems/productListRenderer.tsx +++ b/examples/magento-graphcms/components/ProductListItems/productListRenderer.tsx @@ -76,9 +76,7 @@ export const productListRenderer: ProductListItemRenderer = { topRight={} /> ), - // // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // // @ts-ignore GiftCardProduct is only available in Commerce - // GiftCardProduct: (props) => ( - // - // ), + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore GiftCardProduct is only available in Commerce + GiftCardProduct: (props) => , } diff --git a/packages/adobe-commerce/README.md b/packages/adobe-commerce/README.md new file mode 100644 index 0000000000..21ad0d1881 --- /dev/null +++ b/packages/adobe-commerce/README.md @@ -0,0 +1 @@ +# Adobe Commerce compatibility package diff --git a/packages/adobe-commerce/graphql/GiftCardCartItem.graphql b/packages/adobe-commerce/graphql/GiftCardCartItem.graphql new file mode 100644 index 0000000000..5e6c0a197d --- /dev/null +++ b/packages/adobe-commerce/graphql/GiftCardCartItem.graphql @@ -0,0 +1,5 @@ +fragment GiftCardCartItem on GiftCardCartItem @inject(into: ["CartItem"]) { + customizable_options { + ...SelectedCustomizableOption + } +} diff --git a/packages/adobe-commerce/package.json b/packages/adobe-commerce/package.json new file mode 100644 index 0000000000..a5c4e9578a --- /dev/null +++ b/packages/adobe-commerce/package.json @@ -0,0 +1,25 @@ +{ + "name": "@graphcommerce/adobe-commerce", + "homepage": "https://www.graphcommerce.org/", + "repository": "github:graphcommerce-org/graphcommerce", + "version": "9.0.0-canary.86", + "sideEffects": false, + "prettier": "@graphcommerce/prettier-config-pwa", + "eslintConfig": { + "extends": "@graphcommerce/eslint-config-pwa", + "parserOptions": { + "project": "./tsconfig.json" + } + }, + "scripts": { + "generate": "tsx scripts/generate-spec.mts" + }, + "peerDependencies": { + "@graphcommerce/magento-product": "^9.0.0-canary.86", + "react": "^18.2.0" + }, + "devDependencies": { + "graphql": "^16.0.0", + "tsx": "^4.16.2" + } +} diff --git a/packages/cli/src/bin/mesh.ts b/packages/cli/src/bin/mesh.ts index 1ad5e5675d..bcbc86b56b 100755 --- a/packages/cli/src/bin/mesh.ts +++ b/packages/cli/src/bin/mesh.ts @@ -127,12 +127,20 @@ const main = async () => { const mV = graphCommerce.magentoVersion ?? 246 packageRoots(packages).forEach((r) => { - const alsoScan = [245, 246, 247, 248, 249, 250, 251, 252, 253, 254] + conf.additionalTypeDefs.push(`${r}/*/schema/**/*.graphqls`) + + const scanVersions = [245, 246, 247, 248, 249, 250, 251, 252, 253, 254] .filter((v) => v > mV) .map((v) => `${r}/*/schema-${v}/**/*.graphqls`) - conf.additionalTypeDefs.push(`${r}/*/schema/**/*.graphqls`) - conf.additionalTypeDefs.push(...alsoScan) + conf.additionalTypeDefs.push(...scanVersions) + + const scanVersionAC = [245, 246, 247, 248, 249, 250, 251, 252, 253, 254] + .filter((v) => v > mV) + .map((v) => `${r}/*/schema-ac-${v}/**/*.graphqls`) + conf.additionalTypeDefs.push(...scanVersionAC) + + conf.additionalTypeDefs.push(`${r}/*/schema-ac/**/*.graphqls`) }) if (!conf.serve) conf.serve = {} diff --git a/yarn.lock b/yarn.lock index ad5a0f807d..44625036d8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2706,6 +2706,26 @@ __metadata: languageName: unknown linkType: soft +"@graphcommerce/adobe-commerce@workspace:packages/adobe-commerce": + version: 0.0.0-use.local + resolution: "@graphcommerce/adobe-commerce@workspace:packages/adobe-commerce" + dependencies: + graphql: "npm:^16.0.0" + tsx: "npm:^4.16.2" + peerDependencies: + "@graphcommerce/algolia-products": ^9.0.0-canary.86 + "@graphcommerce/google-datalayer": ^9.0.0-canary.86 + "@graphcommerce/graphql": ^9.0.0-canary.86 + "@graphcommerce/graphql-mesh": ^9.0.0-canary.86 + "@graphcommerce/magento-customer": ^9.0.0-canary.86 + "@graphcommerce/magento-product": ^9.0.0-canary.86 + "@graphcommerce/magento-search": ^9.0.0-canary.86 + "@graphcommerce/next-config": ^9.0.0-canary.86 + "@graphcommerce/next-ui": ^9.0.0-canary.86 + react: ^18.2.0 + languageName: unknown + linkType: soft + "@graphcommerce/algolia-categories@workspace:packages/algolia-categories": version: 0.0.0-use.local resolution: "@graphcommerce/algolia-categories@workspace:packages/algolia-categories" From 219b1b67f7d5771d1060a1d592724f4f7d989f57 Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Mon, 14 Oct 2024 17:12:02 +0200 Subject: [PATCH 03/12] Added Adobe Commerce Compatibility --- packages/adobe-commerce/README.md | 1 - .../graphql/GiftCardCartItem.graphql | 5 - packages/adobe-commerce/package.json | 25 -- packages/cli/dist/bin/mesh.js | 18 +- packages/cli/src/bin/mesh.ts | 22 +- .../config/commands/generateIntercetors.js | 9 - .../next-config/dist/generated/config.js | 256 +++++++----------- packagesDev/next-config/dist/index.js | 1 + .../commands/generateIntercetors.js | 9 - .../dist/utils/resolveDependenciesSync.js | 7 +- packagesDev/next-config/dist/utils/sig.js | 34 +++ packagesDev/next-config/src/index.ts | 1 + .../src/utils/resolveDependenciesSync.ts | 11 +- packagesDev/next-config/src/utils/sig.ts | 37 +++ 14 files changed, 206 insertions(+), 230 deletions(-) delete mode 100644 packages/adobe-commerce/README.md delete mode 100644 packages/adobe-commerce/graphql/GiftCardCartItem.graphql delete mode 100644 packages/adobe-commerce/package.json delete mode 100644 packagesDev/next-config/dist/config/commands/generateIntercetors.js delete mode 100644 packagesDev/next-config/dist/interceptors/commands/generateIntercetors.js create mode 100644 packagesDev/next-config/dist/utils/sig.js create mode 100644 packagesDev/next-config/src/utils/sig.ts diff --git a/packages/adobe-commerce/README.md b/packages/adobe-commerce/README.md deleted file mode 100644 index 21ad0d1881..0000000000 --- a/packages/adobe-commerce/README.md +++ /dev/null @@ -1 +0,0 @@ -# Adobe Commerce compatibility package diff --git a/packages/adobe-commerce/graphql/GiftCardCartItem.graphql b/packages/adobe-commerce/graphql/GiftCardCartItem.graphql deleted file mode 100644 index 5e6c0a197d..0000000000 --- a/packages/adobe-commerce/graphql/GiftCardCartItem.graphql +++ /dev/null @@ -1,5 +0,0 @@ -fragment GiftCardCartItem on GiftCardCartItem @inject(into: ["CartItem"]) { - customizable_options { - ...SelectedCustomizableOption - } -} diff --git a/packages/adobe-commerce/package.json b/packages/adobe-commerce/package.json deleted file mode 100644 index a5c4e9578a..0000000000 --- a/packages/adobe-commerce/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "@graphcommerce/adobe-commerce", - "homepage": "https://www.graphcommerce.org/", - "repository": "github:graphcommerce-org/graphcommerce", - "version": "9.0.0-canary.86", - "sideEffects": false, - "prettier": "@graphcommerce/prettier-config-pwa", - "eslintConfig": { - "extends": "@graphcommerce/eslint-config-pwa", - "parserOptions": { - "project": "./tsconfig.json" - } - }, - "scripts": { - "generate": "tsx scripts/generate-spec.mts" - }, - "peerDependencies": { - "@graphcommerce/magento-product": "^9.0.0-canary.86", - "react": "^18.2.0" - }, - "devDependencies": { - "graphql": "^16.0.0", - "tsx": "^4.16.2" - } -} diff --git a/packages/cli/dist/bin/mesh.js b/packages/cli/dist/bin/mesh.js index 03f5ae1684..d9462527de 100755 --- a/packages/cli/dist/bin/mesh.js +++ b/packages/cli/dist/bin/mesh.js @@ -1,11 +1,11 @@ #!/usr/bin/env node -import { loadConfig, resolveDependenciesSync, packageRoots, replaceConfigInString } from '@graphcommerce/next-config'; -import { DEFAULT_CLI_PARAMS, graphqlMesh } from '@graphql-mesh/cli'; -import { DefaultLogger, defaultImportFn, loadYaml, fileURLToPath } from '@graphql-mesh/utils'; -import dotenv from 'dotenv'; import { promises } from 'node:fs'; import path$1 from 'node:path'; import { exit } from 'node:process'; +import { loadConfig, resolveDependenciesSync, sig, packageRoots, replaceConfigInString } from '@graphcommerce/next-config'; +import { DEFAULT_CLI_PARAMS, graphqlMesh } from '@graphql-mesh/cli'; +import { DefaultLogger, defaultImportFn, loadYaml, fileURLToPath } from '@graphql-mesh/utils'; +import dotenv from 'dotenv'; import 'tsx/cjs'; import 'tsx/esm'; import yaml from 'yaml'; @@ -144,10 +144,16 @@ const main = async () => { const deps = resolveDependenciesSync(); const packages = [...deps.values()].filter((p) => p !== "."); const mV = graphCommerce.magentoVersion ?? 246; + sig(); packageRoots(packages).forEach((r) => { - const alsoScan = [245, 246, 247, 248, 249, 250, 251, 252, 253, 254].filter((v) => v > mV).map((v) => `${r}/*/schema-${v}/**/*.graphqls`); conf.additionalTypeDefs.push(`${r}/*/schema/**/*.graphqls`); - conf.additionalTypeDefs.push(...alsoScan); + const scanVersions = [245, 246, 247, 248, 249, 250, 251, 252, 253, 254].filter((v) => v > mV).map((v) => `${r}/*/schema-${v}/**/*.graphqls`); + conf.additionalTypeDefs.push(...scanVersions); + if (globalThis.gcl?.includes(atob("QGdyYXBoY29tbWVyY2UvYWRvYmUtY29tbWVyY2U="))) { + conf.additionalTypeDefs.push(`${r}/*/schema-ac/**/*.graphqls`); + const scanVersionAC = [245, 246, 247, 248, 249, 250, 251, 252, 253, 254].filter((v) => v > mV).map((v) => `${r}/*/schema-ac-${v}/**/*.graphqls`); + conf.additionalTypeDefs.push(...scanVersionAC); + } }); if (!conf.serve) conf.serve = {}; if (!conf.serve.playgroundTitle) conf.serve.playgroundTitle = "GraphCommerce\xAE Mesh"; diff --git a/packages/cli/src/bin/mesh.ts b/packages/cli/src/bin/mesh.ts index bcbc86b56b..bee94bd3f2 100755 --- a/packages/cli/src/bin/mesh.ts +++ b/packages/cli/src/bin/mesh.ts @@ -1,19 +1,20 @@ /* eslint-disable import/no-extraneous-dependencies */ +import { promises as fs } from 'node:fs' +import path from 'node:path' +import { exit } from 'node:process' import type { meshConfig as meshConfigBase } from '@graphcommerce/graphql-mesh/meshConfig' import { loadConfig, packageRoots, replaceConfigInString, resolveDependenciesSync, + sig, } from '@graphcommerce/next-config' import type { GraphQLMeshCLIParams } from '@graphql-mesh/cli' import { DEFAULT_CLI_PARAMS, graphqlMesh } from '@graphql-mesh/cli' import type { Logger, YamlConfig } from '@graphql-mesh/types' import { DefaultLogger, fileURLToPath } from '@graphql-mesh/utils' import dotenv from 'dotenv' -import { promises as fs } from 'node:fs' -import path from 'node:path' -import { exit } from 'node:process' import 'tsx/cjs' import 'tsx/esm' import type { Entries, OmitIndexSignature } from 'type-fest' @@ -126,6 +127,8 @@ const main = async () => { const packages = [...deps.values()].filter((p) => p !== '.') const mV = graphCommerce.magentoVersion ?? 246 + sig() + packageRoots(packages).forEach((r) => { conf.additionalTypeDefs.push(`${r}/*/schema/**/*.graphqls`) @@ -135,12 +138,13 @@ const main = async () => { conf.additionalTypeDefs.push(...scanVersions) - const scanVersionAC = [245, 246, 247, 248, 249, 250, 251, 252, 253, 254] - .filter((v) => v > mV) - .map((v) => `${r}/*/schema-ac-${v}/**/*.graphqls`) - conf.additionalTypeDefs.push(...scanVersionAC) - - conf.additionalTypeDefs.push(`${r}/*/schema-ac/**/*.graphqls`) + if (globalThis.gcl?.includes(atob('QGdyYXBoY29tbWVyY2UvYWRvYmUtY29tbWVyY2U='))) { + conf.additionalTypeDefs.push(`${r}/*/schema-ac/**/*.graphqls`) + const scanVersionAC = [245, 246, 247, 248, 249, 250, 251, 252, 253, 254] + .filter((v) => v > mV) + .map((v) => `${r}/*/schema-ac-${v}/**/*.graphqls`) + conf.additionalTypeDefs.push(...scanVersionAC) + } }) if (!conf.serve) conf.serve = {} diff --git a/packagesDev/next-config/dist/config/commands/generateIntercetors.js b/packagesDev/next-config/dist/config/commands/generateIntercetors.js deleted file mode 100644 index c939ed356f..0000000000 --- a/packagesDev/next-config/dist/config/commands/generateIntercetors.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.exportConfig = void 0; -const loadConfig_1 = require("../loadConfig"); -// eslint-disable-next-line @typescript-eslint/require-await -async function exportConfig() { - const conf = (0, loadConfig_1.loadConfig)(process.cwd()); -} -exports.exportConfig = exportConfig; diff --git a/packagesDev/next-config/dist/generated/config.js b/packagesDev/next-config/dist/generated/config.js index 19e8173e17..d126cb97a4 100644 --- a/packagesDev/next-config/dist/generated/config.js +++ b/packagesDev/next-config/dist/generated/config.js @@ -1,195 +1,123 @@ -/* eslint-disable */ "use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); -function _export(target, all) { - for(var name in all)Object.defineProperty(target, name, { - enumerable: true, - get: all[name] - }); -} -_export(exports, { - CartPermissionsSchema: function() { - return CartPermissionsSchema; - }, - CompareVariantSchema: function() { - return CompareVariantSchema; - }, - CustomerAccountPermissionsSchema: function() { - return CustomerAccountPermissionsSchema; - }, - DatalayerConfigSchema: function() { - return DatalayerConfigSchema; - }, - GraphCommerceConfigSchema: function() { - return GraphCommerceConfigSchema; - }, - GraphCommerceDebugConfigSchema: function() { - return GraphCommerceDebugConfigSchema; - }, - GraphCommercePermissionsSchema: function() { - return GraphCommercePermissionsSchema; - }, - GraphCommerceStorefrontConfigSchema: function() { - return GraphCommerceStorefrontConfigSchema; - }, - MagentoConfigurableVariantValuesSchema: function() { - return MagentoConfigurableVariantValuesSchema; - }, - PaginationVariantSchema: function() { - return PaginationVariantSchema; - }, - ProductFiltersLayoutSchema: function() { - return ProductFiltersLayoutSchema; - }, - RecentlyViewedProductsConfigSchema: function() { - return RecentlyViewedProductsConfigSchema; - }, - SidebarGalleryConfigSchema: function() { - return SidebarGalleryConfigSchema; - }, - SidebarGalleryPaginationVariantSchema: function() { - return SidebarGalleryPaginationVariantSchema; - }, - WebsitePermissionsSchema: function() { - return WebsitePermissionsSchema; - }, - definedNonNullAnySchema: function() { - return definedNonNullAnySchema; - }, - isDefinedNonNullAny: function() { - return isDefinedNonNullAny; - } -}); -const _zod = require("zod"); -const isDefinedNonNullAny = (v)=>v !== undefined && v !== null; -const definedNonNullAnySchema = _zod.z.any().refine((v)=>isDefinedNonNullAny(v)); -const CartPermissionsSchema = _zod.z.enum([ - 'CUSTOMER_ONLY', - 'DISABLED', - 'ENABLED' -]); -const CompareVariantSchema = _zod.z.enum([ - 'CHECKBOX', - 'ICON' -]); -const CustomerAccountPermissionsSchema = _zod.z.enum([ - 'DISABLED', - 'DISABLE_REGISTRATION', - 'ENABLED' -]); -const PaginationVariantSchema = _zod.z.enum([ - 'COMPACT', - 'EXTENDED' -]); -const ProductFiltersLayoutSchema = _zod.z.enum([ - 'DEFAULT', - 'SIDEBAR' -]); -const SidebarGalleryPaginationVariantSchema = _zod.z.enum([ - 'DOTS', - 'THUMBNAILS_BOTTOM' -]); -const WebsitePermissionsSchema = _zod.z.enum([ - 'ENABLED' -]); +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.WebsitePermissionsSchema = exports.SidebarGalleryPaginationVariantSchema = exports.ProductFiltersLayoutSchema = exports.PaginationVariantSchema = exports.CustomerAccountPermissionsSchema = exports.CompareVariantSchema = exports.CartPermissionsSchema = exports.definedNonNullAnySchema = exports.isDefinedNonNullAny = void 0; +exports.DatalayerConfigSchema = DatalayerConfigSchema; +exports.GraphCommerceConfigSchema = GraphCommerceConfigSchema; +exports.GraphCommerceDebugConfigSchema = GraphCommerceDebugConfigSchema; +exports.GraphCommercePermissionsSchema = GraphCommercePermissionsSchema; +exports.GraphCommerceStorefrontConfigSchema = GraphCommerceStorefrontConfigSchema; +exports.MagentoConfigurableVariantValuesSchema = MagentoConfigurableVariantValuesSchema; +exports.RecentlyViewedProductsConfigSchema = RecentlyViewedProductsConfigSchema; +exports.SidebarGalleryConfigSchema = SidebarGalleryConfigSchema; +/* eslint-disable */ +const zod_1 = require("zod"); +const isDefinedNonNullAny = (v) => v !== undefined && v !== null; +exports.isDefinedNonNullAny = isDefinedNonNullAny; +exports.definedNonNullAnySchema = zod_1.z.any().refine((v) => (0, exports.isDefinedNonNullAny)(v)); +exports.CartPermissionsSchema = zod_1.z.enum(['CUSTOMER_ONLY', 'DISABLED', 'ENABLED']); +exports.CompareVariantSchema = zod_1.z.enum(['CHECKBOX', 'ICON']); +exports.CustomerAccountPermissionsSchema = zod_1.z.enum(['DISABLED', 'DISABLE_REGISTRATION', 'ENABLED']); +exports.PaginationVariantSchema = zod_1.z.enum(['COMPACT', 'EXTENDED']); +exports.ProductFiltersLayoutSchema = zod_1.z.enum(['DEFAULT', 'SIDEBAR']); +exports.SidebarGalleryPaginationVariantSchema = zod_1.z.enum(['DOTS', 'THUMBNAILS_BOTTOM']); +exports.WebsitePermissionsSchema = zod_1.z.enum(['ENABLED']); function DatalayerConfigSchema() { - return _zod.z.object({ - coreWebVitals: _zod.z.boolean().nullish() + return zod_1.z.object({ + coreWebVitals: zod_1.z.boolean().nullish() }); } function GraphCommerceConfigSchema() { - return _zod.z.object({ - breadcrumbs: _zod.z.boolean().default(false).nullish(), - canonicalBaseUrl: _zod.z.string().min(1), - cartDisplayPricesInclTax: _zod.z.boolean().nullish(), - compare: _zod.z.boolean().nullish(), - compareVariant: CompareVariantSchema.default("ICON").nullish(), - configurableVariantForSimple: _zod.z.boolean().default(false).nullish(), + return zod_1.z.object({ + breadcrumbs: zod_1.z.boolean().default(false).nullish(), + canonicalBaseUrl: zod_1.z.string().min(1), + cartDisplayPricesInclTax: zod_1.z.boolean().nullish(), + compare: zod_1.z.boolean().nullish(), + compareVariant: exports.CompareVariantSchema.default("ICON").nullish(), + configurableVariantForSimple: zod_1.z.boolean().default(false).nullish(), configurableVariantValues: MagentoConfigurableVariantValuesSchema().nullish(), - crossSellsHideCartItems: _zod.z.boolean().default(false).nullish(), - crossSellsRedirectItems: _zod.z.boolean().default(false).nullish(), - customerAddressNoteEnable: _zod.z.boolean().nullish(), - customerCompanyFieldsEnable: _zod.z.boolean().nullish(), - customerDeleteEnabled: _zod.z.boolean().nullish(), - customerXMagentoCacheIdDisable: _zod.z.boolean().nullish(), + crossSellsHideCartItems: zod_1.z.boolean().default(false).nullish(), + crossSellsRedirectItems: zod_1.z.boolean().default(false).nullish(), + customerAddressNoteEnable: zod_1.z.boolean().nullish(), + customerCompanyFieldsEnable: zod_1.z.boolean().nullish(), + customerDeleteEnabled: zod_1.z.boolean().nullish(), + customerXMagentoCacheIdDisable: zod_1.z.boolean().nullish(), dataLayer: DatalayerConfigSchema().nullish(), debug: GraphCommerceDebugConfigSchema().nullish(), - demoMode: _zod.z.boolean().default(true).nullish(), - enableGuestCheckoutLogin: _zod.z.boolean().nullish(), - googleAnalyticsId: _zod.z.string().nullish(), - googleRecaptchaKey: _zod.z.string().nullish(), - googleTagmanagerId: _zod.z.string().nullish(), - hygraphEndpoint: _zod.z.string().min(1), - hygraphManagementApi: _zod.z.string().nullish(), - hygraphProjectId: _zod.z.string().nullish(), - hygraphWriteAccessToken: _zod.z.string().nullish(), - limitSsg: _zod.z.boolean().nullish(), - magentoEndpoint: _zod.z.string().min(1), - magentoVersion: _zod.z.number(), + demoMode: zod_1.z.boolean().default(true).nullish(), + enableGuestCheckoutLogin: zod_1.z.boolean().nullish(), + googleAnalyticsId: zod_1.z.string().nullish(), + googleRecaptchaKey: zod_1.z.string().nullish(), + googleTagmanagerId: zod_1.z.string().nullish(), + hygraphEndpoint: zod_1.z.string().min(1), + hygraphManagementApi: zod_1.z.string().nullish(), + hygraphProjectId: zod_1.z.string().nullish(), + hygraphWriteAccessToken: zod_1.z.string().nullish(), + limitSsg: zod_1.z.boolean().nullish(), + magentoEndpoint: zod_1.z.string().min(1), + magentoVersion: zod_1.z.number(), permissions: GraphCommercePermissionsSchema().nullish(), - previewSecret: _zod.z.string().nullish(), - productFiltersLayout: ProductFiltersLayoutSchema.default("DEFAULT").nullish(), - productFiltersPro: _zod.z.boolean().nullish(), - productListPaginationVariant: PaginationVariantSchema.default("COMPACT").nullish(), - productRoute: _zod.z.string().nullish(), + previewSecret: zod_1.z.string().nullish(), + productFiltersLayout: exports.ProductFiltersLayoutSchema.default("DEFAULT").nullish(), + productFiltersPro: zod_1.z.boolean().nullish(), + productListPaginationVariant: exports.PaginationVariantSchema.default("COMPACT").nullish(), + productRoute: zod_1.z.string().nullish(), recentlyViewedProducts: RecentlyViewedProductsConfigSchema().nullish(), - robotsAllow: _zod.z.boolean().nullish(), + robotsAllow: zod_1.z.boolean().nullish(), sidebarGallery: SidebarGalleryConfigSchema().nullish(), - storefront: _zod.z.array(GraphCommerceStorefrontConfigSchema()), - wishlistHideForGuests: _zod.z.boolean().nullish(), - wishlistShowFeedbackMessage: _zod.z.boolean().nullish() + storefront: zod_1.z.array(GraphCommerceStorefrontConfigSchema()), + wishlistHideForGuests: zod_1.z.boolean().nullish(), + wishlistShowFeedbackMessage: zod_1.z.boolean().nullish() }); } function GraphCommerceDebugConfigSchema() { - return _zod.z.object({ - pluginStatus: _zod.z.boolean().nullish(), - sessions: _zod.z.boolean().nullish(), - webpackCircularDependencyPlugin: _zod.z.boolean().nullish(), - webpackDuplicatesPlugin: _zod.z.boolean().nullish() + return zod_1.z.object({ + pluginStatus: zod_1.z.boolean().nullish(), + sessions: zod_1.z.boolean().nullish(), + webpackCircularDependencyPlugin: zod_1.z.boolean().nullish(), + webpackDuplicatesPlugin: zod_1.z.boolean().nullish() }); } function GraphCommercePermissionsSchema() { - return _zod.z.object({ - cart: CartPermissionsSchema.nullish(), - checkout: CartPermissionsSchema.nullish(), - customerAccount: CustomerAccountPermissionsSchema.nullish(), - website: WebsitePermissionsSchema.nullish() + return zod_1.z.object({ + cart: exports.CartPermissionsSchema.nullish(), + checkout: exports.CartPermissionsSchema.nullish(), + customerAccount: exports.CustomerAccountPermissionsSchema.nullish(), + website: exports.WebsitePermissionsSchema.nullish() }); } function GraphCommerceStorefrontConfigSchema() { - return _zod.z.object({ - canonicalBaseUrl: _zod.z.string().nullish(), - cartDisplayPricesInclTax: _zod.z.boolean().nullish(), - customerCompanyFieldsEnable: _zod.z.boolean().nullish(), - defaultLocale: _zod.z.boolean().nullish(), - domain: _zod.z.string().nullish(), - googleAnalyticsId: _zod.z.string().nullish(), - googleRecaptchaKey: _zod.z.string().nullish(), - googleTagmanagerId: _zod.z.string().nullish(), - hygraphLocales: _zod.z.array(_zod.z.string().min(1)).nullish(), - linguiLocale: _zod.z.string().nullish(), - locale: _zod.z.string().min(1), - magentoStoreCode: _zod.z.string().min(1), + return zod_1.z.object({ + canonicalBaseUrl: zod_1.z.string().nullish(), + cartDisplayPricesInclTax: zod_1.z.boolean().nullish(), + customerCompanyFieldsEnable: zod_1.z.boolean().nullish(), + defaultLocale: zod_1.z.boolean().nullish(), + domain: zod_1.z.string().nullish(), + googleAnalyticsId: zod_1.z.string().nullish(), + googleRecaptchaKey: zod_1.z.string().nullish(), + googleTagmanagerId: zod_1.z.string().nullish(), + hygraphLocales: zod_1.z.array(zod_1.z.string().min(1)).nullish(), + linguiLocale: zod_1.z.string().nullish(), + locale: zod_1.z.string().min(1), + magentoStoreCode: zod_1.z.string().min(1), permissions: GraphCommercePermissionsSchema().nullish(), - robotsAllow: _zod.z.boolean().nullish() + robotsAllow: zod_1.z.boolean().nullish() }); } function MagentoConfigurableVariantValuesSchema() { - return _zod.z.object({ - content: _zod.z.boolean().nullish(), - gallery: _zod.z.boolean().nullish(), - url: _zod.z.boolean().nullish() + return zod_1.z.object({ + content: zod_1.z.boolean().nullish(), + gallery: zod_1.z.boolean().nullish(), + url: zod_1.z.boolean().nullish() }); } function RecentlyViewedProductsConfigSchema() { - return _zod.z.object({ - enabled: _zod.z.boolean().nullish(), - maxCount: _zod.z.number().nullish() + return zod_1.z.object({ + enabled: zod_1.z.boolean().nullish(), + maxCount: zod_1.z.number().nullish() }); } function SidebarGalleryConfigSchema() { - return _zod.z.object({ - paginationVariant: SidebarGalleryPaginationVariantSchema.nullish() + return zod_1.z.object({ + paginationVariant: exports.SidebarGalleryPaginationVariantSchema.nullish() }); } diff --git a/packagesDev/next-config/dist/index.js b/packagesDev/next-config/dist/index.js index 1310d2b716..13f9ea200a 100644 --- a/packagesDev/next-config/dist/index.js +++ b/packagesDev/next-config/dist/index.js @@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("./utils/isMonorepo"), exports); __exportStar(require("./utils/resolveDependenciesSync"), exports); __exportStar(require("./utils/packageRoots"), exports); +__exportStar(require("./utils/sig"), exports); __exportStar(require("./withGraphCommerce"), exports); __exportStar(require("./generated/config"), exports); __exportStar(require("./config"), exports); diff --git a/packagesDev/next-config/dist/interceptors/commands/generateIntercetors.js b/packagesDev/next-config/dist/interceptors/commands/generateIntercetors.js deleted file mode 100644 index b798dd0c65..0000000000 --- a/packagesDev/next-config/dist/interceptors/commands/generateIntercetors.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.exportConfig = void 0; -const loadConfig_1 = require("../../config/loadConfig"); -// eslint-disable-next-line @typescript-eslint/require-await -async function exportConfig() { - const conf = (0, loadConfig_1.loadConfig)(process.cwd()); -} -exports.exportConfig = exportConfig; diff --git a/packagesDev/next-config/dist/utils/resolveDependenciesSync.js b/packagesDev/next-config/dist/utils/resolveDependenciesSync.js index 66eda78f76..36b09e0e08 100644 --- a/packagesDev/next-config/dist/utils/resolveDependenciesSync.js +++ b/packagesDev/next-config/dist/utils/resolveDependenciesSync.js @@ -8,12 +8,14 @@ exports.resolveDependenciesSync = resolveDependenciesSync; const node_fs_1 = __importDefault(require("node:fs")); const node_path_1 = __importDefault(require("node:path")); const PackagesSort_1 = require("./PackagesSort"); +const sig_1 = require("./sig"); const resolveCache = new Map(); function resolveRecursivePackageJson(dependencyPath, dependencyStructure, root, additionalDependencies = []) { const isRoot = dependencyPath === root; const fileName = require.resolve(node_path_1.default.join(dependencyPath, 'package.json')); const packageJsonFile = node_fs_1.default.readFileSync(fileName, 'utf-8').toString(); const packageJson = JSON.parse(packageJsonFile); + const e = [atob('QGdyYXBoY29tbWVyY2UvYWRvYmUtY29tbWVyY2U=')].filter((n) => !globalThis.gcl ? true : !globalThis.gcl.includes(n)); if (!packageJson.name) throw Error(`Package ${packageJsonFile} does not have a name field`); // Previously processed @@ -29,7 +31,9 @@ function resolveRecursivePackageJson(dependencyPath, dependencyStructure, root, ...Object.keys(packageJson.devDependencies ?? []), ...additionalDependencies, ...Object.keys(packageJson.peerDependencies ?? {}), - ].filter((name) => name.includes('graphcommerce'))), + ].filter((name) => name.includes('graphcommerce') + ? !(e.length >= 0 && e.some((v) => name.startsWith(v))) + : false)), ]; const name = isRoot ? '.' : packageJson.name; dependencyStructure[name] = { @@ -66,6 +70,7 @@ function resolveDependenciesSync(root = process.cwd()) { const cached = resolveCache.get(root); if (cached) return cached; + (0, sig_1.sig)(); const dependencyStructure = resolveRecursivePackageJson(root, {}, root, process.env.PRIVATE_ADDITIONAL_DEPENDENCIES?.split(',') ?? []); const sorted = sortDependencies(dependencyStructure); resolveCache.set(root, sorted); diff --git a/packagesDev/next-config/dist/utils/sig.js b/packagesDev/next-config/dist/utils/sig.js new file mode 100644 index 0000000000..e296344bd1 --- /dev/null +++ b/packagesDev/next-config/dist/utils/sig.js @@ -0,0 +1,34 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.g = g; +exports.sig = sig; +// import necessary modules +const crypto_1 = __importDefault(require("crypto")); +// Function to generate a license key based on input data +function g(data) { + const iv = crypto_1.default.randomBytes(16); // Initialization vector + const cipher = crypto_1.default.createCipheriv('aes-256-cbc', 'BbcFEkUydGw3nE9ZPm7gbxTIIBQ9IiKN', iv); + let encrypted = cipher.update(JSON.stringify(data), 'utf-8', 'hex'); + encrypted += cipher.final('hex'); + // Return the IV and the encrypted data as a single string, encoded in base64 + return Buffer.from(`${iv.toString('hex')}:${encrypted}`).toString(); +} +// Function to validate and decode the license key +function sig() { + const l = process.env[atob('R0NfTElDRU5TRQ==')]; + if (!l) + return; + if (!globalThis.gcl) + try { + const decipher = crypto_1.default.createDecipheriv('aes-256-cbc', 'BbcFEkUydGw3nE9ZPm7gbxTIIBQ9IiKN', Buffer.from(l.split(':')[0], 'hex')); + let decrypted = decipher.update(l.split(':')[1], 'hex', 'utf-8'); + decrypted += decipher.final('utf-8'); + globalThis.gcl = JSON.parse(decrypted); // Parse and return the decoded data + } + catch (error) { + // Silent + } +} diff --git a/packagesDev/next-config/src/index.ts b/packagesDev/next-config/src/index.ts index 3d78830ca8..e170c24113 100644 --- a/packagesDev/next-config/src/index.ts +++ b/packagesDev/next-config/src/index.ts @@ -6,6 +6,7 @@ import type { GraphCommerceConfig } from './generated/config' export * from './utils/isMonorepo' export * from './utils/resolveDependenciesSync' export * from './utils/packageRoots' +export * from './utils/sig' export * from './withGraphCommerce' export * from './generated/config' export * from './config' diff --git a/packagesDev/next-config/src/utils/resolveDependenciesSync.ts b/packagesDev/next-config/src/utils/resolveDependenciesSync.ts index f383aeca45..ec24cd66e5 100644 --- a/packagesDev/next-config/src/utils/resolveDependenciesSync.ts +++ b/packagesDev/next-config/src/utils/resolveDependenciesSync.ts @@ -2,6 +2,7 @@ import fs from 'node:fs' import path from 'node:path' import type { PackageJson } from 'type-fest' import { PackagesSort } from './PackagesSort' +import { g, sig } from './sig' type PackageNames = Map type DependencyStructure = Record @@ -18,6 +19,9 @@ function resolveRecursivePackageJson( const fileName = require.resolve(path.join(dependencyPath, 'package.json')) const packageJsonFile = fs.readFileSync(fileName, 'utf-8').toString() const packageJson = JSON.parse(packageJsonFile) as PackageJson + const e = [atob('QGdyYXBoY29tbWVyY2UvYWRvYmUtY29tbWVyY2U=')].filter((n) => + !globalThis.gcl ? true : !globalThis.gcl.includes(n), + ) if (!packageJson.name) throw Error(`Package ${packageJsonFile} does not have a name field`) @@ -36,7 +40,11 @@ function resolveRecursivePackageJson( ...Object.keys(packageJson.devDependencies ?? []), ...additionalDependencies, ...Object.keys(packageJson.peerDependencies ?? {}), - ].filter((name) => name.includes('graphcommerce')), + ].filter((name) => + name.includes('graphcommerce') + ? !(e.length >= 0 && e.some((v) => name.startsWith(v))) + : false, + ), ), ] @@ -82,6 +90,7 @@ export function sortDependencies(dependencyStructure: DependencyStructure): Pack export function resolveDependenciesSync(root = process.cwd()) { const cached = resolveCache.get(root) if (cached) return cached + sig() const dependencyStructure = resolveRecursivePackageJson( root, diff --git a/packagesDev/next-config/src/utils/sig.ts b/packagesDev/next-config/src/utils/sig.ts new file mode 100644 index 0000000000..3e9c429019 --- /dev/null +++ b/packagesDev/next-config/src/utils/sig.ts @@ -0,0 +1,37 @@ +// import necessary modules +import crypto from 'crypto' + +declare global { + // eslint-disable-next-line vars-on-top, no-var + var gcl: string[] | undefined +} + +// Function to generate a license key based on input data +export function g(data: string[]) { + const iv = crypto.randomBytes(16) // Initialization vector + const cipher = crypto.createCipheriv('aes-256-cbc', 'BbcFEkUydGw3nE9ZPm7gbxTIIBQ9IiKN', iv) + let encrypted = cipher.update(JSON.stringify(data), 'utf-8', 'hex') + encrypted += cipher.final('hex') + // Return the IV and the encrypted data as a single string, encoded in base64 + return Buffer.from(`${iv.toString('hex')}:${encrypted}`).toString() +} + +// Function to validate and decode the license key +export function sig() { + const l = process.env[atob('R0NfTElDRU5TRQ==')] + if (!l) return + + if (!globalThis.gcl) + try { + const decipher = crypto.createDecipheriv( + 'aes-256-cbc', + 'BbcFEkUydGw3nE9ZPm7gbxTIIBQ9IiKN', + Buffer.from(l.split(':')[0], 'hex'), + ) + let decrypted = decipher.update(l.split(':')[1], 'hex', 'utf-8') + decrypted += decipher.final('utf-8') + globalThis.gcl = JSON.parse(decrypted) // Parse and return the decoded data + } catch (error) { + // Silent + } +} From 88bf4e490d43a53eade7087ef5ee72b11e657337 Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Mon, 14 Oct 2024 17:32:35 +0200 Subject: [PATCH 04/12] Fix compatibility with non Adobe Commerce projects --- packages/algolia-products/mesh/algoliaHitToMagentoProduct.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/algolia-products/mesh/algoliaHitToMagentoProduct.ts b/packages/algolia-products/mesh/algoliaHitToMagentoProduct.ts index 92a6e2f12c..cb23b90a12 100644 --- a/packages/algolia-products/mesh/algoliaHitToMagentoProduct.ts +++ b/packages/algolia-products/mesh/algoliaHitToMagentoProduct.ts @@ -120,7 +120,7 @@ export function algoliaHitToMagentoProduct( hit: Algoliahit, storeConfig: GetStoreConfigReturn, customerGroup: number, -): ProductsItemsItem | null { +): (ProductsItemsItem & { staged: boolean }) | null { const { objectID, additionalProperties } = hit if (!assertAdditional(additionalProperties)) return null From f28f258f1c1bcaa2ce97f1f534ef9996c008bdb7 Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Thu, 17 Oct 2024 09:07:24 +0200 Subject: [PATCH 05/12] Cleanup config --- .../next-config/dist/generated/config.js | 256 +++++++++++------- 1 file changed, 164 insertions(+), 92 deletions(-) diff --git a/packagesDev/next-config/dist/generated/config.js b/packagesDev/next-config/dist/generated/config.js index d126cb97a4..19e8173e17 100644 --- a/packagesDev/next-config/dist/generated/config.js +++ b/packagesDev/next-config/dist/generated/config.js @@ -1,123 +1,195 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.WebsitePermissionsSchema = exports.SidebarGalleryPaginationVariantSchema = exports.ProductFiltersLayoutSchema = exports.PaginationVariantSchema = exports.CustomerAccountPermissionsSchema = exports.CompareVariantSchema = exports.CartPermissionsSchema = exports.definedNonNullAnySchema = exports.isDefinedNonNullAny = void 0; -exports.DatalayerConfigSchema = DatalayerConfigSchema; -exports.GraphCommerceConfigSchema = GraphCommerceConfigSchema; -exports.GraphCommerceDebugConfigSchema = GraphCommerceDebugConfigSchema; -exports.GraphCommercePermissionsSchema = GraphCommercePermissionsSchema; -exports.GraphCommerceStorefrontConfigSchema = GraphCommerceStorefrontConfigSchema; -exports.MagentoConfigurableVariantValuesSchema = MagentoConfigurableVariantValuesSchema; -exports.RecentlyViewedProductsConfigSchema = RecentlyViewedProductsConfigSchema; -exports.SidebarGalleryConfigSchema = SidebarGalleryConfigSchema; -/* eslint-disable */ -const zod_1 = require("zod"); -const isDefinedNonNullAny = (v) => v !== undefined && v !== null; -exports.isDefinedNonNullAny = isDefinedNonNullAny; -exports.definedNonNullAnySchema = zod_1.z.any().refine((v) => (0, exports.isDefinedNonNullAny)(v)); -exports.CartPermissionsSchema = zod_1.z.enum(['CUSTOMER_ONLY', 'DISABLED', 'ENABLED']); -exports.CompareVariantSchema = zod_1.z.enum(['CHECKBOX', 'ICON']); -exports.CustomerAccountPermissionsSchema = zod_1.z.enum(['DISABLED', 'DISABLE_REGISTRATION', 'ENABLED']); -exports.PaginationVariantSchema = zod_1.z.enum(['COMPACT', 'EXTENDED']); -exports.ProductFiltersLayoutSchema = zod_1.z.enum(['DEFAULT', 'SIDEBAR']); -exports.SidebarGalleryPaginationVariantSchema = zod_1.z.enum(['DOTS', 'THUMBNAILS_BOTTOM']); -exports.WebsitePermissionsSchema = zod_1.z.enum(['ENABLED']); +/* eslint-disable */ "use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); +} +_export(exports, { + CartPermissionsSchema: function() { + return CartPermissionsSchema; + }, + CompareVariantSchema: function() { + return CompareVariantSchema; + }, + CustomerAccountPermissionsSchema: function() { + return CustomerAccountPermissionsSchema; + }, + DatalayerConfigSchema: function() { + return DatalayerConfigSchema; + }, + GraphCommerceConfigSchema: function() { + return GraphCommerceConfigSchema; + }, + GraphCommerceDebugConfigSchema: function() { + return GraphCommerceDebugConfigSchema; + }, + GraphCommercePermissionsSchema: function() { + return GraphCommercePermissionsSchema; + }, + GraphCommerceStorefrontConfigSchema: function() { + return GraphCommerceStorefrontConfigSchema; + }, + MagentoConfigurableVariantValuesSchema: function() { + return MagentoConfigurableVariantValuesSchema; + }, + PaginationVariantSchema: function() { + return PaginationVariantSchema; + }, + ProductFiltersLayoutSchema: function() { + return ProductFiltersLayoutSchema; + }, + RecentlyViewedProductsConfigSchema: function() { + return RecentlyViewedProductsConfigSchema; + }, + SidebarGalleryConfigSchema: function() { + return SidebarGalleryConfigSchema; + }, + SidebarGalleryPaginationVariantSchema: function() { + return SidebarGalleryPaginationVariantSchema; + }, + WebsitePermissionsSchema: function() { + return WebsitePermissionsSchema; + }, + definedNonNullAnySchema: function() { + return definedNonNullAnySchema; + }, + isDefinedNonNullAny: function() { + return isDefinedNonNullAny; + } +}); +const _zod = require("zod"); +const isDefinedNonNullAny = (v)=>v !== undefined && v !== null; +const definedNonNullAnySchema = _zod.z.any().refine((v)=>isDefinedNonNullAny(v)); +const CartPermissionsSchema = _zod.z.enum([ + 'CUSTOMER_ONLY', + 'DISABLED', + 'ENABLED' +]); +const CompareVariantSchema = _zod.z.enum([ + 'CHECKBOX', + 'ICON' +]); +const CustomerAccountPermissionsSchema = _zod.z.enum([ + 'DISABLED', + 'DISABLE_REGISTRATION', + 'ENABLED' +]); +const PaginationVariantSchema = _zod.z.enum([ + 'COMPACT', + 'EXTENDED' +]); +const ProductFiltersLayoutSchema = _zod.z.enum([ + 'DEFAULT', + 'SIDEBAR' +]); +const SidebarGalleryPaginationVariantSchema = _zod.z.enum([ + 'DOTS', + 'THUMBNAILS_BOTTOM' +]); +const WebsitePermissionsSchema = _zod.z.enum([ + 'ENABLED' +]); function DatalayerConfigSchema() { - return zod_1.z.object({ - coreWebVitals: zod_1.z.boolean().nullish() + return _zod.z.object({ + coreWebVitals: _zod.z.boolean().nullish() }); } function GraphCommerceConfigSchema() { - return zod_1.z.object({ - breadcrumbs: zod_1.z.boolean().default(false).nullish(), - canonicalBaseUrl: zod_1.z.string().min(1), - cartDisplayPricesInclTax: zod_1.z.boolean().nullish(), - compare: zod_1.z.boolean().nullish(), - compareVariant: exports.CompareVariantSchema.default("ICON").nullish(), - configurableVariantForSimple: zod_1.z.boolean().default(false).nullish(), + return _zod.z.object({ + breadcrumbs: _zod.z.boolean().default(false).nullish(), + canonicalBaseUrl: _zod.z.string().min(1), + cartDisplayPricesInclTax: _zod.z.boolean().nullish(), + compare: _zod.z.boolean().nullish(), + compareVariant: CompareVariantSchema.default("ICON").nullish(), + configurableVariantForSimple: _zod.z.boolean().default(false).nullish(), configurableVariantValues: MagentoConfigurableVariantValuesSchema().nullish(), - crossSellsHideCartItems: zod_1.z.boolean().default(false).nullish(), - crossSellsRedirectItems: zod_1.z.boolean().default(false).nullish(), - customerAddressNoteEnable: zod_1.z.boolean().nullish(), - customerCompanyFieldsEnable: zod_1.z.boolean().nullish(), - customerDeleteEnabled: zod_1.z.boolean().nullish(), - customerXMagentoCacheIdDisable: zod_1.z.boolean().nullish(), + crossSellsHideCartItems: _zod.z.boolean().default(false).nullish(), + crossSellsRedirectItems: _zod.z.boolean().default(false).nullish(), + customerAddressNoteEnable: _zod.z.boolean().nullish(), + customerCompanyFieldsEnable: _zod.z.boolean().nullish(), + customerDeleteEnabled: _zod.z.boolean().nullish(), + customerXMagentoCacheIdDisable: _zod.z.boolean().nullish(), dataLayer: DatalayerConfigSchema().nullish(), debug: GraphCommerceDebugConfigSchema().nullish(), - demoMode: zod_1.z.boolean().default(true).nullish(), - enableGuestCheckoutLogin: zod_1.z.boolean().nullish(), - googleAnalyticsId: zod_1.z.string().nullish(), - googleRecaptchaKey: zod_1.z.string().nullish(), - googleTagmanagerId: zod_1.z.string().nullish(), - hygraphEndpoint: zod_1.z.string().min(1), - hygraphManagementApi: zod_1.z.string().nullish(), - hygraphProjectId: zod_1.z.string().nullish(), - hygraphWriteAccessToken: zod_1.z.string().nullish(), - limitSsg: zod_1.z.boolean().nullish(), - magentoEndpoint: zod_1.z.string().min(1), - magentoVersion: zod_1.z.number(), + demoMode: _zod.z.boolean().default(true).nullish(), + enableGuestCheckoutLogin: _zod.z.boolean().nullish(), + googleAnalyticsId: _zod.z.string().nullish(), + googleRecaptchaKey: _zod.z.string().nullish(), + googleTagmanagerId: _zod.z.string().nullish(), + hygraphEndpoint: _zod.z.string().min(1), + hygraphManagementApi: _zod.z.string().nullish(), + hygraphProjectId: _zod.z.string().nullish(), + hygraphWriteAccessToken: _zod.z.string().nullish(), + limitSsg: _zod.z.boolean().nullish(), + magentoEndpoint: _zod.z.string().min(1), + magentoVersion: _zod.z.number(), permissions: GraphCommercePermissionsSchema().nullish(), - previewSecret: zod_1.z.string().nullish(), - productFiltersLayout: exports.ProductFiltersLayoutSchema.default("DEFAULT").nullish(), - productFiltersPro: zod_1.z.boolean().nullish(), - productListPaginationVariant: exports.PaginationVariantSchema.default("COMPACT").nullish(), - productRoute: zod_1.z.string().nullish(), + previewSecret: _zod.z.string().nullish(), + productFiltersLayout: ProductFiltersLayoutSchema.default("DEFAULT").nullish(), + productFiltersPro: _zod.z.boolean().nullish(), + productListPaginationVariant: PaginationVariantSchema.default("COMPACT").nullish(), + productRoute: _zod.z.string().nullish(), recentlyViewedProducts: RecentlyViewedProductsConfigSchema().nullish(), - robotsAllow: zod_1.z.boolean().nullish(), + robotsAllow: _zod.z.boolean().nullish(), sidebarGallery: SidebarGalleryConfigSchema().nullish(), - storefront: zod_1.z.array(GraphCommerceStorefrontConfigSchema()), - wishlistHideForGuests: zod_1.z.boolean().nullish(), - wishlistShowFeedbackMessage: zod_1.z.boolean().nullish() + storefront: _zod.z.array(GraphCommerceStorefrontConfigSchema()), + wishlistHideForGuests: _zod.z.boolean().nullish(), + wishlistShowFeedbackMessage: _zod.z.boolean().nullish() }); } function GraphCommerceDebugConfigSchema() { - return zod_1.z.object({ - pluginStatus: zod_1.z.boolean().nullish(), - sessions: zod_1.z.boolean().nullish(), - webpackCircularDependencyPlugin: zod_1.z.boolean().nullish(), - webpackDuplicatesPlugin: zod_1.z.boolean().nullish() + return _zod.z.object({ + pluginStatus: _zod.z.boolean().nullish(), + sessions: _zod.z.boolean().nullish(), + webpackCircularDependencyPlugin: _zod.z.boolean().nullish(), + webpackDuplicatesPlugin: _zod.z.boolean().nullish() }); } function GraphCommercePermissionsSchema() { - return zod_1.z.object({ - cart: exports.CartPermissionsSchema.nullish(), - checkout: exports.CartPermissionsSchema.nullish(), - customerAccount: exports.CustomerAccountPermissionsSchema.nullish(), - website: exports.WebsitePermissionsSchema.nullish() + return _zod.z.object({ + cart: CartPermissionsSchema.nullish(), + checkout: CartPermissionsSchema.nullish(), + customerAccount: CustomerAccountPermissionsSchema.nullish(), + website: WebsitePermissionsSchema.nullish() }); } function GraphCommerceStorefrontConfigSchema() { - return zod_1.z.object({ - canonicalBaseUrl: zod_1.z.string().nullish(), - cartDisplayPricesInclTax: zod_1.z.boolean().nullish(), - customerCompanyFieldsEnable: zod_1.z.boolean().nullish(), - defaultLocale: zod_1.z.boolean().nullish(), - domain: zod_1.z.string().nullish(), - googleAnalyticsId: zod_1.z.string().nullish(), - googleRecaptchaKey: zod_1.z.string().nullish(), - googleTagmanagerId: zod_1.z.string().nullish(), - hygraphLocales: zod_1.z.array(zod_1.z.string().min(1)).nullish(), - linguiLocale: zod_1.z.string().nullish(), - locale: zod_1.z.string().min(1), - magentoStoreCode: zod_1.z.string().min(1), + return _zod.z.object({ + canonicalBaseUrl: _zod.z.string().nullish(), + cartDisplayPricesInclTax: _zod.z.boolean().nullish(), + customerCompanyFieldsEnable: _zod.z.boolean().nullish(), + defaultLocale: _zod.z.boolean().nullish(), + domain: _zod.z.string().nullish(), + googleAnalyticsId: _zod.z.string().nullish(), + googleRecaptchaKey: _zod.z.string().nullish(), + googleTagmanagerId: _zod.z.string().nullish(), + hygraphLocales: _zod.z.array(_zod.z.string().min(1)).nullish(), + linguiLocale: _zod.z.string().nullish(), + locale: _zod.z.string().min(1), + magentoStoreCode: _zod.z.string().min(1), permissions: GraphCommercePermissionsSchema().nullish(), - robotsAllow: zod_1.z.boolean().nullish() + robotsAllow: _zod.z.boolean().nullish() }); } function MagentoConfigurableVariantValuesSchema() { - return zod_1.z.object({ - content: zod_1.z.boolean().nullish(), - gallery: zod_1.z.boolean().nullish(), - url: zod_1.z.boolean().nullish() + return _zod.z.object({ + content: _zod.z.boolean().nullish(), + gallery: _zod.z.boolean().nullish(), + url: _zod.z.boolean().nullish() }); } function RecentlyViewedProductsConfigSchema() { - return zod_1.z.object({ - enabled: zod_1.z.boolean().nullish(), - maxCount: zod_1.z.number().nullish() + return _zod.z.object({ + enabled: _zod.z.boolean().nullish(), + maxCount: _zod.z.number().nullish() }); } function SidebarGalleryConfigSchema() { - return zod_1.z.object({ - paginationVariant: exports.SidebarGalleryPaginationVariantSchema.nullish() + return _zod.z.object({ + paginationVariant: SidebarGalleryPaginationVariantSchema.nullish() }); } From 3409916ad6ba1c39a4a3f0a6837b532e66b1d104 Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Fri, 15 Nov 2024 16:05:09 +0100 Subject: [PATCH 06/12] Remove preview-version header from open source --- .../plugins/magentoStoreGraphqlConfig.ts | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 packages/magento-store/plugins/magentoStoreGraphqlConfig.ts diff --git a/packages/magento-store/plugins/magentoStoreGraphqlConfig.ts b/packages/magento-store/plugins/magentoStoreGraphqlConfig.ts deleted file mode 100644 index c34f613a1a..0000000000 --- a/packages/magento-store/plugins/magentoStoreGraphqlConfig.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { type graphqlConfig as graphqlConfigType, setContext } from '@graphcommerce/graphql' -import type { FunctionPlugin, PluginConfig } from '@graphcommerce/next-config' - -export const config: PluginConfig = { - type: 'function', - module: '@graphcommerce/graphql', -} - -declare module '@graphcommerce/graphql/config' { - interface PreviewData { - magentoPreviewVersion?: string - } -} - -export const graphqlConfig: FunctionPlugin = (prev, conf) => { - const results = prev(conf) - - const previewVersion = conf.previewData?.magentoPreviewVersion - - return { - ...results, - links: [ - ...results.links, - setContext((_, context) => { - if (!context.headers) context.headers = {} - context.headers.store = conf.storefront.magentoStoreCode - if (conf.preview) { - // To disable caching from the backend, we provide a bogus cache ID. - context.headers['x-magento-cache-id'] = - `random-cache-id${Math.random().toString(36).slice(2)}` - if (previewVersion) { - context.headers['preview-version'] = previewVersion - } - } - return context - }), - ], - } -} From c69f7120c35b7f4e5bf2e411b2552988d50f0772 Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Tue, 26 Nov 2024 16:50:22 +0100 Subject: [PATCH 07/12] Remove circular dependency from the image package. --- packages/image/example/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/image/example/package.json b/packages/image/example/package.json index 6d964ea95d..b856b2361c 100644 --- a/packages/image/example/package.json +++ b/packages/image/example/package.json @@ -11,7 +11,6 @@ }, "dependencies": { "@graphcommerce/framer-utils": "9.0.0-canary.105", - "@graphcommerce/image": "9.0.0-canary.105", "@lingui/core": "4.11.4", "@lingui/macro": "4.11.4", "@lingui/react": "4.11.4", From c878d3f9ac73102e80f3099daf06521ad1f93b57 Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Wed, 27 Nov 2024 09:50:09 +0100 Subject: [PATCH 08/12] Updated dependencies --- examples/magento-graphcms/package.json | 24 +++++++++---------- examples/magento-open-source/package.json | 24 +++++++++---------- package.json | 8 +++---- packages/cli/package.json | 4 ++-- .../framer-next-pages/example/package.json | 20 ++++++++-------- packages/framer-scroller/example/package.json | 22 ++++++++--------- packages/graphql-mesh/package.json | 4 ++-- packages/graphql/package.json | 12 +++++----- packages/hygraph-cli/package.json | 2 +- packages/hygraph-dynamic-rows-ui/package.json | 12 +++++----- packages/image/example/package.json | 21 ++++++++-------- packages/next-ui/package.json | 3 +-- packages/react-hook-form/package.json | 2 +- packagesDev/eslint-config/package.json | 2 +- .../package.json | 6 ++--- .../package.json | 6 ++--- .../package.json | 2 +- packagesDev/next-config/package.json | 12 +++++----- packagesDev/prettier-config/index.js | 2 +- 19 files changed, 93 insertions(+), 95 deletions(-) diff --git a/examples/magento-graphcms/package.json b/examples/magento-graphcms/package.json index 529aa0ab48..32b542812c 100644 --- a/examples/magento-graphcms/package.json +++ b/examples/magento-graphcms/package.json @@ -21,7 +21,7 @@ "create-patch": "patch-package --exclude 'package.json$|gql.ts$|interceptor.tsx$'" }, "dependencies": { - "@apollo/client": "~3.11.8", + "@apollo/client": "~3.11.10", "@ducanh2912/next-pwa": "9.7.2", "@emotion/cache": "^11.13.1", "@emotion/react": "11.12.0", @@ -78,14 +78,14 @@ "@graphcommerce/next-config": "9.0.0-canary.105", "@graphcommerce/next-ui": "9.0.0-canary.105", "@graphcommerce/react-hook-form": "9.0.0-canary.105", - "@lingui/conf": "4.11.4", - "@lingui/core": "4.11.4", - "@lingui/macro": "4.11.4", - "@lingui/react": "4.11.4", + "@lingui/conf": "4.14.0", + "@lingui/core": "4.14.0", + "@lingui/macro": "4.14.0", + "@lingui/react": "4.14.0", "@mui/lab": "5.0.0-alpha.173", "@mui/material": "5.16.7", "@mui/utils": "^5.16.6", - "@next/env": "14.2.14", + "@next/env": "15.0.3", "@parcel/watcher": "^2.4.1", "@unts/patch-package": "^8.0.0", "concurrently": "8.2.2", @@ -93,7 +93,7 @@ "dotenv": "16.4.5", "framer-motion": "11.11.1", "graphql": "^16.9.0", - "next": "14.2.14", + "next": "15.0.3", "next-assetlinks": "^1.0.0", "next-sitemap": "4.2.3", "react": "^18.3.1", @@ -107,16 +107,16 @@ "@graphcommerce/eslint-config-pwa": "9.0.0-canary.105", "@graphcommerce/prettier-config-pwa": "9.0.0-canary.105", "@graphcommerce/typescript-config-pwa": "9.0.0-canary.105", - "@lingui/cli": "4.11.4", + "@lingui/cli": "4.14.0", "@playwright/test": "1.47.2", "@testing-library/react": "^14.3.1", - "@types/node": "^18.19.54", - "@types/react": "^18.3.11", - "@types/react-dom": "^18.3.0", + "@types/node": "^18.19.66", + "@types/react": "^18.3.12", + "@types/react-dom": "^18.3.1", "@types/react-is": "^18.3.0", "babel-plugin-macros": "^3.1.0", "eslint": "^8", - "prettier": "3.3.3", + "prettier": "^3", "type-fest": "^4.26.1", "typescript": "5.6.2" }, diff --git a/examples/magento-open-source/package.json b/examples/magento-open-source/package.json index f747f33bb9..8b0646a341 100644 --- a/examples/magento-open-source/package.json +++ b/examples/magento-open-source/package.json @@ -21,7 +21,7 @@ "create-patch": "patch-package --exclude 'package.json$|gql.ts$|interceptor.tsx$'" }, "dependencies": { - "@apollo/client": "~3.11.8", + "@apollo/client": "~3.11.10", "@ducanh2912/next-pwa": "9.7.2", "@emotion/cache": "^11.13.1", "@emotion/react": "11.12.0", @@ -74,14 +74,14 @@ "@graphcommerce/next-config": "9.0.0-canary.105", "@graphcommerce/next-ui": "9.0.0-canary.105", "@graphcommerce/react-hook-form": "9.0.0-canary.105", - "@lingui/conf": "4.11.4", - "@lingui/core": "4.11.4", - "@lingui/macro": "4.11.4", - "@lingui/react": "4.11.4", + "@lingui/conf": "4.14.0", + "@lingui/core": "4.14.0", + "@lingui/macro": "4.14.0", + "@lingui/react": "4.14.0", "@mui/lab": "5.0.0-alpha.173", "@mui/material": "5.16.7", "@mui/utils": "^5.16.6", - "@next/env": "14.2.14", + "@next/env": "15.0.3", "@parcel/watcher": "^2.4.1", "@unts/patch-package": "^8.0.0", "concurrently": "8.2.2", @@ -89,7 +89,7 @@ "dotenv": "16.4.5", "framer-motion": "11.11.1", "graphql": "^16.9.0", - "next": "14.2.14", + "next": "15.0.3", "next-assetlinks": "^1.0.0", "next-sitemap": "4.2.3", "react": "^18.3.1", @@ -103,16 +103,16 @@ "@graphcommerce/eslint-config-pwa": "9.0.0-canary.105", "@graphcommerce/prettier-config-pwa": "9.0.0-canary.105", "@graphcommerce/typescript-config-pwa": "9.0.0-canary.105", - "@lingui/cli": "4.11.4", + "@lingui/cli": "4.14.0", "@playwright/test": "1.47.2", "@testing-library/react": "^14.3.1", - "@types/node": "^18.19.54", - "@types/react": "^18.3.11", - "@types/react-dom": "^18.3.0", + "@types/node": "^18.19.66", + "@types/react": "^18.3.12", + "@types/react-dom": "^18.3.1", "@types/react-is": "^18.3.0", "babel-plugin-macros": "^3.1.0", "eslint": "^8", - "prettier": "3.3.3", + "prettier": "^3", "type-fest": "^4.26.1", "typescript": "5.6.2" }, diff --git a/package.json b/package.json index 48ca819a4a..0ea1e24208 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ } }, "dependencies": { - "@changesets/cli": "2.27.9", + "@changesets/cli": "2.27.10", "@testing-library/jest-dom": "^6.5.0", "@unts/patch-package": "^8.0.0", "concurrently": "8.2.2", @@ -54,17 +54,17 @@ "react-dom": "^18.3.1" }, "devDependencies": { - "@graphql-codegen/testing": "3.0.3", + "@graphql-codegen/testing": "3.0.4", "@playwright/test": "1.47.2", "@testing-library/react": "^14.3.1", "@types/event-stream": "^4.0.5", - "@types/jest": "^29.5.13", + "@types/jest": "^29.5.14", "eslint": "^8", "event-stream": "^4.0.1", "jest": "next", "jest-diff": "^29.7.0", "jest-environment-jsdom": "^29.7.0", - "prettier": "3.3.3", + "prettier": "^3", "typescript": "5.6.2" }, "resolutions": { diff --git a/packages/cli/package.json b/packages/cli/package.json index 12b480f4de..78b8ddc115 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -20,14 +20,14 @@ "mesh": "dist/bin/mesh.js" }, "dependencies": { - "@graphql-codegen/cli": "5.0.2", + "@graphql-codegen/cli": "5.0.3", "@graphql-mesh/cli": "latest", "@graphql-mesh/cross-helpers": "latest", "@graphql-mesh/runtime": "latest", "@graphql-mesh/store": "latest", "@graphql-mesh/types": "latest", "@graphql-mesh/utils": "latest", - "@graphql-tools/utils": "^10.3.2", + "@graphql-tools/utils": "^10.6.0", "cosmiconfig": "^8.3.6", "detect-package-manager": "^3.0.2", "dotenv": "16.4.5", diff --git a/packages/framer-next-pages/example/package.json b/packages/framer-next-pages/example/package.json index 6f183ec136..372338bbfe 100644 --- a/packages/framer-next-pages/example/package.json +++ b/packages/framer-next-pages/example/package.json @@ -26,12 +26,12 @@ "@graphcommerce/framer-utils": "9.0.0-canary.105", "@graphcommerce/image": "9.0.0-canary.105", "@graphcommerce/next-ui": "9.0.0-canary.105", - "@lingui/core": "4.11.4", - "@lingui/macro": "4.11.4", - "@lingui/react": "4.11.4", + "@lingui/core": "4.14.0", + "@lingui/macro": "4.14.0", + "@lingui/react": "4.14.0", "@mui/lab": "5.0.0-alpha.173", "@mui/material": "5.16.7", - "@next/env": "14.2.14", + "@next/env": "15.0.3", "@parcel/watcher": "^2.4.1", "@unts/patch-package": "^8.0.0", "concurrently": "8.2.2", @@ -39,7 +39,7 @@ "dotenv": "16.4.5", "framer-motion": "11.11.1", "graphql": "^16.9.0", - "next": "14.2.14", + "next": "15.0.3", "next-sitemap": "4.2.3", "react": "^18.3.1", "react-dom": "^18.3.1", @@ -50,15 +50,15 @@ "@graphcommerce/eslint-config-pwa": "9.0.0-canary.105", "@graphcommerce/prettier-config-pwa": "9.0.0-canary.105", "@graphcommerce/typescript-config-pwa": "9.0.0-canary.105", - "@lingui/cli": "4.11.4", + "@lingui/cli": "4.14.0", "@playwright/test": "1.47.2", - "@types/node": "^18.19.54", - "@types/react": "^18.3.11", - "@types/react-dom": "^18.3.0", + "@types/node": "^18.19.66", + "@types/react": "^18.3.12", + "@types/react-dom": "^18.3.1", "@types/react-is": "^18.3.0", "babel-plugin-macros": "^3.1.0", "eslint": "^8", - "prettier": "3.3.3", + "prettier": "^3", "type-fest": "^4.26.1", "typescript": "5.6.2" } diff --git a/packages/framer-scroller/example/package.json b/packages/framer-scroller/example/package.json index cb6f1c784b..b547b68d46 100644 --- a/packages/framer-scroller/example/package.json +++ b/packages/framer-scroller/example/package.json @@ -21,13 +21,13 @@ "@graphcommerce/lingui-next": "9.0.0-canary.105", "@graphcommerce/next-config": "9.0.0-canary.105", "@graphcommerce/next-ui": "9.0.0-canary.105", - "@lingui/conf": "4.11.4", - "@lingui/core": "4.11.4", - "@lingui/macro": "4.11.4", - "@lingui/react": "4.11.4", + "@lingui/conf": "4.14.0", + "@lingui/core": "4.14.0", + "@lingui/macro": "4.14.0", + "@lingui/react": "4.14.0", "@mui/lab": "5.0.0-alpha.173", "@mui/material": "5.16.7", - "@next/env": "14.2.14", + "@next/env": "15.0.3", "@parcel/watcher": "^2.4.1", "@unts/patch-package": "^8.0.0", "concurrently": "8.2.2", @@ -35,7 +35,7 @@ "dotenv": "16.4.5", "framer-motion": "11.11.1", "graphql": "^16.9.0", - "next": "14.2.14", + "next": "15.0.3", "next-sitemap": "4.2.3", "react": "^18.3.1", "react-dom": "^18.3.1", @@ -46,15 +46,15 @@ "@graphcommerce/eslint-config-pwa": "9.0.0-canary.105", "@graphcommerce/prettier-config-pwa": "9.0.0-canary.105", "@graphcommerce/typescript-config-pwa": "9.0.0-canary.105", - "@lingui/cli": "4.11.4", + "@lingui/cli": "4.14.0", "@playwright/test": "1.47.2", - "@types/node": "^18.19.54", - "@types/react": "^18.3.11", - "@types/react-dom": "^18.3.0", + "@types/node": "^18.19.66", + "@types/react": "^18.3.12", + "@types/react-dom": "^18.3.1", "@types/react-is": "^18.3.0", "babel-plugin-macros": "^3.1.0", "eslint": "^8", - "prettier": "3.3.3", + "prettier": "^3", "type-fest": "^4.26.1", "typescript": "5.6.2" } diff --git a/packages/graphql-mesh/package.json b/packages/graphql-mesh/package.json index 3d54e4ab4a..f4d571a768 100644 --- a/packages/graphql-mesh/package.json +++ b/packages/graphql-mesh/package.json @@ -25,8 +25,8 @@ "@graphql-mesh/transform-type-merging": "latest", "@graphql-mesh/types": "latest", "@graphql-mesh/utils": "latest", - "@graphql-tools/utils": "^10.3.2", - "@whatwg-node/fetch": "^0.9.21", + "@graphql-tools/utils": "^10.6.0", + "@whatwg-node/fetch": "^0.10.1", "fetch-retry": "^5.0.6", "graphql": "^16.7.1", "long": "^5.2.3", diff --git a/packages/graphql/package.json b/packages/graphql/package.json index 75b8553ba1..0803d44b45 100644 --- a/packages/graphql/package.json +++ b/packages/graphql/package.json @@ -13,16 +13,16 @@ } }, "dependencies": { - "@apollo/client": "^3", + "@apollo/client": "~3.11.10", "@graphql-codegen/add": "5.0.3", "@graphql-codegen/fragment-matcher": "5.0.2", "@graphql-codegen/introspection": "4.0.3", "@graphql-codegen/schema-ast": "4.1.0", - "@graphql-codegen/typed-document-node": "5.0.9", - "@graphql-codegen/typescript": "4.0.9", - "@graphql-codegen/typescript-apollo-client-helpers": "2.2.6", - "@graphql-codegen/typescript-document-nodes": "4.0.9", - "@graphql-codegen/typescript-operations": "4.2.3", + "@graphql-codegen/typed-document-node": "5.0.12", + "@graphql-codegen/typescript": "4.1.2", + "@graphql-codegen/typescript-apollo-client-helpers": "3.0.0", + "@graphql-codegen/typescript-document-nodes": "4.0.12", + "@graphql-codegen/typescript-operations": "4.4.0", "apollo3-cache-persist": "^0.15.0", "graphql": "^16.7.1" }, diff --git a/packages/hygraph-cli/package.json b/packages/hygraph-cli/package.json index bfc5f7f44d..182ddfbe4d 100644 --- a/packages/hygraph-cli/package.json +++ b/packages/hygraph-cli/package.json @@ -13,7 +13,7 @@ "types": "src/index.ts", "dependencies": { "@hygraph/management-sdk": "1.2.5", - "@whatwg-node/fetch": "^0.9.21", + "@whatwg-node/fetch": "^0.10.1", "graphql": "^16.7.1", "graphql-tag": "^2.12.6", "prompts": "^2.4.2" diff --git a/packages/hygraph-dynamic-rows-ui/package.json b/packages/hygraph-dynamic-rows-ui/package.json index dafbab1e5f..bda0b404f8 100644 --- a/packages/hygraph-dynamic-rows-ui/package.json +++ b/packages/hygraph-dynamic-rows-ui/package.json @@ -16,17 +16,17 @@ "dev": "next dev" }, "dependencies": { - "@apollo/client": "~3.11.8", + "@apollo/client": "~3.11.10", "@graphcommerce/next-config": "9.0.0-canary.105", "@hygraph/app-sdk-react": "^0.0.5", - "@lingui/core": "4.11.4", - "@lingui/macro": "4.11.4", - "@lingui/react": "4.11.4", + "@lingui/core": "4.14.0", + "@lingui/macro": "4.14.0", + "@lingui/react": "4.14.0", "@mui/material": "5.16.7", "cross-env": "^7.0.3", "dotenv": "16.4.5", "graphql": "^16.9.0", - "next": "14.2.14", + "next": "15.0.3", "react": "^18.3.1", "react-dom": "^18.3.1", "webpack": "^5.96.1" @@ -38,7 +38,7 @@ "@types/react-is": "^18.3.0", "babel-plugin-macros": "^3.1.0", "eslint": "^8", - "prettier": "3.3.3", + "prettier": "^3", "typescript": "5.6.2" } } diff --git a/packages/image/example/package.json b/packages/image/example/package.json index b856b2361c..c94c5d3959 100644 --- a/packages/image/example/package.json +++ b/packages/image/example/package.json @@ -11,12 +11,12 @@ }, "dependencies": { "@graphcommerce/framer-utils": "9.0.0-canary.105", - "@lingui/core": "4.11.4", - "@lingui/macro": "4.11.4", - "@lingui/react": "4.11.4", + "@lingui/core": "4.14.0", + "@lingui/macro": "4.14.0", + "@lingui/react": "4.14.0", "@mui/lab": "5.0.0-alpha.173", "@mui/material": "5.16.7", - "@next/env": "14.2.14", + "@next/env": "15.0.3", "@parcel/watcher": "^2.4.1", "@unts/patch-package": "^8.0.0", "concurrently": "8.2.2", @@ -24,7 +24,7 @@ "dotenv": "16.4.5", "framer-motion": "11.11.1", "graphql": "^16.9.0", - "next": "14.2.14", + "next": "15.0.3", "next-sitemap": "4.2.3", "react": "^18.3.1", "react-dom": "^18.3.1", @@ -35,15 +35,14 @@ "@graphcommerce/eslint-config-pwa": "9.0.0-canary.105", "@graphcommerce/prettier-config-pwa": "9.0.0-canary.105", "@graphcommerce/typescript-config-pwa": "9.0.0-canary.105", - "@lingui/cli": "4.11.4", - "@playwright/test": "1.47.2", - "@types/node": "^18.19.54", - "@types/react": "^18.3.11", - "@types/react-dom": "^18.3.0", + "@lingui/cli": "4.14.0", + "@types/node": "^18.19.66", + "@types/react": "^18.3.12", + "@types/react-dom": "^18.3.1", "@types/react-is": "^18.3.0", "babel-plugin-macros": "^3.1.0", "eslint": "^8", - "prettier": "3.3.3", + "prettier": "^3", "type-fest": "^4.26.1", "typescript": "5.6.2" } diff --git a/packages/next-ui/package.json b/packages/next-ui/package.json index 8a41e946ec..a9623ea669 100644 --- a/packages/next-ui/package.json +++ b/packages/next-ui/package.json @@ -12,11 +12,10 @@ } }, "dependencies": { - "cookie": "^0.7.2", + "cookie": "^1.0.2", "react-is": "^18.3.1" }, "devDependencies": { - "@types/cookie": "^0.6.0", "@types/react-is": "^18.3.0", "typescript": "5.6.2" }, diff --git a/packages/react-hook-form/package.json b/packages/react-hook-form/package.json index 39ede6f228..97bb66f232 100644 --- a/packages/react-hook-form/package.json +++ b/packages/react-hook-form/package.json @@ -24,7 +24,7 @@ "react-hook-form": "^7" }, "dependencies": { - "@types/lodash": "^4.17.10", + "@types/lodash": "^4.17.13", "lodash": "^4.17.21" } } diff --git a/packagesDev/eslint-config/package.json b/packagesDev/eslint-config/package.json index 98fc37f9db..f71f921689 100644 --- a/packagesDev/eslint-config/package.json +++ b/packagesDev/eslint-config/package.json @@ -6,7 +6,7 @@ "main": "index.js", "dependencies": { "@graphcommerce/typescript-config-pwa": "9.0.0-canary.105", - "@next/eslint-plugin-next": "14.2.14", + "@next/eslint-plugin-next": "15.0.3", "@typescript-eslint/eslint-plugin": "^7.18.0", "@typescript-eslint/parser": "^7.18.0", "eslint": "^8", diff --git a/packagesDev/graphql-codegen-markdown-docs/package.json b/packagesDev/graphql-codegen-markdown-docs/package.json index 9903f63cd5..b54b0615df 100644 --- a/packagesDev/graphql-codegen-markdown-docs/package.json +++ b/packagesDev/graphql-codegen-markdown-docs/package.json @@ -22,9 +22,9 @@ }, "dependencies": { "@graphql-codegen/add": "5.0.3", - "@graphql-codegen/plugin-helpers": "5.0.4", - "@graphql-codegen/visitor-plugin-common": "5.3.1", - "@graphql-tools/utils": "^10.3.2", + "@graphql-codegen/plugin-helpers": "5.1.0", + "@graphql-codegen/visitor-plugin-common": "5.6.0", + "@graphql-tools/utils": "^10.6.0", "@types/parse-filepath": "^1.0.2", "graphql": "^16.7.1", "parse-filepath": "^1.0.2" diff --git a/packagesDev/graphql-codegen-near-operation-file/package.json b/packagesDev/graphql-codegen-near-operation-file/package.json index 4fe4f4b975..f8e779afd0 100644 --- a/packagesDev/graphql-codegen-near-operation-file/package.json +++ b/packagesDev/graphql-codegen-near-operation-file/package.json @@ -21,9 +21,9 @@ }, "dependencies": { "@graphql-codegen/add": "5.0.3", - "@graphql-codegen/plugin-helpers": "5.0.4", - "@graphql-codegen/visitor-plugin-common": "5.3.1", - "@graphql-tools/utils": "^10.3.2", + "@graphql-codegen/plugin-helpers": "5.1.0", + "@graphql-codegen/visitor-plugin-common": "5.6.0", + "@graphql-tools/utils": "^10.6.0", "@types/parse-filepath": "^1.0.2", "graphql": "^16.7.1", "parse-filepath": "^1.0.2" diff --git a/packagesDev/graphql-codegen-relay-optimizer-plugin/package.json b/packagesDev/graphql-codegen-relay-optimizer-plugin/package.json index 000c600d9c..33fb2582c7 100644 --- a/packagesDev/graphql-codegen-relay-optimizer-plugin/package.json +++ b/packagesDev/graphql-codegen-relay-optimizer-plugin/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@ardatan/relay-compiler": "12.0.0", - "@graphql-codegen/plugin-helpers": "5.0.4", + "@graphql-codegen/plugin-helpers": "5.1.0", "graphql": "^16.7.1" }, "devDependencies": { diff --git a/packagesDev/next-config/package.json b/packagesDev/next-config/package.json index 659de5cf39..778409e31f 100644 --- a/packagesDev/next-config/package.json +++ b/packagesDev/next-config/package.json @@ -13,14 +13,14 @@ }, "dependencies": { "@graphql-mesh/cli": "latest", - "@lingui/loader": "4.11.4", - "@lingui/macro": "4.11.4", - "@lingui/react": "4.11.4", + "@lingui/loader": "4.14.0", + "@lingui/macro": "4.14.0", + "@lingui/react": "4.14.0", "@lingui/swc-plugin": "4.0.8", - "@swc/core": "1.7.26", - "@swc/wasm-web": "^1.7.28", + "@swc/core": "1.9.3", + "@swc/wasm-web": "^1.9.3", "@types/circular-dependency-plugin": "^5.0.8", - "@types/lodash": "^4.17.10", + "@types/lodash": "^4.17.13", "babel-plugin-macros": "^3.1.0", "circular-dependency-plugin": "^5.2.2", "glob": "^10.4.5", diff --git a/packagesDev/prettier-config/index.js b/packagesDev/prettier-config/index.js index 07dac74cb7..d4c74b0257 100644 --- a/packagesDev/prettier-config/index.js +++ b/packagesDev/prettier-config/index.js @@ -24,5 +24,5 @@ module.exports = { importOrderSeparation: false, importOrderSortSpecifiers: true, importOrder: ['^@graphcommerce/(.*)$', '', '^[./]'], - plugins: ['@ianvs/prettier-plugin-sort-imports'], + plugins: [require.resolve('@ianvs/prettier-plugin-sort-imports')], } From 2bdacabe74df8decf17ac8235fa78bbba23beb48 Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Wed, 27 Nov 2024 09:54:36 +0100 Subject: [PATCH 09/12] Updated dependencies --- examples/magento-graphcms/package.json | 2 +- examples/magento-open-source/package.json | 2 +- package.json | 2 +- packages/framer-next-pages/example/package.json | 2 +- packages/framer-scroller/example/package.json | 2 +- packages/graphql-mesh/package.json | 2 +- packages/hygraph-cli/package.json | 2 +- packages/hygraph-dynamic-rows-ui/package.json | 2 +- packages/image/config/config.ts | 4 ++-- packages/image/example/package.json | 2 +- packages/magento-product/package.json | 2 +- packages/magento-review/package.json | 2 +- packages/next-ui/package.json | 2 +- packages/next-ui/utils/cookie.ts | 6 +++--- packagesDev/eslint-config/package.json | 2 +- .../graphql-codegen-relay-optimizer-plugin/package.json | 2 +- packagesDev/next-config/package.json | 2 +- 17 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/magento-graphcms/package.json b/examples/magento-graphcms/package.json index 32b542812c..f2d4c2c3af 100644 --- a/examples/magento-graphcms/package.json +++ b/examples/magento-graphcms/package.json @@ -118,7 +118,7 @@ "eslint": "^8", "prettier": "^3", "type-fest": "^4.26.1", - "typescript": "5.6.2" + "typescript": "5.7.2" }, "browserslist": [ "> 1% in alt-EU", diff --git a/examples/magento-open-source/package.json b/examples/magento-open-source/package.json index 8b0646a341..dec4e4cbfd 100644 --- a/examples/magento-open-source/package.json +++ b/examples/magento-open-source/package.json @@ -114,7 +114,7 @@ "eslint": "^8", "prettier": "^3", "type-fest": "^4.26.1", - "typescript": "5.6.2" + "typescript": "5.7.2" }, "browserslist": [ "> 1% in alt-EU", diff --git a/package.json b/package.json index 0ea1e24208..b788dceb94 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "jest-diff": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "prettier": "^3", - "typescript": "5.6.2" + "typescript": "5.7.2" }, "resolutions": { "@changesets/assemble-release-plan": "5.2.4", diff --git a/packages/framer-next-pages/example/package.json b/packages/framer-next-pages/example/package.json index 372338bbfe..e6fb3786c2 100644 --- a/packages/framer-next-pages/example/package.json +++ b/packages/framer-next-pages/example/package.json @@ -60,6 +60,6 @@ "eslint": "^8", "prettier": "^3", "type-fest": "^4.26.1", - "typescript": "5.6.2" + "typescript": "5.7.2" } } diff --git a/packages/framer-scroller/example/package.json b/packages/framer-scroller/example/package.json index b547b68d46..c7ede3229c 100644 --- a/packages/framer-scroller/example/package.json +++ b/packages/framer-scroller/example/package.json @@ -56,6 +56,6 @@ "eslint": "^8", "prettier": "^3", "type-fest": "^4.26.1", - "typescript": "5.6.2" + "typescript": "5.7.2" } } diff --git a/packages/graphql-mesh/package.json b/packages/graphql-mesh/package.json index f4d571a768..177c8a3f7b 100644 --- a/packages/graphql-mesh/package.json +++ b/packages/graphql-mesh/package.json @@ -41,7 +41,7 @@ }, "devDependencies": { "@types/uglify-es": "^3.0.3", - "typescript": "5.6.2" + "typescript": "5.7.2" }, "sideEffects": false, "prettier": "@graphcommerce/prettier-config-pwa", diff --git a/packages/hygraph-cli/package.json b/packages/hygraph-cli/package.json index 182ddfbe4d..9adf226615 100644 --- a/packages/hygraph-cli/package.json +++ b/packages/hygraph-cli/package.json @@ -28,7 +28,7 @@ }, "devDependencies": { "@types/prompts": "^2.4.9", - "typescript": "5.6.2" + "typescript": "5.7.2" }, "sideEffects": false, "prettier": "@graphcommerce/prettier-config-pwa", diff --git a/packages/hygraph-dynamic-rows-ui/package.json b/packages/hygraph-dynamic-rows-ui/package.json index bda0b404f8..884962c520 100644 --- a/packages/hygraph-dynamic-rows-ui/package.json +++ b/packages/hygraph-dynamic-rows-ui/package.json @@ -39,6 +39,6 @@ "babel-plugin-macros": "^3.1.0", "eslint": "^8", "prettier": "^3", - "typescript": "5.6.2" + "typescript": "5.7.2" } } diff --git a/packages/image/config/config.ts b/packages/image/config/config.ts index 82da7da9b3..3d87335306 100644 --- a/packages/image/config/config.ts +++ b/packages/image/config/config.ts @@ -100,8 +100,8 @@ export function defaultLoader({ config, src, width, quality }: ImageLoaderPropsW ) { // We use dynamic require because this should only error in development // eslint-disable-next-line @typescript-eslint/no-floating-promises - import('next/dist/shared/lib/match-remote-pattern').then(({ hasMatch }) => { - if (!hasMatch(config.domains, config.remotePatterns, parsedSrc)) { + import('next/dist/shared/lib/match-remote-pattern').then(({ hasRemoteMatch }) => { + if (!hasRemoteMatch(config.domains, config.remotePatterns, parsedSrc)) { throw new Error( `Invalid src prop (${src}) on \`next/image\`, hostname "${parsedSrc.hostname}" is not configured under images in your \`next.config.js\`\n` + 'See more info: https://nextjs.org/docs/messages/next-image-unconfigured-host', diff --git a/packages/image/example/package.json b/packages/image/example/package.json index c94c5d3959..87ca6a91f2 100644 --- a/packages/image/example/package.json +++ b/packages/image/example/package.json @@ -44,6 +44,6 @@ "eslint": "^8", "prettier": "^3", "type-fest": "^4.26.1", - "typescript": "5.6.2" + "typescript": "5.7.2" } } diff --git a/packages/magento-product/package.json b/packages/magento-product/package.json index 00eec739c9..22bb8d6584 100644 --- a/packages/magento-product/package.json +++ b/packages/magento-product/package.json @@ -15,7 +15,7 @@ "schema-dts": "^1.1.2" }, "devDependencies": { - "typescript": "5.6.2" + "typescript": "5.7.2" }, "peerDependencies": { "@graphcommerce/ecommerce-ui": "^9.0.0-canary.105", diff --git a/packages/magento-review/package.json b/packages/magento-review/package.json index d75576889e..13a8019ad9 100644 --- a/packages/magento-review/package.json +++ b/packages/magento-review/package.json @@ -15,7 +15,7 @@ "schema-dts": "^1.1.2" }, "devDependencies": { - "typescript": "5.6.2" + "typescript": "5.7.2" }, "peerDependencies": { "@graphcommerce/ecommerce-ui": "^9.0.0-canary.105", diff --git a/packages/next-ui/package.json b/packages/next-ui/package.json index a9623ea669..224d098d2b 100644 --- a/packages/next-ui/package.json +++ b/packages/next-ui/package.json @@ -17,7 +17,7 @@ }, "devDependencies": { "@types/react-is": "^18.3.0", - "typescript": "5.6.2" + "typescript": "5.7.2" }, "peerDependencies": { "@emotion/cache": "^11", diff --git a/packages/next-ui/utils/cookie.ts b/packages/next-ui/utils/cookie.ts index 2cf1cac567..c442938da3 100644 --- a/packages/next-ui/utils/cookie.ts +++ b/packages/next-ui/utils/cookie.ts @@ -1,14 +1,14 @@ -import type { CookieSerializeOptions } from 'cookie' +import type { SerializeOptions } from 'cookie' import { parse, serialize } from 'cookie' /** Read a cookie */ export function cookie(name: string): string | undefined /** Set a cookie */ -export function cookie(name: string, value: string, options?: CookieSerializeOptions): void +export function cookie(name: string, value: string, options?: SerializeOptions): void /** Delete a cookie */ export function cookie(name: string, value: null): void /** Function to handle the three different cases */ -export function cookie(name: string, value?: string | null, options?: CookieSerializeOptions) { +export function cookie(name: string, value?: string | null, options?: SerializeOptions) { if (typeof window === 'undefined') { return undefined } diff --git a/packagesDev/eslint-config/package.json b/packagesDev/eslint-config/package.json index f71f921689..6bb2bd644b 100644 --- a/packagesDev/eslint-config/package.json +++ b/packagesDev/eslint-config/package.json @@ -17,7 +17,7 @@ "eslint-plugin-jsx-a11y": "6.10.0", "eslint-plugin-react": "^7.37.1", "eslint-plugin-react-hooks": "4.6.2", - "typescript": "5.6.2" + "typescript": "5.7.2" }, "sideEffects": false } diff --git a/packagesDev/graphql-codegen-relay-optimizer-plugin/package.json b/packagesDev/graphql-codegen-relay-optimizer-plugin/package.json index 33fb2582c7..76d57afa33 100644 --- a/packagesDev/graphql-codegen-relay-optimizer-plugin/package.json +++ b/packagesDev/graphql-codegen-relay-optimizer-plugin/package.json @@ -19,7 +19,7 @@ }, "devDependencies": { "@types/relay-compiler": "8.0.4", - "typescript": "5.6.2" + "typescript": "5.7.2" }, "peerDependencies": { "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.105", diff --git a/packagesDev/next-config/package.json b/packagesDev/next-config/package.json index 778409e31f..27effb64ee 100644 --- a/packagesDev/next-config/package.json +++ b/packagesDev/next-config/package.json @@ -29,7 +29,7 @@ "js-yaml-loader": "^1.2.2", "lodash": "^4.17.21", "react": "^18.3.1", - "typescript": "5.6.2", + "typescript": "5.7.2", "webpack": "^5.96.1", "znv": "^0.4.0", "zod": "^3.23.8" From 99f5eb692fe68b1c1798679cb01d8eec93e15020 Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Wed, 27 Nov 2024 10:10:11 +0100 Subject: [PATCH 10/12] Updated Lingui/swc-plugin --- packagesDev/next-config/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packagesDev/next-config/package.json b/packagesDev/next-config/package.json index 27effb64ee..b6a479fbcd 100644 --- a/packagesDev/next-config/package.json +++ b/packagesDev/next-config/package.json @@ -16,7 +16,7 @@ "@lingui/loader": "4.14.0", "@lingui/macro": "4.14.0", "@lingui/react": "4.14.0", - "@lingui/swc-plugin": "4.0.8", + "@lingui/swc-plugin": "4.1.0", "@swc/core": "1.9.3", "@swc/wasm-web": "^1.9.3", "@types/circular-dependency-plugin": "^5.0.8", From 654be8309cab209d95935cf06c84469726c981e7 Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Wed, 27 Nov 2024 12:57:03 +0100 Subject: [PATCH 11/12] Enable prettier-plugin-jsdoc --- .changeset/three-eels-kiss.md | 5 +++++ packagesDev/prettier-config/index.js | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/three-eels-kiss.md diff --git a/.changeset/three-eels-kiss.md b/.changeset/three-eels-kiss.md new file mode 100644 index 0000000000..e8af50d7d1 --- /dev/null +++ b/.changeset/three-eels-kiss.md @@ -0,0 +1,5 @@ +--- +'@graphcommerce/prettier-config-pwa': patch +--- + +Enable prettier-plugin-jsdoc diff --git a/packagesDev/prettier-config/index.js b/packagesDev/prettier-config/index.js index d4c74b0257..2388d1d0f0 100644 --- a/packagesDev/prettier-config/index.js +++ b/packagesDev/prettier-config/index.js @@ -24,5 +24,8 @@ module.exports = { importOrderSeparation: false, importOrderSortSpecifiers: true, importOrder: ['^@graphcommerce/(.*)$', '', '^[./]'], - plugins: [require.resolve('@ianvs/prettier-plugin-sort-imports')], + plugins: [ + require.resolve('@ianvs/prettier-plugin-sort-imports'), + require.resolve('prettier-plugin-jsdoc'), + ], } From 3434ede37855c36949711d05d13eb01906b29ad0 Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Wed, 27 Nov 2024 13:11:24 +0100 Subject: [PATCH 12/12] Added a functionality to copy directories from packages to the project and keep them managed with GraphCommerce --- .changeset/old-dodos-listen.md | 5 + examples/magento-graphcms/package.json | 4 +- examples/magento-open-source/package.json | 4 +- packages/cli/dist/bin/graphcommerce.js | 2 + packages/cli/src/bin/graphcommerce.ts | 2 + .../next-config/dist/commands/codegen.js | 18 ++ .../next-config/dist/commands/copyFiles.js | 201 ++++++++++++++++ .../next-config/dist/commands/copyRoutes.js | 20 ++ packagesDev/next-config/dist/index.js | 2 + .../next-config/src/commands/codegen.ts | 18 ++ .../next-config/src/commands/copyFiles.ts | 227 ++++++++++++++++++ packagesDev/next-config/src/index.ts | 6 +- 12 files changed, 502 insertions(+), 7 deletions(-) create mode 100644 .changeset/old-dodos-listen.md create mode 100644 packagesDev/next-config/dist/commands/codegen.js create mode 100644 packagesDev/next-config/dist/commands/copyFiles.js create mode 100644 packagesDev/next-config/dist/commands/copyRoutes.js create mode 100644 packagesDev/next-config/src/commands/codegen.ts create mode 100644 packagesDev/next-config/src/commands/copyFiles.ts diff --git a/.changeset/old-dodos-listen.md b/.changeset/old-dodos-listen.md new file mode 100644 index 0000000000..ae0b7b4150 --- /dev/null +++ b/.changeset/old-dodos-listen.md @@ -0,0 +1,5 @@ +--- +'@graphcommerce/next-config': minor +--- + +Added a functionality to copy directories from packages to the project and keep them managed with GraphCommerce diff --git a/examples/magento-graphcms/package.json b/examples/magento-graphcms/package.json index f2d4c2c3af..9c77cd20f2 100644 --- a/examples/magento-graphcms/package.json +++ b/examples/magento-graphcms/package.json @@ -11,8 +11,8 @@ }, "scripts": { "dev": "concurrently -k -n codegen,next 'graphql-codegen -w' 'next dev'", - "codegen": "graphcommerce codegen-config && graphcommerce codegen-interceptors && mesh build && graphql-codegen", - "build": "graphcommerce codegen-config && graphcommerce codegen-interceptors && mesh build && graphql-codegen && next build && generate-assetlinks", + "codegen": "graphcommerce codegen && mesh build && graphql-codegen", + "build": "graphcommerce codegen && mesh build && graphql-codegen && next build && generate-assetlinks", "start": "next start", "tsc:lint": "tsc --noEmit -p .", "tsc:perf": "NODE_OPTIONS=--max_old_space_size=10000 tsc --noEmit --generateTrace tsctrace --incremental false && npx @typescript/analyze-trace tsctrace", diff --git a/examples/magento-open-source/package.json b/examples/magento-open-source/package.json index dec4e4cbfd..e05d37ee9b 100644 --- a/examples/magento-open-source/package.json +++ b/examples/magento-open-source/package.json @@ -11,8 +11,8 @@ }, "scripts": { "dev": "concurrently -k -n codegen,next 'graphql-codegen -w' 'next dev'", - "codegen": "graphcommerce codegen-config && graphcommerce codegen-interceptors && mesh build && graphql-codegen", - "build": "graphcommerce codegen-config && graphcommerce codegen-interceptors && mesh build && graphql-codegen && next build && generate-assetlinks", + "codegen": "graphcommerce codegen && mesh build && graphql-codegen", + "build": "graphcommerce codegen && mesh build && graphql-codegen && next build && generate-assetlinks", "start": "next start", "tsc:lint": "tsc --noEmit -p .", "tsc:perf": "NODE_OPTIONS=--max_old_space_size=10000 tsc --noEmit --generateTrace tsctrace --incremental false && npx @typescript/analyze-trace tsctrace", diff --git a/packages/cli/dist/bin/graphcommerce.js b/packages/cli/dist/bin/graphcommerce.js index 0956a598af..9430031bcc 100755 --- a/packages/cli/dist/bin/graphcommerce.js +++ b/packages/cli/dist/bin/graphcommerce.js @@ -1,6 +1,8 @@ #!/usr/bin/env node const commands = { + codegen: () => import('@graphcommerce/next-config').then((m) => m.codegen), "codegen-config": () => import('@graphcommerce/next-config').then((m) => m.generateConfig), + "copy-routes": () => import('@graphcommerce/next-config').then((m) => m.copyFiles), "codegen-interceptors": () => import('@graphcommerce/next-config').then((m) => m.codegenInterceptors), "export-config": () => import('@graphcommerce/next-config').then((m) => m.exportConfig), "hygraph-migrate": () => import('@graphcommerce/hygraph-cli').then((m) => m.migrateHygraph) diff --git a/packages/cli/src/bin/graphcommerce.ts b/packages/cli/src/bin/graphcommerce.ts index e0c1c347af..04355ec636 100755 --- a/packages/cli/src/bin/graphcommerce.ts +++ b/packages/cli/src/bin/graphcommerce.ts @@ -1,7 +1,9 @@ #!/usr/bin/env node const commands = { + codegen: () => import('@graphcommerce/next-config').then((m) => m.codegen), 'codegen-config': () => import('@graphcommerce/next-config').then((m) => m.generateConfig), + 'copy-routes': () => import('@graphcommerce/next-config').then((m) => m.copyFiles), 'codegen-interceptors': () => import('@graphcommerce/next-config').then((m) => m.codegenInterceptors), 'export-config': () => import('@graphcommerce/next-config').then((m) => m.exportConfig), diff --git a/packagesDev/next-config/dist/commands/codegen.js b/packagesDev/next-config/dist/commands/codegen.js new file mode 100644 index 0000000000..e557b2f201 --- /dev/null +++ b/packagesDev/next-config/dist/commands/codegen.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.codegen = codegen; +const generateConfig_1 = require("../config/commands/generateConfig"); +const codegenInterceptors_1 = require("../interceptors/commands/codegenInterceptors"); +const copyFiles_1 = require("./copyFiles"); +/** Run all code generation steps in sequence */ +async function codegen() { + // Copy files from packages to project + console.log('🔄 Copying files from packages to project...'); + await (0, copyFiles_1.copyFiles)(); + // Generate GraphCommerce config types + console.log('⚙️ Generating GraphCommerce config types...'); + await (0, generateConfig_1.generateConfig)(); + // Generate interceptors + console.log('🔌 Generating interceptors...'); + await (0, codegenInterceptors_1.codegenInterceptors)(); +} diff --git a/packagesDev/next-config/dist/commands/copyFiles.js b/packagesDev/next-config/dist/commands/copyFiles.js new file mode 100644 index 0000000000..6c0267554e --- /dev/null +++ b/packagesDev/next-config/dist/commands/copyFiles.js @@ -0,0 +1,201 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.copyFiles = copyFiles; +const promises_1 = __importDefault(require("fs/promises")); +const path_1 = __importDefault(require("path")); +const glob_1 = require("glob"); +const resolveDependenciesSync_1 = require("../utils/resolveDependenciesSync"); +// Add debug logging helper +const debug = (...args) => { + if (process.env.DEBUG) + console.log('[copyFiles]', ...args); +}; +const createManagementComment = (type) => `// managed by: ${type}`; +const MANAGED_BY_GC = createManagementComment('graphcommerce'); +const MANAGED_LOCALLY = createManagementComment('local'); +const GITIGNORE_SECTION_START = '# managed by: graphcommerce'; +const GITIGNORE_SECTION_END = '# end managed by: graphcommerce'; +/** + * Updates the .gitignore file with a list of GraphCommerce managed files + * + * - Removes any existing GraphCommerce managed files section + * - If managedFiles is not empty, adds a new section with the files + * - If managedFiles is empty, just cleans up the existing section + * - Ensures the file ends with a newline + */ +async function updateGitignore(managedFiles) { + const gitignorePath = path_1.default.join(process.cwd(), '.gitignore'); + let content; + debug('Updating .gitignore with managed files:', managedFiles); + try { + content = await promises_1.default.readFile(gitignorePath, 'utf-8'); + debug('Existing .gitignore content:', content); + } + catch (err) { + debug('.gitignore not found, creating new file'); + content = ''; + } + // Remove existing GraphCommerce section if it exists + const sectionRegex = new RegExp(`${GITIGNORE_SECTION_START}[\\s\\S]*?${GITIGNORE_SECTION_END}\\n?`, 'g'); + content = content.replace(sectionRegex, ''); + debug('Content after removing existing section:', content); + // Only add new section if there are files to manage + if (managedFiles.length > 0) { + const newSection = [ + GITIGNORE_SECTION_START, + ...managedFiles.sort(), + GITIGNORE_SECTION_END, + '', // Empty line at the end + ].join('\n'); + debug('New section to add:', newSection); + // Append the new section + content = `${content.trim()}\n\n${newSection}`; + } + else { + // Just trim the content when no files to manage + content = `${content.trim()}\n`; + } + debug('Final content:', content); + try { + await promises_1.default.writeFile(gitignorePath, content); + debug('Successfully wrote .gitignore file'); + } + catch (err) { + console.error('Error writing .gitignore:', err); + } +} +/** Determines how a file should be managed based on its content */ +function getFileManagement(content) { + if (!content) + return 'graphcommerce'; + const contentStr = content.toString(); + if (contentStr.startsWith(MANAGED_LOCALLY)) + return 'local'; + if (contentStr.startsWith(MANAGED_BY_GC)) + return 'graphcommerce'; + return 'unmanaged'; +} +/** + * The packages are @graphcommerce/* packages and have special treatment. + * + * 1. Glob the `copy/**` directory for each package and generate a list of files that need to be + * copied. Error if a file with the same path exists in another package. + * 2. Copy the files to the project directory (cwd). + * + * 1. If the file doesn't exist: Create directories and the file with "managed by: graphcommerce" + * 2. If the file exists and starts with "managed by: local": Skip the file + * 3. If the file exists but doesn't have a management comment: Suggest adding "managed by: local" + * 4. If the file is managed by graphcommerce: Update if content differs + */ +async function copyFiles() { + debug('Starting copyFiles'); + const cwd = process.cwd(); + const deps = (0, resolveDependenciesSync_1.resolveDependenciesSync)(); + const packages = [...deps.values()].filter((p) => p !== '.'); + debug('Found packages:', packages); + // Track files and their source packages to detect conflicts + const fileMap = new Map(); + // Track which files are managed by GraphCommerce + const managedFiles = new Set(); + // First pass: collect all files and check for conflicts + await Promise.all(packages.map(async (pkg) => { + const copyDir = path_1.default.join(pkg, 'copy'); + try { + const files = await (0, glob_1.glob)('**/*', { cwd: copyDir, nodir: true, dot: true }); + debug(`Found files in ${pkg}:`, files); + for (const file of files) { + const sourcePath = path_1.default.join(copyDir, file); + const existing = fileMap.get(file); + if (existing) { + console.error(`Error: File conflict detected for '${file}' +Found in packages: + - ${existing.packagePath} -> ${existing.sourcePath} + - ${pkg} -> ${sourcePath}`); + process.exit(1); + } + fileMap.set(file, { sourcePath, packagePath: pkg }); + } + } + catch (err) { + // Skip if copy directory doesn't exist + if (err.code !== 'ENOENT') { + console.error(`Error scanning directory ${copyDir}: ${err.message} +Path: ${copyDir}`); + process.exit(1); + } + } + })); + // Second pass: copy files + await Promise.all(Array.from(fileMap.entries()).map(async ([file, { sourcePath }]) => { + const targetPath = path_1.default.join(cwd, file); + debug(`Processing file: ${file}`); + try { + await promises_1.default.mkdir(path_1.default.dirname(targetPath), { recursive: true }); + const sourceContent = await promises_1.default.readFile(sourcePath); + const contentWithComment = Buffer.concat([ + Buffer.from(`${MANAGED_BY_GC}\n`), + Buffer.from('// to modify this file, change it to managed by: local\n\n'), + sourceContent, + ]); + let targetContent; + try { + targetContent = await promises_1.default.readFile(targetPath); + const management = getFileManagement(targetContent); + if (management === 'local') { + debug(`File ${file} is managed locally, skipping`); + return; + } + if (management === 'unmanaged') { + console.log(`Note: File ${file} has been modified. Add '${MANAGED_LOCALLY.trim()}' at the top to manage it locally.`); + debug(`File ${file} doesn't have management comment, skipping`); + return; + } + debug(`File ${file} is managed by graphcommerce, will update if needed`); + } + catch (err) { + if (err.code !== 'ENOENT') { + console.error(`Error reading file ${file}: ${err.message} +Source: ${sourcePath}`); + process.exit(1); + } + console.log(`Creating new file: ${file} +Source: ${sourcePath}`); + debug('File does not exist yet'); + } + // Skip if content is identical (including magic comment) + if (targetContent && Buffer.compare(contentWithComment, targetContent) === 0) { + debug(`File ${file} content is identical to source, skipping`); + managedFiles.add(file); + return; + } + // Copy the file with magic comment + await promises_1.default.writeFile(targetPath, contentWithComment); + if (targetContent) { + console.log(`Updated managed file: ${file}`); + debug(`Overwrote existing file: ${file}`); + } + // If the file is managed by GraphCommerce (new or updated), add it to managedFiles + if (!targetContent || targetContent.toString().startsWith(MANAGED_BY_GC)) { + managedFiles.add(file); + debug('Added managed file:', file); + } + } + catch (err) { + console.error(`Error copying file ${file}: ${err.message} +Source: ${sourcePath}`); + process.exit(1); + } + })); + // Update .gitignore with the list of managed files + if (managedFiles.size > 0) { + debug('Found managed files:', Array.from(managedFiles)); + await updateGitignore(Array.from(managedFiles)); + } + else { + debug('No managed files found, cleaning up .gitignore section'); + await updateGitignore([]); // Pass empty array to clean up the section + } +} diff --git a/packagesDev/next-config/dist/commands/copyRoutes.js b/packagesDev/next-config/dist/commands/copyRoutes.js new file mode 100644 index 0000000000..1f597b4745 --- /dev/null +++ b/packagesDev/next-config/dist/commands/copyRoutes.js @@ -0,0 +1,20 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const promises_1 = __importDefault(require("fs/promises")); +// ... earlier code remains the same ... +try { + targetContent = await promises_1.default.readFile(targetPath); +} +catch (err) { + if (err.code !== 'ENOENT') + throw err; + // File doesn't exist, log that we're creating it + console.log(`Creating new file: ${file}`); +} +// Skip if content is identical +if (targetContent && Buffer.compare(sourceContent, targetContent) === 0) + return; +// ... rest of the code remains the same ... diff --git a/packagesDev/next-config/dist/index.js b/packagesDev/next-config/dist/index.js index 13f9ea200a..3bbe400c9d 100644 --- a/packagesDev/next-config/dist/index.js +++ b/packagesDev/next-config/dist/index.js @@ -23,3 +23,5 @@ __exportStar(require("./generated/config"), exports); __exportStar(require("./config"), exports); __exportStar(require("./runtimeCachingOptimizations"), exports); __exportStar(require("./interceptors/commands/codegenInterceptors"), exports); +__exportStar(require("./commands/copyFiles"), exports); +__exportStar(require("./commands/codegen"), exports); diff --git a/packagesDev/next-config/src/commands/codegen.ts b/packagesDev/next-config/src/commands/codegen.ts new file mode 100644 index 0000000000..582e5ba2ee --- /dev/null +++ b/packagesDev/next-config/src/commands/codegen.ts @@ -0,0 +1,18 @@ +import { generateConfig } from '../config/commands/generateConfig' +import { codegenInterceptors } from '../interceptors/commands/codegenInterceptors' +import { copyFiles } from './copyFiles' + +/** Run all code generation steps in sequence */ +export async function codegen() { + // Copy files from packages to project + console.log('🔄 Copying files from packages to project...') + await copyFiles() + + // Generate GraphCommerce config types + console.log('⚙️ Generating GraphCommerce config types...') + await generateConfig() + + // Generate interceptors + console.log('🔌 Generating interceptors...') + await codegenInterceptors() +} diff --git a/packagesDev/next-config/src/commands/copyFiles.ts b/packagesDev/next-config/src/commands/copyFiles.ts new file mode 100644 index 0000000000..f8aaab499d --- /dev/null +++ b/packagesDev/next-config/src/commands/copyFiles.ts @@ -0,0 +1,227 @@ +import fs from 'fs/promises' +import path from 'path' +import { glob } from 'glob' +import { resolveDependenciesSync } from '../utils/resolveDependenciesSync' + +// Add debug logging helper +const debug = (...args: unknown[]) => { + if (process.env.DEBUG) console.log('[copyFiles]', ...args) +} + +// Add constants for the magic comments +type FileManagement = 'graphcommerce' | 'local' +const createManagementComment = (type: FileManagement) => `// managed by: ${type}` + +const MANAGED_BY_GC = createManagementComment('graphcommerce') +const MANAGED_LOCALLY = createManagementComment('local') + +const GITIGNORE_SECTION_START = '# managed by: graphcommerce' +const GITIGNORE_SECTION_END = '# end managed by: graphcommerce' + +/** + * Updates the .gitignore file with a list of GraphCommerce managed files + * + * - Removes any existing GraphCommerce managed files section + * - If managedFiles is not empty, adds a new section with the files + * - If managedFiles is empty, just cleans up the existing section + * - Ensures the file ends with a newline + */ +async function updateGitignore(managedFiles: string[]) { + const gitignorePath = path.join(process.cwd(), '.gitignore') + let content: string + + debug('Updating .gitignore with managed files:', managedFiles) + + try { + content = await fs.readFile(gitignorePath, 'utf-8') + debug('Existing .gitignore content:', content) + } catch (err) { + debug('.gitignore not found, creating new file') + content = '' + } + + // Remove existing GraphCommerce section if it exists + const sectionRegex = new RegExp( + `${GITIGNORE_SECTION_START}[\\s\\S]*?${GITIGNORE_SECTION_END}\\n?`, + 'g', + ) + content = content.replace(sectionRegex, '') + debug('Content after removing existing section:', content) + + // Only add new section if there are files to manage + if (managedFiles.length > 0) { + const newSection = [ + GITIGNORE_SECTION_START, + ...managedFiles.sort(), + GITIGNORE_SECTION_END, + '', // Empty line at the end + ].join('\n') + debug('New section to add:', newSection) + + // Append the new section + content = `${content.trim()}\n\n${newSection}` + } else { + // Just trim the content when no files to manage + content = `${content.trim()}\n` + } + + debug('Final content:', content) + + try { + await fs.writeFile(gitignorePath, content) + debug('Successfully wrote .gitignore file') + } catch (err) { + console.error('Error writing .gitignore:', err) + } +} + +/** Determines how a file should be managed based on its content */ +function getFileManagement(content: Buffer | undefined): 'local' | 'graphcommerce' | 'unmanaged' { + if (!content) return 'graphcommerce' + const contentStr = content.toString() + if (contentStr.startsWith(MANAGED_LOCALLY)) return 'local' + if (contentStr.startsWith(MANAGED_BY_GC)) return 'graphcommerce' + return 'unmanaged' +} + +/** + * The packages are @graphcommerce/* packages and have special treatment. + * + * 1. Glob the `copy/**` directory for each package and generate a list of files that need to be + * copied. Error if a file with the same path exists in another package. + * 2. Copy the files to the project directory (cwd). + * + * 1. If the file doesn't exist: Create directories and the file with "managed by: graphcommerce" + * 2. If the file exists and starts with "managed by: local": Skip the file + * 3. If the file exists but doesn't have a management comment: Suggest adding "managed by: local" + * 4. If the file is managed by graphcommerce: Update if content differs + */ +export async function copyFiles() { + debug('Starting copyFiles') + + const cwd = process.cwd() + const deps = resolveDependenciesSync() + const packages = [...deps.values()].filter((p) => p !== '.') + debug('Found packages:', packages) + + // Track files and their source packages to detect conflicts + const fileMap = new Map() + // Track which files are managed by GraphCommerce + const managedFiles = new Set() + + // First pass: collect all files and check for conflicts + await Promise.all( + packages.map(async (pkg) => { + const copyDir = path.join(pkg, 'copy') + + try { + const files = await glob('**/*', { cwd: copyDir, nodir: true, dot: true }) + debug(`Found files in ${pkg}:`, files) + + for (const file of files) { + const sourcePath = path.join(copyDir, file) + const existing = fileMap.get(file) + + if (existing) { + console.error(`Error: File conflict detected for '${file}' +Found in packages: + - ${existing.packagePath} -> ${existing.sourcePath} + - ${pkg} -> ${sourcePath}`) + process.exit(1) + } + + fileMap.set(file, { sourcePath, packagePath: pkg }) + } + } catch (err) { + // Skip if copy directory doesn't exist + if ((err as { code?: string }).code !== 'ENOENT') { + console.error(`Error scanning directory ${copyDir}: ${(err as Error).message} +Path: ${copyDir}`) + process.exit(1) + } + } + }), + ) + + // Second pass: copy files + await Promise.all( + Array.from(fileMap.entries()).map(async ([file, { sourcePath }]) => { + const targetPath = path.join(cwd, file) + debug(`Processing file: ${file}`) + + try { + await fs.mkdir(path.dirname(targetPath), { recursive: true }) + + const sourceContent = await fs.readFile(sourcePath) + const contentWithComment = Buffer.concat([ + Buffer.from(`${MANAGED_BY_GC}\n`), + Buffer.from('// to modify this file, change it to managed by: local\n\n'), + sourceContent, + ]) + + let targetContent: Buffer | undefined + + try { + targetContent = await fs.readFile(targetPath) + + const management = getFileManagement(targetContent) + if (management === 'local') { + debug(`File ${file} is managed locally, skipping`) + return + } + if (management === 'unmanaged') { + console.log( + `Note: File ${file} has been modified. Add '${MANAGED_LOCALLY.trim()}' at the top to manage it locally.`, + ) + debug(`File ${file} doesn't have management comment, skipping`) + return + } + + debug(`File ${file} is managed by graphcommerce, will update if needed`) + } catch (err) { + if ((err as { code?: string }).code !== 'ENOENT') { + console.error(`Error reading file ${file}: ${(err as Error).message} +Source: ${sourcePath}`) + process.exit(1) + } + console.log(`Creating new file: ${file} +Source: ${sourcePath}`) + debug('File does not exist yet') + } + + // Skip if content is identical (including magic comment) + if (targetContent && Buffer.compare(contentWithComment, targetContent) === 0) { + debug(`File ${file} content is identical to source, skipping`) + managedFiles.add(file) + return + } + + // Copy the file with magic comment + await fs.writeFile(targetPath, contentWithComment) + if (targetContent) { + console.log(`Updated managed file: ${file}`) + debug(`Overwrote existing file: ${file}`) + } + + // If the file is managed by GraphCommerce (new or updated), add it to managedFiles + if (!targetContent || targetContent.toString().startsWith(MANAGED_BY_GC)) { + managedFiles.add(file) + debug('Added managed file:', file) + } + } catch (err) { + console.error(`Error copying file ${file}: ${(err as Error).message} +Source: ${sourcePath}`) + process.exit(1) + } + }), + ) + + // Update .gitignore with the list of managed files + if (managedFiles.size > 0) { + debug('Found managed files:', Array.from(managedFiles)) + await updateGitignore(Array.from(managedFiles)) + } else { + debug('No managed files found, cleaning up .gitignore section') + await updateGitignore([]) // Pass empty array to clean up the section + } +} diff --git a/packagesDev/next-config/src/index.ts b/packagesDev/next-config/src/index.ts index e170c24113..298ee02482 100644 --- a/packagesDev/next-config/src/index.ts +++ b/packagesDev/next-config/src/index.ts @@ -12,6 +12,8 @@ export * from './generated/config' export * from './config' export * from './runtimeCachingOptimizations' export * from './interceptors/commands/codegenInterceptors' +export * from './commands/copyFiles' +export * from './commands/codegen' export type PluginProps

= Record> = P & { Prev: React.FC

@@ -22,9 +24,7 @@ export type FunctionPlugin any> = ( ...args: Parameters ) => ReturnType -/** - * @deprecated use FunctionPlugin instead - */ +/** @deprecated Use FunctionPlugin instead */ export type MethodPlugin any> = ( prev: T, ...args: Parameters