@elliemae/pui-cli 9.0.0-next.68 → 9.0.0-next.69

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.
@@ -56,7 +56,7 @@ const lintJS = async (args) => {
56
56
  const fixIssues = args.fix ? "--fix" : "";
57
57
  const debugFlags = args.debug ? "--env-info --debug" : "";
58
58
  await (0, import_utils.exec)(
59
- `eslint --flag unstable_ts_config ${!(0, import_utils.getCIEnv)() ? "--color" : "--no-color"} ${fixIssues} ${debugFlags} .`
59
+ `eslint ${!(0, import_utils.getCIEnv)() ? "--color" : "--no-color"} ${fixIssues} ${debugFlags} .`
60
60
  );
61
61
  };
62
62
  const cmdArgs = {
@@ -36,6 +36,7 @@ var import_node_fs = require("node:fs");
36
36
  var import_node_url = require("node:url");
37
37
  var import_globals = __toESM(require("globals"));
38
38
  var import_js = __toESM(require("@eslint/js"));
39
+ var import_config = require("eslint/config");
39
40
  var import_eslintrc = require("@eslint/eslintrc");
40
41
  var import_compat = require("@eslint/compat");
41
42
  var import_typescript_eslint = __toESM(require("typescript-eslint"));
@@ -57,207 +58,198 @@ const gitignorePath = import_node_path.default.resolve(process.cwd(), ".gitignor
57
58
  const compat = new import_eslintrc.FlatCompat({
58
59
  baseDirectory: __dirname
59
60
  });
60
- const ignores = {
61
- ignores: [
62
- "build/*",
63
- "**/node_modules/",
64
- "dist/*",
65
- "reports/*",
66
- "allure-report/*",
67
- "public/*",
68
- "webroot/*",
69
- "cdn/*",
70
- ".tmp/*",
71
- "coverage/*",
72
- "demo/*",
73
- "docs/*",
74
- "temp/*",
75
- "**/vendor/*.js",
76
- ".docusaurus/*",
77
- ".scannerwork/*",
78
- ".DS_Store/*",
79
- ".nx/*",
80
- ".idea/*",
81
- "*.tgz",
82
- "npm-debug.log",
83
- "stats.json",
84
- "!.storybook"
85
- ]
86
- };
87
- const options = {
88
- languageOptions: {
89
- ecmaVersion: "latest",
90
- sourceType: "module",
91
- globals: {
92
- ...import_globals.default.builtin,
93
- ...import_globals.default.browser,
94
- ...import_globals.default.es2021,
95
- ...import_globals.default.nodeBuiltin,
96
- ...import_globals.default.node,
97
- ...import_globals.default.serviceworker,
98
- ...import_globals.default.jest,
99
- ...import_globals.default.commonjs,
100
- browser: true,
101
- $: true
102
- },
103
- parserOptions: {
104
- ecmaVersion: "latest",
105
- sourceType: "module",
106
- ecmaFeatures: {
107
- jsx: true
108
- },
109
- project: true,
110
- projectService: true,
111
- tsconfigRootDir: process.cwd()
112
- }
113
- },
114
- settings: {
115
- react: {
116
- version: "detect",
117
- pragma: "React"
118
- },
119
- jest: {
120
- version: "detect"
121
- },
122
- "import-x/parsers": {
123
- espree: [".js", ".cjs", ".mjs", ".jsx"]
124
- },
125
- // "import-x/resolver": {
126
- // node: {
127
- // extensions: [".js", ".jsx", ".ts", ".tsx"],
128
- // },
129
- // typescript: true,
130
- // },
131
- "import/resolver-next": [
132
- (0, import_eslint_import_resolver_typescript.createTypeScriptImportResolver)({
133
- alwaysTryTypes: true
134
- })
135
- ]
136
- }
137
- };
138
- const e2eTestConfig = {
139
- files: ["**/*.func.spec.{js,ts}", "**/*.visual.spec.{js,ts}"],
140
- extends: [import_eslint_plugin_wdio.configs["flat/recommended"]],
141
- rules: {
142
- "jest/valid-expect": "off"
143
- }
144
- };
145
- const jestConfig = {
146
- files: ["**/*.test.{js,jsx,ts,tsx}", "**/testing/**/*.{js,jsx,ts,tsx}"],
147
- extends: [
148
- import_eslint_plugin_jest.default.configs["flat/recommended"],
149
- import_eslint_plugin_jest.default.configs["flat/style"],
150
- import_eslint_plugin_testing_library.default.configs["flat/dom"],
151
- import_eslint_plugin_testing_library.default.configs["flat/react"]
152
- ]
153
- };
154
- const sbConfig = {
155
- files: ["**/*.stories.{js,jsx,ts,tsx,mdx}"],
156
- extends: [import_eslint_plugin_storybook.default.configs["flat/recommended"]]
157
- };
158
- const jsRulesConfig = {
159
- rules: {
160
- complexity: ["error", { max: 10 }],
161
- "import-x/no-named-as-default-member": "off",
162
- "import-x/no-named-as-default": "off",
163
- "import-x/no-unresolved": [
164
- "error",
165
- { caseSensitive: true, caseSensitiveStrict: true }
166
- ],
167
- "import-x/extensions": [
168
- "error",
169
- "never",
170
- {
171
- json: "ignorePackages",
172
- js: "ignorePackages"
173
- }
174
- ],
175
- "max-depth": ["error", { max: 4 }],
176
- "max-nested-callbacks": ["error", { max: 3 }],
177
- "max-params": ["error", { max: 3 }],
178
- "max-statements": ["error", { max: 20 }],
179
- "no-console": "warn",
180
- "no-param-reassign": ["error", { props: false }],
181
- "no-unused-vars": "off",
182
- "prefer-template": "error"
183
- }
184
- };
185
- const tsConfig = {
186
- ignores: ["**/*.{js,jsx,mjs,cjs,mdx,md}"],
187
- extends: [
188
- import_typescript_eslint.default.configs.recommendedTypeChecked,
189
- import_typescript_eslint.default.configs.stylisticTypeChecked
190
- ],
191
- rules: {
192
- "@typescript-eslint/no-unused-vars": [
193
- "error",
194
- {
195
- args: "all",
196
- argsIgnorePattern: "^_",
197
- caughtErrors: "all",
198
- caughtErrorsIgnorePattern: "^_",
199
- destructuredArrayIgnorePattern: "^_",
200
- varsIgnorePattern: "^_",
201
- ignoreRestSiblings: true
202
- }
203
- ],
204
- "@typescript-eslint/unbound-method": [
205
- "error",
206
- {
207
- ignoreStatic: true
208
- }
209
- ]
210
- }
211
- };
212
- const reactConfig = {
213
- files: ["**/*.{jsx,tsx}"],
214
- extends: [
215
- import_eslint_plugin_react.default.configs.flat.recommended,
216
- import_eslint_plugin_react.default.configs.flat["jsx-runtime"],
217
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
218
- import_eslint_plugin_jsx_a11y.default.flatConfigs.recommended,
219
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
220
- ...compat.extends("plugin:redux-saga/recommended")
221
- ],
222
- languageOptions: {
223
- ...import_eslint_plugin_react.default.configs.flat.recommended.languageOptions
224
- },
225
- plugins: {
226
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
227
- "react-hooks": import_eslint_plugin_react_hooks.default
228
- },
229
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
230
- rules: {
231
- "react/prop-types": ["error", { skipUndeclared: true }],
232
- "react/display-name": "off",
233
- "react/function-component-definition": [
234
- 2,
235
- { namedComponents: "arrow-function" }
236
- ],
237
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
238
- ...import_eslint_plugin_react_hooks.default.configs.recommended.rules
239
- }
240
- };
241
61
  const gitignoreExists = (0, import_node_fs.existsSync)(gitignorePath);
242
- const tseslintConfigArgs = [ignores];
62
+ let gitIgnoreConfig = {};
243
63
  if (gitignoreExists) {
244
- tseslintConfigArgs.push((0, import_compat.includeIgnoreFile)(gitignorePath));
64
+ gitIgnoreConfig = (0, import_compat.includeIgnoreFile)(gitignorePath) ?? {};
245
65
  }
246
- tseslintConfigArgs.push(
66
+ const config = (0, import_config.defineConfig)([
67
+ gitIgnoreConfig,
68
+ {
69
+ ignores: [
70
+ "build/*",
71
+ "**/node_modules/",
72
+ "dist/*",
73
+ "reports/*",
74
+ "allure-report/*",
75
+ "public/*",
76
+ "webroot/*",
77
+ "cdn/*",
78
+ ".tmp/*",
79
+ "coverage/*",
80
+ "demo/*",
81
+ "docs/*",
82
+ "temp/*",
83
+ "**/vendor/*.js",
84
+ ".docusaurus/*",
85
+ ".scannerwork/*",
86
+ ".DS_Store/*",
87
+ ".nx/*",
88
+ ".idea/*",
89
+ "*.tgz",
90
+ "npm-debug.log",
91
+ "stats.json",
92
+ "!.storybook"
93
+ ]
94
+ },
247
95
  {
248
96
  ignores: ["**/*.stories.mdx"],
249
97
  extends: [mdx.flat]
250
98
  },
251
99
  import_js.default.configs.recommended,
252
- tsConfig,
100
+ {
101
+ ignores: ["**/*.{js,jsx,mjs,cjs,mdx,md}"],
102
+ extends: [
103
+ import_typescript_eslint.default.configs.recommendedTypeChecked,
104
+ import_typescript_eslint.default.configs.stylisticTypeChecked
105
+ ],
106
+ rules: {
107
+ "@typescript-eslint/no-unused-vars": [
108
+ "error",
109
+ {
110
+ args: "all",
111
+ argsIgnorePattern: "^_",
112
+ caughtErrors: "all",
113
+ caughtErrorsIgnorePattern: "^_",
114
+ destructuredArrayIgnorePattern: "^_",
115
+ varsIgnorePattern: "^_",
116
+ ignoreRestSiblings: true
117
+ }
118
+ ],
119
+ "@typescript-eslint/unbound-method": [
120
+ "error",
121
+ {
122
+ ignoreStatic: true
123
+ }
124
+ ]
125
+ }
126
+ },
253
127
  import_eslint_plugin_import_x.default.flatConfigs.recommended,
254
128
  import_eslint_plugin_import_x.default.flatConfigs.typescript,
255
- jestConfig,
129
+ {
130
+ files: ["**/*.test.{js,jsx,ts,tsx}", "**/testing/**/*.{js,jsx,ts,tsx}"],
131
+ ...import_eslint_plugin_jest.default.configs["flat/recommended"],
132
+ ...import_eslint_plugin_jest.default.configs["flat/style"],
133
+ ...import_eslint_plugin_testing_library.default.configs["flat/dom"],
134
+ ...import_eslint_plugin_testing_library.default.configs["flat/react"]
135
+ },
256
136
  import_recommended.default,
257
- reactConfig,
258
- e2eTestConfig,
259
- sbConfig,
260
- jsRulesConfig,
261
- options
262
- );
263
- const config = import_typescript_eslint.default.config(...tseslintConfigArgs);
137
+ {
138
+ files: ["**/*.{jsx,tsx}"],
139
+ ...import_eslint_plugin_react.default.configs.flat.recommended,
140
+ ...import_eslint_plugin_react.default.configs.flat["jsx-runtime"],
141
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
142
+ ...import_eslint_plugin_jsx_a11y.default.flatConfigs.recommended,
143
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
144
+ ...compat.extends("plugin:redux-saga/recommended"),
145
+ languageOptions: {
146
+ ...import_eslint_plugin_react.default.configs.flat.recommended.languageOptions
147
+ },
148
+ plugins: {
149
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
150
+ "react-hooks": import_eslint_plugin_react_hooks.default
151
+ },
152
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
153
+ rules: {
154
+ "react/prop-types": ["error", { skipUndeclared: true }],
155
+ "react/display-name": "off",
156
+ "react/function-component-definition": [
157
+ 2,
158
+ { namedComponents: "arrow-function" }
159
+ ],
160
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
161
+ ...import_eslint_plugin_react_hooks.default.configs.recommended.rules
162
+ }
163
+ },
164
+ {
165
+ files: ["**/*.func.spec.{js,ts}", "**/*.visual.spec.{js,ts}"],
166
+ extends: [import_eslint_plugin_wdio.configs["flat/recommended"]],
167
+ rules: {
168
+ "jest/valid-expect": "off"
169
+ }
170
+ },
171
+ {
172
+ files: ["**/*.stories.{js,jsx,ts,tsx,mdx}"],
173
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
174
+ // @ts-ignore
175
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
176
+ extends: [import_eslint_plugin_storybook.default.configs["flat/recommended"]]
177
+ },
178
+ {
179
+ rules: {
180
+ complexity: ["error", { max: 10 }],
181
+ "import-x/no-named-as-default-member": "off",
182
+ "import-x/no-named-as-default": "off",
183
+ "import-x/no-unresolved": [
184
+ "error",
185
+ { caseSensitive: true, caseSensitiveStrict: true }
186
+ ],
187
+ "import-x/extensions": [
188
+ "error",
189
+ "never",
190
+ {
191
+ json: "ignorePackages",
192
+ js: "ignorePackages"
193
+ }
194
+ ],
195
+ "max-depth": ["error", { max: 4 }],
196
+ "max-nested-callbacks": ["error", { max: 3 }],
197
+ "max-params": ["error", { max: 3 }],
198
+ "max-statements": ["error", { max: 20 }],
199
+ "no-console": "warn",
200
+ "no-param-reassign": ["error", { props: false }],
201
+ "no-unused-vars": "off",
202
+ "prefer-template": "error"
203
+ }
204
+ },
205
+ {
206
+ languageOptions: {
207
+ ecmaVersion: "latest",
208
+ sourceType: "module",
209
+ globals: {
210
+ ...import_globals.default.builtin,
211
+ ...import_globals.default.browser,
212
+ ...import_globals.default.es2021,
213
+ ...import_globals.default.nodeBuiltin,
214
+ ...import_globals.default.node,
215
+ ...import_globals.default.serviceworker,
216
+ ...import_globals.default.jest,
217
+ ...import_globals.default.commonjs,
218
+ browser: true,
219
+ $: true
220
+ },
221
+ parserOptions: {
222
+ ecmaVersion: "latest",
223
+ sourceType: "module",
224
+ ecmaFeatures: {
225
+ jsx: true
226
+ },
227
+ projectService: true,
228
+ tsconfigRootDir: process.cwd()
229
+ }
230
+ },
231
+ settings: {
232
+ react: {
233
+ version: "detect",
234
+ pragma: "React"
235
+ },
236
+ jest: {
237
+ version: "detect"
238
+ },
239
+ "import-x/parsers": {
240
+ espree: [".js", ".cjs", ".mjs", ".jsx"]
241
+ },
242
+ // "import-x/resolver": {
243
+ // node: {
244
+ // extensions: [".js", ".jsx", ".ts", ".tsx"],
245
+ // },
246
+ // typescript: true,
247
+ // },
248
+ "import/resolver-next": [
249
+ (0, import_eslint_import_resolver_typescript.createTypeScriptImportResolver)({
250
+ alwaysTryTypes: true
251
+ })
252
+ ]
253
+ }
254
+ }
255
+ ]);
@@ -63,7 +63,9 @@ const loadRoutes = async (app) => {
63
63
  const routeFileURL = (0, import_node_url.pathToFileURL)(routeFile).href;
64
64
  const { default: init } = await import(routeFileURL);
65
65
  try {
66
- if (typeof init === "function") init(app);
66
+ if (typeof init === "function") {
67
+ await init(app);
68
+ }
67
69
  } catch (err) {
68
70
  console.error(
69
71
  `unable to load routes from ${routeFile}. ${err.message}`
@@ -55,18 +55,22 @@ const sendFileWithCSPNonce = ({
55
55
  res,
56
56
  fileSystem = import_node_fs.default
57
57
  }) => {
58
- fileSystem.readFile(import_node_path.default.resolve(buildPath, page), "utf8", (err, html) => {
59
- if (err) {
60
- res.sendStatus(404);
61
- } else {
62
- res.set("Content-Type", "text/html");
63
- res.set("Reporting-Endpoints", `csp-report-uri="${CSP_REPORT_URI}"`);
64
- res.set(
65
- "Permissions-Policy",
66
- "geolocation=(), camera=(), microphone=(), interest-cohort=()"
67
- );
68
- res.send(html.replace(nonceRegex, res.locals.cspNonce));
69
- }
58
+ return new Promise((resolve) => {
59
+ fileSystem.readFile(import_node_path.default.resolve(buildPath, page), "utf8", (err, html) => {
60
+ const r = res;
61
+ if (err) {
62
+ r.sendStatus(404);
63
+ } else {
64
+ r.set("Content-Type", "text/html");
65
+ r.set("Reporting-Endpoints", `csp-report-uri="${CSP_REPORT_URI}"`);
66
+ r.set(
67
+ "Permissions-Policy",
68
+ "geolocation=(), camera=(), microphone=(), interest-cohort=()"
69
+ );
70
+ r.send(html.replace(nonceRegex, r.locals.cspNonce ?? ""));
71
+ }
72
+ resolve();
73
+ });
70
74
  });
71
75
  };
72
76
  const getScriptSrc = () => {
@@ -32,19 +32,28 @@ var import_utils2 = require("../utils.js");
32
32
  var import_appRoutes = require("./appRoutes.js");
33
33
  var import_wsServer = require("./wsServer.js");
34
34
  void (async function startServer() {
35
- const app = (0, import_express.default)();
36
- (0, import_middlewares.setupDefaultMiddlewares)(app);
37
- await (0, import_appRoutes.loadRoutes)(app);
38
- (0, import_middlewares.setupAdditionalMiddlewars)(app);
39
- const server = (0, import_utils2.isHttps)() ? import_node_https.default.createServer((0, import_cert.getCertOptions)(), app) : import_node_http.default.createServer(app);
40
- server.listen(import_utils.port, import_utils.host, () => {
41
- import_logger.logger.appStarted(import_utils.port.toString(), import_utils.host || "localhost");
42
- }).on("error", (err) => {
35
+ try {
36
+ const app = (0, import_express.default)();
37
+ (0, import_middlewares.setupDefaultMiddlewares)(app);
38
+ await (0, import_appRoutes.loadRoutes)(app);
39
+ (0, import_middlewares.setupAdditionalMiddlewars)(app);
40
+ const server = (0, import_utils2.isHttps)() ? import_node_https.default.createServer((0, import_cert.getCertOptions)(), app) : import_node_http.default.createServer(app);
41
+ server.listen(import_utils.port, import_utils.host, () => {
42
+ import_logger.logger.appStarted(import_utils.port.toString(), import_utils.host || "localhost");
43
+ }).on("error", (err) => {
44
+ import_logger.logger.error(err);
45
+ process.exit(1);
46
+ });
47
+ const { wsServer } = await (0, import_wsServer.createWSServer)({
48
+ port: import_utils.wsPort
49
+ });
50
+ app.locals.wsServer = wsServer;
51
+ } catch (err) {
43
52
  import_logger.logger.error(err);
44
53
  process.exit(1);
45
- });
46
- const { wsServer } = await (0, import_wsServer.createWSServer)({
47
- port: import_utils.wsPort
48
- });
49
- app.locals.wsServer = wsServer;
54
+ }
50
55
  })();
56
+ process.on("unhandledRejection", (reason) => {
57
+ import_logger.logger.error(reason);
58
+ process.exit(1);
59
+ });
@@ -36,12 +36,12 @@ var import_express = __toESM(require("express"));
36
36
  var import_cors = __toESM(require("cors"));
37
37
  var import_compression = __toESM(require("compression"));
38
38
  var import_express_static_gzip = __toESM(require("express-static-gzip"));
39
- var import_pino_http = __toESM(require("pino-http"));
39
+ var import_pino_http = require("pino-http");
40
40
  var import_csp = require("./csp.js");
41
41
  var import_helpers = require("../webpack/helpers.js");
42
42
  const paths = (0, import_helpers.getPaths)();
43
43
  const setupDefaultMiddlewares = (app) => {
44
- const pino = (0, import_pino_http.default)({
44
+ const pino = (0, import_pino_http.pinoHttp)({
45
45
  transport: {
46
46
  target: "pino-pretty",
47
47
  options: {
@@ -61,8 +61,8 @@ const setupDefaultMiddlewares = (app) => {
61
61
  const setupAdditionalMiddlewars = (app, options = {}) => {
62
62
  const { buildPath = paths.buildPath, basePath = paths.basePath } = options;
63
63
  app.use((0, import_compression.default)());
64
- app.get(basePath, (_req, res) => {
65
- (0, import_csp.sendFileWithCSPNonce)({ buildPath, res });
64
+ app.get(basePath, async (_req, res) => {
65
+ await (0, import_csp.sendFileWithCSPNonce)({ buildPath, res });
66
66
  });
67
67
  app.use(
68
68
  basePath,
@@ -73,9 +73,12 @@ const setupAdditionalMiddlewars = (app, options = {}) => {
73
73
  })
74
74
  );
75
75
  app.use((0, import_express_static_gzip.default)("cdn", {}));
76
- app.get(
77
- "*",
78
- (_req, res) => (0, import_csp.sendFileWithCSPNonce)({ buildPath, res })
79
- );
76
+ app.get("*", async (_req, res) => {
77
+ await (0, import_csp.sendFileWithCSPNonce)({ buildPath, res });
78
+ });
79
+ app.use(function(err, _req, res, _next) {
80
+ console.error("Express error:", err);
81
+ res.status(500).send("Internal Server Error");
82
+ });
80
83
  return app;
81
84
  };
@@ -30,7 +30,7 @@ const lintJS = async (args) => {
30
30
  const fixIssues = args.fix ? "--fix" : "";
31
31
  const debugFlags = args.debug ? "--env-info --debug" : "";
32
32
  await exec(
33
- `eslint --flag unstable_ts_config ${!getCIEnv() ? "--color" : "--no-color"} ${fixIssues} ${debugFlags} .`
33
+ `eslint ${!getCIEnv() ? "--color" : "--no-color"} ${fixIssues} ${debugFlags} .`
34
34
  );
35
35
  };
36
36
  const cmdArgs = {