Skip to content

Commit

Permalink
chore: add Trunk linting and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanfoxtyler committed Dec 11, 2024
1 parent a5e3c23 commit 32e1542
Show file tree
Hide file tree
Showing 58 changed files with 507 additions and 851 deletions.
4 changes: 4 additions & 0 deletions .github/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
self-hosted-runner:
# Labels of self-hosted runner in array of string
labels:
- warp-ubuntu-latest-x64-4x
14 changes: 8 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ on:
- reopened
- ready_for_review
paths:
- '**.go'
- '**.ts'
- '**.json'
- "**.go"
- "**.ts"
- "**.json"
- .github/workflows/*
schedule:
- cron: "0 5 * * *"
- cron: 0 5 * * *

permissions:
contents: read
Expand All @@ -30,7 +30,9 @@ jobs:

- name: Search for go.mod and package.json files
id: get-dirs
run: echo "dirs=$(find . \( -name 'go.mod' -o -name 'package.json' \) -exec dirname {} \; | sed 's|^\./||' | jq -Rsc 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT}
run:
echo "dirs=$(find . \( -name 'go.mod' -o -name 'package.json' \) -exec dirname {} \; | sed
's|^\./||' | jq -Rsc 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT}

build:
needs: get-dirs
Expand All @@ -57,7 +59,7 @@ jobs:
- name: Setup TinyGo
uses: acifani/setup-tinygo@v2
with:
tinygo-version: "0.34.0"
tinygo-version: 0.34.0

- name: Build project
run: npx -p @hypermode/modus-cli -y modus build
Expand Down
5 changes: 5 additions & 0 deletions dgraph-101/api-as/.gitignore → .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ node_modules/

# Ignore logs generated by as-test
logs/

# Ignore Go debuger and generated files
__debug_bin*
*_generated.go
*.generated.go
9 changes: 9 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*out
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
tmp
6 changes: 6 additions & 0 deletions .trunk/configs/.markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"line-length": { "line_length": 150, "tables": false },
"no-inline-html": false,
"no-bare-urls": false,
"no-space-in-emphasis": false
}
6 changes: 6 additions & 0 deletions .trunk/configs/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plugins": ["assemblyscript-prettier"],
"semi": false,
"proseWrap": "always",
"printWidth": 100
}
7 changes: 7 additions & 0 deletions .trunk/configs/.shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enable=all
source-path=SCRIPTDIR
disable=SC2154

# If you're having issues with shellcheck following source, disable the errors via:
# disable=SC1090
# disable=SC1091
7 changes: 7 additions & 0 deletions .trunk/configs/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rules:
quoted-strings:
required: only-when-needed
extra-allowed: ["{|}"]
key-duplicates: {}
octal-values:
forbid-implicit-octal: true
43 changes: 43 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1

cli:
version: 1.22.8

plugins:
sources:
- id: trunk
ref: v1.6.6
uri: https://github.com/trunk-io/plugins

runtimes:
enabled:
- [email protected]
- [email protected]
- [email protected]

lint:
enabled:
- [email protected]
- [email protected]
- git-diff-check
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]:
packages:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]

actions:
enabled:
- trunk-announce
- trunk-check-pre-push
- trunk-fmt-pre-commit
- trunk-upgrade-available
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["trunk.io"]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "trunk.io",
"editor.trimAutoWhitespace": true
}
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Modus Recipes

Code recipes for cooking with [Modus](https://github.com/hypermodeinc/modus), the open source serverless framework for building intelligent APIs, powered by WebAssembly.
Code recipes for cooking with [Modus](https://github.com/hypermodeinc/modus), the open source
serverless framework for building intelligent APIs, powered by WebAssembly.

## 🚀 Getting started with Modus

For more information on getting started with Modus, check out [the docs](https://docs.hypermode.com/modus/overview).
For more information on getting started with Modus, check out
[the docs](https://docs.hypermode.com/modus/overview).

## 📺 Video walkthroughs

Expand Down
22 changes: 10 additions & 12 deletions dgraph-101/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dgraph with modus 101

From ModusHack livestream - 11/19/24 .
From ModusHack livestream - 11/19/24 .

## Dgraph

Expand All @@ -11,16 +11,17 @@ Start a local instance using Docker.
```

Start Ratel, a Graphical data explorer for Dgraph:

```sh
docker run --name ratel -d -p "8000:8000" dgraph/ratel:latest
```

## Data model

Modus is code first, simply define you data using classes.
In this example we are using `Product` and `Category` defined in `classes.ts` file.
Modus is code first, simply define you data using classes. In this example we are using `Product`
and `Category` defined in `classes.ts` file.

## Define your API.
## Define your API

index.ts is where we export the functions that are exposed as GraphQL operations.

Expand All @@ -33,12 +34,9 @@ This project defines the following operations:
Note that Modus is exposing `getProduct` as `product` to follow common coding and GraphQL practices.
Modus also exposes `upsertProduct` and `deleteProduct` as a GraphQL Mutation automatically.

- getProductsByCategory
The data is saved in Dgraph as a graph.
This function shows how to easily use the relationships in the graph.

- searchProducts
Finally we are using an AI model to create text embeddings for our Products: as the embeddings are stored in Dgraph for each Product entity, we can easily expose an API to search by natural language and similarity, leveraging DQL `similar_to` function.


- getProductsByCategory The data is saved in Dgraph as a graph. This function shows how to easily
use the relationships in the graph.

- searchProducts Finally we are using an AI model to create text embeddings for our Products: as the
embeddings are stored in Dgraph for each Product entity, we can easily expose an API to search by
natural language and similarity, leveraging DQL `similar_to` function.
3 changes: 0 additions & 3 deletions dgraph-101/api-as/.prettierrc

This file was deleted.

23 changes: 13 additions & 10 deletions dgraph-101/api-as/assembly/classes.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@

/*
This file contains the classes that are used in our App.
The classes are annotated with the @json decorator
to be serialized and deserialized as json string.
@alias is used to rename the properties in the json string to match Dgraph best practices.
*/


@json
export class Product {

@alias("Product.id")
id!: string;

id!: string


@alias("Product.title")
title: string = "";
title: string = ""


@alias("Product.description")
description: string = "";
description: string = ""


@alias("Product.category")
@omitnull()
category: Category | null = null;
category: Category | null = null
}


@json
export class Category {

@alias("Category.name")
name: string = "";
}
name: string = ""
}
Loading

0 comments on commit 32e1542

Please sign in to comment.