Skip to content

Commit

Permalink
v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
asoseil committed Oct 14, 2016
2 parents 8a2275c + 897c31f commit c9cde5a
Show file tree
Hide file tree
Showing 14 changed files with 1,538 additions and 283 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ _testmain.go
.idea
.DS_Store

server/assets
docker
vendor
bin
Expand Down
68 changes: 33 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@

A Go build system with file watchers, output streams and live reload. Run, build and watch file changes with custom paths

![Preview](http://i.imgur.com/GV2Yus5.png)
![Preview](http://i.imgur.com/dJbNZjt.gif)

#### What's new

##### v1.1
- [ ] Windows support - **Moved to 1.2**
- [x] Custom paths for the commands fast/add
- [x] Save output on a file
- [x] Enable the fields Before/After
- [x] Web panel (localhost:5000)


#### Features

Expand Down Expand Up @@ -48,29 +58,28 @@ A Go build system with file watchers, output streams and live reload. Run, build
```
--name="Project Name" -> Name, if not specified takes the working directory name
--path="server" -> Base Path, if not specified takes the working directory name
--path="server" -> Custom Path, if not specified takes the working directory name
--build -> Enables the build
--test -> Enables the tests
--test -> Enables the tests
--no-bin -> Disables the installation
--no-run -> Disables the run
--no-fmt -> Disables the fmt (go fmt)
--no-server -> Disables the web panel (port :5000)
```
Examples:
```
$ realize add
```
```
$ realize add --path="mypath"
```
```
$ realize add --name="My Project" --build
```
```
$ realize add --name="My Project" --path="/projects/package" --build
```
```
$ realize add --name="My Project" --path="projects/package" --build --no-run
$ realize add --path="/Users/alessio/go/src/github.com/tockins/realize-examples/coin/"
```
If you want, you can specify additional arguments for your project.
Expand Down Expand Up @@ -108,20 +117,23 @@ A Go build system with file watchers, output streams and live reload. Run, build
The fast command supports the following custom parameters:
```
--path="server" -> Custom Path, if not specified takes the working directory name
--build -> Enables the build
--test -> Enables the tests
--config -> Take the defined settings if exist a config file
--no-bin -> Disables the installation
--no-run -> Disables the run
--no-fmt -> Disables the fmt (go fmt)
--config -> Take the defined settings if exist a config file
--no-server -> Disables the web panel (port :5000)
```
The "fast" command supporst addittional arguments as the "add" command.
The "fast" command supports addittional arguments as the "add" command.
```
$ realize fast --no-run yourParams --yourFlags // correct
$ realize fast yourParams --yourFlags --no-run // wrong
$ realize fast --path="/Users/alessio/go/src/github.com/tockins/realize-examples/coin/"
```
Expand All @@ -138,7 +150,6 @@ A Go build system with file watchers, output streams and live reload. Run, build
- For more examples check [Realize Examples](https://github.com/tockins/realize-examples)
```
version: "1.0"
projects:
- app_name: App One -> name
app_path: one -> root path
Expand All @@ -159,30 +170,17 @@ A Go build system with file watchers, output streams and live reload. Run, build
- bin
exts: -> file extensions to observe for live reload
- .go
- app_name: App Two -> another project
app_path: two
app_run: true
app_build: true
app_bin: true
app_watcher:
paths:
- /
ignore_paths:
- vendor
- bin
exts:
- .go
output: -> enable/disable the output destinations
cli: true -> cli output
file: true -> creates an output file inside the project
```
#### Next release
##### Milestone 1.1
- [ ] Testing on windows
- [ ] Custom paths for the commands fast/add
- [ ] Save output on a file
- [ ] Enable the fields Before/After
- [ ] Web panel - **Maybe**
##### v1.2
- [ ] Windows support
- [ ] Go generate support
#### Contacts
Expand Down
151 changes: 151 additions & 0 deletions app/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
package app

import (
"fmt"
c "github.com/tockins/realize/cli"
s "github.com/tockins/realize/server"
"gopkg.in/urfave/cli.v2"
"log"
"os"
"syscall"
)

const (
Name = "Realize"
Version = "1.1"
Description = "A Go build system with file watchers, output streams and live reload. Run, build and watch file changes with custom paths"
Limit = 10000
Config = "r.config.yaml"
Output = "r.output.log"
)

var r realize
var R Realizer

// Realizer interface for wrap the cli, app and server functions
type Realizer interface {
Wdir() string
Before() error
Red(string) string
Blue(string) string
BlueS(string) string
Handle(error) error
Serve(*cli.Context)
Fast(*cli.Context) error
Run(p *cli.Context) error
Add(p *cli.Context) error
Remove(p *cli.Context) error
List(p *cli.Context) error
}

// Realize struct contains the general app informations
type realize struct {
Name, Description, Author, Email string
Version string
Limit uint64
Blueprint c.Blueprint
Server s.Server
Files map[string]string
Sync chan string
}

// Application initialization
func init() {
r = realize{
Name: Name,
Version: Version,
Description: Description,
Limit: Limit,
Files: map[string]string{
"config": Config,
"output": Output,
},
Sync: make(chan string),
}
r.Blueprint = c.Blueprint{
Files: r.Files,
Sync: r.Sync,
}
r.Server = s.Server{
Blueprint: &r.Blueprint,
Files: r.Files,
Sync: r.Sync,
}
r.Increase()
R = &r
}

// Flimit defines the max number of watched files
func (r *realize) Increase() {
// increases the files limit
var rLimit syscall.Rlimit
rLimit.Max = r.Limit
rLimit.Cur = r.Limit
err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
fmt.Println(c.Red("Error Setting Rlimit "), err)
}
}

func (r *realize) Red(s string) string {
return c.Red(s)
}

func (r *realize) Blue(s string) string {
return c.Blue(s)
}

func (r *realize) BlueS(s string) string {
return c.BlueS(s)
}

func (r *realize) Wdir() string {
return c.WorkingDir()
}

func (r *realize) Serve(p *cli.Context) {
if !p.Bool("no-server") {
r.Server.Start()
}
}

func (r *realize) Run(p *cli.Context) error {
r.Serve(p)
return r.Blueprint.Run()
}

func (r *realize) Fast(p *cli.Context) error {
r.Blueprint.Add(p)
r.Serve(p)
return r.Blueprint.Fast(p)
}

func (r *realize) Add(p *cli.Context) error {
return r.Blueprint.Insert(p)
}

func (r *realize) Remove(p *cli.Context) error {
return r.Blueprint.Insert(p)
}

func (r *realize) List(p *cli.Context) error {
return r.Blueprint.List()
}

func (r *realize) Before() error {
fmt.Println(r.Blue(r.Name) + " - " + r.Blue(r.Version))
fmt.Println(r.BlueS(r.Description) + "\n")
gopath := os.Getenv("GOPATH")
if gopath == "" {
log.Fatal(r.Red("$GOPATH isn't set up properly"))
}
return nil
}

func (r *realize) Handle(err error) error {
if err != nil {
fmt.Println(r.Red(err.Error()))
return nil
}
return nil
}
Loading

0 comments on commit c9cde5a

Please sign in to comment.