@zohodesk/react-cli 0.0.1-exp.162.3 → 0.0.1-exp.166.1
Sign up to get free protection for your applications and to get access to all the features.
- package/DOTO.md +13 -0
- package/README.md +29 -5
- package/bin/cli.js +22 -1
- package/docs/CustomChunks.md +26 -0
- package/docs/TODOS.md +10 -0
- package/docs/ValueReplacer.md +60 -0
- package/docs/warnings_while_install.txt +35 -0
- package/eslint/NOTES.md +3 -0
- package/eslint/a23.c +16 -0
- package/eslint/a28.c +25 -0
- package/eslint/a29.c +25 -0
- package/eslint/a30.c +29 -0
- package/eslint/a31.c +23 -0
- package/eslint/a35.c +23 -0
- package/eslint/a36.c +18 -0
- package/eslint/a37.c +25 -0
- package/eslint/a38.c +28 -0
- package/eslint/a39.c +17 -0
- package/eslint/a40.c +32 -0
- package/eslint/mockapi.html +18 -0
- package/eslint/mockapi.md +5 -0
- package/lib/common/splitChunks.js +66 -72
- package/lib/common/testPattern.js +69 -0
- package/lib/common/valueReplacer.js +55 -0
- package/lib/configs/jest.config.js +6 -1
- package/lib/configs/webpack.docs.config.js +31 -27
- package/lib/loaderUtils/getCSSLoaders.js +17 -13
- package/lib/postcss-plugins/ValueReplacer.js +46 -0
- package/lib/schemas/index.js +11 -0
- package/lib/servers/devBulid.js +98 -0
- package/lib/servers/getCliPath.js +24 -0
- package/lib/servers/nowatchserver.js +9 -84
- package/lib/servers/server.js +9 -2
- package/npm8.md +9 -0
- package/package.json +2 -2
@@ -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
|
+
}
|
@@ -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 _devBulid = require("./devBulid");
|
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.
|
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
|
-
|
49
|
-
|
50
|
-
|
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, _devBulid.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
|
+
});
|
package/lib/servers/server.js
CHANGED
@@ -99,9 +99,16 @@ app.use((0, _HMRMiddleware.default)(compiler, {
|
|
99
99
|
path: '/sockjs-node/info'
|
100
100
|
}));
|
101
101
|
app.use((req, res, next) => {
|
102
|
-
|
102
|
+
//console.log('origin', req.get('origin'));
|
103
|
+
res.setHeader('Access-Control-Allow-Origin', req.get('origin') || '*'); // res.setHeader('Access-Control-Allow-Origin', req.get('origin'));
|
104
|
+
|
105
|
+
res.setHeader('Access-Control-Allow-Private-Network', true);
|
106
|
+
res.setHeader('Access-Control-Allow-Credentials', true);
|
103
107
|
next();
|
104
108
|
}).use(`${contextURL}/fonts`, _express.default.static(`${context}/fonts`));
|
109
|
+
app.options('/*', (req, res) => {
|
110
|
+
res.send('Ok');
|
111
|
+
});
|
105
112
|
app.use('/wms/*', (req, res) => {
|
106
113
|
res.sendFile(_path.default.join(__dirname, '..', '..', 'templates', 'wms', 'index.html'));
|
107
114
|
});
|
@@ -197,6 +204,6 @@ app.listen(httpPort, err => {
|
|
197
204
|
(0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
|
198
205
|
host,
|
199
206
|
domain,
|
200
|
-
port:
|
207
|
+
port: port
|
201
208
|
}, 'ht' + 'tp')}${contextURL}/`);
|
202
209
|
});
|
package/npm8.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# npm 8 change related things
|
2
|
+
|
3
|
+
1. in npm run script config options `:` not working (properly|correctly), So we need to use `_` in the place of `:`
|
4
|
+
For Example:
|
5
|
+
- `--app:port` wouldn't work we have to do like this `--app_port`
|
6
|
+
- `--clone:proj:name` wouldn't work we have to do like this `----clone_proj_name`
|
7
|
+
|
8
|
+
@zohodes/react-cli or fz-react-cli regardless of what cli you use.
|
9
|
+
So, we need to change all package.json script which is using this (`:`) we need to change as (`_`)
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@zohodesk/react-cli",
|
3
|
-
"version": "0.0.1-exp.
|
3
|
+
"version": "0.0.1-exp.166.1",
|
4
4
|
"description": "A CLI tool for build modern web application and libraries",
|
5
5
|
"scripts": {
|
6
6
|
"init": "node ./lib/utils/init.js",
|
@@ -100,7 +100,7 @@
|
|
100
100
|
"react-redux": "7.2.1",
|
101
101
|
"react-router": "5.2.0",
|
102
102
|
"react-router-redux": "4.0.8",
|
103
|
-
"react-test-renderer": "
|
103
|
+
"react-test-renderer": "16.13.1",
|
104
104
|
"react-transition-group": "2.7.1",
|
105
105
|
"redis": "3.0.2",
|
106
106
|
"redux": "4.0.5",
|