@zohodesk/react-cli 1.1.14-exp.2 → 1.1.14-kubernetes

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.
Files changed (102) hide show
  1. package/README.md +16 -281
  2. package/bin/cli.js +55 -30
  3. package/docs/CustomChunks.md +9 -12
  4. package/docs/SelectorWeight.md +0 -3
  5. package/docs/ValueReplacer.md +0 -27
  6. package/docs/VariableConversion.md +1 -6
  7. package/lib/common/splitChunks.js +45 -65
  8. package/lib/common/testPattern.js +11 -9
  9. package/lib/common/valueReplacer.js +3 -1
  10. package/lib/configs/resolvers.js +5 -16
  11. package/lib/configs/webpack.css.umd.config.js +2 -3
  12. package/lib/configs/webpack.dev.config.js +5 -15
  13. package/lib/configs/webpack.docs.config.js +3 -14
  14. package/lib/configs/webpack.impact.config.js +2 -8
  15. package/lib/configs/webpack.prod.config.js +5 -15
  16. package/lib/constants.js +3 -3
  17. package/lib/loaderUtils/getCSSLoaders.js +49 -98
  18. package/lib/loaderUtils/windowsModification.js +1 -6
  19. package/lib/loaders/docsLoader.js +7 -18
  20. package/lib/loaders/selectorMappingLoader.js +9 -9
  21. package/lib/pluginUtils/getDevPlugins.js +6 -25
  22. package/lib/pluginUtils/getProdPlugins.js +5 -32
  23. package/lib/pluginUtils/getUMDCSSPlugins.js +1 -1
  24. package/lib/pluginUtils/getUMDComponentPlugins.js +1 -1
  25. package/lib/plugins/EFCPlugin.js +9 -9
  26. package/lib/plugins/EFCTemplatePlugin.js +12 -10
  27. package/lib/plugins/I18NInjectIntoIndexPlugin.js +9 -8
  28. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +3 -2
  29. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +13 -29
  30. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +7 -2
  31. package/lib/plugins/I18nSplitPlugin/index.js +1 -1
  32. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +8 -8
  33. package/lib/plugins/ReportGeneratePlugin.js +6 -8
  34. package/lib/plugins/ResourceHintsPlugin.js +3 -13
  35. package/lib/plugins/SelectorPlugin.js +37 -77
  36. package/lib/plugins/{MinifyPlugin.js → UglifyCSSPlugin.js} +3 -3
  37. package/lib/plugins/UnusedFilesFindPlugin.js +5 -7
  38. package/lib/plugins/VariableConversionCollector.js +101 -40
  39. package/lib/plugins/composeCommonPlugin.js +30 -0
  40. package/lib/plugins/index.js +7 -7
  41. package/lib/postcss-plugins/ExcludePlugin.js +1 -1
  42. package/lib/postcss-plugins/RTLSplitPlugin.js +10 -4
  43. package/lib/postcss-plugins/ValueReplacer.js +29 -8
  44. package/lib/postcss-plugins/hoverActivePlugin.js +6 -0
  45. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +1 -0
  46. package/lib/postcss-plugins/variableModificationPlugin/index.js +38 -94
  47. package/lib/postcss-plugins/variableModifier.js +244 -0
  48. package/lib/schemas/index.js +18 -94
  49. package/lib/servers/devBuild.js +11 -13
  50. package/lib/servers/getCliPath.js +5 -3
  51. package/lib/servers/httpsOptions.js +13 -12
  52. package/lib/servers/nowatchserver.js +55 -62
  53. package/lib/servers/server.js +52 -53
  54. package/lib/utils/cssClassNameGenerate.js +13 -70
  55. package/lib/utils/getOptions.js +28 -35
  56. package/lib/utils/getServerURL.js +9 -1
  57. package/lib/utils/index.js +12 -14
  58. package/lib/utils/initPreCommitHook.js +5 -5
  59. package/lib/utils/pullOrigin.js +3 -3
  60. package/lib/utils/reinstallDependencies.js +3 -3
  61. package/lib/utils/switchBranch.js +2 -4
  62. package/package.json +3 -5
  63. package/templates/docs/all.html +0 -1
  64. package/templates/docs/component.html +0 -1
  65. package/templates/docs/components.html +0 -1
  66. package/templates/docs/css/style.css +169 -136
  67. package/templates/docs/index.html +632 -796
  68. package/.vscode/settings.json +0 -25
  69. package/docs/ComposeMinification.md +0 -13
  70. package/docs/MarkdownParser.md +0 -18
  71. package/docs/ReactLive.md +0 -14
  72. package/docs/patternFiltering.md +0 -57
  73. package/lib/common/buildEs.js +0 -12
  74. package/lib/common/runPreProcess.js +0 -71
  75. package/lib/deprecationLogger.js +0 -40
  76. package/lib/loaderUtils/tests/windowsModification.test.js +0 -10
  77. package/lib/loaders/__test__/markdownLoader.spec.js +0 -145
  78. package/lib/loaders/composeLoader.js +0 -298
  79. package/lib/loaders/markdownLoader.js +0 -71
  80. package/lib/loaders/reactLiveConvertor.js +0 -105
  81. package/lib/logger.js +0 -27
  82. package/lib/plugins/CustomAttributePlugin.js +0 -82
  83. package/lib/plugins/CustomAttributePlugin.md +0 -35
  84. package/lib/plugins/EfcResourceCleanupPlugin.js +0 -43
  85. package/lib/plugins/StatsPlugin.js +0 -82
  86. package/lib/plugins/utils/classHandling.js +0 -35
  87. package/lib/plugins/utils/fileHandling.js +0 -92
  88. package/lib/plugins/utils/tests/fileHandling.test.js +0 -30
  89. package/lib/plugins/variableConvertorUtils.js +0 -133
  90. package/lib/postcss-plugins/EmptyPlugin.js +0 -8
  91. package/lib/postcss-plugins/IncludePlugin.js +0 -23
  92. package/lib/postcss-plugins/SelectorReplace.js +0 -80
  93. package/lib/postcss-plugins/__test__/selectorReplace.test.js +0 -28
  94. package/lib/postcss-plugins/__test__/valueReplacer.spec.js +0 -43
  95. package/lib/servers/requireLocalOrGlobal.js +0 -61
  96. package/lib/utils/deprecationSupport.js +0 -134
  97. package/lib/utils/log.js +0 -11
  98. package/lib/utils/object-manipulation.js +0 -88
  99. package/lib/utils/selectorReplacer.js +0 -47
  100. package/lib/utils/variableConverter.js +0 -104
  101. package/npm-shrinkwrap.json +0 -33485
  102. package/templates/docs/css/markdown.css +0 -202
@@ -1,82 +0,0 @@
1
- "use strict";
2
-
3
- const fs = require('fs');
4
-
5
- const path = require('path');
6
-
7
- const {
8
- Readable
9
- } = require('stream');
10
-
11
- const {
12
- removeKeysFromObject,
13
- convertObjectToStringGen
14
- } = require('../utils/object-manipulation');
15
-
16
- const pluginName = 'stats-plugin';
17
- const statsSchema = {
18
- all: true
19
- };
20
-
21
- class StatsPlugin {
22
- constructor({
23
- statsOptions,
24
- statsOutputExcludeKeys,
25
- statsFileName
26
- }) {
27
- this.excludeKeysInStat = statsOutputExcludeKeys || [];
28
- this.statsFileName = statsFileName || 'bundle-report-integrity.json';
29
- this.statsOptions = Object.assign({}, statsSchema, statsOptions || {});
30
- }
31
-
32
- apply(compiler) {
33
- compiler.hooks.done.tapAsync(pluginName, (stats, callback) => {
34
- const statsJson = removeKeysFromObject(stats.toJson(this.statsOptions), this.excludeKeysInStat);
35
- this.emitStats(statsJson).on('end', () => {
36
- callback();
37
- }).on('error', e => {
38
- callback(e);
39
- });
40
- });
41
- }
42
-
43
- writeStatsFileInAStream(statsObj) {
44
- const {
45
- outputPath
46
- } = statsObj;
47
- const ouputFileName = path.join(outputPath, this.statsFileName);
48
- return this.createReadStream(statsObj).pipe(fs.createWriteStream(ouputFileName));
49
- }
50
-
51
- createReadStream(statsObj) {
52
- const excludeKeys = this.excludeKeysInStat;
53
- return new Readable({
54
- read() {
55
- let isDone = false;
56
- const objToStringGen = convertObjectToStringGen(statsObj, excludeKeys);
57
-
58
- while (!isDone) {
59
- const {
60
- done,
61
- value
62
- } = objToStringGen.next();
63
-
64
- if (done) {
65
- isDone = true;
66
- this.push(null);
67
- } else {
68
- this.push(value);
69
- }
70
- }
71
- }
72
-
73
- });
74
- }
75
-
76
- emitStats(statsJson) {
77
- return this.writeStatsFileInAStream(statsJson);
78
- }
79
-
80
- }
81
-
82
- module.exports = StatsPlugin;
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.hasPrevNodeIgnore = hasPrevNodeIgnore;
7
- exports.isAtRule = isAtRule;
8
- exports.isComment = isComment;
9
- exports.isCommentContentSame = isCommentContentSame;
10
- exports.isInsideMediaQuery = isInsideMediaQuery;
11
- exports.isThisComment = isThisComment;
12
-
13
- function isComment(node) {
14
- return node && node.type && node.type === 'comment';
15
- }
16
-
17
- function isCommentContentSame(node, content) {
18
- return node.text.toLowerCase() === content;
19
- }
20
-
21
- function isThisComment(node, ignoreComment) {
22
- return isComment(node) && isCommentContentSame(node, ignoreComment);
23
- }
24
-
25
- function hasPrevNodeIgnore(index, prevNode, ignoreComment) {
26
- return index !== 0 && isThisComment(prevNode, ignoreComment);
27
- }
28
-
29
- function isAtRule(rule) {
30
- return rule.parent && rule.parent.type === 'atrule';
31
- }
32
-
33
- function isInsideMediaQuery(rule) {
34
- return isAtRule(rule) && rule.parent && rule.parent.name === 'media' ? true : false;
35
- }
@@ -1,92 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isFileNameMatchingPattern = isFileNameMatchingPattern;
7
- exports.isFileNameMatchingPluginPattern = isFileNameMatchingPluginPattern;
8
-
9
- var _ignore = _interopRequireDefault(require("ignore"));
10
-
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
-
13
- const path = require('path');
14
-
15
- const aliasNames = {
16
- valueReplacer: 'postcss-value-replacer',
17
- selectorReplace: 'postcss-selector-replace-new',
18
- hasRTL: 'postcss-rtl',
19
- combinerMediaQuery: 'postcss-combine-media-query',
20
- hoverActive: 'postcss-mobile-hover',
21
- cssVariableReplacement: 'postcss-variable-report',
22
- composeMinification: 'postcss-compose-plugin'
23
- };
24
- /*
25
-
26
- unique scenario
27
-
28
- */
29
- // export function filterFileCssUniqueness(filename, filterObj) {
30
- // let rootDir = 'supportapp';
31
- // let include = false;
32
- // const regex = `^(.+?)${rootDir}?\\\\`;
33
- // const newFilename = windowsModificationFile(filename).replace(
34
- // new RegExp(regex, 'gi'),
35
- // ''
36
- // );
37
- // Object.keys(filterObj).forEach(key => {
38
- // const ig = ignore().add(filterObj[key]);
39
- // if (ig.ignores(newFilename)) {
40
- // include = true;
41
- // }
42
- // });
43
- // return include;
44
- // }
45
-
46
- function isFileNameMatchingPattern({
47
- filename,
48
- filterObject,
49
- plugins,
50
- order
51
- }) {
52
- const pluginObj = {};
53
- plugins.forEach(p => {
54
- pluginObj[p.postcssPlugin] = p;
55
- });
56
- const finalPlugins = order.filter(key => {
57
- const pluginSpecificFilter = filterObject[key];
58
-
59
- if (!pluginSpecificFilter || pluginSpecificFilter.length === 0) {
60
- return true;
61
- } // eslint-disable-next-line no-use-before-define
62
-
63
-
64
- const isMatching = isFilePathMatchingPattern(filename, pluginSpecificFilter);
65
- return isMatching;
66
- }).map(key => {
67
- const p = pluginObj[aliasNames[key]];
68
- return p;
69
- }); // if unknown key given in plugins and pattern loop will run but post-css plugin won't be available and will be undefined in array
70
- // So we do filter as safety measure.
71
-
72
- return finalPlugins.filter(Boolean);
73
- }
74
-
75
- function isFilePathMatchingPattern(filePath, patterns) {
76
- if (patterns.length === 0) {
77
- return true;
78
- }
79
-
80
- const ig = (0, _ignore.default)({
81
- allowRelativePaths: true
82
- }).add(patterns);
83
- return ig.ignores(filePath);
84
- }
85
-
86
- function isFileNameMatchingPluginPattern({
87
- filename,
88
- filterArr
89
- }) {
90
- const newFilename = path.relative(path.parse(process.cwd()).base, filename);
91
- return isFilePathMatchingPattern(newFilename, filterArr);
92
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- const ignore = require('ignore');
4
-
5
- const ignoreArr1 = ['src', '!src\\components', 'src\\Accessibility'];
6
- const ignoreArr2 = ['src\\', '!node_modules\\'];
7
- const ignoreArr3 = ['*'];
8
-
9
- const {
10
- windowsModificationFile
11
- } = require('../../../../lib/loaderUtils/windowsModification');
12
-
13
- const files = ['D:\\MyWork\\React Build\\desk_client_app\\jsapps\\supportapp\\src\\components\\Accessibility\\Accessibility.module.css', 'D:\\MyWork\\React Build\\desk_client_app\\jsapps\\supportapp\\src\\components\\Avatar\\Avatar.module.css', 'D:/MyWork/React Build/desk_client_app/jsapps/supportapp/src/components/Accessibility/Accessibility.module.css', 'D:/MyWork/React Build/desk_client_app/jsapps/supportapp/src/components/Accessibility/AccessibilityNavigation.module.css', 'desk_client_app\\jsapps\\supportapp\\src\\components\\Test.module.css', 'desk_client_app\\jsapps\\supportapp\\src\\components\\Accessibility\\Accessibility.module.css', 'desk_client_app/jsapps/supportapp/src/components/Accessibility/Accessibility.module.css', 'src\\components\\Accessibility\\Accessibility.module.css', 'src/components/Accessibility/Accessibility.module.css', 'Accessibility.module.css', ''];
14
- const ignore1 = ignore().add(ignoreArr1);
15
- const ignore2 = ignore().add(ignoreArr2);
16
- const ignore3 = ignore().add(ignoreArr3);
17
- files.forEach(file => {
18
- // console.log(file);
19
- const rootDir = 'supportapp';
20
- const regex = `^(.+?)${rootDir}?\\\\`;
21
- const newFilename = windowsModificationFile(file).replace(new RegExp(regex, 'gi'), '');
22
- console.log(newFilename);
23
-
24
- if (newFilename.trim() !== '') {
25
- console.log(ignore1.ignores(newFilename));
26
- console.log(ignore2.ignores(newFilename));
27
- console.log(ignore3.ignores(newFilename));
28
- console.log('--------------------------------------------------------------------');
29
- }
30
- });
@@ -1,133 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.extractVariableName = extractVariableName;
7
- exports.ignoreVals = void 0;
8
- exports.variableConverter = variableConverter;
9
-
10
- var _classHandling = require("./utils/classHandling");
11
-
12
- const ignoreVals = ['--zd_size', '--zd_font_size', '--size', '--size_']; // const avoidProps = [];
13
- // -- is issue IO --
14
-
15
- /*
16
- issues eg :
17
- issues = ['--zd_size', '--zd_font_size', '--size', '--size_'];
18
- input :
19
- --zd_size
20
- output :
21
- true
22
- comment :
23
- do not execute when --zd_size comes as prop
24
- */
25
-
26
- exports.ignoreVals = ignoreVals;
27
-
28
- function extractVariableName(val) {
29
- return val.replace(/calc\((.+)\)/gi, '$1').replace(/var\((.+)\)/gi, '$1').replace('-1', '').replace('*', '').replace('\n', '').trim();
30
- }
31
-
32
- function isIgnoreValuePresent(ignoreVals, prop) {
33
- return ignoreVals.some(ignoreVal => prop && prop.includes(ignoreVal)); // let present = false;
34
- // return ignoreVals.forEach(issue => {
35
- // if (prop && prop.includes(issue)) {
36
- // present = true;
37
- // }
38
- // });
39
- // return present;
40
- }
41
-
42
- function parseCalcValue(calcValue) {
43
- // Remove "calc(" and ")" from the string
44
- const value = calcValue.replace(/calc\(/gi, '').replace(/\)/gi, '').trim(); // Split the string by "*" or "/"
45
-
46
- const parts = value.split(/[\\/*]/); // Parse the first part as a number
47
-
48
- const num1 = parts[0].trim(); // Parse the second part as a number
49
-
50
- const num2 = parts[1].trim();
51
- return {
52
- valOne: num1,
53
- valTwo: num2
54
- };
55
- }
56
-
57
- function convertToCalc(pxReplacement, value) {
58
- const parsedValue = parseFloat(value, 10);
59
- const sign = parsedValue < 0 ? '-' : '';
60
- const varName = `${parsedValue < 0 ? parsedValue * -1 : parsedValue}`;
61
- return `calc( ${pxReplacement.replace('$$', varName)} * ${sign}1 )`;
62
- }
63
-
64
- function convertCalcValue(pxReplacement, parsedValue) {
65
- Object.keys(parsedValue).forEach(key => {
66
- if (pxReplacement && parsedValue[key].includes('px')) {
67
- parsedValue[key] = pxReplacement.replace('$$', parsedValue[key].replace('px', ''));
68
- }
69
- });
70
- return parsedValue;
71
- }
72
-
73
- function variableConverter(rootOriginal, variables, settingsObject) {
74
- rootOriginal.walkRules(rule => {
75
- rule.nodes.forEach((decl, index) => {
76
- const prevNode = rule.nodes[index - 1];
77
- const currentNode = rule.nodes[index];
78
-
79
- if (decl.prop && decl.prop.includes('--')) {
80
- if ((0, _classHandling.isThisComment)(prevNode, 'variable:ignore') // prevNode &&
81
- // prevNode.type === 'comment' &&
82
- // prevNode.text.toLowerCase() === 'variable:ignore'
83
- ) {
84
- return;
85
- }
86
-
87
- if (isIgnoreValuePresent(ignoreVals, decl.prop)) {
88
- return;
89
- }
90
-
91
- if (settingsObject[variables[decl.prop]]) {
92
- /* if there is no value for property, set it to default so that undefined doesn't get called as key */
93
- if (!variables[decl.prop]) {
94
- variables[decl.prop] = 'default';
95
- }
96
-
97
- const pxReplacement = settingsObject[variables[decl.prop]].replacements.px;
98
- let valArr = decl.value.split(' ');
99
- valArr = valArr.filter(x => x.trim() !== '');
100
- valArr = valArr.map(x => x.replace(/\r|\t|\n/gi, '')); // single values are considered in the above array and converted below
101
-
102
- valArr.forEach((value, index) => {
103
- if (value.includes('px')) {
104
- if (value.includes('calc')) {
105
- const res = convertCalcValue(pxReplacement, parseCalcValue(value));
106
- valArr[index] = `calc( ${res.valOne.trim()} * ${res.valTwo.trim()} )`;
107
- return;
108
- }
109
-
110
- if (/-(\d+)/gi.test(value)) {
111
- valArr[index] = convertToCalc(pxReplacement, value);
112
- return;
113
- }
114
-
115
- const num = value.replace('px', '');
116
-
117
- if (value) {
118
- valArr[index] = pxReplacement.replace('$$', num);
119
- }
120
- }
121
-
122
- if (value.includes('px')) {
123
- const num = value.replace('px', '');
124
- valArr[index] = pxReplacement.replace('$$', num);
125
- }
126
- });
127
- currentNode.value = valArr.join(' ');
128
- }
129
- }
130
- });
131
- });
132
- return rootOriginal;
133
- }
@@ -1,8 +0,0 @@
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.default.plugin('postcss-empty', () => (root, result) => {// console.log(root.source.input.from, result);
8
- });
@@ -1,23 +0,0 @@
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.default.plugin('postcss-include-files', opts => {
8
- const {
9
- plugins
10
- } = opts;
11
- return (root, result) => {
12
- const inputFile = root.source.input.file;
13
- const includeFile = opts.include.some(file => inputFile.indexOf(file) !== -1);
14
-
15
- if (includeFile) {
16
- const handler = response => response.messages.forEach(msg => result.messages.push(msg));
17
-
18
- return (0, _postcss.default)(plugins).process(root, {
19
- from: undefined
20
- }).then(handler);
21
- }
22
- };
23
- });
@@ -1,80 +0,0 @@
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
- });
@@ -1,28 +0,0 @@
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
@@ -1,43 +0,0 @@
1
- "use strict";
2
-
3
- var _postcss = _interopRequireDefault(require("postcss"));
4
-
5
- var _ValueReplacer = _interopRequireDefault(require("../ValueReplacer"));
6
-
7
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
-
9
- /* eslint-disable no-use-before-define */
10
- describe('postcss value replacer tests', () => {
11
- it('is creating value replaced code', () => {
12
- const cssInputStr = `.abc{ cursor : text }`;
13
- const cssOutputStr = `.abc{ cursor : --textCursor }`;
14
- const cssOptions = [{
15
- props: ['font', 'font-family', 'cursor'],
16
- values: {
17
- 'zdf-': 'zd-react-app-',
18
- '^text$': '--textCursor'
19
- }
20
- }];
21
- const result = runValueReplacerForCssString(cssInputStr, cssOptions);
22
- expect(result.css).toEqual(cssOutputStr);
23
- });
24
- });
25
- describe('postcss value replacer tests', () => {
26
- it('is creating value replaced code', () => {
27
- const cssInputStr = `.def{ cursor : var(--textBoxCursor) }`;
28
- const cssOutputStr = `.def{ cursor : var(--textBoxCursor) }`;
29
- const cssOptions = [{
30
- props: ['font', 'font-family', 'cursor'],
31
- values: {
32
- 'zdf-': 'zd-react-app-',
33
- '^text$': '--textCursor'
34
- }
35
- }];
36
- const result = runValueReplacerForCssString(cssInputStr, cssOptions);
37
- expect(result.css).toEqual(cssOutputStr);
38
- });
39
- });
40
-
41
- function runValueReplacerForCssString(cssInputStr, cssOptions) {
42
- return (0, _postcss.default)([(0, _ValueReplacer.default)(cssOptions)]).process(cssInputStr);
43
- }
@@ -1,61 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.globalNodeModules = void 0;
7
- exports.requireGlobal = requireGlobal;
8
- exports.requireLocal = requireLocal;
9
- exports.requireLocalOrGlobal = requireLocalOrGlobal;
10
-
11
- var _child_process = require("child_process");
12
-
13
- var _path = _interopRequireDefault(require("path"));
14
-
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
-
17
- const globalNodeModules = _path.default.join(`${(0, _child_process.execSync)('npm config get prefix')}`.trim(), 'lib');
18
-
19
- exports.globalNodeModules = globalNodeModules;
20
-
21
- function requireLocalOrGlobal(moduleName, opts = {}) {
22
- let {
23
- global = true
24
- } = opts;
25
- const {
26
- local = true
27
- } = opts;
28
- const isRelativePath = moduleName[0] === '.'; // NOTE: if starts with . then it only mean local
29
-
30
- if (isRelativePath) {
31
- global = false;
32
- }
33
-
34
- try {
35
- const paths = [local && process.cwd(), global && globalNodeModules].filter(Boolean); // x({ paths, globalNodeModules, global, local, opts });
36
-
37
- const moduleResolvePath = require.resolve(moduleName, {
38
- paths
39
- });
40
-
41
- return require(moduleResolvePath);
42
- } catch (error) {
43
- // NOTE: since we return null we can check out side
44
- // console.log('Re validate: ', error);
45
- return null;
46
- }
47
- }
48
-
49
- function requireLocal(moduleName) {
50
- return requireLocalOrGlobal(moduleName, {
51
- global: false,
52
- local: true
53
- });
54
- }
55
-
56
- function requireGlobal(moduleName) {
57
- return requireLocalOrGlobal(moduleName, {
58
- global: true,
59
- local: false
60
- });
61
- }