Skip to content

Commit d342ff8

Browse files
committed
Upgrade to @udibo/[email protected]
1 parent d0e7529 commit d342ff8

30 files changed

+1405
-439
lines changed

.github/workflows/main.yml

100755100644
File mode changed.

.vscode/launch.json

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"--inspect-wait"
3232
],
3333
"env": {
34-
"APP_ENV": "production"
34+
"APP_ENV": "production",
35+
"NODE_ENV": "production"
3536
},
3637
"attachSimplePort": 9229
3738
},
@@ -48,7 +49,26 @@
4849
"--inspect-wait"
4950
],
5051
"env": {
51-
"APP_ENV": "test"
52+
"APP_ENV": "test",
53+
"NODE_ENV": "development"
54+
},
55+
"attachSimplePort": 9229
56+
},
57+
{
58+
"request": "launch",
59+
"name": "deno task: dev",
60+
"type": "node",
61+
"program": "${workspaceFolder}/dev.ts",
62+
"cwd": "${workspaceFolder}",
63+
"runtimeExecutable": "deno",
64+
"runtimeArgs": [
65+
"run",
66+
"-A",
67+
"--inspect-wait"
68+
],
69+
"env": {
70+
"APP_ENV": "development",
71+
"NODE_ENV": "development"
5272
},
5373
"attachSimplePort": 9229
5474
}

.vscode/settings.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
"deno.lint": true,
44
"deno.unstable": false,
55
"deno.config": "./deno.jsonc",
6-
"deno.importMap": "./import_map.json",
7-
"deno.suggest.imports.hosts": {
8-
"https://deno.land": true
9-
},
6+
"editor.formatOnSave": true,
7+
"editor.defaultFormatter": "denoland.vscode-deno",
108
"editor.quickSuggestions": {
119
"strings": true
1210
}

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,29 @@ To run the tests, use `deno task test` or `deno task test-watch`.
2929

3030
To check formatting and run lint, use `deno task check`.
3131

32-
To create a build and to run the build, use `deno task build` and
33-
`deno task run`. By default, the application builds and runs in development
34-
mode. To build and run a production build, set the `APP_ENV` environment
35-
variable to `production`.
32+
The following 2 commands can be used for creating builds.
33+
34+
- `deno task build-dev`: Builds the application in development mode.
35+
- `deno task build-prod`: Builds the application in production mode.
36+
37+
A build must be generated before you can run an application. You can use the
38+
following 2 commands to run the application.
39+
40+
- `deno task run-dev`: Runs the application in development mode.
41+
- `deno task run-prod`: Runs the application in production mode.
3642

3743
To run the application in development mode with live reloading, use
3844
`deno task dev`.
3945

4046
When in development, identifiers are not minified and sourcemaps are generated
4147
and linked.
4248

49+
The commands ending in `-dev` and `-prod` set the `APP_ENV` and `NODE_ENV`
50+
environment variables. The `NODE_ENV` environment variable is needed for react.
51+
If you use the `deno task build` or `deno task run` tasks, you should make sure
52+
that you set both of those environment variables. Those environment variables
53+
are also needed if you deploy to Deno Deploy.
54+
4355
## Contributing
4456

4557
To contribute, please read the [contributing instruction](CONTRIBUTING.md).

app.tsx

Lines changed: 0 additions & 5 deletions
This file was deleted.

components/loading.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { assertEquals } from "@std/assert";
2+
import { describe, it } from "@std/testing/bdd";
3+
4+
import { render } from "../test-utils.tsx";
5+
6+
import { Loading } from "./loading.tsx";
7+
8+
const loadingTests = describe("Loading component");
9+
10+
it(loadingTests, "renders loading message", () => {
11+
using screen = render(<Loading />);
12+
assertEquals(screen.getByText("Loading...").textContent, "Loading...");
13+
});

components/loading.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export const Loading = () => <div>Loading...</div>;
1+
export function Loading() {
2+
return <div>Loading...</div>;
3+
}

data/posts.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { Post } from "../models/posts.ts";
2+
3+
export const posts: { [id: number]: Post } = {
4+
0: {
5+
id: 0,
6+
title: "My first post",
7+
content: "This is my first post.",
8+
},
9+
1: {
10+
id: 1,
11+
title: "My second post",
12+
content: "This is my second post.",
13+
},
14+
};

deno.jsonc

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,60 @@
11
{
22
"tasks": {
3-
"build": "deno run -A --import-map=./import_map.json https://deno.land/x/[email protected]/build.ts",
3+
// Builds the application.
4+
"build": "deno run -A --config=deno.jsonc jsr:@udibo/[email protected]/build",
5+
// Builds the application in development mode.
6+
"build-dev": "export APP_ENV=development NODE_ENV=development && deno task build",
7+
// Builds the application in production mode.
8+
"build-prod": "export APP_ENV=production NODE_ENV=production && deno task build",
9+
// Builds and runs the application in development mode, with hot reloading.
10+
"dev": "export APP_ENV=development NODE_ENV=development && deno run -A --config=deno.jsonc jsr:@udibo/[email protected]/dev",
11+
// Runs the application. Requires the application to be built first.
412
"run": "deno run -A ./main.ts",
5-
"dev": "deno run -A --import-map=./import_map.json https://deno.land/x/[email protected]/dev.ts",
6-
"test": "export APP_ENV=test && deno test -A .",
7-
"test-watch": "export APP_ENV=test && deno test -A --watch .",
13+
// Runs the application in development mode. Requires the application to be built first.
14+
"run-dev": "export APP_ENV=development NODE_ENV=development && deno task run",
15+
// Runs the application in production mode. Requires the application to be built first.
16+
"run-prod": "export APP_ENV=production NODE_ENV=production && deno task run",
17+
// Runs the tests.
18+
"test": "export APP_ENV=test NODE_ENV=development && deno test -A --trace-leaks",
19+
// Runs the tests in watch mode.
20+
"test-watch": "export APP_ENV=test NODE_ENV=development && deno test -A --trace-leaks --watch",
21+
// Checks the formatting and runs the linter.
822
"check": "deno lint && deno fmt --check",
9-
"cache-reload": "deno cache --reload main.ts && deno cache --reload --import-map=./import_map.json https://deno.land/x/[email protected]/dev.ts",
23+
// Gets your branch up to date with master after a squash merge.
1024
"git-rebase": "git fetch origin main && git rebase --onto origin/main HEAD"
1125
},
1226
"compilerOptions": {
1327
"lib": ["esnext", "dom", "dom.iterable", "dom.asynciterable", "deno.ns"],
1428
"jsx": "react-jsx",
15-
"jsxImportSource": "npm/react"
29+
"jsxImportSource": "react",
30+
"jsxImportSourceTypes": "@types/react"
1631
},
1732
"lint": {
18-
"exclude": ["public/build"]
33+
"exclude": ["public/build", "routes/_main.ts", "routes/_main.tsx"]
1934
},
2035
"fmt": {
2136
"exclude": ["public/build"]
2237
},
23-
"importMap": "./import_map.json"
38+
"imports": {
39+
"@udibo/http-error": "jsr:@udibo/http-error@0",
40+
"@udibo/react-app": "jsr:@udibo/[email protected]",
41+
"@luca/esbuild-deno-loader": "jsr:@luca/[email protected]",
42+
"@oak/oak": "jsr:@oak/oak@16",
43+
"@std/assert": "jsr:@std/assert@1",
44+
"@std/async": "jsr:@std/async@1",
45+
"@std/fs": "jsr:@std/fs@0",
46+
"@std/log": "jsr:@std/log@0",
47+
"@std/path": "jsr:@std/path@1",
48+
"@std/testing": "jsr:@std/testing@0",
49+
"esbuild": "npm:[email protected]",
50+
"react": "npm:react@18",
51+
"@types/react": "npm:@types/react@18",
52+
"react-dom": "npm:react-dom@18",
53+
"react-error-boundary": "npm:react-error-boundary@4",
54+
"react-router-dom": "npm:react-router-dom@6",
55+
"react-helmet-async": "npm:react-helmet-async@2",
56+
"serialize-javascript": "npm:serialize-javascript@6",
57+
"@testing-library/react": "npm:@testing-library/react@16",
58+
"global-jsdom": "npm:global-jsdom@24"
59+
}
2460
}

0 commit comments

Comments
 (0)