How to use the check-more-types.oneOf 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 cypress-io / cypress-documentation / cy_scripts / deploy.js View on Github external
const questionsRemain = require('@cypress/questions-remain')
const scrape = require('./scrape')
const { shouldDeploy } = require('./should-deploy')
const R = require('ramda')
const la = require('lazy-ass')
const is = require('check-more-types')
const {
  warnIfNotCI,
  getDeployEnvironment,
  checkBranchEnvFolder,
  uploadToS3,
  getBranch,
} = require('@cypress/deploy-bits')

const distDir = path.resolve('public')
const isValidEnvironment = is.oneOf(['production', 'staging'])

function cliOrAsk (property, ask, minimistOptions) {
  // for now isolate the CLI/question logic
  const askRemaining = questionsRemain({
    [property]: ask,
  })
  const options = minimist(process.argv.slice(2), minimistOptions)

  return askRemaining(options).then(R.prop(property))
}

function prompt (questions) {
  return Promise.resolve(inquirer.prompt(questions))
}

function promptToScrape () {
github cypress-io / cypress-documentation / cy_scripts / should-deploy.js View on Github external
const isEnvVariableOn = (name) => {
  const value = process.env[name]

  if (!value) {
    return false
  }

  return value === 'true'
    || value === 'TRUE'
    || value === 'on'
    || value === '1'
    || value === 'yes'
}
const isForced = process.argv.some(equals('--force')) || isEnvVariableOn('FORCE_DEPLOY')

const isValidEnvironment = is.oneOf(['staging', 'production'])

/* eslint-disable no-console */

/**
 * Checks if current Git branch (develop, master, hot-fix-1)
 * is allowed to deploy to the target environment
 *
 * @param env {string} Target environment, like "staging" or "production"
 */
function isRightBranch (env) {
  la(is.unemptyString(env), 'expected environment name', env)

  // allow multiple branches to deploy to staging environment,
  // add to the keys in this object
  // "my-fix-branch": "staging"
  const branchToEnv = {
github cypress-io / cypress / packages / server / lib / browsers / index.js View on Github external
const _ = require('lodash')
const path = require('path')
const Promise = require('bluebird')
const debug = require('debug')('cypress:server:browsers')
const utils = require('./utils')
const errors = require('../errors')
const check = require('check-more-types')

// returns true if the passed string is a known browser family name
const isBrowserFamily = check.oneOf(['electron', 'chrome'])

let instance = null

const kill = function (unbind) {
  // cleanup our running browser
  // instance
  if (!instance) {
    return Promise.resolve()
  }

  return new Promise((resolve) => {
    if (unbind) {
      instance.removeAllListeners()
    }

    instance.once('exit', function (...args) {
github bahmutov / next-ver / src / increment.js View on Github external
function isSemanticChange (type) {
  return is.oneOf(['major', 'feat', 'fix', 'chore'], type)
}
github bahmutov / dont-crack / src / index.js View on Github external
const log = require('debug')('dont-crack')
const is = require('check-more-types')
const la = require('lazy-ass')
const dontBreak = require('dont-break')
const alwaysError = require('always-error')

const isReleaseType = is.oneOf(['major', 'minor', 'patch', 'initial'])

function dontCrack (opts, config, callback) {
  log('dont-crack arguments')
  log('opts', opts)
  log('commits')
  log(config.commits)
  log('last release was', config.lastRelease)
  log('next release is', config.nextRelease)

  la(isReleaseType(config.nextRelease.type),
    'invalid next release type', config.nextRelease)

  if (config.nextRelease.type === 'initial') {
    log('initial release')
    return callback()
  }
github bahmutov / npm-utils / src / npm-increment-version.js View on Github external
var la = require('lazy-ass')
var is = require('check-more-types')
var run = require('./npm-test')
var debug = require('debug')('npm-utils')

var isIncrement = is.oneOf(['major', 'minor', 'patch'])

function npmVersion (opts) {
  la(is.object(opts), 'missing options')
  la(isIncrement(opts.increment) ||
    is.semver(opts.increment), 'invalid increment or version', opts)

  var cmd = 'npm version ' + opts.increment
  if (opts.noGit) {
    cmd += ' --no-git-tag-version'
  }
  debug('npm version command "%s"', cmd)
  return run(cmd)
}

module.exports = npmVersion
github bahmutov / comment-value / src / update.js View on Github external
function updateVariableComment (c) {
    const line = lines[c.lineIndex]
    la(line, 'missing line', c.lineIndex, 'for comment', c)
    la(is.oneOf(['value', 'type'], c.find), 'invalid variable', c.variable,
      'find', c.find, c)
    const variableString = c.find === 'value'
      ? ` ${c.variable}:` : ` ${c.variable}::`
    const variableIndex = line.indexOf(variableString)
    la(is.found(variableIndex),
      'cannot find variable comment', c, 'on line', line)
    const start = line.substr(0, variableIndex + variableString.length)
    const newComment = start + ' ' + JSON.stringify(c.value)
    lines[c.lineIndex] = newComment
  }
github bahmutov / github-post-release / src / utils.js View on Github external
return message
}

function formDeployMessage (owner, repo, name, version) {
  la(arguments.length === 4, 'invalid arguments', arguments)

  const vTag = `v${version}`
  const releaseText = formReleaseText(repo, vTag)
  const releaseUrl = formReleaseUrl(owner, repo, vTag)
  const message = tags.stripIndent`
    Version \`${version}\` has been deployed. The full release note can be found at [${releaseText}](${releaseUrl}).
  `
  return message
}

const isValidType = is.oneOf(['npm', 'publish', 'deploy'])

function formMessage (type, owner, repo, name, version) {
  la(isValidType(type), 'invalid message type', type)
  const form = {
    npm: formNpmMessage,
    publish: formNpmMessage,
    deploy: formDeployMessage
  }
  const action = form[type]
  la(is.fn(action), 'cannot find action for type', type)
  return action(owner, repo, name, version)
}

module.exports = {
  commitsToIssues: commitsToIssues,
  formReleaseUrl: formReleaseUrl,