Skip to content

Commit

Permalink
fix: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
0xcadams committed Dec 20, 2024
1 parent 6e65d5b commit acd84b9
Show file tree
Hide file tree
Showing 12 changed files with 4,344 additions and 1 deletion.
36 changes: 36 additions & 0 deletions .github/workflows/test-and-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test & Build

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test-and-build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"

- name: Install dependencies
run: pnpm install

- name: Run tests
run: pnpm test

- name: Type check tests
run: pnpm run test:types

- name: Build
run: pnpm run build
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
59 changes: 58 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,59 @@
# drizzle-zero
Generate Zero schemas from Drizzle ORM schemas

Generate [Zero](https://github.com/rocicorp/mono) schemas from [Drizzle ORM](https://orm.drizzle.team) schemas.

## Installation

```bash
npm install drizzle-zero
# or
yarn add drizzle-zero
# or
pnpm add drizzle-zero
```

## Usage

Here's a simple example of how to convert a Drizzle schema to a Zero schema:

```ts
import { pgTable, text } from 'drizzle-orm/pg-core';
import { createSchema, createTableSchema } from '@rocicorp/zero';
import { drizzleToZero } from 'drizzle-zero';

// Define your Drizzle table
const userTable = pgTable("user", {
id: text("id").primaryKey(),
name: text("name").notNull(),
});

// Convert to Zero schema
const userSchema = createTableSchema(
drizzleToZero(userTable, {
id: true,
name: true,
})
);

// Create your Zero schema
export const schema = createSchema({
version: 1,
tables: {
user: userSchema,
},
});
```

## Features

- Convert Drizzle ORM schemas to Zero schemas
- Handles all Drizzle column types that are supported by Zero
- Type-safe schema generation

## Limitations

- Relationships are not supported yet

## License

MIT
52 changes: 52 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "drizzle-zero",
"version": "0.0.1-alpha.1",
"description": "Generate Zero schemas from Drizzle ORM schemas",
"type": "module",
"scripts": {
"build": "tsup src/index.ts --format cjs,esm --dts",
"test:types": "cd tests && tsc",
"publish": "npm publish package.tgz",
"test": "vitest run"
},
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/BriefHQ/drizzle-zero.git"
},
"keywords": [
"zero",
"sync",
"schema",
"drizzle",
"orm",
"pg",
"postgresql",
"postgres",
"database",
"typescript",
"ts"
],
"author": "Brief",
"license": "Apache-2.0",
"peerDependencies": {
"@rocicorp/zero": ">=0.8.2024121204",
"drizzle-orm": ">=0.36.0"
},
"devDependencies": {
"@types/node": "^22.10.2",
"tsup": "^8.0.2",
"typescript": "^5.7.2",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^2.1.8",
"zod": "^3.20.2"
}
}
Loading

0 comments on commit acd84b9

Please sign in to comment.