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

Handling interaction with package.json #38

Closed
wants to merge 2 commits into from

Conversation

ScottyB
Copy link

@ScottyB ScottyB commented Sep 11, 2015

Aims to address issues with interacting with a package.json file.

From #35:

  1. Add option :persist true to persist package.json that overwrites properties except for dependencies.
  2. Motivation for this pull request :).
  3. Dependencies specified in package.json are merged with dependencies in project.clj. As long as :package or :main aren't specified, properties won't get overwritten in package.json. Let me know if this behaviour needs to be changed.

Hopefully this addresses #23 as well.

@RyanMcG
Copy link
Owner

RyanMcG commented Sep 14, 2015

  1. Dependencies specified in package.json are merged with dependencies in project.clj. As long as :package or :main aren't specified, properties won't get overwritten in package.json. Let me know if this behaviour needs to be changed.

I think it might need changed :(.

This means that package.json will be the source of truth for project name and other attributes. My 3 from #35 was to allow for an option to be specified to opt-in to this behaviour. Here's what is what I am thinking that is driving this decision:

Users want to either:

  1. Make project.clj 's :npm hash the source of truth for their package.json OR
  2. Use lein-npm to simply augment their package.json.

Your implementation does not seem to behave well for 1 (package.json attribtues override those from project.clj).

I think "Merge unique dependencies in package.json and project.clj" needs some tests.

@ScottyB
Copy link
Author

ScottyB commented Sep 15, 2015

Thanks for the feedback. I've made the changes you suggested to the first commit.

I think it might need changed :(.

No worries, I figured this would probably be the case. Thanks for explaining your thoughts. The current implementation was intended to make project.clj's :npm the source of truth unless :package attributes were added. I'll clean up the code and add some tests.

"Please remove it.")
(main/abort)))
(when (and (not (persist-package-json? project))
(.exists (package-file-from-project project)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and (not (persist-package-json? project))
     (.exists (package-file-from-project project)))

That's the indentation style I am used to. May I ask what editor/configuration you are using? Not a big deal.
Upon a more meticulous read it seems there are other indentation inconsistencies too.

I think we should be following this guide.

@RyanMcG
Copy link
Owner

RyanMcG commented Sep 21, 2015

@ScottyB let me know if you need anything from me. I want to encourage contribution but I don't want quality to suffer. If you'd prefer me to take this over from your starting point, that's an option too, I just don't want to "steal" this away if you want it merged without modification.

P.S. I'm open to feedback on my feedback.

@ScottyB
Copy link
Author

ScottyB commented Sep 24, 2015

@RyanMcG No worries, I'm new to Clojurescript so happy to get the feedback. I'm keen to finish what I started but I'll be away for the next few weeks so if it can't wait I'm cool if you finish it off. When I get back I'll give it some more thought and will probably have some questions then :).

@gtebbutt
Copy link

Just wondering if there's any progress on this? Being able to persist the package.json would be a big help for deploying compiled projects. Thanks!

@RyanMcG
Copy link
Owner

RyanMcG commented Jan 26, 2016

@gtebbutt @ScottyB feel free to pick this up.

I'm in the midst of job change and move. I hope to pick this up in February though. I know that's not great and I apologize for the delay.

@chancerussell
Copy link

My team would find it useful to have a mode of operation where the package.json gets dumped on command, always completely overwriting if an older one is present. We need the package.json for launching the application via electron, but we'd prefer to treat it as a build artifact, if that makes sense.

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

Successfully merging this pull request may close these issues.

4 participants