Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: prebuild/prebuild-install
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 062cb4153dd9b08e39d8ae34a66052340ea226e8
Choose a base ref
...
head repository: prebuild/prebuild-install
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8250adf958fcec6fb3ddfcd7dd5ceb0e0e29e419
Choose a head ref
Loading
Showing with 1,000 additions and 484 deletions.
  1. +17 −0 .github/workflows/release.yml
  2. +29 −0 .github/workflows/test.yml
  3. +1 −0 .npmignore
  4. +0 −12 .travis.yml
  5. +116 −0 CHANGELOG.md
  6. +4 −6 CONTRIBUTING.md
  7. +83 −21 README.md
  8. +0 −40 appveyor.yml
  9. +13 −17 asset.js
  10. +24 −22 bin.js
  11. +91 −79 download.js
  12. +1 −0 error.js
  13. +3 −0 help.txt
  14. +27 −7 log.js
  15. +22 −25 package.json
  16. +12 −13 proxy.js
  17. +29 −38 rc.js
  18. +33 −32 test/asset-test.js
  19. +89 −49 test/download-test.js
  20. +5 −5 test/log-test.js
  21. +7 −7 test/proxy-test.js
  22. +111 −45 test/rc-test.js
  23. +114 −0 test/skip-test.js
  24. +92 −50 test/util-test.js
  25. +14 −0 test/util/clean-env.js
  26. +63 −16 util.js
17 changes: 17 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Release
on:
push:
tags: ['*']
permissions:
contents: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Create GitHub release
uses: docker://antonyurchenko/git-release:v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test
on: [push, pull_request]
permissions:
contents: read
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [10, 12, 14, 16]
arch: [x64]
include:
- os: windows-latest
node: 14
arch: x86
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / Node ${{ matrix.node }} ${{ matrix.arch }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use node ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
architecture: ${{ matrix.arch }}
- name: Install
run: npm install
- name: Test
run: npm test
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
npm-debug.log
test
.github
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

116 changes: 116 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Changelog

## [7.1.1] - 2022-06-07

### Changed

- Replace use of npmlog dependency with console.error ([#182](https://github.com/prebuild/prebuild-install/issues/182)) ([`4e2284c`](https://github.com/prebuild/prebuild-install/commit/4e2284c)) (Lovell Fuller).

- Ensure script output can be captured by tests ([#181](https://github.com/prebuild/prebuild-install/issues/181)) ([`d1853cb`](https://github.com/prebuild/prebuild-install/commit/d1853cb)) (Lovell Fuller).

## [7.1.0] - 2022-04-20

### Changed

- Allow setting libc to glibc on non-glibc platform ([#176](https://github.com/prebuild/prebuild-install/issues/176)) ([`f729abb`](https://github.com/prebuild/prebuild-install/commit/f729abb)) (Joona Heinikoski).

## [7.0.1] - 2022-01-28

### Changed

- Upgrade to the latest version of `detect-libc` ([#166](https://github.com/prebuild/prebuild-install/issues/166)) ([`f71c6b9`](https://github.com/prebuild/prebuild-install/commit/f71c6b9)) (Lovell Fuller).

## [7.0.0] - 2021-11-12

### Changed

- **Breaking:** bump `node-abi` so that Electron 14+ gets correct ABI ([#161](https://github.com/prebuild/prebuild-install/issues/161)) ([`477f347`](https://github.com/prebuild/prebuild-install/commit/477f347)) (csett86). Drops support of Node.js < 10.
- Bump `simple-get` ([`7468c14`](https://github.com/prebuild/prebuild-install/commit/7468c14)) (Vincent Weevers).

## [6.1.4] - 2021-08-11

### Fixed

- Move auth token to header instead of query param ([#160](https://github.com/prebuild/prebuild-install/issues/160)) ([`b3fad76`](https://github.com/prebuild/prebuild-install/commit/b3fad76)) (nicolai-nordic)
- Remove `_` prefix as it isn't allowed by npm config ([#153](https://github.com/prebuild/prebuild-install/issues/153)) ([`a964e5b`](https://github.com/prebuild/prebuild-install/commit/a964e5b)) (Tom Boothman)
- Make `rc.path` absolute ([#158](https://github.com/prebuild/prebuild-install/issues/158)) ([`57bcc06`](https://github.com/prebuild/prebuild-install/commit/57bcc06)) (George Waters).

## [6.1.3] - 2021-06-03

### Changed

- Inline no longer maintained `noop-logger` ([#155](https://github.com/prebuild/prebuild-install/issues/155)) ([`e08d75a`](https://github.com/prebuild/prebuild-install/commit/e08d75a)) (Alexandru Dima)
- Point users towards `prebuildify` in README ([#150](https://github.com/prebuild/prebuild-install/issues/150)) ([`5ee1a2f`](https://github.com/prebuild/prebuild-install/commit/5ee1a2f)) (Vincent Weevers)

## [6.1.2] - 2021-04-24

### Fixed

- Support URL-safe strings in scoped packages ([#148](https://github.com/prebuild/prebuild-install/issues/148)) ([`db36c7a`](https://github.com/prebuild/prebuild-install/commit/db36c7a)) (Marco)

## [6.1.1] - 2021-04-04

### Fixed

- Support `force` & `buildFromSource` options in yarn ([#140](https://github.com/prebuild/prebuild-install/issues/140)) ([`8cb1ced`](https://github.com/prebuild/prebuild-install/commit/8cb1ced)) (João Moreno)
- Bump `node-abi` to prevent dedupe (closes [#135](https://github.com/prebuild/prebuild-install/issues/135)) ([`2950fb2`](https://github.com/prebuild/prebuild-install/commit/2950fb2)) (Vincent Weevers)

## [6.1.0] - 2021-04-03

### Added

- Restore local prebuilds feature ([#137](https://github.com/prebuild/prebuild-install/issues/137)) ([`dc4e5ea`](https://github.com/prebuild/prebuild-install/commit/dc4e5ea)) (Wes Roberts). Previously removed in [#81](https://github.com/prebuild/prebuild-install/issues/81) / [`a069253`](https://github.com/prebuild/prebuild-install/commit/a06925378d38ca821bfa93aa4c1fdedc253b2420).

## [6.0.1] - 2021-02-14

### Fixed

- Fixes empty `--tag-prefix` ([#143](https://github.com/prebuild/prebuild-install/issues/143)) ([**@mathiask88**](https://github.com/mathiask88))

## [6.0.0] - 2020-10-23

### Changed

- **Breaking:** don't skip downloads in standalone mode ([`b6f3b36`](https://github.com/prebuild/prebuild-install/commit/b6f3b36)) ([**@vweevers**](https://github.com/vweevers))

### Added

- Document cross platform options ([`e5c9a5a`](https://github.com/prebuild/prebuild-install/commit/e5c9a5a)) ([**@fishbone1**](https://github.com/fishbone1))

### Removed

- **Breaking:** remove `--compile` and `--prebuild` options ([`94f2492`](https://github.com/prebuild/prebuild-install/commit/94f2492)) ([**@vweevers**](https://github.com/vweevers))

### Fixed

- Support npm 7 ([`8acccac`](https://github.com/prebuild/prebuild-install/commit/8acccac), [`08eaf6d`](https://github.com/prebuild/prebuild-install/commit/08eaf6d), [`22175b8`](https://github.com/prebuild/prebuild-install/commit/22175b8)) ([**@vweevers**](https://github.com/vweevers))

## [5.3.6] - 2020-10-20

### Changed

- Replace `mkdirp` dependency with `mkdirp-classic` ([**@ralphtheninja**](https://github.com/ralphtheninja))

[7.1.1]: https://github.com/prebuild/prebuild-install/releases/tag/v7.1.1

[7.1.0]: https://github.com/prebuild/prebuild-install/releases/tag/v7.1.0

[7.0.1]: https://github.com/prebuild/prebuild-install/releases/tag/v7.0.1

[7.0.0]: https://github.com/prebuild/prebuild-install/releases/tag/v7.0.0

[6.1.4]: https://github.com/prebuild/prebuild-install/releases/tag/v6.1.4

[6.1.3]: https://github.com/prebuild/prebuild-install/releases/tag/v6.1.3

[6.1.2]: https://github.com/prebuild/prebuild-install/releases/tag/v6.1.2

[6.1.1]: https://github.com/prebuild/prebuild-install/releases/tag/v6.1.1

[6.1.0]: https://github.com/prebuild/prebuild-install/releases/tag/v6.1.0

[6.0.1]: https://github.com/prebuild/prebuild-install/releases/tag/v6.0.1

[6.0.0]: https://github.com/prebuild/prebuild-install/releases/tag/v6.0.0

[5.3.6]: https://github.com/prebuild/prebuild-install/releases/tag/v5.3.6
10 changes: 4 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Contributing to prebuild

* no commits direct to master
* all commits as pull requests (one or several per PR)
* each commit solves one identifiable problem
* never merge one's own PRs, another contributor does this


- no commits direct to master
- all commits as pull requests (one or several per PR)
- each commit solves one identifiable problem
- never merge one's own PRs, another contributor does this
104 changes: 83 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
# prebuild-install

> A command line tool to easily install prebuilt binaries for multiple version of node/iojs on a specific platform.
> **A command line tool to easily install prebuilt binaries for multiple versions of Node.js & Electron on a specific platform.**
> By default it downloads prebuilt binaries from a GitHub release.
[![npm](https://img.shields.io/npm/v/prebuild-install.svg)](https://www.npmjs.com/package/prebuild-install)
![Node version](https://img.shields.io/node/v/prebuild-install.svg)
[![Build Status](https://travis-ci.org/prebuild/prebuild-install.svg?branch=master)](https://travis-ci.org/prebuild/prebuild-install)
[![Build status](https://ci.appveyor.com/api/projects/status/6v6hxxwgjrr99pc8/branch/master?svg=true)](https://ci.appveyor.com/project/mathiask88/prebuild-install)
[![david](https://david-dm.org/prebuild/prebuild-install.svg)](https://david-dm.org/prebuild/prebuild-install)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
[![Test](https://img.shields.io/github/workflow/status/prebuild/prebuild-install/Test?label=test)](https://github.com/prebuild/prebuild-install/actions/workflows/test.yml)
[![Standard](https://img.shields.io/badge/standard-informational?logo=javascript\&logoColor=fff)](https://standardjs.com)
[![Common Changelog](https://common-changelog.org/badge.svg)](https://common-changelog.org)

`prebuild-install` supports installing prebuilt binaries from GitHub by default.
## Note

**Instead of [`prebuild`](https://github.com/prebuild/prebuild) paired with [`prebuild-install`](https://github.com/prebuild/prebuild-install), we recommend [`prebuildify`](https://github.com/prebuild/prebuildify) paired with [`node-gyp-build`](https://github.com/prebuild/node-gyp-build).**

With `prebuildify`, all prebuilt binaries are shipped inside the package that is published to npm, which means there's no need for a separate download step like you find in `prebuild`. The irony of this approach is that it is faster to download all prebuilt binaries for every platform when they are bundled than it is to download a single prebuilt binary as an install script.

Upsides:

1. No extra download step, making it more reliable and faster to install.
2. Supports changing runtime versions locally and using the same install between Node.js and Electron. Reinstalling or rebuilding is not necessary, as all prebuilt binaries are in the npm tarball and the correct one is simply picked on runtime.
3. The `node-gyp-build` runtime dependency is dependency-free and will remain so out of principle, because introducing dependencies would negate the shorter install time.
4. Prebuilt binaries work even if npm install scripts are disabled.
5. The npm package checksum covers prebuilt binaries too.

Downsides:

1. The installed npm package is larger on disk. Using [Node-API](https://nodejs.org/api/n-api.html) alleviates this because Node-API binaries are runtime-agnostic and forward-compatible.
2. Publishing is mildly more complicated, because `npm publish` must be done after compiling and fetching prebuilt binaries (typically in CI).

## Usage

Change your package.json install script to:
Use [`prebuild`](https://github.com/prebuild/prebuild) to create and upload prebuilt binaries. Then change your package.json install script to:

```json
{
"scripts": {
@@ -22,29 +40,45 @@ Change your package.json install script to:
}
```

### Requirements
When a consumer then installs your package with npm thus triggering the above install script, `prebuild-install` will download a suitable prebuilt binary, or exit with a non-zero exit code if there is none, which triggers `node-gyp rebuild` in order to build from source.

You need to provide prebuilds made by [`prebuild`](https://github.com/prebuild/prebuild).
Options (see below) can be passed to `prebuild-install` like so:

```json
{
"scripts": {
"install": "prebuild-install -r napi || node-gyp rebuild"
}
}
```

### Help

```
prebuild-install [options]
--download -d [url] (download prebuilds, no url means github)
--target -t version (version to install for)
--runtime -r runtime (Node runtime [node or electron] to build or install for, default is node)
--runtime -r runtime (Node runtime [node, napi or electron] to build or install for, default is node)
--path -p path (make a prebuild-install here)
--token -T gh-token (github token for private repos)
--arch arch (target CPU architecture, see Node OS module docs, default is current arch)
--platform platform (target platform, see Node OS module docs, default is current platform)
--tag-prefix <prefix> (github tag prefix, default is "v")
--build-from-source (skip prebuild download)
--verbose (log verbosely)
--libc (use provided libc rather than system default)
--debug (set Debug or Release configuration)
--version (print prebuild-install version and exit)
```
```

When `prebuild-install` is run via an `npm` script, options `--build-from-source`, `--debug`, `--download`, `--target`, `--runtime`, `--arch` `--platform` and `--libc` may be passed through via arguments given to the `npm` command.

Alternatively you can set environment variables `npm_config_build_from_source=true`, `npm_config_platform`, `npm_config_arch`, `npm_config_target` `npm_config_runtime` and `npm_config_libc`.

### Libc

When `prebuild-install` is run via an `npm` script, options
`--build-from-source`, `--debug` and `--download`, may be passed through via
arguments given to the `npm` command.
On non-glibc Linux platforms, the Libc name is appended to platform name. For example, musl-based environments are called `linuxmusl`. If `--libc=glibc` is passed as option, glibc is discarded and platform is called as just `linux`. This can be used for example to build cross-platform packages on Alpine Linux.

### Private Repositories

@@ -68,34 +102,62 @@ Note that using a GitHub token uses the API to resolve the correct release meani

To create a token:

* Go to [this page](https://github.com/settings/tokens)
* Click the `Generate new token` button
* Give the token a name and click the `Generate token` button, see below
- Go to [this page](https://github.com/settings/tokens)
- Click the `Generate new token` button
- Give the token a name and click the `Generate token` button, see below

![prebuild-token](https://cloud.githubusercontent.com/assets/13285808/20844584/d0b85268-b8c0-11e6-8b08-2b19522165a9.png)

The default scopes should be fine.

### Custom binaries

The end user can override binary download location through environment variables in their .npmrc file.
The variable needs to meet the mask `% your package name %_binary_host` or `% your package name %_binary_host_mirror`. For example:

```
leveldown_binary_host=http://overriden-host.com/overriden-path
```

Note that the package version subpath and file name will still be appended.
So if you are installing `leveldown@1.2.3` the resulting url will be:

```
http://overriden-host.com/overriden-path/v1.2.3/leveldown-v1.2.3-node-v57-win32-x64.tar.gz
```

#### Local prebuilds

If you want to use prebuilds from your local filesystem, you can use the `% your package name %_local_prebuilds` .npmrc variable to set a path to the folder containing prebuilds. For example:

```
leveldown_local_prebuilds=/path/to/prebuilds
```

This option will look directly in that folder for bundles created with `prebuild`, for example:

```
/path/to/prebuilds/leveldown-v1.2.3-node-v57-win32-x64.tar.gz
```

Non-absolute paths resolve relative to the directory of the package invoking prebuild-install, e.g. for nested dependencies.

### Cache

All prebuilt binaries are cached to minimize traffic. So first `prebuild-install` picks binaries from the cache and if no binary could be found, it will be downloaded. Depending on the environment, the cache folder is determined in the following order:

* `${npm_config_cache}/_prebuilds`
* `${APP_DATA}/npm-cache/_prebuilds`
* `${HOME}/.npm/_prebuilds`
- `${npm_config_cache}/_prebuilds`
- `${APP_DATA}/npm-cache/_prebuilds`
- `${HOME}/.npm/_prebuilds`

## Install

With [npm](https://npmjs.org) do:

```
npm install prebuild-install
```

## License

MIT
[MIT](./LICENSE)
Loading