@bundle-stats/ui 4.4.0-beta.0 → 4.4.0-beta.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.
- package/lib/app/app.js +9 -3
- package/lib/app/app.js.map +1 -1
- package/lib/assets/icons.svg +9 -1
- package/lib/assets/icons.svg.js +6 -0
- package/lib/assets/icons.svg.js.map +1 -1
- package/lib/components/index.js +3 -3
- package/lib/components/index.js.map +1 -1
- package/lib/components/{duplicate-packages-insight → insights}/index.js +1 -1
- package/lib/components/insights/index.js.map +1 -0
- package/lib/components/insights/insights.js +58 -0
- package/lib/components/insights/insights.js.map +1 -0
- package/lib/components/insights/insights.module.css +32 -0
- package/lib/ui/icon/icon.js +2 -0
- package/lib/ui/icon/icon.js.map +1 -1
- package/lib-esm/app/app.js +10 -4
- package/lib-esm/app/app.js.map +1 -1
- package/lib-esm/assets/icons.svg +9 -1
- package/lib-esm/assets/icons.svg.js +6 -0
- package/lib-esm/assets/icons.svg.js.map +1 -1
- package/lib-esm/components/index.js +1 -1
- package/lib-esm/components/index.js.map +1 -1
- package/lib-esm/components/insights/index.js +2 -0
- package/lib-esm/components/insights/index.js.map +1 -0
- package/lib-esm/components/insights/insights.js +51 -0
- package/lib-esm/components/insights/insights.js.map +1 -0
- package/lib-esm/components/insights/insights.module.css +32 -0
- package/lib-esm/ui/icon/icon.js +2 -0
- package/lib-esm/ui/icon/icon.js.map +1 -1
- package/package.json +14 -16
- package/src/app/app.jsx +18 -8
- package/src/assets/icons/error.svg +6 -0
- package/src/assets/icons/info.svg +6 -0
- package/src/assets/icons.svg +9 -1
- package/src/assets/icons.svg.jsx +26 -0
- package/src/components/index.js +1 -1
- package/src/components/insights/index.ts +1 -0
- package/src/components/insights/insights.module.css +32 -0
- package/src/components/insights/insights.stories.tsx +50 -0
- package/src/components/insights/insights.tsx +101 -0
- package/src/ui/icon/icon.jsx +2 -0
- package/types/components/index.d.ts +1 -1
- package/types/components/insights/index.d.ts +1 -0
- package/types/components/insights/insights.d.ts +8 -0
- package/types/ui/icon/icon.d.ts +2 -0
- package/lib/components/duplicate-packages-insight/duplicate-packages-insight.js +0 -31
- package/lib/components/duplicate-packages-insight/duplicate-packages-insight.js.map +0 -1
- package/lib/components/duplicate-packages-insight/duplicate-packages-insight.module.css +0 -18
- package/lib/components/duplicate-packages-insight/index.js.map +0 -1
- package/lib-esm/components/duplicate-packages-insight/duplicate-packages-insight.js +0 -24
- package/lib-esm/components/duplicate-packages-insight/duplicate-packages-insight.js.map +0 -1
- package/lib-esm/components/duplicate-packages-insight/duplicate-packages-insight.module.css +0 -18
- package/lib-esm/components/duplicate-packages-insight/index.js +0 -2
- package/lib-esm/components/duplicate-packages-insight/index.js.map +0 -1
- package/src/components/duplicate-packages-insight/duplicate-packages-insight.module.css +0 -18
- package/src/components/duplicate-packages-insight/duplicate-packages-insight.stories.tsx +0 -66
- package/src/components/duplicate-packages-insight/duplicate-packages-insight.tsx +0 -81
- package/src/components/duplicate-packages-insight/index.ts +0 -1
- package/types/components/duplicate-packages-insight/duplicate-packages-insight.d.ts +0 -11
- package/types/components/duplicate-packages-insight/index.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bundle-stats/ui",
|
|
3
|
-
"version": "4.4.0-beta.
|
|
3
|
+
"version": "4.4.0-beta.1",
|
|
4
4
|
"description": "UI components for BundleStats projects.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-esm/index.js",
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
"start": "cross-env NODE_ENV=development start-storybook -c ./build/storybook -p 8080",
|
|
21
21
|
"test": "npm run test:unit",
|
|
22
22
|
"test:unit": "jest src --passWithNoTests",
|
|
23
|
-
"test:storyshots": "jest build/storybook "
|
|
24
|
-
"chromatic": "chromatic --exit-zero-on-changes"
|
|
23
|
+
"test:storyshots": "jest build/storybook "
|
|
25
24
|
},
|
|
26
25
|
"repository": {
|
|
27
26
|
"type": "git",
|
|
@@ -41,17 +40,16 @@
|
|
|
41
40
|
"devDependencies": {
|
|
42
41
|
"@babel/preset-env": "7.20.2",
|
|
43
42
|
"@babel/preset-react": "7.18.6",
|
|
44
|
-
"@storybook/addon-essentials": "6.5.
|
|
43
|
+
"@storybook/addon-essentials": "6.5.16",
|
|
45
44
|
"@storybook/addon-knobs": "6.4.0",
|
|
46
45
|
"@storybook/addon-postcss": "2.0.0",
|
|
47
|
-
"@storybook/addon-storyshots": "6.5.
|
|
48
|
-
"@storybook/addons": "6.5.
|
|
49
|
-
"@storybook/builder-webpack5": "6.5.
|
|
50
|
-
"@storybook/manager-webpack5": "6.5.
|
|
51
|
-
"@storybook/react": "6.5.
|
|
46
|
+
"@storybook/addon-storyshots": "6.5.16",
|
|
47
|
+
"@storybook/addons": "6.5.16",
|
|
48
|
+
"@storybook/builder-webpack5": "6.5.16",
|
|
49
|
+
"@storybook/manager-webpack5": "6.5.16",
|
|
50
|
+
"@storybook/react": "6.5.16",
|
|
52
51
|
"@types/react": "18.0.26",
|
|
53
52
|
"babel-plugin-require-context-hook": "1.0.0",
|
|
54
|
-
"chromatic": "6.15.0",
|
|
55
53
|
"classnames": "2.3.2",
|
|
56
54
|
"colormap": "2.3.2",
|
|
57
55
|
"cross-env": "7.0.3",
|
|
@@ -60,9 +58,9 @@
|
|
|
60
58
|
"enzyme-to-json": "3.6.2",
|
|
61
59
|
"hex-rgb": "5.0.0",
|
|
62
60
|
"identity-obj-proxy": "3.0.0",
|
|
63
|
-
"jest": "29.4.
|
|
61
|
+
"jest": "29.4.2",
|
|
64
62
|
"jest-date-mock": "1.0.8",
|
|
65
|
-
"jest-environment-jsdom": "29.4.
|
|
63
|
+
"jest-environment-jsdom": "29.4.2",
|
|
66
64
|
"lodash": "4.17.21",
|
|
67
65
|
"postcss": "8.4.21",
|
|
68
66
|
"prop-types": "15.8.1",
|
|
@@ -71,7 +69,7 @@
|
|
|
71
69
|
"react-router-dom": "5.3.4",
|
|
72
70
|
"react-test-renderer": "18.2.0",
|
|
73
71
|
"rimraf": "4.1.2",
|
|
74
|
-
"typescript": "4.9.
|
|
72
|
+
"typescript": "4.9.5"
|
|
75
73
|
},
|
|
76
74
|
"peerDependencies": {
|
|
77
75
|
"classnames": "^2.0.0",
|
|
@@ -82,11 +80,11 @@
|
|
|
82
80
|
"react-router-dom": "^5.0.0"
|
|
83
81
|
},
|
|
84
82
|
"dependencies": {
|
|
85
|
-
"@bundle-stats/utils": "^4.4.0-beta.
|
|
83
|
+
"@bundle-stats/utils": "^4.4.0-beta.1",
|
|
86
84
|
"ariakit": "2.0.0-next.43",
|
|
87
85
|
"modern-css-reset": "1.4.0",
|
|
88
86
|
"query-string": "7.1.3",
|
|
89
|
-
"use-query-params": "2.
|
|
87
|
+
"use-query-params": "2.2.0"
|
|
90
88
|
},
|
|
91
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "282bd9bf5f16be3a868b946e257f1e89c27c90d6"
|
|
92
90
|
}
|
package/src/app/app.jsx
CHANGED
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
} from '../constants';
|
|
13
13
|
import { Box } from '../layout/box';
|
|
14
14
|
import { Container } from '../ui/container';
|
|
15
|
-
import { DuplicatePackagesInsight } from '../components/duplicate-packages-insight';
|
|
16
15
|
import { Summary } from '../components/summary';
|
|
17
16
|
import { BundleAssets } from '../components/bundle-assets';
|
|
18
17
|
import { BundleAssetsTotalsChartBars } from '../components/bundle-assets-totals-chart-bars';
|
|
@@ -22,11 +21,13 @@ import { Stack } from '../layout/stack';
|
|
|
22
21
|
import { BundleAssetsTotalsTable } from '../components/bundle-assets-totals-table';
|
|
23
22
|
import { BundleModules } from '../components/bundle-modules';
|
|
24
23
|
import { BundlePackages } from '../components/bundle-packages';
|
|
24
|
+
import { Insights } from '../components/insights';
|
|
25
25
|
import { TotalSizeTypeTitle } from '../components/total-size-type-title';
|
|
26
26
|
import { QueryStateProvider, useComponentQueryState } from '../query-state';
|
|
27
27
|
import I18N from '../i18n';
|
|
28
28
|
import { Header } from './header';
|
|
29
29
|
import css from './app.module.css';
|
|
30
|
+
import { MetricsTableTitle } from '../components';
|
|
30
31
|
|
|
31
32
|
const ScrollToTop = () => {
|
|
32
33
|
const { pathname } = useLocation();
|
|
@@ -68,18 +69,27 @@ JobsProvider.propTypes = {
|
|
|
68
69
|
|
|
69
70
|
const OverviewContent = () => {
|
|
70
71
|
const { jobs } = useContext(JobsContext);
|
|
72
|
+
|
|
71
73
|
const duplicatePackagesInsight = jobs[0].insights?.webpack?.duplicatePackagesV3;
|
|
74
|
+
const newPackagesInsight = jobs[0].insights?.webpack?.newPackages;
|
|
75
|
+
|
|
76
|
+
console.info(duplicatePackagesInsight, newPackagesInsight);
|
|
72
77
|
|
|
73
78
|
return (
|
|
74
79
|
<Stack space="medium">
|
|
75
|
-
{duplicatePackagesInsight && (
|
|
80
|
+
{(duplicatePackagesInsight || newPackagesInsight) && (
|
|
76
81
|
<Container>
|
|
77
|
-
<
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
<Stack space="xsmall">
|
|
83
|
+
<MetricsTableTitle title="Insights" />
|
|
84
|
+
<Box padding="small" outline>
|
|
85
|
+
<Insights
|
|
86
|
+
duplicatePackages={duplicatePackagesInsight}
|
|
87
|
+
newPackages={newPackagesInsight}
|
|
88
|
+
summary={jobs[0].summary?.webpack}
|
|
89
|
+
showDelta={jobs.length > 1}
|
|
90
|
+
/>
|
|
91
|
+
</Box>
|
|
92
|
+
</Stack>
|
|
83
93
|
</Container>
|
|
84
94
|
)}
|
|
85
95
|
<Container>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2
|
+
<circle cx="12" cy="12" r="10"></circle>
|
|
3
|
+
<line x1="12" y1="8" x2="12" y2="12"></line>
|
|
4
|
+
<line x1="12" y1="16" x2="12.01" y2="16"></line>
|
|
5
|
+
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2
|
+
<circle cx="12" cy="12" r="10"></circle>
|
|
3
|
+
<line x1="12" y1="16" x2="12" y2="12"></line>
|
|
4
|
+
<line x1="12" y1="8" x2="12.01" y2="8"></line>
|
|
5
|
+
|
|
6
|
+
</svg>
|
package/src/assets/icons.svg
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<svg width="
|
|
1
|
+
<svg width="0" height="0" style="position:absolute">
|
|
2
2
|
<symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-down" id="arrow" xmlns="http://www.w3.org/2000/svg">
|
|
3
3
|
<path d="M12 5v14M19 12l-7 7-7-7"/>
|
|
4
4
|
</symbol>
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
<circle cx="12" cy="12" r="4"/>
|
|
23
23
|
<path d="M1.05 12H7M17.01 12h5.95"/>
|
|
24
24
|
</symbol>
|
|
25
|
+
<symbol fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24" id="error" xmlns="http://www.w3.org/2000/svg">
|
|
26
|
+
<circle cx="12" cy="12" r="10"/>
|
|
27
|
+
<path d="M12 8v4M12 16h.01"/>
|
|
28
|
+
</symbol>
|
|
25
29
|
<symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-bar-chart" id="filter" xmlns="http://www.w3.org/2000/svg">
|
|
26
30
|
<path d="M12 20V10M18 20V4M6 20v-4"/>
|
|
27
31
|
</symbol>
|
|
@@ -29,6 +33,10 @@
|
|
|
29
33
|
<circle cx="12" cy="12" r="10"/>
|
|
30
34
|
<path d="M9.09 9a3 3 0 015.83 1c0 2-3 3-3 3M12 17h.01"/>
|
|
31
35
|
</symbol>
|
|
36
|
+
<symbol fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24" id="info" xmlns="http://www.w3.org/2000/svg">
|
|
37
|
+
<circle cx="12" cy="12" r="10"/>
|
|
38
|
+
<path d="M12 16v-4M12 8h.01"/>
|
|
39
|
+
</symbol>
|
|
32
40
|
<symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-menu" id="menu" xmlns="http://www.w3.org/2000/svg">
|
|
33
41
|
<path d="M3 12h18M3 6h18M3 18h18"/>
|
|
34
42
|
</symbol>
|
package/src/assets/icons.svg.jsx
CHANGED
|
@@ -85,6 +85,19 @@ export const SvgIcons = (props) => (
|
|
|
85
85
|
<circle cx="12" cy="12" r="4" />
|
|
86
86
|
<path d="M1.05 12H7M17.01 12h5.95" />
|
|
87
87
|
</symbol>
|
|
88
|
+
<symbol
|
|
89
|
+
fill="none"
|
|
90
|
+
stroke="currentColor"
|
|
91
|
+
stroke-width="2"
|
|
92
|
+
stroke-linecap="round"
|
|
93
|
+
stroke-linejoin="round"
|
|
94
|
+
viewBox="0 0 24 24"
|
|
95
|
+
id="error"
|
|
96
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
97
|
+
>
|
|
98
|
+
<circle cx="12" cy="12" r="10" />
|
|
99
|
+
<path d="M12 8v4M12 16h.01" />
|
|
100
|
+
</symbol>
|
|
88
101
|
<symbol
|
|
89
102
|
viewBox="0 0 24 24"
|
|
90
103
|
fill="none"
|
|
@@ -112,6 +125,19 @@ export const SvgIcons = (props) => (
|
|
|
112
125
|
<circle cx="12" cy="12" r="10" />
|
|
113
126
|
<path d="M9.09 9a3 3 0 015.83 1c0 2-3 3-3 3M12 17h.01" />
|
|
114
127
|
</symbol>
|
|
128
|
+
<symbol
|
|
129
|
+
fill="none"
|
|
130
|
+
stroke="currentColor"
|
|
131
|
+
stroke-width="2"
|
|
132
|
+
stroke-linecap="round"
|
|
133
|
+
stroke-linejoin="round"
|
|
134
|
+
viewBox="0 0 24 24"
|
|
135
|
+
id="info"
|
|
136
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
137
|
+
>
|
|
138
|
+
<circle cx="12" cy="12" r="10" />
|
|
139
|
+
<path d="M12 16v-4M12 8h.01" />
|
|
140
|
+
</symbol>
|
|
115
141
|
<symbol
|
|
116
142
|
viewBox="0 0 24 24"
|
|
117
143
|
fill="none"
|
package/src/components/index.js
CHANGED
|
@@ -5,8 +5,8 @@ export { BundleAssetsTotalsChartBars } from './bundle-assets-totals-chart-bars';
|
|
|
5
5
|
export { BundlePackages } from './bundle-packages';
|
|
6
6
|
export { BundleModules } from './bundle-modules';
|
|
7
7
|
export { ComponentLink } from './component-link';
|
|
8
|
-
export { DuplicatePackagesInsight } from './duplicate-packages-insight';
|
|
9
8
|
export { Delta } from './delta';
|
|
9
|
+
export { Insights } from './insights';
|
|
10
10
|
export { JobName } from './job-name';
|
|
11
11
|
export { JobHeader } from './job-header';
|
|
12
12
|
export { JobsHeader } from './jobs-header';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './insights';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.icon {
|
|
2
|
+
padding: 3px;
|
|
3
|
+
box-sizing: content-box;
|
|
4
|
+
border-radius: 50%;
|
|
5
|
+
background: var(--color-highlight);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.error .icon {
|
|
9
|
+
background: var(--color-red-50);
|
|
10
|
+
color: var(--color-danger);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.warning .icon {
|
|
14
|
+
background: var(--color-yellow-100);
|
|
15
|
+
color: var(--color-warning-dark);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.info .icon {
|
|
19
|
+
background: var(--color-highlight-info);
|
|
20
|
+
color: var(--color-info);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.entry {
|
|
24
|
+
color: inherit;
|
|
25
|
+
text-decoration: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.entry:hover,
|
|
29
|
+
.entry:active,
|
|
30
|
+
.entry:focus {
|
|
31
|
+
text-decoration: underline;
|
|
32
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { getWrapperDecorator } from '../../stories';
|
|
4
|
+
import { Insights } from '.';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/Insights',
|
|
8
|
+
component: Insights,
|
|
9
|
+
decorators: [getWrapperDecorator()],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const Template = (props: any) => <Insights {...props} />;
|
|
13
|
+
|
|
14
|
+
export const Default = Template.bind({});
|
|
15
|
+
|
|
16
|
+
Default.args = {
|
|
17
|
+
duplicatePackages: {
|
|
18
|
+
type: 'error',
|
|
19
|
+
data: {
|
|
20
|
+
packages: { 'package-a': ['package-a', 'package-a~1'] },
|
|
21
|
+
text: 'Bundle introduced 1 and removed 2 duplicate packages',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
newPackages: {
|
|
25
|
+
type: 'warning',
|
|
26
|
+
data: {
|
|
27
|
+
text: 'Bundle introduced 2 new packages: package-c, package-d',
|
|
28
|
+
packages: ['package-c', 'package-d'],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const Info = Template.bind({});
|
|
34
|
+
|
|
35
|
+
Info.args = {
|
|
36
|
+
duplicatePackages: {
|
|
37
|
+
type: 'info',
|
|
38
|
+
data: {
|
|
39
|
+
packages: { 'package-a': ['package-a', 'package-a~1'] },
|
|
40
|
+
text: 'Bundle removed 1 duplicate packages',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
newPackages: {
|
|
44
|
+
type: 'warning',
|
|
45
|
+
data: {
|
|
46
|
+
text: 'Bundle introduced 2 new packages: package-c, package-d',
|
|
47
|
+
packages: ['package-c', 'package-d'],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import {
|
|
4
|
+
BUNDLE_PACKAGES_DUPLICATE,
|
|
5
|
+
BUNDLE_PACKAGES_COUNT,
|
|
6
|
+
InsightType,
|
|
7
|
+
JobInsight,
|
|
8
|
+
JobInsights as JobInsightsType,
|
|
9
|
+
} from '@bundle-stats/utils';
|
|
10
|
+
|
|
11
|
+
import { FlexStack } from '../../layout/flex-stack';
|
|
12
|
+
import { Stack } from '../../layout/stack';
|
|
13
|
+
import { Icon } from '../../ui/icon';
|
|
14
|
+
import { ComponentLink } from '../component-link';
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
import css from './insights.module.css';
|
|
17
|
+
|
|
18
|
+
interface InsightEntry {
|
|
19
|
+
name: string;
|
|
20
|
+
insight: JobInsight;
|
|
21
|
+
link: any;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const normalizedInsights = ({
|
|
25
|
+
duplicatePackages,
|
|
26
|
+
newPackages,
|
|
27
|
+
}: Partial<JobInsightsType['webpack']>): Array<InsightEntry> => {
|
|
28
|
+
const insightsByLevel: Record<InsightType, Array<InsightEntry>> = {
|
|
29
|
+
[InsightType.ERROR]: [],
|
|
30
|
+
[InsightType.WARNING]: [],
|
|
31
|
+
[InsightType.INFO]: [],
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
if (duplicatePackages) {
|
|
35
|
+
insightsByLevel[duplicatePackages.type].push({
|
|
36
|
+
name: 'duplicatePackages',
|
|
37
|
+
insight: duplicatePackages,
|
|
38
|
+
link: BUNDLE_PACKAGES_DUPLICATE,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (newPackages) {
|
|
43
|
+
insightsByLevel[newPackages.type].push({
|
|
44
|
+
name: 'newPackages',
|
|
45
|
+
insight: newPackages,
|
|
46
|
+
link: BUNDLE_PACKAGES_COUNT,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return [
|
|
51
|
+
...(insightsByLevel[InsightType.ERROR] || []),
|
|
52
|
+
...(insightsByLevel[InsightType.WARNING] || []),
|
|
53
|
+
...(insightsByLevel[InsightType.INFO] || []),
|
|
54
|
+
];
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const InsightTypeIconMap = new Map([
|
|
58
|
+
[InsightType.ERROR, Icon.ICONS.ERROR],
|
|
59
|
+
[InsightType.WARNING, Icon.ICONS.WARNING],
|
|
60
|
+
[InsightType.INFO, Icon.ICONS.INFO],
|
|
61
|
+
]);
|
|
62
|
+
|
|
63
|
+
interface InsightsProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
64
|
+
duplicatePackages: any;
|
|
65
|
+
newPackages: any;
|
|
66
|
+
customComponentLink?: React.ElementType;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const Insights = (props: InsightsProps) => {
|
|
70
|
+
const {
|
|
71
|
+
duplicatePackages,
|
|
72
|
+
newPackages,
|
|
73
|
+
customComponentLink: CustomComponentLink = ComponentLink,
|
|
74
|
+
...restProps
|
|
75
|
+
} = props;
|
|
76
|
+
|
|
77
|
+
const insights = normalizedInsights({ duplicatePackages, newPackages });
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<Stack space="xxsmall" {...restProps}>
|
|
81
|
+
{insights.map(({ name, insight, link }) => {
|
|
82
|
+
const glyph = InsightTypeIconMap.get(insight.type);
|
|
83
|
+
const { text } = insight.data as { text: string };
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<FlexStack
|
|
87
|
+
key={name}
|
|
88
|
+
space="xxsmall"
|
|
89
|
+
alignItems="center"
|
|
90
|
+
as={CustomComponentLink}
|
|
91
|
+
{...link}
|
|
92
|
+
className={cx(css.entry, css[insight.type])}
|
|
93
|
+
>
|
|
94
|
+
{glyph && <Icon glyph={glyph} className={css.icon} />}
|
|
95
|
+
<span>{text}</span>
|
|
96
|
+
</FlexStack>
|
|
97
|
+
);
|
|
98
|
+
})}
|
|
99
|
+
</Stack>
|
|
100
|
+
);
|
|
101
|
+
};
|
package/src/ui/icon/icon.jsx
CHANGED
|
@@ -5,8 +5,8 @@ export { BundleAssetsTotalsChartBars } from "./bundle-assets-totals-chart-bars";
|
|
|
5
5
|
export { BundlePackages } from "./bundle-packages";
|
|
6
6
|
export { BundleModules } from "./bundle-modules";
|
|
7
7
|
export { ComponentLink } from "./component-link";
|
|
8
|
-
export { DuplicatePackagesInsight } from "./duplicate-packages-insight";
|
|
9
8
|
export { Delta } from "./delta";
|
|
9
|
+
export { Insights } from "./insights";
|
|
10
10
|
export { JobName } from "./job-name";
|
|
11
11
|
export { JobHeader } from "./job-header";
|
|
12
12
|
export { JobsHeader } from "./jobs-header";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './insights';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface InsightsProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
duplicatePackages: any;
|
|
4
|
+
newPackages: any;
|
|
5
|
+
customComponentLink?: React.ElementType;
|
|
6
|
+
}
|
|
7
|
+
export declare const Insights: (props: InsightsProps) => JSX.Element;
|
|
8
|
+
export {};
|
package/types/ui/icon/icon.d.ts
CHANGED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DuplicatePackagesInsight = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const utils_1 = require("@bundle-stats/utils");
|
|
9
|
-
const alert_1 = require("../../ui/alert");
|
|
10
|
-
const component_link_1 = require("../component-link");
|
|
11
|
-
const delta_1 = require("../delta");
|
|
12
|
-
const duplicate_packages_insight_module_css_1 = __importDefault(require("./duplicate-packages-insight.module.css"));
|
|
13
|
-
const AlertKindMap = new Map([
|
|
14
|
-
[utils_1.InsightType.INFO, 'info'],
|
|
15
|
-
[utils_1.InsightType.ERROR, 'danger'],
|
|
16
|
-
[utils_1.InsightType.WARNING, 'warning'],
|
|
17
|
-
]);
|
|
18
|
-
const DuplicatePackagesInsight = (props) => {
|
|
19
|
-
const { type, data, summary, showDelta = true, customComponentLink: CustomComponentLink = component_link_1.ComponentLink, ...restProps } = props;
|
|
20
|
-
const metric = (0, utils_1.getGlobalMetricType)('webpack.duplicatePackageCount');
|
|
21
|
-
const metricRunInfo = (0, utils_1.getMetricRunInfo)(metric, summary.current, summary.baseline);
|
|
22
|
-
const hasDuplicatePackages = metricRunInfo.value > 0 || (metricRunInfo && (metricRunInfo.delta !== 0));
|
|
23
|
-
return (react_1.default.createElement(alert_1.Alert, { kind: AlertKindMap.get(type), ...restProps },
|
|
24
|
-
react_1.default.createElement("span", { className: duplicate_packages_insight_module_css_1.default.message }, data.text),
|
|
25
|
-
hasDuplicatePackages && (react_1.default.createElement("span", { className: duplicate_packages_insight_module_css_1.default.metric },
|
|
26
|
-
metricRunInfo.value,
|
|
27
|
-
showDelta && typeof metricRunInfo.delta !== 'undefined' && (react_1.default.createElement(delta_1.Delta, { className: duplicate_packages_insight_module_css_1.default.delta, inverted: true, displayValue: metricRunInfo.displayDelta, deltaType: metricRunInfo.deltaType })))),
|
|
28
|
-
react_1.default.createElement("span", { className: duplicate_packages_insight_module_css_1.default.link }, hasDuplicatePackages ? (react_1.default.createElement(CustomComponentLink, { ...utils_1.BUNDLE_PACKAGES_DUPLICATE }, "View duplicate packages")) : (react_1.default.createElement(CustomComponentLink, { ...utils_1.BUNDLE_PACKAGES_COUNT }, "View packages")))));
|
|
29
|
-
};
|
|
30
|
-
exports.DuplicatePackagesInsight = DuplicatePackagesInsight;
|
|
31
|
-
//# sourceMappingURL=duplicate-packages-insight.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"duplicate-packages-insight.js","sourceRoot":"","sources":["../../../src/components/duplicate-packages-insight/duplicate-packages-insight.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,+CAQ6B;AAE7B,0CAAuC;AACvC,sDAAkD;AAClD,oCAAiC;AAEjC,oHAA0D;AAU1D,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,CAAC,mBAAW,CAAC,IAAI,EAAE,MAAM,CAAC;IAC1B,CAAC,mBAAW,CAAC,KAAK,EAAE,QAAQ,CAAC;IAC7B,CAAC,mBAAW,CAAC,OAAO,EAAE,SAAS,CAAC;CACjC,CAAC,CAAC;AAEI,MAAM,wBAAwB,GAAG,CAAC,KAAoC,EAAE,EAAE;IAC/E,MAAM,EACJ,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,SAAS,GAAG,IAAI,EAChB,mBAAmB,EAAE,mBAAmB,GAAG,8BAAa,EACxD,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IAEV,MAAM,MAAM,GAAG,IAAA,2BAAmB,EAAC,+BAA+B,CAAC,CAAC;IAEpE,MAAM,aAAa,GAAG,IAAA,wBAAgB,EACpC,MAAM,EACN,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,QAAQ,CACjB,CAAC;IAEF,MAAM,oBAAoB,GAAG,aAAa,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;IAEvG,OAAO,CACL,8BAAC,aAAK,IAAC,IAAI,EAAE,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,KAAM,SAAS;QAChD,wCAAM,SAAS,EAAE,+CAAG,CAAC,OAAO,IAAG,IAAI,CAAC,IAAI,CAAQ;QAC/C,oBAAoB,IAAI,CACvB,wCAAM,SAAS,EAAE,+CAAG,CAAC,MAAM;YACxB,aAAa,CAAC,KAAK;YACnB,SAAS,IAAI,OAAO,aAAa,CAAC,KAAK,KAAK,WAAW,IAAI,CAC1D,8BAAC,aAAK,IACJ,SAAS,EAAE,+CAAG,CAAC,KAAK,EACpB,QAAQ,QACR,YAAY,EAAE,aAAa,CAAC,YAAsB,EAClD,SAAS,EAAE,aAAa,CAAC,SAAmB,GAC5C,CACH,CACI,CACR;QACD,wCAAM,SAAS,EAAE,+CAAG,CAAC,IAAI,IACtB,oBAAoB,CAAC,CAAC,CAAC,CACtB,8BAAC,mBAAmB,OAAK,iCAAgC,8BAEnC,CACvB,CAAC,CAAC,CAAC,CACF,8BAAC,mBAAmB,OAAK,6BAA4B,oBAE/B,CACvB,CACI,CACD,CACT,CAAC;AACJ,CAAC,CAAC;AAjDW,QAAA,wBAAwB,4BAiDnC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
.metric {
|
|
2
|
-
font-weight: bold;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.metric::before,
|
|
6
|
-
.link::before {
|
|
7
|
-
content: '\00A0\2014\00A0';
|
|
8
|
-
font-weight: normal;
|
|
9
|
-
color: var(--color-text-ultra-light);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.delta {
|
|
13
|
-
margin-left: var(--space-xxxsmall);
|
|
14
|
-
padding: 1px 2px;
|
|
15
|
-
vertical-align: super;
|
|
16
|
-
font-size: 9px;
|
|
17
|
-
line-height: 1;
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/duplicate-packages-insight/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA6C"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { BUNDLE_PACKAGES_DUPLICATE, BUNDLE_PACKAGES_COUNT, InsightType, getMetricRunInfo, getGlobalMetricType, } from '@bundle-stats/utils';
|
|
3
|
-
import { Alert } from '../../ui/alert';
|
|
4
|
-
import { ComponentLink } from '../component-link';
|
|
5
|
-
import { Delta } from '../delta';
|
|
6
|
-
import css from './duplicate-packages-insight.module.css';
|
|
7
|
-
const AlertKindMap = new Map([
|
|
8
|
-
[InsightType.INFO, 'info'],
|
|
9
|
-
[InsightType.ERROR, 'danger'],
|
|
10
|
-
[InsightType.WARNING, 'warning'],
|
|
11
|
-
]);
|
|
12
|
-
export const DuplicatePackagesInsight = (props) => {
|
|
13
|
-
const { type, data, summary, showDelta = true, customComponentLink: CustomComponentLink = ComponentLink, ...restProps } = props;
|
|
14
|
-
const metric = getGlobalMetricType('webpack.duplicatePackageCount');
|
|
15
|
-
const metricRunInfo = getMetricRunInfo(metric, summary.current, summary.baseline);
|
|
16
|
-
const hasDuplicatePackages = metricRunInfo.value > 0 || (metricRunInfo && (metricRunInfo.delta !== 0));
|
|
17
|
-
return (React.createElement(Alert, { kind: AlertKindMap.get(type), ...restProps },
|
|
18
|
-
React.createElement("span", { className: css.message }, data.text),
|
|
19
|
-
hasDuplicatePackages && (React.createElement("span", { className: css.metric },
|
|
20
|
-
metricRunInfo.value,
|
|
21
|
-
showDelta && typeof metricRunInfo.delta !== 'undefined' && (React.createElement(Delta, { className: css.delta, inverted: true, displayValue: metricRunInfo.displayDelta, deltaType: metricRunInfo.deltaType })))),
|
|
22
|
-
React.createElement("span", { className: css.link }, hasDuplicatePackages ? (React.createElement(CustomComponentLink, { ...BUNDLE_PACKAGES_DUPLICATE }, "View duplicate packages")) : (React.createElement(CustomComponentLink, { ...BUNDLE_PACKAGES_COUNT }, "View packages")))));
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=duplicate-packages-insight.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"duplicate-packages-insight.js","sourceRoot":"","sources":["../../../src/components/duplicate-packages-insight/duplicate-packages-insight.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,WAAW,EAEX,gBAAgB,EAEhB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,GAAG,MAAM,yCAAyC,CAAC;AAU1D,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC;IAC1B,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC;IAC7B,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,CAAC;CACjC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,KAAoC,EAAE,EAAE;IAC/E,MAAM,EACJ,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,SAAS,GAAG,IAAI,EAChB,mBAAmB,EAAE,mBAAmB,GAAG,aAAa,EACxD,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IAEV,MAAM,MAAM,GAAG,mBAAmB,CAAC,+BAA+B,CAAC,CAAC;IAEpE,MAAM,aAAa,GAAG,gBAAgB,CACpC,MAAM,EACN,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,QAAQ,CACjB,CAAC;IAEF,MAAM,oBAAoB,GAAG,aAAa,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;IAEvG,OAAO,CACL,oBAAC,KAAK,IAAC,IAAI,EAAE,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,KAAM,SAAS;QAChD,8BAAM,SAAS,EAAE,GAAG,CAAC,OAAO,IAAG,IAAI,CAAC,IAAI,CAAQ;QAC/C,oBAAoB,IAAI,CACvB,8BAAM,SAAS,EAAE,GAAG,CAAC,MAAM;YACxB,aAAa,CAAC,KAAK;YACnB,SAAS,IAAI,OAAO,aAAa,CAAC,KAAK,KAAK,WAAW,IAAI,CAC1D,oBAAC,KAAK,IACJ,SAAS,EAAE,GAAG,CAAC,KAAK,EACpB,QAAQ,QACR,YAAY,EAAE,aAAa,CAAC,YAAsB,EAClD,SAAS,EAAE,aAAa,CAAC,SAAmB,GAC5C,CACH,CACI,CACR;QACD,8BAAM,SAAS,EAAE,GAAG,CAAC,IAAI,IACtB,oBAAoB,CAAC,CAAC,CAAC,CACtB,oBAAC,mBAAmB,OAAK,yBAAgC,8BAEnC,CACvB,CAAC,CAAC,CAAC,CACF,oBAAC,mBAAmB,OAAK,qBAA4B,oBAE/B,CACvB,CACI,CACD,CACT,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
.metric {
|
|
2
|
-
font-weight: bold;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.metric::before,
|
|
6
|
-
.link::before {
|
|
7
|
-
content: '\00A0\2014\00A0';
|
|
8
|
-
font-weight: normal;
|
|
9
|
-
color: var(--color-text-ultra-light);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.delta {
|
|
13
|
-
margin-left: var(--space-xxxsmall);
|
|
14
|
-
padding: 1px 2px;
|
|
15
|
-
vertical-align: super;
|
|
16
|
-
font-size: 9px;
|
|
17
|
-
line-height: 1;
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/duplicate-packages-insight/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
.metric {
|
|
2
|
-
font-weight: bold;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.metric::before,
|
|
6
|
-
.link::before {
|
|
7
|
-
content: '\00A0\2014\00A0';
|
|
8
|
-
font-weight: normal;
|
|
9
|
-
color: var(--color-text-ultra-light);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.delta {
|
|
13
|
-
margin-left: var(--space-xxxsmall);
|
|
14
|
-
padding: 1px 2px;
|
|
15
|
-
vertical-align: super;
|
|
16
|
-
font-size: 9px;
|
|
17
|
-
line-height: 1;
|
|
18
|
-
}
|