commit 3430141184966eed53b089b2c884a447b63f0999
parent c5fe2eb7e7b9ce4d15f19b36b86b0dcd200a7bbc
Author: vx-clutch <[email protected]>
Date: Sun, 28 Dec 2025 15:51:58 -0500
new creation format
Diffstat:
3 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/main.go b/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
}
diff --git a/modules/config/config.go b/modules/config/config.go
@@ -10,6 +10,7 @@ var Doc string
var Port *int
var Color *bool
var Static *bool
+var Docker *bool
type AppConfig struct {
App struct {
diff --git a/modules/new/new.go b/modules/new/new.go
@@ -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
}