cleanup / move files

This commit is contained in:
maddalax 2024-09-22 21:33:22 -05:00
parent 4e563ced3d
commit a975cff0d7
52 changed files with 106 additions and 9 deletions

View file

@ -0,0 +1,46 @@
name: Build and Deploy htmgo.dev todo example
on:
workflow_dispatch: # Trigger on manual workflow_dispatch
push:
branches:
- master # Trigger on pushes to master
paths:
- 'examples/todo-list/**' # Trigger only if files in this directory change
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get short commit hash
id: vars
run: echo "::set-output name=short_sha::$(echo $GITHUB_SHA | cut -c1-7)"
- name: Build Docker image
run: |
cd ./examples/todo-list && docker build -t ghcr.io/${{ github.repository_owner }}/htmgo-todo-example:${{ steps.vars.outputs.short_sha }} .
- name: Tag as latest Docker image
run: |
docker tag ghcr.io/${{ github.repository_owner }}/htmgo-todo-example:${{ steps.vars.outputs.short_sha }} ghcr.io/${{ github.repository_owner }}/htmgo-todo-example:latest
- name: Log in to GitHub Container Registry
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push Docker image
run: |
docker push ghcr.io/${{ github.repository_owner }}/htmgo-todo-example:latest

View file

@ -0,0 +1,10 @@
# Project exclude paths
/tmp/
node_modules/
dist/
js/dist
js/node_modules
go.work
go.work.sum
.idea
!framework/assets/dist

View file

@ -0,0 +1,41 @@
# Stage 1: Build the Go binary
FROM golang:1.23-alpine AS builder
RUN apk update
RUN apk add git
RUN apk add curl
# Set the working directory inside the container
WORKDIR /app
# Copy go.mod and go.sum files
COPY go.mod go.sum ./
# Download and cache the Go modules
RUN go mod download
# Always download the latest version of the framework
RUN go get github.com/maddalax/htmgo/framework@latest
# Copy the source code into the container
COPY . .
# Build the Go binary for Linux
RUN GOPRIVATE=github.com/maddalax LOG_LEVEL=debug go run github.com/maddalax/htmgo/cli/htmgo@latest build
# Stage 2: Create the smallest possible image
FROM gcr.io/distroless/base-debian11
# Set the working directory inside the container
WORKDIR /app
# Copy the Go binary from the builder stage
COPY --from=builder /app/dist .
# Expose the necessary port (replace with your server port)
EXPOSE 3000
# Command to run the binary
CMD ["./todolist"]

View file

@ -31,8 +31,8 @@ const (
// TaskMutation represents an operation that mutates the Task nodes in the graph. // TaskMutation represents an operation that mutates the Task nodes in the graph.
type TaskMutation struct { type TaskMutation struct {
config config
op Op op Op
typ string typ string
id *uuid.UUID id *uuid.UUID
name *string name *string
created_at *time.Time created_at *time.Time
@ -41,9 +41,9 @@ type TaskMutation struct {
tags *[]string tags *[]string
appendtags []string appendtags []string
clearedFields map[string]struct{} clearedFields map[string]struct{}
done bool done bool
oldValue func(context.Context) (*Task, error) oldValue func(context.Context) (*Task, error)
predicates []predicate.Task predicates []predicate.Task
} }
var _ ent.Mutation = (*TaskMutation)(nil) var _ ent.Mutation = (*TaskMutation)(nil)

View file

@ -96,7 +96,7 @@ func TriggerChildren() Ren {
return HxExtension("trigger-children") return HxExtension("trigger-children")
} }
func TriggerString(triggers ...string) *AttributeMap { func HxTriggerString(triggers ...string) *AttributeMap {
trigger := hx.NewStringTrigger(strings.Join(triggers, ", ")) trigger := hx.NewStringTrigger(strings.Join(triggers, ", "))
return Attribute(hx.TriggerAttr, trigger.ToString()) return Attribute(hx.TriggerAttr, trigger.ToString())
} }

View file

@ -128,7 +128,7 @@ func (m *AttributeMap) Render(context *RenderContext) {
func (l *LifeCycle) fromAttributeMap(event string, key string, value string, context *RenderContext) { func (l *LifeCycle) fromAttributeMap(event string, key string, value string, context *RenderContext) {
if key == hx.GetAttr || key == hx.PatchAttr || key == hx.PostAttr { if key == hx.GetAttr || key == hx.PatchAttr || key == hx.PostAttr {
TriggerString(hx.ToHtmxTriggerName(event)).Render(context) HxTriggerString(hx.ToHtmxTriggerName(event)).Render(context)
} }
Attribute(key, value).Render(context) Attribute(key, value).Render(context)

View file

@ -3,7 +3,7 @@ package h
import "github.com/maddalax/htmgo/framework/hx" import "github.com/maddalax/htmgo/framework/hx"
func Get(path string, trigger ...string) *AttributeMap { func Get(path string, trigger ...string) *AttributeMap {
return AttributeList(Attribute(hx.GetAttr, path), TriggerString(trigger...)) return AttributeList(Attribute(hx.GetAttr, path), HxTriggerString(trigger...))
} }
func GetPartial(partial PartialFunc, trigger ...string) *AttributeMap { func GetPartial(partial PartialFunc, trigger ...string) *AttributeMap {
@ -27,7 +27,7 @@ func PostPartialWithQs(partial PartialFunc, qs *Qs, trigger ...string) *Attribut
} }
func Post(url string, trigger ...string) *AttributeMap { func Post(url string, trigger ...string) *AttributeMap {
return AttributeList(Attribute(hx.PostAttr, url), TriggerString(trigger...)) return AttributeList(Attribute(hx.PostAttr, url), HxTriggerString(trigger...))
} }
func PostWithQs(url string, qs *Qs, trigger string) *AttributeMap { func PostWithQs(url string, qs *Qs, trigger string) *AttributeMap {