@appdirect/sfb-toolkit 3.0.1 → 3.0.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.
Files changed (46) hide show
  1. package/coverage/clover.xml +178 -175
  2. package/coverage/coverage-final.json +8 -8
  3. package/coverage/lcov-report/constants/index.html +1 -1
  4. package/coverage/lcov-report/constants/pageUrls.js.html +2 -2
  5. package/coverage/lcov-report/constants/userMock.js.html +1 -1
  6. package/coverage/lcov-report/controllers/controllers-utils/assetsUtils.js.html +8 -8
  7. package/coverage/lcov-report/controllers/controllers-utils/index.html +1 -1
  8. package/coverage/lcov-report/controllers/data-filters/bootstrap-data-filter.js.html +1 -1
  9. package/coverage/lcov-report/controllers/data-filters/call-to-actions-filter.js.html +1 -1
  10. package/coverage/lcov-report/controllers/data-filters/index.html +1 -1
  11. package/coverage/lcov-report/controllers/index.html +18 -18
  12. package/coverage/lcov-report/controllers/index.js.html +144 -75
  13. package/coverage/lcov-report/front-end-utils/src/components/base/ResultItem.js.html +7 -7
  14. package/coverage/lcov-report/front-end-utils/src/components/base/SearchBar.js.html +3 -3
  15. package/coverage/lcov-report/front-end-utils/src/components/base/index.html +1 -1
  16. package/coverage/lcov-report/front-end-utils/src/components/base/item.js.html +11 -11
  17. package/coverage/lcov-report/front-end-utils/src/components/container.js.html +1 -1
  18. package/coverage/lcov-report/front-end-utils/src/components/data-view.js.html +1 -1
  19. package/coverage/lcov-report/front-end-utils/src/components/header-view.js.html +1 -1
  20. package/coverage/lcov-report/front-end-utils/src/components/index.html +1 -1
  21. package/coverage/lcov-report/front-end-utils/src/components/search.js.html +13 -13
  22. package/coverage/lcov-report/front-end-utils/src/constants/index.html +1 -1
  23. package/coverage/lcov-report/front-end-utils/src/constants/pageUrl.js.html +1 -1
  24. package/coverage/lcov-report/front-end-utils/src/constants/roleType.js.html +1 -1
  25. package/coverage/lcov-report/front-end-utils/src/constants/searchType.js.html +1 -1
  26. package/coverage/lcov-report/front-end-utils/src/utils/debounce.js.html +1 -1
  27. package/coverage/lcov-report/front-end-utils/src/utils/index.html +1 -1
  28. package/coverage/lcov-report/index.html +18 -18
  29. package/coverage/lcov-report/middlewares/config.js.html +9 -3
  30. package/coverage/lcov-report/middlewares/index.html +1 -1
  31. package/coverage/lcov.info +350 -336
  32. package/index.js +1 -3
  33. package/npm-shrinkwrap.json +10 -20
  34. package/package.json +3 -2
  35. package/readme.md +13 -2
  36. package/src/controllers/index.js +51 -28
  37. package/src/middlewares/config.js +3 -1
  38. package/src/tools/compiler-components-prod.js +30 -0
  39. package/src/tools/toolkit-common-vars.js +1 -1
  40. package/src/tools/toolkit-components.js +4 -0
  41. package/src/tools/toolkit-package.js +44 -37
  42. package/src/tools/zip-theme.js +15 -8
  43. package/webpack-components.config.js +28 -8
  44. package/webpack-components.config.prod.js +115 -0
  45. package/.node-version +0 -1
  46. package/src/tools/compiler-components.js +0 -25
package/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  const express = require("express")
2
2
  const webpack = require("webpack")
3
3
  const fs = require("fs")
4
-
5
4
  const webpackDevMiddleware = require("webpack-dev-middleware")
6
5
  const webpackHotMiddleware = require("webpack-hot-middleware")
7
6
  const bodyParser = require("body-parser")
@@ -30,7 +29,6 @@ if (process.env.RUN_ENV === "dev") {
30
29
  )
31
30
  }
32
31
 
33
-
34
32
  if (fs.existsSync(`${currentPath}/themes/${config.theme}/customComponents`)) {
35
33
  const configComponentsWebpackAsset = getConfigComponentsWebpack(
36
34
  currentPath,
@@ -54,7 +52,7 @@ if (fs.existsSync(`${currentPath}/themes/${config.theme}/customComponents`)) {
54
52
  path: "/__webpack_hmr",
55
53
  heartbeat: 10 * 1000
56
54
  })
57
- );
55
+ )
58
56
  }
59
57
 
60
58
  app.use(
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appdirect/sfb-toolkit",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
@@ -10,14 +10,14 @@
10
10
  "integrity": "sha1-r5sX3a3DE3JXYDbIdgu668lvZPw="
11
11
  },
12
12
  "@appdirect/sfb-theme-plaza": {
13
- "version": "0.0.45",
14
- "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/@appdirect/sfb-theme-plaza/-/sfb-theme-plaza-0.0.45.tgz",
15
- "integrity": "sha1-pigx8YnmJsvLZGlGDtN0BJW36b4="
13
+ "version": "0.0.47",
14
+ "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/@appdirect/sfb-theme-plaza/-/sfb-theme-plaza-0.0.47.tgz",
15
+ "integrity": "sha1-PE7FNY/q0W/jU+DAzFNcgCCiWoc="
16
16
  },
17
17
  "@appdirect/storefront-utils": {
18
- "version": "0.0.101",
19
- "resolved": "https://registry.npmjs.org/@appdirect/storefront-utils/-/storefront-utils-0.0.101.tgz",
20
- "integrity": "sha512-z5/LJpN6cOobP2ziYlWIJa8z+kLsBH4jeQXFh42dGuWHV3allqfVaol9HmZbOzVu0+FMp9ncIZyjxe/SXCWCiQ==",
18
+ "version": "0.0.108",
19
+ "resolved": "https://registry.npmjs.org/@appdirect/storefront-utils/-/storefront-utils-0.0.108.tgz",
20
+ "integrity": "sha512-hGNyYdHcxhXVNa1tmUcfufUadkvkjz5oKumHzJ/my4RmBWKY9j64fs8si0YW15iXT0ceJgDT/Zx/geHJv2FIQg==",
21
21
  "requires": {
22
22
  "cheerio": "^0.22.0",
23
23
  "directory-tree": "^2.0.0",
@@ -348,11 +348,6 @@
348
348
  "node-releases": "^1.1.71"
349
349
  }
350
350
  },
351
- "caniuse-lite": {
352
- "version": "1.0.30001228",
353
- "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/caniuse-lite/-/caniuse-lite-1.0.30001228.tgz",
354
- "integrity": "sha1-v9xZQs0zJvpR7gtC++9NqdSSp/o="
355
- },
356
351
  "colorette": {
357
352
  "version": "1.2.2",
358
353
  "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/colorette/-/colorette-1.2.2.tgz",
@@ -2095,11 +2090,6 @@
2095
2090
  "node-releases": "^1.1.71"
2096
2091
  }
2097
2092
  },
2098
- "caniuse-lite": {
2099
- "version": "1.0.30001228",
2100
- "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/caniuse-lite/-/caniuse-lite-1.0.30001228.tgz",
2101
- "integrity": "sha1-v9xZQs0zJvpR7gtC++9NqdSSp/o="
2102
- },
2103
2093
  "colorette": {
2104
2094
  "version": "1.2.2",
2105
2095
  "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/colorette/-/colorette-1.2.2.tgz",
@@ -2729,9 +2719,9 @@
2729
2719
  "integrity": "sha1-FkpUg+Yw+kMh5a8HAg5TGDGyYJs="
2730
2720
  },
2731
2721
  "caniuse-lite": {
2732
- "version": "1.0.30001030",
2733
- "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/caniuse-lite/-/caniuse-lite-1.0.30001030.tgz",
2734
- "integrity": "sha1-eAdsTG1n0+Qdbrk5mFP7J/5uRO4="
2722
+ "version": "1.0.30001304",
2723
+ "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/caniuse-lite/-/caniuse-lite-1.0.30001304.tgz",
2724
+ "integrity": "sha1-OK9V7T/IIgyxPjXm5zCcjGWgVVk="
2735
2725
  },
2736
2726
  "capture-stack-trace": {
2737
2727
  "version": "1.0.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appdirect/sfb-toolkit",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -21,6 +21,7 @@
21
21
  "^.+\\.js?$": "babel-jest"
22
22
  }
23
23
  },
24
+ "license": "SEE LICENSE IN https://help.appdirect.com/sfb-eula.pdf",
24
25
  "scripts": {
25
26
  "test": "jest --coverage",
26
27
  "buildToolbar": "webpack --config ./webpack.config.js --mode production",
@@ -46,7 +47,7 @@
46
47
  },
47
48
  "dependencies": {
48
49
  "@appdirect/sfb-theme-classic": "0.0.21",
49
- "@appdirect/sfb-theme-plaza": "0.0.45",
50
+ "@appdirect/sfb-theme-plaza": "0.0.47",
50
51
  "@babel/core": "^7.4.4",
51
52
  "@babel/plugin-proposal-class-properties": "^7.4.4",
52
53
  "@babel/plugin-transform-runtime": "^7.14.3",
package/readme.md CHANGED
@@ -7,8 +7,18 @@ It can be easily mixed with eg. HTML, CSS, JavaScript, jQuery, SASS.
7
7
 
8
8
  ### Requirements
9
9
  * Node 10.x or 12.x
10
+
10
11
  ### Release Notes:
11
12
 
13
+ **3.0.3**
14
+ - Bug fix: Fix `PRODUCTS_LIST` schema type not working on a custom page
15
+ - Update `sfb-toolkit package` command to minify `sfb-components.js` bundle
16
+ - Update `sfb-theme-components` library to version [0.0.245](https://www.npmjs.com/package/@appdirect/sfb-theme-components/v/0.0.245)
17
+ - Update custom components section in the Storybook documentation
18
+ - Update `@appdirect/sfb-theme-plaza` to version 0.0.47 ([sfb-theme-mp2@0.0.47](https://www.npmjs.com/package/@appdirect/sfb-theme-plaza/v/0.0.47))
19
+ - Add product variants template
20
+ - Add `enableProductVariant` theme setting
21
+
12
22
  **3.0.0**
13
23
  - Add new storefront Header & Footer components
14
24
  - Add new menu manager in the Visual Editor
@@ -81,14 +91,15 @@ It can be easily mixed with eg. HTML, CSS, JavaScript, jQuery, SASS.
81
91
  **1.1.0**
82
92
  - Toolkit is now ready and able to work on Node 12
83
93
 
84
- **1.0.0** - Initial release
94
+ **1.0.0**
95
+ - Initial release
85
96
 
86
97
  ### How to use
87
98
  The idea behind Toolkit CLI is similar to how `git` CLI have been made.
88
99
  Developer can have multiple themes in single environment.
89
100
 
90
101
  |Command|Description|
91
- |--|--|
102
+ |---|---|
92
103
  |`sfb-toolkit setup`|Creates a new project/environment where Developer can store themes|
93
104
  |`sfb-toolkit create [name]`|Creates a new theme|
94
105
  |`sfb-toolkit checkout [name]`|Changes context to the theme [name]|
@@ -8,14 +8,13 @@ const { merge } = require("lodash")
8
8
 
9
9
  const { callToActionsFilter } = require("./data-filters/call-to-actions-filter")
10
10
  const { bootstrapDataFilter } = require("./data-filters//bootstrap-data-filter")
11
- const { raw } = require("body-parser")
12
11
 
13
12
  const { themeAssetsPath, toolkitAssetsPath } = require("../constants/pageUrls")
14
13
  const buildHeaderAssets = require("./controllers-utils/assetsUtils")
15
14
 
16
15
  const currentPath = process.cwd()
17
16
  const API_PATHS = storefrontUtils.pageApi
18
- const userMock = require("../constants/userMock");
17
+ const userMock = require("../constants/userMock")
19
18
 
20
19
  const appendClearCartFunction = html => {
21
20
  const clearCartJS = `<script>
@@ -76,6 +75,14 @@ class Pages {
76
75
  }
77
76
  }
78
77
 
78
+ isCustomPage(page) {
79
+ return !!(page === "custom" && this.customPath && this.customPath.length)
80
+ }
81
+
82
+ getPage(page) {
83
+ return this.isCustomPage(page) ? this.customPath[0] : page
84
+ }
85
+
79
86
  redirectToLocalePage() {
80
87
  this.getData(this.config, this.page).then(response => {
81
88
  const { data = {} } = response
@@ -115,8 +122,8 @@ class Pages {
115
122
  getData(pageSettings) {
116
123
  return new Promise(resolve => {
117
124
  let { page, locale, currency } = this
118
- if (page === 'admin') {
119
- page = 'home';
125
+ if (page === "admin") {
126
+ page = "home"
120
127
  }
121
128
  const apiURL = API_PATHS[page](
122
129
  this.config.marketplacePath,
@@ -127,7 +134,8 @@ class Pages {
127
134
  envData: storefrontUtils.getEnvMarketplaceData(
128
135
  this.config.marketplacePath,
129
136
  this.envData
130
- )
137
+ ),
138
+ currentPage: page
131
139
  }),
132
140
  storefrontUtils.getQueryData(
133
141
  {
@@ -151,8 +159,8 @@ class Pages {
151
159
  })
152
160
  .then(response => {
153
161
  const data = Pages.filterData(response.data)
154
- if (this.mockRole === 'USER') {
155
- data.config.user = userMock;
162
+ if (this.mockRole === "USER") {
163
+ data.config.user = userMock
156
164
  }
157
165
  this.defaultLocale = data.config.defaultLocale || "en-US"
158
166
  resolve({
@@ -198,13 +206,13 @@ class Pages {
198
206
  try {
199
207
  return JSON.parse(
200
208
  fs.readFileSync(
201
- `${currentPath}/themes/${
202
- this.config.theme
203
- }/env-data.json`,
209
+ `${currentPath}/themes/${this.config.theme}/env-data.json`,
204
210
  "utf8"
205
211
  )
206
212
  )
207
- } catch (e) { console.log("env data not loading") }
213
+ } catch (e) {
214
+ console.log("env data not loading")
215
+ }
208
216
  return {}
209
217
  }
210
218
 
@@ -228,15 +236,13 @@ class Pages {
228
236
  try {
229
237
  return JSON.parse(
230
238
  fs.readFileSync(
231
- `${currentPath}/themes/${
232
- this.config.theme
233
- }/settings.json`,
239
+ `${currentPath}/themes/${this.config.theme}/settings.json`,
234
240
  "utf8"
235
241
  )
236
242
  )
237
- } catch (e) {
243
+ } catch (e) {
238
244
  // commented for 2.0.1 release.
239
- // console.log("settings not loading")
245
+ // console.log("settings not loading")
240
246
  }
241
247
  return {}
242
248
  }
@@ -312,22 +318,27 @@ class Pages {
312
318
  }
313
319
 
314
320
  getRawMockTemplates(mockedPages) {
315
- const mockedPageObject = {};
316
- const mockedPagesPath = `${__dirname}/../../mockPages`;
321
+ const mockedPageObject = {}
322
+ const mockedPagesPath = `${__dirname}/../../mockPages`
317
323
  mockedPages.forEach(folder => {
318
324
  try {
319
- const htmlContent = fs.readFileSync(`${mockedPagesPath}/${folder}/${folder}.html`, "utf8");
320
- mockedPageObject[folder] = { [`${folder}.html`]: htmlContent };
325
+ const htmlContent = fs.readFileSync(
326
+ `${mockedPagesPath}/${folder}/${folder}.html`,
327
+ "utf8"
328
+ )
329
+ mockedPageObject[folder] = { [`${folder}.html`]: htmlContent }
321
330
  } catch (error) {
322
- console.error(`ERROR: could not find ${folder}.html in ${mockedPagesPath}/${folder}`);
331
+ console.error(
332
+ `ERROR: could not find ${folder}.html in ${mockedPagesPath}/${folder}`
333
+ )
323
334
  }
324
335
  })
325
- return mockedPageObject;
336
+ return mockedPageObject
326
337
  }
327
338
 
328
339
  getFile(isMockedPage, rawTemplates) {
329
340
  if (isMockedPage) {
330
- return `${this.page}/${this.page}.html`;
341
+ return `${this.page}/${this.page}.html`
331
342
  }
332
343
  return storefrontUtils.findPage(rawTemplates, {}, this)
333
344
  }
@@ -340,7 +351,7 @@ class Pages {
340
351
  rawTemplates = { ...rawTemplates, ...rawMockTemplates }
341
352
  const assetsMapperFunc = this.getAssetsMapperFunction()
342
353
  const pageSettings = this.layoutEditorSettings.pages
343
- ? this.layoutEditorSettings.pages[this.page] || {}
354
+ ? this.layoutEditorSettings.pages[this.getPage(this.page)] || {}
344
355
  : {}
345
356
  const defaultGlobalStyles = {
346
357
  namespaces: {
@@ -363,12 +374,22 @@ class Pages {
363
374
  rawTemplates.pages,
364
375
  file.split("/")
365
376
  )
366
- this.getData(pageSettings).then(data => {
367
- // Now we have data for the product, we determine if we need to use a specific page for the product type.
377
+ const updateTemplateWithPageData = data => {
368
378
  if (this.page === "profile") {
369
- file = storefrontUtils.findPage(rawTemplates, data, this)
379
+ file = storefrontUtils.findPage(
380
+ rawTemplates,
381
+ data,
382
+ this,
383
+ undefined,
384
+ this.themeSettings
385
+ )
370
386
  template = `/pages/${file}`
371
387
  }
388
+ }
389
+
390
+ this.getData(pageSettings).then(data => {
391
+ // Now we have data for the product, we determine if we need to use a specific page for the product type.
392
+ updateTemplateWithPageData(data)
372
393
  storefrontUtils.TplEngine.compile(
373
394
  rawTemplates,
374
395
  template,
@@ -389,7 +410,9 @@ class Pages {
389
410
  html,
390
411
  this.themePath,
391
412
  this.config.marketplacePath,
392
- this.themeSettings.useComponents,
413
+ this.themeSettings[
414
+ storefrontUtils.themeSettingsKeys.USE_COMPONENT
415
+ ],
393
416
  this.layoutEditorSettings,
394
417
  this.getLocalization()
395
418
  )
@@ -2,6 +2,7 @@ const path = require("path")
2
2
  const currentPath = process.cwd() // used to get current dev folder
3
3
  const config = require(`${currentPath}/config`)
4
4
  const storefrontUtils = require("@appdirect/storefront-utils")
5
+
5
6
  let envData = {}
6
7
  try {
7
8
  envData = require(`${currentPath}/themes/${config.theme}/env-data.json`)
@@ -28,7 +29,8 @@ module.exports = (req, res, next) => {
28
29
  marketplacePath,
29
30
  envData: storefrontUtils.getEnvMarketplaceData(marketplacePath, envData),
30
31
  pageObjectsPath: PAGE_OBJECTS_OVERRIDE || config.pageObjectsPath,
31
- projectPath: `${path.resolve(__dirname)}/../`
32
+ projectPath: `${path.resolve(__dirname)}/../`,
33
+ serviceName: 'sfb-toolkit'
32
34
  }
33
35
  return next()
34
36
  }
@@ -0,0 +1,30 @@
1
+ const webpack = require("webpack")
2
+ const fs = require("fs")
3
+ const fsExtra = require("fs-extra")
4
+ const { TOOLKIT_PATH } = require("./toolkit-common-vars")
5
+
6
+ const getConfigComponentsProdWebpack = require(`${TOOLKIT_PATH}/webpack-components.config.prod`)
7
+ const currentPath = process.cwd() // used to get current dev folder
8
+ const config = require(`${currentPath}/config`)
9
+ const customComponentsAssets = `${currentPath}/themes/${
10
+ config.theme
11
+ }/assets/js/components`
12
+
13
+ if (fs.existsSync(customComponentsAssets)) {
14
+ // Remove unnecessary hot directory for the webpack hot module reload
15
+ fsExtra.remove(`${customComponentsAssets}/hot`, fsError => {
16
+ if (fsError) {
17
+ console.error(fsError)
18
+ }
19
+
20
+ const configComponentsWebpackAsset = getConfigComponentsProdWebpack(
21
+ currentPath,
22
+ config
23
+ )
24
+ webpack(configComponentsWebpackAsset, (err, stats) => {
25
+ if (err || stats.hasErrors()) {
26
+ console.log(stats.hasErrors())
27
+ }
28
+ })
29
+ })
30
+ }
@@ -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.237";
18
+ const THEME_COMPONENT_VERSION = "0.0.245";
19
19
 
20
20
  let WORKSPACE_CONFIG;
21
21
  try {
@@ -8,6 +8,8 @@ const addCustomCompToBase = (baseFilePath, data) => {
8
8
  fs.writeFile(baseFilePath, data, (err) => {
9
9
  if (err) return console.error(' ERROR: Unable to perform update to use custom components.'.red);
10
10
  console.log('Successfully installed custom components!\nPlease start/restart the toolkit server to observe the changes.'.green);
11
+ console.log('\n\nFor custom components documentation please execute the following command:'.green)
12
+ console.log('sfb-toolkit storybook\n'.cyan)
11
13
  });
12
14
  }
13
15
 
@@ -60,6 +62,8 @@ const settingsSchemaData = `{ "useComponents": true }`;
60
62
 
61
63
  } else {
62
64
  console.log('Theme is already setup to use custom components.'.green)
65
+ console.log('\n\nFor custom components documentation please execute the following command:'.green)
66
+ console.log('sfb-toolkit storybook\n'.cyan)
63
67
  }
64
68
  })
65
69
  })();
@@ -1,68 +1,75 @@
1
1
  const { spawn } = require("child_process")
2
+
2
3
  const PACKFONTS_PATH = "src/tools/package-fonts.js"
3
4
  const ZIPTHEME_PATH = "src/tools/zip-theme.js"
4
- const COMPILECOMPONENTS_PATH = "src/tools/compiler-components.js"
5
- const prompt = require("./prompt-questions");
6
- const fs = require('fs-extra');
7
- const fsProm = fs.promises;
8
- const yaml = require('js-yaml');
5
+ const COMPILECOMPONENTS_PATH = "src/tools/compiler-components-prod.js"
6
+ const prompt = require("./prompt-questions")
7
+ const fs = require("fs-extra")
8
+
9
+ const fsProm = fs.promises
10
+ const yaml = require("js-yaml")
11
+
9
12
  const currentPath = process.cwd()
10
13
  const config = require(`${currentPath}/config`)
11
14
 
12
- const { TOOLKIT_PATH, COMPILERCSS_PATH, COMMAND_PARAM, ACTIVE_THEME_PATH } = require("./toolkit-common-vars");
13
- const { shouldBeProjectFolder } = require("./toolkit-common-fun");
15
+ const {
16
+ TOOLKIT_PATH,
17
+ COMPILERCSS_PATH,
18
+ ACTIVE_THEME_PATH
19
+ } = require("./toolkit-common-vars")
20
+ const { shouldBeProjectFolder } = require("./toolkit-common-fun")
14
21
 
15
- shouldBeProjectFolder(true);
22
+ shouldBeProjectFolder(true)
16
23
 
17
24
  const yamlErrorCustomMessage = `Invalid translation files, please make sure the .yml files are in yaml format and not in JSON.
18
- You can verify your yaml files on various free YAML validators on the web.`;
25
+ You can verify your yaml files on various free YAML validators on the web.`
19
26
 
20
27
  const hasTranslationErrors = async () => {
21
- let yamlErrorFlag = false;
22
- const translationsPath = `${currentPath}/themes/${config.theme}/translations`;
28
+ let yamlErrorFlag = false
29
+ const translationsPath = `${currentPath}/themes/${config.theme}/translations`
23
30
  try {
24
31
  const translationsFiles = await fsProm.readdir(translationsPath)
25
32
 
26
- translationsFiles.forEach(( langFile ) => {
33
+ translationsFiles.forEach(langFile => {
27
34
  try {
28
- yaml.safeLoad(fs.readFileSync(`${translationsPath}/${langFile}`));
35
+ yaml.safeLoad(fs.readFileSync(`${translationsPath}/${langFile}`))
29
36
  } catch (err) {
30
- yamlErrorFlag = true;
31
- err.name === "YAMLException" ? console.log(`${langFile} -> ${err}`.red) : console.log(err.red);
37
+ yamlErrorFlag = true
38
+ if (err.name === "YAMLException") {
39
+ console.log(`${langFile} -> ${err}`.red)
40
+ }
41
+ console.log(err.red)
32
42
  }
33
43
  })
34
44
  if (yamlErrorFlag) {
35
- console.log(yamlErrorCustomMessage.red);
45
+ console.log(yamlErrorCustomMessage.red)
36
46
  }
37
47
  } catch (err) {
38
- yamlErrorFlag = true;
39
- console.log(`${err}`.red);
48
+ yamlErrorFlag = true
49
+ console.log(`${err}`.red)
40
50
  }
41
- return yamlErrorFlag;
51
+ return yamlErrorFlag
42
52
  }
43
53
 
44
- const includeSettings = async (shouldIncludeSettings) => {
45
-
46
- if(fs.existsSync(`${ACTIVE_THEME_PATH}/settings.json`)) {
47
- const userAnswerSettings = await prompt.ask(["PackSettingsChoice"]);
48
- return userAnswerSettings.PackSettingsChoice;
54
+ const includeSettings = async shouldIncludeSettings => {
55
+ if (fs.existsSync(`${ACTIVE_THEME_PATH}/settings.json`)) {
56
+ const userAnswerSettings = await prompt.ask(["PackSettingsChoice"])
57
+ return userAnswerSettings.PackSettingsChoice
49
58
  }
50
59
  return shouldIncludeSettings
51
60
  }
61
+ ;(async () => {
62
+ let shouldIncludeTranslations = true
63
+ let shouldIncludeSettings = true
52
64
 
53
- (async () => {
54
- let shouldIncludeTranslations = true;
55
- let shouldIncludeSettings = true;
56
-
57
- if(process.env.PACK_ALL !== 'true') {
58
- const userAnswerTranslations = await prompt.ask(["PackTranslationsChoice"]);
59
- shouldIncludeTranslations = userAnswerTranslations.PackTranslationsChoice;
60
- if(shouldIncludeTranslations && await hasTranslationErrors()) return;
61
- shouldIncludeSettings = await includeSettings(shouldIncludeSettings);
62
- }
63
- else {
64
- const translationsError = await hasTranslationErrors();
65
- if(translationsError) return;
65
+ if (process.env.PACK_ALL !== "true") {
66
+ const userAnswerTranslations = await prompt.ask(["PackTranslationsChoice"])
67
+ shouldIncludeTranslations = userAnswerTranslations.PackTranslationsChoice
68
+ if (shouldIncludeTranslations && (await hasTranslationErrors())) return
69
+ shouldIncludeSettings = await includeSettings(shouldIncludeSettings)
70
+ } else {
71
+ const translationsError = await hasTranslationErrors()
72
+ if (translationsError) return
66
73
  }
67
74
 
68
75
  spawn(
@@ -9,10 +9,10 @@ const config = require(`${currentPath}/config`)
9
9
  const theme = config.theme || "classic"
10
10
 
11
11
  const dir = `${currentPath}/theme-zips`
12
- const { COMMAND_PARAM } = require("./toolkit-common-vars");
12
+ const { COMMAND_PARAM } = require("./toolkit-common-vars")
13
13
 
14
- const SHOULD_INCLUDE_TRANSLATIONS = COMMAND_PARAM === "true" || false;
15
- const SHOULD_INCLUDE_SETTINGS = process.argv[3] === "true" || false;
14
+ const SHOULD_INCLUDE_TRANSLATIONS = COMMAND_PARAM === "true" || false
15
+ const SHOULD_INCLUDE_SETTINGS = process.argv[3] === "true" || false
16
16
 
17
17
  if (!fs.existsSync(dir)) {
18
18
  fs.mkdirSync(dir)
@@ -33,20 +33,27 @@ fileOutput.on("close", () => {
33
33
  archive.pipe(fileOutput)
34
34
  const root = `${currentPath}/themes/${theme}`
35
35
 
36
- const specialIgnore = [];
37
- if(!SHOULD_INCLUDE_TRANSLATIONS) {
36
+ const specialIgnore = []
37
+ if (!SHOULD_INCLUDE_TRANSLATIONS) {
38
38
  specialIgnore.push("translations/**")
39
39
  }
40
40
 
41
- if(!SHOULD_INCLUDE_SETTINGS) {
41
+ if (!SHOULD_INCLUDE_SETTINGS) {
42
42
  specialIgnore.push("settings.json")
43
43
  }
44
44
 
45
45
  // some glob pattern here
46
46
  archive.glob("**", {
47
47
  cwd: root,
48
- ignore: [".*", "__*/**", "**/node_modules/**", "*.Jenkinsfile", "package.json", "package-lock.json",
49
- "npm-shrinkwrap.json", "README.md", ...specialIgnore
48
+ ignore: [
49
+ ".*",
50
+ "__*/**",
51
+ "**/node_modules/**",
52
+ "*.Jenkinsfile",
53
+ "package-lock.json",
54
+ "npm-shrinkwrap.json",
55
+ "README.md",
56
+ ...specialIgnore
50
57
  ]
51
58
  })
52
59
  // add as many as you like
@@ -1,6 +1,6 @@
1
1
  const path = require("path")
2
2
  const webpack = require("webpack")
3
- const MiniCssExtractPlugin = require("mini-css-extract-plugin");
3
+ const MiniCssExtractPlugin = require("mini-css-extract-plugin")
4
4
 
5
5
  module.exports = (currentPath, config, isAsset) => {
6
6
  const assetPath = path.resolve(
@@ -11,11 +11,14 @@ module.exports = (currentPath, config, isAsset) => {
11
11
  currentPath,
12
12
  `themes/${config.theme}/components/lib`
13
13
  )
14
-
14
+
15
15
  return {
16
16
  entry: [
17
17
  "webpack-hot-middleware/client?path=/__webpack_hmr&reload=true",
18
- path.resolve(currentPath, `themes/${config.theme}/customComponents/index.js`)
18
+ path.resolve(
19
+ currentPath,
20
+ `themes/${config.theme}/customComponents/index.js`
21
+ )
19
22
  ],
20
23
  mode: "development",
21
24
  output: {
@@ -24,8 +27,8 @@ module.exports = (currentPath, config, isAsset) => {
24
27
  filename: "sfb-components.js",
25
28
  path: isAsset ? assetPath : libPath,
26
29
  publicPath: `http://localhost:3555/sfb-toolkit-assets/js/components/`,
27
- hotUpdateChunkFilename: 'hot/hot-update.js',
28
- hotUpdateMainFilename: 'hot/hot-update.json'
30
+ hotUpdateChunkFilename: "hot/hot-update.js",
31
+ hotUpdateMainFilename: "hot/hot-update.json"
29
32
  },
30
33
  plugins: [
31
34
  new webpack.HotModuleReplacementPlugin(),
@@ -49,8 +52,16 @@ module.exports = (currentPath, config, isAsset) => {
49
52
  require.resolve("@babel/plugin-transform-runtime")
50
53
  ],
51
54
  include: [
52
- path.resolve(currentPath, `themes/${config.theme}/customComponents`),
53
- path.resolve(currentPath, `themes/${config.theme}/node_modules/@appdirect/sfb-theme-components`)
55
+ path.resolve(
56
+ currentPath,
57
+ `themes/${config.theme}/customComponents`
58
+ ),
59
+ path.resolve(
60
+ currentPath,
61
+ `themes/${
62
+ config.theme
63
+ }/node_modules/@appdirect/sfb-theme-components`
64
+ )
54
65
  ]
55
66
  }
56
67
  }
@@ -92,7 +103,16 @@ module.exports = (currentPath, config, isAsset) => {
92
103
  path.resolve(__dirname, "node_modules"),
93
104
  path.resolve(currentPath, `themes/${config.theme}/node_modules`)
94
105
  ],
95
- extensions: [".scss", ".js", ".jsx", ".json", ".png", ".gif", ".jpg", ".svg"]
106
+ extensions: [
107
+ ".scss",
108
+ ".js",
109
+ ".jsx",
110
+ ".json",
111
+ ".png",
112
+ ".gif",
113
+ ".jpg",
114
+ ".svg"
115
+ ]
96
116
  },
97
117
  resolveLoader: {
98
118
  modules: [