mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Fix formatters not running in CI + delete unnecessary files (#19433)
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
name: Use Neon Postgres through Drizzle ORM
|
||||
---
|
||||
|
||||
[Neon](https://neon.tech/) is a fully managed serverless Postgres, separating compute and storage to offer features like autoscaling, branching and bottomless storage. Neon can be used from Bun directly using the `@neondatabase/serverless` driver or through an ORM like `Drizzle`.
|
||||
[Neon](https://neon.tech/) is a fully managed serverless Postgres, separating compute and storage to offer features like autoscaling, branching and bottomless storage. Neon can be used from Bun directly using the `@neondatabase/serverless` driver or through an ORM like `Drizzle`.
|
||||
|
||||
Drizzle ORM supports both a SQL-like "query builder" API and an ORM-like [Queries API](https://orm.drizzle.team/docs/rqb). Get started by creating a project directory, initializing the directory using `bun init`, and installing Drizzle and the [Neon serverless driver](https://github.com/neondatabase/serverless/).
|
||||
Drizzle ORM supports both a SQL-like "query builder" API and an ORM-like [Queries API](https://orm.drizzle.team/docs/rqb). Get started by creating a project directory, initializing the directory using `bun init`, and installing Drizzle and the [Neon serverless driver](https://github.com/neondatabase/serverless/).
|
||||
|
||||
```sh
|
||||
$ mkdir bun-drizzle-neon
|
||||
@@ -52,7 +52,7 @@ console.log(result.rows);
|
||||
|
||||
---
|
||||
|
||||
Then run `index.ts` with Bun.
|
||||
Then run `index.ts` with Bun.
|
||||
|
||||
```sh
|
||||
$ bun run index.ts
|
||||
@@ -65,7 +65,7 @@ $ bun run index.ts
|
||||
|
||||
---
|
||||
|
||||
We can define a schema for our database using Drizzle ORM primitives. Create a `schema.ts` file and add this code.
|
||||
We can define a schema for our database using Drizzle ORM primitives. Create a `schema.ts` file and add this code.
|
||||
|
||||
```ts#schema.ts
|
||||
import { pgTable, integer, serial, text, timestamp } from "drizzle-orm/pg-core";
|
||||
@@ -215,6 +215,6 @@ $ bun run index.ts
|
||||
|
||||
---
|
||||
|
||||
This example used the Neon serverless driver's SQL-over-HTTP functionality. Neon's serverless driver also exposes `Client` and `Pool` constructors to enable sessions, interactive transactions, and node-postgres compatibility. Refer to [Neon's documentation](https://neon.tech/docs/serverless/serverless-driver) for a complete overview.
|
||||
This example used the Neon serverless driver's SQL-over-HTTP functionality. Neon's serverless driver also exposes `Client` and `Pool` constructors to enable sessions, interactive transactions, and node-postgres compatibility. Refer to [Neon's documentation](https://neon.tech/docs/serverless/serverless-driver) for a complete overview.
|
||||
|
||||
Refer to the [Drizzle website](https://orm.drizzle.team/docs/overview) for more documentation on using the Drizzle ORM.
|
||||
|
||||
@@ -40,7 +40,7 @@ module.exports = {
|
||||
interpreter: "bun", // Bun interpreter
|
||||
env: {
|
||||
PATH: `${process.env.HOME}/.bun/bin:${process.env.PATH}`, // Add "~/.bun/bin/bun" to PATH
|
||||
}
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
@@ -52,9 +52,9 @@ $ cd my-app
|
||||
$ bun --bun run dev
|
||||
$ vite dev
|
||||
Forced re-optimization of dependencies
|
||||
|
||||
|
||||
VITE v5.4.10 ready in 424 ms
|
||||
|
||||
|
||||
➜ Local: http://localhost:5173/
|
||||
➜ Network: use --host to expose
|
||||
➜ press h + enter to show help
|
||||
@@ -88,7 +88,7 @@ Now, make the following changes to your `svelte.config.js`.
|
||||
// Consult https://svelte.dev/docs/kit/integrations#preprocessors
|
||||
// for more information about preprocessors
|
||||
preprocess: vitePreprocess(),
|
||||
|
||||
|
||||
kit: {
|
||||
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
|
||||
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
|
||||
@@ -96,7 +96,7 @@ Now, make the following changes to your `svelte.config.js`.
|
||||
adapter: adapter()
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export default config;
|
||||
```
|
||||
|
||||
@@ -116,9 +116,9 @@ $ bun --bun run build
|
||||
✓ built in 231ms
|
||||
...
|
||||
✓ built in 899ms
|
||||
|
||||
|
||||
Run npm run preview to preview your production build locally.
|
||||
|
||||
|
||||
> Using svelte-adapter-bun
|
||||
✔ Start server with: bun ./build/index.js
|
||||
✔ done
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
name: Add a peer dependency
|
||||
---
|
||||
|
||||
|
||||
To add an npm package as a peer dependency, use the `--peer` flag.
|
||||
|
||||
```sh
|
||||
|
||||
@@ -56,4 +56,3 @@ $ bun run cli.ts --flag1 --flag2 value
|
||||
}
|
||||
[ "/path/to/bun", "/path/to/cli.ts" ]
|
||||
```
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ $ set FOO=helloworld && bun run dev
|
||||
$ $env:FOO="helloworld"; bun run dev
|
||||
```
|
||||
|
||||
{% /codetabs %}
|
||||
---
|
||||
## {% /codetabs %}
|
||||
|
||||
See [Docs > Runtime > Environment variables](https://bun.sh/docs/runtime/env) for more information on using environment variables with Bun.
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
---
|
||||
name: Using Testing Library with Bun
|
||||
---
|
||||
|
||||
You can use [Testing Library](https://testing-library.com/) with Bun's test runner.
|
||||
|
||||
---
|
||||
|
||||
As a prerequisite to using Testing Library you will need to install [Happy Dom](https://github.com/capricorn86/happy-dom). ([see Bun's Happy DOM guide for more information](https://bun.sh/guides/test/happy-dom)).
|
||||
|
||||
```sh
|
||||
@@ -17,6 +19,7 @@ Next you should install the Testing Library packages you are planning on using.
|
||||
```sh
|
||||
bun add -D @testing-library/react @testing-library/dom @testing-library/jest-dom
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Next you will need to create a preload script for Happy DOM and for Testing Library. For more details about the Happy DOM setup script see [Bun's Happy DOM guide](https://bun.sh/guides/test/happy-dom).
|
||||
@@ -26,6 +29,7 @@ import { GlobalRegistrator } from '@happy-dom/global-registrator';
|
||||
|
||||
GlobalRegistrator.register();
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
For Testing Library, you will want to extend Bun's `expect` function with Testing Library's matchers. Optionally, to better match the behavior of test-runners like Jest, you may want to run cleanup after each test.
|
||||
@@ -51,6 +55,7 @@ Next, add these preload scripts to your `bunfig.toml` (you can also have everyth
|
||||
[test]
|
||||
preload = ["./happydom.ts", "./testing-library.ts"]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
If you are using TypeScript you will also need to make use of declaration merging in order to get the new matcher types to show up in your editor. To do this, create a type declaration file that extends `Matchers` like this.
|
||||
@@ -71,15 +76,15 @@ declare module 'bun:test' {
|
||||
You should now be able to use Testing Library in your tests
|
||||
|
||||
```ts
|
||||
import { test, expect } from 'bun:test';
|
||||
import { screen, render } from '@testing-library/react';
|
||||
import { MyComponent } from './myComponent';
|
||||
import { test, expect } from "bun:test";
|
||||
import { screen, render } from "@testing-library/react";
|
||||
import { MyComponent } from "./myComponent";
|
||||
|
||||
test('Can use Testing Library', () => {
|
||||
test("Can use Testing Library", () => {
|
||||
render(MyComponent);
|
||||
const myComponent = screen.getByTestId('my-component');
|
||||
const myComponent = screen.getByTestId("my-component");
|
||||
expect(myComponent).toBeInTheDocument();
|
||||
})
|
||||
});
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user