refactor: move nebula assets to hway build directory

This commit is contained in:
Prad Nukala 2024-10-09 00:37:50 -04:00
parent a3edb65613
commit 5df9d4a3e5
7 changed files with 115 additions and 213 deletions

View File

@ -311,9 +311,9 @@ gen-pkl:
### motr, hway & nebula ###
###############################################################################
.PHONY: build-motr build-hway build-nebula
.PHONY: motr-build hway-build nebula-build nebula-copy
hway-build: gen-templ
hway-build: nebula-build nebula-copy gen-templ
@echo "(motr) Building Highway gateway"
GOOS=js GOARCH=wasm go build -o ./cmd/hway/build/app.wasm ./cmd/hway/server.go
@ -329,6 +329,10 @@ nebula-build:
@echo "(nebula) Building nebula"
cd pkg/nebula && bun install && bun run build
nebula-copy:
@echo "(nebula) Copying assets to hway"
cp -r pkg/nebula/assets/js pkg/nebula/assets/css cmd/hway/build
###############################################################################
### help ###

View File

@ -12,7 +12,6 @@ import (
func main() {
s := echo.New()
s.Use(ctx.UseSession)
s.GET("/", routes.Home)
s.GET("/login", routes.LoginStart)
s.GET("/register", routes.RegisterStart)

View File

@ -31,47 +31,18 @@
},
"shell": {
"scripts": {
"build:docker": [
"make local-image"
],
"build:hway": [
"make build-nebula",
"make build-hway"
],
"build:nebula": [
"make build-nebula"
],
"build:motr": [
"make build-motr"
],
"build:sonrd": [
"make build-motr",
"make build"
],
"build": [
"make build-motr",
"make build",
"make build-hway"
],
"gen:proto": [
"rm -rf ./pkg/nebula/node_modules",
"make proto-gen"
],
"gen:pkl": [
"make gen-pkl"
],
"gen:templ": [
"make gen-templ"
],
"start": [
"process-compose up -f ./deploy/process-compose.yaml"
],
"stop": [
"process-compose down -f ./deploy/process-compose.yaml"
],
"start:testnet": [
"make sh-testnet"
]
"build:docker": ["make local-image"],
"build:hway": ["make build-nebula", "make build-hway"],
"build:nebula": ["make build-nebula"],
"build:motr": ["make build-motr"],
"build:sonrd": ["make build-motr", "make build"],
"build": ["make build-motr", "make build", "make build-hway"],
"gen:proto": ["rm -rf ./pkg/nebula/node_modules", "make proto-gen"],
"gen:pkl": ["make gen-pkl"],
"gen:templ": ["make gen-templ"],
"start": ["process-compose up -f ./deploy/process-compose.yaml"],
"stop": ["process-compose down -f ./deploy/process-compose.yaml"],
"start:testnet": ["make sh-testnet"]
}
}
}

View File

@ -12,25 +12,17 @@ var (
)
templ Styles() {
@stylesHandle.Once() {
<link href={ "https://cdn.sonr.id/css/styles.css" } rel="stylesheet"/>
}
<link href={ "/css/styles.css" } rel="stylesheet"/>
}
templ Alpine() {
@alpineHandle.Once() {
<script src={ "https://cdn.sonr.id/js/alpine.min.js" } defer></script>
}
<script src={ "/js/alpine.min.js" } defer></script>
}
templ Dexie() {
@dexieHandle.Once() {
<script src={ "https://cdn.sonr.id/js/dexie.min.js" }></script>
}
<script src={ "/js/dexie.min.js" }></script>
}
templ Htmx() {
@htmxHandle.Once() {
<script src={ "https://cdn.sonr.id/js/htmx.min.js" }></script>
}
<script src={ "/js/htmx.min.js" }></script>
}

View File

@ -40,28 +40,16 @@ func Styles() templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<link href=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs("https://cdn.sonr.id/css/styles.css")
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs("/css/styles.css")
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/assets/scripts.templ`, Line: 16, Col: 51}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/assets/scripts.templ`, Line: 15, Col: 31}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -71,12 +59,6 @@ func Styles() templ.Component {
}
return templ_7745c5c3_Err
})
templ_7745c5c3_Err = stylesHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return templ_7745c5c3_Err
})
}
func Alpine() templ.Component {
@ -95,33 +77,21 @@ func Alpine() templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var4 := templ.GetChildren(ctx)
if templ_7745c5c3_Var4 == nil {
templ_7745c5c3_Var4 = templ.NopComponent
templ_7745c5c3_Var3 := templ.GetChildren(ctx)
if templ_7745c5c3_Var3 == nil {
templ_7745c5c3_Var3 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Var5 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script src=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs("https://cdn.sonr.id/js/alpine.min.js")
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs("/js/alpine.min.js")
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/assets/scripts.templ`, Line: 22, Col: 54}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/assets/scripts.templ`, Line: 19, Col: 34}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -131,12 +101,6 @@ func Alpine() templ.Component {
}
return templ_7745c5c3_Err
})
templ_7745c5c3_Err = alpineHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return templ_7745c5c3_Err
})
}
func Dexie() templ.Component {
@ -155,33 +119,21 @@ func Dexie() templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var7 := templ.GetChildren(ctx)
if templ_7745c5c3_Var7 == nil {
templ_7745c5c3_Var7 = templ.NopComponent
templ_7745c5c3_Var5 := templ.GetChildren(ctx)
if templ_7745c5c3_Var5 == nil {
templ_7745c5c3_Var5 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Var8 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script src=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs("https://cdn.sonr.id/js/dexie.min.js")
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs("/js/dexie.min.js")
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/assets/scripts.templ`, Line: 28, Col: 53}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/assets/scripts.templ`, Line: 23, Col: 33}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -191,12 +143,6 @@ func Dexie() templ.Component {
}
return templ_7745c5c3_Err
})
templ_7745c5c3_Err = dexieHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var8), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return templ_7745c5c3_Err
})
}
func Htmx() templ.Component {
@ -215,33 +161,21 @@ func Htmx() templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var10 := templ.GetChildren(ctx)
if templ_7745c5c3_Var10 == nil {
templ_7745c5c3_Var10 = templ.NopComponent
templ_7745c5c3_Var7 := templ.GetChildren(ctx)
if templ_7745c5c3_Var7 == nil {
templ_7745c5c3_Var7 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Var11 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script src=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var12 string
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs("https://cdn.sonr.id/js/htmx.min.js")
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs("/js/htmx.min.js")
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/assets/scripts.templ`, Line: 34, Col: 52}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/assets/scripts.templ`, Line: 27, Col: 32}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -251,12 +185,6 @@ func Htmx() templ.Component {
}
return templ_7745c5c3_Err
})
templ_7745c5c3_Err = htmxHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var11), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return templ_7745c5c3_Err
})
}
var _ = templruntime.GeneratedTemplate

View File

@ -33,8 +33,6 @@ templ Layout(title string, remote bool) {
<!DOCTYPE html>
<html lang="en">
<head>
@cdn.Alpine()
@cdn.Htmx()
@cdn.Styles()
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
@ -49,6 +47,8 @@ templ Layout(title string, remote bool) {
<main class="flex-row items-center justify-center mx-auto w-fit max-w-screen-sm gap-y-3">
{ children... }
</main>
@cdn.Alpine()
@cdn.Htmx()
</body>
</html>
}
@ -57,8 +57,6 @@ templ LayoutNoBody(title string, remote bool) {
<!DOCTYPE html>
<html lang="en">
<head>
@cdn.Alpine()
@cdn.Htmx()
@cdn.Styles()
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
@ -74,6 +72,8 @@ templ LayoutNoBody(title string, remote bool) {
<div class="flex flex-col min-h-screen overflow-hidden supports-[overflow:clip]:overflow-clip">
{ children... }
</div>
@cdn.Alpine()
@cdn.Htmx()
</body>
</main>
</html>

View File

@ -149,14 +149,6 @@ func Layout(title string, remote bool) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = cdn.Alpine().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = cdn.Htmx().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = cdn.Styles().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
@ -168,7 +160,7 @@ func Layout(title string, remote bool) templ.Component {
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(title)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/global/styles/layout.templ`, Line: 42, Col: 17}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/global/styles/layout.templ`, Line: 40, Col: 17}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil {
@ -182,7 +174,19 @@ func Layout(title string, remote bool) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</main></body></html>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</main>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = cdn.Alpine().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = cdn.Htmx().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</body></html>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -215,14 +219,6 @@ func LayoutNoBody(title string, remote bool) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = cdn.Alpine().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = cdn.Htmx().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = cdn.Styles().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
@ -234,7 +230,7 @@ func LayoutNoBody(title string, remote bool) templ.Component {
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(title)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/global/styles/layout.templ`, Line: 66, Col: 17}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/global/styles/layout.templ`, Line: 64, Col: 17}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
if templ_7745c5c3_Err != nil {
@ -248,7 +244,19 @@ func LayoutNoBody(title string, remote bool) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></body></main></html>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = cdn.Alpine().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = cdn.Htmx().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</body></main></html>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}