Giter Site home page Giter Site logo

go-blueprint's People

Contributors

andrerocco avatar arnevm123 avatar basokant avatar brendonotto avatar briancbarrow avatar campen21 avatar einarlogi avatar itschip avatar jamlie avatar joshjms avatar jpx40 avatar juleszs avatar limesten avatar melkeydev avatar mikelerch avatar mimatache avatar mitchellberend avatar mohammadalhallaq avatar muandane avatar narasaka avatar nhlmg93 avatar nimishkashyap avatar rustafariandev avatar sakelig avatar sputnikplop avatar sudosurya avatar tylermeekel avatar ujstor avatar xsadia avatar young-steveo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-blueprint's Issues

[Bug] Update the README

What is the problem?

When I first used the tool, I found that the README referenced pq instead of the current postgres driver it installs when you select postgres, which is pgx. This is a minor change that led me to believe that the driver installed would be pq.

Operating System

all

Architecture Version (x86, x64, arm, etc)

x86

Steps to reproduce

Look at the README and click the postgres link.

Relevant log output

No response

Proposal: Add ability to save a template of the command

Getting a bit meta with a template of a template, but as this project grows and new options get added like #11 it could be good to add ability to save a template of the project using the options selected.

Currently it's only name and framework but I saw there is an open issue (#11) for adding db setup too. If the db setup issue gets added then having a re-usable thing with only the name needing to be suppled would be useful.

example usage could be something like:
go-blueprint create --name test-project --framework gin --save-template new-template or selected at the end if using the interactive version.
Then something like this to use the template
go-blueprint create --template new-template --name not-another-test-project

BUG: white space in name not trimmed

Currently if you append a space to the end of the project name go-blueprint can't cd into the directory. I think a space at the end of a name is always a mistake since it will always create a weird name that has to be escaped in the terminal.

It would be nice if go-blueprint would strip this white space automatically so the dir gets generated properly.

image
image

[Bug] Spinner not working

What is the problem?

spinner is not working if we use flags. its only working if we use cmd go-blueprint create directly

Operating System

Linux

Architecture Version (x86, x64, arm, etc)

x86

Steps to reproduce

image

Relevant log output

No response

No ORM's

As go-blueprint adds more features and expands into DB layers, I am going to make the decision to not include an ORM.
The reason being:

  • ORM's can be opionated
  • Majority should know SQL > a particular ORM
  • Not to bloat the CLI with too many options that can cause a worse user experience

launching air through makefile not working

Abstract

When using the make watch command I get the response air is not installed. Do you want to install it now? (y/n) Even though air is installed and is in my $GOPATH/bin.

Issue Replication

Machine type: darwin amd64 (206 macbook pro)

Expected Behavior

With my environment laid out as it is this command should run air the way it does when I use the air command

Interface inconsistency when selecting framework

When selecting the framework, moving up and down the list, then selecting with space marks that framework with a check. But if I move up or down from that framework, without marking any other framework with space, the framework that is focused (not checked) will be used when pressing 'y' to continue.

image

Add full on CLI support

Instead of opening the TUI, could we add full on CLI support?
In just one command just make a new project:

go-blueprint --name name --framework Chi

[Bug] Remove Homebrew Installation

What is the problem?

Homebrew keeps breaking and we can just delete it

Operating System

bruh

Architecture Version (x86, x64, arm, etc)

etc

Steps to reproduce

look at GHA and all the broken homebrew builds

Relevant log output

Melkey does not like this

gRPC Implementation

It would be super interesting to see if we can include a gRPC implementation.
If someone does this, I want to use Twirp package.

[Feature Request] Using modernc.org/sqlite driver

Tell us about your feature request

When using mattn/sqlite users are also bringing in CGO inherently. I think that when selecting the sqlite driver, it should bring in the modernc.org/sqlite driver, which does not use cgo into the project, leading to a safer project and ease of use with sqlite. The only negative is they would get a minor hit in performance with using this driver instead,

speed_test

speed_test_2

Disclaimer

  • I agree

HTMX/Templ support?

Tell us about your feature request

I used the project to build an HTMX server using Templ. Would we want there to be an option in the cli to setup? I know the project is meant to be minimalistic, so I wasn't going to add it unless people think it is a good idea.

My thought is that opting into this would add another folder for web ui stuff with a basic route to get the project started.

Let me know your thoughts.

Disclaimer

  • I agree

Proposal: CLI App Boilerplate

While writing CLI tools with Cobra and Viper is pretty easy, it would great if this supported setting up that boilerplate and stuff. I'd be happy to work on that contribution, but I wanted to put an issue first to gauge interest. Lmk what you think! :)

Btw great work on this dude, this is sick!

Websocket example implementation

Would a ping pong web socket endpoint example add a lot of value? The way I imagine it, it would add a dependency to the generated project, this dependency does get linked to by the docs.

I think gorilla has their own websocket implementation but I haven't worked with that one yet.

naive example implementation

handler(w http.ResponseWriter, req *http.Request) {
	socket, _ := websocket.Accept(w, req, nil)
	ctx := req.Context()
	for {
		_, socketBytes, _ := socket.Read(ctx)
		if string(socketBytes) == "PING" {
			_ = socket.Write(ctx, websocket.MessageText, "PONG")
		} else {
			_ = socket.Write(ctx, websocket.MessageText, "HUH?")
		}
	}
}

Abort if project directory already exists

Description

The application currently creates a new project directory and files based on the provided project name, even if a directory with the same name already exists. This behavior is problematic as it could lead to unintended overwriting of existing project data. The application should instead abort creation when a project with the same name already exists.

Steps to Reproduce

Run go-blueprint create in a directory with a sub directory called the same as the name of the project.

Expected Result

When attempting to create a project with a name matching an existing project, the application should provide an error message and abort the creation process to avoid overwriting the existing project.

[Feature Request] Using pgx instead of pq

Tell us about your feature request

Looking at the README, it says that pq and mattn/sqlite3 are the supported database drivers, but I do not find these to be the best options for these databases.

For postgres:

  • They literally say that they are only in maintenance mode, probably heading into the same route that gorilla was in a few months ago. I think a better choice would be to switch it to have users integrate and use pgx instead!

For sqlite

  • Using mattn's driver is a great choice, but the driver ships with cgo, which can present scary errors that can be difficult to solve. I feel that using modernc.or/sqlite would be best, since they do not use cgo for the library, and only use it for testing the library.

Disclaimer

  • I agree

Looking for a Core Maintainer

Tell us about your feature request

As blueprint gets bigger, I would really enjoy if someone volunteers to become an active core maintainer.
Preferably someone who has been already contributing as well.
Please comment here or ping me on Discord if you are interested!

Disclaimer

  • I agree

Have each framework have their own set of templates

To make it easier to generate different types of go projects, CLI, HTTP servers, and TCP/UDP servers.

Each framework should have its templates instead of sharing files.

This will increase the duplication of common files like README, .gitignore, and .air.toml.
But, it will increase the flexibility of the different types of frameworks that can be supported.

Maybe a structure like this Where each framework exposes its own embed.FS.

  • cmd/template/chi/fs.go
  • cmd/template/chi/internal/server/routes.go.tmpl
  • cmd/template/chi/internal/server/server.go.tmpl
  • cmd/template/chi/Makefile.tmpl
  • cmd/template/chi/cmd/api/main.go.tmpl
  • cmd/template/chi/.gitignore.tmpl
  • cmd/template/chi/.air.toml.tmpl
  • cmd/template/chi/README.md.tmpl

The contents of cmd/template/chi/fs.go are the following.

package chi

import "embed"

//go:embed internal cmd all:*.tmpl
var FS embed.FS

I have a concept of this working.
Let me know if you are interested.

Add opt-in DB connection structure

Setting up a database and connecting to it in Go projects is a trivial task most of the time, but, similar to creating an HTTP server, it becomes repetitive. My proposal is to introduce an opt-in database setup.

Project used echo framework generated with standard http package

Generated code uses net/http package instead of echo
`
package server

import (
"fmt"
"net/http"
"time"
)

var port = 8080

type Server struct {
port int
}

func NewServer() *http.Server {

NewServer := &Server{
	port: port,
}

// Declare Server config
server := &http.Server{
	Addr:         fmt.Sprintf(":%d", NewServer.port),
	Handler:      NewServer.RegisterRoutes(),
	IdleTimeout:  time.Minute,
	ReadTimeout:  10 * time.Second,
	WriteTimeout: 30 * time.Second,
}

return server

}`

Add echo support

It would be nice to have the option to start a project with echo as well. I could give it a try if you don't mind.

Artisan like???

I am working on a function that can add similar features like Laravel Artisan for models, views, and controllers. I would also like to add authentication, but I need to determine the best approach. I am considering using JWT, OAuth2, or both. I am not sure if this will be something that people would find interesting, but I am making it for Gofiber because that is what I need. For now, I plan to generate the entire CRUD with HTMX for views, but there may be more options in the future.

Linting on generated code

PR #28 adds a workflow for linting the cli code but this does not lint the template code since that is just a string in the go code. Maybe it would be nice to have CI generate all templates to run the linter on those as well. That users don't have to manually check the generated code with the linter.

Proposal: Move template strings to separate files.

This is a proposal to move the template strings from the template directory to separate files outside of the execution code, especially for the full files.

We can use the go embed functionality to ship them with the binaries and make the templates be easier to view, manage and format independently of the execution code.

For naming proposal we could have the files be named with the generated file name and with a .tmpl extension at the end, something like main.go.tmpl.

As the project grows and adds new files and functionality it will become increasingly difficult to manage the template strings directly as multi line strings in the go files.

Example:

image

Directory proposal

package main

import (
	"{{.ProjectName}}/internal/server"
)

func main() {

	server := server.NewServer()

	err := server.ListenAndServe()
	if err != nil {
		panic("cannot start server")
	}
}

main.go.tmpl contents

// Package template provides utility functions that
// help with the templating of created files.
package template

import (
  _"embed"
)


//go:embed resources/main/main.go.tmpl
var mainTemplate []byte

// MakeHTTPRoutes returns a byte slice that represents 
// the default cmd/api/main.go file template.
func MainTemplate() []byte {
	return mainTemplate
}

Changes in the main.go file in templates.

This will be doubly helpful for the README.md and '.air.toml` files, as they will simply be the files.

We could also use the resources (or whatever else we decide to call it) as a mirror of what we want the final project to look like and use the embed.FS to walk the files.

Proposal: Add optional default root directory

If you have all of your projects in a specific directory, rather than needing to run the command in that directory, it could be useful to be able to run the command from anywhere and the project be created in your base/root project directory.

For example I could be in ~/some/random/path and by running go-blueprint create --name new-project would create the project in ~/dev/new-project

Print the Equivalent Non-interactive Command

After completing the last step of the interactive CLI, the user should be able to easily copy and paste the equivalent shorter non-interactive go-blueprint command with the proper flags and program arguments set.

For example, after the user selects Gin in the interactive UI, the output at the end could be something like this:

Tip: Repeat the equivalent Blueprint with the following non-interactive command
go-blueprint create --name my-project --framework gin

Currently, this is not terribly useful, BUT as we add more steps it could save a lot of time.

Add Completion Scripts

A suggestion to the cli itself, wouldn't be cool if there were completion scripts for the program for bash, zsh and fish? I mean the program only has like 5 commands, but still :)

cd into the newly create project once created

I could be wrong on this one but I would think the default next action for someone after creating a new project would be to cd into it. It could improve the user experience to do this for them.

For those times when the user doesn't need to cd into the project straight away a new flag could be added to stop the changing of the directory.

For example: go-blueprint create --name new-project --no-cd or something more fitting.

Current `make watch` target fails to find `air` even after successful installation

Description

When running make watch after successfully installing air, the Makefile still prompts "air is not installed. Do you want to install it now? (y/n)". This happens even though air has been installed and is available in the PATH.

It seems like the GOPATH has been deprecated in Go 1.16 and should not be relied on.

Environment

  • Go version: 1.21.0
  • OS: Ubuntu 22.04

Additional Information

Here is the watch target in the Makefile:

watch:
	@if [ -x "$(GOPATH)/bin/air" ]; then \
	    "$(GOPATH)/bin/air"; \
		@echo "Watching...";\
	else \
	    read -p "air is not installed. Do you want to install it now? (y/n) " choice; \
	    if [ "$$choice" = "y" ]; then \
			go install github.com/cosmtrek/air@latest; \
	        "$(GOPATH)/bin/air"; \
				@echo "Watching...";\
	    else \
	        echo "You chose not to install air. Exiting..."; \
	        exit 1; \
	    fi; \
	fi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.