@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.
- package/CHANGELOG.md +8 -0
- package/__tests__/commands/copyFiles.ts +512 -0
- package/__tests__/config/utils/__snapshots__/mergeEnvIntoConfig.ts.snap +3 -0
- package/__tests__/config/utils/mergeEnvIntoConfig.ts +4 -17
- package/__tests__/config/utils/rewriteLegancyEnv.ts +30 -35
- package/__tests__/interceptors/findPlugins.ts +38 -53
- package/__tests__/interceptors/generateInterceptors.ts +23 -74
- package/__tests__/utils/resolveDependenciesSync.ts +9 -9
- package/dist/commands/codegen.js +18 -0
- package/dist/commands/copyFiles.js +293 -0
- package/dist/commands/copyRoutes.js +20 -0
- package/dist/config/utils/mergeEnvIntoConfig.js +5 -5
- package/dist/generated/config.js +8 -0
- package/dist/index.js +3 -0
- package/dist/interceptors/generateInterceptor.js +3 -5
- package/dist/utils/resolveDependenciesSync.js +6 -1
- package/dist/utils/sig.js +34 -0
- package/dist/withGraphCommerce.js +1 -1
- package/package.json +10 -9
- package/src/commands/codegen.ts +18 -0
- package/src/commands/copyFiles.ts +329 -0
- package/src/config/utils/mergeEnvIntoConfig.ts +6 -7
- package/src/generated/config.ts +18 -0
- package/src/index.ts +4 -3
- package/src/interceptors/generateInterceptor.ts +3 -5
- package/src/utils/resolveDependenciesSync.ts +10 -1
- package/src/utils/sig.ts +37 -0
- package/src/withGraphCommerce.ts +1 -1
- package/dist/config/commands/generateIntercetors.js +0 -9
- package/dist/interceptors/commands/generateIntercetors.js +0 -9
|
@@ -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
|
|
53
|
-
‼ MAGENTO_ENDPOINT
|
|
54
|
-
‼ NEXT_PUBLIC_GRAPHQL_ENDPOINT
|
|
55
|
-
‼ IMAGE_DOMAINS
|
|
56
|
-
‼ NEXT_PUBLIC_LOCALE_STORES
|
|
57
|
-
‼ NEXT_PUBLIC_SITE_URL
|
|
58
|
-
‼ NEXT_PUBLIC_GTM_ID
|
|
59
|
-
‼ NEXT_PUBLIC_GOOGLE_ANALYTICS
|
|
60
|
-
‼ NEXT_PUBLIC_GOOGLE_RECAPTCHA_V3_SITE_KEY
|
|
61
|
-
‼ NEXT_PUBLIC_DISPLAY_INCL_TAX
|
|
62
|
-
‼ PREVIEW_SECRET
|
|
63
|
-
‼ DEMO_MAGENTO_GRAPHCOMMERCE
|
|
64
|
-
~ GC_CANONICAL_BASE_URL
|
|
65
|
-
+ GC_DEMO_MODE
|
|
66
|
-
+ GC_GOOGLE_ANALYTICS_ID
|
|
67
|
-
+ GC_GOOGLE_RECAPTCHA_KEY
|
|
68
|
-
+ GC_GOOGLE_TAGMANAGER_ID
|
|
69
|
-
~ GC_HYGRAPH_ENDPOINT
|
|
70
|
-
~ GC_MAGENTO_ENDPOINT
|
|
71
|
-
~ GC_PREVIEW_SECRET
|
|
72
|
-
= GC_STOREFRONT
|
|
73
|
-
+ GC_STOREFRONT_0_GOOGLE_ANALYTICS_ID
|
|
74
|
-
+ GC_STOREFRONT_1_GOOGLE_ANALYTICS_ID
|
|
75
|
-
+ GC_STOREFRONT_2_CART_DISPLAY_PRICES_INCL_TAX
|
|
76
|
-
+ GC_STOREFRONT_2_GOOGLE_ANALYTICS_ID
|
|
77
|
-
+ GC_STOREFRONT_3_CART_DISPLAY_PRICES_INCL_TAX
|
|
78
|
-
+ GC_STOREFRONT_3_GOOGLE_ANALYTICS_ID
|
|
79
|
-
+ GC_STOREFRONT_4_CART_DISPLAY_PRICES_INCL_TAX
|
|
80
|
-
+ GC_STOREFRONT_4_GOOGLE_ANALYTICS_ID
|
|
81
|
-
+ GC_STOREFRONT_5_GOOGLE_ANALYTICS_ID
|
|
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
|
-
|
|
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",
|