@zohodesk/react-cli 1.1.29-exp.2 → 1.1.29-exp.3
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/README.md +18 -0
- package/lib/babel/babel-option-utils/babel-preset-react-option.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +13 -2
- package/lib/babel/es-plugins-presets.js +14 -3
- package/lib/common/buildEs.js +0 -1
- package/lib/common/getEntries.js +13 -2
- package/lib/common/getPublicPathConfig.js +6 -0
- package/lib/common/index.js +6 -1
- package/lib/common/runPreProcess.js +15 -6
- package/lib/common/splitChunks.js +21 -2
- package/lib/common/sslcertUpdater.js +18 -7
- package/lib/common/templateParameters.js +2 -0
- package/lib/common/testPattern.js +21 -10
- package/lib/common/valueReplacer.js +16 -1
- package/lib/configs/jest.config.js +11 -2
- package/lib/configs/libAlias.js +16 -10
- package/lib/configs/resolvers.js +16 -6
- package/lib/configs/webpack.component.umd.config.js +6 -1
- package/lib/configs/webpack.css.umd.config.js +14 -6
- package/lib/configs/webpack.dev.config.js +14 -1
- package/lib/configs/webpack.docs.config.js +9 -1
- package/lib/configs/webpack.impact.config.js +8 -1
- package/lib/configs/webpack.prod.config.js +17 -4
- package/lib/constants.js +18 -9
- package/lib/deprecationLogger.js +7 -0
- package/lib/hooks/docsProptypeHook.js +8 -4
- package/lib/jest/commitedFilesResult.js +46 -4
- package/lib/jest/coverageCollector.js +12 -1
- package/lib/jest/jsonMaker.js +6 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +9 -1
- package/lib/jest/preProcessors/jsPreprocessor.js +11 -2
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +4 -1
- package/lib/jest/result.js +23 -1
- package/lib/jest/run.js +18 -7
- package/lib/jest/setup.js +60 -8
- package/lib/loaderUtils/configsAssetsLoaders.js +12 -2
- package/lib/loaderUtils/getCSSLoaders.js +22 -10
- package/lib/loaderUtils/getDevJsLoaders.js +13 -4
- package/lib/loaderUtils/index.js +4 -1
- package/lib/loaderUtils/tests/windowsModification.test.js +1 -0
- package/lib/loaderUtils/windowsModification.js +3 -2
- package/lib/loaders/__test__/markdownLoader.spec.js +1 -0
- package/lib/loaders/composeLoader.js +37 -13
- package/lib/loaders/docsLoader.js +12 -1
- package/lib/loaders/docsPropsLoader.js +8 -4
- package/lib/loaders/enhancedReactLiveConverter.js +23 -2
- package/lib/loaders/fileBountryLoader.js +3 -1
- package/lib/loaders/fileLoader.js +23 -12
- package/lib/loaders/markdownLoader.js +19 -14
- package/lib/loaders/reactLiveConvertor.js +15 -5
- package/lib/loaders/scriptInstrumentLoader.js +16 -7
- package/lib/loaders/selectorMappingLoader.js +26 -7
- package/lib/loaders/workerLoader.js +24 -9
- package/lib/logger.js +4 -0
- package/lib/middlewares/HMRMiddleware.js +27 -13
- package/lib/middlewares/SSTMiddleware.js +5 -1
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +24 -1
- package/lib/pluginUtils/getDevPlugins.js +42 -9
- package/lib/pluginUtils/getDocsPlugins.js +13 -3
- package/lib/pluginUtils/getLibraryImactPlugins.js +6 -5
- package/lib/pluginUtils/getLibraryPlugins.js +8 -2
- package/lib/pluginUtils/getProdPlugins.js +47 -8
- package/lib/pluginUtils/getServerPlugins.js +8 -2
- package/lib/pluginUtils/getUMDCSSPlugins.js +10 -2
- package/lib/pluginUtils/getUMDComponentPlugins.js +10 -2
- package/lib/pluginUtils/index.js +9 -1
- package/lib/plugins/CdnChangePlugin.js +18 -2
- package/lib/plugins/CleanupStatsPlugin.js +5 -0
- package/lib/plugins/CssOrderControlPlugin.js +6 -3
- package/lib/plugins/CustomAttributePlugin.js +19 -14
- package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +23 -3
- package/lib/plugins/EFCPlugin.js +34 -20
- package/lib/plugins/EFCTemplatePlugin.js +30 -19
- package/lib/plugins/EfcResourceCleanupPlugin.js +3 -0
- package/lib/plugins/EventsHandlingPlugin.js +4 -2
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +37 -14
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +15 -10
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +155 -78
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +81 -198
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +23 -12
- package/lib/plugins/I18nSplitPlugin/index.js +24 -13
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +12 -2
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +1 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +5 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +8 -1
- package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -0
- package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +1 -0
- package/lib/plugins/ManifestPlugin.js +18 -1
- package/lib/plugins/MinifyPlugin.js +10 -1
- package/lib/plugins/ModuleStatsPlugin.js +24 -1
- package/lib/plugins/OptimizeJSPlugin.js +10 -2
- package/lib/plugins/PublicPathCallbackPlugin.js +12 -1
- package/lib/plugins/PublicPathChangePlugin.js +39 -6
- package/lib/plugins/ReportGeneratePlugin.js +32 -5
- package/lib/plugins/RequireVariablePublicPlugin.js +8 -1
- package/lib/plugins/ResourceHintsPlugin.js +13 -4
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +17 -10
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
- package/lib/plugins/ScriptInstrumentPlugin.js +8 -1
- package/lib/plugins/SelectorPlugin.js +32 -6
- package/lib/plugins/ServiceWorkerPlugin.js +22 -5
- package/lib/plugins/ShadowDOMSupportPlugin.js +41 -4
- package/lib/plugins/SourceMapHookPlugin.js +12 -2
- package/lib/plugins/StatsPlugin.js +14 -0
- package/lib/plugins/TPHashMappingPlugin.js +18 -3
- package/lib/plugins/UnusedFilesFindPlugin.js +39 -4
- package/lib/plugins/VariableConversionCollector.js +42 -15
- package/lib/plugins/index.js +20 -1
- package/lib/plugins/libraryImpactPlugin.js +33 -1
- package/lib/plugins/utils/classHandling.js +6 -0
- package/lib/plugins/utils/fileHandling.js +15 -6
- package/lib/plugins/utils/tests/fileHandling.test.js +4 -0
- package/lib/plugins/variableConvertorUtils.js +29 -14
- package/lib/plugins/webpackwatchrunplugin.js +5 -0
- package/lib/postcss-plugins/EmptyPlugin.js +4 -3
- package/lib/postcss-plugins/ExcludePlugin.js +5 -1
- package/lib/postcss-plugins/IncludePlugin.js +5 -1
- package/lib/postcss-plugins/RTLSplitPlugin.js +27 -14
- package/lib/postcss-plugins/SelectorReplace.js +16 -1
- package/lib/postcss-plugins/ValueReplacer.js +6 -7
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
- package/lib/postcss-plugins/__test__/selectorReplace.test.js +3 -6
- package/lib/postcss-plugins/__test__/valueReplacer.spec.js +5 -2
- package/lib/postcss-plugins/hoverActivePlugin.js +67 -31
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +7 -0
- package/lib/postcss-plugins/variableModificationPlugin/index.js +49 -28
- package/lib/schemas/index.js +10 -3
- package/lib/servers/clusterHubServer.js +11 -1
- package/lib/servers/devBuild.js +26 -14
- package/lib/servers/docsServer.js +3 -1
- package/lib/servers/docsServerCore.js +22 -1
- package/lib/servers/getCliPath.js +9 -0
- package/lib/servers/helpServer.js +6 -1
- package/lib/servers/httpsOptions.js +8 -2
- package/lib/servers/impactServer.js +35 -3
- package/lib/servers/mockserver.js +10 -1
- package/lib/servers/nowatchserver.js +37 -12
- package/lib/servers/requireLocalOrGlobal.js +17 -6
- package/lib/servers/scrServer.js +21 -14
- package/lib/servers/server.js +36 -6
- package/lib/servers/ssServer.js +17 -1
- package/lib/templates/CoverageScriptTemplate.js +14 -0
- package/lib/templates/WMSTemplate.js +13 -7
- package/lib/templates/linterConstant.js +4 -2
- package/lib/utils/babelPresets.js +7 -3
- package/lib/utils/clean.js +9 -3
- package/lib/utils/copy.js +7 -1
- package/lib/utils/copyTimezones.js +9 -1
- package/lib/utils/createEventStream.js +6 -1
- package/lib/utils/cssClassNameGenerate.js +30 -10
- package/lib/utils/cssURLReplacer.js +22 -1
- package/lib/utils/dependencyPostPublish.js +10 -1
- package/lib/utils/deprecationSupport.js +32 -7
- package/lib/utils/fileUtils.js +28 -1
- package/lib/utils/folderIterator.js +13 -2
- package/lib/utils/getComponents.js +21 -0
- package/lib/utils/getCurrentBranch.js +5 -0
- package/lib/utils/getDependenciesImpactList.js +22 -1
- package/lib/utils/getFileType.js +10 -2
- package/lib/utils/getHash.js +8 -1
- package/lib/utils/getIp.js +2 -0
- package/lib/utils/getOptions.js +53 -16
- package/lib/utils/getServerURL.js +10 -1
- package/lib/utils/index.js +51 -4
- package/lib/utils/init.js +1 -0
- package/lib/utils/initPreCommitHook.js +30 -7
- package/lib/utils/jsonHelper.js +22 -3
- package/lib/utils/libraryImpactConfig.js +5 -2
- package/lib/utils/lint/addScripts.js +5 -2
- package/lib/utils/lint/checkExistingConfig.js +12 -3
- package/lib/utils/lint/copyConfigs.js +3 -0
- package/lib/utils/lint/index.js +9 -0
- package/lib/utils/lint/lintScripts.js +1 -0
- package/lib/utils/lint/lintSetup.js +4 -3
- package/lib/utils/lint/lintStagedPreCommitHook.js +1 -0
- package/lib/utils/lint/question.js +7 -0
- package/lib/utils/lintReporter.js +20 -0
- package/lib/utils/log.js +1 -0
- package/lib/utils/mailSender.js +8 -1
- package/lib/utils/object-manipulation.js +17 -1
- package/lib/utils/pullOrigin.js +4 -0
- package/lib/utils/reinstallDependencies.js +29 -1
- package/lib/utils/removeAttributes.js +8 -1
- package/lib/utils/repoClone.js +28 -3
- package/lib/utils/request.js +12 -0
- package/lib/utils/rtl.js +17 -5
- package/lib/utils/selectorReplacer.js +16 -10
- package/lib/utils/setEnvVariables.js +2 -0
- package/lib/utils/ssTestHack.js +11 -1
- package/lib/utils/switchBranch.js +5 -0
- package/lib/utils/typeCheck.js +1 -0
- package/lib/utils/urlConcat.js +4 -0
- package/lib/utils/useExitCleanup.js +10 -9
- package/lib/utils/variableConverter.js +31 -22
- package/{package-lock.json → npm-shrinkwrap.json} +2333 -2101
- package/package.json +3 -2
- package/lib/plugins/I18nSplitPlugin/utils/applyMetaManifest.js +0 -279
- package/lib/plugins/I18nSplitPlugin/utils/createMetaManifest.js +0 -51
- package/lib/plugins/I18nSplitPlugin/utils/createRegularManifest.js +0 -48
- package/lib/plugins/newi18nsplitplugin/18nPlugin1.js +0 -306
- package/lib/plugins/newi18nsplitplugin/18nPlugin2.js +0 -363
- package/lib/plugins/newi18nsplitplugin/18nPlugin3.js +0 -694
- package/lib/plugins/newi18nsplitplugin/18nPlugin_hashed.js +0 -1258
- package/lib/plugins/newi18nsplitplugin/18nPlugin_working.js +0 -542
- package/lib/plugins/newi18nsplitplugin/18nplugin.js +0 -974
- package/lib/plugins/newi18nsplitplugin/ChunkManager.js +0 -131
- package/lib/plugins/newi18nsplitplugin/GenerateModuleIdToKeysMapPlugin.js +0 -59
- package/lib/plugins/newi18nsplitplugin/I18nDiffPlugin.js +0 -262
- package/lib/plugins/newi18nsplitplugin/I18nDownloadLogic.js +0 -166
- package/lib/plugins/newi18nsplitplugin/I18nPropertiesPlugin.js +0 -111
- package/lib/plugins/newi18nsplitplugin/KeyCollector.js +0 -163
- package/lib/plugins/newi18nsplitplugin/ManifestGenerator.js +0 -88
- package/lib/plugins/newi18nsplitplugin/UnicodeConversionPlugin.js +0 -101
- package/lib/plugins/newi18nsplitplugin/constants.js +0 -162
- package/lib/plugins/newi18nsplitplugin/utils/I18nKeyHasher.js +0 -78
- package/lib/plugins/newi18nsplitplugin/utils/getJsResourceKeys.js +0 -22
- package/lib/plugins/newi18nsplitplugin/utils/i18nChunkUtils.js +0 -18
- package/lib/plugins/newi18nsplitplugin/utils/manifestGenerator.js +0 -580
- package/lib/plugins/newi18nsplitplugin/utils/propertiesUtils.js +0 -54
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
+
|
7
8
|
const getServerURL = (serverInfo, protocol) => {
|
8
9
|
// eslint-disable-next-line prefer-const
|
9
10
|
let {
|
@@ -11,21 +12,29 @@ const getServerURL = (serverInfo, protocol) => {
|
|
11
12
|
domain,
|
12
13
|
port
|
13
14
|
} = serverInfo;
|
15
|
+
|
14
16
|
if (domain === 'kubernetes') {
|
15
17
|
return `${protocol ? `${protocol}:` : ''}//${host}`;
|
16
18
|
}
|
19
|
+
|
17
20
|
if (protocol) {
|
18
21
|
if (protocol === 'ht' + 'tp') {
|
19
22
|
port = Number(port) + 1;
|
23
|
+
|
20
24
|
if (domain) {
|
21
25
|
return `${protocol ? `${protocol}:` : ''}//${host}.${domain}.zohocorpin.com:${Number(port) + 1}`;
|
22
26
|
}
|
27
|
+
|
23
28
|
return `${protocol ? `${protocol}:` : ''}//${host}:${Number(port) + 1}`;
|
24
29
|
}
|
25
30
|
}
|
31
|
+
|
26
32
|
if (domain) {
|
27
33
|
return `${protocol ? `${protocol}:` : ''}//${host}.${domain}.zohocorpin.com:${port}`;
|
28
34
|
}
|
35
|
+
|
29
36
|
return `${protocol ? `${protocol}:` : ''}//${host}:${port}`;
|
30
37
|
};
|
31
|
-
|
38
|
+
|
39
|
+
var _default = getServerURL;
|
40
|
+
exports.default = _default;
|
package/lib/utils/index.js
CHANGED
@@ -96,18 +96,31 @@ Object.defineProperty(exports, "switchBranch", {
|
|
96
96
|
}
|
97
97
|
});
|
98
98
|
exports.writeFile = void 0;
|
99
|
+
|
99
100
|
var _stream = require("stream");
|
101
|
+
|
100
102
|
var _fs = _interopRequireDefault(require("fs"));
|
103
|
+
|
101
104
|
var _log = require("./log");
|
105
|
+
|
102
106
|
var _getOptions = _interopRequireDefault(require("./getOptions"));
|
107
|
+
|
103
108
|
var _createEventStream = _interopRequireDefault(require("./createEventStream"));
|
109
|
+
|
104
110
|
var _getServerURL = _interopRequireDefault(require("./getServerURL"));
|
111
|
+
|
105
112
|
var _getCurrentBranch = _interopRequireDefault(require("./getCurrentBranch"));
|
113
|
+
|
106
114
|
var _switchBranch = _interopRequireDefault(require("./switchBranch"));
|
115
|
+
|
107
116
|
var _pullOrigin = _interopRequireDefault(require("./pullOrigin"));
|
117
|
+
|
108
118
|
var _request = _interopRequireDefault(require("./request"));
|
119
|
+
|
109
120
|
var _jsonHelper = _interopRequireDefault(require("./jsonHelper"));
|
121
|
+
|
110
122
|
var _reinstallDependencies = require("./reinstallDependencies");
|
123
|
+
|
111
124
|
Object.keys(_reinstallDependencies).forEach(function (key) {
|
112
125
|
if (key === "default" || key === "__esModule") return;
|
113
126
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
@@ -119,7 +132,9 @@ Object.keys(_reinstallDependencies).forEach(function (key) {
|
|
119
132
|
}
|
120
133
|
});
|
121
134
|
});
|
135
|
+
|
122
136
|
var _cssURLReplacer = require("./cssURLReplacer");
|
137
|
+
|
123
138
|
Object.keys(_cssURLReplacer).forEach(function (key) {
|
124
139
|
if (key === "default" || key === "__esModule") return;
|
125
140
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
@@ -131,7 +146,9 @@ Object.keys(_cssURLReplacer).forEach(function (key) {
|
|
131
146
|
}
|
132
147
|
});
|
133
148
|
});
|
149
|
+
|
134
150
|
var _initPreCommitHook = require("./initPreCommitHook");
|
151
|
+
|
135
152
|
Object.keys(_initPreCommitHook).forEach(function (key) {
|
136
153
|
if (key === "default" || key === "__esModule") return;
|
137
154
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
@@ -143,10 +160,15 @@ Object.keys(_initPreCommitHook).forEach(function (key) {
|
|
143
160
|
}
|
144
161
|
});
|
145
162
|
});
|
163
|
+
|
146
164
|
var _getDependenciesImpactList = _interopRequireDefault(require("./getDependenciesImpactList"));
|
165
|
+
|
147
166
|
var _getComponents = _interopRequireDefault(require("./getComponents"));
|
167
|
+
|
148
168
|
var _ssTestHack = _interopRequireDefault(require("./ssTestHack"));
|
169
|
+
|
149
170
|
var _typeCheck = require("./typeCheck");
|
171
|
+
|
150
172
|
Object.keys(_typeCheck).forEach(function (key) {
|
151
173
|
if (key === "default" || key === "__esModule") return;
|
152
174
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
@@ -158,20 +180,26 @@ Object.keys(_typeCheck).forEach(function (key) {
|
|
158
180
|
}
|
159
181
|
});
|
160
182
|
});
|
161
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
162
|
-
// eslint-disable-next-line no-duplicate-imports
|
163
183
|
|
184
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
185
|
+
|
186
|
+
// eslint-disable-next-line no-duplicate-imports
|
164
187
|
let writeFile = (outputPath, src, isPath = false) => new Promise((resolve, reject) => {
|
165
188
|
let inStr;
|
189
|
+
|
166
190
|
if (isPath) {
|
167
191
|
inStr = _fs.default.createReadStream(src);
|
168
192
|
} else {
|
169
193
|
inStr = new _stream.Readable();
|
194
|
+
|
170
195
|
inStr._read = () => true;
|
196
|
+
|
171
197
|
inStr.push(src);
|
172
198
|
inStr.push(null);
|
173
199
|
}
|
200
|
+
|
174
201
|
let outStr = _fs.default.createWriteStream(outputPath);
|
202
|
+
|
175
203
|
outStr.on('error', err => {
|
176
204
|
reject(err);
|
177
205
|
});
|
@@ -180,40 +208,51 @@ let writeFile = (outputPath, src, isPath = false) => new Promise((resolve, rejec
|
|
180
208
|
});
|
181
209
|
inStr.pipe(outStr);
|
182
210
|
});
|
211
|
+
|
183
212
|
exports.writeFile = writeFile;
|
213
|
+
|
184
214
|
let makeDir = paths => {
|
185
215
|
if (typeof paths === 'string') {
|
186
216
|
//eslint-disable-next-line
|
187
217
|
paths = [paths];
|
188
218
|
}
|
219
|
+
|
189
220
|
paths.forEach(path => {
|
190
221
|
if (!_fs.default.existsSync(path)) {
|
191
222
|
_fs.default.mkdirSync(path);
|
192
223
|
}
|
193
224
|
});
|
194
225
|
};
|
226
|
+
|
195
227
|
exports.makeDir = makeDir;
|
228
|
+
|
196
229
|
let getInfoFromPublicPaths = publicPaths => {
|
197
230
|
let rootFolder = '',
|
198
|
-
|
199
|
-
|
231
|
+
image = '',
|
232
|
+
font = '';
|
233
|
+
|
200
234
|
if (publicPaths && !Array.isArray(publicPaths) && typeof publicPaths === 'object' && !publicPaths.callback) {
|
201
235
|
let [cdn] = Object.keys(publicPaths);
|
202
236
|
rootFolder = `${cdn}/`;
|
237
|
+
|
203
238
|
if (publicPaths[cdn].font) {
|
204
239
|
font = publicPaths[cdn].font; //eslint-disable-line
|
205
240
|
}
|
241
|
+
|
206
242
|
if (publicPaths[cdn].image) {
|
207
243
|
image = publicPaths[cdn].image; //eslint-disable-line
|
208
244
|
}
|
209
245
|
}
|
246
|
+
|
210
247
|
return {
|
211
248
|
rootFolder,
|
212
249
|
image,
|
213
250
|
font
|
214
251
|
};
|
215
252
|
};
|
253
|
+
|
216
254
|
exports.getInfoFromPublicPaths = getInfoFromPublicPaths;
|
255
|
+
|
217
256
|
let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
|
218
257
|
let srcChanges = [];
|
219
258
|
let libraryChanges = [];
|
@@ -227,6 +266,7 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
|
|
227
266
|
if (action !== 'REMOVED') {
|
228
267
|
impactObj[library][action].forEach(srcObject => {
|
229
268
|
let fileName = srcObject["FILEPATH"];
|
269
|
+
|
230
270
|
if (library == "AppSource") {
|
231
271
|
fileName = fileName.replace("jsapps/supportapp", ".");
|
232
272
|
srcChanges.push(fileName);
|
@@ -238,8 +278,10 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
|
|
238
278
|
}
|
239
279
|
});
|
240
280
|
});
|
281
|
+
|
241
282
|
if (!changesOnly) {
|
242
283
|
srcChanges = [];
|
284
|
+
|
243
285
|
if (libraryChanges.length > 0) {
|
244
286
|
libraryChanges.forEach(mdataLibKey => {
|
245
287
|
if (moduleObject[mdataLibKey]) {
|
@@ -254,11 +296,13 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
|
|
254
296
|
});
|
255
297
|
} else {}
|
256
298
|
}
|
299
|
+
|
257
300
|
if (srcChanges.length > 0) {
|
258
301
|
srcChanges.forEach(srcFile => {
|
259
302
|
let cacheObject = {};
|
260
303
|
cacheObject.sourceName = srcFile;
|
261
304
|
let cacheLibraryList = [];
|
305
|
+
|
262
306
|
if (libraryChanges.length > 0) {
|
263
307
|
libraryChanges.forEach(mdataKey => {
|
264
308
|
if (moduleObject[mdataKey]) {
|
@@ -272,6 +316,7 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
|
|
272
316
|
impactThere = false;
|
273
317
|
whichLibrary = 'No library file changes between target branch!';
|
274
318
|
}
|
319
|
+
|
275
320
|
if (cacheLibraryList.length > 0) {
|
276
321
|
cacheObject.impactedBy = cacheLibraryList;
|
277
322
|
allImpactArray.push(cacheObject);
|
@@ -284,6 +329,7 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
|
|
284
329
|
impactThere = false;
|
285
330
|
whichLibrary = "No component file changes!";
|
286
331
|
}
|
332
|
+
|
287
333
|
(0, _log.log)('\n');
|
288
334
|
(0, _log.log)('You can see the HTML out at coverageTest/impactLibrary.html!');
|
289
335
|
(0, _log.log)('\x1b[33m%s\x1b[0m', '************************************************************ \n ');
|
@@ -295,4 +341,5 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
|
|
295
341
|
}
|
296
342
|
};
|
297
343
|
};
|
344
|
+
|
298
345
|
exports.getLibraryConflict = getLibraryConflict;
|
package/lib/utils/init.js
CHANGED
@@ -4,51 +4,73 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.initPreCommitHook = exports.getGitRootDir = void 0;
|
7
|
+
|
7
8
|
var _fs = _interopRequireDefault(require("fs"));
|
9
|
+
|
8
10
|
var _path = _interopRequireDefault(require("path"));
|
11
|
+
|
9
12
|
var _child_process = require("child_process");
|
13
|
+
|
10
14
|
var _log = require("./log");
|
11
|
-
|
15
|
+
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
+
|
12
18
|
let getGitRootDir = () => {
|
13
19
|
try {
|
14
20
|
return (0, _child_process.execSync)('git rev-parse --show-toplevel').toString();
|
15
21
|
} catch (e) {
|
16
22
|
return false;
|
17
23
|
}
|
18
|
-
};
|
24
|
+
}; //eslint-disable-next-line
|
25
|
+
|
19
26
|
|
20
|
-
//eslint-disable-next-line
|
21
27
|
exports.getGitRootDir = getGitRootDir;
|
28
|
+
|
22
29
|
let copyEslintConfig = rootDir => {
|
23
30
|
rootDir = rootDir.replace(/\r?\n|\r/g, ''); //eslint-disable-line
|
31
|
+
|
24
32
|
let srcPath = _path.default.join(__dirname, '..', '..', '.eslintrc.js');
|
33
|
+
|
25
34
|
let targetPath = _path.default.join(rootDir, '.eslintrc.js');
|
35
|
+
|
26
36
|
if (!_fs.default.existsSync(targetPath)) {
|
27
37
|
let src = _fs.default.readFileSync(srcPath).toString();
|
38
|
+
|
28
39
|
_fs.default.writeFileSync(targetPath, src);
|
40
|
+
|
29
41
|
(0, _log.log)('Eslint config added in project root path');
|
30
42
|
}
|
31
43
|
};
|
44
|
+
|
32
45
|
let initPreCommitHook = (forReactCLI = false) => {
|
33
|
-
let gitRootDir = getGitRootDir();
|
34
|
-
|
46
|
+
let gitRootDir = getGitRootDir(); //copyEslintConfig(gitRootDir || process.cwd());
|
47
|
+
|
35
48
|
if (gitRootDir) {
|
36
49
|
let precommit = _fs.default.readFileSync(_path.default.join(__dirname, '../sh/pre-commit.sh')).toString();
|
50
|
+
|
37
51
|
let targetPath = _path.default.join(gitRootDir, '.git', 'hooks', 'pre-commit').replace(/\s/g, '');
|
52
|
+
|
38
53
|
if (_fs.default.existsSync(`${targetPath}.sample`)) {
|
39
|
-
precommit = precommit.replace('${PREFIX_PATH}',
|
40
|
-
//eslint-disable-line
|
54
|
+
precommit = precommit.replace('${PREFIX_PATH}', //eslint-disable-line
|
41
55
|
process.cwd().replace(/\\/g, '/'));
|
56
|
+
|
42
57
|
_fs.default.renameSync(`${targetPath}.sample`, targetPath);
|
58
|
+
|
43
59
|
_fs.default.writeFileSync(targetPath, precommit);
|
60
|
+
|
44
61
|
(0, _log.log)('pre-commit hook added');
|
45
62
|
}
|
63
|
+
|
46
64
|
let packagePath = _path.default.join(process.cwd(), 'package.json');
|
65
|
+
|
47
66
|
try {
|
48
67
|
let packageJson = require(packagePath);
|
68
|
+
|
49
69
|
if (packageJson.scripts.lint !== 'react-cli lint') {
|
50
70
|
packageJson.scripts.lint = forReactCLI ? 'eslint ./src' : 'react-cli lint';
|
71
|
+
|
51
72
|
_fs.default.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2));
|
73
|
+
|
52
74
|
(0, _log.log)('lint script added in your package.json');
|
53
75
|
}
|
54
76
|
} catch (e) {
|
@@ -56,4 +78,5 @@ let initPreCommitHook = (forReactCLI = false) => {
|
|
56
78
|
}
|
57
79
|
}
|
58
80
|
};
|
81
|
+
|
59
82
|
exports.initPreCommitHook = initPreCommitHook;
|
package/lib/utils/jsonHelper.js
CHANGED
@@ -4,11 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.setTestInfoStatus = exports.jsonHelper = exports.jsonConcate = exports.getRunnerDetail = exports.fileHandler = void 0;
|
7
|
+
|
7
8
|
let fs = require('fs');
|
9
|
+
|
8
10
|
let os = require('os');
|
11
|
+
|
9
12
|
let {
|
10
13
|
getCurrentBranch
|
11
14
|
} = require('./');
|
15
|
+
|
12
16
|
let getRunnerDetail = () => {
|
13
17
|
let defaultObj = {
|
14
18
|
jobDetails: {
|
@@ -20,13 +24,15 @@ let getRunnerDetail = () => {
|
|
20
24
|
};
|
21
25
|
return defaultObj;
|
22
26
|
};
|
27
|
+
|
23
28
|
exports.getRunnerDetail = getRunnerDetail;
|
24
|
-
let fileHandler =
|
29
|
+
let fileHandler = {
|
25
30
|
readFile: (path, callback = null) => {
|
26
31
|
if (fs.existsSync(path)) {
|
27
32
|
if (callback === null) {
|
28
33
|
return fs.readFileSync(path);
|
29
34
|
}
|
35
|
+
|
30
36
|
callback(fs.readFileSync(path));
|
31
37
|
} else {
|
32
38
|
return fileHandler.writeFile(path, getRunnerDetail());
|
@@ -37,14 +43,17 @@ let fileHandler = exports.fileHandler = {
|
|
37
43
|
return JSON.stringify(data);
|
38
44
|
}
|
39
45
|
};
|
46
|
+
exports.fileHandler = fileHandler;
|
47
|
+
|
40
48
|
const isObject = obj => obj && obj.constructor === {}.constructor;
|
41
|
-
const isArray = obj => obj && obj.constructor === [].constructor;
|
42
49
|
|
43
|
-
// In below funtion
|
50
|
+
const isArray = obj => obj && obj.constructor === [].constructor; // In below funtion
|
44
51
|
// this function is for concat two json object like _.extend,
|
45
52
|
// if botha array we concat them
|
46
53
|
// if both object we use call this function recurcively
|
47
54
|
// if both differend data type we will just assign it
|
55
|
+
|
56
|
+
|
48
57
|
let jsonConcate = (receiverObj, senterObj) => {
|
49
58
|
Object.keys(senterObj).map(key => {
|
50
59
|
if (Object.prototype.hasOwnProperty.call(receiverObj, key)) {
|
@@ -58,30 +67,40 @@ let jsonConcate = (receiverObj, senterObj) => {
|
|
58
67
|
} else {
|
59
68
|
receiverObj[key] = senterObj[key];
|
60
69
|
}
|
70
|
+
|
61
71
|
return key;
|
62
72
|
});
|
63
73
|
return receiverObj;
|
64
74
|
};
|
75
|
+
|
65
76
|
exports.jsonConcate = jsonConcate;
|
77
|
+
|
66
78
|
let jsonHelper = (path, pathArray, value) => {
|
67
79
|
let tempObj = {};
|
80
|
+
|
68
81
|
if (typeof pathArray === 'string') {
|
69
82
|
pathArray = pathArray.split('.'); //eslint-disable-line no-param-reassign
|
70
83
|
}
|
84
|
+
|
71
85
|
pathArray.slice(0).reverse().map(key => {
|
72
86
|
tempObj = {};
|
73
87
|
tempObj[key] = value;
|
74
88
|
value = tempObj; // eslint-disable-line no-param-reassign
|
89
|
+
|
75
90
|
return key;
|
76
91
|
});
|
77
92
|
let overAllObj = jsonConcate(JSON.parse(fileHandler.readFile(path)), tempObj);
|
78
93
|
fileHandler.writeFile(path, overAllObj);
|
79
94
|
};
|
95
|
+
|
80
96
|
exports.jsonHelper = jsonHelper;
|
97
|
+
|
81
98
|
let setTestInfoStatus = (filepath, status) => {
|
82
99
|
let buildObject = JSON.parse(fileHandler.readFile(filepath));
|
100
|
+
|
83
101
|
if (!buildObject.testInfo || buildObject.testInfo.isBuildVerified !== false) {
|
84
102
|
jsonHelper(filepath, 'testInfo.isBuildVerified', status);
|
85
103
|
}
|
86
104
|
};
|
105
|
+
|
87
106
|
exports.setTestInfoStatus = setTestInfoStatus;
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
+
|
7
8
|
var _utils = require("../utils");
|
9
|
+
|
8
10
|
let options = (0, _utils.getOptions)();
|
9
11
|
let {
|
10
12
|
impactService: {
|
@@ -16,7 +18,7 @@ let {
|
|
16
18
|
sourceServiceName
|
17
19
|
}
|
18
20
|
} = options;
|
19
|
-
var _default =
|
21
|
+
var _default = {
|
20
22
|
AppSource: {
|
21
23
|
impactService: sourceServiceName,
|
22
24
|
gitDomain: "ht" + "tps://zgit.csez.zohocorpin.com",
|
@@ -57,4 +59,5 @@ var _default = exports.default = {
|
|
57
59
|
impactDomain: "ht" + "tp://desk-automation.csez.zohocorpin.com:8080",
|
58
60
|
name: "@zohodesk/variables"
|
59
61
|
}
|
60
|
-
};
|
62
|
+
};
|
63
|
+
exports.default = _default;
|
@@ -1,24 +1,27 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
const fs = require('fs');
|
4
|
+
|
4
5
|
const {
|
5
6
|
log
|
6
7
|
} = require('..');
|
8
|
+
|
7
9
|
function addScripts(scripts) {
|
8
10
|
fs.readFile('./package.json', 'utf8', (err, configFileString) => {
|
9
11
|
if (err) log('[LINT SETUP] No package.json in the current directory');else {
|
10
|
-
const configFile = JSON.parse(configFileString);
|
11
|
-
// Still Object destructuring causes issue. 😐
|
12
|
+
const configFile = JSON.parse(configFileString); // Still Object destructuring causes issue. 😐
|
12
13
|
// configFile.scripts = {
|
13
14
|
// ...configFile.scripts,
|
14
15
|
// ...scripts,
|
15
16
|
// };
|
17
|
+
|
16
18
|
configFile.scripts = Object.assign(configFile.scripts || {}, scripts);
|
17
19
|
const data = JSON.stringify(configFile, undefined, 2);
|
18
20
|
fs.writeFileSync('./package.json', data);
|
19
21
|
}
|
20
22
|
});
|
21
23
|
}
|
24
|
+
|
22
25
|
module.exports = {
|
23
26
|
addScripts
|
24
27
|
};
|
@@ -1,30 +1,35 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
/* eslint-disable operator-linebreak */
|
4
|
+
|
4
5
|
/* eslint-disable implicit-arrow-linebreak */
|
5
6
|
const fs = require('fs');
|
7
|
+
|
6
8
|
const {
|
7
9
|
log
|
8
10
|
} = require('..');
|
11
|
+
|
9
12
|
const {
|
10
13
|
question,
|
11
14
|
rl
|
12
15
|
} = require('./question');
|
16
|
+
|
13
17
|
const eslintConfigFiles = ['.eslintrc.js', '.eslintrc.cjs', '.eslintrc.yaml', '.eslintrc.yml', '.eslintrc.json', '.eslintrc'];
|
14
18
|
const prettierConfigFiles = ['.prettierrc.js', '.prettierrc.json', '.prettierrc', '.prettierrc.yml', '.prettierrc.yaml', '.prettierrc.json5', '.prettierrc.toml', '.prettierrc.cjs', '.prettier.config.js', '.prettier.config.cjs'];
|
19
|
+
|
15
20
|
function isConfigExists(fileNames) {
|
16
21
|
return fileNames.find(file => {
|
17
22
|
if (fs.existsSync(file)) return true;
|
18
23
|
return false;
|
19
24
|
});
|
20
25
|
}
|
26
|
+
|
21
27
|
async function checkConflicts(files) {
|
22
28
|
const conflictFile = isConfigExists(files);
|
29
|
+
|
23
30
|
if (conflictFile) {
|
24
31
|
log(`[LINT SETUP] There's already a config exists as named ${conflictFile}`);
|
25
|
-
const res = await question('[LINT SETUP] Do you want to overwrite? (y/n): ');
|
26
|
-
|
27
|
-
// TODO: Next cycle: Need to delete the current config file.
|
32
|
+
const res = await question('[LINT SETUP] Do you want to overwrite? (y/n): '); // TODO: Next cycle: Need to delete the current config file.
|
28
33
|
// if (res === 'y') {
|
29
34
|
// exec(`rm ${conflictFile}`, (err) => {
|
30
35
|
// if (err) log(err);
|
@@ -36,12 +41,15 @@ async function checkConflicts(files) {
|
|
36
41
|
|
37
42
|
return res;
|
38
43
|
}
|
44
|
+
|
39
45
|
return false;
|
40
46
|
}
|
47
|
+
|
41
48
|
async function promptForPreCommitHook() {
|
42
49
|
const res = await question('[LINT SETUP] Do you need a pre-commit hook for formatting and check lint errors in cached files (newly changed)? (y/n): ');
|
43
50
|
return res;
|
44
51
|
}
|
52
|
+
|
45
53
|
const getChoices = async () => {
|
46
54
|
const eslint = await checkConflicts(eslintConfigFiles);
|
47
55
|
const prettier = await checkConflicts(prettierConfigFiles);
|
@@ -51,6 +59,7 @@ const getChoices = async () => {
|
|
51
59
|
rl.close();
|
52
60
|
return [isESLintAllowed, isPrettierAllowed, isHookInstallEnabled];
|
53
61
|
};
|
62
|
+
|
54
63
|
module.exports = {
|
55
64
|
eslintConfigFiles,
|
56
65
|
prettierConfigFiles,
|
@@ -1,9 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
const fs = require('fs');
|
4
|
+
|
4
5
|
const {
|
5
6
|
log
|
6
7
|
} = require('..');
|
8
|
+
|
7
9
|
async function copyConfigs(file) {
|
8
10
|
// copy the file in react-cli to current working directory
|
9
11
|
fs.readFile(require.resolve(`../../../files/${file}.js`), (err, data) => {
|
@@ -18,4 +20,5 @@ async function copyConfigs(file) {
|
|
18
20
|
}
|
19
21
|
});
|
20
22
|
}
|
23
|
+
|
21
24
|
module.exports = copyConfigs;
|
package/lib/utils/lint/index.js
CHANGED
@@ -7,29 +7,37 @@ const {
|
|
7
7
|
runInstall,
|
8
8
|
installLintStaged
|
9
9
|
} = require('./lintSetup');
|
10
|
+
|
10
11
|
const {
|
11
12
|
log
|
12
13
|
} = require('..');
|
14
|
+
|
13
15
|
const {
|
14
16
|
eslintConfigFiles,
|
15
17
|
prettierConfigFiles,
|
16
18
|
getChoices
|
17
19
|
} = require('./checkExistingConfig');
|
20
|
+
|
18
21
|
const copyConfigs = require('./copyConfigs');
|
22
|
+
|
19
23
|
async function main() {
|
20
24
|
const packages = [];
|
21
25
|
const [isESLintAllowed, isPrettierAllowed, isHookInstallEnabled] = await getChoices();
|
26
|
+
|
22
27
|
if (isESLintAllowed) {
|
23
28
|
copyConfigs('eslintrc', eslintConfigFiles);
|
24
29
|
packages.push(...eslintPackages);
|
25
30
|
}
|
31
|
+
|
26
32
|
if (isPrettierAllowed) {
|
27
33
|
copyConfigs('prettierrc', prettierConfigFiles);
|
28
34
|
packages.push(...prettierPackages);
|
29
35
|
}
|
36
|
+
|
30
37
|
if (isESLintAllowed && isPrettierAllowed) {
|
31
38
|
packages.push(...eslintPrettierConfig);
|
32
39
|
}
|
40
|
+
|
33
41
|
if (packages.length) {
|
34
42
|
const process = runInstall(packages);
|
35
43
|
process.on('close', () => {
|
@@ -41,5 +49,6 @@ async function main() {
|
|
41
49
|
installLintStaged();
|
42
50
|
}
|
43
51
|
}
|
52
|
+
|
44
53
|
log('[LINT SETUP] Beginning configuration...');
|
45
54
|
main();
|
@@ -3,6 +3,7 @@
|
|
3
3
|
const {
|
4
4
|
addScripts
|
5
5
|
} = require('./addScripts');
|
6
|
+
|
6
7
|
const scripts = {
|
7
8
|
lintSetup: 'react-cli lint-setup && npm run lintExtInstall && echo "If changes not reflected kindly restart your VSCode."',
|
8
9
|
lintExtInstall: 'code --install-extension dbaeumer.vscode-eslint && code --install-extension esbenp.prettier-vscode'
|
@@ -3,11 +3,10 @@
|
|
3
3
|
const {
|
4
4
|
spawn
|
5
5
|
} = require('child_process');
|
6
|
+
|
6
7
|
const eslintPackages = ['eslint@7.18.0', 'eslint-config-airbnb@18.2.1', 'eslint-plugin-import@2.22.1', 'eslint-plugin-jsx-a11y@6.4.1', 'eslint-plugin-react@7.22.0', 'eslint-plugin-css-modules@2.11.0', '@zohodesk/eslint-plugin-react-performance@1.0.3', '@zohodesk/eslint-plugin-zsecurity@0.0.1-beta.4', 'eslint-plugin-react-hooks@4.2.0'];
|
7
8
|
const prettierPackages = ['prettier@2.2.1'];
|
8
|
-
const eslintPrettierConfig = ['eslint-config-prettier@7.2.0'];
|
9
|
-
|
10
|
-
// const npmInstall = `npm i --save-dev ${devDependencies.join(' ')}`;
|
9
|
+
const eslintPrettierConfig = ['eslint-config-prettier@7.2.0']; // const npmInstall = `npm i --save-dev ${devDependencies.join(' ')}`;
|
11
10
|
|
12
11
|
function runInstall(packages) {
|
13
12
|
return spawn('npm', ['i', ...packages, '--save-dev'], {
|
@@ -15,12 +14,14 @@ function runInstall(packages) {
|
|
15
14
|
stdio: 'inherit'
|
16
15
|
});
|
17
16
|
}
|
17
|
+
|
18
18
|
function installLintStaged() {
|
19
19
|
spawn('npx', ['mrm', 'lint-staged'], {
|
20
20
|
detached: true,
|
21
21
|
stdio: 'inherit'
|
22
22
|
});
|
23
23
|
}
|
24
|
+
|
24
25
|
module.exports = {
|
25
26
|
eslintPackages,
|
26
27
|
prettierPackages,
|
@@ -1,22 +1,29 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
/* eslint-disable no-await-in-loop */
|
4
|
+
|
4
5
|
/* eslint-disable implicit-arrow-linebreak */
|
5
6
|
const readline = require('readline');
|
7
|
+
|
6
8
|
const rl = readline.createInterface({
|
7
9
|
input: process.stdin,
|
8
10
|
output: process.stdout
|
9
11
|
});
|
12
|
+
|
10
13
|
const question = qn => new Promise(res => {
|
11
14
|
rl.question(qn, ans => res(ans));
|
12
15
|
});
|
16
|
+
|
13
17
|
async function main(qn) {
|
14
18
|
let answer;
|
19
|
+
|
15
20
|
while (!['n', 'y'].includes(answer)) {
|
16
21
|
answer = (await question(qn)).toLowerCase();
|
17
22
|
}
|
23
|
+
|
18
24
|
return answer;
|
19
25
|
}
|
26
|
+
|
20
27
|
module.exports = {
|
21
28
|
question: main,
|
22
29
|
rl
|