Skip to content

Commit

Permalink
🌿 Add local generation configuration (#14)
Browse files Browse the repository at this point in the history
* Add local generation configuration

* Add demo application in local/

* Add local executable to .gitignore

* Revise local generation setup
  • Loading branch information
amckinney authored Sep 4, 2023
1 parent 3b840de commit 89ecdce
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.DS_Store

local/go/generated/hookdeck-go-sdk/
local/go/go
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ fern check # Checks if the definition is valid

Generators read in your API Definition and output files or code (i.e. the TypeScript SDK Generator) and are tracked in [generators.yml](./fern/api/generators.yml).

### Local preview

You can preview the generated code in the `./local/go/generated/hookdeck-go-sdk` directory by running the following command:

```sh
fern generate --group local
```

### Publishing

To trigger the generators run:

```bash
Expand Down
10 changes: 10 additions & 0 deletions fern/api/generators.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
groups:
local:
generators:
- name: fernapi/fern-go-sdk
version: 0.3.0
config:
module:
path: github.com/hookdeck/hookdeck-go-sdk
output:
location: local-file-system
path: ../../local/go/generated/hookdeck-go-sdk
publish:
generators:
- name: fernapi/fern-go-sdk
Expand Down
7 changes: 7 additions & 0 deletions local/go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/hookdeck/hookdeck-api-schema/local/go

go 1.19

require github.com/hookdeck/hookdeck-go-sdk v0.0.0

replace github.com/hookdeck/hookdeck-go-sdk v0.0.0 => ./generated/hookdeck-go-sdk
4 changes: 4 additions & 0 deletions local/go/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
6 changes: 6 additions & 0 deletions local/go/go.work
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
go 1.19

use (
.
./generated/hookdeck-go-sdk
)
33 changes: 33 additions & 0 deletions local/go/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main

import (
"context"
"fmt"
"os"

hookdeck "github.com/hookdeck/hookdeck-go-sdk"
hookdeckclient "github.com/hookdeck/hookdeck-go-sdk/client"
)

func main() {
if err := run(); err != nil {
os.Stderr.WriteString(err.Error())
os.Exit(1)
}
}

func run() error {
client := hookdeckclient.NewClient(
hookdeckclient.ClientWithBaseURL("http://localhost:9000/2023-07-01"),
hookdeckclient.ClientWithAuthToken(os.Getenv("HOOKDECK_AUTH_TOKEN")),
)
issueTriggersResponse, err := client.IssueTrigger.List(
context.TODO(),
new(hookdeck.IssueTriggerListRequest),
)
if err != nil {
return err
}
fmt.Printf("Got %d issue triggers\n", len(issueTriggersResponse.Models))
return nil
}

0 comments on commit 89ecdce

Please sign in to comment.