@appdirect/sfb-toolkit 4.0.0 → 4.0.2

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 (51) hide show
  1. package/bin/index.js +0 -1
  2. package/coverage/clover.xml +2 -2
  3. package/coverage/lcov-report/constants/customUserAttributesMock.js.html +1 -1
  4. package/coverage/lcov-report/constants/index.html +1 -1
  5. package/coverage/lcov-report/constants/pageUrls.js.html +1 -1
  6. package/coverage/lcov-report/constants/userMock.js.html +1 -1
  7. package/coverage/lcov-report/controllers/controllers-utils/assetsUtils.js.html +1 -1
  8. package/coverage/lcov-report/controllers/controllers-utils/index.html +1 -1
  9. package/coverage/lcov-report/controllers/data-filters/bootstrap-data-filter.js.html +1 -1
  10. package/coverage/lcov-report/controllers/data-filters/call-to-actions-filter.js.html +1 -1
  11. package/coverage/lcov-report/controllers/data-filters/index.html +1 -1
  12. package/coverage/lcov-report/controllers/index.html +1 -1
  13. package/coverage/lcov-report/controllers/index.js.html +1 -1
  14. package/coverage/lcov-report/front-end-utils/src/components/base/ResultItem.js.html +1 -1
  15. package/coverage/lcov-report/front-end-utils/src/components/base/SearchBar.js.html +1 -1
  16. package/coverage/lcov-report/front-end-utils/src/components/base/index.html +1 -1
  17. package/coverage/lcov-report/front-end-utils/src/components/base/item.js.html +1 -1
  18. package/coverage/lcov-report/front-end-utils/src/components/container.js.html +1 -1
  19. package/coverage/lcov-report/front-end-utils/src/components/data-view.js.html +1 -1
  20. package/coverage/lcov-report/front-end-utils/src/components/header-view.js.html +1 -1
  21. package/coverage/lcov-report/front-end-utils/src/components/index.html +1 -1
  22. package/coverage/lcov-report/front-end-utils/src/components/search.js.html +1 -1
  23. package/coverage/lcov-report/front-end-utils/src/constants/index.html +1 -1
  24. package/coverage/lcov-report/front-end-utils/src/constants/pageUrl.js.html +1 -1
  25. package/coverage/lcov-report/front-end-utils/src/constants/roleType.js.html +1 -1
  26. package/coverage/lcov-report/front-end-utils/src/constants/searchType.js.html +1 -1
  27. package/coverage/lcov-report/front-end-utils/src/utils/debounce.js.html +1 -1
  28. package/coverage/lcov-report/front-end-utils/src/utils/index.html +1 -1
  29. package/coverage/lcov-report/index.html +1 -1
  30. package/coverage/lcov-report/middlewares/config.js.html +1 -1
  31. package/coverage/lcov-report/middlewares/index.html +1 -1
  32. package/npm-shrinkwrap.json +3776 -6763
  33. package/package.json +4 -5
  34. package/readme.md +11 -4
  35. package/src/tools/prompt-questions.js +9 -9
  36. package/src/tools/toolkit-about.js +7 -7
  37. package/src/tools/toolkit-checkout.js +8 -8
  38. package/src/tools/toolkit-common-fun.js +35 -17
  39. package/src/tools/toolkit-common-vars.js +10 -2
  40. package/src/tools/toolkit-components.js +26 -14
  41. package/src/tools/toolkit-config-setup.js +10 -10
  42. package/src/tools/toolkit-config.js +0 -1
  43. package/src/tools/toolkit-create.js +14 -14
  44. package/src/tools/toolkit-install.js +5 -4
  45. package/src/tools/toolkit-package.js +5 -4
  46. package/src/tools/toolkit-setup-e2e.js +14 -14
  47. package/src/tools/toolkit-setup.js +13 -13
  48. package/src/tools/toolkit-status.js +2 -2
  49. package/src/tools/toolkit-storybook.js +4 -3
  50. package/src/tools/toolkit-update.js +5 -5
  51. package/src/tools/zip-theme.js +6 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appdirect/sfb-toolkit",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -55,8 +55,8 @@
55
55
  "name": "appdirect/sfb-toolkit"
56
56
  },
57
57
  "dependencies": {
58
- "@appdirect/sfb-theme-classic": "0.0.25",
59
- "@appdirect/sfb-theme-plaza": "0.0.56",
58
+ "@appdirect/sfb-theme-classic": "0.0.26",
59
+ "@appdirect/sfb-theme-plaza": "0.0.59",
60
60
  "@babel/core": "^7.19.1",
61
61
  "@babel/plugin-proposal-class-properties": "^7.18.6",
62
62
  "@babel/plugin-transform-runtime": "^7.19.1",
@@ -73,8 +73,8 @@
73
73
  "babel-loader": "^8.2.5",
74
74
  "babel-preset-minify": "^0.5.2",
75
75
  "body-parser": "^1.20.0",
76
+ "chalk": "^4.1.2",
76
77
  "cheerio": "^1.0.0-rc.12",
77
- "colors": "^1.4.0",
78
78
  "commander": "^9.4.0",
79
79
  "concurrently": "^7.4.0",
80
80
  "cookie-parser": "^1.4.6",
@@ -110,7 +110,6 @@
110
110
  "react-select": "^4.3.1",
111
111
  "react-syntax-highlighter": "^15.5.0",
112
112
  "sass": "^1.55.0",
113
- "sass-loader": "^13.0.2",
114
113
  "scheduler": "^0.19.1",
115
114
  "seamless-immutable": "^7.1.4",
116
115
  "snapstub": "^5.0.1",
package/readme.md CHANGED
@@ -10,12 +10,19 @@ It can be easily mixed with eg. HTML, CSS, JavaScript, jQuery, SASS.
10
10
 
11
11
  ### Release Notes:
12
12
 
13
- **4.0.0**
13
+ **4.0.2**
14
+ - `sfb-components` bundles are split by storefront page to improve LCP performance.
15
+ - Bug fix: Fix custom components with sfb-toolkit@4 on Windows.
16
+ - Bug fix: Fix favicon not showing in the Plaza theme.
17
+ - Update `@appdirect/sfb-theme-plaza` to version 0.0.59 ([sfb-theme-mp2@0.0.59](https://www.npmjs.com/package/@appdirect/sfb-theme-plaza/v/0.0.59))
18
+ - Update `sfb-theme-components` library to version [0.0.315](https://www.npmjs.com/package/@appdirect/sfb-theme-components/v/0.0.315)
19
+
20
+ **4.0.1**
14
21
  - Toolkit is now able to work on Node 16.
15
22
  - Remove deprecated `node-sass` to compile SASS files in favour of `sass` aka Dart Sass.
16
23
  - Update `sfb-theme-components` library to version [0.0.293](https://www.npmjs.com/package/@appdirect/sfb-theme-components/v/0.0.293)
17
- - Update `@appdirect/sfb-theme-plaza` to version 0.0.56 ([sfb-theme-mp2@0.0.56](https://www.npmjs.com/package/@appdirect/sfb-theme-plaza/v/0.0.56))
18
- - Update `@appdirect/sfb-theme-classic` to version 0.0.25 ([sfb-theme-classic@0.0.25](https://www.npmjs.com/package/@appdirect/sfb-theme-classic/v/0.0.25))
24
+ - Update `@appdirect/sfb-theme-plaza` to version 0.0.57 ([sfb-theme-mp2@0.0.57](https://www.npmjs.com/package/@appdirect/sfb-theme-plaza/v/0.0.57))
25
+ - Update `@appdirect/sfb-theme-classic` to version 0.0.26 ([sfb-theme-classic@0.0.26](https://www.npmjs.com/package/@appdirect/sfb-theme-classic/v/0.0.26))
19
26
 
20
27
  **3.0.6**
21
28
  - Update `sfb-theme-components` library to version [0.0.282](https://www.npmjs.com/package/@appdirect/sfb-theme-components/v/0.0.282)
@@ -140,7 +147,7 @@ Developers can have multiple themes in a single environment.
140
147
  - [Checkout Integration](https://help.appdirect.com/platform/Default.htm#StorefrontBuilder/sfb-checkout-intro.htm)
141
148
  - [Video Tutorials](https://help.appdirect.com/platform/Default.htm#StorefrontBuilder/sfb-toolkit-intro.htm)
142
149
  - [Nunjucks Template System Documentation](https://mozilla.github.io/nunjucks/)
143
- - [Contact Support](storefrontbuilder@appdirect.com)
150
+ - [Contact Support](mailto:storefrontbuilder@appdirect.com)
144
151
 
145
152
 
146
153
  This Repository is owned and maintained by Storefront Builder Team @ AppDirect Inc.
@@ -1,6 +1,7 @@
1
1
  const fs = require("fs")
2
2
  const inquirer = require("inquirer")
3
3
  const axios = require("axios")
4
+ const chalk = require("chalk")
4
5
  const { TOOLKIT_GLOBAL_CONFIG, THEME_TEMPLATES, WHO_ARE_YOU_PROMPT} = require("./toolkit-common-vars")
5
6
 
6
7
  // small function to check if item has been defined
@@ -11,7 +12,7 @@ const isValidFolderName = toTest => {
11
12
  const pattern = new RegExp(/^[a-z0-9_-]+$/, "i")
12
13
  const result = pattern.test(toTest)
13
14
  if (!result) {
14
- console.error(`\n${toTest} does not seem as valid folder name.`.red)
15
+ console.error(chalk.red(`\n${toTest} does not seem as valid folder name.`))
15
16
  }
16
17
  return toTest !== "undefined" && result
17
18
  }
@@ -34,7 +35,7 @@ const isValidURL = toTest => {
34
35
  )
35
36
  const result = pattern.test(toTest)
36
37
  if (!result) {
37
- console.error(`\n"${toTest}" does not seem as valid URL.`.red)
38
+ console.error(chalk.red(`\n"${toTest}" does not seem as valid URL.`))
38
39
  }
39
40
  return result
40
41
  }
@@ -50,20 +51,19 @@ const isValidMarketplaceURL = async toTest => {
50
51
  } catch (err) {
51
52
  switch (err.code) {
52
53
  case "ETIMEDOUT":
53
- console.log(
54
+ console.log(chalk.red(
54
55
  ` Unable to reach ${toTest}. Please make sure to provide valid marketplace URL and that if you are running a proxy, is it configured correctly with node https://jjasonclark.com/how-to-setup-node-behind-web-proxy/ \n`
55
- .red
56
- )
56
+ ))
57
57
  break
58
58
  default:
59
- console.log(
60
- ` ${toTest} does not seem to be a valid marketplace URL.\n`.red
61
- )
59
+ console.log(chalk.red(
60
+ ` ${toTest} does not seem to be a valid marketplace URL.\n`
61
+ ))
62
62
  break
63
63
  }
64
64
  return false
65
65
  }
66
- console.log(" Marketplace URL successfully verified.\n".green)
66
+ console.log(chalk.green(" Marketplace URL successfully verified.\n"))
67
67
  return true
68
68
  }
69
69
 
@@ -1,6 +1,6 @@
1
- const fs = require("fs")
2
- const moment = require("moment")
3
- const colors = require("colors")
1
+ const fs = require("fs");
2
+ const moment = require("moment");
3
+ const chalk = require("chalk");
4
4
 
5
5
  const { shouldBeProjectFolder } = require("./toolkit-common-fun");
6
6
  const { LOCAL_CONFIG } = require("./toolkit-config");
@@ -11,14 +11,14 @@ shouldBeProjectFolder(true);
11
11
  (() => {
12
12
  try {
13
13
  const projectData = LOCAL_CONFIG.read();
14
- console.log(`\n Available themes for ${projectData.projectName}:`)
14
+ console.log(`\n Available themes for ${projectData.projectName}:`);
15
15
  projectData.namespaces
16
16
  .map(namespace => {
17
- let parsedName = namespace.themeName === projectData.current ? `* ${namespace.themeName}`.yellow : ` ${namespace.themeName}`;
17
+ let parsedName = namespace.themeName === projectData.current ? `* ${chalk.yellow(namespace.themeName)}` : ` ${namespace.themeName}`;
18
18
  console.log(` ${parsedName}`)
19
19
  });
20
20
  console.log(`\n To switch to a different theme configuration, run \`sfb-toolkit checkout [themeName]\`\n`);
21
21
  } catch ( err ) {
22
- console.error(`\n ERROR: Unable to find configuration for current project due to: ${err}.\n`.red);
22
+ console.error(chalk.red(`\n ERROR: Unable to find configuration for current project due to: ${err}.\n`));
23
23
  }
24
- })();
24
+ })();
@@ -1,6 +1,6 @@
1
1
  const fs = require("fs")
2
- const colors = require("colors")
3
2
  const { spawn } = require("child_process")
3
+ const chalk = require("chalk")
4
4
 
5
5
  const { COMMAND_PARAM, TOOLKIT_PATH, COMPILERCSS_PATH } = require("./toolkit-common-vars");
6
6
  const { shouldBeProjectFolder } = require("./toolkit-common-fun");
@@ -12,7 +12,7 @@ const themeName = COMMAND_PARAM;
12
12
  shouldBeProjectFolder(true);
13
13
 
14
14
  if(!validateFun.isValidFolderName(themeName)){
15
- console.error(` ERROR: Please provide the theme name to checkout.`.red);
15
+ console.error(chalk.red(` ERROR: Please provide the theme name to checkout.`));
16
16
  process.exit(1);
17
17
  }
18
18
 
@@ -21,26 +21,26 @@ if(!validateFun.isValidFolderName(themeName)){
21
21
  try {
22
22
  projectData = LOCAL_CONFIG.read();
23
23
  } catch (err) {
24
- console.error(`\n ERROR: Unable to find configuration for current project due to: ${err}.\n`.red)
24
+ console.error(chalk.red(`\n ERROR: Unable to find configuration for current project due to: ${err}.\n`))
25
25
  process.exit(1);
26
26
  }
27
27
  const themeExists = projectData.namespaces.filter(namespace => namespace.themeName == themeName).length;
28
28
  if(!themeExists){
29
- console.error(` ERROR: Unable to find theme ${themeName} in current project.`.red);
29
+ console.error(chalk.red(` ERROR: Unable to find theme ${themeName} in current project.`));
30
30
  process.exit(1);
31
31
  }
32
32
  try {
33
33
  LOCAL_CONFIG.save({...projectData, current: themeName, modified: new Date()});
34
34
  } catch (err) {
35
- console.error(` ERROR: Unable to switch context to ${themeName} due to: ${err}`.red);
35
+ console.error(chalk.red(` ERROR: Unable to switch context to ${themeName} due to: ${err}`));
36
36
  process.exit(1);
37
37
  }
38
38
  try {
39
39
  LOCAL_CONFIG.configFileUpdate();
40
- console.log(` Context switched to ${themeName}.`.green);
41
- console.log("\n ** Please make sure to start or restart server to see changes ** \n".green);
40
+ console.log(chalk.green(` Context switched to ${themeName}.`));
41
+ console.log(chalk.green("\n ** Please make sure to start or restart server to see changes ** \n"));
42
42
  } catch (err) {
43
- console.error(` ERROR: Unable to switch context to ${themeName} due to: ${err}`.red);
43
+ console.error(chalk.red(` ERROR: Unable to switch context to ${themeName} due to: ${err}`));
44
44
  process.exit(1);
45
45
  }
46
46
 
@@ -1,15 +1,15 @@
1
1
  const fs = require("fs-extra");
2
2
  const moment = require("moment");
3
- const colors = require("colors");
4
3
  const prompt = require("./prompt-questions");
5
4
  const packageJson = require('package-json');
6
5
  const { spawnSync } = require("child_process");
6
+ const chalk = require("chalk")
7
7
 
8
8
  const { CURRENT_PATH, TOOLKIT_PATH, BOOTSTRAP_FOLDERS, BOOTSTRAP_FILES, CONFIG_PATH, THEME_COMPONENT_MODULE,
9
- THEME_COMPONENT_VERSION, ACTIVE_THEME_PATH, THEME_LOGS_PATH, THEME_LOGS_FILE_PATH } = require("./toolkit-common-vars");
9
+ THEME_COMPONENT_VERSION, ACTIVE_THEME_PATH, THEME_LOGS_PATH, THEME_LOGS_FILE_PATH, SASS_MODULE,
10
+ SASS_VERSION, SASS_LOADER_MODULE, SASS_LOADER_VERSION } = require("./toolkit-common-vars");
10
11
  const { has } = require("lodash");
11
12
 
12
-
13
13
  // function to remove project's folders (used to revert changes on error)
14
14
  const selfDestruction = (dir) => BOOTSTRAP_FOLDERS.forEach( file => fs.removeSync(`${dir}/${file}`));
15
15
 
@@ -24,11 +24,11 @@ const shouldBeProjectFolder = (should) => {
24
24
  const isProjectFolder = isProjectsFolder(CURRENT_PATH);
25
25
  switch(true){
26
26
  case !should && isProjectFolder:
27
- console.error(` ERROR: Unable to perform requested action. Please navigate away from the project folder.`.red);
27
+ console.error(chalk.red(` ERROR: Unable to perform requested action. Please navigate away from the project folder.`));
28
28
  process.exit(1);
29
29
  break;
30
30
  case should && !isProjectFolder:
31
- console.error(` ERROR: Unable to perform requested action. Please navigate to a project folder.`.red);
31
+ console.error(chalk.red(` ERROR: Unable to perform requested action. Please navigate to a project folder.`));
32
32
  process.exit(1);
33
33
  break;
34
34
  }
@@ -73,7 +73,7 @@ const getAvailableFolderWithPrompt = async (path, name, askFor, createIfNotExist
73
73
  if (err && err.code === 'ENOENT') {
74
74
  if (createIfNotExists) {
75
75
  fs.mkdirSync(`${path}/${name}`);
76
- console.log(` Folder ${path}/${name} created.`.green);
76
+ console.log(chalk.green(` Folder ${path}/${name} created.`));
77
77
  }
78
78
  return resolve(`${path}/${name}`);
79
79
  }
@@ -81,7 +81,7 @@ const getAvailableFolderWithPrompt = async (path, name, askFor, createIfNotExist
81
81
  // check if empty
82
82
  return resolve(`${path}/${name}`);
83
83
  }
84
- console.error(` ERROR: Unable to use a path ${path}/${name}. Folder already exists and is not empty. Try different name or try removing existing folder.`.red);
84
+ console.error(chalk.red(` ERROR: Unable to use a path ${path}/${name}. Folder already exists and is not empty. Try different name or try removing existing folder.`));
85
85
  const userAnswer = await prompt.ask([askFor]);
86
86
  return resolve(getAvailableFolderWithPrompt(path, userAnswer[askFor], askFor, createIfNotExists, canBeEmpty));
87
87
  });
@@ -111,7 +111,7 @@ const installSfbThemeComponents = () => {
111
111
 
112
112
  // check if sfb-theme-components is installed otherwise install it
113
113
  spawnSync('npm',
114
- [`ls ${THEME_COMPONENT_MODULE} 2>&1 | (findstr ${THEME_COMPONENT_MODULE} || grep ${THEME_COMPONENT_MODULE}) > ${THEME_LOGS_FILE_PATH} 2>&1 || npm i -S ${THEME_COMPONENT_MODULE}@${THEME_COMPONENT_VERSION} --production --legacy-peer-deps`], {
114
+ [`ls ${THEME_COMPONENT_MODULE} 2>&1 | (findstr ${THEME_COMPONENT_MODULE} || grep ${THEME_COMPONENT_MODULE}) > ${THEME_LOGS_FILE_PATH} 2>&1 || npm i -S ${THEME_COMPONENT_MODULE}@${THEME_COMPONENT_VERSION} --omit=dev --legacy-peer-deps`], {
115
115
  cwd: ACTIVE_THEME_PATH,
116
116
  stdio: "inherit",
117
117
  shell: true
@@ -158,9 +158,17 @@ const updateCustomComponentsMetadata = (data) => {
158
158
  if (hasPackageJson) {
159
159
  const themePackageJson = JSON.parse(fs.readFileSync(`${ACTIVE_THEME_PATH}/package.json`));
160
160
  const sfbThemeComponentsVersion = themePackageJson.dependencies['@appdirect/sfb-theme-components'];
161
- data = data.replace('data-custom-components="false"', 'data-custom-components="true"');
162
- if(sfbThemeComponentsVersion)
161
+ const customComponentsPath = `${ACTIVE_THEME_PATH}/customComponents`;
162
+ const customComponents = fs.existsSync(customComponentsPath);
163
+ if (customComponents && sfbThemeComponentsVersion) {
164
+ data = data.replace('data-custom-components="false"', 'data-custom-components="true"');
165
+ }
166
+ if (!customComponents) {
167
+ data = data.replace('data-custom-components="true"', 'data-custom-components="false"');
168
+ }
169
+ if(sfbThemeComponentsVersion) {
163
170
  data = data.replace(/data-sfb-theme-components-version=".*"/, `data-sfb-theme-components-version="${sfbThemeComponentsVersion}"`);
171
+ }
164
172
  }
165
173
  return data;
166
174
  }
@@ -176,8 +184,7 @@ const addMetadata = (metadata = {}, themePath) => {
176
184
  fs.writeFileSync(baseFilePath, updatedMetadata);
177
185
  return;
178
186
  }
179
- const headElemIndex = baseFileData.indexOf('<head>');
180
- const headElemLength = '<head>'.length;
187
+ const headElemIndex = baseFileData.indexOf('</head>');
181
188
  const providedMetadata = Object.keys(metadata).length;
182
189
 
183
190
  let themeTemplate;
@@ -220,20 +227,30 @@ const addMetadata = (metadata = {}, themePath) => {
220
227
  }
221
228
  }
222
229
 
223
- const output = baseFileData.substring(0, headElemIndex + headElemLength)
224
- + `\n <ad-theme`
230
+ const output = baseFileData.substring(0, headElemIndex)
231
+ + ` <ad-theme`
225
232
  + (themeTemplate ? `\n data-theme-template="${themeTemplate}"` : '')
226
233
  + (themeVersion ? `\n data-theme-version="${themeVersion}"` : '')
227
234
  + (createdBy ? `\n data-created-by="${createdBy}"` :'')
228
235
  + (createdAt ? `\n data-created-at="${createdAt}"` : '')
229
236
  + `\n data-custom-components="${customComponents}"`
230
237
  + `\n data-sfb-theme-components-version="${sfbThemeComponentsVersion}">`
231
- + `\n </ad-theme>`
232
- + baseFileData.substring(headElemIndex + headElemLength);
238
+ + `\n </ad-theme>\n`
239
+ + baseFileData.substring(headElemIndex);
233
240
 
234
241
  fs.writeFileSync(baseFilePath, output);
235
242
  }
236
243
 
244
+ const installSass = () => {
245
+ // install sass and sass-loader
246
+ spawnSync('npm',
247
+ [`i -S ${SASS_MODULE}@${SASS_VERSION} ${SASS_LOADER_MODULE}@${SASS_LOADER_VERSION} --omit=dev --legacy-peer-deps`], {
248
+ cwd: ACTIVE_THEME_PATH,
249
+ stdio: "inherit",
250
+ shell: true
251
+ })
252
+ }
253
+
237
254
  module.exports = {
238
255
  selfDestruction,
239
256
  filesCounter,
@@ -247,5 +264,6 @@ module.exports = {
247
264
  createThemeLogsFolder,
248
265
  createCustomThemePacakgeJson,
249
266
  updateCustomComponentsMetadata,
250
- addMetadata
267
+ addMetadata,
268
+ installSass
251
269
  }
@@ -15,7 +15,11 @@ 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.293";
18
+ const THEME_COMPONENT_VERSION = "0.0.315";
19
+ const SASS_MODULE = "sass";
20
+ const SASS_VERSION = "1.57.1";
21
+ const SASS_LOADER_MODULE = "sass-loader";
22
+ const SASS_LOADER_VERSION = "13.2.0";
19
23
 
20
24
  let WORKSPACE_CONFIG;
21
25
  try {
@@ -50,7 +54,11 @@ module.exports = {
50
54
  THEME_TEMPLATES,
51
55
  THEME_COMPONENT_MODULE,
52
56
  THEME_COMPONENT_VERSION,
57
+ SASS_MODULE,
58
+ SASS_VERSION,
59
+ SASS_LOADER_MODULE,
60
+ SASS_LOADER_VERSION,
53
61
  THEME_LOGS_PATH,
54
62
  THEME_LOGS_FILE_PATH,
55
- WHO_ARE_YOU_PROMPT
63
+ WHO_ARE_YOU_PROMPT,
56
64
  }
@@ -1,16 +1,17 @@
1
1
  const fs = require("fs-extra")
2
+ const chalk = require("chalk")
2
3
  const { shouldBeProjectFolder, installSfbThemeComponents,
3
- createPackageJson, updateCustomComponentsMetadata } = require("./toolkit-common-fun");
4
- const { ACTIVE_THEME_PATH } = require("./toolkit-common-vars");
4
+ createPackageJson, updateCustomComponentsMetadata, installSass } = require("./toolkit-common-fun");
5
+ const { ACTIVE_THEME_PATH, TOOLKIT_PATH } = require("./toolkit-common-vars");
5
6
 
6
7
  shouldBeProjectFolder(true);
7
8
 
8
9
  const addCustomCompToBase = (baseFilePath, data) => {
9
10
  fs.writeFile(baseFilePath, data, (err) => {
10
- if (err) return console.error(' ERROR: Unable to perform update to use custom components.'.red);
11
- console.log('Successfully installed custom components!\nPlease start/restart the toolkit server to observe the changes.'.green);
12
- console.log('\n\nFor custom components documentation please execute the following command:'.green)
13
- console.log('sfb-toolkit storybook\n'.cyan)
11
+ if (err) return console.error(chalk.red(' ERROR: Unable to perform update to use custom components.'));
12
+ console.log(chalk.green('Successfully installed custom components!\nPlease start/restart the toolkit server to observe the changes.'));
13
+ console.log(chalk.green('\n\nFor custom components documentation please execute the following command:'))
14
+ console.log(chalk.cyan('sfb-toolkit storybook\n'))
14
15
  });
15
16
  }
16
17
 
@@ -25,23 +26,28 @@ const settingsSchemaData = `{ "useComponents": true }`;
25
26
 
26
27
  installSfbThemeComponents();
27
28
 
29
+ installSass();
30
+
28
31
  if(!fs.existsSync(`${ACTIVE_THEME_PATH}/settings-schema.json`)) {
29
32
  fs.writeFile(`${ACTIVE_THEME_PATH}/settings-schema.json`, settingsSchemaData, (err) => {
30
- if (err) return console.error(' ERROR: Unable to create settings-schema.json file.'.red);
33
+ if (err) return console.error(chalk.red(' ERROR: Unable to create settings-schema.json file.'));
31
34
  })
32
35
  }
33
36
 
34
37
  if (!customComponentsEnabled) {
35
- fs.copy(`${__dirname}/../../customComponents`, customComponentsPath, err => {
36
- if (err) return console.error(' ERROR: Unable to copy required files'.red);
37
- })
38
+ try {
39
+ fs.copySync(`${TOOLKIT_PATH}/customComponents`, customComponentsPath)
40
+ } catch (error) {
41
+ return console.error(chalk.red(` ERROR: Unable to copy required files\n ${error}`));
42
+ }
38
43
  }
39
44
 
40
45
  fs.readFile(baseFilePath, 'utf8', (err, data) => {
41
- if (err) return console.error(` ERROR: Unable to read the base layout file. Tried: ${baseFilePath}`.red);
46
+ if (err) return console.error(chalk.red(` ERROR: Unable to read the base layout file. Tried: ${baseFilePath}`));
42
47
 
43
48
  const cdnComponents = data.match(/\S+.+channelCanonicalBaseUrl.+(css|js).+/g);
44
49
  const assetsComponents = data.match(/\S+.+r\(.+assets.+sfb-components.+(css|js).+/g);
50
+ const splitBundles = data.match(/componentsBundles\(config\)/g);
45
51
 
46
52
  if (cdnComponents !== null) {
47
53
  data = data.replace(/\S+.+channelCanonicalBaseUrl.+css.+/,
@@ -54,6 +60,12 @@ const settingsSchemaData = `{ "useComponents": true }`;
54
60
 
55
61
  addCustomCompToBase(baseFilePath, data);
56
62
 
63
+ } else if (splitBundles !== null) {
64
+ data = data.replace('componentsBundles(config)', 'customComponentsBundles(config)');
65
+
66
+ data = updateCustomComponentsMetadata(data);
67
+
68
+ addCustomCompToBase(baseFilePath, data);
57
69
  } else if (assetsComponents === null) {
58
70
  data = updateCustomComponentsMetadata(data);
59
71
 
@@ -67,9 +79,9 @@ const settingsSchemaData = `{ "useComponents": true }`;
67
79
  addCustomCompToBase(baseFilePath, output);
68
80
 
69
81
  } else {
70
- console.log('Theme is already setup to use custom components.'.green)
71
- console.log('\n\nFor custom components documentation please execute the following command:'.green)
72
- console.log('sfb-toolkit storybook\n'.cyan)
82
+ console.log(chalk.green('Theme is already setup to use custom components.'))
83
+ console.log(chalk.green('\n\nFor custom components documentation please execute the following command:'))
84
+ console.log(chalk.cyan('sfb-toolkit storybook\n'))
73
85
  }
74
86
  })
75
87
  })();
@@ -1,6 +1,6 @@
1
1
  const fs = require("fs")
2
2
  const { copy } = require("fs-extra")
3
- const colors = require("colors")
3
+ const chalk = require("chalk")
4
4
  const prompt = require("./prompt-questions");
5
5
  const { TOOLKIT_GLOBAL_CONFIG} = require("./toolkit-common-vars")
6
6
 
@@ -24,12 +24,12 @@ let freshLocalConfig = {
24
24
  // Determine project's dir path
25
25
  let projectPath = `${CURRENT_PATH}/`; // by default
26
26
  if (!prompt.validateFun.isValidFolderName(projectName)){
27
- console.error(`Not valid project name`.red);
27
+ console.error(chalk.red(`Not valid project name`));
28
28
  process.exit(1);
29
29
  }
30
30
 
31
31
  if(!prompt.validateFun.isValidFolderName(themeName)){
32
- console.error(`Not valid theme name`.red);
32
+ console.error(chalk.red(`Not valid theme name`));
33
33
  process.exit(1);
34
34
  }
35
35
 
@@ -57,7 +57,7 @@ let freshLocalConfig = {
57
57
  freshLocalConfig.defaultValues.marketplacePath = TOOLKIT_GLOBAL_CONFIG.defaultValues.marketplacePath;
58
58
  freshLocalConfig.defaultValues.pageObjectsPath = `${TOOLKIT_GLOBAL_CONFIG.defaultValues.marketplacePath}${PAGE_OBJECTS_SUFFIX}`;
59
59
  } catch (err) {
60
- console.error(` Couldn't copy config file due to: \n ${err}`.red);
60
+ console.error(chalk.red(` Couldn't copy config file due to: \n ${err}`));
61
61
  selfDestruction(projectPath); // revert changes
62
62
  process.exit(1);
63
63
  }
@@ -70,19 +70,19 @@ let freshLocalConfig = {
70
70
  try {
71
71
  LOCAL_CONFIG.save(freshLocalConfig, projectPath);
72
72
  } catch (err) {
73
- console.error(` ERROR: Unable to save config file due to: \n ${err}`.red);
73
+ console.error(chalk.red(` ERROR: Unable to save config file due to: \n ${err}`));
74
74
  process.exit(1);
75
75
  }
76
76
 
77
77
  try {
78
78
  LOCAL_CONFIG.configFileUpdate(projectPath);
79
- console.log(` Project context switched to ${freshLocalConfig.current}.`.green);
79
+ console.log(chalk.green(` Project context switched to ${freshLocalConfig.current}.`));
80
80
  } catch ( err ) {
81
- console.error(` ERROR: Unable to switch context to ${freshLocalConfig.current} due to: ${err}`.red);
81
+ console.error(chalk.red(` ERROR: Unable to switch context to ${freshLocalConfig.current} due to: ${err}`));
82
82
  process.exit(1);
83
83
  }
84
84
 
85
- console.log(` Theme location: ${projectPath}/`.green)
86
- console.log(` Configuration file location: ${projectPath}/config/`.green)
87
- console.log(`\n All done for config setup! ${projectPath}\n`.green);
85
+ console.log(chalk.green(` Theme location: ${projectPath}/`))
86
+ console.log(chalk.green(` Configuration file location: ${projectPath}/config/`))
87
+ console.log(chalk.green(`\n All done for config setup! ${projectPath}\n`));
88
88
  })();
@@ -45,4 +45,3 @@ module.exports = {
45
45
  configFileUpdate
46
46
  }
47
47
  }
48
-
@@ -1,8 +1,8 @@
1
- const fs = require("fs")
2
- const { copy, remove } = require("fs-extra")
3
- const { spawn } = require("child_process")
4
- const colors = require("colors")
1
+ const fs = require("fs");
2
+ const { copy, remove } = require("fs-extra");
3
+ const { spawn } = require("child_process");
5
4
  const prompt = require("./prompt-questions");
5
+ const chalk = require("chalk");
6
6
 
7
7
  const { CURRENT_PATH, TOOLKIT_PATH, COMMAND_PARAM, COMPILERCSS_PATH,
8
8
  PAGE_OBJECTS_SUFFIX, ACTIVE_THEME_PATH } = require("./toolkit-common-vars");
@@ -21,7 +21,7 @@ shouldBeProjectFolder(true);
21
21
  try {
22
22
  userThemeAnswer = await prompt.ask(["ThemeTemplates"]);
23
23
  } catch (err) {
24
- console.error(`\n ERROR: Unable to get the starting point theme ${err}.\n`.red);
24
+ console.error(chalk.red(`\n ERROR: Unable to get the starting point theme ${err}.\n`));
25
25
  process.exit(1);
26
26
  }
27
27
 
@@ -33,7 +33,7 @@ shouldBeProjectFolder(true);
33
33
  }
34
34
  themesPath = await getAvailableFolderWithPrompt(`${CURRENT_PATH}/themes`, themeName, "ThemeName");
35
35
  } catch (err) {
36
- console.error(`\n ERROR: Unable to find configuration file due to: ${err}.\n`.red);
36
+ console.error(chalk.red(`\n ERROR: Unable to find configuration file due to: ${err}.\n`));
37
37
  }
38
38
 
39
39
  try {
@@ -45,7 +45,7 @@ shouldBeProjectFolder(true);
45
45
  `${themesPath}/package.json`
46
46
  );
47
47
  } catch (err) {
48
- console.error(` ERROR: Unable to copy theme's files due to: ${err}`.red);
48
+ console.error(chalk.red(` ERROR: Unable to copy theme's files due to: ${err}`));
49
49
  process.exit(1);
50
50
  }
51
51
 
@@ -59,7 +59,7 @@ shouldBeProjectFolder(true);
59
59
  )
60
60
  );
61
61
  } catch(err) {
62
- console.error(` ERROR: Unable to create ${themeName}'s package.json file.`.red);
62
+ console.error(chalk.red(` ERROR: Unable to create ${themeName}'s package.json file.`));
63
63
  process.exit(1);
64
64
  }
65
65
 
@@ -83,24 +83,24 @@ shouldBeProjectFolder(true);
83
83
  modified: new Date()
84
84
  }
85
85
  } catch (err) {
86
- console.error(`\n ERROR: Unable to save updates due to: ${err}.\n`.red);
86
+ console.error(chalk.red(`\n ERROR: Unable to save updates due to: ${err}.\n`));
87
87
  process.exit(1);
88
88
  }
89
89
 
90
90
  try{
91
91
  LOCAL_CONFIG.save(newConfig);
92
92
  } catch (err) {
93
- console.error(` ERROR: Unable to save config file due to: ${err}`.red);
93
+ console.error(chalk.red(` ERROR: Unable to save config file due to: ${err}`));
94
94
  process.exit(1);
95
95
  }
96
96
 
97
97
  try {
98
98
  LOCAL_CONFIG.configFileUpdate();
99
- console.log(` Context switched to ${newConfig.current}.\n`.green);
100
- console.log("\n ** Please make sure to start or restart server to see changes ** \n".green);
99
+ console.log(chalk.green(` Context switched to ${newConfig.current}.\n`));
100
+ console.log(chalk.green("\n ** Please make sure to start or restart server to see changes ** \n"));
101
101
 
102
102
  } catch (err) {
103
- console.error(` ERROR: Unable to switch context to ${newConfig.current} due to: ${err}`.red);
103
+ console.error(chalk.red(` ERROR: Unable to switch context to ${newConfig.current} due to: ${err}`));
104
104
  process.exit(1);
105
105
  }
106
106
 
@@ -117,7 +117,7 @@ shouldBeProjectFolder(true);
117
117
  })
118
118
 
119
119
  } catch (err) {
120
- console.error(` ERROR: Unable to save metadata due to: ${err}`.red);
120
+ console.error(chalk.red(` ERROR: Unable to save metadata due to: ${err}`));
121
121
  }
122
122
 
123
123
  spawn('node',
@@ -1,13 +1,14 @@
1
1
  const fs = require("fs-extra");
2
+ const chalk = require("chalk");
2
3
  const { shouldBeProjectFolder, createPackageJson, updateCustomComponentsMetadata } = require("./toolkit-common-fun");
3
- const { spawn } = require("child_process")
4
+ const { spawn } = require("child_process");
4
5
  const { COMMAND_PARAM, ACTIVE_THEME_PATH } = require("./toolkit-common-vars");
5
6
 
6
7
  const npmModule = COMMAND_PARAM;
7
8
 
8
9
  shouldBeProjectFolder(true);
9
10
  if(npmModule === 'undefined'){
10
- console.error(` ERROR: Please provide the npm module to install.`.red);
11
+ console.error(chalk.red(` ERROR: Please provide the npm module to install.`));
11
12
  process.exit(1);
12
13
  }
13
14
 
@@ -28,10 +29,10 @@ if(npmModule === 'undefined'){
28
29
 
29
30
  if (customComponentsEnabled) {
30
31
  fs.readFile(baseFilePath, 'utf8', (err, data) => {
31
- if (err) return console.error(` ERROR: Unable to read the base layout file. Tried: ${baseFilePath}`.red);
32
+ if (err) return console.error(chalk.red(` ERROR: Unable to read the base layout file. Tried: ${baseFilePath}`));
32
33
  const updatedMetadata = updateCustomComponentsMetadata(data);
33
34
  fs.writeFile(baseFilePath, updatedMetadata, (err) => {
34
- if (err) return console.error(` ERROR: Unable to update metadata due to: ${err}.`.red);
35
+ if (err) return console.error(chalk.red(` ERROR: Unable to update metadata due to: ${err}.`));
35
36
  });
36
37
  });
37
38
  };
@@ -1,4 +1,5 @@
1
1
  const { spawn } = require("child_process")
2
+ const chalk = require("chalk")
2
3
 
3
4
  const PACKFONTS_PATH = "src/tools/package-fonts.js"
4
5
  const ZIPTHEME_PATH = "src/tools/zip-theme.js"
@@ -35,17 +36,17 @@ const hasTranslationErrors = async () => {
35
36
  } catch (err) {
36
37
  yamlErrorFlag = true
37
38
  if (err.name === "YAMLException") {
38
- console.log(`${langFile} -> ${err}`.red)
39
+ console.log(chalk.red(`${langFile} -> ${err}`))
39
40
  }
40
- console.log(err.red)
41
+ console.log(chalk.red(err))
41
42
  }
42
43
  })
43
44
  if (yamlErrorFlag) {
44
- console.log(yamlErrorCustomMessage.red)
45
+ console.log(chalk.red(yamlErrorCustomMessage))
45
46
  }
46
47
  } catch (err) {
47
48
  yamlErrorFlag = true
48
- console.log(`${err}`.red)
49
+ console.log(chalk.red(`${err}`))
49
50
  }
50
51
  return yamlErrorFlag
51
52
  }