|
|
@ -48,6 +48,12 @@ options:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The base path where to install the bower packages
|
|
|
|
- The base path where to install the bower packages
|
|
|
|
required: true
|
|
|
|
required: true
|
|
|
|
|
|
|
|
relative_execpath:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Relative path to bower executable from install path
|
|
|
|
|
|
|
|
default: null
|
|
|
|
|
|
|
|
required: false
|
|
|
|
|
|
|
|
version_added: "2.1"
|
|
|
|
state:
|
|
|
|
state:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The state of the bower package
|
|
|
|
- The state of the bower package
|
|
|
@ -75,6 +81,10 @@ description: Install packages based on bower.json.
|
|
|
|
|
|
|
|
|
|
|
|
description: Update packages based on bower.json to their latest version.
|
|
|
|
description: Update packages based on bower.json to their latest version.
|
|
|
|
- bower: path=/app/location state=latest
|
|
|
|
- bower: path=/app/location state=latest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
description: install bower locally and run from there
|
|
|
|
|
|
|
|
- npm: path=/app/location name=bower global=no
|
|
|
|
|
|
|
|
- bower: path=/app/location relative_execpath=node_modules/.bin
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -85,6 +95,7 @@ class Bower(object):
|
|
|
|
self.offline = kwargs['offline']
|
|
|
|
self.offline = kwargs['offline']
|
|
|
|
self.production = kwargs['production']
|
|
|
|
self.production = kwargs['production']
|
|
|
|
self.path = kwargs['path']
|
|
|
|
self.path = kwargs['path']
|
|
|
|
|
|
|
|
self.relative_execpath = kwargs['relative_execpath']
|
|
|
|
self.version = kwargs['version']
|
|
|
|
self.version = kwargs['version']
|
|
|
|
|
|
|
|
|
|
|
|
if kwargs['version']:
|
|
|
|
if kwargs['version']:
|
|
|
@ -94,7 +105,17 @@ class Bower(object):
|
|
|
|
|
|
|
|
|
|
|
|
def _exec(self, args, run_in_check_mode=False, check_rc=True):
|
|
|
|
def _exec(self, args, run_in_check_mode=False, check_rc=True):
|
|
|
|
if not self.module.check_mode or (self.module.check_mode and run_in_check_mode):
|
|
|
|
if not self.module.check_mode or (self.module.check_mode and run_in_check_mode):
|
|
|
|
cmd = ["bower"] + args + ['--config.interactive=false', '--allow-root']
|
|
|
|
cmd = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.relative_execpath:
|
|
|
|
|
|
|
|
cmd.append(os.path.join(self.path, self.relative_execpath, "bower"))
|
|
|
|
|
|
|
|
if not os.path.isfile(cmd[-1]):
|
|
|
|
|
|
|
|
self.module.fail_json(msg="bower not found at relative path %s" % self.relative_execpath)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
cmd.append("bower")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd.extend(args)
|
|
|
|
|
|
|
|
cmd.extend(['--config.interactive=false', '--allow-root'])
|
|
|
|
|
|
|
|
|
|
|
|
if self.name:
|
|
|
|
if self.name:
|
|
|
|
cmd.append(self.name_version)
|
|
|
|
cmd.append(self.name_version)
|
|
|
@ -130,10 +151,9 @@ class Bower(object):
|
|
|
|
dep_data = data['dependencies'][dep]
|
|
|
|
dep_data = data['dependencies'][dep]
|
|
|
|
if dep_data.get('missing', False):
|
|
|
|
if dep_data.get('missing', False):
|
|
|
|
missing.append(dep)
|
|
|
|
missing.append(dep)
|
|
|
|
elif \
|
|
|
|
elif ('version' in dep_data['pkgMeta'] and
|
|
|
|
'version' in dep_data['pkgMeta'] and \
|
|
|
|
'update' in dep_data and
|
|
|
|
'update' in dep_data and \
|
|
|
|
dep_data['pkgMeta']['version'] != dep_data['update']['latest']):
|
|
|
|
dep_data['pkgMeta']['version'] != dep_data['update']['latest']:
|
|
|
|
|
|
|
|
outdated.append(dep)
|
|
|
|
outdated.append(dep)
|
|
|
|
elif dep_data.get('incompatible', False):
|
|
|
|
elif dep_data.get('incompatible', False):
|
|
|
|
outdated.append(dep)
|
|
|
|
outdated.append(dep)
|
|
|
@ -160,7 +180,8 @@ def main():
|
|
|
|
name=dict(default=None),
|
|
|
|
name=dict(default=None),
|
|
|
|
offline=dict(default='no', type='bool'),
|
|
|
|
offline=dict(default='no', type='bool'),
|
|
|
|
production=dict(default='no', type='bool'),
|
|
|
|
production=dict(default='no', type='bool'),
|
|
|
|
path=dict(required=True),
|
|
|
|
path=dict(required=True, type='path'),
|
|
|
|
|
|
|
|
relative_execpath=dict(default=None, required=False, type='path'),
|
|
|
|
state=dict(default='present', choices=['present', 'absent', 'latest', ]),
|
|
|
|
state=dict(default='present', choices=['present', 'absent', 'latest', ]),
|
|
|
|
version=dict(default=None),
|
|
|
|
version=dict(default=None),
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -172,13 +193,14 @@ def main():
|
|
|
|
offline = module.params['offline']
|
|
|
|
offline = module.params['offline']
|
|
|
|
production = module.params['production']
|
|
|
|
production = module.params['production']
|
|
|
|
path = os.path.expanduser(module.params['path'])
|
|
|
|
path = os.path.expanduser(module.params['path'])
|
|
|
|
|
|
|
|
relative_execpath = module.params['relative_execpath']
|
|
|
|
state = module.params['state']
|
|
|
|
state = module.params['state']
|
|
|
|
version = module.params['version']
|
|
|
|
version = module.params['version']
|
|
|
|
|
|
|
|
|
|
|
|
if state == 'absent' and not name:
|
|
|
|
if state == 'absent' and not name:
|
|
|
|
module.fail_json(msg='uninstalling a package is only available for named packages')
|
|
|
|
module.fail_json(msg='uninstalling a package is only available for named packages')
|
|
|
|
|
|
|
|
|
|
|
|
bower = Bower(module, name=name, offline=offline, production=production, path=path, version=version)
|
|
|
|
bower = Bower(module, name=name, offline=offline, production=production, path=path, relative_execpath=relative_execpath, version=version)
|
|
|
|
|
|
|
|
|
|
|
|
changed = False
|
|
|
|
changed = False
|
|
|
|
if state == 'present':
|
|
|
|
if state == 'present':
|
|
|
@ -201,4 +223,5 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
# Import module snippets
|
|
|
|
# Import module snippets
|
|
|
|
from ansible.module_utils.basic import *
|
|
|
|
from ansible.module_utils.basic import *
|
|
|
|
main()
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
main()
|
|
|
|