Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignite generate can overwrite existing files #1120

Closed
dustinromey opened this issue Jul 26, 2017 · 8 comments
Closed

ignite generate can overwrite existing files #1120

dustinromey opened this issue Jul 26, 2017 · 8 comments

Comments

@dustinromey
Copy link

What's going on?
Accidentally re-ran an ignite generate container command. If there's a container already there with that name, it overwrites the file.

Yes, it was too long between commits. Too long between TimeMachine backups, etc. No I wasn't paying enough attention to what I did in Terminal, etc., etc., etc.

Steps to reproduce
ignite generate container MyCoolNewContainer

Now go edit the container file.

ignite generate container MyCoolNewContainer

You'll find the boilerplate is now in the file.

Suggestion:
Can we get an "Are you sure" if the file name already exists? Or maybe copy the files to FileName-orig.js?

@jamonholmgren
Copy link
Member

Ouch! That hurts.

ow

We currently rely on the app developer to add an askToOverwrite parameter to their ignite/ignite.json config file.

https://github.com/infinitered/ignite/blob/master/src/extensions/ignite/copyBatch.js#L31

Perhaps we should default to true instead, here?

Important: If we do decide to default to true, then you can't just change the false to a true on that line I linked to, there. You'd need to verify that it is undefined and, if so, then set it to true.

const askToOverwrite = (config.askToOverwrite !== undefined) ? config.askToOverwrite : true

Additionally, you might need to update our integration tests so they don't get hung up on this during CI builds.


@GantMan @skellock Any thoughts on that?

@Fr33maan
Copy link

Fr33maan commented Aug 2, 2017

I've got a very good commit workflow, this typically couldn't arrive to me BUT, I'm sure a default with askToOverwrite is the way to do it.
It seems so much probable to be in the "Im going to make a mistake" situation rather than "Im wiping again my file".
The overwrite is something I'm going to use because I'm writing a new generator, but in most cases, I'm sure no one wants to overwrite his file.

@skellock
Copy link
Contributor

skellock commented Aug 2, 2017

The intention was to be true by default.

We should add askToOverride: true in the boilerplate.

You can add askToOverride: true to your .ignite/ignite.json file if you already have a project on the go.

@dustinromey
Copy link
Author

So, just to confirm, I should have something like this?

{
  "createdWith": "2.0.0",
  "examples": "classic",
  "navigation": "react-navigation",
  "askToOverride": true,
  "generators": {
    "component": "ignite-ir-boilerplate",
    "container": "ignite-ir-boilerplate",
    "listview": "ignite-ir-boilerplate",
    "redux": "ignite-ir-boilerplate",
    "saga": "ignite-ir-boilerplate",
    "screen": "ignite-ir-boilerplate"
  }
}

@jamonholmgren
Copy link
Member

@dustinromey Yes, exactly. (Sorry about the late response here). We should probably default to true like you have it. Would you want to do a PR to the boilerplate here?

@dustinromey
Copy link
Author

Done! https://github.com/infinitered/ignite-ir-boilerplate/pull/121

Hope that fits the bill. I'm mostly a solo coder so not intimately familiar with all the git-foo and good manners.

Thanks for a great project. Its helped me not only advance my project, but also really grasp RN, redux, redux-sagas, and a whole bunch of other tech. I can't praise you guys enough for sharing it so widely and readily.

@dustinromey
Copy link
Author

Pull request was merged. Seems like this issue can be closed.

@jamonholmgren
Copy link
Member

@dustinromey Awesome, thanks for the kind words and for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants