@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,15 @@
1
1
  "use strict";
2
2
 
3
3
  var _postcss = _interopRequireDefault(require("postcss"));
4
+
4
5
  var _postcssHashClassname = _interopRequireDefault(require("postcss-hash-classname"));
6
+
5
7
  var _fs = _interopRequireDefault(require("fs"));
8
+
6
9
  var _utils = require("../../utils");
10
+
7
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+
8
13
  let count = 0;
9
14
  const options = (0, _utils.getOptions)();
10
15
  const {
@@ -23,8 +28,11 @@ module.exports = {
23
28
  };
24
29
  const processor = (0, _postcss.default)([(0, _postcssHashClassname.default)(opts)]);
25
30
  processor.process(src).css;
31
+
26
32
  const jsonMap = _fs.default.readFileSync(`jsonFile_test_${count}.json`, 'UTF-8');
33
+
27
34
  _fs.default.unlinkSync(`jsonFile_test_${count}.json`);
35
+
28
36
  return `module.exports =${jsonMap}`;
29
37
  }
30
38
  };
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  var _babelJest = _interopRequireDefault(require("babel-jest"));
4
+
4
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+
5
7
  module.exports = _babelJest.default.createTransformer({
6
8
  presets: [require.resolve('@babel/preset-env'), require.resolve('@babel/preset-react')],
7
9
  plugins: [require.resolve('babel-plugin-transform-dynamic-import')]
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  var _path = _interopRequireDefault(require("path"));
4
+
4
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+
5
7
  module.exports = {
6
8
  process(src, filename) {
7
9
  return `module.exports = ${JSON.stringify(_path.default.basename(filename))};`;
8
10
  }
11
+
9
12
  };
@@ -1,18 +1,25 @@
1
1
  "use strict";
2
2
 
3
3
  var _fs = _interopRequireDefault(require("fs"));
4
+
4
5
  var _utils = require("../utils");
6
+
5
7
  var _jsonMaker = _interopRequireDefault(require("./jsonMaker"));
8
+
6
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+
7
11
  let unitTestReport = [];
12
+
8
13
  const result = inp => {
9
14
  inp.endTime = Date.now();
10
15
  let testPathPattern = process.argv[process.argv.length - 1];
16
+
11
17
  if (testPathPattern.indexOf('--') !== -1) {
12
18
  testPathPattern = '';
13
19
  } else {
14
20
  testPathPattern = _fs.default.realpathSync(process.cwd());
15
21
  }
22
+
16
23
  let testPathRegex = new RegExp(testPathPattern);
17
24
  let {
18
25
  testResults
@@ -20,9 +27,11 @@ const result = inp => {
20
27
  let testFilesArr = [];
21
28
  testResults.forEach(testResult => {
22
29
  let filePath = testResult.testFilePath;
30
+
23
31
  if (!testPathRegex.test(filePath)) {
24
32
  return;
25
33
  }
34
+
26
35
  filePath = filePath.replace('.spec', '');
27
36
  filePath = filePath.replace('/__tests__', '');
28
37
  filePath = filePath.replace('/__test__', '');
@@ -39,28 +48,35 @@ const result = inp => {
39
48
  });
40
49
  });
41
50
  });
51
+
42
52
  let coverageSummary = _fs.default.readFileSync('./coverage/coverage-summary.json').toString();
53
+
43
54
  if (coverageSummary.indexOf('\\') !== -1) {
44
55
  coverageSummary = coverageSummary.replace(/\\/g, '\\\\');
45
56
  }
57
+
46
58
  let coverageJson = JSON.parse(coverageSummary);
47
59
  let linesPercent = 0;
48
60
  let functionPercent = 0;
49
61
  let statementPerment = 0;
50
62
  let branchesPercent = 0;
51
63
  let i = 0;
64
+
52
65
  for (i; i < testFilesArr.length; i++) {
53
66
  let curSourceFile = testFilesArr[i].sourcePath;
54
67
  let coverageData = coverageJson[curSourceFile];
68
+
55
69
  if (!coverageData) {
56
70
  (0, _utils.log)(`Can't able to find source for ${testFilesArr[i].testPath}\n Or The spec file getting failed during test. Please check the file name and the path is correct for test file or Make them pass.`);
57
71
  continue;
58
72
  }
73
+
59
74
  linesPercent += coverageData.lines.pct;
60
75
  functionPercent += coverageData.functions.pct;
61
76
  statementPerment += coverageData.statements.pct;
62
77
  branchesPercent += coverageData.branches.pct;
63
78
  }
79
+
64
80
  let totalLinesPercent = linesPercent / (i * 100) * 100;
65
81
  let totalFunctionPercent = functionPercent / (i * 100) * 100;
66
82
  let totalStatementPercent = statementPerment / (i * 100) * 100;
@@ -69,12 +85,14 @@ const result = inp => {
69
85
  let coverage = (totalPercentage / 4).toFixed(2);
70
86
  coverage = Number(coverage);
71
87
  (0, _jsonMaker.default)(inp, coverage, 'Yes', 'unitcase');
88
+
72
89
  if (Number.isNaN(coverage)) {
73
90
  (0, _utils.log)('This build does\'t have any JS changes!');
74
91
  coverage = 0;
75
92
  } else {
76
93
  (0, _utils.log)(`COVERAGE ${coverage}%`);
77
94
  }
95
+
78
96
  let html = `<html>
79
97
  <head>
80
98
  <style>
@@ -116,10 +134,14 @@ const result = inp => {
116
134
  </body>
117
135
  </html>
118
136
  `;
137
+
119
138
  if (!_fs.default.existsSync('./unittest')) {
120
139
  _fs.default.mkdirSync('./unittest');
121
140
  }
141
+
122
142
  _fs.default.writeFileSync('./unittest/index.html', html, 'utf8');
143
+
123
144
  return inp;
124
145
  };
146
+
125
147
  module.exports = result;
package/lib/jest/run.js CHANGED
@@ -1,11 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  var _jest = require("jest");
4
+
4
5
  var _fs = _interopRequireDefault(require("fs"));
6
+
5
7
  var _utils = require("../utils");
8
+
6
9
  var _jsonHelper = require("../utils/jsonHelper");
10
+
7
11
  var _coverageCollector = _interopRequireDefault(require("./coverageCollector"));
12
+
8
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
9
15
  let options = (0, _utils.getOptions)();
10
16
  let {
11
17
  app: {
@@ -21,7 +27,9 @@ let {
21
27
  }
22
28
  } = options;
23
29
  let argv = process.argv.slice(2);
30
+
24
31
  let config = require('../configs/jest.config');
32
+
25
33
  if (isCommitCoverage) {
26
34
  (0, _coverageCollector.default)(srcBranch, targetBranch, serviceName, impactServerDomain).then((res = {}) => {
27
35
  if (res.STATUS) {
@@ -29,12 +37,15 @@ if (isCommitCoverage) {
29
37
  let content = {
30
38
  FILES: res.LIST
31
39
  };
40
+
32
41
  if (!_fs.default.existsSync('./coverageTest')) {
33
42
  _fs.default.mkdirSync('./coverageTest');
43
+
34
44
  _fs.default.writeFileSync('./coverageTest/result.json', JSON.stringify(content), 'utf8');
35
45
  } else {
36
46
  _fs.default.writeFileSync('./coverageTest/result.json', JSON.stringify(content), 'utf8');
37
47
  }
48
+
38
49
  argv.push('--findRelatedTests');
39
50
  argv = argv.concat(res.LIST);
40
51
  argv = argv.concat(['--config', JSON.stringify(config(null, true))]);
@@ -42,12 +53,12 @@ if (isCommitCoverage) {
42
53
  argv.push('--silent');
43
54
  (0, _jest.run)(argv);
44
55
  } else {
45
- (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, ['tests', 'modifiedFileUnitCase', 'hasChanges'], false);
46
- // jsonHelper(
56
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, ['tests', 'modifiedFileUnitCase', 'hasChanges'], false); // jsonHelper(
47
57
  // `${process.cwd()}/result.json`,
48
58
  // 'testInfo.isBuildVerified',
49
59
  // true
50
60
  // );
61
+
51
62
  (0, _jsonHelper.setTestInfoStatus)(`${process.cwd()}/result.json`, true);
52
63
  (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'testInfo.failures', [{
53
64
  type: 'modifiedUnitcases',
@@ -56,17 +67,17 @@ if (isCommitCoverage) {
56
67
  (0, _utils.log)('No JS changes with last changeset!');
57
68
  }
58
69
  } else {
59
- (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, ['tests', 'modifiedFileUnitCase', 'isExecuted'], res.STATUS);
60
- // jsonHelper(
70
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, ['tests', 'modifiedFileUnitCase', 'isExecuted'], res.STATUS); // jsonHelper(
61
71
  // `${process.cwd()}/result.json`,
62
72
  // 'testInfo.isBuildVerified',
63
73
  // true
64
74
  // );
65
- (0, _jsonHelper.setTestInfoStatus)(`${process.cwd()}/result.json`, true);
66
- // jsonHelper(`${process.cwd()}/result.json`, 'testInfo.failures', [{
75
+
76
+ (0, _jsonHelper.setTestInfoStatus)(`${process.cwd()}/result.json`, true); // jsonHelper(`${process.cwd()}/result.json`, 'testInfo.failures', [{
67
77
  // type: 'modifiedUnitcases',
68
78
  // message: res.REASON
69
79
  // }]);
80
+
70
81
  (0, _utils.log)(res.REASON);
71
82
  }
72
83
  });
package/lib/jest/setup.js CHANGED
@@ -1,15 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  var _jsdom = require("jsdom");
4
+
4
5
  var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));
6
+
5
7
  var _react = _interopRequireDefault(require("react"));
8
+
6
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
+
7
11
  var _reactDom = _interopRequireDefault(require("react-dom"));
12
+
8
13
  var _xhr = _interopRequireDefault(require("xhr2"));
14
+
9
15
  var _nock = _interopRequireDefault(require("nock"));
16
+
10
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- //$Id$//
12
18
 
19
+ //$Id$//
13
20
  let mockDomain = 'htt' + 'p://zoho.com';
14
21
  const {
15
22
  document
@@ -21,136 +28,181 @@ global.localStorage = global.sessionStorage = {
21
28
  getItem(key) {
22
29
  return this[key];
23
30
  },
31
+
24
32
  setItem(key, value) {
25
33
  if (value.length > 100) {
26
34
  throw new Error('Data size is too exceeded');
27
35
  }
36
+
28
37
  this[key] = value;
29
38
  },
39
+
30
40
  removeItem(key) {
31
41
  delete this[key];
32
42
  },
43
+
33
44
  clear() {
34
45
  let keys = ['getItem', 'setItem', 'removeItem', 'clear'];
46
+
35
47
  for (let key in this) {
36
48
  if (keys.indexOf(key) === -1) {
37
49
  delete this[key];
38
50
  }
39
51
  }
40
52
  }
53
+
41
54
  };
42
55
  global.ZE_Init = {};
56
+
43
57
  global.String.prototype.contains = function (text) {
44
58
  return this.indexOf(text) != -1;
45
59
  };
60
+
46
61
  global.TestUtils = _testUtils.default;
47
62
  let xmlReq = _xhr.default;
63
+
48
64
  window.XMLHttpRequest = function () {
49
65
  let xmlReqCopy = new xmlReq();
50
66
  let originalOpen = xmlReqCopy.open;
67
+
51
68
  xmlReqCopy.open = function () {
52
69
  if (arguments[1].indexOf('http') != 0) {
53
70
  arguments[1] = mockDomain + arguments[1];
54
71
  }
72
+
55
73
  return originalOpen.apply(this, arguments);
56
74
  };
75
+
57
76
  return xmlReqCopy;
58
77
  };
78
+
59
79
  _testUtils.default.scryRenderedComponentsWithTestid = function (dom, name) {
60
80
  let componentList = _testUtils.default.findAllInRenderedTree(dom, (i, j) => {
61
81
  if (_testUtils.default.isDOMComponent(i)) {
62
82
  let val = i.getAttribute('data-id');
83
+
63
84
  if (typeof val !== 'undefined' && val == name) {
64
85
  return true;
65
86
  }
87
+
66
88
  return false;
67
89
  }
68
90
  });
91
+
69
92
  return componentList;
70
93
  };
94
+
71
95
  _testUtils.default.findRenderedComponentsWithTestid = function (dom, name) {
72
96
  let list = _testUtils.default.scryRenderedComponentsWithTestid(dom, name);
97
+
73
98
  if (list.length !== 1) {
74
99
  throw new Error(`Did not find exactly one match (found: ${list.length}) ` + `for data-id:${name}`);
75
100
  }
101
+
76
102
  return list[0];
77
103
  };
104
+
78
105
  global.render = function (Component, props) {
79
106
  const renderedDOM = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(Component, props));
107
+
80
108
  return {
81
109
  props,
82
110
  renderedDOM
83
111
  };
84
112
  };
113
+
85
114
  global.setup = function (Component, props, state) {
86
115
  let router = {
87
116
  router: {
88
117
  push() {},
118
+
89
119
  createHref(ob) {
90
120
  return ob.pathname;
91
121
  },
122
+
92
123
  isActive() {
93
124
  return true;
94
125
  },
126
+
95
127
  replace() {},
128
+
96
129
  go() {},
130
+
97
131
  goBack() {},
132
+
98
133
  goForward() {},
134
+
99
135
  setRouteLeaveHook() {},
136
+
100
137
  getState() {}
138
+
101
139
  },
102
140
  store: {
103
141
  getState() {
104
142
  return state;
105
143
  }
144
+
106
145
  }
107
- };
108
- // var store = {
146
+ }; // var store = {
109
147
  // store:{
110
148
  // getState:function(){return state;}
111
149
  // }
112
150
  // }
151
+
113
152
  var Component = higherComponent(Component, router);
153
+
114
154
  const renderedDOM = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(Component, props), router);
155
+
115
156
  return {
116
157
  props,
117
158
  renderedDOM
118
159
  };
119
160
  };
161
+
120
162
  function higherComponent(ActualComponent, context) {
121
163
  if (context) {
122
164
  class HigherComponent extends _react.default.Component {
123
165
  constructor() {
124
166
  super();
125
167
  }
168
+
126
169
  getChildContext() {
127
170
  return context;
128
171
  }
172
+
129
173
  render() {
130
174
  return /*#__PURE__*/_react.default.createElement(ActualComponent, this.props);
131
175
  }
176
+
132
177
  }
178
+
133
179
  HigherComponent.childContextTypes = {
134
180
  router: _propTypes.default.any,
135
181
  store: _propTypes.default.any
136
182
  };
137
183
  return HigherComponent;
138
184
  }
185
+
139
186
  return ActualComponent;
140
187
  }
188
+
141
189
  global.window.matchMedia = window.matchMedia || function () {
142
190
  return {
143
191
  matches: false,
192
+
144
193
  addListener() {},
194
+
145
195
  removeListener() {}
196
+
146
197
  };
147
- };
148
- // global.renderHTML = function(comp) {
198
+ }; // global.renderHTML = function(comp) {
149
199
  // return ReactDOM.findDOMNode(comp);
150
200
  // };
151
201
 
202
+
152
203
  global.TestUtils = _testUtils.default;
153
204
  global.XMLHttpRequest = window.XMLHttpRequest;
205
+
154
206
  global.getI18NValue = function (inp) {
155
207
  return inp;
156
208
  };
@@ -10,47 +10,57 @@ exports.configSVGLoader = configSVGLoader;
10
10
  exports.configVideoLoader = configVideoLoader;
11
11
  exports.configVideoLoaderObj = configVideoLoaderObj;
12
12
  exports.createNameTemplate = createNameTemplate;
13
+
13
14
  var _path = _interopRequireDefault(require("path"));
15
+
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
15
18
  // function getLoaderOptionQueryString(params) {
16
19
  const ImageExtRegex = /\.jpe?g$|\.gif$|\.png$/;
17
20
  const FontExtRegex = /\.woff2|\.woff$|\.ttf$|\.eot$/;
18
21
  const SVGExtRegex = /\.svg$/;
19
22
  const AudioExtRegex = /\.ogg$/;
20
23
  const VidioExtRegex = /\.mp4$/;
24
+
21
25
  function createLoaderOptionQueryString(loaderName, nameTemplate, limit = 1000) {
22
26
  return `${loaderName}?limit=${limit}&name=${nameTemplate}`;
23
27
  }
28
+
24
29
  function configImageLoader(nameTemplate) {
25
30
  return {
26
31
  test: ImageExtRegex,
27
32
  use: createLoaderOptionQueryString('url-loader', `./images/${nameTemplate}`)
28
33
  };
29
34
  }
35
+
30
36
  function configFontLoader(nameTemplate) {
31
37
  return {
32
38
  test: FontExtRegex,
33
39
  use: createLoaderOptionQueryString('url-loader', `./fonts/${nameTemplate}`)
34
40
  };
35
41
  }
42
+
36
43
  function configSVGLoader(nameTemplate) {
37
44
  return {
38
45
  test: SVGExtRegex,
39
46
  use: createLoaderOptionQueryString('url-loader', `./fonts/${nameTemplate}`, 1)
40
47
  };
41
48
  }
49
+
42
50
  function configAudioLoader(nameTemplate) {
43
51
  return {
44
52
  test: AudioExtRegex,
45
53
  use: createLoaderOptionQueryString('file-loader', `./fonts/${nameTemplate}`, 1)
46
54
  };
47
55
  }
56
+
48
57
  function configVideoLoader(nameTemplate) {
49
58
  return {
50
59
  test: VidioExtRegex,
51
60
  use: createLoaderOptionQueryString('url-loader', `./images/${nameTemplate}`, 1)
52
61
  };
53
62
  }
63
+
54
64
  function configVideoLoaderObj(nameTemplate) {
55
65
  return {
56
66
  test: VidioExtRegex,
@@ -64,44 +74,44 @@ function configVideoLoaderObj(nameTemplate) {
64
74
  }
65
75
  };
66
76
  }
77
+
67
78
  function createNameTemplate(enableChunkHash) {
68
79
  const ext = `${enableChunkHash ? '.[hash:20]' : ''}.[ext]`;
69
80
  return `[name]${ext}`;
70
81
  }
71
-
72
- /*
73
- export function createImageAndFontsAndSVGLoaders(enableChunkHash) {
74
- const nameTemplate = createNameTemplate(enableChunkHash);
75
- return [
76
- configImageLoader(nameTemplate),
77
- configFontLoader(nameTemplate),
78
- configSVGLoader(nameTemplate),
79
- configAudioLoader(nameTemplate)
80
- ];
81
- }
82
+ /*
83
+ export function createImageAndFontsAndSVGLoaders(enableChunkHash) {
84
+ const nameTemplate = createNameTemplate(enableChunkHash);
85
+ return [
86
+ configImageLoader(nameTemplate),
87
+ configFontLoader(nameTemplate),
88
+ configSVGLoader(nameTemplate),
89
+ configAudioLoader(nameTemplate)
90
+ ];
91
+ }
82
92
  */
83
93
 
84
- /*
85
- export function createLoaderOptionObject(
86
- loaderName,
87
- nameTemplate,
88
- fallback,
89
- limit = 1000
90
- ) {
91
- return {
92
- loader: loaderName,
93
- options: {
94
- limit,
95
- name: nameTemplate,
96
- fallback
97
- }
98
- };
99
- }
100
-
101
- function configLoaderObject(filter, loaderAndOptions) {
102
- return {
103
- test: filter,
104
- use: loaderAndOptions
105
- };
106
- }
94
+ /*
95
+ export function createLoaderOptionObject(
96
+ loaderName,
97
+ nameTemplate,
98
+ fallback,
99
+ limit = 1000
100
+ ) {
101
+ return {
102
+ loader: loaderName,
103
+ options: {
104
+ limit,
105
+ name: nameTemplate,
106
+ fallback
107
+ }
108
+ };
109
+ }
110
+
111
+ function configLoaderObject(filter, loaderAndOptions) {
112
+ return {
113
+ test: filter,
114
+ use: loaderAndOptions
115
+ };
116
+ }
107
117
  */
@@ -4,16 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
9
+
8
10
  var _cssClassNameGenerate = _interopRequireDefault(require("../utils/cssClassNameGenerate"));
11
+
9
12
  var _utils = require("../utils");
13
+
14
+ var _windowsModification = require("./windowsModification");
15
+
10
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
11
18
  const fs = require('fs');
19
+
12
20
  const options = (0, _utils.getOptions)();
13
- const isWin = process.platform === 'win32';
14
- function windowsModification(array) {
15
- return isWin ? array.map(r => r.replace(/\//g, '\\')) : array;
16
- }
21
+
17
22
  function excludeEmptyCheckPlugin({
18
23
  enable,
19
24
  ignore,
@@ -24,11 +29,23 @@ function excludeEmptyCheckPlugin({
24
29
  plugins
25
30
  })] : [];
26
31
  }
27
- const getCSSLoaders = (plugins, exclude, mediaQueryHoverActiveString, cssVariableReplacementConfig, classNameBlob, cssUniqueness, selectorReplace, cssHashSelectors, classNamePrefix) => {
28
- // console.log('plugins:')
32
+
33
+ const getCSSLoaders = optionsObj => {
34
+ const {
35
+ plugins,
36
+ exclude,
37
+ mediaQueryHoverActiveString,
38
+ cssVariableReplacementConfig,
39
+ classNameBlob,
40
+ cssUniqueness,
41
+ selectorReplace,
42
+ cssHashSelectors,
43
+ classNamePrefix
44
+ } = optionsObj; // console.log('plugins:')
29
45
  // console.log(plugins)
30
46
  // console.log('exclude:')
31
47
  // console.log(exclude)
48
+
32
49
  const {
33
50
  devCssFileBountry
34
51
  } = options.app;
@@ -38,29 +55,25 @@ const getCSSLoaders = (plugins, exclude, mediaQueryHoverActiveString, cssVariabl
38
55
  const {
39
56
  cssSelectorZipPath
40
57
  } = options.impactService;
41
- fs.writeFileSync('./css_error.log', '');
42
- const rtlExcludeLocal = windowsModification(exclude.rtl);
43
- const hoverActiveExcludeLocal = windowsModification(exclude.hoverActive);
44
- const combinerMediaQueryExcludeLocal = windowsModification(exclude.combinerMediaQuery);
45
- const cssVariableReplacementExcludeLocal = windowsModification(exclude.cssVariableReplacement);
58
+ const rtlExcludeLocal = (0, _windowsModification.windowsModification)(exclude.rtl);
59
+ const hoverActiveExcludeLocal = (0, _windowsModification.windowsModification)(exclude.hoverActive);
60
+ const combinerMediaQueryExcludeLocal = (0, _windowsModification.windowsModification)(exclude.combinerMediaQuery);
61
+ const cssVariableReplacementExcludeLocal = (0, _windowsModification.windowsModification)(exclude.cssVariableReplacement);
46
62
  const cssLoaderOptions = {
47
63
  // importLoaders: hasRTL||hoverActive ? 1 : 0,
48
64
  importLoaders: 1,
49
65
  modules: {},
50
66
  sourceMap: true
51
67
  };
68
+
52
69
  if (classNameBlob) {
53
70
  cssLoaderOptions.modules.localIdentName = classNameBlob;
54
71
  } else {
55
72
  cssLoaderOptions.modules.getLocalIdent = (0, _cssClassNameGenerate.default)(cssUniqueness, cssHashSelectors, classNamePrefix);
56
- }
57
- const postcssPlugins = [valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer), selectorReplace && require('postcss-selector-replace')(selectorReplace),
58
- // ...excludeEmptyCheckPlugin({
59
- // enable: true,
60
- // ignore: [],
61
- // plugins: [require('../postcss-plugins/variablePropertiesCollector').default()]
62
- // }),
63
- ...excludeEmptyCheckPlugin({
73
+ } // console.log('selector weight config : ', selectorWeightConfig);
74
+
75
+
76
+ const postcssPlugins = [valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer), selectorReplace && require('postcss-selector-replace')(selectorReplace), ...excludeEmptyCheckPlugin({
64
77
  enable: plugins.hasRTL,
65
78
  ignore: rtlExcludeLocal,
66
79
  plugins: [require('@zohodesk/postcss-rtl')({
@@ -68,6 +81,7 @@ const getCSSLoaders = (plugins, exclude, mediaQueryHoverActiveString, cssVariabl
68
81
  if (prefix === '[dir]') {
69
82
  return selector;
70
83
  }
84
+
71
85
  return `${prefix} ${selector}`; // Make selectors like [dir=rtl] > .selector
72
86
  }
73
87
  })]
@@ -82,7 +96,7 @@ const getCSSLoaders = (plugins, exclude, mediaQueryHoverActiveString, cssVariabl
82
96
  }), ...excludeEmptyCheckPlugin({
83
97
  enable: plugins.cssVariableReplacement,
84
98
  ignore: cssVariableReplacementExcludeLocal,
85
- plugins: [fs.existsSync(cssVariableReplacementConfig) && require('../postcss-plugins/variableModificationPlugin/index')(cssVariableReplacementConfig)]
99
+ plugins: [fs.existsSync(cssVariableReplacementConfig) && require('../postcss-plugins/variableModificationPlugin/index').plugin(cssVariableReplacementConfig)]
86
100
  })].filter(Boolean);
87
101
  return [cssSelectorZipPath && {
88
102
  loader: require.resolve('../loaders/selectorMappingLoader')
@@ -109,5 +123,6 @@ const getCSSLoaders = (plugins, exclude, mediaQueryHoverActiveString, cssVariabl
109
123
  }
110
124
  } : null].filter(Boolean);
111
125
  };
126
+
112
127
  var _default = getCSSLoaders;
113
128
  exports.default = _default;