Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,30 @@ dist:
GOOS=linux GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o build/gozen-linux-amd64
cp build/gozen-linux-amd64 build/gozen
tar -zcvf build/gozen-linux-amd64.tar.gz build/gozen man/gozen.1
cd build && sha256sum gozen-linux-amd64.tar.gz > checksum-sha256sum.txt

GOOS=linux GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -o build/gozen-linux-arm64
cp build/gozen-linux-arm64 build/gozen
tar -zcvf build/gozen-linux-arm64.tar.gz build/gozen man/gozen.1
cd build && sha256sum gozen-linux-arm64.tar.gz >> checksum-sha256sum.txt

GOOS=linux GOARCH=arm go build -ldflags="$(LDFLAGS)" -o build/gozen-linux-arm
cp build/gozen-linux-arm build/gozen
tar -zcvf build/gozen-linux-arm.tar.gz build/gozen man/gozen.1
cd build && sha256sum gozen-linux-arm.tar.gz >> checksum-sha256sum.txt

GOOS=darwin GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o build/gozen-darwin-amd64
cp build/gozen-darwin-amd64 build/gozen
tar -zcvf build/gozen-darwin-amd64.tar.gz build/gozen man/gozen.1
cd build && sha256sum gozen-darwin-amd64.tar.gz >> checksum-sha256sum.txt

GOOS=darwin GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -o build/gozen-darwin-arm64
cp build/gozen-darwin-arm64 build/gozen
tar -zcvf build/gozen-darwin-arm64.tar.gz build/gozen man/gozen.1
cd build && sha256sum gozen-darwin-arm64.tar.gz >> checksum-sha256sum.txt
rm build/gozen

GOOS=windows GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o build/gozen-windows-amd64.exe
cd build && sha256sum gozen-windows-amd64.exe >> checksum-sha256sum.txt
GOOS=windows GOARCH=386 go build -ldflags="$(LDFLAGS)" -o build/gozen-windows-i386.exe
cd build && sha256sum gozen-windows-i386.exe >> checksum-sha256sum.txt

# Generating checksum
cd build && sha256sum * >> checksum-sha256sum.txt
cd build && md5sum * >> checksum-md5sum.txt

clean:
rm -rf gozen*
Expand Down
44 changes: 41 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ Download and install executable binary from GitHub releases page.

### Linux Installation
```sh
curl -sL https://github.com/tech-thinker/gozen/releases/download/v0.1.1/gozen-linux-amd64 -o gozen
# Use latest tag name from release page
TAG=<tag-name>

curl -sL "https://github.com/tech-thinker/gozen/releases/download/${TAG}/gozen-linux-amd64" -o gozen
chmod +x gozen
sudo mv gozen /usr/bin
```

### MacOS Installation
```sh
curl -sL https://github.com/tech-thinker/gozen/releases/download/v0.1.1/gozen-darwin-amd64 -o gozen
# Use latest tag name from release page
TAG=<tag-name>

curl -sL "https://github.com/tech-thinker/gozen/releases/download/${TAG}/gozen-darwin-amd64" -o gozen
chmod +x gozen
sudo mv gozen /usr/bin
```
Expand All @@ -28,10 +34,42 @@ brew install gozen

### Windows Installation
```sh
curl -sL https://github.com/tech-thinker/gozen/releases/download/v0.1.1/gozen-windows-amd64.exe -o gozen.exe
# Use latest tag name from release page
TAG=<tag-name>

curl -sL "https://github.com/tech-thinker/gozen/releases/download/${TAG}/gozen-windows-amd64.exe" -o gozen.exe
gozen.exe
```

### Verify checksum
```sh
# Use latest tag name from release page
TAG=<tag-name>

# Using sha256sum
curl -sL "https://github.com/tech-thinker/gozen/releases/download/${TAG}/checksum-sha256sum.txt" -o checksum-sha256sum.txt
sha256sum --ignore-missing --check checksum-sha256sum.txt

# Using md5sum
curl -sL "https://github.com/tech-thinker/gozen/releases/download/${TAG}/checksum-md5sum.txt" -o checksum-md5sum.txt
md5sum --ignore-missing --check checksum-md5sum.txt
```
Output:
```sh
gozen-darwin-amd64: OK
gozen-darwin-amd64.tar.gz: OK
gozen-darwin-arm64: OK
gozen-darwin-arm64.tar.gz: OK
gozen-linux-amd64: OK
gozen-linux-amd64.tar.gz: OK
gozen-linux-arm: OK
gozen-linux-arm.tar.gz: OK
gozen-linux-arm64: OK
gozen-linux-arm64.tar.gz: OK
gozen-windows-amd64.exe: OK
gozen-windows-i386.exe: OK
```

## CLI Guide
- `gozen` help
```sh
Expand Down
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"embed"
"fmt"
"os"

"github.com/tech-thinker/gozen/cmd"
Expand Down Expand Up @@ -65,6 +66,15 @@ func main() {
Driver: driver,
WorkingDir: outputDir,
}

err := project.Validate()
if err != nil {
fmt.Println(err)
return nil
}

project.AutoFixes()

app := cmd.NewAppCmd(project, helper)

return app.CreateApp()
Expand Down
2 changes: 1 addition & 1 deletion man/gozen.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH GOZEN 1 "September 25, 2024" "Version 0.1.1" "User Commands"
.TH GOZEN 1 "September 25, 2024" "Version 0.1.2" "User Commands"
.SH NAME
gozen \- is a simplified golang MVC framework to generate projects and components.
.SH SYNOPSIS
Expand Down
15 changes: 15 additions & 0 deletions models/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package models

import (
"encoding/json"
"errors"
"fmt"
"io"
"os"
"strings"

"github.com/tech-thinker/gozen/constants"
)
Expand All @@ -16,6 +18,19 @@ type Project struct {
WorkingDir string `json:"-"`
}

func (p Project) Validate() error {
if len(p.PackageName) == 0 {
return errors.New("Please provide package name.")
}
return nil
}

func (p *Project) AutoFixes() {
if len(p.AppName) == 0 {
p.AppName = p.PackageName[strings.LastIndex(p.PackageName, "/")+1:]
}
}

func (p Project) ToJSON() string {
bytes, err := json.Marshal(p)
if err != nil {
Expand Down
8 changes: 7 additions & 1 deletion templates/Makefile.tpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# Environments

# Load .env file
ifneq (,$(wildcard .env))
include .env
export $(shell sed 's/=.*//' .env)
endif

test:
go test -v ./... -race -coverprofile=coverage.out -covermode=atomic

setup:
go mod tidy

run:
export $(cat .env | xargs) && go run main.go start
go run main.go start

build:
go build -o {{.AppName}}
Expand Down
Loading