-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a base structure that will allow us to source this code inside of our repository and get the details we need like name, desc, etc.
- Loading branch information
1 parent
11a4577
commit 47034ce
Showing
10 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
TODO(mark): | ||
- Add issue and PR templates: https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests | ||
- Add details either as config or as part of the starlark | ||
- Add details either as config or as part of the starlark | ||
- Make fuzzy clock a model citizen that includes good code structure and unit tests | ||
- Add codegen so we can `make applet` and it will plop out a new applet. |
This file contains 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,16 @@ | ||
// Package apps provides a clean way for Tidbyt to be able to get a list of all | ||
// community apps. | ||
package apps | ||
|
||
import ( | ||
"tidbyt.dev/community-apps/apps/community" | ||
"tidbyt.dev/community-apps/apps/fuzzyclock" | ||
) | ||
|
||
// GetApps returns a list of all apps in the this repository. Add your applet | ||
// below to include it in the Tidbyt Mobile app for all Tidbyt users. | ||
func GetApps() []community.App { | ||
return []community.App{ | ||
fuzzyclock.New(), | ||
} | ||
} |
This file contains 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,21 @@ | ||
package apps_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"tidbyt.dev/community-apps/apps" | ||
) | ||
|
||
// TODO(mark): add tests to validate all applet fields. We should check casing, | ||
// spelling, and length. | ||
|
||
// TODO(mark): add a test that tests the actual starlark | ||
|
||
// TODO(mark): add the ability to use our unit test module. | ||
func TestGetApps(t *testing.T) { | ||
applets := apps.GetApps() | ||
for _, app := range applets { | ||
fmt.Println(app.Name) | ||
} | ||
} |
This file contains 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,20 @@ | ||
// Package community provides structures and primitives to define apps. | ||
package community | ||
|
||
// App is a structure to define a starlark applet for Tidbyt in Go. | ||
type App struct { | ||
// Name is the name of the applet. Ex. "Fuzzy Clock" | ||
Name string `json:"name"` | ||
// Summary is the short form of what this applet does. Ex. "Human readable | ||
// time". | ||
Summary string `json:"summary"` | ||
// Desc is the long form of what this applet does. Ex. "Display the time in | ||
// a groovy, human-readable way." | ||
Desc string `json:"desc"` | ||
// Author is the person or organization who contributed this applet. Ex, | ||
// "Max Timkovich" | ||
Author string `json:"author"` | ||
// Source is the starlark source code for this applet using the go `embed` | ||
// module. | ||
Source []byte `json:"-"` | ||
} |
This file contains 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 @@ | ||
package community_test | ||
|
||
import ( | ||
_ "embed" | ||
"io/ioutil" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"tidbyt.dev/community-apps/apps/community" | ||
) | ||
|
||
//go:embed testdata/source.star | ||
var source []byte | ||
|
||
func TestApp(t *testing.T) { | ||
app := community.App{ | ||
Name: "Foo Tracker", | ||
Summary: "Track realtime foo", | ||
Desc: "The foo tracker provides realtime feeds for foo.", | ||
Author: "Tidbyt", | ||
Source: source, | ||
} | ||
|
||
expected, err := ioutil.ReadFile("testdata/source.star") | ||
assert.NoError(t, err) | ||
assert.Equal(t, app.Source, expected) | ||
} |
This file contains 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,6 @@ | ||
load("render.star", "render") | ||
|
||
def main(): | ||
return render.Root( | ||
child = render.Text("Hello, World!"), | ||
) |
This file contains 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,22 @@ | ||
// Package fuzzyclock provides details for the Fuzzy Clock applet. | ||
package fuzzyclock | ||
|
||
import ( | ||
_ "embed" | ||
|
||
"tidbyt.dev/community-apps/apps/community" | ||
) | ||
|
||
//go:embed source.star | ||
var source []byte | ||
|
||
// New creates a new instance of the Fuzzy Clock applet. | ||
func New() community.App { | ||
return community.App{ | ||
Name: "Fuzzy Clock", | ||
Author: "Max Timkovich", | ||
Summary: "Human readable time", | ||
Desc: "Display the time in a groovy, human-readable way.", | ||
Source: source, | ||
} | ||
} |
File renamed without changes.
This file contains 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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
module tidbyt.dev/community-apps | ||
|
||
go 1.17 | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.0 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/stretchr/testify v1.7.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect | ||
) |
This file contains 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,10 @@ | ||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= | ||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |