@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
@@ -0,0 +1,51 @@
1
+ import { createBrowserHistory } from "history";
2
+ import { reduxRouter } from "redux-router-middleware";
3
+ import { createStore, applyMiddleware, compose, combineReducers } from "redux";
4
+ import thunk from "redux-thunk";
5
+ import promiseMiddleware from "../middleware/PromiseMiddleware";
6
+ import rootReducer from "../reducers";
7
+
8
+ //import logger from "redux-logger";
9
+ //import { createLogger } from "redux-logger";
10
+ import { createLogger } from "redux-logger";
11
+ import DevTools from "../containers/DevTools";
12
+ import getUrls from "../appUrls";
13
+ import { historyChange } from "../historyChange";
14
+
15
+ const configureStore = preloadedState => {
16
+ let history = createBrowserHistory();
17
+
18
+ let { historyMiddleware, routing } = reduxRouter(
19
+ history,
20
+ getUrls(),
21
+ historyChange
22
+ );
23
+
24
+ //console.log(createLogger);
25
+ let middleWare = compose(
26
+ applyMiddleware(
27
+ thunk,
28
+ promiseMiddleware,
29
+ historyMiddleware,
30
+ createLogger({ collapsed: true })
31
+ ),
32
+ DevTools.instrument()
33
+ );
34
+
35
+ const store = createStore(
36
+ combineReducers(Object.assign(rootReducer, { routing })),
37
+ preloadedState,
38
+ middleWare
39
+ );
40
+
41
+ if (module.hot) {
42
+ // Enable Webpack hot module replacement for reducers
43
+ module.hot.accept("../reducers", () => {
44
+ store.replaceReducer(rootReducer);
45
+ });
46
+ }
47
+
48
+ return store;
49
+ };
50
+
51
+ export default configureStore;
@@ -0,0 +1,5 @@
1
+ /*if (process.env.NODE_ENV === "production") {
2
+ module.exports = require("./configureStore.prod");
3
+ } else {*/
4
+ module.exports = require("./configureStore.dev");
5
+ //}
@@ -0,0 +1,26 @@
1
+ import { createBrowserHistory } from "history";
2
+ import { reduxRouter } from "@zohodesk/router-middleware";
3
+ import { createStore, applyMiddleware, compose, combineReducers } from "redux";
4
+ import { historyChange } from "../historyChange";
5
+ import thunk from "redux-thunk";
6
+ import rootReducer from "../reducers";
7
+
8
+ const configureStore = preloadedState => {
9
+ let history = createBrowserHistory();
10
+
11
+ let { historyMiddleware, routing } = reduxRouter(
12
+ history,
13
+ getUrls(),
14
+ historyChange
15
+ );
16
+
17
+ let middleWare = compose(applyMiddleware(thunk, historyMiddleware));
18
+
19
+ return createStore(
20
+ combineReducers(Object.assign(rootReducer, { routing })),
21
+ preloadedState,
22
+ middleWare
23
+ );
24
+ };
25
+
26
+ export default configureStore;
@@ -0,0 +1,5 @@
1
+ export const URL_PREFIX = '/app';
2
+
3
+ export function generateAPITypes(prefix) {
4
+ return [`${prefix}_REQUEST`, `${prefix}_SUCCESS`, `${prefix}_FAILURE`];
5
+ }
@@ -0,0 +1,132 @@
1
+ /*$Id$*/
2
+ export default function(url, header = null) {
3
+ let contentType = "json";
4
+ let core = {
5
+ ajax(method, url, args, payload, files, onProcess) {
6
+ let p = new Promise((resolve, reject) => {
7
+ let client = new XMLHttpRequest();
8
+ let uri = url;
9
+ var data = "";
10
+ if (args && (method === "POST" || method === "PUT")) {
11
+ let argcount = 0;
12
+ for (let key in args) {
13
+ if ({}.hasOwnProperty.call(args, key)) {
14
+ if (argcount++) {
15
+ data += "&";
16
+ }
17
+ data += `${encodeURIComponent(key)}=${encodeURIComponent(
18
+ args[key]
19
+ )}`;
20
+ }
21
+ }
22
+ }
23
+
24
+ client.upload.addEventListener("progress", onProcess);
25
+
26
+ client.open(method, uri);
27
+
28
+ if (header) {
29
+ Object.keys(header).forEach(key => {
30
+ client.setRequestHeader(key, header[key]);
31
+ });
32
+ }
33
+
34
+ if (files && files.constructor === new FormData().constructor) {
35
+ client.send(files);
36
+ } else if (files) {
37
+ var data = new FormData();
38
+ data.append("file", files[0]);
39
+ client.send(data);
40
+ } else if (payload) {
41
+ if (payload instanceof FormData) {
42
+ client.send(payload);
43
+ } else {
44
+ if (contentType == "json") {
45
+ client.setRequestHeader(
46
+ "Content-Type",
47
+ "application/json;charset=UTF-8"
48
+ );
49
+ client.send(JSON.stringify(payload));
50
+ } else {
51
+ client.setRequestHeader(
52
+ "Content-Type",
53
+ "application/x-www-form-urlencoded;charset=UTF-8"
54
+ );
55
+ let data = "";
56
+ let argcount = 0;
57
+ for (let key in payload) {
58
+ if ({}.hasOwnProperty.call(payload, key)) {
59
+ if (argcount++) {
60
+ data += "&";
61
+ }
62
+ data += `${encodeURIComponent(key)}=${encodeURIComponent(
63
+ payload[key]
64
+ )}`;
65
+ }
66
+ }
67
+ client.send(data);
68
+ }
69
+ }
70
+ } else {
71
+ client.setRequestHeader(
72
+ "Content-Type",
73
+ "application/x-www-form-urlencoded"
74
+ );
75
+ client.send(data);
76
+ }
77
+
78
+ client.onload = function() {
79
+ if (
80
+ this.status === 200 ||
81
+ this.status === 201 ||
82
+ this.status === 204
83
+ ) {
84
+ let response = this.response ? this.response : this.responseText;
85
+ if (response === "") {
86
+ resolve({ responseStatus: this.status }, () => percentComplete);
87
+ } else {
88
+ try {
89
+ resolve(JSON.parse(response));
90
+ } catch (e) {
91
+ resolve(response);
92
+ }
93
+ }
94
+ } else {
95
+ reject(this);
96
+ }
97
+ };
98
+
99
+ client.onerror = function() {
100
+ reject(this);
101
+ };
102
+ });
103
+ p.getProgress = () => p.progress;
104
+ return p;
105
+ }
106
+ };
107
+
108
+ return {
109
+ get() {
110
+ return core.ajax("GET", url);
111
+ },
112
+ patch(args, payload) {
113
+ return core.ajax("PATCH", url, args, payload);
114
+ },
115
+ post(args, payload) {
116
+ return core.ajax("POST", url, args, payload);
117
+ },
118
+ put(args, payload, files) {
119
+ return core.ajax("PUT", url, args, payload, files);
120
+ },
121
+ del() {
122
+ return core.ajax("DELETE", url);
123
+ },
124
+ attach(files, onProcess) {
125
+ return core.ajax("POST", url, {}, undefined, files, onProcess);
126
+ },
127
+ setContentType(type) {
128
+ contentType = type;
129
+ return this;
130
+ }
131
+ };
132
+ }
@@ -0,0 +1,12 @@
1
+ #Some useful command
2
+
3
+ component development command
4
+ npm run docs --server:componentPath=./src/components
5
+
6
+ development mode useful command
7
+ npm run start
8
+ npm run start --server:prod=true
9
+
10
+
11
+ production mode command
12
+ npm run build
@@ -0,0 +1,8 @@
1
+ <html>
2
+ <body>
3
+ <div id="react"></div>
4
+ <script src="/app/js/react.vendor.js"></script>
5
+ <script src="/app/js/vendor.js"></script>
6
+ <script src="/app/js/main.js"></script>
7
+ </body>
8
+ </html>
@@ -0,0 +1,3 @@
1
+ {
2
+ "app.dynkey": "dynkey"
3
+ }
@@ -0,0 +1,69 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
5
+ <style type="text/css">
6
+ .comps
7
+ {
8
+ padding: 10px;
9
+ max-width: 100%;
10
+ margin-bottom: 10px;
11
+ border-bottom: 1px solid #f5f5f5;
12
+ }
13
+ .componentNameRed
14
+ {
15
+ color: red;
16
+ }
17
+ .propertyName
18
+ {
19
+ color:green;
20
+ margin-left: 10px;
21
+ }
22
+ .valueName
23
+ {
24
+ color:orange;
25
+ margin-right: 10px;
26
+ }
27
+ .example
28
+ {
29
+ padding: 20px 20px 20px 0px;
30
+ width: 100%;
31
+ box-sizing: border-box;
32
+ margin: 15px 0px;
33
+ }
34
+ .htmlTag
35
+ {
36
+ color: #999;
37
+ color: #676565;
38
+ line-height: 25px;
39
+ margin-bottom: 10px;
40
+ font-size: 13px;
41
+ }
42
+ .textArea
43
+ {
44
+ min-width: 50%;
45
+ outline: none;
46
+ min-height: 100px;
47
+ margin: 15px 0px;
48
+ max-width: 90%;
49
+ }
50
+
51
+ </style>
52
+ </head>
53
+ <body>
54
+ <div id="react">
55
+
56
+ </div>
57
+
58
+ <script src="/docs/js/vendor.js" ></script>
59
+ <script src="/docs/js/main.js" ></script>
60
+ <script>
61
+ var React = Component.React;
62
+ var ReactDOM = Component.ReactDOM;
63
+ var Text__default = Component.Text__default;
64
+ ReactDOM.render(React.createElement(Text__default), react);
65
+ </script>
66
+
67
+
68
+ </body>
69
+ </html>
@@ -0,0 +1,13 @@
1
+ var path = require('path');
2
+ var fs = require('fs');
3
+
4
+ function mockServer(app) {
5
+ var responseMapper = (url, file, type = 'application/json') => {
6
+ app.use(url, function(req, res) {
7
+ res.setHeader('Content-Type', type);
8
+ res.sendFile(path.join(__dirname, file));
9
+ });
10
+ };
11
+ responseMapper('/api/v1/tickets', 'tickets.json');
12
+ }
13
+ module.exports = mockServer;
File without changes
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "testapp",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "clean": "react-cli clean build unittest coverage",
8
+ "docs":"react-cli docs",
9
+ "component":"react-cli build:component",
10
+ "component:umd":"react-cli build:component:umd",
11
+ "start": "react-cli start",
12
+ "build": "react-cli build",
13
+ "test": "npm run clean && react-cli test"
14
+ },
15
+ "author": "",
16
+ "license": "ISC"
17
+ }
File without changes
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ export default class Text extends React.Component {
4
+ render() {
5
+ return (
6
+ <div
7
+ data-testid="data"
8
+ onClick={this.props.onClick.bind(this, this.props.content)}
9
+ >
10
+ {this.props.content}
11
+ </div>
12
+ );
13
+ }
14
+ }
15
+ Text.propTypes = {
16
+ content: PropTypes.string.isRequired,
17
+ onClick: PropTypes.func.isRequired
18
+ };
19
+ if (__DOCS__) {
20
+ Text.docs = {
21
+ componentGroup: 'Atom'
22
+ };
23
+ }
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import Text from '../Text';
3
+
4
+ describe('Text component specification', () => {
5
+ it('should display text content', () => {
6
+ var renderedDOM = TestUtils.renderIntoDocument(
7
+ <Text content="vimal" onClick={() => {}} />
8
+ );
9
+ expect(
10
+ TestUtils.findRenderedComponentsWithTestid(
11
+ renderedDOM,
12
+ 'data'
13
+ ).textContent.contains('vimal')
14
+ ).toBe(true);
15
+ });
16
+
17
+ it('should call onClick ', () => {
18
+ var mockfn = jest.fn();
19
+ var renderedDOM = TestUtils.renderIntoDocument(
20
+ <Text content="vimal" onClick={mockfn} />
21
+ );
22
+ var textEle = TestUtils.findRenderedComponentsWithTestid(
23
+ renderedDOM,
24
+ 'data'
25
+ );
26
+ TestUtils.Simulate.click(textEle);
27
+ expect(mockfn.mock.calls.length).toBe(1);
28
+ expect(mockfn.mock.calls[0][0]).toBe('vimal1');
29
+ });
30
+ });
@@ -0,0 +1,16 @@
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Text from '../Text';
4
+ export default class Text__default extends Component {
5
+ constructor(props) {
6
+ super(props);
7
+ }
8
+ render() {
9
+ return <Text content="vimal" onClick={val => {}} />;
10
+ }
11
+ }
12
+ if (__DOCS__) {
13
+ Text__default.docs = {
14
+ componentGroup: 'Atom'
15
+ };
16
+ }
@@ -0,0 +1 @@
1
+ export { default as Text__default } from './Text/docs/Text__default.docs';
@@ -0,0 +1,5 @@
1
+ export { default as React } from 'react';
2
+ export { default as ReactDOM } from 'react-dom';
3
+ export { default as Text } from './Text/Text';
4
+
5
+ export * from './docs';
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import Text from './components/Text/Text';
4
+ ReactDOM.render(
5
+ <Text content="vimalesan" onClick={v => {}} />,
6
+ document.getElementById('react')
7
+ );
8
+ if (!__DEVELOPMENT__) {
9
+ global.publicPath = function(chunkId) {
10
+ __webpack_public_path__ = `https://static${chunkId %
11
+ 3}.tsi.zohocorpin.com:9090/app/`;
12
+ };
13
+ }
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE html>
2
- <html>
2
+ <html dir="ltr">
3
3
  <head>
4
4
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
5
5
  <link rel="stylesheet" href="./css/b.min.css">