@zohodesk/react-cli 1.1.17 → 1.1.18-exp.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +13 -0
- package/lib/babel/babel-option-utils/babel-preset-react-option.js +22 -0
- package/lib/babel/cmjs-plugins-presets.js +7 -1
- package/lib/babel/es-plugins-presets.js +7 -1
- package/lib/configs/webpack.dev.config.js +7 -2
- package/lib/configs/webpack.prod.config.js +9 -2
- package/lib/loaderUtils/getDevJsLoaders.js +5 -1
- package/lib/schemas/index.js +4 -0
- package/npm-shrinkwrap.json +31 -5
- package/package.json +1 -1
- package/packages/client_build_tool/lib/allCommandsConfigs.js +23 -0
- package/packages/client_build_tool/lib/buildToolLoggers.js +32 -0
- package/packages/client_build_tool/lib/commands/build/commandExecutor.js +21 -0
- package/packages/client_build_tool/lib/commands/build/config.js +12 -0
- package/packages/client_build_tool/lib/commands/build/errorHander.js +10 -0
- package/packages/client_build_tool/lib/commands/build/index.js +35 -0
- package/packages/client_build_tool/lib/commands/build/optionsProcesser.js +40 -0
- package/packages/client_build_tool/lib/commands/buildEs/commandExecutor.js +17 -0
- package/packages/client_build_tool/lib/commands/buildEs/config.js +12 -0
- package/packages/client_build_tool/lib/commands/buildLib/commandExecutor.js +17 -0
- package/packages/client_build_tool/lib/commands/buildLib/config.js +12 -0
- package/packages/client_build_tool/lib/commands/start/commandExecutor.js +13 -0
- package/packages/client_build_tool/lib/commands/start/config.js +12 -0
- package/packages/client_build_tool/lib/commands/start/deprecationHandler.js +10 -0
- package/packages/client_build_tool/lib/commands/start/errorHander.js +10 -0
- package/packages/client_build_tool/lib/commands/start/optionsProcesser.js +36 -0
- package/packages/client_build_tool/lib/commands/start/postProcesser.js +10 -0
- package/packages/client_build_tool/lib/commands/start/preProcesser.js +10 -0
- package/packages/client_build_tool/lib/commandsRouter.js +71 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/common/decidePublicPath.js +44 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/common/libAlias.js +31 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/common/nameTemplates.js +51 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/common/resourceBasedPublicPath.js +21 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/cssLoaders.js +16 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin.js +111 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/EFCPlugin.js +1 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ContributionGuide.md +11 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +136 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nSplit.md +95 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/README.md +25 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +29 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +24 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nDependency.js +99 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +81 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nModule.js +201 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +401 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +67 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +23 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +29 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +49 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +77 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +63 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +19 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +31 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +127 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RTLSplitPlugin.js +1 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +63 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +89 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtrSplit.md +34 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +15 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +155 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin.js +49 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/ExcludePlugin.js +58 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/RTLSplitPlugin.js +139 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/devServerConfig.js +34 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/getCSSLoaders.js +30 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/jsLoaders.js +17 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/assetLoaders.js +14 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +24 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +18 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +21 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +138 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +83 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +23 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaders/workerLoader.js +133 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/optimizationConfig.js +39 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/outputConfig.js +28 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +18 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCopyThirdpartyFile.js +38 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +24 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +28 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +35 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +16 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +23 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +19 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +27 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +18 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configUglifyCSSPlugin.js +15 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/plugins.js +39 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/postcssPlugins.js +36 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/resolvers.js +42 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/splitChunksConfig.js +12 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/webpack.dev.config.js +17 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/webpackBuild.js +24 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/webpackConfig.js +50 -0
- package/packages/client_build_tool/lib/shared/commands-utlis/doBasicRequiermentCheck.js +16 -0
- package/packages/client_build_tool/lib/shared/commands-utlis/getCliPath.js +38 -0
- package/packages/client_build_tool/lib/shared/commands-utlis/index.js +29 -0
- package/packages/client_build_tool/lib/shared/commands-utlis/log.js +13 -0
- package/packages/client_build_tool/lib/shared/commands-utlis/readArgsFormCommandLine.js +11 -0
- package/packages/client_build_tool/lib/shared/commands-utlis/readOptionFormCommandLine.js +11 -0
- package/packages/client_build_tool/lib/shared/commands-utlis/spanSync.js +35 -0
- package/packages/client_build_tool/lib/shared/constants.js +33 -0
- package/packages/client_build_tool/lib/shared/schemas/applyValuesToShema.js +37 -0
- package/packages/client_build_tool/lib/shared/schemas/cliArgsToObject.js +37 -0
- package/packages/client_build_tool/lib/shared/schemas/defaultConfigValues.js +119 -0
- package/packages/client_build_tool/lib/shared/schemas/deprecatedOptionsHandler.js +65 -0
- package/packages/client_build_tool/lib/shared/schemas/getCWD.js +23 -0
- package/packages/client_build_tool/lib/shared/schemas/getNpmVersion.js +21 -0
- package/packages/client_build_tool/lib/shared/schemas/npmConfigToObject.js +32 -0
- package/packages/client_build_tool/lib/shared/schemas/oldDefaultConfigValues.js +480 -0
- package/packages/client_build_tool/lib/shared/schemas/readOptions.js +55 -0
- package/packages/client_build_tool/lib/shared/schemas/readOptionsForPackageJson.js +26 -0
- package/packages/client_build_tool/lib/shared/schemas/readOptionsOld.js +152 -0
- package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.crt +37 -0
- package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.key +27 -0
- package/packages/client_build_tool/lib/shared/server/configWebpackDevMiddleware.js +40 -0
- package/packages/client_build_tool/lib/shared/server/corsHandleing.js +28 -0
- package/packages/client_build_tool/lib/shared/server/getIp.js +30 -0
- package/packages/client_build_tool/lib/shared/server/getServerURL.js +29 -0
- package/packages/client_build_tool/lib/shared/server/httpsOptions.js +53 -0
- package/packages/client_build_tool/lib/shared/server/initExpressApp.js +19 -0
- package/packages/client_build_tool/lib/shared/server/initialHTMLHandling.js +66 -0
- package/packages/client_build_tool/lib/shared/server/serveContextFiles.js +24 -0
- package/packages/client_build_tool/lib/shared/server/serverBywebpackDevMiddleware.js +40 -0
- package/packages/client_build_tool/lib/shared/server/startHttpServer.js +26 -0
- package/packages/client_build_tool/lib/shared/server/startHttpsServer.js +34 -0
- package/packages/client_build_tool/lib/shared/server/unwanted/addHttp2Server.js +41 -0
- package/packages/client_build_tool/lib/shared/server/unwanted/configWebpackDevMiddleware.js +44 -0
- package/packages/client_build_tool/lib/shared/server/unwanted/devServerUtlis.js +1 -0
- package/packages/client_build_tool/lib/shared/server/unwanted/mockApiSupport.js +19 -0
- package/packages/client_build_tool/lib/shared/server/unwanted/webpackConfig.js +32 -0
- package/packages/client_build_tool/lib/shared/server/unwanted/websocketMockSetup.js +48 -0
- package/packages/client_build_tool/lib/shared/server/urlConcat.js +25 -0
- package/packages/client_build_tool/lib/shared/utils/utils.js +1 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIGXjCCBUagAwIBAgIRAMKJgToWlDYncIf54wIl/K4wDQYJKoZIhvcNAQELBQAw
|
3
|
+
gY8xCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO
|
4
|
+
BgNVBAcTB1NhbGZvcm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|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.configWebpackDevMiddleware = configWebpackDevMiddleware;
|
7
|
+
exports.webpackDevMiddlewareConfig = webpackDevMiddlewareConfig;
|
8
|
+
|
9
|
+
var _webpack = require("webpack");
|
10
|
+
|
11
|
+
var _webpackDevMiddleware = _interopRequireDefault(require("webpack-dev-middleware"));
|
12
|
+
|
13
|
+
var _webpackConfig = _interopRequireDefault(require("../bundler/webpack/webpackConfig"));
|
14
|
+
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
|
+
|
17
|
+
function webpackDevMiddlewareConfig(options) {
|
18
|
+
const {
|
19
|
+
publicPath
|
20
|
+
} = options;
|
21
|
+
return {
|
22
|
+
stats: 'minimal',
|
23
|
+
index: 'index.html',
|
24
|
+
publicPath,
|
25
|
+
headers: {
|
26
|
+
'Access-Control-Allow-Origin': '*'
|
27
|
+
}
|
28
|
+
};
|
29
|
+
}
|
30
|
+
|
31
|
+
function configWebpackDevMiddleware(app, options) {
|
32
|
+
const config = (0, _webpackConfig.default)(options);
|
33
|
+
const compiler = (0, _webpack.webpack)(config); // console.log("mode", mode)
|
34
|
+
|
35
|
+
const devMiddleware = (0, _webpackDevMiddleware.default)(compiler, webpackDevMiddlewareConfig(options));
|
36
|
+
app.use(devMiddleware);
|
37
|
+
return {
|
38
|
+
compiler
|
39
|
+
};
|
40
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.corsHandleing = corsHandleing;
|
7
|
+
|
8
|
+
var _express = _interopRequireDefault(require("express"));
|
9
|
+
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
+
|
12
|
+
function corsHandleing(app, options) {
|
13
|
+
const {
|
14
|
+
contextURL,
|
15
|
+
context
|
16
|
+
} = options;
|
17
|
+
app.use((req, res, next) => {
|
18
|
+
//console.log('origin', req.get('origin'));
|
19
|
+
res.setHeader('Access-Control-Allow-Origin', req.get('origin') || '*'); // res.setHeader('Access-Control-Allow-Origin', req.get('origin'));
|
20
|
+
|
21
|
+
res.setHeader('Access-Control-Allow-Private-Network', true);
|
22
|
+
res.setHeader('Access-Control-Allow-Credentials', true);
|
23
|
+
next();
|
24
|
+
}).use(`${contextURL}/fonts`, _express.default.static(`${context}/fonts`));
|
25
|
+
app.options('/*', (req, res) => {
|
26
|
+
res.send('Ok');
|
27
|
+
});
|
28
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getIp = getIp;
|
7
|
+
|
8
|
+
var _os = _interopRequireDefault(require("os"));
|
9
|
+
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
+
|
12
|
+
function getIp() {
|
13
|
+
let ifaces = _os.default.networkInterfaces();
|
14
|
+
|
15
|
+
let ips = [];
|
16
|
+
Object.keys(ifaces).forEach(ifname => {
|
17
|
+
let a = ifaces[ifname].map(iface => {
|
18
|
+
if ('IPv4' !== iface.family || iface.internal !== false) {
|
19
|
+
return null;
|
20
|
+
}
|
21
|
+
|
22
|
+
return iface.address;
|
23
|
+
}).filter(a => a);
|
24
|
+
ips = ips.concat(a);
|
25
|
+
});
|
26
|
+
ips.push('127.0.0.1');
|
27
|
+
return ips[0];
|
28
|
+
}
|
29
|
+
|
30
|
+
;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getServerDomain = getServerDomain;
|
7
|
+
exports.getServerUrl = getServerUrl;
|
8
|
+
|
9
|
+
function getServerDomain(serverInfo) {
|
10
|
+
const {
|
11
|
+
host,
|
12
|
+
domain
|
13
|
+
} = serverInfo;
|
14
|
+
|
15
|
+
if (domain) {
|
16
|
+
return `${host}.${domain}.zohocorpin.com`;
|
17
|
+
}
|
18
|
+
|
19
|
+
return host;
|
20
|
+
}
|
21
|
+
|
22
|
+
function getServerUrl({
|
23
|
+
domain,
|
24
|
+
port,
|
25
|
+
protocol = 'http'
|
26
|
+
}) {
|
27
|
+
const prefix = protocol ? `${protocol}:` : '';
|
28
|
+
return `${prefix}//${domain}:${port}/`;
|
29
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.httpsOptions = httpsOptions;
|
7
|
+
exports.httpsOptionsWithUserFriendlyError = httpsOptionsWithUserFriendlyError;
|
8
|
+
|
9
|
+
var _buildToolLoggers = require("../../buildToolLoggers");
|
10
|
+
|
11
|
+
var _constants = require("../constants");
|
12
|
+
|
13
|
+
// import fs from 'fs';
|
14
|
+
// import path from 'path';
|
15
|
+
// export const httpsOptions = {
|
16
|
+
// key: fs.readFileSync(path.join(__dirname, './cert/Tsicsezwild-22-23.key')),
|
17
|
+
// cert: fs.readFileSync(path.join(__dirname, './cert/Tsicsezwild-22-23.crt'))
|
18
|
+
// };
|
19
|
+
function httpsOptions(options) {
|
20
|
+
const {
|
21
|
+
httpsCerts
|
22
|
+
} = options.server; // eslint-disable-next-line global-require, import/no-dynamic-require
|
23
|
+
|
24
|
+
const certificate = require(require.resolve(httpsCerts, {
|
25
|
+
paths: [process.cwd()]
|
26
|
+
})); // TODO: in future we may do some version based check. certificate.version
|
27
|
+
|
28
|
+
|
29
|
+
return certificate.httpsOptions;
|
30
|
+
}
|
31
|
+
|
32
|
+
function httpsOptionsWithUserFriendlyError(options) {
|
33
|
+
const {
|
34
|
+
httpsCerts
|
35
|
+
} = options.server;
|
36
|
+
|
37
|
+
if (typeof httpsCerts === 'string' && httpsCerts) {
|
38
|
+
try {
|
39
|
+
const certificate = httpsOptions(options);
|
40
|
+
return certificate;
|
41
|
+
} catch (error) {
|
42
|
+
if (error.msg.indexOf('Error: Cannot find module') !== -1) {
|
43
|
+
(0, _buildToolLoggers.errorLogger)(`You have given ${_constants.BASE_CONFIG_KEY}.server.httpsCerts as "${httpsCerts}.
|
44
|
+
But it seems that file path have some problem";`);
|
45
|
+
}
|
46
|
+
|
47
|
+
(0, _buildToolLoggers.errorLogger)(error);
|
48
|
+
process.exit(0);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
return null;
|
53
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.initExpressApp = initExpressApp;
|
7
|
+
|
8
|
+
var _express = _interopRequireDefault(require("express"));
|
9
|
+
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
+
|
12
|
+
function initExpressApp() {
|
13
|
+
const app = (0, _express.default)();
|
14
|
+
app.use(_express.default.json());
|
15
|
+
app.use(_express.default.urlencoded({
|
16
|
+
extended: true
|
17
|
+
}));
|
18
|
+
return app;
|
19
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.initialHTMLHandling = initialHTMLHandling;
|
7
|
+
|
8
|
+
var _buildToolLoggers = require("../../buildToolLoggers");
|
9
|
+
|
10
|
+
function initialHTMLHandling(compiler, app, options) {
|
11
|
+
const {
|
12
|
+
contextURL
|
13
|
+
} = options;
|
14
|
+
const {
|
15
|
+
i18nChunkSplit
|
16
|
+
} = options;
|
17
|
+
const {
|
18
|
+
rtlSplit
|
19
|
+
} = options.css.plugins;
|
20
|
+
let initalHTML;
|
21
|
+
compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
|
22
|
+
const indexHtml = compilation.assets['index.html']; // compiler.outputFileSystem.readFileSync("build/index.html");
|
23
|
+
|
24
|
+
if (indexHtml) {
|
25
|
+
initalHTML = indexHtml.source();
|
26
|
+
}
|
27
|
+
});
|
28
|
+
app.use(`${contextURL}/*`, (req, res) => {
|
29
|
+
// // app.use(`/desk/*`, (req, res) => {
|
30
|
+
// const { rtlSplit } = options.css.plugins;
|
31
|
+
let newHTML = initalHTML;
|
32
|
+
|
33
|
+
if (i18nChunkSplit.chunkSplitEnable) {
|
34
|
+
// eslint-disable-next-line no-use-before-define
|
35
|
+
newHTML = replaceWithRandomLocale(newHTML, i18nChunkSplit.templateLabel);
|
36
|
+
}
|
37
|
+
|
38
|
+
if (rtlSplit.enableRTLSplit) {
|
39
|
+
// eslint-disable-next-line no-use-before-define
|
40
|
+
newHTML = replaceWithRandomDir(newHTML, rtlSplit.templateLabel);
|
41
|
+
}
|
42
|
+
|
43
|
+
res.send(newHTML);
|
44
|
+
});
|
45
|
+
|
46
|
+
function replaceWithRandomLocale(initalHTML, templateLabel) {
|
47
|
+
const locales = ['ar_EG', 'da_DK', 'de_DE', 'en_US', 'es_AR', 'es_ES', 'fr_FR', 'hi_IN', 'in_ID', 'it_IT', 'iw_IL', 'ja_JP', 'nl_NL', 'pl_PL', 'pt_BR', 'pt_PT', 'ro_RO', 'ru_RU', 'sv_SE', 'ta_IN', 'te_IN', 'tr_TR', 'zh_CN', 'zh_TW']; // app.use(`/desk/*`, (req, res) => {
|
48
|
+
// const locale = 'ta_IN';
|
49
|
+
|
50
|
+
const locale = locales[Math.floor(Math.random() * locales.length)];
|
51
|
+
console.log({
|
52
|
+
locale
|
53
|
+
});
|
54
|
+
return initalHTML.replaceAll(templateLabel, locale);
|
55
|
+
}
|
56
|
+
|
57
|
+
function replaceWithRandomDir(initalHTML, templateLabel) {
|
58
|
+
const dirs = ['ltr', 'rtl']; // const dir = 'rtl';
|
59
|
+
|
60
|
+
const dir = dirs[Math.floor(Math.random() * dirs.length)];
|
61
|
+
console.log({
|
62
|
+
dir
|
63
|
+
});
|
64
|
+
return initalHTML.replaceAll(templateLabel, dir);
|
65
|
+
}
|
66
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.serveContextFiles = serveContextFiles;
|
7
|
+
|
8
|
+
var _express = _interopRequireDefault(require("express"));
|
9
|
+
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
+
|
12
|
+
function serveContextFiles(app, options) {
|
13
|
+
const {
|
14
|
+
context,
|
15
|
+
contextURL,
|
16
|
+
contextFolderPath
|
17
|
+
} = options;
|
18
|
+
|
19
|
+
if (contextURL) {
|
20
|
+
app.use(contextURL, _express.default.static(contextFolderPath));
|
21
|
+
} else {
|
22
|
+
app.use(_express.default.static(context));
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.run = run;
|
7
|
+
|
8
|
+
var _corsHandleing = require("./corsHandleing");
|
9
|
+
|
10
|
+
var _initExpressApp = require("./initExpressApp");
|
11
|
+
|
12
|
+
var _configWebpackDevMiddleware = require("./configWebpackDevMiddleware");
|
13
|
+
|
14
|
+
var _serveContextFiles = require("./serveContextFiles");
|
15
|
+
|
16
|
+
var _startHttpsServer = require("./startHttpsServer");
|
17
|
+
|
18
|
+
var _initialHTMLHandling = require("./initialHTMLHandling");
|
19
|
+
|
20
|
+
var _startHttpServer = require("./startHttpServer");
|
21
|
+
|
22
|
+
// import c from './bundler/webpack/webpack.dev.config.js'
|
23
|
+
// import { spawnSyncIO } from '../commands-utlis/spanSync';
|
24
|
+
// import { startHttpServer } from './startHttpServer';
|
25
|
+
function run(options) {
|
26
|
+
const app = (0, _initExpressApp.initExpressApp)();
|
27
|
+
(0, _corsHandleing.corsHandleing)(app, options);
|
28
|
+
const {
|
29
|
+
compiler
|
30
|
+
} = (0, _configWebpackDevMiddleware.configWebpackDevMiddleware)(app, options);
|
31
|
+
(0, _serveContextFiles.serveContextFiles)(app, options);
|
32
|
+
(0, _startHttpsServer.startHttpsServer)(app, options);
|
33
|
+
(0, _startHttpServer.startHttpServer)(app, options);
|
34
|
+
(0, _initialHTMLHandling.initialHTMLHandling)(compiler, app, options); // return spawnSyncIO('webpack', [
|
35
|
+
// 'serve',
|
36
|
+
// '--config',
|
37
|
+
// require.resolve('../bundler/webpack/webpack.dev.config.js')
|
38
|
+
// ]);
|
39
|
+
// startHttpServer(app, options);
|
40
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.startHttpServer = startHttpServer;
|
7
|
+
|
8
|
+
var _buildToolLoggers = require("../../buildToolLoggers");
|
9
|
+
|
10
|
+
function startHttpServer(app, options) {
|
11
|
+
const {
|
12
|
+
serverExtras
|
13
|
+
} = options;
|
14
|
+
const {
|
15
|
+
httpPort,
|
16
|
+
httpUrl
|
17
|
+
} = serverExtras;
|
18
|
+
app.listen(httpPort, err => {
|
19
|
+
if (err) {
|
20
|
+
throw err;
|
21
|
+
}
|
22
|
+
|
23
|
+
(0, _buildToolLoggers.messageLogger)(`Listening at ${httpUrl}`);
|
24
|
+
});
|
25
|
+
return app;
|
26
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.startHttpsServer = startHttpsServer;
|
7
|
+
|
8
|
+
var _https = _interopRequireDefault(require("https"));
|
9
|
+
|
10
|
+
var _buildToolLoggers = require("../../buildToolLoggers");
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
function startHttpsServer(app, options) {
|
15
|
+
const {
|
16
|
+
httpsOptions,
|
17
|
+
serverExtras
|
18
|
+
} = options;
|
19
|
+
const {
|
20
|
+
httpsPort,
|
21
|
+
httpsUrl
|
22
|
+
} = serverExtras;
|
23
|
+
|
24
|
+
const httpsServer = _https.default.createServer(httpsOptions, app);
|
25
|
+
|
26
|
+
httpsServer.listen(httpsPort, err => {
|
27
|
+
if (err) {
|
28
|
+
throw err;
|
29
|
+
}
|
30
|
+
|
31
|
+
(0, _buildToolLoggers.messageLogger)(`Listening at ${httpsUrl}`);
|
32
|
+
});
|
33
|
+
return httpsServer;
|
34
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.addHttp2Server = addHttp2Server;
|
7
|
+
|
8
|
+
var _utils = require("../../../src/utils");
|
9
|
+
|
10
|
+
var _httpsOptions = require("../../../src/servers/httpsOptions");
|
11
|
+
|
12
|
+
function addHttp2Server(http2Port, host, domain, contextURL) {
|
13
|
+
const isCompatableHttp2 = Number(process.version.slice(1).split('.')[0]) >= 8;
|
14
|
+
|
15
|
+
if (isCompatableHttp2) {
|
16
|
+
const http2 = require('http2');
|
17
|
+
|
18
|
+
const http2Server = http2.createSecureServer(_httpsOptions.httpsOptions); // eslint-disable-next-line no-unused-vars
|
19
|
+
|
20
|
+
http2Server.on('stream', (stream, headers) => {
|
21
|
+
stream.respond({
|
22
|
+
'content-type': 'text/html',
|
23
|
+
':status': 200
|
24
|
+
});
|
25
|
+
stream.end('<h1>Hello World! <br>Working with http2</h1>');
|
26
|
+
});
|
27
|
+
http2Server.listen(http2Port, err => {
|
28
|
+
if (err) {
|
29
|
+
throw err;
|
30
|
+
}
|
31
|
+
|
32
|
+
(0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
|
33
|
+
host,
|
34
|
+
domain,
|
35
|
+
port: http2Port
|
36
|
+
}, 'htt' + 'ps')}${contextURL}/`, 'http2 server');
|
37
|
+
});
|
38
|
+
} else {
|
39
|
+
(0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
|
40
|
+
}
|
41
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.configWebpackDevMiddleware = configWebpackDevMiddleware;
|
7
|
+
|
8
|
+
var _webpackDevMiddleware = _interopRequireDefault(require("webpack-dev-middleware"));
|
9
|
+
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
+
|
12
|
+
function configWebpackDevMiddleware({
|
13
|
+
publicPath,
|
14
|
+
writeToDisk,
|
15
|
+
enableDevCache,
|
16
|
+
disableWatch,
|
17
|
+
compress,
|
18
|
+
compiler
|
19
|
+
}) {
|
20
|
+
let webpackServerOptions = {
|
21
|
+
logLevel: 'error',
|
22
|
+
publicPath,
|
23
|
+
headers: {
|
24
|
+
'Access-Control-Allow-Origin': '*'
|
25
|
+
},
|
26
|
+
compress
|
27
|
+
};
|
28
|
+
|
29
|
+
if (enableDevCache) {
|
30
|
+
webpackServerOptions.headers['Cache-Control'] = 'public, max-age=604800';
|
31
|
+
}
|
32
|
+
|
33
|
+
if (disableWatch) {
|
34
|
+
webpackServerOptions.watchOptions = {
|
35
|
+
ignored: /./
|
36
|
+
};
|
37
|
+
}
|
38
|
+
|
39
|
+
if (writeToDisk) {
|
40
|
+
webpackServerOptions.writeToDisk = true;
|
41
|
+
}
|
42
|
+
|
43
|
+
return (0, _webpackDevMiddleware.default)(compiler, webpackServerOptions);
|
44
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.mockApiSupport = mockApiSupport;
|
7
|
+
|
8
|
+
var _httpProxyMiddleware = require("http-proxy-middleware");
|
9
|
+
|
10
|
+
function mockApiSupport(app, server) {
|
11
|
+
const {
|
12
|
+
mockPrefix,
|
13
|
+
mockPort
|
14
|
+
} = server;
|
15
|
+
app.use(mockPrefix, (0, _httpProxyMiddleware.createProxyMiddleware)({
|
16
|
+
target: 'ht' + `tp://localhost:${mockPort}`,
|
17
|
+
changeOrigin: true
|
18
|
+
}));
|
19
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.webpackConfig = webpackConfig;
|
7
|
+
|
8
|
+
var _webpack = _interopRequireDefault(require("webpack"));
|
9
|
+
|
10
|
+
var _compression = _interopRequireDefault(require("compression"));
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
function webpackConfig(mode, app) {
|
15
|
+
let config;
|
16
|
+
|
17
|
+
if (mode === 'prod') {
|
18
|
+
config = require('../../../src/configs/webpack.prod.config');
|
19
|
+
app.use((0, _compression.default)());
|
20
|
+
} else if (mode === 'dev' || mode === 'dev-no-warn') {
|
21
|
+
config = require('../../../src/configs/webpack.dev.config');
|
22
|
+
} else {
|
23
|
+
throw new Error('You must configure valid option in mode');
|
24
|
+
} // console.log({ contextURL });
|
25
|
+
|
26
|
+
|
27
|
+
let compiler = (0, _webpack.default)(config);
|
28
|
+
return {
|
29
|
+
config,
|
30
|
+
compiler
|
31
|
+
};
|
32
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.websocketMockSetup = websocketMockSetup;
|
7
|
+
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
9
|
+
|
10
|
+
var _ws = _interopRequireDefault(require("ws"));
|
11
|
+
|
12
|
+
var _utils = require("../../../src/utils");
|
13
|
+
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
+
|
16
|
+
function websocketMockSetup(app, httpsServer) {
|
17
|
+
app.use('/wms/*', (req, res) => {
|
18
|
+
res.sendFile(_path.default.join(__dirname, '..', '..', 'templates', 'wms', 'index.html'));
|
19
|
+
});
|
20
|
+
const wss = new _ws.default.Server({
|
21
|
+
server: httpsServer
|
22
|
+
});
|
23
|
+
let wsPool = [];
|
24
|
+
wss.on('connection', ws => {
|
25
|
+
wsPool.push(ws);
|
26
|
+
ws.on('close', () => {
|
27
|
+
wsPool = wsPool.filter(ws1 => ws1 !== ws);
|
28
|
+
});
|
29
|
+
ws.on('message', message => {
|
30
|
+
(0, _utils.log)('received: %s', message);
|
31
|
+
});
|
32
|
+
ws.send('something');
|
33
|
+
});
|
34
|
+
app.post('/wmsmockapi', (req, res) => {
|
35
|
+
wsPool.forEach(ws => {
|
36
|
+
let {
|
37
|
+
body
|
38
|
+
} = req;
|
39
|
+
|
40
|
+
try {
|
41
|
+
ws.send(JSON.stringify(body));
|
42
|
+
} catch (e) {
|
43
|
+
(0, _utils.log)(e, body);
|
44
|
+
}
|
45
|
+
});
|
46
|
+
res.send('success');
|
47
|
+
});
|
48
|
+
}
|