Added npm ci command (#49665)

* #49664 Added npm ci command

* Update lib/ansible/modules/packaging/language/npm.py

Sure

Co-Authored-By: Bramzor <bramverdonck@telenet.be>

* Moved ci_install so it would work for specific packages

Would this work?

* Reverted last commit

npm ci will remove node_modules so cannot be used it to install a specific module.

* Update lib/ansible/modules/packaging/language/npm.py

Co-Authored-By: Bramzor <bramverdonck@telenet.be>

* Update lib/ansible/modules/packaging/language/npm.py

Co-Authored-By: Bramzor <bramverdonck@telenet.be>

* Update lib/ansible/modules/packaging/language/npm.py

Co-Authored-By: Bramzor <bramverdonck@telenet.be>
pull/52820/head
Bramzor 6 years ago committed by John R Barker
parent 7d5418e3d0
commit 17186bbde0

@ -0,0 +1,3 @@
---
minor_changes:
- "npm ci feature added which allows to install a project with a clean slate: https://docs.npmjs.com/cli/ci.html"

@ -59,6 +59,12 @@ options:
type: bool type: bool
default: no default: no
version_added: "2.8" version_added: "2.8"
ci:
description:
- Install packages based on package-lock file, same as running npm ci
type: bool
default: no
version_added: "2.8"
production: production:
description: description:
- Install dependencies in production mode, excluding devDependencies - Install dependencies in production mode, excluding devDependencies
@ -211,6 +217,9 @@ class Npm(object):
def install(self): def install(self):
return self._exec(['install']) return self._exec(['install'])
def ci_install(self):
return self._exec(['ci'])
def update(self): def update(self):
return self._exec(['update']) return self._exec(['update'])
@ -241,6 +250,7 @@ def main():
state=dict(default='present', choices=['present', 'absent', 'latest']), state=dict(default='present', choices=['present', 'absent', 'latest']),
ignore_scripts=dict(default=False, type='bool'), ignore_scripts=dict(default=False, type='bool'),
unsafe_perm=dict(default=False, type='bool'), unsafe_perm=dict(default=False, type='bool'),
ci=dict(default=False, type='bool'),
) )
arg_spec['global'] = dict(default='no', type='bool') arg_spec['global'] = dict(default='no', type='bool')
module = AnsibleModule( module = AnsibleModule(
@ -258,6 +268,7 @@ def main():
state = module.params['state'] state = module.params['state']
ignore_scripts = module.params['ignore_scripts'] ignore_scripts = module.params['ignore_scripts']
unsafe_perm = module.params['unsafe_perm'] unsafe_perm = module.params['unsafe_perm']
ci = module.params['ci']
if not path and not glbl: if not path and not glbl:
module.fail_json(msg='path must be specified when not using global') module.fail_json(msg='path must be specified when not using global')
@ -269,7 +280,10 @@ def main():
unsafe_perm=unsafe_perm, state=state) unsafe_perm=unsafe_perm, state=state)
changed = False changed = False
if state == 'present': if ci:
npm.ci_install()
changed = True
elif state == 'present':
installed, missing = npm.list() installed, missing = npm.list()
if missing: if missing:
changed = True changed = True

Loading…
Cancel
Save