@elliemae/pui-cli 6.16.0 → 7.0.0-alpha.2

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.
Files changed (261) hide show
  1. package/dist/cjs/cli-commands/build.js +72 -0
  2. package/dist/cjs/cli-commands/codemod.js +51 -0
  3. package/dist/cjs/cli-commands/gendoc.js +52 -0
  4. package/dist/cjs/cli-commands/lint.js +86 -0
  5. package/dist/cjs/cli-commands/pack.js +88 -0
  6. package/dist/cjs/cli-commands/start.js +61 -0
  7. package/dist/cjs/cli-commands/storybook.js +63 -0
  8. package/dist/cjs/cli-commands/test.js +86 -0
  9. package/dist/cjs/cli-commands/tsc.js +103 -0
  10. package/dist/cjs/cli-commands/utils.js +137 -0
  11. package/dist/cjs/cli-commands/version.js +71 -0
  12. package/dist/cjs/cli-commands/vitest.js +84 -0
  13. package/dist/cjs/cli.js +47 -0
  14. package/dist/cjs/docgen/jsdoc.conf.json +17 -0
  15. package/{lib/dummy.ts → dist/cjs/dummy.js} +0 -0
  16. package/dist/cjs/index.js +41 -0
  17. package/dist/cjs/lint/lint-staged.config.js +42 -0
  18. package/dist/cjs/monorepo/delete-merged-tags.js +57 -0
  19. package/dist/cjs/monorepo/set-registry-version.js +43 -0
  20. package/dist/cjs/monorepo/set-workspace-version.js +44 -0
  21. package/dist/cjs/monorepo/utils.js +34 -0
  22. package/dist/cjs/package.json +4 -0
  23. package/dist/cjs/pui-config/index.js +40 -0
  24. package/dist/cjs/scripts/helpers/checkmark.js +32 -0
  25. package/dist/cjs/scripts/helpers/get-npm-config.js +27 -0
  26. package/dist/cjs/scripts/helpers/progress.js +35 -0
  27. package/dist/cjs/scripts/helpers/xmark.js +31 -0
  28. package/dist/cjs/scripts/npmcheckversion.js +8 -0
  29. package/dist/cjs/scripts/update-notifier.js +33 -0
  30. package/dist/cjs/server/csp.js +88 -0
  31. package/dist/cjs/server/index.js +29 -0
  32. package/dist/cjs/server/logger.js +50 -0
  33. package/dist/cjs/server/middlewares/addProdMiddlewares.js +44 -0
  34. package/dist/cjs/server/middlewares/index.js +57 -0
  35. package/dist/cjs/server/util/index.js +68 -0
  36. package/dist/cjs/testing/setup-react-env.js +18 -0
  37. package/dist/cjs/testing/setup-tests.js +63 -0
  38. package/dist/cjs/testing/vitest.config.js +39 -0
  39. package/{lib/testing/vitest.setup.ts → dist/cjs/testing/vitest.setup.js} +0 -0
  40. package/dist/cjs/transpile/esbuild.js +138 -0
  41. package/dist/cjs/transpile/react-shim.js +26 -0
  42. package/{lib → dist/cjs}/typescript/app.tsconfig.json +0 -0
  43. package/{lib → dist/cjs}/typescript/library.tsconfig.json +0 -0
  44. package/dist/cjs/typescript/tsc-files/index.js +68 -0
  45. package/dist/cjs/typescript/tsc-files/utils.js +31 -0
  46. package/dist/cjs/typescript/util.js +28 -0
  47. package/dist/cjs/webpack/helpers.js +216 -0
  48. package/dist/cjs/webpack/webpack.base.babel.js +262 -0
  49. package/dist/cjs/webpack/webpack.dev.babel.js +136 -0
  50. package/dist/cjs/webpack/webpack.lib.base.babel.js +217 -0
  51. package/dist/cjs/webpack/webpack.lib.dev.babel.js +67 -0
  52. package/dist/cjs/webpack/webpack.lib.prod.babel.js +92 -0
  53. package/dist/cjs/webpack/webpack.prod.babel.js +139 -0
  54. package/dist/esm/cli-commands/build.js +56 -0
  55. package/dist/esm/cli-commands/codemod.js +29 -0
  56. package/dist/esm/cli-commands/gendoc.js +29 -0
  57. package/dist/esm/cli-commands/lint.js +64 -0
  58. package/dist/esm/cli-commands/pack.js +65 -0
  59. package/dist/esm/cli-commands/start.js +38 -0
  60. package/dist/esm/cli-commands/storybook.js +41 -0
  61. package/dist/esm/cli-commands/test.js +64 -0
  62. package/dist/esm/cli-commands/tsc.js +83 -0
  63. package/dist/esm/cli-commands/utils.js +120 -0
  64. package/dist/esm/cli-commands/version.js +49 -0
  65. package/dist/esm/cli-commands/vitest.js +61 -0
  66. package/dist/esm/cli.js +31 -0
  67. package/dist/esm/docgen/jsdoc.conf.json +17 -0
  68. package/dist/esm/dummy.js +0 -0
  69. package/dist/esm/index.js +22 -0
  70. package/dist/esm/lint/lint-staged.config.js +19 -0
  71. package/dist/esm/monorepo/delete-merged-tags.js +38 -0
  72. package/dist/esm/monorepo/set-registry-version.js +21 -0
  73. package/dist/esm/monorepo/set-workspace-version.js +22 -0
  74. package/dist/esm/monorepo/utils.js +12 -0
  75. package/dist/esm/package.json +4 -0
  76. package/dist/esm/pui-config/index.js +18 -0
  77. package/dist/esm/scripts/helpers/checkmark.js +10 -0
  78. package/dist/esm/scripts/helpers/get-npm-config.js +5 -0
  79. package/dist/esm/scripts/helpers/progress.js +13 -0
  80. package/dist/esm/scripts/helpers/xmark.js +9 -0
  81. package/dist/esm/scripts/npmcheckversion.js +8 -0
  82. package/dist/esm/scripts/update-notifier.js +11 -0
  83. package/dist/esm/server/csp.js +66 -0
  84. package/dist/esm/server/index.js +17 -0
  85. package/dist/esm/server/logger.js +28 -0
  86. package/dist/esm/server/middlewares/addProdMiddlewares.js +22 -0
  87. package/dist/esm/server/middlewares/index.js +35 -0
  88. package/{lib → dist/esm}/server/util/index.js +18 -19
  89. package/dist/esm/testing/setup-react-env.js +3 -0
  90. package/dist/esm/testing/setup-tests.js +48 -0
  91. package/dist/esm/testing/vitest.config.js +17 -0
  92. package/dist/esm/testing/vitest.setup.js +0 -0
  93. package/dist/esm/transpile/esbuild.js +117 -0
  94. package/dist/esm/transpile/react-shim.js +4 -0
  95. package/dist/esm/typescript/app.tsconfig.json +23 -0
  96. package/dist/esm/typescript/library.tsconfig.json +23 -0
  97. package/dist/esm/typescript/tsc-files/index.js +55 -0
  98. package/{lib → dist/esm}/typescript/tsc-files/utils.js +3 -7
  99. package/dist/esm/typescript/util.js +6 -0
  100. package/dist/esm/webpack/helpers.js +196 -0
  101. package/dist/esm/webpack/webpack.base.babel.js +248 -0
  102. package/dist/esm/webpack/webpack.dev.babel.js +118 -0
  103. package/dist/esm/webpack/webpack.lib.base.babel.js +208 -0
  104. package/dist/esm/webpack/webpack.lib.dev.babel.js +45 -0
  105. package/dist/esm/webpack/webpack.lib.prod.babel.js +70 -0
  106. package/dist/esm/webpack/webpack.prod.babel.js +122 -0
  107. package/dist/types/babel/babel.config.d.cts +59 -0
  108. package/dist/types/cli-commands/build.d.ts +14 -0
  109. package/dist/types/cli-commands/codemod.d.ts +6 -0
  110. package/dist/types/cli-commands/gendoc.d.ts +6 -0
  111. package/dist/types/cli-commands/lint.d.ts +29 -0
  112. package/dist/types/cli-commands/pack.d.ts +26 -0
  113. package/dist/types/cli-commands/start.d.ts +13 -0
  114. package/dist/types/cli-commands/storybook.d.ts +19 -0
  115. package/dist/types/cli-commands/test.d.ts +35 -0
  116. package/dist/types/cli-commands/tsc.d.ts +20 -0
  117. package/dist/types/cli-commands/utils.d.ts +14 -0
  118. package/dist/types/cli-commands/version.d.ts +30 -0
  119. package/dist/types/cli-commands/vitest.d.ts +35 -0
  120. package/dist/types/cli.d.ts +2 -0
  121. package/dist/types/dummy.d.ts +0 -0
  122. package/dist/types/index.d.ts +10 -0
  123. package/dist/types/lint/commitlint.config.d.cts +4 -0
  124. package/dist/types/lint/eslint/common.d.cts +124 -0
  125. package/dist/types/lint/eslint/non-react.d.cts +88 -0
  126. package/dist/types/lint/eslint/react.d.cts +118 -0
  127. package/dist/types/lint/eslint/typescript/common.d.cts +37 -0
  128. package/dist/types/lint/eslint/typescript/non-react.d.cts +87 -0
  129. package/dist/types/lint/eslint/typescript/react.d.cts +118 -0
  130. package/dist/types/lint/lint-staged.config.d.ts +5 -0
  131. package/dist/types/lint/prettier.config.d.cts +8 -0
  132. package/dist/types/lint/stylelint.config.d.cts +10 -0
  133. package/dist/types/monorepo/delete-merged-tags.d.ts +1 -0
  134. package/dist/types/monorepo/set-registry-version.d.ts +1 -0
  135. package/dist/types/monorepo/set-workspace-version.d.ts +1 -0
  136. package/dist/types/monorepo/utils.d.ts +1 -0
  137. package/dist/types/pui-config/index.d.ts +1 -0
  138. package/dist/types/release/release.config.d.cts +9 -0
  139. package/dist/types/scripts/helpers/checkmark.d.ts +7 -0
  140. package/dist/types/scripts/helpers/get-npm-config.d.ts +2 -0
  141. package/dist/types/scripts/helpers/progress.d.ts +7 -0
  142. package/dist/types/scripts/helpers/xmark.d.ts +6 -0
  143. package/dist/types/scripts/npmcheckversion.d.ts +1 -0
  144. package/dist/types/scripts/update-notifier.d.ts +2 -0
  145. package/dist/types/server/csp.d.ts +10 -0
  146. package/dist/types/server/index.d.ts +1 -0
  147. package/dist/types/server/logger.d.ts +4 -0
  148. package/dist/types/server/middlewares/addProdMiddlewares.d.ts +1 -0
  149. package/dist/types/server/middlewares/index.d.ts +2 -0
  150. package/dist/types/server/util/index.d.ts +4 -0
  151. package/dist/types/testing/jest.config.d.cts +39 -0
  152. package/dist/types/testing/jest.node.config.d.cts +39 -0
  153. package/dist/types/testing/mocks/axios.d.cts +14 -0
  154. package/dist/types/testing/mocks/cssModule.d.cts +2 -0
  155. package/dist/types/testing/mocks/html.d.cts +2 -0
  156. package/dist/types/testing/mocks/image.d.cts +2 -0
  157. package/dist/types/testing/mocks/matchMedia.d.cts +2 -0
  158. package/dist/types/testing/mocks/pui-app-loader.d.cts +1 -0
  159. package/dist/types/testing/mocks/pui-diagnostics.d.cts +28 -0
  160. package/dist/types/testing/mocks/pui-user-monitoring.d.cts +3 -0
  161. package/dist/types/testing/mocks/retry-axios.d.cts +3 -0
  162. package/dist/types/testing/mocks/svg.d.cts +3 -0
  163. package/dist/types/testing/mocks/webpack-hmr.d.cts +1 -0
  164. package/dist/types/testing/resolver.d.cts +2 -0
  165. package/dist/types/testing/setup-react-env.d.ts +1 -0
  166. package/dist/types/testing/setup-tests.d.ts +1 -0
  167. package/dist/types/testing/vitest.config.d.ts +2 -0
  168. package/dist/types/testing/vitest.setup.d.ts +0 -0
  169. package/dist/types/transpile/esbuild.d.ts +13 -0
  170. package/dist/types/transpile/react-shim.d.ts +2 -0
  171. package/dist/types/transpile/swcrc.config.d.cts +1 -0
  172. package/dist/types/typescript/tsc-files/index.d.ts +1 -0
  173. package/dist/types/typescript/tsc-files/utils.d.ts +3 -0
  174. package/dist/types/typescript/util.d.ts +1 -0
  175. package/dist/types/utils.d.cts +3 -0
  176. package/dist/types/webpack/helpers.d.ts +28 -0
  177. package/dist/types/webpack/webpack.base.babel.d.ts +90 -0
  178. package/dist/types/webpack/webpack.dev.babel.d.ts +1 -0
  179. package/dist/types/webpack/webpack.lib.base.babel.d.ts +107 -0
  180. package/dist/types/webpack/webpack.lib.dev.babel.d.ts +91 -0
  181. package/dist/types/webpack/webpack.lib.prod.babel.d.ts +91 -0
  182. package/dist/types/webpack/webpack.prod.babel.d.ts +2 -0
  183. package/dist/types/webpack/webpack.storybook.d.cts +4 -0
  184. package/package.json +63 -52
  185. package/lib/babel/babel.config.js +0 -101
  186. package/lib/cli-commands/build.js +0 -56
  187. package/lib/cli-commands/codemod.js +0 -31
  188. package/lib/cli-commands/gendoc.js +0 -36
  189. package/lib/cli-commands/lint.js +0 -75
  190. package/lib/cli-commands/pack.js +0 -67
  191. package/lib/cli-commands/start.js +0 -44
  192. package/lib/cli-commands/storybook.js +0 -53
  193. package/lib/cli-commands/test.js +0 -63
  194. package/lib/cli-commands/tsc.js +0 -103
  195. package/lib/cli-commands/utils.js +0 -89
  196. package/lib/cli-commands/version.js +0 -53
  197. package/lib/cli-commands/vitest.js +0 -66
  198. package/lib/cli.js +0 -33
  199. package/lib/docgen/jsdoc.config.js +0 -17
  200. package/lib/index.js +0 -25
  201. package/lib/lint/commitlint.config.js +0 -1
  202. package/lib/lint/eslint/common.js +0 -160
  203. package/lib/lint/eslint/non-react.js +0 -14
  204. package/lib/lint/eslint/react.js +0 -26
  205. package/lib/lint/eslint/typescript/common.js +0 -43
  206. package/lib/lint/eslint/typescript/non-react.js +0 -12
  207. package/lib/lint/eslint/typescript/react.js +0 -19
  208. package/lib/lint/lint-staged.config.js +0 -16
  209. package/lib/lint/prettier.config.js +0 -8
  210. package/lib/lint/stylelint.config.js +0 -19
  211. package/lib/monorepo/delete-merged-tags.js +0 -48
  212. package/lib/monorepo/set-registry-version.js +0 -22
  213. package/lib/monorepo/set-workspace-version.js +0 -29
  214. package/lib/monorepo/utils.js +0 -15
  215. package/lib/pui-config/index.js +0 -18
  216. package/lib/release/release.config.js +0 -31
  217. package/lib/scripts/helpers/checkmark.js +0 -15
  218. package/lib/scripts/helpers/get-npm-config.js +0 -3
  219. package/lib/scripts/helpers/progress.js +0 -19
  220. package/lib/scripts/helpers/xmark.js +0 -13
  221. package/lib/scripts/npmcheckversion.js +0 -8
  222. package/lib/scripts/update-notifier.js +0 -7
  223. package/lib/server/argv.js +0 -1
  224. package/lib/server/csp.js +0 -74
  225. package/lib/server/index.js +0 -69
  226. package/lib/server/logger.js +0 -42
  227. package/lib/server/middlewares/addDevMiddlewares.js +0 -39
  228. package/lib/server/middlewares/addProdMiddlewares.js +0 -31
  229. package/lib/server/middlewares/frontendMiddleware.js +0 -16
  230. package/lib/server/port.js +0 -6
  231. package/lib/testing/jest.config.js +0 -100
  232. package/lib/testing/jest.node.config.js +0 -8
  233. package/lib/testing/mocks/axios.js +0 -15
  234. package/lib/testing/mocks/cssModule.js +0 -1
  235. package/lib/testing/mocks/html.js +0 -1
  236. package/lib/testing/mocks/image.js +0 -1
  237. package/lib/testing/mocks/matchMedia.js +0 -24
  238. package/lib/testing/mocks/pui-app-loader.js +0 -1
  239. package/lib/testing/mocks/pui-diagnostics.js +0 -28
  240. package/lib/testing/mocks/pui-user-monitoring.js +0 -3
  241. package/lib/testing/mocks/retry-axios.js +0 -3
  242. package/lib/testing/mocks/svg.js +0 -5
  243. package/lib/testing/mocks/webpack-hmr.js +0 -1
  244. package/lib/testing/resolver.js +0 -47
  245. package/lib/testing/setup-react-env.js +0 -3
  246. package/lib/testing/setup-tests.js +0 -58
  247. package/lib/testing/vitest.config.ts +0 -16
  248. package/lib/transpile/.swcrc +0 -11
  249. package/lib/transpile/esbuild.js +0 -116
  250. package/lib/transpile/react-shim.js +0 -2
  251. package/lib/transpile/swcrc.config.js +0 -13
  252. package/lib/typescript/tsc-files/index.js +0 -66
  253. package/lib/typescript/util.js +0 -5
  254. package/lib/webpack/helpers.js +0 -255
  255. package/lib/webpack/webpack.base.babel.js +0 -239
  256. package/lib/webpack/webpack.dev.babel.js +0 -122
  257. package/lib/webpack/webpack.lib.base.babel.js +0 -205
  258. package/lib/webpack/webpack.lib.dev.babel.js +0 -49
  259. package/lib/webpack/webpack.lib.prod.babel.js +0 -77
  260. package/lib/webpack/webpack.prod.babel.js +0 -164
  261. package/lib/webpack/webpack.storybook.js +0 -91
@@ -1,69 +0,0 @@
1
- /* eslint consistent-return:0 import/order:0 */
2
-
3
- const express = require('express');
4
- const cors = require('cors');
5
- const { resolve } = require('path');
6
- const expressPinoLogger = require('express-pino-logger');
7
- const { csp } = require('./csp');
8
- const logger = require('./logger');
9
- const argv = require('./argv');
10
- const port = require('./port');
11
- const setup = require('./middlewares/frontendMiddleware');
12
- const { loadRoutes } = require('./util');
13
- const { getAssetPath } = require('../webpack/helpers');
14
-
15
- const pino = expressPinoLogger({
16
- transport: {
17
- target: 'pino-pretty',
18
- options: {
19
- colorize: true,
20
- },
21
- },
22
- });
23
- pino.logger.level = 'warn';
24
-
25
- // const corsOptions = {
26
- // origin: '*',
27
- // methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
28
- // allowedHeaders: [
29
- // 'Authorization',
30
- // 'Content-Type',
31
- // 'Origin',
32
- // 'X-Requested-With',
33
- // 'Accept',
34
- // ],
35
- // preflightContinue: false,
36
- // optionsSuccessStatus: 204,
37
- // maxAge: 3600,
38
- // };
39
- const app = express();
40
- app.use(pino);
41
- app.use(cors());
42
- app.options('*', cors());
43
- csp(app);
44
- app.use(express.urlencoded({ extended: false }));
45
- app.use(express.text({ type: 'text/plain' }));
46
- app.use(express.json({ type: 'application/json' }));
47
- app.use(express.json({ type: 'application/csp-report' }));
48
-
49
- // load all custom routes from the application
50
- loadRoutes(app);
51
-
52
- // In production we need to pass these values in instead of relying on webpack
53
- setup(app, {
54
- outputPath: resolve(process.cwd(), 'build/public'),
55
- publicPath: getAssetPath(),
56
- });
57
-
58
- // get the intended host and port number, use localhost and port 3000 if not provided
59
- const customHost = argv.host || process.env.HOST;
60
- const host = customHost || null; // Let http.Server use its default IPv6/4 host
61
- const prettyHost = customHost || 'localhost';
62
-
63
- // Start your app.
64
- app.listen(port, host, async (err) => {
65
- if (err) {
66
- return logger.error(err.message);
67
- }
68
- logger.appStarted(port, prettyHost);
69
- });
@@ -1,42 +0,0 @@
1
- /* eslint-disable no-console */
2
-
3
- const chalk = require('chalk');
4
- const ip = require('ip');
5
-
6
- const divider = chalk.gray('\n-----------------------------------');
7
-
8
- /**
9
- * Logger middleware, you can customize it to make messages more personal
10
- */
11
- const logger = {
12
- // Called whenever there's an error on the server we want to print
13
- error: (err) => {
14
- console.error(chalk.red(err));
15
- },
16
-
17
- // Called when express.js app starts on given port w/o errors
18
- appStarted: (port, host, tunnelStarted) => {
19
- console.log(`Server started ! ${chalk.green('✓')}`);
20
-
21
- // If the tunnel started, log that and the URL it's available at
22
- if (tunnelStarted) {
23
- console.log(`Tunnel initialised ${chalk.green('✓')}`);
24
- }
25
-
26
- const accessUrls = `${chalk.bold('Access URLs:')}${divider}\n`;
27
- const localHostUrl = `Localhost: ${chalk.magenta(
28
- `http://${host}:${port}`,
29
- )}\n`;
30
- const lanUrl = `LAN: ${chalk.magenta(`http://${ip.address()}:${port}`)}\n`;
31
- const proxy = tunnelStarted
32
- ? `\n Proxy: ${chalk.magenta(tunnelStarted)}`
33
- : '';
34
-
35
- console.log(`${accessUrls}${localHostUrl}${lanUrl}${proxy}${divider}${chalk.blue(
36
- `\nPress ${chalk.italic('CTRL-C')} to stop`,
37
- )}
38
- `);
39
- },
40
- };
41
-
42
- module.exports = logger;
@@ -1,39 +0,0 @@
1
- const webpack = require('webpack');
2
- const expressStaticGzip = require('express-static-gzip');
3
- const webpackDevMiddleware = require('webpack-dev-middleware');
4
- const webpackHotMiddleware = require('webpack-hot-middleware');
5
- const { sendFileWithCSPNonce } = require('../csp');
6
-
7
- function createWebpackMiddleware(compiler, publicPath) {
8
- return webpackDevMiddleware(compiler, {
9
- publicPath,
10
- });
11
- }
12
-
13
- module.exports = function addDevMiddlewares(app, webpackConfig) {
14
- const compiler = webpack(webpackConfig);
15
- const middleware = createWebpackMiddleware(
16
- compiler,
17
- webpackConfig.output.publicPath,
18
- );
19
-
20
- app.use(middleware);
21
- app.use(
22
- webpackHotMiddleware(compiler, {
23
- log: false,
24
- path: `/__webpack_hmr`,
25
- heartbeat: 10 * 1000,
26
- }),
27
- );
28
- app.use(expressStaticGzip('cdn'));
29
-
30
- const { outputFileSystem } = (middleware || {}).context || {};
31
-
32
- app.get('*', (req, res) => {
33
- sendFileWithCSPNonce({
34
- outputPath: compiler.outputPath,
35
- fileSystem: outputFileSystem,
36
- res,
37
- });
38
- });
39
- };
@@ -1,31 +0,0 @@
1
- const path = require('path');
2
- const compression = require('compression');
3
- const expressStaticGzip = require('express-static-gzip');
4
- const { sendFileWithCSPNonce } = require('../csp');
5
-
6
- module.exports = function addProdMiddlewares(app, options) {
7
- const publicPath = options.publicPath || '/';
8
- const outputPath =
9
- options.outputPath || path.resolve(process.cwd(), 'build/public');
10
-
11
- // compression middleware compresses your server responses which makes them
12
- // smaller (applies also to assets). You can read more about that technique
13
- // and other good practices on official Express.js docs http://mxs.is/googmy
14
- app.use(compression());
15
-
16
- app.get(publicPath, (req, res) => {
17
- sendFileWithCSPNonce({ outputPath, res });
18
- });
19
-
20
- app.use(
21
- publicPath,
22
- expressStaticGzip(outputPath, {
23
- index: false,
24
- enableBrotli: true,
25
- orderPreference: ['br'],
26
- }),
27
- );
28
- app.use(expressStaticGzip('cdn'));
29
-
30
- app.get('*', (req, res) => sendFileWithCSPNonce({ outputPath, res }));
31
- };
@@ -1,16 +0,0 @@
1
- /* eslint-disable global-require */
2
-
3
- module.exports = (app, options) => {
4
- const isProd = process.env.NODE_ENV === 'production';
5
-
6
- if (isProd) {
7
- const addProdMiddlewares = require('./addProdMiddlewares');
8
- addProdMiddlewares(app, options);
9
- } else {
10
- const webpackConfig = require('../../webpack/webpack.dev.babel');
11
- const addDevMiddlewares = require('./addDevMiddlewares');
12
- addDevMiddlewares(app, webpackConfig);
13
- }
14
-
15
- return app;
16
- };
@@ -1,6 +0,0 @@
1
- const argv = require('./argv');
2
-
3
- module.exports = parseInt(
4
- argv.port || process.env.port || process.env.PORT || '3000',
5
- 10,
6
- );
@@ -1,100 +0,0 @@
1
- const path = require('path');
2
- const normalizePath = require('normalize-path');
3
- const { getAppConfig, getAssetPath } = require('../webpack/helpers');
4
- const swcrcConfig = require('../transpile/swcrc.config.js');
5
- const { findMonoRepoRoot } = require('../monorepo/utils');
6
-
7
- let isReactModule = true;
8
- try {
9
- /* eslint-disable global-require, import/no-unresolved */
10
- require('react');
11
- require('styled-components');
12
- /* eslint-enable global-require, import/no-unresolved */
13
- } catch (err) {
14
- isReactModule = false;
15
- }
16
-
17
- const getMockFilePath = (fileName) =>
18
- normalizePath(path.resolve(__dirname, './mocks', fileName));
19
-
20
- const getNodeModulesPath = (fileName) => {
21
- const monorepoRoot = findMonoRepoRoot(process.cwd());
22
- return normalizePath(
23
- monorepoRoot
24
- ? path.join(monorepoRoot, 'node_modules', fileName)
25
- : `<rootDir>/node_modules/${fileName}`,
26
- );
27
- };
28
-
29
- const jestConfig = {
30
- collectCoverageFrom: [
31
- 'app/**/*.{js,ts,jsx,tsx}',
32
- 'lib/**/*.{js,ts,jsx,tsx}',
33
- '!app/**/*.d.ts',
34
- '!lib/**/*.d.ts',
35
- '!app/**/*.test.{js,ts,jsx,tsx}',
36
- '!lib/**/*.test.{js,ts,jsx,tsx}',
37
- '!app/**/*.stories.{js,ts,jsx,tsx}',
38
- '!lib/**/*.stories.{js,ts,jsx,tsx}',
39
- '!app/**/*.endpoint.{js,ts,jsx,tsx}',
40
- '!lib/**/*.endpoint.{js,ts,jsx,tsx}',
41
- '!app/*/RbGenerated*/*.{js,ts,jsx,tsx}',
42
- '!app/index.{js,ts,jsx,tsx}',
43
- '!app/global-styles.{js,ts,jsx,tsx}',
44
- '!app/**/loadable.{js,ts,jsx,tsx}',
45
- '!lib/**/loadable.{js,ts,jsx,tsx}',
46
- ],
47
- coverageThreshold: {
48
- // Todo: enable the coverage threshold later
49
- // global: {
50
- // statements: 95,
51
- // branches: 90,
52
- // functions: 95,
53
- // lines: 95,
54
- // },
55
- },
56
- coverageDirectory: 'reports',
57
- coverageReporters: ['lcov', 'html', 'text-summary'],
58
- moduleDirectories: ['node_modules', 'app', 'lib'],
59
- moduleNameMapper: {
60
- '.*\\webpack-hmr(.[t|j]s)?$': getMockFilePath('webpack-hmr.js'),
61
- '.*\\.(css|scss)$': getMockFilePath('cssModule.js'),
62
- '.*\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|ico)$':
63
- getMockFilePath('image.js'),
64
- '.*\\.svg$': getMockFilePath('svg.js'),
65
- '.*\\.(html)$': getMockFilePath('html.js'),
66
- '@elliemae/pui-user-monitoring': getMockFilePath('pui-user-monitoring.js'),
67
- '@elliemae/pui-app-loader': getMockFilePath('webpack-hmr.js'),
68
- '@elliemae/pui-diagnostics': getMockFilePath('pui-app-loader.js'),
69
- 'react-spring/web': getNodeModulesPath('react-spring/web.cjs.js'),
70
- 'react-spring/renderprops': getNodeModulesPath(
71
- 'react-spring/renderprops.cjs.js',
72
- ),
73
- },
74
- moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
75
- setupFilesAfterEnv: [path.resolve(__dirname, './setup-tests.js')],
76
- setupFiles: ['raf/polyfill', 'whatwg-fetch'],
77
- testRegex: '(app|lib).*/tests/.*\\.test\\.[jt]sx?$',
78
- snapshotSerializers: [],
79
- testResultsProcessor: 'jest-sonar-reporter',
80
- resolver: path.resolve(__dirname, './resolver.js'),
81
- transform: {
82
- '^.+\\.[jt]sx?$': ['@swc/jest', swcrcConfig],
83
- },
84
- transformIgnorePatterns: [
85
- 'node_modules/(?!(.*@elliemae/pui-cli|lodash-es|react-select|react-dates)/)',
86
- ],
87
- globals: {
88
- APP_CONFIG: getAppConfig(),
89
- __webpack_public_path__: '/',
90
- },
91
- testURL: `http://localhost:3111${getAssetPath()}`,
92
- testEnvironment: 'jsdom',
93
- };
94
-
95
- if (isReactModule && jestConfig.setupFilesAfterEnv)
96
- jestConfig.setupFilesAfterEnv.push(
97
- path.resolve(__dirname, './setup-react-env.js'),
98
- );
99
-
100
- exports.jestConfig = jestConfig;
@@ -1,8 +0,0 @@
1
- const { jestConfig } = require('./jest.config');
2
- exports.jestNodeConfig = {
3
- ...jestConfig,
4
- testEnvironment: 'node',
5
- transformIgnorePatterns: [],
6
- setupFiles: [],
7
- setupFilesAfterEnv: [],
8
- };
@@ -1,15 +0,0 @@
1
- module.exports = {
2
- defaults: {},
3
- interceptors: {
4
- request: {
5
- use: jest.fn(),
6
- },
7
- response: {
8
- use: jest.fn(),
9
- },
10
- },
11
- create: jest.fn().mockReturnThis(),
12
- get: jest.fn().mockResolvedValue({ data: {} }),
13
- post: jest.fn().mockResolvedValue({ data: {} }),
14
- put: jest.fn().mockResolvedValue({ data: {} }),
15
- };
@@ -1 +0,0 @@
1
- module.exports = 'CSS_MODULE';
@@ -1 +0,0 @@
1
- module.exports = 'HTML_MODULE';
@@ -1 +0,0 @@
1
- module.exports = 'IMAGE_MOCK';
@@ -1,24 +0,0 @@
1
- /**
2
- *
3
- */
4
- export default () => {
5
- Object.defineProperty(window, 'matchMedia', {
6
- writable: true,
7
- value: jest.fn().mockImplementation((query) => ({
8
- matches: false,
9
- media: query,
10
- onchange: null,
11
- addListener: jest.fn(), // Deprecated
12
- removeListener: jest.fn(), // Deprecated
13
- addEventListener: jest.fn(),
14
- removeEventListener: jest.fn(),
15
- dispatchEvent: jest.fn(),
16
- })),
17
- });
18
-
19
- Object.defineProperty(window, 'getComputedStyle', {
20
- value: () => ({
21
- getPropertyValue: () => {},
22
- }),
23
- });
24
- };
@@ -1 +0,0 @@
1
- export const load = () => {};
@@ -1,28 +0,0 @@
1
- export const logger = () => ({
2
- setLogLevel() {},
3
- setOptions() {},
4
- info() {},
5
- warn() {},
6
- error() {},
7
- trace() {},
8
- debug() {},
9
- audit() {},
10
- fatal() {},
11
- });
12
- export const LogLevel = {
13
- info: 'info',
14
- debug: 'debug',
15
- trace: 'trace',
16
- warn: 'warn',
17
- error: 'error',
18
- audit: 'audit',
19
- fatal: 'fatal',
20
- };
21
- export const Console = () => ({
22
- log: () => {},
23
- });
24
- export const http = () => ({
25
- log() {},
26
- });
27
- export const webvitals = () => {};
28
- export const logUnhandledErrors = () => {};
@@ -1,3 +0,0 @@
1
- export const setCustomUserData = () => {};
2
- export const setCustomVirtualPageName = () => {};
3
- export const startVirtualPageMonitoringWithAutoEnd = () => {};
@@ -1,3 +0,0 @@
1
- export const attach = jest.fn();
2
- export const detach = jest.fn();
3
- export const getConfig = jest.fn();
@@ -1,5 +0,0 @@
1
- // eslint-disable-next-line no-unused-vars
2
- import * as React from 'react';
3
-
4
- export default 'SvgrURL';
5
- export const ReactComponent = 'div';
@@ -1 +0,0 @@
1
- exports.enableHotReloading = () => {};
@@ -1,47 +0,0 @@
1
- const resolutions = [
2
- {
3
- matcher: /\.jsx?$/i,
4
- extensions: ['.tsx', '.ts'],
5
- },
6
- {
7
- matcher: /\.mjs$/i,
8
- extensions: ['.mts'],
9
- },
10
- {
11
- matcher: /\.cjs$/i,
12
- extensions: ['.cts'],
13
- },
14
- ];
15
-
16
- const resolveConfig = {
17
- conditionNames: ['import', 'node', 'default'],
18
- extensions: ['.ts', '.tsx', '.js', '.jsx', '.json', '.node'],
19
- modules: ['node_modules', 'app', 'lib'],
20
- };
21
-
22
- const importResolver = require('enhanced-resolve').create.sync(resolveConfig);
23
- const requireResolver = require('enhanced-resolve').create.sync({
24
- ...resolveConfig,
25
- conditionNames: ['require', 'node', 'default'],
26
- });
27
-
28
- module.exports = (request, options) => {
29
- let resolver = requireResolver;
30
- if (options.conditions?.includes('import')) {
31
- resolver = importResolver;
32
- }
33
- const resolution = resolutions.find(({ matcher }) => matcher.test(request));
34
- if (resolution) {
35
- // eslint-disable-next-line no-restricted-syntax
36
- for (const extension of resolution.extensions) {
37
- try {
38
- return resolver(
39
- options.basedir,
40
- request.replace(resolution.matcher, extension),
41
- );
42
- // eslint-disable-next-line no-empty
43
- } catch {}
44
- }
45
- }
46
- return resolver(options.basedir, request);
47
- };
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- import 'jest-styled-components';
3
- global.React = React;
@@ -1,58 +0,0 @@
1
- // needed for regenerator-runtime
2
- // (ES7 generator support is required by redux-saga)
3
- import 'core-js/stable';
4
- import 'regenerator-runtime/runtime';
5
- import '@testing-library/jest-dom/extend-expect';
6
- import jestAxe from 'jest-axe';
7
- import ResizeObserver from 'resize-observer-polyfill';
8
- import addMatchMedia from './mocks/matchMedia.js';
9
- import { logger } from './mocks/pui-diagnostics.js';
10
-
11
- // eslint-disable-next-line no-console
12
- const originalError = console.error;
13
- // eslint-disable-next-line no-console
14
- console.error = (...args) => {
15
- const ignoreList = [
16
- `Warning: Can't perform a React state update on an unmounted component`,
17
- `Warning: Function components cannot be given refs`,
18
- `Warning: Failed %s type:`,
19
- `Warning: Invalid DOM property`,
20
- `Warning: Each child in a list should have a unique`,
21
- 'Warning: Received `%s` for a non-boolean attribute',
22
- 'Warning: <%s /> is using incorrect casing.',
23
- 'Warning: The tag <%s> is unrecognized in this browser',
24
- 'Warning: Invalid arguments supplied to oneOf',
25
- ];
26
- if (
27
- ignoreList.find(
28
- (ignoreMsg) => !!args.find((arg) => arg?.includes?.(ignoreMsg)),
29
- )
30
- )
31
- return false;
32
- return originalError(...args);
33
- };
34
-
35
- if (expect) expect.extend(jestAxe.toHaveNoViolations);
36
- jest.setTimeout(60000);
37
-
38
- const addElementToBody = (element) => {
39
- const documentEle = (window || {}).document;
40
- if (!documentEle) return null;
41
- const bodyEle = documentEle.body;
42
- const newEle = documentEle.createElement(...element);
43
- if (!newEle) return null;
44
- bodyEle.appendChild(newEle);
45
- return newEle;
46
- };
47
-
48
- const addRootElement = (id) => {
49
- const rootEle = addElementToBody('div');
50
- if (rootEle) rootEle.id = id;
51
- };
52
-
53
- addRootElement('root');
54
-
55
- addMatchMedia();
56
- window.ResizeObserver = ResizeObserver;
57
- window.emui = {};
58
- window.emui.logger = logger();
@@ -1,16 +0,0 @@
1
- /// <reference types="vitest" />
2
- import { defineConfig } from 'vite';
3
- import path from 'path';
4
-
5
- export default defineConfig({
6
- test: {
7
- globals: true,
8
- root: process.cwd(),
9
- exclude: ['node_modules', 'dist', '.idea', '.git', '.cache', 'e2e'],
10
- setupFiles: [path.resolve(__dirname, './vitest.setup.ts')],
11
- coverage: {
12
- reportsDirectory: './reports/coverage',
13
- },
14
- environment: 'happy-dom',
15
- },
16
- });
@@ -1,11 +0,0 @@
1
- {
2
- "jsc": {
3
- "parser": {
4
- "syntax": "typescript",
5
- "jsx": true,
6
- "tsx": true,
7
- "dynamicImport": true
8
- },
9
- "target": "es2020"
10
- }
11
- }
@@ -1,116 +0,0 @@
1
- const { build } = require('esbuild');
2
- const fg = require('fast-glob');
3
- const { writeFile, copyFile, readFile, mkdir } = require('fs/promises');
4
- const path = require('path');
5
- const browserslistToEsbuild = require('browserslist-to-esbuild');
6
-
7
- const TARGETS = {
8
- browserslist: browserslistToEsbuild(),
9
- web: 'es2020',
10
- node: 'node14',
11
- };
12
-
13
- const ESBUILD_FORMAT = {
14
- CJS: 'cjs',
15
- ESM: 'esm',
16
- };
17
-
18
- const NODE_MODULE_TYPES = {
19
- CJS: 'commonjs',
20
- ESM: 'module',
21
- };
22
-
23
- const getCommonConfig = ({ injectReactShim }) => ({
24
- bundle: false,
25
- loader: { '.js': 'jsx' },
26
- mainFields: ['module', 'browser', 'main'],
27
- inject: [
28
- injectReactShim ? path.resolve(__dirname, './react-shim.js') : '',
29
- ].filter(Boolean),
30
- });
31
-
32
- const copyFiles = async ({ srcdir, outdir }) => {
33
- const files = await fg([
34
- `${srcdir}/**/*.*`,
35
- `!${srcdir}/**/*.{js,jsx,ts,tsx,cjs,mjs}`,
36
- ]);
37
- await Promise.all(
38
- files.map(async (srcFilePath) => {
39
- const destFilePath = srcFilePath.replace(srcdir, outdir);
40
- const fileDir = path.dirname(destFilePath);
41
- await mkdir(fileDir, { recursive: true });
42
- await copyFile(srcFilePath, destFilePath);
43
- }),
44
- );
45
- };
46
-
47
- const getSideEffects = async () => {
48
- const data = await readFile(path.join(process.cwd(), './package.json'));
49
- const packageJSON = JSON.parse(data);
50
- return packageJSON?.sideEffects || false;
51
- };
52
-
53
- const createPackageJson = async ({ outdir, type = NODE_MODULE_TYPES.ESM }) => {
54
- const filePath = path.join(process.cwd(), outdir, 'package.json');
55
- const packageJSON = JSON.stringify(
56
- {
57
- type,
58
- sideEffects: await getSideEffects(),
59
- },
60
- null,
61
- 2,
62
- );
63
- await writeFile(filePath, packageJSON);
64
- };
65
-
66
- exports.esBuild = async ({
67
- srcdir,
68
- outdir = 'dist',
69
- esmOnly = false,
70
- target = TARGETS.browserslist,
71
- injectReactShim = true,
72
- skipNestedPackageJSON = false,
73
- }) => {
74
- const inputFiles = [
75
- `${srcdir}/**/*.{js,jsx,ts,tsx}`,
76
- `!${srcdir}/**/*.d.ts`,
77
- `!${srcdir}/**/*.test.{js,jsx,ts,tsx}`,
78
- `!${srcdir}/**/*.stories.{js,jsx,ts,tsx}`,
79
- `!${srcdir}/**/*.endpoint.{js,jsx,ts,tsx}`,
80
- ];
81
-
82
- // build commonjs
83
- if (!esmOnly) {
84
- const cjsOutdir = `${outdir}/cjs`;
85
- const commonJSEntryPoints = await fg(inputFiles);
86
- await build({
87
- entryPoints: commonJSEntryPoints,
88
- ...getCommonConfig({ injectReactShim }),
89
- outdir: cjsOutdir,
90
- format: ESBUILD_FORMAT.CJS,
91
- target,
92
- });
93
- // copy files that are not built by esbuild
94
- await copyFiles({ srcdir, outdir: cjsOutdir });
95
- await createPackageJson({ outdir: cjsOutdir, type: NODE_MODULE_TYPES.CJS });
96
- }
97
-
98
- // build esm
99
- const esmOutdir = esmOnly ? outdir : `${outdir}/esm`;
100
- const entryPoints = await fg(
101
- inputFiles.concat([`!${srcdir}/**/cjs/**/*.{js,jsx,ts,tsx}`]),
102
- );
103
- await build({
104
- entryPoints,
105
- ...getCommonConfig({ injectReactShim }),
106
- outdir: esmOutdir,
107
- format: ESBUILD_FORMAT.ESM,
108
- target,
109
- });
110
- // copy files that are not built by esbuild
111
- await copyFiles({ srcdir, outdir: esmOutdir });
112
- if (!skipNestedPackageJSON)
113
- await createPackageJson({ outdir: esmOutdir, type: NODE_MODULE_TYPES.ESM });
114
- };
115
-
116
- exports.TARGETS = TARGETS;