@zohodesk/react-cli 1.1.6 → 1.1.8-exp.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintignore +7 -7
- package/.eslintrc.js +180 -180
- package/.prettierrc +6 -6
- package/Changelog.md +1019 -1019
- package/README.md +1293 -1244
- package/bin/cli.js +497 -497
- package/docs/ComposeMinification.md +13 -13
- package/docs/CustomChunks.md +29 -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/MarkdownParser.md +18 -0
- package/docs/ReactLive.md +13 -13
- 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 +56 -56
- package/docs/warnings_while_install.txt +35 -35
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- package/lib/common/splitChunks.js +65 -45
- package/lib/common/testPattern.js +9 -9
- package/lib/configs/webpack.css.umd.config.js +4 -4
- package/lib/configs/webpack.dev.config.js +24 -3
- package/lib/configs/webpack.docs.config.js +22 -3
- package/lib/configs/webpack.impact.config.js +4 -2
- package/lib/configs/webpack.prod.config.js +6 -3
- package/lib/deprecationLogger.js +41 -0
- package/lib/loaderUtils/configsAssetsLoaders.js +33 -33
- package/lib/loaderUtils/getCSSLoaders.js +77 -56
- package/lib/loaders/__test__/markdownLoader.spec.js +145 -0
- package/lib/loaders/docsLoader.js +3 -0
- package/lib/loaders/markdownLoader.js +71 -0
- package/lib/loaders/workerLoader.js +9 -9
- package/lib/pluginUtils/getDevPlugins.js +8 -7
- package/lib/pluginUtils/getProdPlugins.js +6 -6
- 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 +30 -20
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +6 -6
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
- package/lib/plugins/SelectorPlugin.js +29 -29
- package/lib/plugins/ServiceWorkerPlugin.js +9 -9
- package/lib/plugins/TPHashMappingPlugin.js +4 -4
- package/lib/plugins/VariableConversionCollector.js +59 -59
- package/lib/plugins/utils/fileHandling.js +35 -42
- package/lib/plugins/variableConvertorUtils.js +9 -9
- 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 +23 -36
- 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 +13 -13
- package/lib/utils/deprecationSupport.js +144 -0
- package/lib/utils/getOptions.js +18 -78
- package/lib/utils/resultSchema.json +73 -73
- package/npm-shrinkwrap.json +33393 -33393
- package/npm8.md +9 -9
- package/package.json +123 -122
- package/postpublish.js +8 -8
- package/result.json +1 -0
- 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 +250 -249
- package/templates/docs/component.html +179 -178
- package/templates/docs/components.html +222 -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/markdown.css +202 -0
- package/templates/docs/css/style.css +1022 -1022
- package/templates/docs/impactReportTemplate.html +154 -154
- package/templates/docs/index.html +1502 -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/unittest/index.html +37 -0
@@ -44,7 +44,8 @@ const {
|
|
44
44
|
selectorReplace,
|
45
45
|
removePropTypes,
|
46
46
|
devConsoleExculde,
|
47
|
-
crossorigin
|
47
|
+
crossorigin,
|
48
|
+
postCssPluginOrder
|
48
49
|
}
|
49
50
|
} = options;
|
50
51
|
let {
|
@@ -160,7 +161,8 @@ module.exports = {
|
|
160
161
|
mediaQueryHoverActiveString,
|
161
162
|
classNameBlob: '[local]',
|
162
163
|
cssUniqueness: false,
|
163
|
-
selectorReplace: null
|
164
|
+
selectorReplace: null,
|
165
|
+
postCssPluginOrder
|
164
166
|
})
|
165
167
|
} : null, {
|
166
168
|
test: seperateCssModules ? /\.module\.css$/ : /\.css$/,
|
@@ -175,7 +177,8 @@ module.exports = {
|
|
175
177
|
cssUniqueness,
|
176
178
|
selectorReplace,
|
177
179
|
cssHashSelectors,
|
178
|
-
classNamePrefix
|
180
|
+
classNamePrefix,
|
181
|
+
postCssPluginOrder
|
179
182
|
})
|
180
183
|
}, {
|
181
184
|
test: /\.jpe?g$|\.gif$|\.png$/,
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.deprecateMessage = deprecateMessage;
|
7
|
+
exports.deprecateOption = deprecateOption;
|
8
|
+
exports.deprecationLoggerEnd = deprecationLoggerEnd;
|
9
|
+
exports.deprecationLoggerStart = deprecationLoggerStart;
|
10
|
+
|
11
|
+
var _logger = require("./logger");
|
12
|
+
|
13
|
+
function deprecateMessage(message) {
|
14
|
+
(0, _logger.messageLogger)('\x1b[33m%s\x1b[0m', message);
|
15
|
+
}
|
16
|
+
|
17
|
+
function printLine() {
|
18
|
+
deprecateMessage('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! \n ');
|
19
|
+
}
|
20
|
+
|
21
|
+
let isFirstDeprecation = false;
|
22
|
+
|
23
|
+
function deprecateOption(previousObjPath = '', newObjPath = '', message = '') {
|
24
|
+
// eslint-disable-next-line no-use-before-define
|
25
|
+
deprecationLoggerStart();
|
26
|
+
deprecateMessage(`Please move "${previousObjPath.split('.').join(' > ')}" to "${newObjPath.split('.').join(' > ')}" following option ${message}`);
|
27
|
+
}
|
28
|
+
|
29
|
+
function deprecationLoggerStart() {
|
30
|
+
if (!isFirstDeprecation) {
|
31
|
+
isFirstDeprecation = true;
|
32
|
+
printLine();
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
function deprecationLoggerEnd() {
|
37
|
+
if (isFirstDeprecation) {
|
38
|
+
isFirstDeprecation = false;
|
39
|
+
printLine();
|
40
|
+
}
|
41
|
+
}
|
@@ -79,39 +79,39 @@ function createNameTemplate(enableChunkHash) {
|
|
79
79
|
const ext = `${enableChunkHash ? '.[hash:20]' : ''}.[ext]`;
|
80
80
|
return `[name]${ext}`;
|
81
81
|
}
|
82
|
-
/*
|
83
|
-
export function createImageAndFontsAndSVGLoaders(enableChunkHash) {
|
84
|
-
const nameTemplate = createNameTemplate(enableChunkHash);
|
85
|
-
return [
|
86
|
-
configImageLoader(nameTemplate),
|
87
|
-
configFontLoader(nameTemplate),
|
88
|
-
configSVGLoader(nameTemplate),
|
89
|
-
configAudioLoader(nameTemplate)
|
90
|
-
];
|
91
|
-
}
|
82
|
+
/*
|
83
|
+
export function createImageAndFontsAndSVGLoaders(enableChunkHash) {
|
84
|
+
const nameTemplate = createNameTemplate(enableChunkHash);
|
85
|
+
return [
|
86
|
+
configImageLoader(nameTemplate),
|
87
|
+
configFontLoader(nameTemplate),
|
88
|
+
configSVGLoader(nameTemplate),
|
89
|
+
configAudioLoader(nameTemplate)
|
90
|
+
];
|
91
|
+
}
|
92
92
|
*/
|
93
93
|
|
94
|
-
/*
|
95
|
-
export function createLoaderOptionObject(
|
96
|
-
loaderName,
|
97
|
-
nameTemplate,
|
98
|
-
fallback,
|
99
|
-
limit = 1000
|
100
|
-
) {
|
101
|
-
return {
|
102
|
-
loader: loaderName,
|
103
|
-
options: {
|
104
|
-
limit,
|
105
|
-
name: nameTemplate,
|
106
|
-
fallback
|
107
|
-
}
|
108
|
-
};
|
109
|
-
}
|
110
|
-
|
111
|
-
function configLoaderObject(filter, loaderAndOptions) {
|
112
|
-
return {
|
113
|
-
test: filter,
|
114
|
-
use: loaderAndOptions
|
115
|
-
};
|
116
|
-
}
|
94
|
+
/*
|
95
|
+
export function createLoaderOptionObject(
|
96
|
+
loaderName,
|
97
|
+
nameTemplate,
|
98
|
+
fallback,
|
99
|
+
limit = 1000
|
100
|
+
) {
|
101
|
+
return {
|
102
|
+
loader: loaderName,
|
103
|
+
options: {
|
104
|
+
limit,
|
105
|
+
name: nameTemplate,
|
106
|
+
fallback
|
107
|
+
}
|
108
|
+
};
|
109
|
+
}
|
110
|
+
|
111
|
+
function configLoaderObject(filter, loaderAndOptions) {
|
112
|
+
return {
|
113
|
+
test: filter,
|
114
|
+
use: loaderAndOptions
|
115
|
+
};
|
116
|
+
}
|
117
117
|
*/
|
@@ -18,6 +18,24 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
18
18
|
const fs = require('fs');
|
19
19
|
|
20
20
|
const options = (0, _utils.getOptions)();
|
21
|
+
const defaultPostCssPluginOrder = ['valueReplacer', 'selectorReplace', 'hasRTL', 'hoverActive', 'combinerMediaQuery', 'cssVariableReplacement', 'selectorWeight', 'minifier', 'composeMinification'];
|
22
|
+
|
23
|
+
function calculatePostCssPluginOrder(postCssPluginOrder, pluginOrder) {
|
24
|
+
// if(typeof postCssPluginOrder === Boolean)
|
25
|
+
if (typeof postCssPluginOrder === 'boolean') {
|
26
|
+
if (postCssPluginOrder) {
|
27
|
+
return pluginOrder;
|
28
|
+
}
|
29
|
+
|
30
|
+
return defaultPostCssPluginOrder.filter(value => pluginOrder.includes(value));
|
31
|
+
}
|
32
|
+
|
33
|
+
if (Array.isArray(postCssPluginOrder)) {
|
34
|
+
return postCssPluginOrder;
|
35
|
+
}
|
36
|
+
|
37
|
+
return [];
|
38
|
+
}
|
21
39
|
|
22
40
|
const getCSSLoaders = optionsObj => {
|
23
41
|
const {
|
@@ -29,7 +47,8 @@ const getCSSLoaders = optionsObj => {
|
|
29
47
|
cssUniqueness,
|
30
48
|
selectorReplace,
|
31
49
|
cssHashSelectors,
|
32
|
-
classNamePrefix
|
50
|
+
classNamePrefix,
|
51
|
+
postCssPluginOrder
|
33
52
|
} = optionsObj;
|
34
53
|
const {
|
35
54
|
devCssFileBountry
|
@@ -54,7 +73,7 @@ const getCSSLoaders = optionsObj => {
|
|
54
73
|
} // console.log('selector weight config : ', selectorWeightConfig);
|
55
74
|
|
56
75
|
|
57
|
-
|
76
|
+
const postcssPlugins = [plugins.valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer), plugins.hasRTL && require('@zohodesk/postcss-rtl')({
|
58
77
|
addPrefixToSelector: function addPrefixToSelector(selector, prefix) {
|
59
78
|
if (prefix === '[dir]') {
|
60
79
|
return selector;
|
@@ -62,7 +81,7 @@ const getCSSLoaders = optionsObj => {
|
|
62
81
|
|
63
82
|
return `${prefix} ${selector}`; // Make selectors like [dir=rtl] > .selector
|
64
83
|
}
|
65
|
-
}), plugins.combinerMediaQuery && require('postcss-combine-media-query')(), plugins.hoverActive && require('../postcss-plugins/hoverActivePlugin')(mediaQueryHoverActiveString), plugins.cssVariableReplacement && fs.existsSync(cssVariableReplacementConfig) && require('../postcss-plugins/variableModificationPlugin/index').plugin(cssVariableReplacementConfig) // ,
|
84
|
+
}), plugins.selectorReplace && require('../postcss-plugins/SelectorReplace')(selectorReplace), plugins.combinerMediaQuery && require('postcss-combine-media-query')(), plugins.hoverActive && require('../postcss-plugins/hoverActivePlugin')(mediaQueryHoverActiveString), plugins.cssVariableReplacement && fs.existsSync(cssVariableReplacementConfig) && require('../postcss-plugins/variableModificationPlugin/index').plugin(cssVariableReplacementConfig) // ,
|
66
85
|
// plugins.composeMinification &&
|
67
86
|
// require('../postcss-plugins/composePlugin')()
|
68
87
|
].filter(Boolean);
|
@@ -89,65 +108,67 @@ const getCSSLoaders = optionsObj => {
|
|
89
108
|
// console.log('check here : ', params.resourcePath);
|
90
109
|
// getCSSLoaders for all postcss filtering
|
91
110
|
|
92
|
-
/*
|
93
|
-
input :
|
94
|
-
params.resourcePath : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
|
95
|
-
patterns : [
|
96
|
-
// include all files
|
97
|
-
"valueReplacer": [
|
98
|
-
"*"
|
99
|
-
],
|
100
|
-
// include all files
|
101
|
-
"selectorReplace": [
|
102
|
-
"*"
|
103
|
-
],
|
104
|
-
// include src folder, include deskapp folder, exclude node modules
|
105
|
-
"hoverActive": [
|
106
|
-
"src",
|
107
|
-
"deskapp",
|
108
|
-
"!node_modules"
|
109
|
-
],
|
110
|
-
// include src folder, include deskapp folder, exclude node modules
|
111
|
-
"combinerMediaQuery": [
|
112
|
-
"src",
|
113
|
-
"deskapp",
|
114
|
-
"!node_modules"
|
115
|
-
],
|
116
|
-
// include src folder, include deskapp folder, exclude node modules
|
117
|
-
"hasRTL": [
|
118
|
-
"src",
|
119
|
-
"deskapp",
|
120
|
-
"!node_modules"
|
121
|
-
],
|
122
|
-
// include src folder, include deskapp folder, exclude node modules
|
123
|
-
"cssVariableReplacement": [
|
124
|
-
"src",
|
125
|
-
"deskapp",
|
126
|
-
"!node_modules"
|
127
|
-
],
|
128
|
-
// include src folder, include deskapp folder, exclude node modules
|
129
|
-
"selectorWeight": [
|
130
|
-
"src",
|
131
|
-
"deskapp",
|
132
|
-
"!node_modules"
|
133
|
-
],
|
134
|
-
// include all files
|
135
|
-
"cssUniqueness": [
|
136
|
-
"*"
|
137
|
-
]
|
138
|
-
],
|
139
|
-
|
140
|
-
[ postcssPlugins that are implemented ]
|
141
|
-
|
111
|
+
/*
|
112
|
+
input :
|
113
|
+
params.resourcePath : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
|
114
|
+
patterns : [
|
115
|
+
// include all files
|
116
|
+
"valueReplacer": [
|
117
|
+
"*"
|
118
|
+
],
|
119
|
+
// include all files
|
120
|
+
"selectorReplace": [
|
121
|
+
"*"
|
122
|
+
],
|
123
|
+
// include src folder, include deskapp folder, exclude node modules
|
124
|
+
"hoverActive": [
|
125
|
+
"src",
|
126
|
+
"deskapp",
|
127
|
+
"!node_modules"
|
128
|
+
],
|
129
|
+
// include src folder, include deskapp folder, exclude node modules
|
130
|
+
"combinerMediaQuery": [
|
131
|
+
"src",
|
132
|
+
"deskapp",
|
133
|
+
"!node_modules"
|
134
|
+
],
|
135
|
+
// include src folder, include deskapp folder, exclude node modules
|
136
|
+
"hasRTL": [
|
137
|
+
"src",
|
138
|
+
"deskapp",
|
139
|
+
"!node_modules"
|
140
|
+
],
|
141
|
+
// include src folder, include deskapp folder, exclude node modules
|
142
|
+
"cssVariableReplacement": [
|
143
|
+
"src",
|
144
|
+
"deskapp",
|
145
|
+
"!node_modules"
|
146
|
+
],
|
147
|
+
// include src folder, include deskapp folder, exclude node modules
|
148
|
+
"selectorWeight": [
|
149
|
+
"src",
|
150
|
+
"deskapp",
|
151
|
+
"!node_modules"
|
152
|
+
],
|
153
|
+
// include all files
|
154
|
+
"cssUniqueness": [
|
155
|
+
"*"
|
156
|
+
]
|
157
|
+
],
|
158
|
+
|
159
|
+
[ postcssPlugins that are implemented ]
|
160
|
+
*/
|
142
161
|
// console.log(params.resourcePath);
|
143
162
|
// console.log(postcssPlugins);
|
144
|
-
const
|
163
|
+
const pluginOrder = Object.keys(plugins).filter(x => plugins[x] !== false);
|
164
|
+
const finalPostcssPlugins = (0, _fileHandling.isFileNameMatchingPattern)({
|
145
165
|
filename: params.resourcePath,
|
146
166
|
filterObject: patterns,
|
147
|
-
plugins: postcssPlugins
|
167
|
+
plugins: postcssPlugins,
|
168
|
+
order: calculatePostCssPluginOrder(postCssPluginOrder, pluginOrder)
|
148
169
|
}); // postcssPlugins that are allowed
|
149
170
|
|
150
|
-
return
|
171
|
+
return finalPostcssPlugins.length > 0 ? finalPostcssPlugins : [require('../postcss-plugins/EmptyPlugin')()];
|
151
172
|
}
|
152
173
|
}
|
153
174
|
} : null, plugins.composeMinification ? {
|
@@ -0,0 +1,145 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const {
|
4
|
+
markdownParser
|
5
|
+
} = require('../markdownLoader'); // Replace './your-file' with the correct file path
|
6
|
+
|
7
|
+
|
8
|
+
describe('markdownParser', () => {
|
9
|
+
test('For {}(braces) case', () => {
|
10
|
+
const source = `
|
11
|
+
/* MD:START
|
12
|
+
# {Hi, This is Test Case :)}
|
13
|
+
MD:END */
|
14
|
+
`;
|
15
|
+
const expectedOutput = `
|
16
|
+
<><div class="markDown"><h1>{Hi, This is Test Case :)}</h1>
|
17
|
+
</div></>
|
18
|
+
`;
|
19
|
+
expect(markdownParser(source)).toEqual(expectedOutput);
|
20
|
+
});
|
21
|
+
test('For $ (dollor) case', () => {
|
22
|
+
const source = `
|
23
|
+
/* MD:START
|
24
|
+
# $Hi, This is Test Case :)
|
25
|
+
MD:END */
|
26
|
+
`;
|
27
|
+
const expectedOutput = `
|
28
|
+
<><div class="markDown"><h1>$Hi, This is Test Case :)</h1>
|
29
|
+
</div></>
|
30
|
+
`;
|
31
|
+
expect(markdownParser(source)).toEqual(expectedOutput);
|
32
|
+
});
|
33
|
+
test('For All kind of Tag Cases', () => {
|
34
|
+
const source = `
|
35
|
+
/* MD:START
|
36
|
+
# Markdown File with Variety of Data
|
37
|
+
|
38
|
+
## Text
|
39
|
+
|
40
|
+
This is a paragraph of text.
|
41
|
+
|
42
|
+
## Headings
|
43
|
+
|
44
|
+
### Heading 1
|
45
|
+
|
46
|
+
### Heading 2
|
47
|
+
|
48
|
+
#### Heading 2.1
|
49
|
+
|
50
|
+
#### Heading 2.2
|
51
|
+
|
52
|
+
## Lists
|
53
|
+
|
54
|
+
### Unordered List
|
55
|
+
|
56
|
+
- Item 1
|
57
|
+
- Item 2
|
58
|
+
- Item 3
|
59
|
+
|
60
|
+
### Ordered List
|
61
|
+
|
62
|
+
1. First item
|
63
|
+
2. Second item
|
64
|
+
3. Third item
|
65
|
+
|
66
|
+
## Links
|
67
|
+
|
68
|
+
Here's a link to [OpenAI's website](https://openai.com).
|
69
|
+
|
70
|
+
## Images
|
71
|
+
|
72
|
+
![Markdown Logo](https://upload.wikimedia.org/wikipedia/commons/4/48/Markdown-mark.svg)
|
73
|
+
|
74
|
+
## Tables
|
75
|
+
|
76
|
+
| Name | Age | Gender |
|
77
|
+
|-------|-----|--------|
|
78
|
+
| John | 25 | Male |
|
79
|
+
| Sarah | 30 | Female |
|
80
|
+
| Mark | 35 | Male |
|
81
|
+
|
82
|
+
MD:END */
|
83
|
+
`;
|
84
|
+
const expectedOutput = `
|
85
|
+
<><div class="markDown"><h1>Markdown File with Variety of Data</h1>
|
86
|
+
<h2>Text</h2>
|
87
|
+
<p>This is a paragraph of text.</p>
|
88
|
+
<h2>Headings</h2>
|
89
|
+
<h3>Heading 1</h3>
|
90
|
+
<h3>Heading 2</h3>
|
91
|
+
<h4>Heading 2.1</h4>
|
92
|
+
<h4>Heading 2.2</h4>
|
93
|
+
<h2>Lists</h2>
|
94
|
+
<h3>Unordered List</h3>
|
95
|
+
<ul>
|
96
|
+
<li>Item 1</li>
|
97
|
+
<li>Item 2</li>
|
98
|
+
<li>Item 3</li>
|
99
|
+
</ul>
|
100
|
+
<h3>Ordered List</h3>
|
101
|
+
<ol>
|
102
|
+
<li>First item</li>
|
103
|
+
<li>Second item</li>
|
104
|
+
<li>Third item</li>
|
105
|
+
</ol>
|
106
|
+
<h2>Links</h2>
|
107
|
+
<p>Here's a link to <a href="https://openai.com">OpenAI's website</a>.</p>
|
108
|
+
<h2>Images</h2>
|
109
|
+
<p><img src="https://upload.wikimedia.org/wikipedia/commons/4/48/Markdown-mark.svg" alt="Markdown Logo"/></p>
|
110
|
+
<h2>Tables</h2>
|
111
|
+
<table>
|
112
|
+
<thead>
|
113
|
+
<tr>
|
114
|
+
<th>Name</th>
|
115
|
+
<th>Age</th>
|
116
|
+
<th>Gender</th>
|
117
|
+
</tr>
|
118
|
+
</thead>
|
119
|
+
<tbody>
|
120
|
+
<tr>
|
121
|
+
<td>John</td>
|
122
|
+
<td>25</td>
|
123
|
+
<td>Male</td>
|
124
|
+
</tr>
|
125
|
+
<tr>
|
126
|
+
<td>Sarah</td>
|
127
|
+
<td>30</td>
|
128
|
+
<td>Female</td>
|
129
|
+
</tr>
|
130
|
+
<tr>
|
131
|
+
<td>Mark</td>
|
132
|
+
<td>35</td>
|
133
|
+
<td>Male</td>
|
134
|
+
</tr>
|
135
|
+
</tbody>
|
136
|
+
</table>
|
137
|
+
</div></>
|
138
|
+
`;
|
139
|
+
expect(markdownParser(source)).toEqual(expectedOutput);
|
140
|
+
});
|
141
|
+
test('For Source null case', () => {
|
142
|
+
expect(markdownParser(null)).toEqual('');
|
143
|
+
expect(markdownParser('')).toEqual('');
|
144
|
+
});
|
145
|
+
});
|
@@ -8,6 +8,8 @@ var _path = _interopRequireDefault(require("path"));
|
|
8
8
|
|
9
9
|
var _reactLiveConvertor = require("./reactLiveConvertor");
|
10
10
|
|
11
|
+
var _markdownLoader = require("./markdownLoader.js");
|
12
|
+
|
11
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
12
14
|
|
13
15
|
module.exports = function (source) {
|
@@ -24,6 +26,7 @@ module.exports = function (source) {
|
|
24
26
|
|
25
27
|
const src = _fs.default.readFileSync(originalFilePath).toString();
|
26
28
|
|
29
|
+
options.docs.enableMDParser && (source = (0, _markdownLoader.markdownParser)(source));
|
27
30
|
options.docs.enableReactLive && (source = (0, _reactLiveConvertor.reactLiveConvertor)(source, originalFilePath)); //to Enable the ReactLive Converter
|
28
31
|
|
29
32
|
return `${source};${name}.source=${JSON.stringify(src)};${name}.filePath=${JSON.stringify(filePath)}`;
|
@@ -0,0 +1,71 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.markdownParser = markdownParser;
|
7
|
+
|
8
|
+
const markdownIt = require('markdown-it'); // const md = new markdownIt({ linkify: true,breaks:true });
|
9
|
+
|
10
|
+
|
11
|
+
const md = new markdownIt({
|
12
|
+
html: false,
|
13
|
+
linkify: true,
|
14
|
+
typographer: true,
|
15
|
+
breaks: true,
|
16
|
+
xhtmlOut: true
|
17
|
+
}); //const md = new markdownIt();
|
18
|
+
|
19
|
+
function markdownParser(source) {
|
20
|
+
if (!source) {
|
21
|
+
return '';
|
22
|
+
}
|
23
|
+
|
24
|
+
const startTag = '/* MD:START';
|
25
|
+
const endTag = 'MD:END */'; // Iterate through all occurrences of the tags
|
26
|
+
|
27
|
+
let startIndex = source.indexOf(startTag);
|
28
|
+
|
29
|
+
while (startIndex !== -1) {
|
30
|
+
const endIndex = source.indexOf(endTag, startIndex);
|
31
|
+
|
32
|
+
if (endIndex !== -1) {
|
33
|
+
const extractedMarkdown = source.slice(startIndex + startTag.length, endIndex);
|
34
|
+
let lines = extractedMarkdown.split('\n');
|
35
|
+
lines = lines.filter(line => line.trim() !== '');
|
36
|
+
const firstLineIndentMatch = lines[0].match(/^\s+/);
|
37
|
+
const firstLineIndent = firstLineIndentMatch ? firstLineIndentMatch[0] : '';
|
38
|
+
const modifiedStr = lines.map(line => line.replace(new RegExp(`^${firstLineIndent}`), '')).join('\n').replace(/(:--)|(--:)/g, '---');
|
39
|
+
let html = md.render(modifiedStr); //html = html.replace(/"|<hr>|<img src=(".*?")>|<br>|:--|--:|{|}|\$/g, match => {
|
40
|
+
|
41
|
+
html = html.replace(/"|{|}|\$/g, match => {
|
42
|
+
// if (match === '<hr>') {
|
43
|
+
// return '<hr/>';
|
44
|
+
// } else if (match.startsWith('<img src=')) {
|
45
|
+
// return match.replace('>', '/>');
|
46
|
+
// } else if (match === '<br>') {
|
47
|
+
// return '<br/>';
|
48
|
+
if (match === '$') {
|
49
|
+
return '$';
|
50
|
+
} else if (match === '{') {
|
51
|
+
return '{';
|
52
|
+
} else if (match === '}') {
|
53
|
+
return '}';
|
54
|
+
} // else if (match === ':--' || match === '--:' ) {
|
55
|
+
// return '---';
|
56
|
+
// }
|
57
|
+
else if (match === '}') {
|
58
|
+
return '}';
|
59
|
+
}
|
60
|
+
|
61
|
+
return match;
|
62
|
+
}); // console.log(html,"html");
|
63
|
+
|
64
|
+
source = source.replace(source.slice(startIndex, endIndex + endTag.length), '<><div class="markDown">' + html + '</div></>');
|
65
|
+
}
|
66
|
+
|
67
|
+
startIndex = source.indexOf(startTag, startIndex + 1); // console.log(source)
|
68
|
+
}
|
69
|
+
|
70
|
+
return source;
|
71
|
+
}
|
@@ -16,7 +16,7 @@ var _SingleEntryPlugin = _interopRequireDefault(require("webpack/lib/SingleEntry
|
|
16
16
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
18
18
|
|
19
|
-
/* import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
|
19
|
+
/* import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
|
20
20
|
import ExternalsPlugin from 'webpack/lib/ExternalsPlugin'; */
|
21
21
|
const schema = {
|
22
22
|
'type': 'object',
|
@@ -80,14 +80,14 @@ function pitch(request) {
|
|
80
80
|
globalObject: 'self'
|
81
81
|
};
|
82
82
|
workerContext.compiler = this._compilation.createChildCompiler(`worker-loader ${request}`, workerContext.options);
|
83
|
-
/*
|
84
|
-
new WebWorkerTemplatePlugin().apply(workerContext.compiler);
|
85
|
-
|
86
|
-
if (compilerOptions.externals) {
|
87
|
-
new ExternalsPlugin(
|
88
|
-
getExternalsType(compilerOptions),
|
89
|
-
compilerOptions.externals
|
90
|
-
).apply(workerContext.compiler);
|
83
|
+
/*
|
84
|
+
new WebWorkerTemplatePlugin().apply(workerContext.compiler);
|
85
|
+
|
86
|
+
if (compilerOptions.externals) {
|
87
|
+
new ExternalsPlugin(
|
88
|
+
getExternalsType(compilerOptions),
|
89
|
+
compilerOptions.externals
|
90
|
+
).apply(workerContext.compiler);
|
91
91
|
} */
|
92
92
|
|
93
93
|
new _SingleEntryPlugin.default(this.context, `!!${request}`, _path.default.parse(this.resourcePath).name).apply(workerContext.compiler);
|
@@ -72,7 +72,8 @@ const getDevPlugins = (options, publicPath) => {
|
|
72
72
|
enableRTLSplit
|
73
73
|
},
|
74
74
|
i18n,
|
75
|
-
unusedFiles
|
75
|
+
unusedFiles,
|
76
|
+
resourceHints
|
76
77
|
} = options;
|
77
78
|
const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
|
78
79
|
const cssLTRFileNameTempalte = enableRTLSplit ? 'css/[name].ltr.css' : 'css/[name].css';
|
@@ -94,7 +95,7 @@ const getDevPlugins = (options, publicPath) => {
|
|
94
95
|
filename: cssLTRFileNameTempalte,
|
95
96
|
// ignoreOrder: true,
|
96
97
|
chunkFilename: cssLTRFileNameTempalte
|
97
|
-
}), new _plugins.ResourceHintsPlugin()];
|
98
|
+
}), new _plugins.ResourceHintsPlugin(resourceHints)];
|
98
99
|
|
99
100
|
if (enableRTLSplit) {
|
100
101
|
pluginsArr.push(new _RtlCssPlugin.RtlCssPlugin({
|
@@ -114,11 +115,11 @@ const getDevPlugins = (options, publicPath) => {
|
|
114
115
|
}
|
115
116
|
|
116
117
|
const i18nManifestFileName = 'i18n-manifest.json';
|
117
|
-
/**
|
118
|
-
* NOTE:
|
119
|
-
* this file name ext .i18n.js added
|
120
|
-
* Because, in service worker they maintain cache as file name based
|
121
|
-
* So, to make differce we added .i18n.js ext.
|
118
|
+
/**
|
119
|
+
* NOTE:
|
120
|
+
* this file name ext .i18n.js added
|
121
|
+
* Because, in service worker they maintain cache as file name based
|
122
|
+
* So, to make differce we added .i18n.js ext.
|
122
123
|
*/
|
123
124
|
|
124
125
|
const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].i18n.js';
|
@@ -107,7 +107,7 @@ const getProdPlugins = (options, publicPath = '') => {
|
|
107
107
|
// ignoreOrder: true,
|
108
108
|
filename: cssLTRFileNameTempalte,
|
109
109
|
chunkFilename: cssLTRFileNameTempalte
|
110
|
-
}), new _plugins.ResourceHintsPlugin(), new _plugins.MinifyPlugin()];
|
110
|
+
}), new _plugins.ResourceHintsPlugin(options.resourceHints), new _plugins.MinifyPlugin()];
|
111
111
|
|
112
112
|
if (enableRTLSplit) {
|
113
113
|
pluginsArr.push(new _RtlCssPlugin.RtlCssPlugin({
|
@@ -121,11 +121,11 @@ const getProdPlugins = (options, publicPath = '') => {
|
|
121
121
|
}
|
122
122
|
|
123
123
|
const i18nManifestFileName = 'i18n-manifest.json';
|
124
|
-
/**
|
125
|
-
* NOTE:
|
126
|
-
* this file name ext .i18n.js added
|
127
|
-
* Because, in service worker they maintain cache as file name based
|
128
|
-
* So, to make differce we added .i18n.js ext.
|
124
|
+
/**
|
125
|
+
* NOTE:
|
126
|
+
* this file name ext .i18n.js added
|
127
|
+
* Because, in service worker they maintain cache as file name based
|
128
|
+
* So, to make differce we added .i18n.js ext.
|
129
129
|
*/
|
130
130
|
|
131
131
|
const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].[chunkhash].i18n.js';
|