@code-pushup/utils 0.53.0 → 0.54.0
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/index.js +10 -10
- package/package.json +23 -16
- package/src/lib/transform.d.ts +0 -1
package/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var MAX_ISSUE_MESSAGE_LENGTH = 1024;
|
|
|
12
12
|
var slugRegex = /^[a-z\d]+(?:-[a-z\d]+)*$/;
|
|
13
13
|
var filenameRegex = /^(?!.*[ \\/:*?"<>|]).+$/;
|
|
14
14
|
function hasDuplicateStrings(strings) {
|
|
15
|
-
const sortedStrings =
|
|
15
|
+
const sortedStrings = strings.toSorted();
|
|
16
16
|
const duplStrings = sortedStrings.filter(
|
|
17
17
|
(item, index) => index !== 0 && item === sortedStrings[index - 1]
|
|
18
18
|
);
|
|
@@ -106,7 +106,6 @@ var fileNameSchema = z.string().trim().regex(filenameRegex, {
|
|
|
106
106
|
message: `The filename has to be valid`
|
|
107
107
|
}).min(1, { message: "file name is invalid" });
|
|
108
108
|
var positiveIntSchema = z.number().int().positive();
|
|
109
|
-
var nonnegativeIntSchema = z.number().int().nonnegative();
|
|
110
109
|
var nonnegativeNumberSchema = z.number().nonnegative();
|
|
111
110
|
function packageVersionSchema(options) {
|
|
112
111
|
const { versionDescription = "NPM version of the package", required } = options ?? {};
|
|
@@ -650,7 +649,7 @@ var auditDiffSchema = scorableWithPluginDiffSchema.merge(
|
|
|
650
649
|
z16.object({
|
|
651
650
|
values: makeComparisonSchema(auditValueSchema).merge(
|
|
652
651
|
z16.object({
|
|
653
|
-
diff: z16.number().
|
|
652
|
+
diff: z16.number().describe("Value change (`values.after - values.before`)")
|
|
654
653
|
})
|
|
655
654
|
).describe("Audit `value` comparison"),
|
|
656
655
|
displayValues: makeComparisonSchema(auditDisplayValueSchema).describe(
|
|
@@ -997,6 +996,7 @@ function executeProcess(cfg) {
|
|
|
997
996
|
return new Promise((resolve, reject) => {
|
|
998
997
|
const spawnedProcess = spawn(command, args ?? [], {
|
|
999
998
|
shell: true,
|
|
999
|
+
windowsHide: true,
|
|
1000
1000
|
...options
|
|
1001
1001
|
});
|
|
1002
1002
|
let stdout = "";
|
|
@@ -1873,7 +1873,7 @@ function getColumnAlignments(tableData) {
|
|
|
1873
1873
|
(_, idx) => getColumnAlignmentForIndex(idx, columns)
|
|
1874
1874
|
);
|
|
1875
1875
|
}
|
|
1876
|
-
const biggestRow =
|
|
1876
|
+
const biggestRow = rows.toSorted((a, b) => Object.keys(a).length - Object.keys(b).length).at(-1);
|
|
1877
1877
|
if (columns.length > 0) {
|
|
1878
1878
|
return columns.map(
|
|
1879
1879
|
(column, idx) => typeof column === "string" ? column : getColumnAlignmentForKeyAndIndex(
|
|
@@ -2083,7 +2083,7 @@ function getSortableGroupByRef({ plugin, slug, weight }, plugins) {
|
|
|
2083
2083
|
throwIsNotPresentError(`Group ${slug}`, groupPlugin.slug);
|
|
2084
2084
|
}
|
|
2085
2085
|
const sortedAudits = getSortedGroupAudits(group, groupPlugin.slug, plugins);
|
|
2086
|
-
const sortedAuditRefs =
|
|
2086
|
+
const sortedAuditRefs = group.refs.toSorted((a, b) => {
|
|
2087
2087
|
const aIndex = sortedAudits.findIndex((ref) => ref.slug === a.slug);
|
|
2088
2088
|
const bIndex = sortedAudits.findIndex((ref) => ref.slug === b.slug);
|
|
2089
2089
|
return aIndex - bIndex;
|
|
@@ -2112,7 +2112,7 @@ function sortReport(report) {
|
|
|
2112
2112
|
const sortedAuditsAndGroups = [...audits, ...groups].sort(
|
|
2113
2113
|
compareCategoryAuditsAndGroups
|
|
2114
2114
|
);
|
|
2115
|
-
const sortedRefs =
|
|
2115
|
+
const sortedRefs = category.refs.toSorted((a, b) => {
|
|
2116
2116
|
const aIndex = sortedAuditsAndGroups.findIndex(
|
|
2117
2117
|
(ref) => ref.slug === a.slug && ref.plugin === a.plugin
|
|
2118
2118
|
);
|
|
@@ -2132,12 +2132,12 @@ function sortReport(report) {
|
|
|
2132
2132
|
function sortPlugins(plugins) {
|
|
2133
2133
|
return plugins.map((plugin) => ({
|
|
2134
2134
|
...plugin,
|
|
2135
|
-
audits:
|
|
2135
|
+
audits: plugin.audits.toSorted(compareAudits).map(
|
|
2136
2136
|
(audit) => audit.details?.issues ? {
|
|
2137
2137
|
...audit,
|
|
2138
2138
|
details: {
|
|
2139
2139
|
...audit.details,
|
|
2140
|
-
issues:
|
|
2140
|
+
issues: audit.details.issues.toSorted(compareIssues)
|
|
2141
2141
|
}
|
|
2142
2142
|
} : audit
|
|
2143
2143
|
)
|
|
@@ -2414,7 +2414,7 @@ function formatPortalLink(portalUrl) {
|
|
|
2414
2414
|
return portalUrl && md5.link(portalUrl, "\u{1F575}\uFE0F See full comparison in Code PushUp portal \u{1F50D}");
|
|
2415
2415
|
}
|
|
2416
2416
|
function sortChanges(changes) {
|
|
2417
|
-
return
|
|
2417
|
+
return changes.toSorted(
|
|
2418
2418
|
(a, b) => Math.abs(b.scores.diff) - Math.abs(a.scores.diff) || Math.abs(b.values?.diff ?? 0) - Math.abs(a.values?.diff ?? 0)
|
|
2419
2419
|
);
|
|
2420
2420
|
}
|
|
@@ -2695,7 +2695,7 @@ function reportToHeaderSection(report) {
|
|
|
2695
2695
|
function logPlugins(plugins, verbose) {
|
|
2696
2696
|
plugins.forEach((plugin) => {
|
|
2697
2697
|
const { title, audits } = plugin;
|
|
2698
|
-
const filteredAudits = verbose ? audits : audits.filter(({ score }) => score !== 1);
|
|
2698
|
+
const filteredAudits = verbose || audits.length === 1 ? audits : audits.filter(({ score }) => score !== 1);
|
|
2699
2699
|
const diff = audits.length - filteredAudits.length;
|
|
2700
2700
|
logAudits(title, filteredAudits);
|
|
2701
2701
|
if (diff > 0) {
|
package/package.json
CHANGED
|
@@ -1,33 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
4
4
|
"description": "Low-level utilities (helper functions, etc.) used by Code PushUp CLI",
|
|
5
|
-
"dependencies": {
|
|
6
|
-
"@code-pushup/models": "0.53.0",
|
|
7
|
-
"@isaacs/cliui": "^8.0.2",
|
|
8
|
-
"@poppinss/cliui": "^6.4.0",
|
|
9
|
-
"ansis": "^3.3.0",
|
|
10
|
-
"build-md": "^0.4.2",
|
|
11
|
-
"bundle-require": "^4.0.1",
|
|
12
|
-
"esbuild": "^0.19.2",
|
|
13
|
-
"multi-progress-bars": "^5.0.3",
|
|
14
|
-
"semver": "^7.6.0",
|
|
15
|
-
"simple-git": "^3.20.0"
|
|
16
|
-
},
|
|
17
5
|
"license": "MIT",
|
|
18
6
|
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/utils#readme",
|
|
19
7
|
"bugs": {
|
|
20
|
-
"url": "https://github.com/code-pushup/cli/issues"
|
|
8
|
+
"url": "https://github.com/code-pushup/cli/issues?q=is%3Aissue%20state%3Aopen%20type%3ABug%20label%3A\"🧩%20utils\""
|
|
21
9
|
},
|
|
22
10
|
"repository": {
|
|
23
11
|
"type": "git",
|
|
24
12
|
"url": "git+https://github.com/code-pushup/cli.git",
|
|
25
13
|
"directory": "packages/utils"
|
|
26
14
|
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"CLI",
|
|
17
|
+
"Code PushUp",
|
|
18
|
+
"developer tools",
|
|
19
|
+
"helpers",
|
|
20
|
+
"utils"
|
|
21
|
+
],
|
|
27
22
|
"publishConfig": {
|
|
28
23
|
"access": "public"
|
|
29
24
|
},
|
|
30
25
|
"type": "module",
|
|
31
26
|
"main": "./index.js",
|
|
32
|
-
"types": "./src/index.d.ts"
|
|
33
|
-
|
|
27
|
+
"types": "./src/index.d.ts",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@code-pushup/models": "0.54.0",
|
|
30
|
+
"@isaacs/cliui": "^8.0.2",
|
|
31
|
+
"@poppinss/cliui": "^6.4.0",
|
|
32
|
+
"ansis": "^3.3.0",
|
|
33
|
+
"build-md": "^0.4.2",
|
|
34
|
+
"bundle-require": "^4.0.1",
|
|
35
|
+
"esbuild": "^0.19.2",
|
|
36
|
+
"multi-progress-bars": "^5.0.3",
|
|
37
|
+
"semver": "^7.6.0",
|
|
38
|
+
"simple-git": "^3.20.0"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/lib/transform.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export declare function objectToKeys<T extends object>(obj: T): (keyof T)[];
|
|
|
3
3
|
export declare function objectToEntries<T extends object>(obj: T): [keyof T, T[keyof T]][];
|
|
4
4
|
export declare function objectFromEntries<K extends PropertyKey, V>(entries: [K, V][]): Record<K, V>;
|
|
5
5
|
export declare function countOccurrences<T extends PropertyKey>(values: T[]): Partial<Record<T, number>>;
|
|
6
|
-
export declare function exists<T>(value: T): value is NonNullable<T>;
|
|
7
6
|
export declare function distinct<T extends string | number | boolean>(array: T[]): T[];
|
|
8
7
|
export declare function deepClone<T>(obj: T): T;
|
|
9
8
|
export declare function factorOf<T>(items: T[], filterFn: (i: T) => boolean): number;
|