5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 21:29:09 +08:00

[v2] Misc template updates

This commit is contained in:
Lea Anthony 2021-09-19 17:13:54 +10:00
parent 817952f3d0
commit ae29a3b1cd
21 changed files with 315 additions and 2861 deletions

View File

@ -6,10 +6,12 @@ Congratulations on generating your template!
The next steps to complete the template are:
1. Complete the fields in the `template.json` file.
1. Complete the fields in the `template.json` file.
- It is really important to ensure `helpurl` is valid as this is where users of the template will be directed for help.
2. Update `README.md`.
3. Edit `wails.tmpl.json` and ensure all fields are correct, especially:
- `html` - path to your `index.html`
3. Edit `wails.json` and ensure all fields are correct, especially:
- `assetdir` - path to your assets
- `wailsjsdir` - path to generate wailsjs modules
- `frontend:install` - The command to install your frontend dependencies
- `frontend:build` - The command to build your frontend
4. Remove any `public` or `dist` directories.
@ -21,10 +23,12 @@ You can test your template by running this command:
`wails init -name test -t {{.TemplateDir}}`
### Checklist
### Checklist
Once generated, do the following tests:
- Change into the new project directory and run `wails build`. A working binary should be generated in the `build/bin` project directory.
- Run `wails dev`. This will compile your backend and run it. You should be able to go into the frontend directory and run `npm run dev` (or whatever your dev command is) and this should run correctly. You should be able to then open a browser to your local dev server and the application should work.
- Run `wails dev`. This will compile your app and run it.
- You should be able to see your application running on http://localhost:34115/
## Publishing your template

View File

@ -7,7 +7,7 @@ import (
// App struct
type App struct {
runtime context.Context
ctx context.Context
}
// NewApp creates a new App application struct
@ -16,20 +16,16 @@ func NewApp() *App {
}
// startup is called at application startup
func (b *App) startup(ctx context.Context) {
// Perform your setup here
//TODO: move to new runtime layout
//b.runtime = runtime
//runtime.Window.SetTitle("{{.ProjectName}}")
func (a *App) startup(ctx context.Context) {
a.ctx = ctx
}
// shutdown is called at application termination
func (b *App) shutdown(ctx context.Context) {
func (a *App) shutdown(ctx context.Context) {
// Perform your teardown here
}
// Greet returns a greeting for the given name
func (b *App) Greet(name string) string {
func (a *App) Greet(name string) string {
return fmt.Sprintf("Hello %s!", name)
}

View File

@ -0,0 +1,93 @@
Copyright 2016 The Nunito Project Authors (contact@sansoxygen.com),
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 551 436" version="1.1" xmlns="http://www.w3.org/2000/svg"
xml:space="preserve"
style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g transform="matrix(1.27527,0,0,1.27527,104.01,410.563)">
<path d="M0,-51.891L14.429,-51.891L13.043,-21.183L22.568,-51.891L34.226,-51.891L34.084,-21.183L42.365,-51.891L56.794,-51.891L38.526,0L25.198,0L25.34,-32.45L15.211,0L1.919,0L0,-51.891Z"
style="fill:white;fill-rule:nonzero;"/>
</g>
<g transform="matrix(1.27527,0,0,1.27527,224.985,367.503)">
<path d="M0,15.639L5.793,15.639L5.971,-3.589L0,15.639ZM-20.187,33.765L-0.675,-18.126L16.42,-18.126L20.08,33.765L5.437,33.765L5.509,26.123L-3.057,26.123L-5.332,33.765L-20.187,33.765Z"
style="fill:white;fill-rule:nonzero;"/>
</g>
<g transform="matrix(0.19929,-1.2596,-1.2596,-0.19929,332.323,396.949)">
<path d="M-16.046,33.107L36.491,33.107L38.757,18.784L-13.785,18.82L-16.046,33.107Z"
style="fill:white;fill-rule:nonzero;"/>
</g>
<g transform="matrix(1.27527,0,0,1.27527,353.217,344.388)">
<path d="M0,51.891L8.246,0L22.781,0L16.597,39.024L27.224,39.024L25.199,51.891L0,51.891Z"
style="fill:white;fill-rule:nonzero;"/>
</g>
<g transform="matrix(1.27527,0,0,1.27527,427.939,364.922)">
<path d="M0,19.83C1.611,21.181 3.305,22.224 5.083,22.959C6.859,23.693 8.565,24.06 10.2,24.06C11.645,24.06 12.794,23.663 13.647,22.87C14.5,22.076 14.927,20.992 14.927,19.617C14.927,18.434 14.571,17.254 13.861,16.081C13.15,14.908 11.775,13.351 9.738,11.408C7.273,9.015 5.58,6.906 4.655,5.081C3.731,3.257 3.27,1.243 3.27,-0.96C3.27,-5.912 4.839,-9.846 7.979,-12.76C11.118,-15.674 15.377,-17.132 20.756,-17.132C22.936,-17.132 25.008,-16.889 26.975,-16.403C28.941,-15.917 30.943,-15.165 32.982,-14.146L30.92,-1.493C29.356,-2.583 27.834,-3.412 26.354,-3.981C24.872,-4.551 23.457,-4.835 22.106,-4.835C20.898,-4.835 19.943,-4.521 19.245,-3.894C18.546,-3.265 18.196,-2.406 18.196,-1.316C18.196,0.154 19.535,2.215 22.213,4.868C22.544,5.2 22.805,5.46 22.995,5.649C25.696,8.304 27.473,10.578 28.326,12.475C29.179,14.37 29.605,16.56 29.605,19.049C29.605,24.594 27.893,28.965 24.469,32.163C21.046,35.361 16.36,36.962 10.413,36.962C7.877,36.962 5.479,36.66 3.216,36.056C0.953,35.45 -0.948,34.615 -2.488,33.549L0,19.83Z"
style="fill:white;fill-rule:nonzero;"/>
</g>
<g transform="matrix(-166.599,4.57132,4.57132,166.599,147.403,167.648)">
<path d="M0.883,-0.081L0.121,0.081L0.256,-0.063L0.883,-0.081Z" style="fill:url(#_Linear1);fill-rule:nonzero;"/>
</g>
<g transform="matrix(-106.443,-16.0669,-16.0669,106.443,428.19,188.033)">
<path d="M0.878,-0.285L-0.073,0.71L-1.186,0.542L0.015,0.207L-0.846,0.077L0.355,-0.258L-0.505,-0.388L0.649,-0.71L0.878,-0.285Z"
style="fill:url(#_Linear2);fill-rule:nonzero;"/>
</g>
<g transform="matrix(-114.484,-162.408,-162.408,114.484,333.291,285.804)">
<path d="M0.44,-0.04L0.44,-0.04L0.44,-0.04L0.265,-0.056L0.177,0.437L-0.311,-0.255L0.262,-0.437L0.568,-0.437L0.44,-0.04Z"
style="fill:url(#_Linear3);fill-rule:nonzero;"/>
</g>
<g transform="matrix(61.6919,58.8091,58.8091,-61.6919,258.631,180.413)">
<path d="M0.5,0L0.5,-0L0.5,0L0.5,0Z" style="fill:url(#_Linear4);fill-rule:nonzero;"/>
</g>
<g transform="matrix(238.126,298.893,298.893,-238.126,113.516,-150.536)">
<path d="M0.622,-0.115L0.761,-0.115L0.806,-0.013L0.826,0.182L0.622,-0.115Z"
style="fill:url(#_Linear5);fill-rule:nonzero;"/>
</g>
<g transform="matrix(-369.529,-97.4118,-97.4118,369.529,582.38,94.027)">
<path d="M0.467,0.005L0.49,0.062L0.271,-0.062L0.467,0.005Z" style="fill:url(#_Linear6);fill-rule:nonzero;"/>
</g>
<g transform="matrix(-496.156,-53.9751,-53.9751,496.156,367.888,125.085)">
<path d="M0.2,0.001L0.219,-0.018L0.614,0.012L0.519,0.089L0.282,0.068L0.2,0.135L0.463,0.194L0.374,0.266L0.138,0.186L0.138,0.186L0.138,0.186L0.047,0.033L-0.131,-0.266L0.2,0.001Z"
style="fill:url(#_Linear7);fill-rule:nonzero;"/>
</g>
<g transform="matrix(185.076,176.427,176.427,-185.076,153.446,80.1488)">
<path d="M0.735,-0L0.735,-0L0.735,0L0.735,-0Z" style="fill:url(#_Linear8);fill-rule:nonzero;"/>
</g>
<defs>
<linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,-3.46945e-18,-3.46945e-18,-1,0,-3.05761e-06)"><stop offset="0" style="stop-color:rgb(227,50,50);stop-opacity:1"/>
<stop offset="1" style="stop-color:rgb(107,0,13);stop-opacity:1"/></linearGradient>
<linearGradient id="_Linear2" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,-1,0,-2.75467e-06)"><stop offset="0" style="stop-color:rgb(227,50,50);stop-opacity:1"/>
<stop offset="1" style="stop-color:rgb(107,0,13);stop-opacity:1"/></linearGradient>
<linearGradient id="_Linear3" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,-1.11022e-16,-1.11022e-16,-1,0,-2.61861e-06)"><stop offset="0" style="stop-color:rgb(227,50,50);stop-opacity:1"/>
<stop offset="1" style="stop-color:rgb(107,0,13);stop-opacity:1"/></linearGradient>
<linearGradient id="_Linear4" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,-5.55112e-17,-5.55112e-17,-1,0,-1.57562e-06)"><stop offset="0" style="stop-color:rgb(227,50,50);stop-opacity:1"/>
<stop offset="1" style="stop-color:rgb(107,0,13);stop-opacity:1"/></linearGradient>
<linearGradient id="_Linear5" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-0.801899,-0.59746,-0.59746,0.801899,1.3495,0.447457)"><stop offset="0" style="stop-color:rgb(227,50,50);stop-opacity:1"/>
<stop offset="1" style="stop-color:rgb(107,0,13);stop-opacity:1"/></linearGradient>
<linearGradient id="_Linear6" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,-2.77556e-17,-2.77556e-17,-1,0,-1.92826e-06)"><stop offset="0" style="stop-color:rgb(227,50,50);stop-opacity:1"/>
<stop offset="1" style="stop-color:rgb(107,0,13);stop-opacity:1"/></linearGradient>
<linearGradient id="_Linear7" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,-1,0,9.68429e-07)"><stop offset="0" style="stop-color:rgb(227,50,50);stop-opacity:1"/>
<stop offset="1" style="stop-color:rgb(107,0,13);stop-opacity:1"/></linearGradient>
<linearGradient id="_Linear8" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,-1,0,1.43665e-07)"><stop offset="0" style="stop-color:rgb(227,50,50);stop-opacity:1"/>
<stop offset="1" style="stop-color:rgb(107,0,13);stop-opacity:1"/></linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@ -0,0 +1,47 @@
html {
text-align: center;
color: white;
background-color: rgba(0, 0, 0, 1);
}
body {
color: white;
font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
margin: 0;
}
@font-face {
font-family: 'Nunito';
font-style: normal;
font-weight: 400;
src: local(''),
url('assets/fonts/nunito-v16-latin-regular.woff2') format('woff2')
}
#result {
margin-top: 1rem;
}
button {
-webkit-appearance: default-button;
padding: 6px;
}
#name {
border-radius: 3px;
outline: none;
height: 20px;
-webkit-font-smoothing: antialiased;
}
#logo {
width: 40%;
height: 40%;
padding-top: 20%;
margin: auto;
display: block;
background-position: center;
background-repeat: no-repeat;
background-image: url("./assets/images/logo-dark.svg");
}

View File

@ -0,0 +1,16 @@
// Get input + focus
let nameElement = document.getElementById("name");
nameElement.focus();
// Setup the greet function
window.greet = function () {
// Get name
let name = nameElement.value;
// Call App.Greet(name)
window.go.main.App.Greet(name).then((result) => {
// Update result with data back from App.Greet()
document.getElementById("result").innerText = result;
});
};

View File

@ -1,27 +0,0 @@
{
"name": "vanilla",
"version": "1.0.0",
"description": "Vanilla Wails v2 template",
"main": "src/main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rollup -c",
"dev": "rollup -c -w",
"start": "sirv dist"
},
"author": "{{.AuthorName}}",
"license": "ISC",
"dependencies": {
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-image": "^2.0.6",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-url": "^6.0.0",
"@wails/runtime": "^1.3.20",
"rollup": "^2.50.4",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-postcss": "^4.0.0",
"rollup-plugin-terser": "^7.0.2",
"sirv-cli": "^1.0.12"
}
}

View File

@ -1,103 +0,0 @@
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import postcss from 'rollup-plugin-postcss';
import image from '@rollup/plugin-image';
import url from '@rollup/plugin-url';
import copy from 'rollup-plugin-copy';
const production = !process.env.ROLLUP_WATCH;
export default {
input: 'src/main.js',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'dist/main.js'
},
onwarn: handleRollupWarning,
plugins: [
image(),
copy({
targets: [
{ src: 'src/index.html', dest: 'dist' },
{ src: 'src/main.css', dest: 'dist' },
]
}),
// Embed binary files
url({
include: ['**/*.woff', '**/*.woff2'],
limit: Infinity,
}),
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration -
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
}),
commonjs(),
// PostCSS preprocessing
postcss({
extensions: ['.css', '.scss'],
extract: true,
minimize: false,
use: [
['sass', {
includePaths: [
'./src',
'./node_modules'
]
}]
],
}),
// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),
// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload('dist'),
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser()
],
watch: {
clearScreen: false
}
};
function handleRollupWarning(warning) {
console.error('ERROR: ' + warning.toString());
}
function serve() {
let server;
function toExit() {
if (server) server.kill(0);
}
return {
writeBundle() {
if (server) return;
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true
});
process.on('SIGTERM', toExit);
process.on('exit', toExit);
}
};
}

File diff suppressed because one or more lines are too long

View File

@ -1,21 +0,0 @@
import {ready} from '@wails/runtime';
ready( () => {
// Get input + focus
let nameElement = document.getElementById("name");
nameElement.focus();
// Setup the greet function
window.greet = function () {
// Get name
let name = nameElement.value;
// Call Basic.Greet(name)
window.backend.main.Basic.Greet(name).then((result) => {
// Update result with data back from Basic.Greet()
document.getElementById("result").innerText = result;
});
};
});

View File

@ -1,9 +1,9 @@
module test
go 1.16
go 1.17
require (
github.com/wailsapp/wails/v2 v2.0.0-alpha
github.com/wailsapp/wails/v2 v2.0.0-alpha
)
replace github.com/wailsapp/wails/v2 v2.0.0-alpha => {{.WailsDirectory}}

View File

@ -1,40 +1,26 @@
package main
import (
"embed"
"log"
"github.com/wailsapp/wails/v2/pkg/options/windows"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/logger"
"github.com/wailsapp/wails/v2/pkg/options"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
// Create application with options
app := NewApp()
err := wails.Run(&options.App{
Title: "{{.ProjectName}}",
Width: 800,
Height: 600,
MinWidth: 400,
MinHeight: 400,
MaxWidth: 1280,
MaxHeight: 1024,
DisableResize: false,
Fullscreen: false,
Frameless: false,
StartHidden: false,
HideWindowOnClose: false,
RGBA: &options.RGBA{0, 0, 0, 255},
Windows: &windows.Options{
WebviewIsTransparent: true,
WindowIsTranslucent: true,
DisableWindowIcon: true,
},
LogLevel: logger.DEBUG,
Title: "{{.ProjectName}}",
Width: 1024,
Height: 768,
Assets: assets,
OnStartup: app.startup,
OnShutdown: app.shutdown,
Bind: []interface{}{

View File

@ -1,11 +1,12 @@
{
"name": "{{.ProjectName}}",
"outputfilename": "{{.BinaryName}}",
"html": "frontend/dist/index.html",
"frontend:build": "npm run build",
"frontend:install": "npm install",
"author": {
"name": "{{.AuthorName}}",
"email": "{{.AuthorEmail}}"
}
"name": "{{.ProjectName}}",
"outputfilename": "{{.BinaryName}}",
"assetdir": "frontend/dist",
"html": "frontend/dist/index.html",
"frontend:build": "npm run build",
"frontend:install": "npm install",
"author": {
"name": "{{.AuthorName}}",
"email": "{{.AuthorEmail}}"
}
}

View File

@ -2,6 +2,7 @@ package template
import (
"embed"
"fmt"
"io"
"os"
"path/filepath"
@ -26,8 +27,8 @@ func AddSubCommand(app *clir.Cli, parent *clir.Command, w io.Writer) {
name := ""
command.StringFlag("name", "The name of the template", &name)
migrate := false
command.BoolFlag("migrate", "This indicates that the current directory is a frontend project and should be used by the template", &migrate)
existingProjectDir := ""
command.StringFlag("frontend", "A path to an existing frontend project to include in the template", &existingProjectDir)
// Quiet Init
quiet := false
@ -35,12 +36,23 @@ func AddSubCommand(app *clir.Cli, parent *clir.Command, w io.Writer) {
command.Action(func() error {
// name is mandatory
if name == "" {
return fmt.Errorf("no template name given")
}
// If the current directory is not empty, we create a new directory
cwd, err := os.Getwd()
if err != nil {
return err
}
templateDir := cwd
templateDir := filepath.Join(cwd, name)
if !fs.DirExists(templateDir) {
err := os.MkdirAll(templateDir, 0755)
if err != nil {
return err
}
}
empty, err := fs.DirIsEmpty(templateDir)
if err != nil {
return err
@ -60,7 +72,7 @@ func AddSubCommand(app *clir.Cli, parent *clir.Command, w io.Writer) {
return err
}
g := gosod.New(baseTemplate)
g.SetTemplateFilters([]string{".template"})
g.SetTemplateFilters([]string{".tmpl"})
err = os.Chdir(templateDir)
if err != nil {
@ -83,8 +95,13 @@ func AddSubCommand(app *clir.Cli, parent *clir.Command, w io.Writer) {
return err
}
err = os.Chdir(cwd)
if err != nil {
return err
}
// If we aren't migrating the files, just exit
if migrate == false {
if existingProjectDir == "" {
return nil
}
@ -95,9 +112,16 @@ func AddSubCommand(app *clir.Cli, parent *clir.Command, w io.Writer) {
return err
}
// Move the files into a new frontend directory
println("Migrating files to frontend directory...")
err = fs.MoveDirExtended(cwd, frontendDir, []string{name})
// Copy the files into a new frontend directory
println("Migrating existing project files to frontend directory...")
sourceDir, err := filepath.Abs(existingProjectDir)
if err != nil {
return err
}
newFrontendDir := filepath.Join(templateDir, "frontend")
err = fs.CopyDirExtended(sourceDir, newFrontendDir, []string{name, "node_modules"})
if err != nil {
return err
}

View File

@ -1,8 +1,8 @@
package menu
type CallbackData struct {
MenuItem *MenuItem
ContextData string
MenuItem *MenuItem
//ContextData string
}
type Callback func(*CallbackData)

View File

@ -39,9 +39,9 @@ func TestStringify(t *testing.T) {
{OptionOrAlt("a"), "Alt+A", Windows},
{OptionOrAlt("a"), "Option+A", Mac},
{OptionOrAlt("a"), "Alt+A", Linux},
{Super("a"), "Win+A", Windows},
{Super("a"), "Cmd+A", Mac},
{Super("a"), "Super+A", Linux},
//{Super("a"), "Win+A", Windows},
//{Super("a"), "Cmd+A", Mac},
//{Super("a"), "Super+A", Linux},
// Dual Combo non duplicate
{Combo("a", ControlKey, OptionOrAltKey), "Ctrl+Alt+A", Windows},
@ -53,17 +53,17 @@ func TestStringify(t *testing.T) {
{Combo("a", ShiftKey, OptionOrAltKey), "Shift+Alt+A", Windows},
{Combo("a", ShiftKey, OptionOrAltKey), "Shift+Option+A", Mac},
{Combo("a", ShiftKey, OptionOrAltKey), "Shift+Alt+A", Linux},
{Combo("a", SuperKey, OptionOrAltKey), "Win+Alt+A", Windows},
{Combo("a", SuperKey, OptionOrAltKey), "Cmd+Option+A", Mac},
{Combo("a", SuperKey, OptionOrAltKey), "Super+Alt+A", Linux},
//{Combo("a", SuperKey, OptionOrAltKey), "Win+Alt+A", Windows},
//{Combo("a", SuperKey, OptionOrAltKey), "Cmd+Option+A", Mac},
//{Combo("a", SuperKey, OptionOrAltKey), "Super+Alt+A", Linux},
// Combo duplicate
{Combo("a", OptionOrAltKey, OptionOrAltKey), "Alt+A", Windows},
{Combo("a", OptionOrAltKey, OptionOrAltKey), "Option+A", Mac},
{Combo("a", OptionOrAltKey, OptionOrAltKey), "Alt+A", Linux},
{Combo("a", OptionOrAltKey, SuperKey, OptionOrAltKey), "Alt+Win+A", Windows},
{Combo("a", OptionOrAltKey, SuperKey, OptionOrAltKey), "Option+Cmd+A", Mac},
{Combo("a", OptionOrAltKey, SuperKey, OptionOrAltKey), "Alt+Super+A", Linux},
//{Combo("a", OptionOrAltKey, SuperKey, OptionOrAltKey), "Alt+Win+A", Windows},
//{Combo("a", OptionOrAltKey, SuperKey, OptionOrAltKey), "Option+Cmd+A", Mac},
//{Combo("a", OptionOrAltKey, SuperKey, OptionOrAltKey), "Alt+Super+A", Linux},
}
for index, tt := range tests {
t.Run(strconv.Itoa(index), func(t *testing.T) {

View File

@ -1,5 +1,6 @@
package menu
/*
// DefaultMacMenu returns a default menu including the default
// Application and Edit menus. Use `.Append()` to add to it.
func DefaultMacMenu() *Menu {
@ -8,3 +9,4 @@ func DefaultMacMenu() *Menu {
EditMenu(),
)
}
*/