Comparing version 2.7.2 to 2.8.0
54
bin.js
@@ -39,2 +39,15 @@ #!/usr/bin/env node | ||
if (rc.install) { | ||
if (!(typeof pkg._from === 'string')) { | ||
// From Git directly | ||
rc.compile = true | ||
} else if (pkg._from.length > 4 && pkg._from.substr(0, 4) === 'git+') { | ||
// From npm install git+ | ||
rc.compile = true | ||
} else { | ||
// From npm repository | ||
rc.download = rc.install | ||
} | ||
} | ||
var buildLog = log.info.bind(log, 'build') | ||
@@ -58,2 +71,7 @@ var opts = {pkg: pkg, rc: rc, log: log, buildLog: buildLog} | ||
}) | ||
} else if (rc['upload-all']) { | ||
fs.readdir('prebuilds', function (err, pbFiles) { | ||
if (err) return onbuilderror(err) | ||
uploadFiles(pbFiles.map(function (file) { return 'prebuilds/' + file })) | ||
}) | ||
} else { | ||
@@ -70,21 +88,25 @@ var files = [] | ||
if (!rc.upload) return | ||
buildLog('Uploading ' + files.length + ' prebuilds(s) to Github releases') | ||
upload({pkg: pkg, rc: rc, files: files}, function (err, result) { | ||
if (err) return onbuilderror(err) | ||
buildLog('Found ' + result.old.length + ' prebuild(s) on Github') | ||
if (result.old.length) { | ||
result.old.forEach(function (build) { | ||
buildLog('-> ' + build) | ||
}) | ||
} | ||
buildLog('Uploaded ' + result.new.length + ' new prebuild(s) to Github') | ||
if (result.new.length) { | ||
result.new.forEach(function (build) { | ||
buildLog('-> ' + build) | ||
}) | ||
} | ||
}) | ||
uploadFiles(files) | ||
}) | ||
} | ||
function uploadFiles (files) { | ||
buildLog('Uploading ' + files.length + ' prebuilds(s) to Github releases') | ||
upload({pkg: pkg, rc: rc, files: files}, function (err, result) { | ||
if (err) return onbuilderror(err) | ||
buildLog('Found ' + result.old.length + ' prebuild(s) on Github') | ||
if (result.old.length) { | ||
result.old.forEach(function (build) { | ||
buildLog('-> ' + build) | ||
}) | ||
} | ||
buildLog('Uploaded ' + result.new.length + ' new prebuild(s) to Github') | ||
if (result.new.length) { | ||
result.new.forEach(function (build) { | ||
buildLog('-> ' + build) | ||
}) | ||
} | ||
}) | ||
} | ||
function onbuilderror (err) { | ||
@@ -91,0 +113,0 @@ if (!err) return |
@@ -6,4 +6,6 @@ prebuild [options] | ||
--all (prebuild for all known abi versions) | ||
--install (download when using npm, compile otherwise) | ||
--download -d [url] (download prebuilds, no url means github) | ||
--upload -u [gh-token] (upload prebuilds to github) | ||
--download -d [url] (download prebuilds, no url means github) | ||
--upload-all -u [gh-token] (upload all files from ./prebuilds folder to github) | ||
--preinstall -i script (run this script before prebuilding) | ||
@@ -10,0 +12,0 @@ --compile -c (compile your project using node-gyp) |
{ | ||
"name": "prebuild", | ||
"version": "2.7.2", | ||
"version": "2.8.0", | ||
"description": "A command line tool for easily doing prebuilds for multiple version of node/iojs on a specific platform", | ||
@@ -5,0 +5,0 @@ "scripts": { |
12
rc.js
@@ -28,3 +28,3 @@ var minimist = require('minimist') | ||
var config = module.exports = require('rc')('prebuild', { | ||
var rc = module.exports = require('rc')('prebuild', { | ||
target: process.version, | ||
@@ -55,9 +55,13 @@ arch: process.arch, | ||
if (config.all === true) { | ||
delete config.target | ||
config.target = targets | ||
if (rc.all === true) { | ||
delete rc.target | ||
rc.target = targets | ||
} | ||
if (rc['upload-all']) { | ||
rc.upload = rc['upload-all'] | ||
} | ||
if (!module.parent) { | ||
console.log(JSON.stringify(module.exports, null, 2)) | ||
} |
@@ -14,5 +14,5 @@ # prebuild | ||
* Builds native modules for any version of node/iojs, without having to switch between different versions of node/iojs to do so. This works by only downloading the correct headers and telling `node-gyp` to use those instead of the ones installed on your system. | ||
* Support for uploading (`--upload`) prebuilds to GitHub. | ||
* Support for downloading (`--download`) prebuilds from GitHub. You can also download from a host of your choice and you can customize the url format as you see fit. | ||
* Downloaded binaries will be cached in `~/.npm/_prebuilds/` so you only need to download them once. | ||
* Installs (`--install`) prebuilt binaries from GitHub by default or from a host of your choice. The url format can be customized as you see fit. | ||
* Upload (`--upload`) prebuilt binaries to GitHub. | ||
* Installed binaries are cached in `~/.npm/_prebuilds/` so you only need to download them once. | ||
* Support for stripping (`--strip`) debug information. | ||
@@ -31,35 +31,17 @@ | ||
## Uploading | ||
## Installing | ||
`prebuild` supports uploading prebuilds to GitHub releases. If the release doesn't exist, it will be created for you. To upload prebuilds simply add the `--upload <github-token>` option: | ||
`prebuild` supports installing prebuilt binaries from GitHub by default. To install for your platform, use the `--install` flag. | ||
``` | ||
$ prebuild -t v2.4.0 -t 0.12.7 -u <github-token> | ||
$ prebuild --install | ||
``` | ||
If you don't want to use the token on cli you can also stick that in e.g. `~/.prebuildrc`: | ||
If no suitable binary can be found, `prebuild` will fallback to `node-gyp rebuild`. Native modules that have a javascript fallback can use `--no-compile` to prevent this. | ||
```json | ||
{ | ||
"upload": "<github-token>" | ||
} | ||
``` | ||
See [this page](https://github.com/settings/tokens) for more information on how to create GitHub tokens. | ||
## Downloading | ||
`prebuild` supports downloading prebuilds from GitHub by default. To download a prebuild for your specific platform simply use the `--download` flag. | ||
``` | ||
$ prebuild --download | ||
``` | ||
If no suitable binary is found for the current platform / node version, `prebuild` will fallback to `node-gyp rebuild`. Native modules that have a javascript fallback can use `--no-compile` to prevent this. | ||
Once a binary has been downloaded `prebuild` will `require()` the module and if that fails it will also fallback to building it. | ||
The downloaded binaries will be cached in your npm cache meaning you'll only have to download them once. | ||
Installed binaries are cached in your npm cache meaning you'll only have to download them once. | ||
Add `prebuild --download` to your `package.json` so the binaries will be downloaded when the module is installed | ||
Add `prebuild --install` to your `package.json` so the binaries will be installed when the module is installed | ||
@@ -70,6 +52,6 @@ ```json | ||
"scripts": { | ||
"install": "prebuild --download" | ||
"install": "prebuild --install" | ||
}, | ||
"dependencies": { | ||
"prebuild": "^2.3.0" | ||
"prebuild": "^2.7.2" | ||
} | ||
@@ -79,8 +61,10 @@ } | ||
If you are hosting your binaries elsewhere you can provide a host to the `--download` flag. The host string can also be a template for constructing more intrinsic urls. Download from `example.com` with a custom format for the binary name: | ||
If you are hosting your binaries elsewhere you can provide a host to the `--install` flag. The host string can also be a template for constructing more intrinsic urls. Install from `example.com` with a custom format for the binary name: | ||
``` | ||
$ prebuild --download https://foo.com/{name}-{version}-{abi}-{platform}-{arch}.tar.gz | ||
$ prebuild --install https://example.com/{name}-{version}-{abi}-{platform}-{arch}.tar.gz | ||
``` | ||
`--install` will download binaries when installing from npm and compile in other cases. If you want `prebuild` to always download binaries you can use `--download` instead of `--install`. Either way, if downloading fails for any reason, it will fallback to compiling the code. | ||
There's also support for `node-pre-gyp` style by utilizing the `binary` property in `package.json`. | ||
@@ -131,2 +115,24 @@ | ||
## Uploading | ||
`prebuild` supports uploading prebuilds to GitHub releases. If the release doesn't exist, it will be created for you. To upload prebuilds simply add the `--upload <github-token>` option: | ||
``` | ||
$ prebuild -t v2.4.0 -t 0.12.7 -u <github-token> | ||
``` | ||
If you don't want to use the token on cli you can also stick that in e.g. `~/.prebuildrc`: | ||
```json | ||
{ | ||
"upload": "<github-token>" | ||
} | ||
``` | ||
Note that `--upload` will only upload the targets that was built and stored in `./prebuilds`, so `prebuild --upload <token> -t 2.4.0` will only upload the binary for the `2.4.0` target. | ||
You can use `prebuild --upload-all` to upload all files from the `./prebuilds` folder. | ||
See [this page](https://github.com/settings/tokens) for more information on how to create GitHub tokens. | ||
## Help | ||
@@ -141,4 +147,6 @@ | ||
--all (prebuild for all known abi versions) | ||
--install (download when using npm, compile otherwise) | ||
--download -d [url] (download prebuilds, no url means github) | ||
--upload -u [gh-token] (upload prebuilds to github) | ||
--download -d [url] (download prebuilds, no url means github) | ||
--upload-all -u [gh-token] (upload all files from ./prebuilds folder to github) | ||
--preinstall -i script (run this script before prebuilding) | ||
@@ -145,0 +153,0 @@ --compile -c (compile your project using node-gyp) |
@@ -62,2 +62,10 @@ var test = require('tape') | ||
test('using --upload-all will set token for --upload', function (t) { | ||
var args = ['--upload-all t00k3n'] | ||
runRc(t, args.join(' '), {}, function (rc) { | ||
t.equal(rc.upload, 't00k3n', 'upload should have the same token set') | ||
t.end() | ||
}) | ||
}) | ||
test('npm args are passed on from npm environment into rc', function (t) { | ||
@@ -64,0 +72,0 @@ var env = { |
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
66029
1719
158