@zohodesk/react-cli 0.0.1-exp.175.1 → 0.0.1-exp.176.1
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 +7 -7
- package/.eslintrc.js +180 -180
- package/.prettierrc +6 -6
- package/README.md +1025 -1028
- package/bin/cli.js +482 -482
- package/cert/Tsicsezwild-22-23.crt +37 -37
- package/cert/Tsicsezwild-22-23.key +27 -27
- package/docs/CustomChunks.md +26 -26
- package/docs/DevStart.md +18 -18
- package/docs/HoverActive.md +12 -12
- package/docs/InstallNode.md +28 -28
- package/docs/SelectorWeight.md +6 -0
- package/docs/TODOS.md +10 -10
- package/docs/ValueReplacer.md +60 -60
- package/docs/VariableConversion.md +719 -678
- package/docs/warnings_while_install.txt +35 -35
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- package/lib/babel/cmjs-plugins-presets.js +4 -0
- package/lib/babel/es-plugins-presets.js +4 -0
- package/lib/common/getEntries.js +10 -0
- package/lib/common/getPublicPathConfig.js +6 -0
- package/lib/common/index.js +5 -0
- package/lib/common/splitChunks.js +13 -2
- package/lib/common/sslcertUpdater.js +17 -6
- package/lib/common/templateParameters.js +2 -0
- package/lib/common/testPattern.js +21 -10
- package/lib/common/valueReplacer.js +15 -0
- package/lib/configs/jest.config.js +9 -0
- package/lib/configs/libAlias.js +2 -4
- package/lib/configs/webpack.component.umd.config.js +5 -0
- package/lib/configs/webpack.css.umd.config.js +13 -5
- package/lib/configs/webpack.dev.config.js +36 -2
- package/lib/configs/webpack.docs.config.js +21 -1
- package/lib/configs/webpack.impact.config.js +19 -1
- package/lib/configs/webpack.prod.config.js +37 -3
- package/lib/hooks/docsProptypeHook.js +7 -3
- package/lib/jest/commitedFilesResult.js +45 -3
- package/lib/jest/coverageCollector.js +11 -0
- package/lib/jest/jsonMaker.js +6 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +8 -0
- package/lib/jest/preProcessors/jsPreprocessor.js +2 -0
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +3 -0
- package/lib/jest/result.js +22 -0
- package/lib/jest/run.js +17 -6
- package/lib/jest/setup.js +57 -5
- package/lib/loaderUtils/configsAssetsLoaders.js +44 -34
- package/lib/loaderUtils/getCSSLoaders.js +35 -20
- package/lib/loaderUtils/getDevJsLoaders.js +8 -0
- package/lib/loaderUtils/index.js +3 -0
- package/lib/loaderUtils/windowsModification.js +11 -0
- package/lib/loaders/docsLoader.js +7 -0
- package/lib/loaders/docsPropsLoader.js +7 -3
- package/lib/loaders/fileBountryLoader.js +2 -0
- package/lib/loaders/fileLoader.js +22 -11
- package/lib/loaders/scriptInstrumentLoader.js +13 -5
- package/lib/loaders/selectorMappingLoader.js +25 -7
- package/lib/loaders/workerLoader.js +29 -13
- package/lib/middlewares/HMRMiddleware.js +26 -13
- package/lib/middlewares/SSTMiddleware.js +3 -0
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +9 -3
- package/lib/pluginUtils/getDevPlugins.js +68 -22
- package/lib/pluginUtils/getDocsPlugins.js +10 -1
- package/lib/pluginUtils/getLibraryImactPlugins.js +5 -4
- package/lib/pluginUtils/getLibraryPlugins.js +5 -0
- package/lib/pluginUtils/getProdPlugins.js +77 -28
- package/lib/pluginUtils/getServerPlugins.js +5 -0
- package/lib/pluginUtils/getUMDCSSPlugins.js +7 -0
- package/lib/pluginUtils/getUMDComponentPlugins.js +7 -0
- package/lib/pluginUtils/index.js +8 -0
- package/lib/plugins/CdnChangePlugin.js +14 -0
- package/lib/plugins/CleanupStatsPlugin.js +5 -0
- package/lib/plugins/EFCPlugin.js +34 -23
- package/lib/plugins/EFCPlugin.md +6 -6
- package/lib/plugins/EFCTemplatePlugin.js +32 -23
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +38 -12
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +17 -12
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +77 -46
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +59 -44
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +30 -21
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
- package/lib/plugins/I18nSplitPlugin/README.md +25 -25
- package/lib/plugins/I18nSplitPlugin/index.js +80 -70
- 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 +6 -0
- package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -2
- package/lib/plugins/ManifestPlugin.js +17 -0
- package/lib/plugins/ModuleStatsPlugin.js +23 -0
- package/lib/plugins/OptimizeJSPlugin.js +7 -0
- package/lib/plugins/PublicPathCallbackPlugin.js +10 -0
- package/lib/plugins/PublicPathChangePlugin.js +36 -4
- package/lib/plugins/ReportGeneratePlugin.js +30 -4
- package/lib/plugins/RequireVariablePublicPlugin.js +6 -0
- package/lib/plugins/ResourceHintsPlugin.js +27 -20
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +22 -15
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
- package/lib/plugins/ScriptInstrumentPlugin.js +7 -0
- package/lib/plugins/SelectorPlugin.js +97 -0
- package/lib/plugins/ServiceWorkerPlugin.js +29 -13
- package/lib/plugins/ShadowDOMSupportPlugin.js +40 -3
- package/lib/plugins/SourceMapHookPlugin.js +9 -0
- package/lib/plugins/TPHashMappingPlugin.js +19 -5
- package/lib/plugins/UglifyCSSPlugin.js +9 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +35 -2
- package/lib/plugins/VariableConversionCollector.js +322 -0
- package/lib/plugins/composeCommonPlugin.js +30 -0
- package/lib/plugins/index.js +19 -0
- package/lib/plugins/libraryImpactPlugin.js +32 -0
- package/lib/plugins/webpackwatchrunplugin.js +5 -0
- package/lib/postcss-plugins/ExcludePlugin.js +4 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +37 -24
- package/lib/postcss-plugins/ValueReplacer.js +6 -9
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
- package/lib/postcss-plugins/__test__/test1Input.css +38 -38
- package/lib/postcss-plugins/__test__/test1Output.css +38 -38
- package/lib/postcss-plugins/hoverActivePlugin.js +69 -33
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +42 -13
- package/lib/postcss-plugins/variableModificationPlugin/index.js +216 -141
- package/lib/postcss-plugins/variableModifier.js +20 -13
- package/lib/schemas/index.js +23 -4
- package/lib/servers/clusterHubServer.js +10 -0
- package/lib/servers/devBuild.js +24 -13
- package/lib/servers/docsServer.js +2 -0
- package/lib/servers/docsServerCore.js +21 -0
- package/lib/servers/getCliPath.js +9 -0
- package/lib/servers/helpServer.js +5 -0
- package/lib/servers/httpsOptions.js +4 -0
- package/lib/servers/impactServer.js +34 -2
- package/lib/servers/mockserver.js +9 -0
- package/lib/servers/nowatchserver.js +34 -12
- package/lib/servers/scrServer.js +20 -13
- package/lib/servers/server.js +35 -7
- package/lib/servers/ssServer.js +16 -0
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -45
- package/lib/templates/CoverageScriptTemplate.js +14 -0
- package/lib/templates/WMSTemplate.js +12 -6
- package/lib/utils/babelPresets.js +2 -0
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/clean.js +8 -2
- package/lib/utils/copy.js +6 -0
- package/lib/utils/copyTimezones.js +8 -0
- package/lib/utils/createEventStream.js +4 -0
- package/lib/utils/cssClassNameGenerate.js +19 -3
- package/lib/utils/cssURLReplacer.js +25 -0
- package/lib/utils/dependencyPostPublish.js +9 -0
- package/lib/utils/fileUtils.js +26 -0
- package/lib/utils/folderIterator.js +10 -0
- package/lib/utils/getComponents.js +21 -0
- package/lib/utils/getCurrentBranch.js +5 -0
- package/lib/utils/getDependenciesImpactList.js +21 -0
- package/lib/utils/getHash.js +7 -0
- package/lib/utils/getIp.js +2 -0
- package/lib/utils/getOptions.js +39 -14
- package/lib/utils/getServerURL.js +7 -0
- package/lib/utils/index.js +47 -2
- package/lib/utils/init.js +1 -0
- package/lib/utils/initPreCommitHook.js +29 -6
- package/lib/utils/jsonHelper.js +19 -2
- package/lib/utils/libraryImpactConfig.js +2 -0
- 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/mailSender.js +7 -0
- package/lib/utils/pullOrigin.js +4 -0
- package/lib/utils/reinstallDependencies.js +28 -0
- package/lib/utils/removeAttributes.js +7 -0
- package/lib/utils/repoClone.js +27 -2
- package/lib/utils/request.js +12 -0
- package/lib/utils/resultSchema.json +73 -73
- package/lib/utils/rtl.js +16 -4
- package/lib/utils/setEnvVariables.js +2 -0
- package/lib/utils/ssTestHack.js +10 -0
- package/lib/utils/switchBranch.js +4 -0
- package/lib/utils/urlConcat.js +4 -0
- package/lib/utils/useExitCleanup.js +10 -9
- package/npm8.md +9 -9
- package/package.json +146 -146
- package/postpublish.js +6 -6
- package/templates/app/.eslintrc.js +140 -140
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -24
- 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 -18
- package/templates/app/package.json +37 -37
- package/templates/app/src/actions/SampleActions/index.js +37 -37
- package/templates/app/src/actions/index.js +65 -65
- package/templates/app/src/appUrls.js +19 -19
- package/templates/app/src/components/Alert/Alert.js +134 -134
- package/templates/app/src/components/Alert/Alert.module.css +79 -79
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
- package/templates/app/src/components/Sample/Sample.module.css +11 -11
- package/templates/app/src/components/Sample/SampleList.js +61 -61
- package/templates/app/src/components/Slider/Slider.css +41 -41
- package/templates/app/src/components/Slider/Slider.js +55 -55
- package/templates/app/src/containers/AlertContainer/index.js +15 -15
- package/templates/app/src/containers/AppContainer/index.js +96 -96
- package/templates/app/src/containers/AppContainer/index.module.css +27 -27
- package/templates/app/src/containers/CustomMatch/index.js +65 -65
- package/templates/app/src/containers/DevTools/index.js +10 -10
- package/templates/app/src/containers/Header/index.js +67 -67
- package/templates/app/src/containers/Header/index.module.css +43 -43
- package/templates/app/src/containers/Redirect/index.js +63 -63
- package/templates/app/src/containers/Redirector/index.js +47 -47
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
- package/templates/app/src/historyChange.js +5 -5
- package/templates/app/src/index.html +10 -10
- package/templates/app/src/index.js +24 -24
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
- package/templates/app/src/reducers/alertData.js +11 -11
- package/templates/app/src/reducers/index.js +6 -6
- package/templates/app/src/reducers/samples.js +19 -19
- package/templates/app/src/store/configureStore.dev.js +51 -51
- package/templates/app/src/store/configureStore.js +5 -5
- package/templates/app/src/store/configureStore.prod.js +26 -26
- package/templates/app/src/util/Common.js +5 -5
- package/templates/app/src/util/RequestAPI.js +132 -132
- package/templates/docs/all.html +249 -249
- package/templates/docs/component.html +178 -178
- package/templates/docs/components.html +221 -221
- package/templates/docs/css/b.min.css +6 -6
- package/templates/docs/css/component.css +42 -42
- package/templates/docs/css/componentTest.css +6 -6
- package/templates/docs/css/hopscotch.css +585 -585
- package/templates/docs/css/style.css +1022 -1022
- package/templates/docs/impactReportTemplate.html +154 -154
- package/templates/docs/index.html +1501 -1501
- package/templates/docs/js/active-line.js +72 -72
- package/templates/docs/js/b.min.js +7 -7
- package/templates/docs/js/codemirror.js +9680 -9680
- package/templates/docs/js/designTokens.js +334 -334
- package/templates/docs/js/j.min.js +4 -4
- package/templates/docs/js/javascript.js +874 -874
- package/templates/docs/js/matchbrackets.js +145 -145
package/lib/utils/index.js
CHANGED
|
@@ -90,17 +90,29 @@ Object.defineProperty(exports, "switchBranch", {
|
|
|
90
90
|
}
|
|
91
91
|
});
|
|
92
92
|
exports.writeFile = void 0;
|
|
93
|
+
|
|
93
94
|
var _stream = require("stream");
|
|
95
|
+
|
|
94
96
|
var _fs = _interopRequireDefault(require("fs"));
|
|
97
|
+
|
|
95
98
|
var _getOptions = _interopRequireDefault(require("./getOptions"));
|
|
99
|
+
|
|
96
100
|
var _createEventStream = _interopRequireDefault(require("./createEventStream"));
|
|
101
|
+
|
|
97
102
|
var _getServerURL = _interopRequireDefault(require("./getServerURL"));
|
|
103
|
+
|
|
98
104
|
var _getCurrentBranch = _interopRequireDefault(require("./getCurrentBranch"));
|
|
105
|
+
|
|
99
106
|
var _switchBranch = _interopRequireDefault(require("./switchBranch"));
|
|
107
|
+
|
|
100
108
|
var _pullOrigin = _interopRequireDefault(require("./pullOrigin"));
|
|
109
|
+
|
|
101
110
|
var _request = _interopRequireDefault(require("./request"));
|
|
111
|
+
|
|
102
112
|
var _jsonHelper = _interopRequireDefault(require("./jsonHelper"));
|
|
113
|
+
|
|
103
114
|
var _reinstallDependencies = require("./reinstallDependencies");
|
|
115
|
+
|
|
104
116
|
Object.keys(_reinstallDependencies).forEach(function (key) {
|
|
105
117
|
if (key === "default" || key === "__esModule") return;
|
|
106
118
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -112,7 +124,9 @@ Object.keys(_reinstallDependencies).forEach(function (key) {
|
|
|
112
124
|
}
|
|
113
125
|
});
|
|
114
126
|
});
|
|
127
|
+
|
|
115
128
|
var _cssURLReplacer = require("./cssURLReplacer");
|
|
129
|
+
|
|
116
130
|
Object.keys(_cssURLReplacer).forEach(function (key) {
|
|
117
131
|
if (key === "default" || key === "__esModule") return;
|
|
118
132
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -124,7 +138,9 @@ Object.keys(_cssURLReplacer).forEach(function (key) {
|
|
|
124
138
|
}
|
|
125
139
|
});
|
|
126
140
|
});
|
|
141
|
+
|
|
127
142
|
var _initPreCommitHook = require("./initPreCommitHook");
|
|
143
|
+
|
|
128
144
|
Object.keys(_initPreCommitHook).forEach(function (key) {
|
|
129
145
|
if (key === "default" || key === "__esModule") return;
|
|
130
146
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -136,26 +152,38 @@ Object.keys(_initPreCommitHook).forEach(function (key) {
|
|
|
136
152
|
}
|
|
137
153
|
});
|
|
138
154
|
});
|
|
155
|
+
|
|
139
156
|
var _getDependenciesImpactList = _interopRequireDefault(require("./getDependenciesImpactList"));
|
|
157
|
+
|
|
140
158
|
var _getComponents = _interopRequireDefault(require("./getComponents"));
|
|
159
|
+
|
|
141
160
|
var _ssTestHack = _interopRequireDefault(require("./ssTestHack"));
|
|
161
|
+
|
|
142
162
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
163
|
+
|
|
143
164
|
let log = (...info) => {
|
|
144
165
|
let print = console;
|
|
145
166
|
print.log(...info);
|
|
146
167
|
};
|
|
168
|
+
|
|
147
169
|
exports.log = log;
|
|
170
|
+
|
|
148
171
|
let writeFile = (outputPath, src, isPath = false) => new Promise((resolve, reject) => {
|
|
149
172
|
let inStr;
|
|
173
|
+
|
|
150
174
|
if (isPath) {
|
|
151
175
|
inStr = _fs.default.createReadStream(src);
|
|
152
176
|
} else {
|
|
153
177
|
inStr = new _stream.Readable();
|
|
178
|
+
|
|
154
179
|
inStr._read = () => true;
|
|
180
|
+
|
|
155
181
|
inStr.push(src);
|
|
156
182
|
inStr.push(null);
|
|
157
183
|
}
|
|
184
|
+
|
|
158
185
|
let outStr = _fs.default.createWriteStream(outputPath);
|
|
186
|
+
|
|
159
187
|
outStr.on('error', err => {
|
|
160
188
|
reject(err);
|
|
161
189
|
});
|
|
@@ -164,26 +192,33 @@ let writeFile = (outputPath, src, isPath = false) => new Promise((resolve, rejec
|
|
|
164
192
|
});
|
|
165
193
|
inStr.pipe(outStr);
|
|
166
194
|
});
|
|
195
|
+
|
|
167
196
|
exports.writeFile = writeFile;
|
|
197
|
+
|
|
168
198
|
let makeDir = paths => {
|
|
169
199
|
if (typeof paths === 'string') {
|
|
170
200
|
//eslint-disable-next-line
|
|
171
201
|
paths = [paths];
|
|
172
202
|
}
|
|
203
|
+
|
|
173
204
|
paths.forEach(path => {
|
|
174
205
|
if (!_fs.default.existsSync(path)) {
|
|
175
206
|
_fs.default.mkdirSync(path);
|
|
176
207
|
}
|
|
177
208
|
});
|
|
178
209
|
};
|
|
210
|
+
|
|
179
211
|
exports.makeDir = makeDir;
|
|
212
|
+
|
|
180
213
|
let getInfoFromPublicPaths = publicPaths => {
|
|
181
214
|
let rootFolder = '',
|
|
182
|
-
|
|
183
|
-
|
|
215
|
+
image = '',
|
|
216
|
+
font = '';
|
|
217
|
+
|
|
184
218
|
if (publicPaths && !Array.isArray(publicPaths) && typeof publicPaths === 'object' && !publicPaths.callback) {
|
|
185
219
|
let [cdn] = Object.keys(publicPaths);
|
|
186
220
|
rootFolder = `${cdn}/`;
|
|
221
|
+
|
|
187
222
|
if (publicPaths[cdn].font) {
|
|
188
223
|
font = publicPaths[cdn].font; //eslint-disable-line
|
|
189
224
|
}
|
|
@@ -199,7 +234,9 @@ let getInfoFromPublicPaths = publicPaths => {
|
|
|
199
234
|
font
|
|
200
235
|
};
|
|
201
236
|
};
|
|
237
|
+
|
|
202
238
|
exports.getInfoFromPublicPaths = getInfoFromPublicPaths;
|
|
239
|
+
|
|
203
240
|
let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
|
|
204
241
|
let srcChanges = [];
|
|
205
242
|
let libraryChanges = [];
|
|
@@ -213,6 +250,7 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
|
|
|
213
250
|
if (action !== 'REMOVED') {
|
|
214
251
|
impactObj[library][action].forEach(srcObject => {
|
|
215
252
|
let fileName = srcObject["FILEPATH"];
|
|
253
|
+
|
|
216
254
|
if (library == "AppSource") {
|
|
217
255
|
fileName = fileName.replace("jsapps/supportapp", ".");
|
|
218
256
|
srcChanges.push(fileName);
|
|
@@ -224,8 +262,10 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
|
|
|
224
262
|
}
|
|
225
263
|
});
|
|
226
264
|
});
|
|
265
|
+
|
|
227
266
|
if (!changesOnly) {
|
|
228
267
|
srcChanges = [];
|
|
268
|
+
|
|
229
269
|
if (libraryChanges.length > 0) {
|
|
230
270
|
libraryChanges.forEach(mdataLibKey => {
|
|
231
271
|
if (moduleObject[mdataLibKey]) {
|
|
@@ -240,11 +280,13 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
|
|
|
240
280
|
});
|
|
241
281
|
} else {}
|
|
242
282
|
}
|
|
283
|
+
|
|
243
284
|
if (srcChanges.length > 0) {
|
|
244
285
|
srcChanges.forEach(srcFile => {
|
|
245
286
|
let cacheObject = {};
|
|
246
287
|
cacheObject.sourceName = srcFile;
|
|
247
288
|
let cacheLibraryList = [];
|
|
289
|
+
|
|
248
290
|
if (libraryChanges.length > 0) {
|
|
249
291
|
libraryChanges.forEach(mdataKey => {
|
|
250
292
|
if (moduleObject[mdataKey]) {
|
|
@@ -258,6 +300,7 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
|
|
|
258
300
|
impactThere = false;
|
|
259
301
|
whichLibrary = 'No library file changes between target branch!';
|
|
260
302
|
}
|
|
303
|
+
|
|
261
304
|
if (cacheLibraryList.length > 0) {
|
|
262
305
|
cacheObject.impactedBy = cacheLibraryList;
|
|
263
306
|
allImpactArray.push(cacheObject);
|
|
@@ -270,6 +313,7 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
|
|
|
270
313
|
impactThere = false;
|
|
271
314
|
whichLibrary = "No component file changes!";
|
|
272
315
|
}
|
|
316
|
+
|
|
273
317
|
log('\n');
|
|
274
318
|
log('You can see the HTML out at coverageTest/impactLibrary.html!');
|
|
275
319
|
log('\x1b[33m%s\x1b[0m', '************************************************************ \n ');
|
|
@@ -281,4 +325,5 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
|
|
|
281
325
|
}
|
|
282
326
|
};
|
|
283
327
|
};
|
|
328
|
+
|
|
284
329
|
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 _index = require("./index");
|
|
15
|
+
|
|
11
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, _index.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, _index.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, _index.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,6 +24,7 @@ let getRunnerDetail = () => {
|
|
|
20
24
|
};
|
|
21
25
|
return defaultObj;
|
|
22
26
|
};
|
|
27
|
+
|
|
23
28
|
exports.getRunnerDetail = getRunnerDetail;
|
|
24
29
|
let fileHandler = {
|
|
25
30
|
readFile: (path, callback = null) => {
|
|
@@ -27,6 +32,7 @@ let fileHandler = {
|
|
|
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());
|
|
@@ -38,14 +44,16 @@ let fileHandler = {
|
|
|
38
44
|
}
|
|
39
45
|
};
|
|
40
46
|
exports.fileHandler = fileHandler;
|
|
47
|
+
|
|
41
48
|
const isObject = obj => obj && obj.constructor === {}.constructor;
|
|
42
|
-
const isArray = obj => obj && obj.constructor === [].constructor;
|
|
43
49
|
|
|
44
|
-
// In below funtion
|
|
50
|
+
const isArray = obj => obj && obj.constructor === [].constructor; // In below funtion
|
|
45
51
|
// this function is for concat two json object like _.extend,
|
|
46
52
|
// if botha array we concat them
|
|
47
53
|
// if both object we use call this function recurcively
|
|
48
54
|
// if both differend data type we will just assign it
|
|
55
|
+
|
|
56
|
+
|
|
49
57
|
let jsonConcate = (receiverObj, senterObj) => {
|
|
50
58
|
Object.keys(senterObj).map(key => {
|
|
51
59
|
if (Object.prototype.hasOwnProperty.call(receiverObj, key)) {
|
|
@@ -59,13 +67,17 @@ let jsonConcate = (receiverObj, senterObj) => {
|
|
|
59
67
|
} else {
|
|
60
68
|
receiverObj[key] = senterObj[key];
|
|
61
69
|
}
|
|
70
|
+
|
|
62
71
|
return key;
|
|
63
72
|
});
|
|
64
73
|
return receiverObj;
|
|
65
74
|
};
|
|
75
|
+
|
|
66
76
|
exports.jsonConcate = jsonConcate;
|
|
77
|
+
|
|
67
78
|
let jsonHelper = (path, pathArray, value) => {
|
|
68
79
|
let tempObj = {};
|
|
80
|
+
|
|
69
81
|
if (typeof pathArray === 'string') {
|
|
70
82
|
pathArray = pathArray.split('.'); //eslint-disable-line no-param-reassign
|
|
71
83
|
}
|
|
@@ -74,16 +86,21 @@ let jsonHelper = (path, pathArray, value) => {
|
|
|
74
86
|
tempObj = {};
|
|
75
87
|
tempObj[key] = value;
|
|
76
88
|
value = tempObj; // eslint-disable-line no-param-reassign
|
|
89
|
+
|
|
77
90
|
return key;
|
|
78
91
|
});
|
|
79
92
|
let overAllObj = jsonConcate(JSON.parse(fileHandler.readFile(path)), tempObj);
|
|
80
93
|
fileHandler.writeFile(path, overAllObj);
|
|
81
94
|
};
|
|
95
|
+
|
|
82
96
|
exports.jsonHelper = jsonHelper;
|
|
97
|
+
|
|
83
98
|
let setTestInfoStatus = (filepath, status) => {
|
|
84
99
|
let buildObject = JSON.parse(fileHandler.readFile(filepath));
|
|
100
|
+
|
|
85
101
|
if (!buildObject.testInfo || buildObject.testInfo.isBuildVerified !== false) {
|
|
86
102
|
jsonHelper(filepath, 'testInfo.isBuildVerified', status);
|
|
87
103
|
}
|
|
88
104
|
};
|
|
105
|
+
|
|
89
106
|
exports.setTestInfoStatus = setTestInfoStatus;
|
|
@@ -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
|