-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add npm management support #51
Conversation
8e4047f
to
fec2324
Compare
Hi @javierbertoli This is impressive work. This formula has come a long way from your "First Commit". Thanks for the PR. I really think
The |
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.
LGTM.
As I added here, because I'm depending on an external formula, which has a different configuration/behaviour for different os (`nodejs.ppa, binary, source, etc), I just decided to go and 'test it in a single os'. If it works, I consider THIS formula works, as I can assume npm's behaviour will be consistent across OSes The other choice would be to use |
@javierbertoli I'm a bit caught up at the moment but I'll try to have a look at this fairly soon, even if only an eyeball review. |
packages/npms.sls
Outdated
### NPM PKGS to install using npm | ||
# (requires the npm deb/rpm installed, either by the system or listed in | ||
# the required packages | ||
{% for nn in wanted_npms %} |
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.
https://docs.saltstack.com/en/latest/ref/states/all/salt.states.npm.html#salt.states.npm.installed also has a pkgs
option. Can we avoid this loop and just use that instead? Otherwise lots of extra, unnecessary noise if using this for numerous packages.
# the required packages | ||
{% for nn in wanted_npms %} | ||
{{ nn }}: | ||
npm.installed: |
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.
From the same reference as above, we've got dir
, which controls whether the installation is global or not. Can this be incorporated here? If so, will probably require user
as well. That may be beyond the scope of this PR. However, it would be far easier to structure the pillar and states at this stage, than making (breaking) changes later on to accommodate for non-global installations.
sls: ['nodejs.ppa'] | ||
wanted: | ||
- hello-world-npm | ||
- sax |
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.
It would be great to have an example here of how to supply the package version as well. Again, using the example from the upstream docs, something like coffee-script@1.0.1
.
### WANTED/REQUIRED | ||
control 'Wanted/Required npm packages' do | ||
title 'should be installed' | ||
desc '(only testing in the Debian platform, as the node-formual dependency is too specific)' |
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.
formual
=> formula
.
### UNWANTED | ||
control 'Unwanted npm packages' do | ||
title 'should be uninstalled' | ||
desc '(only testing in the Debian platform, as the node-formual dependency is too specific)' |
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.
formual
=> formula
.
@javierbertoli @noelmcloughlin So this was a fairly breezy eyeball review. I love the idea of this introducing this feature. I think it is better to arrange the structure now, rather than try to accommodate for non-global installations later. But you may consider that beyond the scope of this PR or even the formula itself. |
@javierbertoli Actually, now I'm going to throw a bit of a curveball... when I install |
@javierbertoli Looking at the license and the README of https://github.com/adcade/nvm-formula, it looks like it was a formula that was intended to join our collection here at SaltStack Formulas, but never made it for some reason... but that suggests it would be a very useful basis for introducing |
As per https://docs.saltstack.com/en/latest/ref/states/requisites.html#require, the `require` dependency on a sls file needs an include, which was missing
@javierbertoli This is looking really good now, thanks for the effort you have put in. I was concerned that I may have caused you too much trouble. Let me try running this at my end and see how things fare. I'll get back to you fairly soon. |
@javierbertoli This appears to be working great. I'm running into one problem, though -- Edit: I tried on a minion with a newer version of $ salt -Cv 'ABC' npm.install @davidodio/hello@2.3.0 But still having trouble via. the pillar. |
@javierbertoli OK, it's not just me! I managed to break the build, simply by adding a package starting with [CRITICAL] Rendering SLS 'packages' failed, render error:
found character that cannot start any token
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/pillar/__init__.py", line 736, in render_pstate
**defaults)
File "/usr/lib/python2.7/dist-packages/salt/template.py", line 101, in compile_template
ret = render(input_data, saltenv, sls, **render_kwargs)
File "/usr/lib/python2.7/dist-packages/salt/renderers/yaml.py", line 57, in render
raise SaltRenderError(err_type, line_num, exc.problem_mark.buffer)
SaltRenderError: found character that cannot start any token
[CRITICAL] Pillar render error: Rendering SLS 'packages' failed. Please see master log for details. See:
Upstream code where the error is occurring: |
@myii I can fork nvm-formula into saltstack-formulas organisation. Regarding this formula we could add nvm support in future PR. |
@javierbertoli Excellent, thanks for going the extra mile. As a note, I had some strange issue where enclosing in quotation marks wasn't working -- however, the tests have confirmed it and I was able to restart things in my environment to confirm that all working OK. Thanks to @noelmcloughlin for the review and the offer of reviving the |
Thanks @javierbertoli for adding this feature. Nice. @myii Here is the formula here now: https://github.com/saltstack-formulas/nvm-formula |
@noelmcloughlin Thanks for rolling with that. I hope it gets some traction because it is really useful when working with |
I'm working with node at the moment so will make try it out. thanks guys. |
@noelmcloughlin I understand you install If so, we can add an example in the README/pillar to show how to add a dep to the |
@javierbertoli let's raise an issue for this because that sounds a good idea. I have not use |
New feature suggestion: We could also add |
Should fix #36