Skip to content

Commit

Permalink
chore: upgrade to Fresh 2 (#558)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacasonato authored Nov 8, 2024
1 parent 563c08a commit 44146b0
Show file tree
Hide file tree
Showing 82 changed files with 3,012 additions and 2,153 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ making changes to the API.

### Running jsr

1. `deno task services:macos`, `deno task services:macos:amd` or `deno task services:linux` in one terminal
1. `deno task services:macos`, `deno task services:macos:amd` or
`deno task services:linux` in one terminal
2. `deno task dev:api` in another terminal
3. `deno task dev:frontend` in another terminal

Expand All @@ -135,10 +136,12 @@ registry with data is to publish
[deno_std](https://github.com/denoland/deno_std) to the registry. This can be
done via the following steps:

1. Make sure to [make yourself a staff user/admin](#making-yourself-a-staff-useradmin).
1. Make sure to
[make yourself a staff user/admin](#making-yourself-a-staff-useradmin).
2. Navigate to your profile page and copy the UUID from the URL.
3. Assign the `std` scope to your user through the [admin panel](http://jsr.test/admin/scopes/assign)
by using the UUID from the previous step.
3. Assign the `std` scope to your user through the
[admin panel](http://jsr.test/admin/scopes/assign) by using the UUID from the
previous step.
4. Clone https://github.com/denoland/deno_std in the same parent folder as the
`jsr` project.
5. Run `JSR_URL=http://jsr.test deno publish` to publish all of the @std
Expand Down
20 changes: 6 additions & 14 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"services:linux": "docker compose up & ./tools/bin/linux-amd64/fake-gcs-server -scheme http -port 4080 -filesystem-root=.gcs & ./tools/server.ts",
"services:linux-no-postgres": "docker compose up jaeger & ./tools/bin/linux-amd64/fake-gcs-server -scheme http -port 4080 -filesystem-root=.gcs & ./tools/server.ts",
"dev:api": "cd api && cargo run",
"dev:frontend": "cd frontend && OLTP_ENDPOINT=http://localhost:4318 deno task start",
"prod:frontend": "deno run -A --watch ./tools/prod_proxy.ts & cd frontend && API_ROOT=https://api.jsr.io deno task start",
"dev:frontend": "cd frontend && OLTP_ENDPOINT=http://localhost:4318 deno task dev",
"prod:frontend": "deno run -A --watch ./tools/prod_proxy.ts & cd frontend && API_ROOT=https://api.jsr.io deno task dev",
"lint": "deno task lint:frontend && deno task lint:license",
"lint:frontend": "cd frontend && deno lint && deno check --allow-import=googleapis.deno.dev,deno.land,jsr.io,esm.sh main.ts",
"lint:frontend": "cd frontend && deno lint && deno check --allow-import=googleapis.deno.dev,deno.land,jsr.io dev.ts main.ts routes/**/*.tsx routes/**/*.ts",
"lint:license": "deno run --allow-read jsr:@kt3k/[email protected]/main -q",
"lint:license:fix": "deno run --allow-read --allow-write jsr:@kt3k/[email protected]/main -q --inject",
"tools:orama:package_reindex": "deno run --allow-env --allow-net tools/orama_package_reindex.ts",
Expand All @@ -34,15 +34,7 @@
"target/",
"api/testdata/",
".gcs/",
"frontend/_fresh"
],
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "npm:preact"
},
"imports": {
"@deno/gfm": "jsr:@deno/gfm@^0.8.0",
"github-slugger": "npm:github-slugger@^2.0",
"std/": "https://deno.land/[email protected]/"
}
"frontend/_fresh",
"e2e/vendor"
]
}
509 changes: 1 addition & 508 deletions deno.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM denoland/deno:alpine-2.0.3
FROM denoland/deno:alpine-2.0.5

WORKDIR /app
RUN mkdir /deno_dir
ENV DENO_DIR /deno_dir

COPY . .

RUN deno task build
RUN deno cache --allow-import main.ts
RUN deno install --allow-import -e main.ts

RUN timeout 10s deno run -A main.ts || [ $? -eq 124 ] || exit 1

CMD ["run", "-A", "--cached-only", "main.ts"]
16 changes: 0 additions & 16 deletions frontend/README.md

This file was deleted.

8 changes: 3 additions & 5 deletions frontend/components/HomepageHero.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2024 the JSR authors. All rights reserved. MIT license.
import { asset, Head } from "$fresh/runtime.ts";
import { asset } from "fresh/runtime";
import { GlobalSearch } from "../islands/GlobalSearch.tsx";
import { HomepageHeroParticles } from "../islands/HomepageHeroParticles.tsx";
import { AnimatedLogo } from "./AnimatedLogo.tsx";
Expand Down Expand Up @@ -28,11 +28,9 @@ export function HomepageHero(
class="w-screen -ml-[calc(50vw-50%)] -mt-6 bg-repeat py-32 lg:pt-48 relative before:absolute before:left-0 before:right-0 before:h-32 before:bg-gradient-to-t before:from-white before:bottom-0 before:z-10 before:pointer-events-none"
id="particles-js"
>
<HomepageHeroParticles />
<Head>
<script src={asset("/scripts/particles.js")} defer></script>
</Head>
<script src={asset("/scripts/particles.js")} defer></script>
<style>{canvasStyle}</style>
<HomepageHeroParticles />
<div class="section-x-inset-xl flex flex-col items-center justify-center gap-12 relative pointer-events-none">
<div class="text-center">
<h1 class="relative z-10 flex flex-col items-center gap-6 lg:gap-8">
Expand Down
17 changes: 2 additions & 15 deletions frontend/components/List.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2024 the JSR authors. All rights reserved. MIT license.
import { PaginationData } from "../util.ts";
import { Head } from "$fresh/src/runtime/head.ts";
import { ChevronRight } from "./icons/ChevronRight.tsx";
import { ComponentChildren } from "preact";

Expand Down Expand Up @@ -78,18 +77,6 @@ function Pagination(
class="flex items-center justify-between border-t border-jsr-cyan-900/10 bg-white px-4 py-3 sm:px-6"
aria-label="Pagination"
>
<Head>
{hasPrevious && (
<link rel="prev" href={prevURL.pathname + prevURL.search} />
)}
{hasNext && (
<link
rel="next"
href={nextURL.pathname + nextURL.search}
/>
)}
</Head>

<div class="hidden sm:block">
<p class="text-sm text-jsr-gray-700">
{start + itemsCount === 0 ? "No results found" : (
Expand All @@ -103,7 +90,7 @@ function Pagination(
</p>
</div>
<div class="flex flex-1 justify-between sm:justify-end">
{pagination.page > 1
{hasPrevious
? (
<a
href={prevURL.pathname + prevURL.search}
Expand All @@ -113,7 +100,7 @@ function Pagination(
</a>
)
: <span />}
{itemsCount >= pagination.limit
{hasNext
? (
<a
href={nextURL.pathname + nextURL.search}
Expand Down
16 changes: 8 additions & 8 deletions frontend/components/Markdown.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright 2024 the JSR authors. All rights reserved. MIT license.
import { Marked, render } from "$gfm";
import { markedSmartypants } from "$marked-smartypants";
import { Marked, render } from "@deno/gfm";
import { markedSmartypants } from "marked-smartypants";

import "https://esm.sh/prismjs@1.29.0/components/prism-json?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-typescript?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-jsx?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-tsx?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-bash?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-diff?no-check";
import "prismjs/components/prism-json.js";
import "prismjs/components/prism-typescript.js";
import "prismjs/components/prism-jsx.js";
import "prismjs/components/prism-tsx.js";
import "prismjs/components/prism-bash.js";
import "prismjs/components/prism-diff.js";

Marked.marked.use(markedSmartypants());

Expand Down
13 changes: 0 additions & 13 deletions frontend/components/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2024 the JSR authors. All rights reserved. MIT license.

import { ComponentChild, ComponentChildren } from "preact";
import { Head } from "$fresh/runtime.ts";
import { ChevronLeft } from "./icons/ChevronLeft.tsx";
import { ChevronRight } from "./icons/ChevronRight.tsx";
import { PaginationData } from "../util.ts";
Expand Down Expand Up @@ -80,18 +79,6 @@ function Pagination(

return (
<div class="flex items-center gap-3 text-jsr-gray-700">
<Head>
{hasPrevious && (
<link rel="prev" href={prevURL.pathname + prevURL.search} />
)}
{hasNext && (
<link
rel="next"
href={nextURL.pathname + nextURL.search}
/>
)}
</Head>

{hasPrevious && (
<a
href={prevURL.pathname + prevURL.search}
Expand Down
66 changes: 39 additions & 27 deletions frontend/deno.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,62 @@
{
"lock": false,
"nodeModulesDir": "auto",
"tasks": {
"check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
"start": "deno run -A --watch=static/,routes/ dev.ts",
"dev": "deno run -A --watch=static/,routes/ dev.ts",
"build": "deno run -A dev.ts build",
"preview": "deno run -A main.ts",
"update": "deno run -A -r https://fresh.deno.dev/update ."
"start": "deno run -A main.ts",
"update": "deno run -A -r jsr:@fresh/update ."
},
"lint": {
"rules": {
"tags": [
"fresh",
"recommended"
]
"tags": ["fresh", "recommended"]
}
},
"imports": {
"$fresh/": "https://deno.land/x/[email protected]/",
"preact": "npm:[email protected]",
"fresh": "jsr:@fresh/core@^2.0.0-alpha.25",
"@fresh/plugin-tailwind": "jsr:@fresh/plugin-tailwind@^0.0.1-alpha.7",

"preact": "npm:preact@^10",
"preact-render-to-string": "npm:[email protected]",
"@preact/signals": "npm:@preact/[email protected]",
"@preact/signals-core": "npm:@preact/[email protected]",
"$std/path": "jsr:@std/path@1",
"$std/http": "jsr:@std/http@1",
"$std/front-matter": "jsr:@std/front-matter@1",
"$std/semver": "jsr:@std/semver@1",
"$std/": "https://deno.land/[email protected]/",
"$twas": "npm:[email protected]",
"$gfm": "jsr:@deno/[email protected]",
"$oak_commons": "https://deno.land/x/[email protected]/negotiation.ts",
"$marked-smartypants": "npm:[email protected]",

"@std/path": "jsr:@std/path@1",
"@std/http": "jsr:@std/http@1",
"@std/front-matter": "jsr:@std/front-matter@1",
"@std/semver": "jsr:@std/semver@1",

"twas": "npm:twas@^2.1.3",
"$tabler_icons/": "https://deno.land/x/[email protected]/tsx/",
"$imagescript": "https://deno.land/x/[email protected]/mod.ts",

"@deno/gfm": "jsr:@deno/[email protected]",
"marked-smartypants": "npm:[email protected]",
"prismjs": "npm:prismjs@^1.29.0",

"@orama/orama": "npm:@orama/orama@^2",
"@orama/highlight": "npm:@orama/highlight@^0.1",
"@orama/highlight": "npm:@orama/highlight@^0.1.8",
"@oramacloud/client": "npm:@oramacloud/client@^1",

"tailwindcss": "npm:[email protected]",
"postcss": "npm:[email protected]"
},
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
"lib": [
"dom",
"dom.iterable",
"dom.asynciterable",
"deno.ns"
],
"jsx": "precompile",
"jsxImportSource": "preact",
"jsxPrecompileSkipElements": [
"a",
"img",
"source",
"body",
"html",
"head"
]
},
"exclude": [
"_fresh/",
"**/_fresh/*"
]
"exclude": ["_fresh/", "**/_fresh/*"]
}
Loading

0 comments on commit 44146b0

Please sign in to comment.