@graphcommerce/next-config 8.1.0-canary.9 → 9.0.0-canary.100
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 +261 -67
- package/__tests__/config/utils/__snapshots__/mergeEnvIntoConfig.ts.snap +159 -3
- package/__tests__/config/utils/configToImportMeta.ts +0 -4
- package/__tests__/config/utils/mergeEnvIntoConfig.ts +20 -2
- package/__tests__/config/utils/rewriteLegancyEnv.ts +1 -1
- package/__tests__/interceptors/findPlugins.ts +366 -240
- package/__tests__/interceptors/generateInterceptors.ts +138 -59
- package/__tests__/interceptors/parseStructure.ts +132 -2
- package/__tests__/utils/resolveDependenciesSync.ts +39 -33
- package/dist/config/commands/exportConfig.js +1 -2
- package/dist/config/commands/generateConfig.js +1 -2
- package/dist/config/demoConfig.js +5 -0
- package/dist/config/loadConfig.js +1 -2
- package/dist/config/utils/configToImportMeta.js +1 -2
- package/dist/config/utils/diff.js +1 -1
- package/dist/config/utils/exportConfigToEnv.js +1 -2
- package/dist/config/utils/mergeEnvIntoConfig.js +12 -5
- package/dist/config/utils/replaceConfigInString.js +1 -2
- package/dist/config/utils/rewriteLegacyEnv.js +1 -2
- package/dist/generated/config.js +37 -16
- package/dist/interceptors/Visitor.js +1 -1
- package/dist/interceptors/commands/codegenInterceptors.js +1 -2
- package/dist/interceptors/extractExports.js +23 -20
- package/dist/interceptors/findOriginalSource.js +19 -4
- package/dist/interceptors/findPlugins.js +1 -2
- package/dist/interceptors/generateInterceptor.js +11 -12
- package/dist/interceptors/generateInterceptors.js +1 -2
- package/dist/interceptors/parseStructure.js +20 -7
- package/dist/interceptors/swc.js +2 -3
- package/dist/interceptors/writeInterceptors.js +8 -9
- package/dist/utils/isMonorepo.js +1 -2
- package/dist/utils/resolveDependenciesSync.js +3 -4
- package/dist/withGraphCommerce.js +22 -15
- package/package.json +10 -11
- package/src/config/demoConfig.ts +5 -0
- package/src/config/utils/mergeEnvIntoConfig.ts +9 -1
- package/src/generated/config.ts +109 -22
- package/src/interceptors/Visitor.ts +1 -1
- package/src/interceptors/extractExports.ts +21 -21
- package/src/interceptors/findOriginalSource.ts +17 -2
- package/src/interceptors/generateInterceptor.ts +4 -6
- package/src/interceptors/parseStructure.ts +25 -5
- package/src/interceptors/writeInterceptors.ts +7 -7
- package/src/utils/resolveDependenciesSync.ts +1 -1
- package/src/withGraphCommerce.ts +21 -13
|
@@ -74,17 +74,20 @@ it('it generates an interceptor', async () => {
|
|
|
74
74
|
interceptors['packages/magento-cart-payment-method/PaymentMethodContext/PaymentMethodContext']
|
|
75
75
|
?.template
|
|
76
76
|
expectInterceptor(result).toMatchInlineSnapshot(`
|
|
77
|
-
"type
|
|
77
|
+
"type PluginAddBraintreeMethodsProps = OmitPrev<
|
|
78
|
+
React.ComponentProps<typeof PluginAddBraintreeMethods>,
|
|
79
|
+
'Prev'
|
|
80
|
+
>
|
|
78
81
|
|
|
79
|
-
const
|
|
80
|
-
<
|
|
82
|
+
const PluginAddBraintreeMethodsInterceptor = (props: PluginAddBraintreeMethodsProps) => (
|
|
83
|
+
<PluginAddBraintreeMethods {...props} Prev={PaymentMethodContextProviderOriginal} />
|
|
81
84
|
)
|
|
82
85
|
|
|
83
|
-
type
|
|
84
|
-
OmitPrev<React.ComponentProps<typeof
|
|
86
|
+
type PluginAddMollieMethodsProps = PluginAddBraintreeMethodsProps &
|
|
87
|
+
OmitPrev<React.ComponentProps<typeof PluginAddMollieMethods>, 'Prev'>
|
|
85
88
|
|
|
86
|
-
const
|
|
87
|
-
<
|
|
89
|
+
const PluginAddMollieMethodsInterceptor = (props: PluginAddMollieMethodsProps) => (
|
|
90
|
+
<PluginAddMollieMethods {...props} Prev={PluginAddBraintreeMethodsInterceptor} />
|
|
88
91
|
)
|
|
89
92
|
|
|
90
93
|
/**
|
|
@@ -93,10 +96,10 @@ it('it generates an interceptor', async () => {
|
|
|
93
96
|
* This file is NOT meant to be modified directly and is auto-generated if the plugins or the original source changes.
|
|
94
97
|
*
|
|
95
98
|
* @see {@link file://./PaymentMethodContext.tsx} for original source file
|
|
96
|
-
* @see {
|
|
97
|
-
* @see {
|
|
99
|
+
* @see {PluginAddBraintreeMethods} for source of applied plugin
|
|
100
|
+
* @see {PluginAddMollieMethods} for source of applied plugin
|
|
98
101
|
*/
|
|
99
|
-
export const PaymentMethodContextProvider =
|
|
102
|
+
export const PaymentMethodContextProvider = PluginAddMollieMethodsInterceptor"
|
|
100
103
|
`)
|
|
101
104
|
})
|
|
102
105
|
|
|
@@ -124,7 +127,7 @@ it("resolves a 'root plugin' to be relative to the interceptor", async () => {
|
|
|
124
127
|
).toMatchInlineSnapshot(`
|
|
125
128
|
"import type { DistributedOmit as OmitPrev } from 'type-fest'
|
|
126
129
|
|
|
127
|
-
import { Plugin as
|
|
130
|
+
import { Plugin as PluginAddPaymentMethodEnhancer } from '../../../plugins/AddPaymentMethodEnhancer'"
|
|
128
131
|
`)
|
|
129
132
|
})
|
|
130
133
|
|
|
@@ -157,24 +160,27 @@ it('it can apply multiple plugins to a single export', async () => {
|
|
|
157
160
|
expectImport(result).toMatchInlineSnapshot(`
|
|
158
161
|
"import type { DistributedOmit as OmitPrev } from 'type-fest'
|
|
159
162
|
|
|
160
|
-
import { Plugin as
|
|
161
|
-
import { Plugin as
|
|
163
|
+
import { Plugin as PluginAddAdyenMethods } from '@graphcommerce/magento-payment-adyen/plugins/AddAdyenMethods'
|
|
164
|
+
import { Plugin as PluginAddMollieMethods } from '@graphcommerce/mollie-magento-payment/plugins/AddMollieMethods'"
|
|
162
165
|
`)
|
|
163
166
|
|
|
164
167
|
expectOriginal(result).toContain('PaymentMethodContextProviderOriginal')
|
|
165
168
|
|
|
166
169
|
expectInterceptor(result).toMatchInlineSnapshot(`
|
|
167
|
-
"type
|
|
170
|
+
"type PluginAddAdyenMethodsProps = OmitPrev<
|
|
171
|
+
React.ComponentProps<typeof PluginAddAdyenMethods>,
|
|
172
|
+
'Prev'
|
|
173
|
+
>
|
|
168
174
|
|
|
169
|
-
const
|
|
170
|
-
<
|
|
175
|
+
const PluginAddAdyenMethodsInterceptor = (props: PluginAddAdyenMethodsProps) => (
|
|
176
|
+
<PluginAddAdyenMethods {...props} Prev={PaymentMethodContextProviderOriginal} />
|
|
171
177
|
)
|
|
172
178
|
|
|
173
|
-
type
|
|
174
|
-
OmitPrev<React.ComponentProps<typeof
|
|
179
|
+
type PluginAddMollieMethodsProps = PluginAddAdyenMethodsProps &
|
|
180
|
+
OmitPrev<React.ComponentProps<typeof PluginAddMollieMethods>, 'Prev'>
|
|
175
181
|
|
|
176
|
-
const
|
|
177
|
-
<
|
|
182
|
+
const PluginAddMollieMethodsInterceptor = (props: PluginAddMollieMethodsProps) => (
|
|
183
|
+
<PluginAddMollieMethods {...props} Prev={PluginAddAdyenMethodsInterceptor} />
|
|
178
184
|
)
|
|
179
185
|
|
|
180
186
|
/**
|
|
@@ -183,10 +189,10 @@ it('it can apply multiple plugins to a single export', async () => {
|
|
|
183
189
|
* This file is NOT meant to be modified directly and is auto-generated if the plugins or the original source changes.
|
|
184
190
|
*
|
|
185
191
|
* @see {@link file://./PaymentMethodContext.tsx} for original source file
|
|
186
|
-
* @see {
|
|
187
|
-
* @see {
|
|
192
|
+
* @see {PluginAddAdyenMethods} for source of applied plugin
|
|
193
|
+
* @see {PluginAddMollieMethods} for source of applied plugin
|
|
188
194
|
*/
|
|
189
|
-
export const PaymentMethodContextProvider =
|
|
195
|
+
export const PaymentMethodContextProvider = PluginAddMollieMethodsInterceptor"
|
|
190
196
|
`)
|
|
191
197
|
})
|
|
192
198
|
|
|
@@ -218,10 +224,13 @@ it('it handles on duplicates gracefully', async () => {
|
|
|
218
224
|
interceptors['packages/magento-cart-payment-method/PaymentMethodContext/PaymentMethodContext']
|
|
219
225
|
?.template
|
|
220
226
|
expectInterceptor(result).toMatchInlineSnapshot(`
|
|
221
|
-
"type
|
|
227
|
+
"type PluginAddBraintreeMethodsProps = OmitPrev<
|
|
228
|
+
React.ComponentProps<typeof PluginAddBraintreeMethods>,
|
|
229
|
+
'Prev'
|
|
230
|
+
>
|
|
222
231
|
|
|
223
|
-
const
|
|
224
|
-
<
|
|
232
|
+
const PluginAddBraintreeMethodsInterceptor = (props: PluginAddBraintreeMethodsProps) => (
|
|
233
|
+
<PluginAddBraintreeMethods {...props} Prev={PaymentMethodContextProviderOriginal} />
|
|
225
234
|
)
|
|
226
235
|
|
|
227
236
|
/**
|
|
@@ -230,9 +239,9 @@ it('it handles on duplicates gracefully', async () => {
|
|
|
230
239
|
* This file is NOT meant to be modified directly and is auto-generated if the plugins or the original source changes.
|
|
231
240
|
*
|
|
232
241
|
* @see {@link file://./PaymentMethodContext.tsx} for original source file
|
|
233
|
-
* @see {
|
|
242
|
+
* @see {PluginAddBraintreeMethods} for source of applied plugin
|
|
234
243
|
*/
|
|
235
|
-
export const PaymentMethodContextProvider =
|
|
244
|
+
export const PaymentMethodContextProvider = PluginAddBraintreeMethodsInterceptor"
|
|
236
245
|
`)
|
|
237
246
|
})
|
|
238
247
|
|
|
@@ -389,28 +398,38 @@ it('adds debug logging to interceptors for components', async () => {
|
|
|
389
398
|
)
|
|
390
399
|
|
|
391
400
|
expectImport(interceptors['packages/graphql/config']?.template).toMatchInlineSnapshot(`
|
|
392
|
-
"import { plugin as
|
|
393
|
-
import { plugin as
|
|
401
|
+
"import { plugin as pluginmagentoInitMemoryCache } from '@graphcommerce/magento-graphql/plugins/magentoInitMemoryCache'
|
|
402
|
+
import { plugin as pluginhygraphInitMemoryCache } from '@graphcommerce/magento-hygraph/plugins/hygraphInitMemoryCache'"
|
|
394
403
|
`)
|
|
395
404
|
|
|
396
405
|
expectOriginal(interceptors['packages/graphql/config']?.template).toMatchInlineSnapshot(`
|
|
397
406
|
"import { ApolloLink, TypePolicies } from '@apollo/client'
|
|
398
407
|
import type { GraphCommerceStorefrontConfig } from '@graphcommerce/next-config'
|
|
408
|
+
import type { SetRequired } from 'type-fest'
|
|
399
409
|
import { MigrateCache } from './components/GraphQLProvider/migrateCache'
|
|
410
|
+
export interface PreviewData {}
|
|
411
|
+
export type PreviewConfig = {
|
|
412
|
+
preview?: boolean
|
|
413
|
+
previewData?: PreviewData & Record<string, unknown>
|
|
414
|
+
}
|
|
400
415
|
export type ApolloClientConfigInput = {
|
|
401
416
|
storefront: GraphCommerceStorefrontConfig
|
|
402
417
|
links?: ApolloLink[]
|
|
403
418
|
policies?: TypePolicies[]
|
|
404
419
|
migrations?: MigrateCache[]
|
|
405
|
-
}
|
|
406
|
-
export type ApolloClientConfig =
|
|
420
|
+
} & PreviewConfig
|
|
421
|
+
export type ApolloClientConfig = SetRequired<
|
|
422
|
+
ApolloClientConfigInput,
|
|
423
|
+
'links' | 'policies' | 'migrations'
|
|
424
|
+
>
|
|
407
425
|
export function graphqlConfigOriginal(config: ApolloClientConfigInput): ApolloClientConfig {
|
|
408
|
-
const { storefront, links = [], policies = [], migrations = [] } = config
|
|
426
|
+
const { storefront, links = [], policies = [], migrations = [], ...rest } = config
|
|
409
427
|
return {
|
|
410
428
|
storefront,
|
|
411
429
|
links,
|
|
412
430
|
policies,
|
|
413
431
|
migrations,
|
|
432
|
+
...rest,
|
|
414
433
|
}
|
|
415
434
|
}"
|
|
416
435
|
`)
|
|
@@ -423,17 +442,19 @@ it('adds debug logging to interceptors for components', async () => {
|
|
|
423
442
|
console.warn(log, ...additional)
|
|
424
443
|
}
|
|
425
444
|
|
|
426
|
-
const
|
|
445
|
+
const pluginhygraphInitMemoryCacheInterceptor: typeof graphqlConfigOriginal = (...args) => {
|
|
427
446
|
logOnce(
|
|
428
|
-
\`🔌 Calling graphqlConfig with plugin(s):
|
|
447
|
+
\`🔌 Calling graphqlConfig with plugin(s): pluginmagentoInitMemoryCache wrapping pluginhygraphInitMemoryCache wrapping graphqlConfig()\`,
|
|
429
448
|
)
|
|
430
|
-
return
|
|
449
|
+
return pluginhygraphInitMemoryCache(graphqlConfigOriginal, ...args)
|
|
431
450
|
}
|
|
432
|
-
const
|
|
451
|
+
const pluginmagentoInitMemoryCacheInterceptor: typeof pluginhygraphInitMemoryCacheInterceptor = (
|
|
452
|
+
...args
|
|
453
|
+
) => {
|
|
433
454
|
logOnce(
|
|
434
|
-
\`🔌 Calling graphqlConfig with plugin(s):
|
|
455
|
+
\`🔌 Calling graphqlConfig with plugin(s): pluginhygraphInitMemoryCache wrapping pluginmagentoInitMemoryCache wrapping graphqlConfig()\`,
|
|
435
456
|
)
|
|
436
|
-
return
|
|
457
|
+
return pluginmagentoInitMemoryCache(pluginhygraphInitMemoryCacheInterceptor, ...args)
|
|
437
458
|
}
|
|
438
459
|
|
|
439
460
|
/**
|
|
@@ -442,10 +463,10 @@ it('adds debug logging to interceptors for components', async () => {
|
|
|
442
463
|
* This file is NOT meant to be modified directly and is auto-generated if the plugins or the original source changes.
|
|
443
464
|
*
|
|
444
465
|
* @see {@link file://./config.ts} for original source file
|
|
445
|
-
* @see {
|
|
446
|
-
* @see {
|
|
466
|
+
* @see {pluginhygraphInitMemoryCache} for source of applied plugin
|
|
467
|
+
* @see {pluginmagentoInitMemoryCache} for source of applied plugin
|
|
447
468
|
*/
|
|
448
|
-
export const graphqlConfig =
|
|
469
|
+
export const graphqlConfig = pluginmagentoInitMemoryCacheInterceptor"
|
|
449
470
|
`)
|
|
450
471
|
})
|
|
451
472
|
|
|
@@ -515,14 +536,12 @@ it('Should apply overrides to the correct file', async () => {
|
|
|
515
536
|
interceptors['packages/magento-product/components/ProductStaticPaths/getProductStaticPaths']
|
|
516
537
|
?.template
|
|
517
538
|
expectImport(result).toMatchInlineSnapshot(
|
|
518
|
-
`"import { getProductStaticPaths as
|
|
539
|
+
`"import { getProductStaticPaths as getProductStaticPathsreplaceGetProductStaticPaths } from '../../../../plugins/replaceGetProductStaticPaths'"`,
|
|
519
540
|
)
|
|
520
541
|
|
|
521
542
|
expectOriginal(result).toContain(`getProductStaticPathsDisabled`)
|
|
522
543
|
})
|
|
523
544
|
|
|
524
|
-
it('Should report an error when multiple files are overriding the same export', () => {})
|
|
525
|
-
|
|
526
545
|
it('correctly reports an error for an incorrect export', async () => {
|
|
527
546
|
const fakeconfig = {
|
|
528
547
|
googleRecaptchaKey: '123',
|
|
@@ -532,13 +551,13 @@ it('correctly reports an error for an incorrect export', async () => {
|
|
|
532
551
|
|
|
533
552
|
const src = `
|
|
534
553
|
import { getSitemapPaths as getSitemapPathsType } from '@graphcommerce/magento-product'
|
|
535
|
-
import { IfConfig,
|
|
554
|
+
import { IfConfig, FunctionPlugin } from '@graphcommerce/next-config'
|
|
536
555
|
|
|
537
556
|
export const method = 'getSitemapPaths'
|
|
538
557
|
export const exported = '@graphcommerce/magento-product'
|
|
539
558
|
export const ifConfig: IfConfig = 'demoMode'
|
|
540
559
|
|
|
541
|
-
export const plugin:
|
|
560
|
+
export const plugin: FunctionPlugin<typeof getSitemapPathsType> = (prev, ...args) => {
|
|
542
561
|
console.log('getSitemapPaths plugin ran!')
|
|
543
562
|
return prev(...args)
|
|
544
563
|
}
|
|
@@ -644,8 +663,8 @@ export const Plugin = ConfigurableProductPageName
|
|
|
644
663
|
expectImport(result).toMatchInlineSnapshot(`
|
|
645
664
|
"import type { DistributedOmit as OmitPrev } from 'type-fest'
|
|
646
665
|
|
|
647
|
-
import { Plugin as
|
|
648
|
-
import { ProductPageName as
|
|
666
|
+
import { Plugin as PluginConfigurableProductPageName } from '@graphcommerce/magento-product-configurable/plugins/ConfigurableProductPage/ConfigurableProductPageName'
|
|
667
|
+
import { ProductPageName as ProductPageNameMyPlugin } from '../../../../plugins/MyPlugin'"
|
|
649
668
|
`)
|
|
650
669
|
|
|
651
670
|
expectOriginal(result).toMatchInlineSnapshot(`
|
|
@@ -660,14 +679,12 @@ export const Plugin = ConfigurableProductPageName
|
|
|
660
679
|
`)
|
|
661
680
|
|
|
662
681
|
expectInterceptor(result).toMatchInlineSnapshot(`
|
|
663
|
-
"type
|
|
682
|
+
"type PluginConfigurableProductPageNameProps = React.ComponentProps<typeof ProductPageNameMyPlugin> &
|
|
683
|
+
OmitPrev<React.ComponentProps<typeof PluginConfigurableProductPageName>, 'Prev'>
|
|
664
684
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
const ConfigurableProductPageNameInterceptor = (props: ConfigurableProductPageNameProps) => (
|
|
669
|
-
<ConfigurableProductPageName {...props} Prev={MyPlugin} />
|
|
670
|
-
)
|
|
685
|
+
const PluginConfigurableProductPageNameInterceptor = (
|
|
686
|
+
props: PluginConfigurableProductPageNameProps,
|
|
687
|
+
) => <PluginConfigurableProductPageName {...props} Prev={ProductPageNameMyPlugin} />
|
|
671
688
|
|
|
672
689
|
/**
|
|
673
690
|
* Here you see the 'interceptor' that is applying all the configured plugins.
|
|
@@ -675,10 +692,10 @@ export const Plugin = ConfigurableProductPageName
|
|
|
675
692
|
* This file is NOT meant to be modified directly and is auto-generated if the plugins or the original source changes.
|
|
676
693
|
*
|
|
677
694
|
* @see {@link file://./ProductPageName.tsx} for original source file
|
|
678
|
-
* @see {
|
|
679
|
-
* @see {
|
|
695
|
+
* @see {ProductPageNameMyPlugin} for replacement of the original source (original source not used)
|
|
696
|
+
* @see {PluginConfigurableProductPageName} for source of applied plugin
|
|
680
697
|
*/
|
|
681
|
-
export const ProductPageName =
|
|
698
|
+
export const ProductPageName = PluginConfigurableProductPageNameInterceptor"
|
|
682
699
|
`)
|
|
683
700
|
})
|
|
684
701
|
|
|
@@ -702,3 +719,65 @@ it('generates to a .ts file when the target file is a .ts as well', async () =>
|
|
|
702
719
|
const interceptor = interceptors['packages/graphql/config']
|
|
703
720
|
expect(interceptor.sourcePath).toBe(`packages/graphql/config.ts`)
|
|
704
721
|
})
|
|
722
|
+
|
|
723
|
+
it.todo('Should report an error when multiple files are overriding the same export')
|
|
724
|
+
|
|
725
|
+
it('Can correctly find exports that are default exports', async () => {
|
|
726
|
+
const pluginSource = `
|
|
727
|
+
import { PluginConfig } from '@graphcommerce/next-config'
|
|
728
|
+
|
|
729
|
+
import accessibilityHuman from '@graphcommerce/next-ui/icons/accessibility-human.svg'
|
|
730
|
+
import alarm from '@graphcommerce/next-ui/icons/alarm.svg'
|
|
731
|
+
|
|
732
|
+
export const config: PluginConfig = {
|
|
733
|
+
type: 'replace',
|
|
734
|
+
module: '@graphcommerce/next-ui',
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
export const iconChevronLeft = accessibilityHuman
|
|
738
|
+
export const iconChevronRight = alarm
|
|
739
|
+
`
|
|
740
|
+
|
|
741
|
+
const config = {
|
|
742
|
+
demoMode: true,
|
|
743
|
+
configurableVariantForSimple: true,
|
|
744
|
+
configurableVariantValues: { content: true, gallery: true, url: true },
|
|
745
|
+
} as GraphCommerceConfig
|
|
746
|
+
|
|
747
|
+
const plugins = parseStructure(parseSync(pluginSource), config, './plugins/MyProjectIcon')
|
|
748
|
+
|
|
749
|
+
const interceptors = await generateInterceptors(plugins, resolveDependency(projectRoot))
|
|
750
|
+
expect(Object.keys(interceptors)[0]).toMatchInlineSnapshot(`"packages/next-ui/icons"`)
|
|
751
|
+
|
|
752
|
+
const result = interceptors['packages/next-ui/icons']?.template
|
|
753
|
+
|
|
754
|
+
expectImport(result).toMatchInlineSnapshot(`
|
|
755
|
+
"import { iconChevronLeft as iconChevronLeftMyProjectIcon } from '../../plugins/MyProjectIcon'
|
|
756
|
+
import { iconChevronRight as iconChevronRightMyProjectIcon } from '../../plugins/MyProjectIcon'"
|
|
757
|
+
`)
|
|
758
|
+
|
|
759
|
+
expectOriginal(result).toContain('iconChevronLeftDisabled')
|
|
760
|
+
expectOriginal(result).toContain('iconChevronRightDisabled')
|
|
761
|
+
|
|
762
|
+
expectInterceptor(result).toMatchInlineSnapshot(`
|
|
763
|
+
"/**
|
|
764
|
+
* Here you see the 'interceptor' that is applying all the configured plugins.
|
|
765
|
+
*
|
|
766
|
+
* This file is NOT meant to be modified directly and is auto-generated if the plugins or the original source changes.
|
|
767
|
+
*
|
|
768
|
+
* @see {@link file://./icons.ts} for original source file
|
|
769
|
+
* @see {iconChevronLeftMyProjectIcon} for replacement of the original source (original source not used)
|
|
770
|
+
*/
|
|
771
|
+
export const iconChevronLeft = iconChevronLeftMyProjectIcon
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Here you see the 'interceptor' that is applying all the configured plugins.
|
|
775
|
+
*
|
|
776
|
+
* This file is NOT meant to be modified directly and is auto-generated if the plugins or the original source changes.
|
|
777
|
+
*
|
|
778
|
+
* @see {@link file://./icons.ts} for original source file
|
|
779
|
+
* @see {iconChevronRightMyProjectIcon} for replacement of the original source (original source not used)
|
|
780
|
+
*/
|
|
781
|
+
export const iconChevronRight = iconChevronRightMyProjectIcon"
|
|
782
|
+
`)
|
|
783
|
+
})
|
|
@@ -77,12 +77,12 @@ export const Plugin = DemoProductListItemConfigurable
|
|
|
77
77
|
it('correctly parses the classic function plugin config', () => {
|
|
78
78
|
const src = `
|
|
79
79
|
import { graphqlConfig, setContext } from '@graphcommerce/graphql'
|
|
80
|
-
import type {
|
|
80
|
+
import type { FunctionPlugin } from '@graphcommerce/next-config'
|
|
81
81
|
|
|
82
82
|
export const func = 'graphqlConfig'
|
|
83
83
|
export const exported = '@graphcommerce/graphql'
|
|
84
84
|
|
|
85
|
-
const hygraphGraphqlConfig:
|
|
85
|
+
const hygraphGraphqlConfig: FunctionPlugin<typeof graphqlConfig> = (prev, config) => {
|
|
86
86
|
const results = prev(config)
|
|
87
87
|
|
|
88
88
|
const locales = config.storefront.hygraphLocales
|
|
@@ -156,3 +156,133 @@ export const AddProductsToCartForm = EnableCrossselsPlugin
|
|
|
156
156
|
}
|
|
157
157
|
`)
|
|
158
158
|
})
|
|
159
|
+
|
|
160
|
+
it('parses', () => {
|
|
161
|
+
const src = `
|
|
162
|
+
import {
|
|
163
|
+
PaymentMethodContextProviderProps,
|
|
164
|
+
PaymentModule,
|
|
165
|
+
} from '@graphcommerce/magento-cart-payment-method'
|
|
166
|
+
import type { PluginProps } from '@graphcommerce/next-config'
|
|
167
|
+
import { AdyenPaymentActionCard } from '../components/AdyenPaymentActionCard/AdyenPaymentActionCard'
|
|
168
|
+
import { AdyenPaymentHandler } from '../components/AdyenPaymentHandler/AdyenPaymentHandler'
|
|
169
|
+
import { HppOptions } from '../components/AdyenPaymentOptionsAndPlaceOrder/AdyenPaymentOptionsAndPlaceOrder'
|
|
170
|
+
import { adyenHppExpandMethods } from '../hooks/adyenHppExpandMethods'
|
|
171
|
+
|
|
172
|
+
export const adyen_hpp: PaymentModule = {
|
|
173
|
+
PaymentOptions: HppOptions,
|
|
174
|
+
PaymentPlaceOrder: () => null,
|
|
175
|
+
PaymentHandler: AdyenPaymentHandler,
|
|
176
|
+
PaymentActionCard: AdyenPaymentActionCard,
|
|
177
|
+
expandMethods: adyenHppExpandMethods,
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export const component = 'PaymentMethodContextProvider'
|
|
181
|
+
export const exported = '@graphcommerce/magento-cart-payment-method'
|
|
182
|
+
|
|
183
|
+
function AddAdyenMethods(props: PluginProps<PaymentMethodContextProviderProps>) {
|
|
184
|
+
const { modules, Prev, ...rest } = props
|
|
185
|
+
return <Prev {...rest} modules={{ ...modules, adyen_hpp }} />
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export const Plugin = AddAdyenMethods
|
|
189
|
+
`
|
|
190
|
+
|
|
191
|
+
const plugins = parseStructure(
|
|
192
|
+
parseSync(src),
|
|
193
|
+
fakeconfig,
|
|
194
|
+
'@graphcommerce/magento-payment-adyen/plugins/AddAdyenMethods.tsx',
|
|
195
|
+
)
|
|
196
|
+
expect(plugins).toHaveLength(1)
|
|
197
|
+
expect(plugins[0]).toMatchInlineSnapshot(`
|
|
198
|
+
{
|
|
199
|
+
"enabled": true,
|
|
200
|
+
"sourceExport": "Plugin",
|
|
201
|
+
"sourceModule": "@graphcommerce/magento-payment-adyen/plugins/AddAdyenMethods.tsx",
|
|
202
|
+
"targetExport": "PaymentMethodContextProvider",
|
|
203
|
+
"targetModule": "@graphcommerce/magento-cart-payment-method",
|
|
204
|
+
"type": "component",
|
|
205
|
+
}
|
|
206
|
+
`)
|
|
207
|
+
expect(plugins[1]).toMatchInlineSnapshot(`undefined`)
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
it('correctly allows false value in the ifConfig', () => {
|
|
211
|
+
const src = `
|
|
212
|
+
import { PluginConfig, PluginProps } from '@graphcommerce/next-config'
|
|
213
|
+
import { xMagentoCacheIdHeader } from '../link/xMagentoCacheIdHeader'
|
|
214
|
+
import { GraphQLProviderProps } from '@graphcommerce/graphql'
|
|
215
|
+
|
|
216
|
+
export const config: PluginConfig = {
|
|
217
|
+
type: 'component',
|
|
218
|
+
module: '@graphcommerce/graphql',
|
|
219
|
+
ifConfig: ['customerXMagentoCacheIdDisable', false],
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export function GraphQLProvider(props: PluginProps<GraphQLProviderProps>) {
|
|
223
|
+
const { Prev, links = [], ...rest } = props
|
|
224
|
+
return <Prev {...rest} links={[...links, xMagentoCacheIdHeader]} />
|
|
225
|
+
}
|
|
226
|
+
`
|
|
227
|
+
const ast = parseSync(src)
|
|
228
|
+
|
|
229
|
+
expect(
|
|
230
|
+
parseStructure(ast, {} as GraphCommerceConfig, './plugins/MyReplace')[0].enabled,
|
|
231
|
+
).toBeTruthy()
|
|
232
|
+
|
|
233
|
+
expect(
|
|
234
|
+
parseStructure(
|
|
235
|
+
ast,
|
|
236
|
+
{ customerXMagentoCacheIdDisable: true } as GraphCommerceConfig,
|
|
237
|
+
'./plugins/MyReplace',
|
|
238
|
+
)[0].enabled,
|
|
239
|
+
).toBeFalsy()
|
|
240
|
+
|
|
241
|
+
expect(
|
|
242
|
+
parseStructure(
|
|
243
|
+
ast,
|
|
244
|
+
{ customerXMagentoCacheIdDisable: false } as GraphCommerceConfig,
|
|
245
|
+
'./plugins/MyReplace',
|
|
246
|
+
)[0].enabled,
|
|
247
|
+
).toBeTruthy()
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
it('correctly allows true value in the ifConfig', () => {
|
|
251
|
+
const src = `
|
|
252
|
+
import { PluginConfig, PluginProps } from '@graphcommerce/next-config'
|
|
253
|
+
import { xMagentoCacheIdHeader } from '../link/xMagentoCacheIdHeader'
|
|
254
|
+
import { GraphQLProviderProps } from '@graphcommerce/graphql'
|
|
255
|
+
|
|
256
|
+
export const config: PluginConfig = {
|
|
257
|
+
type: 'component',
|
|
258
|
+
module: '@graphcommerce/graphql',
|
|
259
|
+
ifConfig: ['customerXMagentoCacheIdDisable', true],
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export function GraphQLProvider(props: PluginProps<GraphQLProviderProps>) {
|
|
263
|
+
const { Prev, links = [], ...rest } = props
|
|
264
|
+
return <Prev {...rest} links={[...links, xMagentoCacheIdHeader]} />
|
|
265
|
+
}
|
|
266
|
+
`
|
|
267
|
+
const ast = parseSync(src)
|
|
268
|
+
|
|
269
|
+
expect(
|
|
270
|
+
parseStructure(ast, {} as GraphCommerceConfig, './plugins/MyReplace')[0].enabled,
|
|
271
|
+
).toBeFalsy()
|
|
272
|
+
|
|
273
|
+
expect(
|
|
274
|
+
parseStructure(
|
|
275
|
+
ast,
|
|
276
|
+
{ customerXMagentoCacheIdDisable: true } as GraphCommerceConfig,
|
|
277
|
+
'./plugins/MyReplace',
|
|
278
|
+
)[0].enabled,
|
|
279
|
+
).toBeTruthy()
|
|
280
|
+
|
|
281
|
+
expect(
|
|
282
|
+
parseStructure(
|
|
283
|
+
ast,
|
|
284
|
+
{ customerXMagentoCacheIdDisable: false } as GraphCommerceConfig,
|
|
285
|
+
'./plugins/MyReplace',
|
|
286
|
+
)[0].enabled,
|
|
287
|
+
).toBeFalsy()
|
|
288
|
+
})
|
|
@@ -9,62 +9,68 @@ it('resolves dependences', () => {
|
|
|
9
9
|
Map {
|
|
10
10
|
"." => "examples/magento-graphcms",
|
|
11
11
|
"@graphcommerce/cli" => "packages/cli",
|
|
12
|
+
"@graphcommerce/hygraph-cli" => "packages/hygraph-cli",
|
|
12
13
|
"@graphcommerce/demo-magento-graphcommerce" => "packages/demo-magento-graphcommerce",
|
|
13
|
-
"@graphcommerce/
|
|
14
|
-
"@graphcommerce/framer-next-pages" => "packages/framer-next-pages",
|
|
15
|
-
"@graphcommerce/framer-scroller" => "packages/framer-scroller",
|
|
16
|
-
"@graphcommerce/framer-utils" => "packages/framer-utils",
|
|
14
|
+
"@graphcommerce/magento-recently-viewed-products" => "packages/magento-recently-viewed-products",
|
|
17
15
|
"@graphcommerce/googleanalytics" => "packages/googleanalytics",
|
|
18
16
|
"@graphcommerce/googlerecaptcha" => "packages/googlerecaptcha",
|
|
19
17
|
"@graphcommerce/googletagmanager" => "packages/googletagmanager",
|
|
20
|
-
"@graphcommerce/google-datalayer" => "packages/google-datalayer",
|
|
21
|
-
"@graphcommerce/graphcms-ui" => "packages/hygraph-ui",
|
|
22
|
-
"@graphcommerce/graphql" => "packages/graphql",
|
|
23
|
-
"@graphcommerce/graphql-codegen-near-operation-file" => "packagesDev/graphql-codegen-near-operation-file",
|
|
24
|
-
"@graphcommerce/graphql-codegen-relay-optimizer-plugin" => "packagesDev/graphql-codegen-relay-optimizer-plugin",
|
|
25
|
-
"@graphcommerce/graphql-mesh" => "packages/graphql-mesh",
|
|
26
|
-
"@graphcommerce/hygraph-cli" => "packages/hygraph-cli",
|
|
27
18
|
"@graphcommerce/hygraph-dynamic-rows" => "packages/hygraph-dynamic-rows",
|
|
28
|
-
"@graphcommerce/
|
|
29
|
-
"@graphcommerce/lingui-next" => "packages/lingui-next",
|
|
30
|
-
"@graphcommerce/magento-cart" => "packages/magento-cart",
|
|
19
|
+
"@graphcommerce/graphcms-ui" => "packages/hygraph-ui",
|
|
31
20
|
"@graphcommerce/magento-cart-billing-address" => "packages/magento-cart-billing-address",
|
|
32
21
|
"@graphcommerce/magento-cart-checkout" => "packages/magento-cart-checkout",
|
|
33
22
|
"@graphcommerce/magento-cart-coupon" => "packages/magento-cart-coupon",
|
|
34
23
|
"@graphcommerce/magento-cart-email" => "packages/magento-cart-email",
|
|
35
|
-
"@graphcommerce/magento-cart-items" => "packages/magento-cart-items",
|
|
36
|
-
"@graphcommerce/magento-cart-payment-method" => "packages/magento-cart-payment-method",
|
|
37
|
-
"@graphcommerce/magento-cart-shipping-address" => "packages/magento-cart-shipping-address",
|
|
38
|
-
"@graphcommerce/magento-cart-shipping-method" => "packages/magento-cart-shipping-method",
|
|
39
|
-
"@graphcommerce/magento-category" => "packages/magento-category",
|
|
40
24
|
"@graphcommerce/magento-cms" => "packages/magento-cms",
|
|
41
25
|
"@graphcommerce/magento-compare" => "packages/magento-compare",
|
|
42
|
-
"@graphcommerce/magento-
|
|
43
|
-
"@graphcommerce/magento-graphql" => "packages/magento-graphql",
|
|
26
|
+
"@graphcommerce/magento-graphql-rest" => "packages/magento-graphql-rest",
|
|
44
27
|
"@graphcommerce/magento-newsletter" => "packages/magento-newsletter",
|
|
45
28
|
"@graphcommerce/magento-payment-included" => "packages/magento-payment-included",
|
|
46
|
-
"@graphcommerce/magento-product" => "packages/magento-product",
|
|
47
29
|
"@graphcommerce/magento-product-bundle" => "packages/magento-product-bundle",
|
|
48
|
-
"@graphcommerce/magento-product-configurable" => "packages/magento-product-configurable",
|
|
49
30
|
"@graphcommerce/magento-product-downloadable" => "packages/magento-product-downloadable",
|
|
50
31
|
"@graphcommerce/magento-product-grouped" => "packages/magento-product-grouped",
|
|
51
|
-
"@graphcommerce/magento-product-simple" => "packages/magento-product-simple",
|
|
52
32
|
"@graphcommerce/magento-product-virtual" => "packages/magento-product-virtual",
|
|
53
|
-
"@graphcommerce/magento-recently-viewed-products" => "packages/magento-recently-viewed-products",
|
|
54
33
|
"@graphcommerce/magento-review" => "packages/magento-review",
|
|
55
|
-
"@graphcommerce/magento-search" => "packages/magento-search",
|
|
56
|
-
"@graphcommerce/magento-store" => "packages/magento-store",
|
|
57
34
|
"@graphcommerce/magento-wishlist" => "packages/magento-wishlist",
|
|
58
|
-
"@graphcommerce/next-config" => "packagesDev/next-config",
|
|
59
|
-
"@graphcommerce/next-ui" => "packages/next-ui",
|
|
60
|
-
"@graphcommerce/react-hook-form" => "packages/react-hook-form",
|
|
61
|
-
"@graphcommerce/eslint-config-pwa" => "packagesDev/eslint-config",
|
|
62
|
-
"@graphcommerce/typescript-config-pwa" => "packagesDev/typescript-config",
|
|
63
|
-
"@graphcommerce/prettier-config-pwa" => "packagesDev/prettier-config",
|
|
64
35
|
"@graphcommerce/magento-cart-pickup" => "packages/magento-cart-pickup",
|
|
65
36
|
"@graphcommerce/magento-payment-braintree" => "packages/magento-payment-braintree",
|
|
66
37
|
"@graphcommerce/mollie-magento-payment" => "packages/mollie-magento-payment",
|
|
38
|
+
"@graphcommerce/magento-product-configurable" => "packages/magento-product-configurable",
|
|
39
|
+
"@graphcommerce/magento-product-simple" => "packages/magento-product-simple",
|
|
40
|
+
"@graphcommerce/magento-category" => "packages/magento-category",
|
|
41
|
+
"@graphcommerce/magento-cart-items" => "packages/magento-cart-items",
|
|
42
|
+
"@graphcommerce/lingui-next" => "packages/lingui-next",
|
|
67
43
|
"@graphcommerce/magento-payment-paypal" => "packages/magento-payment-paypal",
|
|
44
|
+
"@graphcommerce/algolia-categories" => "packages/algolia-categories",
|
|
45
|
+
"@graphcommerce/algolia-personalization" => "packages/algolia-personalization",
|
|
46
|
+
"@graphcommerce/algolia-insights" => "packages/algolia-insights",
|
|
47
|
+
"@graphcommerce/algolia-recommend" => "packages/algolia-recommend",
|
|
48
|
+
"@graphcommerce/algolia-products" => "packages/algolia-products",
|
|
49
|
+
"@graphcommerce/next-config" => "packagesDev/next-config",
|
|
50
|
+
"@graphcommerce/magento-search" => "packages/magento-search",
|
|
51
|
+
"@graphcommerce/google-datalayer" => "packages/google-datalayer",
|
|
52
|
+
"@graphcommerce/magento-product" => "packages/magento-product",
|
|
53
|
+
"@graphcommerce/magento-cart-shipping-method" => "packages/magento-cart-shipping-method",
|
|
54
|
+
"@graphcommerce/magento-cart-payment-method" => "packages/magento-cart-payment-method",
|
|
55
|
+
"@graphcommerce/magento-cart-shipping-address" => "packages/magento-cart-shipping-address",
|
|
56
|
+
"@graphcommerce/magento-cart" => "packages/magento-cart",
|
|
57
|
+
"@graphcommerce/magento-customer" => "packages/magento-customer",
|
|
58
|
+
"@graphcommerce/magento-store" => "packages/magento-store",
|
|
59
|
+
"@graphcommerce/magento-graphql" => "packages/magento-graphql",
|
|
60
|
+
"@graphcommerce/graphql-mesh" => "packages/graphql-mesh",
|
|
61
|
+
"@graphcommerce/ecommerce-ui" => "packages/ecommerce-ui",
|
|
62
|
+
"@graphcommerce/react-hook-form" => "packages/react-hook-form",
|
|
63
|
+
"@graphcommerce/next-ui" => "packages/next-ui",
|
|
64
|
+
"@graphcommerce/framer-scroller" => "packages/framer-scroller",
|
|
65
|
+
"@graphcommerce/image" => "packages/image",
|
|
66
|
+
"@graphcommerce/framer-next-pages" => "packages/framer-next-pages",
|
|
67
|
+
"@graphcommerce/framer-utils" => "packages/framer-utils",
|
|
68
|
+
"@graphcommerce/graphql" => "packages/graphql",
|
|
69
|
+
"@graphcommerce/graphql-codegen-relay-optimizer-plugin" => "packagesDev/graphql-codegen-relay-optimizer-plugin",
|
|
70
|
+
"@graphcommerce/graphql-codegen-near-operation-file" => "packagesDev/graphql-codegen-near-operation-file",
|
|
71
|
+
"@graphcommerce/prettier-config-pwa" => "packagesDev/prettier-config",
|
|
72
|
+
"@graphcommerce/eslint-config-pwa" => "packagesDev/eslint-config",
|
|
73
|
+
"@graphcommerce/typescript-config-pwa" => "packagesDev/typescript-config",
|
|
68
74
|
}
|
|
69
75
|
`)
|
|
70
76
|
})
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.exportConfig =
|
|
6
|
+
exports.exportConfig = exportConfig;
|
|
7
7
|
const loadConfig_1 = require("../loadConfig");
|
|
8
8
|
const exportConfigToEnv_1 = require("../utils/exportConfigToEnv");
|
|
9
9
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
@@ -14,4 +14,3 @@ async function exportConfig() {
|
|
|
14
14
|
// eslint-disable-next-line no-console
|
|
15
15
|
console.log((0, exportConfigToEnv_1.exportConfigToEnv)(conf));
|
|
16
16
|
}
|
|
17
|
-
exports.exportConfig = exportConfig;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateConfig =
|
|
6
|
+
exports.generateConfig = generateConfig;
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
9
9
|
const cli_1 = require("@graphql-codegen/cli");
|
|
@@ -55,4 +55,3 @@ async function generateConfig() {
|
|
|
55
55
|
});
|
|
56
56
|
(0, fs_1.writeFileSync)(targetJs, result.code);
|
|
57
57
|
}
|
|
58
|
-
exports.generateConfig = generateConfig;
|