update dependencies and add yarn

This commit is contained in:
2017-02-19 14:46:05 +01:00
parent 97d2a8d1b7
commit b86b090c07
9 changed files with 2898 additions and 180 deletions

View File

@ -3,84 +3,76 @@ import * as paths from './npmci.paths'
let npmciInfo = new plugins.projectinfo.ProjectinfoNpm(paths.NpmciPackageRoot)
plugins.beautylog.log('npmci version: ' + npmciInfo.version)
import {build} from './npmci.build'
import {clean} from './npmci.clean'
import {command} from './npmci.command'
import {install} from './npmci.install'
import {publish} from './npmci.publish'
import {prepare} from './npmci.prepare'
import {test} from './npmci.test'
import {trigger} from './npmci.trigger'
import { build } from './npmci.build'
import { clean } from './npmci.clean'
import { command } from './npmci.command'
import { install } from './npmci.install'
import { publish } from './npmci.publish'
import { prepare } from './npmci.prepare'
import { test } from './npmci.test'
import { trigger } from './npmci.trigger'
import * as NpmciEnv from './npmci.env'
export {build} from './npmci.build'
export {install} from './npmci.install';
export {publish} from './npmci.publish';
export { build } from './npmci.build'
export { install } from './npmci.install';
export { publish } from './npmci.publish';
let smartcli = new plugins.smartcli.Smartcli()
smartcli.addVersion(npmciInfo.version)
// build
smartcli.addCommand({
commandName: 'build'
}).then((argv) => {
build(argv._[1])
.then(NpmciEnv.configStore)
})
smartcli.addCommand('build')
.then((argv) => {
build(argv._[ 1 ])
.then(NpmciEnv.configStore)
})
// clean
smartcli.addCommand({
commandName: 'clean'
}).then((argv) => {
smartcli.addCommand('clean')
.then((argv) => {
clean()
.then(NpmciEnv.configStore)
})
.then(NpmciEnv.configStore)
})
// command
smartcli.addCommand({
commandName: 'command'
}).then((argv) => {
smartcli.addCommand('command')
.then((argv) => {
command()
.then(NpmciEnv.configStore)
})
.then(NpmciEnv.configStore)
})
// install
smartcli.addCommand({
commandName: 'install'
}).then((argv) => {
install(argv._[1])
.then(NpmciEnv.configStore)
})
smartcli.addCommand('install')
.then((argv) => {
install(argv._[ 1 ])
.then(NpmciEnv.configStore)
})
// prepare
smartcli.addCommand({
commandName: 'prepare'
}).then((argv) => {
prepare(argv._[1])
.then(NpmciEnv.configStore)
})
smartcli.addCommand('prepare')
.then((argv) => {
prepare(argv._[ 1 ])
.then(NpmciEnv.configStore)
})
// publish
smartcli.addCommand({
commandName: 'publish'
}).then((argv) => {
publish(argv._[1])
.then(NpmciEnv.configStore)
})
smartcli.addCommand('publish')
.then((argv) => {
publish(argv._[ 1 ])
.then(NpmciEnv.configStore)
})
// test
smartcli.addCommand({
commandName: 'test'
}).then((argv) => {
test(argv._[1])
.then(NpmciEnv.configStore)
})
smartcli.addCommand('test')
.then((argv) => {
test(argv._[ 1 ])
.then(NpmciEnv.configStore)
})
// trigger
smartcli.addCommand({
commandName: 'trigger'
}).then((argv) => {
smartcli.addCommand('trigger')
.then((argv) => {
trigger()
})
})
smartcli.startParse()

View File

@ -3,13 +3,14 @@ import * as plugins from './npmci.plugins'
let nvmSourceString: string = ''
export let nvmAvailable: boolean = false
let checkNvm = () => {
if (plugins.shelljs.exec(`bash -c "source /usr/local/nvm/nvm.sh"`,{silent: true}).code === 0) {
nvmSourceString = `source /usr/local/nvm/nvm.sh && `
nvmAvailable = true
} else if (plugins.shelljs.exec(`bash -c "source ~/.nvm/nvm.sh"`,{silent: true}).code === 0) {
nvmSourceString = `source ~/.nvm/nvm.sh && `
nvmAvailable = true
};
let localExec: any = plugins.shelljs.exec
if (localExec(`bash -c "source /usr/local/nvm/nvm.sh"`, { silent: true }).code === 0) {
nvmSourceString = `source /usr/local/nvm/nvm.sh && `
nvmAvailable = true
} else if (localExec(`bash -c "source ~/.nvm/nvm.sh"`, { silent: true }).code === 0) {
nvmSourceString = `source ~/.nvm/nvm.sh && `
nvmAvailable = true
};
}
checkNvm()
@ -19,54 +20,54 @@ checkNvm()
* @param retryArg - The retryArg: 0 to any positive number will retry, -1 will always succeed, -2 will return undefined
*/
export let bash = (commandArg: string, retryArg: number = 2, bareArg: boolean = false): string => {
let exitCode: number
let stdOut: string
let execResult
let failOnError: boolean = true
if (retryArg === -1) {
failOnError = false
retryArg = 0
}
if (!process.env.NPMTS_TEST) { // NPMTS_TEST is used during testing
for (let i = 0; i <= retryArg; i++) {
if (!bareArg) {
execResult = plugins.shelljs.exec(
`bash -c "${nvmSourceString} ${commandArg}"`
)
} else {
execResult = plugins.shelljs.exec(commandArg)
}
exitCode = execResult.code
stdOut = execResult.stdout
let exitCode: number
let stdOut: string
let execResult
let failOnError: boolean = true
if (retryArg === -1) {
failOnError = false
retryArg = 0
}
if (!process.env.NPMTS_TEST) { // NPMTS_TEST is used during testing
for (let i = 0; i <= retryArg; i++) {
if (!bareArg) {
execResult = plugins.shelljs.exec(
`bash -c "${nvmSourceString} ${commandArg}"`
)
} else {
execResult = plugins.shelljs.exec(commandArg)
}
exitCode = execResult.code
stdOut = execResult.stdout
// determine how bash reacts to error and success
if (exitCode !== 0 && i === retryArg) { // something went wrong and retries are exhausted
if (failOnError) {
process.exit(1)
}
} else if (exitCode === 0) { // everything went fine, or no error wanted
i = retryArg + 1 // retry +1 breaks for loop, if everything works out ok retrials are not wanted
} else {
plugins.beautylog.warn('Something went wrong! Exit Code: ' + exitCode.toString())
plugins.beautylog.info('Retry ' + (i + 1).toString() + ' of ' + retryArg.toString())
}
// determine how bash reacts to error and success
if (exitCode !== 0 && i === retryArg) { // something went wrong and retries are exhausted
if (failOnError) {
process.exit(1)
}
} else {
plugins.beautylog.log('ShellExec would be: ' + commandArg)
} else if (exitCode === 0) { // everything went fine, or no error wanted
i = retryArg + 1 // retry +1 breaks for loop, if everything works out ok retrials are not wanted
} else {
plugins.beautylog.warn('Something went wrong! Exit Code: ' + exitCode.toString())
plugins.beautylog.info('Retry ' + (i + 1).toString() + ' of ' + retryArg.toString())
}
}
return stdOut
} else {
plugins.beautylog.log('ShellExec would be: ' + commandArg)
}
return stdOut
}
/**
* bashBare allows usage of bash without sourcing any files like nvm
*/
export let bashBare = (commandArg: string, retryArg: number = 2) => {
return bash(commandArg, retryArg, true)
return bash(commandArg, retryArg, true)
}
/**
* bashNoError allows executing stuff without throwing an error
*/
export let bashNoError = (commandArg: string): string => {
return bash(commandArg, -1)
return bash(commandArg, -1)
}

View File

@ -3,43 +3,43 @@ import * as configModule from './npmci.config'
import { bash, bashNoError } from './npmci.bash'
import { nvmAvailable } from './npmci.bash'
export let install = (versionArg) => {
let done = plugins.q.defer()
plugins.beautylog.log(`now installing node version ${versionArg}`)
let version: string
if (versionArg === 'stable') {
version = 'stable'
} else if (versionArg === 'lts') {
version = '6'
} else if (versionArg === 'legacy') {
version = '6'
} else {
version = versionArg
};
if (nvmAvailable) {
bash(`nvm install ${version} && nvm alias default ${version}`)
plugins.beautylog.success(`Node version ${version} successfully installed!`)
} else {
plugins.beautylog.warn('Nvm not in path so staying at installed node version!')
};
bash('node -v')
bash('npm -v')
// lets look for further config
configModule.getConfig()
.then(configArg => {
plugins.beautylog.log('Now checking for needed global npm tools...')
for (let npmTool of configArg.globalNpmTools) {
plugins.beautylog.info(`Checking for global "${npmTool}"`)
let whichOutput = bashNoError(`which ${npmTool}`)
let toolAvailable: boolean = !((/not\sfound/.test(whichOutput)) || whichOutput === '')
if (toolAvailable) {
plugins.beautylog.log(`Tool ${npmTool} is available`)
} else {
plugins.beautylog.info(`globally installing ${npmTool} from npm`)
bash(`npm install ${npmTool} -q -g`)
}
}
plugins.beautylog.success('all global npm tools specified in npmextra.json are now available!')
done.resolve()
})
return done.promise
let done = plugins.q.defer()
plugins.beautylog.log(`now installing node version ${versionArg}`)
let version: string
if (versionArg === 'stable') {
version = 'stable'
} else if (versionArg === 'lts') {
version = '6'
} else if (versionArg === 'legacy') {
version = '6'
} else {
version = versionArg
};
if (nvmAvailable) {
bash(`nvm install ${version} && nvm alias default ${version}`)
plugins.beautylog.success(`Node version ${version} successfully installed!`)
} else {
plugins.beautylog.warn('Nvm not in path so staying at installed node version!')
};
bash('node -v')
bash('npm -v')
// lets look for further config
configModule.getConfig()
.then(configArg => {
plugins.beautylog.log('Now checking for needed global npm tools...')
for (let npmTool of configArg.globalNpmTools) {
plugins.beautylog.info(`Checking for global "${npmTool}"`)
let whichOutput = bashNoError(`which ${npmTool}`)
let toolAvailable: boolean = !((/not\sfound/.test(whichOutput)) || whichOutput === '')
if (toolAvailable) {
plugins.beautylog.log(`Tool ${npmTool} is available`)
} else {
plugins.beautylog.info(`globally installing ${npmTool} from npm`)
bash(`npm install ${npmTool} -q -g`)
}
}
plugins.beautylog.success('all global npm tools specified in npmextra.json are now available!')
done.resolve()
})
return done.promise
}