@zohodesk/react-cli 0.0.1-test.148.3 → 1.0.0-exp.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintignore +7 -7
- package/.eslintrc.js +180 -183
- package/.prettierrc +6 -0
- package/{CHANGELOG.md → CHANGELOG-fz.md} +0 -0
- package/Changelog.md +1019 -0
- package/README.md +1161 -678
- package/bin/cli.js +483 -392
- package/docs/CustomChunks.md +26 -0
- package/docs/DevServerPort.md +39 -0
- package/docs/DevStart.md +18 -0
- package/docs/HoverActive.md +12 -0
- package/docs/InstallNode.md +28 -0
- package/docs/SelectorWeight.md +6 -0
- package/docs/TODOS.md +10 -0
- package/docs/ValueReplacer.md +60 -0
- package/docs/VariableConversion.md +724 -0
- package/docs/warnings_while_install.txt +35 -0
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- package/lib/common/getEntries.js +9 -6
- package/lib/common/index.js +6 -6
- package/lib/common/splitChunks.js +60 -12
- package/lib/common/sslcertUpdater.js +59 -0
- package/lib/common/testPattern.js +69 -0
- package/lib/common/valueReplacer.js +55 -0
- package/lib/configs/jest.config.js +18 -8
- package/lib/configs/libAlias.js +38 -0
- package/lib/configs/resolvers.js +40 -0
- package/lib/configs/webpack.css.umd.config.js +4 -4
- package/lib/configs/webpack.dev.config.js +59 -54
- package/lib/configs/webpack.docs.config.js +74 -59
- package/lib/configs/webpack.docs1.config.js +122 -0
- package/lib/configs/webpack.impact.config.js +54 -50
- package/lib/configs/webpack.prod.config.js +72 -47
- package/lib/constants.js +31 -0
- package/lib/hooks/docsEntry.js +18 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -7
- package/lib/loaderUtils/configsAssetsLoaders.js +117 -0
- package/lib/loaderUtils/getCSSLoaders.js +89 -21
- package/lib/loaderUtils/index.js +4 -4
- package/lib/loaderUtils/windowsModification.js +11 -0
- package/lib/loaders/fileBountryLoader.js +17 -0
- package/lib/loaders/scriptInstrumentLoader.js +2 -2
- package/lib/loaders/selectorMappingLoader.js +75 -0
- package/lib/loaders/workerLoader.js +9 -9
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +60 -0
- package/lib/pluginUtils/getDevPlugins.js +70 -45
- package/lib/pluginUtils/getDocsPlugins.js +21 -10
- package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
- package/lib/pluginUtils/getProdPlugins.js +74 -58
- package/lib/pluginUtils/index.js +12 -12
- package/lib/plugins/CdnChangePlugin.js +16 -2
- package/lib/plugins/EFCPlugin.js +52 -20
- package/lib/plugins/EFCPlugin.md +6 -0
- package/lib/plugins/EFCTemplatePlugin.js +151 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +4 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +8 -8
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -86
- package/lib/plugins/I18nSplitPlugin/README.md +25 -25
- package/lib/plugins/I18nSplitPlugin/index.js +57 -57
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +2 -2
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +1 -1
- package/lib/plugins/ManifestPlugin.js +8 -0
- package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
- package/lib/plugins/ResourceHintsPlugin.js +17 -17
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +6 -6
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
- package/lib/plugins/SelectorPlugin.js +97 -0
- package/lib/plugins/ServiceWorkerPlugin.js +13 -9
- package/lib/plugins/SourceMapHookPlugin.js +9 -3
- package/lib/plugins/TPHashMappingPlugin.js +4 -4
- package/lib/plugins/VariableConversionCollector.js +352 -0
- package/lib/plugins/composeCommonPlugin.js +30 -0
- package/lib/plugins/index.js +36 -36
- package/lib/plugins/libraryImpactPlugin.js +14 -2
- package/lib/postcss-plugins/{ExcludeRTLPlugin.js → ExcludePlugin.js} +1 -1
- package/lib/postcss-plugins/RTLSplitPlugin.js +13 -13
- 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 +389 -0
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +60 -0
- package/lib/postcss-plugins/variableModificationPlugin/index.js +307 -0
- package/lib/postcss-plugins/variableModifier.js +244 -0
- package/lib/schemas/index.js +173 -11
- package/lib/servers/devBuild.js +102 -0
- package/lib/servers/docsServerCore.js +16 -18
- package/lib/servers/getCliPath.js +28 -0
- package/lib/servers/httpsOptions.js +49 -0
- package/lib/servers/nowatchserver.js +206 -0
- package/lib/servers/server.js +114 -82
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -45
- package/lib/templates/linterConstant.js +1 -1
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/cssClassNameGenerate.js +9 -2
- package/lib/utils/cssURLReplacer.js +30 -43
- package/lib/utils/getCurrentBranch.js +1 -1
- package/lib/utils/getDependenciesImpactList.js +14 -12
- package/lib/utils/getFileType.js +49 -0
- package/lib/utils/getOptions.js +118 -10
- package/lib/utils/index.js +44 -20
- package/lib/utils/jsonHelper.js +12 -3
- package/lib/utils/reinstallDependencies.js +1 -1
- package/lib/utils/repoClone.js +16 -4
- package/lib/utils/resultSchema.json +73 -73
- package/lib/utils/rtl.js +19 -2
- package/lib/utils/useExitCleanup.js +55 -0
- package/npm8.md +9 -0
- package/package.json +121 -142
- package/postpublish.js +8 -0
- package/result.json +1 -0
- package/templates/app/.eslintrc.js +140 -140
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -24
- package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
- package/templates/app/app/properties/i18nkeys.json +3 -3
- package/templates/app/docs/all.html +69 -69
- package/templates/app/mockapi/index.js +18 -18
- package/templates/app/package.json +37 -37
- package/templates/app/src/actions/SampleActions/index.js +37 -37
- package/templates/app/src/actions/index.js +65 -65
- package/templates/app/src/appUrls.js +19 -19
- package/templates/app/src/components/Alert/Alert.js +134 -134
- package/templates/app/src/components/Alert/Alert.module.css +79 -79
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
- package/templates/app/src/components/Sample/Sample.module.css +11 -11
- package/templates/app/src/components/Sample/SampleList.js +61 -61
- package/templates/app/src/components/Slider/Slider.css +41 -41
- package/templates/app/src/components/Slider/Slider.js +55 -55
- package/templates/app/src/containers/AlertContainer/index.js +15 -15
- package/templates/app/src/containers/AppContainer/index.js +96 -96
- package/templates/app/src/containers/AppContainer/index.module.css +27 -27
- package/templates/app/src/containers/CustomMatch/index.js +65 -65
- package/templates/app/src/containers/DevTools/index.js +10 -10
- package/templates/app/src/containers/Header/index.js +67 -67
- package/templates/app/src/containers/Header/index.module.css +43 -43
- package/templates/app/src/containers/Redirect/index.js +63 -63
- package/templates/app/src/containers/Redirector/index.js +47 -47
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
- package/templates/app/src/historyChange.js +5 -5
- package/templates/app/src/index.html +10 -10
- package/templates/app/src/index.js +24 -24
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
- package/templates/app/src/reducers/alertData.js +11 -11
- package/templates/app/src/reducers/index.js +6 -6
- package/templates/app/src/reducers/samples.js +19 -19
- package/templates/app/src/store/configureStore.dev.js +51 -51
- package/templates/app/src/store/configureStore.js +5 -5
- package/templates/app/src/store/configureStore.prod.js +26 -26
- package/templates/app/src/util/Common.js +5 -5
- package/templates/app/src/util/RequestAPI.js +132 -132
- package/templates/docs/a.html +13 -0
- package/templates/docs/all.html +249 -249
- package/templates/docs/component.html +178 -178
- package/templates/docs/components.html +221 -221
- package/templates/docs/css/b.min.css +6 -6
- package/templates/docs/css/component.css +42 -42
- package/templates/docs/css/componentTest.css +6 -6
- package/templates/docs/css/hopscotch.css +585 -585
- package/templates/docs/css/style.css +1022 -1022
- package/templates/docs/docsEntry.js +14 -0
- package/templates/docs/docsRoot.js +3 -0
- package/templates/docs/impactReportTemplate.html +154 -154
- package/templates/docs/index.html +1501 -1493
- package/templates/docs/js/active-line.js +72 -72
- package/templates/docs/js/b.min.js +7 -7
- package/templates/docs/js/codemirror.js +9680 -9680
- package/templates/docs/js/designTokens.js +334 -334
- package/templates/docs/js/j.min.js +4 -4
- package/templates/docs/js/javascript.js +874 -874
- package/templates/docs/js/matchbrackets.js +145 -145
- package/unittest/index.html +37 -0
- package/cert/cert.pem +0 -105
- package/cert/key.pem +0 -30
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _postcss = _interopRequireDefault(require("postcss"));
|
9
|
+
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
+
|
12
|
+
class ComposeCommonPlugin {
|
13
|
+
constructor(options = {}) {
|
14
|
+
this.optimize = options.optimize;
|
15
|
+
}
|
16
|
+
|
17
|
+
apply(compiler) {
|
18
|
+
compiler.hooks.compilation.tap('OptimizeJSPlugin', compilation => {
|
19
|
+
compilation.hooks.optimizeModules.tap('OptimizeMods', modules => {
|
20
|
+
modules.forEach(module => {
|
21
|
+
console.log(module);
|
22
|
+
});
|
23
|
+
});
|
24
|
+
});
|
25
|
+
}
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
var _default = ComposeCommonPlugin;
|
30
|
+
exports.default = _default;
|
package/lib/plugins/index.js
CHANGED
@@ -3,88 +3,82 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
Object.defineProperty(exports, "
|
7
|
-
enumerable: true,
|
8
|
-
get: function () {
|
9
|
-
return _ModuleStatsPlugin.default;
|
10
|
-
}
|
11
|
-
});
|
12
|
-
Object.defineProperty(exports, "SourceMapHookPlugin", {
|
6
|
+
Object.defineProperty(exports, "CdnChangePlugin", {
|
13
7
|
enumerable: true,
|
14
8
|
get: function () {
|
15
|
-
return
|
9
|
+
return _CdnChangePlugin.default;
|
16
10
|
}
|
17
11
|
});
|
18
|
-
Object.defineProperty(exports, "
|
12
|
+
Object.defineProperty(exports, "CleanUpStatsPlugin", {
|
19
13
|
enumerable: true,
|
20
14
|
get: function () {
|
21
|
-
return
|
15
|
+
return _CleanupStatsPlugin.default;
|
22
16
|
}
|
23
17
|
});
|
24
|
-
Object.defineProperty(exports, "
|
18
|
+
Object.defineProperty(exports, "EFCPlugin", {
|
25
19
|
enumerable: true,
|
26
20
|
get: function () {
|
27
|
-
return
|
21
|
+
return _EFCPlugin.default;
|
28
22
|
}
|
29
23
|
});
|
30
|
-
Object.defineProperty(exports, "
|
24
|
+
Object.defineProperty(exports, "I18NInjectIntoIndexPlugin", {
|
31
25
|
enumerable: true,
|
32
26
|
get: function () {
|
33
|
-
return
|
27
|
+
return _I18NInjectIntoIndexPlugin.default;
|
34
28
|
}
|
35
29
|
});
|
36
|
-
Object.defineProperty(exports, "
|
30
|
+
Object.defineProperty(exports, "ManifestPlugin", {
|
37
31
|
enumerable: true,
|
38
32
|
get: function () {
|
39
|
-
return
|
33
|
+
return _ManifestPlugin.default;
|
40
34
|
}
|
41
35
|
});
|
42
|
-
Object.defineProperty(exports, "
|
36
|
+
Object.defineProperty(exports, "ModuleStatsPlugin", {
|
43
37
|
enumerable: true,
|
44
38
|
get: function () {
|
45
|
-
return
|
39
|
+
return _ModuleStatsPlugin.default;
|
46
40
|
}
|
47
41
|
});
|
48
|
-
Object.defineProperty(exports, "
|
42
|
+
Object.defineProperty(exports, "OptimizeJSPlugin", {
|
49
43
|
enumerable: true,
|
50
44
|
get: function () {
|
51
|
-
return
|
45
|
+
return _OptimizeJSPlugin.default;
|
52
46
|
}
|
53
47
|
});
|
54
|
-
Object.defineProperty(exports, "
|
48
|
+
Object.defineProperty(exports, "PublicPathCallbackPlugin", {
|
55
49
|
enumerable: true,
|
56
50
|
get: function () {
|
57
|
-
return
|
51
|
+
return _PublicPathCallbackPlugin.default;
|
58
52
|
}
|
59
53
|
});
|
60
|
-
Object.defineProperty(exports, "
|
54
|
+
Object.defineProperty(exports, "PublicPathChangePlugin", {
|
61
55
|
enumerable: true,
|
62
56
|
get: function () {
|
63
|
-
return
|
57
|
+
return _PublicPathChangePlugin.default;
|
64
58
|
}
|
65
59
|
});
|
66
|
-
Object.defineProperty(exports, "
|
60
|
+
Object.defineProperty(exports, "ReportGeneratePlugin", {
|
67
61
|
enumerable: true,
|
68
62
|
get: function () {
|
69
|
-
return
|
63
|
+
return _ReportGeneratePlugin.default;
|
70
64
|
}
|
71
65
|
});
|
72
|
-
Object.defineProperty(exports, "
|
66
|
+
Object.defineProperty(exports, "ResourceHintsPlugin", {
|
73
67
|
enumerable: true,
|
74
68
|
get: function () {
|
75
|
-
return
|
69
|
+
return _ResourceHintsPlugin.default;
|
76
70
|
}
|
77
71
|
});
|
78
|
-
Object.defineProperty(exports, "
|
72
|
+
Object.defineProperty(exports, "ScriptInstrumentPlugin", {
|
79
73
|
enumerable: true,
|
80
74
|
get: function () {
|
81
|
-
return
|
75
|
+
return _ScriptInstrumentPlugin.default;
|
82
76
|
}
|
83
77
|
});
|
84
|
-
Object.defineProperty(exports, "
|
78
|
+
Object.defineProperty(exports, "ServiceWorkerPlugin", {
|
85
79
|
enumerable: true,
|
86
80
|
get: function () {
|
87
|
-
return
|
81
|
+
return _ServiceWorkerPlugin.default;
|
88
82
|
}
|
89
83
|
});
|
90
84
|
Object.defineProperty(exports, "ShadowDOMSupportPlugin", {
|
@@ -93,10 +87,10 @@ Object.defineProperty(exports, "ShadowDOMSupportPlugin", {
|
|
93
87
|
return _ShadowDOMSupportPlugin.default;
|
94
88
|
}
|
95
89
|
});
|
96
|
-
Object.defineProperty(exports, "
|
90
|
+
Object.defineProperty(exports, "SourceMapHookPlugin", {
|
97
91
|
enumerable: true,
|
98
92
|
get: function () {
|
99
|
-
return
|
93
|
+
return _SourceMapHookPlugin.default;
|
100
94
|
}
|
101
95
|
});
|
102
96
|
Object.defineProperty(exports, "TPHashMappingPlugin", {
|
@@ -105,10 +99,16 @@ Object.defineProperty(exports, "TPHashMappingPlugin", {
|
|
105
99
|
return _TPHashMappingPlugin.default;
|
106
100
|
}
|
107
101
|
});
|
108
|
-
Object.defineProperty(exports, "
|
102
|
+
Object.defineProperty(exports, "UglifyCSSPlugin", {
|
109
103
|
enumerable: true,
|
110
104
|
get: function () {
|
111
|
-
return
|
105
|
+
return _UglifyCSSPlugin.default;
|
106
|
+
}
|
107
|
+
});
|
108
|
+
Object.defineProperty(exports, "UnusedFilesFindPlugin", {
|
109
|
+
enumerable: true,
|
110
|
+
get: function () {
|
111
|
+
return _UnusedFilesFindPlugin.default;
|
112
112
|
}
|
113
113
|
});
|
114
114
|
|
@@ -11,19 +11,26 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
11
11
|
|
12
12
|
var _webpackSources = require("webpack-sources");
|
13
13
|
|
14
|
+
var _jsonHelper = require("../utils/jsonHelper");
|
15
|
+
|
14
16
|
var _utils = require("../utils");
|
15
17
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
19
|
|
20
|
+
let resultFileName = `${process.cwd()}/result.json`;
|
18
21
|
let options = (0, _utils.getOptions)();
|
19
22
|
let {
|
20
23
|
ssTest: {
|
21
24
|
referBranch,
|
22
25
|
currentBranch,
|
23
26
|
serviceName,
|
24
|
-
tokenGit
|
27
|
+
tokenGit,
|
28
|
+
changesOnly
|
25
29
|
}
|
26
30
|
} = options;
|
31
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.compareBranch', referBranch);
|
32
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.TestBranch', currentBranch);
|
33
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.isExecuted', true);
|
27
34
|
|
28
35
|
let isValidModule = name => {
|
29
36
|
if (name.includes('node_modules') && (name.includes(`@zohodesk${_path.default.sep}components`) || name.includes(`@zohodesk${_path.default.sep}dot`) || name.includes(`@zohodesk${_path.default.sep}icons`) || name.includes(`@zohodesk${_path.default.sep}svg`)) && !name.endsWith('docs.js')) {
|
@@ -57,6 +64,8 @@ class LibraryImpactPlugin {
|
|
57
64
|
apply(compiler) {
|
58
65
|
let loggedInfo = false;
|
59
66
|
compiler.hooks.beforeCompile.tap('LibraryImpactPlugin', () => {
|
67
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.startTime', Date.now());
|
68
|
+
|
60
69
|
if (!loggedInfo) {
|
61
70
|
(0, _utils.log)('\x1b[33m%s\x1b[0m', '************************************************************ \n ');
|
62
71
|
(0, _utils.log)('\x1b[5m\x1b[44m%s\x1b[0m', 'Finding Impacted Source Files Please Wait ...');
|
@@ -141,7 +150,8 @@ class LibraryImpactPlugin {
|
|
141
150
|
}
|
142
151
|
|
143
152
|
(0, _utils.getDependenciesImpactList)(currentBranch, referBranch, tokenGit, serviceName).then(impactedList => {
|
144
|
-
this.resultJson = (0, _utils.getLibraryConflict)(JSON.stringify(results), impactedList);
|
153
|
+
this.resultJson = (0, _utils.getLibraryConflict)(JSON.stringify(results), impactedList, changesOnly);
|
154
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.result', this.resultJson);
|
145
155
|
|
146
156
|
if (this.resultJson.result.status) {
|
147
157
|
(0, _utils.log)(this.resultJson.response);
|
@@ -165,6 +175,8 @@ class LibraryImpactPlugin {
|
|
165
175
|
} else {
|
166
176
|
_fs.default.writeFileSync('./coverageTest/impactLibrary.html', this.topHtml + this.bottomHtml, 'utf8');
|
167
177
|
}
|
178
|
+
|
179
|
+
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.endTime', Date.now());
|
168
180
|
});
|
169
181
|
});
|
170
182
|
compiler.hooks.done.tap('LibraryImpactPlugin', () => {
|
@@ -4,7 +4,7 @@ var _postcss = _interopRequireDefault(require("postcss"));
|
|
4
4
|
|
5
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6
6
|
|
7
|
-
module.exports = _postcss.default.plugin('postcss-exclude-
|
7
|
+
module.exports = _postcss.default.plugin('postcss-exclude-files', opts => {
|
8
8
|
const {
|
9
9
|
plugins
|
10
10
|
} = opts;
|
@@ -3,14 +3,14 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.separateSingleDir = separateSingleDir;
|
7
6
|
exports.separateRtlAndLtr = separateRtlAndLtr;
|
7
|
+
exports.separateSingleDir = separateSingleDir;
|
8
8
|
|
9
9
|
var postcss = _interopRequireWildcard(require("postcss"));
|
10
10
|
|
11
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
12
12
|
|
13
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
14
14
|
|
15
15
|
const oppositeDir = {
|
16
16
|
ltr: 'rtl',
|
@@ -38,11 +38,11 @@ function selectorMinifySameDir(selector, direction) {
|
|
38
38
|
const regex = getRegex(direction);
|
39
39
|
return selector.replace(regex, '').trim();
|
40
40
|
}
|
41
|
-
/**
|
42
|
-
* this funtion will remove given rule,
|
43
|
-
* if given selector and it's previous sibiling rule selector are same
|
44
|
-
* current rule properties will move to previous sibiling rule.
|
45
|
-
* @param {Rule} rule current rule
|
41
|
+
/**
|
42
|
+
* this funtion will remove given rule,
|
43
|
+
* if given selector and it's previous sibiling rule selector are same
|
44
|
+
* current rule properties will move to previous sibiling rule.
|
45
|
+
* @param {Rule} rule current rule
|
46
46
|
*/
|
47
47
|
|
48
48
|
|
@@ -57,11 +57,11 @@ function mergeIfSameSelector(rule) {
|
|
57
57
|
rule.remove();
|
58
58
|
}
|
59
59
|
}
|
60
|
-
/**
|
61
|
-
* this funtion will remove given rule,
|
62
|
-
* if given selector and it's previous sibiling rule selector are same
|
63
|
-
* current rule properties will move to previous sibiling rule.
|
64
|
-
* @param {Rule} rule current rule
|
60
|
+
/**
|
61
|
+
* this funtion will remove given rule,
|
62
|
+
* if given selector and it's previous sibiling rule selector are same
|
63
|
+
* current rule properties will move to previous sibiling rule.
|
64
|
+
* @param {Rule} rule current rule
|
65
65
|
*/
|
66
66
|
|
67
67
|
|
@@ -0,0 +1,46 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _postcss = _interopRequireDefault(require("postcss"));
|
4
|
+
|
5
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6
|
+
|
7
|
+
// module.exports = postcss.plugin('postcss-value-replacer', opts => {
|
8
|
+
// const { plugins } = opts;
|
9
|
+
// return (root, result) => {
|
10
|
+
// const inputFile = root.source.input.file;
|
11
|
+
// let isIgnoredFile= opts.ignore.some(file => inputFile.indexOf(file)!==-1);
|
12
|
+
// if (!isIgnoredFile) {
|
13
|
+
// const handler = response =>
|
14
|
+
// response.messages.forEach(msg => result.messages.push(msg));
|
15
|
+
// return postcss(plugins)
|
16
|
+
// .process(root, { from: undefined })
|
17
|
+
// .then(handler);
|
18
|
+
// }
|
19
|
+
// };
|
20
|
+
// });
|
21
|
+
// export default
|
22
|
+
module.exports = _postcss.default.plugin('postcss-value-replacer', (valueReplacer = {}) => // Work with options here
|
23
|
+
root => {
|
24
|
+
root.walkDecls(decl => {
|
25
|
+
valueReplacer.forEach(obj => {
|
26
|
+
if (obj.props.indexOf(decl.prop) !== -1) {
|
27
|
+
let ks = Object.keys(obj.values).sort((a, b) => b.length - a.length);
|
28
|
+
ks.forEach(k => {
|
29
|
+
decl.value = decl.value.replace(k, obj.values[k]);
|
30
|
+
}); //decl.value = obj.values[decl.value];
|
31
|
+
}
|
32
|
+
}); //console.log({root, roots:root+""}, root+"")
|
33
|
+
// Transform CSS AST here
|
34
|
+
}); // root.walkDecls(decl => {
|
35
|
+
// valueReplacer.forEach(obj => {
|
36
|
+
// if (
|
37
|
+
// obj.props.indexOf(decl.prop) !== -1 &&
|
38
|
+
// obj.values[decl.value] !== undefined
|
39
|
+
// ) {
|
40
|
+
// decl.value = obj.values[decl.value];
|
41
|
+
// }
|
42
|
+
// });
|
43
|
+
// //console.log({root, roots:root+""}, root+"")
|
44
|
+
// // Transform CSS AST here
|
45
|
+
// });
|
46
|
+
});
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const fs = require('fs');
|
4
|
+
|
5
|
+
const postcss = require('postcss');
|
6
|
+
|
7
|
+
function expectRunPostCss(inputFile, outputfile, cb) {
|
8
|
+
const inputStr = fs.readFileSync(inputFile, 'utf-8');
|
9
|
+
postcss(plugins).process(inputStr, {
|
10
|
+
from,
|
11
|
+
to
|
12
|
+
}).then(result => {
|
13
|
+
expect(result.css).toBe(fs.readFileSync(outputfile, 'utf-8'));
|
14
|
+
cb();
|
15
|
+
});
|
16
|
+
}
|
17
|
+
|
18
|
+
describe('To Check Hover active postcss Plugin ', () => {
|
19
|
+
test('should handle normal rule hover', cb => {
|
20
|
+
expectRunPostCss('test1Input.css', 'test1Output.css', cb);
|
21
|
+
});
|
22
|
+
});
|
@@ -0,0 +1,39 @@
|
|
1
|
+
/*Hover_active:ignore*/
|
2
|
+
g,a:hover{
|
3
|
+
color : red
|
4
|
+
}
|
5
|
+
/*Hover:ignore*/
|
6
|
+
h:hover{
|
7
|
+
background : yellow
|
8
|
+
}
|
9
|
+
|
10
|
+
/* Hover_active:ignore */
|
11
|
+
g,d+e:hover{
|
12
|
+
color : black
|
13
|
+
}
|
14
|
+
|
15
|
+
g,d e:hover{
|
16
|
+
color : black
|
17
|
+
}
|
18
|
+
|
19
|
+
@media screen and (max-width:61.25em){
|
20
|
+
/* Hover_active:ignore */
|
21
|
+
a,b,a:hover, b:hover{
|
22
|
+
background-color : blue
|
23
|
+
}
|
24
|
+
a + b,a:hover + b:hover{
|
25
|
+
background-color : blue
|
26
|
+
}
|
27
|
+
a b:hover{
|
28
|
+
background-color : blue
|
29
|
+
}
|
30
|
+
|
31
|
+
.cc:hover {
|
32
|
+
color: red;
|
33
|
+
}
|
34
|
+
|
35
|
+
c:hover{
|
36
|
+
color : red
|
37
|
+
}
|
38
|
+
|
39
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
/*Hover_active:ignore*/
|
2
|
+
g,a:hover{
|
3
|
+
color : red
|
4
|
+
}
|
5
|
+
/*Hover:ignore*/
|
6
|
+
h:hover{
|
7
|
+
background : yellow
|
8
|
+
}
|
9
|
+
|
10
|
+
/* Hover_active:ignore */
|
11
|
+
g,d+e:hover{
|
12
|
+
color : black
|
13
|
+
}
|
14
|
+
|
15
|
+
g,d e:hover{
|
16
|
+
color : black
|
17
|
+
}
|
18
|
+
|
19
|
+
@media screen and (max-width:61.25em){
|
20
|
+
/* Hover_active:ignore */
|
21
|
+
a,b,a:hover, b:hover{
|
22
|
+
background-color : blue
|
23
|
+
}
|
24
|
+
a + b,a:hover + b:hover{
|
25
|
+
background-color : blue
|
26
|
+
}
|
27
|
+
a b:hover{
|
28
|
+
background-color : blue
|
29
|
+
}
|
30
|
+
|
31
|
+
.cc:hover {
|
32
|
+
color: red;
|
33
|
+
}
|
34
|
+
|
35
|
+
c:hover{
|
36
|
+
color : red
|
37
|
+
}
|
38
|
+
|
39
|
+
}
|