@zohodesk/react-cli 0.0.1-beta.17 → 0.0.1-beta.171
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 +49 -10
- package/.prettierrc +6 -0
- package/CHANGELOG.md +5 -0
- package/README.md +859 -0
- package/bin/cli.js +215 -46
- package/cert/Tsicsezwild-22-23.crt +37 -0
- package/cert/Tsicsezwild-22-23.key +27 -0
- package/docs/CustomChunks.md +26 -0
- package/docs/DevStart.md +18 -0
- package/docs/HoverActive.md +12 -0
- package/docs/InstallNode.md +28 -0
- package/docs/TODOS.md +10 -0
- package/docs/ValueReplacer.md +60 -0
- package/docs/warnings_while_install.txt +35 -0
- package/files/eslintrc.js +62 -0
- package/files/prettierrc.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +24 -0
- package/lib/babel/es-plugins-presets.js +34 -0
- package/lib/common/getEntries.js +33 -46
- package/lib/common/getPublicPathConfig.js +40 -0
- package/lib/common/index.js +24 -19
- package/lib/common/splitChunks.js +110 -25
- package/lib/common/sslcertUpdater.js +59 -0
- package/lib/common/templateParameters.js +25 -0
- package/lib/common/testPattern.js +69 -0
- package/lib/common/valueReplacer.js +55 -0
- package/lib/configs/jest.config.js +31 -27
- package/lib/configs/libAlias.js +31 -0
- package/lib/configs/webpack.component.umd.config.js +46 -53
- package/lib/configs/webpack.css.umd.config.js +47 -46
- package/lib/configs/webpack.dev.config.js +99 -84
- package/lib/configs/webpack.docs.config.js +65 -57
- package/lib/configs/webpack.impact.config.js +109 -0
- package/lib/configs/webpack.prod.config.js +147 -104
- package/lib/hooks/docsProptypeHook.js +32 -38
- package/lib/jest/commitedFilesResult.js +144 -71
- package/lib/jest/coverageCollector.js +68 -35
- 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 +92 -42
- package/lib/jest/run.js +75 -28
- package/lib/jest/setup.js +103 -102
- package/lib/loaderUtils/configsAssetsLoaders.js +117 -0
- package/lib/loaderUtils/getCSSLoaders.js +113 -0
- package/lib/loaderUtils/getDevJsLoaders.js +35 -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 +23 -20
- package/lib/loaders/selectorMappingLoader.js +75 -0
- package/lib/loaders/workerLoader.js +136 -0
- package/lib/middlewares/HMRMiddleware.js +90 -72
- package/lib/middlewares/SSTMiddleware.js +21 -0
- package/lib/pluginUtils/getDevPlugins.js +177 -30
- package/lib/pluginUtils/getDocsPlugins.js +36 -15
- package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
- package/lib/pluginUtils/getLibraryPlugins.js +8 -10
- package/lib/pluginUtils/getProdPlugins.js +244 -37
- package/lib/pluginUtils/getServerPlugins.js +8 -11
- package/lib/pluginUtils/getUMDCSSPlugins.js +14 -18
- package/lib/pluginUtils/getUMDComponentPlugins.js +14 -9
- 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 +241 -0
- package/lib/plugins/EFCPlugin.md +6 -0
- package/lib/plugins/EFCTemplatePlugin.js +151 -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 +95 -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 +86 -0
- package/lib/plugins/ModuleStatsPlugin.js +98 -97
- package/lib/plugins/OptimizeJSPlugin.js +41 -0
- package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
- package/lib/plugins/PublicPathChangePlugin.js +226 -0
- package/lib/plugins/ReportGeneratePlugin.js +181 -0
- package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
- package/lib/plugins/ResourceHintsPlugin.js +67 -0
- 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 -59
- package/lib/plugins/TPHashMappingPlugin.js +67 -0
- package/lib/plugins/UglifyCSSPlugin.js +39 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
- package/lib/plugins/index.js +127 -37
- package/lib/plugins/libraryImpactPlugin.js +190 -0
- package/lib/plugins/webpackwatchrunplugin.js +26 -0
- package/lib/postcss-plugins/ExcludePlugin.js +23 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
- package/lib/postcss-plugins/ValueReplacer.js +46 -0
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +22 -0
- package/lib/postcss-plugins/__test__/test1Input.css +39 -0
- package/lib/postcss-plugins/__test__/test1Output.css +39 -0
- package/lib/postcss-plugins/hoverActivePlugin.js +368 -0
- package/lib/postcss-plugins/variableModifier.js +243 -0
- package/lib/schemas/index.js +541 -65
- package/lib/servers/clusterHubServer.js +22 -26
- package/lib/servers/devBuild.js +102 -0
- package/lib/servers/docsServer.js +3 -5
- package/lib/servers/docsServerCore.js +94 -79
- package/lib/servers/getCliPath.js +28 -0
- package/lib/servers/helpServer.js +19 -21
- package/lib/servers/httpsOptions.js +18 -0
- package/lib/servers/impactServer.js +123 -115
- package/lib/servers/mockserver.js +44 -0
- package/lib/servers/nowatchserver.js +200 -0
- package/lib/servers/scrServer.js +147 -0
- package/lib/servers/server.js +134 -132
- package/lib/servers/ssServer.js +106 -70
- 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 -4
- package/lib/utils/buildstats.html +148 -0
- package/lib/utils/clean.js +12 -11
- package/lib/utils/copy.js +16 -109
- package/lib/utils/copyTimezones.js +21 -0
- package/lib/utils/createEventStream.js +24 -19
- package/lib/utils/cssClassNameGenerate.js +77 -0
- package/lib/utils/cssURLReplacer.js +136 -0
- 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 +113 -28
- package/lib/utils/getServerURL.js +25 -8
- package/lib/utils/index.js +283 -68
- package/lib/utils/init.js +2 -2
- package/lib/utils/initPreCommitHook.js +47 -27
- package/lib/utils/jsonHelper.js +106 -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 +59 -63
- package/lib/utils/request.js +64 -77
- package/lib/utils/resultSchema.json +73 -0
- package/lib/utils/rtl.js +59 -0
- package/lib/utils/setEnvVariables.js +13 -0
- package/lib/utils/ssTestHack.js +48 -0
- package/lib/utils/switchBranch.js +28 -0
- package/lib/utils/urlConcat.js +22 -0
- package/lib/utils/useExitCleanup.js +55 -0
- package/npm8.md +9 -0
- package/package.json +96 -64
- package/postpublish.js +6 -0
- 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
- package/.npmignore +0 -3
- package/cert/cert.pem +0 -129
- package/cert/key.pem +0 -27
- package/lib/common/getInsertAt.js +0 -36
- package/lib/common/getInsertIntoFunction.js +0 -13
- package/lib/configs/webpack.server.config.js +0 -93
- package/lib/plugins/ChunkManifestReplacePlugin.js +0 -94
- package/lib/plugins/RuntimePublicPathPlugin.js +0 -46
- package/lib/rmcntrlm.sh +0 -14
- package/lib/servers/nodeServer.js +0 -238
- package/lib/templates/HMRTemplate.js +0 -256
- package/lib/templates/publicPathTemplate.js +0 -16
- package/lib/utils/setConfig.js +0 -14
- package/node_modules/history/CHANGES.md +0 -395
- package/node_modules/history/DOMUtils.js +0 -3
- package/node_modules/history/ExecutionEnvironment.js +0 -3
- package/node_modules/history/LICENSE +0 -21
- package/node_modules/history/LocationUtils.js +0 -3
- package/node_modules/history/PathUtils.js +0 -3
- package/node_modules/history/README.md +0 -282
- package/node_modules/history/cjs/history.js +0 -933
- package/node_modules/history/cjs/history.min.js +0 -1
- package/node_modules/history/createBrowserHistory.js +0 -3
- package/node_modules/history/createHashHistory.js +0 -3
- package/node_modules/history/createMemoryHistory.js +0 -3
- package/node_modules/history/createTransitionManager.js +0 -3
- package/node_modules/history/es/DOMUtils.js +0 -7
- package/node_modules/history/es/ExecutionEnvironment.js +0 -7
- package/node_modules/history/es/LocationUtils.js +0 -7
- package/node_modules/history/es/PathUtils.js +0 -7
- package/node_modules/history/es/createBrowserHistory.js +0 -7
- package/node_modules/history/es/createHashHistory.js +0 -7
- package/node_modules/history/es/createMemoryHistory.js +0 -7
- package/node_modules/history/es/createTransitionManager.js +0 -7
- package/node_modules/history/es/warnAboutDeprecatedESMImport.js +0 -35
- package/node_modules/history/esm/history.js +0 -904
- package/node_modules/history/index.js +0 -7
- package/node_modules/history/package.json +0 -134
- package/node_modules/history/umd/history.js +0 -1059
- package/node_modules/history/umd/history.min.js +0 -1
- package/node_modules/history/warnAboutDeprecatedCJSRequire.js +0 -35
- package/templates/app/.npmignore +0 -9
- package/templates/library/.npmignore +0 -9
package/lib/utils/copy.js
CHANGED
@@ -1,118 +1,25 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
|
-
var
|
3
|
+
var _path = _interopRequireDefault(require("path"));
|
4
4
|
|
5
|
-
var
|
5
|
+
var _fs = _interopRequireDefault(require("fs"));
|
6
6
|
|
7
|
-
var
|
8
|
-
|
9
|
-
var _fs = require('fs');
|
10
|
-
|
11
|
-
var _fs2 = _interopRequireDefault(_fs);
|
12
|
-
|
13
|
-
var _index = require('./index');
|
7
|
+
var _fileUtils = require("./fileUtils");
|
14
8
|
|
15
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
10
|
|
17
|
-
|
18
|
-
var appPath = _fs2.default.realpathSync(process.cwd());
|
11
|
+
let args = process.argv.slice(2);
|
19
12
|
|
20
|
-
|
21
|
-
srcPath = _args[0],
|
22
|
-
targetPath = _args[1],
|
23
|
-
exts = _args[2],
|
24
|
-
_args$ = _args[3],
|
25
|
-
isCopy = _args$ === undefined ? true : _args$,
|
26
|
-
_args$2 = _args[4],
|
27
|
-
flatten = _args$2 === undefined ? '' : _args$2;
|
13
|
+
let appPath = _fs.default.realpathSync(process.cwd());
|
28
14
|
|
29
|
-
exts =
|
30
|
-
|
31
|
-
|
32
|
-
srcPath = _path2.default.join(appPath, srcPath);
|
15
|
+
let [srcPath, targetPath, exts, isCopy = true, flatten = '', changeExt = ''] = args;
|
16
|
+
exts = exts ? exts.split(',').map(ext => `.${ext.trim()}`) : false;
|
17
|
+
srcPath = _path.default.join(appPath, srcPath);
|
33
18
|
targetPath = targetPath === '."' || !targetPath ? '' : targetPath;
|
34
|
-
targetPath =
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
} else {
|
42
|
-
_fs2.default.unlinkSync(fileOrDirPath);
|
43
|
-
}
|
44
|
-
});
|
45
|
-
_fs2.default.rmdirSync(dirPath);
|
46
|
-
};
|
47
|
-
|
48
|
-
var copyFile = function copyFile(srcPath, targetPath) {
|
49
|
-
var isCopy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
50
|
-
|
51
|
-
var readStream = _fs2.default.createReadStream(srcPath);
|
52
|
-
var writeStream = _fs2.default.createWriteStream(targetPath);
|
53
|
-
readStream.pipe(writeStream);
|
54
|
-
|
55
|
-
writeStream.on('finish', function () {
|
56
|
-
if (!isCopy) {
|
57
|
-
_fs2.default.unlinkSync(srcPath);
|
58
|
-
}
|
59
|
-
});
|
60
|
-
};
|
61
|
-
|
62
|
-
var iterateDirectory = function iterateDirectory(srcPath, targetPath, isCopy, extensions, flatten) {
|
63
|
-
_fs2.default.readdirSync(srcPath).forEach(function (fileOrDir) {
|
64
|
-
var fromPath = _path2.default.join(srcPath, fileOrDir);
|
65
|
-
var toPath = targetPath;
|
66
|
-
|
67
|
-
if (flatten !== 'flatten' || !_fs2.default.statSync(fromPath).isDirectory()) {
|
68
|
-
toPath = _path2.default.join(targetPath, fileOrDir);
|
69
|
-
}
|
70
|
-
|
71
|
-
if (_fs2.default.statSync(fromPath).isDirectory()) {
|
72
|
-
if (!_fs2.default.existsSync(toPath)) {
|
73
|
-
_fs2.default.mkdirSync(toPath);
|
74
|
-
}
|
75
|
-
iterateDirectory(fromPath, toPath, isCopy, extensions, flatten);
|
76
|
-
} else {
|
77
|
-
if (extensions) {
|
78
|
-
var _path$parse = _path2.default.parse(fromPath),
|
79
|
-
ext = _path$parse.ext;
|
80
|
-
|
81
|
-
if (extensions.indexOf(ext) !== -1) {
|
82
|
-
copyFile(fromPath, toPath);
|
83
|
-
}
|
84
|
-
} else {
|
85
|
-
copyFile(fromPath, toPath);
|
86
|
-
}
|
87
|
-
}
|
88
|
-
});
|
89
|
-
};
|
90
|
-
|
91
|
-
var copy = function copy(srcPath, targetPath, isCopy, exts, flatten) {
|
92
|
-
if (_fs2.default.statSync(srcPath).isDirectory()) {
|
93
|
-
if (!_fs2.default.existsSync(targetPath)) {
|
94
|
-
_fs2.default.mkdirSync(targetPath);
|
95
|
-
}
|
96
|
-
|
97
|
-
var _path$parse2 = _path2.default.parse(srcPath),
|
98
|
-
name = _path$parse2.name;
|
99
|
-
|
100
|
-
var originPath = targetPath;
|
101
|
-
if (flatten !== 'flatten') {
|
102
|
-
originPath = _path2.default.join(targetPath, name);
|
103
|
-
if (!_fs2.default.existsSync(originPath)) {
|
104
|
-
_fs2.default.mkdirSync(originPath);
|
105
|
-
}
|
106
|
-
}
|
107
|
-
iterateDirectory(srcPath, originPath, isCopy, exts, flatten);
|
108
|
-
} else {
|
109
|
-
/* direct file copy issue there but that feature not needed i think*/
|
110
|
-
copyFile(srcPath, targetPath, isCopy);
|
111
|
-
}
|
112
|
-
if (!isCopy) {
|
113
|
-
removeDirectory(srcPath);
|
114
|
-
}
|
115
|
-
(0, _index.log)(isCopy ? 'Folder/file are copied!' : 'Folder/file are moved!');
|
116
|
-
};
|
117
|
-
|
118
|
-
copy(srcPath, targetPath, isCopy, exts, flatten);
|
19
|
+
targetPath = _path.default.join(appPath, targetPath);
|
20
|
+
changeExt = changeExt.split(',').reduce((obj, ext) => {
|
21
|
+
let [key, value] = ext.split('~');
|
22
|
+
obj[key] = value;
|
23
|
+
return obj;
|
24
|
+
}, {});
|
25
|
+
(0, _fileUtils.copy)(srcPath, targetPath, isCopy, exts, flatten, changeExt);
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _path = _interopRequireDefault(require("path"));
|
4
|
+
|
5
|
+
var _fs = _interopRequireDefault(require("fs"));
|
6
|
+
|
7
|
+
var _fileUtils = require("./fileUtils");
|
8
|
+
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
|
+
|
11
|
+
let args = process.argv.slice(2);
|
12
|
+
|
13
|
+
let appPath = _fs.default.realpathSync(process.cwd());
|
14
|
+
|
15
|
+
let [targetPath] = args;
|
16
|
+
targetPath = targetPath === '."' || !targetPath ? '' : targetPath;
|
17
|
+
targetPath = _path.default.join(appPath, targetPath);
|
18
|
+
|
19
|
+
let srcPath = _path.default.resolve(_path.default.dirname(require.resolve('@zohodesk/datetimejs')), '../data/timezones/');
|
20
|
+
|
21
|
+
(0, _fileUtils.copy)(srcPath, targetPath, true, null, 'flatten');
|
@@ -1,32 +1,36 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
|
7
|
-
var heartbeatInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
6
|
+
exports.default = void 0;
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
let createEventStream = (heartbeat, heartbeatInfo = null) => {
|
9
|
+
let clientId = 0;
|
10
|
+
let clients = {};
|
11
|
+
|
12
|
+
let everyClient = fn => {
|
13
|
+
Object.keys(clients).forEach(id => {
|
13
14
|
fn(clients[id]);
|
14
15
|
});
|
15
16
|
};
|
16
|
-
|
17
|
-
|
17
|
+
|
18
|
+
setInterval(() => {
|
19
|
+
everyClient(client => {
|
18
20
|
if (heartbeatInfo) {
|
19
|
-
client.write(
|
21
|
+
client.write(`data: ${JSON.stringify({
|
20
22
|
type: 'heartbeat',
|
21
23
|
info: heartbeatInfo()
|
22
|
-
})
|
24
|
+
})}\n\n`);
|
23
25
|
} else {
|
24
|
-
client.write(
|
26
|
+
client.write(`data: ${JSON.stringify({
|
27
|
+
type: 'heartbeat'
|
28
|
+
})}\n\n`);
|
25
29
|
}
|
26
30
|
});
|
27
31
|
}, heartbeat).unref();
|
28
32
|
return {
|
29
|
-
handler:
|
33
|
+
handler: (req, res) => {
|
30
34
|
req.socket.setKeepAlive(true);
|
31
35
|
res.writeHead(200, {
|
32
36
|
'Access-Control-Allow-Origin': '*',
|
@@ -35,18 +39,19 @@ var createEventStream = function createEventStream(heartbeat) {
|
|
35
39
|
Connection: 'keep-alive'
|
36
40
|
});
|
37
41
|
res.write('\n');
|
38
|
-
|
42
|
+
let id = clientId++;
|
39
43
|
clients[id] = res;
|
40
|
-
req.on('close',
|
44
|
+
req.on('close', () => {
|
41
45
|
delete clients[id];
|
42
46
|
});
|
43
47
|
},
|
44
|
-
publish:
|
45
|
-
everyClient(
|
46
|
-
client.write(
|
48
|
+
publish: payload => {
|
49
|
+
everyClient(client => {
|
50
|
+
client.write(`data: ${JSON.stringify(payload)}\n\n`);
|
47
51
|
});
|
48
52
|
}
|
49
53
|
};
|
50
54
|
};
|
51
55
|
|
52
|
-
|
56
|
+
var _default = createEventStream;
|
57
|
+
exports.default = _default;
|
@@ -0,0 +1,77 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _os = _interopRequireDefault(require("os"));
|
9
|
+
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
11
|
+
|
12
|
+
var _getHash = _interopRequireDefault(require("./getHash"));
|
13
|
+
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
+
|
16
|
+
let isWindows = _os.default.platform().toLowerCase() === 'win32';
|
17
|
+
|
18
|
+
let isSelectorPackage = (resourcePath, packages) => {
|
19
|
+
if (!resourcePath.includes('node_modules')) {
|
20
|
+
return false;
|
21
|
+
}
|
22
|
+
|
23
|
+
let isValid = false;
|
24
|
+
|
25
|
+
for (let pack of packages) {
|
26
|
+
if (isWindows) {
|
27
|
+
pack = pack.replace(/\//g, '\\');
|
28
|
+
}
|
29
|
+
|
30
|
+
if (resourcePath.includes(pack)) {
|
31
|
+
isValid = true;
|
32
|
+
break;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
return isValid;
|
37
|
+
};
|
38
|
+
|
39
|
+
var _default = (unique = true, {
|
40
|
+
filenames,
|
41
|
+
packages
|
42
|
+
}, classNamePrefix) => (context, localIdentName, localName) => {
|
43
|
+
// NOTE: in build macine we use date as folder path.
|
44
|
+
// So every time we create new build there is path will alway different
|
45
|
+
// in order to minmaze that problem we try in relative path;
|
46
|
+
// console.log('context.resourcePath', context.resourcePath, context);
|
47
|
+
// let contextResourcePath = context.resourcePath;
|
48
|
+
let relativePath = _path.default.relative(context.rootContext, context.resourcePath);
|
49
|
+
|
50
|
+
if (context.resourcePath.endsWith('.plain.css')) {
|
51
|
+
return localName;
|
52
|
+
}
|
53
|
+
/* old production mode start without breaking so added. may be removed in future*/
|
54
|
+
|
55
|
+
|
56
|
+
if (unique) {
|
57
|
+
let h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
|
58
|
+
return `${classNamePrefix}${h}`;
|
59
|
+
}
|
60
|
+
/* old production mode end*/
|
61
|
+
|
62
|
+
|
63
|
+
let filePaths = context.resourcePath.split(_path.default.sep);
|
64
|
+
let fileName = filePaths[filePaths.length - 1];
|
65
|
+
let [fileNameWithoutExt] = fileName.split('.');
|
66
|
+
let cleanFileName = fileNameWithoutExt.replace(/-/g, '_').toLowerCase(); //css file has casesensitive selector issue so can't toLowerCase
|
67
|
+
//let local = localName.toLowerCase()
|
68
|
+
|
69
|
+
if (isSelectorPackage(context.resourcePath, packages) || filenames.indexOf(cleanFileName) !== -1) {
|
70
|
+
let h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
|
71
|
+
return `${classNamePrefix}${h}`;
|
72
|
+
}
|
73
|
+
|
74
|
+
return `${classNamePrefix}-${cleanFileName}-${localName}`;
|
75
|
+
};
|
76
|
+
|
77
|
+
exports.default = _default;
|
@@ -0,0 +1,136 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getUrls = exports.getFileType = exports.cssUrlReplacer = void 0;
|
7
|
+
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
9
|
+
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
11
|
+
|
12
|
+
var _crypto = _interopRequireDefault(require("crypto"));
|
13
|
+
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
+
|
16
|
+
let urlRegex = /url\(.*?\)/g;
|
17
|
+
|
18
|
+
let getHash = (file, isPath = false, needSubStr = true) => {
|
19
|
+
let hash = _crypto.default.createHash('md5');
|
20
|
+
|
21
|
+
if (isPath) {
|
22
|
+
hash.update(_fs.default.readFileSync(file));
|
23
|
+
} else {
|
24
|
+
hash.update(file);
|
25
|
+
}
|
26
|
+
|
27
|
+
hash = hash.digest('hex');
|
28
|
+
return hash ? needSubStr ? hash.substring(0, 20) : hash : null;
|
29
|
+
};
|
30
|
+
|
31
|
+
let getFileType = file => {
|
32
|
+
let {
|
33
|
+
ext
|
34
|
+
} = _path.default.parse(file);
|
35
|
+
|
36
|
+
if (ext === '.gif' || ext === '.png' || ext === '.jpg' || ext === '.jpeg' || ext === '.ico') {
|
37
|
+
return 'image';
|
38
|
+
} else if (ext === '.svg' || ext === '.woff' || ext === '.eot' || ext === '.ttf' || ext === '.woff2') {
|
39
|
+
return 'font';
|
40
|
+
} else if (ext === '.js') {
|
41
|
+
return 'js';
|
42
|
+
} else if (ext === '.css') {
|
43
|
+
return 'css';
|
44
|
+
}
|
45
|
+
|
46
|
+
return null;
|
47
|
+
};
|
48
|
+
|
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);
|
55
|
+
char = char === '(' ? ')' : char;
|
56
|
+
return substr.substring(0, substr.indexOf(char));
|
57
|
+
};
|
58
|
+
|
59
|
+
let getUrls = css => {
|
60
|
+
let urlMatches = css.match(urlRegex);
|
61
|
+
let src = css;
|
62
|
+
|
63
|
+
if (urlMatches) {
|
64
|
+
let patterns = {};
|
65
|
+
urlMatches.forEach(pattern => {
|
66
|
+
let url = formatUrl(pattern);
|
67
|
+
let hash = getHash(url);
|
68
|
+
patterns[url] = hash;
|
69
|
+
let regex = new RegExp(pattern.replace(/([<>*()?${}|])/g, '\\$1'), 'g');
|
70
|
+
src = src.replace(regex, hash);
|
71
|
+
});
|
72
|
+
return {
|
73
|
+
urls: patterns,
|
74
|
+
css: src
|
75
|
+
};
|
76
|
+
}
|
77
|
+
};
|
78
|
+
|
79
|
+
exports.getUrls = getUrls;
|
80
|
+
|
81
|
+
let cssUrlReplacer = (css, domains, chunkHash = {}) => {
|
82
|
+
let obj = getUrls(css);
|
83
|
+
let src = css;
|
84
|
+
|
85
|
+
if (obj) {
|
86
|
+
let patterns = obj.urls;
|
87
|
+
src = obj.css;
|
88
|
+
Object.keys(patterns).forEach(pattern => {
|
89
|
+
let urlParts = pattern.split('/');
|
90
|
+
let fileName = urlParts.pop();
|
91
|
+
|
92
|
+
if (fileName.includes('#')) {
|
93
|
+
if (fileName.includes('?')) {
|
94
|
+
fileName = fileName.replace(/\?.*#/g, '#');
|
95
|
+
}
|
96
|
+
} else {
|
97
|
+
fileName = fileName.replace(/\?.*$/g, '');
|
98
|
+
}
|
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('/');
|
114
|
+
urlParts = customPath.split('/');
|
115
|
+
}
|
116
|
+
|
117
|
+
if (hashedName) {
|
118
|
+
if (fileName.includes('#')) {
|
119
|
+
if (fileName.includes('?')) {
|
120
|
+
hashedName = `${hashedName}?${fileName.split('?')[1]}`;
|
121
|
+
} else {
|
122
|
+
hashedName = `${hashedName}#${fileName.split('#')[1]}`;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
urlParts.push(hashedName || fileName);
|
128
|
+
urlParts = urlParts.join('/');
|
129
|
+
src = src.replace(regex, `url('${urlParts}')`);
|
130
|
+
});
|
131
|
+
}
|
132
|
+
|
133
|
+
return src;
|
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;
|