-
Notifications
You must be signed in to change notification settings - Fork 14
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
Merge pre-existing package.json with file generated by Cloverfield #40
base: master
Are you sure you want to change the base?
Conversation
Tests fail due to a missing package. |
Yeah, seems the guy who maintains package-merge didnt declare Its passing on my machine seemingly because its a dependency of Not sure what the best approach is - theres not a ton of functionality in that package but i thought it would be nice to have. Could fork it and make a PR and in the meantime use the fork or do a simpler |
@@ -54,6 +54,8 @@ | |||
"husky": "^0.10.1", | |||
"isparta": "^3.0.4", | |||
"nsp": "^1.1.0", | |||
"package-merge": "^0.1.2", | |||
"precommit-hook": "^3.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, that was deleted previously
Hi, @halhenke can you please update PR so I can merge it? thanks 👌 |
6171927
to
c1d4b76
Compare
@@ -57,6 +58,7 @@ | |||
"husky": "^0.10.1", | |||
"isparta": "^3.0.4", | |||
"nsp": "^2.0.2", | |||
"package-merge": "^0.1.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this one is extra now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah - i screwed up the rebase! will fix
Sorry, for the delay, @halhenke I am not sure about intended behaviour here. I can suggest that when we merge package.json we can see which values have been changed and replace them accordingly in other files too. But not touching values that should not be changed. Alternative (and much easier) solution could be - read package.json to get "suggested" values for the second run. Then either I just hit "Enter" and use those default ones - or enter new ones - does not matter. Replace all things as usual. Honestly after playing with it a bit I'd rather go for the second solution. Related to #44 by the way. |
👍 |
Hey sorry for delay in getting back to you Nik - busy few days, Didn't realise we wanted to merge README also - was only thinking of package.json. I also like the second idea - at least it makes people aware of whats happening. Will rework it and see if i can come up with something that deals with other files - think there could be some hard to deal with edge cases - but otherwise will go for the user prompt option. Did you want me to try and work in suggestions from #44 also (i got the impression the other guy didnt want to)? Dont mind. |
Awesome! #44 looks like duplicate to me then. |
Cool! 👍 |
What's going on with this? |
Sorry, sort of got lost in Christmas stuff - have a couple of free days, will try to finish it off. |
Cool. Thanks! |
…nal package fields over template ones
334399b
to
5907619
Compare
634d583
to
91b327e
Compare
…rom pre-existing package.json if available
…s into template package.json
91b327e
to
52e69f8
Compare
OK this thing has been dragging on for a while (apologies) would love to wrap it up Not entirely happy with what i've done (it feels a bit hack-ish) but wanted to check its the direction we wanted. Anyway if a
Feels a bit inelegant because its not using the same handlebars template/vars method to modify most fields - though we do now have author/email variables etc that will now be used in other templates also. Could use more tests. Anyway just wanted to get any feedback/suggested changes when you guys have time. |
Hey guys - just wanted to say - if this PR just missed the mark or isnt working out I wont be offended if you just want to kill it or anything. Its all pretty fuzzy for me at this point anyway. |
@nkbt Comments? |
Wow, that looks cool, pretty much package.json-specific merging. I wish github sends emails on PR updated. I'll try it on couple of existing projects and let you know asap! |
@nkbt Any more thoughts? |
const newPackagePath = path.join(process.cwd(), 'package.json'); | ||
const packageIndex = destinations.indexOf(newPackagePath); | ||
const packageContents = JSON.parse(compiledFiles[packageIndex]); | ||
const mergedPack = JSON.stringify(merge(packageContents, origPackage), null, 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried it several times and tried to fix it too... No luck. With current implmentation no matter what I chose deps/devdeps/scrips are preserved and never updated. If I swap packageContents
and origPackage
- they always updated instead. Somehow those props from setPackageProps
are just totally ignored =(
😞 I'll take a look at it either tonight or later this weekend. |
Re issue #23
package-merge
package rather than a straight object merge - keywords field will be merged without duplicates etc. Might want to take a quick look at that package to see if its desired behaviour: