ponzu-cms / ponzu

Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.
https://docs.ponzu-cms.org
BSD 3-Clause "New" or "Revised" License
5.7k stars 385 forks source link

`ponzu new .` ate my entire go src/ directory :( #146

Closed ivanov closed 7 years ago

ivanov commented 7 years ago

So there I was, in a random directory, trying to initialize ponzu....

11:23@try_cms(master)$ pwd
/Users/pi/code/workspace/try_cms

11:23@try_cms(master)$ ponzu new .
Path exists, overwrite contents? (y/N):
y
fatal: repository '/Users/pi/code/go/src/github.com/ponzu-cms/ponzu' does not exist
Couldn't clone from /Users/pi/code/go/src/github.com/ponzu-cms/ponzu - trying network...
Cloning into '/Users/pi/code/go/src'...
fatal: unable to access 'https://github.com/ponzu-cms/ponzu.git/': Could not resolve host: github.com
Network clone failure.
Failed to clone files from local machine [/Users/pi/code/go/src/github.com/ponzu-cms/ponzu] and over the network [https://github.com/ponzu-cms/ponzu.git].
exit status 128

and now

$ ls ~/code/go
bin pkg

I won't be the only one to make this mistake. Let my stupidity be a warning to others.

nilslice commented 7 years ago

Ah, that is super painful - I am very sorry. I've done this (not using Ponzu) on my Go src directory and lost a ton of non-hosted code. It hurts.

@martint17r - while you're working on the CLI updates, do you think this example is reason to put some kind of requirements in place for the new subcommand? The issue above was caused by the "." path supplied as the project name/path. Since all Ponzu projects are created in the $GOPATH/src directory, it wiped out the whole workspace.

The requirements would be:

  1. A path is supplied after new
  2. The path NOT be "."

Why do you think? @ivanov - please feel free to share your thoughts as well.

sirikon commented 7 years ago

@nilslice Just before asking Path exists, overwrite contents? (y/N): would be nice to output the given and resolved path, so it would be like:

Selected path: '/Users/pi/code/go/src'
Path exists, overwrite contents? (y/N):

This could be an extra alert to the user, so he's sure what's he doing.

Also, absolutely blocking the creation of projects in exactly $GOPATH would be useful.

nilslice commented 7 years ago

@Sirikon - definitely agree printing the target path is a good call.

@martint17r, if you can squeeze this into your PR, it would be much appreciated! Happy to discuss specifics about the implementation if you'd like.

ivanov commented 7 years ago

I agree that printing the target path before confirmation would have helped.

Also 👍 to not allowing the creation of projects at precisely $GOPATH - I can imagine someone else stubbing their toe on that by some other accidental means (while trying to use a shell variable that's mis-formed, for example).

(I'm slowly rebuilding on my end, thanks for the kind words and support. I guess I can truly call myself a go getter today ;) )

nilslice commented 7 years ago

I agree that printing the target path before confirmation would have helped.

Ok, let's definitely add the target path to the output when confirming an overwrite. @martint17r - let me know once you have some time to look at this & we can figure out specifics.

@ivanov - I feel really bad about this.. since the beginning of the project, I have tried to put in safe-guards to circumvent something like this from happening, so it feels like a personal failure! I hope you recover all of your important code and if not, that it isn't too much of a burden on you.

For what it is worth, I appreciate you being a positive influence on the project by reporting the issue and helping us determine a better UX... not jumping in just to shame it - although it would be understandable ;)

(I'm slowly rebuilding on my end, thanks for the kind words and support. I guess I can truly call myself a go getter today ;) )

:rofl: a go getter you are indeed... very sorry again that this happened!

ivanov commented 7 years ago

Thankfully, very little of my own code was lost - I essentially use the go workspace for dependencies and projects I'm building on top of, but my own code lives in separate git repos elsewhere. So I guess pretty much all that was lost was not mine to begin with, I was just living off of borrowed bits :)

Glad that you all are receptive to making changes on this front 👍 . I'll go poke around and see if I can find another footgun somewhere... :feelsgood: :grin: :bowtie: