Giter Site home page Giter Site logo

genny's Introduction

Buffalo Documentation

gobuffalo.io

This is the repository for https://www.gobuffalo.io, the official website of the Buffalo ecosystem.

This documentation contains:

Contributing

Contributing to this documentation site is a great, and easy, way to help make Buffalo better!

Note that this repository is only about Buffalo ecosystem documentation. If you want to contribute to the ecosystem itself, please refer to the concerned repository:

See the contribution guide for more info about how to contribute.

genny's People

Contributors

markbates avatar paganotoni avatar sio4 avatar stanislas-m avatar timraymond 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

genny's Issues

genny v3 proposal: change API to make usage easier

genny v2 could be improved imho by making the API feel more like one is writing go code using the standard library instead of an abstraction of such. This issue serves as a collection of sorts for those API proposals:

remove all usages of packr

With the io/fs package introduced in go 1.16 we can remove all usages of packr and replace them with their new equivalents.

genny.Runner should not change behavior after instantiation

All fields of genny.Runner should be private to ensure they are only set during instantiation of the object and not modified afterwards. Provide a New function with options like WithLogger, WithExecFn, etc. to set those fields. WithDisk can be used by gentest.NewRunner to return a runner for testing together with a reference to the virtual disk for seeding.

type Runner struct {
        logger     LoggerInterface    // Instead of a concrete type Logger should just be an interface
	context    context.Context
	execFn     func(*exec.Cmd) error
	fileFn     func(File) (File, error)
	chdirFn    func(string, func() error) error
	deleteFn   func(string) error
	requestFn  func(*http.Request, *http.Client) (*http.Response, error)
	lookPathFn func(string) (string, error)
	root       string
	disk       *Disk
	steps      map[string]*Step
	moot       *sync.RWMutex
	results    Results
	curGen     *Generator
}

genny.Runner should abstract usage of virtual / real files

The disk object represents a virtual file system that is used in a dry run to simulate the actual file system. It should not be accessed from outside genny.Runner to prevent the user from thinking that modifying the disk actually changes something on the hard drive when a wet runner is used. Instead most of it's functionality will be added to genny.Runner:

// replaces File. Create creates a new file the returned file is a proxy of either os.File or a virtual file
// mkdir and mkdirall behave like their os package equivalents or create directories on the virtual disk
func (r *Runner) Create(name string) (*File, error)
func (r *Runner) Mkdir(name string, perm os.FileMode) error
func (r *Runner) MkdirAll(path string, perm os.FileMode) error

// new method signature, runner remembers where it chdir'd to correctly access to the virtual disk after changing the directory
// it also changes back to the original directory when the runner finishes
func (r *Runner) Chdir(dir string) error

// replaces from FindFile. tries to open a file on disk or the virtual file system
func (r *Runner) Open(name string) (*File, error)

// renamed from delete to be more in line with the "os" package
func (r *Runner) Remove(name string) error
func (r *Runner) RemoveAll(path string) error

// updated method signature to be more in line with "net/http" package:
func (r *Runner) DoRequest(req *http.Request) (*http.Response, error)
func (r *Runner) DoRequestWithClient(c *http.Client, req *http.Request) (*http.Response, error)

// unchanged
func (r *Runner) Exec(cmd *exec.Cmd) error
func (r *Runner) FindStep(name string) (*Step, error)
func (r *Runner) LookPath(file string) (string, error)
func (r *Runner) ReplaceStep(name string, s *Step) error
func (r *Runner) Results() Results
func (r *Runner) Run() error
func (r *Runner) Steps() []*Step
func (r *Runner) With(g *Generator) error
func (r *Runner) WithFn(fn func() (*Generator, error)) error
func (r *Runner) WithGroup(gg *Group)
func (r *Runner) WithNew(g *Generator, err error) error
func (r *Runner) WithRun(fn RunFn)
func (r *Runner) WithStep(name string, step *Step) error

gentest package updates

To make it easier to setup a virtual filesystem in tests now gentest.NewRunner() returns access to the internal disk of the runner that is used for testing:

func NewRunner() (*genny.Runner, *genny.Disk)

implementation of io/fs interfaces

Disk should implement the following interfaces; Runner should probably implement most of these interfaces too:

fs.FS{}         // because it is a FS
fs.StatFS{}     // allows to walk the Disk with fs.WalkDir
fs.GlobFS{}     // to easily find all files matching a pattern
fs.ReadDirFS{}  // equivalent of os.ReadDir; allows more efficient walking
fs.ReadFileFS{} // equivalent of os.ReadFile
fs.SubFS{}      // allows the creation of sub-filesystems

Returned virtual files and directories should implement the io/fs interfaces like their os equivalents:

fs.File{}
fs.DirEntry{}

error when using go get github.com/gobuffalo/buffalo/buffalo

Hello,
this worked fine yesterday 23/12/2019 with (probably) version 0.4.1 )v.5.x is 9 hours old right now)

I have a Dockerfile that from golang:1.13.4 uses
go get -u github.com/gobuffalo/buffalo/buffalo

The command fails with the error

build github.com/gobuffalo/buffalo/buffalo: cannot load github.com/gobuffalo/genny/gogen/gomods: module github.com/gobuffalo/genny@latest found (v0.5.2), but does not contain package github.com/gobuffalo/genny/gogen/gomods

In go.mod I have no reference to genny,so I suppose it is a dependency of buffalo

To be ablle to install buffalo can I use something lie
git config --global --add url."github.com/gobuffalo/[email protected]".insteadOf "https://github.com/gobuffalo/genny@latest"

Thanks

genny dependency issue

Description

Hello,
this worked fine yesterday 23/12/2019 with (probably) genny version 0.4.1 )v.5.x is 9 hours old right now)

I have a Dockerfile that from golang:1.13.4 uses
go get github.com/gobuffalo/buffalo/buffalo

The command fails with the error

build github.com/gobuffalo/buffalo/buffalo: cannot load github.com/gobuffalo/genny/gogen/gomods: module github.com/gobuffalo/genny@latest found (v0.5.2), but does not contain package github.com/gobuffalo/genny/gogen/gomods

In go.mod I have no reference to genny,so I suppose it is a dependency of buffalo

To be ablle to install buffalo can I use something lie
git config --global --add url."github.com/gobuffalo/[email protected]".insteadOf "https://github.com/gobuffalo/genny@latest"

Thanks

Steps to Reproduce the Problem

docker run --entrypoin bash -it golang/1.13.4
go get github.com/gobuffalo/buffalo/buffalo

Expected Behavior

no errors

Actual Behavior

build github.com/gobuffalo/buffalo/buffalo: cannot load github.com/gobuffalo/genny/gogen/gomods: module github.com/gobuffalo/genny@latest found (v0.5.2), but does not contain package github.com/gobuffalo/genny/gogen/gomods

Info

buffalo is not installed, so no "buffalo info"

When installing pop, installation fails on nonexistent genny function

When running go get -v github.com/gobuffalo/pop/... v4.7.2+incompatible the installation fails on the following lines

# github.com/gobuffalo/gogen/gomods
/go/src/github.com/gobuffalo/gogen/gomods/init.go:61:24: undefined: genny.GoBin
/go/src/github.com/gobuffalo/gogen/gomods/tidy.go:17:24: undefined: genny.GoBin

looking at the above lines of code gomods/init.go (https://github.com/gobuffalo/gogen/blob/v0.1.0/gomods/init.go#L61) and tidy.go (https://github.com/gobuffalo/gogen/blob/v0.1.0/gomods/tidy.go#L17) the are both calling genny.GoBin which is a non existent function.

Is there workaround or fix for this issue. This is causing problems with getting local environments and dev environments up and running for my organization

Kind regards
Tom Mitic

Remove dependancy on markbates/safe which is calling for go 1.22

The issue here: markbates/safe#1 shows the problem, this tiny dependency is calling for go 1.22 but not actually using go 1.22 features, which is pulling go 1.22 as a transitive compile requirement. This is not great for a monorepo that has things not ready to move to 1.22.

First recommendation: remove this dep. It's a couple lines of go code.

Alternative recommendation: wait for this author to fix this issue and then depend on that version that doesn't have an unnecessary dependency on a bleeding edge version of the language

Hey @fasmat,

          Hey @fasmat,

I just figured out that current runners doesn't support fs.FS, so this issue would be a great enhancement.

What I have in mind is a single NewRunner(fs.FS) :

  • if you want a dry runner use NewRunner(fstest.MapFS{})
  • if you want a wet runner use NewRunner(os.DirFS("."))

That said DryRunner and WetRunner could be kept, but they will just call NewRunner with the appropriate fs.

What do you think ?

EDIT: seems like I went a little too fast, fs.FS is only a readable interface, so it cannot be used by a runner. Maybe this will change in the future.

Originally posted by @tbruyelle in #43 (comment)

temporary files under the /tmp

Hi, I found the code below generates so many files under the /tmp but they are not removed after the build (in fact, buffalo dev).
Also, I saw a comment something like "virtual file" and "virtual disk", and comment for Disk.Find() said, it tries to find a file from virtual disk but if the file does not exist, then check for a real filesystem. Are they the physical files as a backup for this purpose? (or just remained old code?)

tf, err := os.Create(path)
if err != nil {
return gf, errors.WithStack(err)
}
if _, err := tf.Write(src); err != nil {
return gf, errors.WithStack(err)
}
if err := tf.Close(); err != nil {
return gf, errors.WithStack(err)
}

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.