@valbuild/cli 0.102.0 → 0.103.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/cli/dist/valbuild-cli-cli.cjs.dev.js +13 -550
- package/cli/dist/valbuild-cli-cli.cjs.prod.js +13 -550
- package/cli/dist/valbuild-cli-cli.esm.js +12 -549
- package/package.json +5 -5
- package/src/__fixtures__/basic/content/basic-image-from-galleries.val.ts +2 -2
- package/src/__fixtures__/basic/content/basic-image-from-gallery.val.ts +1 -1
- package/src/__fixtures__/basic/content/basic-image.val.ts +3 -5
- package/src/listUnusedFiles.ts +15 -22
- package/src/runValidation.test.ts +5 -5
- package/src/runValidation.ts +25 -771
- package/src/utils/sourcePathToFileLocation.ts +1 -1
- package/src/utils/getFileExt.ts +0 -4
package/src/listUnusedFiles.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FILE_REF_PROP,
|
|
3
|
-
ModuleFilePath,
|
|
4
|
-
ModulePath,
|
|
5
|
-
SourcePath,
|
|
6
|
-
VAL_EXTENSION,
|
|
7
|
-
} from "@valbuild/core";
|
|
1
|
+
import { ModuleFilePath, ModulePath, SourcePath } from "@valbuild/core";
|
|
8
2
|
import { createService } from "@valbuild/server";
|
|
9
3
|
import { glob } from "fast-glob";
|
|
10
4
|
import path from "path";
|
|
@@ -49,7 +43,7 @@ export async function listUnusedFiles({ root }: { root?: string }) {
|
|
|
49
43
|
if (isFileRef(value)) {
|
|
50
44
|
const absoluteFilePathUsedByVal = path.join(
|
|
51
45
|
projectRoot,
|
|
52
|
-
...value
|
|
46
|
+
...value.path.split("/"),
|
|
53
47
|
);
|
|
54
48
|
filesUsedByVal.push(absoluteFilePathUsedByVal);
|
|
55
49
|
}
|
|
@@ -78,18 +72,17 @@ export async function listUnusedFiles({ root }: { root?: string }) {
|
|
|
78
72
|
return;
|
|
79
73
|
}
|
|
80
74
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return false;
|
|
75
|
+
/**
|
|
76
|
+
* Whether a flagged validation value names a file.
|
|
77
|
+
*
|
|
78
|
+
* A `ValidationError` carries no schema, so the shape is all there is to go on —
|
|
79
|
+
* the same heuristic this whole function documents as a TODO.
|
|
80
|
+
*/
|
|
81
|
+
function isFileRef(value: unknown): value is { path: string } {
|
|
82
|
+
return (
|
|
83
|
+
!!value &&
|
|
84
|
+
typeof value === "object" &&
|
|
85
|
+
"path" in value &&
|
|
86
|
+
typeof value.path === "string"
|
|
87
|
+
);
|
|
95
88
|
}
|
|
@@ -372,12 +372,12 @@ describe("runValidation", () => {
|
|
|
372
372
|
.flatMap((e) => e.fixes ?? []);
|
|
373
373
|
expect(allFixes).not.toContain("image:add-metadata");
|
|
374
374
|
}
|
|
375
|
+
// The fix writes the fields it read from the bytes next to `path`.
|
|
375
376
|
expect(result.source).toMatchObject({
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
},
|
|
377
|
+
path: "/public/val/image.png",
|
|
378
|
+
width: 1,
|
|
379
|
+
height: 1,
|
|
380
|
+
mimeType: "image/png",
|
|
381
381
|
});
|
|
382
382
|
} finally {
|
|
383
383
|
service.dispose();
|