@elliemae/pui-cli 6.5.3 → 6.5.4

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.
@@ -1,9 +1,8 @@
1
1
  const path = require('path');
2
+ const normalizePath = require('normalize-path');
2
3
  const { getAppConfig, getAssetPath } = require('../webpack/helpers');
3
4
  const swcrcConfig = require('../transpile/swcrc.config.js');
4
-
5
- const name = '@elliemae/pui-cli';
6
- const rootDir = path.join('<rootDir>', 'node_modules', name);
5
+ const { findPnpmWorkspaceDir } = require('../monorepo/utils');
7
6
 
8
7
  let isReactModule = true;
9
8
  try {
@@ -15,19 +14,16 @@ try {
15
14
  isReactModule = false;
16
15
  }
17
16
 
18
- const getRootDir = () => {
19
- try {
20
- // eslint-disable-next-line global-require
21
- const { name: consumerName } = require(path.join(
22
- process.cwd(),
23
- 'package.json',
24
- ));
25
- return consumerName === name ? '<rootDir>' : rootDir;
26
- } catch (ex) {
27
- // eslint-disable-next-line no-console
28
- console.log(ex);
29
- return '<rootDir>';
30
- }
17
+ const getMockFilePath = (fileName) =>
18
+ normalizePath(path.resolve(__dirname, './mocks', fileName));
19
+
20
+ const getNodeModulesPath = (fileName) => {
21
+ const monorepoRoot = findPnpmWorkspaceDir(process.cwd());
22
+ return normalizePath(
23
+ monorepoRoot
24
+ ? path.join(monorepoRoot, 'node_modules', fileName)
25
+ : `<rootDir>/node_modules/${fileName}`,
26
+ );
31
27
  };
32
28
 
33
29
  const jestConfig = {
@@ -59,23 +55,25 @@ const jestConfig = {
59
55
  coverageReporters: ['lcov', 'html', 'text-summary'],
60
56
  moduleDirectories: ['node_modules', 'app', 'lib'],
61
57
  moduleNameMapper: {
62
- '.*\\webpack-hmr(.[t|j]s)?$': `${getRootDir()}/lib/testing/mocks/webpack-hmr.js`,
63
- '.*\\.(css|scss)$': `${getRootDir()}/lib/testing/mocks/cssModule.js`,
64
- '.*\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|ico)$': `${getRootDir()}/lib/testing/mocks/image.js`,
65
- '.*\\.svg$': `${getRootDir()}/lib/testing/mocks/svg.js`,
66
- '.*\\.(html)$': `${getRootDir()}/lib/testing/mocks/html.js`,
67
- '^lodash-es$': 'lodash',
68
- '@elliemae/pui-user-monitoring': `${getRootDir()}/lib/testing/mocks/pui-user-monitoring.js`,
69
- '@elliemae/pui-app-loader': `${getRootDir()}/lib/testing/mocks/pui-app-loader.js`,
70
- '@elliemae/pui-diagnostics': `${getRootDir()}/lib/testing/mocks/pui-diagnostics.js`,
71
- 'react-spring/web': '<rootDir>/node_modules/react-spring/web.cjs.js',
72
- 'react-spring/renderprops':
73
- '<rootDir>/node_modules/react-spring/renderprops.cjs.js',
74
- 'styled-components':
75
- '<rootDir>/node_modules/styled-components/dist/styled-components.cjs.js',
58
+ '.*\\webpack-hmr(.[t|j]s)?$': getMockFilePath('webpack-hmr.js'),
59
+ '.*\\.(css|scss)$': getMockFilePath('cssModule.js'),
60
+ '.*\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|ico)$':
61
+ getMockFilePath('image.js'),
62
+ '.*\\.svg$': getMockFilePath('svg.js'),
63
+ '.*\\.(html)$': getMockFilePath('html.js'),
64
+ '@elliemae/pui-user-monitoring': getMockFilePath('pui-user-monitoring.js'),
65
+ '@elliemae/pui-app-loader': getMockFilePath('webpack-hmr.js'),
66
+ '@elliemae/pui-diagnostics': getMockFilePath('pui-app-loader.js'),
67
+ 'react-spring/web': getNodeModulesPath('react-spring/web.cjs.js'),
68
+ 'react-spring/renderprops': getNodeModulesPath(
69
+ 'react-spring/renderprops.cjs.js',
70
+ ),
71
+ 'styled-components': getNodeModulesPath(
72
+ 'styled-components/dist/styled-components.cjs.js',
73
+ ),
76
74
  },
77
75
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
78
- setupFilesAfterEnv: [`${getRootDir()}/lib/testing/setup-tests.js`],
76
+ setupFilesAfterEnv: [path.resolve(__dirname, './setup-tests.js')],
79
77
  setupFiles: ['raf/polyfill', 'whatwg-fetch'],
80
78
  testRegex: '(app|lib).*/tests/.*\\.test\\.[jt]sx?$',
81
79
  snapshotSerializers: [],
@@ -97,7 +95,7 @@ const jestConfig = {
97
95
 
98
96
  if (isReactModule && jestConfig.setupFilesAfterEnv)
99
97
  jestConfig.setupFilesAfterEnv.push(
100
- `${getRootDir()}/lib/testing/setup-react-env.js`,
98
+ path.resolve(__dirname, './setup-react-env.js'),
101
99
  );
102
100
 
103
101
  exports.jestConfig = jestConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/pui-cli",
3
- "version": "6.5.3",
3
+ "version": "6.5.4",
4
4
  "private": false,
5
5
  "description": "ICE MT UI Platform CLI",
6
6
  "sideEffects": false,
@@ -185,6 +185,7 @@
185
185
  "node-gyp": "~8.4.1",
186
186
  "node-plop": "~0.30.0",
187
187
  "nodemon": "~2.0.15",
188
+ "normalize-path": "~3.0.0",
188
189
  "npm-check-updates": "12.3.0",
189
190
  "null-loader": "~4.0.1",
190
191
  "pino": "~7.6.5",