Skip to content

Commit f3b030b

Browse files
authored
Rewrite (#20)
1 parent 1dfcf9e commit f3b030b

File tree

244 files changed

+8451
-542039
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

244 files changed

+8451
-542039
lines changed

.github/workflows/deploy-preview.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: deploy-preview
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
workflow_dispatch:
7+
jobs:
8+
build-and-deploy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-node@v4
13+
with:
14+
node-version: 20
15+
cache: npm
16+
- run: npm ci
17+
- run: npm run test
18+
- run: npm run build
19+
env:
20+
VITE_BRANCH: ${{ github.ref_name }}
21+
VITE_PREVIEW: 1
22+
- uses: FirebaseExtended/action-hosting-deploy@v0
23+
with:
24+
repoToken: "${{ secrets.GITHUB_TOKEN }}"
25+
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_KYSELY_PLAYGROUND }}"
26+
channelId: preview
27+
expires: 7d
28+
projectId: kysely-playground

.github/workflows/deploy.yml

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,26 @@
1-
name: Deploy
1+
name: deploy
22
on:
33
push:
4-
branches: [ "main" ]
5-
paths-ignore:
6-
- "README.md"
4+
branches:
5+
- main
76
workflow_dispatch:
87
jobs:
9-
build:
8+
build-and-deploy:
109
runs-on: ubuntu-latest
1110
steps:
12-
- uses: actions/checkout@v3
13-
- uses: actions/configure-pages@v2
14-
- uses: actions/setup-node@v3
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-node@v4
1513
with:
16-
node-version: 18
17-
- run: yarn install --frozen-lockfile
18-
- run: yarn test
19-
- run: yarn build
14+
node-version: 20
15+
cache: npm
16+
- run: npm ci
17+
- run: npm run test
18+
- run: npm run build
2019
env:
21-
NODE_OPTIONS: "--max-old-space-size=8192"
22-
- name: Upload artifact
23-
uses: actions/upload-pages-artifact@v1
20+
VITE_BRANCH: ${{ github.ref_name }}
21+
- uses: FirebaseExtended/action-hosting-deploy@v0
2422
with:
25-
path: 'dist'
26-
deploy:
27-
runs-on: ubuntu-latest
28-
needs: build
29-
permissions:
30-
pages: write
31-
id-token: write
32-
environment:
33-
name: github-pages
34-
url: ${{ steps.deployment.outputs.page_url }}
35-
steps:
36-
- uses: actions/deploy-pages@v1
37-
id: deployment
23+
repoToken: '${{ secrets.GITHUB_TOKEN }}'
24+
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_KYSELY_PLAYGROUND }}'
25+
channelId: live
26+
projectId: kysely-playground

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ dist-ssr
2424
*.sw?
2525

2626
.firebase/*
27+
stats.html

.prettierrc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
2-
"printWidth": 120,
3-
"semi": false,
2+
"printWidth": 110,
3+
"semi": true,
44
"singleQuote": false,
55
"arrowParens": "always",
6-
"endOfLine": "lf"
6+
"endOfLine": "lf",
7+
"trailingComma": "all"
78
}

README.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
# [Kysely Playground](https://kyse.link/)
22

3-
| branch | url |
4-
|---------|-----------------------------------|
5-
| main | https://kyse.link |
63

7-
Playground for [Kysely](https://github.com/kysely-org/kysely).
4+
Playground for [Kysely](https://github.com/kysely-org/kysely),
5+
with vscode-like experiences including type checking and auto suggestions.
6+
Supports built-in dialects, various versions and unrealeased branches.
87

9-
Provides vscode-like experiences including type checking and auto suggestions.
10-
Supports built-in dialects(postgres, mysql, sqlite), last 20 kysely versions.
8+
## Guide
119

12-
You can test stuffs quickly, create issues with reproducing with playground.
10+
There are three panels in playground. From left to right, `type-editor`, `query-editor` and `result`.
1311

14-
## Guide
12+
In `type-editor` you can declare any kind of typescript types.
13+
For Kysely's type-safety and autocompletion to work, `Database` type must be declared with `export`.
14+
If you don't familiar with Kysely, checkout [the official guide](https://kysely.dev/docs/getting-started#types) for more information about database types.
15+
16+
In `query-editor` you can write the query.
17+
`db` is pre-defined Kysely instance with `Database` type from `type-editor`.
18+
You can import any other types from `type-editor`: `import {..} from "type-editor"`.
19+
Result of executions will be displayed in `result`.
20+
21+
For advanced usage, you can import esm module directly from url:
22+
```ts
23+
// @ts-ignore
24+
import isNumber from "https://esm.run/[email protected]/index.js"
25+
```
26+
27+
28+
29+
## API
1530

16-
The playground has 3 editor: `schema`, `query` and `sql`.
31+
### Set states
1732

18-
Schema editor is the leftmost editor(in wide-enough screen).
19-
You can declare global scope interface `DB` to help checking types related database schema.
33+
`<origin>#r<encoded>`
2034

21-
You can hide the editor by clicking `Schema` checkbox on header of playground.
22-
If you want to let people focus on building query not schema, hide the schema editor before share.
23-
The visibility of schema editor will be shared together.
24-
(Type checking for schema still works even though it is hidden.)
35+
`<encoded>` = `encodeURIComponent(JSON.strinify(<state>))`
2536

26-
If you want to disable the type checking for schema,
27-
check out
28-
[the example](https://kyse.link/?p=b&i=haFkqHBvc3RncmVzoXamMC4yNC4yoXPZSmRlY2xhcmUgZ2xvYmFsIHsKICBpbnRlcmZhY2UgREIgewogICAgW2tleTogc3RyaW5nXTogYW55CiAgfQp9CgpleHBvcnQge30KoXHZK2t5c2VseQogIC5zZWxlY3RGcm9tKCJhc2RmIikKICAuc2VsZWN0QWxsKCmhY8M=).
2937

30-
To
31-
prevent [2669 error](https://stackoverflow.com/questions/57132428/augmentations-for-the-global-scope-can-only-be-directly-nested-in-external-modul),
32-
you should specify `export {}` if you import nothing in schema editor.
38+
`<state>` = [Type Definition](https://github.com/wirekang/kysely-playground/tree/main/src/lib/state/state.ts)
3339

34-
The editor in the middle is the query editor.
40+
Example: `https://kyse.link#r%7Beditors%3A%7Btype%3A%22%22%2Cquery%3A%22%22%7D%7D`
3541

36-
These are pre-defined variables you can use without import:
42+
### Override theme
3743

38-
| variable | description |
39-
|----------|---------------------------------------------------------|
40-
| `kysely` | an Kysely instance with DB interface from schema editor |
41-
| `db` | alias for kysely |
44+
`<origin>?theme=light`
4245

43-
You can see the generated sql in the rightmost sql editor.
44-
By default, the playground will show you the generated sql string as-is(with parameter placeholders).
45-
You can generate sql with hard-coded parameter by turning on `More Options` -> `SQL Format` -> `inlineParameters`.
46-
It is useful when you copy-paste the sql into database cli or DataGrip.
46+
`<origin>?theme=dark`

bin/generate

-3.71 MB
Binary file not shown.

generator/cmd/generate/main.go

Lines changed: 0 additions & 13 deletions
This file was deleted.

generator/cmdutils/cmdutils.go

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)