mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 22:33:46 +08:00
Merge pull request #97 from wailsapp/92-build-on-first-init
92 build on first init
This commit is contained in:
commit
3553cb6694
@ -110,16 +110,19 @@ func (fs *FSHelper) RemoveFiles(files []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Dir holds information about a directory
|
||||
type Dir struct {
|
||||
localPath string
|
||||
fullPath string
|
||||
}
|
||||
|
||||
func (fs *FSHelper) Dir(dir string) (*Dir, error) {
|
||||
// Directory creates a new Dir struct with the given directory path
|
||||
func (fs *FSHelper) Directory(dir string) (*Dir, error) {
|
||||
fullPath, err := filepath.Abs(dir)
|
||||
return &Dir{fullPath: fullPath}, err
|
||||
}
|
||||
|
||||
// LocalDir creates a new Dir struct based on a path relative to the caller
|
||||
func (fs *FSHelper) LocalDir(dir string) (*Dir, error) {
|
||||
_, filename, _, _ := runtime.Caller(1)
|
||||
fullPath, err := filepath.Abs(filepath.Join(path.Dir(filename), dir))
|
||||
|
@ -84,8 +84,6 @@ func (ph *ProjectHelper) GenerateProject(projectOptions *ProjectOptions) error {
|
||||
// ph.GenerateWindowsResourceConfig(projectOptions)
|
||||
// }
|
||||
|
||||
ph.log.Yellow("Project '%s' generated in directory '%s'!", projectOptions.Name, projectOptions.OutputDirectory)
|
||||
ph.log.Yellow("To compile the project, run 'wails build' in the project directory.")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ func (t *TemplateHelper) GetTemplateDetails() (map[string]*TemplateDetails, erro
|
||||
func (t *TemplateHelper) GetTemplateFilenames(template *TemplateDetails) (*slicer.StringSlicer, error) {
|
||||
|
||||
// Get the subdirectory details
|
||||
templateDir, err := t.fs.Dir(template.Path)
|
||||
templateDir, err := t.fs.Directory(template.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -2,7 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/leaanthony/spinner"
|
||||
"github.com/wailsapp/wails/cmd"
|
||||
)
|
||||
|
||||
@ -50,11 +53,33 @@ Any flags that are required and not given will be prompted for.`
|
||||
}
|
||||
}
|
||||
|
||||
genSpinner := spinner.NewSpinner()
|
||||
genSpinner.SetSpinSpeed(50)
|
||||
genSpinner.Start("Generating project...")
|
||||
|
||||
// Generate the project
|
||||
err = projectHelper.GenerateProject(projectOptions)
|
||||
if err != nil {
|
||||
logger.Error(err.Error())
|
||||
genSpinner.Error()
|
||||
return err
|
||||
}
|
||||
genSpinner.Success()
|
||||
|
||||
// Build the project
|
||||
cwd, _ := os.Getwd()
|
||||
projectDir := filepath.Join(cwd, projectOptions.OutputDirectory)
|
||||
program := cmd.NewProgramHelper()
|
||||
buildSpinner := spinner.NewSpinner()
|
||||
buildSpinner.SetSpinSpeed(50)
|
||||
buildSpinner.Start("Building project (this may take a while)...")
|
||||
err = program.RunCommandArray([]string{"wails", "build"}, projectDir)
|
||||
if err != nil {
|
||||
buildSpinner.Error(err.Error())
|
||||
return err
|
||||
}
|
||||
buildSpinner.Success()
|
||||
logger.Yellow("Project '%s' built in directory '%s'!", projectOptions.Name, projectOptions.OutputDirectory)
|
||||
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user