Comparing version 1.3.0 to 2.0.0
58
bin.js
@@ -14,5 +14,13 @@ #!/usr/bin/env node | ||
var github = require('github-from-package') | ||
var ghreleases = require('ghreleases') | ||
var os = require('os') | ||
var rc = require('./rc') | ||
if (rc.path) process.chdir(rc.path) | ||
if (rc.version) { | ||
console.log(require('./package.json').version) | ||
process.exit(0) | ||
} | ||
var HOME = process.env.HOME || process.env.USERPROFILE | ||
@@ -26,3 +34,3 @@ var NODE_GYP = path.join(HOME, '.node-gyp') | ||
if (!fs.existsSync('package.json')) { | ||
log.error('No package.json found. Aborting...') | ||
log.error('setup', 'No package.json found. Aborting...') | ||
process.exit(1) | ||
@@ -38,16 +46,41 @@ } | ||
if (rc._[2] === 'install') return installPrebuild() | ||
if (rc.download) return downloadPrebuild() | ||
var targets = [].concat(rc.target) | ||
var buildLog = log.info.bind(log, 'build') | ||
var files = [] | ||
prebuild(targets.shift(), function done (err, result) { | ||
if (err) { | ||
log.error(err.message) | ||
process.exit(2) | ||
} | ||
if (targets.length) prebuild(targets.shift(), done) | ||
if (err) return onbuilderror(err) | ||
files.push(result.path) | ||
if (targets.length) return prebuild(targets.shift(), done) | ||
if (!rc.upload) return | ||
var url = github(pkg) | ||
if (err) return onbuilderror(new Error('package.json is missing a repository field')) | ||
buildLog('Uploading prebuilds to Github releases') | ||
var user = url.split('/')[3] | ||
var repo = url.split('/')[4] | ||
var auth = {user: 'x-oauth', token: rc.upload} | ||
var tag = 'v' + pkg.version | ||
ghreleases.getByTag(auth, user, repo, tag, function (err, release) { | ||
if (err) return onbuilderror(err) | ||
files = files.filter(function (file) { | ||
return !release.assets.some(function (asset) { | ||
return asset.name === path.basename(file) | ||
}) | ||
}) | ||
ghreleases.uploadAssets(auth, user, repo, 'tags/' + tag, files, function (err) { | ||
if (err) return onbuilderror(err) | ||
buildLog('Uploaded ' + files.length + ' new prebuild(s) to Github') | ||
}) | ||
}) | ||
}) | ||
function installPrebuild () { | ||
function downloadPrebuild () { | ||
var name = pkg.name + '-v' + pkg.version + '-node-v' + process.versions.modules + '-' + rc.platform + '-' + rc.arch + '.tar.gz' | ||
@@ -90,3 +123,3 @@ var url = github(pkg) + '/releases/download/v' + pkg.version + '/' + name | ||
if (err) { | ||
log.error(err.message) | ||
log.error('install', err.message) | ||
process.exit(1) | ||
@@ -172,3 +205,3 @@ } | ||
getAbi(v, function (err, abi) { | ||
if (err) return log.error(err.message) | ||
if (err) return log.error('build', err.message) | ||
var tarPath = getTarPath(abi) | ||
@@ -219,2 +252,7 @@ var next = function (err) { | ||
function onbuilderror (err) { | ||
log.error('build', err.message) | ||
process.exit(2) | ||
} | ||
function getTarPath (abi) { | ||
@@ -221,0 +259,0 @@ var name = pkg.name + '-v' + pkg.version + '-node-v' + abi + '-' + rc.platform + '-' + rc.arch + '.tar.gz' |
prebuild [options] | ||
--target, -t [version] (version to prebuild against) | ||
--arch, -a [arch] (use this architecture) | ||
--path, -p [path] (make a prebuild here) | ||
--target, -t [version] (version to prebuild against) | ||
--upload, -u [gh-token] (upload prebuilds to github) | ||
--download, -d (download prebuilds from github) |
{ | ||
"name": "prebuild", | ||
"version": "1.3.0", | ||
"version": "2.0.0", | ||
"description": "A command line tool for easily doing prebuilds for multiple version of node/iojs on a specific platform", | ||
"main": "index.js", | ||
"dependencies": { | ||
"ghreleases": "^1.0.2", | ||
"github-from-package": "0.0.0", | ||
@@ -8,0 +9,0 @@ "minimist": "^1.1.2", |
@@ -12,5 +12,8 @@ var minimist = require('minimist') | ||
arch: 'a', | ||
platform: 'p', | ||
force: 'f' | ||
path: 'p', | ||
force: 'f', | ||
version: 'v', | ||
upload: 'u', | ||
download: 'd' | ||
} | ||
})) |
@@ -17,4 +17,24 @@ # prebuild | ||
For more options run `prebuild --help` | ||
For more options run `prebuild --help`. The prebuilds created are compatible with [node-pre-gyp](https://github.com/mapbox/node-pre-gyp) | ||
## Github integration | ||
Prebuild supports uploading/downloading prebuilds to Github releases. | ||
To upload prebuilds simply add the `--upload [github-token]` option | ||
``` | ||
prebuild -t v2.4.0 -t 0.12.7 -u put-your-github-personal-token-here | ||
``` | ||
To download a prebuild for your specific platform simply use the `--download` flag | ||
``` | ||
prebuild --download | ||
``` | ||
If no suitable prebuild is found for the current platform / node version prebuild | ||
will simply fallback to run `node-gyp rebuild`. | ||
The downloaded prebuilds will be cached in your npm cache meaning you'll only have to download them once. | ||
## ABI | ||
@@ -26,6 +46,6 @@ | ||
``` | ||
prebuild -t 0.10.26 -t 0.12.7 -t 1.8.1 -t 1.0.1 -t 2.4.0 | ||
prebuild -t 0.10.26 -t 0.12.7 -t 1.0.1 -t 1.8.1 -t 2.4.0 | ||
``` | ||
Optionally you can add a rc file to `~/.prebuildrc` with the following content | ||
Optionally to always build for the above versions you can add a rc file to `~/.prebuildrc` with the following content | ||
@@ -35,11 +55,11 @@ ``` ini | ||
target[] = 0.12.7 | ||
target[] = 1.0.1 | ||
target[] = 1.8.1 | ||
target[] = 1.0.1 | ||
target[] = 2.4.0 | ||
``` | ||
To always build for the above versions | ||
## License | ||
MIT |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11559
231
63
11
+ Addedghreleases@^1.0.2
+ Addedafter@0.8.2(transitive)
+ Addedbl@3.0.1(transitive)
+ Addedbuffer-from@0.1.2(transitive)
+ Addedduplexer2@0.0.2(transitive)
+ Addedghreleases@1.0.7(transitive)
+ Addedghrepos@2.1.0(transitive)
+ Addedghutils@3.2.6(transitive)
+ Addedhyperquest@2.1.3(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedjsonist@2.1.2(transitive)
+ Addedreadable-stream@1.0.341.1.143.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsimple-mime@0.1.0(transitive)
+ Addedstring_decoder@0.10.311.3.0(transitive)
+ Addedthrough2@0.6.5(transitive)
+ Addedurl-template@2.0.8(transitive)