@zohodesk/react-cli 0.0.1-exp.175.1 → 0.0.1-exp.176.2

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 (250) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -180
  3. package/.prettierrc +6 -6
  4. package/README.md +1025 -1028
  5. package/bin/cli.js +482 -482
  6. package/cert/Tsicsezwild-22-23.crt +37 -37
  7. package/cert/Tsicsezwild-22-23.key +27 -27
  8. package/docs/CustomChunks.md +26 -26
  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 +6 -0
  13. package/docs/TODOS.md +10 -10
  14. package/docs/ValueReplacer.md +60 -60
  15. package/docs/VariableConversion.md +719 -678
  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/babel/cmjs-plugins-presets.js +4 -0
  20. package/lib/babel/es-plugins-presets.js +4 -0
  21. package/lib/common/getEntries.js +10 -0
  22. package/lib/common/getPublicPathConfig.js +6 -0
  23. package/lib/common/index.js +5 -0
  24. package/lib/common/splitChunks.js +13 -2
  25. package/lib/common/sslcertUpdater.js +17 -6
  26. package/lib/common/templateParameters.js +2 -0
  27. package/lib/common/testPattern.js +21 -10
  28. package/lib/common/valueReplacer.js +15 -0
  29. package/lib/configs/jest.config.js +9 -0
  30. package/lib/configs/libAlias.js +2 -4
  31. package/lib/configs/webpack.component.umd.config.js +5 -0
  32. package/lib/configs/webpack.css.umd.config.js +13 -5
  33. package/lib/configs/webpack.dev.config.js +36 -2
  34. package/lib/configs/webpack.docs.config.js +21 -1
  35. package/lib/configs/webpack.impact.config.js +19 -1
  36. package/lib/configs/webpack.prod.config.js +37 -3
  37. package/lib/hooks/docsProptypeHook.js +7 -3
  38. package/lib/jest/commitedFilesResult.js +45 -3
  39. package/lib/jest/coverageCollector.js +11 -0
  40. package/lib/jest/jsonMaker.js +6 -0
  41. package/lib/jest/preProcessors/cssPreprocessor.js +8 -0
  42. package/lib/jest/preProcessors/jsPreprocessor.js +2 -0
  43. package/lib/jest/preProcessors/otherFilesPreprocessor.js +3 -0
  44. package/lib/jest/result.js +22 -0
  45. package/lib/jest/run.js +17 -6
  46. package/lib/jest/setup.js +57 -5
  47. package/lib/loaderUtils/configsAssetsLoaders.js +44 -34
  48. package/lib/loaderUtils/getCSSLoaders.js +35 -20
  49. package/lib/loaderUtils/getDevJsLoaders.js +8 -0
  50. package/lib/loaderUtils/index.js +3 -0
  51. package/lib/loaderUtils/windowsModification.js +11 -0
  52. package/lib/loaders/docsLoader.js +7 -0
  53. package/lib/loaders/docsPropsLoader.js +7 -3
  54. package/lib/loaders/fileBountryLoader.js +2 -0
  55. package/lib/loaders/fileLoader.js +22 -11
  56. package/lib/loaders/scriptInstrumentLoader.js +13 -5
  57. package/lib/loaders/selectorMappingLoader.js +25 -7
  58. package/lib/loaders/workerLoader.js +29 -13
  59. package/lib/middlewares/HMRMiddleware.js +26 -13
  60. package/lib/middlewares/SSTMiddleware.js +3 -0
  61. package/lib/pluginUtils/configHtmlWebpackPlugins.js +9 -3
  62. package/lib/pluginUtils/getDevPlugins.js +68 -22
  63. package/lib/pluginUtils/getDocsPlugins.js +10 -1
  64. package/lib/pluginUtils/getLibraryImactPlugins.js +5 -4
  65. package/lib/pluginUtils/getLibraryPlugins.js +5 -0
  66. package/lib/pluginUtils/getProdPlugins.js +77 -28
  67. package/lib/pluginUtils/getServerPlugins.js +5 -0
  68. package/lib/pluginUtils/getUMDCSSPlugins.js +7 -0
  69. package/lib/pluginUtils/getUMDComponentPlugins.js +7 -0
  70. package/lib/pluginUtils/index.js +8 -0
  71. package/lib/plugins/CdnChangePlugin.js +14 -0
  72. package/lib/plugins/CleanupStatsPlugin.js +5 -0
  73. package/lib/plugins/EFCPlugin.js +34 -23
  74. package/lib/plugins/EFCPlugin.md +6 -6
  75. package/lib/plugins/EFCTemplatePlugin.js +32 -23
  76. package/lib/plugins/I18NInjectIntoIndexPlugin.js +38 -12
  77. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +17 -12
  78. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
  79. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +77 -46
  80. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +59 -44
  81. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +30 -21
  82. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  83. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  84. package/lib/plugins/I18nSplitPlugin/index.js +80 -70
  85. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +12 -2
  86. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +1 -0
  87. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +5 -0
  88. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +6 -0
  89. package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
  90. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -2
  91. package/lib/plugins/ManifestPlugin.js +17 -0
  92. package/lib/plugins/ModuleStatsPlugin.js +23 -0
  93. package/lib/plugins/OptimizeJSPlugin.js +7 -0
  94. package/lib/plugins/PublicPathCallbackPlugin.js +10 -0
  95. package/lib/plugins/PublicPathChangePlugin.js +36 -4
  96. package/lib/plugins/ReportGeneratePlugin.js +30 -4
  97. package/lib/plugins/RequireVariablePublicPlugin.js +6 -0
  98. package/lib/plugins/ResourceHintsPlugin.js +27 -20
  99. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
  100. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +22 -15
  101. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  102. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
  103. package/lib/plugins/ScriptInstrumentPlugin.js +7 -0
  104. package/lib/plugins/SelectorPlugin.js +97 -0
  105. package/lib/plugins/ServiceWorkerPlugin.js +29 -13
  106. package/lib/plugins/ShadowDOMSupportPlugin.js +40 -3
  107. package/lib/plugins/SourceMapHookPlugin.js +9 -0
  108. package/lib/plugins/TPHashMappingPlugin.js +19 -5
  109. package/lib/plugins/UglifyCSSPlugin.js +9 -0
  110. package/lib/plugins/UnusedFilesFindPlugin.js +35 -2
  111. package/lib/plugins/VariableConversionCollector.js +322 -0
  112. package/lib/plugins/composeCommonPlugin.js +30 -0
  113. package/lib/plugins/index.js +19 -0
  114. package/lib/plugins/libraryImpactPlugin.js +32 -0
  115. package/lib/plugins/webpackwatchrunplugin.js +5 -0
  116. package/lib/postcss-plugins/ExcludePlugin.js +4 -0
  117. package/lib/postcss-plugins/RTLSplitPlugin.js +37 -24
  118. package/lib/postcss-plugins/ValueReplacer.js +6 -9
  119. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
  120. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  121. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  122. package/lib/postcss-plugins/hoverActivePlugin.js +69 -33
  123. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +42 -13
  124. package/lib/postcss-plugins/variableModificationPlugin/index.js +216 -141
  125. package/lib/postcss-plugins/variableModifier.js +20 -13
  126. package/lib/schemas/index.js +23 -4
  127. package/lib/servers/clusterHubServer.js +10 -0
  128. package/lib/servers/devBuild.js +24 -13
  129. package/lib/servers/docsServer.js +2 -0
  130. package/lib/servers/docsServerCore.js +21 -0
  131. package/lib/servers/getCliPath.js +9 -0
  132. package/lib/servers/helpServer.js +5 -0
  133. package/lib/servers/httpsOptions.js +4 -0
  134. package/lib/servers/impactServer.js +34 -2
  135. package/lib/servers/mockserver.js +9 -0
  136. package/lib/servers/nowatchserver.js +34 -12
  137. package/lib/servers/scrServer.js +20 -13
  138. package/lib/servers/server.js +35 -7
  139. package/lib/servers/ssServer.js +16 -0
  140. package/lib/sh/pre-commit.sh +34 -34
  141. package/lib/sh/reportPublish.sh +45 -45
  142. package/lib/templates/CoverageScriptTemplate.js +14 -0
  143. package/lib/templates/WMSTemplate.js +12 -6
  144. package/lib/utils/babelPresets.js +2 -0
  145. package/lib/utils/buildstats.html +148 -148
  146. package/lib/utils/clean.js +8 -2
  147. package/lib/utils/copy.js +6 -0
  148. package/lib/utils/copyTimezones.js +8 -0
  149. package/lib/utils/createEventStream.js +4 -0
  150. package/lib/utils/cssClassNameGenerate.js +19 -3
  151. package/lib/utils/cssURLReplacer.js +25 -0
  152. package/lib/utils/dependencyPostPublish.js +9 -0
  153. package/lib/utils/fileUtils.js +26 -0
  154. package/lib/utils/folderIterator.js +10 -0
  155. package/lib/utils/getComponents.js +21 -0
  156. package/lib/utils/getCurrentBranch.js +5 -0
  157. package/lib/utils/getDependenciesImpactList.js +21 -0
  158. package/lib/utils/getHash.js +7 -0
  159. package/lib/utils/getIp.js +2 -0
  160. package/lib/utils/getOptions.js +39 -14
  161. package/lib/utils/getServerURL.js +7 -0
  162. package/lib/utils/index.js +47 -2
  163. package/lib/utils/init.js +1 -0
  164. package/lib/utils/initPreCommitHook.js +29 -6
  165. package/lib/utils/jsonHelper.js +19 -2
  166. package/lib/utils/libraryImpactConfig.js +2 -0
  167. package/lib/utils/lint/addScripts.js +5 -2
  168. package/lib/utils/lint/checkExistingConfig.js +12 -3
  169. package/lib/utils/lint/copyConfigs.js +3 -0
  170. package/lib/utils/lint/index.js +9 -0
  171. package/lib/utils/lint/lintScripts.js +1 -0
  172. package/lib/utils/lint/lintSetup.js +4 -3
  173. package/lib/utils/lint/lintStagedPreCommitHook.js +1 -0
  174. package/lib/utils/lint/question.js +7 -0
  175. package/lib/utils/lintReporter.js +20 -0
  176. package/lib/utils/mailSender.js +7 -0
  177. package/lib/utils/pullOrigin.js +4 -0
  178. package/lib/utils/reinstallDependencies.js +28 -0
  179. package/lib/utils/removeAttributes.js +7 -0
  180. package/lib/utils/repoClone.js +27 -2
  181. package/lib/utils/request.js +12 -0
  182. package/lib/utils/resultSchema.json +73 -73
  183. package/lib/utils/rtl.js +16 -4
  184. package/lib/utils/setEnvVariables.js +2 -0
  185. package/lib/utils/ssTestHack.js +10 -0
  186. package/lib/utils/switchBranch.js +4 -0
  187. package/lib/utils/urlConcat.js +4 -0
  188. package/lib/utils/useExitCleanup.js +10 -9
  189. package/npm8.md +9 -9
  190. package/package.json +146 -146
  191. package/postpublish.js +6 -6
  192. package/templates/app/.eslintrc.js +140 -140
  193. package/templates/app/README.md +12 -12
  194. package/templates/app/app/index.html +24 -24
  195. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  196. package/templates/app/app/properties/i18nkeys.json +3 -3
  197. package/templates/app/docs/all.html +69 -69
  198. package/templates/app/mockapi/index.js +18 -18
  199. package/templates/app/package.json +37 -37
  200. package/templates/app/src/actions/SampleActions/index.js +37 -37
  201. package/templates/app/src/actions/index.js +65 -65
  202. package/templates/app/src/appUrls.js +19 -19
  203. package/templates/app/src/components/Alert/Alert.js +134 -134
  204. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  205. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  206. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  207. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  208. package/templates/app/src/components/Sample/SampleList.js +61 -61
  209. package/templates/app/src/components/Slider/Slider.css +41 -41
  210. package/templates/app/src/components/Slider/Slider.js +55 -55
  211. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  212. package/templates/app/src/containers/AppContainer/index.js +96 -96
  213. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  214. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  215. package/templates/app/src/containers/DevTools/index.js +10 -10
  216. package/templates/app/src/containers/Header/index.js +67 -67
  217. package/templates/app/src/containers/Header/index.module.css +43 -43
  218. package/templates/app/src/containers/Redirect/index.js +63 -63
  219. package/templates/app/src/containers/Redirector/index.js +47 -47
  220. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  221. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  222. package/templates/app/src/historyChange.js +5 -5
  223. package/templates/app/src/index.html +10 -10
  224. package/templates/app/src/index.js +24 -24
  225. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  226. package/templates/app/src/reducers/alertData.js +11 -11
  227. package/templates/app/src/reducers/index.js +6 -6
  228. package/templates/app/src/reducers/samples.js +19 -19
  229. package/templates/app/src/store/configureStore.dev.js +51 -51
  230. package/templates/app/src/store/configureStore.js +5 -5
  231. package/templates/app/src/store/configureStore.prod.js +26 -26
  232. package/templates/app/src/util/Common.js +5 -5
  233. package/templates/app/src/util/RequestAPI.js +132 -132
  234. package/templates/docs/all.html +249 -249
  235. package/templates/docs/component.html +178 -178
  236. package/templates/docs/components.html +221 -221
  237. package/templates/docs/css/b.min.css +6 -6
  238. package/templates/docs/css/component.css +42 -42
  239. package/templates/docs/css/componentTest.css +6 -6
  240. package/templates/docs/css/hopscotch.css +585 -585
  241. package/templates/docs/css/style.css +1022 -1022
  242. package/templates/docs/impactReportTemplate.html +154 -154
  243. package/templates/docs/index.html +1501 -1501
  244. package/templates/docs/js/active-line.js +72 -72
  245. package/templates/docs/js/b.min.js +7 -7
  246. package/templates/docs/js/codemirror.js +9680 -9680
  247. package/templates/docs/js/designTokens.js +334 -334
  248. package/templates/docs/js/j.min.js +4 -4
  249. package/templates/docs/js/javascript.js +874 -874
  250. package/templates/docs/js/matchbrackets.js +145 -145
@@ -1,10 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  const postcss = require('postcss');
4
+
4
5
  const fs = require('fs');
6
+
5
7
  const path = require('path');
8
+
9
+ const {
10
+ ErrorHandler
11
+ } = require('./ErrorHandler');
12
+
6
13
  const errors = [];
7
- let allowedErrs = {};
14
+ const errorTable = [];
15
+ const errHandler = new ErrorHandler();
8
16
  const convertableProps = {
9
17
  'font-size': true,
10
18
  margin: true,
@@ -26,37 +34,58 @@ const convertableProps = {
26
34
  top: true,
27
35
  bottom: true,
28
36
  left: true,
29
- right: true
37
+ right: true,
38
+ 'text-indent': true,
39
+ clip: true,
40
+ 'flex-basis': true,
41
+ 'row-gap': true,
42
+ gap: true,
43
+ 'column-gap': true,
44
+ flex: true
30
45
  };
31
46
  const constantValues = {
32
47
  inherit: true,
33
48
  initial: true,
34
49
  auto: true,
35
50
  'fit-content': true,
36
- unset: true
51
+ unset: true,
52
+ cover: true,
53
+ contain: true,
54
+ top: true,
55
+ bottom: true,
56
+ left: true,
57
+ center: true,
58
+ right: true
37
59
  };
60
+
38
61
  function getNumericValue(value) {
39
62
  if (value.includes('var')) {
40
63
  return parseInt(value.replace(/var\(--zd_size(\d+)\)/gi, '$1').replace(/var\(--zd_font_size(\d+)\)/gi, '$1'));
41
64
  }
42
65
 
43
- // Not need for this dum loop
66
+ if (value.includes('rect')) {
67
+ return parseInt(value.replace('rect(', '').replace(')', '').replace(',', ''));
68
+ } // Not need for this dum loop
44
69
  // allowed.forEach(alwdUnit => {
45
70
  // if (value.includes(alwdUnit)) {
46
71
  // return parseInt(value);
47
72
  // }
48
73
  // });
49
74
 
75
+
50
76
  if (constantValues[value.toLowerCase()]) {
51
77
  return 1;
52
78
  }
79
+
53
80
  return parseInt(value);
54
81
  }
82
+
55
83
  function pxToCalc(value) {
56
84
  const arr = value.split(' ');
57
85
  arr.forEach((val, index) => {
58
86
  ['px'].forEach(unit => {
59
87
  const valWithUnit = new RegExp(`(\\d+)${unit}`, 'gi');
88
+
60
89
  if (valWithUnit.test(val)) {
61
90
  arr[index] = val.replace(valWithUnit, '(var(--zd_size$1))');
62
91
  }
@@ -64,169 +93,215 @@ function pxToCalc(value) {
64
93
  });
65
94
  return arr.join(' ');
66
95
  }
67
- const addError = errstr => {
68
- errors.push(`{\n${errstr}\n}\n`);
69
- };
70
- const errorFunction = (errStr, type) => {
71
- if (type === 'DECLARATION_IGNORED' && allowedErrs.DECLARATION_IGNORED) {
72
- addError(errStr);
73
- } else if (type === 'UNIT_ERROR' && allowedErrs.UNIT_ERROR) {
74
- addError(errStr);
75
- } else if (type === 'RANGE_ERROR' && allowedErrs.RANGE_ERROR) {
76
- addError(errStr);
77
- } else if (type === 'VARIABLE_PRESENT' && allowedErrs.VARIABLE_PRESENT) {
78
- addError(errStr);
79
- }
80
- };
96
+
81
97
  const singleConvertor = (value, changeVal, details, range) => {
82
98
  const {
83
99
  path,
84
100
  filename,
85
101
  decl
86
102
  } = details;
103
+
104
+ if (decl.prop === 'background-position') {
105
+ if (isNaN(parseInt(value))) {
106
+ // console.log(`${value} skipped`);
107
+ return;
108
+ }
109
+ }
110
+
87
111
  if (getNumericValue(value) >= range.start && getNumericValue(value) <= range.end || getNumericValue(value) === 0) {
88
112
  let retVal = value.replace(/(\d+)px/gi, changeVal.replace('$$', '$1'));
113
+
89
114
  if (/^-var/.test(retVal)) {
90
115
  retVal = `calc( ${retVal.substring(1)} * -1 )`;
91
116
  }
117
+
92
118
  return retVal;
93
- }
119
+ } // if (!value.includes('rect')) {
94
120
  // if(unitErrorVal && unitErrorVal != '0' ){
95
121
  // console.log(value, 'not within range')
96
- errorFunction(` prop: ${decl.prop} ,\n value : ${decl.value} ,\n filename : ${filename} ,\n filepath : ${path} ,\n line : ${decl.source.start.line} ,\n message : value (${value}) (${typeof value}) not within range (${range.start},${range.end})\r`, 'RANGE_ERROR');
122
+
123
+
124
+ let errObj = {
125
+ decl,
126
+ type: 'RANGE_ERROR',
127
+ filename,
128
+ message: `value (${value}) (${typeof value}) not within range (${range.start},${range.end})\r`,
129
+ path: path
130
+ };
131
+ errHandler.errorTable.push(errObj);
132
+ errHandler.errorFunction(errObj); // errorFunction(
133
+ // {
134
+ // decl,
135
+ // type: 'RANGE_ERROR',
136
+ // filename,
137
+ // message: `value (${value}) (${typeof value}) not within range (${
138
+ // range.start
139
+ // },${range.end})\r`,
140
+ // path: path
141
+ // },
142
+ // 'RANGE_ERROR'
143
+ // );
97
144
  // }
98
145
  // addError(` prop: ${decl.prop} ,\n value : ${decl.value} ,\n filename : ${filename} ,\n filepath : ${path} ,\n line : ${decl.source.start.line} ,\n message : value (${value}) not within range (${range.start},${range.end})\r`)
99
- return value;
146
+ // return value;
147
+ // } else {
148
+ // console.log('++++++++++++++++++++++rect val!', value);
149
+ // }
100
150
  };
101
- module.exports = postcss.plugin('postcss-variable-report', cssVariableReplacementConfig => {
102
- const rawdata = fs.readFileSync(cssVariableReplacementConfig);
103
- const data = JSON.parse(rawdata);
104
- const {
105
- errorsAllowed,
106
- settings: settingsObject,
107
- errorLog: errorLogStatus,
108
- errorInConsole: errorConsoleStatus
109
- } = data;
110
- // const keys = Object.keys(settingsObject);
111
- allowedErrs = errorsAllowed;
112
- const replacementArray = [];
113
- Object.keys(settingsObject).forEach(key => {
114
- Object.values(settingsObject[key].replacements).forEach(val => {
115
- if (!replacementArray.includes(val)) {
116
- replacementArray.push(val);
151
+
152
+ module.exports = {
153
+ plugin: postcss.plugin('postcss-variable-report', cssVariableReplacementConfig => {
154
+ const rawdata = fs.readFileSync(cssVariableReplacementConfig);
155
+ const data = JSON.parse(rawdata);
156
+ const {
157
+ errorsAllowed,
158
+ settings: settingsObject // errorLog: errorLogStatus,
159
+ // errorInConsole: errorConsoleStatus
160
+
161
+ } = data; // const keys = Object.keys(settingsObject);
162
+
163
+ errHandler.setAllowedErrs(errorsAllowed);
164
+ const replacementArray = [];
165
+ Object.keys(settingsObject).forEach(key => {
166
+ Object.values(settingsObject[key].replacements).forEach(val => {
167
+ if (!replacementArray.includes(val)) {
168
+ replacementArray.push(val);
169
+ }
170
+ });
171
+ });
172
+ let regValStr = '';
173
+ replacementArray.forEach((val, index) => {
174
+ if (index !== replacementArray.length - 1) {
175
+ regValStr += `${val.replace('$$', '\\d+').replace('(', '\\(').replace(')', '\\)')}|`;
176
+ } else {
177
+ regValStr += `${val.replace('$$', '\\d+').replace('(', '\\(').replace(')', '\\)')}`;
117
178
  }
118
179
  });
119
- });
120
- let regValStr = '';
121
- replacementArray.forEach((val, index) => {
122
- if (index !== replacementArray.length - 1) {
123
- regValStr += `${val.replace('$$', '\\d+').replace('(', '\\(').replace(')', '\\)')}|`;
124
- } else {
125
- regValStr += `${val.replace('$$', '\\d+').replace('(', '\\(').replace(')', '\\)')}`;
126
- }
127
- });
128
- const valRegex = new RegExp(regValStr, 'gi');
129
- return rootOriginal => {
130
- rootOriginal.walkRules(rule => {
131
- // rule.nodes[-1] = {}
132
- // need map, forEach fine less memory
133
- rule.nodes.forEach((decl, position) => {
134
- // case font-size
135
- const commentStr = 'variable:ignore';
136
- const prevNode = rule.nodes[position - 1];
137
- const fromPath = rootOriginal.source.input.from;
138
- // this will be problem for linux and mac use require('path').sep
139
- // split not need use slice and lastIndexOf less memory
140
- const filename = fromPath.split(path.sep).pop();
141
- if (prevNode && prevNode.type === 'comment' && prevNode.text.toLowerCase().includes(commentStr)) {
142
- const errStr = ` prop: ${decl.prop} ,\n value : ${decl.value} ,\n filename : ${filename} ,\n filepath : ${fromPath} ,\n line : ${decl.source.start.line} ,\n message : Declaration Ignored \r`;
143
- errorFunction(errStr, 'DECLARATION_IGNORED');
144
- return;
145
- }
146
- if (settingsObject[decl.prop] && !decl.value.includes('var(--')) {
147
- const settings = settingsObject[decl.prop];
148
- // console.log(settings)
149
- const {
150
- allowed,
151
- range
152
- } = settings;
153
- // suggestion filter !decl.value.includes('calc')
154
- // Reason below some of logic happen based on this
155
- const unit = decl.value.toString()
156
- // no need round braket since you do not need group for less memory
157
- .replace(/\d+/gi, '').replace('var(--zd_size)', 'px').replace('var(--zd_font_size)', 'px').split(' ').filter(x => x !== '');
158
- // unit = unit.replace(unit, unit.replace('-',''))
159
- // console.log('unit : ');
160
- // console.log(unit);
161
- unit.forEach((val, index) => {
162
- allowed.forEach(alwdVal => {
163
- if (val.includes(alwdVal)) {
164
- // ## for what purpose
165
- unit[index] = val.replace(`-${alwdVal}`, `${alwdVal}`).replace(`-.${alwdVal}`, `${alwdVal}`);
166
- }
180
+ const valRegex = new RegExp(regValStr, 'gi');
181
+ return rootOriginal => {
182
+ rootOriginal.walkRules(rule => {
183
+ // rule.nodes[-1] = {}
184
+ // need map, forEach fine less memory
185
+ rule.nodes.forEach((decl, position) => {
186
+ // case font-size
187
+ const commentStr = 'variable:ignore';
188
+ const prevNode = rule.nodes[position - 1];
189
+ const fromPath = rootOriginal.source.input.from; // this will be problem for linux and mac use require('path').sep
190
+ // split not need use slice and lastIndexOf less memory
191
+
192
+ const filename = fromPath.split(path.sep).pop();
193
+
194
+ if (prevNode && prevNode.type === 'comment' && prevNode.text.toLowerCase().includes(commentStr)) {
195
+ let errObj = {
196
+ decl,
197
+ type: 'DECLARATION_IGNORED',
198
+ filename,
199
+ message: 'Declaration Ignored',
200
+ path: fromPath
201
+ };
202
+ errHandler.errorTable.push(errObj);
203
+ errHandler.DECLARATION_IGNORED(errObj);
204
+ return;
205
+ }
206
+
207
+ if (settingsObject[decl.prop] && !decl.value.includes('var(--')) {
208
+ const settings = settingsObject[decl.prop]; // console.log(settings)
209
+
210
+ const {
211
+ allowed,
212
+ range
213
+ } = settings; // suggestion filter !decl.value.includes('calc')
214
+ // Reason below some of logic happen based on this
215
+
216
+ const unit = decl.value.toString() // no need round braket since you do not need group for less memory
217
+ .replace(/\d+/gi, '').replace('var(--zd_size)', 'px').replace('var(--zd_font_size)', 'px').replace('rect(', '').replace(')', '').replace('px,', 'px').replace(',', '').split(' ').filter(x => x !== ''); // unit = unit.replace(unit, unit.replace('-',''))
218
+ // console.log('unit : ');
219
+ // console.log(unit);
220
+
221
+ unit.forEach((val, index) => {
222
+ allowed.forEach(alwdVal => {
223
+ if (val.includes(alwdVal)) {
224
+ // ## for what purpose
225
+ unit[index] = val // .replace(new RegExp('(\\d+).(\\d+)(\\w+)', 'gi'), '$3')
226
+ .replace(`-${alwdVal}`, `${alwdVal}`).replace(`-.${alwdVal}`, `${alwdVal}`).replace(`${alwdVal},`, `${alwdVal}`);
227
+ }
228
+ });
167
229
  });
168
- });
169
- let unitError = false;
170
- let unitErrorVal = '';
171
- unit.forEach(val => {
172
- if (!val.includes('calc')) {
173
- if (!allowed.includes(val.toString())) {
174
- unitError = true;
175
- unitErrorVal = val;
230
+ let unitError = false;
231
+ let unitErrorVal = '';
232
+ unit.forEach(val => {
233
+ if (!val.includes('calc') && decl.prop !== 'clip') {
234
+ if (!allowed.includes(val.toString())) {
235
+ unitError = true;
236
+ unitErrorVal = val;
237
+ }
176
238
  }
177
- }
178
- });
179
- // console.log(allowed, replacements, range)
180
- if (!unitError) {
181
- // use variable decl.value.split(' ')
182
- if (range) {
183
- // console.log('multiple :', decl.value)
184
- let newVal = '';
185
- decl.value.split(' ').forEach(singleVal => {
186
- newVal += `${singleConvertor(singleVal, settings.replacements.px, {
239
+ }); // console.log(allowed, replacements, range)
240
+
241
+ if (!unitError) {
242
+ // use variable decl.value.split(' ')
243
+ if (range) {
244
+ // console.log('multiple :', decl.value)
245
+ let newVal = '';
246
+ decl.value.split(' ').forEach(singleVal => {
247
+ newVal += `${singleConvertor(singleVal, settings.replacements.px, {
248
+ decl,
249
+ filename,
250
+ path: fromPath
251
+ }, range)} `;
252
+ });
253
+ decl.value = newVal;
254
+ }
255
+ } else {
256
+ if (!decl.value.includes('calc')) {
257
+ // addError(` prop: ${decl.prop} ,\n value : ${decl.value} ,\n filename : ${filename} ,\n filepath : ${path} ,\n line : ${decl.source.start.line} ,\n unit : ${unitErrorVal} ,\n message : ${unitErrorVal} (Unit) Not Allowed \r`);
258
+ let errObj = {
187
259
  decl,
188
260
  filename,
261
+ unitErrorVal: unitErrorVal,
189
262
  path: fromPath
190
- }, range)} `;
191
- });
192
- decl.value = newVal;
263
+ };
264
+
265
+ if (unitErrorVal.trim() === '.') {
266
+ errObj.type = 'DECIMAL_CHECK';
267
+ errObj.message = `${unitErrorVal} (Decimal Value) Please check`;
268
+ errHandler.errorTable.push(errObj);
269
+ errHandler.DECIMAL_CHECK(errObj);
270
+ } else if (unitErrorVal.includes('.') && !unitErrorVal.includes('%')) {
271
+ errObj.type = 'DECIMAL_REJECT';
272
+ errObj.message = `${unitErrorVal} (Decimal Value) Not Allowed \r`;
273
+ errHandler.errorTable.push(errObj);
274
+ errHandler.DECIMAL_REJECT(errObj);
275
+ } else {
276
+ if (!unitErrorVal.includes('%')) {
277
+ errObj.type = 'UNIT_ERROR';
278
+ errObj.message = `${unitErrorVal} (Unit) Not Allowed`;
279
+ errHandler.errorTable.push(errObj);
280
+ errHandler.UNIT_ERROR(errObj);
281
+ }
282
+ }
283
+ } else {
284
+ decl.value = pxToCalc(decl.value);
285
+ }
193
286
  }
194
287
  } else {
195
- if (!decl.value.includes('calc')) {
196
- // addError(` prop: ${decl.prop} ,\n value : ${decl.value} ,\n filename : ${filename} ,\n filepath : ${path} ,\n line : ${decl.source.start.line} ,\n unit : ${unitErrorVal} ,\n message : ${unitErrorVal} (Unit) Not Allowed \r`);
197
- errorFunction(` prop: ${decl.prop} ,\n value : ${decl.value} ,\n filename : ${filename} ,\n filepath : ${fromPath} ,\n line : ${decl.source.start.line} ,\n unit : ${unitErrorVal} ,\n message : ${unitErrorVal} (Unit) Not Allowed \r`, 'UNIT_ERROR');
198
- } else {
199
- decl.value = pxToCalc(decl.value);
288
+ if (decl.prop && decl.value && !decl.prop.includes('--') && valRegex.test(decl.value) && (settingsObject[decl.prop] || convertableProps[decl.prop]) && decl.value.includes('var') && !decl.value.includes('calc')) {
289
+ let errObj = {
290
+ decl,
291
+ type: 'VARIABLE_PRESENT',
292
+ filename,
293
+ message: `value (${decl.value}) has var in it, kindly check`,
294
+ path: fromPath
295
+ };
296
+ errHandler.errorTable.push(errObj);
297
+ errHandler.VARIABLE_PRESENT(errObj);
200
298
  }
201
299
  }
202
- } else {
203
- if (decl.prop && decl.value && !decl.prop.includes('--') && valRegex.test(decl.value) && (settingsObject[decl.prop] || convertableProps[decl.prop]) && decl.value.includes('var') && !decl.value.includes('calc')) {
204
- errorFunction(` prop: ${decl.prop} ,\n value : ${decl.value} ,\n filename : ${filename} ,\n filepath : ${fromPath} ,\n line : ${decl.source.start.line} ,\n message : value (${decl.value}) has var in it, kindly check`, 'VARIABLE_PRESENT');
205
- }
206
- }
207
- });
208
- });
209
- // console.log(filename)
210
- // console.log('Done!')
211
- // console.log('----------------------------------------------------------------------------------------------------------------------')
212
- if (errorLogStatus) {
213
- fs.writeFileSync('./css_error.log', '');
214
- if (errors.length > 0) {
215
- errors.forEach(err => {
216
- fs.appendFileSync('./css_error.log', err);
217
300
  });
218
- // console.log('----------------------------------------------------------------------------------------------------------------------')
219
- }
220
- }
221
-
222
- if (errorConsoleStatus) {
223
- if (errors.length > 0) {
224
- errors.forEach(err => {
225
- // fs.appendFileSync('./css_error.log', err);
226
- console.log(err);
227
- });
228
- console.log('----------------------------------------------------------------------------------------------------------------------');
229
- }
230
- }
231
- };
232
- });
301
+ });
302
+ };
303
+ }),
304
+ errors: errHandler.errors,
305
+ errTable: errHandler.errorTable,
306
+ errHandler
307
+ };
@@ -1,15 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  const postcss = require('postcss');
4
+
4
5
  const path = require('path');
6
+
5
7
  const fs = require('fs');
8
+
6
9
  function populateArray(start, end) {
7
10
  let temp = [];
11
+
8
12
  for (var i = start; i < end; i++) {
9
13
  temp.push(i);
10
14
  }
15
+
11
16
  return temp;
12
17
  }
18
+
13
19
  let allwdVars = {
14
20
  'font-size': ['px', 'em']
15
21
  };
@@ -78,9 +84,11 @@ let numberObject = {
78
84
  }
79
85
  }
80
86
  };
87
+
81
88
  function hasIgnoreComment(node) {
82
89
  return node ? node.type == 'comment' ? node.text == 'Variable:Ignore' ? true : false : false : false;
83
90
  }
91
+
84
92
  let errors = [];
85
93
  module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal => {
86
94
  // console.log('inside postcss plugin')
@@ -99,20 +107,21 @@ module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal =>
99
107
  let path = rootOriginal.source.input.from;
100
108
  let filename = path.split('\\');
101
109
  filename = filename[filename.length - 1];
110
+
102
111
  if (decl.prop === 'font-size' || decl.prop === 'margin-left' || decl.prop === 'margin-right' || decl.prop === 'margin-top' || decl.prop === 'margin-bottom') {
103
112
  let {
104
113
  allowed,
105
114
  replacements,
106
115
  available
107
116
  } = settings;
117
+
108
118
  if (!rootOriginal.source.input.from.includes('node_modules')) {
109
119
  if (unit != 0) {
110
120
  if (allowed.includes(unit)) {
111
121
  // console.log(available, parseInt(decl.value))
112
122
  if (available.includes(parseInt(decl.value))) {
113
123
  // replacementValues[unit].push({[decl.value] : replacements[unit].replace('$$', parseInt(decl.value))})
114
- decl.value = replacements[unit].replace('$$', parseInt(decl.value));
115
- //console.log("replacements:")
124
+ decl.value = replacements[unit].replace('$$', parseInt(decl.value)); //console.log("replacements:")
116
125
  } else {
117
126
  let err = {
118
127
  prop: decl.prop,
@@ -144,16 +153,17 @@ module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal =>
144
153
  allowed,
145
154
  replacements,
146
155
  available
147
- } = settings;
148
- //console.log(decl.prop + " " + decl.value)
149
- let valArr = decl.value.split(' ');
150
- //console.log(valArr)
156
+ } = settings; //console.log(decl.prop + " " + decl.value)
157
+
158
+ let valArr = decl.value.split(' '); //console.log(valArr)
151
159
  //console.log(allowed, replacements, available)
160
+
152
161
  let hasError = false;
153
162
  let newVal = '';
154
163
  valArr.forEach(val => {
155
164
  let unit = val.replace(parseInt(val), '');
156
165
  let numVal = parseInt(val);
166
+
157
167
  if (unit != 0) {
158
168
  if (allowed.includes(unit)) {
159
169
  if (available.includes(numVal)) {
@@ -194,31 +204,29 @@ module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal =>
194
204
  }
195
205
  }
196
206
  });
207
+
197
208
  if (!hasError) {
198
209
  decl.value = newVal;
199
210
  }
200
211
  }
201
212
  }
202
213
  });
203
- });
204
- //fs.writeFile('./src/trial.json', JSON.stringify(variables) ,(err) =>{
214
+ }); //fs.writeFile('./src/trial.json', JSON.stringify(variables) ,(err) =>{
205
215
  // if(err)console.log(err);
206
216
  // else{
207
217
  // console.log('updated successfully');
208
218
  // }
209
219
  // })
210
220
  // console.log(errors)
221
+
211
222
  let errorArr = [];
212
223
  errors.forEach(errStr => {
213
224
  errorArr.push(` prop: ${errStr.prop} ,\n value : ${errStr.value} ,\n filename : ${errStr.filename} ,\n filepath : ${errStr.filepath} ,\n line : ${errStr.line} ,\n unit : ${errStr.unit} ,\n message : ${errStr.message} \r`);
214
- });
215
-
216
- //fs.writeFile('./css_error.log','', (err) =>{
225
+ }); //fs.writeFile('./css_error.log','', (err) =>{
217
226
  // if(err){
218
227
  // console.log(err);
219
228
  // }
220
229
  //});
221
-
222
230
  // errorArr.forEach(err => {
223
231
  // let data = `\n{\n${err}\n},\n`;
224
232
  // //fs.appendFile('./css_error.log',data,(err)=>{
@@ -228,7 +236,6 @@ module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal =>
228
236
  // //})
229
237
  // });
230
238
  // fs.writeFileSync('./css_error.log','');
231
-
232
239
  // errorArr.forEach(err => {
233
240
  // let data = `\n{\n${err}\n},\n`;
234
241
  // fs.appendFileSync('./css_error.log',data);
@@ -4,10 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _os = require("os");
9
+
8
10
  var _getIp = _interopRequireDefault(require("../utils/getIp"));
11
+
9
12
  var _getCurrentBranch = _interopRequireDefault(require("../utils/getCurrentBranch"));
13
+
10
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
11
16
  // TODO move deprecated options to separate file and manage seperately
12
17
  var _default = {
13
18
  cliRootPath: null,
@@ -212,15 +217,22 @@ var _default = {
212
217
  hasRTL: false,
213
218
  hoverActive: false,
214
219
  combinerMediaQuery: false,
215
- cssVariableReplacement: false
220
+ cssVariableReplacement: false,
221
+ selectorWeight: false
216
222
  },
217
223
  exclude: {
218
224
  rtl: [],
219
225
  hoverActive: [],
220
226
  combinerMediaQuery: [],
221
- cssVariableReplacement: []
227
+ cssVariableReplacement: [],
228
+ selectorWeight: []
222
229
  },
223
230
  cssVariableReplacementConfig: '',
231
+ selectorWeightConfig: {
232
+ defaultSelector: '',
233
+ customFileDetails: '',
234
+ excludeStrings: []
235
+ },
224
236
  seperateCssModules: {
225
237
  value: false,
226
238
  cli: 'sep_cssmodules'
@@ -302,15 +314,22 @@ var _default = {
302
314
  hasRTL: false,
303
315
  hoverActive: false,
304
316
  combinerMediaQuery: false,
305
- cssVariableReplacement: false
317
+ cssVariableReplacement: false,
318
+ selectorWeight: false
306
319
  },
307
320
  exclude: {
308
321
  rtl: [],
309
322
  hoverActive: [],
310
323
  combinerMediaQuery: [],
311
- cssVariableReplacement: []
324
+ cssVariableReplacement: [],
325
+ selectorWeight: []
312
326
  },
313
327
  cssVariableReplacementConfig: '',
328
+ selectorWeightConfig: {
329
+ defaultSelector: '',
330
+ customFileDetails: '',
331
+ excludeStrings: []
332
+ },
314
333
  cssHashSelectors: {
315
334
  filenames: [],
316
335
  packages: []
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  var _path = _interopRequireDefault(require("path"));
4
+
4
5
  var _fs = _interopRequireDefault(require("fs"));
6
+
5
7
  var _express = _interopRequireDefault(require("express"));
8
+
6
9
  var _utils = require("../utils");
10
+
7
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+
8
13
  let options = (0, _utils.getOptions)();
9
14
  let {
10
15
  cluster: {
@@ -13,13 +18,17 @@ let {
13
18
  } = options;
14
19
  let app = (0, _express.default)();
15
20
  let appPath = process.cwd();
21
+
16
22
  let clusterConfigPath = _path.default.join(appPath, 'clusterConfig.js');
23
+
17
24
  let config;
25
+
18
26
  if (_fs.default.existsSync(clusterConfigPath)) {
19
27
  config = require(clusterConfigPath);
20
28
  } else {
21
29
  throw new Error(`clusterConfig.js doen't exist under following path - ${clusterConfigPath}`);
22
30
  }
31
+
23
32
  app.get('/clusterhub/nodes', (req, res) => {
24
33
  res.send(JSON.stringify(config.cluster));
25
34
  });
@@ -28,5 +37,6 @@ app.listen(server.port, err => {
28
37
  if (err) {
29
38
  throw err;
30
39
  }
40
+
31
41
  (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)(server, 'ht' + 'tp')}/clusterhub/`);
32
42
  });