@bundle-stats/utils 4.1.2 → 4.1.3
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 +11 -8
- package/lib/utils/date.js +53 -19
- package/lib/utils/date.js.map +1 -1
- package/lib-esm/utils/date.js +47 -17
- package/lib-esm/utils/date.js.map +1 -1
- package/package.json +9 -9
- package/src/utils/date.ts +73 -0
- package/types/report/merge-metrics-by-key.d.ts +1 -1
- package/types/utils/date.d.ts +3 -2
- package/types/webpack/types.d.ts +3 -3
- package/src/utils/date.js +0 -24
package/README.md
CHANGED
|
@@ -37,16 +37,19 @@ console.log(report.insights.webpack.assetsSizeTotal.data.text);
|
|
|
37
37
|
|
|
38
38
|
## Related projects
|
|
39
39
|
|
|
40
|
-
### :cyclone: [relative-ci.com](https://relative-ci.com)
|
|
40
|
+
### :cyclone: [relative-ci.com](https://relative-ci.com?utm_medium=bundle-stats-utils)
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
#### In-depth webpack bundle analysis and monitoring
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
- GitHub Check, GitHub Pull Request, and Slack integrations
|
|
46
|
-
- Support for all major CI services (CircleCI, GitHub Actions, Gitlab CI, Jenkins, Travis CI)
|
|
47
|
-
- Free for OpenSource, developers and small teams
|
|
44
|
+
RelativeCI automates webpack bundle analysis, monitoring, and alerting so you can identify and fix bundle regressions before shipping to production:
|
|
48
45
|
|
|
49
|
-
|
|
46
|
+
- :crystal_ball: Analyze webpack bundle stats on every build
|
|
47
|
+
- :chart_with_upwards_trend: Monitor webpack bundle stats changes and identify tendencies over extended periods
|
|
48
|
+
- :bell: Get notified via GitHub Checks, GitHub Pull Request comments, and Slack notifications
|
|
49
|
+
- :hammer: Support for all major CI services (CircleCI, GitHub Actions, Gitlab CI, Jenkins, Travis CI)
|
|
50
|
+
- :two_hearts: Always free for Open Source
|
|
51
|
+
|
|
52
|
+
[Try for free](https://relative-ci.com?utm_medium=bundle-stats-utils)
|
|
50
53
|
|
|
51
54
|
### :first_quarter_moon: [relative-ci/compare](https://compare.relative-ci.com)
|
|
52
55
|
|
|
@@ -56,4 +59,4 @@ Standalone web application to compare Webpack/Lighthouse/Browsertime stats.
|
|
|
56
59
|
|
|
57
60
|
### :zap: [bundle-stats-action](https://github.com/vio/bundle-stats-action)
|
|
58
61
|
|
|
59
|
-
Github Action that generates [bundle-stats](https://github.com/relative-ci/bundle-stats) reports
|
|
62
|
+
Github Action that generates [bundle-stats](https://github.com/relative-ci/bundle-stats) reports.
|
package/lib/utils/date.js
CHANGED
|
@@ -1,25 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatTime = exports.formatDate = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
exports.formatTime = exports.formatDate = exports.formatDateTime = void 0;
|
|
7
|
+
const isDate_1 = __importDefault(require("lodash/isDate"));
|
|
8
|
+
const getNavigatorLanguages = () => (typeof window !== 'undefined' && typeof window.navigator !== 'undefined' && window.navigator.languages) || 'en';
|
|
9
|
+
const getResultAsString = (value) => {
|
|
10
|
+
if ((0, isDate_1.default)(value)) {
|
|
11
|
+
return value.toString();
|
|
12
|
+
}
|
|
13
|
+
if (typeof value === 'number') {
|
|
14
|
+
return value.toString();
|
|
15
|
+
}
|
|
16
|
+
return value || '';
|
|
12
17
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const formatDateTime = (formatterOptions, value) => {
|
|
19
|
+
let date;
|
|
20
|
+
let result = '';
|
|
21
|
+
if (!value) {
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
if ((0, isDate_1.default)(value)) {
|
|
25
|
+
date = value;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
try {
|
|
29
|
+
date = new Date(value);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
return getResultAsString(value);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const formatter = new Intl.DateTimeFormat(getNavigatorLanguages(), formatterOptions);
|
|
36
|
+
try {
|
|
37
|
+
result = formatter.format(date);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
return getResultAsString(value);
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
23
43
|
};
|
|
44
|
+
exports.formatDateTime = formatDateTime;
|
|
45
|
+
const formatDate = (value) => (0, exports.formatDateTime)({
|
|
46
|
+
day: '2-digit',
|
|
47
|
+
month: '2-digit',
|
|
48
|
+
year: 'numeric',
|
|
49
|
+
}, value);
|
|
50
|
+
exports.formatDate = formatDate;
|
|
51
|
+
const formatTime = (value) => (0, exports.formatDateTime)({
|
|
52
|
+
...(process.env.NODE_ENV !== 'test' && {
|
|
53
|
+
hour: '2-digit',
|
|
54
|
+
}),
|
|
55
|
+
minute: '2-digit',
|
|
56
|
+
second: '2-digit',
|
|
57
|
+
}, value);
|
|
24
58
|
exports.formatTime = formatTime;
|
|
25
59
|
//# sourceMappingURL=date.js.map
|
package/lib/utils/date.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../src/utils/date.
|
|
1
|
+
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":";;;;;;AAAA,2DAAmC;AAGnC,MAAM,qBAAqB,GAAG,GAAG,EAAE,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,SAAS,K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ChB,IAAI,EAAE,SAAS;CAChB,EACD,KAAK,CACN,CAAC;AARS,QAAA,UAAU,cAQnB;AAEG,MAAM,UAAU,GAAG,CAAC,KAA8B,EAAU,EAAE,CACnE,IAAA,sBAAc,EACZ;IAEE,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,IAAI;QACrC,IAAI,EAAE,SAAS;KAChB,CAAC;IACF,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;CAClB,EACD,KAAK,CACN,CAAC;AAXS,QAAA,UAAU,cAWnB"}
|
package/lib-esm/utils/date.js
CHANGED
|
@@ -1,20 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import isDate from 'lodash/isDate';
|
|
2
|
+
const getNavigatorLanguages = () => (typeof window !== 'undefined' && typeof window.navigator !== 'undefined' && window.navigator.languages) || 'en';
|
|
3
|
+
const getResultAsString = (value) => {
|
|
4
|
+
if (isDate(value)) {
|
|
5
|
+
return value.toString();
|
|
6
|
+
}
|
|
7
|
+
if (typeof value === 'number') {
|
|
8
|
+
return value.toString();
|
|
9
|
+
}
|
|
10
|
+
return value || '';
|
|
9
11
|
};
|
|
10
|
-
export const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
12
|
+
export const formatDateTime = (formatterOptions, value) => {
|
|
13
|
+
let date;
|
|
14
|
+
let result = '';
|
|
15
|
+
if (!value) {
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
if (isDate(value)) {
|
|
19
|
+
date = value;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
try {
|
|
23
|
+
date = new Date(value);
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
return getResultAsString(value);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const formatter = new Intl.DateTimeFormat(getNavigatorLanguages(), formatterOptions);
|
|
30
|
+
try {
|
|
31
|
+
result = formatter.format(date);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
return getResultAsString(value);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
19
37
|
};
|
|
38
|
+
export const formatDate = (value) => formatDateTime({
|
|
39
|
+
day: '2-digit',
|
|
40
|
+
month: '2-digit',
|
|
41
|
+
year: 'numeric',
|
|
42
|
+
}, value);
|
|
43
|
+
export const formatTime = (value) => formatDateTime({
|
|
44
|
+
...(process.env.NODE_ENV !== 'test' && {
|
|
45
|
+
hour: '2-digit',
|
|
46
|
+
}),
|
|
47
|
+
minute: '2-digit',
|
|
48
|
+
second: '2-digit',
|
|
49
|
+
}, value);
|
|
20
50
|
//# sourceMappingURL=date.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../src/utils/date.
|
|
1
|
+
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,eAAe,CAAC;AAGnC,MAAM,qBAAqB,GAAG,GAAG,EAAE,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,SAAS,KAAK,WAAW,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC;AAErJ,MAAM,iBAAiB,GAAG,CAAC,KAA8B,EAAU,EAAE;IACnE,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;QACjB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;KACzB;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;KACzB;IAED,OAAO,KAAK,IAAI,EAAE,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cA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4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"description": "BundleStats utils",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-esm/index.js",
|
|
@@ -35,27 +35,27 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/relative-ci/bundle-stats/blob/master/packages/utils#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@bundle-stats/plugin-webpack-filter": "^4.1.
|
|
39
|
-
"@bundle-stats/plugin-webpack-validate": "^4.1.
|
|
38
|
+
"@bundle-stats/plugin-webpack-filter": "^4.1.3",
|
|
39
|
+
"@bundle-stats/plugin-webpack-validate": "^4.1.3",
|
|
40
40
|
"query-string": "^7.1.0",
|
|
41
41
|
"serialize-query-params": "^2.0.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/jest": "29.1.1",
|
|
45
|
-
"@types/lodash": "4.14.
|
|
46
|
-
"core-js": "3.26.
|
|
45
|
+
"@types/lodash": "4.14.189",
|
|
46
|
+
"core-js": "3.26.1",
|
|
47
47
|
"jest": "27.5.1",
|
|
48
|
-
"jest-cli": "
|
|
48
|
+
"jest-cli": "29.3.1",
|
|
49
49
|
"jest-date-mock": "1.0.8",
|
|
50
50
|
"lodash": "4.17.21",
|
|
51
|
-
"regenerator-runtime": "0.13.
|
|
51
|
+
"regenerator-runtime": "0.13.11",
|
|
52
52
|
"rimraf": "3.0.2",
|
|
53
53
|
"ts-jest": "29.0.3",
|
|
54
|
-
"typescript": "4.
|
|
54
|
+
"typescript": "4.9.3"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"core-js": "^3.0.0",
|
|
58
58
|
"lodash": "^4.0.0"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "88f6b66c9af17b8761ec3143bf49e696fdf3949b"
|
|
61
61
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import isDate from 'lodash/isDate';
|
|
2
|
+
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
const getNavigatorLanguages = () => (typeof window !== 'undefined' && typeof window.navigator !== 'undefined' && window.navigator.languages) || 'en';
|
|
5
|
+
|
|
6
|
+
const getResultAsString = (value?: Date | string | number): string => {
|
|
7
|
+
if (isDate(value)) {
|
|
8
|
+
return value.toString();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (typeof value === 'number') {
|
|
12
|
+
return value.toString();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return value || '';
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const formatDateTime = (
|
|
19
|
+
formatterOptions: Intl.DateTimeFormatOptions,
|
|
20
|
+
value?: Date | string | number,
|
|
21
|
+
): string => {
|
|
22
|
+
let date;
|
|
23
|
+
let result = '';
|
|
24
|
+
|
|
25
|
+
if (!value) {
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (isDate(value)) {
|
|
30
|
+
date = value;
|
|
31
|
+
} else {
|
|
32
|
+
try {
|
|
33
|
+
date = new Date(value as string | number);
|
|
34
|
+
} catch (err) {
|
|
35
|
+
// noop
|
|
36
|
+
return getResultAsString(value);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const formatter = new Intl.DateTimeFormat(getNavigatorLanguages(), formatterOptions);
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
result = formatter.format(date);
|
|
44
|
+
} catch (err) {
|
|
45
|
+
// noop
|
|
46
|
+
return getResultAsString(value);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const formatDate = (value?: Date | string | number): string =>
|
|
53
|
+
formatDateTime(
|
|
54
|
+
{
|
|
55
|
+
day: '2-digit',
|
|
56
|
+
month: '2-digit',
|
|
57
|
+
year: 'numeric',
|
|
58
|
+
},
|
|
59
|
+
value,
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
export const formatTime = (value?: Date | string | number): string =>
|
|
63
|
+
formatDateTime(
|
|
64
|
+
{
|
|
65
|
+
// Workaround CI node issue
|
|
66
|
+
...(process.env.NODE_ENV !== 'test' && {
|
|
67
|
+
hour: '2-digit',
|
|
68
|
+
}),
|
|
69
|
+
minute: '2-digit',
|
|
70
|
+
second: '2-digit',
|
|
71
|
+
},
|
|
72
|
+
value,
|
|
73
|
+
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as types from './types';
|
|
2
|
-
|
|
2
|
+
type RunMetrics = Record<string, types.MetricValue>;
|
|
3
3
|
export declare const mergeMetricsByKey: (runs: Array<RunMetrics>, rowTransformers?: ((row: types.ReportRow) => types.ReportRow)[] | undefined) => Array<types.ReportRow>;
|
|
4
4
|
export {};
|
package/types/utils/date.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export declare const formatDateTime: (formatterOptions: Intl.DateTimeFormatOptions, value?: Date | string | number) => string;
|
|
2
|
+
export declare const formatDate: (value?: Date | string | number) => string;
|
|
3
|
+
export declare const formatTime: (value?: Date | string | number) => string;
|
package/types/webpack/types.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface Asset extends Metric {
|
|
|
10
10
|
isChunk: boolean;
|
|
11
11
|
chunkId?: string;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
13
|
+
export type Assets = Record<string, Asset>;
|
|
14
14
|
export interface MetricsAssets {
|
|
15
15
|
metrics: {
|
|
16
16
|
assets: Assets;
|
|
@@ -24,7 +24,7 @@ export interface Module extends Metric {
|
|
|
24
24
|
chunkIds: Array<String>;
|
|
25
25
|
duplicated: boolean;
|
|
26
26
|
}
|
|
27
|
-
export
|
|
27
|
+
export type Modules = Record<string, Module>;
|
|
28
28
|
export interface MetricsModules {
|
|
29
29
|
metrics: {
|
|
30
30
|
duplicateCode: MetricRun;
|
|
@@ -36,7 +36,7 @@ export interface MetricsModules {
|
|
|
36
36
|
export interface Package extends Metric {
|
|
37
37
|
path: string;
|
|
38
38
|
}
|
|
39
|
-
export
|
|
39
|
+
export type Packages = Record<string, Package>;
|
|
40
40
|
export interface MetricsPackages {
|
|
41
41
|
metrics: {
|
|
42
42
|
packages: Packages;
|
package/src/utils/date.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const navigatorLanguages = (typeof navigator !== 'undefined' && navigator.languages) || 'en';
|
|
2
|
-
|
|
3
|
-
export const formatDate = (value) => {
|
|
4
|
-
const date = typeof value === 'string' ? new Date(value) : value;
|
|
5
|
-
|
|
6
|
-
return new Intl.DateTimeFormat(navigatorLanguages, {
|
|
7
|
-
day: '2-digit',
|
|
8
|
-
month: '2-digit',
|
|
9
|
-
year: 'numeric',
|
|
10
|
-
}).format(date);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const formatTime = (value) => {
|
|
14
|
-
const date = typeof value === 'string' ? new Date(value) : value;
|
|
15
|
-
|
|
16
|
-
return new Intl.DateTimeFormat(navigatorLanguages, {
|
|
17
|
-
// Workaround CI node issue
|
|
18
|
-
...(process.env.NODE_ENV !== 'test' && {
|
|
19
|
-
hour: '2-digit',
|
|
20
|
-
}),
|
|
21
|
-
minute: '2-digit',
|
|
22
|
-
second: '2-digit',
|
|
23
|
-
}).format(date);
|
|
24
|
-
};
|