Skip to content

Commit 7d2247a

Browse files
committed
Initial commit
0 parents  commit 7d2247a

File tree

7 files changed

+108
-0
lines changed

7 files changed

+108
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sqlc-gen-test
2+
sqlc-gen-test.wasm

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Kyle Conroy
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
all: sqlc-gen-test sqlc-gen-test.wasm
2+
3+
install: all
4+
cp sqlc-gen-test ~/bin
5+
6+
sqlc-gen-test: main.go go.mod go.sum
7+
go build .
8+
9+
sqlc-gen-test.wasm: main.go go.mod go.sum
10+
GOOS=wasip1 GOARCH=wasm go build -o sqlc-gen-test.wasm main.go
11+
12+
sha256: sqlc-gen-test.wasm
13+
openssl sha256 sqlc-gen-test.wasm

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Usage
2+
3+
```yaml
4+
version: '2'
5+
plugins:
6+
- name: py
7+
wasm:
8+
url: https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.0.0.wasm
9+
sha256: "FIXME"
10+
sql:
11+
- schema: "schema.sql"
12+
queries: "query.sql"
13+
engine: postgresql
14+
codegen:
15+
- out: src/authors
16+
plugin: py
17+
options:
18+
package: authors
19+
emit_sync_querier: true
20+
emit_async_querier: true
21+
```

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/sqlc-dev/sqlc-gen-test
2+
3+
go 1.19
4+
5+
require (
6+
buf.build/gen/go/sqlc/sqlc/protocolbuffers/go v1.30.0-20230621221448-196413f69ab3.1
7+
github.com/sqlc-dev/sqlc-go v1.18.1
8+
)
9+
10+
require google.golang.org/protobuf v1.30.0 // indirect

go.sum

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
buf.build/gen/go/sqlc/sqlc/protocolbuffers/go v1.30.0-20230621221448-196413f69ab3.1 h1:ze0HODAjPRXSkiqSpDTYq2baS4IVtRtDLSZY2p1ZCX4=
2+
buf.build/gen/go/sqlc/sqlc/protocolbuffers/go v1.30.0-20230621221448-196413f69ab3.1/go.mod h1:DSpReHp8PwHOeCfGymiiY4HSx2iVL358X7JRMciL7T0=
3+
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
4+
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
5+
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
6+
github.com/sqlc-dev/sqlc-go v1.18.1 h1:mmudfN9G938piXnZGvrMEHp9RF4dD+InQIY1BaoQOvU=
7+
github.com/sqlc-dev/sqlc-go v1.18.1/go.mod h1:v6c+FMh0YrbT9RU9+S5Sh62VXmVhdpTsQoXn1QxH294=
8+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
9+
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
10+
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
11+
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=

main.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"encoding/json"
6+
"os"
7+
8+
"buf.build/gen/go/sqlc/sqlc/protocolbuffers/go/protos/plugin"
9+
"github.com/sqlc-dev/sqlc-go/codegen"
10+
)
11+
12+
func generate(_ context.Context, _ *plugin.CodeGenRequest) (*plugin.CodeGenResponse, error) {
13+
env := os.Environ()
14+
blob, err := json.Marshal(env)
15+
if err != nil {
16+
return nil, err
17+
}
18+
return &plugin.CodeGenResponse{
19+
Files: []*plugin.File{
20+
{
21+
Name: "env.json",
22+
Contents: append(blob, '\n'),
23+
},
24+
},
25+
}, nil
26+
}
27+
28+
func main() {
29+
codegen.Run(generate)
30+
}

0 commit comments

Comments
 (0)