git commit -m "feat: initial release of Strata framework v0.1.0
- Static compiler with STRC pattern (Static Template Resolution with
Compartmentalized Layers)
- Template syntax: { } interpolation, { s-for }, { s-if/s-elif/s-else
}
- File types: .strata, .compiler.sts, .service.sts, .api.sts, .sts,
.scss
- CLI tools: strata dev, strata build, strata g (generators)
- create-strata scaffolding CLI with Pokemon API example
- Dev server with WebSocket HMR (Hot Module Replacement)
- Documentation: README, ARCHITECTURE, CHANGELOG, CONTRIBUTING,
LICENSE
This commit is contained in:
99
compiler/cmd/strata/main.go
Normal file
99
compiler/cmd/strata/main.go
Normal file
@@ -0,0 +1,99 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var version = "0.1.0"
|
||||
|
||||
func main() {
|
||||
rootCmd := &cobra.Command{
|
||||
Use: "strata",
|
||||
Short: "Strata - Static Template Rendering Architecture",
|
||||
Version: version,
|
||||
}
|
||||
|
||||
rootCmd.AddCommand(devCmd())
|
||||
rootCmd.AddCommand(buildCmd())
|
||||
rootCmd.AddCommand(previewCmd())
|
||||
rootCmd.AddCommand(generateCmd())
|
||||
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func devCmd() *cobra.Command {
|
||||
var port int
|
||||
var noOpen bool
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "dev",
|
||||
Short: "Start development server with file watcher",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf("Starting Strata dev server on port %d...\n", port)
|
||||
startDevServer(port, !noOpen)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().IntVarP(&port, "port", "p", 3000, "Port to run dev server")
|
||||
cmd.Flags().BoolVar(&noOpen, "no-open", false, "Don't open browser on start")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func buildCmd() *cobra.Command {
|
||||
var analyze bool
|
||||
var watch bool
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "build",
|
||||
Short: "Build for production",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("Building Strata application...")
|
||||
runBuild(analyze, watch)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().BoolVarP(&analyze, "analyze", "a", false, "Analyze bundle size")
|
||||
cmd.Flags().BoolVarP(&watch, "watch", "w", false, "Watch mode")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func previewCmd() *cobra.Command {
|
||||
var port int
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "preview",
|
||||
Short: "Preview production build",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf("Previewing build on port %d...\n", port)
|
||||
startPreviewServer(port)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().IntVarP(&port, "port", "p", 4000, "Port for preview server")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func generateCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "generate [type] [name]",
|
||||
Aliases: []string{"g"},
|
||||
Short: "Generate component, page, or store",
|
||||
Args: cobra.ExactArgs(2),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
genType := args[0]
|
||||
name := args[1]
|
||||
generateFile(genType, name)
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
||||
Reference in New Issue
Block a user