Skip to content

Extend Node.js NPM support for .npmrc configuration #53

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

Merged
merged 7 commits into from
Jan 2, 2019

Conversation

simalexan
Copy link
Contributor

Description of changes:
NPM can be configured to use proxies or local company repositories using a local file, .npmrc.
The packaging process from step 1 normally excludes this file, so it needs to be copied before dependency installation, and then removed.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Contributor

@jfuss jfuss left a comment

Choose a reason for hiding this comment

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

@simalexan This looks really good! Thanks for taking the time to make the addition.

Just a few small comments.

except OSError as ex:
raise ActionFailedError(str(ex))

class NodejsCleanUpAction(BaseAction):
Copy link
Contributor

Choose a reason for hiding this comment

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

This name indicates we are cleaning up more than .npmrc. Can we scope the name down to be Npmrc, like how you have done for the Copy Action? Or was the goal to make one Npm Clean up action?

Side thought: I wonder if this will be a pattern that develops (adding then removing the same set of files), to the point where it's worth codifying.

Copy link
Contributor

Choose a reason for hiding this comment

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

there will be some other clean up actions to add later (such as npm dedupe). Would you prefer each step to be a separate action, or do we keep it all inside a single action?

on a related note, is it worth adding another Purpose value there? This isn't really COPY_SOURCE, but nothing else fit.

class TestNodejsCleanUpAction(TestCase):

@patch("aws_lambda_builders.workflows.nodejs_npm.utils.OSUtils")
def test_removes_npmrc_if_npmrc_exists(self, OSUtilMock):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also add a tests for when npmrc does not exist, to make sure that branch is also covered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, I'll take a look at it

Copy link
Contributor Author

@simalexan simalexan Dec 17, 2018

Choose a reason for hiding this comment

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

self.actions = [
npm_pack,
npm_copy_npmrc,
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the order matter at all? Does npm_copy_npmrc just need to be between npm_pack and 'npm_install` or must is happen before the copy source?

Trying to understand if there is some documentation we need to add here for the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

it needs to come between npm_pack and npm_install because npm pack will exclude it from the package, but it's needed for npm install to correctly function (it may contain URLs to module repositories etc)

@simalexan
Copy link
Contributor Author

@jfuss I've added the test, @gojko gave good answers on the other two. If you think we should change something else, please do mention, would be happy to fix/add

@sriram-mv sriram-mv self-requested a review December 18, 2018 04:53
Copy link
Contributor

@sriram-mv sriram-mv left a comment

Choose a reason for hiding this comment

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

💯 LGTM :)

@simalexan
Copy link
Contributor Author

@thesriram Thank you! :) Waiting for approval of both of Jacob and you.

Copy link
Contributor

@jfuss jfuss left a comment

Choose a reason for hiding this comment

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

🎉

@simalexan
Copy link
Contributor Author

Thank you both @jfuss and @thesriram !

@simalexan
Copy link
Contributor Author

@thesriram thank you!

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