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

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 (225) hide show
  1. package/dist/cjs/babel.config.cjs +97 -0
  2. package/dist/cjs/cli.js +14 -12
  3. package/dist/cjs/{cli-commands → commands}/build.js +0 -0
  4. package/dist/cjs/{cli-commands → commands}/codemod.js +0 -0
  5. package/dist/cjs/{cli-commands → commands}/gendoc.js +1 -1
  6. package/dist/cjs/{cli-commands → commands}/lint.js +2 -2
  7. package/dist/cjs/{cli-commands → commands}/pack.js +2 -2
  8. package/dist/cjs/{cli-commands → commands}/start.js +0 -0
  9. package/dist/cjs/{cli-commands → commands}/storybook.js +0 -0
  10. package/dist/cjs/{cli-commands → commands}/test.js +13 -5
  11. package/dist/cjs/{cli-commands/tsc.js → commands/tscheck.js} +26 -44
  12. package/dist/cjs/{cli-commands → commands}/utils.js +0 -0
  13. package/dist/cjs/{cli-commands → commands}/version.js +0 -0
  14. package/dist/cjs/{cli-commands → commands}/vitest.js +4 -1
  15. package/dist/cjs/index.cjs +25 -0
  16. package/dist/cjs/index.js +9 -9
  17. package/dist/cjs/{docgen/jsdoc.conf.json → jsdoc.conf.json} +0 -0
  18. package/dist/cjs/lint-config/commitlint.config.cjs +1 -0
  19. package/dist/cjs/lint-config/eslint/common.cjs +160 -0
  20. package/dist/cjs/lint-config/eslint/non-react.cjs +14 -0
  21. package/dist/cjs/lint-config/eslint/react.cjs +26 -0
  22. package/dist/cjs/lint-config/eslint/typescript/common.cjs +43 -0
  23. package/dist/cjs/lint-config/eslint/typescript/non-react.cjs +12 -0
  24. package/dist/cjs/lint-config/eslint/typescript/react.cjs +19 -0
  25. package/dist/cjs/{lint → lint-config}/lint-staged.config.js +1 -6
  26. package/dist/cjs/lint-config/prettier.config.cjs +8 -0
  27. package/dist/cjs/lint-config/stylelint.config.cjs +19 -0
  28. package/dist/cjs/monorepo/set-registry-version.js +1 -1
  29. package/dist/cjs/monorepo/set-workspace-version.js +1 -1
  30. package/dist/cjs/monorepo/utils.cjs +30 -0
  31. package/dist/cjs/{pui-config/index.js → pui-config.js} +0 -0
  32. package/dist/cjs/release.config.cjs +31 -0
  33. package/dist/cjs/server/app-routes.cjs +42 -0
  34. package/dist/cjs/server/index.js +6 -5
  35. package/dist/cjs/server/{middlewares/index.js → middlewares.js} +18 -7
  36. package/dist/cjs/{typescript/util.js → server/utils.js} +11 -7
  37. package/dist/cjs/testing/jest.config.cjs +103 -0
  38. package/dist/cjs/testing/jest.node.config.cjs +8 -0
  39. package/dist/cjs/{typescript/tsc-files/utils.js → testing/mocks/axios.js} +18 -12
  40. package/dist/cjs/{scripts/helpers/checkmark.js → testing/mocks/cssModule.js} +5 -14
  41. package/dist/cjs/testing/mocks/html.js +23 -0
  42. package/dist/cjs/testing/mocks/image.js +23 -0
  43. package/dist/cjs/testing/mocks/matchMedia.js +43 -0
  44. package/dist/cjs/testing/mocks/pui-app-loader.js +24 -0
  45. package/dist/cjs/testing/mocks/pui-diagnostics.js +68 -0
  46. package/dist/cjs/testing/mocks/pui-user-monitoring.js +30 -0
  47. package/dist/cjs/testing/mocks/retry-axios.js +27 -0
  48. package/dist/cjs/{scripts/helpers/xmark.js → testing/mocks/svg.js} +8 -10
  49. package/dist/cjs/testing/mocks/webpack-hmr.js +24 -0
  50. package/dist/cjs/testing/resolver.cjs +47 -0
  51. package/dist/cjs/{scripts/helpers/get-npm-config.js → testing/setup-test-env.js} +4 -12
  52. package/dist/cjs/testing/setup-tests.js +3 -3
  53. package/dist/cjs/testing/vitest.config.js +15 -6
  54. package/dist/cjs/transpile/.swcrc +11 -0
  55. package/dist/cjs/transpile/esbuild.js +2 -1
  56. package/dist/cjs/transpile/swcrc.config.cjs +13 -0
  57. package/dist/cjs/{scripts/update-notifier.js → update-notifier.js} +2 -2
  58. package/dist/cjs/utils.cjs +23 -0
  59. package/dist/cjs/webpack/helpers.js +1 -1
  60. package/dist/cjs/webpack/webpack.base.babel.js +2 -2
  61. package/dist/cjs/webpack/webpack.dev.babel.js +10 -6
  62. package/dist/cjs/webpack/webpack.lib.base.babel.js +7 -7
  63. package/dist/cjs/webpack/webpack.lib.prod.babel.js +3 -3
  64. package/dist/cjs/webpack/webpack.prod.babel.js +2 -2
  65. package/dist/cjs/webpack/webpack.storybook.js +122 -0
  66. package/dist/esm/babel.config.cjs +97 -0
  67. package/dist/esm/cli.js +13 -11
  68. package/dist/esm/{cli-commands → commands}/build.js +0 -0
  69. package/dist/esm/{cli-commands → commands}/codemod.js +0 -0
  70. package/dist/esm/{cli-commands → commands}/gendoc.js +1 -1
  71. package/dist/esm/{cli-commands → commands}/lint.js +1 -1
  72. package/dist/esm/{cli-commands → commands}/pack.js +1 -1
  73. package/dist/esm/{cli-commands → commands}/start.js +0 -0
  74. package/dist/esm/{cli-commands → commands}/storybook.js +0 -0
  75. package/dist/esm/{cli-commands → commands}/test.js +13 -5
  76. package/dist/esm/commands/tscheck.js +65 -0
  77. package/dist/esm/{cli-commands → commands}/utils.js +0 -0
  78. package/dist/esm/{cli-commands → commands}/version.js +0 -0
  79. package/dist/esm/{cli-commands → commands}/vitest.js +4 -1
  80. package/dist/esm/index.cjs +25 -0
  81. package/dist/esm/index.js +8 -8
  82. package/dist/esm/{docgen/jsdoc.conf.json → jsdoc.conf.json} +0 -0
  83. package/dist/esm/lint-config/commitlint.config.cjs +1 -0
  84. package/dist/esm/lint-config/eslint/common.cjs +160 -0
  85. package/dist/esm/lint-config/eslint/non-react.cjs +14 -0
  86. package/dist/esm/lint-config/eslint/react.cjs +26 -0
  87. package/dist/esm/lint-config/eslint/typescript/common.cjs +43 -0
  88. package/dist/esm/lint-config/eslint/typescript/non-react.cjs +12 -0
  89. package/dist/esm/lint-config/eslint/typescript/react.cjs +19 -0
  90. package/dist/esm/{lint → lint-config}/lint-staged.config.js +1 -5
  91. package/dist/esm/lint-config/prettier.config.cjs +8 -0
  92. package/dist/esm/lint-config/stylelint.config.cjs +19 -0
  93. package/dist/esm/monorepo/set-registry-version.js +1 -1
  94. package/dist/esm/monorepo/set-workspace-version.js +1 -1
  95. package/dist/esm/monorepo/utils.cjs +30 -0
  96. package/dist/esm/{pui-config/index.js → pui-config.js} +0 -0
  97. package/dist/esm/release.config.cjs +31 -0
  98. package/dist/esm/server/app-routes.cjs +42 -0
  99. package/dist/esm/server/index.js +3 -2
  100. package/dist/esm/server/middlewares.js +46 -0
  101. package/dist/esm/server/utils.js +10 -0
  102. package/dist/esm/testing/jest.config.cjs +103 -0
  103. package/dist/esm/testing/jest.node.config.cjs +8 -0
  104. package/dist/esm/testing/mocks/axios.js +18 -0
  105. package/dist/esm/testing/mocks/cssModule.js +4 -0
  106. package/dist/esm/testing/mocks/html.js +4 -0
  107. package/dist/esm/testing/mocks/image.js +4 -0
  108. package/dist/esm/testing/mocks/matchMedia.js +24 -0
  109. package/dist/esm/testing/mocks/pui-app-loader.js +5 -0
  110. package/dist/esm/testing/mocks/pui-diagnostics.js +49 -0
  111. package/dist/esm/testing/mocks/pui-user-monitoring.js +11 -0
  112. package/dist/esm/testing/mocks/retry-axios.js +8 -0
  113. package/dist/esm/testing/mocks/svg.js +7 -0
  114. package/dist/esm/testing/mocks/webpack-hmr.js +5 -0
  115. package/dist/esm/testing/resolver.cjs +47 -0
  116. package/dist/esm/testing/setup-test-env.js +4 -0
  117. package/dist/esm/testing/setup-tests.js +2 -2
  118. package/dist/esm/testing/vitest.config.js +13 -5
  119. package/dist/esm/transpile/.swcrc +11 -0
  120. package/dist/esm/transpile/esbuild.js +2 -1
  121. package/dist/esm/transpile/swcrc.config.cjs +13 -0
  122. package/dist/esm/{scripts/update-notifier.js → update-notifier.js} +2 -2
  123. package/dist/esm/utils.cjs +23 -0
  124. package/dist/esm/webpack/helpers.js +1 -1
  125. package/dist/esm/webpack/webpack.base.babel.js +3 -3
  126. package/dist/esm/webpack/webpack.dev.babel.js +8 -5
  127. package/dist/esm/webpack/webpack.lib.base.babel.js +7 -12
  128. package/dist/esm/webpack/webpack.lib.prod.babel.js +2 -2
  129. package/dist/esm/webpack/webpack.prod.babel.js +2 -2
  130. package/dist/esm/webpack/webpack.storybook.js +102 -0
  131. package/dist/types/{babel/babel.config.d.cts → babel.config.d.cts} +0 -0
  132. package/dist/types/{cli-commands → commands}/build.d.ts +0 -0
  133. package/dist/types/{cli-commands → commands}/codemod.d.ts +0 -0
  134. package/dist/types/{cli-commands → commands}/gendoc.d.ts +0 -0
  135. package/dist/types/{cli-commands → commands}/lint.d.ts +0 -0
  136. package/dist/types/{cli-commands → commands}/pack.d.ts +0 -0
  137. package/dist/types/{cli-commands → commands}/start.d.ts +0 -0
  138. package/dist/types/{cli-commands → commands}/storybook.d.ts +0 -0
  139. package/dist/types/{cli-commands → commands}/test.d.ts +10 -6
  140. package/dist/types/commands/tscheck.d.ts +14 -0
  141. package/dist/types/{cli-commands → commands}/utils.d.ts +0 -0
  142. package/dist/types/{cli-commands → commands}/version.d.ts +0 -0
  143. package/dist/types/{cli-commands → commands}/vitest.d.ts +0 -0
  144. package/dist/types/index.d.cts +10 -0
  145. package/dist/types/index.d.ts +8 -8
  146. package/dist/types/{lint → lint-config}/commitlint.config.d.cts +0 -0
  147. package/dist/types/{lint → lint-config}/eslint/common.d.cts +15 -12
  148. package/dist/types/{lint → lint-config}/eslint/non-react.d.cts +6 -1
  149. package/dist/types/{lint → lint-config}/eslint/react.d.cts +6 -1
  150. package/dist/types/{lint → lint-config}/eslint/typescript/common.d.cts +2 -2
  151. package/dist/types/{lint → lint-config}/eslint/typescript/non-react.d.cts +1 -1
  152. package/dist/types/{lint → lint-config}/eslint/typescript/react.d.cts +1 -1
  153. package/dist/types/{lint → lint-config}/lint-staged.config.d.ts +0 -0
  154. package/dist/types/{lint → lint-config}/prettier.config.d.cts +0 -0
  155. package/dist/types/{lint → lint-config}/stylelint.config.d.cts +1 -0
  156. package/dist/types/monorepo/utils.d.cts +1 -0
  157. package/dist/types/{pui-config/index.d.ts → pui-config.d.ts} +0 -0
  158. package/dist/types/{release/release.config.d.cts → release.config.d.cts} +0 -0
  159. package/dist/types/server/app-routes.d.cts +1 -0
  160. package/dist/types/server/{middlewares/index.d.ts → middlewares.d.ts} +1 -1
  161. package/dist/types/server/{util/index.d.ts → utils.d.ts} +0 -1
  162. package/dist/types/testing/jest.config.d.cts +3 -3
  163. package/dist/types/testing/jest.node.config.d.cts +4 -4
  164. package/dist/types/testing/mocks/axios.d.ts +17 -0
  165. package/dist/types/testing/mocks/cssModule.d.ts +2 -0
  166. package/dist/types/testing/mocks/html.d.ts +2 -0
  167. package/dist/types/testing/mocks/image.d.ts +2 -0
  168. package/dist/types/testing/mocks/matchMedia.d.ts +1 -0
  169. package/dist/types/testing/mocks/{pui-app-loader.d.cts → pui-app-loader.d.ts} +0 -0
  170. package/dist/types/testing/mocks/{pui-diagnostics.d.cts → pui-diagnostics.d.ts} +0 -0
  171. package/dist/types/testing/mocks/{pui-user-monitoring.d.cts → pui-user-monitoring.d.ts} +0 -0
  172. package/dist/types/testing/mocks/{retry-axios.d.cts → retry-axios.d.ts} +0 -0
  173. package/dist/types/testing/mocks/{svg.d.cts → svg.d.ts} +1 -1
  174. package/dist/types/testing/mocks/{webpack-hmr.d.cts → webpack-hmr.d.ts} +0 -0
  175. package/dist/types/testing/setup-test-env.d.ts +2 -0
  176. package/dist/types/testing/vitest.config.d.ts +1 -1
  177. package/dist/types/transpile/swcrc.config.d.cts +1 -1
  178. package/dist/types/update-notifier.d.ts +1 -0
  179. package/dist/types/utils.d.cts +2 -1
  180. package/dist/types/webpack/helpers.d.ts +1 -1
  181. package/dist/types/webpack/webpack.dev.babel.d.ts +2 -1
  182. package/dist/types/webpack/webpack.lib.dev.babel.d.ts +1 -1
  183. package/dist/types/webpack/webpack.lib.prod.babel.d.ts +20 -4
  184. package/dist/types/webpack/webpack.prod.babel.d.ts +1 -1
  185. package/dist/types/webpack/{webpack.storybook.d.cts → webpack.storybook.d.ts} +0 -0
  186. package/package.json +98 -93
  187. package/dist/cjs/monorepo/utils.js +0 -34
  188. package/dist/cjs/scripts/helpers/progress.js +0 -35
  189. package/dist/cjs/scripts/npmcheckversion.js +0 -8
  190. package/dist/cjs/server/middlewares/addProdMiddlewares.js +0 -44
  191. package/dist/cjs/server/util/index.js +0 -68
  192. package/dist/cjs/testing/vitest.setup.js +0 -0
  193. package/dist/cjs/typescript/tsc-files/index.js +0 -68
  194. package/dist/esm/cli-commands/tsc.js +0 -83
  195. package/dist/esm/monorepo/utils.js +0 -12
  196. package/dist/esm/scripts/helpers/checkmark.js +0 -10
  197. package/dist/esm/scripts/helpers/get-npm-config.js +0 -5
  198. package/dist/esm/scripts/helpers/progress.js +0 -13
  199. package/dist/esm/scripts/helpers/xmark.js +0 -9
  200. package/dist/esm/scripts/npmcheckversion.js +0 -8
  201. package/dist/esm/server/middlewares/addProdMiddlewares.js +0 -22
  202. package/dist/esm/server/middlewares/index.js +0 -35
  203. package/dist/esm/server/util/index.js +0 -46
  204. package/dist/esm/testing/vitest.setup.js +0 -0
  205. package/dist/esm/typescript/tsc-files/index.js +0 -55
  206. package/dist/esm/typescript/tsc-files/utils.js +0 -12
  207. package/dist/esm/typescript/util.js +0 -6
  208. package/dist/types/cli-commands/tsc.d.ts +0 -20
  209. package/dist/types/monorepo/utils.d.ts +0 -1
  210. package/dist/types/scripts/helpers/checkmark.d.ts +0 -7
  211. package/dist/types/scripts/helpers/get-npm-config.d.ts +0 -2
  212. package/dist/types/scripts/helpers/progress.d.ts +0 -7
  213. package/dist/types/scripts/helpers/xmark.d.ts +0 -6
  214. package/dist/types/scripts/npmcheckversion.d.ts +0 -1
  215. package/dist/types/scripts/update-notifier.d.ts +0 -2
  216. package/dist/types/server/middlewares/addProdMiddlewares.d.ts +0 -1
  217. package/dist/types/testing/mocks/axios.d.cts +0 -14
  218. package/dist/types/testing/mocks/cssModule.d.cts +0 -2
  219. package/dist/types/testing/mocks/html.d.cts +0 -2
  220. package/dist/types/testing/mocks/image.d.cts +0 -2
  221. package/dist/types/testing/mocks/matchMedia.d.cts +0 -2
  222. package/dist/types/testing/vitest.setup.d.ts +0 -0
  223. package/dist/types/typescript/tsc-files/index.d.ts +0 -1
  224. package/dist/types/typescript/tsc-files/utils.d.ts +0 -3
  225. package/dist/types/typescript/util.d.ts +0 -1
@@ -0,0 +1,26 @@
1
+ const {
2
+ baseExtends,
3
+ baseRules,
4
+ baseOverrides,
5
+ baseConfig,
6
+ reactRules,
7
+ } = require('./common.cjs');
8
+ const { tsReactConfig } = require('./typescript/react.cjs');
9
+
10
+ exports.esReactConfig = {
11
+ ...baseConfig,
12
+ extends: ['airbnb', 'airbnb/hooks', 'plugin:redux-saga/recommended'].concat(
13
+ baseExtends,
14
+ ),
15
+ rules: {
16
+ ...baseRules,
17
+ ...reactRules,
18
+ },
19
+ overrides: baseOverrides.concat([
20
+ tsReactConfig,
21
+ {
22
+ files: '*.mdx',
23
+ extends: 'plugin:mdx/recommended',
24
+ },
25
+ ]),
26
+ };
@@ -0,0 +1,43 @@
1
+ const { baseExtends, basePlugins } = require('../common.cjs');
2
+
3
+ exports.tsBaseExtends = [
4
+ 'plugin:@typescript-eslint/recommended',
5
+ 'plugin:import/typescript',
6
+ 'plugin:@typescript-eslint/recommended-requiring-type-checking',
7
+ ].concat(baseExtends);
8
+
9
+ exports.tsBaseRules = {
10
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
11
+ '@typescript-eslint/explicit-function-return-type': 'off',
12
+ '@typescript-eslint/no-use-before-define': [
13
+ 'error',
14
+ { functions: false, classes: true, variables: true, typedefs: true },
15
+ ],
16
+ 'max-lines': ['error', { max: 200, skipComments: true }],
17
+ '@typescript-eslint/unbound-method': [
18
+ 'error',
19
+ {
20
+ ignoreStatic: true,
21
+ },
22
+ ],
23
+ };
24
+
25
+ exports.tsBaseConfig = {
26
+ files: ['*.ts', '*.tsx'],
27
+ parser: '@typescript-eslint/parser',
28
+ plugins: ['@typescript-eslint'].concat(basePlugins),
29
+ parserOptions: {
30
+ tsconfigRootDir: process.cwd(),
31
+ project: 'tsconfig.json',
32
+ },
33
+ settings: {
34
+ 'import/resolver': {
35
+ typescript: {
36
+ alwaysTryTypes: true,
37
+ },
38
+ },
39
+ 'import/parsers': {
40
+ '@typescript-eslint/parser': ['.ts', '.tsx'],
41
+ },
42
+ },
43
+ };
@@ -0,0 +1,12 @@
1
+ /* eslint-disable max-lines */
2
+ const { baseRules } = require('../common.cjs');
3
+ const { tsBaseExtends, tsBaseRules, tsBaseConfig } = require('./common.cjs');
4
+
5
+ exports.tsConfig = {
6
+ ...tsBaseConfig,
7
+ extends: ['airbnb-base', 'airbnb-typescript/base'].concat(tsBaseExtends),
8
+ rules: {
9
+ ...baseRules,
10
+ ...tsBaseRules,
11
+ },
12
+ };
@@ -0,0 +1,19 @@
1
+ /* eslint-disable max-lines */
2
+ const { baseRules, reactRules } = require('../common.cjs');
3
+ const { tsBaseExtends, tsBaseRules, tsBaseConfig } = require('./common.cjs');
4
+
5
+ exports.tsReactConfig = {
6
+ ...tsBaseConfig,
7
+ extends: [
8
+ 'airbnb',
9
+ 'airbnb/hooks',
10
+ 'plugin:redux-saga/recommended',
11
+ 'airbnb-typescript',
12
+ ].concat(tsBaseExtends),
13
+ rules: {
14
+ ...baseRules,
15
+ ...tsBaseRules,
16
+ ...reactRules,
17
+ 'react/prop-types': 0,
18
+ },
19
+ };
@@ -1,13 +1,9 @@
1
1
  import path from "node:path";
2
- import { fileURLToPath } from "node:url";
3
2
  import fs from "node:fs";
4
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
5
3
  const npmClient = fs.existsSync(path.join(process.cwd(), "pnpm-lock.yaml")) ? "pnpm" : "npm";
6
4
  const lintStagedConfig = {
7
5
  "*.{js,ts,jsx,tsx,md,mdx,html,css,json}": ["prettier --write"],
8
- "*.{ts,tsx}": [
9
- `node ${path.resolve(__dirname, "../typescript/tsc-files/index.js")} --noEmit --emitDeclarationOnly false`
10
- ],
6
+ "*.{ts,tsx}": [`${npmClient} run tscheck`],
11
7
  "*.{js,ts,jsx,tsx}": [
12
8
  `${npmClient} run lint:fix`,
13
9
  `${npmClient} run test:staged`,
@@ -0,0 +1,8 @@
1
+ exports.prettierConfig = {
2
+ printWidth: 80,
3
+ tabWidth: 2,
4
+ useTabs: false,
5
+ semi: true,
6
+ singleQuote: true,
7
+ trailingComma: 'all',
8
+ };
@@ -0,0 +1,19 @@
1
+ exports.stylelintConfig = {
2
+ ignoreFiles: [
3
+ '/dist/**/*',
4
+ '/coverage/**/*',
5
+ '/build/**/*',
6
+ '/reports/**/*',
7
+ '/temp/**/*',
8
+ '/docs/**/*',
9
+ '/demo/**/*',
10
+ '/node_modules/**/*',
11
+ '/vendor/**/*',
12
+ ],
13
+ customSyntax: '@stylelint/postcss-css-in-js',
14
+ extends: [
15
+ 'stylelint-config-recommended',
16
+ 'stylelint-config-styled-components',
17
+ ],
18
+ rules: { 'selector-type-no-unknown': null, 'no-extra-semicolons': null, 'function-no-unknown': null },
19
+ };
@@ -1,7 +1,7 @@
1
1
  import { readFile, writeFile } from "node:fs/promises";
2
2
  import fg from "fast-glob";
3
3
  import normalizePath from "normalize-path";
4
- import { findMonoRepoRoot } from "./utils.js";
4
+ import { findMonoRepoRoot } from "./utils.cjs";
5
5
  const monorepoRoot = normalizePath(findMonoRepoRoot() || "");
6
6
  const setRegistryVersion = async () => {
7
7
  const files = await fg([
@@ -1,7 +1,7 @@
1
1
  import { readFile, writeFile } from "node:fs/promises";
2
2
  import fg from "fast-glob";
3
3
  import normalizePath from "normalize-path";
4
- import { findMonoRepoRoot } from "./utils.js";
4
+ import { findMonoRepoRoot } from "./utils.cjs";
5
5
  const monorepoRoot = normalizePath(findMonoRepoRoot() || "");
6
6
  const setWorkspaceVersion = async () => {
7
7
  const files = await fg([
@@ -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
+ // eslint-disable-next-line no-restricted-syntax
10
+ for (const fileName of [WORKSPACE_MANIFEST_FILENAME, 'pnpm-workspace.yml']) {
11
+ try {
12
+ const result = execSync(`npx find-up ${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
+ };
File without changes
@@ -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
+ };
@@ -3,8 +3,9 @@ import { logger } from "./logger.js";
3
3
  import {
4
4
  setupDefaultMiddlewares,
5
5
  setupAdditionalMiddlewars
6
- } from "./middlewares/index.js";
7
- import { loadRoutes, port, host } from "./util/index.js";
6
+ } from "./middlewares.js";
7
+ import { port, host } from "./utils.js";
8
+ import { loadRoutes } from "./app-routes.cjs";
8
9
  const app = express();
9
10
  setupDefaultMiddlewares(app);
10
11
  loadRoutes(app);
@@ -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,103 @@
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
+ watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
96
+ };
97
+
98
+ if (isReactModule && jestConfig.setupFilesAfterEnv)
99
+ jestConfig.setupFilesAfterEnv.push(
100
+ path.resolve(__dirname, './setup-react-env.js'),
101
+ );
102
+
103
+ 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
+ };
@@ -0,0 +1,18 @@
1
+ var axios_default = {
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
+ };
16
+ export {
17
+ axios_default as default
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,4 @@
1
+ import * as React from "react";
2
+ import "jest-styled-components";
3
+ import "@testing-library/jest-dom/extend-expect";
4
+ global.React = React;