@graphcommerce/next-config 9.0.0-canary.103 → 9.0.0-canary.105

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.0.0-canary.105
4
+
5
+ ## 9.0.0-canary.104
6
+
7
+ ### Patch Changes
8
+
9
+ - [#2423](https://github.com/graphcommerce-org/graphcommerce/pull/2423) [`dbf233b`](https://github.com/graphcommerce-org/graphcommerce/commit/dbf233bb6d11432a8effc38fd4672aaa0856e1aa) - Added graphql.config.ts to projects ([@paales](https://github.com/paales))
10
+
3
11
  ## 9.0.0-canary.103
4
12
 
5
13
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import type { GraphCommerceConfig } from '../../src/generated/config'
2
2
  import { findOriginalSource } from '../../src/interceptors/findOriginalSource'
3
- import { SOURCE_START, SOURCE_END } from '../../src/interceptors/generateInterceptor'
3
+ import { SOURCE_END, SOURCE_START } from '../../src/interceptors/generateInterceptor'
4
4
  import { generateInterceptors } from '../../src/interceptors/generateInterceptors'
5
5
  import { parseStructure } from '../../src/interceptors/parseStructure'
6
6
  import { parseSync } from '../../src/interceptors/swc'
@@ -121,14 +121,12 @@ it("resolves a 'root plugin' to be relative to the interceptor", async () => {
121
121
  expect(Object.keys(interceptors)[0]).toMatchInlineSnapshot(
122
122
  '"packages/magento-cart-payment-method/PaymentMethodContext/PaymentMethodContext"',
123
123
  )
124
- expectImport(
124
+ expect(
125
125
  interceptors['packages/magento-cart-payment-method/PaymentMethodContext/PaymentMethodContext']
126
126
  ?.template,
127
- ).toMatchInlineSnapshot(`
128
- "import type { DistributedOmit as OmitPrev } from 'type-fest'
129
-
130
- import { Plugin as PluginAddPaymentMethodEnhancer } from '../../../plugins/AddPaymentMethodEnhancer'"
131
- `)
127
+ ).toContain(
128
+ "import { Plugin as PluginAddPaymentMethodEnhancer } from '../../../plugins/AddPaymentMethodEnhancer'",
129
+ )
132
130
  })
133
131
 
134
132
  it('it can apply multiple plugins to a single export', async () => {
@@ -157,13 +155,12 @@ it('it can apply multiple plugins to a single export', async () => {
157
155
  const result =
158
156
  interceptors['packages/magento-cart-payment-method/PaymentMethodContext/PaymentMethodContext']
159
157
  ?.template
160
- expectImport(result).toMatchInlineSnapshot(`
161
- "import type { DistributedOmit as OmitPrev } from 'type-fest'
162
-
163
- import { Plugin as PluginAddAdyenMethods } from '@graphcommerce/magento-payment-adyen/plugins/AddAdyenMethods'
164
- import { Plugin as PluginAddMollieMethods } from '@graphcommerce/mollie-magento-payment/plugins/AddMollieMethods'"
165
- `)
166
-
158
+ expect(result).toContain(
159
+ "import { Plugin as PluginAddAdyenMethods } from '@graphcommerce/magento-payment-adyen/plugins/AddAdyenMethods'",
160
+ )
161
+ expect(result).toContain(
162
+ "import { Plugin as PluginAddMollieMethods } from '@graphcommerce/mollie-magento-payment/plugins/AddMollieMethods'",
163
+ )
167
164
  expectOriginal(result).toContain('PaymentMethodContextProviderOriginal')
168
165
 
169
166
  expectInterceptor(result).toMatchInlineSnapshot(`
@@ -351,12 +348,15 @@ it('generates method interceptors alognside component interceptors', async () =>
351
348
  resolve,
352
349
  )
353
350
 
354
- expect(Object.keys(interceptors)).toMatchInlineSnapshot(`
351
+ expect(Object.keys(interceptors)).toMatchInlineSnapshot(
352
+ `
355
353
  [
356
354
  "packages/graphql/components/GraphQLProvider/GraphQLProvider",
357
355
  "packages/graphql/config",
358
356
  ]
359
- `)
357
+ `,
358
+ )
359
+
360
360
  expect(
361
361
  interceptors['packages/graphql/components/GraphQLProvider/GraphQLProvider']?.template,
362
362
  ).toContain('MagentoGraphqlGraphqlProvider')
@@ -403,10 +403,11 @@ it('adds debug logging to interceptors for components', async () => {
403
403
  `)
404
404
 
405
405
  expectOriginal(interceptors['packages/graphql/config']?.template).toMatchInlineSnapshot(`
406
- "import type { ApolloLink, TypePolicies } from '@apollo/client'
407
- import type { GraphCommerceStorefrontConfig } from '@graphcommerce/next-config'
406
+ "import type { GraphCommerceStorefrontConfig } from '@graphcommerce/next-config'
407
+ import type { ApolloLink, TypePolicies } from '@apollo/client'
408
408
  import type { SetRequired } from 'type-fest'
409
409
  import type { MigrateCache } from './components/GraphQLProvider/migrateCache'
410
+
410
411
  export interface PreviewData {}
411
412
  export type PreviewConfig = {
412
413
  preview?: boolean
@@ -433,7 +434,6 @@ it('adds debug logging to interceptors for components', async () => {
433
434
  }
434
435
  }"
435
436
  `)
436
-
437
437
  expectInterceptor(interceptors['packages/graphql/config']?.template).toMatchInlineSnapshot(`
438
438
  "const logged: Set<string> = new Set()
439
439
  const logOnce = (log: string, ...additional: unknown[]) => {
@@ -535,8 +535,8 @@ it('Should apply overrides to the correct file', async () => {
535
535
  const result =
536
536
  interceptors['packages/magento-product/components/ProductStaticPaths/getProductStaticPaths']
537
537
  ?.template
538
- expectImport(result).toMatchInlineSnapshot(
539
- '"import { getProductStaticPaths as getProductStaticPathsreplaceGetProductStaticPaths } from \'../../../../plugins/replaceGetProductStaticPaths\'"',
538
+ expect(result).toContain(
539
+ "import { getProductStaticPaths as getProductStaticPathsreplaceGetProductStaticPaths } from '../../../../plugins/replaceGetProductStaticPaths'",
540
540
  )
541
541
 
542
542
  expectOriginal(result).toContain('getProductStaticPathsDisabled')
@@ -547,7 +547,7 @@ it('correctly reports an error for an incorrect export', async () => {
547
547
  googleRecaptchaKey: '123',
548
548
  googleAnalyticsId: '123',
549
549
  demoMode: true,
550
- } as GraphCommerceConfig
550
+ } as unknown as GraphCommerceConfig
551
551
 
552
552
  const src = `
553
553
  import { getSitemapPaths as getSitemapPathsType } from '@graphcommerce/magento-product'
@@ -566,8 +566,7 @@ export const plugin: FunctionPlugin<typeof getSitemapPathsType> = (prev, ...args
566
566
  console.error = jest.fn()
567
567
  const plugins = parseStructure(parseSync(src), fakeconfig, './plugins/MyPlugin.tsx')
568
568
 
569
- // @ts-expect-error mock not typed
570
- expect(console.error.mock.calls[0][0]).toMatchInlineSnapshot(
569
+ expect((console.error as jest.Mock).mock.calls[0][0]).toMatchInlineSnapshot(
571
570
  '"Plugin configuration invalid! See ./plugins/MyPlugin.tsx"',
572
571
  )
573
572
 
@@ -616,7 +615,7 @@ export const Plugin = ConfigurableProductPageName
616
615
  demoMode: true,
617
616
  configurableVariantForSimple: true,
618
617
  configurableVariantValues: { content: true, gallery: true, url: true },
619
- } as GraphCommerceConfig
618
+ } as unknown as GraphCommerceConfig
620
619
 
621
620
  const firstFile = parseStructure(parseSync(src1), config, './plugins/MyPlugin')
622
621
 
@@ -627,8 +626,8 @@ export const Plugin = ConfigurableProductPageName
627
626
  )
628
627
 
629
628
  const plugins = [...firstFile, ...secondFile]
630
-
631
- expect(plugins).toMatchInlineSnapshot(`
629
+ expect(plugins).toMatchInlineSnapshot(
630
+ `
632
631
  [
633
632
  {
634
633
  "enabled": true,
@@ -649,8 +648,8 @@ export const Plugin = ConfigurableProductPageName
649
648
  "type": "component",
650
649
  },
651
650
  ]
652
- `)
653
-
651
+ `,
652
+ )
654
653
  const interceptors = await generateInterceptors(plugins, resolveDependency(projectRoot))
655
654
 
656
655
  expect(Object.keys(interceptors)[0]).toMatchInlineSnapshot(
@@ -661,14 +660,14 @@ export const Plugin = ConfigurableProductPageName
661
660
  interceptors['packages/magento-product/components/ProductPageName/ProductPageName']?.template
662
661
 
663
662
  expectImport(result).toMatchInlineSnapshot(`
664
- "import type { DistributedOmit as OmitPrev } from 'type-fest'
665
-
666
- import { Plugin as PluginConfigurableProductPageName } from '@graphcommerce/magento-product-configurable/plugins/ConfigurableProductPage/ConfigurableProductPageName'
663
+ "import { Plugin as PluginConfigurableProductPageName } from '@graphcommerce/magento-product-configurable/plugins/ConfigurableProductPage/ConfigurableProductPageName'
664
+ import type { DistributedOmit as OmitPrev } from 'type-fest'
667
665
  import { ProductPageName as ProductPageNameMyPlugin } from '../../../../plugins/MyPlugin'"
668
666
  `)
669
667
 
670
668
  expectOriginal(result).toMatchInlineSnapshot(`
671
669
  "import type { ProductPageNameFragment } from './ProductPageName.gql'
670
+
672
671
  export type ProductPageNameProps = {
673
672
  product: ProductPageNameFragment
674
673
  }
@@ -737,12 +736,11 @@ it('Can correctly find exports that are default exports', async () => {
737
736
  export const iconChevronLeft = accessibilityHuman
738
737
  export const iconChevronRight = alarm
739
738
  `
740
-
741
739
  const config = {
742
740
  demoMode: true,
743
741
  configurableVariantForSimple: true,
744
742
  configurableVariantValues: { content: true, gallery: true, url: true },
745
- } as GraphCommerceConfig
743
+ } as unknown as GraphCommerceConfig
746
744
 
747
745
  const plugins = parseStructure(parseSync(pluginSource), config, './plugins/MyProjectIcon')
748
746
 
@@ -752,8 +750,10 @@ it('Can correctly find exports that are default exports', async () => {
752
750
  const result = interceptors['packages/next-ui/icons']?.template
753
751
 
754
752
  expectImport(result).toMatchInlineSnapshot(`
755
- "import { iconChevronLeft as iconChevronLeftMyProjectIcon } from '../../plugins/MyProjectIcon'
756
- import { iconChevronRight as iconChevronRightMyProjectIcon } from '../../plugins/MyProjectIcon'"
753
+ "import {
754
+ iconChevronLeft as iconChevronLeftMyProjectIcon,
755
+ iconChevronRight as iconChevronRightMyProjectIcon,
756
+ } from '../../plugins/MyProjectIcon'"
757
757
  `)
758
758
 
759
759
  expectOriginal(result).toContain('iconChevronLeftDisabled')
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.generateConfig = generateConfig;
7
- const fs_1 = require("fs");
8
7
  // eslint-disable-next-line import/no-extraneous-dependencies
9
8
  const cli_1 = require("@graphql-codegen/cli");
10
9
  const core_1 = require("@swc/core");
11
10
  const dotenv_1 = __importDefault(require("dotenv"));
11
+ const fs_1 = require("fs");
12
12
  const isMonorepo_1 = require("../../utils/isMonorepo");
13
13
  const resolveDependenciesSync_1 = require("../../utils/resolveDependenciesSync");
14
14
  const resolveDependency_1 = require("../../utils/resolveDependency");
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
- /**
3
- * This is an implementation of
4
- * https://github.com/swc-project/swc/blob/main/node-swc/src/Visitor.ts
5
- *
6
- * The JS API is deprecated, but there doesn't seem to be a valid alternative at this point.
7
- */
8
2
  Object.defineProperty(exports, "__esModule", { value: true });
9
3
  exports.Visitor = void 0;
4
+ /* eslint-disable no-param-reassign */
5
+ /* eslint-disable class-methods-use-this */
6
+ /* eslint-disable consistent-return */
10
7
  /**
11
8
  * @deprecated JavaScript API is deprecated. Please use Wasm plugin instead.
12
9
  */
@@ -594,7 +591,7 @@ class Visitor {
594
591
  return n;
595
592
  }
596
593
  visitTsFnParameters(params) {
597
- return params?.map(this.visitTsFnParameter.bind(this));
594
+ return params.map(this.visitTsFnParameter.bind(this));
598
595
  }
599
596
  visitTsFnParameter(n) {
600
597
  n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.RUNTIME_VALUE = exports.UnsupportedValueError = exports.NoSuchDeclarationError = void 0;
4
5
  exports.extractExports = extractExports;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.generateInterceptors = generateInterceptors;
7
+ // eslint-disable-next-line import/no-extraneous-dependencies
7
8
  const promises_1 = __importDefault(require("node:fs/promises"));
8
9
  const node_path_1 = __importDefault(require("node:path"));
9
10
  const findOriginalSource_1 = require("./findOriginalSource");
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.writeInterceptors = writeInterceptors;
7
- const promises_1 = __importDefault(require("node:fs/promises"));
8
- const path_1 = __importDefault(require("path"));
9
7
  // eslint-disable-next-line import/no-extraneous-dependencies
10
8
  const glob_1 = require("glob");
9
+ const promises_1 = __importDefault(require("node:fs/promises"));
10
+ const path_1 = __importDefault(require("path"));
11
11
  const resolveDependenciesSync_1 = require("../utils/resolveDependenciesSync");
12
12
  function checkFileExists(file) {
13
13
  return promises_1.default
@@ -58,6 +58,7 @@ function withGraphCommerce(nextConfig, cwd) {
58
58
  remotePatterns: [
59
59
  { hostname: new URL(graphcommerceConfig.magentoEndpoint).hostname },
60
60
  { hostname: 'media.graphassets.com' },
61
+ { hostname: '*.graphcommerce.org' },
61
62
  ...(nextConfig.images?.remotePatterns ?? []),
62
63
  ],
63
64
  },
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/next-config",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "9.0.0-canary.103",
5
+ "version": "9.0.0-canary.105",
6
6
  "type": "commonjs",
7
7
  "main": "dist/index.js",
8
8
  "types": "src/index.ts",
@@ -30,7 +30,7 @@
30
30
  "lodash": "^4.17.21",
31
31
  "react": "^18.3.1",
32
32
  "typescript": "5.6.2",
33
- "webpack": "~5.93.0",
33
+ "webpack": "^5.96.1",
34
34
  "znv": "^0.4.0",
35
35
  "zod": "^3.23.8"
36
36
  },
@@ -1,8 +1,8 @@
1
- import { writeFileSync } from 'fs'
2
1
  // eslint-disable-next-line import/no-extraneous-dependencies
3
2
  import { generate } from '@graphql-codegen/cli'
4
3
  import { transformFileSync } from '@swc/core'
5
4
  import dotenv from 'dotenv'
5
+ import { writeFileSync } from 'fs'
6
6
  import { isMonorepo } from '../../utils/isMonorepo'
7
7
  import { resolveDependenciesSync } from '../../utils/resolveDependenciesSync'
8
8
  import { resolveDependency } from '../../utils/resolveDependency'
@@ -1,9 +1,9 @@
1
1
  // eslint-disable-next-line import/no-extraneous-dependencies
2
2
  import type { PartialDeep } from 'type-fest'
3
- import type { GraphCommerceConfig } from '../generated/config'
3
+ import type { GraphCommerceConfig, GraphCommerceStorefrontConfig } from '../generated/config'
4
4
 
5
5
  export const demoConfig: PartialDeep<GraphCommerceConfig, { recurseIntoArrays: true }> &
6
- Record<string, unknown> = {
6
+ Record<string, unknown> & { storefront: PartialDeep<GraphCommerceStorefrontConfig>[] } = {
7
7
  canonicalBaseUrl: 'https://graphcommerce.vercel.app',
8
8
  hygraphEndpoint: 'https://eu-central-1.cdn.hygraph.com/content/ckhx7xadya6xs01yxdujt8i80/master',
9
9
  magentoEndpoint: 'https://backend.reachdigital.dev/graphql',
@@ -1,21 +1,21 @@
1
1
  /* eslint-disable import/no-extraneous-dependencies */
2
- import { mergeDeep, cloneDeep } from '@apollo/client/utilities'
2
+ import { cloneDeep, mergeDeep } from '@apollo/client/utilities'
3
3
  import chalk from 'chalk'
4
4
  import { get, set } from 'lodash'
5
5
  import snakeCase from 'lodash/snakeCase'
6
- import type { ZodRawShape, ZodTypeAny, ZodAny } from 'zod'
6
+ import type { ZodAny, ZodRawShape, ZodTypeAny } from 'zod'
7
7
  import {
8
- z,
9
- ZodObject,
10
- ZodBoolean,
11
8
  ZodArray,
12
- ZodString,
13
- ZodNumber,
14
- ZodNullable,
15
- ZodOptional,
9
+ ZodBoolean,
10
+ ZodDefault,
16
11
  ZodEffects,
17
12
  ZodEnum,
18
- ZodDefault,
13
+ ZodNullable,
14
+ ZodNumber,
15
+ ZodObject,
16
+ ZodOptional,
17
+ ZodString,
18
+ z,
19
19
  } from 'zod'
20
20
  import diff from './diff'
21
21
 
@@ -1,16 +1,9 @@
1
1
  /**
2
2
  * This is an implementation of
3
- * https://github.com/swc-project/swc/blob/main/node-swc/src/Visitor.ts
3
+ * https://github.com/swc-project/swc/blob/main/packages/core/src/Visitor.ts
4
4
  *
5
5
  * The JS API is deprecated, but there doesn't seem to be a valid alternative at this point.
6
6
  */
7
-
8
- /* eslint-disable @typescript-eslint/no-unused-vars */
9
- /* eslint-disable @typescript-eslint/no-explicit-any */
10
- /* eslint-disable no-param-reassign */
11
- /* eslint-disable class-methods-use-this */
12
- /* eslint-disable consistent-return */
13
- // eslint-disable-next-line import/no-extraneous-dependencies
14
7
  import type {
15
8
  Accessibility,
16
9
  Argument,
@@ -188,6 +181,10 @@ import type {
188
181
  YieldExpression,
189
182
  } from '@swc/types'
190
183
 
184
+ /* eslint-disable no-param-reassign */
185
+ /* eslint-disable class-methods-use-this */
186
+ /* eslint-disable consistent-return */
187
+
191
188
  /**
192
189
  * @deprecated JavaScript API is deprecated. Please use Wasm plugin instead.
193
190
  */
@@ -872,7 +869,7 @@ export class Visitor {
872
869
  }
873
870
 
874
871
  visitTsFnParameters(params: TsFnParameter[]): TsFnParameter[] {
875
- return params?.map(this.visitTsFnParameter.bind(this))
872
+ return params.map(this.visitTsFnParameter.bind(this))
876
873
  }
877
874
 
878
875
  visitTsFnParameter(n: TsFnParameter): TsFnParameter {
@@ -1,5 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
+
2
3
  /* eslint-disable no-continue */
4
+
3
5
  /* eslint-disable max-classes-per-file */
4
6
  import type {
5
7
  ArrayExpression,
@@ -1,5 +1,5 @@
1
- import path from 'path'
2
1
  import type { ExportAllDeclaration } from '@swc/core'
2
+ import path from 'path'
3
3
  import type { ResolveDependency, ResolveDependencyReturn } from '../utils/resolveDependency'
4
4
  import type { PluginConfig } from './generateInterceptor'
5
5
  import { parseSync } from './swc'
@@ -1,6 +1,6 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
1
2
  import fs from 'node:fs/promises'
2
3
  import path from 'node:path'
3
- // eslint-disable-next-line import/no-extraneous-dependencies
4
4
  import type { GraphCommerceDebugConfig } from '../generated/config'
5
5
  import type { ResolveDependency } from '../utils/resolveDependency'
6
6
  import { findOriginalSource } from './findOriginalSource'
@@ -1,7 +1,7 @@
1
- import fs from 'node:fs/promises'
2
- import path from 'path'
3
1
  // eslint-disable-next-line import/no-extraneous-dependencies
4
2
  import { sync as globSync } from 'glob'
3
+ import fs from 'node:fs/promises'
4
+ import path from 'path'
5
5
  import { resolveDependenciesSync } from '../utils/resolveDependenciesSync'
6
6
  import type { GenerateInterceptorsReturn } from './generateInterceptors'
7
7
 
@@ -72,6 +72,7 @@ export function withGraphCommerce(nextConfig: NextConfig, cwd: string): NextConf
72
72
  remotePatterns: [
73
73
  { hostname: new URL(graphcommerceConfig.magentoEndpoint).hostname },
74
74
  { hostname: 'media.graphassets.com' },
75
+ { hostname: '*.graphcommerce.org' },
75
76
  ...(nextConfig.images?.remotePatterns ?? []),
76
77
  ],
77
78
  },