This repository has been archived by the owner on Feb 10, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(cloudflare): fixup migration issues
- Loading branch information
1 parent
c631438
commit 1f20071
Showing
63 changed files
with
1,610 additions
and
746 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
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
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,50 @@ | ||
import { fileURLToPath } from "node:url"; | ||
import { execa } from "execa"; | ||
/** | ||
* @typedef {{ stop: Promise<void>, port: number }} WranglerCLI | ||
*/ | ||
|
||
const astroPath = fileURLToPath( | ||
new URL("../node_modules/.bin/astro", import.meta.url) | ||
); | ||
/** Returns a process running the Astro CLI. */ | ||
export function astroCli(cwd, /** @type {string[]} */ ...args) { | ||
const spawned = execa(astroPath, [...args], { | ||
env: { ASTRO_TELEMETRY_DISABLED: true }, | ||
cwd: cwd, | ||
}); | ||
|
||
spawned.stdout.setEncoding("utf8"); | ||
|
||
return spawned; | ||
} | ||
|
||
const wranglerPath = fileURLToPath( | ||
new URL("../node_modules/wrangler/bin/wrangler.js", import.meta.url) | ||
); | ||
/** Returns a process running the Astro CLI. */ | ||
export function wranglerCli(cwd) { | ||
const spawned = execa( | ||
wranglerPath, | ||
[ | ||
"pages", | ||
"dev", | ||
"dist", | ||
"--port", | ||
"8788", | ||
"--compatibility-date", | ||
new Date().toISOString().slice(0, 10), | ||
"--log-level", | ||
"info", | ||
], | ||
{ | ||
env: { CI: 1, CF_PAGES: 1 }, | ||
cwd: cwd, | ||
} | ||
); | ||
|
||
spawned.stdout.setEncoding("utf8"); | ||
spawned.stderr.setEncoding("utf8"); | ||
|
||
return spawned; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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,82 @@ | ||
import { expect } from "chai"; | ||
import * as cheerio from "cheerio"; | ||
import { fileURLToPath } from "node:url"; | ||
import { astroCli } from "./_test-utils.js"; | ||
|
||
const root = new URL("./fixtures/dev-runtime/", import.meta.url); | ||
describe("Runtime Astro Dev", () => { | ||
let cli; | ||
before(async () => { | ||
cli = astroCli(fileURLToPath(root), "dev", "--host", "127.0.0.1"); | ||
await new Promise((resolve) => { | ||
cli.stdout.on("data", (data) => { | ||
if (data.includes("http://127.0.0.1:4321/")) { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
after((done) => { | ||
cli.kill(); | ||
setTimeout(() => { | ||
console.log("CLEANED"); | ||
done(); | ||
}, 1000); | ||
}); | ||
|
||
it("exists", async () => { | ||
let res = await fetch(`http://127.0.0.1:4321/`); | ||
let html = await res.text(); | ||
let $ = cheerio.load(html); | ||
expect($("#hasRuntime").text()).to.contain("true"); | ||
}); | ||
|
||
it("adds cf object", async () => { | ||
let res = await fetch(`http://127.0.0.1:4321/`); | ||
let html = await res.text(); | ||
let $ = cheerio.load(html); | ||
expect($("#hasCF").text()).to.equal("true"); | ||
}); | ||
|
||
it("adds cache mocking", async () => { | ||
let res = await fetch(`http://127.0.0.1:4321/caches`); | ||
let html = await res.text(); | ||
let $ = cheerio.load(html); | ||
expect($("#hasCACHE").text()).to.equal("true"); | ||
}); | ||
|
||
it("adds D1 mocking", async () => { | ||
let res = await fetch(`http://127.0.0.1:4321/d1`); | ||
let html = await res.text(); | ||
let $ = cheerio.load(html); | ||
expect($("#hasDB").text()).to.equal("true"); | ||
expect($("#hasPRODDB").text()).to.equal("true"); | ||
expect($("#hasACCESS").text()).to.equal("true"); | ||
}); | ||
|
||
it("adds R2 mocking", async () => { | ||
let res = await fetch(`http://127.0.0.1:4321/r2`); | ||
let html = await res.text(); | ||
let $ = cheerio.load(html); | ||
expect($("#hasBUCKET").text()).to.equal("true"); | ||
expect($("#hasPRODBUCKET").text()).to.equal("true"); | ||
expect($("#hasACCESS").text()).to.equal("true"); | ||
}); | ||
|
||
it("adds KV mocking", async () => { | ||
let res = await fetch(`http://127.0.0.1:4321/kv`); | ||
let html = await res.text(); | ||
let $ = cheerio.load(html); | ||
expect($("#hasKV").text()).to.equal("true"); | ||
expect($("#hasPRODKV").text()).to.equal("true"); | ||
expect($("#hasACCESS").text()).to.equal("true"); | ||
}); | ||
|
||
it("adds DO mocking", async () => { | ||
let res = await fetch(`http://127.0.0.1:4321/do`); | ||
let html = await res.text(); | ||
let $ = cheerio.load(html); | ||
expect($("#hasDO").text()).to.equal("true"); | ||
}); | ||
}); |
Oops, something went wrong.