@zohodesk/react-cli 0.0.1-beta.17 → 0.0.1-beta.171
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 +1 -0
- package/.eslintrc.js +49 -10
- package/.prettierrc +6 -0
- package/CHANGELOG.md +5 -0
- package/README.md +859 -0
- package/bin/cli.js +215 -46
- package/cert/Tsicsezwild-22-23.crt +37 -0
- package/cert/Tsicsezwild-22-23.key +27 -0
- package/docs/CustomChunks.md +26 -0
- package/docs/DevStart.md +18 -0
- package/docs/HoverActive.md +12 -0
- package/docs/InstallNode.md +28 -0
- package/docs/TODOS.md +10 -0
- package/docs/ValueReplacer.md +60 -0
- package/docs/warnings_while_install.txt +35 -0
- package/files/eslintrc.js +62 -0
- package/files/prettierrc.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +24 -0
- package/lib/babel/es-plugins-presets.js +34 -0
- package/lib/common/getEntries.js +33 -46
- package/lib/common/getPublicPathConfig.js +40 -0
- package/lib/common/index.js +24 -19
- package/lib/common/splitChunks.js +110 -25
- package/lib/common/sslcertUpdater.js +59 -0
- package/lib/common/templateParameters.js +25 -0
- package/lib/common/testPattern.js +69 -0
- package/lib/common/valueReplacer.js +55 -0
- package/lib/configs/jest.config.js +31 -27
- package/lib/configs/libAlias.js +31 -0
- package/lib/configs/webpack.component.umd.config.js +46 -53
- package/lib/configs/webpack.css.umd.config.js +47 -46
- package/lib/configs/webpack.dev.config.js +99 -84
- package/lib/configs/webpack.docs.config.js +65 -57
- package/lib/configs/webpack.impact.config.js +109 -0
- package/lib/configs/webpack.prod.config.js +147 -104
- package/lib/hooks/docsProptypeHook.js +32 -38
- package/lib/jest/commitedFilesResult.js +144 -71
- package/lib/jest/coverageCollector.js +68 -35
- package/lib/jest/jsonMaker.js +54 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
- package/lib/jest/preProcessors/jsPreprocessor.js +5 -6
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
- package/lib/jest/result.js +92 -42
- package/lib/jest/run.js +75 -28
- package/lib/jest/setup.js +103 -102
- package/lib/loaderUtils/configsAssetsLoaders.js +117 -0
- package/lib/loaderUtils/getCSSLoaders.js +113 -0
- package/lib/loaderUtils/getDevJsLoaders.js +35 -23
- package/lib/loaderUtils/index.js +14 -7
- package/lib/loaders/docsLoader.js +15 -15
- package/lib/loaders/docsPropsLoader.js +14 -17
- package/lib/loaders/fileBountryLoader.js +17 -0
- package/lib/loaders/fileLoader.js +47 -38
- package/lib/loaders/scriptInstrumentLoader.js +23 -20
- package/lib/loaders/selectorMappingLoader.js +75 -0
- package/lib/loaders/workerLoader.js +136 -0
- package/lib/middlewares/HMRMiddleware.js +90 -72
- package/lib/middlewares/SSTMiddleware.js +21 -0
- package/lib/pluginUtils/getDevPlugins.js +177 -30
- package/lib/pluginUtils/getDocsPlugins.js +36 -15
- package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
- package/lib/pluginUtils/getLibraryPlugins.js +8 -10
- package/lib/pluginUtils/getProdPlugins.js +244 -37
- package/lib/pluginUtils/getServerPlugins.js +8 -11
- package/lib/pluginUtils/getUMDCSSPlugins.js +14 -18
- package/lib/pluginUtils/getUMDComponentPlugins.js +14 -9
- package/lib/pluginUtils/index.js +36 -43
- package/lib/plugins/CdnChangePlugin.js +77 -0
- package/lib/plugins/CleanupStatsPlugin.js +28 -0
- package/lib/plugins/EFCPlugin.js +241 -0
- package/lib/plugins/EFCPlugin.md +6 -0
- package/lib/plugins/EFCTemplatePlugin.js +151 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +141 -0
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -0
- package/lib/plugins/I18nSplitPlugin/README.md +25 -0
- package/lib/plugins/I18nSplitPlugin/index.js +185 -0
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
- package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
- package/lib/plugins/ManifestPlugin.js +86 -0
- package/lib/plugins/ModuleStatsPlugin.js +98 -97
- package/lib/plugins/OptimizeJSPlugin.js +41 -0
- package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
- package/lib/plugins/PublicPathChangePlugin.js +226 -0
- package/lib/plugins/ReportGeneratePlugin.js +181 -0
- package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
- package/lib/plugins/ResourceHintsPlugin.js +67 -0
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +80 -0
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +82 -0
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +26 -0
- package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
- package/lib/plugins/ServiceWorkerPlugin.js +107 -0
- package/lib/plugins/ShadowDOMSupportPlugin.js +270 -0
- package/lib/plugins/SourceMapHookPlugin.js +25 -59
- package/lib/plugins/TPHashMappingPlugin.js +67 -0
- package/lib/plugins/UglifyCSSPlugin.js +39 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
- package/lib/plugins/index.js +127 -37
- package/lib/plugins/libraryImpactPlugin.js +190 -0
- package/lib/plugins/webpackwatchrunplugin.js +26 -0
- package/lib/postcss-plugins/ExcludePlugin.js +23 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
- 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 +368 -0
- package/lib/postcss-plugins/variableModifier.js +243 -0
- package/lib/schemas/index.js +541 -65
- package/lib/servers/clusterHubServer.js +22 -26
- package/lib/servers/devBuild.js +102 -0
- package/lib/servers/docsServer.js +3 -5
- package/lib/servers/docsServerCore.js +94 -79
- package/lib/servers/getCliPath.js +28 -0
- package/lib/servers/helpServer.js +19 -21
- package/lib/servers/httpsOptions.js +18 -0
- package/lib/servers/impactServer.js +123 -115
- package/lib/servers/mockserver.js +44 -0
- package/lib/servers/nowatchserver.js +200 -0
- package/lib/servers/scrServer.js +147 -0
- package/lib/servers/server.js +134 -132
- package/lib/servers/ssServer.js +106 -70
- package/lib/sh/reportPublish.sh +16 -10
- package/lib/templates/CoverageScriptTemplate.js +45 -18
- package/lib/templates/WMSTemplate.js +17 -18
- package/lib/templates/linterConstant.js +10 -0
- package/lib/utils/babelPresets.js +12 -4
- package/lib/utils/buildstats.html +148 -0
- package/lib/utils/clean.js +12 -11
- package/lib/utils/copy.js +16 -109
- package/lib/utils/copyTimezones.js +21 -0
- package/lib/utils/createEventStream.js +24 -19
- package/lib/utils/cssClassNameGenerate.js +77 -0
- package/lib/utils/cssURLReplacer.js +136 -0
- package/lib/utils/dependencyPostPublish.js +42 -0
- package/lib/utils/fileUtils.js +125 -0
- package/lib/utils/folderIterator.js +47 -0
- package/lib/utils/getComponents.js +126 -0
- package/lib/utils/getCurrentBranch.js +11 -17
- package/lib/utils/getDependenciesImpactList.js +151 -0
- package/lib/utils/getHash.js +26 -0
- package/lib/utils/getIp.js +20 -0
- package/lib/utils/getOptions.js +113 -28
- package/lib/utils/getServerURL.js +25 -8
- package/lib/utils/index.js +283 -68
- package/lib/utils/init.js +2 -2
- package/lib/utils/initPreCommitHook.js +47 -27
- package/lib/utils/jsonHelper.js +106 -0
- package/lib/utils/libraryImpactConfig.js +63 -0
- package/lib/utils/lint/addScripts.js +27 -0
- package/lib/utils/lint/checkExistingConfig.js +67 -0
- package/lib/utils/lint/copyConfigs.js +24 -0
- package/lib/utils/lint/index.js +54 -0
- package/lib/utils/lint/lintScripts.js +11 -0
- package/lib/utils/lint/lintSetup.js +31 -0
- package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
- package/lib/utils/lint/question.js +30 -0
- package/lib/utils/lintReporter.js +142 -0
- package/lib/utils/mailSender.js +16 -25
- package/lib/utils/pullOrigin.js +28 -0
- package/lib/utils/reinstallDependencies.js +133 -0
- package/lib/utils/removeAttributes.js +25 -23
- package/lib/utils/repoClone.js +59 -63
- package/lib/utils/request.js +64 -77
- package/lib/utils/resultSchema.json +73 -0
- package/lib/utils/rtl.js +59 -0
- package/lib/utils/setEnvVariables.js +13 -0
- package/lib/utils/ssTestHack.js +48 -0
- package/lib/utils/switchBranch.js +28 -0
- package/lib/utils/urlConcat.js +22 -0
- package/lib/utils/useExitCleanup.js +55 -0
- package/npm8.md +9 -0
- package/package.json +96 -64
- package/postpublish.js +6 -0
- package/templates/app/.eslintrc.js +140 -0
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -8
- 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 -13
- package/templates/app/package.json +37 -17
- package/templates/app/src/actions/SampleActions/index.js +37 -0
- package/templates/app/src/actions/index.js +65 -0
- package/templates/app/src/appUrls.js +19 -0
- package/templates/app/src/components/Alert/Alert.js +134 -0
- package/templates/app/src/components/Alert/Alert.module.css +79 -0
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -0
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -0
- package/templates/app/src/components/Sample/Sample.module.css +11 -0
- package/templates/app/src/components/Sample/SampleList.js +61 -0
- package/templates/app/src/components/Slider/Slider.css +41 -0
- package/templates/app/src/components/Slider/Slider.js +55 -0
- package/templates/app/src/containers/AlertContainer/index.js +15 -0
- package/templates/app/src/containers/AppContainer/index.js +96 -0
- package/templates/app/src/containers/AppContainer/index.module.css +27 -0
- package/templates/app/src/containers/CustomMatch/index.js +65 -0
- package/templates/app/src/containers/DevTools/index.js +10 -0
- package/templates/app/src/containers/Header/index.js +67 -0
- package/templates/app/src/containers/Header/index.module.css +43 -0
- package/templates/app/src/containers/Redirect/index.js +63 -0
- package/templates/app/src/containers/Redirector/index.js +47 -0
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -0
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -0
- package/templates/app/src/historyChange.js +5 -0
- package/templates/app/src/index.html +10 -0
- package/templates/app/src/index.js +24 -0
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -0
- package/templates/app/src/reducers/alertData.js +11 -0
- package/templates/app/src/reducers/index.js +6 -0
- package/templates/app/src/reducers/samples.js +19 -0
- package/templates/app/src/store/configureStore.dev.js +51 -0
- package/templates/app/src/store/configureStore.js +5 -0
- package/templates/app/src/store/configureStore.prod.js +26 -0
- package/templates/app/src/util/Common.js +5 -0
- package/templates/app/src/util/RequestAPI.js +132 -0
- package/templates/appold/README.md +12 -0
- package/templates/appold/app/index.html +8 -0
- package/templates/appold/app/properties/ApplicationResources_en_US.properties +1 -0
- package/templates/appold/app/properties/i18nkeys.json +3 -0
- package/templates/appold/docs/all.html +69 -0
- package/templates/appold/mockapi/index.js +13 -0
- package/templates/{app → appold}/mockapi/tickets.json +0 -0
- package/templates/appold/package.json +17 -0
- package/templates/appold/src/components/Text/Text.css +0 -0
- package/templates/appold/src/components/Text/Text.js +23 -0
- package/templates/appold/src/components/Text/__tests__/Text.spec.js +30 -0
- package/templates/appold/src/components/Text/docs/Text__default.docs.js +16 -0
- package/templates/appold/src/components/docs.js +1 -0
- package/templates/appold/src/components/index.js +5 -0
- package/templates/appold/src/index.js +13 -0
- package/templates/docs/all.html +1 -1
- package/templates/docs/component.html +110 -69
- package/templates/docs/components.html +221 -0
- package/templates/docs/css/component.css +12 -14
- package/templates/docs/css/componentTest.css +7 -0
- package/templates/docs/css/style.css +150 -206
- package/templates/docs/impactReportTemplate.html +154 -0
- package/templates/docs/index.html +1482 -1336
- package/templates/library/src/index.js +0 -0
- package/.npmignore +0 -3
- package/cert/cert.pem +0 -129
- package/cert/key.pem +0 -27
- package/lib/common/getInsertAt.js +0 -36
- package/lib/common/getInsertIntoFunction.js +0 -13
- package/lib/configs/webpack.server.config.js +0 -93
- package/lib/plugins/ChunkManifestReplacePlugin.js +0 -94
- package/lib/plugins/RuntimePublicPathPlugin.js +0 -46
- package/lib/rmcntrlm.sh +0 -14
- package/lib/servers/nodeServer.js +0 -238
- package/lib/templates/HMRTemplate.js +0 -256
- package/lib/templates/publicPathTemplate.js +0 -16
- package/lib/utils/setConfig.js +0 -14
- package/node_modules/history/CHANGES.md +0 -395
- package/node_modules/history/DOMUtils.js +0 -3
- package/node_modules/history/ExecutionEnvironment.js +0 -3
- package/node_modules/history/LICENSE +0 -21
- package/node_modules/history/LocationUtils.js +0 -3
- package/node_modules/history/PathUtils.js +0 -3
- package/node_modules/history/README.md +0 -282
- package/node_modules/history/cjs/history.js +0 -933
- package/node_modules/history/cjs/history.min.js +0 -1
- package/node_modules/history/createBrowserHistory.js +0 -3
- package/node_modules/history/createHashHistory.js +0 -3
- package/node_modules/history/createMemoryHistory.js +0 -3
- package/node_modules/history/createTransitionManager.js +0 -3
- package/node_modules/history/es/DOMUtils.js +0 -7
- package/node_modules/history/es/ExecutionEnvironment.js +0 -7
- package/node_modules/history/es/LocationUtils.js +0 -7
- package/node_modules/history/es/PathUtils.js +0 -7
- package/node_modules/history/es/createBrowserHistory.js +0 -7
- package/node_modules/history/es/createHashHistory.js +0 -7
- package/node_modules/history/es/createMemoryHistory.js +0 -7
- package/node_modules/history/es/createTransitionManager.js +0 -7
- package/node_modules/history/es/warnAboutDeprecatedESMImport.js +0 -35
- package/node_modules/history/esm/history.js +0 -904
- package/node_modules/history/index.js +0 -7
- package/node_modules/history/package.json +0 -134
- package/node_modules/history/umd/history.js +0 -1059
- package/node_modules/history/umd/history.min.js +0 -1
- package/node_modules/history/warnAboutDeprecatedCJSRequire.js +0 -35
- package/templates/app/.npmignore +0 -9
- package/templates/library/.npmignore +0 -9
@@ -0,0 +1,243 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const postcss = require('postcss');
|
4
|
+
|
5
|
+
const path = require('path');
|
6
|
+
|
7
|
+
const fs = require('fs');
|
8
|
+
|
9
|
+
function populateArray(start, end) {
|
10
|
+
let temp = [];
|
11
|
+
|
12
|
+
for (var i = start; i < end; i++) {
|
13
|
+
temp.push(i);
|
14
|
+
}
|
15
|
+
|
16
|
+
return temp;
|
17
|
+
}
|
18
|
+
|
19
|
+
let allwdVars = {
|
20
|
+
'font-size': ['px', 'em']
|
21
|
+
};
|
22
|
+
let numberObject = {
|
23
|
+
'font-size': {
|
24
|
+
allowed: ['px', 'em'],
|
25
|
+
replacements: {
|
26
|
+
px: 'var(--zd_font_size$$)',
|
27
|
+
em: 'var(--zd_font_size$$em)'
|
28
|
+
},
|
29
|
+
//[5,10,15,20,25],
|
30
|
+
available: populateArray(0, 251),
|
31
|
+
replacementValues: {
|
32
|
+
px: [],
|
33
|
+
em: []
|
34
|
+
}
|
35
|
+
},
|
36
|
+
'margin': {
|
37
|
+
allowed: ['px'],
|
38
|
+
replacements: {
|
39
|
+
px: 'var(--zd_size$$)'
|
40
|
+
},
|
41
|
+
available: populateArray(-250, 251),
|
42
|
+
replacementValues: {
|
43
|
+
px: []
|
44
|
+
}
|
45
|
+
},
|
46
|
+
'margin-left': {
|
47
|
+
allowed: ['px'],
|
48
|
+
replacements: {
|
49
|
+
px: 'var(--zd_size$$)'
|
50
|
+
},
|
51
|
+
available: populateArray(-250, 251),
|
52
|
+
replacementValues: {
|
53
|
+
px: []
|
54
|
+
}
|
55
|
+
},
|
56
|
+
'margin-right': {
|
57
|
+
allowed: ['px'],
|
58
|
+
replacements: {
|
59
|
+
px: 'var(--zd_size$$)'
|
60
|
+
},
|
61
|
+
available: populateArray(-250, 251),
|
62
|
+
replacementValues: {
|
63
|
+
px: []
|
64
|
+
}
|
65
|
+
},
|
66
|
+
'margin-top': {
|
67
|
+
allowed: ['px'],
|
68
|
+
replacements: {
|
69
|
+
px: 'var(--zd_size$$)'
|
70
|
+
},
|
71
|
+
available: populateArray(-250, 251),
|
72
|
+
replacementValues: {
|
73
|
+
px: []
|
74
|
+
}
|
75
|
+
},
|
76
|
+
'margin-bottom': {
|
77
|
+
allowed: ['px'],
|
78
|
+
replacements: {
|
79
|
+
px: 'var(--zd_size$$)'
|
80
|
+
},
|
81
|
+
available: populateArray(-250, 251),
|
82
|
+
replacementValues: {
|
83
|
+
px: []
|
84
|
+
}
|
85
|
+
}
|
86
|
+
};
|
87
|
+
|
88
|
+
function hasIgnoreComment(node) {
|
89
|
+
return node ? node.type == 'comment' ? node.text == 'Variable:Ignore' ? true : false : false : false;
|
90
|
+
}
|
91
|
+
|
92
|
+
let errors = [];
|
93
|
+
module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal => {
|
94
|
+
// console.log('inside postcss plugin')
|
95
|
+
// fs.writeFile('./css_error.log', '\r\nLog File: \r\n\r\n', (err) => {
|
96
|
+
// if(err)console.log(err);
|
97
|
+
// });
|
98
|
+
// console.log(rootOriginal.source.input.file);
|
99
|
+
if (!rootOriginal.source.input.file.includes('css_error')) {
|
100
|
+
rootOriginal.walkRules(rule => {
|
101
|
+
rule.walkDecls((decl, position) => {
|
102
|
+
// case font-size
|
103
|
+
if (!hasIgnoreComment(rule.nodes[position - 1])) {
|
104
|
+
let unit = decl.value.replace(/[0-9]/g, '');
|
105
|
+
let settings = numberObject[decl.prop];
|
106
|
+
let path = rootOriginal.source.input.from;
|
107
|
+
let filename = path.split('\\');
|
108
|
+
filename = filename[filename.length - 1];
|
109
|
+
|
110
|
+
if (decl.prop === 'font-size' || decl.prop === 'margin-left' || decl.prop === 'margin-right' || decl.prop === 'margin-top' || decl.prop === 'margin-bottom') {
|
111
|
+
let {
|
112
|
+
allowed,
|
113
|
+
replacements,
|
114
|
+
available
|
115
|
+
} = settings;
|
116
|
+
|
117
|
+
if (!rootOriginal.source.input.from.includes('node_modules')) {
|
118
|
+
if (unit != 0) {
|
119
|
+
if (allowed.includes(unit)) {
|
120
|
+
// console.log(available, parseInt(decl.value))
|
121
|
+
if (available.includes(parseInt(decl.value))) {
|
122
|
+
// replacementValues[unit].push({[decl.value] : replacements[unit].replace('$$', parseInt(decl.value))})
|
123
|
+
decl.value = replacements[unit].replace('$$', parseInt(decl.value)); //console.log("replacements:")
|
124
|
+
} else {
|
125
|
+
let err = {
|
126
|
+
prop: decl.prop,
|
127
|
+
value: decl.value,
|
128
|
+
filename,
|
129
|
+
filepath: rootOriginal.source.input.from,
|
130
|
+
line: decl.source.start.line,
|
131
|
+
unit,
|
132
|
+
message: 'value not available consider others'
|
133
|
+
};
|
134
|
+
errors.push(err);
|
135
|
+
}
|
136
|
+
} else {
|
137
|
+
let err = {
|
138
|
+
prop: decl.prop,
|
139
|
+
value: decl.value,
|
140
|
+
filename,
|
141
|
+
filepath: rootOriginal.source.input.from,
|
142
|
+
line: decl.source.start.line,
|
143
|
+
unit,
|
144
|
+
message: 'Unit not supported'
|
145
|
+
};
|
146
|
+
errors.push(err);
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
} else if (decl.prop === 'margin') {
|
151
|
+
let {
|
152
|
+
allowed,
|
153
|
+
replacements,
|
154
|
+
available
|
155
|
+
} = settings; //console.log(decl.prop + " " + decl.value)
|
156
|
+
|
157
|
+
let valArr = decl.value.split(' '); //console.log(valArr)
|
158
|
+
//console.log(allowed, replacements, available)
|
159
|
+
|
160
|
+
let hasError = false;
|
161
|
+
let newVal = '';
|
162
|
+
valArr.forEach(val => {
|
163
|
+
let unit = val.replace(parseInt(val), '');
|
164
|
+
let numVal = parseInt(val);
|
165
|
+
|
166
|
+
if (unit != 0) {
|
167
|
+
if (allowed.includes(unit)) {
|
168
|
+
if (available.includes(numVal)) {
|
169
|
+
if (numVal >= 0) {
|
170
|
+
if (!hasError) {
|
171
|
+
newVal += replacements[unit].replace('$$', numVal) + " ";
|
172
|
+
}
|
173
|
+
} else {
|
174
|
+
if (!hasError) {
|
175
|
+
newVal += `calc(${replacements[unit].replace('$$', numVal * -1)} * -1)` + " ";
|
176
|
+
}
|
177
|
+
}
|
178
|
+
} else {
|
179
|
+
hasError = true;
|
180
|
+
let err = {
|
181
|
+
prop: decl.prop,
|
182
|
+
value: numVal,
|
183
|
+
filename,
|
184
|
+
filepath: rootOriginal.source.input.from,
|
185
|
+
line: decl.source.start.line,
|
186
|
+
unit,
|
187
|
+
message: 'value not available consider others'
|
188
|
+
};
|
189
|
+
errors.push(err);
|
190
|
+
}
|
191
|
+
} else {
|
192
|
+
hasError = true;
|
193
|
+
let err = {
|
194
|
+
prop: decl.prop,
|
195
|
+
value: decl.value,
|
196
|
+
filename,
|
197
|
+
filepath: rootOriginal.source.input.from,
|
198
|
+
line: decl.source.start.line,
|
199
|
+
unit,
|
200
|
+
message: 'Unit not supported'
|
201
|
+
};
|
202
|
+
errors.push(err);
|
203
|
+
}
|
204
|
+
}
|
205
|
+
});
|
206
|
+
|
207
|
+
if (!hasError) {
|
208
|
+
decl.value = newVal;
|
209
|
+
}
|
210
|
+
}
|
211
|
+
}
|
212
|
+
});
|
213
|
+
}); //fs.writeFile('./src/trial.json', JSON.stringify(variables) ,(err) =>{
|
214
|
+
// if(err)console.log(err);
|
215
|
+
// else{
|
216
|
+
// console.log('updated successfully');
|
217
|
+
// }
|
218
|
+
// })
|
219
|
+
// console.log(errors)
|
220
|
+
|
221
|
+
let errorArr = [];
|
222
|
+
errors.forEach(errStr => {
|
223
|
+
errorArr.push(` prop: ${errStr.prop} ,\n value : ${errStr.value} ,\n filename : ${errStr.filename} ,\n filepath : ${errStr.filepath} ,\n line : ${errStr.line} ,\n unit : ${errStr.unit} ,\n message : ${errStr.message} \r`);
|
224
|
+
}); //fs.writeFile('./css_error.log','', (err) =>{
|
225
|
+
// if(err){
|
226
|
+
// console.log(err);
|
227
|
+
// }
|
228
|
+
//});
|
229
|
+
// errorArr.forEach(err => {
|
230
|
+
// let data = `\n{\n${err}\n},\n`;
|
231
|
+
// //fs.appendFile('./css_error.log',data,(err)=>{
|
232
|
+
// // if(err){
|
233
|
+
// // console.log(err);
|
234
|
+
// // }
|
235
|
+
// //})
|
236
|
+
// });
|
237
|
+
// fs.writeFileSync('./css_error.log','');
|
238
|
+
// errorArr.forEach(err => {
|
239
|
+
// let data = `\n{\n${err}\n},\n`;
|
240
|
+
// fs.appendFileSync('./css_error.log',data);
|
241
|
+
// });
|
242
|
+
}
|
243
|
+
});
|