mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 04:59:38 +08:00

* Tidy up runtime JS * Initial implementation of runtime over http * Update runtime deps. Fix test task. * Support Clipboard. Message Processor refactor. * Add `Window.Screen()` Clipboard `GetText` -> `Text` * Support most dialogs Better JS->Go object mapping Implement Go->JS callback mechanism Rename `window.runtime` -> `window.wails` to better reflect the Go API * Support SaveFile dialog * Remove go.work * Tidy up * Event->CustomEvent to prevent potential clash with native JS Event object Support Eventing * Support application calls * Support logging * Support named windows Remove debug info * Update v3 changes
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package commands
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/wailsapp/wails/v3/internal/parser"
|
|
)
|
|
|
|
type GenerateBindingsOptions struct {
|
|
ModelsFilename string `name:"m" description:"The filename for the models file" default:"models.ts"`
|
|
BindingsFilename string `name:"b" description:"The filename for the bindings file" default:"bindings.js"`
|
|
ProjectDirectory string `name:"d" description:"The project directory" default:"."`
|
|
}
|
|
|
|
func GenerateBindings(options *GenerateBindingsOptions) error {
|
|
|
|
parserContext, err := parser.ParseDirectory(options.ProjectDirectory)
|
|
if err != nil {
|
|
return fmt.Errorf("error parsing project: %v", err)
|
|
}
|
|
|
|
// Generate models
|
|
modelsData, err := parser.GenerateModels(parserContext)
|
|
if err != nil {
|
|
return fmt.Errorf("error generating models: %v", err)
|
|
}
|
|
|
|
var modelsFileData bytes.Buffer
|
|
modelsFileData.WriteString(`// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
|
// This file is automatically generated. DO NOT EDIT
|
|
|
|
`)
|
|
modelsFileData.Write(modelsData)
|
|
err = os.WriteFile(options.ModelsFilename, modelsFileData.Bytes(), 0755)
|
|
if err != nil {
|
|
return fmt.Errorf("error writing models file: %v", err)
|
|
}
|
|
println("Generated models file '" + options.ModelsFilename + "'")
|
|
return nil
|
|
}
|