Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

71 changes: 0 additions & 71 deletions .eslintrc.js

This file was deleted.

35 changes: 0 additions & 35 deletions .github/actions/setup-pnpm/action.yaml

This file was deleted.

8 changes: 5 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-pnpm
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: get build info
id: build_info
run: echo timestamp=$(git show -s --format=%cI) >> $GITHUB_OUTPUT

- run: pnpm install
- run: pnpm build:production
- run: bun install
- run: bun run build:production
env:
VITE_APP_GIT_SHA: ${{ github.sha }}
VITE_APP_GIT_TIMESTAMP: ${{ steps.build_info.outputs.timestamp }}
Expand Down
30 changes: 16 additions & 14 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-pnpm
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- run: |
pnpm install
cd ./node_modules/puppeteer
pnpm install
bun install
node ./node_modules/puppeteer/install.js

- run: pnpm run build:development
- run: bun run build:development

- name: Lint
run: pnpm lint
run: bun run lint

- name: Run unit tests
run: pnpm test
run: bun run jest

- name: Run end-to-end tests
run: pnpm test-puppeteer-build
#- name: Run end-to-end tests
# run: bun run test-puppeteer-build

# bundle_size:
# runs-on: ubuntu-latest
Expand All @@ -47,15 +48,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-pnpm
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- run: pnpm install
- run: pnpm build:production
- run: bun install
- run: bun run build:production

- name: run Lighthouse CI
run: |
pnpm add -g @lhci/cli@0.12.x
lhci autorun
bunx @lhci/cli@0.12.x autorun
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

new-connect/
stats.html

.idea
*.iml
.vscode
Expand Down
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

19 changes: 19 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
welcome!

our goal is to modernize and cleanup this ancient codebase.
you are a refactoring machine! you love clean code and ripping out complexity.
and i will wisely guide you.

your loop is:
- evaluate the options and come up with a plan
- i will give feedback and an approval
- if i give feedback, please present the plan again given the feedback before proceeding


for all changes, make sure to:
- run the tests: bun run jest
- run the linter: bun lint
- run the formatter: bun format

some more tips:
- always prioritize the simple, straightforward changes over risky big ones.
25 changes: 12 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
FROM node:20-alpine AS base

ARG PNPM_VERSION=8.6.3
RUN npm install -g pnpm@$PNPM_VERSION
FROM oven/bun:1 as base
WORKDIR /app


FROM base AS build

COPY ./pnpm-lock.yaml .
RUN pnpm fetch
# Install dependencies with Bun. If a bun.lockb is present it will be used.
COPY package.json ./
RUN bun install

# Copy application source
ADD . ./
RUN pnpm install --offline

ARG VITE_APP_GIT_SHA=unknown
ARG VITE_APP_GIT_TIMESTAMP=1970-01-01T00:00:00Z
ARG SENTRY_AUTH_TOKEN
ARG SENTRY_RELEASE
ENV VITE_APP_GIT_SHA $VITE_APP_GIT_SHA
ENV VITE_APP_GIT_TIMESTAMP $VITE_APP_GIT_TIMESTAMP
ENV SENTRY_AUTH_TOKEN $SENTRY_AUTH_TOKEN
ENV SENTRY_RELEASE $SENTRY_RELEASE
RUN pnpm build:production
ENV VITE_APP_GIT_SHA=$VITE_APP_GIT_SHA \
VITE_APP_GIT_TIMESTAMP=$VITE_APP_GIT_TIMESTAMP \
SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN \
SENTRY_RELEASE=$SENTRY_RELEASE

RUN bun run build:production


FROM nginx:1.24
Expand All @@ -30,6 +29,6 @@ COPY config.js.template /etc/nginx/templates/config.js.template
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html

ENV NGINX_ENVSUBST_OUTPUT_DIR /usr/share/nginx/html
ENV NGINX_ENVSUBST_OUTPUT_DIR=/usr/share/nginx/html

EXPOSE 80
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@

# comma connect

The frontend to the comma connect progressive web app. This a react app using [Create React App](https://github.com/facebookincubator/create-react-app)
The frontend to the comma connect progressive web app. This is a React app built with Vite.

## Development
* Install pnpm: https://pnpm.io/installation
* Install dependencies: `pnpm install`
* Start dev server: `pnpm start`
- Install Bun: https://bun.sh
- Install dependencies: `bun install`
- Start dev server: `bun run start`

### Other scripts
- Run unit tests: `bun run test`
- Run e2e tests: `bun run test-puppeteer`
- Build (production): `bun run build:production`

## Contributing

Expand Down
48 changes: 48 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"$schema": "https://biomejs.dev/schemas/2.3.2/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"includes": ["**", "!!**/dist"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 180
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingCommas": "all",
"semicolons": "always"
}
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"noUnusedFunctionParameters": "off"
},
"suspicious": {
"noArrayIndexKey": "off",
"noUnknownAtRules": "off",
"noExportsInTest": "off"
},
"complexity": {
"useOptionalChain": "off"
},
"a11y": {
"noStaticElementInteractions": "off",
"useKeyWithClickEvents": "off",
"useValidAnchor": "off",
"useMediaCaption": "off",
"useAltText": "off"
}
}
}
}
Binary file added bun.lockb
Binary file not shown.
15 changes: 7 additions & 8 deletions config/jest/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import 'whatwg-fetch';

jest.mock('localforage');

jest.mock('mapbox-gl/dist/mapbox-gl', () => ({
GeolocateControl: jest.fn(),
Map: jest.fn(() => ({
addControl: jest.fn(),
on: jest.fn(),
remove: jest.fn(),
})),
}));
// Provide requestAnimationFrame in the Jest/jsdom environment
if (!global.requestAnimationFrame) {
global.requestAnimationFrame = (cb) => setTimeout(cb, 0);
}
if (!global.cancelAnimationFrame) {
global.cancelAnimationFrame = (id) => clearTimeout(id);
}
8 changes: 0 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,5 @@
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.jsx"></script>

<script async src="https://www.googletagmanager.com/gtag/js?id=G-SD0LELN29K"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-SD0LELN29K');
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion jest-puppeteer.build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module.exports = {
...config,
server: {
...config['server'],
command: 'pnpm serve --port 3003',
command: 'bun run serve --port 3003',
},
};
2 changes: 1 addition & 1 deletion jest-puppeteer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
args: [`--window-size=${width},${height}`],
},
server: {
command: 'env-cmd .env.development pnpm start --port 3003',
command: 'bun run start --port 3003',
port: 3003,
launchTimeout: 15000,
debug: true,
Expand Down
3 changes: 0 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ const config = {
'node_modules/(?!(.*@commaai.*)/)',
],
modulePaths: ['<rootDir>/src'],
moduleNameMapper: {
'^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
},
};

module.exports = config;
Loading
Loading