Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var _ = require('lodash')
var semver = require('semver')
var quote = require('quote')
var installModule = require('./module-install')
var reportSuccess = require('./report').reportSuccess
var reportFailure = require('./report').reportFailure
const {getTestCommand} = require('./utils')
const path = require('path')
const debug = require('debug')('next-update')
var stats = require('./stats')
var cleanVersions = require('./registry').cleanVersions
check.verify.fn(cleanVersions, 'cleanVersions should be a function')
var revertModules = require('./revert')
check.verify.fn(revertModules, 'revert is not a function, but ' +
JSON.stringify(revertModules))
var npmTest = require('./npm-test').test
var execTest = require('./exec-test')
var report = require('./report-available')
var filterAllowed = require('./filter-allowed-updates')
// expect array of objects, each {name, versions (Array) }
// returns promise
function testModulesVersions (options, available) {
verify.object(options, 'missing options')
verify.array(available, 'expected array of available modules')
var cleaned = cleanVersions(options.modules)
// console.log('cleaned', cleaned);
// var listed = _.zipObject(cleaned);
updates.forEach(function (moduleList) {
if (!moduleList.length) {
return
}
var moduleName = moduleList[0].name
check.verify.string(moduleName, 'missing module name')
if (pkg.dependencies && pkg.dependencies[moduleName]) {
result.dependencies.push(moduleList)
} else if (pkg.devDependencies && pkg.devDependencies[moduleName]) {
result.devDependencies.push(moduleList)
} else if (pkg.peerDependencies && pkg.peerDependencies[moduleName]) {
result.peerDependencies.push(moduleList)
} else {
console.warn('Could not find dependency for', moduleName, 'assuming normal')
result.dependencies.push(moduleList)
}
})
return result
function moduleName (str) {
check.verify.string(str, 'expected string module name')
if (isScopedName(str)) {
return parseScopedName(str)
}
var parts = str.split('@')
return {
name: parts[0],
version: parts[1]
}
}
function installModule (options, results) {
check.verify.object(options, 'missing options')
la(check.unemptyString(options.name),
'expected module name string', options.name, 'all options', options)
check.verify.string(options.version, 'expected version string')
if (options.keep) {
console.assert(typeof options.keep === 'boolean', 'invalid keep')
}
if (results) {
check.verify.array(results, 'missing results')
}
var cmd = formInstallCommand([[{
name: options.name,
version: options.version,
works: true
}]])
function installCommandType (updates, type) {
check.verify.array(updates, 'expected array of updates')
if (!updates.length) {
return
}
check.verify.string(type, 'missing type')
var saveCommand = saveOption(type)
if (!saveCommand) {
throw new Error('invalid dependency type ' + type)
}
setWorkingVersion(updates)
var originalCmd, cmd
originalCmd = cmd = 'npm install ' + saveCommand
updates.forEach(function (moduleVersions) {
var latestWorkingVersion = moduleVersions.latestWorkingVersion
var verify = require('check-more-types').verify
var Table = require('easy-table')
var colorProbability = require('./stats').colorProbability
function markProbability (val, width) {
if (width === null) {
return val
}
return Table.padLeft(val, width)
}
function printModulesTable (modules, options) {
verify.array(modules, 'expect an array of modules')
var haveStats = modules.some(function (m) {
return typeof m.stats === 'object'
})
'use strict'
var la = require('lazy-ass')
var check = require('check-more-types')
var log = require('debug')('next-update')
const R = require('ramda')
var request = require('request')
var verify = check.verify
var semver = require('semver')
var q = require('q')
var localVersion = require('./local-module-version')
var isUrl = require('npm-utils').isUrl
var _ = require('lodash')
const {isPrerelease} = require('./utils')
var _registryUrl = require('npm-utils').registryUrl
la(check.fn(_registryUrl), 'expected registry url function')
var registryUrl = _.once(_registryUrl)
const notPrerelease = R.complement(isPrerelease)
function cleanVersion (version, name) {
var originalVersion = version
verify.unemptyString(version, 'missing version string' + version)
versions.forEach(function (info) {
check.verify.string(info.name, 'missing package name ' + info)
if (info.works) {
working = info
}
})
function printCurrentModules (infos) {
check.verify.array(infos, 'expected array of modules')
var modules = []
infos.forEach(function (nameVersionArray) {
check.verify.array(nameVersionArray, 'expected name version in ' + modules)
modules.push({
name: nameVersionArray[0],
version: nameVersionArray[1]
})
})
print(modules)
}
function format (label, deps) {
check.verify.unemptyString(label, 'missing label')
check.verify.object(deps, 'expected deps')
return Object.keys(deps).map(function (name) {
return {
type: label,
name: name,
version: deps[name]
}
})
}