@zohodesk/react-cli 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
package/README.md
CHANGED
@@ -73,7 +73,7 @@ const getCSSLoaders = optionsObj => {
|
|
73
73
|
} // console.log('selector weight config : ', selectorWeightConfig);
|
74
74
|
|
75
75
|
|
76
|
-
const postcssPlugins = [valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer), selectorReplace && require('postcss-
|
76
|
+
const postcssPlugins = [valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer), selectorReplace && require('../postcss-plugins/SelectorReplace')(selectorReplace), ...excludeEmptyCheckPlugin({
|
77
77
|
enable: plugins.hasRTL,
|
78
78
|
ignore: rtlExcludeLocal,
|
79
79
|
plugins: [require('@zohodesk/postcss-rtl')({
|
@@ -0,0 +1,80 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _postcss = _interopRequireDefault(require("postcss"));
|
4
|
+
|
5
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6
|
+
|
7
|
+
function validator(opts) {
|
8
|
+
if (!opts || typeof opts !== 'object') {
|
9
|
+
throw new Error('Always requires argment');
|
10
|
+
}
|
11
|
+
|
12
|
+
const {
|
13
|
+
before,
|
14
|
+
after
|
15
|
+
} = opts;
|
16
|
+
|
17
|
+
if (!before || !after) {
|
18
|
+
throw new Error('Be sure to have "before" and "after" object names');
|
19
|
+
}
|
20
|
+
|
21
|
+
if (!Array.isArray(before) || !Array.isArray(after)) {
|
22
|
+
throw new Error('Objects "before" and "after" must be of type Array');
|
23
|
+
}
|
24
|
+
|
25
|
+
if (before.length !== after.length) {
|
26
|
+
throw new Error('Length of before and after options must be the same');
|
27
|
+
}
|
28
|
+
|
29
|
+
if (before.length === 0) {
|
30
|
+
throw new Error('Array length is 1 or more');
|
31
|
+
}
|
32
|
+
|
33
|
+
before.forEach((beforeOpt, idx) => {
|
34
|
+
const afterOpt = after[idx];
|
35
|
+
|
36
|
+
switch (true) {
|
37
|
+
case typeof beforeOpt === 'string':
|
38
|
+
{
|
39
|
+
if (!typeof afterOpt === 'string') {
|
40
|
+
throw new Error(`The after option ${afterOpt} must be a string. If you want to apply the replace callback function, then use a RegExp for the before option`);
|
41
|
+
}
|
42
|
+
|
43
|
+
break;
|
44
|
+
}
|
45
|
+
|
46
|
+
case beforeOpt instanceof RegExp:
|
47
|
+
{
|
48
|
+
if (!typeof afterOpt === 'string' && !typeof afterOpt === 'function') {
|
49
|
+
throw new Error(`The after option ${afterOpt} must be either a string, or a function`);
|
50
|
+
}
|
51
|
+
|
52
|
+
break;
|
53
|
+
}
|
54
|
+
|
55
|
+
default:
|
56
|
+
throw new Error(`The before option ${beforeOpt} must be either a string, or a RegExp`);
|
57
|
+
}
|
58
|
+
});
|
59
|
+
}
|
60
|
+
|
61
|
+
module.exports = _postcss.default.plugin('postcss-selector-replace-new', opts => {
|
62
|
+
validator(opts);
|
63
|
+
const {
|
64
|
+
before,
|
65
|
+
after
|
66
|
+
} = opts;
|
67
|
+
return root => {
|
68
|
+
root.walkRules(rule => {
|
69
|
+
before.forEach((beforeOpt, idx) => {
|
70
|
+
const afterOpt = after[idx];
|
71
|
+
|
72
|
+
if (typeof beforeOpt === 'string') {
|
73
|
+
rule.selector = rule.selector.split(beforeOpt).join(afterOpt);
|
74
|
+
} else {
|
75
|
+
rule.selector = rule.selector.replace(beforeOpt, afterOpt);
|
76
|
+
}
|
77
|
+
});
|
78
|
+
});
|
79
|
+
};
|
80
|
+
});
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
let settings1 = {
|
4
|
+
selectorReplace: {
|
5
|
+
before: [':root', 'data-mode', 'data-theme'],
|
6
|
+
after: [':global .zohodesk_controlpanel,:global .wms-mainui,:global .wms-hysearch, :global .mcf1ee8b17_overlay,:global .wms-hvalign, :global .KB_Editor_UploadImage,:global .zdeskEditor_popup, :global .ze_dd, :global .__baseZC_Container__', 'data-desk-mode', 'data-desk-theme']
|
7
|
+
}
|
8
|
+
};
|
9
|
+
let settings2 = {
|
10
|
+
selectorReplace: {
|
11
|
+
before: [':root', 'data-'],
|
12
|
+
after: [':global .zohodesk_controlpanel,:global .wms-mainui,:global .wms-hysearch, :global .mcf1ee8b17_overlay,:global .wms-hvalign, :global .KB_Editor_UploadImage,:global .zdeskEditor_popup, :global .ze_dd, :global .__baseZC_Container__', 'test-']
|
13
|
+
}
|
14
|
+
}; //error case
|
15
|
+
|
16
|
+
let settings3 = {
|
17
|
+
selectorReplace: {
|
18
|
+
before: [':root', 'data-'],
|
19
|
+
after: [':global .zohodesk_controlpanel,:global .wms-mainui,:global .wms-hysearch, :global .mcf1ee8b17_overlay,:global .wms-hvalign, :global .KB_Editor_UploadImage,:global .zdeskEditor_popup, :global .ze_dd, :global .__baseZC_Container__']
|
20
|
+
}
|
21
|
+
}; //error case
|
22
|
+
|
23
|
+
let settings4 = {
|
24
|
+
selectorReplace: {
|
25
|
+
before: [':root'],
|
26
|
+
after: [':global .zohodesk_controlpanel,:global .wms-mainui,:global .wms-hysearch, :global .mcf1ee8b17_overlay,:global .wms-hvalign, :global .KB_Editor_UploadImage,:global .zdeskEditor_popup, :global .ze_dd, :global .__baseZC_Container__', 'test-']
|
27
|
+
}
|
28
|
+
}; // here conversion happens for data from one index to another
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@zohodesk/react-cli",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.2",
|
4
4
|
"description": "A CLI tool for build modern web application and libraries",
|
5
5
|
"scripts": {
|
6
6
|
"init": "node ./lib/utils/init.js",
|
@@ -88,7 +88,6 @@
|
|
88
88
|
"postcss-hash-classname": "0.4.0",
|
89
89
|
"postcss-loader": "3.0.0",
|
90
90
|
"postcss-mobile-hover": "1.0.2",
|
91
|
-
"postcss-selector-replace": "1.0.2",
|
92
91
|
"react-test-renderer": "16.13.1",
|
93
92
|
"redis": "3.0.2",
|
94
93
|
"redux-mock-store": "1.5.4",
|
package/.vscode/settings.json
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"workbench.iconTheme": "vscode-icons",
|
3
|
-
"window.zoomLevel": 1,
|
4
|
-
"window.autoDetectColorScheme": true,
|
5
|
-
"gitlens.views.stashes.files.layout": "list",
|
6
|
-
"git.openRepositoryInParentFolders": "never",
|
7
|
-
"diffEditor.ignoreTrimWhitespace": false,
|
8
|
-
"workbench.colorTheme": "Default Light+",
|
9
|
-
"editor.indentSize": "tabSize",
|
10
|
-
"eslint.enable": true
|
11
|
-
}
|