chore: restructure repository into packages/ folder (#3197)
We're having a growing number of packages in this repository. This PR moves them into a `packages/` directory like it's commonly done in other projects.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { expect } from "@std/expect";
|
||||
import { MemoryBuildCache } from "./dev_build_cache.ts";
|
||||
import { FileTransformer } from "./file_transformer.ts";
|
||||
import { createFakeFs, withTmpDir } from "../test_utils.ts";
|
||||
import type { ResolvedBuildConfig } from "./builder.ts";
|
||||
|
||||
Deno.test({
|
||||
name: "MemoryBuildCache - should error if reading outside of staticDir",
|
||||
fn: async () => {
|
||||
await using _tmp = await withTmpDir();
|
||||
const tmp = _tmp.dir;
|
||||
const config: ResolvedBuildConfig = {
|
||||
root: tmp,
|
||||
mode: "development",
|
||||
buildId: "",
|
||||
ignore: [],
|
||||
islandDir: "",
|
||||
outDir: "",
|
||||
routeDir: "",
|
||||
staticDir: "",
|
||||
target: "latest",
|
||||
};
|
||||
const fileTransformer = new FileTransformer(createFakeFs({}), tmp);
|
||||
const buildCache = new MemoryBuildCache(
|
||||
config,
|
||||
{ dir: "", files: [], id: "" },
|
||||
fileTransformer,
|
||||
);
|
||||
|
||||
const thrown = buildCache.readFile("../SECRETS.txt");
|
||||
const thrown2 = buildCache.readFile("./../../SECRETS.txt");
|
||||
const noThrown = buildCache.readFile("styles.css");
|
||||
const noThrown2 = buildCache.readFile(".well-known/foo.txt");
|
||||
const noThrown3 = buildCache.readFile("./styles.css");
|
||||
const noThrown4 = buildCache.readFile("./.well-known/foo.txt");
|
||||
await buildCache.flush();
|
||||
|
||||
const err = "Processed file resolved outside of static dir";
|
||||
await expect(thrown).rejects.toThrow(err);
|
||||
await expect(thrown2).rejects.toThrow(err);
|
||||
await expect(noThrown).resolves.toBe(null);
|
||||
await expect(noThrown2).resolves.toBe(null);
|
||||
await expect(noThrown3).resolves.toBe(null);
|
||||
await expect(noThrown4).resolves.toBe(null);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user