%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/npm.pyo

�
���^c	@@sydZddlmZmZmZyddlmZWn!ek
rYddl	mZnXddl
Z
ddlZddl
ZddlZddlZddlmZddlmZddlmZe
je�Zidd	6Zd
�Zd�Zddddddeed�Z dddd
�Z!dddddd�Z"ddded�Z#dddd�Z$ddd�Z%dS(u 
Manage and query NPM packages.
i(tabsolute_importtunicode_literalstprint_function(tquoteN(tCommandExecutionError(tLooseVersion(tsixulistulist_cC@s^y4tjjjd�dk	r)t�tStdfSWn#tk
rY}tt	j
|�fSXdS(u*
    Only work when npm is installed.
    unpmuTnpm execution module could not be loaded because the npm binary could not be locatedN(tsalttutilstpathtwhichtNonet_check_valid_versiontTruetFalseRRt	text_type(texc((s4/usr/lib/python2.7/site-packages/salt/modules/npm.pyt__virtual__ scC@sXttjjjddd��}td�}||krTtdj||���ndS(us
    Check the version of npm to ensure this module will work. Currently
    npm must be at least version 1.2.
    u
npm --versiontoutput_logleveluquietu1.2u6'npm' is not recent enough({0} < {1}). Please Upgrade.N(t
_LooseVersionRtmodulestcmdmodtrunRtformat(tnpm_versiont
valid_version((s4/usr/lib/python2.7/site-packages/salt/modules/npm.pyR/sc
C@s�|rt|�g}n.|r@g|D]}t|�^q%}ng}|r[t|�}ndddg}	|r�|	jd�n|s�|	jd�n|r�|	jdj|��n|r�|	jd�n|	j|�|p�i}|r&tjjj|�}
|
r&|ji|
d6d	d
6�q&ndj	|	�}	t
d|	d
td|d|d|�}|ddkr�t|d��n|dp�|d}ytjj
j|�SWntk
r�|SXdS(u�
    Install an NPM package.

    If no directory is specified, the package will be installed globally. If
    no package is specified, the dependencies (from package.json) of the
    package in the given directory will be installed.

    pkg
        A package name in any format accepted by NPM, including a version
        identifier

    pkgs
        A list of package names in the same format as the ``name`` parameter

        .. versionadded:: 2014.7.0

    dir
        The target directory in which to install the package, or None for
        global installation

    runas
        The user to run NPM with

    registry
        The NPM registry to install the package from.

        .. versionadded:: 2014.7.0

    env
        Environment variables to set when invoking npm. Uses the same ``env``
        format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution
        function.

        .. versionadded:: 2014.7.0

    silent
        Whether or not to run NPM install with --silent flag.

        .. versionadded:: 2016.3.0

    dry_run
        Whether or not to run NPM install with --dry-run flag.

        .. versionadded:: 2015.8.4

    silent
        Whether or not to run NPM install with --silent flag.

        .. versionadded:: 2015.8.5

    CLI Example:

    .. code-block:: bash

        salt '*' npm.install coffee-script

        salt '*' npm.install coffee-script@1.0.1

    unpmuinstallu--jsonu--silentu--globalu--registry="{0}"u	--dry-runuSUDO_UIDuu	SUDO_USERu ucmd.run_alltpython_shelltcwdtrunastenvuretcodeiustderrustdoutN(t
_cmd_quotetappendRtextendRRtusertget_uidtupdatetjoint__salt__R
Rtjsont	find_jsont
ValueError(
tpkgtpkgstdirRtregistryRtdry_runtsilenttvtcmdtuidtresultt
npm_output((s4/usr/lib/python2.7/site-packages/salt/modules/npm.pytinstallAsFD"
!
	
cC@s�|rt|�}n|pi}|rctjjj|�}|rc|ji|d6dd6�qcndddj|�g}|s�|jd�ndj|�}t	d	|d
t
d|d|d
|�}|ddkr�tj|d�t
St
S(u�
    Uninstall an NPM package.

    If no directory is specified, the package will be uninstalled globally.

    pkg
        A package name in any format accepted by NPM

    dir
        The target directory from which to uninstall the package, or None for
        global installation

    runas
        The user to run NPM with

    env
        Environment variables to set when invoking npm. Uses the same ``env``
        format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution
        function.

        .. versionadded:: 2015.5.3

    CLI Example:

    .. code-block:: bash

        salt '*' npm.uninstall coffee-script

    uSUDO_UIDuu	SUDO_USERunpmu	uninstallu"{0}"u--globalu ucmd.run_allRRRRuretcodeiustderr(RRRR!R"R#RRR$R%R
tlogterrorR(R)R+RRR1R0R2((s4/usr/lib/python2.7/site-packages/salt/modules/npm.pyt	uninstall�s !(c
C@s�|p	i}|rNtjjj|�}|rN|ji|d6dd6�qNnddddg}|sv|jd�n|dk	r�t|tt	f�s�tj
jd	j|���n|jd
jt|���n|r�t
|�}|jdj|��ndj|�}td
|d|d|d|dtdt�}|ddkri|drit|d��ntjjj|d�jdi�S(u�
    List installed NPM packages.

    If no directory is specified, this will return the list of globally-
    installed packages.

    pkg
        Limit package listing by name

    dir
        The directory whose packages will be listed, or None for global
        installation

    runas
        The user to run NPM with

        .. versionadded:: 2014.7.0

    env
        Environment variables to set when invoking npm. Uses the same ``env``
        format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution
        function.

        .. versionadded:: 2014.7.0

    depth
        Limit the depth of the packages listed

        .. versionadded:: 2016.11.6,2017.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' npm.list

    uSUDO_UIDuu	SUDO_USERunpmulistu--jsonu--silentu--globalu!Error: depth {0} must be a numberu--depth={0}u"{0}"u ucmd.run_allRRRRtignore_retcodeuretcodeiustderrustdoutudependenciesN(RRR!R"R#RRt
isinstancetinttfloatt
exceptionstSaltInvocationErrorRRR$R%R
RR&tloadstget(R)R+RRtdepthR1R0R2((s4/usr/lib/python2.7/site-packages/salt/modules/npm.pytlist_�s*&!'c
C@s�|p	i}|rNtjjj|�}|rN|ji|d6dd6�qNndddg}|rs|j|�n|tkr�|jd�ndj|�}td	|d
dd|d|d
tdt�}|ddkr�t
j|d�tStS(uw
    Clean cached NPM packages.

    If no path for a specific package is provided the entire cache will be cleared.

    path
        The cache subpath to delete, or None to clear the entire cache

    runas
        The user to run NPM with

    env
        Environment variables to set when invoking npm. Uses the same ``env``
        format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution
        function.

    force
        Force cleaning of cache.  Required for npm@5 and greater

        .. versionadded:: 2016.11.6

    CLI Example:

    .. code-block:: bash

        salt '*' npm.cache_clean force=True

    uSUDO_UIDuu	SUDO_USERunpmucacheucleanu--forceu ucmd.run_allRRRRR8uretcodeiustderrN(
RRR!R"R#RR
R$R%RR5R6R(R	RRtforceR1R0R2((s4/usr/lib/python2.7/site-packages/salt/modules/npm.pytcache_clean5s"!'c
C@s�|p	i}|rNtjjj|�}|rN|ji|d6dd6�qNndddg}|rs|j|�ndj|�}td|d	dd
|d|dt	d
t	�}|ddkr�|dr�t
|d��n|dS(u�
    List NPM cached packages.

    If no path for a specific package is provided this will list all the cached packages.

    path
        The cache subpath to list, or None to list the entire cache

    runas
        The user to run NPM with

    env
        Environment variables to set when invoking npm. Uses the same ``env``
        format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution
        function.

    CLI Example:

    .. code-block:: bash

        salt '*' npm.cache_clean

    uSUDO_UIDuu	SUDO_USERunpmucacheulsu ucmd.run_allRRRRR8uretcodeiustderrustdoutN(RRR!R"R#RR$R%RR
R(R	RRR1R0R2((s4/usr/lib/python2.7/site-packages/salt/modules/npm.pyt
cache_listis!'c
C@s�|p	i}|rNtjjj|�}|rN|ji|d6dd6�qNnd}td|dd
d|d|d	td
t�}|jd�p�|jd�S(u_
    List path of the NPM cache directory.

    runas
        The user to run NPM with

    env
        Environment variables to set when invoking npm. Uses the same ``env``
        format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution
        function.

    CLI Example:

    .. code-block:: bash

        salt '*' npm.cache_path

    uSUDO_UIDuu	SUDO_USERunpm config get cacheucmd.run_allRRRRR8ustdoutustderrN(	RRR!R"R#R%RR
R?(RRR1R0R2((s4/usr/lib/python2.7/site-packages/salt/modules/npm.pyt
cache_path�s!'(&t__doc__t
__future__RRRtshlexRRtImportErrortpipestloggingtsalt.utils.jsonRtsalt.utils.pathtsalt.utils.usertsalt.modules.cmdmodtsalt.exceptionsRtsalt.utils.versionsRRtsalt.extRt	getLoggert__name__R5t__func_alias__RRRRR
R4R7RARCRDRE(((s4/usr/lib/python2.7/site-packages/salt/modules/npm.pyt<module>s>

		n7H4-

Zerion Mini Shell 1.0