diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4a48855..ddaa4f0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,43 +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 - -0.0.3 (2018-03-02) - -- Allow to hold/unhold system packages (#8) -- Add more tests - -0.0.4 (2018-03-06) - -- Allow to specify held system packages also as a list (#10) - -0.0.5 (2018-03-14) - -- Add snap support - -0.0.6 (2018-04-09) - -- Add snap with classic confinement support - -0.0.7 (2018-07-11) - -- Fix pip/gems for FreeBSD +- Add support for plain files using archive 0.0.8 (2018-08-23) - Add archive support -0.0.9 (2018-10-03) +0.0.7 (2018-07-11) -- Add support for plain files using arcihve +- Fix pip/gems for FreeBSD -0.1.0 (2019-03-10) +0.0.6 (2018-04-09) -- Add npm support +- Add snap with classic confinement support + +0.0.5 (2018-03-14) + +- Add snap support + +0.0.4 (2018-03-06) + +- Allow to specify held system packages also as a list (#10) + +0.0.3 (2018-03-02) + +- Allow to hold/unhold system packages (#8) + +0.0.2 (2018-02-23) + +- Add Fedora support +- Add more tests + +0.0.1 (2018-02-12) + +- Initial version diff --git a/packages/npms.sls b/packages/npms.sls index 4828cc3..4bea20a 100644 --- a/packages/npms.sls +++ b/packages/npms.sls @@ -13,20 +13,47 @@ npm_req_pkgs: - pkgs: {{ req_pkgs | json }} ### NPM PKGS to install using npm -# (requires the npm deb/rpm installed, either by the system or listed in +# (requires the npm binary installed, either by the system or listed in # the required packages -{% for nn in wanted_npms %} -{{ nn }}: + +{% 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: - - reload_modules: true + - 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 %} -{% endfor %} {% for upn in unwanted_npms %} {{ upn }}: diff --git a/pillar.example b/pillar.example index c61f94b..92d25f6 100644 --- a/pillar.example +++ b/pillar.example @@ -62,13 +62,26 @@ packages: - goodbye-world npms: + # dir: /home/kitchen/npms # The target directory in which to install the package, or None for global installation + # user: kitchen # The user to run NPM with (and to assign to `dir`) + # group: kitchen # The group to assign to `dir` + # mode: 0755 # The permissions to assign to `dir` + # registry: None # The NPM registry from which to install the package + # env: None # A list of environment variables to be set prior to execution + # force_reinstall: False # Install the package even if it is already installed required: - # pkgs: - # - some_package_you_need - sls: ['nodejs.ppa'] + pkgs: + - nodejs wanted: + # Valid formats: + # + # @google-cloud/bigquery@^0.9.6 + # @foobar + # buffer-equal-constant-time@1.0.1 + # coffee-script - hello-world-npm - sax + - coffee-script@1.0.1 unwanted: - gist diff --git a/test/integration/default/npms_spec.rb b/test/integration/default/npms_spec.rb index 5077b8d..debcb46 100644 --- a/test/integration/default/npms_spec.rb +++ b/test/integration/default/npms_spec.rb @@ -1,18 +1,24 @@ +wanted_npms = { + '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-formual dependency is too specific)' + desc '(only testing in the Debian platform, as the node-formula dependency is too specific)' only_if do os.name == 'debian' end - %w{ - sax - hello-world-npm - }.each do |p| + wanted_npms.each do |p,v| describe npm(p) do it { should be_installed } + # FIXME! Testing for version is failing, seems an issue in inspec + # Same happens with testing path, as it performs a cd command and it fails when using sudo + # its('version') { should eq v } end end end @@ -20,7 +26,7 @@ end ### 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)' + desc '(only testing in the Debian platform, as the node-formula dependency is too specific)' only_if do os.name == 'debian'