@appdirect/sfb-toolkit 4.0.8 → 4.0.9

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.
Files changed (45) hide show
  1. package/bin/index.js +28 -12
  2. package/config/index.js +1 -0
  3. package/coverage/clover.xml +32 -32
  4. package/coverage/coverage-final.json +4 -4
  5. package/coverage/lcov-report/constants/customUserAttributesMock.js.html +1 -1
  6. package/coverage/lcov-report/constants/index.html +1 -1
  7. package/coverage/lcov-report/constants/pageUrls.js.html +1 -1
  8. package/coverage/lcov-report/constants/userMock.js.html +1 -1
  9. package/coverage/lcov-report/controllers/controllers-utils/assetsUtils.js.html +1 -1
  10. package/coverage/lcov-report/controllers/controllers-utils/index.html +1 -1
  11. package/coverage/lcov-report/controllers/data-filters/bootstrap-data-filter.js.html +1 -1
  12. package/coverage/lcov-report/controllers/data-filters/call-to-actions-filter.js.html +1 -1
  13. package/coverage/lcov-report/controllers/data-filters/index.html +1 -1
  14. package/coverage/lcov-report/controllers/index.html +1 -1
  15. package/coverage/lcov-report/controllers/index.js.html +1 -1
  16. package/coverage/lcov-report/front-end-utils/src/components/base/ResultItem.js.html +7 -7
  17. package/coverage/lcov-report/front-end-utils/src/components/base/SearchBar.js.html +3 -3
  18. package/coverage/lcov-report/front-end-utils/src/components/base/index.html +1 -1
  19. package/coverage/lcov-report/front-end-utils/src/components/base/item.js.html +11 -11
  20. package/coverage/lcov-report/front-end-utils/src/components/container.js.html +1 -1
  21. package/coverage/lcov-report/front-end-utils/src/components/data-view.js.html +1 -1
  22. package/coverage/lcov-report/front-end-utils/src/components/header-view.js.html +1 -1
  23. package/coverage/lcov-report/front-end-utils/src/components/index.html +1 -1
  24. package/coverage/lcov-report/front-end-utils/src/components/search.js.html +13 -13
  25. package/coverage/lcov-report/front-end-utils/src/constants/index.html +1 -1
  26. package/coverage/lcov-report/front-end-utils/src/constants/pageUrl.js.html +1 -1
  27. package/coverage/lcov-report/front-end-utils/src/constants/roleType.js.html +1 -1
  28. package/coverage/lcov-report/front-end-utils/src/constants/searchType.js.html +1 -1
  29. package/coverage/lcov-report/front-end-utils/src/utils/debounce.js.html +1 -1
  30. package/coverage/lcov-report/front-end-utils/src/utils/index.html +1 -1
  31. package/coverage/lcov-report/index.html +1 -1
  32. package/coverage/lcov-report/middlewares/config.js.html +1 -1
  33. package/coverage/lcov-report/middlewares/index.html +1 -1
  34. package/coverage/lcov.info +81 -81
  35. package/index.js +11 -10
  36. package/npm-shrinkwrap.json +559 -113
  37. package/package.json +4 -3
  38. package/readme.md +9 -1
  39. package/src/api/cors.js +1 -1
  40. package/src/tools/prompt-questions.js +43 -1
  41. package/src/tools/proxy-fetch.js +16 -0
  42. package/src/tools/toolkit-common-vars.js +1 -1
  43. package/src/tools/toolkit-components.js +12 -4
  44. package/src/tools/toolkit-install.js +15 -7
  45. package/src/tools/toolkit-start.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appdirect/sfb-toolkit",
3
- "version": "4.0.8",
3
+ "version": "4.0.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -56,8 +56,8 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@appdirect/public-custom-app-ui": "^0.0.17",
59
- "@appdirect/sfb-theme-classic": "TO_CHANGE",
60
- "@appdirect/sfb-theme-plaza": "TO_CHANGE",
59
+ "@appdirect/sfb-theme-classic": "0.0.27",
60
+ "@appdirect/sfb-theme-plaza": "0.0.76",
61
61
  "@appdirect/storefront-utils": "latest",
62
62
  "@babel/core": "^7.19.1",
63
63
  "@babel/plugin-proposal-class-properties": "^7.18.6",
@@ -105,6 +105,7 @@
105
105
  "object-assign-deep": "^0.4.0",
106
106
  "package-json": "^7.0.0",
107
107
  "prop-types": "^15.8.1",
108
+ "proxy-agent": "^6.3.1",
108
109
  "querystrings": "^0.4.0",
109
110
  "react": "16.14.0",
110
111
  "react-dom": "16.14.0",
package/readme.md CHANGED
@@ -10,10 +10,18 @@ It can be easily mixed with eg. HTML, CSS, JavaScript, jQuery, SASS.
10
10
 
11
11
  ### Release Notes:
12
12
 
13
+ **4.0.9**
14
+ - Add Node 18 support
15
+ - Add prompts when enabling custom components and updating sfb-theme-component version
16
+ - Update `@appdirect/sfb-theme-plaza` to version 0.0.76 ([sfb-theme-mp2@0.0.75](https://www.npmjs.com/package/@appdirect/sfb-theme-plaza/v/0.0.76))
17
+ - Add default translations for all supported languages
18
+ - Update `sfb-theme-components` library to version [0.0.340](https://www.npmjs.com/package/@appdirect/sfb-theme-components/v/0.0.340)
19
+ - Add Node 18 support
20
+
13
21
  **4.0.8**
14
22
  - Update `@appdirect/sfb-theme-plaza` to version 0.0.64 ([sfb-theme-mp2@0.0.75](https://www.npmjs.com/package/@appdirect/sfb-theme-plaza/v/0.0.75))
15
23
  - Update `@appdirect/sfb-theme-classic` to version 0.0.27 ([sfb-theme-classic@0.0.27](https://www.npmjs.com/package/@appdirect/sfb-theme-classic/v/0.0.27))
16
- - Update `sfb-theme-components` library to version [0.0.338](https://www.npmjs.com/package/@appdirect/sfb-theme-components/v/0.0.3.5)
24
+ - Update `sfb-theme-components` library to version [0.0.338](https://www.npmjs.com/package/@appdirect/sfb-theme-components/v/0.0.338)
17
25
 
18
26
  **4.0.4**
19
27
  - Update `@appdirect/sfb-theme-plaza` to version 0.0.64 ([sfb-theme-mp2@0.0.64](https://www.npmjs.com/package/@appdirect/sfb-theme-plaza/v/0.0.64))
package/src/api/cors.js CHANGED
@@ -1,4 +1,4 @@
1
- const fetch = require("node-fetch");
1
+ const fetch = require("../tools/proxy-fetch");
2
2
 
3
3
  const cors = {
4
4
  async callApi(req, res, requestType = "get") {
@@ -1,7 +1,7 @@
1
1
  const fs = require("fs");
2
- const fetch = require("node-fetch");
3
2
  const inquirer = require("inquirer");
4
3
  const chalk = require("chalk");
4
+ const fetch = require("./proxy-fetch");
5
5
  const {
6
6
  TOOLKIT_GLOBAL_CONFIG,
7
7
  THEME_TEMPLATES,
@@ -79,6 +79,48 @@ const licenseText = ` In order to use this software, please type 'agree' to acce
79
79
 
80
80
  // list of default questions that could be prompt to user
81
81
  const QUESTIONS = [
82
+ {
83
+ type: "input",
84
+ name: "InstallCustomComponents",
85
+ message: chalk.yellowBright(`${chalk.bgRed(
86
+ "WARNING"
87
+ )}: You are about to install Custom Components in your theme.\n
88
+ \u2022 Custom Components lets you create new UI elements using React and our components library (${chalk.cyan(
89
+ "@appdirect/sfb-theme-components"
90
+ )}).
91
+ \u2022 Once installed, your components library version will be locked and won't receive further updates automatically.
92
+ \u2022 ${chalk.bgRed("This command is irreversible.")}
93
+ \u2022 Please refer to our documentation for comprehensive details.
94
+ ${chalk.cyan(
95
+ "https://developer.appdirect.com/storefront/how-tos/components/storefront-custom-components"
96
+ )}
97
+ \nDo you wish to proceed? (y/n)`),
98
+ },
99
+ {
100
+ type: "input",
101
+ name: "InstallSfbThemeComponents",
102
+ message: chalk.yellowBright(
103
+ `${chalk.bgRed(
104
+ "WARNING"
105
+ )}: You are about to change the installed version of ${chalk.cyan(
106
+ "@appdirect/sfb-theme-components"
107
+ )}.\n
108
+ \u2022 May introduce breaking changes, especially if you leverage or override the ${chalk.cyan(
109
+ "@appdirect/sfb-theme-components"
110
+ )} library.` +
111
+ ` Please note your current ${chalk.cyan(
112
+ "@appdirect/sfb-theme-components"
113
+ )} version before going forward in the event you need to revert.
114
+ \u2022 ${chalk.bgRed.yellowBright(
115
+ "Ensure you thoroughly test your theme before deploying this new version."
116
+ )}
117
+ \u2022 Please see our documentation for more information.
118
+ ${chalk.cyan(
119
+ "https://developer.appdirect.com/storefront/how-tos/components/storefront-custom-components#update-custom-components-ui-library-sfb-theme-components."
120
+ )}
121
+ \nDo you wish to proceed? (y/n)`
122
+ ),
123
+ },
82
124
  {
83
125
  type: "input",
84
126
  name: "ProjectName",
@@ -0,0 +1,16 @@
1
+ const fetch = require("node-fetch");
2
+ const ProxyAgent = require("proxy-agent");
3
+
4
+ async function fetchProxied(url, fetchOptions = {}) {
5
+ // Check if the URL should use a proxy
6
+ const useProxy = process.env.HTTPS_PROXY;
7
+
8
+ // If we should use a proxy, set the agent
9
+ if (useProxy) {
10
+ fetchOptions.agent = new ProxyAgent(process.env.HTTPS_PROXY);
11
+ }
12
+
13
+ return fetch(url, fetchOptions);
14
+ }
15
+
16
+ module.exports = fetchProxied;
@@ -15,7 +15,7 @@ const THEME_TEMPLATES_CONFIG_PATH = `${TOOLKIT_PATH}/themes-config.json`;
15
15
  const THEME_TEMPLATES = JSON.parse(fs.readFileSync(THEME_TEMPLATES_CONFIG_PATH));
16
16
  const PAGE_OBJECTS_SUFFIX = "/api/internal/storefront/v1";
17
17
  const THEME_COMPONENT_MODULE = "@appdirect/sfb-theme-components";
18
- const THEME_COMPONENT_VERSION = "0.0.338";
18
+ const THEME_COMPONENT_VERSION = "0.0.340";
19
19
  const SASS_MODULE = "sass";
20
20
  const SASS_VERSION = "1.57.1";
21
21
  const SASS_LOADER_MODULE = "sass-loader";
@@ -1,5 +1,6 @@
1
- const fs = require("fs-extra")
2
- const chalk = require("chalk")
1
+ const fs = require("fs-extra");
2
+ const chalk = require("chalk");
3
+ const prompt = require("./prompt-questions");
3
4
  const { shouldBeProjectFolder, installSfbThemeComponents,
4
5
  createPackageJson, updateCustomComponentsMetadata, installSass } = require("./toolkit-common-fun");
5
6
  const { ACTIVE_THEME_PATH, TOOLKIT_PATH } = require("./toolkit-common-vars");
@@ -17,11 +18,18 @@ const addCustomCompToBase = (baseFilePath, data) => {
17
18
 
18
19
  const settingsSchemaData = `{ "useComponents": true }`;
19
20
 
20
- (() => {
21
+ (async () => {
21
22
  const baseFilePath = `${ACTIVE_THEME_PATH}/content/layout/base.html`;
22
23
  const customComponentsPath = `${ACTIVE_THEME_PATH}/customComponents`
23
24
  const customComponentsEnabled = fs.existsSync(customComponentsPath);
24
25
 
26
+ if(!customComponentsEnabled) {
27
+ const customComponents = await prompt.ask(["InstallCustomComponents"]);
28
+ if(customComponents.InstallCustomComponents.toLowerCase() !== "y") {
29
+ return;
30
+ }
31
+ }
32
+
25
33
  createPackageJson();
26
34
 
27
35
  installSfbThemeComponents();
@@ -84,4 +92,4 @@ const settingsSchemaData = `{ "useComponents": true }`;
84
92
  console.log(chalk.cyan('sfb-toolkit storybook\n'))
85
93
  }
86
94
  })
87
- })();
95
+ })();
@@ -1,5 +1,6 @@
1
1
  const fs = require("fs-extra");
2
2
  const chalk = require("chalk");
3
+ const prompt = require("./prompt-questions");
3
4
  const { shouldBeProjectFolder, createPackageJson, updateCustomComponentsMetadata } = require("./toolkit-common-fun");
4
5
  const { spawn } = require("child_process");
5
6
  const { COMMAND_PARAM, ACTIVE_THEME_PATH } = require("./toolkit-common-vars");
@@ -7,14 +8,20 @@ const { COMMAND_PARAM, ACTIVE_THEME_PATH } = require("./toolkit-common-vars");
7
8
  const npmModule = COMMAND_PARAM;
8
9
 
9
10
  shouldBeProjectFolder(true);
10
- if(npmModule === 'undefined'){
11
- console.error(chalk.red(` ERROR: Please provide the npm module to install.`));
12
- process.exit(1);
13
- }
14
11
 
15
- (() => {
12
+ const checkCommandParam = async () => {
13
+ if(npmModule === 'undefined'){
14
+ console.error(chalk.red(` ERROR: Please provide the npm module to install.`));
15
+ process.exit(1);
16
+ } else if (npmModule.includes('@appdirect/sfb-theme-components')) {
17
+ const sfbThemeComponents = await prompt.ask(["InstallSfbThemeComponents"]);
18
+ if(sfbThemeComponents.InstallSfbThemeComponents.toLowerCase() !== "y") {
19
+ process.exit(1);
20
+ }
21
+ }
22
+
16
23
  createPackageJson();
17
-
24
+
18
25
  spawn('npm',
19
26
  [`install --save ${npmModule} --production`], {
20
27
  cwd: ACTIVE_THEME_PATH,
@@ -38,5 +45,6 @@ if(npmModule === 'undefined'){
38
45
  };
39
46
  };
40
47
  });
48
+ }
41
49
 
42
- })();
50
+ checkCommandParam();
@@ -26,7 +26,7 @@ shouldBeProjectFolder(true);
26
26
  await versionCheck();
27
27
 
28
28
  const toolkitStartProcess = spawn('node',
29
- [`"${TOOLKIT_PATH}/${NODEMON_PATH}" "${TOOLKIT_PATH}/index.js" --watch themes/${config.theme}/ --ignore themes/${config.theme}/assets/js/`], {
29
+ [`"${TOOLKIT_PATH}/${NODEMON_PATH}" "${TOOLKIT_PATH}/index.js" -e js,mjs,json,yml --watch themes/${config.theme}/ --ignore themes/${config.theme}/assets/js/`], {
30
30
  shell: true
31
31
  }
32
32
  );