-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from netmanagers/master
Add npm management support
- Loading branch information
Showing
12 changed files
with
259 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,43 @@ | ||
packages formula | ||
================ | ||
|
||
0.0.1 (2018-02-12) | ||
0.1.0 (2019-03-10) | ||
|
||
- Initial version | ||
- Add npm support | ||
|
||
0.0.2 (2018-02-23) | ||
0.0.9 (2018-10-03) | ||
|
||
- Add Fedora support | ||
- Add support for plain files using archive | ||
|
||
0.0.3 (2018-03-02) | ||
0.0.8 (2018-08-23) | ||
|
||
- Allow to hold/unhold system packages (#8) | ||
- Add more tests | ||
- Add archive support | ||
|
||
0.0.4 (2018-03-06) | ||
0.0.7 (2018-07-11) | ||
|
||
- Allow to specify held system packages also as a list (#10) | ||
- Fix pip/gems for FreeBSD | ||
|
||
0.0.6 (2018-04-09) | ||
|
||
- Add snap with classic confinement support | ||
|
||
0.0.5 (2018-03-14) | ||
|
||
- Add snap support | ||
|
||
0.0.6 (2018-04-09) | ||
0.0.4 (2018-03-06) | ||
|
||
- Add snap with classic confinement support | ||
- Allow to specify held system packages also as a list (#10) | ||
|
||
0.0.7 (2018-07-11) | ||
0.0.3 (2018-03-02) | ||
|
||
- Fix pip/gems for FreeBSD | ||
- Allow to hold/unhold system packages (#8) | ||
|
||
0.0.8 (2018-08-23) | ||
0.0.2 (2018-02-23) | ||
|
||
- Add archive support | ||
- Add Fedora support | ||
- Add more tests | ||
|
||
0.0.9 (2018-10-03) | ||
0.0.1 (2018-02-12) | ||
|
||
- Add support for plain files using arcihve | ||
- Initial version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
{% from "packages/map.jinja" import packages with context %} | ||
{% set req_states = packages.npms.required.states %} | ||
{% set req_pkgs = packages.npms.required.pkgs %} | ||
{% set wanted_npms = packages.npms.wanted %} | ||
{% set unwanted_npms = packages.npms.unwanted %} | ||
{% if req_states %} | ||
include: | ||
{% for dep in req_states %} | ||
- {{ dep }} | ||
{% endfor %} | ||
{% endif %} | ||
# As we depend on npm installed, if this state file is invoked every time | ||
# if will fail with 'npm not found'. This condition makes sure it's run | ||
# only when explicitly asking for adding/removing npms | ||
{% if wanted_npms or unwanted_npms %} | ||
### REQ PKGS (without these, some of the WANTED NPMS will fail to install) | ||
npm_req_pkgs: | ||
pkg.installed: | ||
- pkgs: {{ req_pkgs | json }} | ||
### NPM PKGS to install using npm | ||
# (requires the npm binary installed, either by the system or listed in | ||
# the required packages | ||
{% if packages.npms.dir is defined %} | ||
npms_dir: | ||
file.directory: | ||
- name: {{ packages.npms.dir }} | ||
- user: {{ 'root' if 'user' not in packages.npms else packages.npms.user }} | ||
- group: {{ 'root' if 'group' not in packages.npms else packages.npms.group }} | ||
- mode: {{ '0755' if 'mode' not in packages.npms else packages.npms.mode }} | ||
- makedirs: True | ||
{% endif %} | ||
wanted_npms: | ||
npm.installed: | ||
- pkgs: {{ wanted_npms | json }} | ||
{% if packages.npms.dir is defined %} | ||
- dir: {{ packages.npms.dir }} | ||
{% endif %} | ||
{% if packages.npms.user is defined %} | ||
- user: {{ packages.npms.user }} | ||
{% endif %} | ||
{% if packages.npms.registry is defined %} | ||
- registry: {{ packages.npms.registry }} | ||
{% endif %} | ||
{% if packages.npms.env is defined %} | ||
- env: {{ packages.npms.env | json }} | ||
{% endif %} | ||
{% if packages.npms.force_reinstall is defined %} | ||
- force_reinstall: {{ packages.npms.force_reinstall }} | ||
{% endif %} | ||
- require: | ||
{% if packages.npms.dir is defined %} | ||
- file: npms_dir | ||
{% endif %} | ||
- pkg: npm_req_pkgs | ||
{% if req_states %} | ||
{% for dep in req_states %} | ||
- sls: {{ dep }} | ||
{% endfor %} | ||
{% endif %} | ||
{% for upn in unwanted_npms %} | ||
{{ upn }}: | ||
npm.removed | ||
{% endfor %} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
## FIXME! inspec's npm resource fails to check correctly (sudo issues, path issues) | ||
## so I added some "poor man's checks" to ensure, at least, that npms are in place | ||
|
||
npms_path = '/home/kitchen/npms' | ||
|
||
wanted_npms = { | ||
'@davidodio/hello': '2.3.0', | ||
'hello-world-npm': '1.1.1', | ||
'sax': '1.2.4', | ||
'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-formula dependency is too specific)' | ||
|
||
only_if do | ||
os.name == 'debian' | ||
end | ||
|
||
describe directory(npms_path) do | ||
it { should exist } | ||
its('owner') { should cmp 'kitchen' } | ||
its('group') { should cmp 'kitchen' } | ||
its('mode') { should cmp '0755' } | ||
end | ||
|
||
wanted_npms.each do |p,v| | ||
describe directory("#{npms_path}/node_modules/#{p}") do | ||
it { should exist } | ||
end | ||
end | ||
end | ||
|
||
### UNWANTED | ||
control 'Unwanted npm packages' do | ||
title 'should be uninstalled' | ||
desc '(only testing in the Debian platform, as the node-formula dependency is too specific)' | ||
|
||
only_if do | ||
os.name == 'debian' | ||
end | ||
|
||
%w{ | ||
gist | ||
}.each do |p| | ||
describe npm(p) do | ||
it { should_not be_installed } | ||
end | ||
end | ||
end |