@bigbinary/neeto-commons-frontend 2.0.35 → 2.0.37

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.
package/README.md CHANGED
@@ -47,6 +47,9 @@ Category
47
47
  - [useLocalStorage](./docs/react/hooks.md#uselocalstorage)
48
48
  - [useOnClickOutside](./docs/react/hooks.md#useonclickoutside)
49
49
  - [useFieldSubmit](./docs/react/hooks.md#usefieldsubmit)
50
+ - [useDisplayErrorPage](./docs/react/hooks.md#usedisplayerrorpage)
51
+ - [useErrorDisplayStore](./docs/react/hooks.md#useerrordisplaystore)
52
+ - [useHotKeys](./docs/react/hooks.md#useHotKeys)
50
53
  - [PrivateRoute](./docs/react/components.md#privateroute)
51
54
  - [HoneybadgerErrorBoundary](./docs/react/components.md#honeybadgererrorboundary)
52
55
  - [Sidebar](./docs/react/components.md#sidebar)
@@ -59,13 +62,14 @@ Category
59
62
  - [CustomDomain](./docs/react/components.md#customdomain)
60
63
  - [BrowserSupport](./docs/react/components.md#browsersupport)
61
64
  - [IpRestriction](./docs/react/components.md#iprestriction)
62
- - [withImmutableActions](./docs/react/utils.md#withimmutableactions) (zustand middleware)
63
- - [withTitle](./docs/react/utils.md#withtitle) (set browser title for pages)
65
+ - [PublishBlock](./docs/react/components.md#publishblock)
66
+ - [KeyboardShortcutsPane](./docs/react/components.md#keyboardshortcutspane)
67
+ - [withImmutableActions](./docs/react/utils.md#withimmutableactions)
68
+ - [withTitle](./docs/react/utils.md#withtitle)
64
69
  - [registerBrowserNotifications](./docs/react/utils.md#registerbrowsernotifications)
65
- (register browser subscription for push notifications)
66
70
  - [destroyBrowserSubscription](./docs/react/utils.md#destroybrowsersubscription)
67
- (destroy browser subscription for push notifications)
68
- - [handleMetaClick](./docs/react/utils.md#handlemetaclick) (handle clicks to redirect to newtab)
71
+ - [handleMetaClick](./docs/react/utils.md#handlemetaclick)
72
+ - [isMetaKeyPressed](./docs/react/utils.md#ismetakeypressed)
69
73
 
70
74
  </td>
71
75
  <td style="vertical-align: top;">
@@ -186,7 +190,7 @@ them to read more:
186
190
  3. [Pure utility functions](./docs/pure/README.md)
187
191
  4. [Web utility functions](./docs/utils/README.md)
188
192
  5. [Default configurations](./docs/configs/README.md)
189
- 5. [Cypress Utils](./docs/cypress/README.md)
193
+ 6. [Cypress Utils](./docs/cypress/README.md)
190
194
 
191
195
  ## Other references
192
196
 
package/configs/babel.js CHANGED
@@ -33,6 +33,7 @@ module.exports = function (api) {
33
33
  isTestEnv
34
34
  ? "babel-plugin-dynamic-import-node" // tests run in node environment
35
35
  : "@babel/plugin-syntax-dynamic-import",
36
+ ["istanbul", { useInlineSourceMaps: false }],
36
37
  isProductionEnv && [
37
38
  "babel-plugin-transform-react-remove-prop-types",
38
39
  { removeImport: true },
@@ -1,61 +1,78 @@
1
1
  const fs = require("fs");
2
2
  const path = require("path");
3
3
 
4
- const { mergeDeepLeft } = require("ramda");
4
+ const { mergeDeepLeft, mergeLeft, keys } = require("ramda");
5
5
 
6
6
  const loadJS = jsPath => {
7
7
  try {
8
- return require(path.resolve(__dirname, "../../../..", jsPath));
9
- } catch (error) {
8
+ return require(jsPath);
9
+ } catch {
10
10
  return {};
11
11
  }
12
12
  };
13
13
 
14
- const buildPathGroupsBasedOnWebpackAliases = ({
15
- customJSRoot = "app/javascript/",
16
- customAliasPath = "config/webpack/resolve.js",
17
- }) => {
18
- const rootOfProject = `${__dirname}/../../../../../../`;
14
+ const doesFileExist = filePath =>
15
+ fs.existsSync(filePath) && fs.lstatSync(filePath).isFile();
16
+
17
+ const generateAllPathsInsideDir = dirPath => {
18
+ const files = fs.readdirSync(dirPath, { withFileTypes: true });
19
19
 
20
- const isFile = filePath =>
21
- fs.existsSync(filePath) && fs.lstatSync(filePath).isFile();
20
+ return files.flatMap(file => {
21
+ const filePath = path.join(dirPath, file.name);
22
22
 
23
- const isRailsProject = isFile(`${rootOfProject}Gemfile`);
23
+ return file.isDirectory() ? generateAllPathsInsideDir(filePath) : filePath;
24
+ });
25
+ };
24
26
 
25
- const emptyPathGroups = [];
27
+ const generatePathGroupsFromAssets = assetsPath => {
28
+ if (!fs.existsSync(assetsPath)) return [];
26
29
 
27
- if (!isRailsProject) return emptyPathGroups;
30
+ return generateAllPathsInsideDir(assetsPath).map(absPath => ({
31
+ pattern: absPath.replace(assetsPath, "").split(".")[0],
32
+ group: "internal",
33
+ }));
34
+ };
28
35
 
29
- const projectResolve = loadJS(rootOfProject + customAliasPath);
36
+ const buildPathGroupsBasedOnWebpackAliases = ({
37
+ customAliasPath = "config/webpack/resolve.js",
38
+ }) => {
39
+ const rootOfProject = path.join(__dirname, "../../../../../../");
40
+ const projectResolve = loadJS(path.join(rootOfProject, customAliasPath));
30
41
  const commonResolve = loadJS(
31
- `${rootOfProject}node_modules/@bigbinary/neeto-commons-frontend/configs/webpack/resolve.js`
42
+ path.join(
43
+ rootOfProject,
44
+ "node_modules/@bigbinary/neeto-commons-frontend/configs/webpack/resolve.js"
45
+ )
32
46
  );
33
- const { alias } = mergeDeepLeft(projectResolve, commonResolve);
34
47
 
35
- const railsJSFilesRoot = rootOfProject + customJSRoot;
36
-
37
- const pathGroups = Object.entries(alias).map(([name, path]) => {
38
- // sometimes alias might be already resolved to full absolute path
39
- const isAlreadyAnAbsolutePath =
40
- path.includes("cypress-tests/") || path.includes("app/");
48
+ const { dependencies = [], devDependencies = [] } = loadJS(
49
+ path.join(rootOfProject, "package.json")
50
+ );
51
+ const packages = keys(mergeLeft(dependencies, devDependencies));
52
+ const { alias = {}, extensions = [] } = mergeDeepLeft(
53
+ projectResolve,
54
+ commonResolve
55
+ );
41
56
 
42
- const absolutePath = isAlreadyAnAbsolutePath
43
- ? path
44
- : `${railsJSFilesRoot}${path}`;
45
- const wildCard =
46
- isFile(`${absolutePath}.js`) || isFile(`${absolutePath}.jsx`)
47
- ? ""
48
- : "/**";
57
+ const pathGroups = Object.entries(alias).flatMap(([pattern, aliasPath]) => {
58
+ const group = packages.includes(aliasPath) ? "external" : "internal";
59
+ const isFile = ["", ...extensions].some(extension =>
60
+ doesFileExist(`${aliasPath}${extension}`)
61
+ );
49
62
 
50
- let group = "internal";
51
- if (name === "neetoui") {
52
- group = "external";
53
- }
63
+ if (isFile) return { pattern, group };
54
64
 
55
- return { pattern: `${name}${wildCard}`, group };
65
+ return [
66
+ { pattern, group },
67
+ { pattern: `${pattern}/**`, group },
68
+ ];
56
69
  });
57
70
 
58
- return pathGroups;
71
+ const pathGroupsFromAssets = generatePathGroupsFromAssets(
72
+ path.join(rootOfProject, "app/assets/")
73
+ );
74
+
75
+ return pathGroups.concat(pathGroupsFromAssets);
59
76
  };
60
77
 
61
78
  module.exports = { buildPathGroupsBasedOnWebpackAliases };