5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 20:41:56 +08:00
wails/v3/internal/commands/service.go
Atterpac e316cd0719
[V3] Plugins implemenations (#3570)
* plugin handler and lifecycle

* rebase

* remove reflect

s

* remove Config and NewPlugin from plugin template

* Remove plugin manager, generation of plugin interface

* implement http handlers for services

remove log

trim path

prefix wails/services

* update plugine example

* Misc updates

* Ported plugins to services, rewritten example

* Added fileserver

* Update OnStartup and use a context for the application

* Rename PathPrefix to Route. Create docs.

* Use service config copy. Add Name to Service Options. Improve service generation.

* Use service config copy. Add Name to Service Options. Improve service generation. Update README

* Remove rogue db

* Update changelog.md

---------

Co-authored-by: Lea O'Anthony <lea.anthony@gmail.com>
2024-09-01 17:26:22 +10:00

46 lines
841 B
Go

package commands
import (
"github.com/wailsapp/wails/v3/internal/flags"
"github.com/wailsapp/wails/v3/internal/service"
"strings"
"github.com/pterm/pterm"
)
func toCamelCasePlugin(s string) string {
var camelCase string
var capitalize = true
for _, c := range s {
if c >= 'a' && c <= 'z' || c >= '0' && c <= '9' {
if capitalize {
camelCase += strings.ToUpper(string(c))
capitalize = false
} else {
camelCase += string(c)
}
} else if c >= 'A' && c <= 'Z' {
camelCase += string(c)
capitalize = false
} else {
capitalize = true
}
}
return camelCase + "Plugin"
}
func ServiceInit(options *flags.ServiceInit) error {
if options.Quiet {
pterm.DisableOutput()
}
if options.PackageName == "" {
options.PackageName = toCamelCasePlugin(options.Name)
}
return service.Install(options)
}