Compare commits
2 Commits
c5fe2eb7e7
...
c43e905729
| Author | SHA1 | Date | |
|---|---|---|---|
| c43e905729 | |||
| 3430141184 |
3
main.go
3
main.go
@@ -25,7 +25,8 @@ var documentation string
|
|||||||
func init() {
|
func init() {
|
||||||
config.Port = flag.Int("p", 3000, "Set the server port")
|
config.Port = flag.Int("p", 3000, "Set the server port")
|
||||||
config.Color = flag.Bool("no-color", false, "Disable color output")
|
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.Lib = lib
|
||||||
config.Doc = documentation
|
config.Doc = documentation
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ var Doc string
|
|||||||
var Port *int
|
var Port *int
|
||||||
var Color *bool
|
var Color *bool
|
||||||
var Static *bool
|
var Static *bool
|
||||||
|
var Docker *bool
|
||||||
|
|
||||||
type AppConfig struct {
|
type AppConfig struct {
|
||||||
App struct {
|
App struct {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package new
|
package new
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fes/modules/config"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@@ -26,7 +27,7 @@ func getName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* helper function for writing files */
|
/* 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)
|
dir := filepath.Dir(path)
|
||||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -49,6 +50,22 @@ func Project(dir string) error {
|
|||||||
return err
|
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()
|
name := getName()
|
||||||
|
|
||||||
write("www/index.lua", `local fes = require("fes")
|
write("www/index.lua", `local fes = require("fes")
|
||||||
@@ -64,5 +81,38 @@ return site`, name)
|
|||||||
name = "%s"
|
name = "%s"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = ["%s"]`, dir, name)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user