@zohodesk/react-cli 0.0.1-beta.164 → 0.0.1-beta.167

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 (79) hide show
  1. package/README.md +63 -0
  2. package/bin/cli.js +28 -2
  3. package/cert/Tsicsezwild-22-23.crt +37 -0
  4. package/cert/Tsicsezwild-22-23.key +27 -0
  5. package/docs/CustomChunks.md +26 -0
  6. package/docs/DevStart.md +18 -0
  7. package/docs/TODOS.md +10 -0
  8. package/docs/ValueReplacer.md +60 -0
  9. package/docs/warnings_while_install.txt +35 -0
  10. package/eslint/React_CDN.zip +0 -0
  11. package/eslint/a23.c +16 -0
  12. package/eslint/a28.c +25 -0
  13. package/eslint/a29.c +25 -0
  14. package/eslint/a30.c +29 -0
  15. package/eslint/a31.c +23 -0
  16. package/eslint/a35.c +23 -0
  17. package/eslint/a36.c +18 -0
  18. package/eslint/a37.c +25 -0
  19. package/eslint/a38.c +28 -0
  20. package/eslint/a39.c +17 -0
  21. package/eslint/a40.c +32 -0
  22. package/eslint/temp/a +0 -0
  23. package/eslint/temp/a.der +0 -0
  24. package/eslint/temp/a.jks +0 -0
  25. package/eslint/temp/a.p12 +0 -0
  26. package/eslint/temp/a.pfx +0 -0
  27. package/eslint/temp/c.jks +0 -0
  28. package/eslint/temp/package.json +15 -0
  29. package/eslint/temp/pkcs12.keystore +0 -0
  30. package/eslint/temp/pkk.pfx +0 -0
  31. package/eslint/temp/sas.keystore +0 -0
  32. package/eslint/temp/sas.keystore.old +0 -0
  33. package/eslint/testa/build1/index.html +12 -0
  34. package/eslint/testa/build1/js/2_.js +15 -0
  35. package/eslint/testa/build1/js/2_.js.map +1 -0
  36. package/eslint/testa/build1/js/main_.js +40 -0
  37. package/eslint/testa/build1/js/main_.js.map +1 -0
  38. package/eslint/testa/build1/js/runtime~main_.js +251 -0
  39. package/eslint/testa/build1/js/runtime~main_.js.map +1 -0
  40. package/eslint/testa/build2/index.html +12 -0
  41. package/eslint/testa/build2/js/2_.js +15 -0
  42. package/eslint/testa/build2/js/2_.js.map +1 -0
  43. package/eslint/testa/build2/js/3_.js +15 -0
  44. package/eslint/testa/build2/js/3_.js.map +1 -0
  45. package/eslint/testa/build2/js/main_.js +46 -0
  46. package/eslint/testa/build2/js/main_.js.map +1 -0
  47. package/eslint/testa/build2/js/runtime~main_.js +251 -0
  48. package/eslint/testa/build2/js/runtime~main_.js.map +1 -0
  49. package/eslint/testa/package.json +22 -0
  50. package/eslint/testa/scr/chunk1.js +3 -0
  51. package/eslint/testa/scr/chunk2.js +3 -0
  52. package/eslint/testa/scr/index.html +12 -0
  53. package/eslint/testa/scr/index.js +4 -0
  54. package/eslint/testa/scr/utlis.js +12 -0
  55. package/eslint/testa/src/chunk1.js +3 -0
  56. package/eslint/testa/src/index.html +12 -0
  57. package/eslint/testa/src/index.js +3 -0
  58. package/eslint/testa/src/utlis.js +7 -0
  59. package/lib/common/splitChunks.js +57 -10
  60. package/lib/common/testPattern.js +69 -0
  61. package/lib/common/valueReplacer.js +55 -0
  62. package/lib/configs/jest.config.js +6 -1
  63. package/lib/configs/webpack.dev.config.js +3 -2
  64. package/lib/configs/webpack.docs.config.js +31 -26
  65. package/lib/configs/webpack.prod.config.js +4 -3
  66. package/lib/loaderUtils/getCSSLoaders.js +17 -13
  67. package/lib/postcss-plugins/ValueReplacer.js +46 -0
  68. package/lib/schemas/index.js +21 -0
  69. package/lib/servers/devBuild.js +102 -0
  70. package/lib/servers/getCliPath.js +24 -0
  71. package/lib/servers/httpsOptions.js +2 -3
  72. package/lib/servers/nowatchserver.js +9 -84
  73. package/lib/servers/server.js +20 -5
  74. package/lib/utils/repoClone.js +5 -2
  75. package/lib/utils/rtl.js +19 -2
  76. package/lib/utils/useExitCleanup.js +55 -0
  77. package/npm8.md +9 -0
  78. package/package.json +2 -1
  79. package/postpublish.js +6 -0
@@ -8,12 +8,16 @@ var _pluginUtils = require("../pluginUtils");
8
8
 
9
9
  var _loaderUtils = require("../loaderUtils");
10
10
 
11
+ var _libAlias = require("./libAlias");
12
+
11
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
14
 
13
15
  let options = (0, _utils.getOptions)();
14
16
  let {
17
+ unstableDepsInverse,
15
18
  docs: {
16
19
  componentFolder,
20
+ disableES5Transpile,
17
21
  cssUniqueness,
18
22
  hasRTL,
19
23
  rtlExclude,
@@ -28,39 +32,39 @@ let appPath = process.cwd();
28
32
 
29
33
  module.exports = isSSTest => ({
30
34
  entry: {
31
- main: [_path.default.resolve(__dirname, "..", "hooks", "docsProptypeHook.js"), _path.default.join(appPath, componentFolder, "index.js")],
32
- vendor: ["react", "react-dom", "redux", "react-redux"]
35
+ main: [_path.default.resolve(__dirname, '..', 'hooks', 'docsProptypeHook.js'), _path.default.join(appPath, componentFolder, 'index.js')],
36
+ vendor: ['react', 'react-dom', 'redux', 'react-redux']
33
37
  },
34
- devtool: "none",
35
- mode: "development",
38
+ devtool: 'none',
39
+ mode: 'development',
36
40
  output: {
37
- path: _path.default.join(appPath, "build"),
38
- filename: "js/[name].js",
39
- publicPath: "/docs/",
40
- library: "Component",
41
- libraryTarget: "umd"
41
+ path: _path.default.join(appPath, 'build'),
42
+ filename: 'js/[name].js',
43
+ publicPath: '/docs/',
44
+ library: 'Component',
45
+ libraryTarget: 'umd'
42
46
  },
43
47
  plugins: (0, _pluginUtils.getDocsPlugins)(isSSTest, options),
44
48
  module: {
45
49
  rules: [{
46
50
  test: /\.js$/,
47
51
  use: [{
48
- loader: "babel-loader",
52
+ loader: 'babel-loader',
49
53
  options: {
50
- presets: [[require.resolve("@babel/preset-env"), {
54
+ presets: [[require.resolve('@babel/preset-env'), {
51
55
  modules: false
52
- }], require.resolve("@babel/preset-react")],
53
- plugins: [[require.resolve("@babel/plugin-transform-runtime"), {
56
+ }], require.resolve('@babel/preset-react')],
57
+ plugins: [[require.resolve('@babel/plugin-transform-runtime'), {
54
58
  helpers: true,
55
59
  regenerator: false
56
- }], require.resolve("@babel/plugin-syntax-dynamic-import"), require.resolve("@babel/plugin-syntax-object-rest-spread")],
60
+ }], require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('@babel/plugin-syntax-object-rest-spread')],
57
61
  cacheDirectory: true
58
62
  }
59
63
  }],
60
64
  include: _path.default.join(appPath, folder)
61
65
  }, {
62
66
  test: /\.docs\.js$/,
63
- use: require.resolve("../loaders/docsLoader.js"),
67
+ use: require.resolve('../loaders/docsLoader.js'),
64
68
  include: _path.default.join(appPath, folder),
65
69
  exclude: /node_modules/
66
70
  }, {
@@ -68,29 +72,29 @@ module.exports = isSSTest => ({
68
72
  use: (0, _loaderUtils.getCSSLoaders)(hasRTL, rtlExclude, false, cssUniqueness, null, cssHashSelectors, classNamePrefix)
69
73
  }, {
70
74
  test: /\.jpe?g$|\.gif$|\.png$/,
71
- use: ["url-loader?limit=1000&name=./images/[name].[ext]"]
75
+ use: ['url-loader?limit=1000&name=./images/[name].[ext]']
72
76
  }, {
73
77
  test: /\.woff2|\.woff$|\.ttf$|\.eot$/,
74
- use: ["url-loader?limit=1000&name=./fonts/[name].[ext]"]
78
+ use: ['url-loader?limit=1000&name=./fonts/[name].[ext]']
75
79
  }, {
76
80
  test: /\.svg$/,
77
- use: ["url-loader?limit=1&name=./fonts/[name].[ext]"]
81
+ use: ['url-loader?limit=1&name=./fonts/[name].[ext]']
78
82
  }, {
79
83
  test: /\.html$/,
80
84
  use: {
81
- loader: "html-loader",
85
+ loader: 'html-loader',
82
86
  options: {
83
- attrs: [":data-src"],
84
- interpolate: "require"
87
+ attrs: [':data-src'],
88
+ interpolate: 'require'
85
89
  }
86
90
  }
87
91
  }, {
88
92
  test: /\.ogg$/,
89
- use: ["file-loader?name=./fonts/[name].[ext]"]
93
+ use: ['file-loader?name=./fonts/[name].[ext]']
90
94
  }, {
91
95
  test: /\.tmpl$/,
92
96
  use: [{
93
- loader: "html-loader",
97
+ loader: 'html-loader',
94
98
  options: {
95
99
  minimize: {
96
100
  removeComments: true,
@@ -104,12 +108,13 @@ module.exports = isSSTest => ({
104
108
  }]
105
109
  },
106
110
  externals: {
107
- ZC: "$ZC"
111
+ ZC: '$ZC'
108
112
  },
109
113
  resolve: {
110
- modules: [_path.default.resolve(__dirname, "..", "..", "node_modules"), "node_modules"]
114
+ modules: unstableDepsInverse ? ['node_modules', _path.default.resolve(__dirname, '..', '..', 'node_modules')] : [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
115
+ alias: disableES5Transpile ? _libAlias.libAlias : {}
111
116
  },
112
117
  resolveLoader: {
113
- modules: [_path.default.resolve(__dirname, "..", "..", "node_modules"), "node_modules"]
118
+ modules: unstableDepsInverse ? ['node_modules', _path.default.resolve(__dirname, '..', '..', 'node_modules')] : [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
114
119
  }
115
120
  });
@@ -17,6 +17,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
17
17
  // import TerserPlugin from 'terser-webpack-plugin';
18
18
  let options = (0, _utils.getOptions)();
19
19
  let {
20
+ unstableDepsInverse,
20
21
  app: {
21
22
  folder,
22
23
  context,
@@ -80,7 +81,7 @@ module.exports = {
80
81
  concatenateModules: true,
81
82
  minimize: true,
82
83
  // by default if minimize: true in webpack minimize then webpack automaticaly add TerserPlugin,
83
- // So we are overrideing it.
84
+ // So we are overrideing it.
84
85
  // minimizer: [
85
86
  // new TerserPlugin({
86
87
  // cache: true,
@@ -208,10 +209,10 @@ module.exports = {
208
209
  ZC: '$ZC'
209
210
  },
210
211
  resolve: {
211
- modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
212
+ modules: unstableDepsInverse ? ['node_modules', _path.default.resolve(__dirname, '..', '..', 'node_modules')] : [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
212
213
  alias: disableES5Transpile ? _libAlias.libAlias : {}
213
214
  },
214
215
  resolveLoader: {
215
- modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
216
+ modules: unstableDepsInverse ? ['node_modules', _path.default.resolve(__dirname, '..', '..', 'node_modules')] : [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
216
217
  }
217
218
  };
@@ -20,6 +20,9 @@ let getCSSLoaders = (hasRTL, rtlExclude, classNameBlob, cssUniqueness, selectorR
20
20
  const {
21
21
  devCssFileBountry
22
22
  } = options.app;
23
+ const {
24
+ valueReplacer
25
+ } = options.css;
23
26
  const {
24
27
  cssSelectorZipPath
25
28
  } = options.impactService;
@@ -36,6 +39,18 @@ let getCSSLoaders = (hasRTL, rtlExclude, classNameBlob, cssUniqueness, selectorR
36
39
  cssLoaderOptions.modules.getLocalIdent = (0, _cssClassNameGenerate.default)(cssUniqueness, cssHashSelectors, classNamePrefix);
37
40
  }
38
41
 
42
+ const postcssPlugins = [valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer), selectorReplace && require('postcss-selector-replace')(selectorReplace), hasRTL && require('../postcss-plugins/ExcludeRTLPlugin')({
43
+ ignore: rtlExcludeLocal,
44
+ plugins: [require('@zohodesk/postcss-rtl')({
45
+ addPrefixToSelector: function addPrefixToSelector(selector, prefix) {
46
+ if (prefix === '[dir]') {
47
+ return selector;
48
+ }
49
+
50
+ return `${prefix} ${selector}`; // Make selectors like [dir=rtl] > .selector
51
+ }
52
+ })]
53
+ })].filter(Boolean);
39
54
  return [cssSelectorZipPath && {
40
55
  loader: require.resolve('../loaders/selectorMappingLoader')
41
56
  }, {
@@ -51,23 +66,12 @@ let getCSSLoaders = (hasRTL, rtlExclude, classNameBlob, cssUniqueness, selectorR
51
66
  options: {
52
67
  devCssFileBountry
53
68
  }
54
- }, hasRTL || selectorReplace ? {
69
+ }, postcssPlugins.length > 0 ? {
55
70
  loader: 'postcss-loader',
56
71
  options: {
57
72
  ident: 'postcss',
58
73
  plugins: function () {
59
- return [selectorReplace && require('postcss-selector-replace')(selectorReplace), hasRTL && require('../postcss-plugins/ExcludeRTLPlugin')({
60
- ignore: rtlExcludeLocal,
61
- plugins: [require('@zohodesk/postcss-rtl')({
62
- addPrefixToSelector: function addPrefixToSelector(selector, prefix) {
63
- if (prefix === '[dir]') {
64
- return selector;
65
- }
66
-
67
- return `${prefix} ${selector}`; // Make selectors like [dir=rtl] > .selector
68
- }
69
- })]
70
- })].filter(Boolean);
74
+ return postcssPlugins;
71
75
  }
72
76
  }
73
77
  } : null].filter(Boolean);
@@ -0,0 +1,46 @@
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.plugin('postcss-value-replacer', opts => {
8
+ // const { plugins } = opts;
9
+ // return (root, result) => {
10
+ // const inputFile = root.source.input.file;
11
+ // let isIgnoredFile= opts.ignore.some(file => inputFile.indexOf(file)!==-1);
12
+ // if (!isIgnoredFile) {
13
+ // const handler = response =>
14
+ // response.messages.forEach(msg => result.messages.push(msg));
15
+ // return postcss(plugins)
16
+ // .process(root, { from: undefined })
17
+ // .then(handler);
18
+ // }
19
+ // };
20
+ // });
21
+ // export default
22
+ module.exports = _postcss.default.plugin('postcss-value-replacer', (valueReplacer = {}) => // Work with options here
23
+ root => {
24
+ root.walkDecls(decl => {
25
+ valueReplacer.forEach(obj => {
26
+ if (obj.props.indexOf(decl.prop) !== -1) {
27
+ let ks = Object.keys(obj.values).sort((a, b) => b.length - a.length);
28
+ ks.forEach(k => {
29
+ decl.value = decl.value.replace(k, obj.values[k]);
30
+ }); //decl.value = obj.values[decl.value];
31
+ }
32
+ }); //console.log({root, roots:root+""}, root+"")
33
+ // Transform CSS AST here
34
+ }); // root.walkDecls(decl => {
35
+ // valueReplacer.forEach(obj => {
36
+ // if (
37
+ // obj.props.indexOf(decl.prop) !== -1 &&
38
+ // obj.values[decl.value] !== undefined
39
+ // ) {
40
+ // decl.value = obj.values[decl.value];
41
+ // }
42
+ // });
43
+ // //console.log({root, roots:root+""}, root+"")
44
+ // // Transform CSS AST here
45
+ // });
46
+ });
@@ -14,6 +14,11 @@ var _getCurrentBranch = _interopRequireDefault(require("../utils/getCurrentBranc
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
16
  var _default = {
17
+ cliRootPath: null,
18
+ unstableDepsInverse: {
19
+ value: false,
20
+ cli: 'unstable_deps_inverse'
21
+ },
17
22
  sslCertURL: {
18
23
  value: null,
19
24
  cli: 'ssl_cert_url'
@@ -44,6 +49,17 @@ var _default = {
44
49
  },
45
50
  css: {
46
51
  enableRTLSplit: false,
52
+ valueReplacer: null,
53
+ //valueReplacer: [
54
+ // {
55
+ // props: ['font', 'font-family'],
56
+ // values: {
57
+ // 'zdfonts-rCallBar': 'zdfonts-rCallBar01',
58
+ // 'zdfonts-rCall': 'zdfonts-rCallBar02'
59
+ // }
60
+ // // ,suffix: '0'
61
+ // }
62
+ // ],
47
63
  templateLabel: '{{--dir}}',
48
64
  disableMiniFiySelector: false,
49
65
  dirVarName: 'document.dir'
@@ -246,6 +262,7 @@ var _default = {
246
262
  cli: 'css_unique'
247
263
  },
248
264
  folder: 'src',
265
+ disableES5Transpile: false,
249
266
  hasRTL: false,
250
267
  rtlExclude: [],
251
268
  cssHashSelectors: {
@@ -542,6 +559,10 @@ var _default = {
542
559
  value: null,
543
560
  cli: 'clone_revision'
544
561
  },
562
+ shallowClone: {
563
+ value: false,
564
+ cli: 'shallow_clone'
565
+ },
545
566
  projectName: {
546
567
  value: null,
547
568
  cli: 'clone_proj_name'
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPaths = getPaths;
7
+
8
+ var _fs = _interopRequireDefault(require("fs"));
9
+
10
+ var _path = _interopRequireDefault(require("path"));
11
+
12
+ var _child_process = require("child_process");
13
+
14
+ var _utils = require("../utils");
15
+
16
+ var _getCliPath = require("./getCliPath");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ const options = (0, _utils.getOptions)(); // const args = process.argv.slice(3);
21
+ // NOTE: need to discuss about in below codes,
22
+ // when we run webpack the usable options that comes for npm run not working as automatical
23
+ // we are use this option always --disable_watch=true reason for now no need for
24
+
25
+ const {
26
+ app: {
27
+ outputFolder
28
+ }
29
+ } = options;
30
+ const {
31
+ cssSelectorZipPath
32
+ } = options.impactService;
33
+ const zipname = cssSelectorZipPath ? _path.default.parse(cssSelectorZipPath).name : null;
34
+
35
+ const outputFolderLocation = _path.default.join(process.cwd(), outputFolder);
36
+
37
+ function execSyncDefalut(command) {
38
+ console.log(' command running ==>', command);
39
+ return (0, _child_process.execSync)(command, {
40
+ stdio: 'inherit'
41
+ });
42
+ }
43
+
44
+ const isQuiet = 'q';
45
+ const webpack = (0, _getCliPath.getCliPath)('webpack'); // console.log('webpack === > ', webpack, fs.existsSync(webpack));
46
+
47
+ if (_fs.default.existsSync(outputFolderLocation)) {
48
+ execSyncDefalut(`rm -rf ${outputFolder}`);
49
+ console.log(`previous ${outputFolder} removed`);
50
+ }
51
+
52
+ if (_fs.default.existsSync(_path.default.join(process.cwd(), 'build.zip'))) {
53
+ execSyncDefalut('rm build.zip');
54
+ console.log('previous build.zip removed');
55
+ } // execSyncDefalut(`${webpack } --version`);
56
+ // execSyncDefalut(`${webpack} --config ${require.resolve('../configs/webpack.dev.config.js')}`);
57
+
58
+
59
+ console.log('webpack compilation starts...');
60
+ const startTime = Date.now(); // const result = spawnSync(
61
+ // webpack,
62
+ // ['--config', require.resolve('../configs/webpack.dev.config.js')].concat(
63
+ // args
64
+ // ),
65
+ // { stdio: 'inherit' }
66
+ // );
67
+ // --disable_watch=true
68
+
69
+ const result = execSyncDefalut(`${webpack} --config ${require.resolve('../configs/webpack.dev.config.js')} ${process.argv.slice(2).map(o => o.replace(/(.*?)=(.*)/, '$1="$2"')).join(' ')} `);
70
+ result && console.log(result);
71
+
72
+ if (result && result.stderr) {
73
+ throw result.stderr;
74
+ }
75
+
76
+ console.log(`compailation done in ${Date.now() - startTime}ms`);
77
+
78
+ if (zipname) {
79
+ execSyncDefalut(`zip -r${isQuiet} build.zip ${outputFolder}/*`);
80
+ console.log('build.zip file created');
81
+ const result = execSyncDefalut(`zip -r${isQuiet} ${cssSelectorZipPath} ${zipname}/*`);
82
+ execSyncDefalut(`rm -rf ${zipname}`);
83
+
84
+ if (result && result.stderr) {
85
+ console.log('zip file not created', cssSelectorZipPath);
86
+ console.error(result.stderr);
87
+ } else {
88
+ console.log('zip file created', cssSelectorZipPath);
89
+ }
90
+ } // npm run start --app:domain=tsi --impact:cssbountry="{$@&&@$}" --disable-watch --dev-cache --cssselector_zip=css-source-map.zip
91
+ // npm run start --app_domain=tsi --impact_cssbountry="{$@&&@$}" --disable-watch --dev-cache --cssselector_zip=css-source-map.zip
92
+
93
+
94
+ console.log(`compailation done in ${Date.now() - startTime}ms`);
95
+
96
+ function getPaths() {
97
+ return {
98
+ zipname,
99
+ cssSelectorZipPath,
100
+ outputFolderLocation
101
+ };
102
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getCliPath = getCliPath;
7
+
8
+ var _path = _interopRequireDefault(require("path"));
9
+
10
+ var _os = require("os");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ let appPath = process.cwd();
15
+ const isNodeModuleUnderAppFolder = __dirname.indexOf(appPath) !== -1;
16
+ let isWindows = (0, _os.platform)().toLowerCase() === 'win32';
17
+
18
+ const _getCliPath = !isNodeModuleUnderAppFolder ? libName => _path.default.join(__dirname, '..', '..', 'node_modules', '.bin', libName) : libName => libName;
19
+
20
+ const suffixExt = isWindows ? '.cmd' : '';
21
+
22
+ function getCliPath(libName) {
23
+ return _getCliPath(libName) + suffixExt;
24
+ }
@@ -12,8 +12,7 @@ var _path = _interopRequireDefault(require("path"));
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
14
  const httpsOptions = {
15
- key: _fs.default.readFileSync(_path.default.join(__dirname, '../../cert/key.pem')),
16
- cert: _fs.default.readFileSync(_path.default.join(__dirname, '../../cert/cert.pem')),
17
- passphrase: _fs.default.readFileSync(_path.default.join(__dirname, '../../cert/passphrase.pem')).toString()
15
+ key: _fs.default.readFileSync(_path.default.join(__dirname, '../../cert/Tsicsezwild-22-23.key')),
16
+ cert: _fs.default.readFileSync(_path.default.join(__dirname, '../../cert/Tsicsezwild-22-23.crt'))
18
17
  };
19
18
  exports.httpsOptions = httpsOptions;
@@ -1,25 +1,21 @@
1
1
  "use strict";
2
2
 
3
- var _fs = _interopRequireDefault(require("fs"));
4
-
5
3
  var _path = _interopRequireDefault(require("path"));
6
4
 
7
5
  var _https = _interopRequireDefault(require("https"));
8
6
 
9
- var _os = require("os");
10
-
11
7
  var _express = _interopRequireDefault(require("express"));
12
8
 
13
9
  var _ws = _interopRequireDefault(require("ws"));
14
10
 
15
- var _child_process = require("child_process");
16
-
17
11
  var _httpProxyMiddleware = require("http-proxy-middleware");
18
12
 
19
13
  var _utils = require("../utils");
20
14
 
21
15
  var _httpsOptions = require("./httpsOptions");
22
16
 
17
+ var _devBuild = require("./devBuild");
18
+
23
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
20
 
25
21
  // import webpack from 'webpack';
@@ -28,95 +24,25 @@ let options = (0, _utils.getOptions)(); // let args = process.argv.slice(3);
28
24
  let {
29
25
  app: {
30
26
  context,
31
- server,
32
- outputFolder
27
+ server
33
28
  }
34
29
  } = options;
35
30
  let {
36
31
  host,
37
32
  port,
38
33
  domain,
39
- mode,
40
34
  disableContextURL,
41
35
  hasMock,
42
36
  mockPort
43
37
  } = server;
44
- let isCompatableHttp2 = Number(process.version.substr(1).split('.')[0]) >= 8;
38
+ let isCompatableHttp2 = Number(process.version.slice(1).split('.')[0]) >= 8;
45
39
  let contextURL = disableContextURL ? '' : `/${context}`;
46
40
  let serverUrl = (0, _utils.getServerURL)(server, 'htt' + 'ps');
47
41
  const {
48
- cssSelectorZipPath
49
- } = options.impactService;
50
- const zipname = cssSelectorZipPath ? _path.default.parse(cssSelectorZipPath).name : null;
51
-
52
- let outputFolderLocation = _path.default.join(process.cwd(), outputFolder);
53
-
54
- function execSyncDefalut(command) {
55
- console.log(' command running ==>', command);
56
- return (0, _child_process.execSync)(command, {
57
- stdio: 'inherit'
58
- });
59
- }
60
-
61
- let appPath = process.cwd();
62
- const isNodeModuleUnderAppFolder = __dirname.indexOf(appPath) !== -1;
63
- const isQuiet = 'q';
64
- let isWindows = (0, _os.platform)().toLowerCase() === 'win32';
65
-
66
- const _getCliPath = !isNodeModuleUnderAppFolder ? libName => _path.default.join(__dirname, '..', '..', 'node_modules', '.bin', libName) : libName => libName;
67
-
68
- const suffixExt = isWindows ? '.cmd' : '';
69
-
70
- function getCliPath(libName) {
71
- return _getCliPath(libName) + suffixExt;
72
- }
73
-
74
- let webpack = getCliPath('webpack'); // console.log('webpack === > ', webpack, fs.existsSync(webpack));
75
-
76
- if (_fs.default.existsSync(outputFolderLocation)) {
77
- execSyncDefalut(`rm -rf ${outputFolder}`);
78
- console.log(`previous ${outputFolder} removed`);
79
- }
80
-
81
- if (_fs.default.existsSync(_path.default.join(process.cwd(), 'build.zip'))) {
82
- execSyncDefalut('rm build.zip');
83
- console.log('previous build.zip removed');
84
- } // execSyncDefalut(`${webpack } --version`);
85
- // execSyncDefalut(`${webpack} --config ${require.resolve('../configs/webpack.dev.config.js')}`);
86
-
87
-
88
- console.log('webpack compilation starts...');
89
- let startTime = Date.now(); // let result = spawnSync(
90
- // webpack,
91
- // ['--config', require.resolve('../configs/webpack.dev.config.js')].concat(
92
- // args
93
- // ),
94
- // { stdio: 'inherit' }
95
- // );
96
-
97
- let result = execSyncDefalut(`${webpack} --config ${require.resolve('../configs/webpack.dev.config.js')}`);
98
- result && console.log(result);
99
-
100
- if (result && result.stderr) {
101
- throw result.stderr;
102
- }
103
-
104
- console.log(`compailation done in ${Date.now() - startTime}ms`);
105
-
106
- if (zipname) {
107
- execSyncDefalut(`zip -r${isQuiet} build.zip ${outputFolder}/*`);
108
- console.log('build.zip file created');
109
- let result = execSyncDefalut(`zip -r${isQuiet} ${cssSelectorZipPath} ${zipname}/*`);
110
- execSyncDefalut(`rm -rf ${zipname}`);
111
-
112
- if (result && result.stderr) {
113
- console.log('zip file not created', cssSelectorZipPath);
114
- console.error(result.stderr);
115
- } else {
116
- console.log('zip file created', cssSelectorZipPath);
117
- }
118
- }
119
-
42
+ zipname,
43
+ cssSelectorZipPath,
44
+ outputFolderLocation
45
+ } = (0, _devBuild.getPaths)();
120
46
  const app = (0, _express.default)();
121
47
 
122
48
  if (hasMock) {
@@ -271,5 +197,4 @@ app.listen(httpPort, err => {
271
197
  domain,
272
198
  port: httpPort
273
199
  }, 'ht' + 'tp')}${contextURL}/`);
274
- });
275
- console.log(`compailation done in ${Date.now() - startTime}ms`);
200
+ });
@@ -69,7 +69,8 @@ if (mode === 'prod') {
69
69
  config = require('../configs/webpack.dev.config');
70
70
  } else {
71
71
  throw new Error('You must configure valid option in mode');
72
- }
72
+ } // console.log({ contextURL });
73
+
73
74
 
74
75
  let compiler = (0, _webpack.default)(config);
75
76
  let webpackServerOptions = {
@@ -99,9 +100,16 @@ app.use((0, _HMRMiddleware.default)(compiler, {
99
100
  path: '/sockjs-node/info'
100
101
  }));
101
102
  app.use((req, res, next) => {
102
- res.setHeader('Access-Control-Allow-Origin', '*');
103
+ //console.log('origin', req.get('origin'));
104
+ res.setHeader('Access-Control-Allow-Origin', req.get('origin') || '*'); // res.setHeader('Access-Control-Allow-Origin', req.get('origin'));
105
+
106
+ res.setHeader('Access-Control-Allow-Private-Network', true);
107
+ res.setHeader('Access-Control-Allow-Credentials', true);
103
108
  next();
104
109
  }).use(`${contextURL}/fonts`, _express.default.static(`${context}/fonts`));
110
+ app.options('/*', (req, res) => {
111
+ res.send('Ok');
112
+ });
105
113
  app.use('/wms/*', (req, res) => {
106
114
  res.sendFile(_path.default.join(__dirname, '..', '..', 'templates', 'wms', 'index.html'));
107
115
  });
@@ -137,15 +145,22 @@ app.post('/wmsmockapi', (req, res) => {
137
145
  res.send('success');
138
146
  });
139
147
  let webpackCompilation;
148
+ let initalHTML;
140
149
  compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
141
150
  webpackCompilation = compilation;
142
151
  });
152
+ compiler.hooks.done.tap('ReactCLI', () => {
153
+ const indexHtml = webpackCompilation.assets['index.html'];
154
+
155
+ if (indexHtml) {
156
+ initalHTML = indexHtml.source();
157
+ }
158
+ });
143
159
 
144
160
  if (contextURL) {
145
161
  app.use(contextURL, _express.default.static(context));
146
162
  app.use(`${contextURL}/*`, (req, res) => {
147
- let indexHtml = webpackCompilation.assets['index.html'];
148
- res.send(indexHtml && indexHtml.source());
163
+ res.send(initalHTML);
149
164
  });
150
165
  } else {
151
166
  app.use(_express.default.static(context));
@@ -197,6 +212,6 @@ app.listen(httpPort, err => {
197
212
  (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
198
213
  host,
199
214
  domain,
200
- port: httpPort
215
+ port: port
201
216
  }, 'ht' + 'tp')}${contextURL}/`);
202
217
  });
@@ -28,6 +28,7 @@ let {
28
28
  branch,
29
29
  revision,
30
30
  projectName,
31
+ shallowClone,
31
32
  cacheDir,
32
33
  remoteName,
33
34
  shouldDelete
@@ -73,9 +74,11 @@ let cloneRepo = () => {
73
74
  }
74
75
  }
75
76
 
76
- (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
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
77
78
 
78
- spawnSyncWithErrorLog(type, ['clone', url, revisionOrBranch, projectName], {
79
+ let oargs = ['clone', url, revisionOrBranch, projectName];
80
+ type === 'git' && shallowClone && oargs.push('--depth=1');
81
+ spawnSyncWithErrorLog(type, oargs, {
79
82
  cwd: cacheDir,
80
83
  stdio: 'inherit'
81
84
  });