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

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.
package/.eslintrc.js CHANGED
@@ -108,7 +108,9 @@ let commonConfigs = {
108
108
  'comma-dangle': [logLevel],
109
109
  'comma-spacing': [logLevel],
110
110
  'func-call-spacing': [logLevel],
111
- indent: [logLevel, 2, { SwitchCase: 1 }],
111
+ // reference to this https://stackoverflow.com/questions/56337176/prettier-and-eslint-indents-not-working-together
112
+ // when using prettier, we should disable eslint's indent rule
113
+ indent: ['off', 2, { SwitchCase: 1 }],
112
114
  'jsx-quotes': [logLevel, 'prefer-single'],
113
115
  'key-spacing': [logLevel],
114
116
  'keyword-spacing': [logLevel],
@@ -140,8 +142,6 @@ let commonConfigs = {
140
142
  'prefer-template': [logLevel],
141
143
  'prefer-rest-params': [logLevel],
142
144
  'no-useless-constructor': [logLevel],
143
- 'no-duplicate-imports': [logLevel],
144
- 'array-callback-return': [logLevel],
145
145
  'no-use-before-define': [logLevel],
146
146
 
147
147
  'react/default-props-match-prop-types': [logLevel],
@@ -152,7 +152,6 @@ let commonConfigs = {
152
152
  'react/no-this-in-sfc': [logLevel],
153
153
  'react/no-will-update-set-state': [logLevel],
154
154
  'react/no-unused-state': [logLevel],
155
- 'react/no-will-update-set-state': [logLevel],
156
155
  // 'react/require-default-props': [logLevel],
157
156
  // 'react/require-optimization': [logLevel],
158
157
 
@@ -171,9 +170,6 @@ let commonConfigs = {
171
170
  'react/jsx-no-duplicate-props': [logLevel],
172
171
  'react/no-deprecated': [logLevel],
173
172
  'react/no-children-prop': [logLevel],
174
- 'react/no-unused-state': [logLevel],
175
- 'react/destructuring-assignment': [logLevel],
176
- 'react/default-props-match-prop-types': [logLevel],
177
173
 
178
174
  'css-modules/no-unused-class': [logLevel, { camelCase: true }],
179
175
  'css-modules/no-undef-class': [logLevel, { camelCase: 'only' }]
package/README.md CHANGED
@@ -2,6 +2,34 @@
2
2
 
3
3
  A CLI tool for build modern web application and libraries
4
4
 
5
+ # 0.0.1-beta.164
6
+
7
+ - typo fix
8
+
9
+ # 0.0.1-beta.163
10
+
11
+ - **Issue Fix:-**
12
+
13
+ - if git not installed react-cli throws error for any command due to `getCurrentBranch` in `shemas/index.js` now fixed
14
+ - jest test cases not runnig issue fix (typo moduleNameMapper => libAlias)
15
+
16
+ - **Features :-**
17
+ - feature added for pre process logic
18
+ - tailer made requirement for preprocess, just write node js file
19
+ - mention file in `"react-cli" => "preprocess" => "runner"`
20
+ - option parse logic added for react-cli (exprimental)
21
+ - `--stop_nodemon` usally preprocessor run in `nodemon` so to stop it this option is provided
22
+
23
+ # 0.0.1-exp.162.2
24
+
25
+ - **Optimazation:-**
26
+ - double time minimize optimazation
27
+
28
+ # 0.0.1-beta.162.1
29
+
30
+ - **Issue Fix:-**
31
+ - if git not installed react-cli throws error for any command due to `getCurrentBranch` in `shemas/index.js` now fixed
32
+
5
33
  # 0.0.1-beta.161.1
6
34
 
7
35
  - **Features :-**
@@ -10,10 +38,14 @@ A CLI tool for build modern web application and libraries
10
38
  - mention file in `"react-cli" => "preprocess" => "runner"`
11
39
  - option parse logic added for react-cli (exprimental)
12
40
 
41
+ # 0.0.1-beta.162
42
+
43
+ - @zohodesk/datetimejs package updated to beta.8
44
+
13
45
  # 0.0.1-beta.161
14
46
 
15
47
  - **Features :-**
16
- - feature added for efc `templateFilePath` in `package.json` option palce is `"react-cli" => "efc" `
48
+ - feature added for efc `templateFilePath` in `package.json` option palce is `"react-cli" => "efc" => "templateFilePath"`
17
49
  - `(('publicPath'))` this placeholder will be replace as publicPath string `publicPath`
18
50
  - `(('getInitalAssets'))` this placeholder will be replace as function `getInitalAssets`
19
51
  - `getInitalAssets` this function has two arguments `assetsType`, `lang`
package/bin/cli.js CHANGED
@@ -1,28 +1,30 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- let path = require('path');
4
- let os = require('os');
5
- let { spawnSync, spawn } = require('child_process');
6
- let { getOptions } = require('../lib/utils/index.js');
3
+ const path = require('path');
4
+ const os = require('os');
5
+ const { existsSync } = require('fs');
6
+ const { spawnSync, spawn } = require('child_process');
7
+ const { getOptions } = require('../lib/utils/index.js');
7
8
 
8
- let { log } = require('../lib/utils');
9
+ const { log } = require('../lib/utils');
9
10
  //initPreCommitHook();
10
11
 
11
- let options = getOptions();
12
+ const options = getOptions();
12
13
 
13
- let { esLint: esLintOptions } = options || {};
14
- let {
14
+ const { esLint: esLintOptions } = options || {};
15
+ const { preprocess } = options;
16
+ const {
15
17
  ignoreFilePaths: esLintIgnorePaths,
16
18
  fix: esLintFix,
17
19
  isCI: isCI,
18
20
  reportPath: reportPath
19
21
  } = esLintOptions || {};
20
22
 
21
- let isWindows = os.platform().toLowerCase() === 'win32';
23
+ const isWindows = os.platform().toLowerCase() === 'win32';
22
24
 
23
- let [, , option] = process.argv;
24
- let args = process.argv.slice(3);
25
- let appPath = process.cwd();
25
+ const [, , option] = process.argv;
26
+ const args = process.argv.slice(3);
27
+ const appPath = process.cwd();
26
28
 
27
29
  const isNodeModuleUnderAppFolder = __dirname.indexOf(appPath) !== -1;
28
30
 
@@ -35,56 +37,53 @@ function getCliPath(libName) {
35
37
  return _getCliPath(libName) + suffixExt;
36
38
  }
37
39
 
38
- let webpack = getCliPath('webpack');
40
+ const webpack = getCliPath('webpack');
39
41
 
40
- let nodemon = getCliPath('nodemon');
41
- let babel = getCliPath('babel');
42
- let propertyToJson = getCliPath('propertyToJson');
43
- let esLint = getCliPath('eslint');
42
+ const nodemon = getCliPath('nodemon');
43
+ const babel = getCliPath('babel');
44
+ const propertyToJson = getCliPath('propertyToJson');
45
+ const esLint = getCliPath('eslint');
44
46
 
45
- let preprocesserPath = options.preprocessor.runner
46
- ? path.join(process.cwd(), options.preprocessor.runner)
47
+ const preprocesserPath = preprocess.runner
48
+ ? path.join(process.cwd(), preprocess.runner)
47
49
  : '';
48
- console.log(
49
- 'options.app.preprocessor',
50
- options.preprocessor.runner,
51
- preprocesserPath
52
- );
53
-
54
- // eslint-disable-next-line default-case
55
- switch (option) {
56
- case 'start':
57
- case 'docs':
58
- spawn(nodemon, [preprocesserPath], {
59
- stdio: 'inherit',
60
- cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
61
- });
62
- // NOTE: it's ok if we not close this here
63
- // Because when node server stops this program willbe closed So this nodemon will be killed as well
64
- break;
65
- case 'nowatchstart':
66
- case 'build:library:es':
67
- case 'build:component:es':
68
- case 'build:library:cmjs':
69
- case 'build:component:cmjs':
70
- spawnSync('node', [preprocesserPath], {
71
- stdio: 'inherit',
72
- cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
73
- });
74
- break;
50
+ const preprocessCli = preprocess.stopNodemon ? 'node' : nodemon;
51
+ if (preprocesserPath && existsSync(preprocesserPath)) {
52
+ // eslint-disable-next-line default-case
53
+ switch (option) {
54
+ case 'start':
55
+ case 'docs':
56
+ spawn(preprocessCli, [preprocesserPath], {
57
+ stdio: 'inherit',
58
+ cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
59
+ });
60
+ // NOTE: it's ok if we not close this here
61
+ // Because when node server stops this program willbe closed So this nodemon will be killed as well
62
+ break;
63
+ case 'nowatchstart':
64
+ case 'build:library:es':
65
+ case 'build:component:es':
66
+ case 'build:library:cmjs':
67
+ case 'build:component:cmjs':
68
+ spawnSync('node', [preprocesserPath], {
69
+ stdio: 'inherit',
70
+ cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
71
+ });
72
+ break;
73
+ }
75
74
  }
76
75
 
77
76
  let result;
78
77
  switch (option) {
79
78
  case 'preprocessor':
80
- if (preprocesserPath) {
81
- result = spawnSync(nodemon, [preprocesserPath], {
79
+ if (preprocesserPath && existsSync(preprocesserPath)) {
80
+ result = spawnSync(preprocessCli, [preprocesserPath], {
82
81
  stdio: 'inherit',
83
82
  cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
84
83
  });
85
84
  process.exit(result.status);
86
85
  } else {
87
- console.error('preProcessor not exists ');
86
+ console.error(`preProcessor not exists ${preprocesserPath}`);
88
87
  }
89
88
  break;
90
89
  case 'lint-setup': {
@@ -198,10 +197,11 @@ switch (option) {
198
197
  break;
199
198
 
200
199
  case 'clean':
201
- args = args.map(arg => path.join(appPath, arg));
202
200
  result = spawnSync(
203
201
  'node',
204
- [require.resolve('../lib/utils/clean')].concat(args),
202
+ [require.resolve('../lib/utils/clean')].concat(
203
+ args.map(arg => path.join(appPath, arg))
204
+ ),
205
205
  { stdio: 'inherit' }
206
206
  );
207
207
  process.exit(result.status);
@@ -261,12 +261,15 @@ switch (option) {
261
261
  result = spawnSync(
262
262
  webpack,
263
263
  [
264
+ // '--progress',
265
+ // '--profile',
264
266
  '--config',
265
- require.resolve('../lib/configs/webpack.prod.config.js')
267
+ require.resolve('../lib/configs/webpack.prod.config.js'),
266
268
  ].concat(args),
267
269
  { stdio: 'inherit' }
268
270
  );
269
271
 
272
+ // console.log(result);
270
273
  process.exit(result.status);
271
274
  break;
272
275
 
@@ -10,7 +10,7 @@ let appPath = process.cwd(); // '^@root(.*)$': '<rootDir>/src$1',
10
10
  // '^@components(.*)$': '<rootDir>/src/components$1',
11
11
 
12
12
  let moduleNameMapper = Object.keys(_libAlias.libAlias).reduce((previousValue, key) => {
13
- previousValue[`^${key}(.*)$`] = `${moduleNameMapper[key]}$1`;
13
+ previousValue[`^${key}(.*)$`] = `${_libAlias.libAlias[key]}$1`;
14
14
  return previousValue;
15
15
  }, {});
16
16
  let commonConfig = {
@@ -57,9 +57,9 @@ module.exports = {
57
57
  entry: (0, _common.getEntries)(options, 'dev'),
58
58
  devtool: sourcemap,
59
59
  mode: 'development',
60
- watchOptions: {
61
- ignored: /node_modules.(?!@zohodesk)/
62
- },
60
+ // watchOptions: {
61
+ // ignored: /node_modules.(?!@zohodesk)/
62
+ // },
63
63
  output,
64
64
  stats: options.app.disableWatch ? 'errors-only' : {
65
65
  children: false
@@ -14,6 +14,7 @@ var _libAlias = require("./libAlias");
14
14
 
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
16
 
17
+ // import TerserPlugin from 'terser-webpack-plugin';
17
18
  let options = (0, _utils.getOptions)();
18
19
  let {
19
20
  app: {
@@ -78,12 +79,23 @@ module.exports = {
78
79
  },
79
80
  concatenateModules: true,
80
81
  minimize: true,
82
+ // by default if minimize: true in webpack minimize then webpack automaticaly add TerserPlugin,
83
+ // So we are overrideing it.
84
+ // minimizer: [
85
+ // new TerserPlugin({
86
+ // cache: true,
87
+ // parallel: true,
88
+ // sourceMap: isDevelopment && enableSMap,
89
+ // exclude: /\/smap/
90
+ // })
91
+ // ],
81
92
  moduleIds: 'named'
82
93
  },
83
94
  stats: {
84
95
  children: false,
85
96
  colors: true,
86
97
  // excludeAssets: /i18n/,
98
+ // excludeAssets: /./,
87
99
  warningsFilter: /\[mini-css-extract-plugin\]/
88
100
  },
89
101
  plugins: (0, _pluginUtils.getProdPlugins)(options, output.publicPath),
@@ -115,7 +127,8 @@ module.exports = {
115
127
  }] : null].filter(Boolean),
116
128
  cacheDirectory: true
117
129
  }
118
- }],
130
+ }].filter(Boolean),
131
+ // include: path.join(appPath, folder)
119
132
  include: module => {
120
133
  let srcPath = _path.default.join(appPath, folder);
121
134
 
@@ -132,7 +145,7 @@ module.exports = {
132
145
  exclude: /\.module\.css$/,
133
146
  use: (0, _loaderUtils.getCSSLoaders)(hasRTL, rtlExclude, '[local]', false, null)
134
147
  } : null, {
135
- test: seperateCssModules ? /\.module\.css$/ : /(\.module)?\.css$/,
148
+ test: seperateCssModules ? /\.module\.css$/ : /\.css$/,
136
149
  use: (0, _loaderUtils.getCSSLoaders)(hasRTL, rtlExclude, false, cssUniqueness, selectorReplace, cssHashSelectors, classNamePrefix)
137
150
  }, {
138
151
  test: /\.jpe?g$|\.gif$|\.png$/,
@@ -18,10 +18,16 @@ var _default = {
18
18
  value: null,
19
19
  cli: 'ssl_cert_url'
20
20
  },
21
- preprocessor: {
21
+ preprocess: {
22
+ // This option is for tell the react-cli which in preprocessor js file path
22
23
  runner: {
23
24
  value: '',
24
25
  cli: 'preprocessor'
26
+ },
27
+ // usally preprocessor run in nodemon for, start and docs , preprocessor
28
+ stopNodemon: {
29
+ value: false,
30
+ cli: 'stop_nodemon'
25
31
  }
26
32
  },
27
33
  i18n: {
@@ -22,7 +22,7 @@ var _default = (type = 'git', cwd = process.cwd()) => {
22
22
  });
23
23
  }
24
24
 
25
- let [currentBranch] = results.output.filter(d => d);
25
+ let [currentBranch] = results && results.output ? results.output.filter(d => d) : [''];
26
26
  return currentBranch.replace(/(\r\n|\n|\r)/gm, '');
27
27
  };
28
28
 
@@ -11,14 +11,13 @@ var _fs = _interopRequireDefault(require("fs"));
11
11
 
12
12
  var _path = _interopRequireDefault(require("path"));
13
13
 
14
- var _process = require("process");
15
-
16
14
  var _schemas = _interopRequireDefault(require("../schemas"));
17
15
 
18
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
17
 
20
- let args = process.argv.slice(2);
21
- console.log('argv', _process.argv);
18
+ // import { argv } from 'process';
19
+ const args = process.argv.slice(2); // console.log('argv', argv);
20
+
22
21
  const NPM_CONFIG_PREFIX = 'npm_config_'; // TODO: we have to do option parse logic little better
23
22
  // if user use react-cli stritly without using npm scripts options won't work,
24
23
  // So we have to write our own option parse logic or some other library
@@ -63,13 +62,14 @@ function getCWD() {
63
62
  try {
64
63
  let ress = (0, _child_process.execSync)('npm bin').toString();
65
64
  let i = ress.lastIndexOf('node_modules');
66
- cwd = i === -1 ? cwd : ress.slice(0, ress.lastIndexOf('node_modules'));
65
+ cwd = i === -1 ? cwd : ress.slice(0, i);
67
66
  } catch (error) {
68
67
  console.log(error);
69
68
  }
70
69
 
71
70
  return cwd;
72
- }
71
+ } // experimental argumnet parsing logic
72
+
73
73
 
74
74
  args.forEach(option => {
75
75
  if (/^--./.test(option)) {
@@ -83,7 +83,7 @@ args.forEach(option => {
83
83
  value = true;
84
84
  }
85
85
 
86
- key = key.replace(/-/g, '_').replace(/:/g, '_');
86
+ key = key.replace(/-|:/g, '_');
87
87
  processEnv[key] = value;
88
88
  }
89
89
  });
@@ -138,7 +138,8 @@ let getOptions = () => {
138
138
  userSchemas = require(packagePath)['react-cli'] || {};
139
139
  }
140
140
 
141
- let options = defaulter(_schemas.default, userSchemas || {});
141
+ let options = defaulter(_schemas.default, userSchemas || {}); // for future may be for npm 8 edge cases
142
+
142
143
  options.npmVersion = getNpmVersion();
143
144
  options.cwd = getCWD();
144
145
  options.packageVersion = process.env.npm_package_version;
@@ -45,12 +45,21 @@ let fileHandler = {
45
45
  };
46
46
  exports.fileHandler = fileHandler;
47
47
 
48
+ const isObject = obj => obj && obj.constructor === {}.constructor;
49
+
50
+ const isArray = obj => obj && obj.constructor === [].constructor; // In below funtion
51
+ // this function is for concat two json object like _.extend,
52
+ // if botha array we concat them
53
+ // if both object we use call this function recurcively
54
+ // if both differend data type we will just assign it
55
+
56
+
48
57
  let jsonConcate = (receiverObj, senterObj) => {
49
58
  Object.keys(senterObj).map(key => {
50
59
  if (Object.prototype.hasOwnProperty.call(receiverObj, key)) {
51
- if (receiverObj[key].constructor === {}.constructor && senterObj[key].constructor === {}.constructor) {
60
+ if (isObject(receiverObj[key]) && isObject(senterObj[key])) {
52
61
  jsonConcate(receiverObj[key], senterObj[key]);
53
- } else if (receiverObj[key].constructor === [].constructor && senterObj[key].constructor === [].constructor) {
62
+ } else if (isArray(receiverObj[key]) && isArray(senterObj[key])) {
54
63
  receiverObj[key] = receiverObj[key].concat(senterObj[key]);
55
64
  } else {
56
65
  receiverObj[key] = senterObj[key];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/react-cli",
3
- "version": "0.0.1-beta.161.1",
3
+ "version": "0.0.1-beta.164",
4
4
  "description": "A CLI tool for build modern web application and libraries",
5
5
  "scripts": {
6
6
  "init": "node ./lib/utils/init.js",
@@ -35,7 +35,7 @@
35
35
  "@babel/preset-env": "7.11.0",
36
36
  "@babel/preset-react": "7.10.4",
37
37
  "@babel/runtime": "7.11.2",
38
- "@zohodesk/datetimejs": "1.0.0-beta.7",
38
+ "@zohodesk/datetimejs": "1.0.0-beta.8",
39
39
  "@zohodesk/eslint-plugin-react-performance": "1.0.3",
40
40
  "@zohodesk/eslint-plugin-zsecurity": "0.0.1-beta.4",
41
41
  "@zohodesk/normalizer": "1.0.2",
package/c.sh DELETED
@@ -1,46 +0,0 @@
1
- #!/bin/bash
2
-
3
-
4
- # s_time= `echo 1640321666`
5
- # e_time= 1640121666
6
- # r_time= s_time - e_time
7
- # echo `((r_time/60000)) min`
8
- # s_time= e_time
9
- # e_time= 1639384489
10
- # r_time= s_time - e_time
11
- # echo `((r_time/60000)) min`
12
-
13
-
14
- main() {
15
-
16
- s_time=`date +%s`
17
- npm run build --app_mode=build
18
- # sleep 2
19
- # e_time=`date +%s`
20
- # r_time=$(($s_time - $e_time))
21
- # echo $s_time
22
- # echo $e_time
23
- # echo "$(($r_time/60)) min $(($r_time%60)) sec"
24
-
25
- printTime() {
26
- e_time=`date +%s`
27
- r_time=$(($e_time-$s_time))
28
- echo "$r_time $s_time $e_time"
29
- echo "$1 Time: $(($r_time/60)) min $(($r_time%60)) sec"
30
- s_time=$e_time
31
- }
32
- printTime "React-Cli installation"
33
- sleep 3
34
- printTime "React-Cli installation1"
35
- sleep 1
36
- printTime "React-Cli installation2"
37
- echo finished
38
- # echo `(($r_time/60)) min`
39
- # s_time= e_time
40
- # e_time= 1639384489
41
- # r_time= s_time - e_time
42
- # echo `((r_time/60000)) min
43
-
44
- }
45
- main 773
46
- echo "function call finished"
package/t.js DELETED
@@ -1,8 +0,0 @@
1
- setTimeout(() => {
2
- console.log('its working');
3
- }, 2000);
4
-
5
- console.log('will it work ?');
6
-
7
- let child_process = require('child_process');
8
- child_process.spawn('ssss', []);