@zohodesk/react-cli 0.0.1-exp.175.1 → 0.0.1-exp.176.11
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 +35 -40
- package/docs/SelectorWeight.md +6 -0
- package/docs/VariableConversion.md +33 -1
- 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 +11 -1
- 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 +20 -4
- 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 +63 -17
- 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 +72 -23
- 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/EFCTemplatePlugin.js +32 -23
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +34 -8
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +17 -12
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +39 -8
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +29 -14
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +22 -13
- package/lib/plugins/I18nSplitPlugin/index.js +23 -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 +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 +10 -3
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +16 -9
- 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 +20 -4
- package/lib/plugins/ShadowDOMSupportPlugin.js +40 -3
- package/lib/plugins/SourceMapHookPlugin.js +9 -0
- package/lib/plugins/TPHashMappingPlugin.js +15 -1
- package/lib/plugins/UglifyCSSPlugin.js +9 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +35 -2
- package/lib/plugins/VariableConversionCollector.js +252 -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 +27 -14
- package/lib/postcss-plugins/ValueReplacer.js +6 -9
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
- package/lib/postcss-plugins/hoverActivePlugin.js +66 -30
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +40 -13
- package/lib/postcss-plugins/variableModificationPlugin/index.js +215 -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/templates/CoverageScriptTemplate.js +14 -0
- package/lib/templates/WMSTemplate.js +12 -6
- package/lib/utils/babelPresets.js +2 -0
- 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 +50 -38
- 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/getFileType.js +49 -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/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/package.json +10 -9
package/lib/utils/getOptions.js
CHANGED
|
@@ -4,21 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
7
8
|
var _child_process = require("child_process");
|
|
9
|
+
|
|
8
10
|
var _fs = _interopRequireDefault(require("fs"));
|
|
11
|
+
|
|
9
12
|
var _path = _interopRequireDefault(require("path"));
|
|
13
|
+
|
|
10
14
|
var _schemas = _interopRequireDefault(require("../schemas"));
|
|
15
|
+
|
|
11
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
// import { argv } from 'process';
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
// console.log('argv', argv);
|
|
18
|
+
// import { argv } from 'process';
|
|
19
|
+
const args = process.argv.slice(2); // console.log('argv', argv);
|
|
16
20
|
|
|
17
|
-
const NPM_CONFIG_PREFIX = 'npm_config_';
|
|
18
|
-
// TODO: we have to do option parse logic little better
|
|
21
|
+
const NPM_CONFIG_PREFIX = 'npm_config_'; // TODO: we have to do option parse logic little better
|
|
19
22
|
// if user use react-cli stritly without using npm scripts options won't work,
|
|
20
23
|
// So we have to write our own option parse logic or some other library
|
|
21
|
-
|
|
22
24
|
// console.log('type', process.argv, process.env.npm_config_check, process.env.npm_config_clone_type, process.env.npm_config_clone_url);
|
|
23
25
|
// console.log('Object.keys(process.env).filter(s => s.startsWith(\'npm_config_\') && s.includes(\'clone\')', Object.keys(process.env).filter(s => s.startsWith('npm_config_') && s.includes('clone')));
|
|
24
26
|
// // clone:type
|
|
@@ -32,24 +34,31 @@ Object.keys(process.env).filter(key => key.startsWith(NPM_CONFIG_PREFIX)).forEac
|
|
|
32
34
|
});
|
|
33
35
|
keysWithColon.forEach(key => {
|
|
34
36
|
let nkey = key.replace(/:/g, '_');
|
|
37
|
+
|
|
35
38
|
if (processEnv[nkey]) {
|
|
36
39
|
throw Error('there is some options conflict', key, nkey);
|
|
37
40
|
}
|
|
41
|
+
|
|
38
42
|
processEnv[nkey] = processEnv[key];
|
|
39
43
|
});
|
|
44
|
+
|
|
40
45
|
function getNpmVersion() {
|
|
41
46
|
// require("child_process").
|
|
42
47
|
let vers = '6';
|
|
48
|
+
|
|
43
49
|
try {
|
|
44
50
|
[vers] = (0, _child_process.execSync)('npm -v').toString().trim().split('.');
|
|
45
51
|
} catch (error) {
|
|
46
52
|
console.log(error);
|
|
47
53
|
}
|
|
54
|
+
|
|
48
55
|
return vers;
|
|
49
56
|
}
|
|
57
|
+
|
|
50
58
|
function getCWD() {
|
|
51
59
|
// require("child_process").
|
|
52
60
|
let cwd = process.cwd();
|
|
61
|
+
|
|
53
62
|
try {
|
|
54
63
|
let ress = (0, _child_process.execSync)('npm bin').toString();
|
|
55
64
|
let i = ress.lastIndexOf('node_modules');
|
|
@@ -57,33 +66,39 @@ function getCWD() {
|
|
|
57
66
|
} catch (error) {
|
|
58
67
|
console.log(error);
|
|
59
68
|
}
|
|
69
|
+
|
|
60
70
|
return cwd;
|
|
61
|
-
}
|
|
71
|
+
} // experimental argumnet parsing logic
|
|
72
|
+
|
|
62
73
|
|
|
63
|
-
// experimental argumnet parsing logic
|
|
64
74
|
args.forEach(option => {
|
|
65
75
|
if (/^--./.test(option)) {
|
|
66
|
-
let equIndex = option.indexOf('=');
|
|
67
|
-
|
|
76
|
+
let equIndex = option.indexOf('='); // equIndex = equIndex === -1 ? option.length : equIndex;
|
|
77
|
+
|
|
68
78
|
let key = option.slice(2, equIndex);
|
|
69
79
|
let value = option.slice(equIndex + 1);
|
|
80
|
+
|
|
70
81
|
if (equIndex === -1) {
|
|
71
82
|
key = option.slice(2);
|
|
72
83
|
value = true;
|
|
73
84
|
}
|
|
85
|
+
|
|
74
86
|
key = key.replace(/-|:/g, '_');
|
|
75
87
|
processEnv[key] = value;
|
|
76
88
|
}
|
|
77
89
|
});
|
|
90
|
+
|
|
78
91
|
let defaulter = (target, source) => {
|
|
79
92
|
let defaultObject = {};
|
|
80
93
|
Object.keys(target).forEach(key => {
|
|
81
94
|
let data = target[key];
|
|
95
|
+
|
|
82
96
|
if (data && typeof data === 'object') {
|
|
83
97
|
if (Array.isArray(data)) {
|
|
84
98
|
defaultObject[key] = source[key] || data;
|
|
85
99
|
} else if (typeof data.cli === 'string') {
|
|
86
100
|
let cliData;
|
|
101
|
+
|
|
87
102
|
if (typeof processEnv[data.cli] === 'string') {
|
|
88
103
|
cliData = processEnv[data.cli];
|
|
89
104
|
} else if (typeof processEnv[data.cli.toLowerCase()] === 'string') {
|
|
@@ -91,9 +106,11 @@ let defaulter = (target, source) => {
|
|
|
91
106
|
} else {
|
|
92
107
|
cliData = source && source[key] || data.value;
|
|
93
108
|
}
|
|
109
|
+
|
|
94
110
|
if (typeof data.value === 'boolean') {
|
|
95
111
|
cliData = cliData === 'true' || cliData === true ? true : cliData === 'false' || cliData === false || cliData === '' ? false : data.value;
|
|
96
112
|
}
|
|
113
|
+
|
|
97
114
|
defaultObject[key] = cliData;
|
|
98
115
|
} else {
|
|
99
116
|
defaultObject[key] = defaulter(data, source && source[key] ? source[key] : Array.isArray(target[key]) ? [] : {});
|
|
@@ -104,9 +121,8 @@ let defaulter = (target, source) => {
|
|
|
104
121
|
});
|
|
105
122
|
return defaultObject;
|
|
106
123
|
};
|
|
107
|
-
global.reactCLIOptions = null;
|
|
108
124
|
|
|
109
|
-
// function selectn(obj, key) {
|
|
125
|
+
global.reactCLIOptions = null; // function selectn(obj, key) {
|
|
110
126
|
// let temp = obj;
|
|
111
127
|
// let keys = key.split('.');
|
|
112
128
|
// for (let i = 0; i < keys.length; i++) {
|
|
@@ -121,28 +137,36 @@ function deprecationSupport(options) {
|
|
|
121
137
|
if (options.app.hasRTL === true) {
|
|
122
138
|
options.app.plugins.hasRTL = true;
|
|
123
139
|
}
|
|
140
|
+
|
|
124
141
|
if (options.docs.hasRTL === true) {
|
|
125
142
|
options.docs.plugins.hasRTL = true;
|
|
126
143
|
}
|
|
144
|
+
|
|
127
145
|
if (options.app.rtlExclude.length > 0) {
|
|
128
146
|
options.app.exclude.rtl = options.app.rtlExclude;
|
|
129
147
|
}
|
|
148
|
+
|
|
130
149
|
if (options.docs.rtlExclude.length > 0) {
|
|
131
150
|
options.docs.exclude.rtl = options.docs.rtlExclude;
|
|
132
151
|
}
|
|
133
152
|
}
|
|
153
|
+
|
|
134
154
|
let getOptions = () => {
|
|
135
155
|
if (global.reactCLIOptions) {
|
|
136
156
|
return global.reactCLIOptions;
|
|
137
157
|
}
|
|
158
|
+
|
|
138
159
|
let appPath = process.cwd();
|
|
139
160
|
let userSchemas;
|
|
161
|
+
|
|
140
162
|
let packagePath = _path.default.join(appPath, 'package.json');
|
|
163
|
+
|
|
141
164
|
if (_fs.default.existsSync(packagePath)) {
|
|
142
165
|
userSchemas = require(packagePath)['react-cli'] || {};
|
|
143
166
|
}
|
|
144
|
-
|
|
145
|
-
// for future may be for npm 8 edge cases
|
|
167
|
+
|
|
168
|
+
let options = defaulter(_schemas.default, userSchemas || {}); // for future may be for npm 8 edge cases
|
|
169
|
+
|
|
146
170
|
options.npmVersion = getNpmVersion();
|
|
147
171
|
options.cwd = getCWD();
|
|
148
172
|
deprecationSupport(options);
|
|
@@ -150,5 +174,6 @@ let getOptions = () => {
|
|
|
150
174
|
global.reactCLIOptions = options;
|
|
151
175
|
return options;
|
|
152
176
|
};
|
|
177
|
+
|
|
153
178
|
var _default = getOptions;
|
|
154
179
|
exports.default = _default;
|
|
@@ -4,25 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
7
8
|
let getServerURL = (serverInfo, protocol) => {
|
|
8
9
|
let {
|
|
9
10
|
host,
|
|
10
11
|
domain,
|
|
11
12
|
port
|
|
12
13
|
} = serverInfo;
|
|
14
|
+
|
|
13
15
|
if (protocol) {
|
|
14
16
|
if (protocol === 'ht' + 'tp') {
|
|
15
17
|
port = Number(port) + 1;
|
|
18
|
+
|
|
16
19
|
if (domain) {
|
|
17
20
|
return `${protocol ? `${protocol}:` : ''}//${host}.${domain}.zohocorpin.com:${Number(port) + 1}`;
|
|
18
21
|
}
|
|
22
|
+
|
|
19
23
|
return `${protocol ? `${protocol}:` : ''}//${host}:${port}`;
|
|
20
24
|
}
|
|
21
25
|
}
|
|
26
|
+
|
|
22
27
|
if (domain) {
|
|
23
28
|
return `${protocol ? `${protocol}:` : ''}//${host}.${domain}.zohocorpin.com:${port}`;
|
|
24
29
|
}
|
|
30
|
+
|
|
25
31
|
return `${protocol ? `${protocol}:` : ''}//${host}:${port}`;
|
|
26
32
|
};
|
|
33
|
+
|
|
27
34
|
var _default = getServerURL;
|
|
28
35
|
exports.default = _default;
|
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;
|