@zohodesk/react-cli 1.1.29-exp.1 → 1.1.29-exp.2
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/lib/babel/babel-option-utils/babel-preset-react-option.js +0 -3
- package/lib/babel/cmjs-plugins-presets.js +1 -8
- package/lib/babel/es-plugins-presets.js +1 -8
- package/lib/common/buildEs.js +1 -0
- package/lib/common/getEntries.js +2 -13
- package/lib/common/getPublicPathConfig.js +0 -6
- package/lib/common/index.js +1 -6
- package/lib/common/runPreProcess.js +6 -15
- package/lib/common/splitChunks.js +2 -21
- package/lib/common/sslcertUpdater.js +7 -18
- package/lib/common/templateParameters.js +0 -2
- package/lib/common/testPattern.js +10 -21
- package/lib/common/valueReplacer.js +1 -16
- package/lib/configs/jest.config.js +1 -10
- package/lib/configs/libAlias.js +8 -14
- package/lib/configs/resolvers.js +4 -14
- package/lib/configs/webpack.component.umd.config.js +1 -6
- package/lib/configs/webpack.css.umd.config.js +6 -14
- package/lib/configs/webpack.dev.config.js +1 -14
- package/lib/configs/webpack.docs.config.js +1 -9
- package/lib/configs/webpack.impact.config.js +1 -8
- package/lib/configs/webpack.prod.config.js +4 -17
- package/lib/constants.js +9 -18
- package/lib/deprecationLogger.js +0 -7
- package/lib/hooks/docsProptypeHook.js +4 -8
- package/lib/jest/commitedFilesResult.js +4 -46
- package/lib/jest/coverageCollector.js +1 -12
- package/lib/jest/jsonMaker.js +0 -6
- package/lib/jest/preProcessors/cssPreprocessor.js +1 -9
- package/lib/jest/preProcessors/jsPreprocessor.js +1 -6
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +1 -4
- package/lib/jest/result.js +1 -23
- package/lib/jest/run.js +7 -18
- package/lib/jest/setup.js +8 -60
- package/lib/loaderUtils/configsAssetsLoaders.js +2 -12
- package/lib/loaderUtils/getCSSLoaders.js +10 -22
- package/lib/loaderUtils/getDevJsLoaders.js +4 -13
- package/lib/loaderUtils/index.js +1 -4
- package/lib/loaderUtils/tests/windowsModification.test.js +0 -1
- package/lib/loaderUtils/windowsModification.js +2 -3
- package/lib/loaders/__test__/markdownLoader.spec.js +0 -1
- package/lib/loaders/composeLoader.js +13 -37
- package/lib/loaders/docsLoader.js +1 -12
- package/lib/loaders/docsPropsLoader.js +4 -8
- package/lib/loaders/enhancedReactLiveConverter.js +2 -23
- package/lib/loaders/fileBountryLoader.js +1 -3
- package/lib/loaders/fileLoader.js +12 -23
- package/lib/loaders/markdownLoader.js +14 -19
- package/lib/loaders/reactLiveConvertor.js +5 -15
- package/lib/loaders/scriptInstrumentLoader.js +7 -16
- package/lib/loaders/selectorMappingLoader.js +7 -26
- package/lib/loaders/workerLoader.js +9 -24
- package/lib/logger.js +0 -4
- package/lib/middlewares/HMRMiddleware.js +13 -27
- package/lib/middlewares/SSTMiddleware.js +1 -5
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +1 -24
- package/lib/pluginUtils/getDevPlugins.js +9 -42
- package/lib/pluginUtils/getDocsPlugins.js +3 -13
- package/lib/pluginUtils/getLibraryImactPlugins.js +5 -6
- package/lib/pluginUtils/getLibraryPlugins.js +2 -8
- package/lib/pluginUtils/getProdPlugins.js +8 -47
- package/lib/pluginUtils/getServerPlugins.js +2 -8
- package/lib/pluginUtils/getUMDCSSPlugins.js +2 -10
- package/lib/pluginUtils/getUMDComponentPlugins.js +2 -10
- package/lib/pluginUtils/index.js +1 -9
- package/lib/plugins/CdnChangePlugin.js +2 -18
- package/lib/plugins/CleanupStatsPlugin.js +0 -5
- package/lib/plugins/CssOrderControlPlugin.js +3 -6
- package/lib/plugins/CustomAttributePlugin.js +14 -19
- package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +3 -23
- package/lib/plugins/EFCPlugin.js +20 -34
- package/lib/plugins/EFCTemplatePlugin.js +19 -30
- package/lib/plugins/EfcResourceCleanupPlugin.js +0 -3
- package/lib/plugins/EventsHandlingPlugin.js +2 -4
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +11 -37
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +10 -15
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +12 -25
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +55 -133
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +12 -23
- package/lib/plugins/I18nSplitPlugin/index.js +13 -24
- package/lib/plugins/I18nSplitPlugin/utils/applyMetaManifest.js +64 -58
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
- package/lib/plugins/I18nSplitPlugin/utils/createMetaManifest.js +10 -29
- package/lib/plugins/I18nSplitPlugin/utils/createRegularManifest.js +8 -19
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +0 -1
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +0 -5
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +1 -8
- package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +0 -20
- package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +0 -1
- package/lib/plugins/ManifestPlugin.js +1 -18
- package/lib/plugins/MinifyPlugin.js +1 -10
- package/lib/plugins/ModuleStatsPlugin.js +1 -24
- package/lib/plugins/OptimizeJSPlugin.js +2 -10
- package/lib/plugins/PublicPathCallbackPlugin.js +1 -12
- package/lib/plugins/PublicPathChangePlugin.js +6 -39
- package/lib/plugins/ReportGeneratePlugin.js +5 -32
- package/lib/plugins/RequireVariablePublicPlugin.js +1 -8
- package/lib/plugins/ResourceHintsPlugin.js +4 -13
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +10 -17
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
- package/lib/plugins/ScriptInstrumentPlugin.js +1 -8
- package/lib/plugins/SelectorPlugin.js +6 -32
- package/lib/plugins/ServiceWorkerPlugin.js +5 -22
- package/lib/plugins/ShadowDOMSupportPlugin.js +4 -41
- package/lib/plugins/SourceMapHookPlugin.js +2 -12
- package/lib/plugins/StatsPlugin.js +0 -14
- package/lib/plugins/TPHashMappingPlugin.js +3 -18
- package/lib/plugins/UnusedFilesFindPlugin.js +4 -39
- package/lib/plugins/VariableConversionCollector.js +15 -42
- package/lib/plugins/index.js +1 -20
- package/lib/plugins/libraryImpactPlugin.js +1 -33
- package/lib/plugins/newi18nsplitplugin/18nPlugin1.js +306 -0
- package/lib/plugins/newi18nsplitplugin/18nPlugin2.js +363 -0
- package/lib/plugins/newi18nsplitplugin/18nPlugin3.js +694 -0
- package/lib/plugins/newi18nsplitplugin/18nPlugin_hashed.js +1258 -0
- package/lib/plugins/newi18nsplitplugin/18nPlugin_working.js +542 -0
- package/lib/plugins/newi18nsplitplugin/18nplugin.js +974 -0
- package/lib/plugins/newi18nsplitplugin/ChunkManager.js +131 -0
- package/lib/plugins/newi18nsplitplugin/GenerateModuleIdToKeysMapPlugin.js +59 -0
- package/lib/plugins/newi18nsplitplugin/I18nDiffPlugin.js +262 -0
- package/lib/plugins/newi18nsplitplugin/I18nDownloadLogic.js +166 -0
- package/lib/plugins/newi18nsplitplugin/I18nPropertiesPlugin.js +111 -0
- package/lib/plugins/newi18nsplitplugin/KeyCollector.js +163 -0
- package/lib/plugins/newi18nsplitplugin/ManifestGenerator.js +88 -0
- package/lib/plugins/newi18nsplitplugin/UnicodeConversionPlugin.js +101 -0
- package/lib/plugins/newi18nsplitplugin/constants.js +162 -0
- package/lib/plugins/newi18nsplitplugin/utils/I18nKeyHasher.js +78 -0
- package/lib/plugins/newi18nsplitplugin/utils/getJsResourceKeys.js +22 -0
- package/lib/plugins/newi18nsplitplugin/utils/i18nChunkUtils.js +18 -0
- package/lib/plugins/newi18nsplitplugin/utils/manifestGenerator.js +580 -0
- package/lib/plugins/newi18nsplitplugin/utils/propertiesUtils.js +54 -0
- package/lib/plugins/utils/classHandling.js +0 -6
- package/lib/plugins/utils/fileHandling.js +6 -15
- package/lib/plugins/utils/tests/fileHandling.test.js +0 -4
- package/lib/plugins/variableConvertorUtils.js +14 -29
- package/lib/plugins/webpackwatchrunplugin.js +0 -5
- package/lib/postcss-plugins/EmptyPlugin.js +3 -4
- package/lib/postcss-plugins/ExcludePlugin.js +1 -5
- package/lib/postcss-plugins/IncludePlugin.js +1 -5
- package/lib/postcss-plugins/RTLSplitPlugin.js +14 -27
- package/lib/postcss-plugins/SelectorReplace.js +1 -16
- package/lib/postcss-plugins/ValueReplacer.js +7 -6
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
- package/lib/postcss-plugins/__test__/selectorReplace.test.js +6 -3
- package/lib/postcss-plugins/__test__/valueReplacer.spec.js +2 -5
- package/lib/postcss-plugins/hoverActivePlugin.js +31 -67
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +0 -7
- package/lib/postcss-plugins/variableModificationPlugin/index.js +28 -49
- package/lib/schemas/index.js +3 -9
- package/lib/servers/clusterHubServer.js +1 -11
- package/lib/servers/devBuild.js +14 -26
- package/lib/servers/docsServer.js +1 -3
- package/lib/servers/docsServerCore.js +1 -22
- package/lib/servers/getCliPath.js +0 -9
- package/lib/servers/helpServer.js +1 -6
- package/lib/servers/httpsOptions.js +2 -8
- package/lib/servers/impactServer.js +3 -35
- package/lib/servers/mockserver.js +1 -10
- package/lib/servers/nowatchserver.js +12 -37
- package/lib/servers/requireLocalOrGlobal.js +6 -17
- package/lib/servers/scrServer.js +14 -21
- package/lib/servers/server.js +6 -36
- package/lib/servers/ssServer.js +1 -17
- package/lib/templates/CoverageScriptTemplate.js +0 -14
- package/lib/templates/WMSTemplate.js +7 -13
- package/lib/templates/linterConstant.js +2 -4
- package/lib/utils/babelPresets.js +3 -7
- package/lib/utils/clean.js +3 -9
- package/lib/utils/copy.js +1 -7
- package/lib/utils/copyTimezones.js +1 -9
- package/lib/utils/createEventStream.js +1 -6
- package/lib/utils/cssClassNameGenerate.js +10 -30
- package/lib/utils/cssURLReplacer.js +1 -22
- package/lib/utils/dependencyPostPublish.js +1 -10
- package/lib/utils/deprecationSupport.js +7 -32
- package/lib/utils/fileUtils.js +1 -28
- package/lib/utils/folderIterator.js +2 -13
- package/lib/utils/getComponents.js +0 -21
- package/lib/utils/getCurrentBranch.js +0 -5
- package/lib/utils/getDependenciesImpactList.js +1 -22
- package/lib/utils/getFileType.js +2 -10
- package/lib/utils/getHash.js +1 -8
- package/lib/utils/getIp.js +0 -2
- package/lib/utils/getOptions.js +16 -53
- package/lib/utils/getServerURL.js +1 -10
- package/lib/utils/index.js +4 -51
- package/lib/utils/init.js +0 -1
- package/lib/utils/initPreCommitHook.js +7 -30
- package/lib/utils/jsonHelper.js +3 -22
- package/lib/utils/libraryImpactConfig.js +2 -5
- package/lib/utils/lint/addScripts.js +2 -5
- package/lib/utils/lint/checkExistingConfig.js +3 -12
- package/lib/utils/lint/copyConfigs.js +0 -3
- package/lib/utils/lint/index.js +0 -9
- package/lib/utils/lint/lintScripts.js +0 -1
- package/lib/utils/lint/lintSetup.js +3 -4
- package/lib/utils/lint/lintStagedPreCommitHook.js +0 -1
- package/lib/utils/lint/question.js +0 -7
- package/lib/utils/lintReporter.js +0 -20
- package/lib/utils/log.js +0 -1
- package/lib/utils/mailSender.js +1 -8
- package/lib/utils/object-manipulation.js +1 -17
- package/lib/utils/pullOrigin.js +0 -4
- package/lib/utils/reinstallDependencies.js +1 -29
- package/lib/utils/removeAttributes.js +1 -8
- package/lib/utils/repoClone.js +3 -28
- package/lib/utils/request.js +0 -12
- package/lib/utils/rtl.js +5 -17
- package/lib/utils/selectorReplacer.js +10 -16
- package/lib/utils/setEnvVariables.js +0 -2
- package/lib/utils/ssTestHack.js +1 -11
- package/lib/utils/switchBranch.js +0 -5
- package/lib/utils/typeCheck.js +0 -1
- package/lib/utils/urlConcat.js +0 -4
- package/lib/utils/useExitCleanup.js +9 -10
- package/lib/utils/variableConverter.js +22 -31
- package/{npm-shrinkwrap.json → package-lock.json} +2098 -1999
- package/package.json +1 -1
@@ -1,28 +1,19 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _path = _interopRequireDefault(require("path"));
|
4
|
-
|
5
4
|
var _https = _interopRequireDefault(require("https"));
|
6
|
-
|
7
5
|
var _express = _interopRequireDefault(require("express"));
|
8
|
-
|
9
6
|
var _ws = _interopRequireDefault(require("ws"));
|
10
|
-
|
11
7
|
var _httpProxyMiddleware = require("http-proxy-middleware");
|
12
|
-
|
13
8
|
var _utils = require("../utils");
|
14
|
-
|
15
9
|
var _httpsOptions = require("./httpsOptions");
|
16
|
-
|
17
10
|
var _devBuild = require("./devBuild");
|
18
|
-
|
19
11
|
var _logger = require("../logger");
|
20
|
-
|
21
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
22
|
-
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
23
13
|
// import webpack from 'webpack';
|
24
|
-
const options = (0, _utils.getOptions)(); // let args = process.argv.slice(3);
|
25
14
|
|
15
|
+
const options = (0, _utils.getOptions)();
|
16
|
+
// let args = process.argv.slice(3);
|
26
17
|
const httpsOptions = (0, _httpsOptions.httpsOptionsWithUserFriendlyError)(options);
|
27
18
|
const {
|
28
19
|
app: {
|
@@ -47,37 +38,31 @@ const {
|
|
47
38
|
outputFolderLocation
|
48
39
|
} = (0, _devBuild.getPaths)();
|
49
40
|
const app = (0, _express.default)();
|
50
|
-
|
51
41
|
if (hasMock) {
|
52
42
|
app.use(server.mockPrefix, (0, _httpProxyMiddleware.createProxyMiddleware)({
|
53
43
|
target: 'ht' + `tp://localhost:${mockPort}`,
|
54
44
|
changeOrigin: true
|
55
45
|
}));
|
56
|
-
}
|
57
|
-
|
58
|
-
|
46
|
+
}
|
47
|
+
// Nb@$#3NGscc
|
59
48
|
app.use(_express.default.json());
|
60
49
|
app.use(_express.default.urlencoded({
|
61
50
|
extended: true
|
62
51
|
}));
|
63
|
-
|
64
52
|
const staticPart = _express.default.static(outputFolderLocation, {
|
65
53
|
cacheControl: true,
|
66
54
|
setHeaders: function (res) {
|
67
55
|
if (options.app.enableDevCache) {
|
68
56
|
res.setHeader('Cache-Control', 'public, max-age=604800');
|
69
57
|
}
|
70
|
-
|
71
58
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
72
59
|
}
|
73
60
|
});
|
74
|
-
|
75
61
|
if (contextURL === '') {
|
76
62
|
app.use(staticPart);
|
77
63
|
} else {
|
78
64
|
app.use(contextURL, staticPart);
|
79
65
|
}
|
80
|
-
|
81
66
|
app.use((req, res, next) => {
|
82
67
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
83
68
|
next();
|
@@ -85,9 +70,7 @@ app.use((req, res, next) => {
|
|
85
70
|
app.use('/wms/*', (req, res) => {
|
86
71
|
res.sendFile(_path.default.join(__dirname, '..', '..', 'templates', 'wms', 'index.html'));
|
87
72
|
});
|
88
|
-
|
89
73
|
const httpsServer = _https.default.createServer(httpsOptions, app);
|
90
|
-
|
91
74
|
if (httpsOptions) {
|
92
75
|
const wss = new _ws.default.Server({
|
93
76
|
server: httpsServer
|
@@ -108,7 +91,6 @@ if (httpsOptions) {
|
|
108
91
|
const {
|
109
92
|
body
|
110
93
|
} = req;
|
111
|
-
|
112
94
|
try {
|
113
95
|
ws.send(JSON.stringify(body));
|
114
96
|
} catch (e) {
|
@@ -117,19 +99,19 @@ if (httpsOptions) {
|
|
117
99
|
});
|
118
100
|
res.send('success');
|
119
101
|
});
|
120
|
-
}
|
102
|
+
}
|
103
|
+
|
104
|
+
// let webpackCompilation;
|
121
105
|
// compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
|
122
106
|
// webpackCompilation = compilation;
|
123
107
|
// });
|
124
108
|
|
125
|
-
|
126
109
|
if (zipname) {
|
127
110
|
app.use(`/zips/${zipname}.zip`, (req, res) => {
|
128
111
|
res.download(_path.default.join(process.cwd(), cssSelectorZipPath), err => {
|
129
112
|
if (err) {
|
130
113
|
throw err;
|
131
114
|
}
|
132
|
-
|
133
115
|
(0, _logger.messageLogger)(`${zipname}.zip downloaded`);
|
134
116
|
});
|
135
117
|
});
|
@@ -138,38 +120,34 @@ if (zipname) {
|
|
138
120
|
if (err) {
|
139
121
|
throw err;
|
140
122
|
}
|
141
|
-
|
142
123
|
(0, _logger.messageLogger)('build.zip downloaded');
|
143
124
|
});
|
144
125
|
});
|
145
126
|
}
|
146
|
-
|
147
127
|
if (contextURL) {
|
148
128
|
app.use(contextURL, _express.default.static(context));
|
149
129
|
app.use(`${contextURL}/*`, (req, res) => {
|
150
130
|
// let indexHtml = webpackCompilation.assets['index.html'];
|
151
|
-
res.sendFile(_path.default.join(outputFolderLocation, 'index.html'));
|
131
|
+
res.sendFile(_path.default.join(outputFolderLocation, 'index.html'));
|
132
|
+
// let indexHtml = webpackCompilation.assets['index.html'];
|
152
133
|
// res.send(indexHtml && indexHtml.source());
|
153
134
|
});
|
154
135
|
} else {
|
155
136
|
app.use(_express.default.static(context));
|
156
137
|
app.use('/*', _express.default.static(context));
|
157
138
|
}
|
158
|
-
|
159
139
|
if (httpsOptions) {
|
160
140
|
httpsServer.listen(port, err => {
|
161
141
|
if (err) {
|
162
142
|
throw err;
|
163
143
|
}
|
164
|
-
|
165
144
|
(0, _utils.log)(`Listening at ${serverUrl}${contextURL}/`);
|
166
145
|
});
|
167
|
-
|
168
146
|
if (isCompatableHttp2) {
|
169
147
|
const http2 = require('http2');
|
148
|
+
const http2Server = http2.createSecureServer(httpsOptions);
|
170
149
|
|
171
|
-
|
172
|
-
|
150
|
+
// eslint-disable-next-line no-unused-vars
|
173
151
|
http2Server.on('stream', (stream, headers) => {
|
174
152
|
stream.respond({
|
175
153
|
'content-type': 'text/html',
|
@@ -182,7 +160,6 @@ if (httpsOptions) {
|
|
182
160
|
if (err) {
|
183
161
|
throw err;
|
184
162
|
}
|
185
|
-
|
186
163
|
(0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
|
187
164
|
host,
|
188
165
|
domain,
|
@@ -193,13 +170,11 @@ if (httpsOptions) {
|
|
193
170
|
(0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
|
194
171
|
}
|
195
172
|
}
|
196
|
-
|
197
173
|
const httpPort = Number(port) + (isCompatableHttp2 ? 2 : 1);
|
198
174
|
app.listen(httpPort, err => {
|
199
175
|
if (err) {
|
200
176
|
throw err;
|
201
177
|
}
|
202
|
-
|
203
178
|
(0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
|
204
179
|
host,
|
205
180
|
domain,
|
@@ -7,17 +7,10 @@ exports.globalNodeModules = void 0;
|
|
7
7
|
exports.requireGlobal = requireGlobal;
|
8
8
|
exports.requireLocal = requireLocal;
|
9
9
|
exports.requireLocalOrGlobal = requireLocalOrGlobal;
|
10
|
-
|
11
10
|
var _child_process = require("child_process");
|
12
|
-
|
13
11
|
var _path = _interopRequireDefault(require("path"));
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
const globalNodeModules = _path.default.join(`${(0, _child_process.execSync)('npm config get prefix')}`.trim(), 'lib');
|
18
|
-
|
19
|
-
exports.globalNodeModules = globalNodeModules;
|
20
|
-
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
13
|
+
const globalNodeModules = exports.globalNodeModules = _path.default.join(`${(0, _child_process.execSync)('npm config get prefix')}`.trim(), 'lib');
|
21
14
|
function requireLocalOrGlobal(moduleName, opts = {}) {
|
22
15
|
let {
|
23
16
|
global = true
|
@@ -25,19 +18,17 @@ function requireLocalOrGlobal(moduleName, opts = {}) {
|
|
25
18
|
const {
|
26
19
|
local = true
|
27
20
|
} = opts;
|
28
|
-
const isRelativePath = moduleName[0] === '.';
|
29
|
-
|
21
|
+
const isRelativePath = moduleName[0] === '.';
|
22
|
+
// NOTE: if starts with . then it only mean local
|
30
23
|
if (isRelativePath) {
|
31
24
|
global = false;
|
32
25
|
}
|
33
|
-
|
34
26
|
try {
|
35
|
-
const paths = [local && process.cwd(), global && globalNodeModules].filter(Boolean);
|
36
|
-
|
27
|
+
const paths = [local && process.cwd(), global && globalNodeModules].filter(Boolean);
|
28
|
+
// x({ paths, globalNodeModules, global, local, opts });
|
37
29
|
const moduleResolvePath = require.resolve(moduleName, {
|
38
30
|
paths
|
39
31
|
});
|
40
|
-
|
41
32
|
return require(moduleResolvePath);
|
42
33
|
} catch (error) {
|
43
34
|
// NOTE: since we return null we can check out side
|
@@ -45,14 +36,12 @@ function requireLocalOrGlobal(moduleName, opts = {}) {
|
|
45
36
|
return null;
|
46
37
|
}
|
47
38
|
}
|
48
|
-
|
49
39
|
function requireLocal(moduleName) {
|
50
40
|
return requireLocalOrGlobal(moduleName, {
|
51
41
|
global: false,
|
52
42
|
local: true
|
53
43
|
});
|
54
44
|
}
|
55
|
-
|
56
45
|
function requireGlobal(moduleName) {
|
57
46
|
return requireLocalOrGlobal(moduleName, {
|
58
47
|
global: true,
|
package/lib/servers/scrServer.js
CHANGED
@@ -1,20 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _screenshotTest = _interopRequireDefault(require("@zohodesk/screenshot-test"));
|
4
|
-
|
5
4
|
var _jsonHelper = require("../utils/jsonHelper");
|
6
|
-
|
7
5
|
var _child_process = require("child_process");
|
8
|
-
|
9
6
|
var _utils = require("../utils");
|
10
|
-
|
11
7
|
var _docsServerCore = _interopRequireDefault(require("./docsServerCore"));
|
12
|
-
|
13
8
|
var _SSTMiddleware = _interopRequireDefault(require("../middlewares/SSTMiddleware"));
|
14
|
-
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
|
-
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
17
10
|
//Getting variables from flag and exe
|
11
|
+
|
18
12
|
let cwd = process.cwd();
|
19
13
|
let options = (0, _utils.getOptions)();
|
20
14
|
let {
|
@@ -36,8 +30,8 @@ let {
|
|
36
30
|
}
|
37
31
|
} = options;
|
38
32
|
let resultFileName = `${cwd}/result.json`;
|
39
|
-
let docsServerInstance;
|
40
|
-
|
33
|
+
let docsServerInstance;
|
34
|
+
// let impactedComponentList = null;
|
41
35
|
let url = (0, _utils.getServerURL)(Object.assign(server, {
|
42
36
|
host: server.iphost
|
43
37
|
}), 'ht' + 'tp');
|
@@ -45,12 +39,16 @@ let commitID = (0, _child_process.execSync)('git log --first-parent --pretty="fo
|
|
45
39
|
cwd: cwd
|
46
40
|
}).toString() || '';
|
47
41
|
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;';
|
42
|
+
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;';
|
43
|
+
|
44
|
+
// Variable getting part end //
|
49
45
|
|
50
46
|
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.compareBranch', referBranch);
|
51
47
|
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.TestBranch', currentBranch);
|
52
48
|
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.isExecuted', true);
|
53
|
-
(0, _utils.log)('Test Branch Name :- ', currentBranch);
|
49
|
+
(0, _utils.log)('Test Branch Name :- ', currentBranch);
|
50
|
+
|
51
|
+
// function declaration part //
|
54
52
|
|
55
53
|
let closeServer = serverInstance => {
|
56
54
|
(0, _utils.log)('Docs service stopped!');
|
@@ -62,9 +60,9 @@ let closeServer = serverInstance => {
|
|
62
60
|
http.close();
|
63
61
|
https.close();
|
64
62
|
wdm.close();
|
65
|
-
};
|
66
|
-
|
63
|
+
};
|
67
64
|
|
65
|
+
//eslint-disable-next-line
|
68
66
|
let afterFirstScreenShotCollected = () => {
|
69
67
|
closeServer(docsServerInstance);
|
70
68
|
(0, _utils.switchBranch)('git', referBranch).then(() => {
|
@@ -74,7 +72,6 @@ let afterFirstScreenShotCollected = () => {
|
|
74
72
|
});
|
75
73
|
});
|
76
74
|
};
|
77
|
-
|
78
75
|
let onSStestEnd = (status, resultObject, message) => {
|
79
76
|
if (status) {
|
80
77
|
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.endTime', Date.now());
|
@@ -82,8 +79,8 @@ let onSStestEnd = (status, resultObject, message) => {
|
|
82
79
|
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.result', resultObject);
|
83
80
|
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.message', message);
|
84
81
|
(0, _jsonHelper.setTestInfoStatus)(resultFileName, true);
|
85
|
-
(0, _utils.log)(message);
|
86
|
-
|
82
|
+
(0, _utils.log)(message);
|
83
|
+
//'Screenshot test completed successfully.'
|
87
84
|
closeServer(docsServerInstance);
|
88
85
|
} else {
|
89
86
|
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.isPassed', false);
|
@@ -98,7 +95,6 @@ let onSStestEnd = (status, resultObject, message) => {
|
|
98
95
|
throw new Error('Component list undefined! Please check component Docs');
|
99
96
|
}
|
100
97
|
};
|
101
|
-
|
102
98
|
let run = (listOfComponents = [], configObject) => {
|
103
99
|
docsServerInstance = (0, _docsServerCore.default)(true);
|
104
100
|
docsServerInstance.app.use((0, _SSTMiddleware.default)(docsServerInstance.compiler, mData => {
|
@@ -107,13 +103,11 @@ let run = (listOfComponents = [], configObject) => {
|
|
107
103
|
configObject.impactedComponentList = finalResultObject.impactedComponentList;
|
108
104
|
configObject.unDocsComList = finalResultObject.unDocsComList;
|
109
105
|
}
|
110
|
-
|
111
106
|
_screenshotTest.default.run(configObject, (status, finalObj, message) => {
|
112
107
|
onSStestEnd(status, finalObj, message);
|
113
108
|
});
|
114
109
|
}));
|
115
110
|
};
|
116
|
-
|
117
111
|
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.startTime', Date.now());
|
118
112
|
(0, _utils.ssTestHack)();
|
119
113
|
let scrObject = {
|
@@ -131,7 +125,6 @@ let scrObject = {
|
|
131
125
|
script,
|
132
126
|
tableName
|
133
127
|
};
|
134
|
-
|
135
128
|
if (isImpactRun) {
|
136
129
|
if (!isStore) {
|
137
130
|
(0, _utils.getDependenciesImpactList)(currentBranch, referBranch, tokenGit, serviceName).then(impactedList => {
|
package/lib/servers/server.js
CHANGED
@@ -1,30 +1,19 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _path = _interopRequireDefault(require("path"));
|
4
|
-
|
5
4
|
var _https = _interopRequireDefault(require("https"));
|
6
|
-
|
7
5
|
var _webpack = _interopRequireDefault(require("webpack"));
|
8
|
-
|
9
6
|
var _express = _interopRequireDefault(require("express"));
|
10
|
-
|
11
7
|
var _ws = _interopRequireDefault(require("ws"));
|
12
|
-
|
13
8
|
var _compression = _interopRequireDefault(require("compression"));
|
14
|
-
|
15
9
|
var _webpackDevMiddleware = _interopRequireDefault(require("webpack-dev-middleware"));
|
16
|
-
|
17
10
|
var _httpProxyMiddleware = require("http-proxy-middleware");
|
18
|
-
|
19
11
|
var _HMRMiddleware = _interopRequireDefault(require("../middlewares/HMRMiddleware"));
|
20
|
-
|
21
12
|
var _utils = require("../utils");
|
22
|
-
|
23
13
|
var _httpsOptions = require("./httpsOptions");
|
24
|
-
|
25
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
26
|
-
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
27
15
|
// import fs from 'fs';
|
16
|
+
|
28
17
|
const options = (0, _utils.getOptions)();
|
29
18
|
const httpsOptions = (0, _httpsOptions.httpsOptionsWithUserFriendlyError)(options);
|
30
19
|
const {
|
@@ -49,20 +38,17 @@ const {
|
|
49
38
|
writeToDisk
|
50
39
|
} = options.impactService;
|
51
40
|
const app = (0, _express.default)();
|
52
|
-
|
53
41
|
if (hasMock) {
|
54
42
|
app.use(server.mockPrefix, (0, _httpProxyMiddleware.createProxyMiddleware)({
|
55
43
|
target: 'ht' + `tp://localhost:${mockPort}`,
|
56
44
|
changeOrigin: true
|
57
45
|
}));
|
58
46
|
}
|
59
|
-
|
60
47
|
app.use(_express.default.json());
|
61
48
|
app.use(_express.default.urlencoded({
|
62
49
|
extended: true
|
63
50
|
}));
|
64
51
|
let config;
|
65
|
-
|
66
52
|
if (mode === 'prod') {
|
67
53
|
config = require('../configs/webpack.prod.config');
|
68
54
|
app.use((0, _compression.default)());
|
@@ -71,7 +57,6 @@ if (mode === 'prod') {
|
|
71
57
|
} else {
|
72
58
|
throw new Error('You must configure valid option in mode');
|
73
59
|
}
|
74
|
-
|
75
60
|
const compiler = (0, _webpack.default)(config);
|
76
61
|
const webpackServerOptions = {
|
77
62
|
logLevel: 'error',
|
@@ -84,24 +69,21 @@ const webpackServerOptions = {
|
|
84
69
|
},
|
85
70
|
compress: mode === 'prod'
|
86
71
|
};
|
87
|
-
|
88
72
|
if (options.app.disableWatch) {
|
89
73
|
webpackServerOptions.watchOptions = {
|
90
74
|
ignored: /./
|
91
75
|
};
|
92
76
|
}
|
93
|
-
|
94
77
|
if (writeToDisk) {
|
95
78
|
webpackServerOptions.writeToDisk = true;
|
96
79
|
}
|
97
|
-
|
98
80
|
app.use((0, _webpackDevMiddleware.default)(compiler, webpackServerOptions));
|
99
81
|
app.use((0, _HMRMiddleware.default)(compiler, {
|
100
82
|
path: '/sockjs-node/info'
|
101
83
|
}));
|
102
84
|
app.use((req, res, next) => {
|
103
|
-
res.setHeader('Access-Control-Allow-Origin', req.get('origin') || '*');
|
104
|
-
|
85
|
+
res.setHeader('Access-Control-Allow-Origin', req.get('origin') || '*');
|
86
|
+
// res.setHeader('Access-Control-Allow-Origin', req.get('origin'));
|
105
87
|
res.setHeader('Access-Control-Allow-Private-Network', true);
|
106
88
|
res.setHeader('Access-Control-Allow-Credentials', true);
|
107
89
|
next();
|
@@ -112,9 +94,7 @@ app.options('/*', (req, res) => {
|
|
112
94
|
app.use('/wms/*', (req, res) => {
|
113
95
|
res.sendFile(_path.default.join(__dirname, '..', '..', 'templates', 'wms', 'index.html'));
|
114
96
|
});
|
115
|
-
|
116
97
|
const httpsServer = _https.default.createServer(httpsOptions, app);
|
117
|
-
|
118
98
|
if (httpsOptions) {
|
119
99
|
const wss = new _ws.default.Server({
|
120
100
|
server: httpsServer
|
@@ -135,7 +115,6 @@ if (httpsOptions) {
|
|
135
115
|
const {
|
136
116
|
body
|
137
117
|
} = req;
|
138
|
-
|
139
118
|
try {
|
140
119
|
ws.send(JSON.stringify(body));
|
141
120
|
} catch (e) {
|
@@ -145,7 +124,6 @@ if (httpsOptions) {
|
|
145
124
|
res.send('success');
|
146
125
|
});
|
147
126
|
}
|
148
|
-
|
149
127
|
let webpackCompilation;
|
150
128
|
let initalHTML;
|
151
129
|
compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
|
@@ -153,12 +131,10 @@ compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
|
|
153
131
|
});
|
154
132
|
compiler.hooks.done.tap('ReactCLI', () => {
|
155
133
|
const indexHtml = webpackCompilation.assets['index.html'];
|
156
|
-
|
157
134
|
if (indexHtml) {
|
158
135
|
initalHTML = indexHtml.source();
|
159
136
|
}
|
160
137
|
});
|
161
|
-
|
162
138
|
if (contextURL) {
|
163
139
|
app.use(contextURL, _express.default.static(context));
|
164
140
|
app.use(`${contextURL}/*`, (req, res) => {
|
@@ -168,21 +144,18 @@ if (contextURL) {
|
|
168
144
|
app.use(_express.default.static(context));
|
169
145
|
app.use('/*', _express.default.static(context));
|
170
146
|
}
|
171
|
-
|
172
147
|
if (httpsOptions) {
|
173
148
|
httpsServer.listen(port, err => {
|
174
149
|
if (err) {
|
175
150
|
throw err;
|
176
151
|
}
|
177
|
-
|
178
152
|
(0, _utils.log)(`Listening at ${serverUrl}${contextURL}/`);
|
179
153
|
});
|
180
|
-
|
181
154
|
if (isCompatableHttp2) {
|
182
155
|
const http2 = require('http2');
|
156
|
+
const http2Server = http2.createSecureServer(httpsOptions);
|
183
157
|
|
184
|
-
|
185
|
-
|
158
|
+
// eslint-disable-next-line no-unused-vars
|
186
159
|
http2Server.on('stream', (stream, headers) => {
|
187
160
|
stream.respond({
|
188
161
|
'content-type': 'text/html',
|
@@ -195,7 +168,6 @@ if (httpsOptions) {
|
|
195
168
|
if (err) {
|
196
169
|
throw err;
|
197
170
|
}
|
198
|
-
|
199
171
|
(0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
|
200
172
|
host,
|
201
173
|
domain,
|
@@ -206,13 +178,11 @@ if (httpsOptions) {
|
|
206
178
|
(0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
|
207
179
|
}
|
208
180
|
}
|
209
|
-
|
210
181
|
const httpPort = Number(port) + (isCompatableHttp2 ? 2 : 1);
|
211
182
|
app.listen(httpPort, err => {
|
212
183
|
if (err) {
|
213
184
|
throw err;
|
214
185
|
}
|
215
|
-
|
216
186
|
(0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
|
217
187
|
host,
|
218
188
|
domain,
|
package/lib/servers/ssServer.js
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _screenshotTest = _interopRequireDefault(require("@zohodesk/screenshot-test"));
|
4
|
-
|
5
4
|
var _jsonHelper = require("../utils/jsonHelper");
|
6
|
-
|
7
5
|
var _utils = require("../utils");
|
8
|
-
|
9
6
|
var _docsServerCore = _interopRequireDefault(require("./docsServerCore"));
|
10
|
-
|
11
7
|
var _SSTMiddleware = _interopRequireDefault(require("../middlewares/SSTMiddleware"));
|
12
|
-
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
|
-
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
15
9
|
let options = (0, _utils.getOptions)();
|
16
10
|
let impactedComponentObject = null;
|
17
11
|
let docsServerInstance;
|
@@ -27,7 +21,6 @@ let {
|
|
27
21
|
server
|
28
22
|
}
|
29
23
|
} = options;
|
30
|
-
|
31
24
|
function closeServer(serverInstance) {
|
32
25
|
(0, _utils.log)('Docs service stopped!');
|
33
26
|
let {
|
@@ -39,12 +32,10 @@ function closeServer(serverInstance) {
|
|
39
32
|
https.close();
|
40
33
|
wdm.close();
|
41
34
|
}
|
42
|
-
|
43
35
|
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.compareBranch', referBranch);
|
44
36
|
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.TestBranch', currentBranch);
|
45
37
|
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.isExecuted', true);
|
46
38
|
(0, _utils.log)('Test Branch Name :- ', currentBranch);
|
47
|
-
|
48
39
|
let afterFirstScreenShotCollected = () => {
|
49
40
|
closeServer(docsServerInstance);
|
50
41
|
(0, _utils.switchBranch)('git', referBranch).then(() => {
|
@@ -54,7 +45,6 @@ let afterFirstScreenShotCollected = () => {
|
|
54
45
|
});
|
55
46
|
});
|
56
47
|
};
|
57
|
-
|
58
48
|
let onSStestEnd = (status, resultObject, isLastRun, runSSTest) => {
|
59
49
|
if (status) {
|
60
50
|
if (!isLastRun) {
|
@@ -82,17 +72,13 @@ let onSStestEnd = (status, resultObject, isLastRun, runSSTest) => {
|
|
82
72
|
throw new Error('Component list undefined! Please check component Docs');
|
83
73
|
}
|
84
74
|
};
|
85
|
-
|
86
75
|
(0, _utils.ssTestHack)();
|
87
|
-
|
88
76
|
let getDocsServerInstance = beforeJobs => {
|
89
77
|
if (typeof beforeJobs === 'function') {
|
90
78
|
beforeJobs();
|
91
79
|
}
|
92
|
-
|
93
80
|
return (0, _docsServerCore.default)(true);
|
94
81
|
};
|
95
|
-
|
96
82
|
let runSSTest = (onBefore, isLastRun, mode, branch, listOfComponents) => {
|
97
83
|
let url = (0, _utils.getServerURL)(Object.assign(server, {
|
98
84
|
host: server.iphost
|
@@ -100,7 +86,6 @@ let runSSTest = (onBefore, isLastRun, mode, branch, listOfComponents) => {
|
|
100
86
|
docsServerInstance = getDocsServerInstance(onBefore);
|
101
87
|
docsServerInstance.app.use((0, _SSTMiddleware.default)(docsServerInstance.compiler, mData => {
|
102
88
|
impactedComponentObject = (0, _utils.getComponents)(mData, listOfComponents);
|
103
|
-
|
104
89
|
_screenshotTest.default.run({
|
105
90
|
branch,
|
106
91
|
seleniumHub: seleniumHub,
|
@@ -115,7 +100,6 @@ let runSSTest = (onBefore, isLastRun, mode, branch, listOfComponents) => {
|
|
115
100
|
});
|
116
101
|
}));
|
117
102
|
};
|
118
|
-
|
119
103
|
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.startTime', Date.now());
|
120
104
|
(0, _utils.getDependenciesImpactList)(currentBranch, referBranch).then(impactedList => {
|
121
105
|
(0, _utils.log)('from here ');
|
@@ -8,27 +8,21 @@ window.ClientCoverage = {
|
|
8
8
|
localStorage.setItem(property, JSON.stringify(defaultVal));
|
9
9
|
return defaultVal;
|
10
10
|
}
|
11
|
-
|
12
11
|
localStorage.setItem(property, JSON.stringify(defaultVal));
|
13
12
|
return defaultVal || {};
|
14
13
|
},
|
15
|
-
|
16
14
|
clearLocalStorage(property) {
|
17
15
|
localStorage.removeItem(property);
|
18
16
|
}
|
19
|
-
|
20
17
|
},
|
21
18
|
JS: {
|
22
19
|
jsMethodInstrumentObject: {},
|
23
20
|
jsStorageKey: 'jsClientCoverageObject',
|
24
|
-
|
25
21
|
init() {
|
26
22
|
this.jsMethodInstrumentObject = ClientCoverage.LocalStorageWrapper.getLocalStorage(this.jsStorageKey, this.jsMethodInstrumentObject);
|
27
23
|
},
|
28
|
-
|
29
24
|
visitMethod(jsFileName, jsMethodName) {
|
30
25
|
this.init();
|
31
|
-
|
32
26
|
if (this.jsMethodInstrumentObject.hasOwnProperty(jsFileName)) {
|
33
27
|
if (!this.jsMethodInstrumentObject[jsFileName].includes(jsMethodName)) {
|
34
28
|
this.jsMethodInstrumentObject[jsFileName].push(jsMethodName);
|
@@ -37,35 +31,27 @@ window.ClientCoverage = {
|
|
37
31
|
this.jsMethodInstrumentObject[jsFileName] = [];
|
38
32
|
this.jsMethodInstrumentObject[jsFileName].push(jsMethodName);
|
39
33
|
}
|
40
|
-
|
41
34
|
localStorage.setItem(this.jsStorageKey, JSON.stringify(this.jsMethodInstrumentObject));
|
42
35
|
},
|
43
|
-
|
44
36
|
clear() {
|
45
37
|
this.jsMethodInstrumentObject = {};
|
46
38
|
ClientCoverage.LocalStorageWrapper.clearLocalStorage(this.jsStorageKey);
|
47
39
|
},
|
48
|
-
|
49
40
|
getData() {
|
50
41
|
return {
|
51
42
|
methods: this.jsMethodInstrumentObject
|
52
43
|
};
|
53
44
|
}
|
54
|
-
|
55
45
|
},
|
56
|
-
|
57
46
|
getCoverageData() {
|
58
47
|
return {
|
59
48
|
JS: this.JS.getData()
|
60
49
|
};
|
61
50
|
},
|
62
|
-
|
63
51
|
clear() {
|
64
52
|
this.JS.clear();
|
65
53
|
},
|
66
|
-
|
67
54
|
init() {
|
68
55
|
this.JS.init();
|
69
56
|
}
|
70
|
-
|
71
57
|
};
|