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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. package/README.md +35 -40
  2. package/docs/SelectorWeight.md +6 -0
  3. package/docs/VariableConversion.md +33 -1
  4. package/lib/babel/cmjs-plugins-presets.js +4 -0
  5. package/lib/babel/es-plugins-presets.js +4 -0
  6. package/lib/common/getEntries.js +10 -0
  7. package/lib/common/getPublicPathConfig.js +6 -0
  8. package/lib/common/index.js +5 -0
  9. package/lib/common/splitChunks.js +13 -2
  10. package/lib/common/sslcertUpdater.js +17 -6
  11. package/lib/common/templateParameters.js +2 -0
  12. package/lib/common/testPattern.js +21 -10
  13. package/lib/common/valueReplacer.js +15 -0
  14. package/lib/configs/jest.config.js +9 -0
  15. package/lib/configs/libAlias.js +2 -4
  16. package/lib/configs/webpack.component.umd.config.js +5 -0
  17. package/lib/configs/webpack.css.umd.config.js +13 -5
  18. package/lib/configs/webpack.dev.config.js +36 -2
  19. package/lib/configs/webpack.docs.config.js +21 -1
  20. package/lib/configs/webpack.impact.config.js +19 -1
  21. package/lib/configs/webpack.prod.config.js +37 -3
  22. package/lib/hooks/docsProptypeHook.js +7 -3
  23. package/lib/jest/commitedFilesResult.js +45 -3
  24. package/lib/jest/coverageCollector.js +11 -0
  25. package/lib/jest/jsonMaker.js +6 -0
  26. package/lib/jest/preProcessors/cssPreprocessor.js +8 -0
  27. package/lib/jest/preProcessors/jsPreprocessor.js +2 -0
  28. package/lib/jest/preProcessors/otherFilesPreprocessor.js +3 -0
  29. package/lib/jest/result.js +22 -0
  30. package/lib/jest/run.js +17 -6
  31. package/lib/jest/setup.js +57 -5
  32. package/lib/loaderUtils/configsAssetsLoaders.js +11 -1
  33. package/lib/loaderUtils/getCSSLoaders.js +35 -20
  34. package/lib/loaderUtils/getDevJsLoaders.js +8 -0
  35. package/lib/loaderUtils/index.js +3 -0
  36. package/lib/loaderUtils/windowsModification.js +11 -0
  37. package/lib/loaders/docsLoader.js +7 -0
  38. package/lib/loaders/docsPropsLoader.js +7 -3
  39. package/lib/loaders/fileBountryLoader.js +2 -0
  40. package/lib/loaders/fileLoader.js +22 -11
  41. package/lib/loaders/scriptInstrumentLoader.js +13 -5
  42. package/lib/loaders/selectorMappingLoader.js +25 -7
  43. package/lib/loaders/workerLoader.js +20 -4
  44. package/lib/middlewares/HMRMiddleware.js +26 -13
  45. package/lib/middlewares/SSTMiddleware.js +3 -0
  46. package/lib/pluginUtils/configHtmlWebpackPlugins.js +9 -3
  47. package/lib/pluginUtils/getDevPlugins.js +63 -17
  48. package/lib/pluginUtils/getDocsPlugins.js +10 -1
  49. package/lib/pluginUtils/getLibraryImactPlugins.js +5 -4
  50. package/lib/pluginUtils/getLibraryPlugins.js +5 -0
  51. package/lib/pluginUtils/getProdPlugins.js +72 -23
  52. package/lib/pluginUtils/getServerPlugins.js +5 -0
  53. package/lib/pluginUtils/getUMDCSSPlugins.js +7 -0
  54. package/lib/pluginUtils/getUMDComponentPlugins.js +7 -0
  55. package/lib/pluginUtils/index.js +8 -0
  56. package/lib/plugins/CdnChangePlugin.js +14 -0
  57. package/lib/plugins/CleanupStatsPlugin.js +5 -0
  58. package/lib/plugins/EFCPlugin.js +34 -23
  59. package/lib/plugins/EFCTemplatePlugin.js +32 -23
  60. package/lib/plugins/I18NInjectIntoIndexPlugin.js +34 -8
  61. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +17 -12
  62. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
  63. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +39 -8
  64. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +29 -14
  65. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +22 -13
  66. package/lib/plugins/I18nSplitPlugin/index.js +23 -13
  67. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +12 -2
  68. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +1 -0
  69. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +5 -0
  70. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +6 -0
  71. package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
  72. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -2
  73. package/lib/plugins/ManifestPlugin.js +17 -0
  74. package/lib/plugins/ModuleStatsPlugin.js +23 -0
  75. package/lib/plugins/OptimizeJSPlugin.js +7 -0
  76. package/lib/plugins/PublicPathCallbackPlugin.js +10 -0
  77. package/lib/plugins/PublicPathChangePlugin.js +36 -4
  78. package/lib/plugins/ReportGeneratePlugin.js +30 -4
  79. package/lib/plugins/RequireVariablePublicPlugin.js +6 -0
  80. package/lib/plugins/ResourceHintsPlugin.js +10 -3
  81. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
  82. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +16 -9
  83. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
  84. package/lib/plugins/ScriptInstrumentPlugin.js +7 -0
  85. package/lib/plugins/SelectorPlugin.js +97 -0
  86. package/lib/plugins/ServiceWorkerPlugin.js +20 -4
  87. package/lib/plugins/ShadowDOMSupportPlugin.js +40 -3
  88. package/lib/plugins/SourceMapHookPlugin.js +9 -0
  89. package/lib/plugins/TPHashMappingPlugin.js +15 -1
  90. package/lib/plugins/UglifyCSSPlugin.js +9 -0
  91. package/lib/plugins/UnusedFilesFindPlugin.js +35 -2
  92. package/lib/plugins/VariableConversionCollector.js +252 -0
  93. package/lib/plugins/composeCommonPlugin.js +30 -0
  94. package/lib/plugins/index.js +19 -0
  95. package/lib/plugins/libraryImpactPlugin.js +32 -0
  96. package/lib/plugins/webpackwatchrunplugin.js +5 -0
  97. package/lib/postcss-plugins/ExcludePlugin.js +4 -0
  98. package/lib/postcss-plugins/RTLSplitPlugin.js +27 -14
  99. package/lib/postcss-plugins/ValueReplacer.js +6 -9
  100. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
  101. package/lib/postcss-plugins/hoverActivePlugin.js +66 -30
  102. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +40 -13
  103. package/lib/postcss-plugins/variableModificationPlugin/index.js +215 -141
  104. package/lib/postcss-plugins/variableModifier.js +20 -13
  105. package/lib/schemas/index.js +23 -4
  106. package/lib/servers/clusterHubServer.js +10 -0
  107. package/lib/servers/devBuild.js +24 -13
  108. package/lib/servers/docsServer.js +2 -0
  109. package/lib/servers/docsServerCore.js +21 -0
  110. package/lib/servers/getCliPath.js +9 -0
  111. package/lib/servers/helpServer.js +5 -0
  112. package/lib/servers/httpsOptions.js +4 -0
  113. package/lib/servers/impactServer.js +34 -2
  114. package/lib/servers/mockserver.js +9 -0
  115. package/lib/servers/nowatchserver.js +34 -12
  116. package/lib/servers/scrServer.js +20 -13
  117. package/lib/servers/server.js +35 -7
  118. package/lib/servers/ssServer.js +16 -0
  119. package/lib/templates/CoverageScriptTemplate.js +14 -0
  120. package/lib/templates/WMSTemplate.js +12 -6
  121. package/lib/utils/babelPresets.js +2 -0
  122. package/lib/utils/clean.js +8 -2
  123. package/lib/utils/copy.js +6 -0
  124. package/lib/utils/copyTimezones.js +8 -0
  125. package/lib/utils/createEventStream.js +4 -0
  126. package/lib/utils/cssClassNameGenerate.js +19 -3
  127. package/lib/utils/cssURLReplacer.js +50 -38
  128. package/lib/utils/dependencyPostPublish.js +9 -0
  129. package/lib/utils/fileUtils.js +26 -0
  130. package/lib/utils/folderIterator.js +10 -0
  131. package/lib/utils/getComponents.js +21 -0
  132. package/lib/utils/getCurrentBranch.js +5 -0
  133. package/lib/utils/getDependenciesImpactList.js +21 -0
  134. package/lib/utils/getFileType.js +49 -0
  135. package/lib/utils/getHash.js +7 -0
  136. package/lib/utils/getIp.js +2 -0
  137. package/lib/utils/getOptions.js +39 -14
  138. package/lib/utils/getServerURL.js +7 -0
  139. package/lib/utils/index.js +47 -2
  140. package/lib/utils/init.js +1 -0
  141. package/lib/utils/initPreCommitHook.js +29 -6
  142. package/lib/utils/jsonHelper.js +19 -2
  143. package/lib/utils/libraryImpactConfig.js +2 -0
  144. package/lib/utils/lint/addScripts.js +5 -2
  145. package/lib/utils/lint/checkExistingConfig.js +12 -3
  146. package/lib/utils/lint/copyConfigs.js +3 -0
  147. package/lib/utils/lint/index.js +9 -0
  148. package/lib/utils/lint/lintScripts.js +1 -0
  149. package/lib/utils/lint/lintSetup.js +4 -3
  150. package/lib/utils/lint/lintStagedPreCommitHook.js +1 -0
  151. package/lib/utils/lint/question.js +7 -0
  152. package/lib/utils/lintReporter.js +20 -0
  153. package/lib/utils/mailSender.js +7 -0
  154. package/lib/utils/pullOrigin.js +4 -0
  155. package/lib/utils/reinstallDependencies.js +28 -0
  156. package/lib/utils/removeAttributes.js +7 -0
  157. package/lib/utils/repoClone.js +27 -2
  158. package/lib/utils/request.js +12 -0
  159. package/lib/utils/rtl.js +16 -4
  160. package/lib/utils/setEnvVariables.js +2 -0
  161. package/lib/utils/ssTestHack.js +10 -0
  162. package/lib/utils/switchBranch.js +4 -0
  163. package/lib/utils/urlConcat.js +4 -0
  164. package/lib/utils/useExitCleanup.js +10 -9
  165. package/package.json +10 -9
@@ -7,29 +7,37 @@ const {
7
7
  runInstall,
8
8
  installLintStaged
9
9
  } = require('./lintSetup');
10
+
10
11
  const {
11
12
  log
12
13
  } = require('..');
14
+
13
15
  const {
14
16
  eslintConfigFiles,
15
17
  prettierConfigFiles,
16
18
  getChoices
17
19
  } = require('./checkExistingConfig');
20
+
18
21
  const copyConfigs = require('./copyConfigs');
22
+
19
23
  async function main() {
20
24
  const packages = [];
21
25
  const [isESLintAllowed, isPrettierAllowed, isHookInstallEnabled] = await getChoices();
26
+
22
27
  if (isESLintAllowed) {
23
28
  copyConfigs('eslintrc', eslintConfigFiles);
24
29
  packages.push(...eslintPackages);
25
30
  }
31
+
26
32
  if (isPrettierAllowed) {
27
33
  copyConfigs('prettierrc', prettierConfigFiles);
28
34
  packages.push(...prettierPackages);
29
35
  }
36
+
30
37
  if (isESLintAllowed && isPrettierAllowed) {
31
38
  packages.push(...eslintPrettierConfig);
32
39
  }
40
+
33
41
  if (packages.length) {
34
42
  const process = runInstall(packages);
35
43
  process.on('close', () => {
@@ -41,5 +49,6 @@ async function main() {
41
49
  installLintStaged();
42
50
  }
43
51
  }
52
+
44
53
  log('[LINT SETUP] Beginning configuration...');
45
54
  main();
@@ -3,6 +3,7 @@
3
3
  const {
4
4
  addScripts
5
5
  } = require('./addScripts');
6
+
6
7
  const scripts = {
7
8
  lintSetup: 'react-cli lint-setup && npm run lintExtInstall && echo "If changes not reflected kindly restart your VSCode."',
8
9
  lintExtInstall: 'code --install-extension dbaeumer.vscode-eslint && code --install-extension esbenp.prettier-vscode'
@@ -3,11 +3,10 @@
3
3
  const {
4
4
  spawn
5
5
  } = require('child_process');
6
+
6
7
  const eslintPackages = ['eslint@7.18.0', 'eslint-config-airbnb@18.2.1', 'eslint-plugin-import@2.22.1', 'eslint-plugin-jsx-a11y@6.4.1', 'eslint-plugin-react@7.22.0', 'eslint-plugin-css-modules@2.11.0', '@zohodesk/eslint-plugin-react-performance@1.0.3', '@zohodesk/eslint-plugin-zsecurity@0.0.1-beta.4', 'eslint-plugin-react-hooks@4.2.0'];
7
8
  const prettierPackages = ['prettier@2.2.1'];
8
- const eslintPrettierConfig = ['eslint-config-prettier@7.2.0'];
9
-
10
- // const npmInstall = `npm i --save-dev ${devDependencies.join(' ')}`;
9
+ const eslintPrettierConfig = ['eslint-config-prettier@7.2.0']; // const npmInstall = `npm i --save-dev ${devDependencies.join(' ')}`;
11
10
 
12
11
  function runInstall(packages) {
13
12
  return spawn('npm', ['i', ...packages, '--save-dev'], {
@@ -15,12 +14,14 @@ function runInstall(packages) {
15
14
  stdio: 'inherit'
16
15
  });
17
16
  }
17
+
18
18
  function installLintStaged() {
19
19
  spawn('npx', ['mrm', 'lint-staged'], {
20
20
  detached: true,
21
21
  stdio: 'inherit'
22
22
  });
23
23
  }
24
+
24
25
  module.exports = {
25
26
  eslintPackages,
26
27
  prettierPackages,
@@ -3,4 +3,5 @@
3
3
  const {
4
4
  installLintStaged
5
5
  } = require('./lintSetup');
6
+
6
7
  installLintStaged();
@@ -1,22 +1,29 @@
1
1
  "use strict";
2
2
 
3
3
  /* eslint-disable no-await-in-loop */
4
+
4
5
  /* eslint-disable implicit-arrow-linebreak */
5
6
  const readline = require('readline');
7
+
6
8
  const rl = readline.createInterface({
7
9
  input: process.stdin,
8
10
  output: process.stdout
9
11
  });
12
+
10
13
  const question = qn => new Promise(res => {
11
14
  rl.question(qn, ans => res(ans));
12
15
  });
16
+
13
17
  async function main(qn) {
14
18
  let answer;
19
+
15
20
  while (!['n', 'y'].includes(answer)) {
16
21
  answer = (await question(qn)).toLowerCase();
17
22
  }
23
+
18
24
  return answer;
19
25
  }
26
+
20
27
  module.exports = {
21
28
  question: main,
22
29
  rl
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  let getOptions = require('./getOptions').default;
4
+
4
5
  let fs = require('fs');
6
+
5
7
  let coverageCollector = require('../jest/coverageCollector');
8
+
6
9
  let path = require('path');
10
+
7
11
  let {
8
12
  htmlTemplate,
9
13
  endTag
10
14
  } = require('../templates/linterConstant');
15
+
11
16
  let {
12
17
  esLint: {
13
18
  srcBranch,
@@ -19,9 +24,12 @@ let {
19
24
  reportPath
20
25
  }
21
26
  } = getOptions();
27
+
22
28
  function writeFile(filePath, data) {
23
29
  filePath = path.join(process.cwd(), filePath); //eslint-disable-line
30
+
24
31
  let dirName = path.dirname(filePath);
32
+
25
33
  if (!fs.existsSync(dirName)) {
26
34
  fs.mkdirSync(dirName);
27
35
  fs.writeFileSync(filePath, data);
@@ -29,6 +37,7 @@ function writeFile(filePath, data) {
29
37
  fs.writeFileSync(filePath, data);
30
38
  }
31
39
  }
40
+
32
41
  let formatter = {
33
42
  jsonFormatter: data => {
34
43
  let finalList = [];
@@ -39,6 +48,7 @@ let formatter = {
39
48
  tempMessageList.push(messageObj);
40
49
  }
41
50
  });
51
+
42
52
  if (tempMessageList.length > 0) {
43
53
  finalList.push(errorFileObj);
44
54
  }
@@ -47,6 +57,7 @@ let formatter = {
47
57
  },
48
58
  htmlFormatter: data => {
49
59
  data = formatter.jsonFormatter(data); //eslint-disable-line
60
+
50
61
  if (data.length > 0) {
51
62
  let liTag = '';
52
63
  data.forEach(errorFileObj => {
@@ -54,16 +65,19 @@ let formatter = {
54
65
  let messageTag = '';
55
66
  errorFileObj.messages.forEach(messageObj => {
56
67
  let errorType = messageObj.severity == 2 ? 'Error' : 'Warning'; //eslint-disable-line
68
+
57
69
  messageTag = `${messageTag}<div class="pkDetailsRow"><div class="pkDetailsCol">${messageObj.line}</div><div class="pkDetailsCol pkError">${errorType}</div><div class="pkDetailsCol">${messageObj.message}</div><div class="pkDetailsCol">${messageObj.ruleId}</div></div>`;
58
70
  });
59
71
  liTag = `${liTag + messageTag}</div></div></li>`;
60
72
  });
61
73
  return `${htmlTemplate}<ul class="pkUl">${liTag}</ul>${endTag}`;
62
74
  }
75
+
63
76
  return `${htmlTemplate}<div class="pkEmpty"><div>No test results with found</div></div>${endTag}`;
64
77
  },
65
78
  xmlFormatter: data => {
66
79
  data = formatter.jsonFormatter(data); //eslint-disable-line
80
+
67
81
  let startTag = '<jscheck>';
68
82
  let engTag = '</jscheck>';
69
83
  let bodyContent = '';
@@ -79,8 +93,10 @@ let formatter = {
79
93
  return startTag + bodyContent + engTag;
80
94
  }
81
95
  };
96
+
82
97
  function formatSplitter(inputJson) {
83
98
  let outputData;
99
+
84
100
  if (reportType === 'json') {
85
101
  outputData = JSON.stringify(formatter.jsonFormatter(inputJson));
86
102
  } else if (reportType === 'html') {
@@ -88,8 +104,10 @@ function formatSplitter(inputJson) {
88
104
  } else if (reportType === 'xml') {
89
105
  outputData = formatter.xmlFormatter(inputJson);
90
106
  }
107
+
91
108
  writeFile(reportPath, outputData);
92
109
  }
110
+
93
111
  module.exports = function (results) {
94
112
  let erroredFileObjectList = [];
95
113
  results.forEach(fileObject => {
@@ -102,9 +120,11 @@ module.exports = function (results) {
102
120
  });
103
121
  }
104
122
  });
123
+
105
124
  if (impactRun) {
106
125
  coverageCollector(srcBranch, targetBranch, serviceName, impactServerDomain).then((res = {}) => {
107
126
  let impactList = [];
127
+
108
128
  if (res.STATUS) {
109
129
  if (res.LIST.length > 0) {
110
130
  erroredFileObjectList.forEach(errFileObj => {
@@ -1,15 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  var _nodemailer = _interopRequireDefault(require("nodemailer"));
4
+
4
5
  var _index = require("./index");
6
+
5
7
  var _jsonHelper = require("./jsonHelper");
8
+
6
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+
7
11
  if (process.argv.length <= 6) {
8
12
  (0, _index.log)('Usage: node mailSender <from> <pass> <to> <subject> <html>');
9
13
  process.exit(-1);
10
14
  }
15
+
11
16
  let [from, pass, to, subject, html, cc, user, reportURL] = process.argv.slice(2);
12
17
  (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'Report_URL', reportURL);
18
+
13
19
  let transporter = _nodemailer.default.createTransport({
14
20
  host: 'smtp.tsi.zohocorpin.com',
15
21
  port: 25,
@@ -19,6 +25,7 @@ let transporter = _nodemailer.default.createTransport({
19
25
  pass
20
26
  }
21
27
  });
28
+
22
29
  let mailOptions = {
23
30
  from: from,
24
31
  to: to,
@@ -4,8 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _child_process = require("child_process");
9
+
8
10
  var _utils = require("../utils");
11
+
9
12
  var _default = (type = 'git', branchName) => new Promise(resolve => {
10
13
  if (type === 'git') {
11
14
  (0, _child_process.spawnSync)('git', ['pull', 'origin', branchName], {
@@ -21,4 +24,5 @@ var _default = (type = 'git', branchName) => new Promise(resolve => {
21
24
  resolve();
22
25
  }
23
26
  });
27
+
24
28
  exports.default = _default;
@@ -4,13 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.reinstallDependencies1 = exports.reinstallDependencies = exports.collectPackageDiff = void 0;
7
+
7
8
  var _fs = _interopRequireDefault(require("fs"));
9
+
8
10
  var _path = _interopRequireDefault(require("path"));
11
+
9
12
  var _child_process = require("child_process");
13
+
10
14
  var _gitRootDir = _interopRequireDefault(require("git-root-dir"));
15
+
11
16
  var _index = require("./index");
17
+
12
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
13
20
  let packageJsons = {};
21
+
14
22
  let packageDiffChecker = (pre, current) => {
15
23
  let {
16
24
  dependencies = {},
@@ -19,23 +27,28 @@ let packageDiffChecker = (pre, current) => {
19
27
  let diffs = {};
20
28
  Object.keys(dependencies).forEach(pack => {
21
29
  let version = dependencies[pack];
30
+
22
31
  if (version !== pre.dependencies && pre.dependencies[pack]) {
23
32
  diffs[pack] = version;
24
33
  }
25
34
  });
26
35
  Object.keys(devDependencies).forEach(pack => {
27
36
  let version = devDependencies[pack];
37
+
28
38
  if (version !== pre.devDependencies && pre.devDependencies[pack]) {
29
39
  diffs[pack] = version;
30
40
  }
31
41
  });
32
42
  return diffs;
33
43
  };
44
+
34
45
  let collectPackageDiff = pathToSubProjects => new Promise(resolve => {
35
46
  (0, _gitRootDir.default)(process.cwd()).then(rootDir => {
36
47
  let projects = _fs.default.readdirSync(_path.default.join(rootDir, pathToSubProjects));
48
+
37
49
  projects.forEach(project => {
38
50
  let packageJson = _path.default.join(_path.default.join(rootDir, pathToSubProjects), project, 'package.json');
51
+
39
52
  if (_fs.default.existsSync(packageJson)) {
40
53
  packageJsons[project] = require(packageJson);
41
54
  }
@@ -43,21 +56,29 @@ let collectPackageDiff = pathToSubProjects => new Promise(resolve => {
43
56
  resolve();
44
57
  });
45
58
  });
59
+
46
60
  exports.collectPackageDiff = collectPackageDiff;
61
+
47
62
  let reinstallDependencies1 = pathToSubProjects => {
48
63
  (0, _gitRootDir.default)(process.cwd()).then(rootDir => {
49
64
  let projects = _fs.default.readdirSync(_path.default.join(rootDir, pathToSubProjects));
65
+
50
66
  projects.forEach(project => {
51
67
  let prePackageJson = packageJsons[project];
52
68
  let currentPackageJson;
69
+
53
70
  if (prePackageJson) {
54
71
  currentPackageJson = _path.default.join(_path.default.join(rootDir, pathToSubProjects), project, 'package.json');
72
+
55
73
  if (_fs.default.existsSync(currentPackageJson)) {
56
74
  currentPackageJson = require(currentPackageJson);
57
75
  }
58
76
  }
77
+
59
78
  let projPath = _path.default.join(_path.default.join(rootDir, pathToSubProjects), project);
79
+
60
80
  let diffs = packageDiffChecker(prePackageJson, currentPackageJson);
81
+
61
82
  if (Object.keys(diffs).length) {
62
83
  (0, _index.log)(diffs, `package diffs between branches for ${project} project`);
63
84
  (0, _child_process.spawnSync)('rm', ['-rf', 'package-lock.json'], {
@@ -66,10 +87,12 @@ let reinstallDependencies1 = pathToSubProjects => {
66
87
  });
67
88
  let packages = Object.keys(diffs);
68
89
  let dummy = [];
90
+
69
91
  for (let name of packages) {
70
92
  let version = diffs[name];
71
93
  dummy.push(`${name}@${version}`);
72
94
  }
95
+
73
96
  (0, _index.log)(`npm ${['install'].concat(dummy).join(' ')}`);
74
97
  (0, _child_process.spawnSync)('npm', ['install'].concat(dummy), {
75
98
  cwd: projPath,
@@ -88,12 +111,16 @@ let reinstallDependencies1 = pathToSubProjects => {
88
111
  });
89
112
  });
90
113
  };
114
+
91
115
  exports.reinstallDependencies1 = reinstallDependencies1;
116
+
92
117
  let reinstallDependencies = pathToSubProjects => new Promise(resolve => {
93
118
  (0, _gitRootDir.default)(process.cwd()).then(rootDir => {
94
119
  let projects = _fs.default.readdirSync(_path.default.join(rootDir, pathToSubProjects));
120
+
95
121
  projects.forEach(project => {
96
122
  let projPath = _path.default.join(_path.default.join(rootDir, pathToSubProjects), project);
123
+
97
124
  (0, _child_process.spawnSync)('npm', ['install'], {
98
125
  cwd: projPath,
99
126
  stdio: 'inherit'
@@ -102,4 +129,5 @@ let reinstallDependencies = pathToSubProjects => new Promise(resolve => {
102
129
  });
103
130
  });
104
131
  });
132
+
105
133
  exports.reinstallDependencies = reinstallDependencies;
@@ -1,27 +1,34 @@
1
1
  "use strict";
2
2
 
3
3
  var _getOptions = _interopRequireDefault(require("./getOptions"));
4
+
4
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+
5
7
  let options = (0, _getOptions.default)();
6
8
  let {
7
9
  app: {
8
10
  attrbuteNames
9
11
  }
10
12
  } = options;
13
+
11
14
  module.exports = () => ({
12
15
  visitor: {
13
16
  Program(path, state) {
14
17
  let properties = state.opts.properties || [];
18
+
15
19
  if (properties.length === 0) {
16
20
  properties = properties.concat(attrbuteNames);
17
21
  }
22
+
18
23
  path.traverse({
19
24
  JSXIdentifier(path2) {
20
25
  if (properties.indexOf(path2.node.name.toLowerCase()) > -1) {
21
26
  path2.parentPath.remove();
22
27
  }
23
28
  }
29
+
24
30
  });
25
31
  }
32
+
26
33
  }
27
34
  });
@@ -1,17 +1,25 @@
1
1
  "use strict";
2
2
 
3
3
  var _os = require("os");
4
+
4
5
  var _path = _interopRequireDefault(require("path"));
6
+
5
7
  var _fs = _interopRequireDefault(require("fs"));
8
+
6
9
  var _child_process = require("child_process");
10
+
7
11
  var _index = require("./index");
12
+
8
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
9
15
  function spawnSyncWithErrorLog(...args) {
10
16
  let result = (0, _child_process.spawnSync)(...args);
17
+
11
18
  if (result.stderr) {
12
19
  console.error(result.stderr);
13
20
  }
14
21
  }
22
+
15
23
  let options = (0, _index.getOptions)();
16
24
  let {
17
25
  clone: {
@@ -26,28 +34,36 @@ let {
26
34
  shouldDelete
27
35
  }
28
36
  } = options;
37
+
29
38
  if (type && (type === 'git' || type === 'hg')) {
30
39
  (0, _index.log)(`Going to clone ${type} repository`);
31
40
  } else {
32
41
  throw new Error('You must give valid type to clone a repository');
33
42
  }
43
+
34
44
  if (!cacheDir) {
35
45
  cacheDir = _path.default.join((0, _os.homedir)(), '.react-cli');
36
46
  } else {
37
47
  cacheDir = _path.default.join(process.cwd(), cacheDir);
38
48
  }
49
+
39
50
  if (!projectName) {
40
51
  let {
41
52
  name
42
53
  } = _path.default.parse(url);
54
+
43
55
  projectName = name;
44
56
  }
57
+
45
58
  let projectPath = _path.default.join(cacheDir, projectName);
59
+
46
60
  let cloneRepo = () => {
47
61
  if (!_fs.default.existsSync(cacheDir)) {
48
62
  _fs.default.mkdirSync(cacheDir);
49
63
  }
64
+
50
65
  let revisionOrBranch;
66
+
51
67
  if (type === 'git') {
52
68
  revisionOrBranch = `-b${branch}`;
53
69
  } else {
@@ -57,23 +73,30 @@ let cloneRepo = () => {
57
73
  revisionOrBranch = `-b${branch}`;
58
74
  }
59
75
  }
60
- (0, _index.log)(`Going to clone ${url} repo to ${cacheDir} path`);
61
- // this is for some time error will because of hg or git so we addid error log for this
76
+
77
+ (0, _index.log)(`Going to clone ${url} repo to ${cacheDir} path`); // this is for some time error will because of hg or git so we addid error log for this
78
+
62
79
  let oargs = ['clone', url, revisionOrBranch, projectName];
63
80
  type === 'git' && shallowClone && oargs.push('--depth=1');
64
81
  spawnSyncWithErrorLog(type, oargs, {
65
82
  cwd: cacheDir,
66
83
  stdio: 'inherit'
67
84
  });
85
+
68
86
  _fs.default.writeFileSync(_path.default.join(projectPath, type === 'hg' ? '.hg' : '.git', 'remoteUrl'), url);
87
+
69
88
  (0, _index.log)('Repository cloned!');
70
89
  };
90
+
71
91
  let getRemoteURL = () => {
72
92
  let remoteUrl = _fs.default.readFileSync(_path.default.join(projectPath, type === 'hg' ? '.hg' : '.git', 'remoteUrl')).toString();
93
+
73
94
  return remoteUrl.trim();
74
95
  };
96
+
75
97
  if (_fs.default.existsSync(projectPath)) {
76
98
  let remoteUrl = getRemoteURL();
99
+
77
100
  if (remoteUrl === url) {
78
101
  if (type === 'git') {
79
102
  spawnSyncWithErrorLog(type, ['pull', remoteName, branch], {
@@ -82,11 +105,13 @@ if (_fs.default.existsSync(projectPath)) {
82
105
  });
83
106
  } else {
84
107
  let revisionOrBranch;
108
+
85
109
  if (revision) {
86
110
  revisionOrBranch = `-r${revision}`;
87
111
  } else {
88
112
  revisionOrBranch = `-b${branch}`;
89
113
  }
114
+
90
115
  spawnSyncWithErrorLog(type, ['pull', revisionOrBranch, '-u', url], {
91
116
  cwd: projectPath,
92
117
  stdio: 'inherit'
@@ -1,12 +1,19 @@
1
1
  "use strict";
2
2
 
3
3
  const https = require('https');
4
+
4
5
  const http = require('http');
6
+
5
7
  const url = require('url');
8
+
6
9
  const querystring = require('querystring');
10
+
7
11
  let isObject = data => data && data.toString && data.toString() === '[object Object]';
12
+
8
13
  let isArray = data => data && Array.isArray(data);
14
+
9
15
  process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
16
+
10
17
  let callback = resolve => res => {
11
18
  res.setEncoding('utf8');
12
19
  let str = '';
@@ -23,6 +30,7 @@ let callback = resolve => res => {
23
30
  process.stdout.write(err);
24
31
  });
25
32
  };
33
+
26
34
  let request = options => new Promise((resolve, reject) => {
27
35
  let {
28
36
  protocol,
@@ -44,11 +52,13 @@ let request = options => new Promise((resolve, reject) => {
44
52
  headers: headers
45
53
  };
46
54
  let req;
55
+
47
56
  if (protocol === 'https:') {
48
57
  req = https.request(newOptions, callback(resolve));
49
58
  } else if (protocol === 'http:') {
50
59
  req = http.request(newOptions, callback(resolve));
51
60
  }
61
+
52
62
  if (method.toUpperCase() === 'POST') {
53
63
  if (isObject(payload) || isArray(payload)) {
54
64
  payload = JSON.stringify(payload);
@@ -58,6 +68,7 @@ let request = options => new Promise((resolve, reject) => {
58
68
  req.write(formdata);
59
69
  }
60
70
  }
71
+
61
72
  req.on('error', err => {
62
73
  //eslint-disable-next-line
63
74
  console.log(err);
@@ -65,4 +76,5 @@ let request = options => new Promise((resolve, reject) => {
65
76
  });
66
77
  req.end();
67
78
  });
79
+
68
80
  module.exports = request;
package/lib/utils/rtl.js CHANGED
@@ -1,24 +1,35 @@
1
1
  "use strict";
2
2
 
3
3
  var _postcss = _interopRequireDefault(require("postcss"));
4
+
4
5
  var _path = _interopRequireDefault(require("path"));
6
+
5
7
  var _fs = _interopRequireDefault(require("fs"));
8
+
6
9
  var _folderIterator = _interopRequireDefault(require("./folderIterator"));
10
+
7
11
  var _postcssRtl = _interopRequireDefault(require("@zohodesk/postcss-rtl"));
12
+
8
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
9
15
  let cwd = process.cwd();
16
+
10
17
  let src = _path.default.join(cwd, process.argv[2]);
18
+
11
19
  let dist = _path.default.join(cwd, process.argv[3]);
20
+
12
21
  let canWacth = '-w' === process.argv[4];
13
- // import { useExitCleanup } from './useExitCleanup';
14
22
 
23
+ // import { useExitCleanup } from './useExitCleanup';
15
24
  function watchHandler(fromPath, toPath) {
16
25
  let css = _fs.default.readFileSync(fromPath);
26
+
17
27
  (0, _postcss.default)([(0, _postcssRtl.default)({
18
28
  addPrefixToSelector: function addPrefixToSelector(selector, prefix) {
19
29
  if (prefix === '[dir]') {
20
30
  return selector;
21
31
  }
32
+
22
33
  return `${prefix} ${selector}`; // Make selectors like [dir=rtl] > .selector
23
34
  }
24
35
  })]).process(css, {
@@ -26,21 +37,22 @@ function watchHandler(fromPath, toPath) {
26
37
  to: toPath
27
38
  }).then(result => {
28
39
  _fs.default.writeFile(toPath, result.css, () => true);
40
+
29
41
  if (result.map) {
30
42
  _fs.default.writeFile(`${toPath}.map`, result.map, () => true);
31
43
  }
32
44
  });
33
45
  }
46
+
34
47
  (0, _folderIterator.default)(src, dist, ['.css'], false, (fromPath, toPath) => {
35
48
  if (canWacth && fromPath) {
36
49
  _fs.default.watchFile(fromPath, () => {
37
50
  watchHandler(fromPath, toPath);
38
51
  });
39
52
  }
40
- watchHandler(fromPath, toPath);
41
- });
42
53
 
43
- // if (canWacth) {
54
+ watchHandler(fromPath, toPath);
55
+ }); // if (canWacth) {
44
56
  // useExitCleanup(() => {
45
57
  // fs.unwatchFile(src, watchHandler);
46
58
  // });
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _child_process = require("child_process");
4
+
4
5
  let args = process.argv.slice(2);
5
6
  args.forEach(arg => {
6
7
  if (arg.startsWith('-')) {
7
8
  //eslint-disable-next-line
8
9
  arg = arg.substring(2);
9
10
  }
11
+
10
12
  (0, _child_process.execSync)(`npm config set ${arg}`);
11
13
  });