
    Vh;                     v    d dl mZmZmZ eZdZdZd dlZd dl	Z	d dl
mZ  G d de      Zd Zed	k(  r e        yy)
    )absolute_importdivisionprint_functionaW  
module: bower
short_description: Manage bower packages with C(bower)
description:
  - Manage bower packages with C(bower).
author: "Michael Warkentin (@mwarkentin)"
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: none
  diff_mode:
    support: none
options:
  name:
    type: str
    description:
      - The name of a bower package to install.
  offline:
    description:
      - Install packages from local cache, if the packages were installed before.
    type: bool
    default: false
  production:
    description:
      - Install with C(--production) flag.
    type: bool
    default: false
  path:
    type: path
    description:
      - The base path where to install the bower packages.
    required: true
  relative_execpath:
    type: path
    description:
      - Relative path to bower executable from install path.
  state:
    type: str
    description:
      - The state of the bower package.
    default: present
    choices: ["present", "absent", "latest"]
  version:
    type: str
    description:
      - The version to be installed.
a  
- name: Install "bootstrap" bower package.
  community.general.bower:
    name: bootstrap

- name: Install "bootstrap" bower package on version 3.1.1.
  community.general.bower:
    name: bootstrap
    version: '3.1.1'

- name: Remove the "bootstrap" bower package.
  community.general.bower:
    name: bootstrap
    state: absent

- name: Install packages based on bower.json.
  community.general.bower:
    path: /app/location

- name: Update packages based on bower.json to their latest version.
  community.general.bower:
    path: /app/location
    state: latest

# install bower locally and run from there
- npm:
    path: /app/location
    name: bower
    global: false
- community.general.bower:
    path: /app/location
    relative_execpath: node_modules/.bin
N)AnsibleModulec                   2    e Zd Zd ZddZd Zd Zd Zd Zy)	Bowerc                     || _         |d   | _        |d   | _        |d   | _        |d   | _        |d   | _        |d   | _        |d   r"| j                  dz   | j                  z   | _        y | j                  | _        y )Nnameoffline
productionpathrelative_execpathversion#)moduler
   r   r   r   r   r   name_version)selfr   kwargss      k/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/bower.py__init__zBower.__init__f   s~    6N	i( .6N	!'(;!<i() $		C$,, >D $		D    c                 |   | j                   j                  r| j                   j                  r|rg }| j                  r|j                  t        j
                  j                  | j
                  | j                  d             t        j
                  j                  |d         s;| j                   j                  d| j                  z         n|j                  d       |j                  |       |j                  ddg       | j                  r|j                  | j                         | j                  r|j                  d       | j                  r|j                  d       d }| j
                  rt        j
                  j                  | j
                        st	        j                  | j
                         t        j
                  j!                  | j
                        s)| j                   j                  d	| j
                  z         | j
                  }| j                   j#                  |||
      \  }}}|S y)Nbowerz#bower not found at relative path %smsgz--config.interactive=falsez--allow-rootz	--offlinez--productionzpath %s is not a directory)check_rccwd )r   
check_moder   appendosr   joinisfile	fail_jsonextendr
   r   r   r   existsmakedirsisdirrun_command)	r   argsrun_in_check_moder   cmdr   rcouterrs	            r   _execzBower._exect   s   {{%%$++*@*@EVC%%

277<<		43I3I7STww~~c"g.KK)).SVZVlVl.l)m

7#JJtJJ4nEFyy

4,,-||

;'

>* Cyyww~~dii0KK		*ww}}TYY/KK)).JTYY.V)Wii;;223s2SLBSJr   c                    ddg}t               }t               }t               }t        j                  | j                  |dd            }d|v r|d   D ]  }|d   |   }|j	                  dd      r|j                  |       /d|d   v r'd	|v r#|d   d   |d	   d
   k7  r|j                  |       ]|j	                  dd      r|j                  |       |j                  |        n|j                  | j                         |||fS )Nlistz--jsonTFdependenciesmissingr   pkgMetaupdatelatestincompatible)r3   jsonloadsr1   getr!   r
   )r   r-   	installedr5   outdateddatadepdep_datas           r   r3   z
Bower.list   s   x F	&6zz$**S$67T!N+ */4<<	51NN3'8I#66 H, +I6(8:LX:VVOOC(\\.%8OOC($$S)* NN499%'8++r   c                 &    | j                  dg      S )Ninstallr1   r   s    r   rC   zBower.install   s    zz9+&&r   c                 &    | j                  dg      S )Nr7   rD   rE   s    r   r7   zBower.update   s    zz8*%%r   c                 &    | j                  dg      S )N	uninstallrD   rE   s    r   rH   zBower.uninstall   s    zz;-((r   N)FT)	__name__
__module____qualname__r   r1   r3   rC   r7   rH    r   r   r   r   e   s!    *"H,4'&)r   r   c                  <   t        t        d       t        dd      t        dd      t        dd      t        d dd      t        d	g d
      t        d             } t        |       }|j                  d   }|j                  d   }|j                  d   }|j                  d   }|j                  d   }|j                  d   }|j                  d   }|dk(  r|s|j                  d       t	        |||||||      }	d}
|d	k(  r)|	j                         \  }}}|rmd}
|	j                          nZ|dk(  r+|	j                         \  }}}|s|r=d}
|	j                          n*|	j                         \  }}}||v rd}
|	j                          |j                  |
       y )N)defaultFbool)rN   typeTr   )requiredrP   )rN   rQ   rP   present)rR   absentr8   )rN   choices)r
   r   r   r   r   stater   )argument_specr
   r   r   r   rU   r   rS   z;uninstalling a package is only available for named packagesr   )r
   r   r   r   r   r   r8   )changed)
dictr   paramsr%   r   r3   rC   r7   rH   	exit_json)arg_specr   r
   r   r   r   r   rU   r   r   rW   r=   r5   r>   s                 r   mainr\      s   $U0F34f-te&I9.OPT"H F == DmmI&G|,J== D&9:MM'"EmmI&GZ[&tWRVj{  FM  NEG	',zz|$	7HGMMO	(	',zz|$	7HhGLLN',zz|$	7H9GOO
W%r   __main__)
__future__r   r   r   rP   __metaclass__DOCUMENTATIONEXAMPLESr:   r"   ansible.module_utils.basicr   objectr   r\   rI   rL   r   r   <module>rd      sW    A @/b D  	 4T)F T)n,&^ zF r   