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

Pre-Clean Backup and Maybye Restore on Error #6

Closed
ralphcallaway opened this issue Sep 27, 2019 · 9 comments
Closed

Pre-Clean Backup and Maybye Restore on Error #6

ralphcallaway opened this issue Sep 27, 2019 · 9 comments

Comments

@ralphcallaway
Copy link
Collaborator

Seems inevitable that there be a fair amount of stuff like #4 where it doesn't complete and all the files are "DELETED"

Recoverying with source control is a snap, but it's easy to mess something up and forget some of your stuff wasn't committed.

A small protective measure would be to save a backup of the folder being cleaned, say .cleanbk that could make clean up a quick move folder. Or even better just magically bring it back. If it worked well the warning prompt might not be as critical

@ChuckJonas
Copy link
Collaborator

The backup would be nice and allow us to automatically reset on failures (so you aren't left with a bunch of files that sale [delete_me].

Probably would want to make it controllable via a param -b --backup. Not sure if the default would be on or off. (if off we would still use a tmp folder to allow us to restore on failure)

A second command sfdx force:source:clean:undo could be added to undo a successful clean

@ChuckJonas
Copy link
Collaborator

maybe the param isn't needed... I guess it would only be if someone didn't want the command creating a .clean.bak file

@ralphcallaway
Copy link
Collaborator Author

i'd vote for it just being used if something went wrong, i.e. if something errors don't put the onus on the user to recover it, but if they just screwed it up (say they ran clean with the wrong org) the onus would be on them to use source control to clean it up ...

@ChuckJonas
Copy link
Collaborator

released in 0.0.3

@ralphcallaway
Copy link
Collaborator Author

so how is this working?

was using today and got an error about an unexpected file due to some merge conflict artifacts, but wasn't automatically restored, but maybe there is an extra step?

ran plugins update, and pulled down the latest code for my local version from master, could have messed that up and ended up using an old version

@ChuckJonas
Copy link
Collaborator

https://github.com/ChuckJonas/force-source-clean/blob/master/src/commands/force/source/clean.ts#L86

I only did very limited testing, so it's highly possible there is a bug.

Looks like it's only handling errors on the retrieve cmd (the markContents code should also be moved inside the handler), but it sounds like that's where your failure occurred.

Next time, please zip your project so we can reproduce.

You can run sfdx plugins to determine if the plugin is linked via npm or local source (it will say link followed by the path).

@ChuckJonas ChuckJonas reopened this Oct 28, 2019
@ralphcallaway
Copy link
Collaborator Author

sending you a zip, although fairly easy to reproduce, just copy any class and change to MyClass.cls.orig to mimic a merge artifact

output

➜  example git:(test) ✗ sfdx force:source:clean -x manifest/package.xml -n
(node:30064) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
WARNING: Failed to retrieve! All files are "marked" and will need to be manually reset!
ERROR running force:source:retrieve:  Unexpected file found in package directory: /afolder/aproject/src/main/default/classes/SomeClass.cls.orig

@ralphcallaway
Copy link
Collaborator Author

@ChuckJonas scratch that, the example repo i had was pretty big and was taking forever to upload, a lot easier to just have you copy an apex class and add .orig suffix and then run the command

@ChuckJonas
Copy link
Collaborator

ChuckJonas commented Nov 2, 2019

@ralphcallaway What do you see when your run sfdx plugins for force-source-clean?

I've tried to repro this with both the steps above and the topcon project (both from source and via the npm install), but can't. Maybe I just don't have the right repo steps...

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

No branches or pull requests

2 participants