@zohodesk/react-cli 1.0.3-exp.5 → 1.1.0
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 +7 -7
- package/.eslintrc.js +180 -180
- package/.prettierrc +6 -6
- package/Changelog.md +1019 -1019
- package/README.md +1201 -1197
- package/bin/cli.js +489 -489
- package/docs/ComposeMinification.md +13 -13
- package/docs/CustomChunks.md +26 -26
- package/docs/DevServerPort.md +39 -39
- package/docs/DevStart.md +18 -18
- package/docs/HoverActive.md +12 -12
- package/docs/InstallNode.md +28 -28
- package/docs/ReactLive.md +10 -0
- package/docs/SelectorWeight.md +8 -8
- package/docs/TODOS.md +10 -10
- package/docs/ValueReplacer.md +60 -60
- package/docs/VariableConversion.md +729 -729
- package/docs/patternFiltering.md +57 -27
- package/docs/warnings_while_install.txt +35 -35
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- package/lib/configs/webpack.css.umd.config.js +4 -4
- package/lib/configs/webpack.dev.config.js +0 -3
- package/lib/configs/webpack.docs.config.js +4 -2
- package/lib/configs/webpack.impact.config.js +0 -2
- package/lib/configs/webpack.prod.config.js +0 -3
- package/lib/loaderUtils/configsAssetsLoaders.js +33 -33
- package/lib/loaderUtils/getCSSLoaders.js +51 -54
- package/lib/loaders/docsLoader.js +15 -7
- package/lib/loaders/reactLiveConvertor.js +107 -0
- package/lib/loaders/workerLoader.js +9 -9
- package/lib/pluginUtils/getDevPlugins.js +7 -10
- package/lib/pluginUtils/getProdPlugins.js +7 -10
- package/lib/plugins/CustomAttributePlugin.md +35 -35
- package/lib/plugins/EFCPlugin.md +6 -6
- 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 -95
- package/lib/plugins/I18nSplitPlugin/README.md +25 -25
- package/lib/plugins/I18nSplitPlugin/index.js +57 -57
- package/lib/plugins/ResourceHintsPlugin.js +17 -17
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +6 -6
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
- package/lib/plugins/SelectorPlugin.js +46 -47
- package/lib/plugins/ServiceWorkerPlugin.js +9 -9
- package/lib/plugins/TPHashMappingPlugin.js +4 -4
- package/lib/plugins/VariableConversionCollector.js +66 -184
- package/lib/plugins/utils/classHandling.js +16 -1
- package/lib/plugins/utils/fileHandling.js +10 -10
- package/lib/plugins/variableConvertorUtils.js +131 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +10 -10
- package/lib/postcss-plugins/__test__/test1Input.css +38 -38
- package/lib/postcss-plugins/__test__/test1Output.css +38 -38
- package/lib/postcss-plugins/hoverActivePlugin.js +3 -3
- package/lib/schemas/index.js +4 -2
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -45
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/cssClassNameGenerate.js +22 -24
- package/lib/utils/resultSchema.json +73 -73
- package/lib/utils/variableConverter.js +16 -129
- package/npm-shrinkwrap.json +14407 -14407
- package/npm8.md +9 -9
- package/package.json +122 -122
- package/postpublish.js +8 -8
- 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/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/impactReportTemplate.html +154 -154
- package/templates/docs/index.html +1501 -1501
- 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
|
@@ -41,33 +41,32 @@ const isSelectorPackage = (resourcePath, packages) => {
|
|
|
41
41
|
var _default = (unique = true, {
|
|
42
42
|
filenames,
|
|
43
43
|
packages
|
|
44
|
-
}, classNamePrefix, patterns
|
|
44
|
+
}, classNamePrefix, patterns) => (context, localIdentName, localName) => {
|
|
45
45
|
// console.log(patterns, context.resourcePath);
|
|
46
46
|
// NOTE: in build macine we use date as folder path.
|
|
47
47
|
// So every time we create new build there is path will alway different
|
|
48
48
|
// in order to minmaze that problem we try in relative path;
|
|
49
49
|
// console.log('context.resourcePath', context.resourcePath, context);
|
|
50
50
|
// let contextResourcePath = context.resourcePath;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
/*
|
|
58
|
-
input :
|
|
59
|
-
context.resourcePath : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// include src folder, include deskapp folder, exclude node modules
|
|
63
|
-
"cssUniqueness": [
|
|
64
|
-
"src",
|
|
65
|
-
"deskapp",
|
|
66
|
-
"!node_modules"
|
|
67
|
-
]
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
true or false
|
|
51
|
+
const filePaths = context.resourcePath.split(_path.default.sep);
|
|
52
|
+
const fileName = filePaths[filePaths.length - 1];
|
|
53
|
+
const [fileNameWithoutExt] = fileName.split('.');
|
|
54
|
+
const cleanFileName = fileNameWithoutExt.replace(/-/g, '_').toLowerCase();
|
|
55
|
+
|
|
56
|
+
const relativePath = _path.default.relative(context.rootContext, context.resourcePath);
|
|
57
|
+
/*
|
|
58
|
+
input :
|
|
59
|
+
context.resourcePath : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
|
|
60
|
+
|
|
61
|
+
patterns.cssVariableReplacement:
|
|
62
|
+
// include src folder, include deskapp folder, exclude node modules
|
|
63
|
+
"cssUniqueness": [
|
|
64
|
+
"src",
|
|
65
|
+
"deskapp",
|
|
66
|
+
"!node_modules"
|
|
67
|
+
]
|
|
68
|
+
output :
|
|
69
|
+
true or false
|
|
71
70
|
*/
|
|
72
71
|
|
|
73
72
|
|
|
@@ -77,8 +76,7 @@ var _default = (unique = true, {
|
|
|
77
76
|
|
|
78
77
|
if (!(0, _fileHandling.isFileNameMatchingPluginPattern)({
|
|
79
78
|
filename: context.resourcePath,
|
|
80
|
-
filterArr: patterns.cssUniqueness
|
|
81
|
-
rootDir
|
|
79
|
+
filterArr: patterns.cssUniqueness
|
|
82
80
|
})) {
|
|
83
81
|
return `${classNamePrefix}-${cleanFileName}-${localName}`;
|
|
84
82
|
}
|
|
@@ -86,7 +84,7 @@ var _default = (unique = true, {
|
|
|
86
84
|
|
|
87
85
|
|
|
88
86
|
if (unique) {
|
|
89
|
-
|
|
87
|
+
const h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
|
|
90
88
|
return `${classNamePrefix}${h}`;
|
|
91
89
|
} //css file has casesensitive selector issue so can't toLowerCase
|
|
92
90
|
//let local = localName.toLowerCase()
|
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
{
|
|
2
|
-
"jobDetails": {
|
|
3
|
-
"isTriggeredFromGit": true,
|
|
4
|
-
"isCIPassed": true,
|
|
5
|
-
"developerName": "GITLAB_USER_NAME",
|
|
6
|
-
"jobID": "CI_PIPELINE_ID",
|
|
7
|
-
"branchName": "CI_COMMIT_REF_NAME",
|
|
8
|
-
"commitMessage": "CI_COMMIT_MESSAGE",
|
|
9
|
-
"jobURL": "CI_JOB_URL",
|
|
10
|
-
"isByManual": "CI_JOB_MANUAL",
|
|
11
|
-
"commitID": "CI_COMMIT_SHA",
|
|
12
|
-
"executionTime": "Date.now()-Date.now()",
|
|
13
|
-
"hostName": "kathir-zt252"
|
|
14
|
-
},
|
|
15
|
-
"tests": {
|
|
16
|
-
"unitCase": {
|
|
17
|
-
"startTime": "123455",
|
|
18
|
-
"endTime": "123446",
|
|
19
|
-
"isExecuted": true,
|
|
20
|
-
"numberOfSuccess": "",
|
|
21
|
-
"numberOfFails": "",
|
|
22
|
-
"numberOfCases": "",
|
|
23
|
-
"numberOfSuites": "",
|
|
24
|
-
"fileDetail": {
|
|
25
|
-
"fileName": "sample.spec.js",
|
|
26
|
-
"caseDetail": {
|
|
27
|
-
"failedCaseLists": [],
|
|
28
|
-
"passedCaseList": []
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"coverageDetail": {
|
|
32
|
-
"codeCoveragePercentage": "",
|
|
33
|
-
"fileCoveragePercentage": ""
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"modifiedFileUnitCase": {
|
|
37
|
-
"hasChanges": "true",
|
|
38
|
-
"startTime": "123455",
|
|
39
|
-
"endTime": "123446",
|
|
40
|
-
"isExecuted": true,
|
|
41
|
-
"isPassed": true,
|
|
42
|
-
"numberOfSuccess": "",
|
|
43
|
-
"numberOfFails": "",
|
|
44
|
-
"numberOfCases": "",
|
|
45
|
-
"numberOfSuites": "",
|
|
46
|
-
"fileDetail": {
|
|
47
|
-
"fileName": "sample.spec.js",
|
|
48
|
-
"caseDetail": {
|
|
49
|
-
"failedCaseLists": [],
|
|
50
|
-
"passedCaseList": []
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
"coverageDetail": {
|
|
54
|
-
"codeCoveragePercentage": "",
|
|
55
|
-
"fileCoveragePercentage": ""
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
"screenshotTest": {
|
|
59
|
-
"message": "some",
|
|
60
|
-
"startTime": "123455",
|
|
61
|
-
"endTime": "123446",
|
|
62
|
-
"isThisExecuted": true,
|
|
63
|
-
"compareBranch": "master",
|
|
64
|
-
"isPassed": true,
|
|
65
|
-
"result": {
|
|
66
|
-
"numberOfComponents": 200,
|
|
67
|
-
"numberOfDiffFiles": 20,
|
|
68
|
-
"improperDocsList": [],
|
|
69
|
-
"erroredComponents": []
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"jobDetails": {
|
|
3
|
+
"isTriggeredFromGit": true,
|
|
4
|
+
"isCIPassed": true,
|
|
5
|
+
"developerName": "GITLAB_USER_NAME",
|
|
6
|
+
"jobID": "CI_PIPELINE_ID",
|
|
7
|
+
"branchName": "CI_COMMIT_REF_NAME",
|
|
8
|
+
"commitMessage": "CI_COMMIT_MESSAGE",
|
|
9
|
+
"jobURL": "CI_JOB_URL",
|
|
10
|
+
"isByManual": "CI_JOB_MANUAL",
|
|
11
|
+
"commitID": "CI_COMMIT_SHA",
|
|
12
|
+
"executionTime": "Date.now()-Date.now()",
|
|
13
|
+
"hostName": "kathir-zt252"
|
|
14
|
+
},
|
|
15
|
+
"tests": {
|
|
16
|
+
"unitCase": {
|
|
17
|
+
"startTime": "123455",
|
|
18
|
+
"endTime": "123446",
|
|
19
|
+
"isExecuted": true,
|
|
20
|
+
"numberOfSuccess": "",
|
|
21
|
+
"numberOfFails": "",
|
|
22
|
+
"numberOfCases": "",
|
|
23
|
+
"numberOfSuites": "",
|
|
24
|
+
"fileDetail": {
|
|
25
|
+
"fileName": "sample.spec.js",
|
|
26
|
+
"caseDetail": {
|
|
27
|
+
"failedCaseLists": [],
|
|
28
|
+
"passedCaseList": []
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"coverageDetail": {
|
|
32
|
+
"codeCoveragePercentage": "",
|
|
33
|
+
"fileCoveragePercentage": ""
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"modifiedFileUnitCase": {
|
|
37
|
+
"hasChanges": "true",
|
|
38
|
+
"startTime": "123455",
|
|
39
|
+
"endTime": "123446",
|
|
40
|
+
"isExecuted": true,
|
|
41
|
+
"isPassed": true,
|
|
42
|
+
"numberOfSuccess": "",
|
|
43
|
+
"numberOfFails": "",
|
|
44
|
+
"numberOfCases": "",
|
|
45
|
+
"numberOfSuites": "",
|
|
46
|
+
"fileDetail": {
|
|
47
|
+
"fileName": "sample.spec.js",
|
|
48
|
+
"caseDetail": {
|
|
49
|
+
"failedCaseLists": [],
|
|
50
|
+
"passedCaseList": []
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"coverageDetail": {
|
|
54
|
+
"codeCoveragePercentage": "",
|
|
55
|
+
"fileCoveragePercentage": ""
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"screenshotTest": {
|
|
59
|
+
"message": "some",
|
|
60
|
+
"startTime": "123455",
|
|
61
|
+
"endTime": "123446",
|
|
62
|
+
"isThisExecuted": true,
|
|
63
|
+
"compareBranch": "master",
|
|
64
|
+
"isPassed": true,
|
|
65
|
+
"result": {
|
|
66
|
+
"numberOfComponents": 200,
|
|
67
|
+
"numberOfDiffFiles": 20,
|
|
68
|
+
"improperDocsList": [],
|
|
69
|
+
"erroredComponents": []
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _windowsModification = require("../loaderUtils/windowsModification");
|
|
4
|
-
|
|
5
3
|
var _fileHandling = require("../plugins/utils/fileHandling");
|
|
6
4
|
|
|
7
5
|
var _getOptions = _interopRequireDefault(require("./getOptions"));
|
|
8
6
|
|
|
9
7
|
var _folderIterator = _interopRequireDefault(require("./folderIterator"));
|
|
10
8
|
|
|
9
|
+
var _variableConvertorUtils = require("../plugins/variableConvertorUtils");
|
|
10
|
+
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
|
|
13
13
|
const postcss = require('postcss');
|
|
@@ -18,149 +18,39 @@ const fs = require('fs');
|
|
|
18
18
|
|
|
19
19
|
const postcssVariableConvertor = require('../postcss-plugins/variableModificationPlugin/index').plugin;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const cwd = process.cwd();
|
|
22
|
+
const src = path.join(cwd, process.argv[2]);
|
|
23
|
+
const dist = path.join(cwd, process.argv[3]);
|
|
24
24
|
const options = (0, _getOptions.default)();
|
|
25
|
-
const ignoreVals = ['--zd_size', '--zd_font_size', '--size', '--size_'];
|
|
26
|
-
|
|
27
|
-
function extractVariableName(val) {
|
|
28
|
-
return val.replace(/calc\((.+)\)/gi, '$1').replace(/var\((.+)\)/gi, '$1').replace('-1', '').replace('*', '').replace('\n', '').trim();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function isIgnoreValuePresent(ignoreVals, prop) {
|
|
32
|
-
let present = false;
|
|
33
|
-
ignoreVals.forEach(issue => {
|
|
34
|
-
if (prop && prop.includes(issue)) {
|
|
35
|
-
present = true;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
return present;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function convertCalcValue(pxReplacement, parsedValue) {
|
|
42
|
-
Object.keys(parsedValue).forEach(key => {
|
|
43
|
-
if (parsedValue[key].includes('px')) {
|
|
44
|
-
parsedValue[key] = pxReplacement.replace('$$', parsedValue[key].replace('px', ''));
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
return parsedValue;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function parseCalcValue(calcValue) {
|
|
51
|
-
// Remove "calc(" and ")" from the string
|
|
52
|
-
const value = calcValue.replace(/calc\(/gi, '').replace(/\)/gi, '').trim(); // Split the string by "*" or "/"
|
|
53
|
-
|
|
54
|
-
const parts = value.split(/[\\/*]/); // Parse the first part as a number
|
|
55
|
-
|
|
56
|
-
const num1 = parts[0].trim(); // Parse the second part as a number
|
|
57
|
-
|
|
58
|
-
const num2 = parts[1].trim();
|
|
59
|
-
return {
|
|
60
|
-
valOne: num1,
|
|
61
|
-
valTwo: num2
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function convertToCalc(pxReplacement, value) {
|
|
66
|
-
const parsedValue = parseFloat(value, 10);
|
|
67
|
-
const sign = parsedValue < 0 ? '-' : '';
|
|
68
|
-
const varName = `${parsedValue < 0 ? parsedValue * -1 : parsedValue}`;
|
|
69
|
-
return `calc( ${pxReplacement.replace('$$', varName)} * ${sign}1 )`;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function variableConverter(rootOriginal, variables, settingsObject) {
|
|
73
|
-
rootOriginal.walkRules(rule => {
|
|
74
|
-
rule.nodes.forEach((decl, index) => {
|
|
75
|
-
const prevNode = rule.nodes[index - 1];
|
|
76
|
-
const currentNode = rule.nodes[index];
|
|
77
|
-
|
|
78
|
-
if (decl.prop && decl.prop.includes('--')) {
|
|
79
|
-
if (prevNode && prevNode.type === 'comment' && prevNode.text.toLowerCase() === 'variable:ignore') {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (isIgnoreValuePresent(ignoreVals, decl.prop)) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (settingsObject[variables[decl.prop]]) {
|
|
88
|
-
/* if there is no value for property, set it to default so that undefined doesn't get called as key */
|
|
89
|
-
if (!variables[decl.prop]) {
|
|
90
|
-
variables[decl.prop] = 'default';
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const pxReplacement = settingsObject[variables[decl.prop]].replacements.px;
|
|
94
|
-
const valArr = decl.value.split(' '); // single values are considered in the above array and converted below
|
|
95
|
-
|
|
96
|
-
valArr.forEach((value, index) => {
|
|
97
|
-
if (value.includes('px')) {
|
|
98
|
-
if (value.includes('calc')) {
|
|
99
|
-
const res = convertCalcValue(pxReplacement, parseCalcValue(value));
|
|
100
|
-
valArr[index] = `calc( ${res.valOne.trim()} * ${res.valTwo.trim()} )`;
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (/-(\d+)/gi.test(value)) {
|
|
105
|
-
valArr[index] = convertToCalc(pxReplacement, value);
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const num = value.replace('px', '');
|
|
110
|
-
|
|
111
|
-
if (value) {
|
|
112
|
-
valArr[index] = pxReplacement.replace('$$', num);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (value.includes('px')) {
|
|
117
|
-
const num = value.replace('px', '');
|
|
118
|
-
valArr[index] = pxReplacement.replace('$$', num);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
currentNode.value = valArr.join(' ');
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
return rootOriginal;
|
|
127
|
-
}
|
|
128
25
|
|
|
129
26
|
function watchHandler(fromPath, toPath) {
|
|
130
|
-
|
|
27
|
+
const css = fs.readFileSync(fromPath, 'utf-8'); // console.log(css);
|
|
131
28
|
|
|
132
29
|
const {
|
|
133
|
-
css: cssOptions
|
|
134
|
-
app: appOptions
|
|
30
|
+
css: cssOptions
|
|
135
31
|
} = options; // console.log(cssOptions, appOptions);
|
|
136
32
|
|
|
137
33
|
const {
|
|
138
34
|
cssVariableReplacementConfig: cssVariableConfigFilePath,
|
|
139
|
-
patterns:
|
|
35
|
+
patterns: filterArr
|
|
140
36
|
} = cssOptions;
|
|
141
|
-
const {
|
|
142
|
-
cssVariableReplacementConfig: appVariableConfigFilePath,
|
|
143
|
-
patterns: appPatterns
|
|
144
|
-
} = appOptions;
|
|
145
|
-
const cssVariableOptions = cssVariableConfigFilePath && cssVariableConfigFilePath !== '' ? cssVariableConfigFilePath : appVariableConfigFilePath;
|
|
146
|
-
const filterArr = cssOptions && cssPatterns && cssPatterns.cssVariableReplacement && cssPatterns.cssVariableReplacement !== {} ? cssPatterns.cssVariableReplacement : appPatterns.cssVariableReplacement;
|
|
147
37
|
const rootOriginal = postcss.parse(css);
|
|
148
38
|
const variables = {}; // const unassigned = {};
|
|
149
39
|
|
|
150
|
-
const rawdata = fs.readFileSync(
|
|
151
|
-
const
|
|
40
|
+
const rawdata = fs.readFileSync(cssVariableConfigFilePath).toString();
|
|
41
|
+
const cssVariableOptions = JSON.parse(rawdata);
|
|
152
42
|
const {
|
|
153
43
|
settings: settingsObject // errorLog: errorLogStatus,
|
|
154
44
|
// errorInConsole: errorConsoleStatus,
|
|
155
45
|
// errorsAllowed,
|
|
156
46
|
// strictMode
|
|
157
47
|
|
|
158
|
-
} =
|
|
48
|
+
} = cssVariableOptions;
|
|
159
49
|
rootOriginal.walkRules(rule => {
|
|
160
50
|
rule.walkDecls(decl => {
|
|
161
51
|
decl.value.split(' ').forEach(val => {
|
|
162
|
-
if (val && val.includes('--') && !new RegExp(ignoreVals.join('|'), 'gi').test(val) && decl.prop) {
|
|
163
|
-
const extractedValue = extractVariableName(val);
|
|
52
|
+
if (val && val.includes('--') && !new RegExp(_variableConvertorUtils.ignoreVals.join('|'), 'gi').test(val) && decl.prop) {
|
|
53
|
+
const extractedValue = (0, _variableConvertorUtils.extractVariableName)(val);
|
|
164
54
|
|
|
165
55
|
if (!variables[extractedValue]) {
|
|
166
56
|
variables[extractedValue] = decl.prop;
|
|
@@ -169,23 +59,20 @@ function watchHandler(fromPath, toPath) {
|
|
|
169
59
|
});
|
|
170
60
|
});
|
|
171
61
|
});
|
|
172
|
-
const strArray = (0, _windowsModification.windowsModificationFile)(process.cwd()).split('\\');
|
|
173
|
-
const lastElem = strArray[strArray.length - 1].toString();
|
|
174
62
|
|
|
175
63
|
if (!(0, _fileHandling.isFileNameMatchingPluginPattern)({
|
|
176
64
|
filename: fromPath,
|
|
177
|
-
filterArr
|
|
178
|
-
rootDir: lastElem
|
|
65
|
+
filterArr
|
|
179
66
|
})) {
|
|
180
67
|
return;
|
|
181
68
|
}
|
|
182
69
|
|
|
183
|
-
const convertedCode = variableConverter(rootOriginal, variables, settingsObject).toString(); // if (convertedCode.trim() !== '') {
|
|
70
|
+
const convertedCode = (0, _variableConvertorUtils.variableConverter)(rootOriginal, variables, settingsObject).toString(); // if (convertedCode.trim() !== '') {
|
|
184
71
|
// fs.writeFileSync(fromPath, convertedCode);
|
|
185
72
|
// }
|
|
186
73
|
// console.log(convertedCode);
|
|
187
74
|
|
|
188
|
-
postcss([postcssVariableConvertor(
|
|
75
|
+
postcss([postcssVariableConvertor(cssVariableConfigFilePath)]).process(convertedCode, {
|
|
189
76
|
from: undefined
|
|
190
77
|
}).then(result => {
|
|
191
78
|
fs.writeFileSync(toPath, result.css);
|