mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 19:50:15 +08:00
Only run default command if no args
Add custom template (Frameworks)
This commit is contained in:
parent
859b2dd638
commit
53cf2bb953
@ -172,7 +172,10 @@ func (c *Command) Run(args []string) error {
|
|||||||
if c.App.defaultCommand != nil {
|
if c.App.defaultCommand != nil {
|
||||||
// Prevent recursion!
|
// Prevent recursion!
|
||||||
if c.App.defaultCommand != c {
|
if c.App.defaultCommand != c {
|
||||||
return c.App.defaultCommand.Run(args)
|
// only run default command if no args passed
|
||||||
|
if len(args) == 0 {
|
||||||
|
return c.App.defaultCommand.Run(args)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
cmd/frameworks/a_frameworks-packr.go
Normal file
16
cmd/frameworks/a_frameworks-packr.go
Normal file
File diff suppressed because one or more lines are too long
16
cmd/frameworks/bootstrap4default.go
Normal file
16
cmd/frameworks/bootstrap4default.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// +build frameworkbootstrap4
|
||||||
|
|
||||||
|
package frameworks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gobuffalo/packr"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
assets := packr.NewBox("./bootstrap4default/assets")
|
||||||
|
FrameworkToUse = &Framework{
|
||||||
|
Name: "Bootstrap 4",
|
||||||
|
JS: assets.String("bootstrap.bundle.min.js"),
|
||||||
|
CSS: assets.String("bootstrap.min.css"),
|
||||||
|
}
|
||||||
|
}
|
16
cmd/frameworks/bootstrap4default/a_bootstrap4-packr.go
Normal file
16
cmd/frameworks/bootstrap4default/a_bootstrap4-packr.go
Normal file
File diff suppressed because one or more lines are too long
22
cmd/frameworks/bootstrap4default/assets/LICENSE
Normal file
22
cmd/frameworks/bootstrap4default/assets/LICENSE
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2011-2018 Twitter, Inc.
|
||||||
|
Copyright (c) 2011-2018 The Bootstrap Authors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
7
cmd/frameworks/bootstrap4default/assets/bootstrap.bundle.min.js
vendored
Normal file
7
cmd/frameworks/bootstrap4default/assets/bootstrap.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
cmd/frameworks/bootstrap4default/assets/bootstrap.min.css
vendored
Normal file
7
cmd/frameworks/bootstrap4default/assets/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
17
cmd/frameworks/bootstrap4default/main.go
Normal file
17
cmd/frameworks/bootstrap4default/main.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// +build frameworkbootstrap4
|
||||||
|
|
||||||
|
package bootstrap4
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gobuffalo/packr"
|
||||||
|
"github.com/wailsapp/wails/frameworks"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
assets := packr.NewBox("./assets")
|
||||||
|
frameworks.FrameworkToUse = &frameworks.Framework{
|
||||||
|
Name: "Bootstrap 4",
|
||||||
|
JS: assets.String("bootstrap.bundle.min.js"),
|
||||||
|
CSS: assets.String("bootstrap.min.css"),
|
||||||
|
}
|
||||||
|
}
|
5
cmd/frameworks/bootstrap4default/metadata.json
Normal file
5
cmd/frameworks/bootstrap4default/metadata.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"Name": "Bootstrap 4",
|
||||||
|
"Description": "Standard Bootstrap 4 with default theme",
|
||||||
|
"BuildTag": "frameworkbootstrap4"
|
||||||
|
}
|
16
cmd/frameworks/bootstrap4lux.go
Normal file
16
cmd/frameworks/bootstrap4lux.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// +build frameworkbootstrap4lux
|
||||||
|
|
||||||
|
package frameworks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gobuffalo/packr"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
assets := packr.NewBox("./bootstrap4lux/assets")
|
||||||
|
FrameworkToUse = &Framework{
|
||||||
|
Name: "Bootstrap 4 (Lux)",
|
||||||
|
JS: assets.String("bootstrap.bundle.min.js"),
|
||||||
|
CSS: assets.String("bootstrap.min.css"),
|
||||||
|
}
|
||||||
|
}
|
16
cmd/frameworks/bootstrap4lux/a_bootstrap4-packr.go
Normal file
16
cmd/frameworks/bootstrap4lux/a_bootstrap4-packr.go
Normal file
File diff suppressed because one or more lines are too long
22
cmd/frameworks/bootstrap4lux/assets/LICENSE
Normal file
22
cmd/frameworks/bootstrap4lux/assets/LICENSE
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2011-2018 Twitter, Inc.
|
||||||
|
Copyright (c) 2011-2018 The Bootstrap Authors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
7
cmd/frameworks/bootstrap4lux/assets/bootstrap.bundle.min.js
vendored
Normal file
7
cmd/frameworks/bootstrap4lux/assets/bootstrap.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
12
cmd/frameworks/bootstrap4lux/assets/bootstrap.min.css
vendored
Normal file
12
cmd/frameworks/bootstrap4lux/assets/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
17
cmd/frameworks/bootstrap4lux/main.go
Normal file
17
cmd/frameworks/bootstrap4lux/main.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// +build frameworkbootstrap4lux
|
||||||
|
|
||||||
|
package bootstrap4
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gobuffalo/packr"
|
||||||
|
"github.com/wailsapp/wails/frameworks"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
assets := packr.NewBox("./assets")
|
||||||
|
frameworks.FrameworkToUse = &frameworks.Framework{
|
||||||
|
Name: "Bootstrap 4 (Lux)",
|
||||||
|
JS: assets.String("bootstrap.bundle.min.js"),
|
||||||
|
CSS: assets.String("bootstrap.min.css"),
|
||||||
|
}
|
||||||
|
}
|
5
cmd/frameworks/bootstrap4lux/metadata.json
Normal file
5
cmd/frameworks/bootstrap4lux/metadata.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"Name": "Bootstrap 4 (Lux)",
|
||||||
|
"Description": "Bootstrap with Lux theme",
|
||||||
|
"BuildTag": "frameworkbootstrap4lux"
|
||||||
|
}
|
13
cmd/frameworks/main.go
Normal file
13
cmd/frameworks/main.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package frameworks
|
||||||
|
|
||||||
|
// Framework has details about a specific framework
|
||||||
|
type Framework struct {
|
||||||
|
Name string
|
||||||
|
JS string
|
||||||
|
CSS string
|
||||||
|
Options string
|
||||||
|
}
|
||||||
|
|
||||||
|
// FrameworkToUse is the framework we will use when building
|
||||||
|
// Set by `wails init`, used by `wails build`
|
||||||
|
var FrameworkToUse *Framework
|
@ -256,7 +256,6 @@ func (po *ProjectOptions) PromptForInputs() error {
|
|||||||
// Ask for the framework
|
// Ask for the framework
|
||||||
var frameworkName string
|
var frameworkName string
|
||||||
frameworks, err := GetFrameworks()
|
frameworks, err := GetFrameworks()
|
||||||
fmt.Printf("Frameworks = %+v\n", frameworks)
|
|
||||||
frameworkNames := []string{}
|
frameworkNames := []string{}
|
||||||
metadataMap := make(map[string]*FrameworkMetadata)
|
metadataMap := make(map[string]*FrameworkMetadata)
|
||||||
for _, frameworkMetadata := range frameworks {
|
for _, frameworkMetadata := range frameworks {
|
||||||
@ -311,6 +310,8 @@ func (po *ProjectOptions) PromptForInputs() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteProjectConfig writes the project configuration into
|
||||||
|
// the project directory
|
||||||
func (po *ProjectOptions) WriteProjectConfig() error {
|
func (po *ProjectOptions) WriteProjectConfig() error {
|
||||||
targetDir, err := filepath.Abs(po.OutputDirectory)
|
targetDir, err := filepath.Abs(po.OutputDirectory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -326,6 +327,8 @@ func (po *ProjectOptions) WriteProjectConfig() error {
|
|||||||
return ioutil.WriteFile(targetFile, filedata, 0600)
|
return ioutil.WriteFile(targetFile, filedata, 0600)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadConfig loads the project configuration file from the
|
||||||
|
// given directory
|
||||||
func (po *ProjectOptions) LoadConfig(projectDir string) error {
|
func (po *ProjectOptions) LoadConfig(projectDir string) error {
|
||||||
targetFile := filepath.Join(projectDir, "project.json")
|
targetFile := filepath.Join(projectDir, "project.json")
|
||||||
rawBytes, err := ioutil.ReadFile(targetFile)
|
rawBytes, err := ioutil.ReadFile(targetFile)
|
||||||
|
19
cmd/templates/custom/main.go
Normal file
19
cmd/templates/custom/main.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
wails "github.com/wailsapp/wails"
|
||||||
|
)
|
||||||
|
|
||||||
|
var html = `<h1> Custom Project </h1>`
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
// Initialise the app
|
||||||
|
app := wails.CreateApp(&wails.AppConfig{
|
||||||
|
Width: 800,
|
||||||
|
Height: 600,
|
||||||
|
Title: "My Project",
|
||||||
|
HTML: html,
|
||||||
|
})
|
||||||
|
app.Run()
|
||||||
|
}
|
7
cmd/templates/custom/template.json
Normal file
7
cmd/templates/custom/template.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"name": "Custom",
|
||||||
|
"shortdescription": "Choose your own CSS Framework",
|
||||||
|
"description": "A basic template allowing use of CSS Frameworks",
|
||||||
|
"author": "Lea Anthony<lea.anthony@gmail.com>",
|
||||||
|
"created": "2018-10-22"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user