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

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.
@@ -2,7 +2,6 @@ import { formatAppliedEnv } from '../../../src/config/utils/mergeEnvIntoConfig'
2
2
  import { rewriteLegacyEnv } from '../../../src/config/utils/rewriteLegacyEnv'
3
3
  import type { GraphCommerceConfig } from '../../../src/generated/config'
4
4
  import { GraphCommerceConfigSchema } from '../../../src/generated/config'
5
-
6
5
  export const removeColor = (str: string) =>
7
6
  str.replace(
8
7
  new RegExp(
@@ -14,7 +13,6 @@ export const removeColor = (str: string) =>
14
13
  ),
15
14
  '',
16
15
  )
17
-
18
16
  it('rewrites legacy env', () => {
19
17
  const configFile: GraphCommerceConfig = {
20
18
  storefront: [{ locale: 'en', hygraphLocales: ['en'], magentoStoreCode: 'en_us' }],
@@ -26,7 +24,6 @@ it('rewrites legacy env', () => {
26
24
  robotsAllow: true,
27
25
  magentoVersion: 246,
28
26
  }
29
-
30
27
  const legacyEnv = {
31
28
  GRAPHCMS_URL: 'https://api-eu-central-1.graphcms.com/v2/ckhx7xadya6xs01yxdujt8i80/master',
32
29
  MAGENTO_ENDPOINT: 'https://backend.reachdigital.dev/graphql',
@@ -44,40 +41,38 @@ it('rewrites legacy env', () => {
44
41
  DEMO_MAGENTO_GRAPHCOMMERCE: '1',
45
42
  SOME_KEY: 'bla',
46
43
  }
47
-
48
44
  const [, appliedRewrite] = rewriteLegacyEnv(GraphCommerceConfigSchema(), legacyEnv, configFile)
49
-
50
45
  expect(removeColor(formatAppliedEnv(appliedRewrite))).toMatchInlineSnapshot(`
51
46
  "warning - Loaded GraphCommerce env variables
52
- ‼ GRAPHCMS_URL='https://api-eu-central-1.graphcms.com/v2/ckhx7xadya6xs01yxdujt8i80/master' => should be renamed to GC_HYGRAPH_ENDPOINT='https://api-eu-central-1.graphcms.com/v2/ckhx7xadya6xs01yxdujt8i80/master'
53
- ‼ MAGENTO_ENDPOINT='https://backend.reachdigital.dev/graphql' => should be renamed to GC_MAGENTO_ENDPOINT='https://backend.reachdigital.dev/graphql'
54
- ‼ NEXT_PUBLIC_GRAPHQL_ENDPOINT='http://localhost:3000/api/graphql' => should be removed
55
- ‼ IMAGE_DOMAINS='backend.reachdigital.dev,media.graphcms.com,media.graphassets.com' => should be removed: will automatically add the Magento/Hygraph URL. For more advanced configurations, see: https://nextjs.org/docs/api-reference/next/image#configuration-options
56
- ‼ NEXT_PUBLIC_LOCALE_STORES='{"en-us": "en_US", "nl-nl": "nl_NL", "fr-be": "fr_BE", "nl-be": "nl_BE", "en-gb": "en_GB", "en-ca": "en_CA"}' => env variable is is modified, rewritten to GC_STOREFRONT.
57
- ‼ NEXT_PUBLIC_SITE_URL='https://graphcommerce.vercel.app/' => should be renamed to GC_CANONICAL_BASE_URL='https://graphcommerce.vercel.app/'
58
- ‼ NEXT_PUBLIC_GTM_ID='123' => should be renamed to GC_GOOGLE_TAGMANAGER_ID='123'
59
- ‼ NEXT_PUBLIC_GOOGLE_ANALYTICS='{"en-us": "G-111", "nl-nl": "G-222", "fr-be": "G-333", "nl-be": "G-444", "en-gb":"G-555", "en-ca": "G-666"}' => should be rewritten to GC_STOREFRONT_*_GOOGLE_ANALYTICS_ID
60
- ‼ NEXT_PUBLIC_GOOGLE_RECAPTCHA_V3_SITE_KEY='' => should be renamed to GC_GOOGLE_RECAPTCHA_KEY=''
61
- ‼ NEXT_PUBLIC_DISPLAY_INCL_TAX='nl,fr-be,nl-be,en-gb,eu' => env variable is renamed, move to configuration: cartDisplayPricesInclTax
62
- ‼ PREVIEW_SECRET='dya6xs01y' => should be renamed to GC_PREVIEW_SECRET='dya6xs01y'
63
- ‼ DEMO_MAGENTO_GRAPHCOMMERCE='1' => should be renamed to GC_DEMO_MODE='1'
64
- ~ GC_CANONICAL_BASE_URL='https://graphcommerce.vercel.app/' => canonicalBaseUrl: "https://example.com" => "https://graphcommerce.vercel.app/"
65
- + GC_DEMO_MODE='1' => demoMode: true
66
- + GC_GOOGLE_ANALYTICS_ID='enabled' => googleAnalyticsId: "enabled"
67
- + GC_GOOGLE_RECAPTCHA_KEY='' => googleRecaptchaKey: ""
68
- + GC_GOOGLE_TAGMANAGER_ID='123' => googleTagmanagerId: "123"
69
- ~ GC_HYGRAPH_ENDPOINT='https://api-eu-central-1.graphcms.com/v2/ckhx7xadya6xs01yxdujt8i80/master' => hygraphEndpoint: "https://example.com" => "https://api-eu-central-1.graphcms.com/v2/ckhx7xadya6xs01yxdujt8i80/master"
70
- ~ GC_MAGENTO_ENDPOINT='https://backend.reachdigital.dev/graphql' => magentoEndpoint: "https://example.com" => "https://backend.reachdigital.dev/graphql"
71
- ~ GC_PREVIEW_SECRET='dya6xs01y' => previewSecret: "secret" => "dya6xs01y"
72
- = GC_STOREFRONT='[{"locale":"en-us","magentoStoreCode":"en_US"},{"locale":"nl-nl","magentoStoreCode":"nl_NL"},{"locale":"fr-be","magentoStoreCode":"fr_BE"},{"locale":"nl-be","magentoStoreCode":"nl_BE"},{"locale":"en-gb","magentoStoreCode":"en_GB"},{"locale":"en-ca","magentoStoreCode":"en_CA"}]' => storefront: (ignored, no change/wrong format)
73
- + GC_STOREFRONT_0_GOOGLE_ANALYTICS_ID='G-111' => storefront.[0].googleAnalyticsId: "G-111"
74
- + GC_STOREFRONT_1_GOOGLE_ANALYTICS_ID='G-222' => storefront.[1].googleAnalyticsId: "G-222"
75
- + GC_STOREFRONT_2_CART_DISPLAY_PRICES_INCL_TAX='1' => storefront.[2].cartDisplayPricesInclTax: true
76
- + GC_STOREFRONT_2_GOOGLE_ANALYTICS_ID='G-333' => storefront.[2].googleAnalyticsId: "G-333"
77
- + GC_STOREFRONT_3_CART_DISPLAY_PRICES_INCL_TAX='1' => storefront.[3].cartDisplayPricesInclTax: true
78
- + GC_STOREFRONT_3_GOOGLE_ANALYTICS_ID='G-444' => storefront.[3].googleAnalyticsId: "G-444"
79
- + GC_STOREFRONT_4_CART_DISPLAY_PRICES_INCL_TAX='1' => storefront.[4].cartDisplayPricesInclTax: true
80
- + GC_STOREFRONT_4_GOOGLE_ANALYTICS_ID='G-555' => storefront.[4].googleAnalyticsId: "G-555"
81
- + GC_STOREFRONT_5_GOOGLE_ANALYTICS_ID='G-666' => storefront.[5].googleAnalyticsId: "G-666""
47
+ ‼ GRAPHCMS_URL => should be renamed to GC_HYGRAPH_ENDPOINT='https://api-eu-central-1.graphcms.com/v2/ckhx7xadya6xs01yxdujt8i80/master'
48
+ ‼ MAGENTO_ENDPOINT => should be renamed to GC_MAGENTO_ENDPOINT='https://backend.reachdigital.dev/graphql'
49
+ ‼ NEXT_PUBLIC_GRAPHQL_ENDPOINT => should be removed
50
+ ‼ IMAGE_DOMAINS => should be removed: will automatically add the Magento/Hygraph URL. For more advanced configurations, see: https://nextjs.org/docs/api-reference/next/image#configuration-options
51
+ ‼ NEXT_PUBLIC_LOCALE_STORES => env variable is is modified, rewritten to GC_STOREFRONT.
52
+ ‼ NEXT_PUBLIC_SITE_URL => should be renamed to GC_CANONICAL_BASE_URL='https://graphcommerce.vercel.app/'
53
+ ‼ NEXT_PUBLIC_GTM_ID => should be renamed to GC_GOOGLE_TAGMANAGER_ID='123'
54
+ ‼ NEXT_PUBLIC_GOOGLE_ANALYTICS => should be rewritten to GC_STOREFRONT_*_GOOGLE_ANALYTICS_ID
55
+ ‼ NEXT_PUBLIC_GOOGLE_RECAPTCHA_V3_SITE_KEY => should be renamed to GC_GOOGLE_RECAPTCHA_KEY=''
56
+ ‼ NEXT_PUBLIC_DISPLAY_INCL_TAX => env variable is renamed, move to configuration: cartDisplayPricesInclTax
57
+ ‼ PREVIEW_SECRET => should be renamed to GC_PREVIEW_SECRET='dya6xs01y'
58
+ ‼ DEMO_MAGENTO_GRAPHCOMMERCE => should be renamed to GC_DEMO_MODE='1'
59
+ ~ GC_CANONICAL_BASE_URL => canonicalBaseUrl
60
+ + GC_DEMO_MODE => demoMode
61
+ + GC_GOOGLE_ANALYTICS_ID => googleAnalyticsId
62
+ + GC_GOOGLE_RECAPTCHA_KEY => googleRecaptchaKey
63
+ + GC_GOOGLE_TAGMANAGER_ID => googleTagmanagerId
64
+ ~ GC_HYGRAPH_ENDPOINT => hygraphEndpoint
65
+ ~ GC_MAGENTO_ENDPOINT => magentoEndpoint
66
+ ~ GC_PREVIEW_SECRET => previewSecret
67
+ = GC_STOREFRONT => storefront: (ignored)
68
+ + GC_STOREFRONT_0_GOOGLE_ANALYTICS_ID => storefront.[0].googleAnalyticsId
69
+ + GC_STOREFRONT_1_GOOGLE_ANALYTICS_ID => storefront.[1].googleAnalyticsId
70
+ + GC_STOREFRONT_2_CART_DISPLAY_PRICES_INCL_TAX => storefront.[2].cartDisplayPricesInclTax
71
+ + GC_STOREFRONT_2_GOOGLE_ANALYTICS_ID => storefront.[2].googleAnalyticsId
72
+ + GC_STOREFRONT_3_CART_DISPLAY_PRICES_INCL_TAX => storefront.[3].cartDisplayPricesInclTax
73
+ + GC_STOREFRONT_3_GOOGLE_ANALYTICS_ID => storefront.[3].googleAnalyticsId
74
+ + GC_STOREFRONT_4_CART_DISPLAY_PRICES_INCL_TAX => storefront.[4].cartDisplayPricesInclTax
75
+ + GC_STOREFRONT_4_GOOGLE_ANALYTICS_ID => storefront.[4].googleAnalyticsId
76
+ + GC_STOREFRONT_5_GOOGLE_ANALYTICS_ID => storefront.[5].googleAnalyticsId"
82
77
  `)
83
78
  })
@@ -1,26 +1,55 @@
1
1
  import type { GraphCommerceConfig } from '../../src/generated/config'
2
2
  import { findPlugins } from '../../src/interceptors/findPlugins'
3
-
4
3
  const projectRoot = `${process.cwd()}/examples/magento-graphcms`
5
-
6
4
  it('finds plugins', () => {
7
5
  const fakeconfig = {
8
6
  googleRecaptchaKey: '123',
9
7
  googleAnalyticsId: '123',
10
- // demoMode: true,
11
- debug: {
12
- pluginStatus: true,
13
- },
8
+ demoMode: true,
9
+ debug: { pluginStatus: true },
14
10
  } as GraphCommerceConfig
15
-
16
11
  const [plugins, errors] = findPlugins(fakeconfig, projectRoot)
17
12
  const disabled = plugins.filter((p) => !p.enabled)
18
13
  const enabled = plugins.filter((p) => p.enabled)
19
-
20
14
  expect(errors).toMatchInlineSnapshot('[]')
21
-
22
15
  expect(enabled).toMatchInlineSnapshot(`
23
16
  [
17
+ {
18
+ "enabled": true,
19
+ "ifConfig": "demoMode",
20
+ "sourceExport": "AddProductsToCartForm",
21
+ "sourceModule": "./plugins/EnableCrosssellsPlugin",
22
+ "targetExport": "AddProductsToCartForm",
23
+ "targetModule": "@graphcommerce/magento-product",
24
+ "type": "component",
25
+ },
26
+ {
27
+ "enabled": true,
28
+ "ifConfig": "demoMode",
29
+ "sourceExport": "RowLinks",
30
+ "sourceModule": "@graphcommerce/demo-magento-graphcommerce/plugins/demo/DemoRowLinks",
31
+ "targetExport": "RowLinks",
32
+ "targetModule": "@graphcommerce/next-ui",
33
+ "type": "component",
34
+ },
35
+ {
36
+ "enabled": true,
37
+ "ifConfig": "demoMode",
38
+ "sourceExport": "RecentlyViewedProducts",
39
+ "sourceModule": "@graphcommerce/demo-magento-graphcommerce/plugins/demo/DemoRecentlyViewedProducts",
40
+ "targetExport": "RecentlyViewedProducts",
41
+ "targetModule": "@graphcommerce/magento-recently-viewed-products",
42
+ "type": "component",
43
+ },
44
+ {
45
+ "enabled": true,
46
+ "ifConfig": "demoMode",
47
+ "sourceExport": "ProductListItemConfigurable",
48
+ "sourceModule": "@graphcommerce/demo-magento-graphcommerce/plugins/demo/DemoProductListItemConfigurable",
49
+ "targetExport": "ProductListItemConfigurable",
50
+ "targetModule": "@graphcommerce/magento-product-configurable",
51
+ "type": "component",
52
+ },
24
53
  {
25
54
  "enabled": true,
26
55
  "ifConfig": "googleAnalyticsId",
@@ -503,14 +532,6 @@ it('finds plugins', () => {
503
532
  "targetModule": "@graphcommerce/graphql",
504
533
  "type": "component",
505
534
  },
506
- {
507
- "enabled": true,
508
- "sourceExport": "graphqlConfig",
509
- "sourceModule": "@graphcommerce/magento-store/plugins/magentoStoreGraphqlConfig",
510
- "targetExport": "graphqlConfig",
511
- "targetModule": "@graphcommerce/graphql",
512
- "type": "function",
513
- },
514
535
  {
515
536
  "enabled": true,
516
537
  "sourceExport": "meshConfig",
@@ -539,42 +560,6 @@ it('finds plugins', () => {
539
560
  `)
540
561
  expect(disabled).toMatchInlineSnapshot(`
541
562
  [
542
- {
543
- "enabled": false,
544
- "ifConfig": "demoMode",
545
- "sourceExport": "AddProductsToCartForm",
546
- "sourceModule": "./plugins/EnableCrosssellsPlugin",
547
- "targetExport": "AddProductsToCartForm",
548
- "targetModule": "@graphcommerce/magento-product",
549
- "type": "component",
550
- },
551
- {
552
- "enabled": false,
553
- "ifConfig": "demoMode",
554
- "sourceExport": "RowLinks",
555
- "sourceModule": "@graphcommerce/demo-magento-graphcommerce/plugins/demo/DemoRowLinks",
556
- "targetExport": "RowLinks",
557
- "targetModule": "@graphcommerce/next-ui",
558
- "type": "component",
559
- },
560
- {
561
- "enabled": false,
562
- "ifConfig": "demoMode",
563
- "sourceExport": "RecentlyViewedProducts",
564
- "sourceModule": "@graphcommerce/demo-magento-graphcommerce/plugins/demo/DemoRecentlyViewedProducts",
565
- "targetExport": "RecentlyViewedProducts",
566
- "targetModule": "@graphcommerce/magento-recently-viewed-products",
567
- "type": "component",
568
- },
569
- {
570
- "enabled": false,
571
- "ifConfig": "demoMode",
572
- "sourceExport": "ProductListItemConfigurable",
573
- "sourceModule": "@graphcommerce/demo-magento-graphcommerce/plugins/demo/DemoProductListItemConfigurable",
574
- "targetExport": "ProductListItemConfigurable",
575
- "targetModule": "@graphcommerce/magento-product-configurable",
576
- "type": "component",
577
- },
578
563
  {
579
564
  "enabled": false,
580
565
  "ifConfig": "recentlyViewedProducts.enabled",