-
-
Notifications
You must be signed in to change notification settings - Fork 0
Foundation #1
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
Merged
Merged
Foundation #1
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
cef2f0a
feature: add base files
coopbri b806b97
test: add drizzle emitter tester fixture and basic test
coopbri 453a9fa
build(deps): add Biome, Changesets
coopbri b72b80d
build(pkg): add metadata
coopbri 5999af3
feature(code-quality): add code quality configs
coopbri 95f531c
feature: add changesets support
coopbri df4be0e
docs: add license
coopbri 67765ba
feature: add `.env`
coopbri e968461
chore: format
coopbri 6646363
feature: add Tiltfile
coopbri 14b3cc8
ci: add workflows
coopbri f5c6a23
docs: add README
coopbri 1258d8d
chore: format
coopbri 100a880
chore: format
coopbri a5f8d27
feature(tilt): add install resource
coopbri 7b41c5c
build(scripts): add `pretest` build script
coopbri 48c1a8e
ci(publish): fix scripts
coopbri ede9303
ci(test): add build step
coopbri 4eaabd6
chore: format
coopbri e4483eb
docs(readme): add logo
coopbri dee221e
docs(readme): reduce logo size
coopbri 61df87d
docs(readme): reduce logo size
coopbri 9fb31d1
docs(readme): update project status warning
coopbri b1f3280
docs(readme): add TypeSpec link
coopbri e5b6046
docs(readme): add TSP emitter docs link
coopbri df06791
docs(readme,installation): add development flag
coopbri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json", | ||
| "changelog": [ | ||
| "@changesets/changelog-github", | ||
| { "repo": "omnidotdev/typespec-drizzle" } | ||
| ], | ||
| "commit": false, | ||
| "access": "public", | ||
| "baseBranch": "master", | ||
| "updateInternalDependencies": "patch", | ||
| "ignore": [] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| DO_NOT_TRACK=1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| name: Publish Commit ⚙️ | ||
|
|
||
| on: | ||
| push: | ||
| branches: [master] | ||
| pull_request: | ||
| branches: [master] | ||
|
|
||
| jobs: | ||
| # check author permissions | ||
| check: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| has-permissions: ${{ steps.checkPermissions.outputs.require-result }} | ||
| steps: | ||
| - name: Check permissions | ||
| id: checkPermissions | ||
| uses: actions-cool/check-user-permission@v2 | ||
| with: | ||
| # require repo write access to trigger the package preview | ||
| require: "write" | ||
| # build and publish the preview package | ||
| publish: | ||
| needs: check | ||
| # publish the preview package only if permissions check passed | ||
| if: needs.check.outputs.has-permissions == 'true' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: oven-sh/setup-bun@v2 | ||
| - name: Install dependencies | ||
| run: bun i | ||
| - name: Build package | ||
| run: bun run build | ||
| - name: Publish package | ||
| run: bunx pkg-pr-new publish |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| name: Release 🏗️ | ||
|
|
||
| on: | ||
| push: | ||
| branches: [master] | ||
|
|
||
| concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
|
||
| jobs: | ||
| release: | ||
| name: Handle release 🦋 | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: oven-sh/setup-bun@v2 | ||
| - name: Install dependencies | ||
| run: bun i | ||
| - name: Create release PR or publish package | ||
| id: changesets | ||
| uses: changesets/action@v1 | ||
| with: | ||
| publish: bun release | ||
| title: "feature(release): version packages" | ||
| commit: "ci(changesets): version packages" | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| name: Test 🧪 | ||
|
|
||
| on: | ||
| push: | ||
| branches: [master] | ||
| pull_request: | ||
| branches: [master] | ||
|
|
||
| jobs: | ||
| test_unit: | ||
| name: Run unit tests 🃏 | ||
| timeout-minutes: 1 | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: oven-sh/setup-bun@v2 | ||
| with: | ||
| bun-version: 1.1.42 | ||
| # - uses: ArtiomTr/jest-coverage-report-action@v2 | ||
| # with: | ||
| # package-manager: bun | ||
| # test-script: bun test:coverage | ||
| # annotations: failed-tests | ||
| # TODO replace below with commented job above, blocked by Bun not yet supporting a JSON coverage reporter for the action to consume nor generate (similar: https://github.com/oven-sh/bun/issues/4099) | ||
| - name: Install dependencies | ||
| run: bun install | ||
| # NB: build is necessary for test fixtures to resolve paths properly | ||
| - name: Build project | ||
| run: bun run build | ||
| - name: Run unit tests | ||
| run: bun test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| node_modules/ | ||
| build/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| bun biome check --write --staged --no-errors-on-unmatched src |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) Omni LLC | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| # TypeSpec Drizzle Emitter | ||
|
|
||
| <div align="center"> | ||
| <img src="/assets/logo.png" width="150" /> | ||
|
|
||
| [Join Omni community on Discord](https://discord.gg/omnidotdev) | ||
|
|
||
| [](https://github.com/omnidotdev/typespec-drizzle/releases) | ||
| [](https://github.com/omnidotdev/typespec-drizzle/actions/workflows/release.yml) | ||
| [](https://github.com/omnidotdev/typespec-drizzle/blob/master/LICENSE.md) | ||
|
|
||
| </div> | ||
|
|
||
| A [TypeSpec](https://typespec.io) emitter that generates [Drizzle ORM](https://orm.drizzle.team) schema definitions and types from TypeSpec specifications. Learn about TypeSpec emitters [here](https://typespec.io/docs/extending-typespec/emitters-basics). | ||
|
|
||
| > [!IMPORTANT] | ||
| > **Project Status:** 🚧 This project is **brand new**. Use at your own risk. | ||
|
|
||
| ## Overview | ||
|
|
||
| This emitter allows you to define your database schema using TypeSpec's type-safe language and automatically generate Drizzle ORM schema files, enabling a single source of truth for your database schema definitions alongside other artifacts. | ||
|
|
||
| ## Features | ||
|
|
||
| - Generate Drizzle schema definitions from TypeSpec models | ||
| - Type-safe database schema generation | ||
| - Support for common database types and constraints | ||
| - Integration with TypeSpec's existing ecosystem | ||
|
|
||
| ## Installation | ||
|
|
||
| ```sh | ||
| bun add -D @omnidotdev/typespec-drizzle | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Basic Usage | ||
|
|
||
| 1. Add the emitter to your TypeSpec configuration (`tspconfig.yaml`): | ||
|
|
||
| ```yaml | ||
| emit: | ||
| - "@omnidotdev/typespec-drizzle" | ||
| ``` | ||
|
|
||
| 2. Define your models in TypeSpec: | ||
|
|
||
| ```typespec | ||
| import "@omnidotdev/typespec-drizzle"; | ||
|
|
||
| model User { | ||
| id: string; | ||
| email: string; | ||
| name: string; | ||
| createdAt: utcDateTime; | ||
| } | ||
|
|
||
| model Post { | ||
| id: string; | ||
| title: string; | ||
| content: string; | ||
| authorId: string; | ||
| publishedAt?: utcDateTime; | ||
| } | ||
| ``` | ||
|
|
||
| 3. Run the TypeSpec compiler: | ||
|
|
||
| ```sh | ||
| tsp compile . | ||
| ``` | ||
|
|
||
| The emitter will generate Drizzle schema files in the output directory. | ||
|
|
||
| ## Getting Started | ||
|
|
||
| ### Local Development | ||
|
|
||
| Use [Tilt](https://tilt.dev) for a unified development experience: | ||
|
|
||
| ```sh | ||
| tilt up | ||
| ``` | ||
|
|
||
| or manually install and build: | ||
|
|
||
| ```sh | ||
| bun install | ||
| bun run build # or `bun run build:watch` | ||
| ``` | ||
|
|
||
| Tests can be run with `bun test`. | ||
|
|
||
| ## Contributing | ||
|
|
||
| See Omni's [contributing docs](https://docs.omni.dev/contributing/overview). | ||
|
|
||
| ## License | ||
|
|
||
| The code in this repository is licensed under MIT, © Omni LLC. See [LICENSE.md](LICENSE.md) for more information. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| load("ext://dotenv", "dotenv") | ||
| dotenv() | ||
|
|
||
| local_resource( | ||
| "install", | ||
| "bun install", | ||
| ) | ||
|
|
||
| local_resource( | ||
| "build", | ||
| "bun run build", | ||
| auto_init=False, | ||
| trigger_mode=TRIGGER_MODE_MANUAL | ||
| ) | ||
|
|
||
| local_resource( | ||
| "build:watch", | ||
| serve_cmd="bun build:watch", | ||
| auto_init=False, | ||
| trigger_mode=TRIGGER_MODE_MANUAL | ||
| ) | ||
|
|
||
| local_resource( | ||
| "test", | ||
| "bun test", | ||
| auto_init=False, | ||
| trigger_mode=TRIGGER_MODE_MANUAL | ||
| ) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // see https://biomejs.dev/reference/configuration | ||
| { | ||
| "$schema": "https://biomejs.dev/schemas/2.3.6/schema.json", | ||
| "assist": { | ||
| "actions": { | ||
| "source": { | ||
| "organizeImports": { | ||
| "options": { | ||
| "groups": [ | ||
| { "type": false, "source": [":BUN:", ":NODE:"] }, | ||
| ":BLANK_LINE:", | ||
| { | ||
| "type": false, | ||
| // TODO look into this for TS `baseUrl` (https://github.com/omnidotdev/golden/pull/1#discussion_r2487186008) | ||
| "source": [":PACKAGE:", ":PACKAGE_WITH_PROTOCOL:"] | ||
| }, | ||
| ":BLANK_LINE:", | ||
| { "type": false, "source": ["**"] }, | ||
| ":BLANK_LINE:", | ||
| { "type": true } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "files": { | ||
| "includes": [ | ||
| "**", | ||
| "!!**/*.gen.*", | ||
| "!!**/.cache", | ||
| "!!**/build", | ||
| "!!**/bun.lock", | ||
| "!!**/dist", | ||
| "!!**/generated", | ||
| "!!**/node_modules", | ||
| "!!**/out", | ||
| "!!**/public", | ||
| "!!**/vendor", | ||
| "!!**/certificates" | ||
| ] | ||
| }, | ||
| "formatter": { | ||
| "indentStyle": "space", | ||
| "indentWidth": 2, | ||
| "lineWidth": 80 | ||
| }, | ||
| "linter": { | ||
| "rules": { | ||
| "correctness": { | ||
| "noUnusedImports": { | ||
| "fix": "safe", | ||
| "level": "error" | ||
| } | ||
| }, | ||
| "nursery": { | ||
| "useSortedClasses": { | ||
| "fix": "safe", | ||
| "level": "error", | ||
| "options": { | ||
| "attributes": ["class", "className"], | ||
| "functions": ["cn", "clsx", "classnames", "cva", "tv"] | ||
| } | ||
| } | ||
| }, | ||
| "style": { | ||
| "useImportType": { | ||
| "level": "error", | ||
| "options": { "style": "separatedType" } | ||
| } | ||
| }, | ||
| "suspicious": { | ||
| "noArrayIndexKey": "warn", | ||
| "noConsole": { | ||
| "level": "error", | ||
| "options": { "allow": ["error", "warn"] } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.