@@ -40,32 +40,32 @@ jobs:
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.cache/deno/deno_puppeteer
|
||||
key: chrome-${{ runner.os }}-${{ hashFiles('tests/deps.ts') }}
|
||||
restore-keys: chrome-${{ runner.os }}-
|
||||
key: chrome-991974-${{ runner.os }}-${{ hashFiles('tests/deps.ts') }}
|
||||
restore-keys: chrome-991974-${{ runner.os }}-
|
||||
|
||||
- name: Cache Chrome (macOS)
|
||||
if: startsWith(matrix.os, 'mac')
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/Library/Caches/deno/deno_puppeteer
|
||||
key: chrome-${{ runner.os }}-${{ hashFiles('tests/deps.ts') }}
|
||||
restore-keys: chrome-${{ runner.os }}-
|
||||
key: chrome-991974-${{ runner.os }}-${{ hashFiles('tests/deps.ts') }}
|
||||
restore-keys: chrome-991974-${{ runner.os }}-
|
||||
|
||||
- name: Cache Chrome (Windows)
|
||||
if: startsWith(matrix.os, 'win')
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: "C:\\Users\\RUNNER~1\\AppData\\Local\\deno\\deno_puppeteer"
|
||||
key: chrome-${{ runner.os }}-${{ hashFiles('tests/deps.ts') }}
|
||||
restore-keys: chrome-${{ runner.os }}-
|
||||
key: chrome-991974-${{ runner.os }}-${{ hashFiles('tests/deps.ts') }}
|
||||
restore-keys: chrome-991974-${{ runner.os }}-
|
||||
|
||||
- name: Install Chromium (Unix)
|
||||
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'mac')
|
||||
run: PUPPETEER_PRODUCT=chrome deno run -A --unstable https://deno.land/x/puppeteer@9.0.2/install.ts
|
||||
run: PUPPETEER_PRODUCT=chrome deno run -A --unstable https://deno.land/x/puppeteer@14.1.1/install.ts
|
||||
|
||||
- name: Install Chromium (Windows)
|
||||
if: startsWith(matrix.os, 'windows')
|
||||
run: set "PUPPETEER_PRODUCT=chrome" && deno run -A --unstable https://deno.land/x/puppeteer@9.0.2/install.ts
|
||||
run: set "PUPPETEER_PRODUCT=chrome" && deno run -A --unstable https://deno.land/x/puppeteer@14.1.1/install.ts
|
||||
|
||||
- name: Run tests
|
||||
run: deno test -A
|
||||
|
||||
Vendored
+4
-4
@@ -7,10 +7,10 @@
|
||||
"twind": "https://esm.sh/twind@0.16.17",
|
||||
"twind/": "https://esm.sh/twind@0.16.17/",
|
||||
|
||||
"preact": "https://esm.sh/preact@10.8.2",
|
||||
"preact/": "https://esm.sh/preact@10.8.2/",
|
||||
"preact-render-to-string": "https://esm.sh/preact-render-to-string@5.2.0?external=preact",
|
||||
"preact": "https://esm.sh/preact@10.10.0",
|
||||
"preact/": "https://esm.sh/preact@10.10.0/",
|
||||
"preact-render-to-string": "https://esm.sh/preact-render-to-string@5.2.1?external=preact",
|
||||
|
||||
"$semver/": "https://deno.land/x/semver@v1.4.0/"
|
||||
"$std/": "https://deno.land/std@0.150.0/"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ do this you can just `deno task start`.
|
||||
```
|
||||
$ deno task start
|
||||
Watcher Process started.
|
||||
Server listening on http://localhost:8000
|
||||
Listening on http://localhost:8000
|
||||
```
|
||||
|
||||
If you want to start manually without Deno task, `deno run` the `main.ts` with
|
||||
@@ -45,7 +45,7 @@ Combining all of this we get the following `deno run` command:
|
||||
```
|
||||
$ deno run --allow-net --allow-read --allow-env --allow-run --watch=static/,routes/ main.ts
|
||||
Watcher Process started.
|
||||
Server listening on http://localhost:8000
|
||||
Listening on http://localhost:8000
|
||||
```
|
||||
|
||||
If you now visit http://localhost:8000, you can see the running project. Try
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"imports": {
|
||||
"$fresh/": "../../",
|
||||
"preact": "https://esm.sh/preact@10.8.2",
|
||||
"preact/": "https://esm.sh/preact@10.8.2/",
|
||||
"preact-render-to-string": "https://esm.sh/preact-render-to-string@5.2.0?external=preact"
|
||||
"preact": "https://esm.sh/preact@10.10.0",
|
||||
"preact/": "https://esm.sh/preact@10.10.0/",
|
||||
"preact-render-to-string": "https://esm.sh/preact-render-to-string@5.2.1?external=preact"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,10 +96,10 @@ if (useTwind) {
|
||||
const importMap = {
|
||||
"imports": {
|
||||
"$fresh/": new URL("./", import.meta.url).href,
|
||||
"preact": "https://esm.sh/preact@10.8.2",
|
||||
"preact/": "https://esm.sh/preact@10.8.2/",
|
||||
"preact": "https://esm.sh/preact@10.10.0",
|
||||
"preact/": "https://esm.sh/preact@10.10.0/",
|
||||
"preact-render-to-string":
|
||||
"https://esm.sh/preact-render-to-string@5.2.0?external=preact",
|
||||
"https://esm.sh/preact-render-to-string@5.2.1?external=preact",
|
||||
} as Record<string, string>,
|
||||
};
|
||||
if (useTwind) {
|
||||
|
||||
+4
-5
@@ -6,8 +6,7 @@ export {
|
||||
join,
|
||||
resolve,
|
||||
toFileUrl,
|
||||
} from "https://deno.land/std@0.128.0/path/mod.ts";
|
||||
export { walk } from "https://deno.land/std@0.128.0/fs/walk.ts";
|
||||
export { bold, red } from "https://deno.land/std@0.128.0/fmt/colors.ts";
|
||||
export { parse } from "https://deno.land/std@0.128.0/flags/mod.ts";
|
||||
export { gte } from "https://deno.land/x/semver@v1.4.0/mod.ts";
|
||||
} from "https://deno.land/std@0.150.0/path/mod.ts";
|
||||
export { walk } from "https://deno.land/std@0.150.0/fs/walk.ts";
|
||||
export { parse } from "https://deno.land/std@0.150.0/flags/mod.ts";
|
||||
export { gte } from "https://deno.land/std@0.150.0/semver/mod.ts";
|
||||
|
||||
+1
-3
@@ -1,7 +1,5 @@
|
||||
import { bold, red } from "./deps.ts";
|
||||
|
||||
export function printError(message: string) {
|
||||
console.error(red(`${bold("error")}: ${message}`));
|
||||
console.error(`%cerror%c: ${message}`, "color: red; font-weight: bold", "");
|
||||
}
|
||||
|
||||
export function error(message: string): never {
|
||||
|
||||
@@ -7,7 +7,7 @@ async function ensureEsbuildInitialized() {
|
||||
if (esbuildInitialized === false) {
|
||||
if (Deno.run === undefined) {
|
||||
esbuildInitialized = esbuild.initialize({
|
||||
wasmURL: "https://unpkg.com/esbuild-wasm@0.14.39/esbuild.wasm",
|
||||
wasmURL: "https://unpkg.com/esbuild-wasm@0.14.51/esbuild.wasm",
|
||||
worker: false,
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -2,10 +2,10 @@ import {
|
||||
ConnInfo,
|
||||
extname,
|
||||
fromFileUrl,
|
||||
mediaTypeLookup,
|
||||
RequestHandler,
|
||||
router,
|
||||
toFileUrl,
|
||||
typeByExtension,
|
||||
walk,
|
||||
} from "./deps.ts";
|
||||
import { h } from "preact";
|
||||
@@ -224,7 +224,7 @@ export class ServerContext {
|
||||
const localUrl = toFileUrl(entry.path);
|
||||
const path = localUrl.href.substring(staticFolder.href.length);
|
||||
const stat = await Deno.stat(localUrl);
|
||||
const contentType = mediaTypeLookup(extname(path)) ??
|
||||
const contentType = typeByExtension(extname(path)) ??
|
||||
"application/octet-stream";
|
||||
const etag = await crypto.subtle.digest(
|
||||
"SHA-1",
|
||||
@@ -559,7 +559,7 @@ export class ServerContext {
|
||||
"Cache-Control": "public, max-age=604800, immutable",
|
||||
});
|
||||
|
||||
const contentType = mediaTypeLookup(path);
|
||||
const contentType = typeByExtension(extname(path));
|
||||
if (contentType) {
|
||||
headers.set("Content-Type", contentType);
|
||||
}
|
||||
|
||||
+11
-11
@@ -3,28 +3,28 @@ export {
|
||||
extname,
|
||||
fromFileUrl,
|
||||
toFileUrl,
|
||||
} from "https://deno.land/std@0.128.0/path/mod.ts";
|
||||
export { walk } from "https://deno.land/std@0.128.0/fs/walk.ts";
|
||||
export { serve } from "https://deno.land/std@0.128.0/http/server.ts";
|
||||
} from "https://deno.land/std@0.150.0/path/mod.ts";
|
||||
export { walk } from "https://deno.land/std@0.150.0/fs/walk.ts";
|
||||
export { serve } from "https://deno.land/std@0.150.0/http/server.ts";
|
||||
export type {
|
||||
ConnInfo,
|
||||
Handler as RequestHandler,
|
||||
ServeInit,
|
||||
} from "https://deno.land/std@0.128.0/http/server.ts";
|
||||
} from "https://deno.land/std@0.150.0/http/server.ts";
|
||||
export {
|
||||
typeByExtension,
|
||||
} from "https://deno.land/std@0.150.0/media_types/mod.ts";
|
||||
|
||||
// -- router --
|
||||
export * as router from "https://crux.land/router@0.0.11";
|
||||
|
||||
// -- media types --
|
||||
export { lookup as mediaTypeLookup } from "https://deno.land/x/media_types@v2.10.2/mod.ts";
|
||||
|
||||
// -- esbuild --
|
||||
// @deno-types="https://deno.land/x/esbuild@v0.14.39/mod.d.ts"
|
||||
import * as esbuildWasm from "https://unpkg.com/esbuild-wasm@0.14.39/esm/browser.js";
|
||||
import * as esbuildNative from "https://deno.land/x/esbuild@v0.14.39/mod.js";
|
||||
// @deno-types="https://deno.land/x/esbuild@v0.14.51/mod.d.ts"
|
||||
import * as esbuildWasm from "https://deno.land/x/esbuild@v0.14.51/wasm.js";
|
||||
import * as esbuildNative from "https://deno.land/x/esbuild@v0.14.51/mod.js";
|
||||
// @ts-ignore trust me
|
||||
const esbuild: typeof esbuildWasm = Deno.run === undefined
|
||||
? esbuildWasm
|
||||
: esbuildNative;
|
||||
export { esbuild, esbuildWasm as esbuildTypes };
|
||||
export { denoPlugin } from "https://deno.land/x/esbuild_deno_loader@0.5.0/mod.ts";
|
||||
export { denoPlugin } from "https://deno.land/x/esbuild_deno_loader@0.5.2/mod.ts";
|
||||
|
||||
@@ -50,10 +50,5 @@ export async function start(
|
||||
opts: StartOptions = {},
|
||||
) {
|
||||
const ctx = await ServerContext.fromManifest(routes, opts);
|
||||
console.log(
|
||||
`Server listening on http://${opts?.hostname ?? "localhost"}:${
|
||||
opts?.port ?? 8000
|
||||
}`,
|
||||
);
|
||||
await serve(ctx.handler(), opts);
|
||||
}
|
||||
|
||||
+17
-5
@@ -47,9 +47,8 @@ Deno.test({
|
||||
"-A",
|
||||
"init.ts",
|
||||
tmpDirName,
|
||||
"--no-twind",
|
||||
"--no-vscode",
|
||||
],
|
||||
stdin: "null",
|
||||
stdout: "null",
|
||||
});
|
||||
const { code } = await cliProcess.status();
|
||||
@@ -107,6 +106,7 @@ Deno.test({
|
||||
await t.step("start up the server and access the root page", async () => {
|
||||
const serverProcess = Deno.run({
|
||||
cmd: ["deno", "run", "-A", "--check", "main.ts"],
|
||||
stdin: "null",
|
||||
stdout: "piped",
|
||||
stderr: "inherit",
|
||||
cwd: tmpDirName,
|
||||
@@ -119,7 +119,7 @@ Deno.test({
|
||||
let started = false;
|
||||
for await (const line of lines) {
|
||||
console.log(line);
|
||||
if (line.includes("Server listening on http://")) {
|
||||
if (line.includes("Listening on http://")) {
|
||||
started = true;
|
||||
break;
|
||||
}
|
||||
@@ -136,7 +136,9 @@ Deno.test({
|
||||
assertEquals(res.status, 200);
|
||||
|
||||
// verify the island is revived.
|
||||
const browser = await puppeteer.launch({ args: ["--no-sandbox"] });
|
||||
const browser = await puppeteer.launch({
|
||||
args: ["--no-sandbox"],
|
||||
});
|
||||
const page = await browser.newPage();
|
||||
await page.goto("http://localhost:8000", { waitUntil: "networkidle2" });
|
||||
const counter = await page.$("body > div > div > p");
|
||||
@@ -146,7 +148,10 @@ Deno.test({
|
||||
const buttonPlus = await page.$("body > div > div > button:nth-child(3)");
|
||||
await buttonPlus?.click();
|
||||
|
||||
await delay(100);
|
||||
|
||||
counterValue = await counter?.evaluate((el) => el.textContent);
|
||||
console.log(counterValue);
|
||||
assert(counterValue === "4");
|
||||
await page.close();
|
||||
await browser.close();
|
||||
@@ -177,6 +182,7 @@ Deno.test({
|
||||
"--twind",
|
||||
"--vscode",
|
||||
],
|
||||
stdin: "null",
|
||||
stdout: "null",
|
||||
});
|
||||
const { code } = await cliProcess.status();
|
||||
@@ -249,6 +255,7 @@ Deno.test({
|
||||
await t.step("start up the server and access the root page", async () => {
|
||||
const serverProcess = Deno.run({
|
||||
cmd: ["deno", "run", "-A", "--check", "main.ts"],
|
||||
stdin: "null",
|
||||
stdout: "piped",
|
||||
stderr: "inherit",
|
||||
cwd: tmpDirName,
|
||||
@@ -261,7 +268,7 @@ Deno.test({
|
||||
let started = false;
|
||||
for await (const line of lines) {
|
||||
console.log(line);
|
||||
if (line.includes("Server listening on http://")) {
|
||||
if (line.includes("Listening on http://")) {
|
||||
started = true;
|
||||
break;
|
||||
}
|
||||
@@ -294,6 +301,8 @@ Deno.test({
|
||||
const buttonPlus = await page.$("body > div > div > button:nth-child(3)");
|
||||
await buttonPlus?.click();
|
||||
|
||||
await delay(100);
|
||||
|
||||
counterValue = await counter?.evaluate((el) => el.textContent);
|
||||
assert(counterValue === "4");
|
||||
await page.close();
|
||||
@@ -316,6 +325,7 @@ Deno.test("fresh-init error(help)", async function (t) {
|
||||
async () => {
|
||||
const cliProcess = Deno.run({
|
||||
cmd: ["deno", "run", "-A", "init.ts"],
|
||||
stdin: "null",
|
||||
stderr: "piped",
|
||||
});
|
||||
const { code } = await cliProcess.status();
|
||||
@@ -334,6 +344,7 @@ Deno.test("fresh-init error(help)", async function (t) {
|
||||
async () => {
|
||||
const cliProcess = Deno.run({
|
||||
cmd: ["deno", "run", "-A", "init.ts", "-f"],
|
||||
stdin: "null",
|
||||
stderr: "piped",
|
||||
});
|
||||
const { code } = await cliProcess.status();
|
||||
@@ -352,6 +363,7 @@ Deno.test("fresh-init error(help)", async function (t) {
|
||||
async () => {
|
||||
const cliProcess = Deno.run({
|
||||
cmd: ["deno", "run", "-A", "init.ts", "--foo"],
|
||||
stdin: "null",
|
||||
stderr: "piped",
|
||||
});
|
||||
const { code } = await cliProcess.status();
|
||||
|
||||
+4
-4
@@ -8,9 +8,9 @@ export {
|
||||
assert,
|
||||
assertEquals,
|
||||
assertStringIncludes,
|
||||
} from "https://deno.land/std@0.129.0/testing/asserts.ts";
|
||||
} from "https://deno.land/std@0.150.0/testing/asserts.ts";
|
||||
export {
|
||||
TextLineStream,
|
||||
} from "https://deno.land/std@0.129.0/streams/delimiter.ts";
|
||||
export { delay } from "https://deno.land/std@0.129.0/async/delay.ts";
|
||||
export { default as puppeteer } from "https://deno.land/x/puppeteer@9.0.2/mod.ts";
|
||||
} from "https://deno.land/std@0.150.0/streams/delimiter.ts";
|
||||
export { delay } from "https://deno.land/std@0.150.0/async/delay.ts";
|
||||
export { default as puppeteer } from "https://deno.land/x/puppeteer@14.1.1/mod.ts";
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"imports": {
|
||||
"$fresh/": "../../",
|
||||
"preact": "https://esm.sh/preact@10.8.2",
|
||||
"preact/": "https://esm.sh/preact@10.8.2/",
|
||||
"preact-render-to-string": "https://esm.sh/preact-render-to-string@5.2.0?external=preact"
|
||||
"preact": "https://esm.sh/preact@10.10.0",
|
||||
"preact/": "https://esm.sh/preact@10.10.0/",
|
||||
"preact-render-to-string": "https://esm.sh/preact-render-to-string@5.2.1?external=preact"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"imports": {
|
||||
"$fresh/": "../../",
|
||||
"preact": "https://esm.sh/preact@10.8.2",
|
||||
"preact/": "https://esm.sh/preact@10.8.2/",
|
||||
"preact-render-to-string": "https://esm.sh/preact-render-to-string@5.2.0?external=preact"
|
||||
"preact": "https://esm.sh/preact@10.10.0",
|
||||
"preact/": "https://esm.sh/preact@10.10.0/",
|
||||
"preact-render-to-string": "https://esm.sh/preact-render-to-string@5.2.1?external=preact"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,7 @@ Deno.test({
|
||||
|
||||
let started = false;
|
||||
for await (const line of lines) {
|
||||
console.log(line);
|
||||
if (line.includes("Server listening on http://")) {
|
||||
if (line.includes("Listening on http://")) {
|
||||
started = true;
|
||||
break;
|
||||
}
|
||||
@@ -45,6 +44,7 @@ Deno.test({
|
||||
|
||||
const buttonPlus = await page.$(`#b-${counterId}`);
|
||||
await buttonPlus?.click();
|
||||
await delay(100);
|
||||
value = await pElem?.evaluate((el) => el.textContent);
|
||||
assert(value === `${originalValue + 1}`, `${counterId} click`);
|
||||
}
|
||||
|
||||
+4
-4
@@ -6,10 +6,10 @@
|
||||
"twind": "https://esm.sh/twind@0.16.17",
|
||||
"twind/": "https://esm.sh/twind@0.16.17/",
|
||||
|
||||
"preact": "https://esm.sh/preact@10.8.2",
|
||||
"preact/": "https://esm.sh/preact@10.8.2/",
|
||||
"preact-render-to-string": "https://esm.sh/preact-render-to-string@5.2.0?external=preact",
|
||||
"preact": "https://esm.sh/preact@10.10.0",
|
||||
"preact/": "https://esm.sh/preact@10.10.0/",
|
||||
"preact-render-to-string": "https://esm.sh/preact-render-to-string@5.2.1?external=preact",
|
||||
|
||||
"$semver/": "https://deno.land/x/semver@v1.4.0/"
|
||||
"$std/": "https://deno.land/std@0.150.0/"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import { RouteConfig } from "$fresh/server.ts";
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
import { parse } from "$semver/mod.ts";
|
||||
import { parse } from "$std/semver/mod.ts";
|
||||
import VERSIONS from "../../versions.json" assert { type: "json" };
|
||||
|
||||
const BASE_URL = "https://raw.githubusercontent.com/denoland/fresh/";
|
||||
@@ -11,7 +11,7 @@ export const handler: Handlers = {
|
||||
const isHTML = accept?.includes("text/html");
|
||||
const { version, path } = ctx.params;
|
||||
|
||||
const semver = parse(version, { includePrerelease: true, loose: false });
|
||||
const semver = parse(version, { includePrerelease: true });
|
||||
if (!semver) {
|
||||
return new Response("Invalid version", { status: 400 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user