@elliemae/pui-cli 7.0.0-alpha.1 → 7.0.0-alpha.10

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 (281) hide show
  1. package/{lib/babel/babel.config.js → dist/cjs/babel.config.cjs} +2 -2
  2. package/dist/cjs/cli.js +49 -0
  3. package/dist/cjs/commands/build.js +72 -0
  4. package/dist/cjs/commands/codemod.js +51 -0
  5. package/dist/cjs/commands/gendoc.js +52 -0
  6. package/dist/cjs/commands/lint.js +86 -0
  7. package/dist/cjs/commands/pack.js +88 -0
  8. package/dist/cjs/commands/start.js +61 -0
  9. package/dist/cjs/commands/storybook.js +63 -0
  10. package/dist/cjs/commands/test.js +86 -0
  11. package/dist/cjs/commands/tscheck.js +85 -0
  12. package/dist/cjs/commands/utils.js +137 -0
  13. package/dist/cjs/commands/version.js +71 -0
  14. package/dist/cjs/commands/vitest.js +84 -0
  15. package/{lib/dummy.ts → dist/cjs/dummy.js} +0 -0
  16. package/dist/cjs/index.cjs +25 -0
  17. package/dist/cjs/index.js +41 -0
  18. package/dist/cjs/jsdoc.conf.json +17 -0
  19. package/dist/cjs/lint-config/commitlint.config.cjs +1 -0
  20. package/{lib/lint/eslint/common.js → dist/cjs/lint-config/eslint/common.cjs} +5 -5
  21. package/{lib/lint/eslint/non-react.js → dist/cjs/lint-config/eslint/non-react.cjs} +2 -2
  22. package/{lib/lint/eslint/react.js → dist/cjs/lint-config/eslint/react.cjs} +2 -2
  23. package/{lib/lint/eslint/typescript/common.js → dist/cjs/lint-config/eslint/typescript/common.cjs} +1 -1
  24. package/{lib/lint/eslint/typescript/non-react.js → dist/cjs/lint-config/eslint/typescript/non-react.cjs} +2 -2
  25. package/{lib/lint/eslint/typescript/react.js → dist/cjs/lint-config/eslint/typescript/react.cjs} +2 -2
  26. package/dist/cjs/lint-config/lint-staged.config.js +37 -0
  27. package/{lib/lint/prettier.config.js → dist/cjs/lint-config/prettier.config.cjs} +1 -1
  28. package/{lib/lint/stylelint.config.js → dist/cjs/lint-config/stylelint.config.cjs} +2 -2
  29. package/dist/cjs/monorepo/delete-merged-tags.js +57 -0
  30. package/dist/cjs/monorepo/set-registry-version.js +43 -0
  31. package/dist/cjs/monorepo/set-workspace-version.js +44 -0
  32. package/dist/cjs/monorepo/utils.cjs +30 -0
  33. package/dist/cjs/package.json +4 -0
  34. package/dist/cjs/pui-config.js +40 -0
  35. package/{lib/release/release.config.js → dist/cjs/release.config.cjs} +0 -0
  36. package/{lib/server/util/index.js → dist/cjs/server/app-routes.cjs} +5 -15
  37. package/dist/cjs/server/csp.js +88 -0
  38. package/dist/cjs/server/index.js +30 -0
  39. package/dist/cjs/server/logger.js +50 -0
  40. package/dist/cjs/server/middlewares.js +68 -0
  41. package/dist/cjs/server/utils.js +32 -0
  42. package/{lib/testing/jest.config.js → dist/cjs/testing/jest.config.cjs} +6 -9
  43. package/{lib/testing/jest.node.config.js → dist/cjs/testing/jest.node.config.cjs} +1 -1
  44. package/dist/cjs/testing/mocks/axios.js +37 -0
  45. package/dist/cjs/testing/mocks/cssModule.js +23 -0
  46. package/dist/cjs/testing/mocks/html.js +23 -0
  47. package/dist/cjs/testing/mocks/image.js +23 -0
  48. package/dist/cjs/testing/mocks/matchMedia.js +43 -0
  49. package/dist/cjs/testing/mocks/pui-app-loader.js +24 -0
  50. package/dist/cjs/testing/mocks/pui-diagnostics.js +68 -0
  51. package/dist/cjs/testing/mocks/pui-user-monitoring.js +30 -0
  52. package/dist/cjs/testing/mocks/retry-axios.js +27 -0
  53. package/dist/cjs/testing/mocks/svg.js +29 -0
  54. package/dist/cjs/testing/mocks/webpack-hmr.js +24 -0
  55. package/{lib/testing/resolver.js → dist/cjs/testing/resolver.cjs} +0 -0
  56. package/dist/cjs/testing/setup-react-env.js +18 -0
  57. package/dist/cjs/testing/setup-tests.js +63 -0
  58. package/dist/cjs/testing/vitest.config.js +39 -0
  59. package/{lib/testing/vitest.setup.ts → dist/cjs/testing/vitest.setup.js} +0 -0
  60. package/{lib → dist/cjs}/transpile/.swcrc +0 -0
  61. package/dist/cjs/transpile/esbuild.js +139 -0
  62. package/dist/cjs/transpile/react-shim.js +26 -0
  63. package/{lib/transpile/swcrc.config.js → dist/cjs/transpile/swcrc.config.cjs} +1 -1
  64. package/{lib → dist/cjs}/typescript/app.tsconfig.json +0 -0
  65. package/{lib → dist/cjs}/typescript/library.tsconfig.json +0 -0
  66. package/dist/cjs/update-notifier.js +33 -0
  67. package/dist/cjs/utils.cjs +23 -0
  68. package/dist/cjs/webpack/helpers.js +216 -0
  69. package/dist/cjs/webpack/webpack.base.babel.js +262 -0
  70. package/dist/cjs/webpack/webpack.dev.babel.js +140 -0
  71. package/dist/cjs/webpack/webpack.lib.base.babel.js +217 -0
  72. package/dist/cjs/webpack/webpack.lib.dev.babel.js +67 -0
  73. package/dist/cjs/webpack/webpack.lib.prod.babel.js +92 -0
  74. package/dist/cjs/webpack/webpack.prod.babel.js +139 -0
  75. package/dist/cjs/webpack/webpack.storybook.js +122 -0
  76. package/dist/esm/babel.config.cjs +101 -0
  77. package/dist/esm/cli.js +33 -0
  78. package/dist/esm/commands/build.js +56 -0
  79. package/dist/esm/commands/codemod.js +29 -0
  80. package/dist/esm/commands/gendoc.js +29 -0
  81. package/dist/esm/commands/lint.js +64 -0
  82. package/dist/esm/commands/pack.js +65 -0
  83. package/dist/esm/commands/start.js +38 -0
  84. package/dist/esm/commands/storybook.js +41 -0
  85. package/dist/esm/commands/test.js +64 -0
  86. package/dist/esm/commands/tscheck.js +65 -0
  87. package/dist/esm/commands/utils.js +120 -0
  88. package/dist/esm/commands/version.js +49 -0
  89. package/dist/esm/commands/vitest.js +61 -0
  90. package/dist/esm/dummy.js +0 -0
  91. package/dist/esm/index.cjs +25 -0
  92. package/dist/esm/index.js +22 -0
  93. package/dist/esm/jsdoc.conf.json +17 -0
  94. package/dist/esm/lint-config/commitlint.config.cjs +1 -0
  95. package/dist/esm/lint-config/eslint/common.cjs +160 -0
  96. package/dist/esm/lint-config/eslint/non-react.cjs +14 -0
  97. package/dist/esm/lint-config/eslint/react.cjs +26 -0
  98. package/dist/esm/lint-config/eslint/typescript/common.cjs +43 -0
  99. package/dist/esm/lint-config/eslint/typescript/non-react.cjs +12 -0
  100. package/dist/esm/lint-config/eslint/typescript/react.cjs +19 -0
  101. package/dist/esm/lint-config/lint-staged.config.js +15 -0
  102. package/dist/esm/lint-config/prettier.config.cjs +8 -0
  103. package/dist/esm/lint-config/stylelint.config.cjs +19 -0
  104. package/dist/esm/monorepo/delete-merged-tags.js +38 -0
  105. package/dist/esm/monorepo/set-registry-version.js +21 -0
  106. package/dist/esm/monorepo/set-workspace-version.js +22 -0
  107. package/dist/esm/monorepo/utils.cjs +30 -0
  108. package/dist/esm/package.json +4 -0
  109. package/dist/esm/pui-config.js +18 -0
  110. package/dist/esm/release.config.cjs +31 -0
  111. package/dist/esm/server/app-routes.cjs +42 -0
  112. package/dist/esm/server/csp.js +66 -0
  113. package/dist/esm/server/index.js +18 -0
  114. package/dist/esm/server/logger.js +28 -0
  115. package/dist/esm/server/middlewares.js +46 -0
  116. package/dist/esm/server/utils.js +10 -0
  117. package/dist/esm/testing/jest.config.cjs +102 -0
  118. package/dist/esm/testing/jest.node.config.cjs +8 -0
  119. package/{lib → dist/esm}/testing/mocks/axios.js +8 -5
  120. package/dist/esm/testing/mocks/cssModule.js +4 -0
  121. package/dist/esm/testing/mocks/html.js +4 -0
  122. package/dist/esm/testing/mocks/image.js +4 -0
  123. package/dist/esm/testing/mocks/matchMedia.js +24 -0
  124. package/dist/esm/testing/mocks/pui-app-loader.js +5 -0
  125. package/dist/esm/testing/mocks/pui-diagnostics.js +49 -0
  126. package/dist/esm/testing/mocks/pui-user-monitoring.js +11 -0
  127. package/dist/esm/testing/mocks/retry-axios.js +8 -0
  128. package/dist/esm/testing/mocks/svg.js +7 -0
  129. package/dist/esm/testing/mocks/webpack-hmr.js +5 -0
  130. package/dist/esm/testing/resolver.cjs +47 -0
  131. package/dist/esm/testing/setup-react-env.js +3 -0
  132. package/dist/esm/testing/setup-tests.js +48 -0
  133. package/dist/esm/testing/vitest.config.js +17 -0
  134. package/dist/esm/testing/vitest.setup.js +0 -0
  135. package/dist/esm/transpile/.swcrc +11 -0
  136. package/dist/esm/transpile/esbuild.js +118 -0
  137. package/dist/esm/transpile/react-shim.js +4 -0
  138. package/dist/esm/transpile/swcrc.config.cjs +13 -0
  139. package/dist/esm/typescript/app.tsconfig.json +23 -0
  140. package/dist/esm/typescript/library.tsconfig.json +23 -0
  141. package/dist/esm/update-notifier.js +11 -0
  142. package/dist/esm/utils.cjs +23 -0
  143. package/dist/esm/webpack/helpers.js +196 -0
  144. package/dist/esm/webpack/webpack.base.babel.js +248 -0
  145. package/dist/esm/webpack/webpack.dev.babel.js +121 -0
  146. package/dist/esm/webpack/webpack.lib.base.babel.js +208 -0
  147. package/dist/esm/webpack/webpack.lib.dev.babel.js +45 -0
  148. package/dist/esm/webpack/webpack.lib.prod.babel.js +70 -0
  149. package/dist/esm/webpack/webpack.prod.babel.js +122 -0
  150. package/dist/esm/webpack/webpack.storybook.js +102 -0
  151. package/dist/types/babel.config.d.cts +59 -0
  152. package/dist/types/cli.d.ts +2 -0
  153. package/dist/types/commands/build.d.ts +14 -0
  154. package/dist/types/commands/codemod.d.ts +6 -0
  155. package/dist/types/commands/gendoc.d.ts +6 -0
  156. package/dist/types/commands/lint.d.ts +29 -0
  157. package/dist/types/commands/pack.d.ts +26 -0
  158. package/dist/types/commands/start.d.ts +13 -0
  159. package/dist/types/commands/storybook.d.ts +19 -0
  160. package/dist/types/commands/test.d.ts +35 -0
  161. package/dist/types/commands/tscheck.d.ts +14 -0
  162. package/dist/types/commands/utils.d.ts +14 -0
  163. package/dist/types/commands/version.d.ts +30 -0
  164. package/dist/types/commands/vitest.d.ts +35 -0
  165. package/dist/types/dummy.d.ts +0 -0
  166. package/dist/types/index.d.cts +10 -0
  167. package/dist/types/index.d.ts +10 -0
  168. package/dist/types/lint-config/commitlint.config.d.cts +4 -0
  169. package/dist/types/lint-config/eslint/common.d.cts +127 -0
  170. package/dist/types/lint-config/eslint/non-react.d.cts +93 -0
  171. package/dist/types/lint-config/eslint/react.d.cts +123 -0
  172. package/dist/types/lint-config/eslint/typescript/common.d.cts +37 -0
  173. package/dist/types/lint-config/eslint/typescript/non-react.d.cts +87 -0
  174. package/dist/types/lint-config/eslint/typescript/react.d.cts +118 -0
  175. package/dist/types/lint-config/lint-staged.config.d.ts +5 -0
  176. package/dist/types/lint-config/prettier.config.d.cts +8 -0
  177. package/dist/types/lint-config/stylelint.config.d.cts +11 -0
  178. package/dist/types/monorepo/delete-merged-tags.d.ts +1 -0
  179. package/dist/types/monorepo/set-registry-version.d.ts +1 -0
  180. package/dist/types/monorepo/set-workspace-version.d.ts +1 -0
  181. package/dist/types/monorepo/utils.d.cts +1 -0
  182. package/dist/types/pui-config.d.ts +1 -0
  183. package/dist/types/release.config.d.cts +9 -0
  184. package/dist/types/server/app-routes.d.cts +1 -0
  185. package/dist/types/server/csp.d.ts +10 -0
  186. package/dist/types/server/index.d.ts +1 -0
  187. package/dist/types/server/logger.d.ts +4 -0
  188. package/dist/types/server/middlewares.d.ts +2 -0
  189. package/dist/types/server/utils.d.ts +3 -0
  190. package/dist/types/testing/jest.config.d.cts +38 -0
  191. package/dist/types/testing/jest.node.config.d.cts +38 -0
  192. package/dist/types/testing/mocks/axios.d.ts +17 -0
  193. package/dist/types/testing/mocks/cssModule.d.ts +2 -0
  194. package/dist/types/testing/mocks/html.d.ts +2 -0
  195. package/dist/types/testing/mocks/image.d.ts +2 -0
  196. package/dist/types/testing/mocks/matchMedia.d.ts +1 -0
  197. package/dist/types/testing/mocks/pui-app-loader.d.ts +1 -0
  198. package/dist/types/testing/mocks/pui-diagnostics.d.ts +28 -0
  199. package/dist/types/testing/mocks/pui-user-monitoring.d.ts +3 -0
  200. package/dist/types/testing/mocks/retry-axios.d.ts +3 -0
  201. package/dist/types/testing/mocks/svg.d.ts +3 -0
  202. package/dist/types/testing/mocks/webpack-hmr.d.ts +1 -0
  203. package/dist/types/testing/resolver.d.cts +2 -0
  204. package/dist/types/testing/setup-react-env.d.ts +1 -0
  205. package/dist/types/testing/setup-tests.d.ts +1 -0
  206. package/dist/types/testing/vitest.config.d.ts +2 -0
  207. package/dist/types/testing/vitest.setup.d.ts +0 -0
  208. package/dist/types/transpile/esbuild.d.ts +13 -0
  209. package/dist/types/transpile/react-shim.d.ts +2 -0
  210. package/dist/types/transpile/swcrc.config.d.cts +1 -0
  211. package/dist/types/update-notifier.d.ts +1 -0
  212. package/dist/types/utils.d.cts +4 -0
  213. package/dist/types/webpack/helpers.d.ts +28 -0
  214. package/dist/types/webpack/webpack.base.babel.d.ts +90 -0
  215. package/dist/types/webpack/webpack.dev.babel.d.ts +2 -0
  216. package/dist/types/webpack/webpack.lib.base.babel.d.ts +107 -0
  217. package/dist/types/webpack/webpack.lib.dev.babel.d.ts +91 -0
  218. package/dist/types/webpack/webpack.lib.prod.babel.d.ts +91 -0
  219. package/dist/types/webpack/webpack.prod.babel.d.ts +2 -0
  220. package/dist/types/webpack/webpack.storybook.d.ts +4 -0
  221. package/package.json +55 -39
  222. package/lib/cli-commands/build.js +0 -60
  223. package/lib/cli-commands/codemod.js +0 -31
  224. package/lib/cli-commands/gendoc.js +0 -36
  225. package/lib/cli-commands/lint.js +0 -75
  226. package/lib/cli-commands/pack.js +0 -67
  227. package/lib/cli-commands/start.js +0 -49
  228. package/lib/cli-commands/storybook.js +0 -53
  229. package/lib/cli-commands/test.js +0 -63
  230. package/lib/cli-commands/tsc.js +0 -103
  231. package/lib/cli-commands/utils.js +0 -135
  232. package/lib/cli-commands/version.js +0 -53
  233. package/lib/cli-commands/vitest.js +0 -66
  234. package/lib/cli.js +0 -33
  235. package/lib/docgen/jsdoc.config.js +0 -17
  236. package/lib/index.js +0 -25
  237. package/lib/lint/commitlint.config.js +0 -1
  238. package/lib/lint/lint-staged.config.js +0 -16
  239. package/lib/monorepo/delete-merged-tags.js +0 -48
  240. package/lib/monorepo/set-registry-version.js +0 -22
  241. package/lib/monorepo/set-workspace-version.js +0 -29
  242. package/lib/monorepo/utils.js +0 -15
  243. package/lib/pui-config/index.js +0 -18
  244. package/lib/scripts/helpers/checkmark.js +0 -15
  245. package/lib/scripts/helpers/get-npm-config.js +0 -3
  246. package/lib/scripts/helpers/progress.js +0 -19
  247. package/lib/scripts/helpers/xmark.js +0 -13
  248. package/lib/scripts/npmcheckversion.js +0 -8
  249. package/lib/scripts/update-notifier.js +0 -7
  250. package/lib/server/csp.js +0 -74
  251. package/lib/server/index.js +0 -37
  252. package/lib/server/logger.js +0 -42
  253. package/lib/server/middlewares/addDevMiddlewares.js +0 -39
  254. package/lib/server/middlewares/addProdMiddlewares.js +0 -30
  255. package/lib/server/middlewares/index.js +0 -37
  256. package/lib/testing/mocks/cssModule.js +0 -1
  257. package/lib/testing/mocks/html.js +0 -1
  258. package/lib/testing/mocks/image.js +0 -1
  259. package/lib/testing/mocks/matchMedia.js +0 -24
  260. package/lib/testing/mocks/pui-app-loader.js +0 -1
  261. package/lib/testing/mocks/pui-diagnostics.js +0 -28
  262. package/lib/testing/mocks/pui-user-monitoring.js +0 -3
  263. package/lib/testing/mocks/retry-axios.js +0 -3
  264. package/lib/testing/mocks/svg.js +0 -5
  265. package/lib/testing/mocks/webpack-hmr.js +0 -1
  266. package/lib/testing/setup-react-env.js +0 -3
  267. package/lib/testing/setup-tests.js +0 -58
  268. package/lib/testing/vitest.config.ts +0 -16
  269. package/lib/transpile/esbuild.js +0 -116
  270. package/lib/transpile/react-shim.js +0 -2
  271. package/lib/typescript/tsc-files/index.js +0 -66
  272. package/lib/typescript/tsc-files/utils.js +0 -16
  273. package/lib/typescript/util.js +0 -5
  274. package/lib/webpack/helpers.js +0 -252
  275. package/lib/webpack/webpack.base.babel.js +0 -242
  276. package/lib/webpack/webpack.dev.babel.js +0 -137
  277. package/lib/webpack/webpack.lib.base.babel.js +0 -205
  278. package/lib/webpack/webpack.lib.dev.babel.js +0 -49
  279. package/lib/webpack/webpack.lib.prod.babel.js +0 -77
  280. package/lib/webpack/webpack.prod.babel.js +0 -142
  281. package/lib/webpack/webpack.storybook.js +0 -87
@@ -0,0 +1,21 @@
1
+ import { readFile, writeFile } from "node:fs/promises";
2
+ import fg from "fast-glob";
3
+ import normalizePath from "normalize-path";
4
+ import { findMonoRepoRoot } from "./utils.cjs";
5
+ const monorepoRoot = normalizePath(findMonoRepoRoot() || "");
6
+ const setRegistryVersion = async () => {
7
+ const files = await fg([
8
+ `${monorepoRoot}/libs/*/package.json`,
9
+ `${monorepoRoot}/apps/*/package.json`,
10
+ `${monorepoRoot}/package.json`
11
+ ]);
12
+ Promise.all(files.map(async (file) => {
13
+ let pkgJSONData = await readFile(file, "utf8");
14
+ const pkgVersion = JSON.parse(pkgJSONData).version;
15
+ pkgJSONData = pkgJSONData.replace(/workspace:\*/g, pkgVersion);
16
+ await writeFile(file, pkgJSONData);
17
+ }));
18
+ };
19
+ export {
20
+ setRegistryVersion
21
+ };
@@ -0,0 +1,22 @@
1
+ import { readFile, writeFile } from "node:fs/promises";
2
+ import fg from "fast-glob";
3
+ import normalizePath from "normalize-path";
4
+ import { findMonoRepoRoot } from "./utils.cjs";
5
+ const monorepoRoot = normalizePath(findMonoRepoRoot() || "");
6
+ const setWorkspaceVersion = async () => {
7
+ const files = await fg([
8
+ `${monorepoRoot}/libs/*/package.json`,
9
+ `${monorepoRoot}/apps/*/package.json`,
10
+ `${monorepoRoot}/package.json`
11
+ ]);
12
+ Promise.all(files.map(async (file) => {
13
+ let pkgJSONData = await readFile(file, "utf8");
14
+ const pkgVersion = JSON.parse(pkgJSONData).version;
15
+ pkgJSONData = pkgJSONData.replace(new RegExp(pkgVersion, "g"), "workspace:*");
16
+ pkgJSONData = pkgJSONData.replace(/"version": "workspace:\*"/g, `"version": "${pkgVersion}"`);
17
+ await writeFile(file, pkgJSONData);
18
+ }));
19
+ };
20
+ export {
21
+ setWorkspaceVersion
22
+ };
@@ -0,0 +1,30 @@
1
+ const path = require('path');
2
+ const { execSync } = require('child_process');
3
+
4
+ const WORKSPACE_DIR_ENV_VAR = 'NPM_CONFIG_WORKSPACE_DIR';
5
+ const WORKSPACE_MANIFEST_FILENAME = 'pnpm-workspace.yaml';
6
+
7
+ const getPNPMWorkspaceLocation = (cwd) => {
8
+ let location = null;
9
+ const findUpExec = path.resolve(process.cwd(), path.join('node_modules', '.bin', `find-up${process.platform === 'win32' ? '.cmd' : ''}`));
10
+ for (const fileName of [WORKSPACE_MANIFEST_FILENAME, 'pnpm-workspace.yml']){
11
+ try {
12
+ const result = execSync(`${findUpExec} ${fileName}`, { cwd });
13
+ location = result.toString().trim();
14
+ break;
15
+ } catch (err) {
16
+ // ignore
17
+ }
18
+ };
19
+ return location;
20
+ };
21
+
22
+ exports.findMonoRepoRoot = (cwd = process.cwd()) => {
23
+ const workspaceManifestDirEnvVar =
24
+ process.env[WORKSPACE_DIR_ENV_VAR] ??
25
+ process.env[WORKSPACE_DIR_ENV_VAR.toLowerCase()];
26
+ const workspaceManifestLocation = workspaceManifestDirEnvVar
27
+ ? path.join(workspaceManifestDirEnvVar, 'pnpm-workspace.yaml')
28
+ : getPNPMWorkspaceLocation(cwd);
29
+ return workspaceManifestLocation && path.dirname(workspaceManifestLocation);
30
+ };
@@ -0,0 +1,4 @@
1
+ {
2
+ "type": "module",
3
+ "sideEffects": false
4
+ }
@@ -0,0 +1,18 @@
1
+ import path from "node:path";
2
+ import fs from "node:fs";
3
+ import { merge } from "lodash";
4
+ const baseConfig = {
5
+ esBuild: {
6
+ target: "es2020"
7
+ }
8
+ };
9
+ const getPUIConfig = () => {
10
+ const configPath = path.resolve(process.cwd(), "./pui.config.js");
11
+ if (!fs.existsSync(configPath))
12
+ return baseConfig;
13
+ const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
14
+ return merge(baseConfig, config);
15
+ };
16
+ export {
17
+ getPUIConfig
18
+ };
@@ -0,0 +1,31 @@
1
+ module.exports = {
2
+ branches: [
3
+ '+([0-9])?(.{+([0-9]),x}).x',
4
+ 'master',
5
+ 'next-major',
6
+ { name: 'beta', prerelease: true },
7
+ { name: 'alpha', prerelease: true },
8
+ { name: 'hotfix', prerelease: true },
9
+ { name: 'next', prerelease: true },
10
+ ],
11
+ plugins: [
12
+ '@semantic-release/commit-analyzer',
13
+ '@semantic-release/release-notes-generator',
14
+ [
15
+ '@semantic-release/changelog',
16
+ {
17
+ changelogTitle:
18
+ '# Changelog\n\nAll notable changes to this project will be documented in this file. See\n[Conventional Commits](https://conventionalcommits.org) for commit guidelines.',
19
+ },
20
+ ],
21
+ '@semantic-release/npm',
22
+ '@semantic-release/github',
23
+ [
24
+ '@semantic-release/exec',
25
+ {
26
+ successCmd:
27
+ 'scmutil get slack-release-notes && scmutil get contributors',
28
+ },
29
+ ],
30
+ ],
31
+ };
@@ -0,0 +1,42 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const allJS = /\.js$/;
5
+
6
+ const serviceEndpoints = /\.endpoint\.js$/;
7
+
8
+ const getFilesMatching = (filePattern) => {
9
+ const getFiles = (dir) => {
10
+ let routeFiles = [];
11
+ if (!fs.existsSync(dir)) return routeFiles;
12
+ fs.readdirSync(dir).forEach((file) => {
13
+ const fullPath = path.join(dir, file);
14
+ if (fs.lstatSync(fullPath).isDirectory()) {
15
+ routeFiles = routeFiles.concat(getFiles(fullPath));
16
+ } else if (filePattern.test(fullPath)) routeFiles.push(fullPath);
17
+ });
18
+ return routeFiles;
19
+ };
20
+ return getFiles;
21
+ };
22
+
23
+ const getServerRouteFiles = getFilesMatching(allJS);
24
+ const getServiceEndpoints = getFilesMatching(serviceEndpoints);
25
+
26
+ exports.loadRoutes = (app) => {
27
+ const routeFiles = getServerRouteFiles(
28
+ path.join(process.cwd(), 'server/routes'),
29
+ );
30
+ routeFiles.push(...getServiceEndpoints(path.join(process.cwd(), 'app')));
31
+ routeFiles.push(...getServiceEndpoints(path.join(process.cwd(), 'lib')));
32
+ routeFiles.forEach((routeFile) => {
33
+ // eslint-disable-next-line global-require
34
+ const init = require(routeFile);
35
+ try {
36
+ init(app);
37
+ } catch (err) {
38
+ // eslint-disable-next-line no-console
39
+ console.error(`unable to load routes from ${routeFile}. ${err.message}`);
40
+ }
41
+ });
42
+ };
@@ -0,0 +1,66 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import cspPolicy from "helmet-csp";
4
+ import crypto from "crypto";
5
+ const sources = [
6
+ "'self'",
7
+ "http://localhost:*",
8
+ "*.elliemae.io",
9
+ "*.elliemae.com",
10
+ "*.elliservices.com",
11
+ "*.ellielabs.com",
12
+ "http://pdx-col.eum-appdynamics.com",
13
+ "https://pdx-col.eum-appdynamics.com/",
14
+ "https://www.google-analytics.com",
15
+ "https://www.googletagmanager.com"
16
+ ];
17
+ const sendFileWithCSPNonce = ({
18
+ buildPath,
19
+ page = "index.html",
20
+ nonceRegex = /__CSP_NONCE__/g,
21
+ res,
22
+ fileSystem = fs
23
+ }) => {
24
+ fileSystem.readFile(path.resolve(buildPath, page), "utf8", (err, html) => {
25
+ if (err) {
26
+ res.sendStatus(404);
27
+ } else {
28
+ res.set("Content-Type", "text/html");
29
+ res.send(html.replace(nonceRegex, (res.locals || {}).cspNonce));
30
+ }
31
+ });
32
+ };
33
+ const getScriptSrc = () => {
34
+ const scriptSrc = sources.concat([
35
+ (req, res) => `'nonce-${res.locals.cspNonce}'`
36
+ ]);
37
+ return true ? scriptSrc.concat(["'unsafe-eval'"]) : scriptSrc;
38
+ };
39
+ const csp = (app) => {
40
+ app.use((req, res, next) => {
41
+ res.locals.cspNonce = crypto.randomBytes(16).toString("hex");
42
+ next();
43
+ });
44
+ app.use(cspPolicy({
45
+ directives: {
46
+ defaultSrc: ["'self'"],
47
+ baseUri: ["'self'"],
48
+ blockAllMixedContent: [],
49
+ connectSrc: sources,
50
+ fontSrc: sources.concat(["data:"]),
51
+ frameAncestors: sources,
52
+ imgSrc: sources.concat(["data:"]),
53
+ objectSrc: ["'none'"],
54
+ scriptSrc: getScriptSrc(),
55
+ scriptSrcAttr: ["'none'"],
56
+ styleSrc: sources.concat(["'unsafe-inline'"]),
57
+ upgradeInsecureRequests: [],
58
+ reportUri: "/v1/csp"
59
+ },
60
+ reportOnly: true
61
+ }));
62
+ };
63
+ export {
64
+ csp,
65
+ sendFileWithCSPNonce
66
+ };
@@ -0,0 +1,18 @@
1
+ import express from "express";
2
+ import { logger } from "./logger.js";
3
+ import {
4
+ setupDefaultMiddlewares,
5
+ setupAdditionalMiddlewars
6
+ } from "./middlewares.js";
7
+ import { port, host } from "./utils.js";
8
+ import { loadRoutes } from "./app-routes.cjs";
9
+ const app = express();
10
+ setupDefaultMiddlewares(app);
11
+ loadRoutes(app);
12
+ setupAdditionalMiddlewars(app);
13
+ app.listen(port, host, async (err) => {
14
+ if (err) {
15
+ return logger.error(err.message);
16
+ }
17
+ logger.appStarted(port, host || "localhost");
18
+ });
@@ -0,0 +1,28 @@
1
+ import chalk from "chalk";
2
+ import ip from "ip";
3
+ const divider = chalk.gray("\n-----------------------------------");
4
+ const logger = {
5
+ error: (err) => {
6
+ console.error(chalk.red(err));
7
+ },
8
+ appStarted: (port, host, tunnelStarted) => {
9
+ console.log(`Server started ! ${chalk.green("\u2713")}`);
10
+ if (tunnelStarted) {
11
+ console.log(`Tunnel initialised ${chalk.green("\u2713")}`);
12
+ }
13
+ const accessUrls = `${chalk.bold("Access URLs:")}${divider}
14
+ `;
15
+ const localHostUrl = `Localhost: ${chalk.magenta(`http://${host}:${port}`)}
16
+ `;
17
+ const lanUrl = `LAN: ${chalk.magenta(`http://${ip.address()}:${port}`)}
18
+ `;
19
+ const proxy = tunnelStarted ? `
20
+ Proxy: ${chalk.magenta(tunnelStarted)}` : "";
21
+ console.log(`${accessUrls}${localHostUrl}${lanUrl}${proxy}${divider}${chalk.blue(`
22
+ Press ${chalk.italic("CTRL-C")} to stop`)}
23
+ `);
24
+ }
25
+ };
26
+ export {
27
+ logger
28
+ };
@@ -0,0 +1,46 @@
1
+ import express from "express";
2
+ import cors from "cors";
3
+ import compression from "compression";
4
+ import expressStaticGzip from "express-static-gzip";
5
+ import expressPinoLogger from "express-pino-logger";
6
+ import { csp, sendFileWithCSPNonce } from "./csp.js";
7
+ import { getPaths } from "../webpack/helpers.js";
8
+ const paths = getPaths();
9
+ const setupDefaultMiddlewares = (app) => {
10
+ const pino = expressPinoLogger({
11
+ transport: {
12
+ target: "pino-pretty",
13
+ options: {
14
+ colorize: true
15
+ }
16
+ }
17
+ });
18
+ pino.logger.level = "warn";
19
+ app.use(pino);
20
+ app.use(cors());
21
+ app.options("*", cors());
22
+ csp(app);
23
+ app.use(express.urlencoded({ extended: false }));
24
+ app.use(express.text({ type: "text/plain" }));
25
+ app.use(express.json({ type: "application/json" }));
26
+ app.use(express.json({ type: "application/csp-report" }));
27
+ };
28
+ const setupAdditionalMiddlewars = (app, options = {}) => {
29
+ const { buildPath = paths.buildPath, basePath = paths.basePath } = options;
30
+ app.use(compression());
31
+ app.get(basePath, (req, res) => {
32
+ sendFileWithCSPNonce({ buildPath, res });
33
+ });
34
+ app.use(basePath, expressStaticGzip(buildPath, {
35
+ index: false,
36
+ enableBrotli: true,
37
+ orderPreference: ["br"]
38
+ }));
39
+ app.use(expressStaticGzip("cdn"));
40
+ app.get("*", (req, res) => sendFileWithCSPNonce({ buildPath, res }));
41
+ return app;
42
+ };
43
+ export {
44
+ setupAdditionalMiddlewars,
45
+ setupDefaultMiddlewares
46
+ };
@@ -0,0 +1,10 @@
1
+ import minimist from "minimist";
2
+ const argv = minimist(process.argv.slice(2));
3
+ const getCWD = () => process.cwd();
4
+ const port = parseInt(argv.port || process.env.port || process.env.PORT || "3000", 10);
5
+ const host = argv.host || process.env.HOST;
6
+ export {
7
+ getCWD,
8
+ host,
9
+ port
10
+ };
@@ -0,0 +1,102 @@
1
+ const path = require('path');
2
+ const normalizePath = require('normalize-path');
3
+ const { getAppConfig, basePath } = require('../utils.cjs');
4
+ const { swcrcConfig } = require('../transpile/swcrc.config.cjs');
5
+ const { findMonoRepoRoot } = require('../monorepo/utils.cjs');
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(?:\\?[a-zA-Z]+)?$': getMockFilePath('svg.js'),
65
+ '.*\\.html(?:\\?[a-zA-Z]+)?$': getMockFilePath('html.js'),
66
+ '@elliemae/pui-user-monitoring': getMockFilePath('pui-user-monitoring.js'),
67
+ '@elliemae/pui-app-loader': getMockFilePath('pui-app-loader.js'),
68
+ '@elliemae/pui-diagnostics': getMockFilePath('pui-diagnostics.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.cjs'),
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
+ testEnvironmentOptions: {
92
+ url: `http://localhost:3111${basePath}`,
93
+ },
94
+ testEnvironment: 'jsdom',
95
+ };
96
+
97
+ if (isReactModule && jestConfig.setupFilesAfterEnv)
98
+ jestConfig.setupFilesAfterEnv.push(
99
+ path.resolve(__dirname, './setup-react-env.js'),
100
+ );
101
+
102
+ exports.jestConfig = jestConfig;
@@ -0,0 +1,8 @@
1
+ const { jestConfig } = require('./jest.config.cjs');
2
+ exports.jestNodeConfig = {
3
+ ...jestConfig,
4
+ testEnvironment: 'node',
5
+ transformIgnorePatterns: [],
6
+ setupFiles: [],
7
+ setupFilesAfterEnv: [],
8
+ };
@@ -1,15 +1,18 @@
1
- module.exports = {
1
+ var axios_default = {
2
2
  defaults: {},
3
3
  interceptors: {
4
4
  request: {
5
- use: jest.fn(),
5
+ use: jest.fn()
6
6
  },
7
7
  response: {
8
- use: jest.fn(),
9
- },
8
+ use: jest.fn()
9
+ }
10
10
  },
11
11
  create: jest.fn().mockReturnThis(),
12
12
  get: jest.fn().mockResolvedValue({ data: {} }),
13
13
  post: jest.fn().mockResolvedValue({ data: {} }),
14
- put: jest.fn().mockResolvedValue({ data: {} }),
14
+ put: jest.fn().mockResolvedValue({ data: {} })
15
+ };
16
+ export {
17
+ axios_default as default
15
18
  };
@@ -0,0 +1,4 @@
1
+ var cssModule_default = "CSS_MODULE";
2
+ export {
3
+ cssModule_default as default
4
+ };
@@ -0,0 +1,4 @@
1
+ var html_default = "HTML_MODULE";
2
+ export {
3
+ html_default as default
4
+ };
@@ -0,0 +1,4 @@
1
+ var image_default = "IMAGE_MOCK";
2
+ export {
3
+ image_default as default
4
+ };
@@ -0,0 +1,24 @@
1
+ const addMatchMedia = () => {
2
+ Object.defineProperty(window, "matchMedia", {
3
+ writable: true,
4
+ value: jest.fn().mockImplementation((query) => ({
5
+ matches: false,
6
+ media: query,
7
+ onchange: null,
8
+ addListener: jest.fn(),
9
+ removeListener: jest.fn(),
10
+ addEventListener: jest.fn(),
11
+ removeEventListener: jest.fn(),
12
+ dispatchEvent: jest.fn()
13
+ }))
14
+ });
15
+ Object.defineProperty(window, "getComputedStyle", {
16
+ value: () => ({
17
+ getPropertyValue: () => {
18
+ }
19
+ })
20
+ });
21
+ };
22
+ export {
23
+ addMatchMedia
24
+ };
@@ -0,0 +1,5 @@
1
+ const load = () => {
2
+ };
3
+ export {
4
+ load
5
+ };
@@ -0,0 +1,49 @@
1
+ const logger = () => ({
2
+ setLogLevel() {
3
+ },
4
+ setOptions() {
5
+ },
6
+ info() {
7
+ },
8
+ warn() {
9
+ },
10
+ error() {
11
+ },
12
+ trace() {
13
+ },
14
+ debug() {
15
+ },
16
+ audit() {
17
+ },
18
+ fatal() {
19
+ }
20
+ });
21
+ const LogLevel = {
22
+ info: "info",
23
+ debug: "debug",
24
+ trace: "trace",
25
+ warn: "warn",
26
+ error: "error",
27
+ audit: "audit",
28
+ fatal: "fatal"
29
+ };
30
+ const Console = () => ({
31
+ log: () => {
32
+ }
33
+ });
34
+ const http = () => ({
35
+ log() {
36
+ }
37
+ });
38
+ const webvitals = () => {
39
+ };
40
+ const logUnhandledErrors = () => {
41
+ };
42
+ export {
43
+ Console,
44
+ LogLevel,
45
+ http,
46
+ logUnhandledErrors,
47
+ logger,
48
+ webvitals
49
+ };
@@ -0,0 +1,11 @@
1
+ const setCustomUserData = () => {
2
+ };
3
+ const setCustomVirtualPageName = () => {
4
+ };
5
+ const startVirtualPageMonitoringWithAutoEnd = () => {
6
+ };
7
+ export {
8
+ setCustomUserData,
9
+ setCustomVirtualPageName,
10
+ startVirtualPageMonitoringWithAutoEnd
11
+ };
@@ -0,0 +1,8 @@
1
+ const attach = jest.fn();
2
+ const detach = jest.fn();
3
+ const getConfig = jest.fn();
4
+ export {
5
+ attach,
6
+ detach,
7
+ getConfig
8
+ };
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ var svg_default = "SvgrURL";
3
+ const ReactComponent = "div";
4
+ export {
5
+ ReactComponent,
6
+ svg_default as default
7
+ };
@@ -0,0 +1,5 @@
1
+ const enableHotReloading = () => {
2
+ };
3
+ export {
4
+ enableHotReloading
5
+ };
@@ -0,0 +1,47 @@
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
+ };
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ import "jest-styled-components";
3
+ global.React = React;