Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #111 from Level/napi
Browse files Browse the repository at this point in the history
Rewrite to N-API
  • Loading branch information
vweevers authored May 25, 2019
2 parents fab2d10 + ea6d0df commit c7f8481
Show file tree
Hide file tree
Showing 43 changed files with 2,319 additions and 2,750 deletions.
58 changes: 48 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,56 @@
sudo: false

language: node_js

jobs:
include:
- os: linux
node_js: 8
env: [TEST=1]
- os: linux
node_js: 10
env: [TEST=1]
- os: linux
node_js: node
env: [TEST=1, TEST_ELECTRON=1, BUILD_CMD=prebuild, BUILD_GROUP=linux-x64]
addons:
apt:
packages:
- xvfb
before_script:
- export DISPLAY=':99.0'
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
- os: osx
node_js: 8
env: [TEST=1]
- os: osx
node_js: 10
env: [TEST=1]
- os: osx
node_js: node
env: [TEST=1, TEST_ELECTRON=1, BUILD_CMD=prebuild, BUILD_GROUP=darwin-x64]

before_install:
- export JOBS=max
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export JOBS=4; fi

os:
- osx
- linux
script:
- if [[ ! -z "$TEST" ]]; then npm run test; fi
- if [[ ! -z "$TEST_ELECTRON" ]]; then npm run test-electron; fi

after_success:
- if [[ ! -z "$TEST" ]]; then npm run coverage; fi

node_js:
- 6
- 8
- 10
before_deploy:
- export ARCHIVE_NAME="${TRAVIS_TAG:-latest}-$BUILD_GROUP.tar.gz"
- npm run $BUILD_CMD -- --tag-libc
- file prebuilds/*/*
- tar -zcvf "$ARCHIVE_NAME" -C prebuilds .

after_success: npm run coverage
deploy:
provider: releases
draft: false
api_key: "$PREBUILD_TOKEN"
file: "$ARCHIVE_NAME"
skip_cleanup: true
on:
tags: true
condition: "! -z $BUILD_CMD"
34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,19 @@ It is **strongly recommended** that you use LevelUP in preference to `rocksdb` u
<a name="platforms"></a>
## Supported Platforms

* **Linux** (including ARM platforms such as Raspberry Pi *and Kindle!*)
* **Mac OS**
* **Solaris** (SmartOS & Nodejitsu)
* **FreeBSD**
* **Windows**
* See installation instructions for *node-gyp* dependencies [here](https://github.com/TooTallNate/node-gyp#installation), you'll need these (free) components from Microsoft to compile and run any native Node add-on in Windows.
We aim to support _at least_ Active LTS and Current Node.js releases, Electron 4.0.0, as well as any future Node.js and Electron releases thanks to [N-API](https://nodejs.org/api/n-api.html). Because N-API has an experimental status in node 6 and early 8.x releases, the minimum node version for `rocksdb` is `8.6.0`.

The `rocksdb` npm package ships with prebuilt binaries for popular 64-bit platforms ~~as well as ARM, Android and Alpine (musl)~~ and is known to work on:

- **Linux** (including ARM platforms such as Raspberry Pi and Kindle)
- **Mac OS**
- **Solaris** (SmartOS & Nodejitsu)
- **FreeBSD**
- **Windows**

When installing `rocksdb`, [`node-gyp-build`](https://github.com/prebuild/node-gyp-build) will check if a compatible binary exists and fallback to a compile step if it doesn't. In that case you'll need a [valid `node-gyp` installation](https://github.com/nodejs/node-gyp#installation).

If you don't want to use the prebuilt binary for the platform you are installing on, specify the `--build-from-source` flag when you install. If you are working on `rocksdb` itself and want to re-compile the C++ code it's enough to do `npm install`.

<a name="api"></a>
## API
Expand All @@ -51,13 +58,16 @@ There are multiple ways you can find help in using LevelDB in Node.js:
See the [Contribution Guide](https://github.com/Level/community/blob/master/CONTRIBUTING.md) for more details.

## Prebuilt Binaries

`rocksdb` uses `prebuild` and `prebuild-install` for handling prebuilt binaries. See [this list](https://github.com/Level/rocksdb/releases) of supported prebuilt platform binaries. When installing rocksdb `prebuild-install` will install prebuilt binaries from GitHub if they exist and fallback to a compile step if they don't.

If you are working on `rocksdb` and want to re-compile the C++ code it's enough to do `npm install`.
### Publishing

If you don't want to use the `prebuild` for the platform you are installing on, specify the `--build-from-source` flag when you install.
1. Increment the version: `npm version ..`
2. Push to GitHub: `git push --follow-tags`
3. Wait for Travis and AppVeyor builds to complete
4. Download prebuilds into `./prebuilds`: `npm run download-prebuilds`
5. Optionally verify loading a prebuild: `npm run test-prebuild`
6. Optionally verify which files npm will include: `canadian-pub`
7. Add changelog to the GitHub release
8. Finally: `npm publish`

## Donate

Expand Down
30 changes: 25 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
version: "{build}"
build: off
skip_tags: true
build: false
skip_branch_with_pr: true

environment:
matrix:
- nodejs_version: "6"
- nodejs_version: "8"
- nodejs_version: "10"
- nodejs_version: "Current"

configuration: Release
platform:
- x64

install:
- SET PATH=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin;%PATH%
- ps: Install-Product node $env:nodejs_version $env:platform
- set PATH=%APPDATA%\npm;%APPVEYOR_BUILD_FOLDER%\node_modules\.bin;%PATH%
- SET PATH=%APPDATA%\npm;%APPVEYOR_BUILD_FOLDER%\node_modules\.bin;%PATH%
- npm i

test_script:
- node --version
- npm --version
- npm test
- ps: if ($env:nodejs_version -eq "Current") { npm run test-electron }

before_deploy:
- SET ARCHIVE_NAME=%APPVEYOR_REPO_TAG_NAME%-win32-%PLATFORM%.tar.gz
- npm run prebuild
- tar -zcvf "%ARCHIVE_NAME%" -C prebuilds .
- appveyor PushArtifact %ARCHIVE_NAME%

deploy:
- provider: GitHub
artifact: $(ARCHIVE_NAME)
auth_token:
secure: AjmYV2zeogfen7F6tXvR9PO1zynJVF/jhMCExQ9RMtqEHDMH8Frclym3GniZkEB0
draft: false
on:
appveyor_repo_tag: true
nodejs_version: "Current"
Loading

0 comments on commit c7f8481

Please sign in to comment.