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

fix: adding bun #14

Merged
merged 8 commits into from
Sep 16, 2023
Merged
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
13 changes: 8 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ TODO text
# Configs
*.cnf text
*.conf text
*.config text
.editorconfig text
*.config text
.editorconfig text
.env text
.gitattributes text
.gitconfig text
.gitconfig text
.htaccess text
*.lock text -diff
package.json text eol=lf
Expand Down Expand Up @@ -171,8 +171,8 @@ Procfile text
*.asf binary
*.asx binary
*.avi binary
*.fla binary
*.flv binary
*.fla binary
*.flv binary
*.m4v binary
*.mng binary
*.mov binary
Expand Down Expand Up @@ -213,3 +213,6 @@ Procfile text
.yarn/* linguist-vendored
.pnp.js linguist-vendored
*.test.ts linguist-vendored

# Bun
*.lockb binary diff=lockb
8 changes: 4 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Closes #{issueNumber}

## Changsets

Instructions: Changesets automate our changelog. If you modify files in `/packages/ui`, run `pnpm changeset` in the root of the monorepo, follow the prompts, then commit the markdown file. Changes that add features should be `minor` while chores and bugfixes should be `patch`. Please prefix the changeset message with `feat:`, `fix:` or `chore:`.
Instructions: Changesets automate our changelog. If you modify files in `/packages/ui`, run `bun run changeset` in the root of the monorepo, follow the prompts, then commit the markdown file. Changes that add features should be `minor` while chores and bugfixes should be `patch`. Please prefix the changeset message with `feat:`, `fix:` or `chore:`.

## Checklist

Expand All @@ -17,9 +17,9 @@ Please read and apply all [contribution requirements](../CODE_OF_CONDUCT.md).
- [ ] This PR targets the `main` branch
- [ ] Documentation reflects all relevant changes
- [ ] Branch is prefixed with: `docs/`, `feat/`, `chore/`, `fix/`
- [ ] Ensure Svelte and Typescript linting is current - run `pnpm check`
- [ ] Ensure Prettier linting is current - run `pnpm format`
- [ ] All test cases are passing - run `pnpm test`
- [ ] Ensure Svelte and Typescript linting is current - run `bun run check`
- [ ] Ensure Prettier linting is current - run `bun run format`
- [ ] All test cases are passing - run `bun run test`
- [ ] Includes a changeset (if relevant; see above)

### Commit message format
Expand Down
104 changes: 64 additions & 40 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,44 +28,68 @@ jobs:
uses: cocogitto/[email protected]
with:
check-latest-tag-only: true
# linter:
# name: Lint Code Base
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Code
# uses: actions/checkout@v4
# with:
# # Full git history is needed to get a proper list of changed files within `super-linter`
# fetch-depth: 0
# - name: Lint Code Base
# uses: github/super-linter@v5
# env:
# VALIDATE_ALL_CODEBASE: false
# IGNORE_GENERATED_FILES: true
# # FILTER_REGEX_EXCLUDE: CHANGELOG.md
# DEFAULT_BRANCH: main
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# build:
# name: Build and Test
# timeout-minutes: 15
# runs-on: ubuntu-latest
# # To use Remote Caching, uncomment the next lines and follow the steps below.
# env:
# TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
# TURBO_TEAM: ${{ vars.TURBO_TEAM }}
# linter:
# name: Lint Code Base
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Code
# uses: actions/checkout@v4
# with:
# # Full git history is needed to get a proper list of changed files within `super-linter`
# fetch-depth: 0
# - name: Lint Code Base
# uses: github/super-linter@v5
# env:
# VALIDATE_ALL_CODEBASE: false
# IGNORE_GENERATED_FILES: true
# # FILTER_REGEX_EXCLUDE: CHANGELOG.md
# DEFAULT_BRANCH: main
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# build:
# name: Build and Test
# timeout-minutes: 15
# runs-on: ubuntu-latest
# # To use Remote Caching, uncomment the next lines and follow the steps below.
# env:
# TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
# TURBO_TEAM: ${{ vars.TURBO_TEAM }}

# steps:
# - name: Check out code
# uses: actions/checkout@v4
# with:
# fetch-depth: 2
# - uses: pnpm/action-setup@v2
# with:
# version: 8
# - uses: actions/setup-node@v3
# with:
# node-version: '20'
# cache: 'pnpm'
# - run: pnpm install
# - run: pnpm build
# - run: pnpm test:unit:coverage
# steps:
# - name: Check out code
# uses: actions/checkout@v4
# with:
# fetch-depth: 2
# - uses: pnpm/action-setup@v2
# with:
# version: 8
# - uses: actions/setup-node@v3
# with:
# node-version: '20'
# cache: 'pnpm'
# - run: pnpm install
# - run: pnpm run build --filter=playground
# - run: pnpm run test:unit:coverage --filter=playground

build:
name: Build and Test
timeout-minutes: 15
runs-on: ubuntu-latest
# To use Remote Caching, uncomment the next lines and follow the steps below.
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}

steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install Dependencies
run: bun install
# - run: bun run check --filter=docs
# - run: bun run lint --filter=docs
- run: bun run build --filter=docs
- run: bun run test:unit:coverage --filter=docs
6 changes: 3 additions & 3 deletions .lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* jshint esversion: 9 */

module.exports = {
'*.{js,ts,json,svelte}': ['pnpm format', 'git add'],
'./src/**/*.{svelte,ts}': ['pnpm format', 'git add', 'pnpm lint:fix'],
'./.{ts,cjs,js}': ['pnpm lint:fix']
'*.{js,ts,json,svelte}': ['bun run format', 'git add'],
'./src/**/*.{svelte,ts}': ['bun run format', 'git add', 'bun run lint:fix'],
'./.{ts,cjs,js}': ['bun run lint:fix']
};
63 changes: 35 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
```shell
cd ~/Developer/Work/SPA
git clone https://github.com/xmlking/spectacular.git
cd spectacular && pnpm i
# playwright is required for end-to-end testing
pnpx playwright install
cd spectacular && bun i
# (optional) playwright is required for end-to-end testing
bunx playwright install
# (optional) add git-commit-hooks
cog install-hook --all
```
Expand All @@ -66,29 +66,26 @@ cog install-hook --all

By default, the `dev` server (dev command) runs in `development` mode and the `build` command run in `production`
mode.
This means when running `npm build`, it will load the env variables from `.env.production` if there is one:
This means when running `bun run build`, it will load the env variables from `.env.production` if there is one:
Use `.env.local` to override environment variables in `.env` (like API keys) for local development.

````shell
## Developing

Once you've cloned the project and installed dependencies with `pnpm i`, start a development server:
Once you've cloned the project and installed dependencies with `bun i`, start a development server:

```shell
turbo dev --filter=playground
turbo dev --filter=web
turbo dev --filter=docs
bun run dev --filter=web

# or start the server and open the app in a new browser tab
turbo dev --filter=playground -- --open
bun run dev --filter=web -- --open

# run in debug mode
turbo de:debug --filter=web
bun run dev:debug --filter=web

# run with a custom inline config
# inline environment variables has higher precedence than ones loaded from .env and .env.local files
PUBLIC_GRAPHQL_ENDPOINT=api.mycompany.com:443 pnpm dev
````
PUBLIC_GRAPHQL_ENDPOINT=api.mycompany.com:443 bun run dev
```

## Maintenance

Expand All @@ -97,48 +94,58 @@ PUBLIC_GRAPHQL_ENDPOINT=api.mycompany.com:443 pnpm dev
To update the packages to their latest versions in `package.json`

```shell
pnpm up --latest -r
pnpm audit --fix
# TODO: not at available for bun
bun up --latest -r
bun audit --fix
```

## Format

Format and lint code

```shell
bun run format
bun run lint
```

## Testing

### Unit/Component Tests

```shell
turbo test
bun run test

turbo test:ui
bun run test:ui
#Then, you can visit the Vitest UI at http://localhost:51204/__vitest__/.

# test coverage
turbo test:coverage
bun run test:coverage

# updating Snapshots
pnpx vitest -u
bunx vitest -u

# test specific folder
pnpx vitest run apps/web/src/lib/utils
bunx vitest apps/web/src/lib/utils
(or)
./node_modules/.bin/vitest run apps/web/src/lib/utils
```

### E2E Tests

```shell
turbo test:e2e
bun run test:e2e
```

## Building

To create a production version of your app:

```shell
turbo build
bun run build
# run build
turbo build --filter=playground...
turbo build --filter=playground... --dry
turbo build --filter=playground... --graph
bun run build --filter=playground...
bun run build --filter=playground... --dry
bun run build --filter=playground... --graph
```

Run from the local build directory:
Expand All @@ -155,7 +162,7 @@ ORIGIN=https://my.site \
node build
```

You can preview the production build with `pnpm preview`.
You can preview the production build with `bun run preview`.

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target
> environment.
Expand All @@ -176,7 +183,7 @@ cog bump --auto
To build and publish libs

```shell
trubo build --filter=lib...
bun run build --filter=lib...
cd package
pnpm publish
bun publish
```
1 change: 0 additions & 1 deletion apps/docs/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
module.exports = {
root: true,
extends: ['custom']
};
6 changes: 3 additions & 3 deletions apps/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ If you're seeing this, you've probably already done this step. Congrats!

```bash
# create a new project in the current directory
npm init svelte
bun create svelte@latest

# create a new project in my-app
npm init svelte my-app
bun create svelte@latest my-app
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `bun install`), start a development server:

```bash
npm run dev
Expand Down
8 changes: 6 additions & 2 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"format": "prettier --plugin-search-dir . --write --ignore-path=../../.prettierignore ."
},
"devDependencies": {
"@playwright/test": "1.37.1",
"@sveltejs/adapter-auto": "2.1.0",
"@sveltejs/kit": "1.24.1",
"@tailwindcss/container-queries": "0.1.1",
Expand All @@ -27,15 +28,18 @@
"svelte": "4.2.0",
"svelte-check": "3.5.1",
"svelte-meta-tags": "3.0.3",
"svelte-preprocess": "5.0.4",
"sveltekit-rate-limiter": "0.4.1",
"tailwind-merge": "1.14.0",
"tailwindcss-animate": "1.0.7",
"tslib": "2.6.2",
"typescript": "5.2.2",
"ui": "workspace:*",
"vite": "4.4.9",
"vite-imagetools": "5.0.8"
"vitest": "0.34.4"
},
"optionalDependencies": {
"@playwright/test": "1.37.1",
"@vitest/ui": "0.34.4"
},
"type": "module"
}
12 changes: 12 additions & 0 deletions apps/docs/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
webServer: {
command: 'npm run build && npm run preview',
port: 4173
},
testDir: 'tests',
testMatch: /(.+\.)?(test|spec)\.[jt]s/
};

export default config;
Loading