@zohodesk/react-cli 0.0.1-beta.16 → 0.0.1-beta.160
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +1 -0
- package/.eslintrc.js +46 -3
- package/CHANGELOG.md +5 -0
- package/README.md +650 -0
- package/bin/cli.js +134 -27
- package/cert/cert.pem +37 -129
- package/cert/key.pem +27 -27
- package/cert/passphrase.pem +1 -0
- package/files/eslintrc.js +62 -0
- package/files/prettierrc.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +16 -9
- package/lib/babel/es-plugins-presets.js +26 -14
- package/lib/common/getEntries.js +33 -24
- package/lib/common/getPublicPathConfig.js +40 -0
- package/lib/common/index.js +27 -13
- package/lib/common/splitChunks.js +64 -26
- package/lib/common/sslcertUpdater.js +59 -0
- package/lib/common/templateParameters.js +25 -0
- package/lib/configs/jest.config.js +18 -28
- package/lib/configs/webpack.component.umd.config.js +31 -37
- package/lib/configs/webpack.css.umd.config.js +44 -44
- package/lib/configs/webpack.dev.config.js +113 -57
- package/lib/configs/webpack.docs.config.js +104 -98
- package/lib/configs/webpack.impact.config.js +116 -0
- package/lib/configs/webpack.prod.config.js +154 -86
- package/lib/hooks/docsProptypeHook.js +32 -38
- package/lib/jest/commitedFilesResult.js +144 -71
- package/lib/jest/coverageCollector.js +62 -29
- package/lib/jest/jsonMaker.js +54 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
- package/lib/jest/preProcessors/jsPreprocessor.js +5 -6
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
- package/lib/jest/result.js +91 -41
- package/lib/jest/run.js +74 -27
- package/lib/jest/setup.js +103 -102
- package/lib/loaderUtils/getCSSLoaders.js +77 -0
- package/lib/loaderUtils/getDevJsLoaders.js +30 -23
- package/lib/loaderUtils/index.js +14 -7
- package/lib/loaders/docsLoader.js +15 -15
- package/lib/loaders/docsPropsLoader.js +14 -17
- package/lib/loaders/fileBountryLoader.js +17 -0
- package/lib/loaders/fileLoader.js +47 -38
- package/lib/loaders/scriptInstrumentLoader.js +21 -20
- package/lib/loaders/selectorMappingLoader.js +75 -0
- package/lib/loaders/workerLoader.js +136 -0
- package/lib/middlewares/HMRMiddleware.js +59 -41
- package/lib/middlewares/SSTMiddleware.js +21 -0
- package/lib/pluginUtils/getDevPlugins.js +173 -26
- package/lib/pluginUtils/getDocsPlugins.js +32 -17
- package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
- package/lib/pluginUtils/getLibraryPlugins.js +8 -10
- package/lib/pluginUtils/getProdPlugins.js +238 -37
- package/lib/pluginUtils/getServerPlugins.js +8 -11
- package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
- package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
- package/lib/pluginUtils/index.js +36 -43
- package/lib/plugins/CdnChangePlugin.js +77 -0
- package/lib/plugins/CleanupStatsPlugin.js +28 -0
- package/lib/plugins/EFCPlugin.js +211 -0
- package/lib/plugins/EFCPlugin.md +6 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +141 -0
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
- package/lib/plugins/I18nSplitPlugin/README.md +25 -0
- package/lib/plugins/I18nSplitPlugin/index.js +185 -0
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
- package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
- package/lib/plugins/ManifestPlugin.js +52 -63
- package/lib/plugins/ModuleStatsPlugin.js +98 -97
- package/lib/plugins/OptimizeJSPlugin.js +24 -41
- package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
- package/lib/plugins/PublicPathChangePlugin.js +187 -174
- package/lib/plugins/ReportGeneratePlugin.js +181 -0
- package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
- package/lib/plugins/ResourceHintsPlugin.js +53 -35
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +80 -0
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +82 -0
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +26 -0
- package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
- package/lib/plugins/ServiceWorkerPlugin.js +107 -0
- package/lib/plugins/ShadowDOMSupportPlugin.js +270 -0
- package/lib/plugins/SourceMapHookPlugin.js +25 -31
- package/lib/plugins/TPHashMappingPlugin.js +67 -0
- package/lib/plugins/UglifyCSSPlugin.js +23 -30
- package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
- package/lib/plugins/index.js +118 -55
- package/lib/plugins/libraryImpactPlugin.js +190 -0
- package/lib/plugins/webpackwatchrunplugin.js +26 -0
- package/lib/postcss-plugins/ExcludeRTLPlugin.js +23 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
- package/lib/schemas/index.js +463 -52
- package/lib/servers/clusterHubServer.js +22 -26
- package/lib/servers/docsServer.js +3 -5
- package/lib/servers/docsServerCore.js +93 -85
- package/lib/servers/helpServer.js +19 -21
- package/lib/servers/httpsOptions.js +19 -0
- package/lib/servers/impactServer.js +99 -92
- package/lib/servers/mockserver.js +44 -0
- package/lib/servers/nowatchserver.js +275 -0
- package/lib/servers/scrServer.js +147 -0
- package/lib/servers/server.js +118 -124
- package/lib/servers/ssServer.js +107 -65
- package/lib/sh/reportPublish.sh +16 -10
- package/lib/templates/CoverageScriptTemplate.js +45 -18
- package/lib/templates/WMSTemplate.js +17 -18
- package/lib/templates/linterConstant.js +10 -0
- package/lib/utils/babelPresets.js +12 -5
- package/lib/utils/buildstats.html +148 -0
- package/lib/utils/clean.js +12 -11
- package/lib/utils/copy.js +13 -127
- package/lib/utils/copyTimezones.js +21 -0
- package/lib/utils/createEventStream.js +24 -19
- package/lib/utils/cssClassNameGenerate.js +70 -0
- package/lib/utils/cssURLReplacer.js +67 -54
- package/lib/utils/dependencyPostPublish.js +42 -0
- package/lib/utils/fileUtils.js +125 -0
- package/lib/utils/folderIterator.js +47 -0
- package/lib/utils/getComponents.js +126 -0
- package/lib/utils/getCurrentBranch.js +11 -17
- package/lib/utils/getDependenciesImpactList.js +151 -0
- package/lib/utils/getHash.js +26 -0
- package/lib/utils/getIp.js +20 -0
- package/lib/utils/getOptions.js +55 -30
- package/lib/utils/getServerURL.js +25 -8
- package/lib/utils/index.js +259 -82
- package/lib/utils/init.js +2 -2
- package/lib/utils/initPreCommitHook.js +40 -31
- package/lib/utils/jsonHelper.js +97 -0
- package/lib/utils/libraryImpactConfig.js +63 -0
- package/lib/utils/lint/addScripts.js +27 -0
- package/lib/utils/lint/checkExistingConfig.js +67 -0
- package/lib/utils/lint/copyConfigs.js +24 -0
- package/lib/utils/lint/index.js +54 -0
- package/lib/utils/lint/lintScripts.js +11 -0
- package/lib/utils/lint/lintSetup.js +31 -0
- package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
- package/lib/utils/lint/question.js +30 -0
- package/lib/utils/lintReporter.js +142 -0
- package/lib/utils/mailSender.js +16 -25
- package/lib/utils/pullOrigin.js +28 -0
- package/lib/utils/reinstallDependencies.js +133 -0
- package/lib/utils/removeAttributes.js +25 -23
- package/lib/utils/repoClone.js +56 -63
- package/lib/utils/request.js +64 -77
- package/lib/utils/resultSchema.json +73 -0
- package/lib/utils/rtl.js +42 -0
- package/lib/utils/setEnvVariables.js +5 -6
- package/lib/utils/ssTestHack.js +48 -0
- package/lib/utils/switchBranch.js +28 -0
- package/lib/utils/urlConcat.js +22 -0
- package/package.json +92 -64
- package/templates/app/.eslintrc.js +140 -0
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -8
- package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
- package/templates/app/app/properties/i18nkeys.json +3 -3
- package/templates/app/docs/all.html +69 -69
- package/templates/app/mockapi/index.js +18 -13
- package/templates/app/package.json +37 -17
- package/templates/app/src/actions/SampleActions/index.js +37 -0
- package/templates/app/src/actions/index.js +65 -0
- package/templates/app/src/appUrls.js +19 -0
- package/templates/app/src/components/Alert/Alert.js +134 -0
- package/templates/app/src/components/Alert/Alert.module.css +79 -0
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -0
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -0
- package/templates/app/src/components/Sample/Sample.module.css +11 -0
- package/templates/app/src/components/Sample/SampleList.js +61 -0
- package/templates/app/src/components/Slider/Slider.css +41 -0
- package/templates/app/src/components/Slider/Slider.js +55 -0
- package/templates/app/src/containers/AlertContainer/index.js +15 -0
- package/templates/app/src/containers/AppContainer/index.js +96 -0
- package/templates/app/src/containers/AppContainer/index.module.css +27 -0
- package/templates/app/src/containers/CustomMatch/index.js +65 -0
- package/templates/app/src/containers/DevTools/index.js +10 -0
- package/templates/app/src/containers/Header/index.js +67 -0
- package/templates/app/src/containers/Header/index.module.css +43 -0
- package/templates/app/src/containers/Redirect/index.js +63 -0
- package/templates/app/src/containers/Redirector/index.js +47 -0
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -0
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -0
- package/templates/app/src/historyChange.js +5 -0
- package/templates/app/src/index.html +10 -0
- package/templates/app/src/index.js +24 -0
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -0
- package/templates/app/src/reducers/alertData.js +11 -0
- package/templates/app/src/reducers/index.js +6 -0
- package/templates/app/src/reducers/samples.js +19 -0
- package/templates/app/src/store/configureStore.dev.js +51 -0
- package/templates/app/src/store/configureStore.js +5 -0
- package/templates/app/src/store/configureStore.prod.js +26 -0
- package/templates/app/src/util/Common.js +5 -0
- package/templates/app/src/util/RequestAPI.js +132 -0
- package/templates/appold/README.md +12 -0
- package/templates/appold/app/index.html +8 -0
- package/templates/appold/app/properties/ApplicationResources_en_US.properties +1 -0
- package/templates/appold/app/properties/i18nkeys.json +3 -0
- package/templates/appold/docs/all.html +69 -0
- package/templates/appold/mockapi/index.js +13 -0
- package/templates/{app → appold}/mockapi/tickets.json +0 -0
- package/templates/appold/package.json +17 -0
- package/templates/appold/src/components/Text/Text.css +0 -0
- package/templates/appold/src/components/Text/Text.js +23 -0
- package/templates/appold/src/components/Text/__tests__/Text.spec.js +30 -0
- package/templates/appold/src/components/Text/docs/Text__default.docs.js +16 -0
- package/templates/appold/src/components/docs.js +1 -0
- package/templates/appold/src/components/index.js +5 -0
- package/templates/appold/src/index.js +13 -0
- package/templates/docs/all.html +1 -1
- package/templates/docs/component.html +110 -69
- package/templates/docs/components.html +221 -0
- package/templates/docs/css/component.css +12 -14
- package/templates/docs/css/componentTest.css +7 -0
- package/templates/docs/css/style.css +150 -206
- package/templates/docs/impactReportTemplate.html +154 -0
- package/templates/docs/index.html +1482 -1336
- package/templates/library/src/index.js +0 -0
@@ -1,70 +1,72 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.cssUrlReplacer = exports.getUrls = exports.getFileType =
|
6
|
+
exports.cssUrlReplacer = exports.getUrls = exports.getFileType = void 0;
|
7
7
|
|
8
|
-
var _fs = require(
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
9
9
|
|
10
|
-
var
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
11
11
|
|
12
|
-
var
|
13
|
-
|
14
|
-
var _path2 = _interopRequireDefault(_path);
|
15
|
-
|
16
|
-
var _crypto = require('crypto');
|
17
|
-
|
18
|
-
var _crypto2 = _interopRequireDefault(_crypto);
|
12
|
+
var _crypto = _interopRequireDefault(require("crypto"));
|
19
13
|
|
20
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
15
|
|
22
|
-
|
16
|
+
let urlRegex = /url\(.*?\)/g;
|
23
17
|
|
24
|
-
|
25
|
-
|
26
|
-
var needSubStr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
18
|
+
let getHash = (file, isPath = false, needSubStr = true) => {
|
19
|
+
let hash = _crypto.default.createHash('md5');
|
27
20
|
|
28
|
-
var hash = _crypto2.default.createHash('md5');
|
29
21
|
if (isPath) {
|
30
|
-
hash.update(
|
22
|
+
hash.update(_fs.default.readFileSync(file));
|
31
23
|
} else {
|
32
24
|
hash.update(file);
|
33
25
|
}
|
26
|
+
|
34
27
|
hash = hash.digest('hex');
|
35
28
|
return hash ? needSubStr ? hash.substring(0, 20) : hash : null;
|
36
29
|
};
|
37
30
|
|
38
|
-
|
39
|
-
|
40
|
-
|
31
|
+
let getFileType = file => {
|
32
|
+
let {
|
33
|
+
ext
|
34
|
+
} = _path.default.parse(file);
|
41
35
|
|
42
36
|
if (ext === '.gif' || ext === '.png' || ext === '.jpg' || ext === '.jpeg' || ext === '.ico') {
|
43
37
|
return 'image';
|
44
38
|
} else if (ext === '.svg' || ext === '.woff' || ext === '.eot' || ext === '.ttf' || ext === '.woff2') {
|
45
39
|
return 'font';
|
40
|
+
} else if (ext === '.js') {
|
41
|
+
return 'js';
|
42
|
+
} else if (ext === '.css') {
|
43
|
+
return 'css';
|
46
44
|
}
|
45
|
+
|
47
46
|
return null;
|
48
47
|
};
|
49
48
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
exports.getFileType = getFileType;
|
50
|
+
|
51
|
+
let formatUrl = str => {
|
52
|
+
let char = str.includes('"') ? '"' : str.includes('\'') ? '\'' : '(';
|
53
|
+
let statingIdx = str.indexOf(char) + 1;
|
54
|
+
let substr = str.substring(statingIdx, str.length);
|
54
55
|
char = char === '(' ? ')' : char;
|
55
56
|
return substr.substring(0, substr.indexOf(char));
|
56
57
|
};
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
let getUrls = css => {
|
60
|
+
let urlMatches = css.match(urlRegex);
|
61
|
+
let src = css;
|
62
|
+
|
61
63
|
if (urlMatches) {
|
62
|
-
|
63
|
-
urlMatches.forEach(
|
64
|
-
|
65
|
-
|
64
|
+
let patterns = {};
|
65
|
+
urlMatches.forEach(pattern => {
|
66
|
+
let url = formatUrl(pattern);
|
67
|
+
let hash = getHash(url);
|
66
68
|
patterns[url] = hash;
|
67
|
-
|
69
|
+
let regex = new RegExp(pattern.replace(/([<>*()?${}|])/g, '\\$1'), 'g');
|
68
70
|
src = src.replace(regex, hash);
|
69
71
|
});
|
70
72
|
return {
|
@@ -74,17 +76,19 @@ var getUrls = exports.getUrls = function getUrls(css) {
|
|
74
76
|
}
|
75
77
|
};
|
76
78
|
|
77
|
-
|
78
|
-
|
79
|
+
exports.getUrls = getUrls;
|
80
|
+
|
81
|
+
let cssUrlReplacer = (css, domains, chunkHash = {}) => {
|
82
|
+
let obj = getUrls(css);
|
83
|
+
let src = css;
|
79
84
|
|
80
|
-
var obj = getUrls(css);
|
81
|
-
var src = css;
|
82
85
|
if (obj) {
|
83
|
-
|
86
|
+
let patterns = obj.urls;
|
84
87
|
src = obj.css;
|
85
|
-
Object.keys(patterns).forEach(
|
86
|
-
|
87
|
-
|
88
|
+
Object.keys(patterns).forEach(pattern => {
|
89
|
+
let urlParts = pattern.split('/');
|
90
|
+
let fileName = urlParts.pop();
|
91
|
+
|
88
92
|
if (fileName.includes('#')) {
|
89
93
|
if (fileName.includes('?')) {
|
90
94
|
fileName = fileName.replace(/\?.*#/g, '#');
|
@@ -92,32 +96,41 @@ var cssUrlReplacer = exports.cssUrlReplacer = function cssUrlReplacer(css, domai
|
|
92
96
|
} else {
|
93
97
|
fileName = fileName.replace(/\?.*$/g, '');
|
94
98
|
}
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
99
|
+
|
100
|
+
let hash = patterns[pattern];
|
101
|
+
let filename = fileName.replace(/(\?|#).*?$/g, '');
|
102
|
+
let regex = new RegExp(hash, 'g');
|
103
|
+
let {
|
104
|
+
hashedName
|
105
|
+
} = chunkHash[filename] || fileName;
|
106
|
+
|
107
|
+
if (domains && typeof urlParts[0] === 'string' && !urlParts[0].includes('http')) {
|
108
|
+
let {
|
109
|
+
font,
|
110
|
+
image
|
111
|
+
} = domains;
|
112
|
+
let type = getFileType(filename);
|
113
|
+
let customPath = type === 'image' ? `${image}/images` : type === 'font' ? `${font}/fonts` : urlParts.join('/');
|
105
114
|
urlParts = customPath.split('/');
|
106
115
|
}
|
107
116
|
|
108
117
|
if (hashedName) {
|
109
118
|
if (fileName.includes('#')) {
|
110
119
|
if (fileName.includes('?')) {
|
111
|
-
hashedName = hashedName
|
120
|
+
hashedName = `${hashedName}?${fileName.split('?')[1]}`;
|
112
121
|
} else {
|
113
|
-
hashedName = hashedName
|
122
|
+
hashedName = `${hashedName}#${fileName.split('#')[1]}`;
|
114
123
|
}
|
115
124
|
}
|
116
125
|
}
|
126
|
+
|
117
127
|
urlParts.push(hashedName || fileName);
|
118
128
|
urlParts = urlParts.join('/');
|
119
|
-
src = src.replace(regex,
|
129
|
+
src = src.replace(regex, `url('${urlParts}')`);
|
120
130
|
});
|
121
131
|
}
|
132
|
+
|
122
133
|
return src;
|
123
|
-
};
|
134
|
+
};
|
135
|
+
|
136
|
+
exports.cssUrlReplacer = cssUrlReplacer;
|
@@ -0,0 +1,42 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _child_process = require("child_process");
|
4
|
+
|
5
|
+
var _path = _interopRequireDefault(require("path"));
|
6
|
+
|
7
|
+
var _request = _interopRequireDefault(require("./request"));
|
8
|
+
|
9
|
+
var _index = require("./index");
|
10
|
+
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
12
|
+
|
13
|
+
let changeset = (0, _child_process.execSync)('git rev-parse HEAD', {
|
14
|
+
cwd: process.cwd()
|
15
|
+
}).toString() || '';
|
16
|
+
changeset = changeset.trim();
|
17
|
+
|
18
|
+
if (!changeset) {
|
19
|
+
throw new Error('Changeset doesn\'t exists');
|
20
|
+
}
|
21
|
+
|
22
|
+
(0, _index.log)(changeset, 'changeset');
|
23
|
+
|
24
|
+
let {
|
25
|
+
version,
|
26
|
+
name
|
27
|
+
} = require(_path.default.join(process.cwd(), './package.json'));
|
28
|
+
|
29
|
+
(0, _request.default)({
|
30
|
+
url: `${'ht'}${'tp'}://tsi-desk-mock.tsi.zohocorpin.com:8080/Hbase/addKey?method=addkey`,
|
31
|
+
method: 'POST',
|
32
|
+
payload: {
|
33
|
+
tablename: `${name.replace('@', '').replace(/\//g, '_')}_changesets`,
|
34
|
+
row: 'dependencies_changesets',
|
35
|
+
column: version,
|
36
|
+
value: changeset
|
37
|
+
}
|
38
|
+
}).then(res => {
|
39
|
+
(0, _index.log)(`changeset push done --> ${res.body}`);
|
40
|
+
}).catch(e => {
|
41
|
+
throw e;
|
42
|
+
});
|
@@ -0,0 +1,125 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.copy = void 0;
|
7
|
+
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
9
|
+
|
10
|
+
var _fs = _interopRequireDefault(require("fs"));
|
11
|
+
|
12
|
+
var _index = require("./index");
|
13
|
+
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
+
|
16
|
+
let removeDirectory = dirPath => {
|
17
|
+
_fs.default.readdirSync(dirPath).forEach(fileOrDir => {
|
18
|
+
let fileOrDirPath = _path.default.join(dirPath, fileOrDir);
|
19
|
+
|
20
|
+
if (_fs.default.statSync(fileOrDirPath).isDirectory()) {
|
21
|
+
removeDirectory(fileOrDirPath);
|
22
|
+
} else {
|
23
|
+
_fs.default.unlinkSync(fileOrDirPath);
|
24
|
+
}
|
25
|
+
});
|
26
|
+
|
27
|
+
_fs.default.rmdirSync(dirPath);
|
28
|
+
};
|
29
|
+
|
30
|
+
let copyFile = (srcPath, targetPath, isCopy = true, changeExt) => {
|
31
|
+
let {
|
32
|
+
ext,
|
33
|
+
dir,
|
34
|
+
name,
|
35
|
+
root
|
36
|
+
} = _path.default.parse(targetPath);
|
37
|
+
|
38
|
+
if (changeExt[ext]) {
|
39
|
+
ext = changeExt[ext];
|
40
|
+
targetPath = _path.default.format({
|
41
|
+
ext,
|
42
|
+
dir,
|
43
|
+
name,
|
44
|
+
root
|
45
|
+
}); //eslint-disable-line
|
46
|
+
}
|
47
|
+
|
48
|
+
let readStream = _fs.default.createReadStream(srcPath);
|
49
|
+
|
50
|
+
let writeStream = _fs.default.createWriteStream(targetPath);
|
51
|
+
|
52
|
+
readStream.pipe(writeStream);
|
53
|
+
writeStream.on('finish', () => {
|
54
|
+
if (!isCopy) {
|
55
|
+
_fs.default.unlinkSync(srcPath);
|
56
|
+
}
|
57
|
+
});
|
58
|
+
};
|
59
|
+
|
60
|
+
let iterateDirectory = (srcPath, targetPath, isCopy, extensions, flatten, changeExt) => {
|
61
|
+
_fs.default.readdirSync(srcPath).forEach(fileOrDir => {
|
62
|
+
let fromPath = _path.default.join(srcPath, fileOrDir);
|
63
|
+
|
64
|
+
let toPath = targetPath;
|
65
|
+
|
66
|
+
if (flatten !== 'flatten' || !_fs.default.statSync(fromPath).isDirectory()) {
|
67
|
+
toPath = _path.default.join(targetPath, fileOrDir);
|
68
|
+
}
|
69
|
+
|
70
|
+
if (_fs.default.statSync(fromPath).isDirectory()) {
|
71
|
+
if (!_fs.default.existsSync(toPath)) {
|
72
|
+
_fs.default.mkdirSync(toPath);
|
73
|
+
}
|
74
|
+
|
75
|
+
iterateDirectory(fromPath, toPath, isCopy, extensions, flatten, changeExt);
|
76
|
+
} else {
|
77
|
+
if (extensions) {
|
78
|
+
let {
|
79
|
+
ext
|
80
|
+
} = _path.default.parse(fromPath);
|
81
|
+
|
82
|
+
if (extensions.indexOf(ext) !== -1) {
|
83
|
+
copyFile(fromPath, toPath, true, changeExt);
|
84
|
+
}
|
85
|
+
} else {
|
86
|
+
copyFile(fromPath, toPath, true, changeExt);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
});
|
90
|
+
};
|
91
|
+
|
92
|
+
let copy = (srcPath, targetPath, isCopy, exts, flatten, changeExt = {}) => {
|
93
|
+
if (_fs.default.statSync(srcPath).isDirectory()) {
|
94
|
+
if (!_fs.default.existsSync(targetPath)) {
|
95
|
+
_fs.default.mkdirSync(targetPath);
|
96
|
+
}
|
97
|
+
|
98
|
+
let {
|
99
|
+
name
|
100
|
+
} = _path.default.parse(srcPath);
|
101
|
+
|
102
|
+
let originPath = targetPath;
|
103
|
+
|
104
|
+
if (flatten !== 'flatten') {
|
105
|
+
originPath = _path.default.join(targetPath, name);
|
106
|
+
|
107
|
+
if (!_fs.default.existsSync(originPath)) {
|
108
|
+
_fs.default.mkdirSync(originPath);
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
iterateDirectory(srcPath, originPath, isCopy, exts, flatten, changeExt);
|
113
|
+
} else {
|
114
|
+
/* direct file copy issue there but that feature not needed i think*/
|
115
|
+
copyFile(srcPath, targetPath, isCopy, changeExt);
|
116
|
+
}
|
117
|
+
|
118
|
+
if (!isCopy) {
|
119
|
+
removeDirectory(srcPath);
|
120
|
+
}
|
121
|
+
|
122
|
+
(0, _index.log)(isCopy ? 'Folder/file are copied!' : 'Folder/file are moved!');
|
123
|
+
};
|
124
|
+
|
125
|
+
exports.copy = copy;
|
@@ -0,0 +1,47 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
9
|
+
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
let iterateDirectory = (srcPath, targetPath, extensions, flatten, cb) => {
|
15
|
+
_fs.default.readdirSync(srcPath).forEach(fileOrDir => {
|
16
|
+
let fromPath = _path.default.join(srcPath, fileOrDir);
|
17
|
+
|
18
|
+
let toPath = targetPath;
|
19
|
+
|
20
|
+
if (flatten !== 'flatten' || !_fs.default.statSync(fromPath).isDirectory()) {
|
21
|
+
toPath = _path.default.join(targetPath, fileOrDir);
|
22
|
+
}
|
23
|
+
|
24
|
+
if (_fs.default.statSync(fromPath).isDirectory()) {
|
25
|
+
if (!_fs.default.existsSync(toPath)) {
|
26
|
+
_fs.default.mkdirSync(toPath);
|
27
|
+
}
|
28
|
+
|
29
|
+
iterateDirectory(fromPath, toPath, extensions, flatten, cb);
|
30
|
+
} else {
|
31
|
+
if (extensions) {
|
32
|
+
let {
|
33
|
+
ext
|
34
|
+
} = _path.default.parse(fromPath);
|
35
|
+
|
36
|
+
if (extensions.indexOf(ext) !== -1) {
|
37
|
+
cb(fromPath, toPath);
|
38
|
+
}
|
39
|
+
} else {
|
40
|
+
cb(fromPath, toPath);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
});
|
44
|
+
};
|
45
|
+
|
46
|
+
var _default = iterateDirectory;
|
47
|
+
exports.default = _default;
|
@@ -0,0 +1,126 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
let eliminateDuplicates = inputList => {
|
9
|
+
let outputList = [];
|
10
|
+
let tempObj = {};
|
11
|
+
|
12
|
+
for (let i = 0; i < inputList.length; i++) {
|
13
|
+
tempObj[inputList[i]] = 1;
|
14
|
+
}
|
15
|
+
|
16
|
+
for (let j in tempObj) {
|
17
|
+
if (tempObj[j]) {
|
18
|
+
outputList.push(j);
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
outputList = outputList.filter(item => item);
|
23
|
+
return outputList;
|
24
|
+
};
|
25
|
+
|
26
|
+
let removeExtn = componentObjectList => {
|
27
|
+
let fileNameArray = [];
|
28
|
+
componentObjectList.forEach(fileObject => {
|
29
|
+
let filename = fileObject.name.includes('.docs.js') ? fileObject.name.replace('.docs.js', '') : fileObject.name.replace('.js', '');
|
30
|
+
fileNameArray.push(filename);
|
31
|
+
});
|
32
|
+
return fileNameArray;
|
33
|
+
};
|
34
|
+
|
35
|
+
let getChangedFileName = impactedObject => {
|
36
|
+
let changedComponentsList = [];
|
37
|
+
|
38
|
+
if (impactedObject.ADDED && impactedObject.ADDED.length) {
|
39
|
+
changedComponentsList = changedComponentsList.concat(removeExtn(impactedObject.ADDED));
|
40
|
+
}
|
41
|
+
|
42
|
+
if (impactedObject.UPDATED && impactedObject.UPDATED.length) {
|
43
|
+
changedComponentsList = changedComponentsList.concat(removeExtn(impactedObject.UPDATED));
|
44
|
+
}
|
45
|
+
|
46
|
+
if (impactedObject.REMOVED && impactedObject.REMOVED.length) {
|
47
|
+
changedComponentsList = changedComponentsList.concat(removeExtn(impactedObject.REMOVED));
|
48
|
+
}
|
49
|
+
|
50
|
+
return changedComponentsList;
|
51
|
+
};
|
52
|
+
|
53
|
+
let referencedbyList = [];
|
54
|
+
|
55
|
+
let getReferencedBy = (moduleDataObject, fileName) => {
|
56
|
+
if (moduleDataObject[fileName]) {
|
57
|
+
let referenceObject = moduleDataObject[fileName];
|
58
|
+
let referencedbyObject = referenceObject.referencedby;
|
59
|
+
|
60
|
+
if (referencedbyObject.length) {
|
61
|
+
if (!referencedbyList.includes(referenceObject.docsName)) {
|
62
|
+
referencedbyList.push(referenceObject.docsName);
|
63
|
+
}
|
64
|
+
|
65
|
+
referencedbyObject.forEach(referencedByFile => {
|
66
|
+
if (!referencedbyList.includes(moduleDataObject[referencedByFile].docsName)) {
|
67
|
+
let result = getReferencedBy(moduleDataObject, referencedByFile);
|
68
|
+
|
69
|
+
if (typeof result === 'string') {
|
70
|
+
referencedbyList.push(result);
|
71
|
+
}
|
72
|
+
}
|
73
|
+
});
|
74
|
+
} else {
|
75
|
+
return fileName;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
return referencedbyList;
|
80
|
+
};
|
81
|
+
|
82
|
+
let checkDocs = AppComponentObject => {
|
83
|
+
let unDocsComponentNameList = [];
|
84
|
+
Object.keys(AppComponentObject).forEach(actionKey => {
|
85
|
+
AppComponentObject[actionKey].forEach(compObj => {
|
86
|
+
if (compObj.FILEPATH.includes('/src/components/')) {
|
87
|
+
if (compObj.name.includes('.js') || compObj.name.includes('.css')) {
|
88
|
+
if (!compObj.name.includes('.docs.')) {
|
89
|
+
if (!compObj.FILEPATH.includes('/src/components/docs/')) {
|
90
|
+
unDocsComponentNameList.push(process.cwd() + compObj.FILEPATH.replace('jsapps/supportapp', ''));
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
});
|
96
|
+
});
|
97
|
+
return unDocsComponentNameList;
|
98
|
+
};
|
99
|
+
|
100
|
+
var _default = (mDataStr, ComponentObj) => {
|
101
|
+
let mDataObject = JSON.parse(mDataStr);
|
102
|
+
let impactedComponentList = [];
|
103
|
+
let unDocsComList = [];
|
104
|
+
Object.keys(ComponentObj).forEach(libraryName => {
|
105
|
+
if (libraryName === 'AppSource') {
|
106
|
+
unDocsComList = checkDocs(ComponentObj[libraryName]);
|
107
|
+
}
|
108
|
+
|
109
|
+
let totalChangedFilesList = getChangedFileName(ComponentObj[libraryName]);
|
110
|
+
totalChangedFilesList.forEach(changedFileName => {
|
111
|
+
let referencedByComponents = getReferencedBy(mDataObject, changedFileName);
|
112
|
+
|
113
|
+
if (Array.isArray(referencedByComponents)) {
|
114
|
+
impactedComponentList = impactedComponentList.concat(referencedByComponents);
|
115
|
+
} else if (typeof referencedByComponents === 'string') {
|
116
|
+
impactedComponentList.push(referencedByComponents);
|
117
|
+
}
|
118
|
+
});
|
119
|
+
});
|
120
|
+
return {
|
121
|
+
impactedComponentList: eliminateDuplicates(impactedComponentList),
|
122
|
+
unDocsComList: unDocsComList
|
123
|
+
};
|
124
|
+
};
|
125
|
+
|
126
|
+
exports.default = _default;
|
@@ -1,35 +1,29 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.default = void 0;
|
6
7
|
|
7
|
-
var
|
8
|
+
var _child_process = require("child_process");
|
8
9
|
|
9
|
-
var
|
10
|
+
var _default = (type = 'git', cwd = process.cwd()) => {
|
11
|
+
let results;
|
10
12
|
|
11
|
-
exports.default = function () {
|
12
|
-
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'git';
|
13
|
-
var cwd = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : __dirname;
|
14
|
-
|
15
|
-
var results = void 0;
|
16
13
|
if (type === 'git') {
|
17
14
|
results = (0, _child_process.spawnSync)('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {
|
18
15
|
encoding: 'utf8',
|
19
|
-
cwd
|
16
|
+
cwd
|
20
17
|
});
|
21
18
|
} else if (type === 'hg') {
|
22
19
|
results = (0, _child_process.spawnSync)('hg', ['identify', '-b'], {
|
23
20
|
encoding: 'utf8',
|
24
|
-
cwd
|
21
|
+
cwd
|
25
22
|
});
|
26
23
|
}
|
27
24
|
|
28
|
-
|
29
|
-
return d;
|
30
|
-
}),
|
31
|
-
_results$output$filte2 = _slicedToArray(_results$output$filte, 1),
|
32
|
-
currentBranch = _results$output$filte2[0];
|
33
|
-
|
25
|
+
let [currentBranch] = results.output.filter(d => d);
|
34
26
|
return currentBranch.replace(/(\r\n|\n|\r)/gm, '');
|
35
|
-
};
|
27
|
+
};
|
28
|
+
|
29
|
+
exports.default = _default;
|