@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
@@ -0,0 +1,83 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import path from "node:path";
21
+ import yargs from "yargs";
22
+ import { spawnSync } from "child_process";
23
+ import fs from "fs";
24
+ import { logInfo, logError } from "./utils.js";
25
+ const randomChars = () => Math.random().toString(36).slice(2);
26
+ const resolveFromRoot = (...paths) => path.join(process.cwd(), ...paths);
27
+ const validateTypescript = async () => {
28
+ const args = process.argv.slice(2);
29
+ const argsProjectIndex = args.findIndex((arg) => ["-p", "--project"].includes(arg));
30
+ const argsProjectValue = argsProjectIndex !== -1 ? args[argsProjectIndex + 1] : void 0;
31
+ const files = args.filter((file) => /\.(ts|tsx)$/.test(file));
32
+ if (files.length === 0) {
33
+ process.exit(0);
34
+ }
35
+ const remainingArgsToForward = args.slice().filter((arg) => !files.includes(arg));
36
+ if (argsProjectIndex !== -1) {
37
+ remainingArgsToForward.splice(argsProjectIndex, 2);
38
+ }
39
+ const tsconfigPath = argsProjectValue || resolveFromRoot("tsconfig.json");
40
+ const tsconfigContent = fs.readFileSync(tsconfigPath).toString();
41
+ let tsconfig = {};
42
+ eval(`tsconfig = ${tsconfigContent}`);
43
+ const tmpTsconfigPath = resolveFromRoot(`tsconfig.${randomChars()}.json`);
44
+ const tmpTsconfig = __spreadProps(__spreadValues({}, tsconfig), {
45
+ compilerOptions: __spreadProps(__spreadValues({}, tsconfig.compilerOptions), {
46
+ skipLibCheck: true
47
+ }),
48
+ files,
49
+ include: ["shared/typings"]
50
+ });
51
+ fs.writeFileSync(tmpTsconfigPath, JSON.stringify(tmpTsconfig, null, 2));
52
+ const { status } = spawnSync("tsc", ["-p", tmpTsconfigPath, ...remainingArgsToForward], { stdio: "inherit" });
53
+ fs.unlinkSync(tmpTsconfigPath);
54
+ process.exit(status);
55
+ };
56
+ const tscCmd = {
57
+ handler: async (argv) => {
58
+ try {
59
+ await validateTypescript(argv.p);
60
+ logInfo("Typescript validation started");
61
+ } catch (err) {
62
+ logError("Typescript validation failed", err);
63
+ yargs().exit(-1, err);
64
+ }
65
+ },
66
+ command: "tsc [options]",
67
+ describe: "validate typescript code",
68
+ builder: {
69
+ project: {
70
+ alias: "p",
71
+ type: "boolean",
72
+ default: false
73
+ },
74
+ docs: {
75
+ type: "boolean",
76
+ default: false
77
+ }
78
+ }
79
+ };
80
+ export {
81
+ tscCmd,
82
+ validateTypescript
83
+ };
@@ -0,0 +1,120 @@
1
+ import path from "node:path";
2
+ import { readFile, writeFile, mkdir, readdir, copyFile } from "fs/promises";
3
+ import { execaCommand } from "execa";
4
+ import chalk from "chalk";
5
+ import {
6
+ getPaths,
7
+ isAppLoaderEnabled,
8
+ getAppVersion,
9
+ LATEST_VERSION
10
+ } from "../webpack/helpers.js";
11
+ const browsersMapping = {
12
+ and_chr: "Chrome for Android",
13
+ chrome: "Google Chrome",
14
+ edge: "Microsoft Edge",
15
+ firefox: "Mozilla Firefox",
16
+ ios_saf: "iOS Safari",
17
+ safari: "Safari",
18
+ samsung: "Samsung Internet"
19
+ };
20
+ const exec = async (command, options = { stdio: "inherit" }) => execaCommand(command, options);
21
+ const logInfo = console.log;
22
+ const logSuccess = (...args) => console.log(chalk.green(...args));
23
+ const logError = console.error;
24
+ const readPackageLock = async () => {
25
+ try {
26
+ const appPkgLockFile = path.join(process.cwd(), "package-lock.json");
27
+ const pkgLockJSON = await readFile(appPkgLockFile, "utf8");
28
+ const { dependencies } = JSON.parse(pkgLockJSON);
29
+ return (moduleName) => dependencies[moduleName]?.version || "";
30
+ } catch (err) {
31
+ console.warn("Package lock file not found");
32
+ return () => "";
33
+ }
34
+ };
35
+ const getSupportedBrowsers = async () => {
36
+ const { stdout } = await exec("npx --no-install browserslist", {
37
+ stdout: "pipe"
38
+ });
39
+ const browserVersions = stdout && stdout.split("\n") || [];
40
+ return browserVersions.reduce((acc, nameVersion) => {
41
+ const [name, version] = nameVersion.split(" ");
42
+ const versionRange = version.split("-");
43
+ acc[browsersMapping[name]] = versionRange && versionRange[0] || version;
44
+ return acc;
45
+ }, {});
46
+ };
47
+ const getModulesInfo = async () => {
48
+ try {
49
+ const getModuleVersion = await readPackageLock();
50
+ return {
51
+ react: getModuleVersion("react"),
52
+ "react-dom": getModuleVersion("react-dom"),
53
+ "app-react-dependencies": getModuleVersion("@elliemae/app-react-dependencies"),
54
+ "app-sdk": getModuleVersion("@elliemae/pui-app-sdk"),
55
+ cli: getModuleVersion("@elliemae/pui-cli"),
56
+ dimsum: getModuleVersion("@elliemae/ds-system")
57
+ };
58
+ } catch (err) {
59
+ console.warn(err);
60
+ return {};
61
+ }
62
+ };
63
+ const writeAppInfo = async () => {
64
+ const appInfo = {
65
+ timestamp: new Date().toISOString(),
66
+ modules: await getModulesInfo(),
67
+ browserSupport: await getSupportedBrowsers(),
68
+ screenReaderSupport: [
69
+ "JAWS with Chrome",
70
+ "NVDA with Chrome",
71
+ "VoiceOver with Safari",
72
+ "iOS VoiceOver",
73
+ "Android Talkback"
74
+ ]
75
+ };
76
+ const infoJSON = JSON.stringify(appInfo, null, 2);
77
+ const { buildPath: versionedPath } = getPaths();
78
+ [
79
+ path.join(versionedPath, "info.json"),
80
+ path.join(process.cwd(), "build", "public", "info.json")
81
+ ].forEach(async (infoPath) => writeFile(infoPath, infoJSON));
82
+ };
83
+ const copyDir = async (src, dest) => {
84
+ const entries = await readdir(src, {
85
+ withFileTypes: true
86
+ });
87
+ await mkdir(dest);
88
+ return Promise.all(entries.map((entry) => {
89
+ const srcPath = path.join(src, entry.name);
90
+ const destPath = path.join(dest, entry.name);
91
+ if (entry.isDirectory()) {
92
+ return copyDir(srcPath, destPath);
93
+ }
94
+ return copyFile(srcPath, destPath);
95
+ }));
96
+ };
97
+ const updateManifestWithVersionInfo = async (dest) => {
98
+ const manifestFile = path.join(dest, "manifest.json");
99
+ let manifestData = await readFile(manifestFile, "utf8");
100
+ manifestData = manifestData.replace(/latest\//g, `${getAppVersion()}/`);
101
+ await writeFile(manifestFile, manifestData);
102
+ };
103
+ const copyBuildAssetsToVersionedFolder = async () => {
104
+ const appVersion = getAppVersion();
105
+ const isVersionedApp = isAppLoaderEnabled() && appVersion !== LATEST_VERSION;
106
+ if (!isVersionedApp)
107
+ return;
108
+ const src = path.resolve(process.cwd(), "build/public/latest");
109
+ const dest = path.resolve(process.cwd(), `build/public/${appVersion}`);
110
+ await copyDir(src, dest);
111
+ await updateManifestWithVersionInfo(dest);
112
+ };
113
+ export {
114
+ copyBuildAssetsToVersionedFolder,
115
+ exec,
116
+ logError,
117
+ logInfo,
118
+ logSuccess,
119
+ writeAppInfo
120
+ };
@@ -0,0 +1,49 @@
1
+ import yargs from "yargs";
2
+ import { exec, logError } from "./utils.js";
3
+ import { setWorkspaceVersion } from "../monorepo/set-workspace-version.js";
4
+ import { setRegistryVersion } from "../monorepo/set-registry-version.js";
5
+ import { deleteMergedTags } from "../monorepo/delete-merged-tags.js";
6
+ const version = async (lernaOptions = "") => {
7
+ await exec(`cross-env NODE_ENV=production lerna version --conventional-commits --exact --create-release github --force-publish --yes ${lernaOptions}`);
8
+ };
9
+ const versionCmd = {
10
+ handler: async (argv) => {
11
+ try {
12
+ if (argv.deleteTags) {
13
+ await deleteMergedTags();
14
+ } else if (argv.useRegistry) {
15
+ await setRegistryVersion();
16
+ } else if (argv.useWorkspace) {
17
+ await setWorkspaceVersion();
18
+ } else {
19
+ await version(argv.lernaOptions);
20
+ }
21
+ } catch (err) {
22
+ logError("Monorepo versioning failed", err);
23
+ yargs().exit(-1, err);
24
+ }
25
+ },
26
+ command: "version [options]",
27
+ describe: "version monorepo",
28
+ builder: {
29
+ deleteTags: {
30
+ type: "boolean",
31
+ default: false
32
+ },
33
+ useRegistry: {
34
+ type: "boolean",
35
+ default: false
36
+ },
37
+ useWorkspace: {
38
+ type: "boolean",
39
+ default: false
40
+ },
41
+ lernaOptions: {
42
+ type: "string",
43
+ default: false
44
+ }
45
+ }
46
+ };
47
+ export {
48
+ versionCmd
49
+ };
@@ -0,0 +1,61 @@
1
+ import yargs from "yargs";
2
+ import { exec, logError, logSuccess } from "./utils.js";
3
+ const { CI = false } = process.env;
4
+ const configPath = new URL("../testing/vitest.config.ts", import.meta.url);
5
+ const test = async (commandOptions) => {
6
+ await exec(`cross-env FORCE_COLOR=true vitest --config ${configPath} ${commandOptions}`);
7
+ };
8
+ const vitestCmd = {
9
+ handler: async (argv) => {
10
+ let commandOptions = "--coverage";
11
+ if (argv.fix)
12
+ commandOptions = "-u";
13
+ else if (argv.watch)
14
+ commandOptions = "--watch";
15
+ if (argv.p)
16
+ commandOptions += " --passWithNoTests";
17
+ if (argv.r)
18
+ commandOptions += " --related";
19
+ if (argv.s)
20
+ commandOptions += " --silent";
21
+ try {
22
+ if (CI) {
23
+ await exec("rimraf ./reports");
24
+ }
25
+ await test(commandOptions);
26
+ logSuccess("Unit test execution completed");
27
+ } catch (err) {
28
+ logError("Unit test execution failed", err);
29
+ yargs().exit(-1, err);
30
+ return -1;
31
+ }
32
+ return 0;
33
+ },
34
+ command: "vitest [options]",
35
+ describe: "unit tests application code using vitest",
36
+ builder: {
37
+ fix: {
38
+ alias: "f",
39
+ type: "boolean"
40
+ },
41
+ watch: {
42
+ alias: "w",
43
+ type: "boolean"
44
+ },
45
+ passWithNoTests: {
46
+ alias: "p",
47
+ type: "boolean"
48
+ },
49
+ related: {
50
+ alias: "r",
51
+ type: "boolean"
52
+ },
53
+ silent: {
54
+ alias: "s",
55
+ type: "boolean"
56
+ }
57
+ }
58
+ };
59
+ export {
60
+ vitestCmd
61
+ };
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import yargs from "yargs";
5
+ import { hideBin } from "yargs/helpers";
6
+ import { config as envConfig } from "dotenv";
7
+ import notifyUpdates from "./scripts/update-notifier.js";
8
+ import { buildCmd } from "./cli-commands/build.js";
9
+ import { packCmd } from "./cli-commands/pack.js";
10
+ import { startCmd } from "./cli-commands/start.js";
11
+ import { testCmd } from "./cli-commands/test.js";
12
+ import { lintCmd } from "./cli-commands/lint.js";
13
+ import { gendocCmd } from "./cli-commands/gendoc.js";
14
+ import { codemodCmd } from "./cli-commands/codemod.js";
15
+ import { storybookCmd } from "./cli-commands/storybook.js";
16
+ import { vitestCmd } from "./cli-commands/vitest.js";
17
+ import { versionCmd } from "./cli-commands/version.js";
18
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
19
+ envConfig();
20
+ process.env.PATH += path.delimiter + path.join(__dirname, "..", "node_modules", ".bin");
21
+ yargs(hideBin(process.argv)).command(buildCmd).help().argv;
22
+ yargs(hideBin(process.argv)).command(packCmd).help().argv;
23
+ yargs(hideBin(process.argv)).command(startCmd).help().argv;
24
+ yargs(hideBin(process.argv)).command(testCmd).help().argv;
25
+ yargs(hideBin(process.argv)).command(lintCmd).help().argv;
26
+ yargs(hideBin(process.argv)).command(gendocCmd).help().argv;
27
+ yargs(hideBin(process.argv)).command(codemodCmd).help().argv;
28
+ yargs(hideBin(process.argv)).command(storybookCmd).help().argv;
29
+ yargs(hideBin(process.argv)).command(vitestCmd).help().argv;
30
+ yargs(hideBin(process.argv)).command(versionCmd).help().argv;
31
+ notifyUpdates();
@@ -0,0 +1,17 @@
1
+ {
2
+ "plugins": ["plugins/markdown"],
3
+ "opts": {
4
+ "template": "node_modules/docdash"
5
+ },
6
+ "docdash": {
7
+ "sort": true,
8
+ "search": true,
9
+ "collapse": true,
10
+ "wrap": true
11
+ },
12
+ "templates": {
13
+ "default": {
14
+ "includeDate": false
15
+ }
16
+ }
17
+ }
File without changes
@@ -0,0 +1,22 @@
1
+ import { babelConfig } from "./babel/babel.config.cjs";
2
+ import { esConfig } from "./lint/eslint/non-react.cjs";
3
+ import { esReactConfig } from "./lint/eslint/react.cjs";
4
+ import { stylelintConfig } from "./lint/stylelint.config.cjs";
5
+ import { prettierConfig } from "./lint/prettier.config.cjs";
6
+ import { commitlintConfig } from "./lint/commitlint.config.cjs";
7
+ import { jestConfig } from "./testing/jest.config.cjs";
8
+ import { jestNodeConfig } from "./testing/jest.node.config.cjs";
9
+ import { lintStagedConfig } from "./lint/lint-staged.config.js";
10
+ import { loadRoutes } from "./server/util/index.js";
11
+ export {
12
+ babelConfig,
13
+ commitlintConfig,
14
+ esConfig as eslintBaseConfig,
15
+ esReactConfig as eslintConfig,
16
+ jestConfig,
17
+ jestNodeConfig,
18
+ lintStagedConfig,
19
+ loadRoutes,
20
+ prettierConfig,
21
+ stylelintConfig
22
+ };
@@ -0,0 +1,19 @@
1
+ import path from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import fs from "node:fs";
4
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
5
+ const npmClient = fs.existsSync(path.join(process.cwd(), "pnpm-lock.yaml")) ? "pnpm" : "npm";
6
+ const lintStagedConfig = {
7
+ "*.{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
+ ],
11
+ "*.{js,ts,jsx,tsx}": [
12
+ `${npmClient} run lint:fix`,
13
+ `${npmClient} run test:staged`,
14
+ `${npmClient} run gendoc`
15
+ ]
16
+ };
17
+ export {
18
+ lintStagedConfig
19
+ };
@@ -0,0 +1,38 @@
1
+ import { execSync } from "child_process";
2
+ const cwd = process.cwd();
3
+ const execaOptions = { cwd, stdio: "inherit" };
4
+ const semVerRegEx = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
5
+ const isSemVersion = (tagName) => semVerRegEx.test(tagName);
6
+ const branchName = (process.env.BRANCH_NAME || "master").toLowerCase();
7
+ const branchTags = {
8
+ master: /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/,
9
+ next: /^v.*-next\.(0|[1-9]\d*)/,
10
+ alpha: /^v.*-alpha\.(0|[1-9]\d*)/,
11
+ beta: /^v.*-beta\.(0|[1-9]\d*)/
12
+ };
13
+ const deleteTags = (cmd, filter) => {
14
+ const result = execSync(cmd, { cwd });
15
+ if (!result)
16
+ return;
17
+ const tags = result.toString().split("\n").join(" ");
18
+ execSync(`git tag -d ${filter ? filter(tags) : tags}`, { cwd });
19
+ };
20
+ const tagsFromOtherBranches = (tags = []) => {
21
+ const regex = branchTags[branchName] || branchTags.master;
22
+ return tags.split(" ").filter((tagName) => isSemVersion(tagName) && !regex.test(tagName)).join(" ");
23
+ };
24
+ const deleteMergedTags = () => {
25
+ try {
26
+ if (branchName) {
27
+ deleteTags(`git tag -l --no-merged ${branchName}`);
28
+ deleteTags(`git tag -l --merged ${branchName}`, tagsFromOtherBranches);
29
+ console.log("Last two tags: ");
30
+ execSync("git tag --sort=-creatordate | head -n 2", execaOptions);
31
+ }
32
+ } catch (error) {
33
+ console.error(error);
34
+ }
35
+ };
36
+ export {
37
+ deleteMergedTags
38
+ };
@@ -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.js";
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.js";
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,12 @@
1
+ import path from "node:path";
2
+ import { findUpSync } from "find-up";
3
+ const WORKSPACE_DIR_ENV_VAR = "NPM_CONFIG_WORKSPACE_DIR";
4
+ const WORKSPACE_MANIFEST_FILENAME = "pnpm-workspace.yaml";
5
+ const findMonoRepoRoot = (cwd = process.cwd()) => {
6
+ const workspaceManifestDirEnvVar = process.env[WORKSPACE_DIR_ENV_VAR] ?? process.env[WORKSPACE_DIR_ENV_VAR.toLowerCase()];
7
+ const workspaceManifestLocation = workspaceManifestDirEnvVar ? path.join(workspaceManifestDirEnvVar, "pnpm-workspace.yaml") : findUpSync([WORKSPACE_MANIFEST_FILENAME, "pnpm-workspace.yml"], { cwd });
8
+ return workspaceManifestLocation && path.dirname(workspaceManifestLocation);
9
+ };
10
+ export {
11
+ findMonoRepoRoot
12
+ };
@@ -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,10 @@
1
+ import chalk from "chalk";
2
+ function checkmark_default(callback, message = "") {
3
+ process.stdout.write("\n\n");
4
+ process.stdout.write(chalk.green(" \u2713"));
5
+ if (callback)
6
+ callback(message);
7
+ }
8
+ export {
9
+ checkmark_default as default
10
+ };
@@ -0,0 +1,5 @@
1
+ import fs from "node:fs";
2
+ var get_npm_config_default = JSON.parse(fs.readFileSync("package.json", "utf8"));
3
+ export {
4
+ get_npm_config_default as default
5
+ };
@@ -0,0 +1,13 @@
1
+ import readline from "readline";
2
+ function progress_default(message, amountOfDots = 3) {
3
+ let i = 0;
4
+ return setInterval(() => {
5
+ readline.cursorTo(process.stdout, 0);
6
+ i = (i + 1) % (amountOfDots + 1);
7
+ const dots = new Array(i + 1).join(".");
8
+ process.stdout.write(message + dots);
9
+ }, 500);
10
+ }
11
+ export {
12
+ progress_default as default
13
+ };
@@ -0,0 +1,9 @@
1
+ import chalk from "chalk";
2
+ function xmark_default(callback) {
3
+ process.stdout.write(chalk.red(" \u2718"));
4
+ if (callback)
5
+ callback();
6
+ }
7
+ export {
8
+ xmark_default as default
9
+ };
@@ -0,0 +1,8 @@
1
+ import { exec } from "child_process";
2
+ exec("npm -v", (err, stdout) => {
3
+ if (err)
4
+ throw err;
5
+ if (parseFloat(stdout) < 5) {
6
+ throw new Error(`[ERROR] You need npm version @>=5 but you have ${stdout}`);
7
+ }
8
+ });
@@ -0,0 +1,11 @@
1
+ import updateNotifier from "update-notifier";
2
+ import path from "node:path";
3
+ import fs from "node:fs/promises";
4
+ var update_notifier_default = async () => {
5
+ const pkgFile = await fs.readFile(path.join(process.cwd(), "./package.json"));
6
+ const pkg = JSON.parse(pkgFile);
7
+ updateNotifier({ pkg }).notify();
8
+ };
9
+ export {
10
+ update_notifier_default as default
11
+ };
@@ -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
+ };