@appdirect/sfb-toolkit 2.0.14 → 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.
- package/Dockerfile +26 -0
- package/bin/index.js +191 -189
- package/commands.sh +2 -0
- package/coverage/clover.xml +570 -0
- package/coverage/coverage-final.json +19 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +79 -0
- package/coverage/lcov-report/constants/index.html +126 -0
- package/coverage/lcov-report/constants/pageUrls.js.html +98 -0
- package/coverage/lcov-report/constants/userMock.js.html +158 -0
- package/coverage/lcov-report/controllers/controllers-utils/assetsUtils.js.html +173 -0
- package/coverage/lcov-report/controllers/controllers-utils/index.html +111 -0
- package/coverage/lcov-report/controllers/data-filters/bootstrap-data-filter.js.html +146 -0
- package/coverage/lcov-report/controllers/data-filters/call-to-actions-filter.js.html +347 -0
- package/coverage/lcov-report/controllers/data-filters/index.html +126 -0
- package/coverage/lcov-report/controllers/index.html +111 -0
- package/coverage/lcov-report/controllers/index.js.html +1400 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/front-end-utils/src/components/base/ResultItem.js.html +518 -0
- package/coverage/lcov-report/front-end-utils/src/components/base/SearchBar.js.html +452 -0
- package/coverage/lcov-report/front-end-utils/src/components/base/index.html +141 -0
- package/coverage/lcov-report/front-end-utils/src/components/base/item.js.html +458 -0
- package/coverage/lcov-report/front-end-utils/src/components/container.js.html +548 -0
- package/coverage/lcov-report/front-end-utils/src/components/data-view.js.html +383 -0
- package/coverage/lcov-report/front-end-utils/src/components/header-view.js.html +803 -0
- package/coverage/lcov-report/front-end-utils/src/components/index.html +156 -0
- package/coverage/lcov-report/front-end-utils/src/components/search.js.html +977 -0
- package/coverage/lcov-report/front-end-utils/src/constants/index.html +141 -0
- package/coverage/lcov-report/front-end-utils/src/constants/pageUrl.js.html +86 -0
- package/coverage/lcov-report/front-end-utils/src/constants/roleType.js.html +92 -0
- package/coverage/lcov-report/front-end-utils/src/constants/searchType.js.html +164 -0
- package/coverage/lcov-report/front-end-utils/src/utils/debounce.js.html +116 -0
- package/coverage/lcov-report/front-end-utils/src/utils/index.html +111 -0
- package/coverage/lcov-report/index.html +231 -0
- package/coverage/lcov-report/middlewares/config.js.html +188 -0
- package/coverage/lcov-report/middlewares/index.html +111 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +170 -0
- package/coverage/lcov.info +1146 -0
- package/index.js +1 -3
- package/npm-shrinkwrap.json +35 -46
- package/package.json +11 -4
- package/readme.md +24 -2
- package/src/constants/userMock.js +27 -0
- package/src/controllers/index.js +53 -25
- package/src/middlewares/config.js +3 -1
- package/src/tools/compiler-components-prod.js +30 -0
- package/src/tools/toolkit-common-vars.js +1 -1
- package/src/tools/toolkit-components.js +4 -0
- package/src/tools/toolkit-dev-e2e.js +85 -0
- package/src/tools/toolkit-package.js +44 -37
- package/src/tools/toolkit-setup-e2e.js +109 -0
- package/src/tools/zip-theme.js +15 -8
- package/webpack-components.config.js +28 -8
- package/webpack-components.config.prod.js +115 -0
- package/.node-version +0 -1
- 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(
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appdirect/sfb-toolkit",
|
|
3
|
-
"version": "
|
|
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.
|
|
14
|
-
"resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/@appdirect/sfb-theme-plaza/-/sfb-theme-plaza-0.0.
|
|
15
|
-
"integrity": "sha1-
|
|
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.
|
|
19
|
-
"resolved": "https://registry.npmjs.org/@appdirect/storefront-utils/-/storefront-utils-0.0.
|
|
20
|
-
"integrity": "sha512-
|
|
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.
|
|
2733
|
-
"resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/caniuse-lite/-/caniuse-lite-1.0.
|
|
2734
|
-
"integrity": "sha1-
|
|
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",
|
|
@@ -3118,9 +3108,9 @@
|
|
|
3118
3108
|
}
|
|
3119
3109
|
},
|
|
3120
3110
|
"config-chain": {
|
|
3121
|
-
"version": "1.1.
|
|
3122
|
-
"resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/config-chain/-/config-chain-1.1.
|
|
3123
|
-
"integrity": "sha1
|
|
3111
|
+
"version": "1.1.13",
|
|
3112
|
+
"resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/config-chain/-/config-chain-1.1.13.tgz",
|
|
3113
|
+
"integrity": "sha1-+tB5Wqamza/57Rto6d/5Q3LCMvQ=",
|
|
3124
3114
|
"requires": {
|
|
3125
3115
|
"ini": "^1.3.4",
|
|
3126
3116
|
"proto-list": "~1.2.1"
|
|
@@ -5883,22 +5873,16 @@
|
|
|
5883
5873
|
"integrity": "sha1-MTtidN2nGPcU0AszMLuubjjpAgk="
|
|
5884
5874
|
},
|
|
5885
5875
|
"js-beautify": {
|
|
5886
|
-
"version": "1.
|
|
5887
|
-
"resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/js-beautify/-/js-beautify-1.
|
|
5888
|
-
"integrity": "sha1-
|
|
5876
|
+
"version": "1.14.0",
|
|
5877
|
+
"resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/js-beautify/-/js-beautify-1.14.0.tgz",
|
|
5878
|
+
"integrity": "sha1-LOeQxVXVPOHj1zYyJ6z13GkCTC0=",
|
|
5889
5879
|
"requires": {
|
|
5890
5880
|
"config-chain": "^1.1.12",
|
|
5891
5881
|
"editorconfig": "^0.15.3",
|
|
5892
5882
|
"glob": "^7.1.3",
|
|
5893
|
-
"mkdirp": "^1.0.4",
|
|
5894
5883
|
"nopt": "^5.0.0"
|
|
5895
5884
|
},
|
|
5896
5885
|
"dependencies": {
|
|
5897
|
-
"mkdirp": {
|
|
5898
|
-
"version": "1.0.4",
|
|
5899
|
-
"resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/mkdirp/-/mkdirp-1.0.4.tgz",
|
|
5900
|
-
"integrity": "sha1-PrXtYmInVteaXw4qIh3+utdcL34="
|
|
5901
|
-
},
|
|
5902
5886
|
"nopt": {
|
|
5903
5887
|
"version": "5.0.0",
|
|
5904
5888
|
"resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/nopt/-/nopt-5.0.0.tgz",
|
|
@@ -6883,9 +6867,9 @@
|
|
|
6883
6867
|
}
|
|
6884
6868
|
},
|
|
6885
6869
|
"needle": {
|
|
6886
|
-
"version": "2.
|
|
6887
|
-
"resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/needle/-/needle-2.
|
|
6888
|
-
"integrity": "sha1-
|
|
6870
|
+
"version": "2.9.1",
|
|
6871
|
+
"resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/needle/-/needle-2.9.1.tgz",
|
|
6872
|
+
"integrity": "sha1-ItHf++NJDCuD4wH3cJtnNs2PJoQ=",
|
|
6889
6873
|
"requires": {
|
|
6890
6874
|
"debug": "^3.2.6",
|
|
6891
6875
|
"iconv-lite": "^0.4.4",
|
|
@@ -7034,18 +7018,23 @@
|
|
|
7034
7018
|
"osenv": "^0.1.4"
|
|
7035
7019
|
}
|
|
7036
7020
|
},
|
|
7021
|
+
"safe-buffer": {
|
|
7022
|
+
"version": "5.2.1",
|
|
7023
|
+
"resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
|
7024
|
+
"integrity": "sha1-Hq+fqb2x/dTsdfWPnNtOa3gn7sY="
|
|
7025
|
+
},
|
|
7037
7026
|
"tar": {
|
|
7038
|
-
"version": "4.4.
|
|
7039
|
-
"resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/tar/-/tar-4.4.
|
|
7040
|
-
"integrity": "sha1-
|
|
7041
|
-
"requires": {
|
|
7042
|
-
"chownr": "^1.1.
|
|
7043
|
-
"fs-minipass": "^1.2.
|
|
7044
|
-
"minipass": "^2.
|
|
7045
|
-
"minizlib": "^1.
|
|
7046
|
-
"mkdirp": "^0.5.
|
|
7047
|
-
"safe-buffer": "^5.1
|
|
7048
|
-
"yallist": "^3.
|
|
7027
|
+
"version": "4.4.19",
|
|
7028
|
+
"resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/tar/-/tar-4.4.19.tgz",
|
|
7029
|
+
"integrity": "sha1-Lk1yY98m8rkU3uEMglqxMhI3QvM=",
|
|
7030
|
+
"requires": {
|
|
7031
|
+
"chownr": "^1.1.4",
|
|
7032
|
+
"fs-minipass": "^1.2.7",
|
|
7033
|
+
"minipass": "^2.9.0",
|
|
7034
|
+
"minizlib": "^1.3.3",
|
|
7035
|
+
"mkdirp": "^0.5.5",
|
|
7036
|
+
"safe-buffer": "^5.2.1",
|
|
7037
|
+
"yallist": "^3.1.1"
|
|
7049
7038
|
}
|
|
7050
7039
|
},
|
|
7051
7040
|
"yallist": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appdirect/sfb-toolkit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -21,8 +21,9 @@
|
|
|
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
|
-
"test": "jest",
|
|
26
|
+
"test": "jest --coverage",
|
|
26
27
|
"buildToolbar": "webpack --config ./webpack.config.js --mode production",
|
|
27
28
|
"dev": "RUN_ENV=dev concurrently \"npm run watchCSS\" \"npm run devserver\"",
|
|
28
29
|
"start": "RUN_ENV=test concurrently \"npm run watchCSS\" \"npm run devserver\"",
|
|
@@ -35,12 +36,18 @@
|
|
|
35
36
|
"lint": "eslint src tools --ignore-path .eslintignore",
|
|
36
37
|
"lintfix": "eslint src tools --ignore-path .eslintignore --fix",
|
|
37
38
|
"watchCSS": "RUNDEVSERVER=true node src/tools/compiler-css.js",
|
|
38
|
-
"package": "node src/tools/compiler-css.js && node src/tools/package-fonts.js && node src/tools/zip-theme.js"
|
|
39
|
+
"package": "node src/tools/compiler-css.js && node src/tools/package-fonts.js && node src/tools/zip-theme.js",
|
|
40
|
+
"docker:toolkit:build": "DOCKER_TAG=${DOCKER_TAG:=} docker build -t $npm_package_docker_registry/$npm_package_docker_name:$DOCKER_TAG .",
|
|
41
|
+
"docker:toolkit:push": "DOCKER_TAG=${DOCKER_TAG:=} docker push $npm_package_docker_registry/$npm_package_docker_name:$DOCKER_TAG"
|
|
39
42
|
},
|
|
40
43
|
"author": "AppDirect, Inc.",
|
|
44
|
+
"docker": {
|
|
45
|
+
"registry": "docker.appdirect.tools",
|
|
46
|
+
"name": "appdirect/sfb-toolkit"
|
|
47
|
+
},
|
|
41
48
|
"dependencies": {
|
|
42
49
|
"@appdirect/sfb-theme-classic": "0.0.21",
|
|
43
|
-
"@appdirect/sfb-theme-plaza": "0.0.
|
|
50
|
+
"@appdirect/sfb-theme-plaza": "0.0.47",
|
|
44
51
|
"@babel/core": "^7.4.4",
|
|
45
52
|
"@babel/plugin-proposal-class-properties": "^7.4.4",
|
|
46
53
|
"@babel/plugin-transform-runtime": "^7.14.3",
|
package/readme.md
CHANGED
|
@@ -7,8 +7,29 @@ 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
|
+
|
|
22
|
+
**3.0.0**
|
|
23
|
+
- Add new storefront Header & Footer components
|
|
24
|
+
- Add new menu manager in the Visual Editor
|
|
25
|
+
- Update `sfb-theme-components` library to version [0.0.237](https://www.npmjs.com/package/@appdirect/sfb-theme-components/v/0.0.237) and the Plaza theme to meet WCAG 2.1 level AA for accessibility
|
|
26
|
+
- Update `@appdirect/sfb-theme-plaza` to version 0.0.45 ([sfb-theme-mp2@0.0.45](https://www.npmjs.com/package/@appdirect/sfb-theme-plaza/v/0.0.45))
|
|
27
|
+
|
|
28
|
+
**2.0.15**
|
|
29
|
+
- Add new domain cross-selling page in Plaza theme. ([See Documentation](https://help.appdirect.com/products/Default.htm#StorefrontBuilder/sfb-configure-domain-x-sell.htm))
|
|
30
|
+
- Read `crossSellingEnabled` setting from theme to optionally disable cross-selling
|
|
31
|
+
- Update `@appdirect/sfb-theme-plaza` to version 0.0.44 ([sfb-theme-mp2@0.0.44](https://www.npmjs.com/package/@appdirect/sfb-theme-plaza/v/0.0.44))
|
|
32
|
+
|
|
12
33
|
**2.0.14**
|
|
13
34
|
- Fix npm security vulnerabilities when running `sfb-toolkit storybook` and `sfb-toolkit components` commands
|
|
14
35
|
|
|
@@ -70,14 +91,15 @@ It can be easily mixed with eg. HTML, CSS, JavaScript, jQuery, SASS.
|
|
|
70
91
|
**1.1.0**
|
|
71
92
|
- Toolkit is now ready and able to work on Node 12
|
|
72
93
|
|
|
73
|
-
**1.0.0**
|
|
94
|
+
**1.0.0**
|
|
95
|
+
- Initial release
|
|
74
96
|
|
|
75
97
|
### How to use
|
|
76
98
|
The idea behind Toolkit CLI is similar to how `git` CLI have been made.
|
|
77
99
|
Developer can have multiple themes in single environment.
|
|
78
100
|
|
|
79
101
|
|Command|Description|
|
|
80
|
-
|
|
102
|
+
|---|---|
|
|
81
103
|
|`sfb-toolkit setup`|Creates a new project/environment where Developer can store themes|
|
|
82
104
|
|`sfb-toolkit create [name]`|Creates a new theme|
|
|
83
105
|
|`sfb-toolkit checkout [name]`|Changes context to the theme [name]|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const userMock = {
|
|
2
|
+
name: "{Username} LastName",
|
|
3
|
+
isLoggedIn: true,
|
|
4
|
+
email: "Username.lastname@email.com",
|
|
5
|
+
family_name: "{Username}",
|
|
6
|
+
given_name: "LastName",
|
|
7
|
+
roles: [
|
|
8
|
+
"CREATE_QUOTE",
|
|
9
|
+
"USER"
|
|
10
|
+
],
|
|
11
|
+
userUuid: "686e6521-4ed5-4164-a776-00b04c9d73ff",
|
|
12
|
+
hasCustomerContract: false,
|
|
13
|
+
locale: "en_US",
|
|
14
|
+
attributes: {
|
|
15
|
+
HAS_CUSTOMER_CONTRACT: "false"
|
|
16
|
+
},
|
|
17
|
+
companyUuid: "3dc98547-47dd-47bb-9b01-4569be3412e6",
|
|
18
|
+
currency: "USD",
|
|
19
|
+
customUserAttributes: { },
|
|
20
|
+
customerContractEditionUuids: [ ],
|
|
21
|
+
ownedPartners: [ ],
|
|
22
|
+
segments: {
|
|
23
|
+
items: [ ]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = userMock;
|
package/src/controllers/index.js
CHANGED
|
@@ -8,13 +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
|
|
17
|
+
const userMock = require("../constants/userMock")
|
|
18
18
|
|
|
19
19
|
const appendClearCartFunction = html => {
|
|
20
20
|
const clearCartJS = `<script>
|
|
@@ -46,6 +46,7 @@ class Pages {
|
|
|
46
46
|
}) {
|
|
47
47
|
this.req = req
|
|
48
48
|
this.sessionId = req.cookies.JSESSIONID
|
|
49
|
+
this.mockRole = req.cookies.mockRole
|
|
49
50
|
this.id = req.params.id
|
|
50
51
|
this.section = req.params.section
|
|
51
52
|
this.customPath = req.params && req.params[0] && req.params[0].split("/")
|
|
@@ -74,6 +75,14 @@ class Pages {
|
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
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
|
+
|
|
77
86
|
redirectToLocalePage() {
|
|
78
87
|
this.getData(this.config, this.page).then(response => {
|
|
79
88
|
const { data = {} } = response
|
|
@@ -113,8 +122,8 @@ class Pages {
|
|
|
113
122
|
getData(pageSettings) {
|
|
114
123
|
return new Promise(resolve => {
|
|
115
124
|
let { page, locale, currency } = this
|
|
116
|
-
if (page ===
|
|
117
|
-
page =
|
|
125
|
+
if (page === "admin") {
|
|
126
|
+
page = "home"
|
|
118
127
|
}
|
|
119
128
|
const apiURL = API_PATHS[page](
|
|
120
129
|
this.config.marketplacePath,
|
|
@@ -125,7 +134,8 @@ class Pages {
|
|
|
125
134
|
envData: storefrontUtils.getEnvMarketplaceData(
|
|
126
135
|
this.config.marketplacePath,
|
|
127
136
|
this.envData
|
|
128
|
-
)
|
|
137
|
+
),
|
|
138
|
+
currentPage: page
|
|
129
139
|
}),
|
|
130
140
|
storefrontUtils.getQueryData(
|
|
131
141
|
{
|
|
@@ -149,6 +159,9 @@ class Pages {
|
|
|
149
159
|
})
|
|
150
160
|
.then(response => {
|
|
151
161
|
const data = Pages.filterData(response.data)
|
|
162
|
+
if (this.mockRole === "USER") {
|
|
163
|
+
data.config.user = userMock
|
|
164
|
+
}
|
|
152
165
|
this.defaultLocale = data.config.defaultLocale || "en-US"
|
|
153
166
|
resolve({
|
|
154
167
|
config: this.config,
|
|
@@ -193,13 +206,13 @@ class Pages {
|
|
|
193
206
|
try {
|
|
194
207
|
return JSON.parse(
|
|
195
208
|
fs.readFileSync(
|
|
196
|
-
`${currentPath}/themes/${
|
|
197
|
-
this.config.theme
|
|
198
|
-
}/env-data.json`,
|
|
209
|
+
`${currentPath}/themes/${this.config.theme}/env-data.json`,
|
|
199
210
|
"utf8"
|
|
200
211
|
)
|
|
201
212
|
)
|
|
202
|
-
} catch (e) {
|
|
213
|
+
} catch (e) {
|
|
214
|
+
console.log("env data not loading")
|
|
215
|
+
}
|
|
203
216
|
return {}
|
|
204
217
|
}
|
|
205
218
|
|
|
@@ -223,15 +236,13 @@ class Pages {
|
|
|
223
236
|
try {
|
|
224
237
|
return JSON.parse(
|
|
225
238
|
fs.readFileSync(
|
|
226
|
-
`${currentPath}/themes/${
|
|
227
|
-
this.config.theme
|
|
228
|
-
}/settings.json`,
|
|
239
|
+
`${currentPath}/themes/${this.config.theme}/settings.json`,
|
|
229
240
|
"utf8"
|
|
230
241
|
)
|
|
231
242
|
)
|
|
232
|
-
} catch (e) {
|
|
243
|
+
} catch (e) {
|
|
233
244
|
// commented for 2.0.1 release.
|
|
234
|
-
// console.log("settings not loading")
|
|
245
|
+
// console.log("settings not loading")
|
|
235
246
|
}
|
|
236
247
|
return {}
|
|
237
248
|
}
|
|
@@ -307,22 +318,27 @@ class Pages {
|
|
|
307
318
|
}
|
|
308
319
|
|
|
309
320
|
getRawMockTemplates(mockedPages) {
|
|
310
|
-
const mockedPageObject = {}
|
|
311
|
-
const mockedPagesPath = `${__dirname}/../../mockPages
|
|
321
|
+
const mockedPageObject = {}
|
|
322
|
+
const mockedPagesPath = `${__dirname}/../../mockPages`
|
|
312
323
|
mockedPages.forEach(folder => {
|
|
313
324
|
try {
|
|
314
|
-
const htmlContent = fs.readFileSync(
|
|
315
|
-
|
|
325
|
+
const htmlContent = fs.readFileSync(
|
|
326
|
+
`${mockedPagesPath}/${folder}/${folder}.html`,
|
|
327
|
+
"utf8"
|
|
328
|
+
)
|
|
329
|
+
mockedPageObject[folder] = { [`${folder}.html`]: htmlContent }
|
|
316
330
|
} catch (error) {
|
|
317
|
-
console.error(
|
|
331
|
+
console.error(
|
|
332
|
+
`ERROR: could not find ${folder}.html in ${mockedPagesPath}/${folder}`
|
|
333
|
+
)
|
|
318
334
|
}
|
|
319
335
|
})
|
|
320
|
-
return mockedPageObject
|
|
336
|
+
return mockedPageObject
|
|
321
337
|
}
|
|
322
338
|
|
|
323
339
|
getFile(isMockedPage, rawTemplates) {
|
|
324
340
|
if (isMockedPage) {
|
|
325
|
-
return `${this.page}/${this.page}.html
|
|
341
|
+
return `${this.page}/${this.page}.html`
|
|
326
342
|
}
|
|
327
343
|
return storefrontUtils.findPage(rawTemplates, {}, this)
|
|
328
344
|
}
|
|
@@ -335,7 +351,7 @@ class Pages {
|
|
|
335
351
|
rawTemplates = { ...rawTemplates, ...rawMockTemplates }
|
|
336
352
|
const assetsMapperFunc = this.getAssetsMapperFunction()
|
|
337
353
|
const pageSettings = this.layoutEditorSettings.pages
|
|
338
|
-
? this.layoutEditorSettings.pages[this.page] || {}
|
|
354
|
+
? this.layoutEditorSettings.pages[this.getPage(this.page)] || {}
|
|
339
355
|
: {}
|
|
340
356
|
const defaultGlobalStyles = {
|
|
341
357
|
namespaces: {
|
|
@@ -358,12 +374,22 @@ class Pages {
|
|
|
358
374
|
rawTemplates.pages,
|
|
359
375
|
file.split("/")
|
|
360
376
|
)
|
|
361
|
-
|
|
362
|
-
// 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 => {
|
|
363
378
|
if (this.page === "profile") {
|
|
364
|
-
file = storefrontUtils.findPage(
|
|
379
|
+
file = storefrontUtils.findPage(
|
|
380
|
+
rawTemplates,
|
|
381
|
+
data,
|
|
382
|
+
this,
|
|
383
|
+
undefined,
|
|
384
|
+
this.themeSettings
|
|
385
|
+
)
|
|
365
386
|
template = `/pages/${file}`
|
|
366
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)
|
|
367
393
|
storefrontUtils.TplEngine.compile(
|
|
368
394
|
rawTemplates,
|
|
369
395
|
template,
|
|
@@ -384,7 +410,9 @@ class Pages {
|
|
|
384
410
|
html,
|
|
385
411
|
this.themePath,
|
|
386
412
|
this.config.marketplacePath,
|
|
387
|
-
this.themeSettings
|
|
413
|
+
this.themeSettings[
|
|
414
|
+
storefrontUtils.themeSettingsKeys.USE_COMPONENT
|
|
415
|
+
],
|
|
388
416
|
this.layoutEditorSettings,
|
|
389
417
|
this.getLocalization()
|
|
390
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.
|
|
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
|
})();
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const fs = require("fs-extra")
|
|
2
|
+
const { shouldBeProjectFolder } = require("./toolkit-common-fun")
|
|
3
|
+
const { ACTIVE_THEME_PATH } = require("./toolkit-common-vars")
|
|
4
|
+
|
|
5
|
+
shouldBeProjectFolder(true)
|
|
6
|
+
|
|
7
|
+
const addAssetsToBase = (baseFilePath, data) => {
|
|
8
|
+
fs.writeFile(baseFilePath, data, err => {
|
|
9
|
+
if (err)
|
|
10
|
+
return console.error(
|
|
11
|
+
" ERROR: Unable to perform update to add local sfb-components assets."
|
|
12
|
+
.red
|
|
13
|
+
)
|
|
14
|
+
console.log(
|
|
15
|
+
"Successfully installed update to add local sfb-components assets!\nPlease start/restart the toolkit server to observe the changes."
|
|
16
|
+
.green
|
|
17
|
+
)
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const settingsSchemaData = `{ "useComponents": true }`
|
|
22
|
+
;(() => {
|
|
23
|
+
const baseFilePath = `${ACTIVE_THEME_PATH}/content/layout/base.html`
|
|
24
|
+
|
|
25
|
+
if (!fs.existsSync(`${ACTIVE_THEME_PATH}/settings-schema.json`)) {
|
|
26
|
+
fs.writeFile(
|
|
27
|
+
`${ACTIVE_THEME_PATH}/settings-schema.json`,
|
|
28
|
+
settingsSchemaData,
|
|
29
|
+
err => {
|
|
30
|
+
if (err)
|
|
31
|
+
return console.error(
|
|
32
|
+
" ERROR: Unable to create settings-schema.json file.".red
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
fs.readFile(baseFilePath, "utf8", (err, data) => {
|
|
39
|
+
if (err)
|
|
40
|
+
return console.error(
|
|
41
|
+
` ERROR: Unable to read the base layout file. Tried: ${baseFilePath}`
|
|
42
|
+
.red
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
const cdnComponents = data.match(
|
|
46
|
+
/\S+.+channelCanonicalBaseUrl.+(css|js).+/g
|
|
47
|
+
)
|
|
48
|
+
const assetsComponents = data.match(
|
|
49
|
+
/\S+.+r\(.+assets.+sfb-components.+(css|js).+/g
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
const sfbComponentsLocalBaseUrl = "http://localhost:3444"
|
|
53
|
+
|
|
54
|
+
if (cdnComponents !== null) {
|
|
55
|
+
data = data.replace(
|
|
56
|
+
/\S+.+channelCanonicalBaseUrl.+css.+/,
|
|
57
|
+
`<link rel="stylesheet" type="text/css" href="${sfbComponentsLocalBaseUrl}/sfb-components.css">`
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
data = data.replace(
|
|
61
|
+
/\S+.+channelCanonicalBaseUrl.+js.+/,
|
|
62
|
+
`<script src="${sfbComponentsLocalBaseUrl}/sfb-components.js"></script>`
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
addAssetsToBase(baseFilePath, data)
|
|
66
|
+
} else if (assetsComponents === null) {
|
|
67
|
+
const headElemIndex = data.indexOf("</head>")
|
|
68
|
+
const output =
|
|
69
|
+
`${data.substring(
|
|
70
|
+
0,
|
|
71
|
+
headElemIndex
|
|
72
|
+
)} <link rel="stylesheet" type="text/css" href="${sfbComponentsLocalBaseUrl}/sfb-components.css">\n` +
|
|
73
|
+
` <script src="${sfbComponentsLocalBaseUrl}/sfb-components.js"></script>\n${data.substring(
|
|
74
|
+
headElemIndex
|
|
75
|
+
)}`
|
|
76
|
+
|
|
77
|
+
addAssetsToBase(baseFilePath, output)
|
|
78
|
+
} else {
|
|
79
|
+
console.log(
|
|
80
|
+
"Theme is already setup to use local sfb-components dev server assets."
|
|
81
|
+
.green
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
})()
|