@zohodesk/react-cli 0.0.1-beta.17 → 0.0.1-beta.171
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 +49 -10
- package/.prettierrc +6 -0
- package/CHANGELOG.md +5 -0
- package/README.md +859 -0
- package/bin/cli.js +215 -46
- package/cert/Tsicsezwild-22-23.crt +37 -0
- package/cert/Tsicsezwild-22-23.key +27 -0
- package/docs/CustomChunks.md +26 -0
- package/docs/DevStart.md +18 -0
- package/docs/HoverActive.md +12 -0
- package/docs/InstallNode.md +28 -0
- package/docs/TODOS.md +10 -0
- package/docs/ValueReplacer.md +60 -0
- package/docs/warnings_while_install.txt +35 -0
- package/files/eslintrc.js +62 -0
- package/files/prettierrc.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +24 -0
- package/lib/babel/es-plugins-presets.js +34 -0
- package/lib/common/getEntries.js +33 -46
- package/lib/common/getPublicPathConfig.js +40 -0
- package/lib/common/index.js +24 -19
- package/lib/common/splitChunks.js +110 -25
- package/lib/common/sslcertUpdater.js +59 -0
- package/lib/common/templateParameters.js +25 -0
- package/lib/common/testPattern.js +69 -0
- package/lib/common/valueReplacer.js +55 -0
- package/lib/configs/jest.config.js +31 -27
- package/lib/configs/libAlias.js +31 -0
- package/lib/configs/webpack.component.umd.config.js +46 -53
- package/lib/configs/webpack.css.umd.config.js +47 -46
- package/lib/configs/webpack.dev.config.js +99 -84
- package/lib/configs/webpack.docs.config.js +65 -57
- package/lib/configs/webpack.impact.config.js +109 -0
- package/lib/configs/webpack.prod.config.js +147 -104
- package/lib/hooks/docsProptypeHook.js +32 -38
- package/lib/jest/commitedFilesResult.js +144 -71
- package/lib/jest/coverageCollector.js +68 -35
- 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 +92 -42
- package/lib/jest/run.js +75 -28
- package/lib/jest/setup.js +103 -102
- package/lib/loaderUtils/configsAssetsLoaders.js +117 -0
- package/lib/loaderUtils/getCSSLoaders.js +113 -0
- package/lib/loaderUtils/getDevJsLoaders.js +35 -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 +23 -20
- package/lib/loaders/selectorMappingLoader.js +75 -0
- package/lib/loaders/workerLoader.js +136 -0
- package/lib/middlewares/HMRMiddleware.js +90 -72
- package/lib/middlewares/SSTMiddleware.js +21 -0
- package/lib/pluginUtils/getDevPlugins.js +177 -30
- package/lib/pluginUtils/getDocsPlugins.js +36 -15
- package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
- package/lib/pluginUtils/getLibraryPlugins.js +8 -10
- package/lib/pluginUtils/getProdPlugins.js +244 -37
- package/lib/pluginUtils/getServerPlugins.js +8 -11
- package/lib/pluginUtils/getUMDCSSPlugins.js +14 -18
- package/lib/pluginUtils/getUMDComponentPlugins.js +14 -9
- 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 +241 -0
- package/lib/plugins/EFCPlugin.md +6 -0
- package/lib/plugins/EFCTemplatePlugin.js +151 -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 +95 -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 +86 -0
- package/lib/plugins/ModuleStatsPlugin.js +98 -97
- package/lib/plugins/OptimizeJSPlugin.js +41 -0
- package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
- package/lib/plugins/PublicPathChangePlugin.js +226 -0
- package/lib/plugins/ReportGeneratePlugin.js +181 -0
- package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
- package/lib/plugins/ResourceHintsPlugin.js +67 -0
- 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 -59
- package/lib/plugins/TPHashMappingPlugin.js +67 -0
- package/lib/plugins/UglifyCSSPlugin.js +39 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
- package/lib/plugins/index.js +127 -37
- package/lib/plugins/libraryImpactPlugin.js +190 -0
- package/lib/plugins/webpackwatchrunplugin.js +26 -0
- package/lib/postcss-plugins/ExcludePlugin.js +23 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
- package/lib/postcss-plugins/ValueReplacer.js +46 -0
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +22 -0
- package/lib/postcss-plugins/__test__/test1Input.css +39 -0
- package/lib/postcss-plugins/__test__/test1Output.css +39 -0
- package/lib/postcss-plugins/hoverActivePlugin.js +368 -0
- package/lib/postcss-plugins/variableModifier.js +243 -0
- package/lib/schemas/index.js +541 -65
- package/lib/servers/clusterHubServer.js +22 -26
- package/lib/servers/devBuild.js +102 -0
- package/lib/servers/docsServer.js +3 -5
- package/lib/servers/docsServerCore.js +94 -79
- package/lib/servers/getCliPath.js +28 -0
- package/lib/servers/helpServer.js +19 -21
- package/lib/servers/httpsOptions.js +18 -0
- package/lib/servers/impactServer.js +123 -115
- package/lib/servers/mockserver.js +44 -0
- package/lib/servers/nowatchserver.js +200 -0
- package/lib/servers/scrServer.js +147 -0
- package/lib/servers/server.js +134 -132
- package/lib/servers/ssServer.js +106 -70
- 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 -4
- package/lib/utils/buildstats.html +148 -0
- package/lib/utils/clean.js +12 -11
- package/lib/utils/copy.js +16 -109
- package/lib/utils/copyTimezones.js +21 -0
- package/lib/utils/createEventStream.js +24 -19
- package/lib/utils/cssClassNameGenerate.js +77 -0
- package/lib/utils/cssURLReplacer.js +136 -0
- 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 +113 -28
- package/lib/utils/getServerURL.js +25 -8
- package/lib/utils/index.js +283 -68
- package/lib/utils/init.js +2 -2
- package/lib/utils/initPreCommitHook.js +47 -27
- package/lib/utils/jsonHelper.js +106 -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 +59 -63
- package/lib/utils/request.js +64 -77
- package/lib/utils/resultSchema.json +73 -0
- package/lib/utils/rtl.js +59 -0
- package/lib/utils/setEnvVariables.js +13 -0
- package/lib/utils/ssTestHack.js +48 -0
- package/lib/utils/switchBranch.js +28 -0
- package/lib/utils/urlConcat.js +22 -0
- package/lib/utils/useExitCleanup.js +55 -0
- package/npm8.md +9 -0
- package/package.json +96 -64
- package/postpublish.js +6 -0
- 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/.npmignore +0 -3
- package/cert/cert.pem +0 -129
- package/cert/key.pem +0 -27
- package/lib/common/getInsertAt.js +0 -36
- package/lib/common/getInsertIntoFunction.js +0 -13
- package/lib/configs/webpack.server.config.js +0 -93
- package/lib/plugins/ChunkManifestReplacePlugin.js +0 -94
- package/lib/plugins/RuntimePublicPathPlugin.js +0 -46
- package/lib/rmcntrlm.sh +0 -14
- package/lib/servers/nodeServer.js +0 -238
- package/lib/templates/HMRTemplate.js +0 -256
- package/lib/templates/publicPathTemplate.js +0 -16
- package/lib/utils/setConfig.js +0 -14
- package/node_modules/history/CHANGES.md +0 -395
- package/node_modules/history/DOMUtils.js +0 -3
- package/node_modules/history/ExecutionEnvironment.js +0 -3
- package/node_modules/history/LICENSE +0 -21
- package/node_modules/history/LocationUtils.js +0 -3
- package/node_modules/history/PathUtils.js +0 -3
- package/node_modules/history/README.md +0 -282
- package/node_modules/history/cjs/history.js +0 -933
- package/node_modules/history/cjs/history.min.js +0 -1
- package/node_modules/history/createBrowserHistory.js +0 -3
- package/node_modules/history/createHashHistory.js +0 -3
- package/node_modules/history/createMemoryHistory.js +0 -3
- package/node_modules/history/createTransitionManager.js +0 -3
- package/node_modules/history/es/DOMUtils.js +0 -7
- package/node_modules/history/es/ExecutionEnvironment.js +0 -7
- package/node_modules/history/es/LocationUtils.js +0 -7
- package/node_modules/history/es/PathUtils.js +0 -7
- package/node_modules/history/es/createBrowserHistory.js +0 -7
- package/node_modules/history/es/createHashHistory.js +0 -7
- package/node_modules/history/es/createMemoryHistory.js +0 -7
- package/node_modules/history/es/createTransitionManager.js +0 -7
- package/node_modules/history/es/warnAboutDeprecatedESMImport.js +0 -35
- package/node_modules/history/esm/history.js +0 -904
- package/node_modules/history/index.js +0 -7
- package/node_modules/history/package.json +0 -134
- package/node_modules/history/umd/history.js +0 -1059
- package/node_modules/history/umd/history.min.js +0 -1
- package/node_modules/history/warnAboutDeprecatedCJSRequire.js +0 -35
- package/templates/app/.npmignore +0 -9
- package/templates/library/.npmignore +0 -9
@@ -0,0 +1,147 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _screenshotTest = _interopRequireDefault(require("@zohodesk/screenshot-test"));
|
4
|
+
|
5
|
+
var _jsonHelper = require("../utils/jsonHelper");
|
6
|
+
|
7
|
+
var _child_process = require("child_process");
|
8
|
+
|
9
|
+
var _utils = require("../utils");
|
10
|
+
|
11
|
+
var _docsServerCore = _interopRequireDefault(require("./docsServerCore"));
|
12
|
+
|
13
|
+
var _SSTMiddleware = _interopRequireDefault(require("../middlewares/SSTMiddleware"));
|
14
|
+
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
|
+
|
17
|
+
//Getting variables from flag and exe
|
18
|
+
let cwd = process.cwd();
|
19
|
+
let options = (0, _utils.getOptions)();
|
20
|
+
let {
|
21
|
+
ssTest: {
|
22
|
+
seleniumHub,
|
23
|
+
referBranch,
|
24
|
+
currentBranch,
|
25
|
+
enableImage,
|
26
|
+
pathToSubProjects,
|
27
|
+
isImpactRun,
|
28
|
+
isStore,
|
29
|
+
dbURL,
|
30
|
+
tableName,
|
31
|
+
serviceName,
|
32
|
+
tokenGit
|
33
|
+
},
|
34
|
+
docs: {
|
35
|
+
server
|
36
|
+
}
|
37
|
+
} = options;
|
38
|
+
let resultFileName = `${cwd}/result.json`;
|
39
|
+
let docsServerInstance; // let impactedComponentList = null;
|
40
|
+
|
41
|
+
let url = (0, _utils.getServerURL)(Object.assign(server, {
|
42
|
+
host: server.iphost
|
43
|
+
}), 'ht' + 'tp');
|
44
|
+
let commitID = (0, _child_process.execSync)('git log --first-parent --pretty="format:%H" --max-count 2', {
|
45
|
+
cwd: cwd
|
46
|
+
}).toString() || '';
|
47
|
+
let [latestCommitHash, lastCommitHash] = commitID.split('\n');
|
48
|
+
let script = 'var Objlist = {};for (i in componentList) {try { if (componentList[i].prototype.isReactComponent) Objlist[i] = componentList[i].docs.componentGroup;}catch (err) {console.log(i, err);}};if (Object.keys(Objlist).length < 5) {Objlist = false;}return Objlist;'; // Variable getting part end //
|
49
|
+
|
50
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.compareBranch', referBranch);
|
51
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.TestBranch', currentBranch);
|
52
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.isExecuted', true);
|
53
|
+
(0, _utils.log)('Test Branch Name :- ', currentBranch); // function declaration part //
|
54
|
+
|
55
|
+
let closeServer = serverInstance => {
|
56
|
+
(0, _utils.log)('Docs service stopped!');
|
57
|
+
let {
|
58
|
+
http,
|
59
|
+
https,
|
60
|
+
wdm
|
61
|
+
} = serverInstance;
|
62
|
+
http.close();
|
63
|
+
https.close();
|
64
|
+
wdm.close();
|
65
|
+
}; //eslint-disable-next-line
|
66
|
+
|
67
|
+
|
68
|
+
let afterFirstScreenShotCollected = () => {
|
69
|
+
closeServer(docsServerInstance);
|
70
|
+
(0, _utils.switchBranch)('git', referBranch).then(() => {
|
71
|
+
(0, _utils.log)('Reference Branch Name :- ', (0, _utils.getCurrentBranch)());
|
72
|
+
(0, _utils.reinstallDependencies)(pathToSubProjects).then(() => {
|
73
|
+
(0, _utils.ssTestHack)();
|
74
|
+
});
|
75
|
+
});
|
76
|
+
};
|
77
|
+
|
78
|
+
let onSStestEnd = (status, resultObject, message) => {
|
79
|
+
if (status) {
|
80
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.endTime', Date.now());
|
81
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.isPassed', true);
|
82
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.result', resultObject);
|
83
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.message', message);
|
84
|
+
(0, _jsonHelper.setTestInfoStatus)(resultFileName, true);
|
85
|
+
(0, _utils.log)(message); //'Screenshot test completed successfully.'
|
86
|
+
|
87
|
+
closeServer(docsServerInstance);
|
88
|
+
} else {
|
89
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.isPassed', false);
|
90
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.message', message);
|
91
|
+
(0, _jsonHelper.setTestInfoStatus)(resultFileName, false);
|
92
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'testInfo.failures', {
|
93
|
+
type: 'screenshotTest',
|
94
|
+
message
|
95
|
+
});
|
96
|
+
closeServer(docsServerInstance);
|
97
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.endTime', Date.now());
|
98
|
+
throw new Error('Component list undefined! Please check component Docs');
|
99
|
+
}
|
100
|
+
};
|
101
|
+
|
102
|
+
let run = (listOfComponents = [], configObject) => {
|
103
|
+
docsServerInstance = (0, _docsServerCore.default)(true);
|
104
|
+
docsServerInstance.app.use((0, _SSTMiddleware.default)(docsServerInstance.compiler, mData => {
|
105
|
+
if (isImpactRun) {
|
106
|
+
let finalResultObject = (0, _utils.getComponents)(mData, listOfComponents);
|
107
|
+
configObject.impactedComponentList = finalResultObject.impactedComponentList;
|
108
|
+
configObject.unDocsComList = finalResultObject.unDocsComList;
|
109
|
+
}
|
110
|
+
|
111
|
+
_screenshotTest.default.run(configObject, (status, finalObj, message) => {
|
112
|
+
onSStestEnd(status, finalObj, message);
|
113
|
+
});
|
114
|
+
}));
|
115
|
+
};
|
116
|
+
|
117
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.startTime', Date.now());
|
118
|
+
(0, _utils.ssTestHack)();
|
119
|
+
let scrObject = {
|
120
|
+
currentBranch,
|
121
|
+
referBranch,
|
122
|
+
latestCommitHash,
|
123
|
+
lastCommitHash,
|
124
|
+
seleniumHub,
|
125
|
+
url: `${url}/docs/components.html`,
|
126
|
+
browser: 'chrome',
|
127
|
+
enableImage,
|
128
|
+
dbURL,
|
129
|
+
isImpactRun,
|
130
|
+
isStore,
|
131
|
+
script,
|
132
|
+
tableName
|
133
|
+
};
|
134
|
+
|
135
|
+
if (isImpactRun) {
|
136
|
+
if (!isStore) {
|
137
|
+
(0, _utils.getDependenciesImpactList)(currentBranch, referBranch, tokenGit, serviceName).then(impactedList => {
|
138
|
+
run(impactedList, scrObject);
|
139
|
+
});
|
140
|
+
} else {
|
141
|
+
(0, _utils.getDependenciesImpactList)(latestCommitHash, lastCommitHash, tokenGit, serviceName).then(impactedList => {
|
142
|
+
run(impactedList, scrObject);
|
143
|
+
});
|
144
|
+
}
|
145
|
+
} else {
|
146
|
+
run([], scrObject);
|
147
|
+
}
|
package/lib/servers/server.js
CHANGED
@@ -1,147 +1,140 @@
|
|
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
|
-
// import
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
context
|
48
|
-
server
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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)();
|
62
51
|
|
63
|
-
|
52
|
+
if (hasMock) {
|
53
|
+
app.use(server.mockPrefix, (0, _httpProxyMiddleware.createProxyMiddleware)({
|
54
|
+
target: 'ht' + `tp://localhost:${mockPort}`,
|
55
|
+
changeOrigin: true
|
56
|
+
}));
|
57
|
+
}
|
64
58
|
|
65
|
-
app.use(
|
66
|
-
app.use(
|
59
|
+
app.use(_express.default.json());
|
60
|
+
app.use(_express.default.urlencoded({
|
67
61
|
extended: true
|
68
62
|
}));
|
63
|
+
let config;
|
69
64
|
|
70
|
-
var config = void 0;
|
71
65
|
if (mode === 'prod') {
|
72
|
-
process.isDevelopment = true;
|
73
66
|
config = require('../configs/webpack.prod.config');
|
74
|
-
app.use((0,
|
75
|
-
} else if (
|
76
|
-
process.isDevelopment = true;
|
67
|
+
app.use((0, _compression.default)());
|
68
|
+
} else if (mode === 'dev' || mode === 'dev-no-warn') {
|
77
69
|
config = require('../configs/webpack.dev.config');
|
78
70
|
} else {
|
79
71
|
throw new Error('You must configure valid option in mode');
|
80
|
-
}
|
72
|
+
} // console.log({ contextURL });
|
81
73
|
|
82
|
-
var compiler = (0, _webpack2.default)(config);
|
83
|
-
var appPath = process.cwd();
|
84
74
|
|
85
|
-
|
75
|
+
let compiler = (0, _webpack.default)(config);
|
76
|
+
let webpackServerOptions = {
|
86
77
|
logLevel: 'error',
|
87
|
-
publicPath: mode === 'prod' ? contextURL === '' ? serverUrl
|
88
|
-
headers:
|
78
|
+
publicPath: mode === 'prod' ? contextURL === '' ? `${serverUrl}/${contextURL}` : serverUrl + contextURL : config.output.publicPath,
|
79
|
+
headers: options.app.enableDevCache ? {
|
80
|
+
'Cache-Control': 'public, max-age=604800',
|
81
|
+
'Access-Control-Allow-Origin': '*'
|
82
|
+
} : {
|
83
|
+
'Access-Control-Allow-Origin': '*'
|
84
|
+
},
|
89
85
|
compress: mode === 'prod'
|
90
|
-
}
|
86
|
+
};
|
91
87
|
|
92
|
-
if (
|
93
|
-
|
88
|
+
if (options.app.disableWatch) {
|
89
|
+
webpackServerOptions.watchOptions = {
|
90
|
+
ignored: /./
|
91
|
+
};
|
94
92
|
}
|
95
93
|
|
96
|
-
|
97
|
-
|
98
|
-
if (hasMock) {
|
99
|
-
var mockServerPath = _path2.default.join(appPath, 'mockapi', 'index.js');
|
100
|
-
if (_fs2.default.existsSync(mockServerPath)) {
|
101
|
-
var mockServer = require(mockServerPath);
|
102
|
-
mockServer(app);
|
103
|
-
} else {
|
104
|
-
(0, _utils.log)('You must export a function from mockapi folder by only we can provide mock api hook');
|
105
|
-
}
|
94
|
+
if (writeToDisk) {
|
95
|
+
webpackServerOptions.writeToDisk = true;
|
106
96
|
}
|
107
97
|
|
108
|
-
app.use(
|
109
|
-
|
110
|
-
|
111
|
-
})
|
98
|
+
app.use((0, _webpackDevMiddleware.default)(compiler, webpackServerOptions));
|
99
|
+
app.use((0, _HMRMiddleware.default)(compiler, {
|
100
|
+
path: '/sockjs-node/info'
|
101
|
+
}));
|
102
|
+
app.use((req, res, next) => {
|
103
|
+
//console.log('origin', req.get('origin'));
|
104
|
+
res.setHeader('Access-Control-Allow-Origin', req.get('origin') || '*'); // res.setHeader('Access-Control-Allow-Origin', req.get('origin'));
|
112
105
|
|
113
|
-
|
114
|
-
res.
|
106
|
+
res.setHeader('Access-Control-Allow-Private-Network', true);
|
107
|
+
res.setHeader('Access-Control-Allow-Credentials', true);
|
108
|
+
next();
|
109
|
+
}).use(`${contextURL}/fonts`, _express.default.static(`${context}/fonts`));
|
110
|
+
app.options('/*', (req, res) => {
|
111
|
+
res.send('Ok');
|
112
|
+
});
|
113
|
+
app.use('/wms/*', (req, res) => {
|
114
|
+
res.sendFile(_path.default.join(__dirname, '..', '..', 'templates', 'wms', 'index.html'));
|
115
115
|
});
|
116
116
|
|
117
|
-
|
118
|
-
key: _fs2.default.readFileSync(_path2.default.join(__dirname, '../../cert/key.pem')),
|
119
|
-
cert: _fs2.default.readFileSync(_path2.default.join(__dirname, '../../cert/cert.pem')),
|
120
|
-
passphrase: 'zddqa1585f82'
|
121
|
-
}, app);
|
122
|
-
|
123
|
-
var wss = new _ws2.default.Server({ server: httpsServer });
|
124
|
-
var wsPool = [];
|
117
|
+
const httpsServer = _https.default.createServer(_httpsOptions.httpsOptions, app);
|
125
118
|
|
126
|
-
wss
|
119
|
+
const wss = new _ws.default.Server({
|
120
|
+
server: httpsServer
|
121
|
+
});
|
122
|
+
let wsPool = [];
|
123
|
+
wss.on('connection', ws => {
|
127
124
|
wsPool.push(ws);
|
128
|
-
|
129
|
-
|
130
|
-
wsPool = wsPool.filter(function (ws1) {
|
131
|
-
return ws1 !== ws;
|
132
|
-
});
|
125
|
+
ws.on('close', () => {
|
126
|
+
wsPool = wsPool.filter(ws1 => ws1 !== ws);
|
133
127
|
});
|
134
|
-
|
135
|
-
ws.on('message', function (message) {
|
128
|
+
ws.on('message', message => {
|
136
129
|
(0, _utils.log)('received: %s', message);
|
137
130
|
});
|
138
|
-
|
139
131
|
ws.send('something');
|
140
132
|
});
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
133
|
+
app.post('/wmsmockapi', (req, res) => {
|
134
|
+
wsPool.forEach(ws => {
|
135
|
+
let {
|
136
|
+
body
|
137
|
+
} = req;
|
145
138
|
|
146
139
|
try {
|
147
140
|
ws.send(JSON.stringify(body));
|
@@ -149,67 +142,76 @@ app.post('/wmsmockapi', function (req, res) {
|
|
149
142
|
(0, _utils.log)(e, body);
|
150
143
|
}
|
151
144
|
});
|
152
|
-
|
153
145
|
res.send('success');
|
154
146
|
});
|
147
|
+
let webpackCompilation;
|
148
|
+
let initalHTML;
|
149
|
+
compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
|
150
|
+
webpackCompilation = compilation;
|
151
|
+
});
|
152
|
+
compiler.hooks.done.tap('ReactCLI', () => {
|
153
|
+
const indexHtml = webpackCompilation.assets['index.html'];
|
154
|
+
|
155
|
+
if (indexHtml) {
|
156
|
+
initalHTML = indexHtml.source();
|
157
|
+
}
|
158
|
+
});
|
155
159
|
|
156
160
|
if (contextURL) {
|
157
|
-
app.use(contextURL,
|
158
|
-
app.use(contextURL
|
161
|
+
app.use(contextURL, _express.default.static(context));
|
162
|
+
app.use(`${contextURL}/*`, (req, res) => {
|
163
|
+
res.send(initalHTML);
|
164
|
+
});
|
159
165
|
} else {
|
160
|
-
app.use(
|
161
|
-
app.use('/*',
|
166
|
+
app.use(_express.default.static(context));
|
167
|
+
app.use('/*', _express.default.static(context));
|
162
168
|
}
|
163
169
|
|
164
|
-
httpsServer.listen(port,
|
170
|
+
httpsServer.listen(port, err => {
|
165
171
|
if (err) {
|
166
172
|
throw err;
|
167
173
|
}
|
168
|
-
|
174
|
+
|
175
|
+
(0, _utils.log)(`Listening at ${serverUrl}${contextURL}/`);
|
169
176
|
});
|
170
177
|
|
171
178
|
if (isCompatableHttp2) {
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
cert: _fs2.default.readFileSync(_path2.default.join(__dirname, '../../cert/cert.pem')),
|
176
|
-
passphrase: 'zddqa1585f82'
|
177
|
-
});
|
179
|
+
const http2 = require('http2');
|
180
|
+
|
181
|
+
const http2Server = http2.createSecureServer(_httpsOptions.httpsOptions); // eslint-disable-next-line no-unused-vars
|
178
182
|
|
179
|
-
|
180
|
-
http2Server.on('stream', function (stream, headers) {
|
183
|
+
http2Server.on('stream', (stream, headers) => {
|
181
184
|
stream.respond({
|
182
185
|
'content-type': 'text/html',
|
183
186
|
':status': 200
|
184
187
|
});
|
185
188
|
stream.end('<h1>Hello World! <br>Working with http2</h1>');
|
186
189
|
});
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
http2Server.listen(http2Port, function (err) {
|
190
|
+
let http2Port = Number(port) + 1;
|
191
|
+
http2Server.listen(http2Port, err => {
|
191
192
|
if (err) {
|
192
193
|
throw err;
|
193
194
|
}
|
194
|
-
|
195
|
-
|
196
|
-
|
195
|
+
|
196
|
+
(0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
|
197
|
+
host,
|
198
|
+
domain,
|
197
199
|
port: http2Port
|
198
|
-
}, 'htt' + 'ps')
|
200
|
+
}, 'htt' + 'ps')}${contextURL}/`, 'http2 server');
|
199
201
|
});
|
200
202
|
} else {
|
201
203
|
(0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
|
202
204
|
}
|
203
205
|
|
204
|
-
|
205
|
-
|
206
|
-
app.listen(httpPort, function (err) {
|
206
|
+
let httpPort = Number(port) + (isCompatableHttp2 ? 2 : 1);
|
207
|
+
app.listen(httpPort, err => {
|
207
208
|
if (err) {
|
208
209
|
throw err;
|
209
210
|
}
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
211
|
+
|
212
|
+
(0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
|
213
|
+
host,
|
214
|
+
domain,
|
215
|
+
port: port
|
216
|
+
}, 'ht' + 'tp')}${contextURL}/`);
|
215
217
|
});
|