HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/bower.cpython-310.pyc
o

�N�g� �@sHdZddlmZmZdd�Zddd�Zddd	�Zdd
d�Zddd
�ZdS)a�
Installation of Bower Packages
==============================

These states manage the installed packages using Bower.
Note that npm, git and bower must be installed for these states to be
available, so bower states should include requisites to pkg.installed states
for the packages which provide npm and git (simply ``npm`` and ``git`` in most
cases), and npm.installed state for the package which provides bower.

Example:

.. code-block:: yaml

    npm:
      pkg.installed
    git:
      pkg.installed
    bower:
      npm.installed
      require:
        - pkg: npm
        - pkg: git

    underscore:
      bower.installed:
        - dir: /path/to/project
        - require:
          - npm: bower
�)�CommandExecutionError�CommandNotFoundErrorcCsdtvrdSdS)z@
    Only load if the bower module is available in __salt__
    �
bower.listZbower)Fz bower module could not be loaded)�__salt__�rr�E/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/bower.py�__virtual__#srNc
Cs�|ddid�}|dur|}n|g}ztd|||d�}Wn$ttfy@}zd|d<d|�d	|��|d
<|WYd}~Sd}~wwdd�|��D�}g}	g}
|D]G}|�d
�\}}
}|��}||vrh|
�|�qP||vr�||}|�d��d�}|�d
|��}|r�||kr�|
�|�n|	�|�qP|	�|�qPqPtdr�d|d<g}|
r�|�d�	d�
|
���g|
d�|d<|	r�|�d�	d�
|�d�
|	���d�
|�|d
<|S|
s�d|d<d�	d�
|�d�
|	��|d
<|Sz d|d||d�}|dur�||d<n||d<tddi|��}Wn&ttf�y,}zd|d<d�	d�
|�|�|d
<|WYd}~Sd}~ww|�rGd|d<g|
d�|d<d�	d�
|
��|d
<|Sd|d<d�	d�
|��|d
<|S) a,
    Verify that the given package is installed and is at the correct version
    (if specified).

    .. code-block:: yaml

        underscore:
          bower.installed:
            - dir: /path/to/project
            - user: someuser

        jquery#2.0:
          bower.installed:
            - dir: /path/to/project

    name
        The package to install

    dir
        The target directory in which to install the package

    pkgs
        A list of packages to install with a single Bower invocation;
        specifying this argument will ignore the ``name`` argument

    user
        The user to run Bower with

    env
        A list of environment variables to be set prior to execution. The
        format is the same as the :py:func:`cmd.run <salt.states.cmd.run>`.
        state function.

    N���name�result�comment�changesr��dir�runas�envFrzError looking up '�': r
cSsi|]\}}||�qSrr)�.0�p�inforrr�
<dictcomp>]szinstalled.<locals>.<dictcomp>�#ZpkgMeta�version�testz-Bower package(s) '{}' are set to be installedz, ��old�newrzPackage(s) '{}' satisfied by {}z. T)�pkgr�pkgsrrrr�
bower.installzError installing '{}': {}z&Package(s) '{}' successfully installedz!Could not install package(s) '{}'r)rrr�items�	partition�strip�append�get�__opts__�format�join)rrr�userr�retZpkg_list�installed_pkgs�errZpkgs_satisfiedZpkgs_to_installr�pkg_name�_Zpkg_verZ
installed_pkgZinstalled_pkg_verZinstalled_name_verZcomment_msgZcmd_args�callrrr�	installed,s�#��


�������
����r0c
CsV|ddid�}z
td||d�}Wn$ttfy5}zd|d<d|�d	|��|d
<|WYd}~Sd}~ww||vrHd|d<d|�d
�|d
<|StdrZd|d<d|�d�|d
<|Sz-td|||d�ryd|d<|di|d<d|�d�|d
<W|Sd|d<d|�d�|d
<W|Sttfy�}zd|d<d|�d	|��|d
<WYd}~|Sd}~ww)z�
    Verify that the given package is not installed.

    dir
        The target directory in which to install the package

    user
        The user to run Bower with

    Nr	r
r)rrFrzError removing 'rr
Tz	Package 'z' is not installedrz' is set to be removedzbower.uninstall�rrrZRemovedrz' was successfully removed�')rrrr&)rrr)r*r+r,rrr�removed�s@������r3c
Cs�|ddid�}tdrd|d<d|�d�|d<|Sztd	d||d
�}Wn$ttfyH}zd|d<d|�d
|��|d<|WYd}~Sd}~ww|sUd|d<d|d<|Sd|d<|di|d<d|d<|S)z�
    Bootstraps a frontend distribution.

    Will execute 'bower install' on the specified directory.

    user
        The user to run Bower with

    Nr	r
rr�Directory 'z' is set to be bootstrappedr
r r1FzError bootstrapping 'rTz!Directory is already bootstrappedZBootstrappedrz'Directory was successfully bootstrapped�r&rrr)rr)r*r/r,rrr�	bootstrap�s*
��r6c
Cs�|ddid�}tdrd|d<d|�d�|d<|Sztd	|||d
�}Wn$ttfyH}zd|d<d|�d
|��|d<|WYd}~Sd}~wwd|d<|r`d|�d�|d<g|d�|d<|Sd|�d�|d<|S)z�
    .. versionadded:: 2017.7.0

    Cleans up local bower_components directory.

    Will execute 'bower prune' on the specified directory (param: name)

    user
        The user to run Bower with

    Nr	r
rrr4z' is set to be prunedr
zbower.prunerFzError pruning 'rTz' was successfully prunedrrz(No packages were pruned from directory 'r2r5)rr)rr*r/r,rrr�pruned
s(���r7)NNN)N)NN)	�__doc__Zsalt.exceptionsrrrr0r3r6r7rrrr�<module>s
	

-$