How to use the check-more-types.verify function in check-more-types

To help you get started, we’ve selected a few check-more-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bahmutov / next-update / src / test-module-version.js View on Github external
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);
github bahmutov / next-update / src / report-install-command.js View on Github external
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
github bahmutov / next-update / src / moduleName.js View on Github external
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]
  }
}
github bahmutov / next-update / src / module-install.js View on Github external
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
  }]])
github bahmutov / next-update / src / report-install-command.js View on Github external
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
github bahmutov / next-update / src / print-modules-table.js View on Github external
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'
  })
github bahmutov / next-update / src / registry.js View on Github external
'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)
github bahmutov / next-update / src / report-install-command.js View on Github external
versions.forEach(function (info) {
    check.verify.string(info.name, 'missing package name ' + info)
    if (info.works) {
      working = info
    }
  })
github bahmutov / next-update / src / dependencies.js View on Github external
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)
}
github bahmutov / next-update / src / get-known-dependencies.js View on Github external
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]
    }
  })
}