Skip to content

Commit 2057083

Browse files
committed
migrate to workers assets
1 parent 296b64d commit 2057083

File tree

16 files changed

+225
-84
lines changed

16 files changed

+225
-84
lines changed

.eslintrc.cjs

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**
2+
* This is intended to be a basic starting point for linting in your app.
3+
* It relies on recommended configs out of the box for simplicity, but you can
4+
* and should modify this configuration to best suit your team's needs.
5+
*/
6+
7+
/** @type {import('eslint').Linter.Config} */
8+
module.exports = {
9+
root: true,
10+
parserOptions: {
11+
ecmaVersion: 'latest',
12+
sourceType: 'module',
13+
ecmaFeatures: {
14+
jsx: true,
15+
},
16+
},
17+
env: {
18+
browser: true,
19+
commonjs: true,
20+
es6: true,
21+
},
22+
23+
// Base config
24+
extends: ['eslint:recommended'],
25+
26+
overrides: [
27+
// React
28+
{
29+
files: ['**/*.{js,jsx,ts,tsx}'],
30+
plugins: ['react', 'jsx-a11y'],
31+
extends: [
32+
'plugin:react/recommended',
33+
'plugin:react/jsx-runtime',
34+
'plugin:react-hooks/recommended',
35+
'plugin:jsx-a11y/recommended',
36+
],
37+
settings: {
38+
react: {
39+
version: 'detect',
40+
},
41+
formComponents: ['Form'],
42+
linkComponents: [
43+
{ name: 'Link', linkAttribute: 'to' },
44+
{ name: 'NavLink', linkAttribute: 'to' },
45+
],
46+
'import/resolver': {
47+
typescript: {},
48+
},
49+
},
50+
},
51+
52+
// Typescript
53+
{
54+
files: ['**/*.{ts,tsx}'],
55+
plugins: ['@typescript-eslint', 'import'],
56+
parser: '@typescript-eslint/parser',
57+
settings: {
58+
'import/internal-regex': '^~/',
59+
'import/resolver': {
60+
node: {
61+
extensions: ['.ts', '.tsx'],
62+
},
63+
typescript: {
64+
alwaysTryTypes: true,
65+
},
66+
},
67+
},
68+
extends: [
69+
'plugin:@typescript-eslint/recommended',
70+
'plugin:import/recommended',
71+
'plugin:import/typescript',
72+
],
73+
},
74+
75+
// Node
76+
{
77+
files: ['.eslintrc.cjs'],
78+
env: {
79+
node: true,
80+
},
81+
},
82+
],
83+
};

.eslintrc.json

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

LICENSE renamed to .github/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Edmund Hung
3+
Copyright (c) 2024 Edmund Hung
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- name: ⎔ Setup node
1212
uses: actions/setup-node@v3
1313
with:
14-
node-version: 18
14+
node-version: 20
1515
- name: 📥 Download deps
1616
uses: bahmutov/npm-install@v1
1717
with:
@@ -21,7 +21,7 @@ jobs:
2121
- name: 📦 Prepare the environment
2222
run: cp .dev.vars.example .dev.vars
2323
- name: 💣 Run some tests
24-
run: npx playwright test
24+
run: npm run test
2525

2626
lint:
2727
name: ⬣ Linting
@@ -32,12 +32,12 @@ jobs:
3232
- name: ⎔ Setup node
3333
uses: actions/setup-node@v3
3434
with:
35-
node-version: 18
35+
node-version: 20
3636
- name: 📥 Download deps
3737
uses: bahmutov/npm-install@v1
3838
with:
3939
useLockFile: false
4040
- name: ✨ Code format check
41-
run: npx prettier --check .
41+
run: npm run format -- --check .
4242
- name: ✅ Code linting
43-
run: npx eslint . --ext .js,.mjs,.ts,.tsx
43+
run: npm run lint

.node-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ npx create-remix@latest --template edmundhung/remix-cloudflare-template
99
What's included?
1010

1111
- Development with [Vite](https://vitejs.dev)
12-
- [Github Actions](https://github.com/features/actions) for CI/CD
12+
- Hosting on [Cloudflare Workers](https://developers.cloudflare.com/workers/)
13+
with [Static Assets](https://developers.cloudflare.com/workers/static-assets/)
14+
- [Github Actions](https://github.com/features/actions) for continuous
15+
integration
16+
- Automatic builds and deployments with
17+
[Workers Build](https://developers.cloudflare.com/workers/ci-cd/builds/)
1318
- [Markdoc](https://markdoc.dev) for rendering markdown
1419
- Styling with [Tailwind](https://tailwindcss.com/)
1520
- End-to-end testing with [Playwright](https://playwright.dev/)
@@ -86,7 +91,7 @@ You can generate the types of the `env` object based on `wrangler.toml` and
8691
`.dev.vars` with:
8792

8893
```sh
89-
npx wrangler types
94+
npm run typegen
9095
```
9196

9297
## Deployment

app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export function MainNavigation({ menus }: { menus: Menu[] }) {
105105
</header>
106106
<div className="-ml-5 flex-1 space-y-4 overflow-y-auto">
107107
{menus.map(menu => (
108-
<div key={menu.title} className="px-2 ">
108+
<div key={menu.title} className="px-2">
109109
<div className="sticky top-0 bg-white pb-2 pl-5 font-bold">
110110
{menu.title}
111111
</div>

functions/[[path]].ts

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

load-context.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
import type { PlatformProxy } from 'wrangler';
2-
3-
// You can generate the ENV type based on `wrangler.toml` and `.dev.vars`
4-
// by running `npm run typegen`
5-
type Cloudflare = Omit<PlatformProxy<Env>, 'dispose'>;
6-
type LoadContext = {
7-
cloudflare: Cloudflare;
8-
};
1+
import { type PlatformProxy } from 'wrangler';
92

103
declare module '@remix-run/cloudflare' {
11-
interface AppLoadContext {
12-
env: Cloudflare['env'];
13-
cf: Cloudflare['cf'];
14-
ctx: Cloudflare['ctx'];
15-
cache: Cloudflare['caches'];
4+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
5+
interface AppLoadContext extends ReturnType<typeof getLoadContext> {
6+
// This will merge the result of `getLoadContext` into the `AppLoadContext`
167
}
178
}
189

1910
export function getLoadContext({
2011
context,
2112
}: {
2213
request: Request;
23-
context: LoadContext;
14+
context: {
15+
cloudflare: Omit<
16+
PlatformProxy<Env, IncomingRequestCfProperties>,
17+
'dispose' | 'caches'
18+
> & {
19+
caches:
20+
| PlatformProxy<Env, IncomingRequestCfProperties>['caches']
21+
| CacheStorage;
22+
};
23+
};
2424
}) {
2525
return {
2626
env: context.cloudflare.env,

0 commit comments

Comments
 (0)