Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const isUrlOrPort = input => {
const str = is.string(input) ? input.split('|') : [input]
return str.every(s => {
if (is.url(s)) {
return s
}
// wait-on allows specifying HTTP verb to use instead of default HEAD
// and the format then is like "http-get://domain.com" to use GET
if (isWaitOnUrl(s)) {
return s
}
if (is.number(s)) {
return is.port(s)
}
if (!is.string(s)) {
return false
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);
return str.map(s => {
if (is.url(s)) {
return s
}
if (is.number(s) && is.port(s)) {
return `http://localhost:${s}`
}
if (!is.string(s)) {
return s
}
if (is.port(parseInt(s))) {
return `http://localhost:${s}`
}
if (s[0] === ':') {
return `http://localhost${s}`
}
// for anything else, return original argument
return s
return str.every(s => {
if (is.url(s)) {
return s
}
// wait-on allows specifying HTTP verb to use instead of default HEAD
// and the format then is like "http-get://domain.com" to use GET
if (isWaitOnUrl(s)) {
return s
}
if (is.number(s)) {
return is.port(s)
}
if (!is.string(s)) {
return false
}
if (s[0] === ':') {
const withoutColon = s.substr(1)
const getArguments = cliArgs => {
la(is.strings(cliArgs), 'expected list of strings', cliArgs)
let start = 'start'
let test = 'test'
let url
if (cliArgs.length === 1 && isUrlOrPort(cliArgs[0])) {
// passed just single url or port number, for example
// "start": "http://localhost:8080"
url = normalizeUrl(cliArgs[0])
} else if (cliArgs.length === 2) {
if (isUrlOrPort(cliArgs[0])) {
// passed port and custom test command
// like ":8080 test-ci"
url = normalizeUrl(cliArgs[0])
test = cliArgs[1]
}
getCIName,
getCIBuildUrl,
} = require('./utils')
const { addCommitComment } = require('@cypress/github-commit-status-check')
const { stripIndent } = require('common-tags')
/* eslint-disable no-console */
const { npm, binary } = getNameAndBinary(process.argv)
la(is.unemptyString(npm), 'missing npm url')
la(is.unemptyString(binary), 'missing binary url')
const commitInfo = getShortCommit()
la(is.object(commitInfo), 'could not determine current commit information')
const { sha } = commitInfo
la(is.commitId(sha), 'could not find commit SHA')
const platform = os.platform()
const arch = os.arch()
console.log('posting pre-release instructions')
console.log(' commit:', sha)
console.log(' npm:', npm)
console.log(' binary:', binary)
console.log(' platform:', platform)
console.log(' arch:', arch)
const ciName = getCIName() || 'Unknown CI'
const buildUrl = getCIBuildUrl()
if (f.f === R.append) {
const allValues = grab.everything(examples)
la(is.array(allValues), 'could not grab values from', examples)
return allValues.map((value) => {
const s = is.string(value) ? `'${value}'` : value
return {
f: f.f(value),
name: `${f.name}(${s})`
}
})
}
if (f.f === R.split) {
const strings = grab.strings(examples)
la(is.array(strings), 'expected list of strings from', examples, strings)
const characters = R.uniq(strings.join('').split(''))
// console.log('characters', characters)
return characters.map((sep) => {
return {
f: f.f(sep),
name: `${f.name}('${sep}')`
}
})
}
return []
}
const statementCovered = (options) => {
// console.log('%s s %s covered %d', options.name, options.s, options.counter)
if (server && cover) {
la(is.unemptyString(options.s), 'no covered statement', options)
la(is.unemptyString(options.filename), 'no filename', options)
const fileCoverage = cover[options.filename]
if (fileCoverage) {
const statementInfo = fileCoverage.statementMap[options.s]
la(statementInfo, 'missing start for statement', options.s)
const firstLine = statementInfo.start.line
la(is.number(firstLine), 'not a number of line', statementInfo)
console.log('line', firstLine, 'counter', options.counter)
server.statementCovered(options.filename, firstLine, options.counter)
}
}
}
var testWithPreviousVersion
var currentModuleInstallMethod
if (check.string(dependent)) {
dependent = {name: dependent.trim()}
}
dependent = Object.assign({pretest: true, currentModuleInstall: 'npm install $CURRENT_MODULE_DIR'}, config, dependent)
moduleTestCommand = dependent.test
modulePostinstallCommand = dependent.postinstall || 'npm install'
testWithPreviousVersion = dependent.pretest
currentModuleInstallMethod = dependent.currentModuleInstall
var dependentInstall = dependent.install
dependent = dependent.name
la(check.unemptyString(dependent), 'invalid dependent', dependent)
banner(' testing', quote(dependent))
const moduleName = getDependencyName(dependent)
function formFullFolderName () {
if (isRepoUrl(dependent)) {
// simple repo installation
return toFolder
} else {
let scoped = moduleName.startsWith('@')
let idx = scoped ? 1 : 0
let moduleDir = moduleName.split('@')[idx]
moduleDir = scoped ? `@${moduleDir}` : moduleDir
return join(toFolder, 'node_modules', moduleDir)
}
}
debug(json.name, 'bare name', bareName, 'main', json.main)
const destinationFolder = path.join(pathToPackages, bareName)
const destPackageFilename = path.join(destinationFolder, 'package.json')
const registerPath = path.join(destinationFolder, 'register.js')
const fullMain = path.resolve(dirname, json.main)
debug('full name', fullMain)
const relativePathToMain = path.relative(destinationFolder, fullMain)
debug('relative path to main', relativePathToMain)
// for browserify, some packages use "browser" field
// need to pass it as well
let relativePathToBrowser
if (is.unemptyString(json.browser)) {
debug('package has browser field %s', json.browser)
relativePathToBrowser = path.relative(destinationFolder,
path.resolve(dirname, json.browser)
)
debug('relative path to browser', relativePathToBrowser)
}
const proxy = proxyModule(json.name, relativePathToMain, relativePathToBrowser)
console.log(path.dirname(destPackageFilename), '->', relativePathToMain)
return fs.outputJsonAsync(destPackageFilename, proxy)
.then(() => {
if (needsRegister(json.name)) {
console.log('adding register file', registerPath)