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

bun #212

Merged
merged 11 commits into from
Feb 20, 2024
Merged

bun #212

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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.lockb binary diff=lockb
* text=auto eol=lf
src/mystyles.css linguist-generated=true
17 changes: 8 additions & 9 deletions .github/workflows/ci_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,20 @@ jobs:
uses: actions/checkout@v4
- name: Check JSON syntax errors in translations via jq
run: jq . public/locales/*/translation.json > /dev/null
- name: Setup Node JS
uses: actions/setup-node@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
node-version: 20
cache: 'npm'
bun-version: latest
- name: Install dependencies
run: npm ci
run: bun install --frozen-lockfile
- name: Run TypeScript typecheck
run: npm run typecheck
run: bun run typecheck
- name: Run linter & formatter
run: npm run check
run: bun run check
- name: Run tests
run: npm test
run: bun test
- name: Build
run: npm run build
run: bun run build
env:
VITE_DEFAULT_LANG: en
VITE_BACKEND_API_URL: "https://dev.openaedmap.org"
17 changes: 8 additions & 9 deletions .github/workflows/deploy_development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@ jobs:
ssh-port: ${{ secrets.SSH_HOST_NEW_PORT }}
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Node JS
uses: actions/setup-node@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
node-version: 20
cache: "npm"
bun-version: latest
- name: Install dependencies
run: npm ci
run: bun install --frozen-lockfile
- name: Run linter & formatter
run: npm run check
run: bun run check
- name: Run tests
run: npm test
run: bun test
- name: Run TypeScript typecheck
run: npm run typecheck
run: bun run typecheck
- name: Set git commit
run: echo "VITE_GIT_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Build app (main)
Expand All @@ -40,7 +39,7 @@ jobs:
VITE_OSM_OAUTH2_CLIENT_ID: ${{ secrets.REACT_APP_OSM_OAUTH2_CLIENT_ID }}
VITE_BACKEND_API_URL: "https://dev.openaedmap.org"
VITE_SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
run: npm run build
run: bun run build
- name: Create robots.txt
run: |
cat << 'EOF' > build/robots.txt
Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@ jobs:
ssh-port: ${{ secrets.SSH_HOST_NEW_PORT }}
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Node JS
uses: actions/setup-node@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
node-version: 20
cache: "npm"
bun-version: latest
- name: Install dependencies
run: npm ci
run: bun install --frozen-lockfile
- name: Run linter & formatter
run: npm run check
run: bun run check
- name: Run tests
run: npm test
run: bun test
- name: Run TypeScript typecheck
run: npm run typecheck
run: bun run typecheck
- name: Set git commit
run: echo "VITE_GIT_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Build app
Expand All @@ -41,7 +40,7 @@ jobs:
VITE_OSM_OAUTH2_CLIENT_ID: ${{ secrets.REACT_APP_OSM_OAUTH2_CLIENT_ID }}
VITE_BACKEND_API_URL: "https://openaedmap.org"
VITE_SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
run: npm run build && ./scripts/build_every_lang.sh
run: bun run build && ./scripts/build_every_lang.sh
- name: Run deploy script on host
run: |
rsync -rp --delete -e 'ssh -p ${{ secrets.SSH_HOST_NEW_PORT }}' build/* ${{ secrets.SSH_USER_NEW }}@${{ secrets.SSH_HOST_NEW_IP }}:~/main-static/
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Production environment: https://openaedmap.org \
Development environment: https://dev.openaedmap.org

# Development
## Bun
It's recommended to use bun instead of npm.
See https://bun.sh/docs/installation for installation manual

## Gitflow

`dev` is main branch. After pushing to it dev environment is autodeployed.
Expand All @@ -36,18 +40,17 @@ Status:
One way to set up is:
1. Clone repo and open terminal in the project directory
2. Install Node version 20 or use [Node version manager](https://github.com/nvm-sh/nvm)
3. Run `npm install --include dev`
3. Install bun. See https://bun.sh/docs/installation
4. Run `bun install`

Second way is if you are using VS Code and have Docker installed you can use devContainer extension.

Create .env file and put these variables there:
```
VITE_VERSION=$npm_package_version
VITE_DEFAULT_LANG=en
VITE_OSM_API_URL=https://master.apis.dev.openstreetmap.org
VITE_BACKEND_API_URL=https://dev.openaedmap.org
VITE_OSM_OAUTH2_CLIENT_ID=xXaPFXSLizLHuZzoLI1eebHncPdDdVH7nA917S9uFUo
HOST=127.0.0.1
```

*Note: You can use Github Codespaces to develop.*
Expand All @@ -61,32 +64,28 @@ Formatter and linter will run before git commit.

In the project directory, you can run:

#### `npm start`
#### `bun start`

Runs the app in the development mode.\
Open [http://127.0.0.1:5173](http://127.0.0.1:5173) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

#### `npm run build`
#### `bun run build`

Builds the app for production to the `build` folder.

#### Create sprites from marker icons

Use `npx @beyondtracks/spritezero-cli ./public/img/sprite ./src/marker_icons; spritezero --ratio=2 ./public/img/sprite@2x ./src/marker_icons; spritezero --ratio=4 ./public/img/sprite@4x ./src/marker_icons`

#### `npm run css-build`
#### `bun run css-build`

Build `sass/mystyles.scss` file into `src/mystyles.css` which is included in `index.tsc` and has the adjusted bulma css for the entire app.

Run this if changed e.g. navbar breakpoint or customized bulma further in `sass/mystyles.css`.

#### `npm run css-watch`

Watches `sass/mystyles.scss` for changes and runs `npm run css-build` if it detects any.

# Data source
Map and AED locations are from [OpenStreetMap](https://www.openstreetmap.org/copyright)

Expand Down
Binary file added bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ pre-commit:
parallel: true
commands:
biome:
run: npm run lint-fix
run: bun lint-fix
stage_fixed: true
test:
run: npm run test
run: bun test

skip_output:
- meta # Skips lefthook version printing
Expand Down
Loading