@appdirect/sfb-toolkit 3.0.0 → 3.0.4

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 (49) hide show
  1. package/coverage/clover.xml +157 -148
  2. package/coverage/coverage-final.json +6 -5
  3. package/coverage/lcov-report/constants/customUserAttributesMock.js.html +491 -0
  4. package/coverage/lcov-report/constants/index.html +20 -5
  5. package/coverage/lcov-report/constants/pageUrls.js.html +2 -2
  6. package/coverage/lcov-report/constants/userMock.js.html +29 -29
  7. package/coverage/lcov-report/controllers/controllers-utils/assetsUtils.js.html +8 -8
  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 +18 -18
  13. package/coverage/lcov-report/controllers/index.js.html +145 -76
  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 +20 -20
  30. package/coverage/lcov-report/middlewares/config.js.html +9 -3
  31. package/coverage/lcov-report/middlewares/index.html +1 -1
  32. package/coverage/lcov.info +284 -258
  33. package/index.js +1 -3
  34. package/npm-shrinkwrap.json +24 -29
  35. package/package.json +3 -2
  36. package/readme.md +18 -2
  37. package/src/constants/customUserAttributesMock.js +137 -0
  38. package/src/constants/userMock.js +22 -23
  39. package/src/controllers/index.js +52 -29
  40. package/src/middlewares/config.js +3 -1
  41. package/src/tools/compiler-components-prod.js +30 -0
  42. package/src/tools/toolkit-common-vars.js +1 -1
  43. package/src/tools/toolkit-components.js +4 -0
  44. package/src/tools/toolkit-package.js +44 -37
  45. package/src/tools/zip-theme.js +15 -8
  46. package/webpack-components.config.js +28 -8
  47. package/webpack-components.config.prod.js +115 -0
  48. package/.node-version +0 -1
  49. package/src/tools/compiler-components.js +0 -25
@@ -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: [
@@ -0,0 +1,115 @@
1
+ const path = require("path")
2
+ const MiniCssExtractPlugin = require("mini-css-extract-plugin")
3
+
4
+ module.exports = (currentPath, config) => {
5
+ const assetPath = path.resolve(
6
+ currentPath,
7
+ `themes/${config.theme}/assets/js/components`
8
+ )
9
+
10
+ return {
11
+ entry: [
12
+ path.resolve(
13
+ currentPath,
14
+ `themes/${config.theme}/customComponents/index.js`
15
+ )
16
+ ],
17
+ mode: "production",
18
+ output: {
19
+ library: "__ADComponents",
20
+ libraryTarget: "var",
21
+ filename: "sfb-components.js",
22
+ path: assetPath
23
+ },
24
+ plugins: [
25
+ new MiniCssExtractPlugin({
26
+ filename: "sfb-components.css"
27
+ })
28
+ ],
29
+ module: {
30
+ rules: [
31
+ {
32
+ test: /\.(js|jsx)$/,
33
+ use: {
34
+ loader: "babel-loader",
35
+ options: {
36
+ presets: [
37
+ require.resolve("@babel/preset-env"),
38
+ require.resolve("@babel/preset-react")
39
+ ],
40
+ plugins: [
41
+ require.resolve("@babel/plugin-proposal-class-properties"),
42
+ require.resolve("@babel/plugin-transform-runtime")
43
+ ],
44
+ include: [
45
+ path.resolve(
46
+ currentPath,
47
+ `themes/${config.theme}/customComponents`
48
+ ),
49
+ path.resolve(
50
+ currentPath,
51
+ `themes/${
52
+ config.theme
53
+ }/node_modules/@appdirect/sfb-theme-components`
54
+ )
55
+ ]
56
+ }
57
+ }
58
+ },
59
+ {
60
+ test: /\.(sa|sc|c)ss$/,
61
+ use: [
62
+ MiniCssExtractPlugin.loader,
63
+ { loader: "css-loader" },
64
+ { loader: "sass-loader" }
65
+ ]
66
+ },
67
+ {
68
+ test: /\.(png|gif|jpg|svg)$/,
69
+ use: {
70
+ loader: "url-loader",
71
+ options: {
72
+ limit: 50000
73
+ }
74
+ }
75
+ },
76
+ {
77
+ test: /\.(woff(2)?|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
78
+ use: [
79
+ {
80
+ loader: "file-loader",
81
+ options: {
82
+ name: "[name].[ext]",
83
+ outputPath: "fonts/"
84
+ }
85
+ }
86
+ ]
87
+ }
88
+ ]
89
+ },
90
+ resolve: {
91
+ modules: [
92
+ path.resolve(currentPath, "node_modules"),
93
+ path.resolve(__dirname, "node_modules"),
94
+ path.resolve(currentPath, `themes/${config.theme}/node_modules`)
95
+ ],
96
+ extensions: [
97
+ ".scss",
98
+ ".js",
99
+ ".jsx",
100
+ ".json",
101
+ ".png",
102
+ ".gif",
103
+ ".jpg",
104
+ ".svg"
105
+ ]
106
+ },
107
+ resolveLoader: {
108
+ modules: [
109
+ path.resolve(currentPath, "node_modules"),
110
+ path.resolve(__dirname, "node_modules"),
111
+ path.resolve(currentPath, `themes/${config.theme}/node_modules`)
112
+ ]
113
+ }
114
+ }
115
+ }
package/.node-version DELETED
@@ -1 +0,0 @@
1
- 8.9.4
@@ -1,25 +0,0 @@
1
- const webpack = require("webpack")
2
- const fs = require("fs")
3
- const { TOOLKIT_PATH } = require("./toolkit-common-vars")
4
-
5
- const getConfigComponentsWebpack = require(`${TOOLKIT_PATH}/webpack-components.config`)
6
- const currentPath = process.cwd() // used to get current dev folder
7
- const config = require(`${currentPath}/config`)
8
-
9
- fs.exists(
10
- `${currentPath}/themes/${config.theme}/components/index.js`,
11
- exist => {
12
- if (exist) {
13
- const configComponentsWebpackAsset = getConfigComponentsWebpack(
14
- currentPath,
15
- config,
16
- true
17
- )
18
- webpack(configComponentsWebpackAsset, (err, stats) => {
19
- if (err || stats.hasErrors()) {
20
- console.log(stats.hasErrors())
21
- }
22
- })
23
- }
24
- }
25
- )