@elliemae/pui-cli 7.27.0-beta.2 → 7.27.1

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 (105) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/cli.js +12 -14
  3. package/dist/cjs/commands/build.js +8 -9
  4. package/dist/cjs/commands/codemod.js +9 -7
  5. package/dist/cjs/commands/gendoc.js +2 -2
  6. package/dist/cjs/commands/lint.js +23 -21
  7. package/dist/cjs/commands/pack.js +20 -25
  8. package/dist/cjs/commands/start.js +10 -11
  9. package/dist/cjs/commands/storybook.js +18 -19
  10. package/dist/cjs/commands/test.js +31 -37
  11. package/dist/cjs/commands/tscheck.js +8 -9
  12. package/dist/cjs/commands/utils.js +6 -11
  13. package/dist/cjs/commands/version.js +19 -21
  14. package/dist/cjs/commands/vitest.js +28 -32
  15. package/dist/cjs/index.cjs +2 -0
  16. package/dist/cjs/index.js +2 -2
  17. package/dist/cjs/monorepo/delete-merged-tags.js +1 -1
  18. package/dist/cjs/monorepo/set-registry-version.js +2 -2
  19. package/dist/cjs/monorepo/set-workspace-version.js +2 -2
  20. package/dist/cjs/server/app-routes.cjs +42 -0
  21. package/dist/cjs/server/csp.js +4 -3
  22. package/dist/cjs/server/index.js +11 -13
  23. package/dist/cjs/server/middlewares.js +4 -7
  24. package/dist/cjs/server/utils.js +1 -1
  25. package/dist/cjs/testing/setup-tests.js +4 -2
  26. package/dist/cjs/webpack/helpers.js +3 -3
  27. package/dist/cjs/webpack/webpack.base.babel.js +10 -3
  28. package/dist/cjs/webpack/webpack.dev.babel.js +10 -13
  29. package/dist/cjs/webpack/webpack.lib.base.babel.js +5 -4
  30. package/dist/cjs/webpack/webpack.lib.dev.babel.js +0 -1
  31. package/dist/cjs/webpack/webpack.prod.babel.js +15 -7
  32. package/dist/cjs/webpack/webpack.storybook.js +20 -27
  33. package/dist/esm/cli.js +12 -14
  34. package/dist/esm/commands/build.js +8 -9
  35. package/dist/esm/commands/codemod.js +9 -7
  36. package/dist/esm/commands/gendoc.js +2 -2
  37. package/dist/esm/commands/lint.js +23 -27
  38. package/dist/esm/commands/pack.js +20 -32
  39. package/dist/esm/commands/start.js +10 -11
  40. package/dist/esm/commands/storybook.js +18 -19
  41. package/dist/esm/commands/test.js +31 -37
  42. package/dist/esm/commands/tscheck.js +8 -9
  43. package/dist/esm/commands/utils.js +5 -10
  44. package/dist/esm/commands/version.js +19 -21
  45. package/dist/esm/commands/vitest.js +28 -32
  46. package/dist/esm/index.cjs +2 -0
  47. package/dist/esm/index.js +1 -1
  48. package/dist/esm/monorepo/delete-merged-tags.js +1 -1
  49. package/dist/esm/monorepo/set-registry-version.js +2 -2
  50. package/dist/esm/monorepo/set-workspace-version.js +2 -2
  51. package/dist/esm/server/app-routes.cjs +42 -0
  52. package/dist/esm/server/csp.js +4 -3
  53. package/dist/esm/server/index.js +11 -13
  54. package/dist/esm/server/middlewares.js +4 -7
  55. package/dist/esm/server/utils.js +1 -1
  56. package/dist/esm/testing/setup-tests.js +4 -2
  57. package/dist/esm/webpack/helpers.js +3 -3
  58. package/dist/esm/webpack/webpack.base.babel.js +10 -3
  59. package/dist/esm/webpack/webpack.dev.babel.js +10 -13
  60. package/dist/esm/webpack/webpack.lib.base.babel.js +5 -4
  61. package/dist/esm/webpack/webpack.lib.dev.babel.js +0 -1
  62. package/dist/esm/webpack/webpack.prod.babel.js +15 -7
  63. package/dist/esm/webpack/webpack.storybook.js +20 -27
  64. package/dist/types/commands/build.d.ts +13 -13
  65. package/dist/types/commands/codemod.d.ts +6 -13
  66. package/dist/types/commands/gendoc.d.ts +6 -7
  67. package/dist/types/commands/lint.d.ts +29 -29
  68. package/dist/types/commands/pack.d.ts +26 -29
  69. package/dist/types/commands/start.d.ts +13 -17
  70. package/dist/types/commands/storybook.d.ts +27 -28
  71. package/dist/types/commands/test.d.ts +39 -47
  72. package/dist/types/commands/tscheck.d.ts +14 -16
  73. package/dist/types/commands/utils.d.ts +11 -11
  74. package/dist/types/commands/version.d.ts +28 -31
  75. package/dist/types/commands/vitest.d.ts +35 -41
  76. package/dist/types/index.d.cts +2 -1
  77. package/dist/types/index.d.ts +11 -11
  78. package/dist/types/monorepo/delete-merged-tags.d.ts +1 -1
  79. package/dist/types/monorepo/set-registry-version.d.ts +1 -1
  80. package/dist/types/monorepo/set-workspace-version.d.ts +1 -1
  81. package/dist/types/server/app-routes.d.cts +1 -0
  82. package/dist/types/server/csp.d.ts +9 -12
  83. package/dist/types/server/logger.d.ts +4 -7
  84. package/dist/types/server/middlewares.d.ts +2 -6
  85. package/dist/types/server/utils.d.ts +3 -3
  86. package/dist/types/testing/jest.config.d.cts +10 -10
  87. package/dist/types/testing/jest.node.config.d.cts +10 -10
  88. package/dist/types/webpack/helpers.d.ts +18 -19
  89. package/dist/types/webpack/webpack.base.babel.d.ts +106 -3
  90. package/dist/types/webpack/webpack.dev.babel.d.ts +1 -2
  91. package/dist/types/webpack/webpack.lib.base.babel.d.ts +102 -3
  92. package/dist/types/webpack/webpack.lib.dev.babel.d.ts +101 -3
  93. package/dist/types/webpack/webpack.lib.prod.babel.d.ts +101 -2
  94. package/dist/types/webpack/webpack.prod.babel.d.ts +2 -3
  95. package/dist/types/webpack/webpack.storybook.d.ts +4 -5
  96. package/package.json +52 -66
  97. package/dist/cjs/monorepo/utils.js +0 -54
  98. package/dist/cjs/server/appRoutes.js +0 -74
  99. package/dist/cjs/utils.js +0 -50
  100. package/dist/esm/monorepo/utils.js +0 -24
  101. package/dist/esm/server/appRoutes.js +0 -44
  102. package/dist/esm/utils.js +0 -20
  103. package/dist/types/monorepo/utils.d.ts +0 -1
  104. package/dist/types/server/appRoutes.d.ts +0 -2
  105. package/dist/types/utils.d.ts +0 -4
@@ -1,12 +1,7 @@
1
1
  import path from "node:path";
2
2
  import yargs from "yargs";
3
- import {
4
- exec,
5
- logError,
6
- logSuccess,
7
- getCIEnv,
8
- isTypeScriptEnabled
9
- } from "./utils.js";
3
+ import { exec, logError, logSuccess, getCIEnv } from "./utils.js";
4
+ import { isTypeScriptEnabled } from "../utils.cjs";
10
5
  const lintCSS = async (fix = false) => {
11
6
  const fixIssues = fix ? "--fix" : "";
12
7
  await exec(
@@ -22,23 +17,6 @@ const lintJS = async (fix = false) => {
22
17
  `eslint ${!getCIEnv() ? "--color" : "--no-color"} ${fixIssues} .`
23
18
  );
24
19
  };
25
- const cmdArgs = {
26
- css: {
27
- boolean: true,
28
- alias: "css",
29
- default: true
30
- },
31
- js: {
32
- boolean: true,
33
- alias: "js",
34
- default: true
35
- },
36
- fix: {
37
- boolean: true,
38
- alias: "fix",
39
- default: false
40
- }
41
- };
42
20
  const lintCmd = {
43
21
  handler: async (argv) => {
44
22
  if (argv.js) {
@@ -51,7 +29,7 @@ const lintCmd = {
51
29
  } catch (err) {
52
30
  logError("JS linting failed");
53
31
  yargs().exit(-1, err);
54
- return;
32
+ return -1;
55
33
  }
56
34
  }
57
35
  if (argv.css) {
@@ -62,12 +40,30 @@ const lintCmd = {
62
40
  } catch (err) {
63
41
  logError("CSS linting failed");
64
42
  yargs().exit(-1, err);
43
+ return -1;
65
44
  }
66
45
  }
46
+ return 0;
67
47
  },
68
48
  command: "lint [options]",
69
- desc: "lints application code",
70
- builder: (yargsRef) => yargsRef.options(cmdArgs).help()
49
+ describe: "lints application code",
50
+ builder: {
51
+ css: {
52
+ alias: "css",
53
+ type: "boolean",
54
+ default: true
55
+ },
56
+ js: {
57
+ alias: "js",
58
+ type: "boolean",
59
+ default: true
60
+ },
61
+ fix: {
62
+ alias: "fix",
63
+ type: "boolean",
64
+ default: false
65
+ }
66
+ }
71
67
  };
72
68
  export {
73
69
  lintCmd
@@ -1,14 +1,8 @@
1
1
  import path from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import yargs from "yargs";
4
- import {
5
- exec,
6
- logInfo,
7
- logError,
8
- logSuccess,
9
- getCIEnv,
10
- isTypeScriptEnabled
11
- } from "./utils.js";
4
+ import { exec, logInfo, logError, logSuccess, getCIEnv } from "./utils.js";
5
+ import { isTypeScriptEnabled } from "../utils.cjs";
12
6
  import { esBuild } from "../transpile/esbuild.js";
13
7
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
14
8
  const compileTypeScript = async () => {
@@ -32,11 +26,7 @@ const webBuild = async (productionBuild) => {
32
26
  );
33
27
  logInfo("Building source files for browser environment completed...");
34
28
  };
35
- const pack = async ({
36
- production,
37
- target,
38
- srcPath
39
- }) => {
29
+ const pack = async ({ production, target, srcPath }) => {
40
30
  logInfo("Build in-progress...");
41
31
  await exec("rimraf ./dist");
42
32
  if (isTypeScriptEnabled()) {
@@ -50,23 +40,6 @@ const pack = async ({
50
40
  logInfo("Building source files for nodejs environment completed.");
51
41
  }
52
42
  };
53
- const cmdArgs = {
54
- production: {
55
- boolean: true,
56
- alias: "p",
57
- default: false
58
- },
59
- target: {
60
- string: true,
61
- alias: "t",
62
- default: "",
63
- description: "target environment where this library will be used. allowed values are web, node. by default libraries will be compiled for both web and nodejs environments"
64
- },
65
- srcPath: {
66
- string: true,
67
- default: "./lib"
68
- }
69
- };
70
43
  const packCmd = {
71
44
  handler: async (argv) => {
72
45
  try {
@@ -78,8 +51,23 @@ const packCmd = {
78
51
  }
79
52
  },
80
53
  command: "pack",
81
- desc: "builds library",
82
- builder: (yargsRef) => yargsRef.options(cmdArgs).help()
54
+ describe: "builds library",
55
+ builder: {
56
+ production: {
57
+ alias: "p",
58
+ type: "boolean",
59
+ default: false
60
+ },
61
+ target: {
62
+ alias: "t",
63
+ type: "string",
64
+ description: "target environment where this library will be used. allowed values are web, node. by default libraries will be compiled for both web and nodejs environments"
65
+ },
66
+ srcPath: {
67
+ type: "string",
68
+ default: "./lib"
69
+ }
70
+ }
83
71
  };
84
72
  export {
85
73
  packCmd
@@ -5,9 +5,9 @@ import { exec, logError, logSuccess, isApp } from "./utils.js";
5
5
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
6
  const startProdServer = async () => {
7
7
  await exec(
8
- `cross-env NODE_ENV=production ts-node --esm ${path.resolve(
8
+ `cross-env NODE_ENV=production ts-node ${path.resolve(
9
9
  __dirname,
10
- "../server.ts"
10
+ "../server"
11
11
  )} --color always`
12
12
  );
13
13
  };
@@ -20,13 +20,6 @@ const startDevServer = async () => {
20
20
  )}`
21
21
  );
22
22
  };
23
- const cmdArgs = {
24
- prod: {
25
- boolean: true,
26
- alias: "p",
27
- default: false
28
- }
29
- };
30
23
  const startCmd = {
31
24
  handler: async (argv) => {
32
25
  try {
@@ -42,8 +35,14 @@ const startCmd = {
42
35
  }
43
36
  },
44
37
  command: "start [options]",
45
- desc: "starts local web server to test the application",
46
- builder: (yargsRef) => yargsRef.options(cmdArgs).help()
38
+ describe: "starts local web server to test the application",
39
+ builder: {
40
+ prod: {
41
+ alias: "p",
42
+ default: false,
43
+ type: "boolean"
44
+ }
45
+ }
47
46
  };
48
47
  export {
49
48
  startCmd
@@ -8,25 +8,9 @@ const buildStoryBook = async (outputDir = "demo", isDoc = false) => {
8
8
  };
9
9
  const startStoryBook = async (isDoc = false) => {
10
10
  await exec(
11
- `cross-env NODE_ENV=development STORYBOOK_BUILD=true start-storybook ${isDoc ? "--docs" : ""} -p 11000 --quiet`
11
+ `cross-env NODE_ENV=development STORYBOOK_BUILD=true start-storybook ${isDoc && "--docs"} -p 11000 --quiet`
12
12
  );
13
13
  };
14
- const cmdArgs = {
15
- build: {
16
- boolean: true,
17
- alias: "b",
18
- default: false
19
- },
20
- docs: {
21
- boolean: true,
22
- default: false
23
- },
24
- output: {
25
- string: true,
26
- alias: "o",
27
- default: "demo"
28
- }
29
- };
30
14
  const storybookCmd = {
31
15
  handler: async (argv) => {
32
16
  try {
@@ -43,8 +27,23 @@ const storybookCmd = {
43
27
  }
44
28
  },
45
29
  command: "storybook [options]",
46
- desc: "story book application code",
47
- builder: (yargsRef) => yargsRef.options(cmdArgs).help()
30
+ describe: "story book application code",
31
+ builder: {
32
+ build: {
33
+ alias: "b",
34
+ type: "boolean",
35
+ default: false
36
+ },
37
+ docs: {
38
+ type: "boolean",
39
+ default: false
40
+ },
41
+ output: {
42
+ alias: "o",
43
+ type: "string",
44
+ default: "demo"
45
+ }
46
+ }
48
47
  };
49
48
  export {
50
49
  storybookCmd
@@ -8,38 +8,6 @@ const debugTest = async () => {
8
8
  `node --inspect-brk ./node_modules/jest-cli/bin/jest.js --runInBand --watch`
9
9
  );
10
10
  };
11
- const cmdArgs = {
12
- fix: {
13
- boolean: true,
14
- alias: "f",
15
- default: false
16
- },
17
- watch: {
18
- boolean: true,
19
- alias: "w",
20
- default: false
21
- },
22
- debug: {
23
- boolean: true,
24
- alias: "d",
25
- default: false
26
- },
27
- passWithNoTests: {
28
- boolean: true,
29
- alias: "p",
30
- default: false
31
- },
32
- findReleatedTests: {
33
- boolean: true,
34
- alias: "r",
35
- default: false
36
- },
37
- silent: {
38
- boolean: true,
39
- alias: "s",
40
- default: false
41
- }
42
- };
43
11
  const testCmd = {
44
12
  // eslint-disable-next-line max-statements
45
13
  handler: async (argv) => {
@@ -50,11 +18,11 @@ const testCmd = {
50
18
  commandOptions = "--watchAll";
51
19
  if (getCIEnv())
52
20
  commandOptions += " --ci --no-colors";
53
- if (argv.passWithNoTests)
21
+ if (argv.p)
54
22
  commandOptions += " --passWithNoTests";
55
- if (argv.findReleatedTests)
23
+ if (argv.r)
56
24
  commandOptions += " --bail --findRelatedTests";
57
- if (argv.silent)
25
+ if (argv.s)
58
26
  commandOptions += " --silent";
59
27
  try {
60
28
  if (getCIEnv()) {
@@ -69,11 +37,37 @@ const testCmd = {
69
37
  } catch (err) {
70
38
  logError("Unit test execution failed", err);
71
39
  yargs().exit(-1, err);
40
+ return -1;
72
41
  }
42
+ return 0;
73
43
  },
74
44
  command: "test [options]",
75
- desc: "unit tests application code",
76
- builder: (yargsRef) => yargsRef.options(cmdArgs).help()
45
+ describe: "unit tests application code",
46
+ builder: {
47
+ fix: {
48
+ alias: "f",
49
+ type: "boolean"
50
+ },
51
+ watch: {
52
+ alias: "w",
53
+ type: "boolean"
54
+ },
55
+ debug: {
56
+ type: "boolean"
57
+ },
58
+ passWithNoTests: {
59
+ alias: "p",
60
+ type: "boolean"
61
+ },
62
+ findReleatedTests: {
63
+ alias: "r",
64
+ type: "boolean"
65
+ },
66
+ silent: {
67
+ alias: "s",
68
+ type: "boolean"
69
+ }
70
+ }
77
71
  };
78
72
  export {
79
73
  testCmd
@@ -5,7 +5,7 @@ import { exec, logInfo, logError } from "./utils.js";
5
5
  const randomChars = () => Math.random().toString(36).slice(2);
6
6
  const validateTypescript = async (files = []) => {
7
7
  const tsconfigPath = path.join(process.cwd(), "tsconfig.json");
8
- const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath).toString());
8
+ const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath));
9
9
  const tmpTsconfigPath = path.join(
10
10
  process.cwd(),
11
11
  `tsconfig.${randomChars()}.json`
@@ -32,12 +32,6 @@ const validateTypescript = async (files = []) => {
32
32
  fs.unlinkSync(tmpTsconfigPath);
33
33
  }
34
34
  };
35
- const cmdArgs = {
36
- files: {
37
- array: true,
38
- default: []
39
- }
40
- };
41
35
  const tscheckCmd = {
42
36
  handler: async ({ files }) => {
43
37
  try {
@@ -49,8 +43,13 @@ const tscheckCmd = {
49
43
  }
50
44
  },
51
45
  command: "tscheck [options]",
52
- desc: "validate typescript file(s)",
53
- builder: (yargsRef) => yargsRef.options(cmdArgs).help()
46
+ describe: "validate typescript file(s)",
47
+ builder: {
48
+ files: {
49
+ type: "array",
50
+ default: []
51
+ }
52
+ }
54
53
  };
55
54
  export {
56
55
  tscheckCmd
@@ -1,5 +1,5 @@
1
1
  import path from "node:path";
2
- import fs, { constants } from "node:fs";
2
+ import { constants } from "fs";
3
3
  import {
4
4
  readFile,
5
5
  writeFile,
@@ -44,7 +44,7 @@ const getSupportedBrowsers = async () => {
44
44
  const { stdout } = await exec("npx --no-install browserslist", {
45
45
  stdout: "pipe"
46
46
  });
47
- const browserVersions = stdout?.toString()?.split("\n") || [];
47
+ const browserVersions = stdout && stdout.split("\n") || [];
48
48
  return browserVersions.reduce((acc, nameVersion) => {
49
49
  const [name, version] = nameVersion.split(" ");
50
50
  const versionRange = version.split("-");
@@ -88,18 +88,15 @@ const writeAppInfo = async () => {
88
88
  [
89
89
  path.join(versionedPath, "info.json"),
90
90
  path.join(process.cwd(), "build", "public", "info.json")
91
- ].forEach((infoPath) => {
92
- writeFile(infoPath, infoJSON).then(() => {
93
- }).catch((err) => console.error(err));
94
- });
91
+ ].forEach(async (infoPath) => writeFile(infoPath, infoJSON));
95
92
  };
96
93
  const copyDir = async (src, dest) => {
97
94
  const entries = await readdir(src, {
98
95
  withFileTypes: true
99
96
  });
100
97
  await mkdir(dest);
101
- await Promise.all(
102
- entries.map(async (entry) => {
98
+ return Promise.all(
99
+ entries.map((entry) => {
103
100
  const srcPath = path.join(src, entry.name);
104
101
  const destPath = path.join(dest, entry.name);
105
102
  if (entry.isDirectory()) {
@@ -135,14 +132,12 @@ const isPathExist = async (pathToCheck) => {
135
132
  };
136
133
  const isApp = async () => isPathExist(path.join(process.cwd(), "app"));
137
134
  const getCIEnv = () => process.env.CI === "true";
138
- const isTypeScriptEnabled = () => fs.existsSync(path.join(process.cwd(), "tsconfig.json"));
139
135
  export {
140
136
  copyBuildAssetsToVersionedFolder,
141
137
  exec,
142
138
  getCIEnv,
143
139
  isApp,
144
140
  isPathExist,
145
- isTypeScriptEnabled,
146
141
  logError,
147
142
  logInfo,
148
143
  logSuccess,
@@ -8,29 +8,11 @@ const version = async (lernaOptions = "") => {
8
8
  `cross-env NODE_ENV=production lerna version --conventional-commits --exact --create-release github --force-publish --yes ${lernaOptions}`
9
9
  );
10
10
  };
11
- const cmdArgs = {
12
- deleteTags: {
13
- boolean: true,
14
- default: false
15
- },
16
- useRegistry: {
17
- boolean: true,
18
- default: false
19
- },
20
- useWorkspace: {
21
- boolean: true,
22
- default: false
23
- },
24
- lernaOptions: {
25
- string: true,
26
- default: ""
27
- }
28
- };
29
11
  const versionCmd = {
30
12
  handler: async (argv) => {
31
13
  try {
32
14
  if (argv.deleteTags) {
33
- deleteMergedTags();
15
+ await deleteMergedTags();
34
16
  } else if (argv.useRegistry) {
35
17
  await setRegistryVersion();
36
18
  } else if (argv.useWorkspace) {
@@ -44,8 +26,24 @@ const versionCmd = {
44
26
  }
45
27
  },
46
28
  command: "version [options]",
47
- desc: "version monorepo",
48
- builder: (yargsRef) => yargsRef.options(cmdArgs).help()
29
+ describe: "version monorepo",
30
+ builder: {
31
+ deleteTags: {
32
+ type: "boolean",
33
+ default: false
34
+ },
35
+ useRegistry: {
36
+ type: "boolean",
37
+ default: false
38
+ },
39
+ useWorkspace: {
40
+ type: "boolean",
41
+ default: false
42
+ },
43
+ lernaOptions: {
44
+ type: "string"
45
+ }
46
+ }
49
47
  };
50
48
  export {
51
49
  versionCmd
@@ -3,33 +3,6 @@ import { exec, logError, logSuccess, getCIEnv } from "./utils.js";
3
3
  const test = async (commandOptions) => {
4
4
  await exec(`vitest ${commandOptions}`);
5
5
  };
6
- const cmdArgs = {
7
- fix: {
8
- boolean: true,
9
- alias: "f",
10
- default: false
11
- },
12
- watch: {
13
- boolean: true,
14
- alias: "w",
15
- default: false
16
- },
17
- passWithNoTests: {
18
- boolean: true,
19
- alias: "p",
20
- default: false
21
- },
22
- findReleatedTests: {
23
- boolean: true,
24
- alias: "r",
25
- default: false
26
- },
27
- silent: {
28
- boolean: true,
29
- alias: "s",
30
- default: false
31
- }
32
- };
33
6
  const vitestCmd = {
34
7
  // eslint-disable-next-line max-statements
35
8
  handler: async (argv) => {
@@ -38,11 +11,11 @@ const vitestCmd = {
38
11
  commandOptions = "-u";
39
12
  else if (argv.watch)
40
13
  commandOptions = "--watch";
41
- if (argv.passWithNoTests)
14
+ if (argv.p)
42
15
  commandOptions += " --passWithNoTests";
43
- if (argv.findReleatedTests)
16
+ if (argv.r)
44
17
  commandOptions += " --related";
45
- if (argv.silent)
18
+ if (argv.s)
46
19
  commandOptions += " --silent";
47
20
  try {
48
21
  if (getCIEnv()) {
@@ -53,11 +26,34 @@ const vitestCmd = {
53
26
  } catch (err) {
54
27
  logError("Unit test execution failed", err);
55
28
  yargs().exit(-1, err);
29
+ return -1;
56
30
  }
31
+ return 0;
57
32
  },
58
33
  command: "vitest [options]",
59
- desc: "unit tests application code using vitest",
60
- builder: (yargsRef) => yargsRef.options(cmdArgs).help()
34
+ describe: "unit tests application code using vitest",
35
+ builder: {
36
+ fix: {
37
+ alias: "f",
38
+ type: "boolean"
39
+ },
40
+ watch: {
41
+ alias: "w",
42
+ type: "boolean"
43
+ },
44
+ passWithNoTests: {
45
+ alias: "p",
46
+ type: "boolean"
47
+ },
48
+ related: {
49
+ alias: "r",
50
+ type: "boolean"
51
+ },
52
+ silent: {
53
+ alias: "s",
54
+ type: "boolean"
55
+ }
56
+ }
61
57
  };
62
58
  export {
63
59
  vitestCmd
@@ -10,6 +10,7 @@ const { prettierConfig } = require('./lint-config/prettier.config.cjs');
10
10
  const { commitlintConfig } = require('./lint-config/commitlint.config.cjs');
11
11
  const { jestConfig } = require('./testing/jest.config.cjs');
12
12
  const { jestNodeConfig } = require('./testing/jest.node.config.cjs');
13
+ const { loadRoutes } = require('./server/app-routes.cjs');
13
14
 
14
15
  module.exports = {
15
16
  babelConfig,
@@ -20,4 +21,5 @@ module.exports = {
20
21
  commitlintConfig,
21
22
  jestConfig,
22
23
  jestNodeConfig,
24
+ loadRoutes,
23
25
  };
package/dist/esm/index.js CHANGED
@@ -8,7 +8,7 @@ import { jestConfig } from "./testing/jest.config.cjs";
8
8
  import { vitestConfig } from "./testing/vitest.config.js";
9
9
  import { jestNodeConfig } from "./testing/jest.node.config.cjs";
10
10
  import { lintStagedConfig } from "./lint-config/lint-staged.config.js";
11
- import { loadRoutes } from "./server/appRoutes.js";
11
+ import { loadRoutes } from "./server/app-routes.cjs";
12
12
  export {
13
13
  babelConfig,
14
14
  commitlintConfig,
@@ -17,7 +17,7 @@ const deleteTags = (cmd, filter) => {
17
17
  const tags = result.toString().split("\n").join(" ");
18
18
  execSync(`git tag -d ${filter ? filter(tags) : tags}`, { cwd });
19
19
  };
20
- const tagsFromOtherBranches = (tags) => {
20
+ const tagsFromOtherBranches = (tags = []) => {
21
21
  const regex = branchTags[branchName] || branchTags.master;
22
22
  return tags.split(" ").filter((tagName) => isSemVersion(tagName) && !regex.test(tagName)).join(" ");
23
23
  };
@@ -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([
@@ -9,7 +9,7 @@ const setRegistryVersion = async () => {
9
9
  `${monorepoRoot}/apps/*/package.json`,
10
10
  `${monorepoRoot}/package.json`
11
11
  ]);
12
- await Promise.all(
12
+ Promise.all(
13
13
  files.map(async (file) => {
14
14
  let pkgJSONData = await readFile(file, "utf8");
15
15
  const pkgVersion = JSON.parse(pkgJSONData).version;
@@ -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([
@@ -9,7 +9,7 @@ const setWorkspaceVersion = async () => {
9
9
  `${monorepoRoot}/apps/*/package.json`,
10
10
  `${monorepoRoot}/package.json`
11
11
  ]);
12
- await Promise.all(
12
+ Promise.all(
13
13
  files.map(async (file) => {
14
14
  let pkgJSONData = await readFile(file, "utf8");
15
15
  const pkgVersion = JSON.parse(pkgJSONData).version;
@@ -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
+ };