@graphcommerce/docs 4.12.0-canary.1 → 4.12.0-canary.3
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 +14 -0
- package/framework/plugins.md +64 -49
- package/package.json +1 -1
- package/upgrading.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.12.0-canary.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1738](https://github.com/graphcommerce-org/graphcommerce/pull/1738) [`163be59f2`](https://github.com/graphcommerce-org/graphcommerce/commit/163be59f2bf0f1573e91da036e56455262c6abd5) - Better clone instructions when upgrading ([@paales](https://github.com/paales))
|
|
8
|
+
|
|
9
|
+
- [#1738](https://github.com/graphcommerce-org/graphcommerce/pull/1738) [`6171ad02c`](https://github.com/graphcommerce-org/graphcommerce/commit/6171ad02c19782b1e1f0eb00ea25ea6b764250b5) - Added topological sorting to plugins and added ifEnv export to plugins to conditionally load plugins ([@paales](https://github.com/paales))
|
|
10
|
+
|
|
11
|
+
## 4.12.0-canary.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#1733](https://github.com/graphcommerce-org/graphcommerce/pull/1733) [`b2d73c726`](https://github.com/graphcommerce-org/graphcommerce/commit/b2d73c726fa123435fa6c54b4e0fd0db2df7c4ab) - Move to <Prev/> instead of <Component/> to call the plugin component ([@paales](https://github.com/paales))
|
|
16
|
+
|
|
3
17
|
## 4.12.0-canary.1
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/framework/plugins.md
CHANGED
|
@@ -74,11 +74,11 @@ export const exported = '@graphcommerce/magento-cart-payment-method'
|
|
|
74
74
|
function AddPaymentMethodEnhancer(
|
|
75
75
|
props: PluginProps<PaymentMethodContextProviderProps>,
|
|
76
76
|
) {
|
|
77
|
-
const {
|
|
78
|
-
return <
|
|
77
|
+
const { Prev, modules, ...rest } = props
|
|
78
|
+
return <Prev {...rest} modules={{ ...modules, purchaseorder }} />
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
/** The export must be named `Plugin` and must accept a
|
|
81
|
+
/** The export must be named `Plugin` and must accept a Prev component to render */
|
|
82
82
|
export const Plugin = AddIncludedMethods
|
|
83
83
|
```
|
|
84
84
|
|
|
@@ -97,37 +97,59 @@ export const Plugin = AddIncludedMethods
|
|
|
97
97
|
Example of generated interceptor with additional comments:
|
|
98
98
|
|
|
99
99
|
```tsx
|
|
100
|
-
|
|
101
|
-
import { Plugin as AddIncludedMethods } from '@graphcommerce/magento-payment-included/plugins/AddIncludedMethods'
|
|
102
|
-
import { Plugin as AddPaypalMethods } from '@graphcommerce/magento-payment-paypal/plugins/AddPaypalMethods'
|
|
103
|
-
|
|
104
|
-
// This file is placed next to the original component, so it is imported with a relative path, in the Webpack plugin we
|
|
105
|
-
// load the original file if it is loaded from the interceptor.
|
|
106
|
-
import { PaymentMethodContextProvider as PaymentMethodContextProviderBase } from './PaymentMethodContext'
|
|
107
|
-
|
|
108
|
-
// All original exports are exported, if the original file exports more than we're intercepting, it will still work.
|
|
109
|
-
export * from './PaymentMethodContext'
|
|
100
|
+
/* This file is automatically generated for @graphcommerce/magento-cart-payment-method */
|
|
110
101
|
|
|
111
|
-
|
|
102
|
+
export * from '.'
|
|
103
|
+
import { Plugin as GaPaymentMethodButton } from '@graphcommerce/googleanalytics/plugins/GaPaymentMethodButton'
|
|
104
|
+
import { Plugin as GaPaymentMethodContextProvider } from '@graphcommerce/googleanalytics/plugins/GaPaymentMethodContextProvider'
|
|
105
|
+
import { Plugin as AddIncludedMethods } from '@graphcommerce/magento-payment-included/plugins/AddIncludedMethods'
|
|
106
|
+
import { ComponentProps } from 'react'
|
|
107
|
+
import {
|
|
108
|
+
PaymentMethodButton as PaymentMethodButtonBase,
|
|
109
|
+
PaymentMethodContextProvider as PaymentMethodContextProviderBase,
|
|
110
|
+
} from '.'
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Interceptor for `<PaymentMethodButton/>` with these plugins:
|
|
114
|
+
*
|
|
115
|
+
* - `@graphcommerce/googleanalytics/plugins/GaPaymentMethodButton`
|
|
116
|
+
*/
|
|
117
|
+
type PaymentMethodButtonProps = ComponentProps<typeof PaymentMethodButtonBase>
|
|
118
|
+
|
|
119
|
+
function GaPaymentMethodButtonInterceptor(props: PaymentMethodButtonProps) {
|
|
120
|
+
return <GaPaymentMethodButton {...props} Prev={PaymentMethodButtonBase} />
|
|
121
|
+
}
|
|
122
|
+
export const PaymentMethodButton = GaPaymentMethodButtonInterceptor
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Interceptor for `<PaymentMethodContextProvider/>` with these plugins:
|
|
126
|
+
*
|
|
127
|
+
* - `@graphcommerce/magento-payment-included/plugins/AddIncludedMethods`
|
|
128
|
+
* - `@graphcommerce/googleanalytics/plugins/GaPaymentMethodContextProvider`
|
|
129
|
+
*/
|
|
130
|
+
type PaymentMethodContextProviderProps = ComponentProps<
|
|
112
131
|
typeof PaymentMethodContextProviderBase
|
|
113
132
|
>
|
|
114
133
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
props:
|
|
124
|
-
)
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
134
|
+
function AddIncludedMethodsInterceptor(
|
|
135
|
+
props: PaymentMethodContextProviderProps,
|
|
136
|
+
) {
|
|
137
|
+
return (
|
|
138
|
+
<AddIncludedMethods {...props} Prev={PaymentMethodContextProviderBase} />
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
function GaPaymentMethodContextProviderInterceptor(
|
|
142
|
+
props: PaymentMethodContextProviderProps,
|
|
143
|
+
) {
|
|
144
|
+
return (
|
|
145
|
+
<GaPaymentMethodContextProvider
|
|
146
|
+
{...props}
|
|
147
|
+
Prev={AddIncludedMethodsInterceptor}
|
|
148
|
+
/>
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
export const PaymentMethodContextProvider =
|
|
152
|
+
GaPaymentMethodContextProviderInterceptor
|
|
131
153
|
```
|
|
132
154
|
|
|
133
155
|
React profile will show that all components are nested:
|
|
@@ -147,28 +169,21 @@ work for other things such as:
|
|
|
147
169
|
- Abstraction between GraphCommerce and Backends? (Magento, BigCommerce,
|
|
148
170
|
CommerceTools, etc.)
|
|
149
171
|
|
|
150
|
-
###
|
|
172
|
+
### Conditionally include a plugin
|
|
151
173
|
|
|
152
|
-
|
|
174
|
+
Provide an ifEnv export in the plugin that will only include the plugin if the
|
|
175
|
+
environment variable is set.
|
|
153
176
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
configuration file.
|
|
177
|
+
```tsx
|
|
178
|
+
export const ifEnv = 'MY_ENV_VARIABLE'
|
|
179
|
+
```
|
|
158
180
|
|
|
159
|
-
|
|
160
|
-
intercepting last, followed by the packages in reverse alphabetical order,
|
|
161
|
-
followed by dependencies' dependencies. We don't generate a proper graph at the
|
|
162
|
-
moment to figure out the actual dependencies but is an artifact of how we
|
|
163
|
-
resolve the dependencies.
|
|
181
|
+
### When to use a plugin?
|
|
164
182
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
added if the user has configured it. This is currently not possible. Of if a
|
|
168
|
-
user wants to disable a plugin, this is currently not possible.
|
|
183
|
+
A plugin should be used when a new package is created that influences the
|
|
184
|
+
behavior of other packages.
|
|
169
185
|
|
|
170
|
-
|
|
171
|
-
the foundation to allow for a more flexible plugin system in the future.
|
|
186
|
+
### Plugin loading order
|
|
172
187
|
|
|
173
|
-
|
|
174
|
-
|
|
188
|
+
A plugin is injected later than the dependencies of the package. So if a plugin
|
|
189
|
+
is loaded to early, make sure the package has a dependency on the other package.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/docs",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/docs",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce/docs",
|
|
5
|
-
"version": "4.12.0-canary.
|
|
5
|
+
"version": "4.12.0-canary.3",
|
|
6
6
|
"sideEffects": true,
|
|
7
7
|
"devDependencies": {
|
|
8
8
|
"@graphcommerce/prettier-config-pwa": "^4.0.7"
|
package/upgrading.md
CHANGED
|
@@ -38,7 +38,7 @@ dependencies, while keeping your customizations.
|
|
|
38
38
|
2. Download a fresh copy of the repository:
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
|
-
git clone
|
|
41
|
+
git clone -b main --depth 1 https://github.com/graphcommerce-org/graphcommerce.git
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
3. Navigate to the /upgrade directory you've just created. Run the following
|