@zohodesk/react-cli 0.0.1-beta.16 → 0.0.1-beta.160

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 (226) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.js +46 -3
  3. package/CHANGELOG.md +5 -0
  4. package/README.md +650 -0
  5. package/bin/cli.js +134 -27
  6. package/cert/cert.pem +37 -129
  7. package/cert/key.pem +27 -27
  8. package/cert/passphrase.pem +1 -0
  9. package/files/eslintrc.js +62 -0
  10. package/files/prettierrc.js +3 -0
  11. package/lib/babel/cmjs-plugins-presets.js +16 -9
  12. package/lib/babel/es-plugins-presets.js +26 -14
  13. package/lib/common/getEntries.js +33 -24
  14. package/lib/common/getPublicPathConfig.js +40 -0
  15. package/lib/common/index.js +27 -13
  16. package/lib/common/splitChunks.js +64 -26
  17. package/lib/common/sslcertUpdater.js +59 -0
  18. package/lib/common/templateParameters.js +25 -0
  19. package/lib/configs/jest.config.js +18 -28
  20. package/lib/configs/webpack.component.umd.config.js +31 -37
  21. package/lib/configs/webpack.css.umd.config.js +44 -44
  22. package/lib/configs/webpack.dev.config.js +113 -57
  23. package/lib/configs/webpack.docs.config.js +104 -98
  24. package/lib/configs/webpack.impact.config.js +116 -0
  25. package/lib/configs/webpack.prod.config.js +154 -86
  26. package/lib/hooks/docsProptypeHook.js +32 -38
  27. package/lib/jest/commitedFilesResult.js +144 -71
  28. package/lib/jest/coverageCollector.js +62 -29
  29. package/lib/jest/jsonMaker.js +54 -0
  30. package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
  31. package/lib/jest/preProcessors/jsPreprocessor.js +5 -6
  32. package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
  33. package/lib/jest/result.js +91 -41
  34. package/lib/jest/run.js +74 -27
  35. package/lib/jest/setup.js +103 -102
  36. package/lib/loaderUtils/getCSSLoaders.js +77 -0
  37. package/lib/loaderUtils/getDevJsLoaders.js +30 -23
  38. package/lib/loaderUtils/index.js +14 -7
  39. package/lib/loaders/docsLoader.js +15 -15
  40. package/lib/loaders/docsPropsLoader.js +14 -17
  41. package/lib/loaders/fileBountryLoader.js +17 -0
  42. package/lib/loaders/fileLoader.js +47 -38
  43. package/lib/loaders/scriptInstrumentLoader.js +21 -20
  44. package/lib/loaders/selectorMappingLoader.js +75 -0
  45. package/lib/loaders/workerLoader.js +136 -0
  46. package/lib/middlewares/HMRMiddleware.js +59 -41
  47. package/lib/middlewares/SSTMiddleware.js +21 -0
  48. package/lib/pluginUtils/getDevPlugins.js +173 -26
  49. package/lib/pluginUtils/getDocsPlugins.js +32 -17
  50. package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
  51. package/lib/pluginUtils/getLibraryPlugins.js +8 -10
  52. package/lib/pluginUtils/getProdPlugins.js +238 -37
  53. package/lib/pluginUtils/getServerPlugins.js +8 -11
  54. package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
  55. package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
  56. package/lib/pluginUtils/index.js +36 -43
  57. package/lib/plugins/CdnChangePlugin.js +77 -0
  58. package/lib/plugins/CleanupStatsPlugin.js +28 -0
  59. package/lib/plugins/EFCPlugin.js +211 -0
  60. package/lib/plugins/EFCPlugin.md +6 -0
  61. package/lib/plugins/I18NInjectIntoIndexPlugin.js +141 -0
  62. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
  63. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
  64. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
  65. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
  66. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
  67. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
  68. package/lib/plugins/I18nSplitPlugin/README.md +25 -0
  69. package/lib/plugins/I18nSplitPlugin/index.js +185 -0
  70. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
  71. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
  72. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
  73. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
  74. package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
  75. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
  76. package/lib/plugins/ManifestPlugin.js +52 -63
  77. package/lib/plugins/ModuleStatsPlugin.js +98 -97
  78. package/lib/plugins/OptimizeJSPlugin.js +24 -41
  79. package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
  80. package/lib/plugins/PublicPathChangePlugin.js +187 -174
  81. package/lib/plugins/ReportGeneratePlugin.js +181 -0
  82. package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
  83. package/lib/plugins/ResourceHintsPlugin.js +53 -35
  84. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +80 -0
  85. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +82 -0
  86. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
  87. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +26 -0
  88. package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
  89. package/lib/plugins/ServiceWorkerPlugin.js +107 -0
  90. package/lib/plugins/ShadowDOMSupportPlugin.js +270 -0
  91. package/lib/plugins/SourceMapHookPlugin.js +25 -31
  92. package/lib/plugins/TPHashMappingPlugin.js +67 -0
  93. package/lib/plugins/UglifyCSSPlugin.js +23 -30
  94. package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
  95. package/lib/plugins/index.js +118 -55
  96. package/lib/plugins/libraryImpactPlugin.js +190 -0
  97. package/lib/plugins/webpackwatchrunplugin.js +26 -0
  98. package/lib/postcss-plugins/ExcludeRTLPlugin.js +23 -0
  99. package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
  100. package/lib/schemas/index.js +463 -52
  101. package/lib/servers/clusterHubServer.js +22 -26
  102. package/lib/servers/docsServer.js +3 -5
  103. package/lib/servers/docsServerCore.js +93 -85
  104. package/lib/servers/helpServer.js +19 -21
  105. package/lib/servers/httpsOptions.js +19 -0
  106. package/lib/servers/impactServer.js +99 -92
  107. package/lib/servers/mockserver.js +44 -0
  108. package/lib/servers/nowatchserver.js +275 -0
  109. package/lib/servers/scrServer.js +147 -0
  110. package/lib/servers/server.js +118 -124
  111. package/lib/servers/ssServer.js +107 -65
  112. package/lib/sh/reportPublish.sh +16 -10
  113. package/lib/templates/CoverageScriptTemplate.js +45 -18
  114. package/lib/templates/WMSTemplate.js +17 -18
  115. package/lib/templates/linterConstant.js +10 -0
  116. package/lib/utils/babelPresets.js +12 -5
  117. package/lib/utils/buildstats.html +148 -0
  118. package/lib/utils/clean.js +12 -11
  119. package/lib/utils/copy.js +13 -127
  120. package/lib/utils/copyTimezones.js +21 -0
  121. package/lib/utils/createEventStream.js +24 -19
  122. package/lib/utils/cssClassNameGenerate.js +70 -0
  123. package/lib/utils/cssURLReplacer.js +67 -54
  124. package/lib/utils/dependencyPostPublish.js +42 -0
  125. package/lib/utils/fileUtils.js +125 -0
  126. package/lib/utils/folderIterator.js +47 -0
  127. package/lib/utils/getComponents.js +126 -0
  128. package/lib/utils/getCurrentBranch.js +11 -17
  129. package/lib/utils/getDependenciesImpactList.js +151 -0
  130. package/lib/utils/getHash.js +26 -0
  131. package/lib/utils/getIp.js +20 -0
  132. package/lib/utils/getOptions.js +55 -30
  133. package/lib/utils/getServerURL.js +25 -8
  134. package/lib/utils/index.js +259 -82
  135. package/lib/utils/init.js +2 -2
  136. package/lib/utils/initPreCommitHook.js +40 -31
  137. package/lib/utils/jsonHelper.js +97 -0
  138. package/lib/utils/libraryImpactConfig.js +63 -0
  139. package/lib/utils/lint/addScripts.js +27 -0
  140. package/lib/utils/lint/checkExistingConfig.js +67 -0
  141. package/lib/utils/lint/copyConfigs.js +24 -0
  142. package/lib/utils/lint/index.js +54 -0
  143. package/lib/utils/lint/lintScripts.js +11 -0
  144. package/lib/utils/lint/lintSetup.js +31 -0
  145. package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
  146. package/lib/utils/lint/question.js +30 -0
  147. package/lib/utils/lintReporter.js +142 -0
  148. package/lib/utils/mailSender.js +16 -25
  149. package/lib/utils/pullOrigin.js +28 -0
  150. package/lib/utils/reinstallDependencies.js +133 -0
  151. package/lib/utils/removeAttributes.js +25 -23
  152. package/lib/utils/repoClone.js +56 -63
  153. package/lib/utils/request.js +64 -77
  154. package/lib/utils/resultSchema.json +73 -0
  155. package/lib/utils/rtl.js +42 -0
  156. package/lib/utils/setEnvVariables.js +5 -6
  157. package/lib/utils/ssTestHack.js +48 -0
  158. package/lib/utils/switchBranch.js +28 -0
  159. package/lib/utils/urlConcat.js +22 -0
  160. package/package.json +92 -64
  161. package/templates/app/.eslintrc.js +140 -0
  162. package/templates/app/README.md +12 -12
  163. package/templates/app/app/index.html +24 -8
  164. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  165. package/templates/app/app/properties/i18nkeys.json +3 -3
  166. package/templates/app/docs/all.html +69 -69
  167. package/templates/app/mockapi/index.js +18 -13
  168. package/templates/app/package.json +37 -17
  169. package/templates/app/src/actions/SampleActions/index.js +37 -0
  170. package/templates/app/src/actions/index.js +65 -0
  171. package/templates/app/src/appUrls.js +19 -0
  172. package/templates/app/src/components/Alert/Alert.js +134 -0
  173. package/templates/app/src/components/Alert/Alert.module.css +79 -0
  174. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -0
  175. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -0
  176. package/templates/app/src/components/Sample/Sample.module.css +11 -0
  177. package/templates/app/src/components/Sample/SampleList.js +61 -0
  178. package/templates/app/src/components/Slider/Slider.css +41 -0
  179. package/templates/app/src/components/Slider/Slider.js +55 -0
  180. package/templates/app/src/containers/AlertContainer/index.js +15 -0
  181. package/templates/app/src/containers/AppContainer/index.js +96 -0
  182. package/templates/app/src/containers/AppContainer/index.module.css +27 -0
  183. package/templates/app/src/containers/CustomMatch/index.js +65 -0
  184. package/templates/app/src/containers/DevTools/index.js +10 -0
  185. package/templates/app/src/containers/Header/index.js +67 -0
  186. package/templates/app/src/containers/Header/index.module.css +43 -0
  187. package/templates/app/src/containers/Redirect/index.js +63 -0
  188. package/templates/app/src/containers/Redirector/index.js +47 -0
  189. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -0
  190. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -0
  191. package/templates/app/src/historyChange.js +5 -0
  192. package/templates/app/src/index.html +10 -0
  193. package/templates/app/src/index.js +24 -0
  194. package/templates/app/src/middleware/PromiseMiddleware.js +59 -0
  195. package/templates/app/src/reducers/alertData.js +11 -0
  196. package/templates/app/src/reducers/index.js +6 -0
  197. package/templates/app/src/reducers/samples.js +19 -0
  198. package/templates/app/src/store/configureStore.dev.js +51 -0
  199. package/templates/app/src/store/configureStore.js +5 -0
  200. package/templates/app/src/store/configureStore.prod.js +26 -0
  201. package/templates/app/src/util/Common.js +5 -0
  202. package/templates/app/src/util/RequestAPI.js +132 -0
  203. package/templates/appold/README.md +12 -0
  204. package/templates/appold/app/index.html +8 -0
  205. package/templates/appold/app/properties/ApplicationResources_en_US.properties +1 -0
  206. package/templates/appold/app/properties/i18nkeys.json +3 -0
  207. package/templates/appold/docs/all.html +69 -0
  208. package/templates/appold/mockapi/index.js +13 -0
  209. package/templates/{app → appold}/mockapi/tickets.json +0 -0
  210. package/templates/appold/package.json +17 -0
  211. package/templates/appold/src/components/Text/Text.css +0 -0
  212. package/templates/appold/src/components/Text/Text.js +23 -0
  213. package/templates/appold/src/components/Text/__tests__/Text.spec.js +30 -0
  214. package/templates/appold/src/components/Text/docs/Text__default.docs.js +16 -0
  215. package/templates/appold/src/components/docs.js +1 -0
  216. package/templates/appold/src/components/index.js +5 -0
  217. package/templates/appold/src/index.js +13 -0
  218. package/templates/docs/all.html +1 -1
  219. package/templates/docs/component.html +110 -69
  220. package/templates/docs/components.html +221 -0
  221. package/templates/docs/css/component.css +12 -14
  222. package/templates/docs/css/componentTest.css +7 -0
  223. package/templates/docs/css/style.css +150 -206
  224. package/templates/docs/impactReportTemplate.html +154 -0
  225. package/templates/docs/index.html +1482 -1336
  226. package/templates/library/src/index.js +0 -0
@@ -1,150 +1,327 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getInfoFromPublicPaths = exports.makeDir = exports.writeFile = exports.log = exports.request = exports.getCurrentBranch = exports.getServerURL = exports.createEventStream = exports.getOptions = undefined;
7
-
8
- var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
9
-
10
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
11
-
12
- var _getOptions = require('./getOptions');
13
-
14
- Object.defineProperty(exports, 'getOptions', {
6
+ var _exportNames = {
7
+ log: true,
8
+ writeFile: true,
9
+ makeDir: true,
10
+ getInfoFromPublicPaths: true,
11
+ getLibraryConflict: true,
12
+ getOptions: true,
13
+ createEventStream: true,
14
+ getServerURL: true,
15
+ getCurrentBranch: true,
16
+ switchBranch: true,
17
+ pullOrigin: true,
18
+ request: true,
19
+ jsonHelper: true,
20
+ getDependenciesImpactList: true,
21
+ getComponents: true,
22
+ ssTestHack: true
23
+ };
24
+ Object.defineProperty(exports, "getOptions", {
15
25
  enumerable: true,
16
- get: function get() {
17
- return _interopRequireDefault(_getOptions).default;
26
+ get: function () {
27
+ return _getOptions.default;
18
28
  }
19
29
  });
20
-
21
- var _createEventStream = require('./createEventStream');
22
-
23
- Object.defineProperty(exports, 'createEventStream', {
30
+ Object.defineProperty(exports, "createEventStream", {
24
31
  enumerable: true,
25
- get: function get() {
26
- return _interopRequireDefault(_createEventStream).default;
32
+ get: function () {
33
+ return _createEventStream.default;
27
34
  }
28
35
  });
29
-
30
- var _getServerURL = require('./getServerURL');
31
-
32
- Object.defineProperty(exports, 'getServerURL', {
36
+ Object.defineProperty(exports, "getServerURL", {
33
37
  enumerable: true,
34
- get: function get() {
35
- return _interopRequireDefault(_getServerURL).default;
38
+ get: function () {
39
+ return _getServerURL.default;
36
40
  }
37
41
  });
38
-
39
- var _getCurrentBranch = require('./getCurrentBranch');
40
-
41
- Object.defineProperty(exports, 'getCurrentBranch', {
42
+ Object.defineProperty(exports, "getCurrentBranch", {
42
43
  enumerable: true,
43
- get: function get() {
44
- return _interopRequireDefault(_getCurrentBranch).default;
44
+ get: function () {
45
+ return _getCurrentBranch.default;
45
46
  }
46
47
  });
47
-
48
- var _request = require('./request');
49
-
50
- Object.defineProperty(exports, 'request', {
48
+ Object.defineProperty(exports, "switchBranch", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _switchBranch.default;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "pullOrigin", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _pullOrigin.default;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "request", {
61
+ enumerable: true,
62
+ get: function () {
63
+ return _request.default;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "jsonHelper", {
51
67
  enumerable: true,
52
- get: function get() {
53
- return _interopRequireDefault(_request).default;
68
+ get: function () {
69
+ return _jsonHelper.default;
54
70
  }
55
71
  });
72
+ Object.defineProperty(exports, "getDependenciesImpactList", {
73
+ enumerable: true,
74
+ get: function () {
75
+ return _getDependenciesImpactList.default;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, "getComponents", {
79
+ enumerable: true,
80
+ get: function () {
81
+ return _getComponents.default;
82
+ }
83
+ });
84
+ Object.defineProperty(exports, "ssTestHack", {
85
+ enumerable: true,
86
+ get: function () {
87
+ return _ssTestHack.default;
88
+ }
89
+ });
90
+ exports.getLibraryConflict = exports.getInfoFromPublicPaths = exports.makeDir = exports.writeFile = exports.log = void 0;
91
+
92
+ var _stream = require("stream");
93
+
94
+ var _fs = _interopRequireDefault(require("fs"));
56
95
 
57
- var _cssURLReplacer = require('./cssURLReplacer');
96
+ var _getOptions = _interopRequireDefault(require("./getOptions"));
97
+
98
+ var _createEventStream = _interopRequireDefault(require("./createEventStream"));
99
+
100
+ var _getServerURL = _interopRequireDefault(require("./getServerURL"));
101
+
102
+ var _getCurrentBranch = _interopRequireDefault(require("./getCurrentBranch"));
103
+
104
+ var _switchBranch = _interopRequireDefault(require("./switchBranch"));
105
+
106
+ var _pullOrigin = _interopRequireDefault(require("./pullOrigin"));
107
+
108
+ var _request = _interopRequireDefault(require("./request"));
109
+
110
+ var _jsonHelper = _interopRequireDefault(require("./jsonHelper"));
111
+
112
+ var _reinstallDependencies = require("./reinstallDependencies");
113
+
114
+ Object.keys(_reinstallDependencies).forEach(function (key) {
115
+ if (key === "default" || key === "__esModule") return;
116
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
117
+ if (key in exports && exports[key] === _reinstallDependencies[key]) return;
118
+ Object.defineProperty(exports, key, {
119
+ enumerable: true,
120
+ get: function () {
121
+ return _reinstallDependencies[key];
122
+ }
123
+ });
124
+ });
125
+
126
+ var _cssURLReplacer = require("./cssURLReplacer");
58
127
 
59
128
  Object.keys(_cssURLReplacer).forEach(function (key) {
60
129
  if (key === "default" || key === "__esModule") return;
130
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
131
+ if (key in exports && exports[key] === _cssURLReplacer[key]) return;
61
132
  Object.defineProperty(exports, key, {
62
133
  enumerable: true,
63
- get: function get() {
134
+ get: function () {
64
135
  return _cssURLReplacer[key];
65
136
  }
66
137
  });
67
138
  });
68
139
 
69
- var _initPreCommitHook = require('./initPreCommitHook');
140
+ var _initPreCommitHook = require("./initPreCommitHook");
70
141
 
71
142
  Object.keys(_initPreCommitHook).forEach(function (key) {
72
143
  if (key === "default" || key === "__esModule") return;
144
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
145
+ if (key in exports && exports[key] === _initPreCommitHook[key]) return;
73
146
  Object.defineProperty(exports, key, {
74
147
  enumerable: true,
75
- get: function get() {
148
+ get: function () {
76
149
  return _initPreCommitHook[key];
77
150
  }
78
151
  });
79
152
  });
80
153
 
81
- var _stream = require('stream');
154
+ var _getDependenciesImpactList = _interopRequireDefault(require("./getDependenciesImpactList"));
82
155
 
83
- var _fs = require('fs');
156
+ var _getComponents = _interopRequireDefault(require("./getComponents"));
84
157
 
85
- var _fs2 = _interopRequireDefault(_fs);
158
+ var _ssTestHack = _interopRequireDefault(require("./ssTestHack"));
86
159
 
87
160
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
88
161
 
89
- var log = exports.log = function log() {
90
- var print = console;
91
- print.log.apply(print, arguments);
162
+ let log = (...info) => {
163
+ let print = console;
164
+ print.log(...info);
92
165
  };
93
166
 
94
- var writeFile = exports.writeFile = function writeFile(outputPath, src) {
95
- var isPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
96
- return new Promise(function (resolve, reject) {
97
- var inStr = void 0;
98
- if (isPath) {
99
- inStr = _fs2.default.createReadStream(src);
100
- } else {
101
- inStr = new _stream.Readable();
102
- inStr._read = function () {
103
- return true;
104
- };
105
- inStr.push(src);
106
- inStr.push(null);
107
- }
108
- var outStr = _fs2.default.createWriteStream(outputPath);
109
- outStr.on('error', function (err) {
110
- reject(err);
111
- });
112
- outStr.on('finish', function () {
113
- resolve();
114
- });
167
+ exports.log = log;
168
+
169
+ let writeFile = (outputPath, src, isPath = false) => new Promise((resolve, reject) => {
170
+ let inStr;
171
+
172
+ if (isPath) {
173
+ inStr = _fs.default.createReadStream(src);
174
+ } else {
175
+ inStr = new _stream.Readable();
115
176
 
116
- inStr.pipe(outStr);
177
+ inStr._read = () => true;
178
+
179
+ inStr.push(src);
180
+ inStr.push(null);
181
+ }
182
+
183
+ let outStr = _fs.default.createWriteStream(outputPath);
184
+
185
+ outStr.on('error', err => {
186
+ reject(err);
117
187
  });
118
- };
188
+ outStr.on('finish', () => {
189
+ resolve();
190
+ });
191
+ inStr.pipe(outStr);
192
+ });
193
+
194
+ exports.writeFile = writeFile;
119
195
 
120
- var makeDir = exports.makeDir = function makeDir(paths) {
196
+ let makeDir = paths => {
121
197
  if (typeof paths === 'string') {
122
198
  //eslint-disable-next-line
123
199
  paths = [paths];
124
200
  }
125
- paths.forEach(function (path) {
126
- if (!_fs2.default.existsSync(path)) {
127
- _fs2.default.mkdirSync(path);
201
+
202
+ paths.forEach(path => {
203
+ if (!_fs.default.existsSync(path)) {
204
+ _fs.default.mkdirSync(path);
128
205
  }
129
206
  });
130
207
  };
131
208
 
132
- var getInfoFromPublicPaths = exports.getInfoFromPublicPaths = function getInfoFromPublicPaths(publicPaths) {
133
- var rootFolder = '',
209
+ exports.makeDir = makeDir;
210
+
211
+ let getInfoFromPublicPaths = publicPaths => {
212
+ let rootFolder = '',
134
213
  image = '',
135
214
  font = '';
136
- if (publicPaths && !Array.isArray(publicPaths) && (typeof publicPaths === 'undefined' ? 'undefined' : _typeof(publicPaths)) === 'object') {
137
- var _Object$keys = Object.keys(publicPaths),
138
- _Object$keys2 = _slicedToArray(_Object$keys, 1),
139
- cdn = _Object$keys2[0];
140
215
 
141
- rootFolder = cdn + '/';
216
+ if (publicPaths && !Array.isArray(publicPaths) && typeof publicPaths === 'object' && !publicPaths.callback) {
217
+ let [cdn] = Object.keys(publicPaths);
218
+ rootFolder = `${cdn}/`;
219
+
142
220
  if (publicPaths[cdn].font) {
143
221
  font = publicPaths[cdn].font; //eslint-disable-line
144
222
  }
223
+
145
224
  if (publicPaths[cdn].image) {
146
225
  image = publicPaths[cdn].image; //eslint-disable-line
147
226
  }
148
227
  }
149
- return { rootFolder: rootFolder, image: image, font: font };
150
- };
228
+
229
+ return {
230
+ rootFolder,
231
+ image,
232
+ font
233
+ };
234
+ };
235
+
236
+ exports.getInfoFromPublicPaths = getInfoFromPublicPaths;
237
+
238
+ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
239
+ let srcChanges = [];
240
+ let libraryChanges = [];
241
+ let overallSourceList = [];
242
+ let allImpactArray = [];
243
+ let impactThere = true;
244
+ let whichLibrary = "";
245
+ moduleObject = JSON.parse(moduleObject);
246
+ Object.keys(impactObj).forEach(library => {
247
+ Object.keys(impactObj[library]).forEach(action => {
248
+ if (action !== 'REMOVED') {
249
+ impactObj[library][action].forEach(srcObject => {
250
+ let fileName = srcObject["FILEPATH"];
251
+
252
+ if (library == "AppSource") {
253
+ fileName = fileName.replace("jsapps/supportapp", ".");
254
+ srcChanges.push(fileName);
255
+ } else {
256
+ fileName = fileName.replace("jsapps/" + library + "/src", "./node_modules/@zohodesk/" + library + "/lib");
257
+ libraryChanges.push(fileName);
258
+ }
259
+ });
260
+ }
261
+ });
262
+ });
263
+
264
+ if (!changesOnly) {
265
+ srcChanges = [];
266
+
267
+ if (libraryChanges.length > 0) {
268
+ libraryChanges.forEach(mdataLibKey => {
269
+ if (moduleObject[mdataLibKey]) {
270
+ moduleObject[mdataLibKey].referencedby.forEach(refByFileName => {
271
+ if (refByFileName.indexOf("@zohodesk") == -1) {
272
+ if (srcChanges.indexOf(refByFileName) == -1) {
273
+ srcChanges.push(refByFileName);
274
+ }
275
+ }
276
+ });
277
+ }
278
+ });
279
+ } else {}
280
+ }
281
+
282
+ if (srcChanges.length > 0) {
283
+ srcChanges.forEach(srcFile => {
284
+ let cacheObject = {};
285
+ cacheObject.sourceName = srcFile;
286
+ let cacheLibraryList = [];
287
+
288
+ if (libraryChanges.length > 0) {
289
+ libraryChanges.forEach(mdataKey => {
290
+ if (moduleObject[mdataKey]) {
291
+ if (moduleObject[mdataKey].referencedby.indexOf(srcFile) > -1) {
292
+ mdataKey = mdataKey.replace("./node_modules/", "");
293
+ cacheLibraryList.push(mdataKey);
294
+ }
295
+ }
296
+ });
297
+ } else {
298
+ impactThere = false;
299
+ whichLibrary = 'No library file changes between target branch!';
300
+ }
301
+
302
+ if (cacheLibraryList.length > 0) {
303
+ cacheObject.impactedBy = cacheLibraryList;
304
+ allImpactArray.push(cacheObject);
305
+ } else {
306
+ impactThere = false;
307
+ whichLibrary = "No component file changes!";
308
+ }
309
+ });
310
+ } else {
311
+ impactThere = false;
312
+ whichLibrary = "No component file changes!";
313
+ }
314
+
315
+ log('\n');
316
+ log('You can see the HTML out at coverageTest/impactLibrary.html!');
317
+ log('\x1b[33m%s\x1b[0m', '************************************************************ \n ');
318
+ return {
319
+ response: allImpactArray,
320
+ result: {
321
+ status: impactThere,
322
+ message: whichLibrary
323
+ }
324
+ };
325
+ };
326
+
327
+ exports.getLibraryConflict = getLibraryConflict;
package/lib/utils/init.js CHANGED
@@ -1,5 +1,5 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _initPreCommitHook = require('./initPreCommitHook');
3
+ var _initPreCommitHook = require("./initPreCommitHook");
4
4
 
5
5
  (0, _initPreCommitHook.initPreCommitHook)(true);
@@ -1,73 +1,82 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.initPreCommitHook = exports.getGitRootDir = undefined;
6
+ exports.initPreCommitHook = exports.getGitRootDir = void 0;
7
7
 
8
- var _fs = require('fs');
8
+ var _fs = _interopRequireDefault(require("fs"));
9
9
 
10
- var _fs2 = _interopRequireDefault(_fs);
10
+ var _path = _interopRequireDefault(require("path"));
11
11
 
12
- var _path = require('path');
12
+ var _child_process = require("child_process");
13
13
 
14
- var _path2 = _interopRequireDefault(_path);
15
-
16
- var _child_process = require('child_process');
17
-
18
- var _index = require('./index');
14
+ var _index = require("./index");
19
15
 
20
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
17
 
22
- var getGitRootDir = exports.getGitRootDir = function getGitRootDir() {
18
+ let getGitRootDir = () => {
23
19
  try {
24
20
  return (0, _child_process.execSync)('git rev-parse --show-toplevel').toString();
25
21
  } catch (e) {
26
22
  return false;
27
23
  }
28
- };
24
+ }; //eslint-disable-next-line
25
+
26
+
27
+ exports.getGitRootDir = getGitRootDir;
29
28
 
30
- var copyEslintConfig = function copyEslintConfig(rootDir) {
29
+ let copyEslintConfig = rootDir => {
31
30
  rootDir = rootDir.replace(/\r?\n|\r/g, ''); //eslint-disable-line
32
- var srcPath = _path2.default.join(__dirname, '..', '..', '.eslintrc.js');
33
- var targetPath = _path2.default.join(rootDir, '.eslintrc.js');
34
- if (!_fs2.default.existsSync(targetPath)) {
35
- var src = _fs2.default.readFileSync(srcPath).toString();
36
- _fs2.default.writeFileSync(targetPath, src);
31
+
32
+ let srcPath = _path.default.join(__dirname, '..', '..', '.eslintrc.js');
33
+
34
+ let targetPath = _path.default.join(rootDir, '.eslintrc.js');
35
+
36
+ if (!_fs.default.existsSync(targetPath)) {
37
+ let src = _fs.default.readFileSync(srcPath).toString();
38
+
39
+ _fs.default.writeFileSync(targetPath, src);
40
+
37
41
  (0, _index.log)('Eslint config added in project root path');
38
42
  }
39
43
  };
40
44
 
41
- var initPreCommitHook = exports.initPreCommitHook = function initPreCommitHook() {
42
- var forReactCLI = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
45
+ let initPreCommitHook = (forReactCLI = false) => {
46
+ let gitRootDir = getGitRootDir(); //copyEslintConfig(gitRootDir || process.cwd());
43
47
 
44
- var gitRootDir = getGitRootDir();
45
- copyEslintConfig(gitRootDir || process.cwd());
46
48
  if (gitRootDir) {
47
- var precommit = _fs2.default.readFileSync(_path2.default.join(__dirname, '../sh/pre-commit.sh')).toString();
49
+ let precommit = _fs.default.readFileSync(_path.default.join(__dirname, '../sh/pre-commit.sh')).toString();
48
50
 
49
- var targetPath = _path2.default.join(gitRootDir, '.git', 'hooks', 'pre-commit').replace(/\s/g, '');
51
+ let targetPath = _path.default.join(gitRootDir, '.git', 'hooks', 'pre-commit').replace(/\s/g, '');
50
52
 
51
- if (_fs2.default.existsSync(targetPath + '.sample')) {
53
+ if (_fs.default.existsSync(`${targetPath}.sample`)) {
52
54
  precommit = precommit.replace('${PREFIX_PATH}', //eslint-disable-line
53
55
  process.cwd().replace(/\\/g, '/'));
54
- _fs2.default.renameSync(targetPath + '.sample', targetPath);
55
- _fs2.default.writeFileSync(targetPath, precommit);
56
+
57
+ _fs.default.renameSync(`${targetPath}.sample`, targetPath);
58
+
59
+ _fs.default.writeFileSync(targetPath, precommit);
60
+
56
61
  (0, _index.log)('pre-commit hook added');
57
62
  }
58
63
 
59
- var packagePath = _path2.default.join(process.cwd(), 'package.json');
64
+ let packagePath = _path.default.join(process.cwd(), 'package.json');
65
+
60
66
  try {
61
- var packageJson = require(packagePath);
67
+ let packageJson = require(packagePath);
62
68
 
63
69
  if (packageJson.scripts.lint !== 'react-cli lint') {
64
70
  packageJson.scripts.lint = forReactCLI ? 'eslint ./src' : 'react-cli lint';
65
71
 
66
- _fs2.default.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2));
72
+ _fs.default.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2));
73
+
67
74
  (0, _index.log)('lint script added in your package.json');
68
75
  }
69
76
  } catch (e) {
70
77
  (0, _index.log)('package.json not found');
71
78
  }
72
79
  }
73
- };
80
+ };
81
+
82
+ exports.initPreCommitHook = initPreCommitHook;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setTestInfoStatus = exports.jsonHelper = exports.jsonConcate = exports.fileHandler = exports.getRunnerDetail = void 0;
7
+
8
+ let fs = require('fs');
9
+
10
+ let os = require('os');
11
+
12
+ let {
13
+ getCurrentBranch
14
+ } = require('./');
15
+
16
+ let getRunnerDetail = () => {
17
+ let defaultObj = {
18
+ jobDetails: {
19
+ isRunByLocal: true,
20
+ hostName: os.hostname(),
21
+ platForm: os.type(),
22
+ branchName: getCurrentBranch('git', process.cwd())
23
+ }
24
+ };
25
+ return defaultObj;
26
+ };
27
+
28
+ exports.getRunnerDetail = getRunnerDetail;
29
+ let fileHandler = {
30
+ readFile: (path, callback = null) => {
31
+ if (fs.existsSync(path)) {
32
+ if (callback === null) {
33
+ return fs.readFileSync(path);
34
+ }
35
+
36
+ callback(fs.readFileSync(path));
37
+ } else {
38
+ return fileHandler.writeFile(path, getRunnerDetail());
39
+ }
40
+ },
41
+ writeFile: (path, data) => {
42
+ fs.writeFileSync(path, JSON.stringify(data));
43
+ return JSON.stringify(data);
44
+ }
45
+ };
46
+ exports.fileHandler = fileHandler;
47
+
48
+ let jsonConcate = (receiverObj, senterObj) => {
49
+ Object.keys(senterObj).map(key => {
50
+ if (Object.prototype.hasOwnProperty.call(receiverObj, key)) {
51
+ if (receiverObj[key].constructor === {}.constructor && senterObj[key].constructor === {}.constructor) {
52
+ jsonConcate(receiverObj[key], senterObj[key]);
53
+ } else if (receiverObj[key].constructor === [].constructor && senterObj[key].constructor === [].constructor) {
54
+ receiverObj[key] = receiverObj[key].concat(senterObj[key]);
55
+ } else {
56
+ receiverObj[key] = senterObj[key];
57
+ }
58
+ } else {
59
+ receiverObj[key] = senterObj[key];
60
+ }
61
+
62
+ return key;
63
+ });
64
+ return receiverObj;
65
+ };
66
+
67
+ exports.jsonConcate = jsonConcate;
68
+
69
+ let jsonHelper = (path, pathArray, value) => {
70
+ let tempObj = {};
71
+
72
+ if (typeof pathArray === 'string') {
73
+ pathArray = pathArray.split('.'); //eslint-disable-line no-param-reassign
74
+ }
75
+
76
+ pathArray.slice(0).reverse().map(key => {
77
+ tempObj = {};
78
+ tempObj[key] = value;
79
+ value = tempObj; // eslint-disable-line no-param-reassign
80
+
81
+ return key;
82
+ });
83
+ let overAllObj = jsonConcate(JSON.parse(fileHandler.readFile(path)), tempObj);
84
+ fileHandler.writeFile(path, overAllObj);
85
+ };
86
+
87
+ exports.jsonHelper = jsonHelper;
88
+
89
+ let setTestInfoStatus = (filepath, status) => {
90
+ let buildObject = JSON.parse(fileHandler.readFile(filepath));
91
+
92
+ if (!buildObject.testInfo || buildObject.testInfo.isBuildVerified !== false) {
93
+ jsonHelper(filepath, 'testInfo.isBuildVerified', status);
94
+ }
95
+ };
96
+
97
+ exports.setTestInfoStatus = setTestInfoStatus;