From 3430141184966eed53b089b2c884a447b63f0999 Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Sun, 28 Dec 2025 15:51:58 -0500 Subject: [PATCH] new creation format --- main.go | 3 ++- modules/config/config.go | 1 + modules/new/new.go | 52 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 4fc9e98..b54d3a7 100644 --- 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 index 297c5d5..1a9ba14 100644 --- 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 index 71ad79e..a3b8e63 100644 --- 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 }