Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Do Not Merge] Try out bun #244

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ vendor.bundle.js
bundle.js.map
dist/
yarn-error.log
src/app/public/data
src/app/data

# Bundled JS
src/app/build
Expand Down
11 changes: 5 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,20 @@ services:
retries: 6

app:
image: node:18-slim
image: oven/bun:1
stdin_open: true
working_dir: /usr/local/src
environment:
- REACT_APP_GIT_COMMIT=${REACT_APP_GIT_COMMIT:-latest}
- VITE_GIT_COMMIT=${VITE_GIT_COMMIT:-latest}
- CHOKIDAR_USEPOLLING=true
- CHOKIDAR_INTERVAL=100
- PORT=4545
- NODE_OPTIONS=--openssl-legacy-provider
volumes:
- ./src/app:/usr/local/src
- ./src/django/static:/usr/local/src/build
- ./src/django/static:/usr/local/src/dist
# Ensure node_modules cache doesn't clash with other jobs on CI.
- node-modules-volume:/usr/local/src/node_modules
command: yarn start
# - node-modules-volume:/usr/local/src/node_modules
command: bun start

django:
image: iow-django
Expand Down
4 changes: 2 additions & 2 deletions scripts/yarn → scripts/bun
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fi
function usage() {
echo -n \
"Usage: $(basename "$0")
Execute Yarn CLI commands.
Execute Bun CLI commands.
"
}

Expand All @@ -19,6 +19,6 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
else
docker-compose \
run --rm --no-deps --entrypoint "bash -c" app \
"yarn ${*:1}"
"bun ${*:1}"
fi
fi
4 changes: 2 additions & 2 deletions scripts/format
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# Disable "double quote to prevent globbing and word splitting"
# ${changed_files} is a list that needs to be split on words
# ${changed_files} is a list that needs to be split on words
# shellcheck disable=SC2086

set -e
Expand All @@ -22,7 +22,7 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
else
# Format JavaScript app
docker-compose \
run --rm --no-TTY --entrypoint yarn app \
run --rm --no-TTY app \
prettier --loglevel warn --write src/

# Format Django app
Expand Down
8 changes: 2 additions & 6 deletions scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
scripts/*

# Lint JavaScript
docker-compose \
run --rm --entrypoint yarn app prettier --check src/

docker-compose \
run --rm --entrypoint ./node_modules/.bin/eslint \
app src/ --ext .js --ext .jsx
./scripts/bun run prettier --check src/
./scripts/bun run eslint src/ --ext .js --ext .jsx

if [[ -n "${CI}" ]]; then
# Lint Django app
Expand Down
6 changes: 3 additions & 3 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ function test_django_ci() {
function test_app() {
docker-compose \
run --rm --no-deps app \
yarn test --watchAll=false
bun test --watchAll=false
}

function test_app_watch() {
docker-compose \
run --rm --no-deps app \
yarn test
bun test
}

function test_app_ci() {
docker-compose \
run --rm --no-deps -e CI app \
yarn test --watchAll=false
bun test --watchAll=false
}

if [[ ${BASH_SOURCE[0]} == "${0}" ]]; then
Expand Down
8 changes: 5 additions & 3 deletions scripts/update
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
# Ensure container images are current
docker-compose build

# Update Yarn dependencies
# Update Bun dependencies
docker-compose \
run --rm --no-deps app \
yarn install
bun install

# Build static asset bundle for React frontend
docker-compose \
run --rm --no-deps app \
yarn run build
bun run build

# Bring up PostgreSQL and Django in a way that respects
# configured service health checks.
Expand All @@ -38,5 +38,7 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then

# Collect Django static files
./scripts/manage collectstatic --no-input

docker-compose stop
fi
fi
2 changes: 2 additions & 0 deletions src/app/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.jpg
*.png
Binary file added src/app/bun.lockb
Binary file not shown.
19 changes: 0 additions & 19 deletions src/app/craco.config.js

This file was deleted.

File renamed without changes.
File renamed without changes.
18 changes: 5 additions & 13 deletions src/app/public/index.html → src/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,27 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="iow-boundary-tool"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="apple-touch-icon" href="/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<link rel="manifest" href="/manifest.json" />
<title>Boundary Sync</title>
<!-- Initialize Environment Variables -->
<script src="%PUBLIC_URL%/web/environment.js"></script>
<script src="/web/environment.js"></script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.jsx"></script>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes.
17 changes: 8 additions & 9 deletions src/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@
"react-redux": "^8.0.2",
"react-router": "^6.3.0",
"react-router-dom": "^6.3.0",
"react-scripts": "^5.0.1",
"react-use": "^17.3.2",
"redux": "^4.2.0",
"redux-logger": "^3.0.6"
},
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test"
"start": "vite",
"build": "vite build",
"test": "vite test"
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -60,10 +59,10 @@
]
},
"devDependencies": {
"@babel/core": "^7.17.12",
"@craco/craco": "^6.4.3",
"babel-jest": "28.1.0",
"prettier": "^2.6.2",
"prettier-loader": "^3.3.0"
"@vitejs/plugin-react": "^4.0.4",
"eslint": "^8.25.0",
"eslint-config-react-app": "^7.0.1",
"prettier": "^3.0.3",
"vite": "^4.4.9"
}
}
File renamed without changes.
6 changes: 4 additions & 2 deletions src/app/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@
font-weight: bold;
font-size: var(--chakra-fontSizes-sm);
color: var(--chakra-colors-purple-900);
text-shadow: 0 0 0.2em var(--chakra-colors-purple-50),
text-shadow:
0 0 0.2em var(--chakra-colors-purple-50),
0 0 0.2em var(--chakra-colors-purple-50);
}

.muni-label-light {
color: var(--chakra-colors-purple-50);
text-shadow: 0 0 0.2em var(--chakra-colors-purple-900),
text-shadow:
0 0 0.2em var(--chakra-colors-purple-900),
0 0 0.2em var(--chakra-colors-purple-900);
}

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export default function AnnotationMarkers() {
boundary.status === BOUNDARY_STATUS.NEEDS_REVISIONS
? boundary.submission.review.annotations
: boundary.status === BOUNDARY_STATUS.DRAFT
? boundary?.previous_submission?.review.annotations
: null;
? boundary?.previous_submission?.review.annotations
: null;

const [annotationToDelete, setAnnotationToDelete] = useState(null);
const [annotationToView, setAnnotationToView] = useState(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import EditToolbar from './EditToolbar';
import MapControlButtons from './MapControlButtons';

import { useDialogController } from '../../hooks';
import { useDrawBoundary, useDrawPermissions } from '../DrawContext.js';
import { useDrawBoundary, useDrawPermissions } from '../DrawContext';

import useEditingPolygon from './useEditingPolygon';
import useGeocoderResult from './useGeocoderResult';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ import {
} from '@heroicons/react/outline';
import { CursorClickIcon } from '@heroicons/react/solid';

import AddPolygonIcon from '../../img/AddPolygonIcon.js';
import DeletePolygonConfirmModal from './DeletePolygonConfirmModal.js';
import { useDialogController } from '../../hooks.js';
import EditPolygonModal from './EditPolygonModal.js';
import AddPolygonIcon from '../../img/AddPolygonIcon';
import DeletePolygonConfirmModal from './DeletePolygonConfirmModal';
import { useDialogController } from '../../hooks';
import EditPolygonModal from './EditPolygonModal';
import {
disableAddCursor,
enableAddCursor,
toggleEditMode,
togglePolygonVisibility,
} from '../../store/mapSlice.js';
import { useDrawBoundary, useDrawPermissions } from '../DrawContext.js';
import { BOUNDARY_STATUS } from '../../constants.js';
} from '../../store/mapSlice';
import { useDrawBoundary, useDrawPermissions } from '../DrawContext';
import { BOUNDARY_STATUS } from '../../constants';

const POLYGON_BUTTON_WIDTH = 40;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Button, Text } from '@chakra-ui/react';

import { useGetBoundaryDetailsQuery } from '../api/boundaries';
import apiClient from '../api/client';
import LoginForm from '../components/LoginForm';
import LoginForm from './LoginForm';
import { UtilitySelector } from './UtilityControl';
import CenteredSpinner from './CenteredSpinner';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Icon from '@chakra-ui/icon';
import { Icon } from '@chakra-ui/icon';

export default function AddPolygonIcon() {
return (
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions src/app/src/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 0 additions & 11 deletions src/app/src/setupProxy.js

This file was deleted.

File renamed without changes.
15 changes: 15 additions & 0 deletions src/app/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
plugins: [react()],
server: {
port: process.env.PORT,
host: true,
proxy: {
'/api': 'http://django:8181',
'/media': 'http://django:8181',
'/web': 'http://django:8181',
}
},
});
Loading
Loading