@zohodesk/react-cli 0.0.1-beta.160 → 0.0.1-beta.162.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/README.md CHANGED
@@ -1,39 +1,106 @@
1
1
  # React CLI
2
2
 
3
3
  A CLI tool for build modern web application and libraries
4
+
5
+ # 0.0.1-beta.162.1
6
+
7
+ - **Issue Fix:-**
8
+ - if git not installed react-cli throws error for any command due to `getCurrentBranch` in `shemas/index.js` now fixed
9
+
10
+ # 0.0.1-beta.161.1
11
+
12
+ - **Features :-**
13
+ - feature added for pre process logic
14
+ - tailer made requirement for preprocess, just write node js file
15
+ - mention file in `"react-cli" => "preprocess" => "runner"`
16
+ - option parse logic added for react-cli (exprimental)
17
+
18
+ # 0.0.1-beta.161
19
+
20
+ - **Features :-**
21
+ - feature added for efc `templateFilePath` in `package.json` option palce is `"react-cli" => "efc" `
22
+ - `(('publicPath'))` this placeholder will be replace as publicPath string `publicPath`
23
+ - `(('getInitalAssets'))` this placeholder will be replace as function `getInitalAssets`
24
+ - `getInitalAssets` this function has two arguments `assetsType`, `lang`
25
+ - `assetsType` are `js`, `css`, `i18n`
26
+ - `lang` this argument only works when `i18n` is `assetsType`
27
+ - feature added for efc `cdnStatement`
28
+ - **Issue fixes:-**
29
+ - css classname hash change issue fix
30
+ - debug package conflit issue fix in nock in (react-cli test)
31
+ - manifest.json css file name correction issue for rtl and ltr
32
+
33
+ # 0.0.1-exp.161.2
34
+
35
+ - Features
36
+ - feature added for efc `templateFilePath` in `package.json` option palce is `"react-cli" => "efc" `
37
+ - `(('publicPath'))` this placeholder will be replace as publicPath string `publicPath`
38
+ - `(('getInitalAssets'))` this placeholder will be replace as function `getInitalAssets`
39
+ - `getInitalAssets` this function has two arguments `assetsType`, `lang`
40
+ - `assetsType` are `js`, `css`, `i18n`
41
+ - `lang` this argument only works when `i18n` is `assetsType`
42
+
43
+ # 0.0.1-exp.161.1
44
+
45
+ - Features
46
+ - feature added for efc `cdnStatement`
47
+ - Issue fixes:-
48
+ - css classname hash change issue fix
49
+ - debug package conflit issue fix in nock in (react-cli test)
50
+ - manifest.json css file name correction issue for rtl and ltr
51
+
4
52
  # 0.0.1-beta.160
53
+
5
54
  - @zohodesk/normalizer package version updated to 1.0.2
55
+
6
56
  # 0.0.1-beta.159
57
+
7
58
  - @zohodesk/datetimejs package updated to beta.7
59
+
60
+ # 0.0.1-exp.159
61
+
62
+ - isse fix:-
63
+ - when rtl ltr css split enable manifest json css filename keys comes with hash .
64
+
8
65
  # 0.0.1-beta.158
9
- - Removing source map files from service worker caching.
66
+
67
+ - Removing source map files from service worker caching.
68
+
10
69
  # 0.0.1-beta.157
11
- - Experimental version issue fix(Dummy version removed)
70
+
71
+ - Experimental version issue fix(Dummy version removed)
72
+
12
73
  # 0.0.1-beta.156
13
- - ReportPublish issue fix
74
+
75
+ - ReportPublish issue fix
14
76
 
15
77
  # 0.0.1-beta.155
16
- - get impacted library source files option added
78
+
79
+ - get impacted library source files option added
17
80
 
18
81
  # 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
82
+
83
+ - mockPrefix option for mock url prefix change
84
+ - Issue fix:-
85
+ - un wanted {{--js-smap}} in inital html without enable smap in build
22
86
 
23
87
  # 0.0.1-beta.153
88
+
24
89
  - Vendor include array added
25
90
  - If you need to include any thrid party js in vendor we can use this array
26
91
 
27
92
  # 0.0.1-beta.152
93
+
28
94
  impact servise related changes:-
95
+
29
96
  - 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
97
  - cssselector_zip option added. will be used like `--cssselector-zip=selectormapping.zip`
31
98
  only work in two ways
32
99
  1. `react-cli start --disable-watch --cssselector-zip=selectormapping.zip` app start command with `--disable-watch` flag and your usaul options
33
100
  2. `react-cli nowatchstart --cssselector-zip=selectormapping.zip` app start command's usaul options
34
101
  #### 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)
102
+ Below express path are added, For download zip files and
103
+ - `/zips/${zipname}.zip` for css selector maps zip file (contains css_map filies and original css files)
37
104
  - `/zips/build.zip` build zip file (contains bundled all files)
38
105
 
39
106
  # 0.0.1-beta.151
package/bin/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  let path = require('path');
4
4
  let os = require('os');
5
- let { spawnSync } = require('child_process');
5
+ let { spawnSync, spawn } = require('child_process');
6
6
  let { getOptions } = require('../lib/utils/index.js');
7
7
 
8
8
  let { log } = require('../lib/utils');
@@ -42,8 +42,53 @@ let babel = getCliPath('babel');
42
42
  let propertyToJson = getCliPath('propertyToJson');
43
43
  let esLint = getCliPath('eslint');
44
44
 
45
+ let preprocesserPath = options.preprocessor.runner
46
+ ? path.join(process.cwd(), options.preprocessor.runner)
47
+ : '';
48
+
49
+ // console.log(
50
+ // 'options.app.preprocessor',
51
+ // options.preprocessor.runner,
52
+ // preprocesserPath
53
+ // );
54
+ if (preprocesserPath) {
55
+ // eslint-disable-next-line default-case
56
+ switch (option) {
57
+ case 'start':
58
+ case 'docs':
59
+ spawn(nodemon, [preprocesserPath], {
60
+ stdio: 'inherit',
61
+ cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
62
+ });
63
+ // NOTE: it's ok if we not close this here
64
+ // Because when node server stops this program willbe closed So this nodemon will be killed as well
65
+ break;
66
+ case 'nowatchstart':
67
+ case 'build:library:es':
68
+ case 'build:component:es':
69
+ case 'build:library:cmjs':
70
+ case 'build:component:cmjs':
71
+ spawnSync('node', [preprocesserPath], {
72
+ stdio: 'inherit',
73
+ cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
74
+ });
75
+ break;
76
+ }
77
+ }
78
+
45
79
  let result;
46
80
  switch (option) {
81
+ case 'preprocessor':
82
+ if (preprocesserPath) {
83
+ result = spawnSync(nodemon, [preprocesserPath], {
84
+ stdio: 'inherit',
85
+ cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
86
+ });
87
+ process.exit(result.status);
88
+ } else {
89
+ console.error('preProcessor not exists ');
90
+ }
91
+ break;
47
92
  case 'lint-setup': {
48
93
  result = spawnSync(
49
94
  'node',
@@ -0,0 +1,3 @@
1
+ Suggestions :
2
+
3
+ 1. 'lint-setup', 'add-lint-scripts' not need to exposed
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <title>mock api</title>
7
+ </head>
8
+ <body>
9
+ <h1>We are going to see how to use mock api</h1>
10
+ <ul>
11
+ <li>
12
+ Step 1:-
13
+ you need to start the app with "react-cli"."app"."server"."hasMock" as "true" in package.json
14
+ <code>npm run start --app-port=9090</code>
15
+ </li>
16
+ </ul>
17
+ </body>
18
+ </html>
@@ -0,0 +1,5 @@
1
+ # We are going to see how to use `Mock api`
2
+
3
+ - Step 1:-
4
+ you need to start the app with **"react-cli"."app"."server"."hasMock"** as `true` and **"react-cli"."app"."server"."hasMock"** as `true` in package.json <code>npm run start --app-port=9090</code>
5
+ - Step 2:- you need to start the app with **"react-cli"."app"."server"."hasMock"** as `true` in package.json <code>npm run start --app-port=9090</code>
@@ -3,12 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "splitChunks", {
7
- enumerable: true,
8
- get: function () {
9
- return _splitChunks.default;
10
- }
11
- });
12
6
  Object.defineProperty(exports, "getEntries", {
13
7
  enumerable: true,
14
8
  get: function () {
@@ -21,6 +15,12 @@ Object.defineProperty(exports, "getPublicPathConfig", {
21
15
  return _getPublicPathConfig.default;
22
16
  }
23
17
  });
18
+ Object.defineProperty(exports, "splitChunks", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _splitChunks.default;
22
+ }
23
+ });
24
24
  Object.defineProperty(exports, "templateParameters", {
25
25
  enumerable: true,
26
26
  get: function () {
@@ -2,9 +2,17 @@
2
2
 
3
3
  var _path = _interopRequireDefault(require("path"));
4
4
 
5
+ var _libAlias = require("./libAlias");
6
+
5
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
8
 
7
- let appPath = process.cwd();
9
+ let appPath = process.cwd(); // '^@root(.*)$': '<rootDir>/src$1',
10
+ // '^@components(.*)$': '<rootDir>/src/components$1',
11
+
12
+ let moduleNameMapper = Object.keys(_libAlias.libAlias).reduce((previousValue, key) => {
13
+ previousValue[`^${key}(.*)$`] = `${moduleNameMapper[key]}$1`;
14
+ return previousValue;
15
+ }, {});
8
16
  let commonConfig = {
9
17
  coverageReporters: ['json', 'html', 'json-summary', 'text'],
10
18
  collectCoverage: true,
@@ -14,10 +22,11 @@ let commonConfig = {
14
22
  '^.+\\.css$': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'cssPreprocessor.js'),
15
23
  '^(?!.*\\.(js|jsx|css|json)$)': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'otherFilesPreprocessor.js')
16
24
  },
17
- moduleNameMapper: {
25
+ moduleNameMapper: { ...moduleNameMapper,
18
26
  '\\.(css|less)$': 'identity-obj-proxy'
19
27
  },
20
- transformIgnorePatterns: ['/node_modules.*?.js$'],
28
+ transformIgnorePatterns: ['/node_modules/(?!(@zohodesk)/)'],
29
+ // transformIgnorePatterns: ['/node_modules.*?.js$'],
21
30
  moduleFileExtensions: ['js'],
22
31
  setupFiles: [_path.default.resolve(appPath, '__testUtils__', 'globals.js'), _path.default.resolve(__dirname, '..', 'jest', 'setup.js')],
23
32
  globals: {
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.libAlias = void 0;
7
+ // the reason for alias at the time was code tree shaking
8
+ // tree shaking was most compactable with ES module system
9
+ // FIXME: But there is a posiblity when these package does not have lib,
10
+ // app will work because of alias, But may be jest won't work because of not alais
11
+ // So need to think about use alais in jest
12
+ const libAlias = {
13
+ '@zohodesk/components/lib': '@zohodesk/components/es',
14
+ // '@zohodesk/zc-custom/lib': '@zohodesk/zc-custom/es',
15
+ '@zohodesk/dot/lib': '@zohodesk/dot/es',
16
+ '@zohodesk/i18n/lib': '@zohodesk/i18n/es',
17
+ '@zohodesk/icons/lib': '@zohodesk/icons/es',
18
+ '@zohodesk/normalizer/lib': '@zohodesk/normalizer/es',
19
+ '@zohodesk/perf-components/lib': '@zohodesk/perf-components/es',
20
+ '@zohodesk/perf-middleware/lib': '@zohodesk/perf-middleware/es',
21
+ '@zohodesk/permissions/lib': '@zohodesk/permissions/es',
22
+ '@zohodesk/platform-middleware/lib': '@zohodesk/platform-middleware/es',
23
+ '@zohodesk/react-dnd/lib': '@zohodesk/react-dnd/es',
24
+ '@zohodesk/router-middleware/lib': '@zohodesk/router-middleware/es',
25
+ '@zohodesk/storage/lib': '@zohodesk/storage/es',
26
+ '@zohodesk/svg/lib': '@zohodesk/svg/es',
27
+ '@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
28
+ '@zohodesk/variables/lib': '@zohodesk/variables/es',
29
+ '@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
30
+ };
31
+ exports.libAlias = libAlias;
@@ -10,6 +10,8 @@ var _pluginUtils = require("../pluginUtils");
10
10
 
11
11
  var _loaderUtils = require("../loaderUtils");
12
12
 
13
+ var _libAlias = require("./libAlias");
14
+
13
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
16
 
15
17
  let options = (0, _utils.getOptions)();
@@ -55,6 +57,9 @@ module.exports = {
55
57
  entry: (0, _common.getEntries)(options, 'dev'),
56
58
  devtool: sourcemap,
57
59
  mode: 'development',
60
+ watchOptions: {
61
+ ignored: /node_modules.(?!@zohodesk)/
62
+ },
58
63
  output,
59
64
  stats: options.app.disableWatch ? 'errors-only' : {
60
65
  children: false
@@ -127,25 +132,7 @@ module.exports = {
127
132
  },
128
133
  resolve: {
129
134
  modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
130
- alias: disableES5Transpile ? {
131
- '@zohodesk/components/lib': '@zohodesk/components/es',
132
- // "@zohodesk/zc-custom/lib": "@zohodesk/zc-custom/es",
133
- '@zohodesk/dot/lib': '@zohodesk/dot/es',
134
- '@zohodesk/i18n/lib': '@zohodesk/i18n/es',
135
- '@zohodesk/icons/lib': '@zohodesk/icons/es',
136
- '@zohodesk/normalizer/lib': '@zohodesk/normalizer/es',
137
- '@zohodesk/perf-components/lib': '@zohodesk/perf-components/es',
138
- '@zohodesk/perf-middleware/lib': '@zohodesk/perf-middleware/es',
139
- '@zohodesk/permissions/lib': '@zohodesk/permissions/es',
140
- '@zohodesk/platform-middleware/lib': '@zohodesk/platform-middleware/es',
141
- '@zohodesk/react-dnd/lib': '@zohodesk/react-dnd/es',
142
- '@zohodesk/router-middleware/lib': '@zohodesk/router-middleware/es',
143
- '@zohodesk/storage/lib': '@zohodesk/storage/es',
144
- '@zohodesk/svg/lib': '@zohodesk/svg/es',
145
- '@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
146
- '@zohodesk/variables/lib': '@zohodesk/variables/es',
147
- '@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
148
- } : {}
135
+ alias: disableES5Transpile ? _libAlias.libAlias : {}
149
136
  },
150
137
  resolveLoader: {
151
138
  modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
@@ -10,6 +10,8 @@ var _pluginUtils = require("../pluginUtils");
10
10
 
11
11
  var _loaderUtils = require("../loaderUtils");
12
12
 
13
+ var _libAlias = require("./libAlias");
14
+
13
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
16
 
15
17
  let options = (0, _utils.getOptions)();
@@ -194,25 +196,7 @@ module.exports = {
194
196
  },
195
197
  resolve: {
196
198
  modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
197
- alias: disableES5Transpile ? {
198
- '@zohodesk/components/lib': '@zohodesk/components/es',
199
- // '@zohodesk/zc-custom/lib': '@zohodesk/zc-custom/es',
200
- '@zohodesk/dot/lib': '@zohodesk/dot/es',
201
- '@zohodesk/i18n/lib': '@zohodesk/i18n/es',
202
- '@zohodesk/icons/lib': '@zohodesk/icons/es',
203
- '@zohodesk/normalizer/lib': '@zohodesk/normalizer/es',
204
- '@zohodesk/perf-components/lib': '@zohodesk/perf-components/es',
205
- '@zohodesk/perf-middleware/lib': '@zohodesk/perf-middleware/es',
206
- '@zohodesk/permissions/lib': '@zohodesk/permissions/es',
207
- '@zohodesk/platform-middleware/lib': '@zohodesk/platform-middleware/es',
208
- '@zohodesk/react-dnd/lib': '@zohodesk/react-dnd/es',
209
- '@zohodesk/router-middleware/lib': '@zohodesk/router-middleware/es',
210
- '@zohodesk/storage/lib': '@zohodesk/storage/es',
211
- '@zohodesk/svg/lib': '@zohodesk/svg/es',
212
- '@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
213
- '@zohodesk/variables/lib': '@zohodesk/variables/es',
214
- '@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
215
- } : {}
199
+ alias: disableES5Transpile ? _libAlias.libAlias : {}
216
200
  },
217
201
  resolveLoader: {
218
202
  modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
@@ -3,16 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "getDevJsLoaders", {
6
+ Object.defineProperty(exports, "getCSSLoaders", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _getDevJsLoaders.default;
9
+ return _getCSSLoaders.default;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "getCSSLoaders", {
12
+ Object.defineProperty(exports, "getDevJsLoaders", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _getCSSLoaders.default;
15
+ return _getDevJsLoaders.default;
16
16
  }
17
17
  });
18
18
 
@@ -55,6 +55,7 @@ let getDevPlugins = (options, publicPath) => {
55
55
  },
56
56
  efc: {
57
57
  hasEFC: newOptionForEnableEFC,
58
+ templateFilePath,
58
59
  nameScope: efcNameSpace,
59
60
  localeAttr: efcLocaleAttr
60
61
  },
@@ -162,6 +163,7 @@ let getDevPlugins = (options, publicPath) => {
162
163
  plugins.push(new _plugins.EFCPlugin({
163
164
  isDevelopment: true,
164
165
  i18nManifestFileName,
166
+ templateFilePath,
165
167
  i18nFileNameTemplate,
166
168
  serverUrl: publicPath,
167
169
  entryPointName: 'efc',
@@ -72,6 +72,7 @@ let getProdPlugins = (options, publicPath = '') => {
72
72
  const {
73
73
  hasEFC: newOptionForEnableEFC,
74
74
  nameScope: efcNameSpace,
75
+ templateFilePath,
75
76
  localeAttr: efcLocaleAttr
76
77
  } = options.efc;
77
78
  const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
@@ -166,6 +167,7 @@ let getProdPlugins = (options, publicPath = '') => {
166
167
  isDevelopment,
167
168
  serverUrl: publicPath,
168
169
  i18nFileNameTemplate,
170
+ templateFilePath,
169
171
  i18nManifestFileName,
170
172
  entryPointName: 'efc',
171
173
  // outputFile: 'zohodesk-efc-sdk-latest.js',
@@ -9,34 +9,28 @@ Object.defineProperty(exports, "getDevPlugins", {
9
9
  return _getDevPlugins.default;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "getProdPlugins", {
13
- enumerable: true,
14
- get: function () {
15
- return _getProdPlugins.default;
16
- }
17
- });
18
12
  Object.defineProperty(exports, "getDocsPlugins", {
19
13
  enumerable: true,
20
14
  get: function () {
21
15
  return _getDocsPlugins.default;
22
16
  }
23
17
  });
24
- Object.defineProperty(exports, "getServerPlugins", {
18
+ Object.defineProperty(exports, "getLibraryPlugins", {
25
19
  enumerable: true,
26
20
  get: function () {
27
- return _getServerPlugins.default;
21
+ return _getLibraryPlugins.default;
28
22
  }
29
23
  });
30
- Object.defineProperty(exports, "getLibraryPlugins", {
24
+ Object.defineProperty(exports, "getProdPlugins", {
31
25
  enumerable: true,
32
26
  get: function () {
33
- return _getLibraryPlugins.default;
27
+ return _getProdPlugins.default;
34
28
  }
35
29
  });
36
- Object.defineProperty(exports, "getUMDComponentPlugins", {
30
+ Object.defineProperty(exports, "getServerPlugins", {
37
31
  enumerable: true,
38
32
  get: function () {
39
- return _getUMDComponentPlugins.default;
33
+ return _getServerPlugins.default;
40
34
  }
41
35
  });
42
36
  Object.defineProperty(exports, "getUMDCSSPlugins", {
@@ -45,6 +39,12 @@ Object.defineProperty(exports, "getUMDCSSPlugins", {
45
39
  return _getUMDCSSPlugins.default;
46
40
  }
47
41
  });
42
+ Object.defineProperty(exports, "getUMDComponentPlugins", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _getUMDComponentPlugins.default;
46
+ }
47
+ });
48
48
 
49
49
  var _getDevPlugins = _interopRequireDefault(require("./getDevPlugins"));
50
50
 
@@ -17,6 +17,8 @@ var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nK
17
17
 
18
18
  var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
19
19
 
20
+ var _EFCTemplatePlugin = _interopRequireDefault(require("./EFCTemplatePlugin"));
21
+
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
23
 
22
24
  // import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
@@ -34,17 +36,19 @@ const {
34
36
  efc: efcOptios
35
37
  } = cliOptions;
36
38
  const {
37
- createSDkFile
39
+ createSDkFile,
40
+ cdnStatement
38
41
  } = efcOptios;
39
42
 
40
43
  class EFCPlugin {
41
44
  constructor(options = {}) {
42
45
  this.isDevelopment = options.isDevelopment;
46
+ this.templateFilePath = options.templateFilePath;
43
47
  this.serverUrl = options.serverUrl;
44
48
  this.i18nFileNameTemplate = options.i18nFileNameTemplate; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
45
49
  // this.i18nManifestFileName = options.i18nManifestFileName;
46
50
  // IMPORTANT: here we mergeing optionds from pacakge.json and options via constructor
47
- // So when debugging consider this as well
51
+ // So when debugging consider this as well
48
52
 
49
53
  this.options = Object.assign({}, efcOptios, options);
50
54
  this.options.entryPointName = options.entryPointName || 'efc';
@@ -125,20 +129,35 @@ class EFCPlugin {
125
129
  ${enableRTLSplit ? `const cssDir = ${cssDirStatement};` : ''}
126
130
  const prod = !${this.isDevelopment};
127
131
  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
- };
132
+
133
+ function getAssetUrl(ext) {
134
+ ${cdnStatement ? `
135
+ return (() => {
136
+ let fu = (${cdnStatement});
137
+ return typeof fu === "function" ? fu(ext) : fu;
138
+ })();` : ''}
139
+
140
+ ${publicPaths.callback ? `return (${publicPaths.callback})(ext)` : ''}
141
+
142
+ let assetURLs = {
143
+ //hook
144
+ js: ${JSON.stringify(jsPath || serverUrl)},
145
+ css: ${JSON.stringify(cssPath || serverUrl)},
146
+ i18n: ${JSON.stringify(i18nJsPath || serverUrl)}
147
+ };
148
+
149
+ return assetURLs[ext];
150
+
151
+ }
152
+
134
153
 
135
154
  window.desk_urls={}
136
- window.desk_urls.staticDomain = 'https:' + assetURLs.js + '/';
155
+ window.desk_urls.staticDomain = 'https:' + getAssetUrl('js') + '/';
137
156
  if (prod && cdnVariableName) {
138
- window["${cdnVariableName}"] = 'https:' + assetURLs.css + '/';
157
+ window["${cdnVariableName}"] = 'https:' + getAssetUrl('css') + '/';
139
158
  }
140
159
 
141
- let initalI18nAssets = ${initalI18nAssets}.map(urlpath => "${i18nJsPath}/"+ urlpath);
160
+ let initalI18nAssets = ${initalI18nAssets};
142
161
  let initialAssets = initalI18nAssets.concat(${JSON.stringify(enableRTLSplit ? filteredInitialFiles.map(filePath => (0, _replaceCssDirTemplate.replaceCssDirTemplate)(filePath, cssDirTemplate)) : filteredInitialFiles)});
143
162
 
144
163
  let loadAsset = (id, type, url) => {
@@ -150,12 +169,12 @@ class EFCPlugin {
150
169
  switch(type) {
151
170
  case 'script':
152
171
  case 'i18n':
153
- el.src = (type === 'i18n'? assetURLs.i18n : assetURLs.js)+'/'+url
172
+ el.src = (type === 'i18n'? getAssetUrl('i18n') : getAssetUrl('js'))+'/'+url
154
173
  el.defer = 'defer';
155
174
  document.body.appendChild(el);
156
175
  break;
157
176
  case 'link':
158
- el.href = assetURLs.css+'/'+url${enableRTLSplit ? `.replace(${JSON.stringify(cssDirTemplate)}, cssDir)` : ''}
177
+ el.href = getAssetUrl('css')+'/'+url${enableRTLSplit ? `.replace(${JSON.stringify(cssDirTemplate)}, cssDir)` : ''}
159
178
  el.rel = 'stylesheet';
160
179
  document.head.appendChild(el);
161
180
  break;
@@ -186,6 +205,17 @@ class EFCPlugin {
186
205
  apply(compiler) {
187
206
  if (!createSDkFile) {
188
207
  return;
208
+ } //console.log('this.templateFilePath', this.templateFilePath, this.options);
209
+
210
+
211
+ if (this.templateFilePath) {
212
+ new _EFCTemplatePlugin.default({
213
+ templateFilePath: this.templateFilePath,
214
+ publicPath: this.serverUrl,
215
+ i18nFileNameTemplate: this.i18nFileNameTemplate,
216
+ entryPointName: this.options.entryPointName
217
+ }).apply(compiler);
218
+ return;
189
219
  }
190
220
 
191
221
  compiler.hooks.emit.tap('EFCPlugin', compilation => {
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _webpackSources = require("webpack-sources");
9
+
10
+ var _utils = require("../utils");
11
+
12
+ var _path = _interopRequireDefault(require("path"));
13
+
14
+ var _fs = require("fs");
15
+
16
+ var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
17
+
18
+ var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nKeysIdentifer"));
19
+
20
+ var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
24
+ // import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
25
+ const cliOptions = (0, _utils.getOptions)();
26
+ const {
27
+ i18n: {
28
+ chunkSplitEnable
29
+ },
30
+ css: {
31
+ enableRTLSplit
32
+ },
33
+ efc: efcOptios
34
+ } = cliOptions;
35
+ const {
36
+ createSDkFile
37
+ } = efcOptios; // for smap relate changes
38
+ // CdnChangePlugin
39
+ // SourceMapHookPlugin
40
+
41
+ class EFCTemplatePlugin {
42
+ constructor(options = {}) {
43
+ // console.log(' templateFilePath ', process.cwd(), options.templateFilePath, templateFilePath);
44
+ this.templateFilePath = _path.default.join(process.cwd(), options.templateFilePath); // console.log(' templateFilePath ', this.templateFilePath);
45
+
46
+ this.i18nFileNameTemplate = options.i18nFileNameTemplate;
47
+ this.publicPath = options.publicPath; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
48
+ // this.i18nManifestFileName = options.i18nManifestFileName;
49
+ // IMPORTANT: here we mergeing optionds from pacakge.json and options via constructor
50
+ // So when debugging consider this as well
51
+ // this.options = Object.assign({}, efcOptios, options);
52
+
53
+ this.entryPointName = options.entryPointName || 'efc';
54
+ this.outputFile = efcOptios.outputFile.replace('[version]', efcOptios.version);
55
+ } // NOTE: this logic may be needed for i18n splited file name with contenthash cases
56
+ // getI18nManifest(compilation) {
57
+ // const i18nManifestFile =
58
+ // compilation.assets[this.options.i18nManifestFileName];
59
+ // if (i18nManifestFile) {
60
+ // const manifest = JSON.parse(i18nManifestFile.source());
61
+ // return manifest;
62
+ // }
63
+ // return {};
64
+ // }
65
+
66
+
67
+ getI18nAssetsStr(entryPoint, compilation) {
68
+ // NOTE: we have used lang variable inside
69
+ if (!chunkSplitEnable) {
70
+ let i18nAsstes = {};
71
+ let i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1); //hook for i18n url contains i18n/ may cause problem
72
+
73
+ i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
74
+ let fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
75
+ let splittedFileName = fileName.split('.');
76
+ res[splittedFileName[0]] = i18nFilePath;
77
+ return res;
78
+ }, {});
79
+ return `[${JSON.stringify(i18nAsstes)}[lang]]`;
80
+ }
81
+
82
+ let initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
83
+ return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
84
+ }
85
+
86
+ templateReplacer(entryPoint, compilation) {
87
+ const cssDirTemplate = '@dir@'; // const i18nManifest = this.getI18nManifest(compilation);
88
+
89
+ const initialFiles = entryPoint.getFiles();
90
+ const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file));
91
+ const initialJsFiles = filteredInitialFiles.filter(file => /\.js$/.test(file));
92
+ let initialCssFiles = filteredInitialFiles.filter(file => /\.css$/.test(file));
93
+
94
+ if (enableRTLSplit) {
95
+ initialCssFiles = initialCssFiles.map(filePath => (0, _replaceCssDirTemplate.replaceCssDirTemplate)(filePath, cssDirTemplate));
96
+ } // const i18nAssets = getShortI18nAssets(
97
+ // entryPoint.chunks,
98
+ // i18nManifest,
99
+ // '' // i18nJsPath
100
+ // );
101
+
102
+
103
+ const initalI18nAssets = this.getI18nAssetsStr(entryPoint, compilation, '' // i18nJsPath
104
+ );
105
+ let templateStr = (0, _fs.readFileSync)(this.templateFilePath).toString();
106
+ return templateStr.replace('((\'getInitalAssets\'))', `function getInitalAssets(assetsType, lang) {
107
+ if (assetsType === "js") {
108
+ return ${JSON.stringify(initialJsFiles)}
109
+ }
110
+ if (assetsType === "css") {
111
+ return ${JSON.stringify(initialCssFiles)}
112
+ }
113
+ if (assetsType === "i18n") {
114
+ return ${initalI18nAssets};
115
+ }
116
+ return [];
117
+ }`).replace('((\'@dir@\'))', '\'@dir@\'').replace('((\'publicPath\'))', this.publicPath).replace('((\'@locale@\'))', '\'@locale@\'');
118
+ }
119
+
120
+ apply(compiler) {
121
+ if (!createSDkFile) {
122
+ return;
123
+ }
124
+
125
+ compiler.hooks.emit.tap('EFCTemplatePlugin', compilation => {
126
+ const {
127
+ entryPointName,
128
+ outputFile
129
+ } = this;
130
+ const entryPoint = compilation.entrypoints.get(entryPointName);
131
+
132
+ if (!entryPoint) {
133
+ return;
134
+ }
135
+
136
+ if (!(0, _fs.existsSync)(this.templateFilePath)) {
137
+ console.error(`EFC Template file not exists ${this.templateFilePath}`);
138
+ return;
139
+ }
140
+
141
+ const source = new _webpackSources.RawSource(this.templateReplacer(entryPoint, compilation));
142
+ compilation.assets[outputFile] = source; // console.log('EFCTemplatePlugin working');
143
+ // eslint-disable-next-line no-console
144
+
145
+ console.log('The EFC embedded code was created successfully..!!!');
146
+ });
147
+ }
148
+
149
+ }
150
+
151
+ exports.default = EFCTemplatePlugin;
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.hasContentHash = hasContentHash;
7
- exports.getShortI18nAssets = getShortI18nAssets;
8
6
  exports.REGEXP_CONTENTHASH = void 0;
7
+ exports.getShortI18nAssets = getShortI18nAssets;
8
+ exports.hasContentHash = hasContentHash;
9
9
 
10
10
  var _urlConcat = require("../../../utils/urlConcat");
11
11
 
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getPropertiesAsJSON = getPropertiesAsJSON;
7
6
  exports.getAllI18n = getAllI18n;
7
+ exports.getPropertiesAsJSON = getPropertiesAsJSON;
8
8
  exports.jsonToString = jsonToString;
9
9
 
10
10
  var _fs = require("fs");
@@ -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
@@ -3,88 +3,82 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "ModuleStatsPlugin", {
7
- enumerable: true,
8
- get: function () {
9
- return _ModuleStatsPlugin.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "SourceMapHookPlugin", {
6
+ Object.defineProperty(exports, "CdnChangePlugin", {
13
7
  enumerable: true,
14
8
  get: function () {
15
- return _SourceMapHookPlugin.default;
9
+ return _CdnChangePlugin.default;
16
10
  }
17
11
  });
18
- Object.defineProperty(exports, "UnusedFilesFindPlugin", {
12
+ Object.defineProperty(exports, "CleanUpStatsPlugin", {
19
13
  enumerable: true,
20
14
  get: function () {
21
- return _UnusedFilesFindPlugin.default;
15
+ return _CleanupStatsPlugin.default;
22
16
  }
23
17
  });
24
- Object.defineProperty(exports, "ScriptInstrumentPlugin", {
18
+ Object.defineProperty(exports, "EFCPlugin", {
25
19
  enumerable: true,
26
20
  get: function () {
27
- return _ScriptInstrumentPlugin.default;
21
+ return _EFCPlugin.default;
28
22
  }
29
23
  });
30
- Object.defineProperty(exports, "PublicPathChangePlugin", {
24
+ Object.defineProperty(exports, "I18NInjectIntoIndexPlugin", {
31
25
  enumerable: true,
32
26
  get: function () {
33
- return _PublicPathChangePlugin.default;
27
+ return _I18NInjectIntoIndexPlugin.default;
34
28
  }
35
29
  });
36
- Object.defineProperty(exports, "OptimizeJSPlugin", {
30
+ Object.defineProperty(exports, "ManifestPlugin", {
37
31
  enumerable: true,
38
32
  get: function () {
39
- return _OptimizeJSPlugin.default;
33
+ return _ManifestPlugin.default;
40
34
  }
41
35
  });
42
- Object.defineProperty(exports, "ResourceHintsPlugin", {
36
+ Object.defineProperty(exports, "ModuleStatsPlugin", {
43
37
  enumerable: true,
44
38
  get: function () {
45
- return _ResourceHintsPlugin.default;
39
+ return _ModuleStatsPlugin.default;
46
40
  }
47
41
  });
48
- Object.defineProperty(exports, "UglifyCSSPlugin", {
42
+ Object.defineProperty(exports, "OptimizeJSPlugin", {
49
43
  enumerable: true,
50
44
  get: function () {
51
- return _UglifyCSSPlugin.default;
45
+ return _OptimizeJSPlugin.default;
52
46
  }
53
47
  });
54
- Object.defineProperty(exports, "ManifestPlugin", {
48
+ Object.defineProperty(exports, "PublicPathCallbackPlugin", {
55
49
  enumerable: true,
56
50
  get: function () {
57
- return _ManifestPlugin.default;
51
+ return _PublicPathCallbackPlugin.default;
58
52
  }
59
53
  });
60
- Object.defineProperty(exports, "CleanUpStatsPlugin", {
54
+ Object.defineProperty(exports, "PublicPathChangePlugin", {
61
55
  enumerable: true,
62
56
  get: function () {
63
- return _CleanupStatsPlugin.default;
57
+ return _PublicPathChangePlugin.default;
64
58
  }
65
59
  });
66
- Object.defineProperty(exports, "EFCPlugin", {
60
+ Object.defineProperty(exports, "ReportGeneratePlugin", {
67
61
  enumerable: true,
68
62
  get: function () {
69
- return _EFCPlugin.default;
63
+ return _ReportGeneratePlugin.default;
70
64
  }
71
65
  });
72
- Object.defineProperty(exports, "PublicPathCallbackPlugin", {
66
+ Object.defineProperty(exports, "ResourceHintsPlugin", {
73
67
  enumerable: true,
74
68
  get: function () {
75
- return _PublicPathCallbackPlugin.default;
69
+ return _ResourceHintsPlugin.default;
76
70
  }
77
71
  });
78
- Object.defineProperty(exports, "I18NInjectIntoIndexPlugin", {
72
+ Object.defineProperty(exports, "ScriptInstrumentPlugin", {
79
73
  enumerable: true,
80
74
  get: function () {
81
- return _I18NInjectIntoIndexPlugin.default;
75
+ return _ScriptInstrumentPlugin.default;
82
76
  }
83
77
  });
84
- Object.defineProperty(exports, "ReportGeneratePlugin", {
78
+ Object.defineProperty(exports, "ServiceWorkerPlugin", {
85
79
  enumerable: true,
86
80
  get: function () {
87
- return _ReportGeneratePlugin.default;
81
+ return _ServiceWorkerPlugin.default;
88
82
  }
89
83
  });
90
84
  Object.defineProperty(exports, "ShadowDOMSupportPlugin", {
@@ -93,10 +87,10 @@ Object.defineProperty(exports, "ShadowDOMSupportPlugin", {
93
87
  return _ShadowDOMSupportPlugin.default;
94
88
  }
95
89
  });
96
- Object.defineProperty(exports, "ServiceWorkerPlugin", {
90
+ Object.defineProperty(exports, "SourceMapHookPlugin", {
97
91
  enumerable: true,
98
92
  get: function () {
99
- return _ServiceWorkerPlugin.default;
93
+ return _SourceMapHookPlugin.default;
100
94
  }
101
95
  });
102
96
  Object.defineProperty(exports, "TPHashMappingPlugin", {
@@ -105,10 +99,16 @@ Object.defineProperty(exports, "TPHashMappingPlugin", {
105
99
  return _TPHashMappingPlugin.default;
106
100
  }
107
101
  });
108
- Object.defineProperty(exports, "CdnChangePlugin", {
102
+ Object.defineProperty(exports, "UglifyCSSPlugin", {
109
103
  enumerable: true,
110
104
  get: function () {
111
- return _CdnChangePlugin.default;
105
+ return _UglifyCSSPlugin.default;
106
+ }
107
+ });
108
+ Object.defineProperty(exports, "UnusedFilesFindPlugin", {
109
+ enumerable: true,
110
+ get: function () {
111
+ return _UnusedFilesFindPlugin.default;
112
112
  }
113
113
  });
114
114
 
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.separateSingleDir = separateSingleDir;
7
6
  exports.separateRtlAndLtr = separateRtlAndLtr;
7
+ exports.separateSingleDir = separateSingleDir;
8
8
 
9
9
  var postcss = _interopRequireWildcard(require("postcss"));
10
10
 
@@ -18,6 +18,12 @@ var _default = {
18
18
  value: null,
19
19
  cli: 'ssl_cert_url'
20
20
  },
21
+ preprocessor: {
22
+ runner: {
23
+ value: '',
24
+ cli: 'preprocessor'
25
+ }
26
+ },
21
27
  i18n: {
22
28
  chunkSplitEnable: {
23
29
  value: false,
@@ -42,11 +48,14 @@ var _default = {
42
48
  nameScope: 'ZOHODESK',
43
49
  version: 'default',
44
50
  outputFile: 'zohodesk-efc-sdk-[version].js',
51
+ templateFilePath: '',
45
52
  localeAttr: 'data-efc-locale',
46
53
  localeDefaultValue: 'en_US',
47
54
  localeStatement: null,
48
55
  cssDirAttr: 'data-efc-dir',
49
56
  cssDirDefaultValue: 'ltr',
57
+ cdnStatement: '',
58
+ // cdnStatement: "new URL(document.querySelector(\"script[src*='zohodesk-efc-sdk']\").src).origin",
50
59
  cssDirStatement: null
51
60
  },
52
61
  app: {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.endTag = exports.htmlTemplate = void 0;
6
+ exports.htmlTemplate = exports.endTag = void 0;
7
7
  const htmlTemplate = '<!DOCTYPE html><html> <head> <title>Eslint Security Rule</title> <style type="text/css"> body{margin: 0; font: 93.75%/1.6 -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif;}body, html{width: 100%; height: 100%;}.pkCont{}.pkEmpty{height: 300px;display: flex;align-items: center;justify-content: center;font-size: 20px;}.pkUl{margin: 0; padding: 0; list-style-type: none;}.pkLi{}.pkRow{display: flex; padding: 12px 16px;}.pkArrowCont{cursor: pointer; width: 50px; display: flex; align-items: center; justify-content: center; background-color: #f4f5f5; border-radius: 4px;}.pkArrow{width: 1px; height: 1px; border: 5px solid; border-color: #000 transparent transparent; margin-top: 7px;}.pkDetailsOpen .pkArrow{margin: 0 0 7px; border-color: transparent transparent #000;}.pkFileName{font-weight: 600; margin: 0 8px;}.pkUrl{flex: 1; min-width: 0; min-height: 0; word-break: break-word; word-wrap: break-word; color: blue;}.pkDetails{margin-left: 66px; display: none;}.pkDetailsOpen .pkDetails{display: block;}.pkDetailsHead{font-weight: 600; display: flex; border: 1px solid #e5e5e5; padding: 3px 8px;}.pkDetailsBody{max-height: 400px; overflow: auto;}.pkDetailsRow{display: flex; padding: 10px 8px;}.pkDetailsRow:nth-child(even){background-color: #f4f5f5;}.pkDetailsCol{word-break: break-word; word-wrap: break-word;}.pkError{color: red;}.pkDetailsCol:nth-child(1){width: 10%;}.pkDetailsCol:nth-child(2){width: 10%;}.pkDetailsCol:nth-child(3){width: 40%;}.pkDetailsCol:nth-child(4){width: 40%;}</style> <script>function toggleWrapper(element){var classArray=element.parentElement.parentElement.className; if (classArray.includes("pkDetailsOpen")){element.parentElement.parentElement.className="pkLi";}else{element.parentElement.parentElement.className="pkLi pkDetailsOpen";}}</script> </head> <body> <div class="pkCont">';
8
8
  exports.htmlTemplate = htmlTemplate;
9
9
  const endTag = '</div></body></html>';
@@ -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
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.cssUrlReplacer = exports.getUrls = exports.getFileType = void 0;
6
+ exports.getUrls = exports.getFileType = exports.cssUrlReplacer = void 0;
7
7
 
8
8
  var _fs = _interopRequireDefault(require("fs"));
9
9
 
@@ -22,7 +22,7 @@ var _default = (type = 'git', cwd = process.cwd()) => {
22
22
  });
23
23
  }
24
24
 
25
- let [currentBranch] = results.output.filter(d => d);
25
+ let [currentBranch] = results && results.output ? results.output.filter(d => d) : [''];
26
26
  return currentBranch.replace(/(\r\n|\n|\r)/gm, '');
27
27
  };
28
28
 
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ var _child_process = require("child_process");
9
+
8
10
  var _fs = _interopRequireDefault(require("fs"));
9
11
 
10
12
  var _path = _interopRequireDefault(require("path"));
@@ -13,6 +15,9 @@ var _schemas = _interopRequireDefault(require("../schemas"));
13
15
 
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
17
 
18
+ // import { argv } from 'process';
19
+ let args = process.argv.slice(2); // console.log('argv', argv);
20
+
16
21
  const NPM_CONFIG_PREFIX = 'npm_config_'; // TODO: we have to do option parse logic little better
17
22
  // if user use react-cli stritly without using npm scripts options won't work,
18
23
  // So we have to write our own option parse logic or some other library
@@ -37,6 +42,51 @@ keysWithColon.forEach(key => {
37
42
  processEnv[nkey] = processEnv[key];
38
43
  });
39
44
 
45
+ function getNpmVersion() {
46
+ // require("child_process").
47
+ let vers = '6';
48
+
49
+ try {
50
+ [vers] = (0, _child_process.execSync)('npm -v').toString().trim().split('.');
51
+ } catch (error) {
52
+ console.log(error);
53
+ }
54
+
55
+ return vers;
56
+ }
57
+
58
+ function getCWD() {
59
+ // require("child_process").
60
+ let cwd = process.cwd();
61
+
62
+ try {
63
+ let ress = (0, _child_process.execSync)('npm bin').toString();
64
+ let i = ress.lastIndexOf('node_modules');
65
+ cwd = i === -1 ? cwd : ress.slice(0, ress.lastIndexOf('node_modules'));
66
+ } catch (error) {
67
+ console.log(error);
68
+ }
69
+
70
+ return cwd;
71
+ }
72
+
73
+ args.forEach(option => {
74
+ if (/^--./.test(option)) {
75
+ let equIndex = option.indexOf('='); // equIndex = equIndex === -1 ? option.length : equIndex;
76
+
77
+ let key = option.slice(2, equIndex);
78
+ let value = option.slice(equIndex + 1);
79
+
80
+ if (equIndex === -1) {
81
+ key = option.slice(2);
82
+ value = true;
83
+ }
84
+
85
+ key = key.replace(/-/g, '_').replace(/:/g, '_');
86
+ processEnv[key] = value;
87
+ }
88
+ });
89
+
40
90
  let defaulter = (target, source) => {
41
91
  let defaultObject = {};
42
92
  Object.keys(target).forEach(key => {
@@ -88,6 +138,8 @@ let getOptions = () => {
88
138
  }
89
139
 
90
140
  let options = defaulter(_schemas.default, userSchemas || {});
141
+ options.npmVersion = getNpmVersion();
142
+ options.cwd = getCWD();
91
143
  options.packageVersion = process.env.npm_package_version;
92
144
  global.reactCLIOptions = options;
93
145
  return options;
@@ -21,22 +21,16 @@ var _exportNames = {
21
21
  getComponents: true,
22
22
  ssTestHack: true
23
23
  };
24
- Object.defineProperty(exports, "getOptions", {
25
- enumerable: true,
26
- get: function () {
27
- return _getOptions.default;
28
- }
29
- });
30
24
  Object.defineProperty(exports, "createEventStream", {
31
25
  enumerable: true,
32
26
  get: function () {
33
27
  return _createEventStream.default;
34
28
  }
35
29
  });
36
- Object.defineProperty(exports, "getServerURL", {
30
+ Object.defineProperty(exports, "getComponents", {
37
31
  enumerable: true,
38
32
  get: function () {
39
- return _getServerURL.default;
33
+ return _getComponents.default;
40
34
  }
41
35
  });
42
36
  Object.defineProperty(exports, "getCurrentBranch", {
@@ -45,22 +39,23 @@ Object.defineProperty(exports, "getCurrentBranch", {
45
39
  return _getCurrentBranch.default;
46
40
  }
47
41
  });
48
- Object.defineProperty(exports, "switchBranch", {
42
+ Object.defineProperty(exports, "getDependenciesImpactList", {
49
43
  enumerable: true,
50
44
  get: function () {
51
- return _switchBranch.default;
45
+ return _getDependenciesImpactList.default;
52
46
  }
53
47
  });
54
- Object.defineProperty(exports, "pullOrigin", {
48
+ exports.getLibraryConflict = exports.getInfoFromPublicPaths = void 0;
49
+ Object.defineProperty(exports, "getOptions", {
55
50
  enumerable: true,
56
51
  get: function () {
57
- return _pullOrigin.default;
52
+ return _getOptions.default;
58
53
  }
59
54
  });
60
- Object.defineProperty(exports, "request", {
55
+ Object.defineProperty(exports, "getServerURL", {
61
56
  enumerable: true,
62
57
  get: function () {
63
- return _request.default;
58
+ return _getServerURL.default;
64
59
  }
65
60
  });
66
61
  Object.defineProperty(exports, "jsonHelper", {
@@ -69,16 +64,17 @@ Object.defineProperty(exports, "jsonHelper", {
69
64
  return _jsonHelper.default;
70
65
  }
71
66
  });
72
- Object.defineProperty(exports, "getDependenciesImpactList", {
67
+ exports.makeDir = exports.log = void 0;
68
+ Object.defineProperty(exports, "pullOrigin", {
73
69
  enumerable: true,
74
70
  get: function () {
75
- return _getDependenciesImpactList.default;
71
+ return _pullOrigin.default;
76
72
  }
77
73
  });
78
- Object.defineProperty(exports, "getComponents", {
74
+ Object.defineProperty(exports, "request", {
79
75
  enumerable: true,
80
76
  get: function () {
81
- return _getComponents.default;
77
+ return _request.default;
82
78
  }
83
79
  });
84
80
  Object.defineProperty(exports, "ssTestHack", {
@@ -87,7 +83,13 @@ Object.defineProperty(exports, "ssTestHack", {
87
83
  return _ssTestHack.default;
88
84
  }
89
85
  });
90
- exports.getLibraryConflict = exports.getInfoFromPublicPaths = exports.makeDir = exports.writeFile = exports.log = void 0;
86
+ Object.defineProperty(exports, "switchBranch", {
87
+ enumerable: true,
88
+ get: function () {
89
+ return _switchBranch.default;
90
+ }
91
+ });
92
+ exports.writeFile = void 0;
91
93
 
92
94
  var _stream = require("stream");
93
95
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setTestInfoStatus = exports.jsonHelper = exports.jsonConcate = exports.fileHandler = exports.getRunnerDetail = void 0;
6
+ exports.setTestInfoStatus = exports.jsonHelper = exports.jsonConcate = exports.getRunnerDetail = exports.fileHandler = void 0;
7
7
 
8
8
  let fs = require('fs');
9
9
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.reinstallDependencies = exports.reinstallDependencies1 = exports.collectPackageDiff = void 0;
6
+ exports.reinstallDependencies1 = exports.reinstallDependencies = exports.collectPackageDiff = void 0;
7
7
 
8
8
  var _fs = _interopRequireDefault(require("fs"));
9
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/react-cli",
3
- "version": "0.0.1-beta.160",
3
+ "version": "0.0.1-beta.162.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",
@@ -94,7 +95,6 @@
94
95
  "postcss-selector-replace": "1.0.2",
95
96
  "prop-types": "15.7.2",
96
97
  "react": "16.13.1",
97
- "react-dev-utils": "10.2.1",
98
98
  "react-dom": "16.13.1",
99
99
  "react-error-overlay": "6.0.7",
100
100
  "react-redux": "7.2.1",
@@ -117,7 +117,7 @@
117
117
  "url-loader": "4.1.0",
118
118
  "velocity-react": "1.4.3",
119
119
  "webpack": "4.44.1",
120
- "webpack-bundle-analyzer": "3.8.0",
120
+ "webpack-bundle-analyzer": "4.5.0",
121
121
  "webpack-cli": "3.3.12",
122
122
  "webpack-core": "0.6.9",
123
123
  "webpack-dev-middleware": "3.7.2",