feat: support automatic workspace detection in Dev (#2985)
Adds support for [Automatic Workspace Detection](https://chromium.googlesource.com/devtools/devtools-frontend/+/main/docs/ecosystem/automatic_workspace_folders.md). - Avoids 404's or middleware logging when this feature is active (e.g. Chrome/Edge with DevTools open) - Generates the same UUID based on root folder path (without writing anything to disk) - The middleware is lazy and does nothing until the path is opened for `com.chrome.devtools.json`
This commit is contained in:
@@ -209,3 +209,38 @@ Deno.test({
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "Builder - workspace folder middleware on listen",
|
||||
fn: async () => {
|
||||
const builder = new Builder();
|
||||
const tmp = await Deno.makeTempDir();
|
||||
const app = new App({
|
||||
staticDir: tmp,
|
||||
build: {
|
||||
outDir: path.join(tmp, "dist"),
|
||||
},
|
||||
});
|
||||
const abort = new AbortController();
|
||||
const port = 8011;
|
||||
await builder.listen(app, { port, signal: abort.signal });
|
||||
|
||||
const res = await fetch(
|
||||
`http://localhost:${port}/.well-known/appspecific/com.chrome.devtools.json`,
|
||||
);
|
||||
const json = await res.json();
|
||||
await abort.abort();
|
||||
|
||||
expect(res.ok).toBe(true);
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.headers.get("etag")).toEqual(expect.any(String));
|
||||
expect(json).toEqual({
|
||||
workspace: {
|
||||
root: app.config.root,
|
||||
uuid: expect.any(String),
|
||||
},
|
||||
});
|
||||
},
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user