@appdirect/sfb-toolkit 2.0.12 → 3.0.0

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 (55) hide show
  1. package/Dockerfile +26 -0
  2. package/bin/index.js +191 -189
  3. package/commands.sh +2 -0
  4. package/coverage/clover.xml +567 -0
  5. package/coverage/coverage-final.json +19 -0
  6. package/coverage/lcov-report/base.css +224 -0
  7. package/coverage/lcov-report/block-navigation.js +79 -0
  8. package/coverage/lcov-report/constants/index.html +126 -0
  9. package/coverage/lcov-report/constants/pageUrls.js.html +98 -0
  10. package/coverage/lcov-report/constants/userMock.js.html +158 -0
  11. package/coverage/lcov-report/controllers/controllers-utils/assetsUtils.js.html +173 -0
  12. package/coverage/lcov-report/controllers/controllers-utils/index.html +111 -0
  13. package/coverage/lcov-report/controllers/data-filters/bootstrap-data-filter.js.html +146 -0
  14. package/coverage/lcov-report/controllers/data-filters/call-to-actions-filter.js.html +347 -0
  15. package/coverage/lcov-report/controllers/data-filters/index.html +126 -0
  16. package/coverage/lcov-report/controllers/index.html +111 -0
  17. package/coverage/lcov-report/controllers/index.js.html +1331 -0
  18. package/coverage/lcov-report/favicon.png +0 -0
  19. package/coverage/lcov-report/front-end-utils/src/components/base/ResultItem.js.html +518 -0
  20. package/coverage/lcov-report/front-end-utils/src/components/base/SearchBar.js.html +452 -0
  21. package/coverage/lcov-report/front-end-utils/src/components/base/index.html +141 -0
  22. package/coverage/lcov-report/front-end-utils/src/components/base/item.js.html +458 -0
  23. package/coverage/lcov-report/front-end-utils/src/components/container.js.html +548 -0
  24. package/coverage/lcov-report/front-end-utils/src/components/data-view.js.html +383 -0
  25. package/coverage/lcov-report/front-end-utils/src/components/header-view.js.html +803 -0
  26. package/coverage/lcov-report/front-end-utils/src/components/index.html +156 -0
  27. package/coverage/lcov-report/front-end-utils/src/components/search.js.html +977 -0
  28. package/coverage/lcov-report/front-end-utils/src/constants/index.html +141 -0
  29. package/coverage/lcov-report/front-end-utils/src/constants/pageUrl.js.html +86 -0
  30. package/coverage/lcov-report/front-end-utils/src/constants/roleType.js.html +92 -0
  31. package/coverage/lcov-report/front-end-utils/src/constants/searchType.js.html +164 -0
  32. package/coverage/lcov-report/front-end-utils/src/utils/debounce.js.html +116 -0
  33. package/coverage/lcov-report/front-end-utils/src/utils/index.html +111 -0
  34. package/coverage/lcov-report/index.html +231 -0
  35. package/coverage/lcov-report/middlewares/config.js.html +182 -0
  36. package/coverage/lcov-report/middlewares/index.html +111 -0
  37. package/coverage/lcov-report/prettify.css +1 -0
  38. package/coverage/lcov-report/prettify.js +2 -0
  39. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  40. package/coverage/lcov-report/sorter.js +170 -0
  41. package/coverage/lcov.info +1132 -0
  42. package/npm-shrinkwrap.json +29 -30
  43. package/package.json +10 -4
  44. package/readme.md +17 -0
  45. package/src/constants/userMock.js +27 -0
  46. package/src/controllers/index.js +9 -1
  47. package/src/tools/prompt-questions.js +7 -1
  48. package/src/tools/toolkit-common-fun.js +26 -2
  49. package/src/tools/toolkit-common-vars.js +11 -4
  50. package/src/tools/toolkit-components.js +1 -1
  51. package/src/tools/toolkit-create.js +17 -1
  52. package/src/tools/toolkit-dev-e2e.js +85 -0
  53. package/src/tools/toolkit-install.js +1 -1
  54. package/src/tools/toolkit-setup-e2e.js +109 -0
  55. package/src/tools/toolkit-storybook.js +5 -3
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appdirect/sfb-toolkit",
3
- "version": "2.0.12",
3
+ "version": "3.0.0",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
@@ -10,9 +10,9 @@
10
10
  "integrity": "sha1-r5sX3a3DE3JXYDbIdgu668lvZPw="
11
11
  },
12
12
  "@appdirect/sfb-theme-plaza": {
13
- "version": "0.0.43",
14
- "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/@appdirect/sfb-theme-plaza/-/sfb-theme-plaza-0.0.43.tgz",
15
- "integrity": "sha1-N0ktxaN62bTTldKl/mT8gsEWLGw="
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="
16
16
  },
17
17
  "@appdirect/storefront-utils": {
18
18
  "version": "0.0.101",
@@ -3118,9 +3118,9 @@
3118
3118
  }
3119
3119
  },
3120
3120
  "config-chain": {
3121
- "version": "1.1.12",
3122
- "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/config-chain/-/config-chain-1.1.12.tgz",
3123
- "integrity": "sha1-D96NCRIA616AjK8l/mGMAvSOTvo=",
3121
+ "version": "1.1.13",
3122
+ "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/config-chain/-/config-chain-1.1.13.tgz",
3123
+ "integrity": "sha1-+tB5Wqamza/57Rto6d/5Q3LCMvQ=",
3124
3124
  "requires": {
3125
3125
  "ini": "^1.3.4",
3126
3126
  "proto-list": "~1.2.1"
@@ -5883,22 +5883,16 @@
5883
5883
  "integrity": "sha1-MTtidN2nGPcU0AszMLuubjjpAgk="
5884
5884
  },
5885
5885
  "js-beautify": {
5886
- "version": "1.13.13",
5887
- "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/js-beautify/-/js-beautify-1.13.13.tgz",
5888
- "integrity": "sha1-dWkH0XKPMp8rhMQu/VatF1FGIL8=",
5886
+ "version": "1.14.0",
5887
+ "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/js-beautify/-/js-beautify-1.14.0.tgz",
5888
+ "integrity": "sha1-LOeQxVXVPOHj1zYyJ6z13GkCTC0=",
5889
5889
  "requires": {
5890
5890
  "config-chain": "^1.1.12",
5891
5891
  "editorconfig": "^0.15.3",
5892
5892
  "glob": "^7.1.3",
5893
- "mkdirp": "^1.0.4",
5894
5893
  "nopt": "^5.0.0"
5895
5894
  },
5896
5895
  "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
5896
  "nopt": {
5903
5897
  "version": "5.0.0",
5904
5898
  "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/nopt/-/nopt-5.0.0.tgz",
@@ -6883,9 +6877,9 @@
6883
6877
  }
6884
6878
  },
6885
6879
  "needle": {
6886
- "version": "2.6.0",
6887
- "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/needle/-/needle-2.6.0.tgz",
6888
- "integrity": "sha1-JNu1XyUJ4jJLSpnWH0E5ggE8zb4=",
6880
+ "version": "2.9.1",
6881
+ "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/needle/-/needle-2.9.1.tgz",
6882
+ "integrity": "sha1-ItHf++NJDCuD4wH3cJtnNs2PJoQ=",
6889
6883
  "requires": {
6890
6884
  "debug": "^3.2.6",
6891
6885
  "iconv-lite": "^0.4.4",
@@ -7034,18 +7028,23 @@
7034
7028
  "osenv": "^0.1.4"
7035
7029
  }
7036
7030
  },
7031
+ "safe-buffer": {
7032
+ "version": "5.2.1",
7033
+ "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/safe-buffer/-/safe-buffer-5.2.1.tgz",
7034
+ "integrity": "sha1-Hq+fqb2x/dTsdfWPnNtOa3gn7sY="
7035
+ },
7037
7036
  "tar": {
7038
- "version": "4.4.13",
7039
- "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/tar/-/tar-4.4.13.tgz",
7040
- "integrity": "sha1-Q7NkvFKIjVVSmGN7ENYHkCVKtSU=",
7041
- "requires": {
7042
- "chownr": "^1.1.1",
7043
- "fs-minipass": "^1.2.5",
7044
- "minipass": "^2.8.6",
7045
- "minizlib": "^1.2.1",
7046
- "mkdirp": "^0.5.0",
7047
- "safe-buffer": "^5.1.2",
7048
- "yallist": "^3.0.3"
7037
+ "version": "4.4.19",
7038
+ "resolved": "https://artifactory.appdirect.tools/artifactory/api/npm/npm-repo/tar/-/tar-4.4.19.tgz",
7039
+ "integrity": "sha1-Lk1yY98m8rkU3uEMglqxMhI3QvM=",
7040
+ "requires": {
7041
+ "chownr": "^1.1.4",
7042
+ "fs-minipass": "^1.2.7",
7043
+ "minipass": "^2.9.0",
7044
+ "minizlib": "^1.3.3",
7045
+ "mkdirp": "^0.5.5",
7046
+ "safe-buffer": "^5.2.1",
7047
+ "yallist": "^3.1.1"
7049
7048
  }
7050
7049
  },
7051
7050
  "yallist": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appdirect/sfb-toolkit",
3
- "version": "2.0.12",
3
+ "version": "3.0.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -22,7 +22,7 @@
22
22
  }
23
23
  },
24
24
  "scripts": {
25
- "test": "jest",
25
+ "test": "jest --coverage",
26
26
  "buildToolbar": "webpack --config ./webpack.config.js --mode production",
27
27
  "dev": "RUN_ENV=dev concurrently \"npm run watchCSS\" \"npm run devserver\"",
28
28
  "start": "RUN_ENV=test concurrently \"npm run watchCSS\" \"npm run devserver\"",
@@ -35,12 +35,18 @@
35
35
  "lint": "eslint src tools --ignore-path .eslintignore",
36
36
  "lintfix": "eslint src tools --ignore-path .eslintignore --fix",
37
37
  "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"
38
+ "package": "node src/tools/compiler-css.js && node src/tools/package-fonts.js && node src/tools/zip-theme.js",
39
+ "docker:toolkit:build": "DOCKER_TAG=${DOCKER_TAG:=} docker build -t $npm_package_docker_registry/$npm_package_docker_name:$DOCKER_TAG .",
40
+ "docker:toolkit:push": "DOCKER_TAG=${DOCKER_TAG:=} docker push $npm_package_docker_registry/$npm_package_docker_name:$DOCKER_TAG"
39
41
  },
40
42
  "author": "AppDirect, Inc.",
43
+ "docker": {
44
+ "registry": "docker.appdirect.tools",
45
+ "name": "appdirect/sfb-toolkit"
46
+ },
41
47
  "dependencies": {
42
48
  "@appdirect/sfb-theme-classic": "0.0.21",
43
- "@appdirect/sfb-theme-plaza": "0.0.43",
49
+ "@appdirect/sfb-theme-plaza": "0.0.45",
44
50
  "@babel/core": "^7.4.4",
45
51
  "@babel/plugin-proposal-class-properties": "^7.4.4",
46
52
  "@babel/plugin-transform-runtime": "^7.14.3",
package/readme.md CHANGED
@@ -9,6 +9,23 @@ It can be easily mixed with eg. HTML, CSS, JavaScript, jQuery, SASS.
9
9
  * Node 10.x or 12.x
10
10
  ### Release Notes:
11
11
 
12
+ **3.0.0**
13
+ - Add new storefront Header & Footer components
14
+ - Add new menu manager in the Visual Editor
15
+ - 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
16
+ - 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))
17
+
18
+ **2.0.15**
19
+ - 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))
20
+ - Read `crossSellingEnabled` setting from theme to optionally disable cross-selling
21
+ - 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))
22
+
23
+ **2.0.14**
24
+ - Fix npm security vulnerabilities when running `sfb-toolkit storybook` and `sfb-toolkit components` commands
25
+
26
+ **2.0.13**
27
+ - Customize CTA labels and `i18n` object in the theme ([See Documentation](https://help.appdirect.com/platform/Default.htm#StorefrontBuilder/sfb-override-labels.htm%3FTocPath%3DCustomize%2520the%2520storefront%7CWork%2520with%2520the%2520Storefront%2520Toolkit%7C_____10))
28
+
12
29
  **2.0.10**
13
30
  - Bug fix: `sfb-toolkit storybook` command throws an error
14
31
 
@@ -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;
@@ -15,6 +15,7 @@ const buildHeaderAssets = require("./controllers-utils/assetsUtils")
15
15
 
16
16
  const currentPath = process.cwd()
17
17
  const API_PATHS = storefrontUtils.pageApi
18
+ const userMock = require("../constants/userMock");
18
19
 
19
20
  const appendClearCartFunction = html => {
20
21
  const clearCartJS = `<script>
@@ -46,6 +47,7 @@ class Pages {
46
47
  }) {
47
48
  this.req = req
48
49
  this.sessionId = req.cookies.JSESSIONID
50
+ this.mockRole = req.cookies.mockRole
49
51
  this.id = req.params.id
50
52
  this.section = req.params.section
51
53
  this.customPath = req.params && req.params[0] && req.params[0].split("/")
@@ -136,7 +138,10 @@ class Pages {
136
138
  page,
137
139
  ...this.req.params
138
140
  },
139
- this.req.query
141
+ {
142
+ ...this.req.query,
143
+ crossSellingEnabled: this.themeSettings.crossSellingEnabled
144
+ }
140
145
  )
141
146
  )
142
147
  axios
@@ -146,6 +151,9 @@ class Pages {
146
151
  })
147
152
  .then(response => {
148
153
  const data = Pages.filterData(response.data)
154
+ if (this.mockRole === 'USER') {
155
+ data.config.user = userMock;
156
+ }
149
157
  this.defaultLocale = data.config.defaultLocale || "en-US"
150
158
  resolve({
151
159
  config: this.config,
@@ -1,7 +1,7 @@
1
1
  const fs = require("fs")
2
2
  const inquirer = require("inquirer")
3
3
  const axios = require("axios")
4
- const { TOOLKIT_GLOBAL_CONFIG, THEME_TEMPLATES} = require("./toolkit-common-vars")
4
+ const { TOOLKIT_GLOBAL_CONFIG, THEME_TEMPLATES, WHO_ARE_YOU_PROMPT} = require("./toolkit-common-vars")
5
5
 
6
6
  // small function to check if item has been defined
7
7
  const isDefined = answer => !!answer
@@ -111,6 +111,12 @@ const QUESTIONS = [
111
111
  message: "Choose a marketplace theme as a starting point:",
112
112
  choices: THEME_TEMPLATES
113
113
  },
114
+ {
115
+ type: "list",
116
+ name: "WhoAreYou",
117
+ message: "Please indicate which option most closely represents who you are:",
118
+ choices: WHO_ARE_YOU_PROMPT
119
+ },
114
120
  {
115
121
  type: "confirm",
116
122
  name: "PackSettingsChoice",
@@ -110,7 +110,7 @@ const installSfbThemeComponents = () => {
110
110
 
111
111
  // check if sfb-theme-components is installed otherwise install it
112
112
  spawnSync('npm',
113
- [`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}`], {
113
+ [`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`], {
114
114
  cwd: ACTIVE_THEME_PATH,
115
115
  stdio: "inherit",
116
116
  shell: true
@@ -129,6 +129,29 @@ const createPackageJson = () => {
129
129
  }
130
130
  }
131
131
 
132
+ const createCustomThemePacakgeJson = (themeName, themePackageName, createdBy) => {
133
+ const toolkitPackageJson = JSON.parse(fs.readFileSync(`${TOOLKIT_PATH}/package.json`));
134
+ const version = toolkitPackageJson.dependencies[`${themePackageName}`];
135
+ const customThemePackageJson = {
136
+ "name": themeName.toLocaleLowerCase(),
137
+ "version": version,
138
+ "description": "",
139
+ "metadata": {
140
+ "toolkitVersion": toolkitPackageJson.version,
141
+ "themeTemplate": themePackageName,
142
+ "themeVersion": version,
143
+ "createdBy": createdBy,
144
+ "createdAt": new Date()
145
+ },
146
+ "scripts": {},
147
+ "keywords": [],
148
+ "author": "",
149
+ "license": "ISC",
150
+ "dependencies": {}
151
+ }
152
+ return JSON.stringify(customThemePackageJson, null, 2);
153
+ }
154
+
132
155
  module.exports = {
133
156
  selfDestruction,
134
157
  filesCounter,
@@ -139,5 +162,6 @@ module.exports = {
139
162
  versionCheck,
140
163
  installSfbThemeComponents,
141
164
  createPackageJson,
142
- createThemeLogsFolder
165
+ createThemeLogsFolder,
166
+ createCustomThemePacakgeJson
143
167
  }
@@ -11,11 +11,11 @@ const COMPILERCSS_PATH = "src/tools/compiler-css.js"
11
11
 
12
12
  const TOOLKIT_GLOBAL_CONFIG_PATH = `${TOOLKIT_PATH}/src/tools/.sfbconfig`;
13
13
  const TOOLKIT_GLOBAL_CONFIG = JSON.parse(fs.readFileSync(TOOLKIT_GLOBAL_CONFIG_PATH));
14
- const THEME_TEMPLATES_CONFIG_PATH = `${TOOLKIT_PATH}/themes-config.json`;
15
- const THEME_TEMPLATES = JSON.parse(fs.readFileSync(THEME_TEMPLATES_CONFIG_PATH));
14
+ const THEME_TEMPLATES_CONFIG_PATH = `${TOOLKIT_PATH}/themes-config.json`;
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.203";
18
+ const THEME_COMPONENT_VERSION = "0.0.237";
19
19
 
20
20
  let WORKSPACE_CONFIG;
21
21
  try {
@@ -28,6 +28,12 @@ const ACTIVE_THEME_PATH = `${CURRENT_PATH}/themes/${ACTIVE_THEME}`;
28
28
  const THEME_LOGS_PATH = `${CURRENT_PATH}/theme-logs`;
29
29
  const THEME_LOGS_FILE_PATH = `${THEME_LOGS_PATH}/${ACTIVE_THEME}`;
30
30
 
31
+ const WHO_ARE_YOU_PROMPT = [
32
+ { "name": "customer" },
33
+ { "name": "AppDirect DTS" },
34
+ { "name": "external dev" }
35
+ ]
36
+
31
37
  module.exports = {
32
38
  TOOLKIT_GLOBAL_CONFIG,
33
39
  BOOTSTRAP_FOLDERS,
@@ -45,5 +51,6 @@ module.exports = {
45
51
  THEME_COMPONENT_MODULE,
46
52
  THEME_COMPONENT_VERSION,
47
53
  THEME_LOGS_PATH,
48
- THEME_LOGS_FILE_PATH
54
+ THEME_LOGS_FILE_PATH,
55
+ WHO_ARE_YOU_PROMPT
49
56
  }
@@ -35,7 +35,7 @@ const settingsSchemaData = `{ "useComponents": true }`;
35
35
  }
36
36
 
37
37
  fs.readFile(baseFilePath, 'utf8', (err, data) => {
38
- if (err) return console.error(' ERROR: Unable to read the file.'.red);
38
+ if (err) return console.error(` ERROR: Unable to read the base layout file. Tried: ${baseFilePath}`.red);
39
39
 
40
40
  const cdnComponents = data.match(/\S+.+channelCanonicalBaseUrl.+(css|js).+/g);
41
41
  const assetsComponents = data.match(/\S+.+r\(.+assets.+sfb-components.+(css|js).+/g)
@@ -5,7 +5,7 @@ const colors = require("colors")
5
5
  const prompt = require("./prompt-questions");
6
6
 
7
7
  const { CURRENT_PATH, TOOLKIT_PATH, COMMAND_PARAM, COMPILERCSS_PATH, PAGE_OBJECTS_SUFFIX } = require("./toolkit-common-vars");
8
- const { shouldBeProjectFolder, getAvailableFolderWithPrompt } = require("./toolkit-common-fun");
8
+ const { shouldBeProjectFolder, getAvailableFolderWithPrompt, createCustomThemePacakgeJson } = require("./toolkit-common-fun");
9
9
  const { LOCAL_CONFIG } = require("./toolkit-config");
10
10
 
11
11
  shouldBeProjectFolder(true);
@@ -14,6 +14,8 @@ shouldBeProjectFolder(true);
14
14
  let themesPath = `${CURRENT_PATH}/themes/`; // by default
15
15
  let themeName = COMMAND_PARAM;
16
16
  let userThemeAnswer
17
+ const themeCreatedBy = await prompt.ask(["WhoAreYou"]);
18
+
17
19
 
18
20
  try {
19
21
  userThemeAnswer = await prompt.ask(["ThemeTemplates"]);
@@ -46,6 +48,20 @@ shouldBeProjectFolder(true);
46
48
  process.exit(1);
47
49
  }
48
50
 
51
+ try{
52
+ fs.writeFileSync(
53
+ `${themesPath}/package.json`,
54
+ createCustomThemePacakgeJson(
55
+ themeName,
56
+ userThemeAnswer.ThemeTemplates.dependency,
57
+ themeCreatedBy.WhoAreYou
58
+ )
59
+ );
60
+ } catch(err) {
61
+ console.error(` ERROR: Unable to create ${themeName}'s package.json file.`.red);
62
+ process.exit(1);
63
+ }
64
+
49
65
  let newConfig = {};
50
66
  try {
51
67
  const projectData = LOCAL_CONFIG.read();
@@ -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
+ })()
@@ -14,7 +14,7 @@ if(npmModule === 'undefined'){
14
14
  createPackageJson();
15
15
 
16
16
  spawn('npm',
17
- [`install --save ${npmModule}`], {
17
+ [`install --save ${npmModule} --production`], {
18
18
  cwd: ACTIVE_THEME_PATH,
19
19
  stdio: "inherit",
20
20
  shell: true
@@ -0,0 +1,109 @@
1
+ const fs = require("fs")
2
+ const { copy, remove } = require("fs-extra")
3
+
4
+ const {
5
+ CURRENT_PATH,
6
+ TOOLKIT_PATH,
7
+ COMMAND_PARAM,
8
+ BOOTSTRAP_FOLDERS,
9
+ CONFIG_PATH,
10
+ PAGE_OBJECTS_SUFFIX
11
+ } = require("./toolkit-common-vars")
12
+ const {
13
+ selfDestruction,
14
+ shouldBeProjectFolder,
15
+ getAvailableFolderWithPrompt,
16
+ versionCheck
17
+ } = require("./toolkit-common-fun")
18
+ const { LOCAL_CONFIG } = require("./toolkit-config")
19
+
20
+ const projectName = COMMAND_PARAM // [optional] project name
21
+
22
+ const freshLocalConfig = {
23
+ namespaces: [],
24
+ defaultValues: {}
25
+ }
26
+ ;(async () => {
27
+ shouldBeProjectFolder(false)
28
+
29
+ await versionCheck()
30
+
31
+ // Determine project's dir path
32
+ let projectPath = `${CURRENT_PATH}/` // by default
33
+ projectPath = await getAvailableFolderWithPrompt(
34
+ CURRENT_PATH,
35
+ projectName,
36
+ "ProjectName"
37
+ )
38
+
39
+ freshLocalConfig.projectName = projectPath.replace(`${CURRENT_PATH}/`, "")
40
+
41
+ // create bootstrap folders
42
+ BOOTSTRAP_FOLDERS.forEach(folderName => {
43
+ if (!fs.existsSync(`${projectPath}/${folderName}`)) {
44
+ fs.mkdirSync(`${projectPath}/${folderName}`)
45
+ }
46
+ })
47
+
48
+ // copy theme folder
49
+ try {
50
+ await copy(
51
+ `${TOOLKIT_PATH}/node_modules/@appdirect/sfb-theme-plaza`,
52
+ `${projectPath}/themes/Plaza`
53
+ )
54
+ await remove(`${projectPath}/themes/Plaza/package.json`)
55
+ freshLocalConfig.defaultValues.themeName = projectName
56
+ } catch (err) {
57
+ console.error(` Could not create theme folder due to: \n ${err}`.red)
58
+ selfDestruction(projectPath) // revert changes
59
+ process.exit(1)
60
+ }
61
+
62
+ // copy config/index.js file
63
+ try {
64
+ await copy(
65
+ `${TOOLKIT_PATH}/${CONFIG_PATH}`,
66
+ `${projectPath}/${CONFIG_PATH}`
67
+ )
68
+ const marketplacePath = "https://marketplace.appdirect.com"
69
+ freshLocalConfig.defaultValues.marketplacePath = marketplacePath
70
+ freshLocalConfig.defaultValues.pageObjectsPath = `${marketplacePath}${PAGE_OBJECTS_SUFFIX}`
71
+ } catch (err) {
72
+ console.error(` Couldn't copy config file due to: \n ${err}`.red)
73
+ selfDestruction(projectPath) // revert changes
74
+ process.exit(1)
75
+ }
76
+
77
+ freshLocalConfig.current = freshLocalConfig.defaultValues.themeName
78
+ freshLocalConfig.namespaces.push(freshLocalConfig.defaultValues)
79
+ freshLocalConfig.created = new Date()
80
+ freshLocalConfig.modified = new Date()
81
+
82
+ try {
83
+ LOCAL_CONFIG.save(freshLocalConfig, projectPath)
84
+ } catch (err) {
85
+ console.error(` ERROR: Unable to save config file due to: \n ${err}`.red)
86
+ process.exit(1)
87
+ }
88
+
89
+ try {
90
+ LOCAL_CONFIG.configFileUpdate(projectPath)
91
+ console.log(
92
+ ` Project context switched to ${freshLocalConfig.current}.`.green
93
+ )
94
+ } catch (err) {
95
+ console.error(
96
+ ` ERROR: Unable to switch context to ${
97
+ freshLocalConfig.current
98
+ } due to: ${err}`.red
99
+ )
100
+ process.exit(1)
101
+ }
102
+
103
+ console.log(` Theme location: ${projectPath}/`.green)
104
+ console.log(` Configuration file location: ${projectPath}/config/`.green)
105
+ console.log(
106
+ `\n All done! You can start your server by running \`sfb-toolkit start\` inside the project root folder: ${projectPath}\n`
107
+ .green
108
+ )
109
+ })()
@@ -8,11 +8,13 @@ const storybookDependencies = [
8
8
  "@babel/core@7.14.0",
9
9
  "@babel/plugin-proposal-class-properties@7.13.0",
10
10
  "@babel/preset-env@7.14.1",
11
- "@storybook/addon-actions@6.2.9",
11
+ "@storybook/addon-actions@6.3.1",
12
12
  "@storybook/addon-essentials@6.2.9",
13
13
  "@storybook/addon-knobs@6.2.9",
14
14
  "@storybook/addon-links@6.2.9",
15
- "@storybook/react@6.2.9",
15
+ "@storybook/addon-a11y@6.3.1",
16
+ "@storybook/addon-docs@6.3.1",
17
+ "@storybook/react@6.3.1",
16
18
  "babel-loader@8.2.2",
17
19
  "core-js@3.12.1",
18
20
  "preset-react@1.0.0",
@@ -37,7 +39,7 @@ const storybookModule = "@storybook/react";
37
39
 
38
40
  // check if storybook module is installed otherwise install storybook dependencies
39
41
  spawnSync('npm',
40
- [`ls ${storybookModule} 2>&1 | (findstr ${storybookModule} || grep ${storybookModule}) > ${THEME_LOGS_FILE_PATH} 2>&1 || npm i -S ${storybookDependencies}`], {
42
+ [`ls ${storybookModule} 2>&1 | (findstr ${storybookModule} || grep ${storybookModule}) > ${THEME_LOGS_FILE_PATH} 2>&1 || npm i -S ${storybookDependencies} --production`], {
41
43
  cwd: ACTIVE_THEME_PATH,
42
44
  stdio: "inherit",
43
45
  shell: true