@zohodesk/react-cli 0.0.1-beta.162.1 → 0.0.1-beta.165

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,37 @@
2
2
 
3
3
  A CLI tool for build modern web application and libraries
4
4
 
5
+ # 0.0.1-beta.165
6
+
7
+ - `valueReplacer` option added in shemas for font name replace related issue handling, for more [details](./docs/ValueReplacer.md)
8
+ - `valuereplacer` option added in react-cli it takes three
9
+ 1. sourceDir
10
+ 2. distDir
11
+ 3. `copyAll` is boolean flag which is for copy all other file or not. "true" means copy all files.
12
+
13
+ # 0.0.1-beta.164
14
+
15
+ - typo fix
16
+
17
+ # 0.0.1-beta.163
18
+
19
+ - **Issue Fix:-**
20
+
21
+ - if git not installed react-cli throws error for any command due to `getCurrentBranch` in `shemas/index.js` now fixed
22
+ - jest test cases not runnig issue fix (typo moduleNameMapper => libAlias)
23
+
24
+ - **Features :-**
25
+ - feature added for pre process logic
26
+ - tailer made requirement for preprocess, just write node js file
27
+ - mention file in `"react-cli" => "preprocess" => "runner"`
28
+ - option parse logic added for react-cli (exprimental)
29
+ - `--stop_nodemon` usally preprocessor run in `nodemon` so to stop it this option is provided
30
+
31
+ # 0.0.1-exp.162.2
32
+
33
+ - **Optimazation:-**
34
+ - double time minimize optimazation
35
+
5
36
  # 0.0.1-beta.162.1
6
37
 
7
38
  - **Issue Fix:-**
@@ -15,10 +46,14 @@ A CLI tool for build modern web application and libraries
15
46
  - mention file in `"react-cli" => "preprocess" => "runner"`
16
47
  - option parse logic added for react-cli (exprimental)
17
48
 
49
+ # 0.0.1-beta.162
50
+
51
+ - @zohodesk/datetimejs package updated to beta.8
52
+
18
53
  # 0.0.1-beta.161
19
54
 
20
55
  - **Features :-**
21
- - feature added for efc `templateFilePath` in `package.json` option palce is `"react-cli" => "efc" `
56
+ - feature added for efc `templateFilePath` in `package.json` option palce is `"react-cli" => "efc" => "templateFilePath"`
22
57
  - `(('publicPath'))` this placeholder will be replace as publicPath string `publicPath`
23
58
  - `(('getInitalAssets'))` this placeholder will be replace as function `getInitalAssets`
24
59
  - `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,28 +37,23 @@ 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
-
49
- // console.log(
50
- // 'options.app.preprocessor',
51
- // options.preprocessor.runner,
52
- // preprocesserPath
53
- // );
54
- if (preprocesserPath) {
50
+ const preprocessCli = preprocess.stopNodemon ? 'node' : nodemon;
51
+ if (preprocesserPath && existsSync(preprocesserPath)) {
55
52
  // eslint-disable-next-line default-case
56
53
  switch (option) {
57
54
  case 'start':
58
55
  case 'docs':
59
- spawn(nodemon, [preprocesserPath], {
56
+ spawn(preprocessCli, [preprocesserPath], {
60
57
  stdio: 'inherit',
61
58
  cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
62
59
  });
@@ -79,14 +76,14 @@ if (preprocesserPath) {
79
76
  let result;
80
77
  switch (option) {
81
78
  case 'preprocessor':
82
- if (preprocesserPath) {
83
- result = spawnSync(nodemon, [preprocesserPath], {
79
+ if (preprocesserPath && existsSync(preprocesserPath)) {
80
+ result = spawnSync(preprocessCli, [preprocesserPath], {
84
81
  stdio: 'inherit',
85
82
  cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
86
83
  });
87
84
  process.exit(result.status);
88
85
  } else {
89
- console.error('preProcessor not exists ');
86
+ console.error(`preProcessor not exists ${preprocesserPath}`);
90
87
  }
91
88
  break;
92
89
  case 'lint-setup': {
@@ -123,6 +120,15 @@ switch (option) {
123
120
  { stdio: 'inherit' }
124
121
  );
125
122
 
123
+ process.exit(result.status);
124
+ break;
125
+ case 'valuereplacer':
126
+ result = spawnSync(
127
+ 'node',
128
+ [require.resolve('../lib/common/valueReplacer')].concat(args),
129
+ { stdio: 'inherit' }
130
+ );
131
+
126
132
  process.exit(result.status);
127
133
  break;
128
134
  case 'app':
@@ -200,10 +206,11 @@ switch (option) {
200
206
  break;
201
207
 
202
208
  case 'clean':
203
- args = args.map(arg => path.join(appPath, arg));
204
209
  result = spawnSync(
205
210
  'node',
206
- [require.resolve('../lib/utils/clean')].concat(args),
211
+ [require.resolve('../lib/utils/clean')].concat(
212
+ args.map(arg => path.join(appPath, arg))
213
+ ),
207
214
  { stdio: 'inherit' }
208
215
  );
209
216
  process.exit(result.status);
@@ -263,12 +270,15 @@ switch (option) {
263
270
  result = spawnSync(
264
271
  webpack,
265
272
  [
273
+ // '--progress',
274
+ // '--profile',
266
275
  '--config',
267
276
  require.resolve('../lib/configs/webpack.prod.config.js')
268
277
  ].concat(args),
269
278
  { stdio: 'inherit' }
270
279
  );
271
280
 
281
+ // console.log(result);
272
282
  process.exit(result.status);
273
283
  break;
274
284
 
@@ -0,0 +1,60 @@
1
+ # value replacer
2
+
3
+ <!-- file paths
4
+ 1. src/postcss-plugins/ValueReplacer.js
5
+ 2. src/common/valueReplacer.js
6
+ -->
7
+
8
+ this option is array of objects which will have a two keys
9
+ new option `valueReplacer` added for replace css property value while build running
10
+
11
+ - this option is array of object, that object two keys
12
+ 1. `props` key for array of property names
13
+ 2. `values` key is object ,this object key contents will be replaced as value content
14
+ - this option wiil be work for below
15
+
16
+ - `start`
17
+ - `docs`
18
+ - `nowatchstart`
19
+ - `devbuild`
20
+ - `build:library:es`
21
+ - `build:component:es`
22
+ - `build:library:cmjs`
23
+ - `build:component:cmjs`
24
+ Example data:-
25
+
26
+ ```json
27
+ {
28
+ "react-cli": {
29
+ "css": {
30
+ "valueReplacer": [
31
+ {
32
+ "props": ["font", "font-family"],
33
+ "values": {
34
+ "zdfonts-rCallBar": "zdf-rCallBar_1",
35
+ "zdfonts-rPuvi": "zdf-rPuvi_1"
36
+ }
37
+ // ,suffix: '0'
38
+ }
39
+ ]
40
+ }
41
+ }
42
+ }
43
+ ```
44
+
45
+ Example Replace:-
46
+ before replace
47
+
48
+ ```css
49
+ .some-selector {
50
+ font: zdfonts-rCallBar !important;
51
+ }
52
+ ```
53
+
54
+ after replace
55
+
56
+ ```css
57
+ .some-selector {
58
+ font: zdf-rCallBar_1 !important;
59
+ }
60
+ ```
package/eslint/a23.c ADDED
@@ -0,0 +1,16 @@
1
+ // Online C compiler to run C program online
2
+ #include <stdio.h>
3
+ // 23
4
+
5
+ int main()
6
+ {
7
+ // Write C code here
8
+ int i = 20, j = 22, k = 20, l = 10;
9
+
10
+ for (int m = 0; m <= 10; m++)
11
+ {
12
+ l = ++i + ++j - k--;
13
+ }
14
+ printf("%d\n", l);
15
+ return 0;
16
+ }
package/eslint/a28.c ADDED
@@ -0,0 +1,25 @@
1
+ // Online C compiler to run C program online
2
+ #include <stdio.h>
3
+ // 28
4
+ int mark(int x)
5
+ {
6
+ if (x <= 0)
7
+ {
8
+ return 1;
9
+ }
10
+ return 0;
11
+ }
12
+
13
+ int main()
14
+ {
15
+ // Write C code here
16
+ int x = 2345, t, a = 0;
17
+ while (x > 0)
18
+ {
19
+ t = x % 10;
20
+ a += mark(t);
21
+ x /= 10;
22
+ }
23
+ printf("%d\n", a);
24
+ return 0;
25
+ }
package/eslint/a29.c ADDED
@@ -0,0 +1,25 @@
1
+ // Online C compiler to run C program online
2
+ #include <stdio.h>
3
+ // 29
4
+
5
+ int main()
6
+ {
7
+ // Write C code here
8
+ int x = 777, y, s = 0, m, n, t, u;
9
+ y = x;
10
+ for (m = 0; y != 0; y /= 10)
11
+ {
12
+ u = y % 9;
13
+ for (n = m, t = 1; n >= 0; n--)
14
+ {
15
+ t *= 9;
16
+ }
17
+ if (u < 5)
18
+ {
19
+ u += 3;
20
+ }
21
+ s = s * u + t;
22
+ }
23
+ printf("%d\n", s);
24
+ return 0;
25
+ }
package/eslint/a30.c ADDED
@@ -0,0 +1,29 @@
1
+ // Online C compiler to run C program online
2
+ #include <stdio.h>
3
+ // 30
4
+
5
+ int main()
6
+ {
7
+ // Write C code here
8
+ int a[8] = {24, 27, 33, 27, 9, 43, 0, 3};
9
+ int i, sum = 0;
10
+ for (i = 0; i < 5; i = i + 1)
11
+ {
12
+ switch (a[i] % 3)
13
+ {
14
+ case 2:
15
+ sum = sum * sum;
16
+ break;
17
+ case 1:
18
+ sum += a[i];
19
+ break;
20
+ case 0:
21
+ sum -= a[i];
22
+ break;
23
+ default:
24
+ sum = sum * a[i];
25
+ }
26
+ }
27
+ printf("%d\n", sum);
28
+ return 0;
29
+ }
package/eslint/a31.c ADDED
@@ -0,0 +1,23 @@
1
+ // Online C compiler to run C program online
2
+ #include <stdio.h>
3
+ // 31
4
+
5
+ int main()
6
+ {
7
+ // Write C code here
8
+ int x = 16, y = 32, i = 0;
9
+ do
10
+ {
11
+ if (x % 2 == 0)
12
+ {
13
+ y /= 2;
14
+ }
15
+ if (y % 2 < 1)
16
+ {
17
+ x /= 2;
18
+ }
19
+ i++;
20
+ } while (x > 1);
21
+ printf("%d\n", i);
22
+ return 0;
23
+ }
package/eslint/a35.c ADDED
@@ -0,0 +1,23 @@
1
+ // Online C compiler to run C program online
2
+ #include <stdio.h>
3
+ // 34
4
+ int compute(int a, int b)
5
+ {
6
+ if (b == 1)
7
+ {
8
+ return a;
9
+ }
10
+ else
11
+ {
12
+ return a + compute(a, --b);
13
+ }
14
+ }
15
+
16
+ int main()
17
+ {
18
+ // Write C code here
19
+ int a = 37, b = 26, result = 0;
20
+ result = compute(a, b);
21
+ printf("%d\n", result);
22
+ return 0;
23
+ }
package/eslint/a36.c ADDED
@@ -0,0 +1,18 @@
1
+ // Online C compiler to run C program online
2
+ #include <stdio.h>
3
+ // 36
4
+ int main()
5
+ {
6
+ // Write C code here
7
+ char a[] = {'o', 'm', 'p', 'n', 'j', 'o'};
8
+ for (int i = 1; i <= 6; i++)
9
+ {
10
+ a[i - 1] = a[i - 1] + i;
11
+ }
12
+ for (int i = 0; i < 6; i++)
13
+ {
14
+ printf("%c\n", a[i]);
15
+ }
16
+ // printf("%d\n", result);
17
+ return 0;
18
+ }
package/eslint/a37.c ADDED
@@ -0,0 +1,25 @@
1
+ // Online C compiler to run C program online
2
+ #include <stdio.h>
3
+ // 37
4
+ int main()
5
+ {
6
+ // Write C code here
7
+ char name[] = {'o', 'h', 'o', 'z', 'p', 'r', 'o', 'c'};
8
+ for (int i = 0, j = 7; i <= 7; i++, j--)
9
+ {
10
+ if (name[i] < name[j])
11
+ {
12
+ name[i] = name[j];
13
+ }
14
+ else
15
+ {
16
+ name[i] = name[i];
17
+ }
18
+ }
19
+ for (int i = 0; i <= 7; i++)
20
+ {
21
+ printf("%c", name[i]);
22
+ }
23
+ // printf("%d\n", result);
24
+ return 0;
25
+ }
package/eslint/a38.c ADDED
@@ -0,0 +1,28 @@
1
+ // Online C compiler to run C program online
2
+ #include <stdio.h>
3
+ // 38
4
+ int main()
5
+ {
6
+ // Write C code here
7
+ int a = 7798, d = 1, temp, result = 1;
8
+ temp = a;
9
+ while (d)
10
+ {
11
+ d = temp % 10;
12
+ temp = temp / 10;
13
+ d %= 4;
14
+ switch (d)
15
+ {
16
+ case 0:
17
+ result += (a / 100) + (a % 100);
18
+ case 1:
19
+ result += (a / 100) + (a % 100);
20
+ case 2:
21
+ result += (a / 100) + (a % 100);
22
+ case 3:
23
+ result += (a / 100) + (a % 100);
24
+ };
25
+ }
26
+ printf("%d\n", result);
27
+ return 0;
28
+ }
package/eslint/a39.c ADDED
@@ -0,0 +1,17 @@
1
+ // Online C compiler to run C program online
2
+ #include <stdio.h>
3
+ // 39
4
+ int main()
5
+ {
6
+ // Write C code here
7
+ int a = 20, b = 15, c = 0;
8
+
9
+ while (b > 0)
10
+ {
11
+ a = c + a - b;
12
+ b = a + 1;
13
+ c = b - 1;
14
+ }
15
+ printf("%d\n", a);
16
+ return 0;
17
+ }
package/eslint/a40.c ADDED
@@ -0,0 +1,32 @@
1
+ // Online C compiler to run C program online
2
+ #include <stdio.h>
3
+ // 40
4
+ int main()
5
+ {
6
+ // Write C code here
7
+ char a[5] = {'i', 'j', 'k', 'l', 'm'};
8
+ int i;
9
+ for (i = 0; i < 5; i++)
10
+ {
11
+ // printf("%d\n", a[i]);
12
+ switch (i % 2)
13
+ {
14
+ case 0:
15
+ a[i] = a[i] + 2;
16
+ break;
17
+ case 1:
18
+ a[i] = a[i] + 3;
19
+ break;
20
+ default:
21
+ a[i] = a[i] + 3;
22
+ }
23
+ }
24
+
25
+ for (i = 0; i < 5; i++)
26
+ {
27
+ printf("%c", a[i]);
28
+ }
29
+ // printf("\nHello world");
30
+
31
+ return 0;
32
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ var _postcss = _interopRequireDefault(require("postcss"));
4
+
5
+ var _path = _interopRequireDefault(require("path"));
6
+
7
+ var _fs = _interopRequireDefault(require("fs"));
8
+
9
+ var _folderIterator = _interopRequireDefault(require("../utils/folderIterator"));
10
+
11
+ var _utils = require("../utils");
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
15
+ const cwd = process.cwd();
16
+
17
+ const src = _path.default.join(cwd, process.argv[2]);
18
+
19
+ const dist = _path.default.join(cwd, process.argv[3]);
20
+
21
+ const docopy = process.argv[4] === 'true';
22
+ const {
23
+ css: {
24
+ valueReplacer
25
+ }
26
+ } = (0, _utils.getOptions)();
27
+
28
+ if (!_fs.default.existsSync(dist)) {
29
+ _fs.default.mkdirSync(dist, {
30
+ recursive: true
31
+ });
32
+ }
33
+
34
+ (0, _folderIterator.default)(src, dist, docopy ? false : ['.css'], false, (fromPath, toPath) => {
35
+ //console.log({ fromPath: fromPath, toPath: toPath });
36
+ let css = _fs.default.readFileSync(fromPath);
37
+
38
+ if (docopy && !fromPath.endsWith('.css')) {
39
+ //console.log(toPath,'....');
40
+ _fs.default.writeFileSync(toPath, css);
41
+
42
+ return;
43
+ }
44
+
45
+ (0, _postcss.default)([valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer)]).process(css, {
46
+ from: fromPath,
47
+ to: toPath
48
+ }).then(result => {
49
+ _fs.default.writeFile(toPath, result.css, () => true);
50
+
51
+ if (result.map) {
52
+ _fs.default.writeFile(`${toPath}.map`, result.map, () => true);
53
+ }
54
+ });
55
+ });
@@ -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$/,
@@ -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;
@@ -51,12 +54,12 @@ let getCSSLoaders = (hasRTL, rtlExclude, classNameBlob, cssUniqueness, selectorR
51
54
  options: {
52
55
  devCssFileBountry
53
56
  }
54
- }, hasRTL || selectorReplace ? {
57
+ }, hasRTL || selectorReplace || valueReplacer ? {
55
58
  loader: 'postcss-loader',
56
59
  options: {
57
60
  ident: 'postcss',
58
61
  plugins: function () {
59
- return [selectorReplace && require('postcss-selector-replace')(selectorReplace), hasRTL && require('../postcss-plugins/ExcludeRTLPlugin')({
62
+ return [valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer), selectorReplace && require('postcss-selector-replace')(selectorReplace), hasRTL && require('../postcss-plugins/ExcludeRTLPlugin')({
60
63
  ignore: rtlExcludeLocal,
61
64
  plugins: [require('@zohodesk/postcss-rtl')({
62
65
  addPrefixToSelector: function addPrefixToSelector(selector, prefix) {
@@ -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
+ });
@@ -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: {
@@ -38,6 +44,17 @@ var _default = {
38
44
  },
39
45
  css: {
40
46
  enableRTLSplit: false,
47
+ valueReplacer: null,
48
+ //valueReplacer: [
49
+ // {
50
+ // props: ['font', 'font-family'],
51
+ // values: {
52
+ // 'zdfonts-rCallBar': 'zdfonts-rCallBar01',
53
+ // 'zdfonts-rCall': 'zdfonts-rCallBar02'
54
+ // }
55
+ // // ,suffix: '0'
56
+ // }
57
+ // ],
41
58
  templateLabel: '{{--dir}}',
42
59
  disableMiniFiySelector: false,
43
60
  dirVarName: 'document.dir'
@@ -16,7 +16,7 @@ var _schemas = _interopRequireDefault(require("../schemas"));
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
18
  // import { argv } from 'process';
19
- let args = process.argv.slice(2); // console.log('argv', argv);
19
+ const args = process.argv.slice(2); // console.log('argv', argv);
20
20
 
21
21
  const NPM_CONFIG_PREFIX = 'npm_config_'; // TODO: we have to do option parse logic little better
22
22
  // if user use react-cli stritly without using npm scripts options won't work,
@@ -62,13 +62,14 @@ function getCWD() {
62
62
  try {
63
63
  let ress = (0, _child_process.execSync)('npm bin').toString();
64
64
  let i = ress.lastIndexOf('node_modules');
65
- cwd = i === -1 ? cwd : ress.slice(0, ress.lastIndexOf('node_modules'));
65
+ cwd = i === -1 ? cwd : ress.slice(0, i);
66
66
  } catch (error) {
67
67
  console.log(error);
68
68
  }
69
69
 
70
70
  return cwd;
71
- }
71
+ } // experimental argumnet parsing logic
72
+
72
73
 
73
74
  args.forEach(option => {
74
75
  if (/^--./.test(option)) {
@@ -82,7 +83,7 @@ args.forEach(option => {
82
83
  value = true;
83
84
  }
84
85
 
85
- key = key.replace(/-/g, '_').replace(/:/g, '_');
86
+ key = key.replace(/-|:/g, '_');
86
87
  processEnv[key] = value;
87
88
  }
88
89
  });
@@ -137,7 +138,8 @@ let getOptions = () => {
137
138
  userSchemas = require(packagePath)['react-cli'] || {};
138
139
  }
139
140
 
140
- let options = defaulter(_schemas.default, userSchemas || {});
141
+ let options = defaulter(_schemas.default, userSchemas || {}); // for future may be for npm 8 edge cases
142
+
141
143
  options.npmVersion = getNpmVersion();
142
144
  options.cwd = getCWD();
143
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.162.1",
3
+ "version": "0.0.1-beta.165",
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",