Skip to content

Commit

Permalink
D1 support (#1687)
Browse files Browse the repository at this point in the history
* First version of D1 support in Wrangler

* Bumped to miniflare v2.9.0

* Changes based on PR feedback

* Added clarifying comment to performApiFetch

* Cast Request objects in test to avoid typing issue

* moved npx-import to be a dev dep, since it is bundled

* added comment to readableRelative

* added Beta warning message on all D1 commands (and --help)

* adding d1_database to the safe bindings list

* Added D1 warning, and env var to silence it, on detecting D1 bindings

* updated changeset

Co-authored-by: Glen Maddern <glen@cloudflare.com>
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
  • Loading branch information
3 people committed Sep 26, 2022
1 parent 6ff5a03 commit 28cd736
Show file tree
Hide file tree
Showing 44 changed files with 2,129 additions and 302 deletions.
5 changes: 5 additions & 0 deletions .changeset/witty-rice-pull.md
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Wrangler now supports the beta release of D1.
35 changes: 35 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -224,3 +224,38 @@ We use the following guidelines to determine the kind of change for a PR:
- Bugfixes and new features are considered to be 'patch' changes. If the new feature is experimental and its behaviour may functionally change, be sure to log warnings whenever they're used. (You'll note that this is where we deviate from semver, which otherwise suggests that behaviour/api changes should go into minor releases. We may revisit this in the future.)
- New deprecation warnings for future breaking changes are considered as 'minor' changes. These changes shouldn't break existing code, but the deprecation warnings should suggest alternate solutions to not trigger the warning.
- Breaking changes are considered to be 'major' changes. These are usually when deprecations take effect, or functional breaking behaviour is added with relevant logs (either as errors or warnings.)

## Miniflare Development

Wrangler builds upon, and provides a new entry point for, [Miniflare](https://github.com/cloudflare/miniflare), a local Cloudflare Workers simulator. To develop on both Wrangler and Miniflare together, you need to link the two projects, but as of NodeJS `v18.3.0` and NPM `v8.15.0`, relative NPM installs between two workspaces don't work, so you need things to be manual:

Assume you have the two directories checked out right beside each other:

```
❯ ll src
drwxr-xr-x - user 30 Jun 14:12 src
drwxr-xr-x - user 26 Jul 17:34 ├── miniflare
drwxr-xr-x - user 27 Jul 17:51 └── wrangler2
```

> Note: recommend using [exa](https://the.exa.website/) and `alias ll='exa --icons -laTL 1'` for the above output
Inside `packages/wrangler/package.json`, replace:

```
"@miniflare/d1": "^2.x.x",
"@miniflare/core": "^2.x.x",
"@miniflare/durable-objects": "^2.x.x",
"miniflare": "^2.x.x",
```

with

```
"miniflare": "file:../../../miniflare/packages/miniflare",
"@miniflare/d1": "file:../../../miniflare/packages/d1",
"@miniflare/core": "file:../../../miniflare/packages/core",
"@miniflare/durable-objects": "file:../../../miniflare/packages/durable-objects",
```

Then run `npm install` in the root of this monorepo.

0 comments on commit 28cd736

Please sign in to comment.