@zohodesk/react-cli 1.0.2-exp.4 → 1.0.3-beta.1
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 +1189 -1165
- package/bin/cli.js +483 -483
- 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/SelectorWeight.md +8 -8
- package/docs/TODOS.md +10 -10
- package/docs/ValueReplacer.md +60 -60
- package/docs/VariableConversion.md +729 -729
- package/docs/warnings_while_install.txt +35 -35
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- package/lib/common/testPattern.js +0 -2
- package/lib/common/valueReplacer.js +1 -3
- package/lib/configs/resolvers.js +14 -3
- package/lib/configs/webpack.css.umd.config.js +4 -4
- package/lib/configs/webpack.dev.config.js +0 -6
- package/lib/configs/webpack.docs.config.js +0 -4
- package/lib/configs/webpack.impact.config.js +0 -4
- package/lib/configs/webpack.prod.config.js +0 -6
- package/lib/loaderUtils/configsAssetsLoaders.js +33 -33
- package/lib/loaderUtils/getCSSLoaders.js +47 -81
- package/lib/loaderUtils/windowsModification.js +1 -6
- package/lib/loaders/selectorMappingLoader.js +9 -9
- package/lib/loaders/workerLoader.js +9 -9
- package/lib/logger.js +20 -0
- package/lib/pluginUtils/getDevPlugins.js +13 -18
- package/lib/pluginUtils/getProdPlugins.js +12 -16
- package/lib/pluginUtils/getUMDCSSPlugins.js +1 -1
- package/lib/pluginUtils/getUMDComponentPlugins.js +1 -1
- package/lib/plugins/CustomAttributePlugin.js +82 -0
- package/lib/plugins/CustomAttributePlugin.md +35 -0
- package/lib/plugins/EFCPlugin.js +9 -9
- package/lib/plugins/EFCPlugin.md +6 -6
- package/lib/plugins/EFCTemplatePlugin.js +10 -12
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +12 -13
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +2 -3
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +10 -15
- 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/I18nSplitPlugin/utils/propertiesUtils.js +8 -8
- 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 +36 -53
- package/lib/plugins/ServiceWorkerPlugin.js +9 -9
- package/lib/plugins/TPHashMappingPlugin.js +4 -4
- package/lib/plugins/{MinifyPlugin.js → UglifyCSSPlugin.js} +3 -3
- package/lib/plugins/VariableConversionCollector.js +84 -98
- package/lib/plugins/composeCommonPlugin.js +30 -0
- package/lib/plugins/index.js +7 -7
- package/lib/postcss-plugins/ExcludePlugin.js +1 -1
- package/lib/postcss-plugins/IncludePlugin.js +0 -1
- package/lib/postcss-plugins/RTLSplitPlugin.js +14 -20
- package/lib/postcss-plugins/ValueReplacer.js +14 -5
- 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 -9
- package/lib/postcss-plugins/variableModificationPlugin/index.js +20 -3
- package/lib/postcss-plugins/variableModifier.js +24 -58
- package/lib/schemas/index.js +11 -35
- package/lib/servers/devBuild.js +13 -11
- package/lib/servers/httpsOptions.js +12 -13
- package/lib/servers/nowatchserver.js +5 -3
- package/lib/servers/requireLocalOrGlobal.js +61 -0
- package/lib/servers/server.js +3 -5
- 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 +14 -43
- package/lib/utils/resultSchema.json +73 -73
- package/npm-shrinkwrap.json +14407 -0
- package/npm8.md +9 -9
- package/package.json +121 -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
- package/lib/loaderUtils/tests/windowsModification.test.js +0 -10
- package/lib/loaders/composeLoader.js +0 -175
- package/lib/plugins/utils/classHandling.js +0 -20
- package/lib/plugins/utils/fileHandling.js +0 -107
- package/lib/plugins/utils/tests/fileHandling.test.js +0 -30
- package/lib/postcss-plugins/EmptyPlugin.js +0 -8
|
@@ -11,6 +11,8 @@ var _fs = require("fs");
|
|
|
11
11
|
|
|
12
12
|
var _path = require("path");
|
|
13
13
|
|
|
14
|
+
var _logger = require("../../../logger");
|
|
15
|
+
|
|
14
16
|
function isComment(line) {
|
|
15
17
|
return line[0] === '#';
|
|
16
18
|
}
|
|
@@ -18,7 +20,7 @@ function isComment(line) {
|
|
|
18
20
|
function getPropertiesAsJSON(filePath) {
|
|
19
21
|
try {
|
|
20
22
|
const data = (0, _fs.readFileSync)(filePath);
|
|
21
|
-
|
|
23
|
+
const source = data.toString();
|
|
22
24
|
const i18nObj = {};
|
|
23
25
|
source.split(/\r?\n\r?/).forEach(fline => {
|
|
24
26
|
const line = fline.trim();
|
|
@@ -42,7 +44,7 @@ function getPropertiesAsJSON(filePath) {
|
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
function getLang(file) {
|
|
45
|
-
|
|
47
|
+
const underScoreIndex = file.indexOf('_');
|
|
46
48
|
let language = 'en_US';
|
|
47
49
|
|
|
48
50
|
if (underScoreIndex !== -1) {
|
|
@@ -68,26 +70,24 @@ function getAllI18n({
|
|
|
68
70
|
const filePath = (0, _path.join)(context, file);
|
|
69
71
|
|
|
70
72
|
if (exclude.test(filePath) || !include.test(filePath)) {
|
|
71
|
-
// console.log('exclude', filePath);
|
|
72
73
|
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
74
|
+
}
|
|
75
75
|
|
|
76
76
|
const i18n = getPropertiesAsJSON(filePath);
|
|
77
77
|
allLangI18n[getLang(file)] = disableDefault ? i18n : Object.assign({}, jsResourceI18nKeys, i18n);
|
|
78
78
|
});
|
|
79
79
|
return allLangI18n;
|
|
80
80
|
} catch (err) {
|
|
81
|
-
|
|
81
|
+
(0, _logger.errorLogger)(err);
|
|
82
82
|
return {};
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
function jsonToString(json, keySeperator) {
|
|
87
87
|
let str = '{';
|
|
88
|
-
|
|
88
|
+
const keys = Object.keys(json);
|
|
89
89
|
keys.forEach((key, i) => {
|
|
90
|
-
|
|
90
|
+
const value = json[key];
|
|
91
91
|
|
|
92
92
|
if (!value) {
|
|
93
93
|
return;
|
|
@@ -33,25 +33,25 @@ class ResourceHintsPlugin {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
return Template.asString([source, '', `${mainTemplate.requireFn}.getChunkId = function getChunkId(chunkId) {`, Template.indent((needsMap ? [`chunkId = ${JSON.stringify(nameIdMap)}[chunkId]||chunkId;`] : []).concat(['return chunkId;'])), '}', `// Prefetch a chunk (${pluginName})`, `${mainTemplate.requireFn}.pfc = function prefetchChunk(chunkId) {`, Template.indent([`chunkId = ${mainTemplate.requireFn}.getChunkId(chunkId)`, `${mainTemplate.requireFn}.e(chunkId);`]), '};',
|
|
36
|
-
/*
|
|
37
|
-
(needsMap
|
|
38
|
-
? [`chunkId = ${JSON.stringify(nameIdMap)}[chunkId]||chunkId;`]
|
|
39
|
-
: []
|
|
40
|
-
).concat([
|
|
41
|
-
'var promises = [];',
|
|
42
|
-
'if(installedChunks[chunkId] === undefined) {',
|
|
43
|
-
Template.indent([
|
|
44
|
-
'installedChunks[chunkId] = null;',
|
|
45
|
-
/* mainTemplate.hooks.linkPrefetch.call('', chunk, hash),
|
|
36
|
+
/*
|
|
37
|
+
(needsMap
|
|
38
|
+
? [`chunkId = ${JSON.stringify(nameIdMap)}[chunkId]||chunkId;`]
|
|
39
|
+
: []
|
|
40
|
+
).concat([
|
|
41
|
+
'var promises = [];',
|
|
42
|
+
'if(installedChunks[chunkId] === undefined) {',
|
|
43
|
+
Template.indent([
|
|
44
|
+
'installedChunks[chunkId] = null;',
|
|
45
|
+
/* mainTemplate.hooks.linkPrefetch.call('', chunk, hash),
|
|
46
46
|
'document.head.appendChild(link);', */
|
|
47
47
|
|
|
48
|
-
/*
|
|
49
|
-
mainTemplate.hooks.requireEnsure.call('', chunk, hash)
|
|
50
|
-
]),
|
|
51
|
-
'}'
|
|
52
|
-
])
|
|
53
|
-
),
|
|
54
|
-
'}',
|
|
48
|
+
/*
|
|
49
|
+
mainTemplate.hooks.requireEnsure.call('', chunk, hash)
|
|
50
|
+
]),
|
|
51
|
+
'}'
|
|
52
|
+
])
|
|
53
|
+
),
|
|
54
|
+
'}',
|
|
55
55
|
*/
|
|
56
56
|
`// Preload a chunk (${pluginName})`, `${mainTemplate.requireFn}.plc = function preloadChunk(chunkId) {`, Template.indent([`chunkId = ${mainTemplate.requireFn}.getChunkId(chunkId)`, 'if(installedChunks[chunkId] === undefined) {', Template.indent(['installedChunks[chunkId] = null;', mainTemplate.hooks.linkPreload.call('', chunk, hash), 'document.head.appendChild(link);', `${mainTemplate.requireFn}.e(chunkId);` // 'var head = document.getElementsByTagName(\'head\')[0];',
|
|
57
57
|
// mainTemplate.hooks.jsonpScript.call('', chunk, hash),
|
|
@@ -24,12 +24,12 @@ const isCss = filename => _path.default.extname(filename) === '.css'; // this p
|
|
|
24
24
|
|
|
25
25
|
class RtlCssPlugin {
|
|
26
26
|
constructor(options = {}) {
|
|
27
|
-
/**
|
|
28
|
-
* @typedef {Object} Options
|
|
29
|
-
* @property {String} filename [not used]
|
|
30
|
-
* @property {String} dirVarName
|
|
31
|
-
* @property {Boolean} sourcemap
|
|
32
|
-
* @property {Object} config
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {Object} Options
|
|
29
|
+
* @property {String} filename [not used]
|
|
30
|
+
* @property {String} dirVarName
|
|
31
|
+
* @property {Boolean} sourcemap
|
|
32
|
+
* @property {Object} config
|
|
33
33
|
*/
|
|
34
34
|
this.options = {
|
|
35
35
|
filename: options.filename || '[name].rtl.css',
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
# RTL Split
|
|
2
|
-
|
|
3
|
-
we are doing in build time generating rtl related css code by using @zohodesk/postcss-rt npm.
|
|
4
|
-
It was automated, That postcss plugin create rtl reacted css and put them into same file, with css selector [dir=rtl] and ltr realted css with [dir=ltr].
|
|
5
|
-
Here is problem mostly no one need rtl and ltr related css at the same time in browser,
|
|
6
|
-
we are try to split them by [dir] and load which type of css is needed.
|
|
7
|
-
For this purpose we created RTL Split Plugin
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# To Try it out rtl-ltr split
|
|
11
|
-
### how to use this feature?
|
|
12
|
-
|
|
13
|
-
to use this feature use have give the below oprtions
|
|
14
|
-
`package.json`
|
|
15
|
-
```json
|
|
16
|
-
{
|
|
17
|
-
/// ...some things
|
|
18
|
-
"react-cli": {
|
|
19
|
-
// ...some things
|
|
20
|
-
"css": {
|
|
21
|
-
"enableRTLSplit": true,
|
|
22
|
-
"templateLabel": "{{--dir}}",// this is for html template css file path dir template
|
|
23
|
-
"disableMiniFiySelector": false,
|
|
24
|
-
"dirVarName": "document.dir" // this will be used for download css based on dir
|
|
25
|
-
},
|
|
26
|
-
// ...some things
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
```
|
|
30
|
-
|
|
1
|
+
# RTL Split
|
|
2
|
+
|
|
3
|
+
we are doing in build time generating rtl related css code by using @zohodesk/postcss-rt npm.
|
|
4
|
+
It was automated, That postcss plugin create rtl reacted css and put them into same file, with css selector [dir=rtl] and ltr realted css with [dir=ltr].
|
|
5
|
+
Here is problem mostly no one need rtl and ltr related css at the same time in browser,
|
|
6
|
+
we are try to split them by [dir] and load which type of css is needed.
|
|
7
|
+
For this purpose we created RTL Split Plugin
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# To Try it out rtl-ltr split
|
|
11
|
+
### how to use this feature?
|
|
12
|
+
|
|
13
|
+
to use this feature use have give the below oprtions
|
|
14
|
+
`package.json`
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
/// ...some things
|
|
18
|
+
"react-cli": {
|
|
19
|
+
// ...some things
|
|
20
|
+
"css": {
|
|
21
|
+
"enableRTLSplit": true,
|
|
22
|
+
"templateLabel": "{{--dir}}",// this is for html template css file path dir template
|
|
23
|
+
"disableMiniFiySelector": false,
|
|
24
|
+
"dirVarName": "document.dir" // this will be used for download css based on dir
|
|
25
|
+
},
|
|
26
|
+
// ...some things
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
@@ -9,24 +9,32 @@ var _postcss = _interopRequireDefault(require("postcss"));
|
|
|
9
9
|
|
|
10
10
|
var _fs = _interopRequireDefault(require("fs"));
|
|
11
11
|
|
|
12
|
-
var _classHandling = require("./utils/classHandling");
|
|
13
|
-
|
|
14
|
-
var _fileHandling = require("./utils/fileHandling");
|
|
15
|
-
|
|
16
12
|
var _windowsModification = require("../loaderUtils/windowsModification");
|
|
17
13
|
|
|
18
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
15
|
|
|
20
|
-
function
|
|
16
|
+
function checkFilename(filename, data) {
|
|
17
|
+
let keyMatch = undefined;
|
|
18
|
+
Object.keys(data).forEach(key => {
|
|
19
|
+
if (filename.includes(key)) {
|
|
20
|
+
keyMatch = key;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return keyMatch;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function rootConvertor(rootOriginal, defaultSelector, data, filename, excludeStrings) {
|
|
21
27
|
rootOriginal.walkRules((rule, index) => {
|
|
22
28
|
const prevNode = rootOriginal.nodes[index - 1];
|
|
23
29
|
|
|
24
|
-
if (
|
|
30
|
+
if (index !== 0 && prevNode.type && prevNode.type === 'comment' && prevNode.text.toLowerCase() === 'updateselector:ignore') {
|
|
25
31
|
return;
|
|
26
32
|
}
|
|
27
33
|
|
|
28
|
-
if (
|
|
29
|
-
|
|
34
|
+
if (rule.parent && rule.parent.type === 'atrule') {
|
|
35
|
+
if (rule.parent.name !== 'media') {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
const selectorArr = rule.selector.split(',');
|
|
@@ -40,24 +48,33 @@ function selectorWeightPrefixAdder(rootOriginal, selector, excludeStrings) {
|
|
|
40
48
|
return;
|
|
41
49
|
}
|
|
42
50
|
|
|
43
|
-
selectorArr[index] = `${singleSelectorStr.slice(0, singleSelectorStr.lastIndexOf(']') + 1).trim()} ${
|
|
51
|
+
selectorArr[index] = `${singleSelectorStr.slice(0, singleSelectorStr.lastIndexOf(']') + 1).trim()} ${defaultSelector}${singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 2).trim()}`;
|
|
44
52
|
return;
|
|
45
53
|
}
|
|
46
54
|
|
|
47
|
-
|
|
55
|
+
const keyMatch = checkFilename(filename, data);
|
|
56
|
+
selectorArr[index] = data[keyMatch] ? `${data[keyMatch].defaultSelector}${singleSelectorStr}` : `${defaultSelector}${singleSelectorStr}`;
|
|
48
57
|
});
|
|
49
58
|
rule.selector = selectorArr.join(',\n');
|
|
50
59
|
});
|
|
51
60
|
return rootOriginal;
|
|
52
61
|
}
|
|
53
62
|
|
|
63
|
+
function ignoreFile(excludeArr, filename) {
|
|
64
|
+
let ignore = false;
|
|
65
|
+
excludeArr.forEach(exclStr => {
|
|
66
|
+
if (filename.includes(exclStr)) {
|
|
67
|
+
ignore = true;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return ignore;
|
|
71
|
+
}
|
|
72
|
+
|
|
54
73
|
class SelectorPlugin {
|
|
55
74
|
constructor(options = {}) {
|
|
56
75
|
this.optimize = options.optimize;
|
|
57
76
|
this.selectorWeightConfig = options.selectorWeightConfig;
|
|
58
77
|
this.exclude = options.exclude;
|
|
59
|
-
this.patterns = options.patterns;
|
|
60
|
-
this.rootDir = options.patternsRootDir;
|
|
61
78
|
}
|
|
62
79
|
|
|
63
80
|
apply(compiler) {
|
|
@@ -77,49 +94,15 @@ class SelectorPlugin {
|
|
|
77
94
|
mods.forEach(module => {
|
|
78
95
|
const rootOriginal = _postcss.default.parse(module.content);
|
|
79
96
|
|
|
80
|
-
const filename = module.issuer.resource;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
filename : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
|
|
84
|
-
|
|
85
|
-
patterns.cssVariableReplacement:
|
|
86
|
-
// include src folder, include deskapp folder, exclude node modules
|
|
87
|
-
"selectorWeight": [
|
|
88
|
-
"src",
|
|
89
|
-
"deskapp",
|
|
90
|
-
"!node_modules"
|
|
91
|
-
]
|
|
92
|
-
rootDir : patternsRootDir : 'supportapp'
|
|
93
|
-
|
|
94
|
-
output :
|
|
95
|
-
true or false
|
|
96
|
-
*/
|
|
97
|
-
|
|
98
|
-
if (!(0, _fileHandling.isFileNameMatchingPluginPattern)({
|
|
99
|
-
filename,
|
|
100
|
-
filterArr: this.patterns.selectorWeight,
|
|
101
|
-
rootDir: this.rootDir
|
|
102
|
-
})) {
|
|
97
|
+
const filename = module.issuer.resource; // if (!filename.includes('node_modules')) {
|
|
98
|
+
|
|
99
|
+
if (ignoreFile(this.exclude, filename)) {
|
|
103
100
|
return;
|
|
104
101
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
filename
|
|
108
|
-
|
|
109
|
-
{
|
|
110
|
-
"DeskApp.module.css": {"defaultSelector" : ".desk_app_ui "}
|
|
111
|
-
}
|
|
112
|
-
selectorWeightConfig :
|
|
113
|
-
defaultSelector : .zoho_desk_ui
|
|
114
|
-
|
|
115
|
-
case filename = 'DeskApp.module.css' ?
|
|
116
|
-
data[filename].defaultSelector = '.desk_app_ui'
|
|
117
|
-
case filename is different ?
|
|
118
|
-
defaultSelector = '.zoho_desk_ui'
|
|
119
|
-
*/
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
module.content = selectorWeightPrefixAdder(rootOriginal, data[filename] ? data[filename].defaultSelector : defaultSelector, excludeStrings).toString();
|
|
102
|
+
|
|
103
|
+
module.content = //new RawSource(
|
|
104
|
+
rootConvertor(rootOriginal, defaultSelector, data, filename, excludeStrings).toString(); // );
|
|
105
|
+
// }
|
|
123
106
|
});
|
|
124
107
|
});
|
|
125
108
|
});
|
|
@@ -51,11 +51,11 @@ class ServiceWorkerPlugin {
|
|
|
51
51
|
if (err) {
|
|
52
52
|
throw new Error(err);
|
|
53
53
|
} else {
|
|
54
|
-
/* const extractedChunks = compilation.chunks.filter(chunk => {
|
|
55
|
-
if ('canBeInitial' in chunk) {
|
|
56
|
-
return chunk.canBeInitial();
|
|
57
|
-
}
|
|
58
|
-
return chunk.isInitial();
|
|
54
|
+
/* const extractedChunks = compilation.chunks.filter(chunk => {
|
|
55
|
+
if ('canBeInitial' in chunk) {
|
|
56
|
+
return chunk.canBeInitial();
|
|
57
|
+
}
|
|
58
|
+
return chunk.isInitial();
|
|
59
59
|
}); */
|
|
60
60
|
// let [js, css, , , i18nPublicPath] = this.publicPaths;
|
|
61
61
|
// let initialChunkUrls = [];
|
|
@@ -64,10 +64,10 @@ class ServiceWorkerPlugin {
|
|
|
64
64
|
let entrypoint = compilation.entrypoints.get('main');
|
|
65
65
|
let initialChunkUrls = entrypoint.getFiles();
|
|
66
66
|
const cssDirTemplate = '@dir@';
|
|
67
|
-
/**
|
|
68
|
-
* NOTE:
|
|
69
|
-
* if chunkSplitEnable is false means,
|
|
70
|
-
* serviceWorker will get i18n files path for html
|
|
67
|
+
/**
|
|
68
|
+
* NOTE:
|
|
69
|
+
* if chunkSplitEnable is false means,
|
|
70
|
+
* serviceWorker will get i18n files path for html
|
|
71
71
|
*/
|
|
72
72
|
|
|
73
73
|
let initalI18nAssets = chunkSplitEnable ? entrypoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@')) : [];
|
|
@@ -15,10 +15,10 @@ var _crypto = _interopRequireDefault(require("crypto"));
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Plugin that generates hash for the provided list of third party files
|
|
20
|
-
* Map the provided key with the file hash and add it to the list of exisiting global constants.
|
|
21
|
-
* Plugin in turn uses the defineplugin to generate global constants.
|
|
18
|
+
/**
|
|
19
|
+
* Plugin that generates hash for the provided list of third party files
|
|
20
|
+
* Map the provided key with the file hash and add it to the list of exisiting global constants.
|
|
21
|
+
* Plugin in turn uses the defineplugin to generate global constants.
|
|
22
22
|
*/
|
|
23
23
|
class TPHashMappingPlugin {
|
|
24
24
|
constructor(options) {
|
|
@@ -11,9 +11,9 @@ var _uglifycss = _interopRequireDefault(require("uglifycss"));
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
|
-
class
|
|
14
|
+
class UglifyCSSPlugin {
|
|
15
15
|
apply(compiler) {
|
|
16
|
-
compiler.hooks.emit.tap('
|
|
16
|
+
compiler.hooks.emit.tap('UglifyCSSPlugin', compilation => {
|
|
17
17
|
Object.keys(compilation.assets).forEach(filename => {
|
|
18
18
|
if (/\.css$/.test(filename)) {
|
|
19
19
|
try {
|
|
@@ -36,4 +36,4 @@ class MinifierPlugin {
|
|
|
36
36
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
exports.default =
|
|
39
|
+
exports.default = UglifyCSSPlugin;
|
|
@@ -9,8 +9,6 @@ var _postcss = _interopRequireDefault(require("postcss"));
|
|
|
9
9
|
|
|
10
10
|
var _ErrorHandler = require("../postcss-plugins/variableModificationPlugin/ErrorHandler");
|
|
11
11
|
|
|
12
|
-
var _fileHandling = require("./utils/fileHandling");
|
|
13
|
-
|
|
14
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
13
|
|
|
16
14
|
// import { RawSource } from 'webpack-sources';
|
|
@@ -28,15 +26,15 @@ const {
|
|
|
28
26
|
const supportedProps = ['font-size', 'margin', 'margin-top', 'margin-bottom', 'margin-left', 'margin-right', 'padding', 'padding-top', 'padding-bottom', 'padding-left', 'padding-right', '^top', '^right', '^bottom', '^left', '^width', 'min-width', 'max-width', '^height', 'min-height', 'max-height', 'text-indent', 'clip', 'flex-basis', 'row-gap', 'gap', 'column-gap', 'flex']; // const avoidProps = [];
|
|
29
27
|
// -- is issue IO --
|
|
30
28
|
|
|
31
|
-
/*
|
|
32
|
-
issues eg :
|
|
33
|
-
issues = ['--zd_size', '--zd_font_size', '--size', '--size_'];
|
|
34
|
-
input :
|
|
35
|
-
--zd_size
|
|
36
|
-
output :
|
|
37
|
-
true
|
|
38
|
-
comment :
|
|
39
|
-
do not execute when --zd_size comes as prop
|
|
29
|
+
/*
|
|
30
|
+
issues eg :
|
|
31
|
+
issues = ['--zd_size', '--zd_font_size', '--size', '--size_'];
|
|
32
|
+
input :
|
|
33
|
+
--zd_size
|
|
34
|
+
output :
|
|
35
|
+
true
|
|
36
|
+
comment :
|
|
37
|
+
do not execute when --zd_size comes as prop
|
|
40
38
|
*/
|
|
41
39
|
|
|
42
40
|
function isIgnoreValuePresent(ignoreVals, prop) {
|
|
@@ -49,14 +47,14 @@ function isIgnoreValuePresent(ignoreVals, prop) {
|
|
|
49
47
|
return present;
|
|
50
48
|
} // -- to convert the hyphen values to values --
|
|
51
49
|
|
|
52
|
-
/*
|
|
53
|
-
input :
|
|
54
|
-
var(--zdt_uploadlist_default_width)
|
|
55
|
-
output :
|
|
56
|
-
--zdt_uploadlist_default_width
|
|
57
|
-
|
|
58
|
-
comment :
|
|
59
|
-
to make the variable object using the output as key and decl.prop such as font-size as value
|
|
50
|
+
/*
|
|
51
|
+
input :
|
|
52
|
+
var(--zdt_uploadlist_default_width)
|
|
53
|
+
output :
|
|
54
|
+
--zdt_uploadlist_default_width
|
|
55
|
+
|
|
56
|
+
comment :
|
|
57
|
+
to make the variable object using the output as key and decl.prop such as font-size as value
|
|
60
58
|
*/
|
|
61
59
|
|
|
62
60
|
|
|
@@ -64,7 +62,7 @@ function extractVariableName(val) {
|
|
|
64
62
|
return val.replace(/calc\((.+)\)/gi, '$1').replace(/var\((.+)\)/gi, '$1').replace('-1', '').replace('*', '').replace('\n', '').trim();
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
function
|
|
65
|
+
function rootConvertor(rootOriginal, variables, settingsObject) {
|
|
68
66
|
rootOriginal.walkRules(rule => {
|
|
69
67
|
rule.nodes.forEach((decl, index) => {
|
|
70
68
|
const prevNode = rule.nodes[index - 1];
|
|
@@ -120,13 +118,10 @@ class VariableConversionCollector {
|
|
|
120
118
|
constructor(options = {}) {
|
|
121
119
|
this.optimize = options.optimize;
|
|
122
120
|
this.filename = options.cssVariableReplacementConfig;
|
|
123
|
-
this.
|
|
124
|
-
this.rootDir = options.patternsRootDir; // console.log(options.patterns, this.patterns);
|
|
125
|
-
|
|
126
|
-
this.initializeFiles();
|
|
121
|
+
this.fileHandler();
|
|
127
122
|
}
|
|
128
123
|
|
|
129
|
-
|
|
124
|
+
fileHandler() {
|
|
130
125
|
createFolderIfNonExistant('./.cli/logs/');
|
|
131
126
|
createFolderIfNonExistant('./.cli/config/variables/');
|
|
132
127
|
createFolderIfNonExistant('./.cli/config/selectorWeight/');
|
|
@@ -136,8 +131,7 @@ class VariableConversionCollector {
|
|
|
136
131
|
|
|
137
132
|
apply(compiler) {
|
|
138
133
|
const variables = {};
|
|
139
|
-
const unassigned = {};
|
|
140
|
-
|
|
134
|
+
const unassigned = {};
|
|
141
135
|
const rawdata = fs.readFileSync(this.filename);
|
|
142
136
|
const data = JSON.parse(rawdata);
|
|
143
137
|
const {
|
|
@@ -160,13 +154,13 @@ class VariableConversionCollector {
|
|
|
160
154
|
}
|
|
161
155
|
};
|
|
162
156
|
}
|
|
163
|
-
/*
|
|
164
|
-
purpose of tap : to create a variable object such as:
|
|
165
|
-
{
|
|
166
|
-
--zdt_uploadlist_default_width : width,
|
|
167
|
-
--zdt_uploadlist_default_height : height,
|
|
168
|
-
}
|
|
169
|
-
which will help in the conversion further
|
|
157
|
+
/*
|
|
158
|
+
purpose of tap : to create a variable object such as:
|
|
159
|
+
{
|
|
160
|
+
--zdt_uploadlist_default_width : width,
|
|
161
|
+
--zdt_uploadlist_default_height : height,
|
|
162
|
+
}
|
|
163
|
+
which will help in the conversion further
|
|
170
164
|
*/
|
|
171
165
|
|
|
172
166
|
|
|
@@ -196,9 +190,6 @@ class VariableConversionCollector {
|
|
|
196
190
|
variables[extractedValue] = decl.prop;
|
|
197
191
|
} else {
|
|
198
192
|
if (new RegExp(supportedProps.join('|'), 'gi').test(decl.prop)) {
|
|
199
|
-
// console.log(
|
|
200
|
-
// `${extractedValue} : ${variables[extractedValue]} already exists please check!`
|
|
201
|
-
// );
|
|
202
193
|
if (errorsAllowed.MULTIPLE_OCCURANCES) {
|
|
203
194
|
const errObj = {
|
|
204
195
|
decl,
|
|
@@ -212,7 +203,6 @@ class VariableConversionCollector {
|
|
|
212
203
|
}
|
|
213
204
|
}
|
|
214
205
|
} else {
|
|
215
|
-
// console.log(decl.prop);
|
|
216
206
|
if (/^--/gi.test(decl.prop) && val.trim() !== '' && !variables[decl.prop]) {
|
|
217
207
|
if (!Object.keys(variablesRead.ignore).includes(decl.prop)) {
|
|
218
208
|
unassigned[decl.prop] = variables[decl.prop];
|
|
@@ -222,19 +212,19 @@ class VariableConversionCollector {
|
|
|
222
212
|
});
|
|
223
213
|
});
|
|
224
214
|
});
|
|
225
|
-
/*
|
|
226
|
-
current value example:
|
|
227
|
-
{
|
|
228
|
-
--zdt_uploadlist_default_width : --zd_upload_width,
|
|
229
|
-
--zd_upload_width : width
|
|
230
|
-
}
|
|
231
|
-
expected value :
|
|
232
|
-
{
|
|
233
|
-
--zdt_uploadlist_default_width : width,
|
|
234
|
-
--zd_upload_width : width
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
conversion is done in the while loop below
|
|
215
|
+
/*
|
|
216
|
+
current value example:
|
|
217
|
+
{
|
|
218
|
+
--zdt_uploadlist_default_width : --zd_upload_width,
|
|
219
|
+
--zd_upload_width : width
|
|
220
|
+
}
|
|
221
|
+
expected value :
|
|
222
|
+
{
|
|
223
|
+
--zdt_uploadlist_default_width : width,
|
|
224
|
+
--zd_upload_width : width
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
conversion is done in the while loop below
|
|
238
228
|
*/
|
|
239
229
|
|
|
240
230
|
Object.keys(variables).forEach(key => {
|
|
@@ -244,62 +234,36 @@ class VariableConversionCollector {
|
|
|
244
234
|
});
|
|
245
235
|
}
|
|
246
236
|
});
|
|
247
|
-
}); // -- conversion for the root using
|
|
248
|
-
|
|
249
|
-
/*
|
|
250
|
-
input :
|
|
251
|
-
.a{
|
|
252
|
-
padding : 20px
|
|
253
|
-
}
|
|
254
|
-
output :
|
|
255
|
-
// on settingObject file :
|
|
256
|
-
{ padding : { replacements : { px : 'zd_size$$' }}}
|
|
257
|
-
.a{
|
|
258
|
-
padding : zd_size20;
|
|
259
|
-
}
|
|
237
|
+
}); // -- conversion for the root using rootConvertor --
|
|
238
|
+
|
|
239
|
+
/*
|
|
240
|
+
input :
|
|
241
|
+
.a{
|
|
242
|
+
padding : 20px
|
|
243
|
+
}
|
|
244
|
+
output :
|
|
245
|
+
// on settingObject file :
|
|
246
|
+
{ padding : { replacements : { px : 'zd_size$$' }}}
|
|
247
|
+
.a{
|
|
248
|
+
padding : zd_size20;
|
|
249
|
+
}
|
|
260
250
|
*/
|
|
261
251
|
|
|
262
252
|
compilation.hooks.optimizeModules.tap('VariableConversionCollector', modules => {
|
|
263
253
|
const mods = modules.filter(x => x.type.includes('css'));
|
|
264
254
|
mods.forEach(module => {
|
|
265
|
-
const filename = module.issuer.resource;
|
|
266
|
-
/*
|
|
267
|
-
input :
|
|
268
|
-
filename : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
|
|
269
|
-
|
|
270
|
-
patterns.cssVariableReplacement:
|
|
271
|
-
// include src folder, include deskapp folder, exclude node modules
|
|
272
|
-
"cssVariableReplacement": [
|
|
273
|
-
"src",
|
|
274
|
-
"deskapp",
|
|
275
|
-
"!node_modules"
|
|
276
|
-
]
|
|
277
|
-
rootDir : patternsRootDir : 'supportapp'
|
|
278
|
-
|
|
279
|
-
output :
|
|
280
|
-
true or false
|
|
281
|
-
*/
|
|
282
|
-
|
|
283
|
-
if (!(0, _fileHandling.isFileNameMatchingPluginPattern)({
|
|
284
|
-
filename,
|
|
285
|
-
filterArr: this.patterns.cssVariableReplacement,
|
|
286
|
-
rootDir: this.rootDir
|
|
287
|
-
})) {
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
255
|
const rootOriginal = _postcss.default.parse(module.content);
|
|
292
256
|
|
|
293
|
-
module.content =
|
|
257
|
+
module.content = rootConvertor(rootOriginal, variables, settingsObject).toString();
|
|
294
258
|
});
|
|
295
259
|
});
|
|
296
260
|
});
|
|
297
|
-
/*
|
|
298
|
-
purpose of tap : to display the errors encountered so far
|
|
299
|
-
input :
|
|
300
|
-
all css files
|
|
301
|
-
output :
|
|
302
|
-
all errors that are present in the errTable arr
|
|
261
|
+
/*
|
|
262
|
+
purpose of tap : to display the errors encountered so far
|
|
263
|
+
input :
|
|
264
|
+
all css files
|
|
265
|
+
output :
|
|
266
|
+
all errors that are present in the errTable arr
|
|
303
267
|
*/
|
|
304
268
|
|
|
305
269
|
compiler.hooks.afterEmit.tap('error-display', () => {
|
|
@@ -324,7 +288,29 @@ class VariableConversionCollector {
|
|
|
324
288
|
if (a.type < b.type) {
|
|
325
289
|
return -1;
|
|
326
290
|
}
|
|
327
|
-
});
|
|
291
|
+
}); // variable constructed now to be written in a json file
|
|
292
|
+
// const newVars = Object.keys(variables)
|
|
293
|
+
// //Filter Object with key contanis "NAME"
|
|
294
|
+
// .filter(key => variables[key].includes('--'))
|
|
295
|
+
// .reduce(
|
|
296
|
+
// (obj, key) =>
|
|
297
|
+
// Object.assign(obj, {
|
|
298
|
+
// [key]: variables[key]
|
|
299
|
+
// }),
|
|
300
|
+
// {}
|
|
301
|
+
// );
|
|
302
|
+
// console.log('new variables: ', newVars);
|
|
303
|
+
// try {
|
|
304
|
+
// fs.writeFileSync('./variableMapping.json', JSON.stringify(variables));
|
|
305
|
+
// } catch (err) {
|
|
306
|
+
// console.log(err);
|
|
307
|
+
// }
|
|
308
|
+
// fs.writeFile('./variableMapping.json', JSON.stringify(variables), err => {
|
|
309
|
+
// if (err) {
|
|
310
|
+
// throw err;
|
|
311
|
+
// }
|
|
312
|
+
// console.log('variable mapping file generated.');
|
|
313
|
+
// });
|
|
328
314
|
|
|
329
315
|
if (errorConsoleStatus) {
|
|
330
316
|
const errorHandler = new _ErrorHandler.ErrorHandler();
|