@code-pushup/utils 0.16.7 → 0.17.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 +11 -6
- package/package.json +1 -1
- package/src/index.d.ts +1 -1
- package/src/lib/file-system.d.ts +1 -0
package/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { z as z2 } from "zod";
|
|
3
3
|
|
|
4
4
|
// packages/models/src/lib/implementation/schemas.ts
|
|
5
|
+
import { MATERIAL_ICONS } from "vscode-material-icons";
|
|
5
6
|
import { z } from "zod";
|
|
6
|
-
import { MATERIAL_ICONS } from "@code-pushup/portal-client";
|
|
7
7
|
|
|
8
8
|
// packages/models/src/lib/implementation/limits.ts
|
|
9
9
|
var MAX_SLUG_LENGTH = 128;
|
|
@@ -161,10 +161,9 @@ function scorableSchema(description, refSchema, duplicateCheckFn, duplicateMessa
|
|
|
161
161
|
{ description }
|
|
162
162
|
);
|
|
163
163
|
}
|
|
164
|
-
var materialIconSchema = z.enum(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
);
|
|
164
|
+
var materialIconSchema = z.enum(MATERIAL_ICONS, {
|
|
165
|
+
description: "Icon from VSCode Material Icons extension"
|
|
166
|
+
});
|
|
168
167
|
function hasWeightedRefsInCategories(categoryRefs) {
|
|
169
168
|
return categoryRefs.reduce((acc, { weight }) => weight + acc, 0) !== 0;
|
|
170
169
|
}
|
|
@@ -553,7 +552,7 @@ import { join as join2 } from "node:path";
|
|
|
553
552
|
// packages/utils/src/lib/file-system.ts
|
|
554
553
|
import { bundleRequire } from "bundle-require";
|
|
555
554
|
import chalk from "chalk";
|
|
556
|
-
import { mkdir, readFile, readdir, stat } from "node:fs/promises";
|
|
555
|
+
import { mkdir, readFile, readdir, rm, stat } from "node:fs/promises";
|
|
557
556
|
import { join } from "node:path";
|
|
558
557
|
|
|
559
558
|
// packages/utils/src/lib/formatting.ts
|
|
@@ -692,6 +691,11 @@ async function ensureDirectoryExists(baseDir) {
|
|
|
692
691
|
}
|
|
693
692
|
}
|
|
694
693
|
}
|
|
694
|
+
async function removeDirectoryIfExists(dir) {
|
|
695
|
+
if (await directoryExists(dir)) {
|
|
696
|
+
await rm(dir, { recursive: true, force: true });
|
|
697
|
+
}
|
|
698
|
+
}
|
|
695
699
|
function logMultipleFileResults(fileResults, messagePrefix) {
|
|
696
700
|
const succeededCallback = (result) => {
|
|
697
701
|
const [fileName, size] = result.value;
|
|
@@ -1755,6 +1759,7 @@ export {
|
|
|
1755
1759
|
portalCommitDashboardLink,
|
|
1756
1760
|
readJsonFile,
|
|
1757
1761
|
readTextFile,
|
|
1762
|
+
removeDirectoryIfExists,
|
|
1758
1763
|
scoreReport,
|
|
1759
1764
|
slugify,
|
|
1760
1765
|
sortReport,
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { exists } from '@code-pushup/models';
|
|
2
2
|
export { ProcessConfig, ProcessError, ProcessObserver, ProcessResult, executeProcess, } from './lib/execute-process';
|
|
3
|
-
export { CrawlFileSystemOptions, FileResult, MultipleFileResults, crawlFileSystem, directoryExists, ensureDirectoryExists, fileExists, findLineNumberInText, importEsmModule, logMultipleFileResults, pluginWorkDir, readJsonFile, readTextFile, } from './lib/file-system';
|
|
3
|
+
export { CrawlFileSystemOptions, FileResult, MultipleFileResults, crawlFileSystem, directoryExists, ensureDirectoryExists, fileExists, findLineNumberInText, importEsmModule, logMultipleFileResults, pluginWorkDir, readJsonFile, readTextFile, removeDirectoryIfExists, } from './lib/file-system';
|
|
4
4
|
export { formatBytes, formatDuration, pluralize, pluralizeToken, slugify, truncateDescription, truncateIssueMessage, truncateText, truncateTitle, } from './lib/formatting';
|
|
5
5
|
export { getLatestCommit, git, validateCommitData } from './lib/git';
|
|
6
6
|
export { groupByStatus } from './lib/group-by-status';
|
package/src/lib/file-system.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare function readJsonFile<T = unknown>(path: string): Promise<T>;
|
|
|
4
4
|
export declare function fileExists(path: string): Promise<boolean>;
|
|
5
5
|
export declare function directoryExists(path: string): Promise<boolean>;
|
|
6
6
|
export declare function ensureDirectoryExists(baseDir: string): Promise<void>;
|
|
7
|
+
export declare function removeDirectoryIfExists(dir: string): Promise<void>;
|
|
7
8
|
export type FileResult = readonly [string] | readonly [string, number];
|
|
8
9
|
export type MultipleFileResults = PromiseSettledResult<FileResult>[];
|
|
9
10
|
export declare function logMultipleFileResults(fileResults: MultipleFileResults, messagePrefix: string): void;
|