-
Notifications
You must be signed in to change notification settings - Fork 735
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bdebc5
commit fb53fda
Showing
12 changed files
with
187 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
feat: Non-interactive mode | ||
|
||
Continuing the work from https://github.com/cloudflare/wrangler2/pull/325, this detects when wrangler is running inside an environment where "raw" mode is not available on stdin, and disables the features for hot keys and the shortcut bar. This also adds stubs for testing local mode functionality in `local-mode-tests`, and deletes the previous hacky `dev2.test.tsx`. | ||
|
||
Fixes https://github.com/cloudflare/wrangler2/issues/322 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "local-mode-tests", | ||
"version": "1.0.0", | ||
"private": true, | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "npx jest --forceExit" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"jest": { | ||
"restoreMocks": true, | ||
"testTimeout": 30000, | ||
"testRegex": ".*.(test|spec)\\.[jt]sx?$", | ||
"transform": { | ||
"^.+\\.c?(t|j)sx?$": [ | ||
"esbuild-jest", | ||
{ | ||
"sourcemap": true | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default { | ||
async fetch(_request: Request): Promise<Response> { | ||
return new Response("Hello World!"); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { spawn } from "child_process"; | ||
import { fetch } from "undici"; | ||
import type { ChildProcess } from "child_process"; | ||
import type { Response } from "undici"; | ||
|
||
const waitUntilReady = async (url: string): Promise<Response> => { | ||
let response: Response | undefined = undefined; | ||
|
||
while (response === undefined) { | ||
await new Promise((resolvePromise) => setTimeout(resolvePromise, 100)); | ||
|
||
try { | ||
response = await fetch(url); | ||
} catch {} | ||
} | ||
|
||
return response as Response; | ||
}; | ||
const isWindows = process.platform === "win32"; | ||
|
||
let wranglerProcess: ChildProcess; | ||
|
||
beforeAll(async () => { | ||
wranglerProcess = spawn("npx", ["wrangler", "dev", "--local"], { | ||
shell: isWindows, | ||
}); | ||
}); | ||
|
||
afterAll(async () => { | ||
await new Promise((resolve, reject) => { | ||
wranglerProcess.once("exit", (code) => { | ||
if (!code) { | ||
resolve(code); | ||
} else { | ||
reject(code); | ||
} | ||
}); | ||
wranglerProcess.kill(); | ||
}); | ||
}); | ||
|
||
it("renders", async () => { | ||
const response = await waitUntilReady("http://localhost:8787/"); | ||
const text = await response.text(); | ||
expect(text).toContain("Hello World!"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"isolatedModules": true, | ||
"esModuleInterop": true, | ||
"allowJs": true, | ||
"allowSyntheticDefaultImports": true, | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"target": "esnext", | ||
"strict": true, | ||
"noEmit": true, | ||
"skipLibCheck": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name = "local-mode-tests" | ||
main = "src/index.ts" | ||
compatibility_date = "2022-03-27" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.