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

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 (228) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.js +46 -3
  3. package/CHANGELOG.md +5 -0
  4. package/README.md +708 -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 +26 -27
  20. package/lib/configs/libAlias.js +31 -0
  21. package/lib/configs/webpack.component.umd.config.js +31 -37
  22. package/lib/configs/webpack.css.umd.config.js +44 -44
  23. package/lib/configs/webpack.dev.config.js +96 -56
  24. package/lib/configs/webpack.docs.config.js +104 -98
  25. package/lib/configs/webpack.impact.config.js +116 -0
  26. package/lib/configs/webpack.prod.config.js +137 -85
  27. package/lib/hooks/docsProptypeHook.js +32 -38
  28. package/lib/jest/commitedFilesResult.js +144 -71
  29. package/lib/jest/coverageCollector.js +62 -29
  30. package/lib/jest/jsonMaker.js +54 -0
  31. package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
  32. package/lib/jest/preProcessors/jsPreprocessor.js +5 -6
  33. package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
  34. package/lib/jest/result.js +91 -41
  35. package/lib/jest/run.js +74 -27
  36. package/lib/jest/setup.js +103 -102
  37. package/lib/loaderUtils/getCSSLoaders.js +77 -0
  38. package/lib/loaderUtils/getDevJsLoaders.js +30 -23
  39. package/lib/loaderUtils/index.js +14 -7
  40. package/lib/loaders/docsLoader.js +15 -15
  41. package/lib/loaders/docsPropsLoader.js +14 -17
  42. package/lib/loaders/fileBountryLoader.js +17 -0
  43. package/lib/loaders/fileLoader.js +47 -38
  44. package/lib/loaders/scriptInstrumentLoader.js +21 -20
  45. package/lib/loaders/selectorMappingLoader.js +75 -0
  46. package/lib/loaders/workerLoader.js +136 -0
  47. package/lib/middlewares/HMRMiddleware.js +59 -41
  48. package/lib/middlewares/SSTMiddleware.js +21 -0
  49. package/lib/pluginUtils/getDevPlugins.js +175 -26
  50. package/lib/pluginUtils/getDocsPlugins.js +32 -17
  51. package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
  52. package/lib/pluginUtils/getLibraryPlugins.js +8 -10
  53. package/lib/pluginUtils/getProdPlugins.js +240 -37
  54. package/lib/pluginUtils/getServerPlugins.js +8 -11
  55. package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
  56. package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
  57. package/lib/pluginUtils/index.js +36 -43
  58. package/lib/plugins/CdnChangePlugin.js +77 -0
  59. package/lib/plugins/CleanupStatsPlugin.js +28 -0
  60. package/lib/plugins/EFCPlugin.js +241 -0
  61. package/lib/plugins/EFCPlugin.md +6 -0
  62. package/lib/plugins/EFCTemplatePlugin.js +151 -0
  63. package/lib/plugins/I18NInjectIntoIndexPlugin.js +141 -0
  64. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
  65. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
  66. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
  67. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
  68. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
  69. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
  70. package/lib/plugins/I18nSplitPlugin/README.md +25 -0
  71. package/lib/plugins/I18nSplitPlugin/index.js +185 -0
  72. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
  73. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
  74. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
  75. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
  76. package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
  77. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
  78. package/lib/plugins/ManifestPlugin.js +59 -62
  79. package/lib/plugins/ModuleStatsPlugin.js +98 -97
  80. package/lib/plugins/OptimizeJSPlugin.js +24 -41
  81. package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
  82. package/lib/plugins/PublicPathChangePlugin.js +187 -174
  83. package/lib/plugins/ReportGeneratePlugin.js +181 -0
  84. package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
  85. package/lib/plugins/ResourceHintsPlugin.js +53 -35
  86. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +80 -0
  87. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +82 -0
  88. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
  89. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +26 -0
  90. package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
  91. package/lib/plugins/ServiceWorkerPlugin.js +107 -0
  92. package/lib/plugins/ShadowDOMSupportPlugin.js +270 -0
  93. package/lib/plugins/SourceMapHookPlugin.js +25 -31
  94. package/lib/plugins/TPHashMappingPlugin.js +67 -0
  95. package/lib/plugins/UglifyCSSPlugin.js +23 -30
  96. package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
  97. package/lib/plugins/index.js +118 -55
  98. package/lib/plugins/libraryImpactPlugin.js +190 -0
  99. package/lib/plugins/webpackwatchrunplugin.js +26 -0
  100. package/lib/postcss-plugins/ExcludeRTLPlugin.js +23 -0
  101. package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
  102. package/lib/schemas/index.js +466 -52
  103. package/lib/servers/clusterHubServer.js +22 -26
  104. package/lib/servers/docsServer.js +3 -5
  105. package/lib/servers/docsServerCore.js +93 -85
  106. package/lib/servers/helpServer.js +19 -21
  107. package/lib/servers/httpsOptions.js +19 -0
  108. package/lib/servers/impactServer.js +99 -92
  109. package/lib/servers/mockserver.js +44 -0
  110. package/lib/servers/nowatchserver.js +275 -0
  111. package/lib/servers/scrServer.js +147 -0
  112. package/lib/servers/server.js +118 -124
  113. package/lib/servers/ssServer.js +107 -65
  114. package/lib/sh/reportPublish.sh +16 -10
  115. package/lib/templates/CoverageScriptTemplate.js +45 -18
  116. package/lib/templates/WMSTemplate.js +17 -18
  117. package/lib/templates/linterConstant.js +10 -0
  118. package/lib/utils/babelPresets.js +12 -5
  119. package/lib/utils/buildstats.html +148 -0
  120. package/lib/utils/clean.js +12 -11
  121. package/lib/utils/copy.js +13 -127
  122. package/lib/utils/copyTimezones.js +21 -0
  123. package/lib/utils/createEventStream.js +24 -19
  124. package/lib/utils/cssClassNameGenerate.js +77 -0
  125. package/lib/utils/cssURLReplacer.js +67 -54
  126. package/lib/utils/dependencyPostPublish.js +42 -0
  127. package/lib/utils/fileUtils.js +125 -0
  128. package/lib/utils/folderIterator.js +47 -0
  129. package/lib/utils/getComponents.js +126 -0
  130. package/lib/utils/getCurrentBranch.js +11 -17
  131. package/lib/utils/getDependenciesImpactList.js +151 -0
  132. package/lib/utils/getHash.js +26 -0
  133. package/lib/utils/getIp.js +20 -0
  134. package/lib/utils/getOptions.js +55 -30
  135. package/lib/utils/getServerURL.js +25 -8
  136. package/lib/utils/index.js +259 -82
  137. package/lib/utils/init.js +2 -2
  138. package/lib/utils/initPreCommitHook.js +40 -31
  139. package/lib/utils/jsonHelper.js +97 -0
  140. package/lib/utils/libraryImpactConfig.js +63 -0
  141. package/lib/utils/lint/addScripts.js +27 -0
  142. package/lib/utils/lint/checkExistingConfig.js +67 -0
  143. package/lib/utils/lint/copyConfigs.js +24 -0
  144. package/lib/utils/lint/index.js +54 -0
  145. package/lib/utils/lint/lintScripts.js +11 -0
  146. package/lib/utils/lint/lintSetup.js +31 -0
  147. package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
  148. package/lib/utils/lint/question.js +30 -0
  149. package/lib/utils/lintReporter.js +142 -0
  150. package/lib/utils/mailSender.js +16 -25
  151. package/lib/utils/pullOrigin.js +28 -0
  152. package/lib/utils/reinstallDependencies.js +133 -0
  153. package/lib/utils/removeAttributes.js +25 -23
  154. package/lib/utils/repoClone.js +56 -63
  155. package/lib/utils/request.js +64 -77
  156. package/lib/utils/resultSchema.json +73 -0
  157. package/lib/utils/rtl.js +42 -0
  158. package/lib/utils/setEnvVariables.js +5 -6
  159. package/lib/utils/ssTestHack.js +48 -0
  160. package/lib/utils/switchBranch.js +28 -0
  161. package/lib/utils/urlConcat.js +22 -0
  162. package/package.json +92 -64
  163. package/templates/app/.eslintrc.js +140 -0
  164. package/templates/app/README.md +12 -12
  165. package/templates/app/app/index.html +24 -8
  166. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  167. package/templates/app/app/properties/i18nkeys.json +3 -3
  168. package/templates/app/docs/all.html +69 -69
  169. package/templates/app/mockapi/index.js +18 -13
  170. package/templates/app/package.json +37 -17
  171. package/templates/app/src/actions/SampleActions/index.js +37 -0
  172. package/templates/app/src/actions/index.js +65 -0
  173. package/templates/app/src/appUrls.js +19 -0
  174. package/templates/app/src/components/Alert/Alert.js +134 -0
  175. package/templates/app/src/components/Alert/Alert.module.css +79 -0
  176. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -0
  177. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -0
  178. package/templates/app/src/components/Sample/Sample.module.css +11 -0
  179. package/templates/app/src/components/Sample/SampleList.js +61 -0
  180. package/templates/app/src/components/Slider/Slider.css +41 -0
  181. package/templates/app/src/components/Slider/Slider.js +55 -0
  182. package/templates/app/src/containers/AlertContainer/index.js +15 -0
  183. package/templates/app/src/containers/AppContainer/index.js +96 -0
  184. package/templates/app/src/containers/AppContainer/index.module.css +27 -0
  185. package/templates/app/src/containers/CustomMatch/index.js +65 -0
  186. package/templates/app/src/containers/DevTools/index.js +10 -0
  187. package/templates/app/src/containers/Header/index.js +67 -0
  188. package/templates/app/src/containers/Header/index.module.css +43 -0
  189. package/templates/app/src/containers/Redirect/index.js +63 -0
  190. package/templates/app/src/containers/Redirector/index.js +47 -0
  191. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -0
  192. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -0
  193. package/templates/app/src/historyChange.js +5 -0
  194. package/templates/app/src/index.html +10 -0
  195. package/templates/app/src/index.js +24 -0
  196. package/templates/app/src/middleware/PromiseMiddleware.js +59 -0
  197. package/templates/app/src/reducers/alertData.js +11 -0
  198. package/templates/app/src/reducers/index.js +6 -0
  199. package/templates/app/src/reducers/samples.js +19 -0
  200. package/templates/app/src/store/configureStore.dev.js +51 -0
  201. package/templates/app/src/store/configureStore.js +5 -0
  202. package/templates/app/src/store/configureStore.prod.js +26 -0
  203. package/templates/app/src/util/Common.js +5 -0
  204. package/templates/app/src/util/RequestAPI.js +132 -0
  205. package/templates/appold/README.md +12 -0
  206. package/templates/appold/app/index.html +8 -0
  207. package/templates/appold/app/properties/ApplicationResources_en_US.properties +1 -0
  208. package/templates/appold/app/properties/i18nkeys.json +3 -0
  209. package/templates/appold/docs/all.html +69 -0
  210. package/templates/appold/mockapi/index.js +13 -0
  211. package/templates/{app → appold}/mockapi/tickets.json +0 -0
  212. package/templates/appold/package.json +17 -0
  213. package/templates/appold/src/components/Text/Text.css +0 -0
  214. package/templates/appold/src/components/Text/Text.js +23 -0
  215. package/templates/appold/src/components/Text/__tests__/Text.spec.js +30 -0
  216. package/templates/appold/src/components/Text/docs/Text__default.docs.js +16 -0
  217. package/templates/appold/src/components/docs.js +1 -0
  218. package/templates/appold/src/components/index.js +5 -0
  219. package/templates/appold/src/index.js +13 -0
  220. package/templates/docs/all.html +1 -1
  221. package/templates/docs/component.html +110 -69
  222. package/templates/docs/components.html +221 -0
  223. package/templates/docs/css/component.css +12 -14
  224. package/templates/docs/css/componentTest.css +7 -0
  225. package/templates/docs/css/style.css +150 -206
  226. package/templates/docs/impactReportTemplate.html +154 -0
  227. package/templates/docs/index.html +1482 -1336
  228. package/templates/library/src/index.js +0 -0
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _path = _interopRequireDefault(require("path"));
9
+
10
+ var _fs = _interopRequireDefault(require("fs"));
11
+
12
+ var _webpackSources = require("webpack-sources");
13
+
14
+ var _jsonHelper = require("../utils/jsonHelper");
15
+
16
+ var _utils = require("../utils");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ let resultFileName = `${process.cwd()}/result.json`;
21
+ let options = (0, _utils.getOptions)();
22
+ let {
23
+ ssTest: {
24
+ referBranch,
25
+ currentBranch,
26
+ serviceName,
27
+ tokenGit,
28
+ changesOnly
29
+ }
30
+ } = options;
31
+ (0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.compareBranch', referBranch);
32
+ (0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.TestBranch', currentBranch);
33
+ (0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.isExecuted', true);
34
+
35
+ let isValidModule = name => {
36
+ if (name.includes('node_modules') && (name.includes(`@zohodesk${_path.default.sep}components`) || name.includes(`@zohodesk${_path.default.sep}dot`) || name.includes(`@zohodesk${_path.default.sep}icons`) || name.includes(`@zohodesk${_path.default.sep}svg`)) && !name.endsWith('docs.js')) {
37
+ return true;
38
+ }
39
+
40
+ return !name.includes('index.js') && !name.endsWith('.css') && !name.endsWith('.png') && !name.includes('node_modules') && name.includes('src');
41
+ };
42
+
43
+ let getModuleName = modulePath => {
44
+ let [name] = _path.default.parse(modulePath).name.split('.');
45
+
46
+ if (modulePath.includes(`@zohodesk${_path.default.sep}components`)) {
47
+ name = `@zohodesk/components/${name}`;
48
+ } else if (modulePath.includes(`@zohodesk${_path.default.sep}dot`)) {
49
+ name = `@zohodesk/dot/${name}`;
50
+ }
51
+
52
+ return name;
53
+ };
54
+
55
+ class LibraryImpactPlugin {
56
+ constructor(options = {}) {
57
+ this.options = options;
58
+ this.options.filename = options.filename || 'js/moduleStats.js';
59
+ this.topHtml = '<!DOCTYPE html><html><head><style>.sourcenameRow .methodDetail { clear: both; padding: 10px; position: relative;}.sourcenameRow.methodDetail > div{float: left; min-width: 50%; padding-bottom: 10px;}.noCoverage { color: red; width: 80%; padding: 10px;}.fl { float: left;}.fr { float: right ! important;}.pointer, #har tr[main] td { cursor: pointer;}.impactTestcaseRow { float: left; width: 45%; padding: 20px; margin-right: 5%; background: white; margin-bottom: 10px; box-sizing: border-box; border-bottom: 2px dotted #eee;}.anchorNone, .modifiedMethodRow:hover .anchorNone { text-decoration: none; color: #00bfff !important;}/* .impactTestcaseRow:hover { box-shadow: -3px 0px 10px #ddd, 2px 1px 3px #ddd;} */.impactedBy{ float: left; padding: 10px; margin-top: 11px; color: green; width: 80%;}div#impactTCListContainer { font-size: 15px;}.impactTestcaseRowContainer,.sourcenameRow{ display:flex; flex-direction:column;}summary{ outline:none;}details{ padding:25px 10px;}</style></head><body> <div class="sourcenameRow pointer bg-clr-hr">';
60
+ this.bottomHtml = '</div> <script type="text/javascript"> const details = document.querySelectorAll("details"); details.forEach((targetDetail) => { targetDetail.addEventListener("click", () => { // Close all the details that are not targetDetail. details.forEach((detail) => { if (detail !== targetDetail) { detail.removeAttribute("open"); } }); }); }); </script></body></html>';
61
+ this.resultJson = {};
62
+ }
63
+
64
+ apply(compiler) {
65
+ let loggedInfo = false;
66
+ compiler.hooks.beforeCompile.tap('LibraryImpactPlugin', () => {
67
+ (0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.startTime', Date.now());
68
+
69
+ if (!loggedInfo) {
70
+ (0, _utils.log)('\x1b[33m%s\x1b[0m', '************************************************************ \n ');
71
+ (0, _utils.log)('\x1b[5m\x1b[44m%s\x1b[0m', 'Finding Impacted Source Files Please Wait ...');
72
+ loggedInfo = true;
73
+ }
74
+ });
75
+ compiler.hooks.emit.tap('LibraryImpactPlugin', compilation => {
76
+ let stats = compilation.getStats().toJson();
77
+ let results = {};
78
+ let {
79
+ modules
80
+ } = stats;
81
+
82
+ for (let module of modules) {
83
+ let {
84
+ name,
85
+ reasons
86
+ } = module;
87
+
88
+ if (isValidModule(name)) {
89
+ let references = new Set();
90
+ let referencedby = new Set();
91
+ let docsName;
92
+ let fileName;
93
+ compilation.modules.forEach(module => {
94
+ module.reasons.forEach(reason => {
95
+ let exportedValue = reason.dependency;
96
+
97
+ if (exportedValue.type === 'harmony export imported specifier') {
98
+ if (exportedValue.module.userRequest.includes(name.replace('.', ''))) {
99
+ docsName = exportedValue.name;
100
+ }
101
+ }
102
+ });
103
+ });
104
+ let currentModuleName = name;
105
+
106
+ if (Array.isArray(reasons)) {
107
+ for (let reason of reasons) {
108
+ let {
109
+ moduleName
110
+ } = reason;
111
+
112
+ if (isValidModule(moduleName)) {
113
+ let reasonedModuleName = moduleName;
114
+ referencedby.add(reasonedModuleName);
115
+ }
116
+ }
117
+ }
118
+
119
+ for (let subModule of modules) {
120
+ let {
121
+ name: subModuleName,
122
+ reasons
123
+ } = subModule;
124
+
125
+ if (isValidModule(subModuleName)) {
126
+ let currentModuleName = subModuleName;
127
+
128
+ if (Array.isArray(reasons)) {
129
+ for (let reason of reasons) {
130
+ let {
131
+ moduleName: reasonedModuleName
132
+ } = reason;
133
+
134
+ if (name === reasonedModuleName) {
135
+ references.add(currentModuleName);
136
+ }
137
+ }
138
+ }
139
+ }
140
+ }
141
+
142
+ results[currentModuleName] = {
143
+ name: currentModuleName,
144
+ references: Array.from(references),
145
+ referencedby: Array.from(referencedby),
146
+ docsName: docsName ? docsName : '',
147
+ fileName: name ? name : currentModuleName
148
+ };
149
+ }
150
+ }
151
+
152
+ (0, _utils.getDependenciesImpactList)(currentBranch, referBranch, tokenGit, serviceName).then(impactedList => {
153
+ this.resultJson = (0, _utils.getLibraryConflict)(JSON.stringify(results), impactedList, changesOnly);
154
+ (0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.result', this.resultJson);
155
+
156
+ if (this.resultJson.result.status) {
157
+ (0, _utils.log)(this.resultJson.response);
158
+ this.resultJson.response.forEach(fileObject => {
159
+ this.topHtml = this.topHtml + '<details><summary><b>Source Name: </b>' + fileObject.sourceName + '</summary><div class="impactTestcaseRowContainer"><div class="impactedBy"> ImpactedBy :- </div>';
160
+ fileObject.impactedBy.forEach(fileName => {
161
+ this.topHtml = this.topHtml + '<div class="impactTestcaseRow"><a class="anchorNone">' + fileName + '</a></div>';
162
+ });
163
+ this.topHtml = this.topHtml + '</div></details>';
164
+ });
165
+ } else {
166
+ (0, _utils.log)('\n');
167
+ (0, _utils.log)(this.resultJson.result.message);
168
+ this.topHtml = this.topHtml + '<div style="font-size: xxx-large; text-align: center; padding-top: 50px;"> ' + this.resultJson.result.message + '</div>';
169
+ }
170
+
171
+ if (!_fs.default.existsSync('./coverageTest')) {
172
+ _fs.default.mkdirSync('./coverageTest');
173
+
174
+ _fs.default.writeFileSync('./coverageTest/impactLibrary.html', this.topHtml + this.bottomHtml, 'utf8');
175
+ } else {
176
+ _fs.default.writeFileSync('./coverageTest/impactLibrary.html', this.topHtml + this.bottomHtml, 'utf8');
177
+ }
178
+
179
+ (0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.endTime', Date.now());
180
+ });
181
+ });
182
+ compiler.hooks.done.tap('LibraryImpactPlugin', () => {
183
+ (0, _utils.log)('\n');
184
+ (0, _utils.log)('Compilation finished!!!');
185
+ });
186
+ }
187
+
188
+ }
189
+
190
+ exports.default = LibraryImpactPlugin;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _utils = require("../utils");
9
+
10
+ class WebpackWatchRunPlugin {
11
+ apply(compiler) {
12
+ compiler.hooks.watchRun.tap('WatchRun', comp => {
13
+ const changedTimes = comp.watchFileSystem.watcher.mtimes;
14
+ const changedFiles = Object.keys(changedTimes).map(file => `\n ${file}`).join('');
15
+
16
+ if (changedFiles.length) {
17
+ (0, _utils.log)('====================================');
18
+ (0, _utils.log)('NEW BUILD FILES CHANGED:', changedFiles);
19
+ (0, _utils.log)('====================================');
20
+ }
21
+ });
22
+ }
23
+
24
+ }
25
+
26
+ exports.default = WebpackWatchRunPlugin;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ var _postcss = _interopRequireDefault(require("postcss"));
4
+
5
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+
7
+ module.exports = _postcss.default.plugin('postcss-exclude-rtl-files', opts => {
8
+ const {
9
+ plugins
10
+ } = opts;
11
+ return (root, result) => {
12
+ const inputFile = root.source.input.file;
13
+ let isIgnoredFile = opts.ignore.some(file => inputFile.indexOf(file) !== -1);
14
+
15
+ if (!isIgnoredFile) {
16
+ const handler = response => response.messages.forEach(msg => result.messages.push(msg));
17
+
18
+ return (0, _postcss.default)(plugins).process(root, {
19
+ from: undefined
20
+ }).then(handler);
21
+ }
22
+ };
23
+ });
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.separateSingleDir = separateSingleDir;
7
+ exports.separateRtlAndLtr = separateRtlAndLtr;
8
+
9
+ var postcss = _interopRequireWildcard(require("postcss"));
10
+
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+
13
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
+
15
+ const oppositeDir = {
16
+ ltr: 'rtl',
17
+ rtl: 'ltr'
18
+ };
19
+
20
+ function compareSelector(selector1, selector2) {
21
+ // console.log({ selector1, selector2 }, selector1 === selector2);
22
+ return selector1 === selector2;
23
+ }
24
+
25
+ const directionRegexs = {
26
+ ltr: /\[dir=ltr\]/,
27
+ rtl: /\[dir=rtl\]/
28
+ };
29
+
30
+ const getRegex = dir => directionRegexs[dir];
31
+
32
+ const getOppositeRegex = dir => getRegex(oppositeDir[dir]);
33
+
34
+ function selectorMinifySameDir(selector, direction) {
35
+ // NOTE: if this rule is same dir as current need
36
+ // then we can just remove that [dir=ltr] or [dir=rtl]
37
+ // it just for minimaze selector
38
+ const regex = getRegex(direction);
39
+ return selector.replace(regex, '').trim();
40
+ }
41
+ /**
42
+ * this funtion will remove given rule,
43
+ * if given selector and it's previous sibiling rule selector are same
44
+ * current rule properties will move to previous sibiling rule.
45
+ * @param {Rule} rule current rule
46
+ */
47
+
48
+
49
+ function mergeIfSameSelector(rule) {
50
+ // NOTE: to merge dublicate selector rules
51
+ const prev = rule.prev();
52
+
53
+ if (prev && compareSelector(prev.selector, rule.selector)) {
54
+ rule.each(decl => {
55
+ prev.append(decl);
56
+ });
57
+ rule.remove();
58
+ }
59
+ }
60
+ /**
61
+ * this funtion will remove given rule,
62
+ * if given selector and it's previous sibiling rule selector are same
63
+ * current rule properties will move to previous sibiling rule.
64
+ * @param {Rule} rule current rule
65
+ */
66
+
67
+
68
+ function removeIfOppsiteDirRule(rule, direction, rootOptions) {
69
+ // console.log({ rule, type: rule.type });
70
+ const selectors = rule.selector.split(/\s*,\s*/); // NOTE: if we use opposite dir selector as custom override reason,
71
+ // and compain normal selector with it, In this case
72
+ // we just a have to remove that selector only not full rule
73
+
74
+ const oppositeDirRegex = getOppositeRegex(direction);
75
+ let remainingSelectors = selectors.filter(selector => !oppositeDirRegex.test(selector));
76
+
77
+ if (!rootOptions.disableMiniFiySelector) {
78
+ remainingSelectors = remainingSelectors.map(selector => selectorMinifySameDir(selector, direction));
79
+ }
80
+
81
+ if (remainingSelectors.length) {
82
+ rule.selector = remainingSelectors.join(', ');
83
+ } else {
84
+ // NOTE: every selector is opposite dir then we have to remove the rule
85
+ rule.remove();
86
+ }
87
+ }
88
+
89
+ function removeIfOppsiteDirKeyframe(rule, direction) {
90
+ let name = rule.params;
91
+ let keyFrameDirName = name.slice(name.lastIndexOf('-') + 1);
92
+
93
+ if (keyFrameDirName === oppositeDir[direction]) {
94
+ // console.log({ m: 'removed', keyFrameName: rule.params });
95
+ rule.remove();
96
+ }
97
+ }
98
+
99
+ function separateSingleDir(root, direction, rootOptions) {
100
+ root.walkRules(rule => {
101
+ removeIfOppsiteDirRule(rule, direction, rootOptions);
102
+ mergeIfSameSelector(rule);
103
+ });
104
+ root.walkAtRules(rule => {
105
+ removeIfOppsiteDirKeyframe(rule, direction);
106
+ });
107
+ return root;
108
+ }
109
+
110
+ function separateRtlAndLtr(css, rootOptions) {
111
+ // let processor = postcss([]).process(css);
112
+ let root = postcss.parse(css); // let { root } = processor;
113
+ // console.log(processor, root);
114
+ // NOTE: I did first rtl then ltr , Because for ltr I use original root ref
115
+
116
+ const rtlRoot = separateSingleDir(root.clone(), 'rtl', rootOptions); // console.log('############################');
117
+
118
+ const ltrRoot = separateSingleDir(root, 'ltr', rootOptions);
119
+ return {
120
+ ltrRoot,
121
+ rtlRoot,
122
+ ltr: ltrRoot.toString(),
123
+ rtl: rtlRoot.toString()
124
+ };
125
+ } // NOTE: to test in https://astexplorer.net/
126
+ // you can test with sample input https://astexplorer.net/#/gist/a892a509eb585099355ef53ef094f836/1ca70d5f7af3b88ca4910296e12f118e9712c874
127
+ // export default postcss.plugin('postcss-rtl-remove', (options = {}) =>
128
+ // // Work with options here
129
+ // root => {
130
+ // const rtlRoot = separateSingleDir(root.clone(), 'rtl');
131
+ // const ltrRoot = separateSingleDir(root, 'ltr');
132
+ // // root.append(postcss.comment({ text: 'comment' }));
133
+ // root.append(postcss.comment({ text: 'this is spliting part ' }));
134
+ // root.append(rtlRoot);
135
+ // //console.log({root, roots:root+""}, root+"")
136
+ // // Transform CSS AST here
137
+ // }
138
+ // );