@zohodesk/react-cli 0.0.1-exp.160.3 → 0.0.1-exp.161.1

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,39 +1,68 @@
1
1
  # React CLI
2
2
 
3
3
  A CLI tool for build modern web application and libraries
4
+
5
+ # 0.0.1-exp.161.1
6
+
7
+ - Features
8
+ - feature added for efc cdnStatement
9
+ - Issue fixes:-
10
+ - css classname hash change issue fix
11
+ - debug package conflit issue fix in nock in (react-cli test)
12
+ - manifest.json css file name correction issue for rtl and ltr
13
+
4
14
  # 0.0.1-beta.160
15
+
5
16
  - @zohodesk/normalizer package version updated to 1.0.2
17
+
6
18
  # 0.0.1-beta.159
19
+
7
20
  - @zohodesk/datetimejs package updated to beta.7
21
+
22
+ # 0.0.1-exp.159
23
+
24
+ - isse fix:-
25
+ - when rtl ltr css split enable manifest json css filename keys comes with hash .
26
+
8
27
  # 0.0.1-beta.158
9
- - Removing source map files from service worker caching.
28
+
29
+ - Removing source map files from service worker caching.
30
+
10
31
  # 0.0.1-beta.157
11
- - Experimental version issue fix(Dummy version removed)
32
+
33
+ - Experimental version issue fix(Dummy version removed)
34
+
12
35
  # 0.0.1-beta.156
13
- - ReportPublish issue fix
36
+
37
+ - ReportPublish issue fix
14
38
 
15
39
  # 0.0.1-beta.155
16
- - get impacted library source files option added
40
+
41
+ - get impacted library source files option added
17
42
 
18
43
  # 0.0.1-beta.154
19
- - mockPrefix option for mock url prefix change
20
- - Issue fix:-
21
- - un wanted {{--js-smap}} in inital html without enable smap in build
44
+
45
+ - mockPrefix option for mock url prefix change
46
+ - Issue fix:-
47
+ - un wanted {{--js-smap}} in inital html without enable smap in build
22
48
 
23
49
  # 0.0.1-beta.153
50
+
24
51
  - Vendor include array added
25
52
  - If you need to include any thrid party js in vendor we can use this array
26
53
 
27
54
  # 0.0.1-beta.152
55
+
28
56
  impact servise related changes:-
57
+
29
58
  - nowatchstart option added. will be used like `react-cli nowatchstart <...options>` this will be used for src file changes no need to reflect (or no need to rebulid on file changes)
30
59
  - cssselector_zip option added. will be used like `--cssselector-zip=selectormapping.zip`
31
60
  only work in two ways
32
61
  1. `react-cli start --disable-watch --cssselector-zip=selectormapping.zip` app start command with `--disable-watch` flag and your usaul options
33
62
  2. `react-cli nowatchstart --cssselector-zip=selectormapping.zip` app start command's usaul options
34
63
  #### Urls are:-
35
- Below express path are added, For download zip files and
36
- - `/zips/${zipname}.zip` for css selector maps zip file (contains css_map filies and original css files)
64
+ Below express path are added, For download zip files and
65
+ - `/zips/${zipname}.zip` for css selector maps zip file (contains css_map filies and original css files)
37
66
  - `/zips/build.zip` build zip file (contains bundled all files)
38
67
 
39
68
  # 0.0.1-beta.151
@@ -12,9 +12,6 @@ var _loaderUtils = require("../loaderUtils");
12
12
 
13
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
14
 
15
- const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
16
-
17
- const smp = new SpeedMeasurePlugin();
18
15
  let options = (0, _utils.getOptions)();
19
16
  let {
20
17
  app: {
@@ -67,7 +64,7 @@ if (isDevelopment) {
67
64
  }
68
65
 
69
66
  let shouldRemovePropTypes = !isDevelopment && removePropTypes;
70
- module.exports = smp.wrap({
67
+ module.exports = {
71
68
  entry: (0, _common.getEntries)(options, 'production'),
72
69
  devtool: isDevelopment ? 'cheap-module-source-map' : enableSMap ? 'hidden-source-map' : 'none',
73
70
  mode: 'production',
@@ -84,7 +81,7 @@ module.exports = smp.wrap({
84
81
  stats: {
85
82
  children: false,
86
83
  colors: true,
87
- excludeAssets: /i18n|\.map$/,
84
+ // excludeAssets: /i18n/,
88
85
  warningsFilter: /\[mini-css-extract-plugin\]/
89
86
  },
90
87
  plugins: (0, _pluginUtils.getProdPlugins)(options, output.publicPath),
@@ -220,4 +217,4 @@ module.exports = smp.wrap({
220
217
  resolveLoader: {
221
218
  modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
222
219
  }
223
- });
220
+ };
@@ -11,6 +11,8 @@ var _fs = _interopRequireDefault(require("fs"));
11
11
 
12
12
  var _webpack = _interopRequireDefault(require("webpack"));
13
13
 
14
+ var _caseSensitivePathsWebpackPlugin = _interopRequireDefault(require("case-sensitive-paths-webpack-plugin"));
15
+
14
16
  var _webpackBundleAnalyzer = require("webpack-bundle-analyzer");
15
17
 
16
18
  var _lodashWebpackPlugin = _interopRequireDefault(require("lodash-webpack-plugin"));
@@ -33,7 +35,6 @@ var _RtlCssPlugin = require("../plugins/RtlSplitPlugin/RtlCssPlugin");
33
35
 
34
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
37
 
36
- // import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
37
38
  // eslint-disable-next-line no-unused-vars
38
39
  let getProdPlugins = (options, publicPath = '') => {
39
40
  let {
@@ -79,8 +80,7 @@ let getProdPlugins = (options, publicPath = '') => {
79
80
  const cssRTLFileNameTempalte = `css/[name]${hashTempalate}.rtl.css`;
80
81
  let isDevelopment = mode === 'prod' || mode === 'dev' || mode === 'dev-no-warn';
81
82
  enableChunkHash = !isDevelopment && enableChunkHash;
82
- let plugins = [// new CaseSensitivePathsPlugin(),
83
- new _webpack.default.IgnorePlugin(/^\.\/locale$/, /moment$/), new _webpack.default.DefinePlugin({
83
+ let plugins = [new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/locale$/, /moment$/), new _webpack.default.DefinePlugin({
84
84
  __TEST__: false,
85
85
  __DEVELOPMENT__: false,
86
86
  __LOCAL_PRODUCTION__: isDevelopment,
@@ -34,7 +34,8 @@ const {
34
34
  efc: efcOptios
35
35
  } = cliOptions;
36
36
  const {
37
- createSDkFile
37
+ createSDkFile,
38
+ cdnStatement
38
39
  } = efcOptios;
39
40
 
40
41
  class EFCPlugin {
@@ -44,7 +45,7 @@ class EFCPlugin {
44
45
  this.i18nFileNameTemplate = options.i18nFileNameTemplate; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
45
46
  // this.i18nManifestFileName = options.i18nManifestFileName;
46
47
  // IMPORTANT: here we mergeing optionds from pacakge.json and options via constructor
47
- // So when debugging consider this as well
48
+ // So when debugging consider this as well
48
49
 
49
50
  this.options = Object.assign({}, efcOptios, options);
50
51
  this.options.entryPointName = options.entryPointName || 'efc';
@@ -125,17 +126,32 @@ class EFCPlugin {
125
126
  ${enableRTLSplit ? `const cssDir = ${cssDirStatement};` : ''}
126
127
  const prod = !${this.isDevelopment};
127
128
  let cdnVariableName = "${cdnVariableName}";
128
- let assetURLs = {
129
- //hook
130
- js: ${JSON.stringify(jsPath || serverUrl)},
131
- css: ${JSON.stringify(cssPath || serverUrl)},
132
- i18n: ${JSON.stringify(i18nJsPath || serverUrl)}
133
- };
129
+
130
+ function getAssetUrl(ext) {
131
+ ${cdnStatement ? `
132
+ return (() => {
133
+ let fu = (${cdnStatement});
134
+ return typeof fu === "function" ? fu(ext) : fu;
135
+ })();` : ''}
136
+
137
+ ${publicPaths.callback ? `return (${publicPaths.callback})(ext)` : ''}
138
+
139
+ let assetURLs = {
140
+ //hook
141
+ js: ${JSON.stringify(jsPath || serverUrl)},
142
+ css: ${JSON.stringify(cssPath || serverUrl)},
143
+ i18n: ${JSON.stringify(i18nJsPath || serverUrl)}
144
+ };
145
+
146
+ return assetURLs[ext];
147
+
148
+ }
149
+
134
150
 
135
151
  window.desk_urls={}
136
- window.desk_urls.staticDomain = 'https:' + assetURLs.js + '/';
152
+ window.desk_urls.staticDomain = 'https:' + getAssetUrl('js') + '/';
137
153
  if (prod && cdnVariableName) {
138
- window["${cdnVariableName}"] = 'https:' + assetURLs.css + '/';
154
+ window["${cdnVariableName}"] = 'https:' + getAssetUrl('css') + '/';
139
155
  }
140
156
 
141
157
  let initalI18nAssets = ${initalI18nAssets}.map(urlpath => "${i18nJsPath}/"+ urlpath);
@@ -150,12 +166,12 @@ class EFCPlugin {
150
166
  switch(type) {
151
167
  case 'script':
152
168
  case 'i18n':
153
- el.src = (type === 'i18n'? assetURLs.i18n : assetURLs.js)+'/'+url
169
+ el.src = (type === 'i18n'? getAssetUrl('i18n') : getAssetUrl('js'))+'/'+url
154
170
  el.defer = 'defer';
155
171
  document.body.appendChild(el);
156
172
  break;
157
173
  case 'link':
158
- el.href = assetURLs.css+'/'+url${enableRTLSplit ? `.replace(${JSON.stringify(cssDirTemplate)}, cssDir)` : ''}
174
+ el.href = getAssetUrl('css')+'/'+url${enableRTLSplit ? `.replace(${JSON.stringify(cssDirTemplate)}, cssDir)` : ''}
159
175
  el.rel = 'stylesheet';
160
176
  document.head.appendChild(el);
161
177
  break;
@@ -21,6 +21,14 @@ let filenameParser = filename => {
21
21
  } = _path.default.parse(hashedName);
22
22
 
23
23
  let nameparts = name.split('.');
24
+
25
+ if (ext === '.css' && /^(rtl|ltr)$/.test(nameparts[nameparts.length - 1])) {
26
+ return {
27
+ name: nameparts.slice(0, nameparts.length - 2).join('.') + ext,
28
+ hashedName
29
+ };
30
+ }
31
+
24
32
  return {
25
33
  name: nameparts.slice(0, nameparts.length - 1).join('.') + ext,
26
34
  hashedName
@@ -47,6 +47,8 @@ var _default = {
47
47
  localeStatement: null,
48
48
  cssDirAttr: 'data-efc-dir',
49
49
  cssDirDefaultValue: 'ltr',
50
+ cdnStatement: '',
51
+ // cdnStatement: 'new URL(document.querySelector("script[src*=\'zohodesk-efc-sdk\']").src).origin',
50
52
  cssDirStatement: null
51
53
  },
52
54
  app: {
@@ -40,6 +40,13 @@ var _default = (unique = true, {
40
40
  filenames,
41
41
  packages
42
42
  }, classNamePrefix) => (context, localIdentName, localName) => {
43
+ // NOTE: in build macine we use date as folder path.
44
+ // So every time we create new build there is path will alway different
45
+ // in order to minmaze that problem we try in relative path;
46
+ // console.log('context.resourcePath', context.resourcePath, context);
47
+ // let contextResourcePath = context.resourcePath;
48
+ let relativePath = _path.default.relative(context.rootContext, context.resourcePath);
49
+
43
50
  if (context.resourcePath.endsWith('.plain.css')) {
44
51
  return localName;
45
52
  }
@@ -47,7 +54,7 @@ var _default = (unique = true, {
47
54
 
48
55
 
49
56
  if (unique) {
50
- let h = (0, _getHash.default)(context.resourcePath + localName, 10);
57
+ let h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
51
58
  return `${classNamePrefix}${h}`;
52
59
  }
53
60
  /* old production mode end*/
@@ -60,7 +67,7 @@ var _default = (unique = true, {
60
67
  //let local = localName.toLowerCase()
61
68
 
62
69
  if (isSelectorPackage(context.resourcePath, packages) || filenames.indexOf(cleanFileName) !== -1) {
63
- let h = (0, _getHash.default)(context.resourcePath + localName, 10);
70
+ let h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
64
71
  return `${classNamePrefix}${h}`;
65
72
  }
66
73
 
@@ -39,15 +39,14 @@ let fileHandler = {
39
39
  }
40
40
  },
41
41
  writeFile: (path, data) => {
42
- let jsonStr = JSON.stringify(data);
43
- fs.writeFileSync(path, jsonStr);
44
- return jsonStr;
42
+ fs.writeFileSync(path, JSON.stringify(data));
43
+ return JSON.stringify(data);
45
44
  }
46
45
  };
47
46
  exports.fileHandler = fileHandler;
48
47
 
49
48
  let jsonConcate = (receiverObj, senterObj) => {
50
- Object.keys(senterObj).forEach(key => {
49
+ Object.keys(senterObj).map(key => {
51
50
  if (Object.prototype.hasOwnProperty.call(receiverObj, key)) {
52
51
  if (receiverObj[key].constructor === {}.constructor && senterObj[key].constructor === {}.constructor) {
53
52
  jsonConcate(receiverObj[key], senterObj[key]);
@@ -59,6 +58,8 @@ let jsonConcate = (receiverObj, senterObj) => {
59
58
  } else {
60
59
  receiverObj[key] = senterObj[key];
61
60
  }
61
+
62
+ return key;
62
63
  });
63
64
  return receiverObj;
64
65
  };
@@ -72,10 +73,12 @@ let jsonHelper = (path, pathArray, value) => {
72
73
  pathArray = pathArray.split('.'); //eslint-disable-line no-param-reassign
73
74
  }
74
75
 
75
- pathArray.slice(0).reverse().forEach(key => {
76
+ pathArray.slice(0).reverse().map(key => {
76
77
  tempObj = {};
77
78
  tempObj[key] = value;
78
79
  value = tempObj; // eslint-disable-line no-param-reassign
80
+
81
+ return key;
79
82
  });
80
83
  let overAllObj = jsonConcate(JSON.parse(fileHandler.readFile(path)), tempObj);
81
84
  fileHandler.writeFile(path, overAllObj);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/react-cli",
3
- "version": "0.0.1-exp.160.3",
3
+ "version": "0.0.1-exp.161.1",
4
4
  "description": "A CLI tool for build modern web application and libraries",
5
5
  "scripts": {
6
6
  "init": "node ./lib/utils/init.js",
@@ -55,6 +55,7 @@
55
55
  "copy-webpack-plugin": "5.1.2",
56
56
  "core-js": "3.6.5",
57
57
  "css-loader": "4.2.1",
58
+ "debug": "4.3.3",
58
59
  "escodegen": "2.0.0",
59
60
  "eslint": "7.6.0",
60
61
  "eslint-html-reporter": "0.7.4",
@@ -93,9 +94,9 @@
93
94
  "postcss-loader": "3.0.0",
94
95
  "postcss-selector-replace": "1.0.2",
95
96
  "prop-types": "15.7.2",
96
- "react": "16.13.1",
97
+ "react": "^16.8.6",
97
98
  "react-dev-utils": "10.2.1",
98
- "react-dom": "16.13.1",
99
+ "react-dom": "^16.8.6",
99
100
  "react-error-overlay": "6.0.7",
100
101
  "react-redux": "7.2.1",
101
102
  "react-router": "5.2.0",
@@ -113,7 +114,6 @@
113
114
  "script-loader": "0.7.2",
114
115
  "selectn": "1.1.2",
115
116
  "simple-normalizr": "1.2.5",
116
- "speed-measure-webpack-plugin": "1.5.0",
117
117
  "uglifycss": "0.0.29",
118
118
  "url-loader": "4.1.0",
119
119
  "velocity-react": "1.4.3",
@@ -141,8 +141,5 @@
141
141
  ],
142
142
  "@babel/react"
143
143
  ]
144
- },
145
- "devDependencies": {
146
- "speed-measure-webpack-plugin": "1.5.0"
147
144
  }
148
145
  }