????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 3.137.185.239 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/lib/node_modules/npm/node_modules/libnpmfund/ |
Upload File : |
'use strict' const URL = require('url').URL const Arborist = require('@npmcli/arborist') // supports object funding and string shorthand, or an array of these // if original was an array, returns an array; else returns the lone item function normalizeFunding (funding) { const normalizeItem = item => typeof item === 'string' ? { url: item } : item const sources = [].concat(funding || []).map(normalizeItem) return Array.isArray(funding) ? sources : sources[0] } // Is the value of a `funding` property of a `package.json` // a valid type+url for `npm fund` to display? function isValidFunding (funding) { if (!funding) return false if (Array.isArray(funding)) return funding.every(f => !Array.isArray(f) && isValidFunding(f)) try { var parsed = new URL(funding.url || funding) } catch (error) { return false } if ( parsed.protocol !== 'https:' && parsed.protocol !== 'http:' ) return false return Boolean(parsed.host) } const empty = () => Object.create(null) function readTree (tree, opts) { let packageWithFundingCount = 0 const seen = new Set() const { countOnly } = opts || {} const _trailingDependencies = Symbol('trailingDependencies') let filterSet if (opts && opts.workspaces && opts.workspaces.length) { const arb = new Arborist(opts) filterSet = arb.workspaceDependencySet(tree, opts.workspaces) } function tracked (name, version) { const key = String(name) + String(version) if (seen.has(key)) return true seen.add(key) } function retrieveDependencies (dependencies) { const trailing = dependencies[_trailingDependencies] if (trailing) { return Object.assign( empty(), dependencies, trailing ) } return dependencies } function hasDependencies (dependencies) { return dependencies && ( Object.keys(dependencies).length || dependencies[_trailingDependencies] ) } function attachFundingInfo (target, funding) { if (funding && isValidFunding(funding)) { target.funding = normalizeFunding(funding) packageWithFundingCount++ } } function getFundingDependencies (tree) { const edges = tree && tree.edgesOut && tree.edgesOut.values() if (!edges) return empty() const directDepsWithFunding = Array.from(edges).map(edge => { if (!edge || !edge.to) return empty() const node = edge.to.target || edge.to if (!node.package) return empty() if (filterSet && filterSet.size > 0 && !filterSet.has(node)) return empty() const { name, funding, version } = node.package // avoids duplicated items within the funding tree if (tracked(name, version)) return empty() const fundingItem = {} if (version) fundingItem.version = version attachFundingInfo(fundingItem, funding) return { node, fundingItem, } }) return directDepsWithFunding.reduce( (res, { node, fundingItem }, i) => { if (!fundingItem || fundingItem.length === 0 || !node) return res // recurse const transitiveDependencies = node.edgesOut && node.edgesOut.size > 0 && getFundingDependencies(node) // if we're only counting items there's no need // to add all the data to the resulting object if (countOnly) return null if (hasDependencies(transitiveDependencies)) { fundingItem.dependencies = retrieveDependencies(transitiveDependencies) } if (isValidFunding(fundingItem.funding)) res[node.package.name] = fundingItem else if (hasDependencies(fundingItem.dependencies)) { res[_trailingDependencies] = Object.assign( empty(), res[_trailingDependencies], fundingItem.dependencies ) } return res }, countOnly ? null : empty()) } const treeDependencies = getFundingDependencies(tree) const result = { length: packageWithFundingCount, } if (!countOnly) { const name = (tree && tree.package && tree.package.name) || (tree && tree.name) result.name = name || (tree && tree.path) if (tree && tree.package && tree.package.version) result.version = tree.package.version if (tree && tree.package && tree.package.funding) result.funding = normalizeFunding(tree.package.funding) result.dependencies = retrieveDependencies(treeDependencies) } return result } async function read (opts) { const arb = new Arborist(opts) const tree = await arb.loadActual(opts) return readTree(tree, opts) } module.exports = { read, readTree, normalizeFunding, isValidFunding, }