@zohodesk/react-cli 1.0.2-exp.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -180
  3. package/.prettierrc +6 -6
  4. package/Changelog.md +1019 -1019
  5. package/README.md +1184 -1165
  6. package/bin/cli.js +483 -483
  7. package/docs/CustomChunks.md +26 -26
  8. package/docs/DevServerPort.md +39 -39
  9. package/docs/DevStart.md +18 -18
  10. package/docs/HoverActive.md +12 -12
  11. package/docs/InstallNode.md +28 -28
  12. package/docs/SelectorWeight.md +8 -8
  13. package/docs/TODOS.md +10 -10
  14. package/docs/ValueReplacer.md +60 -60
  15. package/docs/VariableConversion.md +729 -729
  16. package/docs/warnings_while_install.txt +35 -35
  17. package/files/eslintrc.js +62 -62
  18. package/files/prettierrc.js +3 -3
  19. package/lib/common/testPattern.js +0 -2
  20. package/lib/common/valueReplacer.js +1 -3
  21. package/lib/configs/resolvers.js +14 -3
  22. package/lib/configs/webpack.css.umd.config.js +4 -4
  23. package/lib/configs/webpack.dev.config.js +0 -6
  24. package/lib/configs/webpack.docs.config.js +0 -4
  25. package/lib/configs/webpack.impact.config.js +0 -4
  26. package/lib/configs/webpack.prod.config.js +0 -6
  27. package/lib/loaderUtils/configsAssetsLoaders.js +33 -33
  28. package/lib/loaderUtils/getCSSLoaders.js +47 -81
  29. package/lib/loaderUtils/windowsModification.js +1 -6
  30. package/lib/loaders/selectorMappingLoader.js +9 -9
  31. package/lib/loaders/workerLoader.js +9 -9
  32. package/lib/logger.js +20 -0
  33. package/lib/pluginUtils/getDevPlugins.js +12 -18
  34. package/lib/pluginUtils/getProdPlugins.js +10 -6
  35. package/lib/pluginUtils/getUMDCSSPlugins.js +1 -1
  36. package/lib/pluginUtils/getUMDComponentPlugins.js +1 -1
  37. package/lib/plugins/CustomAttributePlugin.js +82 -0
  38. package/lib/plugins/CustomAttributePlugin.md +35 -0
  39. package/lib/plugins/EFCPlugin.js +9 -9
  40. package/lib/plugins/EFCPlugin.md +6 -6
  41. package/lib/plugins/EFCTemplatePlugin.js +10 -12
  42. package/lib/plugins/I18NInjectIntoIndexPlugin.js +12 -13
  43. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +2 -3
  44. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
  45. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
  46. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +10 -15
  47. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  48. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  49. package/lib/plugins/I18nSplitPlugin/index.js +57 -57
  50. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +8 -8
  51. package/lib/plugins/ResourceHintsPlugin.js +17 -17
  52. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +6 -6
  53. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  54. package/lib/plugins/SelectorPlugin.js +36 -53
  55. package/lib/plugins/ServiceWorkerPlugin.js +9 -9
  56. package/lib/plugins/TPHashMappingPlugin.js +4 -4
  57. package/lib/plugins/{MinifyPlugin.js → UglifyCSSPlugin.js} +3 -3
  58. package/lib/plugins/VariableConversionCollector.js +84 -97
  59. package/lib/plugins/composeCommonPlugin.js +30 -0
  60. package/lib/plugins/index.js +7 -7
  61. package/lib/postcss-plugins/ExcludePlugin.js +1 -1
  62. package/lib/postcss-plugins/IncludePlugin.js +0 -1
  63. package/lib/postcss-plugins/RTLSplitPlugin.js +14 -20
  64. package/lib/postcss-plugins/ValueReplacer.js +14 -5
  65. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  66. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  67. package/lib/postcss-plugins/hoverActivePlugin.js +3 -9
  68. package/lib/postcss-plugins/variableModificationPlugin/index.js +20 -3
  69. package/lib/postcss-plugins/variableModifier.js +24 -58
  70. package/lib/schemas/index.js +11 -35
  71. package/lib/servers/devBuild.js +13 -11
  72. package/lib/servers/httpsOptions.js +12 -13
  73. package/lib/servers/nowatchserver.js +5 -3
  74. package/lib/servers/requireLocalOrGlobal.js +61 -0
  75. package/lib/servers/server.js +3 -5
  76. package/lib/sh/pre-commit.sh +34 -34
  77. package/lib/sh/reportPublish.sh +45 -45
  78. package/lib/utils/buildstats.html +148 -148
  79. package/lib/utils/cssClassNameGenerate.js +12 -41
  80. package/lib/utils/resultSchema.json +73 -73
  81. package/npm8.md +9 -9
  82. package/package-lock.json +14407 -0
  83. package/package.json +120 -122
  84. package/postpublish.js +8 -8
  85. package/templates/app/.eslintrc.js +140 -140
  86. package/templates/app/README.md +12 -12
  87. package/templates/app/app/index.html +24 -24
  88. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  89. package/templates/app/app/properties/i18nkeys.json +3 -3
  90. package/templates/app/docs/all.html +69 -69
  91. package/templates/app/mockapi/index.js +18 -18
  92. package/templates/app/package.json +37 -37
  93. package/templates/app/src/actions/SampleActions/index.js +37 -37
  94. package/templates/app/src/actions/index.js +65 -65
  95. package/templates/app/src/appUrls.js +19 -19
  96. package/templates/app/src/components/Alert/Alert.js +134 -134
  97. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  98. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  99. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  100. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  101. package/templates/app/src/components/Sample/SampleList.js +61 -61
  102. package/templates/app/src/components/Slider/Slider.css +41 -41
  103. package/templates/app/src/components/Slider/Slider.js +55 -55
  104. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  105. package/templates/app/src/containers/AppContainer/index.js +96 -96
  106. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  107. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  108. package/templates/app/src/containers/DevTools/index.js +10 -10
  109. package/templates/app/src/containers/Header/index.js +67 -67
  110. package/templates/app/src/containers/Header/index.module.css +43 -43
  111. package/templates/app/src/containers/Redirect/index.js +63 -63
  112. package/templates/app/src/containers/Redirector/index.js +47 -47
  113. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  114. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  115. package/templates/app/src/historyChange.js +5 -5
  116. package/templates/app/src/index.html +10 -10
  117. package/templates/app/src/index.js +24 -24
  118. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  119. package/templates/app/src/reducers/alertData.js +11 -11
  120. package/templates/app/src/reducers/index.js +6 -6
  121. package/templates/app/src/reducers/samples.js +19 -19
  122. package/templates/app/src/store/configureStore.dev.js +51 -51
  123. package/templates/app/src/store/configureStore.js +5 -5
  124. package/templates/app/src/store/configureStore.prod.js +26 -26
  125. package/templates/app/src/util/Common.js +5 -5
  126. package/templates/app/src/util/RequestAPI.js +132 -132
  127. package/templates/docs/all.html +249 -249
  128. package/templates/docs/component.html +178 -178
  129. package/templates/docs/components.html +221 -221
  130. package/templates/docs/css/b.min.css +6 -6
  131. package/templates/docs/css/component.css +42 -42
  132. package/templates/docs/css/componentTest.css +6 -6
  133. package/templates/docs/css/hopscotch.css +585 -585
  134. package/templates/docs/css/style.css +1022 -1022
  135. package/templates/docs/impactReportTemplate.html +154 -154
  136. package/templates/docs/index.html +1501 -1501
  137. package/templates/docs/js/active-line.js +72 -72
  138. package/templates/docs/js/b.min.js +7 -7
  139. package/templates/docs/js/codemirror.js +9680 -9680
  140. package/templates/docs/js/designTokens.js +334 -334
  141. package/templates/docs/js/j.min.js +4 -4
  142. package/templates/docs/js/javascript.js +874 -874
  143. package/templates/docs/js/matchbrackets.js +145 -145
  144. package/lib/loaderUtils/tests/windowsModification.test.js +0 -10
  145. package/lib/loaders/composeLoader.js +0 -175
  146. package/lib/plugins/utils/classHandling.js +0 -20
  147. package/lib/plugins/utils/fileHandling.js +0 -92
  148. package/lib/plugins/utils/tests/fileHandling.test.js +0 -30
  149. package/lib/postcss-plugins/EmptyPlugin.js +0 -8
@@ -11,6 +11,8 @@ var _fs = require("fs");
11
11
 
12
12
  var _path = require("path");
13
13
 
14
+ var _logger = require("../../../logger");
15
+
14
16
  function isComment(line) {
15
17
  return line[0] === '#';
16
18
  }
@@ -18,7 +20,7 @@ function isComment(line) {
18
20
  function getPropertiesAsJSON(filePath) {
19
21
  try {
20
22
  const data = (0, _fs.readFileSync)(filePath);
21
- let source = data.toString();
23
+ const source = data.toString();
22
24
  const i18nObj = {};
23
25
  source.split(/\r?\n\r?/).forEach(fline => {
24
26
  const line = fline.trim();
@@ -42,7 +44,7 @@ function getPropertiesAsJSON(filePath) {
42
44
  }
43
45
 
44
46
  function getLang(file) {
45
- let underScoreIndex = file.indexOf('_');
47
+ const underScoreIndex = file.indexOf('_');
46
48
  let language = 'en_US';
47
49
 
48
50
  if (underScoreIndex !== -1) {
@@ -68,26 +70,24 @@ function getAllI18n({
68
70
  const filePath = (0, _path.join)(context, file);
69
71
 
70
72
  if (exclude.test(filePath) || !include.test(filePath)) {
71
- // console.log('exclude', filePath);
72
73
  return;
73
- } // console.log('include', filePath);
74
-
74
+ }
75
75
 
76
76
  const i18n = getPropertiesAsJSON(filePath);
77
77
  allLangI18n[getLang(file)] = disableDefault ? i18n : Object.assign({}, jsResourceI18nKeys, i18n);
78
78
  });
79
79
  return allLangI18n;
80
80
  } catch (err) {
81
- // console.log(err);
81
+ (0, _logger.errorLogger)(err);
82
82
  return {};
83
83
  }
84
84
  }
85
85
 
86
86
  function jsonToString(json, keySeperator) {
87
87
  let str = '{';
88
- let keys = Object.keys(json);
88
+ const keys = Object.keys(json);
89
89
  keys.forEach((key, i) => {
90
- let value = json[key];
90
+ const value = json[key];
91
91
 
92
92
  if (!value) {
93
93
  return;
@@ -33,25 +33,25 @@ class ResourceHintsPlugin {
33
33
  }
34
34
 
35
35
  return Template.asString([source, '', `${mainTemplate.requireFn}.getChunkId = function getChunkId(chunkId) {`, Template.indent((needsMap ? [`chunkId = ${JSON.stringify(nameIdMap)}[chunkId]||chunkId;`] : []).concat(['return chunkId;'])), '}', `// Prefetch a chunk (${pluginName})`, `${mainTemplate.requireFn}.pfc = function prefetchChunk(chunkId) {`, Template.indent([`chunkId = ${mainTemplate.requireFn}.getChunkId(chunkId)`, `${mainTemplate.requireFn}.e(chunkId);`]), '};',
36
- /*
37
- (needsMap
38
- ? [`chunkId = ${JSON.stringify(nameIdMap)}[chunkId]||chunkId;`]
39
- : []
40
- ).concat([
41
- 'var promises = [];',
42
- 'if(installedChunks[chunkId] === undefined) {',
43
- Template.indent([
44
- 'installedChunks[chunkId] = null;',
45
- /* mainTemplate.hooks.linkPrefetch.call('', chunk, hash),
36
+ /*
37
+ (needsMap
38
+ ? [`chunkId = ${JSON.stringify(nameIdMap)}[chunkId]||chunkId;`]
39
+ : []
40
+ ).concat([
41
+ 'var promises = [];',
42
+ 'if(installedChunks[chunkId] === undefined) {',
43
+ Template.indent([
44
+ 'installedChunks[chunkId] = null;',
45
+ /* mainTemplate.hooks.linkPrefetch.call('', chunk, hash),
46
46
  'document.head.appendChild(link);', */
47
47
 
48
- /*
49
- mainTemplate.hooks.requireEnsure.call('', chunk, hash)
50
- ]),
51
- '}'
52
- ])
53
- ),
54
- '}',
48
+ /*
49
+ mainTemplate.hooks.requireEnsure.call('', chunk, hash)
50
+ ]),
51
+ '}'
52
+ ])
53
+ ),
54
+ '}',
55
55
  */
56
56
  `// Preload a chunk (${pluginName})`, `${mainTemplate.requireFn}.plc = function preloadChunk(chunkId) {`, Template.indent([`chunkId = ${mainTemplate.requireFn}.getChunkId(chunkId)`, 'if(installedChunks[chunkId] === undefined) {', Template.indent(['installedChunks[chunkId] = null;', mainTemplate.hooks.linkPreload.call('', chunk, hash), 'document.head.appendChild(link);', `${mainTemplate.requireFn}.e(chunkId);` // 'var head = document.getElementsByTagName(\'head\')[0];',
57
57
  // mainTemplate.hooks.jsonpScript.call('', chunk, hash),
@@ -24,12 +24,12 @@ const isCss = filename => _path.default.extname(filename) === '.css'; // this p
24
24
 
25
25
  class RtlCssPlugin {
26
26
  constructor(options = {}) {
27
- /**
28
- * @typedef {Object} Options
29
- * @property {String} filename [not used]
30
- * @property {String} dirVarName
31
- * @property {Boolean} sourcemap
32
- * @property {Object} config
27
+ /**
28
+ * @typedef {Object} Options
29
+ * @property {String} filename [not used]
30
+ * @property {String} dirVarName
31
+ * @property {Boolean} sourcemap
32
+ * @property {Object} config
33
33
  */
34
34
  this.options = {
35
35
  filename: options.filename || '[name].rtl.css',
@@ -1,30 +1,30 @@
1
- # RTL Split
2
-
3
- we are doing in build time generating rtl related css code by using @zohodesk/postcss-rt npm.
4
- It was automated, That postcss plugin create rtl reacted css and put them into same file, with css selector [dir=rtl] and ltr realted css with [dir=ltr].
5
- Here is problem mostly no one need rtl and ltr related css at the same time in browser,
6
- we are try to split them by [dir] and load which type of css is needed.
7
- For this purpose we created RTL Split Plugin
8
-
9
-
10
- # To Try it out rtl-ltr split
11
- ### how to use this feature?
12
-
13
- to use this feature use have give the below oprtions
14
- `package.json`
15
- ```json
16
- {
17
- /// ...some things
18
- "react-cli": {
19
- // ...some things
20
- "css": {
21
- "enableRTLSplit": true,
22
- "templateLabel": "{{--dir}}",// this is for html template css file path dir template
23
- "disableMiniFiySelector": false,
24
- "dirVarName": "document.dir" // this will be used for download css based on dir
25
- },
26
- // ...some things
27
- }
28
- }
29
- ```
30
-
1
+ # RTL Split
2
+
3
+ we are doing in build time generating rtl related css code by using @zohodesk/postcss-rt npm.
4
+ It was automated, That postcss plugin create rtl reacted css and put them into same file, with css selector [dir=rtl] and ltr realted css with [dir=ltr].
5
+ Here is problem mostly no one need rtl and ltr related css at the same time in browser,
6
+ we are try to split them by [dir] and load which type of css is needed.
7
+ For this purpose we created RTL Split Plugin
8
+
9
+
10
+ # To Try it out rtl-ltr split
11
+ ### how to use this feature?
12
+
13
+ to use this feature use have give the below oprtions
14
+ `package.json`
15
+ ```json
16
+ {
17
+ /// ...some things
18
+ "react-cli": {
19
+ // ...some things
20
+ "css": {
21
+ "enableRTLSplit": true,
22
+ "templateLabel": "{{--dir}}",// this is for html template css file path dir template
23
+ "disableMiniFiySelector": false,
24
+ "dirVarName": "document.dir" // this will be used for download css based on dir
25
+ },
26
+ // ...some things
27
+ }
28
+ }
29
+ ```
30
+
@@ -9,24 +9,32 @@ var _postcss = _interopRequireDefault(require("postcss"));
9
9
 
10
10
  var _fs = _interopRequireDefault(require("fs"));
11
11
 
12
- var _classHandling = require("./utils/classHandling");
13
-
14
- var _fileHandling = require("./utils/fileHandling");
15
-
16
12
  var _windowsModification = require("../loaderUtils/windowsModification");
17
13
 
18
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
15
 
20
- function selectorWeightPrefixAdder(rootOriginal, selector, excludeStrings) {
16
+ function checkFilename(filename, data) {
17
+ let keyMatch = undefined;
18
+ Object.keys(data).forEach(key => {
19
+ if (filename.includes(key)) {
20
+ keyMatch = key;
21
+ }
22
+ });
23
+ return keyMatch;
24
+ }
25
+
26
+ function rootConvertor(rootOriginal, defaultSelector, data, filename, excludeStrings) {
21
27
  rootOriginal.walkRules((rule, index) => {
22
28
  const prevNode = rootOriginal.nodes[index - 1];
23
29
 
24
- if ((0, _classHandling.hasPrevNodeIgnore)(index, prevNode, 'updateselector:ignore')) {
30
+ if (index !== 0 && prevNode.type && prevNode.type === 'comment' && prevNode.text.toLowerCase() === 'updateselector:ignore') {
25
31
  return;
26
32
  }
27
33
 
28
- if (!(0, _classHandling.isInsideMediaQuery)(rule)) {
29
- return;
34
+ if (rule.parent && rule.parent.type === 'atrule') {
35
+ if (rule.parent.name !== 'media') {
36
+ return;
37
+ }
30
38
  }
31
39
 
32
40
  const selectorArr = rule.selector.split(',');
@@ -40,24 +48,33 @@ function selectorWeightPrefixAdder(rootOriginal, selector, excludeStrings) {
40
48
  return;
41
49
  }
42
50
 
43
- selectorArr[index] = `${singleSelectorStr.slice(0, singleSelectorStr.lastIndexOf(']') + 1).trim()} ${selector}${singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 2).trim()}`;
51
+ selectorArr[index] = `${singleSelectorStr.slice(0, singleSelectorStr.lastIndexOf(']') + 1).trim()} ${defaultSelector}${singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 2).trim()}`;
44
52
  return;
45
53
  }
46
54
 
47
- selectorArr[index] = `${selector}${singleSelectorStr}`;
55
+ const keyMatch = checkFilename(filename, data);
56
+ selectorArr[index] = data[keyMatch] ? `${data[keyMatch].defaultSelector}${singleSelectorStr}` : `${defaultSelector}${singleSelectorStr}`;
48
57
  });
49
58
  rule.selector = selectorArr.join(',\n');
50
59
  });
51
60
  return rootOriginal;
52
61
  }
53
62
 
63
+ function ignoreFile(excludeArr, filename) {
64
+ let ignore = false;
65
+ excludeArr.forEach(exclStr => {
66
+ if (filename.includes(exclStr)) {
67
+ ignore = true;
68
+ }
69
+ });
70
+ return ignore;
71
+ }
72
+
54
73
  class SelectorPlugin {
55
74
  constructor(options = {}) {
56
75
  this.optimize = options.optimize;
57
76
  this.selectorWeightConfig = options.selectorWeightConfig;
58
77
  this.exclude = options.exclude;
59
- this.patterns = options.patterns;
60
- this.rootDir = options.patternsRootDir;
61
78
  }
62
79
 
63
80
  apply(compiler) {
@@ -77,49 +94,15 @@ class SelectorPlugin {
77
94
  mods.forEach(module => {
78
95
  const rootOriginal = _postcss.default.parse(module.content);
79
96
 
80
- const filename = module.issuer.resource;
81
- /*
82
- input :
83
- filename : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
84
-
85
- patterns.cssVariableReplacement:
86
- // include src folder, include deskapp folder, exclude node modules
87
- "selectorWeight": [
88
- "src",
89
- "deskapp",
90
- "!node_modules"
91
- ]
92
- rootDir : patternsRootDir : 'supportapp'
93
-
94
- output :
95
- true or false
96
- */
97
-
98
- if (!(0, _fileHandling.isFileNameMatchingPluginPattern)({
99
- filename,
100
- filterArr: this.patterns.selectorWeight,
101
- rootDir: this.rootDir
102
- })) {
97
+ const filename = module.issuer.resource; // if (!filename.includes('node_modules')) {
98
+
99
+ if (ignoreFile(this.exclude, filename)) {
103
100
  return;
104
101
  }
105
- /*
106
-
107
- filename : Deskapp.module.css ?
108
- data :
109
- {
110
- "DeskApp.module.css": {"defaultSelector" : ".desk_app_ui "}
111
- }
112
- selectorWeightConfig :
113
- defaultSelector : .zoho_desk_ui
114
-
115
- case filename = 'DeskApp.module.css' ?
116
- data[filename].defaultSelector = '.desk_app_ui'
117
- case filename is different ?
118
- defaultSelector = '.zoho_desk_ui'
119
- */
120
-
121
-
122
- module.content = selectorWeightPrefixAdder(rootOriginal, data[filename] ? data[filename].defaultSelector : defaultSelector, excludeStrings).toString();
102
+
103
+ module.content = //new RawSource(
104
+ rootConvertor(rootOriginal, defaultSelector, data, filename, excludeStrings).toString(); // );
105
+ // }
123
106
  });
124
107
  });
125
108
  });
@@ -51,11 +51,11 @@ class ServiceWorkerPlugin {
51
51
  if (err) {
52
52
  throw new Error(err);
53
53
  } else {
54
- /* const extractedChunks = compilation.chunks.filter(chunk => {
55
- if ('canBeInitial' in chunk) {
56
- return chunk.canBeInitial();
57
- }
58
- return chunk.isInitial();
54
+ /* const extractedChunks = compilation.chunks.filter(chunk => {
55
+ if ('canBeInitial' in chunk) {
56
+ return chunk.canBeInitial();
57
+ }
58
+ return chunk.isInitial();
59
59
  }); */
60
60
  // let [js, css, , , i18nPublicPath] = this.publicPaths;
61
61
  // let initialChunkUrls = [];
@@ -64,10 +64,10 @@ class ServiceWorkerPlugin {
64
64
  let entrypoint = compilation.entrypoints.get('main');
65
65
  let initialChunkUrls = entrypoint.getFiles();
66
66
  const cssDirTemplate = '@dir@';
67
- /**
68
- * NOTE:
69
- * if chunkSplitEnable is false means,
70
- * serviceWorker will get i18n files path for html
67
+ /**
68
+ * NOTE:
69
+ * if chunkSplitEnable is false means,
70
+ * serviceWorker will get i18n files path for html
71
71
  */
72
72
 
73
73
  let initalI18nAssets = chunkSplitEnable ? entrypoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@')) : [];
@@ -15,10 +15,10 @@ var _crypto = _interopRequireDefault(require("crypto"));
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- /**
19
- * Plugin that generates hash for the provided list of third party files
20
- * Map the provided key with the file hash and add it to the list of exisiting global constants.
21
- * Plugin in turn uses the defineplugin to generate global constants.
18
+ /**
19
+ * Plugin that generates hash for the provided list of third party files
20
+ * Map the provided key with the file hash and add it to the list of exisiting global constants.
21
+ * Plugin in turn uses the defineplugin to generate global constants.
22
22
  */
23
23
  class TPHashMappingPlugin {
24
24
  constructor(options) {
@@ -11,9 +11,9 @@ var _uglifycss = _interopRequireDefault(require("uglifycss"));
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
- class MinifierPlugin {
14
+ class UglifyCSSPlugin {
15
15
  apply(compiler) {
16
- compiler.hooks.emit.tap('MinifierPlugin', compilation => {
16
+ compiler.hooks.emit.tap('UglifyCSSPlugin', compilation => {
17
17
  Object.keys(compilation.assets).forEach(filename => {
18
18
  if (/\.css$/.test(filename)) {
19
19
  try {
@@ -36,4 +36,4 @@ class MinifierPlugin {
36
36
 
37
37
  }
38
38
 
39
- exports.default = MinifierPlugin;
39
+ exports.default = UglifyCSSPlugin;
@@ -9,8 +9,6 @@ var _postcss = _interopRequireDefault(require("postcss"));
9
9
 
10
10
  var _ErrorHandler = require("../postcss-plugins/variableModificationPlugin/ErrorHandler");
11
11
 
12
- var _fileHandling = require("./utils/fileHandling");
13
-
14
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
13
 
16
14
  // import { RawSource } from 'webpack-sources';
@@ -28,15 +26,15 @@ const {
28
26
  const supportedProps = ['font-size', 'margin', 'margin-top', 'margin-bottom', 'margin-left', 'margin-right', 'padding', 'padding-top', 'padding-bottom', 'padding-left', 'padding-right', '^top', '^right', '^bottom', '^left', '^width', 'min-width', 'max-width', '^height', 'min-height', 'max-height', 'text-indent', 'clip', 'flex-basis', 'row-gap', 'gap', 'column-gap', 'flex']; // const avoidProps = [];
29
27
  // -- is issue IO --
30
28
 
31
- /*
32
- issues eg :
33
- issues = ['--zd_size', '--zd_font_size', '--size', '--size_'];
34
- input :
35
- --zd_size
36
- output :
37
- true
38
- comment :
39
- do not execute when --zd_size comes as prop
29
+ /*
30
+ issues eg :
31
+ issues = ['--zd_size', '--zd_font_size', '--size', '--size_'];
32
+ input :
33
+ --zd_size
34
+ output :
35
+ true
36
+ comment :
37
+ do not execute when --zd_size comes as prop
40
38
  */
41
39
 
42
40
  function isIgnoreValuePresent(ignoreVals, prop) {
@@ -49,14 +47,14 @@ function isIgnoreValuePresent(ignoreVals, prop) {
49
47
  return present;
50
48
  } // -- to convert the hyphen values to values --
51
49
 
52
- /*
53
- input :
54
- var(--zdt_uploadlist_default_width)
55
- output :
56
- --zdt_uploadlist_default_width
57
-
58
- comment :
59
- to make the variable object using the output as key and decl.prop such as font-size as value
50
+ /*
51
+ input :
52
+ var(--zdt_uploadlist_default_width)
53
+ output :
54
+ --zdt_uploadlist_default_width
55
+
56
+ comment :
57
+ to make the variable object using the output as key and decl.prop such as font-size as value
60
58
  */
61
59
 
62
60
 
@@ -64,7 +62,7 @@ function extractVariableName(val) {
64
62
  return val.replace(/calc\((.+)\)/gi, '$1').replace(/var\((.+)\)/gi, '$1').replace('-1', '').replace('*', '').replace('\n', '').trim();
65
63
  }
66
64
 
67
- function variableConvertor(rootOriginal, variables, settingsObject) {
65
+ function rootConvertor(rootOriginal, variables, settingsObject) {
68
66
  rootOriginal.walkRules(rule => {
69
67
  rule.nodes.forEach((decl, index) => {
70
68
  const prevNode = rule.nodes[index - 1];
@@ -120,12 +118,10 @@ class VariableConversionCollector {
120
118
  constructor(options = {}) {
121
119
  this.optimize = options.optimize;
122
120
  this.filename = options.cssVariableReplacementConfig;
123
- this.patterns = options.patterns;
124
- this.rootDir = options.patternsRootDir;
125
- this.initializeFiles();
121
+ this.fileHandler();
126
122
  }
127
123
 
128
- initializeFiles() {
124
+ fileHandler() {
129
125
  createFolderIfNonExistant('./.cli/logs/');
130
126
  createFolderIfNonExistant('./.cli/config/variables/');
131
127
  createFolderIfNonExistant('./.cli/config/selectorWeight/');
@@ -135,8 +131,7 @@ class VariableConversionCollector {
135
131
 
136
132
  apply(compiler) {
137
133
  const variables = {};
138
- const unassigned = {}; // console.log(windowsModification([this.filename])[0]);
139
-
134
+ const unassigned = {};
140
135
  const rawdata = fs.readFileSync(this.filename);
141
136
  const data = JSON.parse(rawdata);
142
137
  const {
@@ -159,13 +154,13 @@ class VariableConversionCollector {
159
154
  }
160
155
  };
161
156
  }
162
- /*
163
- purpose of tap : to create a variable object such as:
164
- {
165
- --zdt_uploadlist_default_width : width,
166
- --zdt_uploadlist_default_height : height,
167
- }
168
- which will help in the conversion further
157
+ /*
158
+ purpose of tap : to create a variable object such as:
159
+ {
160
+ --zdt_uploadlist_default_width : width,
161
+ --zdt_uploadlist_default_height : height,
162
+ }
163
+ which will help in the conversion further
169
164
  */
170
165
 
171
166
 
@@ -195,9 +190,6 @@ class VariableConversionCollector {
195
190
  variables[extractedValue] = decl.prop;
196
191
  } else {
197
192
  if (new RegExp(supportedProps.join('|'), 'gi').test(decl.prop)) {
198
- // console.log(
199
- // `${extractedValue} : ${variables[extractedValue]} already exists please check!`
200
- // );
201
193
  if (errorsAllowed.MULTIPLE_OCCURANCES) {
202
194
  const errObj = {
203
195
  decl,
@@ -211,7 +203,6 @@ class VariableConversionCollector {
211
203
  }
212
204
  }
213
205
  } else {
214
- // console.log(decl.prop);
215
206
  if (/^--/gi.test(decl.prop) && val.trim() !== '' && !variables[decl.prop]) {
216
207
  if (!Object.keys(variablesRead.ignore).includes(decl.prop)) {
217
208
  unassigned[decl.prop] = variables[decl.prop];
@@ -221,19 +212,19 @@ class VariableConversionCollector {
221
212
  });
222
213
  });
223
214
  });
224
- /*
225
- current value example:
226
- {
227
- --zdt_uploadlist_default_width : --zd_upload_width,
228
- --zd_upload_width : width
229
- }
230
- expected value :
231
- {
232
- --zdt_uploadlist_default_width : width,
233
- --zd_upload_width : width
234
- }
235
-
236
- conversion is done in the while loop below
215
+ /*
216
+ current value example:
217
+ {
218
+ --zdt_uploadlist_default_width : --zd_upload_width,
219
+ --zd_upload_width : width
220
+ }
221
+ expected value :
222
+ {
223
+ --zdt_uploadlist_default_width : width,
224
+ --zd_upload_width : width
225
+ }
226
+
227
+ conversion is done in the while loop below
237
228
  */
238
229
 
239
230
  Object.keys(variables).forEach(key => {
@@ -243,62 +234,36 @@ class VariableConversionCollector {
243
234
  });
244
235
  }
245
236
  });
246
- }); // -- conversion for the root using variableConvertor --
247
-
248
- /*
249
- input :
250
- .a{
251
- padding : 20px
252
- }
253
- output :
254
- // on settingObject file :
255
- { padding : { replacements : { px : 'zd_size$$' }}}
256
- .a{
257
- padding : zd_size20;
258
- }
237
+ }); // -- conversion for the root using rootConvertor --
238
+
239
+ /*
240
+ input :
241
+ .a{
242
+ padding : 20px
243
+ }
244
+ output :
245
+ // on settingObject file :
246
+ { padding : { replacements : { px : 'zd_size$$' }}}
247
+ .a{
248
+ padding : zd_size20;
249
+ }
259
250
  */
260
251
 
261
252
  compilation.hooks.optimizeModules.tap('VariableConversionCollector', modules => {
262
253
  const mods = modules.filter(x => x.type.includes('css'));
263
254
  mods.forEach(module => {
264
- const filename = module.issuer.resource;
265
- /*
266
- input :
267
- filename : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
268
-
269
- patterns.cssVariableReplacement:
270
- // include src folder, include deskapp folder, exclude node modules
271
- "cssVariableReplacement": [
272
- "src",
273
- "deskapp",
274
- "!node_modules"
275
- ]
276
- rootDir : patternsRootDir : 'supportapp'
277
-
278
- output :
279
- true or false
280
- */
281
-
282
- if (!(0, _fileHandling.isFileNameMatchingPluginPattern)({
283
- filename,
284
- filterArr: this.patterns.cssVariableReplacement,
285
- rootDir: this.rootDir
286
- })) {
287
- return;
288
- }
289
-
290
255
  const rootOriginal = _postcss.default.parse(module.content);
291
256
 
292
- module.content = variableConvertor(rootOriginal, variables, settingsObject).toString();
257
+ module.content = rootConvertor(rootOriginal, variables, settingsObject).toString();
293
258
  });
294
259
  });
295
260
  });
296
- /*
297
- purpose of tap : to display the errors encountered so far
298
- input :
299
- all css files
300
- output :
301
- all errors that are present in the errTable arr
261
+ /*
262
+ purpose of tap : to display the errors encountered so far
263
+ input :
264
+ all css files
265
+ output :
266
+ all errors that are present in the errTable arr
302
267
  */
303
268
 
304
269
  compiler.hooks.afterEmit.tap('error-display', () => {
@@ -323,7 +288,29 @@ class VariableConversionCollector {
323
288
  if (a.type < b.type) {
324
289
  return -1;
325
290
  }
326
- });
291
+ }); // variable constructed now to be written in a json file
292
+ // const newVars = Object.keys(variables)
293
+ // //Filter Object with key contanis "NAME"
294
+ // .filter(key => variables[key].includes('--'))
295
+ // .reduce(
296
+ // (obj, key) =>
297
+ // Object.assign(obj, {
298
+ // [key]: variables[key]
299
+ // }),
300
+ // {}
301
+ // );
302
+ // console.log('new variables: ', newVars);
303
+ // try {
304
+ // fs.writeFileSync('./variableMapping.json', JSON.stringify(variables));
305
+ // } catch (err) {
306
+ // console.log(err);
307
+ // }
308
+ // fs.writeFile('./variableMapping.json', JSON.stringify(variables), err => {
309
+ // if (err) {
310
+ // throw err;
311
+ // }
312
+ // console.log('variable mapping file generated.');
313
+ // });
327
314
 
328
315
  if (errorConsoleStatus) {
329
316
  const errorHandler = new _ErrorHandler.ErrorHandler();