@zohodesk/react-cli 0.0.1-beta.16 → 0.0.1-beta.160
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/.eslintignore +1 -0
- package/.eslintrc.js +46 -3
- package/CHANGELOG.md +5 -0
- package/README.md +650 -0
- package/bin/cli.js +134 -27
- package/cert/cert.pem +37 -129
- package/cert/key.pem +27 -27
- package/cert/passphrase.pem +1 -0
- package/files/eslintrc.js +62 -0
- package/files/prettierrc.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +16 -9
- package/lib/babel/es-plugins-presets.js +26 -14
- package/lib/common/getEntries.js +33 -24
- package/lib/common/getPublicPathConfig.js +40 -0
- package/lib/common/index.js +27 -13
- package/lib/common/splitChunks.js +64 -26
- package/lib/common/sslcertUpdater.js +59 -0
- package/lib/common/templateParameters.js +25 -0
- package/lib/configs/jest.config.js +18 -28
- package/lib/configs/webpack.component.umd.config.js +31 -37
- package/lib/configs/webpack.css.umd.config.js +44 -44
- package/lib/configs/webpack.dev.config.js +113 -57
- package/lib/configs/webpack.docs.config.js +104 -98
- package/lib/configs/webpack.impact.config.js +116 -0
- package/lib/configs/webpack.prod.config.js +154 -86
- package/lib/hooks/docsProptypeHook.js +32 -38
- package/lib/jest/commitedFilesResult.js +144 -71
- package/lib/jest/coverageCollector.js +62 -29
- package/lib/jest/jsonMaker.js +54 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
- package/lib/jest/preProcessors/jsPreprocessor.js +5 -6
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
- package/lib/jest/result.js +91 -41
- package/lib/jest/run.js +74 -27
- package/lib/jest/setup.js +103 -102
- package/lib/loaderUtils/getCSSLoaders.js +77 -0
- package/lib/loaderUtils/getDevJsLoaders.js +30 -23
- package/lib/loaderUtils/index.js +14 -7
- package/lib/loaders/docsLoader.js +15 -15
- package/lib/loaders/docsPropsLoader.js +14 -17
- package/lib/loaders/fileBountryLoader.js +17 -0
- package/lib/loaders/fileLoader.js +47 -38
- package/lib/loaders/scriptInstrumentLoader.js +21 -20
- package/lib/loaders/selectorMappingLoader.js +75 -0
- package/lib/loaders/workerLoader.js +136 -0
- package/lib/middlewares/HMRMiddleware.js +59 -41
- package/lib/middlewares/SSTMiddleware.js +21 -0
- package/lib/pluginUtils/getDevPlugins.js +173 -26
- package/lib/pluginUtils/getDocsPlugins.js +32 -17
- package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
- package/lib/pluginUtils/getLibraryPlugins.js +8 -10
- package/lib/pluginUtils/getProdPlugins.js +238 -37
- package/lib/pluginUtils/getServerPlugins.js +8 -11
- package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
- package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
- package/lib/pluginUtils/index.js +36 -43
- package/lib/plugins/CdnChangePlugin.js +77 -0
- package/lib/plugins/CleanupStatsPlugin.js +28 -0
- package/lib/plugins/EFCPlugin.js +211 -0
- package/lib/plugins/EFCPlugin.md +6 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +141 -0
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
- package/lib/plugins/I18nSplitPlugin/README.md +25 -0
- package/lib/plugins/I18nSplitPlugin/index.js +185 -0
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
- package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
- package/lib/plugins/ManifestPlugin.js +52 -63
- package/lib/plugins/ModuleStatsPlugin.js +98 -97
- package/lib/plugins/OptimizeJSPlugin.js +24 -41
- package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
- package/lib/plugins/PublicPathChangePlugin.js +187 -174
- package/lib/plugins/ReportGeneratePlugin.js +181 -0
- package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
- package/lib/plugins/ResourceHintsPlugin.js +53 -35
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +80 -0
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +82 -0
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +26 -0
- package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
- package/lib/plugins/ServiceWorkerPlugin.js +107 -0
- package/lib/plugins/ShadowDOMSupportPlugin.js +270 -0
- package/lib/plugins/SourceMapHookPlugin.js +25 -31
- package/lib/plugins/TPHashMappingPlugin.js +67 -0
- package/lib/plugins/UglifyCSSPlugin.js +23 -30
- package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
- package/lib/plugins/index.js +118 -55
- package/lib/plugins/libraryImpactPlugin.js +190 -0
- package/lib/plugins/webpackwatchrunplugin.js +26 -0
- package/lib/postcss-plugins/ExcludeRTLPlugin.js +23 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
- package/lib/schemas/index.js +463 -52
- package/lib/servers/clusterHubServer.js +22 -26
- package/lib/servers/docsServer.js +3 -5
- package/lib/servers/docsServerCore.js +93 -85
- package/lib/servers/helpServer.js +19 -21
- package/lib/servers/httpsOptions.js +19 -0
- package/lib/servers/impactServer.js +99 -92
- package/lib/servers/mockserver.js +44 -0
- package/lib/servers/nowatchserver.js +275 -0
- package/lib/servers/scrServer.js +147 -0
- package/lib/servers/server.js +118 -124
- package/lib/servers/ssServer.js +107 -65
- package/lib/sh/reportPublish.sh +16 -10
- package/lib/templates/CoverageScriptTemplate.js +45 -18
- package/lib/templates/WMSTemplate.js +17 -18
- package/lib/templates/linterConstant.js +10 -0
- package/lib/utils/babelPresets.js +12 -5
- package/lib/utils/buildstats.html +148 -0
- package/lib/utils/clean.js +12 -11
- package/lib/utils/copy.js +13 -127
- package/lib/utils/copyTimezones.js +21 -0
- package/lib/utils/createEventStream.js +24 -19
- package/lib/utils/cssClassNameGenerate.js +70 -0
- package/lib/utils/cssURLReplacer.js +67 -54
- package/lib/utils/dependencyPostPublish.js +42 -0
- package/lib/utils/fileUtils.js +125 -0
- package/lib/utils/folderIterator.js +47 -0
- package/lib/utils/getComponents.js +126 -0
- package/lib/utils/getCurrentBranch.js +11 -17
- package/lib/utils/getDependenciesImpactList.js +151 -0
- package/lib/utils/getHash.js +26 -0
- package/lib/utils/getIp.js +20 -0
- package/lib/utils/getOptions.js +55 -30
- package/lib/utils/getServerURL.js +25 -8
- package/lib/utils/index.js +259 -82
- package/lib/utils/init.js +2 -2
- package/lib/utils/initPreCommitHook.js +40 -31
- package/lib/utils/jsonHelper.js +97 -0
- package/lib/utils/libraryImpactConfig.js +63 -0
- package/lib/utils/lint/addScripts.js +27 -0
- package/lib/utils/lint/checkExistingConfig.js +67 -0
- package/lib/utils/lint/copyConfigs.js +24 -0
- package/lib/utils/lint/index.js +54 -0
- package/lib/utils/lint/lintScripts.js +11 -0
- package/lib/utils/lint/lintSetup.js +31 -0
- package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
- package/lib/utils/lint/question.js +30 -0
- package/lib/utils/lintReporter.js +142 -0
- package/lib/utils/mailSender.js +16 -25
- package/lib/utils/pullOrigin.js +28 -0
- package/lib/utils/reinstallDependencies.js +133 -0
- package/lib/utils/removeAttributes.js +25 -23
- package/lib/utils/repoClone.js +56 -63
- package/lib/utils/request.js +64 -77
- package/lib/utils/resultSchema.json +73 -0
- package/lib/utils/rtl.js +42 -0
- package/lib/utils/setEnvVariables.js +5 -6
- package/lib/utils/ssTestHack.js +48 -0
- package/lib/utils/switchBranch.js +28 -0
- package/lib/utils/urlConcat.js +22 -0
- package/package.json +92 -64
- package/templates/app/.eslintrc.js +140 -0
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -8
- package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
- package/templates/app/app/properties/i18nkeys.json +3 -3
- package/templates/app/docs/all.html +69 -69
- package/templates/app/mockapi/index.js +18 -13
- package/templates/app/package.json +37 -17
- package/templates/app/src/actions/SampleActions/index.js +37 -0
- package/templates/app/src/actions/index.js +65 -0
- package/templates/app/src/appUrls.js +19 -0
- package/templates/app/src/components/Alert/Alert.js +134 -0
- package/templates/app/src/components/Alert/Alert.module.css +79 -0
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -0
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -0
- package/templates/app/src/components/Sample/Sample.module.css +11 -0
- package/templates/app/src/components/Sample/SampleList.js +61 -0
- package/templates/app/src/components/Slider/Slider.css +41 -0
- package/templates/app/src/components/Slider/Slider.js +55 -0
- package/templates/app/src/containers/AlertContainer/index.js +15 -0
- package/templates/app/src/containers/AppContainer/index.js +96 -0
- package/templates/app/src/containers/AppContainer/index.module.css +27 -0
- package/templates/app/src/containers/CustomMatch/index.js +65 -0
- package/templates/app/src/containers/DevTools/index.js +10 -0
- package/templates/app/src/containers/Header/index.js +67 -0
- package/templates/app/src/containers/Header/index.module.css +43 -0
- package/templates/app/src/containers/Redirect/index.js +63 -0
- package/templates/app/src/containers/Redirector/index.js +47 -0
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -0
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -0
- package/templates/app/src/historyChange.js +5 -0
- package/templates/app/src/index.html +10 -0
- package/templates/app/src/index.js +24 -0
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -0
- package/templates/app/src/reducers/alertData.js +11 -0
- package/templates/app/src/reducers/index.js +6 -0
- package/templates/app/src/reducers/samples.js +19 -0
- package/templates/app/src/store/configureStore.dev.js +51 -0
- package/templates/app/src/store/configureStore.js +5 -0
- package/templates/app/src/store/configureStore.prod.js +26 -0
- package/templates/app/src/util/Common.js +5 -0
- package/templates/app/src/util/RequestAPI.js +132 -0
- package/templates/appold/README.md +12 -0
- package/templates/appold/app/index.html +8 -0
- package/templates/appold/app/properties/ApplicationResources_en_US.properties +1 -0
- package/templates/appold/app/properties/i18nkeys.json +3 -0
- package/templates/appold/docs/all.html +69 -0
- package/templates/appold/mockapi/index.js +13 -0
- package/templates/{app → appold}/mockapi/tickets.json +0 -0
- package/templates/appold/package.json +17 -0
- package/templates/appold/src/components/Text/Text.css +0 -0
- package/templates/appold/src/components/Text/Text.js +23 -0
- package/templates/appold/src/components/Text/__tests__/Text.spec.js +30 -0
- package/templates/appold/src/components/Text/docs/Text__default.docs.js +16 -0
- package/templates/appold/src/components/docs.js +1 -0
- package/templates/appold/src/components/index.js +5 -0
- package/templates/appold/src/index.js +13 -0
- package/templates/docs/all.html +1 -1
- package/templates/docs/component.html +110 -69
- package/templates/docs/components.html +221 -0
- package/templates/docs/css/component.css +12 -14
- package/templates/docs/css/componentTest.css +7 -0
- package/templates/docs/css/style.css +150 -206
- package/templates/docs/impactReportTemplate.html +154 -0
- package/templates/docs/index.html +1482 -1336
- package/templates/library/src/index.js +0 -0
package/lib/servers/server.js
CHANGED
@@ -1,140 +1,132 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
|
-
var
|
3
|
+
var _path = _interopRequireDefault(require("path"));
|
4
4
|
|
5
|
-
var
|
5
|
+
var _https = _interopRequireDefault(require("https"));
|
6
6
|
|
7
|
-
var
|
7
|
+
var _webpack = _interopRequireDefault(require("webpack"));
|
8
8
|
|
9
|
-
var
|
9
|
+
var _express = _interopRequireDefault(require("express"));
|
10
10
|
|
11
|
-
var
|
11
|
+
var _ws = _interopRequireDefault(require("ws"));
|
12
12
|
|
13
|
-
var
|
13
|
+
var _compression = _interopRequireDefault(require("compression"));
|
14
14
|
|
15
|
-
var
|
15
|
+
var _webpackDevMiddleware = _interopRequireDefault(require("webpack-dev-middleware"));
|
16
16
|
|
17
|
-
var
|
17
|
+
var _httpProxyMiddleware = require("http-proxy-middleware");
|
18
18
|
|
19
|
-
var
|
19
|
+
var _HMRMiddleware = _interopRequireDefault(require("../middlewares/HMRMiddleware"));
|
20
20
|
|
21
|
-
var
|
21
|
+
var _utils = require("../utils");
|
22
22
|
|
23
|
-
var
|
24
|
-
|
25
|
-
var _ws2 = _interopRequireDefault(_ws);
|
26
|
-
|
27
|
-
var _compression = require('compression');
|
28
|
-
|
29
|
-
var _compression2 = _interopRequireDefault(_compression);
|
30
|
-
|
31
|
-
var _webpackDevMiddleware = require('webpack-dev-middleware');
|
32
|
-
|
33
|
-
var _webpackDevMiddleware2 = _interopRequireDefault(_webpackDevMiddleware);
|
34
|
-
|
35
|
-
var _HMRMiddleware = require('../middlewares/HMRMiddleware');
|
36
|
-
|
37
|
-
var _HMRMiddleware2 = _interopRequireDefault(_HMRMiddleware);
|
38
|
-
|
39
|
-
var _utils = require('../utils');
|
23
|
+
var _httpsOptions = require("./httpsOptions");
|
40
24
|
|
41
25
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
42
26
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
27
|
+
// import fs from 'fs';
|
28
|
+
let options = (0, _utils.getOptions)();
|
29
|
+
let {
|
30
|
+
app: {
|
31
|
+
context,
|
32
|
+
server
|
33
|
+
}
|
34
|
+
} = options;
|
35
|
+
let {
|
36
|
+
host,
|
37
|
+
port,
|
38
|
+
domain,
|
39
|
+
mode,
|
40
|
+
disableContextURL,
|
41
|
+
hasMock,
|
42
|
+
mockPort
|
43
|
+
} = server;
|
44
|
+
let isCompatableHttp2 = Number(process.version.substr(1).split('.')[0]) >= 8;
|
45
|
+
let contextURL = disableContextURL ? '' : `/${context}`;
|
46
|
+
let serverUrl = (0, _utils.getServerURL)(server, 'htt' + 'ps');
|
47
|
+
const {
|
48
|
+
writeToDisk
|
49
|
+
} = options.impactService;
|
50
|
+
const app = (0, _express.default)();
|
59
51
|
|
60
|
-
|
52
|
+
if (hasMock) {
|
53
|
+
app.use(server.mockPrefix, (0, _httpProxyMiddleware.createProxyMiddleware)({
|
54
|
+
target: 'ht' + `tp://localhost:${mockPort}`,
|
55
|
+
changeOrigin: true
|
56
|
+
}));
|
57
|
+
}
|
61
58
|
|
62
|
-
app.use(
|
63
|
-
app.use(
|
59
|
+
app.use(_express.default.json());
|
60
|
+
app.use(_express.default.urlencoded({
|
64
61
|
extended: true
|
65
62
|
}));
|
63
|
+
let config;
|
66
64
|
|
67
|
-
var config = void 0;
|
68
65
|
if (mode === 'prod') {
|
69
66
|
config = require('../configs/webpack.prod.config');
|
70
|
-
app.use((0,
|
71
|
-
} else if (mode === 'dev') {
|
67
|
+
app.use((0, _compression.default)());
|
68
|
+
} else if (mode === 'dev' || mode === 'dev-no-warn') {
|
72
69
|
config = require('../configs/webpack.dev.config');
|
73
70
|
} else {
|
74
71
|
throw new Error('You must configure valid option in mode');
|
75
72
|
}
|
76
73
|
|
77
|
-
|
78
|
-
|
79
|
-
var compiler = (0, _webpack2.default)(config);
|
80
|
-
var appPath = process.cwd();
|
81
|
-
|
82
|
-
app.use((0, _webpackDevMiddleware2.default)(compiler, {
|
74
|
+
let compiler = (0, _webpack.default)(config);
|
75
|
+
let webpackServerOptions = {
|
83
76
|
logLevel: 'error',
|
84
|
-
publicPath: mode === 'prod' ? contextURL === '' ? serverUrl
|
85
|
-
headers:
|
77
|
+
publicPath: mode === 'prod' ? contextURL === '' ? `${serverUrl}/${contextURL}` : serverUrl + contextURL : config.output.publicPath,
|
78
|
+
headers: options.app.enableDevCache ? {
|
79
|
+
'Cache-Control': 'public, max-age=604800',
|
80
|
+
'Access-Control-Allow-Origin': '*'
|
81
|
+
} : {
|
82
|
+
'Access-Control-Allow-Origin': '*'
|
83
|
+
},
|
86
84
|
compress: mode === 'prod'
|
87
|
-
}
|
85
|
+
};
|
88
86
|
|
89
|
-
app.
|
87
|
+
if (options.app.disableWatch) {
|
88
|
+
webpackServerOptions.watchOptions = {
|
89
|
+
ignored: /./
|
90
|
+
};
|
91
|
+
}
|
90
92
|
|
91
|
-
if (
|
92
|
-
|
93
|
-
if (_fs2.default.existsSync(mockServerPath)) {
|
94
|
-
var mockServer = require(mockServerPath);
|
95
|
-
mockServer(app);
|
96
|
-
} else {
|
97
|
-
(0, _utils.log)('You must export a function from mockapi folder by only we can provide mock api hook');
|
98
|
-
}
|
93
|
+
if (writeToDisk) {
|
94
|
+
webpackServerOptions.writeToDisk = true;
|
99
95
|
}
|
100
96
|
|
101
|
-
app.use(
|
97
|
+
app.use((0, _webpackDevMiddleware.default)(compiler, webpackServerOptions));
|
98
|
+
app.use((0, _HMRMiddleware.default)(compiler, {
|
99
|
+
path: '/sockjs-node/info'
|
100
|
+
}));
|
101
|
+
app.use((req, res, next) => {
|
102
102
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
103
103
|
next();
|
104
|
-
}).use(contextURL
|
105
|
-
|
106
|
-
|
107
|
-
res.sendFile(_path2.default.join(__dirname, '..', '..', 'templates', 'wms', 'index.html'));
|
104
|
+
}).use(`${contextURL}/fonts`, _express.default.static(`${context}/fonts`));
|
105
|
+
app.use('/wms/*', (req, res) => {
|
106
|
+
res.sendFile(_path.default.join(__dirname, '..', '..', 'templates', 'wms', 'index.html'));
|
108
107
|
});
|
109
108
|
|
110
|
-
|
111
|
-
key: _fs2.default.readFileSync(_path2.default.join(__dirname, '../../cert/key.pem')),
|
112
|
-
cert: _fs2.default.readFileSync(_path2.default.join(__dirname, '../../cert/cert.pem')),
|
113
|
-
passphrase: 'zddqa1585f82'
|
114
|
-
}, app);
|
115
|
-
|
116
|
-
var wss = new _ws2.default.Server({ server: httpsServer });
|
117
|
-
var wsPool = [];
|
109
|
+
const httpsServer = _https.default.createServer(_httpsOptions.httpsOptions, app);
|
118
110
|
|
119
|
-
wss
|
111
|
+
const wss = new _ws.default.Server({
|
112
|
+
server: httpsServer
|
113
|
+
});
|
114
|
+
let wsPool = [];
|
115
|
+
wss.on('connection', ws => {
|
120
116
|
wsPool.push(ws);
|
121
|
-
|
122
|
-
|
123
|
-
wsPool = wsPool.filter(function (ws1) {
|
124
|
-
return ws1 !== ws;
|
125
|
-
});
|
117
|
+
ws.on('close', () => {
|
118
|
+
wsPool = wsPool.filter(ws1 => ws1 !== ws);
|
126
119
|
});
|
127
|
-
|
128
|
-
ws.on('message', function (message) {
|
120
|
+
ws.on('message', message => {
|
129
121
|
(0, _utils.log)('received: %s', message);
|
130
122
|
});
|
131
|
-
|
132
123
|
ws.send('something');
|
133
124
|
});
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
125
|
+
app.post('/wmsmockapi', (req, res) => {
|
126
|
+
wsPool.forEach(ws => {
|
127
|
+
let {
|
128
|
+
body
|
129
|
+
} = req;
|
138
130
|
|
139
131
|
try {
|
140
132
|
ws.send(JSON.stringify(body));
|
@@ -142,67 +134,69 @@ app.post('/wmsmockapi', function (req, res) {
|
|
142
134
|
(0, _utils.log)(e, body);
|
143
135
|
}
|
144
136
|
});
|
145
|
-
|
146
137
|
res.send('success');
|
147
138
|
});
|
139
|
+
let webpackCompilation;
|
140
|
+
compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
|
141
|
+
webpackCompilation = compilation;
|
142
|
+
});
|
148
143
|
|
149
144
|
if (contextURL) {
|
150
|
-
app.use(contextURL,
|
151
|
-
app.use(contextURL
|
145
|
+
app.use(contextURL, _express.default.static(context));
|
146
|
+
app.use(`${contextURL}/*`, (req, res) => {
|
147
|
+
let indexHtml = webpackCompilation.assets['index.html'];
|
148
|
+
res.send(indexHtml && indexHtml.source());
|
149
|
+
});
|
152
150
|
} else {
|
153
|
-
app.use(
|
154
|
-
app.use('/*',
|
151
|
+
app.use(_express.default.static(context));
|
152
|
+
app.use('/*', _express.default.static(context));
|
155
153
|
}
|
156
154
|
|
157
|
-
httpsServer.listen(port,
|
155
|
+
httpsServer.listen(port, err => {
|
158
156
|
if (err) {
|
159
157
|
throw err;
|
160
158
|
}
|
161
|
-
|
159
|
+
|
160
|
+
(0, _utils.log)(`Listening at ${serverUrl}${contextURL}/`);
|
162
161
|
});
|
163
162
|
|
164
163
|
if (isCompatableHttp2) {
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
cert: _fs2.default.readFileSync(_path2.default.join(__dirname, '../../cert/cert.pem')),
|
169
|
-
passphrase: 'zddqa1585f82'
|
170
|
-
});
|
164
|
+
const http2 = require('http2');
|
165
|
+
|
166
|
+
const http2Server = http2.createSecureServer(_httpsOptions.httpsOptions); // eslint-disable-next-line no-unused-vars
|
171
167
|
|
172
|
-
|
173
|
-
http2Server.on('stream', function (stream, headers) {
|
168
|
+
http2Server.on('stream', (stream, headers) => {
|
174
169
|
stream.respond({
|
175
170
|
'content-type': 'text/html',
|
176
171
|
':status': 200
|
177
172
|
});
|
178
173
|
stream.end('<h1>Hello World! <br>Working with http2</h1>');
|
179
174
|
});
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
http2Server.listen(http2Port, function (err) {
|
175
|
+
let http2Port = Number(port) + 1;
|
176
|
+
http2Server.listen(http2Port, err => {
|
184
177
|
if (err) {
|
185
178
|
throw err;
|
186
179
|
}
|
187
|
-
|
188
|
-
|
189
|
-
|
180
|
+
|
181
|
+
(0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
|
182
|
+
host,
|
183
|
+
domain,
|
190
184
|
port: http2Port
|
191
|
-
}, 'htt' + 'ps')
|
185
|
+
}, 'htt' + 'ps')}${contextURL}/`, 'http2 server');
|
192
186
|
});
|
193
187
|
} else {
|
194
188
|
(0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
|
195
189
|
}
|
196
190
|
|
197
|
-
|
198
|
-
|
199
|
-
app.listen(httpPort, function (err) {
|
191
|
+
let httpPort = Number(port) + (isCompatableHttp2 ? 2 : 1);
|
192
|
+
app.listen(httpPort, err => {
|
200
193
|
if (err) {
|
201
194
|
throw err;
|
202
195
|
}
|
203
|
-
|
204
|
-
|
205
|
-
|
196
|
+
|
197
|
+
(0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
|
198
|
+
host,
|
199
|
+
domain,
|
206
200
|
port: httpPort
|
207
|
-
}, 'ht' + 'tp')
|
201
|
+
}, 'ht' + 'tp')}${contextURL}/`);
|
208
202
|
});
|
package/lib/servers/ssServer.js
CHANGED
@@ -1,81 +1,123 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
|
-
var
|
3
|
+
var _screenshotTest = _interopRequireDefault(require("@zohodesk/screenshot-test"));
|
4
4
|
|
5
|
-
var
|
5
|
+
var _jsonHelper = require("../utils/jsonHelper");
|
6
6
|
|
7
|
-
var
|
7
|
+
var _utils = require("../utils");
|
8
8
|
|
9
|
-
var
|
9
|
+
var _docsServerCore = _interopRequireDefault(require("./docsServerCore"));
|
10
10
|
|
11
|
-
var
|
12
|
-
|
13
|
-
var _docsServerCore2 = _interopRequireDefault(_docsServerCore);
|
11
|
+
var _SSTMiddleware = _interopRequireDefault(require("../middlewares/SSTMiddleware"));
|
14
12
|
|
15
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
let options = (0, _utils.getOptions)();
|
16
|
+
let impactedComponentObject = null;
|
17
|
+
let docsServerInstance;
|
18
|
+
let {
|
19
|
+
ssTest: {
|
20
|
+
seleniumHub,
|
21
|
+
referBranch,
|
22
|
+
currentBranch,
|
23
|
+
enableImage,
|
24
|
+
pathToSubProjects
|
25
|
+
},
|
26
|
+
docs: {
|
27
|
+
server
|
28
|
+
}
|
29
|
+
} = options;
|
30
|
+
|
31
|
+
function closeServer(serverInstance) {
|
32
|
+
(0, _utils.log)('Docs service stopped!');
|
33
|
+
let {
|
34
|
+
http,
|
35
|
+
https,
|
36
|
+
wdm
|
37
|
+
} = serverInstance;
|
38
|
+
http.close();
|
39
|
+
https.close();
|
40
|
+
wdm.close();
|
41
|
+
}
|
23
42
|
|
43
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.compareBranch', referBranch);
|
44
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.TestBranch', currentBranch);
|
45
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.isExecuted', true);
|
46
|
+
(0, _utils.log)('Test Branch Name :- ', currentBranch);
|
47
|
+
|
48
|
+
let afterFirstScreenShotCollected = () => {
|
49
|
+
closeServer(docsServerInstance);
|
50
|
+
(0, _utils.switchBranch)('git', referBranch).then(() => {
|
51
|
+
(0, _utils.log)('Reference Branch Name :- ', (0, _utils.getCurrentBranch)());
|
52
|
+
(0, _utils.reinstallDependencies)(pathToSubProjects).then(() => {
|
53
|
+
(0, _utils.ssTestHack)();
|
54
|
+
});
|
55
|
+
});
|
56
|
+
};
|
24
57
|
|
25
|
-
|
58
|
+
let onSStestEnd = (status, resultObject, isLastRun, runSSTest) => {
|
59
|
+
if (status) {
|
60
|
+
if (!isLastRun) {
|
61
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.result', resultObject);
|
62
|
+
runSSTest(afterFirstScreenShotCollected, true, 'reference', referBranch, impactedComponentObject);
|
63
|
+
} else {
|
64
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.endTime', Date.now());
|
65
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.isPassed', true);
|
66
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.result', resultObject);
|
67
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.message', 'Screenshot test succesfully completed.');
|
68
|
+
(0, _jsonHelper.setTestInfoStatus)(`${process.cwd()}/result.json`, true);
|
69
|
+
(0, _utils.log)('Screenshot test completed succesfully.');
|
70
|
+
closeServer(docsServerInstance);
|
71
|
+
}
|
72
|
+
} else {
|
73
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.isPassed', false);
|
74
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.message', 'Component list undefined! Please check component Docs');
|
75
|
+
(0, _jsonHelper.setTestInfoStatus)(`${process.cwd()}/result.json`, false);
|
76
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'testInfo.failures', {
|
77
|
+
type: 'screenshotTest',
|
78
|
+
message: 'Component list undefined! Please check component Docs'
|
79
|
+
});
|
80
|
+
closeServer(docsServerInstance);
|
81
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.endTime', Date.now());
|
82
|
+
throw new Error('Component list undefined! Please check component Docs');
|
83
|
+
}
|
84
|
+
};
|
26
85
|
|
27
|
-
(0, _utils.
|
86
|
+
(0, _utils.ssTestHack)();
|
28
87
|
|
29
|
-
|
30
|
-
|
31
|
-
|
88
|
+
let getDocsServerInstance = beforeJobs => {
|
89
|
+
if (typeof beforeJobs === 'function') {
|
90
|
+
beforeJobs();
|
91
|
+
}
|
32
92
|
|
33
|
-
|
34
|
-
(0, _child_process.spawnSync)('git', ['pull', 'origin', remoteBranch], {
|
35
|
-
stdio: 'inherit'
|
36
|
-
});
|
37
|
-
}
|
38
|
-
res.send('done');
|
39
|
-
});
|
40
|
-
}
|
41
|
-
|
42
|
-
var afterFirstScreenShotCollected = function afterFirstScreenShotCollected() {
|
43
|
-
(0, _child_process.spawnSync)('git', ['checkout', referBranch], { encoding: 'utf8' });
|
44
|
-
(0, _utils.log)((0, _utils.getCurrentBranch)(), 'Reference Branch');
|
93
|
+
return (0, _docsServerCore.default)(true);
|
45
94
|
};
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
} else {
|
69
|
-
var _http = docsServerInstance.http,
|
70
|
-
_https = docsServerInstance.https,
|
71
|
-
_wdm = docsServerInstance.wdm;
|
72
|
-
|
73
|
-
_http.close();
|
74
|
-
_https.close();
|
75
|
-
_wdm.close();
|
76
|
-
throw new Error('Component list undefined! Please check component Docs');
|
77
|
-
}
|
78
|
-
});
|
95
|
+
|
96
|
+
let runSSTest = (onBefore, isLastRun, mode, branch, listOfComponents) => {
|
97
|
+
let url = (0, _utils.getServerURL)(Object.assign(server, {
|
98
|
+
host: server.iphost
|
99
|
+
}), 'ht' + 'tp');
|
100
|
+
docsServerInstance = getDocsServerInstance(onBefore);
|
101
|
+
docsServerInstance.app.use((0, _SSTMiddleware.default)(docsServerInstance.compiler, mData => {
|
102
|
+
impactedComponentObject = (0, _utils.getComponents)(mData, listOfComponents);
|
103
|
+
|
104
|
+
_screenshotTest.default.run({
|
105
|
+
branch,
|
106
|
+
seleniumHub: seleniumHub,
|
107
|
+
url: `${url}/docs/components.html`,
|
108
|
+
browserList: ['chrome'],
|
109
|
+
mode,
|
110
|
+
enableImage,
|
111
|
+
impactedComponentObject,
|
112
|
+
script: 'var Objlist = {};for (i in Component) {try { if (Component[i].prototype.isReactComponent) Objlist[i] = Component[i].docs.componentGroup;}catch (err) {console.log(i, err);}};if (Object.keys(Objlist).length < 5) {Objlist = false;}return Objlist;'
|
113
|
+
}, (status, finalObj) => {
|
114
|
+
onSStestEnd(status, finalObj, isLastRun, runSSTest);
|
115
|
+
});
|
116
|
+
}));
|
79
117
|
};
|
80
118
|
|
81
|
-
|
119
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.startTime', Date.now());
|
120
|
+
(0, _utils.getDependenciesImpactList)(currentBranch, referBranch).then(impactedList => {
|
121
|
+
(0, _utils.log)('from here ');
|
122
|
+
runSSTest(null, null, 'test', currentBranch, impactedList);
|
123
|
+
});
|
package/lib/sh/reportPublish.sh
CHANGED
@@ -2,13 +2,12 @@
|
|
2
2
|
branchName=$2
|
3
3
|
url=$1
|
4
4
|
zipUrl=$3
|
5
|
-
commitMessage=$8
|
6
|
-
|
7
5
|
unique=$(date +"%d_%m_%y_Time_%H_%M_%S")
|
8
6
|
publishFolder=$branchName"_"$unique
|
9
7
|
|
10
8
|
rm -rf ./reports
|
11
9
|
rm -rf ./scrTemplate
|
10
|
+
rm -rf ./errTemplate
|
12
11
|
rm -rf ./css
|
13
12
|
rm -rf ./js
|
14
13
|
rm -rf ./index.html
|
@@ -18,13 +17,20 @@ curl $zipUrl | tar xz
|
|
18
17
|
cp -rf ./reports/css ./css
|
19
18
|
cp -rf ./reports/js ./js
|
20
19
|
cp -rf ./reports/index.html ./index.html
|
20
|
+
if [ -d "./screenShots" ] ; then
|
21
|
+
cp -rf ./scrTemplate/* ./screenShots/
|
22
|
+
else
|
23
|
+
mkdir ./screenShots
|
24
|
+
cp -rf ./scrTemplate/* ./screenShots/
|
25
|
+
fi
|
21
26
|
|
22
|
-
cp -rf ./
|
23
|
-
cp -rf ./
|
24
|
-
cp -rf ./
|
25
|
-
cp -rf ./
|
27
|
+
[ ! -f "./result.json" ] && touch result.json && cp -rf ./errTemplate/* ./result.json
|
28
|
+
[ ! -d "./commitCoverage" ] && mkdir commitCoverage && cp -rf ./errTemplate/* ./commitCoverage/
|
29
|
+
[ ! -d "./unittest" ] && mkdir unittest && cp -rf ./errTemplate/* ./unittest/
|
30
|
+
[ ! -d "./coverageTest" ] && mkdir coverageTest && cp -rf ./errTemplate/* ./coverageTest/
|
31
|
+
[ ! -d "./coverage" ] && mkdir coverage && cp -rf ./errTemplate/* ./coverage/
|
26
32
|
|
27
|
-
tar -czvf $publishFolder.tar.gz coverage screenShots unittest coverageTest commitCoverage ./css ./js ./index.html
|
33
|
+
tar -czvf $publishFolder.tar.gz coverage screenShots unittest coverageTest commitCoverage ./css ./js ./index.html ./result.json
|
28
34
|
|
29
35
|
curl -i -F name=file -F file=@$publishFolder.tar.gz $url"/cgi-bin/upload.py"
|
30
36
|
replace=$publishFolder
|
@@ -33,7 +39,7 @@ subject="Client Report - React - $publishFolder"
|
|
33
39
|
msg="<p><b>Report URL - <a href='$reportUrl'>Link</a></b></p>
|
34
40
|
<p><b>Report Branchname - $branchName</b></p>
|
35
41
|
<p><b>Report Unique ID - $unique</b></p>
|
36
|
-
<p><b>Report Developer - $6</b></p>
|
37
|
-
<p><b>Report commitMessage - $commitMessage</b></p>"
|
42
|
+
<p><b>Report Developer - $6</b></p>"
|
38
43
|
#node mailSender.js <from> <pass> <to> <subject> <text>
|
39
|
-
|
44
|
+
BASEDIR=$(dirname "$0")
|
45
|
+
node $BASEDIR"/../utils/mailSender" $4 $5 $6 "$subject" "$msg" $7 $8 "$reportUrl"
|
@@ -1,44 +1,71 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
window.ClientCoverage = {
|
4
4
|
LocalStorageWrapper: {
|
5
|
-
getLocalStorage
|
5
|
+
getLocalStorage(property, defaultVal) {
|
6
6
|
if (localStorage.hasOwnProperty(property)) {
|
7
7
|
Object.assign(defaultVal, JSON.parse(localStorage.getItem(property)));
|
8
|
-
localStorage.setItem(property, JSON.stringify(defaultVal));
|
8
|
+
localStorage.setItem(property, JSON.stringify(defaultVal));
|
9
|
+
return defaultVal;
|
9
10
|
}
|
10
|
-
|
11
|
+
|
12
|
+
localStorage.setItem(property, JSON.stringify(defaultVal));
|
13
|
+
return defaultVal || {};
|
11
14
|
},
|
12
|
-
|
15
|
+
|
16
|
+
clearLocalStorage(property) {
|
13
17
|
localStorage.removeItem(property);
|
14
18
|
}
|
15
|
-
|
16
|
-
|
19
|
+
|
20
|
+
},
|
21
|
+
JS: {
|
22
|
+
jsMethodInstrumentObject: {},
|
23
|
+
jsStorageKey: 'jsClientCoverageObject',
|
24
|
+
|
25
|
+
init() {
|
17
26
|
this.jsMethodInstrumentObject = ClientCoverage.LocalStorageWrapper.getLocalStorage(this.jsStorageKey, this.jsMethodInstrumentObject);
|
18
27
|
},
|
19
|
-
|
20
|
-
|
28
|
+
|
29
|
+
visitMethod(jsFileName, jsMethodName) {
|
30
|
+
this.init();
|
31
|
+
|
32
|
+
if (this.jsMethodInstrumentObject.hasOwnProperty(jsFileName)) {
|
21
33
|
if (!this.jsMethodInstrumentObject[jsFileName].includes(jsMethodName)) {
|
22
34
|
this.jsMethodInstrumentObject[jsFileName].push(jsMethodName);
|
23
35
|
}
|
24
36
|
} else {
|
25
|
-
this.jsMethodInstrumentObject[jsFileName] = [];
|
37
|
+
this.jsMethodInstrumentObject[jsFileName] = [];
|
38
|
+
this.jsMethodInstrumentObject[jsFileName].push(jsMethodName);
|
26
39
|
}
|
40
|
+
|
27
41
|
localStorage.setItem(this.jsStorageKey, JSON.stringify(this.jsMethodInstrumentObject));
|
28
42
|
},
|
29
|
-
|
30
|
-
|
43
|
+
|
44
|
+
clear() {
|
45
|
+
this.jsMethodInstrumentObject = {};
|
46
|
+
ClientCoverage.LocalStorageWrapper.clearLocalStorage(this.jsStorageKey);
|
31
47
|
},
|
32
|
-
|
33
|
-
|
48
|
+
|
49
|
+
getData() {
|
50
|
+
return {
|
51
|
+
methods: this.jsMethodInstrumentObject
|
52
|
+
};
|
34
53
|
}
|
35
|
-
|
36
|
-
|
54
|
+
|
55
|
+
},
|
56
|
+
|
57
|
+
getCoverageData() {
|
58
|
+
return {
|
59
|
+
JS: this.JS.getData()
|
60
|
+
};
|
37
61
|
},
|
38
|
-
|
62
|
+
|
63
|
+
clear() {
|
39
64
|
this.JS.clear();
|
40
65
|
},
|
41
|
-
|
66
|
+
|
67
|
+
init() {
|
42
68
|
this.JS.init();
|
43
69
|
}
|
70
|
+
|
44
71
|
};
|