Skip to content

Commit 32f562b

Browse files
feat(core): a folder with index.html is one a step can work on, apart from finding projects (#7734)
* feat(core): a folder with index.html is one a step can work on, apart from finding projects isHyperframesProject needs index.html and a marker file, which is right for finding projects on a computer (a website's folder must not be listed) but not for what a step works on. isCompositionFolder says that: any folder whose index.html is the composition. * build(core): raise core's unpacked size budget for the step folder rule
1 parent c31e7dd commit 32f562b

5 files changed

Lines changed: 22 additions & 5 deletions

File tree

‎packages/core/src/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ export {
355355
realProjectRoot,
356356
resolveWithinProject,
357357
} from "./safePath";
358-
export { isHyperframesProject, PROJECT_MARKER_FILES } from "./projectRule";
358+
export { isCompositionFolder, isHyperframesProject, PROJECT_MARKER_FILES } from "./projectRule";
359359
export type {
360360
HyperframePickerApi,
361361
HyperframePickerBoundingBox,

‎packages/core/src/projectRule.test.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
import { isHyperframesProject } from "./projectRule";
2+
import { isCompositionFolder, isHyperframesProject } from "./projectRule";
33

44
describe("isHyperframesProject", () => {
55
it.each(["hyperframes.json", "meta.json", "project.json"])(
@@ -14,3 +14,16 @@ describe("isHyperframesProject", () => {
1414
expect(isHyperframesProject(["hyperframes.json", "README.md"])).toBe(false);
1515
});
1616
});
17+
18+
// fails without the fix: a step had only the discovery rule, so a folder holding a composition but no marker file was
19+
// refused by `open` though `snapshot` and `check` worked on it.
20+
describe("isCompositionFolder", () => {
21+
it("counts any folder with index.html, marker or not", () => {
22+
expect(isCompositionFolder(["index.html"])).toBe(true);
23+
expect(isCompositionFolder(["index.html", "hyperframes.json"])).toBe(true);
24+
});
25+
26+
it("does not count a folder without index.html", () => {
27+
expect(isCompositionFolder(["hyperframes.json", "assets"])).toBe(false);
28+
});
29+
});

‎packages/core/src/projectRule.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ export function isHyperframesProject(fileNames: Iterable<string>): boolean {
55
const names = new Set(fileNames);
66
return names.has("index.html") && PROJECT_MARKER_FILES.some((name) => names.has(name));
77
}
8+
9+
export function isCompositionFolder(fileNames: Iterable<string>): boolean {
10+
return new Set(fileNames).has("index.html");
11+
}

‎packages/core/src/projects.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import type { Dirent } from "node:fs";
33
import { readFile, readdir, realpath, stat } from "node:fs/promises";
44
import { homedir } from "node:os";
55
import { basename, dirname, isAbsolute, join, relative, sep } from "node:path";
6-
import { isHyperframesProject, PROJECT_MARKER_FILES } from "./projectRule";
6+
import { isCompositionFolder, isHyperframesProject, PROJECT_MARKER_FILES } from "./projectRule";
77

8-
export { isHyperframesProject, PROJECT_MARKER_FILES };
8+
export { isCompositionFolder, isHyperframesProject, PROJECT_MARKER_FILES };
99

1010
export interface FoundProject {
1111
path: string;

‎scripts/package-size-budgets.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"@hyperframes/core": {
1111
"packed": 1762752,
12-
"unpacked": 4330000
12+
"unpacked": 4374000
1313
},
1414
"@hyperframes/engine": {
1515
"packed": 490452,

0 commit comments

Comments
 (0)