Skip to content

Commit 5fbaa19

Browse files
committed
Upgrade the entire stack
- convert project to ESM - use Remix Vite plugin - use TS Project References feature so that the entire project works both in VS Code and that it can be type checked with a single tsc call - use Lefthook for defining git hooks, fixing staged files and defining custom commands - use SVG sprites instead of icon packages - craft our own ESLint config instead of using Remix config, this approach is recommended by the Remix team in their new templates - handle all MDX via Vite instead of custom scripts, taking advantage of the module system and Vite's glob import feature - implement Utterances ourselves to work the way we want, based on utterances-react-component - convert Cloudinary esbuild plugin to a Vite plugin - load Metronome via its Vite plugin - use native Date over date-fns - check code formatting on CI - use Vite's ?raw import for inlining contents of redirects file - prefer throwing redirects instead of returning them for easier TypeScript serialization
1 parent ab5ee5f commit 5fbaa19

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+9285
-10372
lines changed

.dockerignore

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
node_modules
22
*.log
33
.DS_Store
4-
.env
4+
5+
.env*.local
6+
57
/.cache
68
/build
7-
/public/build
8-
/app/posts
9+
10+
/test-results/
11+
/playwright-report/
12+
/blob-report/
13+
/playwright/.cache

.env

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CLOUDINARY_URL=
2+
SESSION_SECRET=
3+
GH_TOKEN=

.eslintignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
node_modules
2+
3+
/.cache
4+
/build
5+
6+
/test-results/
7+
/playwright-report/
8+
/blob-report/
9+
/playwright/.cache
10+
11+
!.server
12+
!.client
13+
14+
!.prettierrc.js

.eslintrc.cjs

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/** @type {import('@types/eslint').Linter.BaseConfig} */
2+
module.exports = {
3+
root: true,
4+
reportUnusedDisableDirectives: true,
5+
parserOptions: {
6+
ecmaVersion: 'latest',
7+
sourceType: 'module',
8+
},
9+
extends: ['eslint:recommended'],
10+
rules: {
11+
'no-var': 'error',
12+
'prefer-const': 'error',
13+
'no-warning-comments': 'warn',
14+
'no-use-before-define': ['error', { functions: false }],
15+
},
16+
overrides: [
17+
{
18+
files: ['.eslintrc.cjs'],
19+
env: { node: true },
20+
},
21+
{
22+
files: ['*.{ts,tsx}'],
23+
extends: ['plugin:@typescript-eslint/recommended'],
24+
parserOptions: {
25+
project: ['./tsconfig.app.json', './integration/tsconfig.json'],
26+
tsconfigRootDir: __dirname,
27+
},
28+
rules: {
29+
'no-use-before-define': 'off',
30+
'@typescript-eslint/no-unused-vars': [
31+
'error',
32+
{
33+
args: 'after-used',
34+
argsIgnorePattern: '^_',
35+
ignoreRestSiblings: true,
36+
},
37+
],
38+
'@typescript-eslint/no-floating-promises': 'error',
39+
},
40+
},
41+
{
42+
files: ['*.tsx'],
43+
extends: [
44+
'plugin:react/recommended',
45+
'plugin:react-hooks/recommended',
46+
'plugin:jsx-a11y/recommended',
47+
],
48+
settings: {
49+
react: {
50+
version: 'detect',
51+
},
52+
},
53+
rules: {
54+
'react/react-in-jsx-scope': 'off',
55+
},
56+
},
57+
{
58+
files: ['*.{test,spec}.{ts,tsx}'],
59+
extends: ['plugin:testing-library/react'],
60+
},
61+
{
62+
files: './integration/**/*.spec.ts',
63+
rules: {
64+
'testing-library/prefer-screen-queries': 'off',
65+
},
66+
},
67+
{
68+
files: ['**/*'],
69+
extends: ['prettier'],
70+
},
71+
],
72+
}

.eslintrc.js

-66
This file was deleted.

.github/workflows/deploy.yml

+62-30
Original file line numberDiff line numberDiff line change
@@ -16,45 +16,65 @@ permissions:
1616
contents: read
1717

1818
jobs:
19-
lint:
19+
prettier:
20+
name: Prettier
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout repo
24+
uses: actions/checkout@v4
25+
26+
- name: Setup Node
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: 18
30+
cache: npm
31+
32+
- name: Install dependencies
33+
run: npm ci
34+
35+
- name: Check formatting
36+
run: npm run pretty
37+
38+
eslint:
2039
name: ESLint
2140
runs-on: ubuntu-latest
2241
steps:
2342
- name: Checkout repo
2443
uses: actions/checkout@v4
2544

26-
- name: Setup node
45+
- name: Setup Node
2746
uses: actions/setup-node@v4
2847
with:
48+
node-version: 18
2949
cache: npm
30-
cache-dependency-path: ./package.json
31-
node-version-file: package.json
3250

33-
- name: Install deps
34-
run: npm install
51+
- name: Install dependencies
52+
run: npm ci
53+
54+
- name: Check config
55+
run: npm run lint:check-config
3556

3657
- name: Lint
3758
run: npm run lint
3859

39-
typecheck:
60+
typescript:
4061
name: TypeScript
4162
runs-on: ubuntu-latest
4263
steps:
4364
- name: Checkout repo
4465
uses: actions/checkout@v4
4566

46-
- name: Setup node
67+
- name: Setup Node
4768
uses: actions/setup-node@v4
4869
with:
70+
node-version: 18
4971
cache: npm
50-
cache-dependency-path: ./package.json
51-
node-version-file: package.json
5272

53-
- name: Install deps
54-
run: npm install
73+
- name: Install dependencies
74+
run: npm ci
5575

56-
- name: Type check
57-
run: npm run typecheck --if-present
76+
- name: Check types
77+
run: npm run typecheck
5878

5979
vitest:
6080
name: Vitest
@@ -63,23 +83,22 @@ jobs:
6383
- name: Checkout repo
6484
uses: actions/checkout@v4
6585

66-
- name: Setup node
86+
- name: Setup Node
6787
uses: actions/setup-node@v4
6888
with:
89+
node-version: 18
6990
cache: npm
70-
cache-dependency-path: ./package.json
71-
node-version-file: package.json
7291

73-
- name: Install deps
74-
run: npm install
92+
- name: Install dependencies
93+
run: npm ci
7594

7695
- name: Compile posts
7796
run: npm run build:posts
7897
env:
7998
CLOUDINARY_URL: ${{ secrets.CLOUDINARY_URL }}
8099

81-
- name: Run vitest
82-
run: npm run test:unit -- --coverage
100+
- name: Run tests
101+
run: npm run test:unit
83102
env:
84103
CLOUDINARY_URL: ${{ secrets.CLOUDINARY_URL }}
85104

@@ -91,25 +110,38 @@ jobs:
91110
- name: Checkout repo
92111
uses: actions/checkout@v4
93112

94-
- name: Setup node
113+
- name: Setup Node
95114
uses: actions/setup-node@v4
96115
with:
116+
node-version: 18
97117
cache: npm
98-
cache-dependency-path: ./package.json
99-
node-version-file: package.json
100118

101-
- name: Install deps
102-
run: npm install
119+
- name: Install dependencies
120+
run: npm ci
121+
122+
- name: Add environment variables
123+
run: |
124+
echo "NODE_VERSION=$(node --version)" >> $GITHUB_ENV
125+
npm list @playwright/test --depth=0 --json > npm-list-playwright.json
126+
echo "PLAYWRIGHT_VERSION=$(node --print "require('./npm-list-playwright.json').dependencies['@playwright/test'].version")" >> $GITHUB_ENV
127+
128+
- name: Cache binaries
129+
uses: actions/cache@v3
130+
id: playwright-cache
131+
with:
132+
path: ~/.cache/ms-playwright
133+
key: os-${{ runner.os }}-node-${{ env.NODE_VERSION }}-playwright-v${{ env.PLAYWRIGHT_VERSION }}
103134

104-
- name: Install Playwright Browsers
135+
- name: Install browsers
136+
if: steps.playwright-cache.outputs.cache-hit != 'true'
105137
run: npx playwright install --with-deps
106138

107-
- name: Build
139+
- name: Build app
108140
run: npm run build
109141
env:
110142
CLOUDINARY_URL: ${{ secrets.CLOUDINARY_URL }}
111143

112-
- name: Playwright run
144+
- name: Run tests
113145
run: npm run test:e2e
114146
env:
115147
CLOUDINARY_URL: ${{ secrets.CLOUDINARY_URL }}
@@ -125,7 +157,7 @@ jobs:
125157
deploy:
126158
name: Deploy
127159
runs-on: ubuntu-latest
128-
needs: [lint, typecheck, vitest, playwright]
160+
needs: [prettier, eslint, typescript, vitest, playwright]
129161
# only deploy main/dev branch on pushes
130162
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}
131163

.gitignore

+6-8
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@ node_modules
55
.DS_Store
66

77
# text editors
8-
.vscode/*
9-
!.vscode/launch.json
108
.idea
119

1210
# secrets
13-
.env
11+
.env*.local
1412

1513
# build
14+
/.cache
1615
/build
17-
/public/build
18-
/app/posts
19-
/coverage
20-
tsconfig.tsbuildinfo
16+
17+
# Playwright
2118
/test-results/
2219
/playwright-report/
23-
/playwright/.cache/
20+
/blob-report/
21+
/playwright/.cache

.prettierignore

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
node_modules
22

3+
/.cache
34
/build
4-
/public/build
5-
/app/posts
6-
/coverage
75
/playwright-report
86

97
package-lock.json
108

11-
.env
12-
139
# Prettier doesn't yet play nice with MDX v2, for example it can't keep JSX
1410
# in a single line if it exceeds print width, which results in a nested <p>
1511
*.mdx
@@ -22,6 +18,3 @@ package-lock.json
2218
*.yaml
2319

2420
README.md
25-
26-
# tsconfig.json supports trailing commas, but Prettier doesn't know that
27-
tsconfig.json

0 commit comments

Comments
 (0)