Skip to content

Commit 11e6224

Browse files
Merge pull request #32 from hyva-themes/port-1.1.2
1.1.2 release related changes
2 parents 57c1984 + fdab2c5 commit 11e6224

12 files changed

+119
-40
lines changed

reactapp/.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
parser: '@babel/eslint-parser',
3-
extends: ['airbnb', 'plugin:prettier/recommended'],
3+
extends: ['airbnb', 'airbnb/hooks', 'plugin:prettier/recommended'],
44
env: {
55
es6: true,
66
node: true,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const configurePaymentMethods = require('./integrations/configurePaymentMethods');
2+
const configureShippingMethods = require('./integrations/configureShippingMethods');
3+
4+
module.exports = (async () => {
5+
try {
6+
await configurePaymentMethods();
7+
await configureShippingMethods();
8+
} catch (error) {
9+
console.error(error);
10+
}
11+
})();

reactapp/scripts/configurePaymentMethods.js reactapp/scripts/integrations/configurePaymentMethods.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const paymentDirectoryPath = './src/paymentMethods/';
1313
* It will also populate `src/paymentMethods/customRenderers.js` which can be
1414
* used to port custom payment renderers into the react app.
1515
*/
16-
module.exports = (async () => {
16+
const configurePaymentMethods = async () => {
1717
const paymentRepos = util.collectConfiguredReposFromEnv('paymentMethodsRepo');
1818
const paymentMethodList = Object.keys(paymentRepos);
1919

@@ -50,4 +50,6 @@ module.exports = (async () => {
5050
}
5151

5252
console.log('Payment methods successfully added');
53-
})();
53+
};
54+
55+
module.exports = configurePaymentMethods;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
const fs = require('fs');
2+
const util = require('./utility');
3+
4+
const shippingDirectoryPath = './src/shippingMethods/';
5+
6+
/**
7+
* Setting up custom shipping methods into the react app section
8+
*
9+
* This will clone the shipping methods repository specified under
10+
* `config.shippingMethodsRepo` section in package.json file into the
11+
* `src/shippingMethods`
12+
*
13+
* It will also populate `src/shippingMethods/customRenderers.js` which can be
14+
* used to port custom shipping renderers into the react app.
15+
*/
16+
const configureShippingMethods = async () => {
17+
const shippingRepos = util.collectConfiguredReposFromEnv(
18+
'shippingMethodsRepo'
19+
);
20+
const shippingMethodList = Object.keys(shippingRepos);
21+
22+
await util.cloneAndConfigureRepos(
23+
shippingRepos,
24+
shippingDirectoryPath,
25+
'shipping method'
26+
);
27+
28+
if (shippingMethodList.length) {
29+
let content = `/**
30+
* 📢 📢 📢 This file is autogenerated and may be overwritten. Handle with care. 🙅🏽 🙅🏽 🙅🏽
31+
*
32+
* When you have custom shipping repo integration, then the content of this file
33+
* will be overwritten during performing "npm install". So, in most of the cases,
34+
* you don't need to alter the content of this file.
35+
*
36+
* But, if you have your own custom shipping methods locally, then you need to
37+
* include them here as well. That is the only time you need to touch this file.
38+
*/\n\n`;
39+
content += shippingMethodList
40+
.map(
41+
(method) => `import ${method}Renderers from './${method}/renderers';\n`
42+
)
43+
.join('');
44+
content += '\n';
45+
content += `export default {\n`;
46+
content += shippingMethodList
47+
.map((method) => ` ...${method}Renderers,\n`)
48+
.join('');
49+
content += '};\n';
50+
51+
fs.writeFileSync(`${shippingDirectoryPath}customRenderers.js`, content);
52+
}
53+
54+
console.log('Shipping methods successfully added');
55+
};
56+
57+
module.exports = configureShippingMethods;

reactapp/scripts/utility/index.js reactapp/scripts/integrations/utility/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ module.exports = {
1616

1717
Object.keys(env).forEach((envProp) => {
1818
if (envProp.startsWith(configPrefix)) {
19-
const paymentCode = envProp.replace(configPrefix, '');
20-
if (paymentCode) {
21-
repos[paymentCode] = env[envProp];
19+
const integrationCode = envProp.replace(configPrefix, '');
20+
if (integrationCode) {
21+
repos[integrationCode] = env[envProp];
2222
}
2323
}
2424
});
@@ -27,10 +27,10 @@ module.exports = {
2727
},
2828

2929
async cloneAndConfigureRepos(repoList, installationPath, repoType) {
30-
const paymentMethodList = Object.keys(repoList);
30+
const integrationMethodList = Object.keys(repoList);
3131

3232
await Promise.all(
33-
paymentMethodList.map(async (repo) => {
33+
integrationMethodList.map(async (repo) => {
3434
if (!fs.existsSync(`${installationPath}${repo}`)) {
3535
await this.installRepo(
3636
installationPath,

reactapp/scripts/react-app-rewire/postcss-applier.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,30 @@
88
* version of postcss. Hence, we go for custom script to give the ability to configure
99
* postcss.config.js file with cra-5
1010
*/
11-
const customPostCssSettings = require('../../postcss.config');
11+
const customPostCssSettings = require('../../postcss.config');
1212

13-
// return a filtered array that includes postcss-loader
14-
const filterPostCSSLoader = (array) =>
15-
array.filter((object) => JSON.stringify(object).includes('postcss-loader'));
13+
// return a filtered array that includes postcss-loader
14+
const filterPostCSSLoader = (array) =>
15+
array.filter((object) => JSON.stringify(object).includes('postcss-loader'));
1616

17-
module.exports = (config) => {
18-
// find any first matching rule that contains postcss-loader
19-
filterPostCSSLoader(config.module.rules).forEach((rule) => {
20-
filterPostCSSLoader(rule.oneOf).forEach((oneOf) => {
21-
filterPostCSSLoader(oneOf.use || oneOf.loader).forEach((use) => {
22-
// use the latest version of postcss-loader
23-
use.loader = require.resolve('postcss-loader');
24-
use.options = {
25-
...use.options,
26-
postcssOptions: {
27-
...use.options.postcssOptions,
28-
...customPostCssSettings,
29-
},
30-
};
31-
});
32-
});
33-
});
17+
module.exports = (config) => {
18+
// find any first matching rule that contains postcss-loader
19+
filterPostCSSLoader(config.module.rules).forEach((rule) => {
20+
filterPostCSSLoader(rule.oneOf).forEach((oneOf) => {
21+
filterPostCSSLoader(oneOf.use || oneOf.loader).forEach((use) => {
22+
// use the latest version of postcss-loader
23+
use.loader = require.resolve('postcss-loader');
24+
use.options = {
25+
...use.options,
26+
postcssOptions: {
27+
...use.options.postcssOptions,
28+
...customPostCssSettings,
29+
},
30+
};
31+
});
32+
});
33+
});
3434

35-
// return the mutated configuration
36-
return config;
37-
};
35+
// return the mutated configuration
36+
return config;
37+
};

reactapp/src/index.jsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { createRoot } from 'react-dom/client';
44

55
import RootElement from '@hyva/react-checkout/utils/rootElement';
66
import CheckoutForm from '@hyva/react-checkout/components/CheckoutForm';
7-
import StepProvider from '@hyva/react-checkout/context/Form/Step/StepProvider';
87
import AppDataProvider from '@hyva/react-checkout/context/App/AppDataProvider';
98
import CartDataProvider from '@hyva/react-checkout/context/Cart/CartDataProvider';
109
import CheckoutFormProvider from '@hyva/react-checkout/context/Form/CheckoutFormProvider';
@@ -16,9 +15,7 @@ function Checkout() {
1615
<AppDataProvider>
1716
<CartDataProvider>
1817
<CheckoutFormProvider>
19-
<StepProvider>
20-
<CheckoutForm />
21-
</StepProvider>
18+
<CheckoutForm />
2219
</CheckoutFormProvider>
2320
</CartDataProvider>
2421
</AppDataProvider>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* 📢 📢 📢 This file is autogenerated and may be overwritten. Handle with care. 🙅🏽 🙅🏽 🙅🏽
3+
*
4+
* When you have custom shipping repo integration, then the content of this file
5+
* will be overwritten during performing "npm install". So, in most of the cases,
6+
* you don't need to alter the content of this file.
7+
*
8+
* But, if you have your own custom shipping methods locally, then you need to
9+
* include them here as well. That is the only time you need to touch this file.
10+
*/
11+
12+
export default {};

view/frontend/web/css/styles.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

view/frontend/web/css/styles.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

view/frontend/web/js/react-checkout.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

view/frontend/web/js/react-checkout.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)