�
u��ec@s|ddlZddlZddlmZmZmZmZmZdeeeeefd��YZdefd��YZ dS(i����N(tPlugintRedHatPlugintDebianPlugintUbuntuPlugint
SuSEPlugintNpmcBsGeZdZdZd
ZdgZdZd
d�Zd�Z d �Z
RS(s.
Get info about available npm modules
tnpmtsystemtproject_paths/List npm modules of a project specified by pathtfasttcCs#|j|d|dtd|�dS(Ntsuggest_filenametstderrtrunat(tadd_cmd_outputtFalse(tselftcmdtfilenametworking_directory((s3/usr/lib/python2.7/site-packages/sos/plugins/npm.pyt_get_npm_output s
cCsi}|jddt�}|ddkr�x�g|dj�D]}|jd�r?|^q?D]u}|jtjj�}t|�dkr�q^n|\}}}} }
||kr�| g||<q^||j | �q^Wn|j
d|�|jd �}|jt
j|�|�d
S(sY
Example 'npm cache ls' output
~/.npm
~/.npm/acorn
~/.npm/acorn/1.2.2
~/.npm/acorn/1.2.2/package.tgz
~/.npm/acorn/1.2.2/package
~/.npm/acorn/1.2.2/package/package.json
~/.npm/acorn/4.0.3
~/.npm/acorn/4.0.3/package.tgz
~/.npm/acorn/4.0.3/package
~/.npm/acorn/4.0.3/package/package.json
~/.npm/registry.npmjs.org
~/.npm/registry.npmjs.org/acorn
~/.npm/registry.npmjs.org/acorn/.cache.json
https://docs.npmjs.com/cli/cache
snpm cache lstchroottstatusitoutputspackage.tgzismodules in cache: %stnpm_cache_modulesN(tcollect_cmd_outputRt
splitlinestendswithtsplittostpathtseptlentappendt
_log_debugt_make_command_filenametadd_string_as_filetjsontdumps(RRt
user_cachetltpackaget
five_tuplethometcachetnametversiontpackage_tgztoutfn((s3/usr/lib/python2.7/site-packages/sos/plugins/npm.pyt_find_modules_in_npm_cache)scCs�|jd�retjjtjj|jd���}|jddd|�|jddd|�n|jdd�|jdd �|j�dS(
NRs
npm ls --jsontnpm_ls_projectRsnpm config list -ltnpm_config_list_projectsnpm ls -g --jsont
npm_ls_globaltnpm_config_list_global(t
get_optionRRtabspatht
expanduserRR1(RR((s3/usr/lib/python2.7/site-packages/sos/plugins/npm.pytsetupPs
(ssystem(sproject_paths/List npm modules of a project specified by pathR R
(RN(t__name__t
__module__t__doc__tplugin_nametprofilestoption_listtpackagestNoneRR1R9(((s3/usr/lib/python2.7/site-packages/sos/plugins/npm.pyRs 'tNpmViaNodeJScBseZdZdZRS(sG
some distribution methods don't provide 'npm' via npm package
tnodejs(RC(R:R;R<R@(((s3/usr/lib/python2.7/site-packages/sos/plugins/npm.pyRB_s(
RR%tsos.pluginsRRRRRRRB(((s3/usr/lib/python2.7/site-packages/sos/plugins/npm.pyt<module>
s("N |