new creation format
This commit is contained in:
3
main.go
3
main.go
@@ -25,7 +25,8 @@ var documentation string
|
||||
func init() {
|
||||
config.Port = flag.Int("p", 3000, "Set the server port")
|
||||
config.Color = flag.Bool("no-color", false, "Disable color output")
|
||||
config.Static = flag.Bool("static", false, "Render and save all pages.")
|
||||
config.Static = flag.Bool("static", false, "Render and save all pages")
|
||||
config.Docker = flag.Bool("docker", false, "Create a docker project")
|
||||
config.Lib = lib
|
||||
config.Doc = documentation
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ var Doc string
|
||||
var Port *int
|
||||
var Color *bool
|
||||
var Static *bool
|
||||
var Docker *bool
|
||||
|
||||
type AppConfig struct {
|
||||
App struct {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package new
|
||||
|
||||
import (
|
||||
"fes/modules/config"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -26,7 +27,7 @@ func getName() string {
|
||||
}
|
||||
|
||||
/* helper function for writing files */
|
||||
func write(path string, format string, args ...interface{}) error {
|
||||
func write(path string, format string, args ...any) error {
|
||||
dir := filepath.Dir(path)
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
panic(err)
|
||||
@@ -49,6 +50,22 @@ func Project(dir string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if *config.Docker {
|
||||
write("docker-compose.yml", `services:
|
||||
%s:
|
||||
image: git.vxserver.dev/fsd/fes:latest
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- ./app:/app`, dir)
|
||||
if err := os.Mkdir("app", 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.Chdir("app"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
name := getName()
|
||||
|
||||
write("www/index.lua", `local fes = require("fes")
|
||||
@@ -64,5 +81,38 @@ return site`, name)
|
||||
name = "%s"
|
||||
version = "0.0.1"
|
||||
authors = ["%s"]`, dir, name)
|
||||
write("README.md", strings.ReplaceAll(`# %s
|
||||
|
||||
$$$$$$
|
||||
fes new %s
|
||||
$$$$$$
|
||||
|
||||
> **Know what you are doing?** Delete this file. Have fun!
|
||||
|
||||
## Project Structure
|
||||
|
||||
Inside your Fes project, you'll see the following directories and files:
|
||||
|
||||
$$$$$$
|
||||
.
|
||||
├── Fes.toml
|
||||
├── README.md
|
||||
└── www
|
||||
└── index.lua
|
||||
$$$$$$
|
||||
|
||||
Fes looks for $$.lua$$ files in the $$www/$$ directory. Each file is exposed as a route based on its file name.
|
||||
|
||||
## Commands
|
||||
|
||||
All commands are run from the root of the project, from a terminal:
|
||||
|
||||
| Command | Action |
|
||||
| :------------------------ | :----------------------------------------------- |
|
||||
| $$fes run .$$ | Runs the project at $$.$$ |
|
||||
|
||||
## What to learn more?
|
||||
|
||||
Check out [Fes's docs](https://docs.vxserver.dev/static/fes.html).`, "$$", "`"), dir, dir)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user