@bundle-stats/utils 3.4.0-beta.0 → 4.0.0-alpha.9
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/constants.js +1 -8
- package/lib/constants.js.map +1 -1
- package/lib/index.js +0 -15
- package/lib/index.js.map +1 -1
- package/lib/jobs/create-job.js +2 -2
- package/lib/jobs/create-job.js.map +1 -1
- package/lib/jobs/create-jobs.js +2 -2
- package/lib/jobs/create-jobs.js.map +1 -1
- package/lib/utils/format.js +12 -4
- package/lib/utils/format.js.map +1 -1
- package/lib/webpack/constants.js +14 -28
- package/lib/webpack/constants.js.map +1 -1
- package/lib/webpack/extract/assets-size-total-insight.js +4 -4
- package/lib/webpack/extract/assets-size-total-insight.js.map +1 -1
- package/lib/webpack/extract/assets-size.js +4 -3
- package/lib/webpack/extract/assets-size.js.map +1 -1
- package/lib/webpack/extract/index.js +1 -26
- package/lib/webpack/extract/index.js.map +1 -1
- package/lib/webpack/extract/modules-packages-duplicate.js +2 -2
- package/lib/webpack/extract/modules-packages-duplicate.js.map +1 -1
- package/lib/webpack/metrics.js +18 -29
- package/lib/webpack/metrics.js.map +1 -1
- package/lib-esm/constants.js +0 -7
- package/lib-esm/constants.js.map +1 -1
- package/lib-esm/index.js +0 -3
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/jobs/create-job.js +2 -2
- package/lib-esm/jobs/create-job.js.map +1 -1
- package/lib-esm/jobs/create-jobs.js +2 -2
- package/lib-esm/jobs/create-jobs.js.map +1 -1
- package/lib-esm/utils/format.js +12 -4
- package/lib-esm/utils/format.js.map +1 -1
- package/lib-esm/webpack/constants.js +13 -27
- package/lib-esm/webpack/constants.js.map +1 -1
- package/lib-esm/webpack/extract/assets-size-total-insight.js +4 -4
- package/lib-esm/webpack/extract/assets-size-total-insight.js.map +1 -1
- package/lib-esm/webpack/extract/assets-size.js +4 -3
- package/lib-esm/webpack/extract/assets-size.js.map +1 -1
- package/lib-esm/webpack/extract/index.js +1 -3
- package/lib-esm/webpack/extract/index.js.map +1 -1
- package/lib-esm/webpack/extract/modules-packages-duplicate.js +2 -2
- package/lib-esm/webpack/extract/modules-packages-duplicate.js.map +1 -1
- package/lib-esm/webpack/metrics.js +18 -29
- package/lib-esm/webpack/metrics.js.map +1 -1
- package/package.json +12 -12
- package/src/constants.ts +0 -7
- package/src/index.js +0 -2
- package/src/jobs/create-job.js +2 -2
- package/src/jobs/create-jobs.js +2 -2
- package/src/utils/format.js +17 -4
- package/src/webpack/{constants.ts → constants.js} +13 -28
- package/src/webpack/extract/assets-size-total-insight.js +4 -4
- package/src/webpack/extract/assets-size.js +5 -3
- package/src/webpack/extract/index.js +5 -7
- package/src/webpack/extract/modules-packages-duplicate.js +2 -2
- package/src/webpack/{metrics.ts → metrics.js} +18 -29
- package/types/constants.d.ts +0 -6
- package/types/index.d.ts +0 -2
- package/types/jobs/create-job.d.ts +1 -1
- package/types/jobs/create-jobs.d.ts +1 -1
- package/types/report/add-row-metric-data.d.ts +1 -1
- package/types/webpack/constants.d.ts +9 -33
- package/types/webpack/extract/index.d.ts +1 -1
- package/types/webpack/extract/modules-packages-duplicate.d.ts +1 -2
- package/types/webpack/extract/modules-packages.d.ts +1 -1
- package/types/webpack/metrics.d.ts +153 -116
- package/lib/transformers/budgets-insights.js +0 -133
- package/lib/transformers/budgets-insights.js.map +0 -1
- package/lib/transformers/index.js +0 -28
- package/lib/transformers/index.js.map +0 -1
- package/lib/types.js +0 -3
- package/lib/types.js.map +0 -1
- package/lib-esm/transformers/budgets-insights.js +0 -126
- package/lib-esm/transformers/budgets-insights.js.map +0 -1
- package/lib-esm/transformers/index.js +0 -3
- package/lib-esm/transformers/index.js.map +0 -1
- package/lib-esm/types.js +0 -2
- package/lib-esm/types.js.map +0 -1
- package/src/transformers/budgets-insights.ts +0 -212
- package/src/transformers/index.ts +0 -1
- package/src/types.ts +0 -14
- package/types/transformers/budgets-insights.d.ts +0 -34
- package/types/transformers/index.d.ts +0 -1
- package/types/types.d.ts +0 -9
|
@@ -1,133 +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.getExtract = void 0;
|
|
7
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
8
|
-
const template_1 = __importDefault(require("lodash/template"));
|
|
9
|
-
const constants_1 = require("../constants");
|
|
10
|
-
const utils_1 = require("../utils");
|
|
11
|
-
const resolveType = (insights) => {
|
|
12
|
-
if (insights.find(([_, { type }]) => type === constants_1.InsightType.ERROR)) {
|
|
13
|
-
return constants_1.InsightType.ERROR;
|
|
14
|
-
}
|
|
15
|
-
if (insights.find(([_, { type }]) => type === constants_1.InsightType.WARNING)) {
|
|
16
|
-
return constants_1.InsightType.WARNING;
|
|
17
|
-
}
|
|
18
|
-
return constants_1.InsightType.SUCCESS;
|
|
19
|
-
};
|
|
20
|
-
const budgetInsightTemplate = (0, template_1.default)('<%= count %>/<%= total %> budget checks <%= status %>');
|
|
21
|
-
const resolveStatus = (failedCount, warningCount) => {
|
|
22
|
-
if (failedCount) {
|
|
23
|
-
return 'failed';
|
|
24
|
-
}
|
|
25
|
-
if (warningCount) {
|
|
26
|
-
return 'warned';
|
|
27
|
-
}
|
|
28
|
-
return 'passed';
|
|
29
|
-
};
|
|
30
|
-
const getMessage = (insights) => {
|
|
31
|
-
const total = insights.length;
|
|
32
|
-
const failedCount = insights.filter(([___, insight]) => insight.type === constants_1.InsightType.ERROR).length;
|
|
33
|
-
const warningCount = insights.filter(([___, insight]) => insight.type === constants_1.InsightType.WARNING).length;
|
|
34
|
-
const count = failedCount || warningCount || total;
|
|
35
|
-
const status = resolveStatus(failedCount, warningCount);
|
|
36
|
-
return {
|
|
37
|
-
text: budgetInsightTemplate({
|
|
38
|
-
count,
|
|
39
|
-
total,
|
|
40
|
-
status,
|
|
41
|
-
}),
|
|
42
|
-
md: budgetInsightTemplate({
|
|
43
|
-
count: `**${count}**`,
|
|
44
|
-
total: `**${total}**`,
|
|
45
|
-
status,
|
|
46
|
-
}),
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
const budgetInsightMetricTemplate = (0, template_1.default)('<%= metricLabel %> is <%= diffLabel %> budget \(<%= currentValue %> / <%= budgetValue %>\)');
|
|
50
|
-
const resolveDiffLabel = (metricBudgetInsight) => {
|
|
51
|
-
const { currentValue, budgetValue } = metricBudgetInsight;
|
|
52
|
-
if (currentValue > budgetValue) {
|
|
53
|
-
return 'above';
|
|
54
|
-
}
|
|
55
|
-
if (currentValue < budgetValue) {
|
|
56
|
-
return 'below';
|
|
57
|
-
}
|
|
58
|
-
return 'equal with';
|
|
59
|
-
};
|
|
60
|
-
const resolveBudgetInsightMetricType = (metricBudgetInsight) => {
|
|
61
|
-
if (metricBudgetInsight.failed) {
|
|
62
|
-
return constants_1.InsightType.ERROR;
|
|
63
|
-
}
|
|
64
|
-
if (metricBudgetInsight.currentValue === metricBudgetInsight.budgetValue) {
|
|
65
|
-
return constants_1.InsightType.WARNING;
|
|
66
|
-
}
|
|
67
|
-
return constants_1.InsightType.SUCCESS;
|
|
68
|
-
};
|
|
69
|
-
const getExtract = (source) => (_, currentExtractedData, __, options = {}) => {
|
|
70
|
-
const { budgets: budgetsOptions } = options;
|
|
71
|
-
if (!budgetsOptions) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
const insights = [];
|
|
75
|
-
budgetsOptions.forEach((budgetOption) => {
|
|
76
|
-
const { metric: sourceMetricId, value: budgetValue } = budgetOption;
|
|
77
|
-
const currentValue = (0, get_1.default)(currentExtractedData, `metrics.${sourceMetricId}.value`);
|
|
78
|
-
const metricData = (0, utils_1.getGlobalMetricType)(`${source}.${sourceMetricId}`);
|
|
79
|
-
if (!currentValue) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const isValueOverBudget = currentValue > budgetValue;
|
|
83
|
-
const failed = metricData.biggerIsBetter ? !isValueOverBudget : isValueOverBudget;
|
|
84
|
-
const budgetInsightMetricData = {
|
|
85
|
-
currentValue,
|
|
86
|
-
budgetValue,
|
|
87
|
-
failed,
|
|
88
|
-
};
|
|
89
|
-
const diffLabel = resolveDiffLabel(budgetInsightMetricData);
|
|
90
|
-
const type = resolveBudgetInsightMetricType(budgetInsightMetricData);
|
|
91
|
-
const currentFormattedValue = metricData.formatter(currentValue);
|
|
92
|
-
const budgetFormattedValue = metricData.formatter(budgetValue);
|
|
93
|
-
const messageText = budgetInsightMetricTemplate({
|
|
94
|
-
metricLabel: metricData.label,
|
|
95
|
-
currentValue: currentFormattedValue,
|
|
96
|
-
diffLabel,
|
|
97
|
-
budgetValue: budgetFormattedValue,
|
|
98
|
-
});
|
|
99
|
-
const messageMd = budgetInsightMetricTemplate({
|
|
100
|
-
metricLabel: `**${metricData.label}**`,
|
|
101
|
-
currentValue: `**${currentFormattedValue}**`,
|
|
102
|
-
diffLabel,
|
|
103
|
-
budgetValue: `**${budgetFormattedValue}**`,
|
|
104
|
-
});
|
|
105
|
-
insights.push([
|
|
106
|
-
sourceMetricId,
|
|
107
|
-
{
|
|
108
|
-
type,
|
|
109
|
-
message: {
|
|
110
|
-
text: messageText,
|
|
111
|
-
md: messageMd,
|
|
112
|
-
},
|
|
113
|
-
data: budgetInsightMetricData,
|
|
114
|
-
},
|
|
115
|
-
]);
|
|
116
|
-
});
|
|
117
|
-
if (insights.length === 0) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
const type = resolveType(insights);
|
|
121
|
-
const message = getMessage(insights);
|
|
122
|
-
return {
|
|
123
|
-
insights: {
|
|
124
|
-
budgets: {
|
|
125
|
-
type,
|
|
126
|
-
message,
|
|
127
|
-
data: Object.fromEntries(insights),
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
exports.getExtract = getExtract;
|
|
133
|
-
//# sourceMappingURL=budgets-insights.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"budgets-insights.js","sourceRoot":"","sources":["../../src/transformers/budgets-insights.ts"],"names":[],"mappings":";;;;;;AAAA,qDAA6B;AAC7B,+DAAuC;AAGvC,4CAA2C;AAC3C,oCAA+C;AAwC/C,MAAM,WAAW,GAAG,CAAC,QAA8C,EAAe,EAAE;IAClF,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,uBAAW,CAAC,KAAK,CAAC,EAAE;QAChE,OAAO,uBAAW,CAAC,KAAK,CAAC;KAC1B;IAED,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,uBAAW,CAAC,OAAO,CAAC,EAAE;QAClE,OAAO,uBAAW,CAAC,OAAO,CAAC;KAC5B;IAED,OAAO,uBAAW,CAAC,OAAO,CAAC;AAC7B,CAAC,CAAC;AAMF,MAAM,qBAAqB,GAAG,IAAA,kBAAQ,EACpC,uDAAuD,CACxD,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,WAAmB,EAAE,YAAoB,EAAU,EAAE;IAC1E,IAAI,WAAW,EAAE;QACf,OAAO,QAAQ,CAAC;KACjB;IAED,IAAI,YAAY,EAAE;QAChB,OAAO,QAAQ,CAAC;KACjB;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,QAA8C,EAAE,EAAE;IACpE,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC9B,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,uBAAW,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AAqB;YACnC,SAAS;YACT,WAAW,EAAE,oBAAoB;SAClC,CAAC,CAAC;QACH,MAAM,SAAS,GAAG,2BAA2B,CAAC;YAC5C,WAAW,EAAE,KAAK,UAAU,CAAC,KAAK,IAAI;YACtC,YAAY,EAAE,KAAK,qBAAqB,IAAI;YAC5C,SAAS;YACT,WAAW,EAAE,KAAK,oBAAoB,IAAI;SAC3C,CAAC,CAAC;QAEH,QAAQ,CAAC,IAAI,CAAC;YACZ,cAAc;YACd;gBACE,IAAI;gBACJ,OAAO,EAAE;oBACP,IAAI,EAAE,WAAW;oBACjB,EAAE,EAAE,SAAS;iBACd;gBACD,IAAI,EAAE,uBAAuB;aAC9B;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QACzB,OAAO,IAAI,CAAC;KACb;IAED,MAAM,IAAI,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAErC,OAAO;QACL,QAAQ,EAAE;YACR,OAAO,EAAE;gBACP,IAAI;gBACJ,OAAO;gBACP,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC;aACnC;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAjFS,QAAA,UAAU,cAiFnB"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.budgetInsights = void 0;
|
|
27
|
-
exports.budgetInsights = __importStar(require("./budgets-insights"));
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transformers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qEAAqD"}
|
package/lib/types.js
DELETED
package/lib/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import get from 'lodash/get';
|
|
2
|
-
import template from 'lodash/template';
|
|
3
|
-
import { InsightType } from '../constants';
|
|
4
|
-
import { getGlobalMetricType } from '../utils';
|
|
5
|
-
const resolveType = (insights) => {
|
|
6
|
-
if (insights.find(([_, { type }]) => type === InsightType.ERROR)) {
|
|
7
|
-
return InsightType.ERROR;
|
|
8
|
-
}
|
|
9
|
-
if (insights.find(([_, { type }]) => type === InsightType.WARNING)) {
|
|
10
|
-
return InsightType.WARNING;
|
|
11
|
-
}
|
|
12
|
-
return InsightType.SUCCESS;
|
|
13
|
-
};
|
|
14
|
-
const budgetInsightTemplate = template('<%= count %>/<%= total %> budget checks <%= status %>');
|
|
15
|
-
const resolveStatus = (failedCount, warningCount) => {
|
|
16
|
-
if (failedCount) {
|
|
17
|
-
return 'failed';
|
|
18
|
-
}
|
|
19
|
-
if (warningCount) {
|
|
20
|
-
return 'warned';
|
|
21
|
-
}
|
|
22
|
-
return 'passed';
|
|
23
|
-
};
|
|
24
|
-
const getMessage = (insights) => {
|
|
25
|
-
const total = insights.length;
|
|
26
|
-
const failedCount = insights.filter(([___, insight]) => insight.type === InsightType.ERROR).length;
|
|
27
|
-
const warningCount = insights.filter(([___, insight]) => insight.type === InsightType.WARNING).length;
|
|
28
|
-
const count = failedCount || warningCount || total;
|
|
29
|
-
const status = resolveStatus(failedCount, warningCount);
|
|
30
|
-
return {
|
|
31
|
-
text: budgetInsightTemplate({
|
|
32
|
-
count,
|
|
33
|
-
total,
|
|
34
|
-
status,
|
|
35
|
-
}),
|
|
36
|
-
md: budgetInsightTemplate({
|
|
37
|
-
count: `**${count}**`,
|
|
38
|
-
total: `**${total}**`,
|
|
39
|
-
status,
|
|
40
|
-
}),
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
const budgetInsightMetricTemplate = template('<%= metricLabel %> is <%= diffLabel %> budget \(<%= currentValue %> / <%= budgetValue %>\)');
|
|
44
|
-
const resolveDiffLabel = (metricBudgetInsight) => {
|
|
45
|
-
const { currentValue, budgetValue } = metricBudgetInsight;
|
|
46
|
-
if (currentValue > budgetValue) {
|
|
47
|
-
return 'above';
|
|
48
|
-
}
|
|
49
|
-
if (currentValue < budgetValue) {
|
|
50
|
-
return 'below';
|
|
51
|
-
}
|
|
52
|
-
return 'equal with';
|
|
53
|
-
};
|
|
54
|
-
const resolveBudgetInsightMetricType = (metricBudgetInsight) => {
|
|
55
|
-
if (metricBudgetInsight.failed) {
|
|
56
|
-
return InsightType.ERROR;
|
|
57
|
-
}
|
|
58
|
-
if (metricBudgetInsight.currentValue === metricBudgetInsight.budgetValue) {
|
|
59
|
-
return InsightType.WARNING;
|
|
60
|
-
}
|
|
61
|
-
return InsightType.SUCCESS;
|
|
62
|
-
};
|
|
63
|
-
export const getExtract = (source) => (_, currentExtractedData, __, options = {}) => {
|
|
64
|
-
const { budgets: budgetsOptions } = options;
|
|
65
|
-
if (!budgetsOptions) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
const insights = [];
|
|
69
|
-
budgetsOptions.forEach((budgetOption) => {
|
|
70
|
-
const { metric: sourceMetricId, value: budgetValue } = budgetOption;
|
|
71
|
-
const currentValue = get(currentExtractedData, `metrics.${sourceMetricId}.value`);
|
|
72
|
-
const metricData = getGlobalMetricType(`${source}.${sourceMetricId}`);
|
|
73
|
-
if (!currentValue) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const isValueOverBudget = currentValue > budgetValue;
|
|
77
|
-
const failed = metricData.biggerIsBetter ? !isValueOverBudget : isValueOverBudget;
|
|
78
|
-
const budgetInsightMetricData = {
|
|
79
|
-
currentValue,
|
|
80
|
-
budgetValue,
|
|
81
|
-
failed,
|
|
82
|
-
};
|
|
83
|
-
const diffLabel = resolveDiffLabel(budgetInsightMetricData);
|
|
84
|
-
const type = resolveBudgetInsightMetricType(budgetInsightMetricData);
|
|
85
|
-
const currentFormattedValue = metricData.formatter(currentValue);
|
|
86
|
-
const budgetFormattedValue = metricData.formatter(budgetValue);
|
|
87
|
-
const messageText = budgetInsightMetricTemplate({
|
|
88
|
-
metricLabel: metricData.label,
|
|
89
|
-
currentValue: currentFormattedValue,
|
|
90
|
-
diffLabel,
|
|
91
|
-
budgetValue: budgetFormattedValue,
|
|
92
|
-
});
|
|
93
|
-
const messageMd = budgetInsightMetricTemplate({
|
|
94
|
-
metricLabel: `**${metricData.label}**`,
|
|
95
|
-
currentValue: `**${currentFormattedValue}**`,
|
|
96
|
-
diffLabel,
|
|
97
|
-
budgetValue: `**${budgetFormattedValue}**`,
|
|
98
|
-
});
|
|
99
|
-
insights.push([
|
|
100
|
-
sourceMetricId,
|
|
101
|
-
{
|
|
102
|
-
type,
|
|
103
|
-
message: {
|
|
104
|
-
text: messageText,
|
|
105
|
-
md: messageMd,
|
|
106
|
-
},
|
|
107
|
-
data: budgetInsightMetricData,
|
|
108
|
-
},
|
|
109
|
-
]);
|
|
110
|
-
});
|
|
111
|
-
if (insights.length === 0) {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
const type = resolveType(insights);
|
|
115
|
-
const message = getMessage(insights);
|
|
116
|
-
return {
|
|
117
|
-
insights: {
|
|
118
|
-
budgets: {
|
|
119
|
-
type,
|
|
120
|
-
message,
|
|
121
|
-
data: Object.fromEntries(insights),
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
//# sourceMappingURL=budgets-insights.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"budgets-insights.js","sourceRoot":"","sources":["../../src/transformers/budgets-insights.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAGvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAwC/C,MAAM,WAAW,GAAG,CAAC,QAA8C,EAAe,EAAE;IAClF,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,WAAW,CAAC,KAAK,CAAC,EAAE;QAChE,OAAO,WAAW,CAAC,KAAK,CAAC;KAC1B;IAED,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,WAAW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,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAErC,OAAO;QACL,QAAQ,EAAE;YACR,OAAO,EAAE;gBACP,IAAI;gBACJ,OAAO;gBACP,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC;aACnC;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transformers/index.ts"],"names":[],"mappings":"kCAAgC,oBAAoB;6BAAxC,cAAc"}
|
package/lib-esm/types.js
DELETED
package/lib-esm/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import get from 'lodash/get';
|
|
2
|
-
import template from 'lodash/template';
|
|
3
|
-
|
|
4
|
-
import * as types from '../types';
|
|
5
|
-
import { InsightType } from '../constants';
|
|
6
|
-
import { getGlobalMetricType } from '../utils';
|
|
7
|
-
|
|
8
|
-
interface OptionBudgetMetric {
|
|
9
|
-
metric: string;
|
|
10
|
-
value: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface Options {
|
|
14
|
-
budgets?: Array<OptionBudgetMetric>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface BudgetInsightMetricData {
|
|
18
|
-
currentValue: number;
|
|
19
|
-
budgetValue: number;
|
|
20
|
-
failed: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface BudgetInsightMetric {
|
|
24
|
-
/** Metric budget insight type */
|
|
25
|
-
type: InsightType;
|
|
26
|
-
message: {
|
|
27
|
-
text: string;
|
|
28
|
-
md: string;
|
|
29
|
-
};
|
|
30
|
-
/** Metric budget check data */
|
|
31
|
-
data: BudgetInsightMetricData;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface BudgetInsight extends types.Insight {
|
|
35
|
-
data: {
|
|
36
|
-
[metricId: string]: BudgetInsightMetric;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
interface BudgetsInsightsOutput {
|
|
41
|
-
insights: {
|
|
42
|
-
budgets: BudgetInsight;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const resolveType = (insights: Array<[string, BudgetInsightMetric]>): InsightType => {
|
|
47
|
-
if (insights.find(([_, { type }]) => type === InsightType.ERROR)) {
|
|
48
|
-
return InsightType.ERROR;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (insights.find(([_, { type }]) => type === InsightType.WARNING)) {
|
|
52
|
-
return InsightType.WARNING;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return InsightType.SUCCESS;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// 3/3 budget checks passed
|
|
59
|
-
// 2/3 budget checks failed
|
|
60
|
-
// 1 failed, 1 warning, 2 success
|
|
61
|
-
|
|
62
|
-
const budgetInsightTemplate = template(
|
|
63
|
-
'<%= count %>/<%= total %> budget checks <%= status %>'
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const resolveStatus = (failedCount: number, warningCount: number): string => {
|
|
67
|
-
if (failedCount) {
|
|
68
|
-
return 'failed';
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (warningCount) {
|
|
72
|
-
return 'warned';
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return 'passed';
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const getMessage = (insights: Array<[string, BudgetInsightMetric]>) => {
|
|
79
|
-
const total = insights.length;
|
|
80
|
-
const failedCount = insights.filter(([___, insight]) => insight.type === InsightType.ERROR).length;
|
|
81
|
-
const warningCount = insights.filter(([___, insight]) => insight.type === InsightType.WARNING).length;
|
|
82
|
-
const count = failedCount || warningCount || total;
|
|
83
|
-
const status = resolveStatus(failedCount, warningCount);
|
|
84
|
-
|
|
85
|
-
return {
|
|
86
|
-
text: budgetInsightTemplate({
|
|
87
|
-
count,
|
|
88
|
-
total,
|
|
89
|
-
status,
|
|
90
|
-
}),
|
|
91
|
-
md: budgetInsightTemplate({
|
|
92
|
-
count: `**${count}**`,
|
|
93
|
-
total: `**${total}**`,
|
|
94
|
-
status,
|
|
95
|
-
}),
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const budgetInsightMetricTemplate = template(
|
|
100
|
-
// Add escapes for (|) to avoid lodash.template syntax errors
|
|
101
|
-
// eslint-disable-next-line no-useless-escape
|
|
102
|
-
'<%= metricLabel %> is <%= diffLabel %> budget \(<%= currentValue %> / <%= budgetValue %>\)',
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
const resolveDiffLabel = (metricBudgetInsight: BudgetInsightMetricData): string => {
|
|
106
|
-
const { currentValue, budgetValue } = metricBudgetInsight;
|
|
107
|
-
|
|
108
|
-
if (currentValue > budgetValue) {
|
|
109
|
-
return 'above';
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (currentValue < budgetValue) {
|
|
113
|
-
return 'below';
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return 'equal with';
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const resolveBudgetInsightMetricType = (metricBudgetInsight: BudgetInsightMetricData): InsightType => {
|
|
120
|
-
if (metricBudgetInsight.failed) {
|
|
121
|
-
return InsightType.ERROR;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (metricBudgetInsight.currentValue === metricBudgetInsight.budgetValue) {
|
|
125
|
-
return InsightType.WARNING;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return InsightType.SUCCESS;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
export const getExtract =
|
|
132
|
-
(source: string) => (
|
|
133
|
-
_: unknown,
|
|
134
|
-
currentExtractedData: any,
|
|
135
|
-
__: unknown,
|
|
136
|
-
options: Options = {},
|
|
137
|
-
): BudgetsInsightsOutput | null => {
|
|
138
|
-
const { budgets: budgetsOptions } = options;
|
|
139
|
-
|
|
140
|
-
if (!budgetsOptions) {
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const insights: Array<[string, BudgetInsightMetric]> = [];
|
|
145
|
-
|
|
146
|
-
budgetsOptions.forEach((budgetOption) => {
|
|
147
|
-
const { metric: sourceMetricId, value: budgetValue } = budgetOption;
|
|
148
|
-
const currentValue = get(currentExtractedData, `metrics.${sourceMetricId}.value`);
|
|
149
|
-
const metricData = getGlobalMetricType(`${source}.${sourceMetricId}`);
|
|
150
|
-
|
|
151
|
-
if (!currentValue) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const isValueOverBudget = currentValue > budgetValue;
|
|
156
|
-
const failed = metricData.biggerIsBetter ? !isValueOverBudget : isValueOverBudget;
|
|
157
|
-
|
|
158
|
-
const budgetInsightMetricData = {
|
|
159
|
-
currentValue,
|
|
160
|
-
budgetValue,
|
|
161
|
-
failed,
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// Message template data
|
|
165
|
-
const diffLabel = resolveDiffLabel(budgetInsightMetricData);
|
|
166
|
-
const type = resolveBudgetInsightMetricType(budgetInsightMetricData);
|
|
167
|
-
const currentFormattedValue = metricData.formatter(currentValue);
|
|
168
|
-
const budgetFormattedValue = metricData.formatter(budgetValue);
|
|
169
|
-
|
|
170
|
-
const messageText = budgetInsightMetricTemplate({
|
|
171
|
-
metricLabel: metricData.label,
|
|
172
|
-
currentValue: currentFormattedValue,
|
|
173
|
-
diffLabel,
|
|
174
|
-
budgetValue: budgetFormattedValue,
|
|
175
|
-
});
|
|
176
|
-
const messageMd = budgetInsightMetricTemplate({
|
|
177
|
-
metricLabel: `**${metricData.label}**`,
|
|
178
|
-
currentValue: `**${currentFormattedValue}**`,
|
|
179
|
-
diffLabel,
|
|
180
|
-
budgetValue: `**${budgetFormattedValue}**`,
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
insights.push([
|
|
184
|
-
sourceMetricId,
|
|
185
|
-
{
|
|
186
|
-
type,
|
|
187
|
-
message: {
|
|
188
|
-
text: messageText,
|
|
189
|
-
md: messageMd,
|
|
190
|
-
},
|
|
191
|
-
data: budgetInsightMetricData,
|
|
192
|
-
},
|
|
193
|
-
]);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
if (insights.length === 0) {
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const type = resolveType(insights);
|
|
201
|
-
const message = getMessage(insights);
|
|
202
|
-
|
|
203
|
-
return {
|
|
204
|
-
insights: {
|
|
205
|
-
budgets: {
|
|
206
|
-
type,
|
|
207
|
-
message,
|
|
208
|
-
data: Object.fromEntries(insights),
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
};
|
|
212
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as budgetInsights from './budgets-insights';
|
package/src/types.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as constants from './constants';
|
|
2
|
-
|
|
3
|
-
/** Insight v2 structure */
|
|
4
|
-
export interface Insight {
|
|
5
|
-
type: constants.InsightType;
|
|
6
|
-
message: {
|
|
7
|
-
/** Insight message text format */
|
|
8
|
-
text: string;
|
|
9
|
-
/** Insight message markdown format */
|
|
10
|
-
md: string;
|
|
11
|
-
};
|
|
12
|
-
/** Insight specific data */
|
|
13
|
-
data: unknown;
|
|
14
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as types from '../types';
|
|
2
|
-
import { InsightType } from '../constants';
|
|
3
|
-
interface OptionBudgetMetric {
|
|
4
|
-
metric: string;
|
|
5
|
-
value: number;
|
|
6
|
-
}
|
|
7
|
-
interface Options {
|
|
8
|
-
budgets?: Array<OptionBudgetMetric>;
|
|
9
|
-
}
|
|
10
|
-
interface BudgetInsightMetricData {
|
|
11
|
-
currentValue: number;
|
|
12
|
-
budgetValue: number;
|
|
13
|
-
failed: boolean;
|
|
14
|
-
}
|
|
15
|
-
interface BudgetInsightMetric {
|
|
16
|
-
type: InsightType;
|
|
17
|
-
message: {
|
|
18
|
-
text: string;
|
|
19
|
-
md: string;
|
|
20
|
-
};
|
|
21
|
-
data: BudgetInsightMetricData;
|
|
22
|
-
}
|
|
23
|
-
interface BudgetInsight extends types.Insight {
|
|
24
|
-
data: {
|
|
25
|
-
[metricId: string]: BudgetInsightMetric;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
interface BudgetsInsightsOutput {
|
|
29
|
-
insights: {
|
|
30
|
-
budgets: BudgetInsight;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export declare const getExtract: (source: string) => (_: unknown, currentExtractedData: any, __: unknown, options?: Options) => BudgetsInsightsOutput | null;
|
|
34
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as budgetInsights from './budgets-insights';
|