@zohodesk/react-cli 1.1.17 → 1.1.18-exp.1

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 (135) hide show
  1. package/README.md +13 -0
  2. package/lib/babel/babel-option-utils/babel-preset-react-option.js +22 -0
  3. package/lib/babel/cmjs-plugins-presets.js +7 -1
  4. package/lib/babel/es-plugins-presets.js +7 -1
  5. package/lib/configs/webpack.dev.config.js +7 -2
  6. package/lib/configs/webpack.prod.config.js +9 -2
  7. package/lib/loaderUtils/getDevJsLoaders.js +5 -1
  8. package/lib/schemas/index.js +4 -0
  9. package/npm-shrinkwrap.json +31 -5
  10. package/package.json +1 -1
  11. package/packages/client_build_tool/lib/allCommandsConfigs.js +23 -0
  12. package/packages/client_build_tool/lib/buildToolLoggers.js +32 -0
  13. package/packages/client_build_tool/lib/commands/build/commandExecutor.js +21 -0
  14. package/packages/client_build_tool/lib/commands/build/config.js +12 -0
  15. package/packages/client_build_tool/lib/commands/build/errorHander.js +10 -0
  16. package/packages/client_build_tool/lib/commands/build/index.js +35 -0
  17. package/packages/client_build_tool/lib/commands/build/optionsProcesser.js +40 -0
  18. package/packages/client_build_tool/lib/commands/buildEs/commandExecutor.js +17 -0
  19. package/packages/client_build_tool/lib/commands/buildEs/config.js +12 -0
  20. package/packages/client_build_tool/lib/commands/buildLib/commandExecutor.js +17 -0
  21. package/packages/client_build_tool/lib/commands/buildLib/config.js +12 -0
  22. package/packages/client_build_tool/lib/commands/start/commandExecutor.js +13 -0
  23. package/packages/client_build_tool/lib/commands/start/config.js +12 -0
  24. package/packages/client_build_tool/lib/commands/start/deprecationHandler.js +10 -0
  25. package/packages/client_build_tool/lib/commands/start/errorHander.js +10 -0
  26. package/packages/client_build_tool/lib/commands/start/optionsProcesser.js +36 -0
  27. package/packages/client_build_tool/lib/commands/start/postProcesser.js +10 -0
  28. package/packages/client_build_tool/lib/commands/start/preProcesser.js +10 -0
  29. package/packages/client_build_tool/lib/commandsRouter.js +71 -0
  30. package/packages/client_build_tool/lib/shared/bundler/webpack/common/decidePublicPath.js +44 -0
  31. package/packages/client_build_tool/lib/shared/bundler/webpack/common/libAlias.js +31 -0
  32. package/packages/client_build_tool/lib/shared/bundler/webpack/common/nameTemplates.js +51 -0
  33. package/packages/client_build_tool/lib/shared/bundler/webpack/common/resourceBasedPublicPath.js +21 -0
  34. package/packages/client_build_tool/lib/shared/bundler/webpack/cssLoaders.js +16 -0
  35. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin.js +111 -0
  36. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/EFCPlugin.js +1 -0
  37. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ContributionGuide.md +11 -0
  38. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +136 -0
  39. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nSplit.md +95 -0
  40. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/README.md +25 -0
  41. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +29 -0
  42. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +24 -0
  43. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nDependency.js +99 -0
  44. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +81 -0
  45. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nModule.js +201 -0
  46. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +401 -0
  47. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +67 -0
  48. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +23 -0
  49. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +29 -0
  50. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +49 -0
  51. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +77 -0
  52. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +63 -0
  53. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +19 -0
  54. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +31 -0
  55. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +127 -0
  56. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RTLSplitPlugin.js +1 -0
  57. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +63 -0
  58. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +89 -0
  59. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtrSplit.md +34 -0
  60. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +15 -0
  61. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +155 -0
  62. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin.js +49 -0
  63. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/ExcludePlugin.js +58 -0
  64. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/RTLSplitPlugin.js +139 -0
  65. package/packages/client_build_tool/lib/shared/bundler/webpack/devServerConfig.js +34 -0
  66. package/packages/client_build_tool/lib/shared/bundler/webpack/getCSSLoaders.js +30 -0
  67. package/packages/client_build_tool/lib/shared/bundler/webpack/jsLoaders.js +17 -0
  68. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/assetLoaders.js +14 -0
  69. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +24 -0
  70. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +18 -0
  71. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +21 -0
  72. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +138 -0
  73. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +83 -0
  74. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +23 -0
  75. package/packages/client_build_tool/lib/shared/bundler/webpack/loaders/workerLoader.js +133 -0
  76. package/packages/client_build_tool/lib/shared/bundler/webpack/optimizationConfig.js +39 -0
  77. package/packages/client_build_tool/lib/shared/bundler/webpack/outputConfig.js +28 -0
  78. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +18 -0
  79. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCopyThirdpartyFile.js +38 -0
  80. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +24 -0
  81. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +28 -0
  82. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +35 -0
  83. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +16 -0
  84. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +23 -0
  85. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +19 -0
  86. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +27 -0
  87. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +18 -0
  88. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configUglifyCSSPlugin.js +15 -0
  89. package/packages/client_build_tool/lib/shared/bundler/webpack/plugins.js +39 -0
  90. package/packages/client_build_tool/lib/shared/bundler/webpack/postcssPlugins.js +36 -0
  91. package/packages/client_build_tool/lib/shared/bundler/webpack/resolvers.js +42 -0
  92. package/packages/client_build_tool/lib/shared/bundler/webpack/splitChunksConfig.js +12 -0
  93. package/packages/client_build_tool/lib/shared/bundler/webpack/webpack.dev.config.js +17 -0
  94. package/packages/client_build_tool/lib/shared/bundler/webpack/webpackBuild.js +24 -0
  95. package/packages/client_build_tool/lib/shared/bundler/webpack/webpackConfig.js +50 -0
  96. package/packages/client_build_tool/lib/shared/commands-utlis/doBasicRequiermentCheck.js +16 -0
  97. package/packages/client_build_tool/lib/shared/commands-utlis/getCliPath.js +38 -0
  98. package/packages/client_build_tool/lib/shared/commands-utlis/index.js +29 -0
  99. package/packages/client_build_tool/lib/shared/commands-utlis/log.js +13 -0
  100. package/packages/client_build_tool/lib/shared/commands-utlis/readArgsFormCommandLine.js +11 -0
  101. package/packages/client_build_tool/lib/shared/commands-utlis/readOptionFormCommandLine.js +11 -0
  102. package/packages/client_build_tool/lib/shared/commands-utlis/spanSync.js +35 -0
  103. package/packages/client_build_tool/lib/shared/constants.js +33 -0
  104. package/packages/client_build_tool/lib/shared/schemas/applyValuesToShema.js +37 -0
  105. package/packages/client_build_tool/lib/shared/schemas/cliArgsToObject.js +37 -0
  106. package/packages/client_build_tool/lib/shared/schemas/defaultConfigValues.js +119 -0
  107. package/packages/client_build_tool/lib/shared/schemas/deprecatedOptionsHandler.js +65 -0
  108. package/packages/client_build_tool/lib/shared/schemas/getCWD.js +23 -0
  109. package/packages/client_build_tool/lib/shared/schemas/getNpmVersion.js +21 -0
  110. package/packages/client_build_tool/lib/shared/schemas/npmConfigToObject.js +32 -0
  111. package/packages/client_build_tool/lib/shared/schemas/oldDefaultConfigValues.js +480 -0
  112. package/packages/client_build_tool/lib/shared/schemas/readOptions.js +55 -0
  113. package/packages/client_build_tool/lib/shared/schemas/readOptionsForPackageJson.js +26 -0
  114. package/packages/client_build_tool/lib/shared/schemas/readOptionsOld.js +152 -0
  115. package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.crt +37 -0
  116. package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.key +27 -0
  117. package/packages/client_build_tool/lib/shared/server/configWebpackDevMiddleware.js +40 -0
  118. package/packages/client_build_tool/lib/shared/server/corsHandleing.js +28 -0
  119. package/packages/client_build_tool/lib/shared/server/getIp.js +30 -0
  120. package/packages/client_build_tool/lib/shared/server/getServerURL.js +29 -0
  121. package/packages/client_build_tool/lib/shared/server/httpsOptions.js +53 -0
  122. package/packages/client_build_tool/lib/shared/server/initExpressApp.js +19 -0
  123. package/packages/client_build_tool/lib/shared/server/initialHTMLHandling.js +66 -0
  124. package/packages/client_build_tool/lib/shared/server/serveContextFiles.js +24 -0
  125. package/packages/client_build_tool/lib/shared/server/serverBywebpackDevMiddleware.js +40 -0
  126. package/packages/client_build_tool/lib/shared/server/startHttpServer.js +26 -0
  127. package/packages/client_build_tool/lib/shared/server/startHttpsServer.js +34 -0
  128. package/packages/client_build_tool/lib/shared/server/unwanted/addHttp2Server.js +41 -0
  129. package/packages/client_build_tool/lib/shared/server/unwanted/configWebpackDevMiddleware.js +44 -0
  130. package/packages/client_build_tool/lib/shared/server/unwanted/devServerUtlis.js +1 -0
  131. package/packages/client_build_tool/lib/shared/server/unwanted/mockApiSupport.js +19 -0
  132. package/packages/client_build_tool/lib/shared/server/unwanted/webpackConfig.js +32 -0
  133. package/packages/client_build_tool/lib/shared/server/unwanted/websocketMockSetup.js +48 -0
  134. package/packages/client_build_tool/lib/shared/server/urlConcat.js +25 -0
  135. package/packages/client_build_tool/lib/shared/utils/utils.js +1 -0
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = webpackConfigCreator;
7
+
8
+ var _outputConfig = require("./outputConfig");
9
+
10
+ var _jsLoaders = require("./jsLoaders");
11
+
12
+ var _cssLoaders = require("./cssLoaders");
13
+
14
+ var _assetLoaders = require("./loaderConfigs/assetLoaders");
15
+
16
+ var _plugins = require("./plugins");
17
+
18
+ var _resolvers = require("./resolvers");
19
+
20
+ var _optimizationConfig = require("./optimizationConfig");
21
+
22
+ var _configHtmlTemplateLoader = require("./loaderConfigs/configHtmlTemplateLoader");
23
+
24
+ var _configWebWorkerLoader = require("./loaderConfigs/configWebWorkerLoader");
25
+
26
+ // import { devServerConfig } from './devServerConfig';
27
+ function webpackConfigCreator(options) {
28
+ return {
29
+ mode: 'development',
30
+ output: (0, _outputConfig.outputConfig)(options),
31
+ devtool: 'cheap-source-map',
32
+ // stats: 'errors-only',
33
+ stats: {
34
+ children: false,
35
+ colors: true,
36
+ errorDetails: true // excludeAssets: /i18n/,
37
+ // excludeAssets: /./,
38
+ // warningsFilter: /\[mini-css-extract-plugin\]/
39
+
40
+ },
41
+ // devServer: devServerConfig(options),
42
+ optimization: (0, _optimizationConfig.optimizationConfig)(options),
43
+ module: {
44
+ rules: [...(0, _jsLoaders.jsLoaders)(options), ...(0, _cssLoaders.cssLoaders)(options), (0, _configWebWorkerLoader.configWebWorkerLoader)(options), (0, _configHtmlTemplateLoader.configHtmlTemplateLoader)(options), ...(0, _assetLoaders.assetLoaders)(options)]
45
+ },
46
+ plugins: (0, _plugins.plugins)(options),
47
+ resolve: (0, _resolvers.moduleResolver)(options),
48
+ resolveLoader: (0, _resolvers.loaderResolver)(options)
49
+ };
50
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.doBasicRequiermentCheck = doBasicRequiermentCheck;
7
+
8
+ function doBasicRequiermentCheck() {
9
+ const majorV = Number(process.version.slice(1, 4));
10
+
11
+ if (majorV >= 12 && majorV <= 18) {
12
+ return true;
13
+ }
14
+
15
+ throw `your node version not compactable with this cli please update node vesrion to 12 - 18, and your current version is ${process.version}`;
16
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getCliPath = void 0;
7
+
8
+ var _os = require("os");
9
+
10
+ var _fs = require("fs");
11
+
12
+ var _path = require("path");
13
+
14
+ const appPath = process.cwd();
15
+ const isNodeModuleUnderAppFolder = __dirname.indexOf(appPath) !== -1;
16
+ const isWindows = (0, _os.platform)().toLowerCase() === 'win32';
17
+ const suffixExt = isWindows ? '.cmd' : ''; // function searchForCommandPath(commandName) {
18
+ // let pathFolders = __dirname.split(sep);
19
+ // let cliPath;
20
+ // while (pathFolders.pop()) {
21
+ // cliPath = join(pathFolders.join(sep), 'node_modules', '.bin', commandName);
22
+ // if (existsSync(cliPath)) {
23
+ // return cliPath;
24
+ // }
25
+ // }
26
+ // console.warn(`unable to find command "${commandName}"`);
27
+ // return join(__dirname, '..', 'node_modules', '.bin', commandName);
28
+ // }
29
+
30
+ function searchForCommandPath(libName) {
31
+ const commandPath = (0, _path.join)(__dirname, '..', '..', '..', 'node_modules', '.bin', libName); // TODO: need to check for windows machine reason command with ext added,
32
+ // when we use global react-cli package (executable) working or not
33
+
34
+ return (0, _fs.existsSync)(commandPath) ? commandPath : libName;
35
+ }
36
+
37
+ const getCliPath = !isNodeModuleUnderAppFolder ? commandName => searchForCommandPath(commandName + suffixExt) : commandName => commandName + suffixExt;
38
+ exports.getCliPath = getCliPath;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "doBasicRequiermentCheck", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _doBasicRequiermentCheck.doBasicRequiermentCheck;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "readArgsFormCommandLine", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _readArgsFormCommandLine.readArgsFormCommandLine;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "readOptionFormCommandLine", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _readOptionFormCommandLine.readOptionFormCommandLine;
22
+ }
23
+ });
24
+
25
+ var _readArgsFormCommandLine = require("./readArgsFormCommandLine");
26
+
27
+ var _readOptionFormCommandLine = require("./readOptionFormCommandLine");
28
+
29
+ var _doBasicRequiermentCheck = require("./doBasicRequiermentCheck");
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.log = void 0;
7
+
8
+ let log = (...info) => {
9
+ let print = console;
10
+ print.log(...info);
11
+ };
12
+
13
+ exports.log = log;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.readArgsFormCommandLine = readArgsFormCommandLine;
7
+ const args = process.argv.slice(3);
8
+
9
+ function readArgsFormCommandLine() {
10
+ return args;
11
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.readOptionFormCommandLine = readOptionFormCommandLine;
7
+ const [,, option] = process.argv;
8
+
9
+ function readOptionFormCommandLine() {
10
+ return option;
11
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.spawnIO = spawnIO;
7
+ exports.spawnSyncIO = spawnSyncIO;
8
+
9
+ var _getCliPath = require("./getCliPath");
10
+
11
+ const {
12
+ spawnSync,
13
+ spawn
14
+ } = require('child_process');
15
+
16
+ function spawnSyncIO(commandName, args) {
17
+ const command = (0, _getCliPath.getCliPath)(commandName);
18
+ const result = spawnSync(command, args, {
19
+ stdio: 'inherit'
20
+ });
21
+
22
+ if (result.error || result.stderr) {
23
+ console.error(result.error || result.stderr);
24
+ } // console.log(result.output);
25
+
26
+
27
+ process.exit(result.status);
28
+ }
29
+
30
+ function spawnIO(commandName, args, cb) {
31
+ // const result =
32
+ spawn(commandName, args, {
33
+ stdio: 'inherit'
34
+ }, cb); // process.exit(result.status);
35
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.cliRootPath = exports.cliNodemodulesPath = exports.babelrcPath = exports.appPath = exports.appInitialHTMLTemplatePath = exports.CONFIG_ROOT = exports.BASE_CONFIG_KEY = void 0;
7
+
8
+ var _path = _interopRequireWildcard(require("path"));
9
+
10
+ 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); }
11
+
12
+ 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; }
13
+
14
+ const BASE_CONFIG_KEY = 'react-cli';
15
+ exports.BASE_CONFIG_KEY = BASE_CONFIG_KEY;
16
+
17
+ const cliRootPath = _path.default.resolve(__dirname, '..', '..');
18
+
19
+ exports.cliRootPath = cliRootPath;
20
+ const CONFIG_ROOT = 'client-build-config';
21
+ exports.CONFIG_ROOT = CONFIG_ROOT;
22
+
23
+ const cliNodemodulesPath = _path.default.resolve(cliRootPath, 'node_modules');
24
+
25
+ exports.cliNodemodulesPath = cliNodemodulesPath;
26
+ const babelrcPath = (0, _path.join)(cliRootPath, '.babelrc');
27
+ exports.babelrcPath = babelrcPath;
28
+ const appPath = process.cwd();
29
+ exports.appPath = appPath;
30
+
31
+ const appInitialHTMLTemplatePath = _path.default.join(process.cwd(), 'src', 'index.html');
32
+
33
+ exports.appInitialHTMLTemplatePath = appInitialHTMLTemplatePath;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.applyValuesToShema = applyValuesToShema;
7
+
8
+ function isObject(obj) {
9
+ return obj !== null && typeof obj === 'object' && !Array.isArray(obj);
10
+ }
11
+
12
+ function applyValuesToShema(schemas, customOptions, processEnv) {
13
+ const output = {};
14
+
15
+ function decideValue(schema, key, customOptions) {
16
+ const specificShema = schema[key];
17
+ const correspondingValue = customOptions && customOptions[key];
18
+
19
+ if (isObject(specificShema)) {
20
+ if (typeof specificShema.cli === 'string') {
21
+ var _ref, _processEnv$specificS;
22
+
23
+ return (_ref = (_processEnv$specificS = processEnv[specificShema.cli]) !== null && _processEnv$specificS !== void 0 ? _processEnv$specificS : correspondingValue) !== null && _ref !== void 0 ? _ref : specificShema.value;
24
+ }
25
+
26
+ return applyValuesToShema(specificShema, correspondingValue, processEnv);
27
+ }
28
+
29
+ return correspondingValue !== null && correspondingValue !== void 0 ? correspondingValue : schema[key];
30
+ } // console.log({schemas})
31
+
32
+
33
+ Object.keys(schemas).forEach(key => {
34
+ output[key] = decideValue(schemas, key, customOptions);
35
+ });
36
+ return output;
37
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.cliArgsToObject = cliArgsToObject;
7
+
8
+ /**
9
+ * experimental argument parsing logic
10
+ * @param {Array} cliArgs is when we use cli the options or args
11
+ *
12
+ * cliArgs:-
13
+ * `cbt start --port=2332 --mode=prod` in this command
14
+ * ['--port=2332', '--mode=prod'] these are cliArgs
15
+ *
16
+ * retunr {"port": 2332, "mode":"prod"}
17
+ */
18
+ function cliArgsToObject(cliArgs) {
19
+ const processEnv = {};
20
+ cliArgs.forEach(option => {
21
+ if (/^--./.test(option)) {
22
+ const equIndex = option.indexOf('='); // equIndex = equIndex === -1 ? option.length : equIndex;
23
+
24
+ let key = option.slice(2, equIndex);
25
+ let value = option.slice(equIndex + 1);
26
+
27
+ if (equIndex === -1) {
28
+ key = option.slice(2);
29
+ value = true;
30
+ }
31
+
32
+ key = key.replace(/-|:/g, '_');
33
+ processEnv[key] = value;
34
+ }
35
+ });
36
+ return processEnv;
37
+ }
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _os = require("os");
9
+
10
+ // import { join } from 'path';
11
+ // import { cliRootPath } from '../constants';
12
+ // import { getIp } from '../server/getIp';
13
+ var _default = {
14
+ context: {
15
+ value: 'app',
16
+ cli: 'context'
17
+ },
18
+ enableChunkHash: {
19
+ value: true,
20
+ cli: 'enablehash'
21
+ },
22
+ output: {
23
+ value: 'build',
24
+ cli: 'output'
25
+ },
26
+ server: {
27
+ httpsCerts: {
28
+ value: '',
29
+ cli: 'https_certs'
30
+ },
31
+ host: {
32
+ value: (0, _os.hostname)(),
33
+ cli: 'host'
34
+ },
35
+ port: {
36
+ value: 9090,
37
+ cli: 'port'
38
+ },
39
+ domain: {
40
+ value: 'tsi',
41
+ cli: 'domain'
42
+ },
43
+ // domain: { value: null, cli: 'domain' },
44
+ mode: {
45
+ value: 'dev',
46
+ cli: 'mode'
47
+ },
48
+ disableContextURL: false,
49
+ hasMock: false,
50
+ mockPrefix: {
51
+ value: '/api',
52
+ cli: 'mock_prefix'
53
+ },
54
+ mockPort: {
55
+ value: 5000,
56
+ cli: 'mock_port'
57
+ }
58
+ },
59
+ css: {
60
+ selectorReplace: null,
61
+ classNameOptions: {
62
+ classNamePrefix: 'zd',
63
+ classNameBlob: false
64
+ },
65
+ plugins: {
66
+ rtlSplit: {
67
+ enableRTLSplit: false,
68
+ templateLabel: '{{--dir}}',
69
+ disableMinifySelector: false,
70
+ dirVarName: 'document.dir'
71
+ },
72
+ rtl: {
73
+ enable: false,
74
+ exclude: []
75
+ }
76
+ }
77
+ },
78
+ i18nChunkSplit: {
79
+ chunkSplitEnable: {
80
+ value: false,
81
+ cli: 'i18n_split'
82
+ },
83
+ disableDefault: false,
84
+ templateLabel: '{{--user-locale}}',
85
+ localeVarName: 'document.documentElement.lang',
86
+ jsonpFunc: 'console.log',
87
+ jsResource: null,
88
+ propertiesFolder: null
89
+ },
90
+ app: {
91
+ tpFolder: null,
92
+ moduleResolvePath: {
93
+ value: '',
94
+ cli: 'module_resolve_path'
95
+ },
96
+ htmlTemplate: {
97
+ inject: true
98
+ },
99
+ cdnMapping: {
100
+ isCdnEnabled: false,
101
+ variableName: '',
102
+ cssTemplate: '',
103
+ jsTemplate: '',
104
+ i18nTemplate: ''
105
+ },
106
+ serviceWorker: {
107
+ enableSw: false,
108
+ filePath: 'sw.js',
109
+ fileName: 'v1.js',
110
+ exitPath: '/',
111
+ replaceText: '//<!--AssetsFromBuild -->'
112
+ },
113
+ enableSMap: {
114
+ value: false,
115
+ cli: 'source_map_enable'
116
+ }
117
+ }
118
+ };
119
+ exports.default = _default;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.deprecatedOptionsHandler = deprecatedOptionsHandler;
7
+
8
+ var _buildToolLoggers = require("../../buildToolLoggers");
9
+
10
+ function selectn(obj, key) {
11
+ let temp = obj;
12
+ const keys = key.split('.');
13
+
14
+ for (let i = 0; i < keys.length; i++) {
15
+ const element = keys[i];
16
+ temp = temp && temp[element];
17
+ }
18
+
19
+ return temp;
20
+ }
21
+
22
+ function selectnu(obj, key, value) {
23
+ let temp = obj;
24
+ const keys = key.split('.');
25
+ let i = 0;
26
+
27
+ for (; i < keys.length - 1; i++) {
28
+ const element = keys[i];
29
+ temp = temp && temp[element];
30
+ }
31
+
32
+ temp[keys[i]] = value;
33
+ }
34
+
35
+ function deprecatedOptionsHandler(options) {
36
+ function checkAndupdateAndPrintWaring(oldKey, newkey) {
37
+ const oldVal = selectn(options, oldKey);
38
+ const newVal = selectn(options, newkey); // console.log({ oldVal, newVal });
39
+
40
+ if (oldVal !== undefined && newVal === undefined) {
41
+ selectnu(options, newkey, newVal);
42
+ (0, _buildToolLoggers.warnLogger)(`"${oldKey}" deprecated use "${newkey}" instead`);
43
+ }
44
+ } // return;
45
+
46
+
47
+ checkAndupdateAndPrintWaring('app.context', 'context'); // TODO handle deprecations here
48
+ // we will finish this logic later when options are confirmed
49
+
50
+ if (selectn(options, 'app.hasRTL') === true) {
51
+ options.app.plugins.hasRTL = true;
52
+ }
53
+
54
+ if (selectn(options, 'docs.hasRTL') === true) {
55
+ options.docs.plugins.hasRTL = true;
56
+ }
57
+
58
+ if (selectn(options, 'app.rtlExclude.length') > 0) {
59
+ options.app.exclude.rtl = selectn(options, 'app.rtlExclude');
60
+ }
61
+
62
+ if (selectn(options, 'docs.rtlExclude.length') > 0) {
63
+ options.docs.exclude.rtl = selectn(options, 'docs.rtlExclude');
64
+ }
65
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getCWD = getCWD;
7
+
8
+ var _child_process = require("child_process");
9
+
10
+ function getCWD() {
11
+ // require("child_process").
12
+ let cwd = process.cwd();
13
+
14
+ try {
15
+ let ress = (0, _child_process.execSync)('npm bin').toString();
16
+ let i = ress.lastIndexOf('node_modules');
17
+ cwd = i === -1 ? cwd : ress.slice(0, i);
18
+ } catch (error) {
19
+ console.log(error);
20
+ }
21
+
22
+ return cwd;
23
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getNpmVersion = getNpmVersion;
7
+
8
+ var _child_process = require("child_process");
9
+
10
+ function getNpmVersion() {
11
+ // require("child_process").
12
+ let vers = '6';
13
+
14
+ try {
15
+ [vers] = (0, _child_process.execSync)('npm -v').toString().trim().split('.');
16
+ } catch (error) {
17
+ console.log(error);
18
+ }
19
+
20
+ return vers;
21
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.npmConfigToObject = npmConfigToObject;
7
+ const NPM_CONFIG_PREFIX = 'npm_config_'; // TODO: we have to do option parse logic little better
8
+ // if user use react-cli stritly without using npm scripts options won't work,
9
+ // So we have to write our own option parse logic or some other library
10
+ // console.log('type', process.argv, process.env.npm_config_check, process.env.npm_config_clone_type, process.env.npm_config_clone_url);
11
+ // console.log('Object.keys(process.env).filter(s => s.startsWith(\'npm_config_\') && s.includes(\'clone\')', Object.keys(process.env).filter(s => s.startsWith('npm_config_') && s.includes('clone')));
12
+
13
+ function npmConfigToObject() {
14
+ // // clone:type
15
+ const processEnv = {};
16
+ let keysWithColon = [];
17
+ Object.keys(process.env).filter(key => key.startsWith(NPM_CONFIG_PREFIX)).forEach(key => {
18
+ let nkey = key.slice(NPM_CONFIG_PREFIX.length);
19
+ processEnv[nkey] = process.env[key];
20
+ nkey.includes(':') && keysWithColon.push(nkey);
21
+ });
22
+ keysWithColon.forEach(key => {
23
+ let nkey = key.replace(/:/g, '_');
24
+
25
+ if (processEnv[nkey]) {
26
+ console.warn('there is some options conflict', key, nkey);
27
+ }
28
+
29
+ processEnv[nkey] = processEnv[key];
30
+ });
31
+ return processEnv;
32
+ }