Socket
Socket
Sign inDemoInstall

unleash

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unleash - npm Package Compare versions

Comparing version 1.6.1 to 2.0.0-beta.2

58

CHANGELOG.md

@@ -0,1 +1,59 @@

<a name="2.0.0-beta.2"></a>
### 2.0.0-beta.2 (2017-10-26)
#### Bug Fixes
* bad merge ([d5db9698](https://github.com/netflix/unleash/commit/d5db9698))
* pass cli args ([0a44262f](https://github.com/netflix/unleash/commit/0a44262f))
* **dry:** sep push & pub ([fca5fc64](https://github.com/netflix/unleash/commit/fca5fc64))
* **dryrun:**
* don't commit or tag ([1c47b7ef](https://github.com/netflix/unleash/commit/1c47b7ef))
* don't commit or tag ([f4a6b62b](https://github.com/netflix/unleash/commit/f4a6b62b))
#### Features
* revert ([51b1e857](https://github.com/netflix/unleash/commit/51b1e857))
* revert ([c0190f98](https://github.com/netflix/unleash/commit/c0190f98))
* revert ([3252915a](https://github.com/netflix/unleash/commit/3252915a))
* revert ([9021340d](https://github.com/netflix/unleash/commit/9021340d))
* revert ([a6232987](https://github.com/netflix/unleash/commit/a6232987))
<a name="2.0.0-beta.1"></a>
### 2.0.0-beta.1 (2017-10-26)
#### Bug Fixes
* pass cli args ([0a44262f](https://github.com/netflix/unleash/commit/0a44262f))
* **dry:** sep push & pub ([fca5fc64](https://github.com/netflix/unleash/commit/fca5fc64))
* **dryrun:** don't commit or tag ([1c47b7ef](https://github.com/netflix/unleash/commit/1c47b7ef))
#### Features
* revert ([c0190f98](https://github.com/netflix/unleash/commit/c0190f98))
* revert ([3252915a](https://github.com/netflix/unleash/commit/3252915a))
* revert ([9021340d](https://github.com/netflix/unleash/commit/9021340d))
* revert ([a6232987](https://github.com/netflix/unleash/commit/a6232987))
<a name="2.0.0-beta.1"></a>
### 2.0.0-beta.1 (2017-10-26)
#### Bug Fixes
* pass cli args ([0a44262f](https://github.com/netflix/unleash/commit/0a44262f))
* **dry:** sep push & pub ([fca5fc64](https://github.com/netflix/unleash/commit/fca5fc64))
* **dryrun:** don't commit or tag ([1c47b7ef](https://github.com/netflix/unleash/commit/1c47b7ef))
#### Features
* revert ([a6232987](https://github.com/netflix/unleash/commit/a6232987))
<a name="1.6.1"></a>

@@ -2,0 +60,0 @@ ### 1.6.1 (2017-07-05)

213

index.js

@@ -9,2 +9,3 @@ #!/usr/bin/env node

const
ChildProcess = require('child_process'),
Undertaker = require('undertaker'),

@@ -14,2 +15,3 @@ colors = require('chalk'),

git = require('gulp-git'),
merge = require('lodash.merge'),
values = require('object-values'),

@@ -26,3 +28,4 @@ vinylFS = require('vinyl-fs'),

versionType,
repoType
repoType,
ghp

@@ -57,9 +60,76 @@ const

const REF_SHA_CMD = 'git rev-parse --verify HEAD'
const CURRENT_SHA = ChildProcess.execSync(REF_SHA_CMD)
.toString().replace('\n','')
const PKG_STS_CMD = 'git status package.json -s'
const PKG_STATUS = ChildProcess.execSync(PKG_STS_CMD)
.toString().replace('\n','').trim()
const CL_STS_CMD = 'git status CHANGELOG.md -s'
const CL_STATUS = ChildProcess.execSync(CL_STS_CMD)
.toString().replace('\n','').trim()
const unleash = shortVersionFlags.reduce(function (y, shortFlag) {
return y.option(shortFlag, {
alias: VersionFlagMap[shortFlag],
describe: 'Alias for --type=' + VersionFlagMap[shortFlag],
type: 'boolean'
})
}, require('yargs'))
.option('type', {
describe: 'The SemVer version type such as "patch"',
type: 'string'
})
.option('ls', {
alias: 'l',
describe: 'Prints the files and directories that will and won\'t be published',
type: 'boolean'
})
.option('repo-type', {
alias: 'r',
describe: 'The remote repository type such as "stash"',
default: 'github',
type: 'string'
})
.option('publish', {
alias: 'pb',
describe: 'Sets whether or not the package is published to NPM',
default: true,
type: 'boolean'
})
.option('push', {
alias: 'ps',
describe: 'Sets whether or not the package is pushed to a git remote',
default: true,
type: 'boolean'
})
.option('ghpages-deploy', {
alias: 'gh',
describe: 'Deploy gh-pages',
type: 'boolean'
})
.option('ghpages-path', {
alias: 'ghp',
describe: 'The glob path to deploy to gh-pages',
default: './docs/**/*',
type: 'string'
})
.alias(DRY_RUN_SHORT_FLAG, DRY_RUN_LONG_FLAG)
.alias('list-publishables', 'ls')
.help('h').alias('h', 'help')
.argv
unleash.CURRENT_SHA = CURRENT_SHA
unleash.PKG_STATUS = PKG_STATUS
unleash.CL_STATUS = CL_STATUS
taskManager.task(CHANGELOG_WRITE, function (done) {
const nextVersion = Deploy.getNextVersion(versionType)
log('Utilizing next version for changelog: ', colors.magenta(nextVersion))
if (isDryRun === true) {
log(
'* Creating a changelog entry for version ' + nextVersion + ' with links to the commits on ' + repoType
)
return done()
} else {
log('Utilizing next version for changelog: ', colors.magenta(nextVersion))
return writeChangelog({

@@ -76,5 +146,8 @@ version : nextVersion,

taskManager.task(CHANGELOG_COMMIT, function () {
taskManager.task(CHANGELOG_COMMIT, function (done) {
const docsCommit = 'docs(CHANGELOG): Update changelog'
if (isDryRun) {
return true
log('* Adding commit "' + docsCommit + '"')
return done()
} else {

@@ -84,13 +157,13 @@ // TODO - allow configuration of this src?

.pipe(git.add())
.pipe(git.commit('docs(CHANGELOG): Update changelog'))
.pipe(git.commit(docsCommit))
}
})
taskManager.task(GH_PAGES_DEPLOY, function (options) {
log('Deploying to gh-pages from ' + options.path)
taskManager.task(GH_PAGES_DEPLOY, function (done) {
if (isDryRun) {
return true
log('* Pushing a gh-pages branch from the contents of "' + ghp + '"')
return done ? done() : true
} else {
return vinylFS.src([ options.path ])
log('Deploying to gh-pages from ' + ghp)
return vinylFS.src([ ghp ])
.pipe(ghPages())

@@ -100,2 +173,12 @@ }

function dryRunStartGh (done) {
log('Utilizing ' + colors.magenta('dry run mode') + '. This is a dry run of the following actions:')
return done()
}
taskManager.task(join(GH_PAGES_DEPLOY, DRY_RUN), taskManager.series([
dryRunStartGh,
GH_PAGES_DEPLOY
]))
// bump:major, bump:minor, bump:patch

@@ -108,3 +191,3 @@ ; versionTypes.forEach(function (bumpType) {

function noTrial () {
return deployWithBump({ dryRun : false })
return deployWithBump(merge({ dryRun : false }, unleash))
}

@@ -120,6 +203,15 @@

function dryRun () {
return deployWithBump({ dryRun: true })
return deployWithBump(merge({ dryRun : true }, unleash))
}
function dryRunStart (done) {
const nextVersion = Deploy.getNextVersion(versionType)
log('Utilizing ' + colors.magenta('dry run mode') + '. This is a dry run of the following actions:')
log('* Incrementing to the next "' + bumpType + '" semantic version, "' + nextVersion + '"')
return done()
}
return taskManager.task(join(bumpTaskName, DRY_RUN), taskManager.series([
dryRunStart,
CHANGELOG_WRITE,

@@ -134,40 +226,2 @@ CHANGELOG_COMMIT,

const unleash = shortVersionFlags.reduce(function (y, shortFlag) {
return y.option(shortFlag, {
alias: VersionFlagMap[shortFlag],
describe: 'Alias for --type=' + VersionFlagMap[shortFlag],
type: 'boolean'
})
}, require('yargs'))
.option('type', {
describe: 'The SemVer version type such as "patch"',
type: 'string'
})
.option('ls', {
alias: 'l',
describe: 'Prints the files and directories that will and won\'t be published',
type: 'boolean'
})
.option('repo-type', {
alias: 'r',
describe: 'The remote repository type such as "stash"',
default: 'github',
type: 'string'
})
.option('ghpages-deploy', {
alias: 'gh',
describe: 'Deploy gh-pages',
type: 'boolean'
})
.option('ghpages-path', {
alias: 'ghp',
describe: 'The glob path to deploy to gh-pages',
default: './docs/**/*',
type: 'string'
})
.alias(DRY_RUN_SHORT_FLAG, DRY_RUN_LONG_FLAG)
.alias('list-publishables', 'ls')
.help('h').alias('h', 'help')
.argv
// Kray Kray McFadden ish to fake mutually exclusive arguments

@@ -185,24 +239,41 @@ // See https://github.com/bcoe/yargs/issues/275

if (unleash.dryRun) {
isDryRun = true
}
const command = process.argv.slice(1).map(function (a) {
return a.split('/').reverse()[0]
}).join(' ')
const wut = 'What did you want me to dry run?'
const noType = 'Need a semantic version type homie...'
const fakeBumpType = 'semantic-version-type-should-be-here'
function logFlagCommand () {
return log.error('Run "unleash --help" to discover available flags')
}
function logCorrectedCommand (flag) {
return log.error(command + ' --' + colors.bgGreen(colors.white(flag)))
}
if (unleash.type) {
if (unleash.ls) {
if (unleash.ls)
ls()
}
if (unleash.gh) {
ghp = unleash.ghp
const task = taskManager.task(GH_PAGES_DEPLOY)
task({ path : unleash.ghp })
task()
}
let taskName = bumperize(unleash.type)
versionType = unleash.type
repoType = unleash.repoType
if (unleash.dryRun) {
isDryRun = true
if (unleash.dryRun)
taskName = join(taskName, DRY_RUN)
log('Utilizing dry run mode')
}
const task = taskManager.task(taskName)
task()
task(unleash)
} else if (unleash.ls) {

@@ -212,6 +283,24 @@ const task = taskManager.task('ls')

} else if (unleash.gh) {
const task = taskManager.task(GH_PAGES_DEPLOY)
task({ path : unleash.ghp })
ghp = unleash.ghp
const task = taskManager.task(isDryRun ? join(GH_PAGES_DEPLOY, DRY_RUN) : GH_PAGES_DEPLOY)
task()
} else if (!unleash.publish) {
const errorMessage = colors.bgRed(colors.white(isDryRun ? wut : noType))
log.error(errorMessage)
logCorrectedCommand(fakeBumpType)
logFlagCommand()
} else if (!unleash.push) {
const errorMessage = colors.bgRed(colors.white(isDryRun ? wut : noType))
log.error(errorMessage)
logCorrectedCommand(fakeBumpType)
logFlagCommand()
} else {
throw new Error('Need a task homie')
const noTask = 'Need a task homie...'
const errorMessage = colors.bgRed(colors.white(isDryRun ? wut : noTask))
log.error(errorMessage)
logCorrectedCommand('flag-name-should-be-here')
logFlagCommand()
}

@@ -218,0 +307,0 @@ }

@@ -7,7 +7,6 @@ const

const currentVersion = paqman.packageJSON.version
function getNextVersion (type) {
const SemVer = require('semver')
const currentVersion = paqman.packageJSON.version
log('Getting next version of type: ', colors.magenta(type))
log('Incrementing from version: ', colors.magenta(currentVersion))
return SemVer.inc(currentVersion, type)

@@ -46,6 +45,6 @@ }

bumpType = options.bumpType,
dryRun = options.dryRun
dryRun = options.dryRun,
noPublish = !options.publish,
noPush = !options.push
log('Utilizing bumpType', colors.magenta(options.bumpType))
function streamDone (finalOperation) {

@@ -62,4 +61,2 @@ const stream = new Stream.Transform({ objectMode: true })

log('Retrieving latest git commit...')
const

@@ -71,54 +68,118 @@ REF_HEAD_CMD = 'git rev-parse --abbrev-ref HEAD',

let fileStream = vinylFS.src([ './package.json' ])
if (!dryRun) {
let tagVersionConfig
log('Utilizing bumpType', colors.magenta(options.bumpType))
log('Retrieving latest git commit...')
log('Getting next version of type: ', colors.magenta(bumpType))
log('Incrementing from version: ', colors.magenta(currentVersion))
}
if (isLernaPackage()) {
const pkgName = paqman.packageJSON.name
tagVersionConfig = {
prefix : pkgName + '_v',
label : 'Tagging ' + pkgName + ' release as %t'
}
log('Tagging ' + pkgName + ' as a package in a Lerna repo')
}
const fileStream = vinylFS.src([ './package.json' ])
fileStream = fileStream
.pipe(bump({ type: bumpType }))
.pipe(vinylFS.dest('./'))
.pipe(git.commit('chore(release): release ' + NEXT_VERSION))
.pipe(filter('package.json'))
.pipe(tagVersion(tagVersionConfig))
}
const
args = ' --tags',
remote = 'origin',
releaseCommitMsg = 'chore(release): release ' + NEXT_VERSION
return fileStream.pipe(streamDone(function () {
const
args = ' --tags',
remote = 'origin'
const wouldPublish = !noPublish
const wouldPublishButNotPush = noPush && wouldPublish
const wouldPush = !noPush
let tagVersionConfig, pkgName
const isLPkg = isLernaPackage()
if (dryRun) {
return log('This is a dry run. We\'d be running git push ' +
remote + ' ' + CURRENT_BRANCH + args)
if (isLPkg) {
pkgName = paqman.packageJSON.name
tagVersionConfig = {
prefix : pkgName + '_v',
label : 'Tagging ' + pkgName + ' release as %t'
}
}
const tagPrefix = tagVersionConfig ? tagVersionConfig.prefix : 'v'
function publish () {
log('Loading NPM....')
const NPM = require('npm')
NPM.load(function () { // must be called first
NPM.publish(function (pubError) {
if (pubError) {
log.error('Publish failed, your changelog may get in an undefined state :(')
log.error(pubError)
throw pubError
}
})
})
}
function pushAndMaybePublish () {
return git.push(remote, CURRENT_BRANCH, { args: args }, function (error) {
if (error) {
log(colors.bgRed(colors.black('~~~ ERROR ~~~')))
log('`git push` failed, reverting your unchanged files to their')
log(`state prior to running Unleash (${options.CURRENT_SHA})`)
ChildProcess.execSync(`git tag -d ${tagPrefix + NEXT_VERSION}`)
if (options.PKG_STATUS === '')
ChildProcess.execSync(`git checkout ${options.CURRENT_SHA} package.json`)
if (options.CL_STATUS === '')
ChildProcess.execSync(`git checkout ${options.CURRENT_SHA} CHANGELOG.md`)
ChildProcess.execSync(`git reset --mixed ${options.CURRENT_SHA}`)
throw error
}
log('Loading NPM....')
if (!noPublish)
publish()
})
}
const NPM = require('npm')
NPM.load(function () { // must be called first
NPM.publish(function (pubError) {
if (pubError) {
log.error('Publish failed, your changelog may get in an undefined state :(')
log.error(pubError)
throw pubError
}
})
})
})
}))
function warnLocalOnly () {
if (!options.publish && !options.push) {
const command = process.argv.slice(1).map(function (a) {
return a.split('/').reverse()[0]
}).join(' ')
log(colors.bgYellow(colors.black('~~~ WARNING ~~~')))
log('You\'ve turned both publishing & pushing off. Your ' +
'changelog & package files will be updated + committed locally but ' +
'nothing outside your machine will change.')
log(command
.replace('publish',
colors.bgYellow('publish'))
.replace('push',
colors.bgYellow('push'))
)
}
}
if (isLPkg)
log('Tagging ' + pkgName + ' as a package in a Lerna repo')
if (!dryRun) {
warnLocalOnly()
return fileStream
.pipe(bump({ type: bumpType }))
.pipe(vinylFS.dest('./'))
.pipe(git.commit(releaseCommitMsg))
.pipe(filter('package.json'))
.pipe(tagVersion(tagVersionConfig))
.pipe(streamDone(function () {
if (wouldPublishButNotPush)
publish()
else if (wouldPush)
pushAndMaybePublish()
}))
} else {
const pubLog = wouldPublish ? '* Publishing to NPM' : ''
const pushLog = wouldPush ? '* Pushing to ' + remote + ' branch ' + CURRENT_BRANCH : ''
log('* Bumping to a ' + bumpType + ' version with the commit "' + releaseCommitMsg + '"')
log('* Tagging the commit with "' + tagPrefix + NEXT_VERSION + '"')
pubLog && log(pubLog)
pushLog && log(pushLog)
warnLocalOnly()
return true
}
}
})
{
"name": "unleash",
"version": "1.6.1",
"version": "2.0.0-beta.2",
"description": "Unleash your code into the wild yonder",

@@ -12,3 +12,3 @@ "engines": {

"report-deps": "npm-check",
"prepublish": "npm run test",
"prepublishOnly": "echo \"prepublishOnly\" && npm run test",
"test": "npm run lint && node --harmony ./node_modules/.bin/tape tests/specs/*.js | tap-difflet",

@@ -41,3 +41,3 @@ "test:single": "tape tests/single-runner.js | tap-difflet",

"chalk": "1.1.1",
"fancy-log": "1.1.0",
"fancy-log": "1.3.0",
"fstream-npm": "1.0.7",

@@ -58,3 +58,3 @@ "gift": "0.9.0",

"nf-conventional-changelog": "1.0.0",
"npm": "2.14.8",
"npm": "5.4.2",
"npm-check": "4.1.2",

@@ -69,3 +69,3 @@ "object-values": "1.0.0",

"wrap-promise": "1.0.1",
"yargs": "^3.29.0"
"yargs": "10.0.3"
},

@@ -72,0 +72,0 @@ "devDependencies": {

@@ -16,3 +16,3 @@ ![Bad Release](https://cloud.githubusercontent.com/assets/77849/16959116/498ef28a-4d98-11e6-8d99-6fb08aa1d1c4.gif)

### Convince your manager (Why use Unleash?)
* Unleash eats it's own dogfood. Unleash is used to release itself
* Unleash eats its own dogfood. Unleash is used to release itself
* Unleash eliminates common time-wasting mistakes such as forgetting to tag your releases (or forgetting to publish your module)

@@ -19,0 +19,0 @@ * Unleash encourages use of software conventions such as the CHANGELOG by making it dead easy

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc