@zohodesk/react-cli 0.0.1-exp.161.2 → 0.0.1-exp.162.3
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +3 -7
- package/README.md +61 -1
- package/bin/cli.js +67 -21
- package/lib/common/splitChunks.js +63 -10
- package/lib/configs/jest.config.js +12 -3
- package/lib/configs/libAlias.js +31 -0
- package/lib/configs/webpack.dev.config.js +6 -19
- package/lib/configs/webpack.prod.config.js +18 -21
- package/lib/schemas/index.js +12 -0
- package/lib/utils/getCurrentBranch.js +1 -1
- package/lib/utils/getOptions.js +55 -1
- package/lib/utils/jsonHelper.js +11 -2
- package/package.json +6 -7
- package/node_modules0/history/CHANGES.md +0 -395
- package/node_modules0/history/DOMUtils.js +0 -3
- package/node_modules0/history/ExecutionEnvironment.js +0 -3
- package/node_modules0/history/LICENSE +0 -21
- package/node_modules0/history/LocationUtils.js +0 -3
- package/node_modules0/history/PathUtils.js +0 -3
- package/node_modules0/history/README.md +0 -282
- package/node_modules0/history/cjs/history.js +0 -933
- package/node_modules0/history/cjs/history.min.js +0 -1
- package/node_modules0/history/createBrowserHistory.js +0 -3
- package/node_modules0/history/createHashHistory.js +0 -3
- package/node_modules0/history/createMemoryHistory.js +0 -3
- package/node_modules0/history/createTransitionManager.js +0 -3
- package/node_modules0/history/es/DOMUtils.js +0 -7
- package/node_modules0/history/es/ExecutionEnvironment.js +0 -7
- package/node_modules0/history/es/LocationUtils.js +0 -7
- package/node_modules0/history/es/PathUtils.js +0 -7
- package/node_modules0/history/es/createBrowserHistory.js +0 -7
- package/node_modules0/history/es/createHashHistory.js +0 -7
- package/node_modules0/history/es/createMemoryHistory.js +0 -7
- package/node_modules0/history/es/createTransitionManager.js +0 -7
- package/node_modules0/history/es/warnAboutDeprecatedESMImport.js +0 -35
- package/node_modules0/history/esm/history.js +0 -904
- package/node_modules0/history/index.js +0 -7
- package/node_modules0/history/package.json +0 -120
- package/node_modules0/history/umd/history.js +0 -1059
- package/node_modules0/history/umd/history.min.js +0 -1
- package/node_modules0/history/warnAboutDeprecatedCJSRequire.js +0 -35
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
|
-
|
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,10 +2,70 @@
|
|
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.3
|
24
|
+
|
25
|
+
- **Optimazation:-**
|
26
|
+
- Split chunks Optimization check
|
27
|
+
|
28
|
+
# 0.0.1-exp.162.2
|
29
|
+
|
30
|
+
- **Optimazation:-**
|
31
|
+
- double time minimize optimazation
|
32
|
+
|
33
|
+
# 0.0.1-beta.162.1
|
34
|
+
|
35
|
+
- **Issue Fix:-**
|
36
|
+
- if git not installed react-cli throws error for any command due to `getCurrentBranch` in `shemas/index.js` now fixed
|
37
|
+
|
38
|
+
# 0.0.1-beta.161.1
|
39
|
+
|
40
|
+
- **Features :-**
|
41
|
+
- feature added for pre process logic
|
42
|
+
- tailer made requirement for preprocess, just write node js file
|
43
|
+
- mention file in `"react-cli" => "preprocess" => "runner"`
|
44
|
+
- option parse logic added for react-cli (exprimental)
|
45
|
+
|
46
|
+
# 0.0.1-beta.162
|
47
|
+
|
48
|
+
- @zohodesk/datetimejs package updated to beta.8
|
49
|
+
|
50
|
+
# 0.0.1-beta.161
|
51
|
+
|
52
|
+
- **Features :-**
|
53
|
+
- feature added for efc `templateFilePath` in `package.json` option palce is `"react-cli" => "efc" => "templateFilePath"`
|
54
|
+
- `(('publicPath'))` this placeholder will be replace as publicPath string `publicPath`
|
55
|
+
- `(('getInitalAssets'))` this placeholder will be replace as function `getInitalAssets`
|
56
|
+
- `getInitalAssets` this function has two arguments `assetsType`, `lang`
|
57
|
+
- `assetsType` are `js`, `css`, `i18n`
|
58
|
+
- `lang` this argument only works when `i18n` is `assetsType`
|
59
|
+
- feature added for efc `cdnStatement`
|
60
|
+
- **Issue fixes:-**
|
61
|
+
- css classname hash change issue fix
|
62
|
+
- debug package conflit issue fix in nock in (react-cli test)
|
63
|
+
- manifest.json css file name correction issue for rtl and ltr
|
64
|
+
|
5
65
|
# 0.0.1-exp.161.2
|
6
66
|
|
7
67
|
- Features
|
8
|
-
- feature added for efc `templateFilePath` in `
|
68
|
+
- feature added for efc `templateFilePath` in `package.json` option palce is `"react-cli" => "efc" `
|
9
69
|
- `(('publicPath'))` this placeholder will be replace as publicPath string `publicPath`
|
10
70
|
- `(('getInitalAssets'))` this placeholder will be replace as function `getInitalAssets`
|
11
71
|
- `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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
9
|
+
const { log } = require('../lib/utils');
|
9
10
|
//initPreCommitHook();
|
10
11
|
|
11
|
-
|
12
|
+
const options = getOptions();
|
12
13
|
|
13
|
-
|
14
|
-
|
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
|
-
|
23
|
+
const isWindows = os.platform().toLowerCase() === 'win32';
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
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,15 +37,55 @@ function getCliPath(libName) {
|
|
35
37
|
return _getCliPath(libName) + suffixExt;
|
36
38
|
}
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
const webpack = getCliPath('webpack');
|
41
|
+
|
42
|
+
const nodemon = getCliPath('nodemon');
|
43
|
+
const babel = getCliPath('babel');
|
44
|
+
const propertyToJson = getCliPath('propertyToJson');
|
45
|
+
const esLint = getCliPath('eslint');
|
46
|
+
|
47
|
+
const preprocesserPath = preprocess.runner
|
48
|
+
? path.join(process.cwd(), preprocess.runner)
|
49
|
+
: '';
|
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
|
+
}
|
74
|
+
}
|
44
75
|
|
45
76
|
let result;
|
46
77
|
switch (option) {
|
78
|
+
case 'preprocessor':
|
79
|
+
if (preprocesserPath && existsSync(preprocesserPath)) {
|
80
|
+
result = spawnSync(preprocessCli, [preprocesserPath], {
|
81
|
+
stdio: 'inherit',
|
82
|
+
cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
|
83
|
+
});
|
84
|
+
process.exit(result.status);
|
85
|
+
} else {
|
86
|
+
console.error(`preProcessor not exists ${preprocesserPath}`);
|
87
|
+
}
|
88
|
+
break;
|
47
89
|
case 'lint-setup': {
|
48
90
|
result = spawnSync(
|
49
91
|
'node',
|
@@ -155,10 +197,11 @@ switch (option) {
|
|
155
197
|
break;
|
156
198
|
|
157
199
|
case 'clean':
|
158
|
-
args = args.map(arg => path.join(appPath, arg));
|
159
200
|
result = spawnSync(
|
160
201
|
'node',
|
161
|
-
[require.resolve('../lib/utils/clean')].concat(
|
202
|
+
[require.resolve('../lib/utils/clean')].concat(
|
203
|
+
args.map(arg => path.join(appPath, arg))
|
204
|
+
),
|
162
205
|
{ stdio: 'inherit' }
|
163
206
|
);
|
164
207
|
process.exit(result.status);
|
@@ -218,12 +261,15 @@ switch (option) {
|
|
218
261
|
result = spawnSync(
|
219
262
|
webpack,
|
220
263
|
[
|
264
|
+
// '--progress',
|
265
|
+
// '--profile',
|
221
266
|
'--config',
|
222
|
-
require.resolve('../lib/configs/webpack.prod.config.js')
|
267
|
+
require.resolve('../lib/configs/webpack.prod.config.js'),
|
223
268
|
].concat(args),
|
224
269
|
{ stdio: 'inherit' }
|
225
270
|
);
|
226
271
|
|
272
|
+
// console.log(result);
|
227
273
|
process.exit(result.status);
|
228
274
|
break;
|
229
275
|
|
@@ -39,22 +39,75 @@ let isReact = module => {
|
|
39
39
|
} = module;
|
40
40
|
let reactBundle = ['react', 'react-dom'];
|
41
41
|
return userRequest && reactBundle.some(pkg => userRequest.indexOf(`node_modules${ps}${pkg}${ps}`) >= 0);
|
42
|
-
};
|
42
|
+
}; // let defaultChunks = {
|
43
|
+
// 'react.vendor': {
|
44
|
+
// name: 'react.vendor',
|
45
|
+
// chunks: 'all',
|
46
|
+
// minChunks: 1,
|
47
|
+
// test: isReact,
|
48
|
+
// priority: -10
|
49
|
+
// },
|
50
|
+
// vendor: {
|
51
|
+
// name: 'vendor',
|
52
|
+
// chunks: 'all',
|
53
|
+
// minChunks: 1,
|
54
|
+
// test: isVendor,
|
55
|
+
// priority: -10
|
56
|
+
// },
|
57
|
+
// zohocharts: {
|
58
|
+
// chunks: 'all',
|
59
|
+
// minChunks: 1,
|
60
|
+
// test: /[\\/]node_modules[\\/]((@zohodesk|@zohocharts))[\\/]((zc-custom|d3).*)/,
|
61
|
+
// priority: 30,
|
62
|
+
// enforce: true
|
63
|
+
// }
|
64
|
+
// };
|
65
|
+
|
43
66
|
|
44
67
|
let defaultChunks = {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
68
|
+
vendors: {
|
69
|
+
// picks up everything from node_modules as long as the sum of node modules is larger than minSize
|
70
|
+
//test: /[\\/]node_modules[\\/]((?!react).*)[\\/]/,
|
71
|
+
test: isVendor,
|
72
|
+
name: 'vendors',
|
73
|
+
priority: 19,
|
74
|
+
enforce: true,
|
75
|
+
// causes maxInitialRequests to be ignored, minSize still respected if specified in cacheGroup
|
76
|
+
minSize: 30000 // use the default minSize
|
77
|
+
|
78
|
+
},
|
79
|
+
vendorsAsync: {
|
80
|
+
// vendors async chunk, remaining asynchronously used node modules as single chunk file
|
81
|
+
test: /[\\/]node_modules[\\/]((?!react).*)[\\/]/,
|
82
|
+
name: 'vendors.async',
|
83
|
+
chunks: 'async',
|
84
|
+
priority: 9,
|
85
|
+
reuseExistingChunk: true,
|
86
|
+
minSize: 10000 // use smaller minSize to avoid too much potential bundle bloat due to module duplication.
|
87
|
+
|
88
|
+
},
|
89
|
+
react: {
|
90
|
+
automaticNamePrefix: 'react',
|
91
|
+
test: /[\\/]node_modules[\\/]((react).*)[\\/]/,
|
50
92
|
priority: -10
|
51
93
|
},
|
52
|
-
|
53
|
-
|
94
|
+
commonsAsync: {
|
95
|
+
// commons async chunk, remaining asynchronously used modules as single chunk file
|
96
|
+
name: 'commons.async',
|
97
|
+
minChunks: 2,
|
98
|
+
// Minimum number of chunks that must share a module before splitting
|
99
|
+
chunks: 'async',
|
100
|
+
priority: -10,
|
101
|
+
reuseExistingChunk: true,
|
102
|
+
//minSize: 10000 // use smaller minSize to avoid too much potential bundle bloat due to module duplication.
|
103
|
+
minSize: 5000
|
104
|
+
},
|
105
|
+
zohocharts: {
|
54
106
|
chunks: 'all',
|
55
107
|
minChunks: 1,
|
56
|
-
test:
|
57
|
-
priority:
|
108
|
+
test: /[\\/]node_modules[\\/]((@zohodesk|@zohocharts))[\\/]((zc-custom|d3).*)/,
|
109
|
+
priority: 30,
|
110
|
+
enforce: true
|
58
111
|
}
|
59
112
|
};
|
60
113
|
let customChunksConfig = {};
|
@@ -2,9 +2,17 @@
|
|
2
2
|
|
3
3
|
var _path = _interopRequireDefault(require("path"));
|
4
4
|
|
5
|
+
var _libAlias = require("./libAlias");
|
6
|
+
|
5
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6
8
|
|
7
|
-
let appPath = process.cwd();
|
9
|
+
let appPath = process.cwd(); // '^@root(.*)$': '<rootDir>/src$1',
|
10
|
+
// '^@components(.*)$': '<rootDir>/src/components$1',
|
11
|
+
|
12
|
+
let moduleNameMapper = Object.keys(_libAlias.libAlias).reduce((previousValue, key) => {
|
13
|
+
previousValue[`^${key}(.*)$`] = `${_libAlias.libAlias[key]}$1`;
|
14
|
+
return previousValue;
|
15
|
+
}, {});
|
8
16
|
let commonConfig = {
|
9
17
|
coverageReporters: ['json', 'html', 'json-summary', 'text'],
|
10
18
|
collectCoverage: true,
|
@@ -14,10 +22,11 @@ let commonConfig = {
|
|
14
22
|
'^.+\\.css$': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'cssPreprocessor.js'),
|
15
23
|
'^(?!.*\\.(js|jsx|css|json)$)': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'otherFilesPreprocessor.js')
|
16
24
|
},
|
17
|
-
moduleNameMapper: {
|
25
|
+
moduleNameMapper: { ...moduleNameMapper,
|
18
26
|
'\\.(css|less)$': 'identity-obj-proxy'
|
19
27
|
},
|
20
|
-
transformIgnorePatterns: ['/node_modules
|
28
|
+
transformIgnorePatterns: ['/node_modules/(?!(@zohodesk)/)'],
|
29
|
+
// transformIgnorePatterns: ['/node_modules.*?.js$'],
|
21
30
|
moduleFileExtensions: ['js'],
|
22
31
|
setupFiles: [_path.default.resolve(appPath, '__testUtils__', 'globals.js'), _path.default.resolve(__dirname, '..', 'jest', 'setup.js')],
|
23
32
|
globals: {
|
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.libAlias = void 0;
|
7
|
+
// the reason for alias at the time was code tree shaking
|
8
|
+
// tree shaking was most compactable with ES module system
|
9
|
+
// FIXME: But there is a posiblity when these package does not have lib,
|
10
|
+
// app will work because of alias, But may be jest won't work because of not alais
|
11
|
+
// So need to think about use alais in jest
|
12
|
+
const libAlias = {
|
13
|
+
'@zohodesk/components/lib': '@zohodesk/components/es',
|
14
|
+
// '@zohodesk/zc-custom/lib': '@zohodesk/zc-custom/es',
|
15
|
+
'@zohodesk/dot/lib': '@zohodesk/dot/es',
|
16
|
+
'@zohodesk/i18n/lib': '@zohodesk/i18n/es',
|
17
|
+
'@zohodesk/icons/lib': '@zohodesk/icons/es',
|
18
|
+
'@zohodesk/normalizer/lib': '@zohodesk/normalizer/es',
|
19
|
+
'@zohodesk/perf-components/lib': '@zohodesk/perf-components/es',
|
20
|
+
'@zohodesk/perf-middleware/lib': '@zohodesk/perf-middleware/es',
|
21
|
+
'@zohodesk/permissions/lib': '@zohodesk/permissions/es',
|
22
|
+
'@zohodesk/platform-middleware/lib': '@zohodesk/platform-middleware/es',
|
23
|
+
'@zohodesk/react-dnd/lib': '@zohodesk/react-dnd/es',
|
24
|
+
'@zohodesk/router-middleware/lib': '@zohodesk/router-middleware/es',
|
25
|
+
'@zohodesk/storage/lib': '@zohodesk/storage/es',
|
26
|
+
'@zohodesk/svg/lib': '@zohodesk/svg/es',
|
27
|
+
'@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
|
28
|
+
'@zohodesk/variables/lib': '@zohodesk/variables/es',
|
29
|
+
'@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
|
30
|
+
};
|
31
|
+
exports.libAlias = libAlias;
|
@@ -10,6 +10,8 @@ var _pluginUtils = require("../pluginUtils");
|
|
10
10
|
|
11
11
|
var _loaderUtils = require("../loaderUtils");
|
12
12
|
|
13
|
+
var _libAlias = require("./libAlias");
|
14
|
+
|
13
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
16
|
|
15
17
|
let options = (0, _utils.getOptions)();
|
@@ -55,6 +57,9 @@ module.exports = {
|
|
55
57
|
entry: (0, _common.getEntries)(options, 'dev'),
|
56
58
|
devtool: sourcemap,
|
57
59
|
mode: 'development',
|
60
|
+
// watchOptions: {
|
61
|
+
// ignored: /node_modules.(?!@zohodesk)/
|
62
|
+
// },
|
58
63
|
output,
|
59
64
|
stats: options.app.disableWatch ? 'errors-only' : {
|
60
65
|
children: false
|
@@ -127,25 +132,7 @@ module.exports = {
|
|
127
132
|
},
|
128
133
|
resolve: {
|
129
134
|
modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
|
130
|
-
alias: disableES5Transpile ? {
|
131
|
-
'@zohodesk/components/lib': '@zohodesk/components/es',
|
132
|
-
// "@zohodesk/zc-custom/lib": "@zohodesk/zc-custom/es",
|
133
|
-
'@zohodesk/dot/lib': '@zohodesk/dot/es',
|
134
|
-
'@zohodesk/i18n/lib': '@zohodesk/i18n/es',
|
135
|
-
'@zohodesk/icons/lib': '@zohodesk/icons/es',
|
136
|
-
'@zohodesk/normalizer/lib': '@zohodesk/normalizer/es',
|
137
|
-
'@zohodesk/perf-components/lib': '@zohodesk/perf-components/es',
|
138
|
-
'@zohodesk/perf-middleware/lib': '@zohodesk/perf-middleware/es',
|
139
|
-
'@zohodesk/permissions/lib': '@zohodesk/permissions/es',
|
140
|
-
'@zohodesk/platform-middleware/lib': '@zohodesk/platform-middleware/es',
|
141
|
-
'@zohodesk/react-dnd/lib': '@zohodesk/react-dnd/es',
|
142
|
-
'@zohodesk/router-middleware/lib': '@zohodesk/router-middleware/es',
|
143
|
-
'@zohodesk/storage/lib': '@zohodesk/storage/es',
|
144
|
-
'@zohodesk/svg/lib': '@zohodesk/svg/es',
|
145
|
-
'@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
|
146
|
-
'@zohodesk/variables/lib': '@zohodesk/variables/es',
|
147
|
-
'@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
|
148
|
-
} : {}
|
135
|
+
alias: disableES5Transpile ? _libAlias.libAlias : {}
|
149
136
|
},
|
150
137
|
resolveLoader: {
|
151
138
|
modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
|
@@ -10,8 +10,11 @@ var _pluginUtils = require("../pluginUtils");
|
|
10
10
|
|
11
11
|
var _loaderUtils = require("../loaderUtils");
|
12
12
|
|
13
|
+
var _libAlias = require("./libAlias");
|
14
|
+
|
13
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
16
|
|
17
|
+
// import TerserPlugin from 'terser-webpack-plugin';
|
15
18
|
let options = (0, _utils.getOptions)();
|
16
19
|
let {
|
17
20
|
app: {
|
@@ -76,12 +79,23 @@ module.exports = {
|
|
76
79
|
},
|
77
80
|
concatenateModules: true,
|
78
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
|
+
// ],
|
79
92
|
moduleIds: 'named'
|
80
93
|
},
|
81
94
|
stats: {
|
82
95
|
children: false,
|
83
96
|
colors: true,
|
84
97
|
// excludeAssets: /i18n/,
|
98
|
+
// excludeAssets: /./,
|
85
99
|
warningsFilter: /\[mini-css-extract-plugin\]/
|
86
100
|
},
|
87
101
|
plugins: (0, _pluginUtils.getProdPlugins)(options, output.publicPath),
|
@@ -113,7 +127,8 @@ module.exports = {
|
|
113
127
|
}] : null].filter(Boolean),
|
114
128
|
cacheDirectory: true
|
115
129
|
}
|
116
|
-
}],
|
130
|
+
}].filter(Boolean),
|
131
|
+
// include: path.join(appPath, folder)
|
117
132
|
include: module => {
|
118
133
|
let srcPath = _path.default.join(appPath, folder);
|
119
134
|
|
@@ -130,7 +145,7 @@ module.exports = {
|
|
130
145
|
exclude: /\.module\.css$/,
|
131
146
|
use: (0, _loaderUtils.getCSSLoaders)(hasRTL, rtlExclude, '[local]', false, null)
|
132
147
|
} : null, {
|
133
|
-
test: seperateCssModules ? /\.module\.css$/ :
|
148
|
+
test: seperateCssModules ? /\.module\.css$/ : /\.css$/,
|
134
149
|
use: (0, _loaderUtils.getCSSLoaders)(hasRTL, rtlExclude, false, cssUniqueness, selectorReplace, cssHashSelectors, classNamePrefix)
|
135
150
|
}, {
|
136
151
|
test: /\.jpe?g$|\.gif$|\.png$/,
|
@@ -194,25 +209,7 @@ module.exports = {
|
|
194
209
|
},
|
195
210
|
resolve: {
|
196
211
|
modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
|
197
|
-
alias: disableES5Transpile ? {
|
198
|
-
'@zohodesk/components/lib': '@zohodesk/components/es',
|
199
|
-
// '@zohodesk/zc-custom/lib': '@zohodesk/zc-custom/es',
|
200
|
-
'@zohodesk/dot/lib': '@zohodesk/dot/es',
|
201
|
-
'@zohodesk/i18n/lib': '@zohodesk/i18n/es',
|
202
|
-
'@zohodesk/icons/lib': '@zohodesk/icons/es',
|
203
|
-
'@zohodesk/normalizer/lib': '@zohodesk/normalizer/es',
|
204
|
-
'@zohodesk/perf-components/lib': '@zohodesk/perf-components/es',
|
205
|
-
'@zohodesk/perf-middleware/lib': '@zohodesk/perf-middleware/es',
|
206
|
-
'@zohodesk/permissions/lib': '@zohodesk/permissions/es',
|
207
|
-
'@zohodesk/platform-middleware/lib': '@zohodesk/platform-middleware/es',
|
208
|
-
'@zohodesk/react-dnd/lib': '@zohodesk/react-dnd/es',
|
209
|
-
'@zohodesk/router-middleware/lib': '@zohodesk/router-middleware/es',
|
210
|
-
'@zohodesk/storage/lib': '@zohodesk/storage/es',
|
211
|
-
'@zohodesk/svg/lib': '@zohodesk/svg/es',
|
212
|
-
'@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
|
213
|
-
'@zohodesk/variables/lib': '@zohodesk/variables/es',
|
214
|
-
'@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
|
215
|
-
} : {}
|
212
|
+
alias: disableES5Transpile ? _libAlias.libAlias : {}
|
216
213
|
},
|
217
214
|
resolveLoader: {
|
218
215
|
modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
|
package/lib/schemas/index.js
CHANGED
@@ -18,6 +18,18 @@ var _default = {
|
|
18
18
|
value: null,
|
19
19
|
cli: 'ssl_cert_url'
|
20
20
|
},
|
21
|
+
preprocess: {
|
22
|
+
// This option is for tell the react-cli which in preprocessor js file path
|
23
|
+
runner: {
|
24
|
+
value: '',
|
25
|
+
cli: 'preprocessor'
|
26
|
+
},
|
27
|
+
// usally preprocessor run in nodemon for, start and docs , preprocessor
|
28
|
+
stopNodemon: {
|
29
|
+
value: false,
|
30
|
+
cli: 'stop_nodemon'
|
31
|
+
}
|
32
|
+
},
|
21
33
|
i18n: {
|
22
34
|
chunkSplitEnable: {
|
23
35
|
value: false,
|
@@ -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
|
|
package/lib/utils/getOptions.js
CHANGED
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
7
|
|
8
|
+
var _child_process = require("child_process");
|
9
|
+
|
8
10
|
var _fs = _interopRequireDefault(require("fs"));
|
9
11
|
|
10
12
|
var _path = _interopRequireDefault(require("path"));
|
@@ -13,6 +15,9 @@ var _schemas = _interopRequireDefault(require("../schemas"));
|
|
13
15
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
17
|
|
18
|
+
// import { argv } from 'process';
|
19
|
+
const args = process.argv.slice(2); // console.log('argv', argv);
|
20
|
+
|
16
21
|
const NPM_CONFIG_PREFIX = 'npm_config_'; // TODO: we have to do option parse logic little better
|
17
22
|
// if user use react-cli stritly without using npm scripts options won't work,
|
18
23
|
// So we have to write our own option parse logic or some other library
|
@@ -37,6 +42,52 @@ keysWithColon.forEach(key => {
|
|
37
42
|
processEnv[nkey] = processEnv[key];
|
38
43
|
});
|
39
44
|
|
45
|
+
function getNpmVersion() {
|
46
|
+
// require("child_process").
|
47
|
+
let vers = '6';
|
48
|
+
|
49
|
+
try {
|
50
|
+
[vers] = (0, _child_process.execSync)('npm -v').toString().trim().split('.');
|
51
|
+
} catch (error) {
|
52
|
+
console.log(error);
|
53
|
+
}
|
54
|
+
|
55
|
+
return vers;
|
56
|
+
}
|
57
|
+
|
58
|
+
function getCWD() {
|
59
|
+
// require("child_process").
|
60
|
+
let cwd = process.cwd();
|
61
|
+
|
62
|
+
try {
|
63
|
+
let ress = (0, _child_process.execSync)('npm bin').toString();
|
64
|
+
let i = ress.lastIndexOf('node_modules');
|
65
|
+
cwd = i === -1 ? cwd : ress.slice(0, i);
|
66
|
+
} catch (error) {
|
67
|
+
console.log(error);
|
68
|
+
}
|
69
|
+
|
70
|
+
return cwd;
|
71
|
+
} // experimental argumnet parsing logic
|
72
|
+
|
73
|
+
|
74
|
+
args.forEach(option => {
|
75
|
+
if (/^--./.test(option)) {
|
76
|
+
let equIndex = option.indexOf('='); // equIndex = equIndex === -1 ? option.length : equIndex;
|
77
|
+
|
78
|
+
let key = option.slice(2, equIndex);
|
79
|
+
let value = option.slice(equIndex + 1);
|
80
|
+
|
81
|
+
if (equIndex === -1) {
|
82
|
+
key = option.slice(2);
|
83
|
+
value = true;
|
84
|
+
}
|
85
|
+
|
86
|
+
key = key.replace(/-|:/g, '_');
|
87
|
+
processEnv[key] = value;
|
88
|
+
}
|
89
|
+
});
|
90
|
+
|
40
91
|
let defaulter = (target, source) => {
|
41
92
|
let defaultObject = {};
|
42
93
|
Object.keys(target).forEach(key => {
|
@@ -87,7 +138,10 @@ let getOptions = () => {
|
|
87
138
|
userSchemas = require(packagePath)['react-cli'] || {};
|
88
139
|
}
|
89
140
|
|
90
|
-
let options = defaulter(_schemas.default, userSchemas || {});
|
141
|
+
let options = defaulter(_schemas.default, userSchemas || {}); // for future may be for npm 8 edge cases
|
142
|
+
|
143
|
+
options.npmVersion = getNpmVersion();
|
144
|
+
options.cwd = getCWD();
|
91
145
|
options.packageVersion = process.env.npm_package_version;
|
92
146
|
global.reactCLIOptions = options;
|
93
147
|
return options;
|
package/lib/utils/jsonHelper.js
CHANGED
@@ -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]
|
60
|
+
if (isObject(receiverObj[key]) && isObject(senterObj[key])) {
|
52
61
|
jsonConcate(receiverObj[key], senterObj[key]);
|
53
|
-
} else if (receiverObj[key]
|
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];
|