pax_global_header00006660000000000000000000000064133136161370014516gustar00rootroot0000000000000052 comment=21f30f7895a4c9a0805ac2e436e892031ac6a500 node-pre-gyp-0.10.2/000077500000000000000000000000001331361613700141045ustar00rootroot00000000000000node-pre-gyp-0.10.2/.gitignore000066400000000000000000000001351331361613700160730ustar00rootroot00000000000000.DS_Store node_modules nwsnapshot node-webkit*.zip credits.html node-webkit.app npm-debug.lognode-pre-gyp-0.10.2/.npmignore000066400000000000000000000003261331361613700161040ustar00rootroot00000000000000.gitignore .npmignore .DS_Store nwsnapshot node-webkit*.zip credits.html node-webkit.app npm-debug.log node_modules test/ test.sh test.bat test-node-webkit.sh test-custom-target.sh scripts .travis.yml TODO.md *.tgznode-pre-gyp-0.10.2/.travis.yml000066400000000000000000000020611331361613700162140ustar00rootroot00000000000000language: cpp sudo: false # https://docs.travis-ci.com/user/languages/objective-c/#Supported-OS-X-iOS-SDK-versions osx_image: xcode8.2 os: - linux - osx addons: apt: sources: [ 'ubuntu-toolchain-r-test' ] packages: ['g++-4.8', 'xvfb','libasound2','libx11-6','libglib2.0-0','libgtk2.0-0','libatk1.0-0','libgdk-pixbuf2.0-0','libcairo2','libfreetype6','libfontconfig1','libxcomposite1','libasound2','libxdamage1','libxext6','libxfixes3','libnss3','libnspr4','libgconf-2-4','libexpat1','libdbus-1-3','libudev1'] env: matrix: - NODE_VERSION="6" - NODE_VERSION="8" - NODE_VERSION="9" - NODE_VERSION="10" before_install: - if [[ $(uname -s) == 'Linux' ]]; then export CXX="g++-4.8"; fi; - source ./scripts/install_node.sh ${NODE_VERSION} - npm config set loglevel=error install: - npm install before_script: - npm test - if [[ ${RETIRE:-false} == true ]]; then ./node_modules/.bin/retire -n; fi; # test node-webkit usage - ./scripts/test-node-webkit.sh script: # test non-authenticated mode - unset node_pre_gyp_accessKeyId - npm test node-pre-gyp-0.10.2/CHANGELOG.md000066400000000000000000000306051331361613700157210ustar00rootroot00000000000000# node-pre-gyp changelog ## 0.10.2 - Fixed rc/deep-extent security vulnerability - Fixed broken reinstall script do to incorrectly named get_best_napi_version ## 0.10.1 - Fix needle error event (@medns) ## 0.10.0 - Allow for a single-level module path when packing @allenluce (https://github.com/mapbox/node-pre-gyp/pull/371) - Log warnings instead of errors when falling back @xzyfer (https://github.com/mapbox/node-pre-gyp/pull/366) - Add Node.js v10 support to tests (https://github.com/mapbox/node-pre-gyp/pull/372) - Remove retire.js from CI (https://github.com/mapbox/node-pre-gyp/pull/372) - Remove support for Node.js v4 due to [EOL on April 30th, 2018](https://github.com/nodejs/Release/blob/7dd52354049cae99eed0e9fe01345b0722a86fde/schedule.json#L14) - Update appveyor tests to install default NPM version instead of NPM v2.x for all Windows builds (https://github.com/mapbox/node-pre-gyp/pull/375) ## 0.9.1 - Fixed regression (in v0.9.0) with support for http redirects @allenluce (https://github.com/mapbox/node-pre-gyp/pull/361) ## 0.9.0 - Switched from using `request` to `needle` to reduce size of module deps (https://github.com/mapbox/node-pre-gyp/pull/350) ## 0.8.0 - N-API support (@inspiredware) ## 0.7.1 - Upgraded to tar v4.x ## 0.7.0 - Updated request and hawk (#347) - Dropped node v0.10.x support ## 0.6.40 - Improved error reporting if an install fails ## 0.6.39 - Support for node v9 - Support for versioning on `{libc}` to allow binaries to work on non-glic linux systems like alpine linux ## 0.6.38 - Maintaining compatibility (for v0.6.x series) with node v0.10.x ## 0.6.37 - Solved one part of #276: now now deduce the node ABI from the major version for node >= 2 even when not stored in the abi_crosswalk.json - Fixed docs to avoid mentioning the deprecated and dangerous `prepublish` in package.json (#291) - Add new node versions to crosswalk - Ported tests to use tape instead of mocha - Got appveyor tests passing by downgrading npm and node-gyp ## 0.6.36 - Removed the running of `testbinary` during install. Because this was regressed for so long, it is too dangerous to re-enable by default. Developers needing validation can call `node-pre-gyp testbinary` directory. - Fixed regression in v0.6.35 for electron installs (now skipping binary validation which is not yet supported for electron) ## 0.6.35 - No longer recommending `npm ls` in `prepublish` (#291) - Fixed testbinary command (#283) @szdavid92 ## 0.6.34 - Added new node versions to crosswalk, including v8 - Upgraded deps to latest versions, started using `^` instead of `~` for all deps. ## 0.6.33 - Improved support for yarn ## 0.6.32 - Honor npm configuration for CA bundles (@heikkipora) - Add node-pre-gyp and npm versions to user agent (@addaleax) - Updated various deps - Add known node version for v7.x ## 0.6.31 - Updated various deps ## 0.6.30 - Update to npmlog@4.x and semver@5.3.x - Add known node version for v6.5.0 ## 0.6.29 - Add known node versions for v0.10.45, v0.12.14, v4.4.4, v5.11.1, and v6.1.0 ## 0.6.28 - Now more verbose when remote binaries are not available. This is needed since npm is increasingly more quiet by default and users need to know why builds are falling back to source compiles that might then error out. ## 0.6.27 - Add known node version for node v6 - Stopped bundling dependencies - Documented method for module authors to avoid bundling node-pre-gyp - See https://github.com/mapbox/node-pre-gyp/tree/master#configuring for details ## 0.6.26 - Skip validation for nw runtime (https://github.com/mapbox/node-pre-gyp/pull/181) via @fleg ## 0.6.25 - Improved support for auto-detection of electron runtime in `node-pre-gyp.find()` - Pull request from @enlight - https://github.com/mapbox/node-pre-gyp/pull/187 - Add known node version for 4.4.1 and 5.9.1 ## 0.6.24 - Add known node version for 5.8.0, 5.9.0, and 4.4.0. ## 0.6.23 - Add known node version for 0.10.43, 0.12.11, 4.3.2, and 5.7.1. ## 0.6.22 - Add known node version for 4.3.1, and 5.7.0. ## 0.6.21 - Add known node version for 0.10.42, 0.12.10, 4.3.0, and 5.6.0. ## 0.6.20 - Add known node version for 4.2.5, 4.2.6, 5.4.0, 5.4.1,and 5.5.0. ## 0.6.19 - Add known node version for 4.2.4 ## 0.6.18 - Add new known node versions for 0.10.x, 0.12.x, 4.x, and 5.x ## 0.6.17 - Re-tagged to fix packaging problem of `Error: Cannot find module 'isarray'` ## 0.6.16 - Added known version in crosswalk for 5.1.0. ## 0.6.15 - Upgraded tar-pack (https://github.com/mapbox/node-pre-gyp/issues/182) - Support custom binary hosting mirror (https://github.com/mapbox/node-pre-gyp/pull/170) - Added known version in crosswalk for 4.2.2. ## 0.6.14 - Added node 5.x version ## 0.6.13 - Added more known node 4.x versions ## 0.6.12 - Added support for [Electron](http://electron.atom.io/). Just pass the `--runtime=electron` flag when building/installing. Thanks @zcbenz ## 0.6.11 - Added known node and io.js versions including more 3.x and 4.x versions ## 0.6.10 - Added known node and io.js versions including 3.x and 4.x versions - Upgraded `tar` dep ## 0.6.9 - Upgraded `rc` dep - Updated known io.js version: v2.4.0 ## 0.6.8 - Upgraded `semver` and `rimraf` deps - Updated known node and io.js versions ## 0.6.7 - Fixed `node_abi` versions for io.js 1.1.x -> 1.8.x (should be 43, but was stored as 42) (refs https://github.com/iojs/build/issues/94) ## 0.6.6 - Updated with known io.js 2.0.0 version ## 0.6.5 - Now respecting `npm_config_node_gyp` (https://github.com/npm/npm/pull/4887) - Updated to semver@4.3.2 - Updated known node v0.12.x versions and io.js 1.x versions. ## 0.6.4 - Improved support for `io.js` (@fengmk2) - Test coverage improvements (@mikemorris) - Fixed support for `--dist-url` that regressed in 0.6.3 ## 0.6.3 - Added support for passing raw options to node-gyp using `--` separator. Flags passed after the `--` to `node-pre-gyp configure` will be passed directly to gyp while flags passed after the `--` will be passed directly to make/visual studio. - Added `node-pre-gyp configure` command to be able to call `node-gyp configure` directly - Fix issue with require validation not working on windows 7 (@edgarsilva) ## 0.6.2 - Support for io.js >= v1.0.2 - Deferred require of `request` and `tar` to help speed up command line usage of `node-pre-gyp`. ## 0.6.1 - Fixed bundled `tar` version ## 0.6.0 - BREAKING: node odd releases like v0.11.x now use `major.minor.patch` for `{node_abi}` instead of `NODE_MODULE_VERSION` (#124) - Added support for `toolset` option in versioning. By default is an empty string but `--toolset` can be passed to publish or install to select alternative binaries that target a custom toolset like C++11. For example to target Visual Studio 2014 modules like node-sqlite3 use `--toolset=v140`. - Added support for `--no-rollback` option to request that a failed binary test does not remove the binary module leaves it in place. - Added support for `--update-binary` option to request an existing binary be re-installed and the check for a valid local module be skipped. - Added support for passing build options from `npm` through `node-pre-gyp` to `node-gyp`: `--nodedir`, `--disturl`, `--python`, and `--msvs_version` ## 0.5.31 - Added support for deducing node_abi for node.js runtime from previous release if the series is even - Added support for --target=0.10.33 ## 0.5.30 - Repackaged with latest bundled deps ## 0.5.29 - Added support for semver `build`. - Fixed support for downloading from urls that include `+`. ## 0.5.28 - Now reporting unix style paths only in reveal command ## 0.5.27 - Fixed support for auto-detecting s3 bucket name when it contains `.` - @taavo - Fixed support for installing when path contains a `'` - @halfdan - Ported tests to mocha ## 0.5.26 - Fix node-webkit support when `--target` option is not provided ## 0.5.25 - Fix bundling of deps ## 0.5.24 - Updated ABI crosswalk to incldue node v0.10.30 and v0.10.31 ## 0.5.23 - Added `reveal` command. Pass no options to get all versioning data as json. Pass a second arg to grab a single versioned property value - Added support for `--silent` (shortcut for `--loglevel=silent`) ## 0.5.22 - Fixed node-webkit versioning name (NOTE: node-webkit support still experimental) ## 0.5.21 - New package to fix `shasum check failed` error with v0.5.20 ## 0.5.20 - Now versioning node-webkit binaries based on major.minor.patch - assuming no compatible ABI across versions (#90) ## 0.5.19 - Updated to know about more node-webkit releases ## 0.5.18 - Updated to know about more node-webkit releases ## 0.5.17 - Updated to know about node v0.10.29 release ## 0.5.16 - Now supporting all aws-sdk configuration parameters (http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html) (#86) ## 0.5.15 - Fixed installation of windows packages sub directories on unix systems (#84) ## 0.5.14 - Finished support for cross building using `--target_platform` option (#82) - Now skipping binary validation on install if target arch/platform do not match the host. - Removed multi-arch validing for OS X since it required a FAT node.js binary ## 0.5.13 - Fix problem in 0.5.12 whereby the wrong versions of mkdirp and semver where bundled. ## 0.5.12 - Improved support for node-webkit (@Mithgol) ## 0.5.11 - Updated target versions listing ## 0.5.10 - Fixed handling of `-debug` flag passed directory to node-pre-gyp (#72) - Added optional second arg to `node_pre_gyp.find` to customize the default versioning options used to locate the runtime binary - Failed install due to `testbinary` check failure no longer leaves behind binary (#70) ## 0.5.9 - Fixed regression in `testbinary` command causing installs to fail on windows with 0.5.7 (#60) ## 0.5.8 - Started bundling deps ## 0.5.7 - Fixed the `testbinary` check, which is used to determine whether to re-download or source compile, to work even in complex dependency situations (#63) - Exposed the internal `testbinary` command in node-pre-gyp command line tool - Fixed minor bug so that `fallback_to_build` option is always respected ## 0.5.6 - Added support for versioning on the `name` value in `package.json` (#57). - Moved to using streams for reading tarball when publishing (#52) ## 0.5.5 - Improved binary validation that also now works with node-webkit (@Mithgol) - Upgraded test apps to work with node v0.11.x - Improved test coverage ## 0.5.4 - No longer depends on external install of node-gyp for compiling builds. ## 0.5.3 - Reverted fix for debian/nodejs since it broke windows (#45) ## 0.5.2 - Support for debian systems where the node binary is named `nodejs` (#45) - Added `bin/node-pre-gyp.cmd` to be able to run command on windows locally (npm creates an .npm automatically when globally installed) - Updated abi-crosswalk with node v0.10.26 entry. ## 0.5.1 - Various minor bug fixes, several improving windows support for publishing. ## 0.5.0 - Changed property names in `binary` object: now required are `module_name`, `module_path`, and `host`. - Now `module_path` supports versioning, which allows developers to opt-in to using a versioned install path (#18). - Added `remote_path` which also supports versioning. - Changed `remote_uri` to `host`. ## 0.4.2 - Added support for `--target` flag to request cross-compile against a specific node/node-webkit version. - Added preliminary support for node-webkit - Fixed support for `--target_arch` option being respected in all cases. ## 0.4.1 - Fixed exception when only stderr is available in binary test (@bendi / #31) ## 0.4.0 - Enforce only `https:` based remote publishing access. - Added `node-pre-gyp info` command to display listing of published binaries - Added support for changing the directory node-pre-gyp should build in with the `-C/--directory` option. - Added support for S3 prefixes. ## 0.3.1 - Added `unpublish` command. - Fixed module path construction in tests. - Added ability to disable falling back to build behavior via `npm install --fallback-to-build=false` which overrides setting in a depedencies package.json `install` target. ## 0.3.0 - Support for packaging all files in `module_path` directory - see `app4` for example - Added `testpackage` command. - Changed `clean` command to only delete `.node` not entire `build` directory since node-gyp will handle that. - `.node` modules must be in a folder of there own since tar-pack will remove everything when it unpacks. node-pre-gyp-0.10.2/LICENSE000066400000000000000000000027351331361613700151200ustar00rootroot00000000000000Copyright (c), Mapbox All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of node-pre-gyp nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. node-pre-gyp-0.10.2/README.md000066400000000000000000000754631331361613700154020ustar00rootroot00000000000000# node-pre-gyp #### node-pre-gyp makes it easy to publish and install Node.js C++ addons from binaries [![NPM](https://nodei.co/npm/node-pre-gyp.png?downloads=true&downloadRank=true)](https://nodei.co/npm/node-pre-gyp/) [![Build Status](https://api.travis-ci.org/mapbox/node-pre-gyp.svg)](https://travis-ci.org/mapbox/node-pre-gyp) [![Build status](https://ci.appveyor.com/api/projects/status/3nxewb425y83c0gv)](https://ci.appveyor.com/project/Mapbox/node-pre-gyp) [![Dependencies](https://david-dm.org/mapbox/node-pre-gyp.svg)](https://david-dm.org/mapbox/node-pre-gyp) `node-pre-gyp` stands between [npm](https://github.com/npm/npm) and [node-gyp](https://github.com/Tootallnate/node-gyp) and offers a cross-platform method of binary deployment. ### Features - A command line tool called `node-pre-gyp` that can install your package's C++ module from a binary. - A variety of developer targeted commands for packaging, testing, and publishing binaries. - A JavaScript module that can dynamically require your installed binary: `require('node-pre-gyp').find` For a hello world example of a module packaged with `node-pre-gyp` see and [the wiki ](https://github.com/mapbox/node-pre-gyp/wiki/Modules-using-node-pre-gyp) for real world examples. ## Credits - The module is modeled after [node-gyp](https://github.com/Tootallnate/node-gyp) by [@Tootallnate](https://github.com/Tootallnate) - Motivation for initial development came from [@ErisDS](https://github.com/ErisDS) and the [Ghost Project](https://github.com/TryGhost/Ghost). - Development is sponsored by [Mapbox](https://www.mapbox.com/) ## FAQ See the [Frequently Ask Questions](https://github.com/mapbox/node-pre-gyp/wiki/FAQ). ## Depends - Node.js >= node v6.x ## Install `node-pre-gyp` is designed to be installed as a local dependency of your Node.js C++ addon and accessed like: ./node_modules/.bin/node-pre-gyp --help But you can also install it globally: npm install node-pre-gyp -g ## Usage ### Commands View all possible commands: node-pre-gyp --help - clean - Remove the entire folder containing the compiled .node module - install - Install pre-built binary for module - reinstall - Run "clean" and "install" at once - build - Compile the module by dispatching to node-gyp or nw-gyp - rebuild - Run "clean" and "build" at once - package - Pack binary into tarball - testpackage - Test that the staged package is valid - publish - Publish pre-built binary - unpublish - Unpublish pre-built binary - info - Fetch info on published binaries You can also chain commands: node-pre-gyp clean build unpublish publish info ### Options Options include: - `-C/--directory`: run the command in this directory - `--build-from-source`: build from source instead of using pre-built binary - `--update-binary`: reinstall by replacing previously installed local binary with remote binary - `--runtime=node-webkit`: customize the runtime: `node`, `electron` and `node-webkit` are the valid options - `--fallback-to-build`: fallback to building from source if pre-built binary is not available - `--target=0.4.0`: Pass the target node or node-webkit version to compile against - `--target_arch=ia32`: Pass the target arch and override the host `arch`. Valid values are 'ia32','x64', or `arm`. - `--target_platform=win32`: Pass the target platform and override the host `platform`. Valid values are `linux`, `darwin`, `win32`, `sunos`, `freebsd`, `openbsd`, and `aix`. Both `--build-from-source` and `--fallback-to-build` can be passed alone or they can provide values. You can pass `--fallback-to-build=false` to override the option as declared in package.json. In addition to being able to pass `--build-from-source` you can also pass `--build-from-source=myapp` where `myapp` is the name of your module. For example: `npm install --build-from-source=myapp`. This is useful if: - `myapp` is referenced in the package.json of a larger app and therefore `myapp` is being installed as a dependent with `npm install`. - The larger app also depends on other modules installed with `node-pre-gyp` - You only want to trigger a source compile for `myapp` and the other modules. ### Configuring This is a guide to configuring your module to use node-pre-gyp. #### 1) Add new entries to your `package.json` - Add `node-pre-gyp` to `dependencies` - Add `aws-sdk` as a `devDependency` - Add a custom `install` script - Declare a `binary` object This looks like: ```js "dependencies" : { "node-pre-gyp": "0.6.x" }, "devDependencies": { "aws-sdk": "2.x" } "bundledDependencies":["node-pre-gyp"], "scripts": { "install": "node-pre-gyp install --fallback-to-build" }, "binary": { "module_name": "your_module", "module_path": "./lib/binding/", "host": "https://your_module.s3-us-west-1.amazonaws.com" } ``` For a full example see [node-addon-examples's package.json](https://github.com/springmeyer/node-addon-example/blob/master/package.json). Let's break this down: - Dependencies need to list `node-pre-gyp` - Your devDependencies should list `aws-sdk` so that you can run `node-pre-gyp publish` locally or a CI system. We recommend using `devDependencies` only since `aws-sdk` is large and not needed for `node-pre-gyp install` since it only uses http to fetch binaries - You should add `"bundledDependencies":["node-pre-gyp"]`. This ensures that when you publish your module that the correct version of node-pre-gyp will be included in the `node_modules` folder during publishing. Then when uses install your module `node-pre-gyp` will already be present. Without this your module will not be safely installable for downstream applications that have a depedency on node-pre-gyp in the npm tree (without bundling npm deduping might break the install when node-pre-gyp is moved in flight) - Your `scripts` section should optionally add `"prepublishOnly": "npm ls"` to ensure the right node-pre-gyp version is bundled before publishing your module. If node-pre-gyp is missing or an old version is present then this will catch that error before you publish a broken package. - Your `scripts` section should override the `install` target with `"install": "node-pre-gyp install --fallback-to-build"`. This allows node-pre-gyp to be used instead of the default npm behavior of always source compiling with `node-gyp` directly. - Your package.json should contain a `binary` section describing key properties you provide to allow node-pre-gyp to package optimally. They are detailed below. Note: in the past we recommended using `"preinstall": "npm install node-pre-gyp"` as an alternative method to avoid needing to bundle. But this does not behave predictably across all npm versions - see https://github.com/mapbox/node-pre-gyp/issues/260 for the details. So we do not recommend using `preinstall` to install `node-pre-gyp`. Instead we recommend bundling. More history on this at https://github.com/strongloop/fsevents/issues/157#issuecomment-265545908. ##### The `binary` object has three required properties ###### module_name The name of your native node module. This value must: - Match the name passed to [the NODE_MODULE macro](http://nodejs.org/api/addons.html#addons_hello_world) - Must be a valid C variable name (e.g. it cannot contain `-`) - Should not include the `.node` extension. ###### module_path The location your native module is placed after a build. This should be an empty directory without other Javascript files. This entire directory will be packaged in the binary tarball. When installing from a remote package this directory will be overwritten with the contents of the tarball. Note: This property supports variables based on [Versioning](#versioning). ###### host A url to the remote location where you've published tarball binaries (must be `https` not `http`). It is highly recommended that you use Amazon S3. The reasons are: - Various node-pre-gyp commands like `publish` and `info` only work with an S3 host. - S3 is a very solid hosting platform for distributing large files. - We provide detail documentation for using [S3 hosting](#s3-hosting) with node-pre-gyp. Why then not require S3? Because while some applications using node-pre-gyp need to distribute binaries as large as 20-30 MB, others might have very small binaries and might wish to store them in a GitHub repo. This is not recommended, but if an author really wants to host in a non-s3 location then it should be possible. It should also be mentioned that there is an optional and entirely separate npm module called [node-pre-gyp-github](https://github.com/bchr02/node-pre-gyp-github) which is intended to complement node-pre-gyp and be installed along with it. It provides the ability to store and publish your binaries within your repositories GitHub Releases if you would rather not use S3 directly. Installation and usage instructions can be found [here](https://github.com/bchr02/node-pre-gyp-github), but the basic premise is that instead of using the ```node-pre-gyp publish``` command you would use ```node-pre-gyp-github publish```. ##### The `binary` object has two optional properties ###### remote_path It **is recommended** that you customize this property. This is an extra path to use for publishing and finding remote tarballs. The default value for `remote_path` is `""` meaning that if you do not provide it then all packages will be published at the base of the `host`. It is recommended to provide a value like `./{name}/v{version}` to help organize remote packages in the case that you choose to publish multiple node addons to the same `host`. Note: This property supports variables based on [Versioning](#versioning). ###### package_name It is **not recommended** to override this property unless you are also overriding the `remote_path`. This is the versioned name of the remote tarball containing the binary `.node` module and any supporting files you've placed inside the `module_path` directory. Unless you specify `package_name` in your `package.json` then it defaults to `{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz` which allows your binary to work across node versions, platforms, and architectures. If you are using `remote_path` that is also versioned by `./{module_name}/v{version}` then you could remove these variables from the `package_name` and just use: `{node_abi}-{platform}-{arch}.tar.gz`. Then your remote tarball will be looked up at, for example, `https://example.com/your-module/v0.1.0/node-v11-linux-x64.tar.gz`. Avoiding the version of your module in the `package_name` and instead only embedding in a directory name can be useful when you want to make a quick tag of your module that does not change any C++ code. In this case you can just copy binaries to the new version behind the scenes like: ```sh aws s3 sync --acl public-read s3://mapbox-node-binary/sqlite3/v3.0.3/ s3://mapbox-node-binary/sqlite3/v3.0.4/ ``` Note: This property supports variables based on [Versioning](#versioning). #### 2) Add a new target to binding.gyp `node-pre-gyp` calls out to `node-gyp` to compile the module and passes variables along like [module_name](#module_name) and [module_path](#module_path). A new target must be added to `binding.gyp` that moves the compiled `.node` module from `./build/Release/module_name.node` into the directory specified by `module_path`. Add a target like this at the end of your `targets` list: ```js { "target_name": "action_after_build", "type": "none", "dependencies": [ "<(module_name)" ], "copies": [ { "files": [ "<(PRODUCT_DIR)/<(module_name).node" ], "destination": "<(module_path)" } ] } ``` For a full example see [node-addon-example's binding.gyp](https://github.com/springmeyer/node-addon-example/blob/2ff60a8ded7f042864ad21db00c3a5a06cf47075/binding.gyp). #### 3) Dynamically require your `.node` Inside the main js file that requires your addon module you are likely currently doing: ```js var binding = require('../build/Release/binding.node'); ``` or: ```js var bindings = require('./bindings') ``` Change those lines to: ```js var binary = require('node-pre-gyp'); var path = require('path'); var binding_path = binary.find(path.resolve(path.join(__dirname,'./package.json'))); var binding = require(binding_path); ``` For a full example see [node-addon-example's index.js](https://github.com/springmeyer/node-addon-example/blob/2ff60a8ded7f042864ad21db00c3a5a06cf47075/index.js#L1-L4) #### 4) Build and package your app Now build your module from source: npm install --build-from-source The `--build-from-source` tells `node-pre-gyp` to not look for a remote package and instead dispatch to node-gyp to build. Now `node-pre-gyp` should now also be installed as a local dependency so the command line tool it offers can be found at `./node_modules/.bin/node-pre-gyp`. #### 5) Test Now `npm test` should work just as it did before. #### 6) Publish the tarball Then package your app: ./node_modules/.bin/node-pre-gyp package Once packaged, now you can publish: ./node_modules/.bin/node-pre-gyp publish Currently the `publish` command pushes your binary to S3. This requires: - You have installed `aws-sdk` with `npm install aws-sdk` - You have created a bucket already. - The `host` points to an S3 http or https endpoint. - You have configured node-pre-gyp to read your S3 credentials (see [S3 hosting](#s3-hosting) for details). You can also host your binaries elsewhere. To do this requires: - You manually publish the binary created by the `package` command to an `https` endpoint - Ensure that the `host` value points to your custom `https` endpoint. #### 7) Automate builds Now you need to publish builds for all the platforms and node versions you wish to support. This is best automated. - See [Appveyor Automation](#appveyor-automation) for how to auto-publish builds on Windows. - See [Travis Automation](#travis-automation) for how to auto-publish builds on OS X and Linux. #### 8) You're done! Now publish your module to the npm registry. Users will now be able to install your module from a binary. What will happen is this: 1. `npm install ` will pull from the npm registry 2. npm will run the `install` script which will call out to `node-pre-gyp` 3. `node-pre-gyp` will fetch the binary `.node` module and unpack in the right place 4. Assuming that all worked, you are done If a a binary was not available for a given platform and `--fallback-to-build` was used then `node-gyp rebuild` will be called to try to source compile the module. ## N-API Considerations [N-API](https://nodejs.org/api/n-api.html#n_api_n_api) is an ABI-stable alternative to previous technologies such as [nan](https://github.com/nodejs/nan) which are tied to a specific Node runtime engine. N-API is Node runtime engine agnostic and guarantees modules created today will continue to run, without changes, into the future. Using `node-pre-gyp` with N-API projects requires a handful of additional configuration values and imposes some additional requirements. The most significant difference is that an N-API module can be coded to target multiple N-API versions. Therefore, an N-API module must declare in its `package.json` file which N-API versions the module is designed to run against. In addition, since multiple builds may be required for a single module, path and file names must be specified in way that avoids naming conflicts. ### The `napi_versions` array property An N-API modules must declare in its `package.json` file, the N-API versions the module is intended to support. This is accomplished by including an `napi-versions` array property in the `binary` object. For example: ```js "binary": { "module_name": "your_module", "module_path": "your_module_path", "host": "https://your_bucket.s3-us-west-1.amazonaws.com", "napi_versions": [1,3] } ``` If the `napi_versions` array property is *not* present, `node-pre-gyp` operates as it always has. Including the `napi_versions` array property instructs `node-pre-gyp` that this is a N-API module build. When the `napi_versions` array property is present, `node-pre-gyp` fires off multiple operations, one for each of the N-API versions in the array. In the example above, two operations are initiated, one for N-API version 1 and second for N-API version 3. How this version number is communicated is described next. ### The `napi_build_version` value For each of the N-API module operations `node-pre-gyp` initiates, it insures that the `napi_build_version` is set appropriately. This value is of importance in two areas: 1. The C/C++ code which needs to know against which N-API version it should compile. 2. `node-pre-gyp` itself which must assign appropriate path and file names to avoid collisions. ### Defining `NAPI_BUILD_VERSION` for the C/C++ code The `napi_build_version` value is communicated to the C/C++ code by adding this code to the `binding.gyp` file: ``` "defines": [ "NAPI_BUILD_VERSION=<(napi_build_version)", ] ``` This insures that `NAPI_BUILD_VERSION`, an integer value, is declared appropriately to the C/C++ code for each build. ### Path and file naming requirements in `package.json` Since `node-pre-gyp` fires off multiple operations for each request, it is essential that path and file names be created in such a way as to avoid collisions. This is accomplished by imposing additional path and file naming requirements. Specifically, when performing N-API builds, the `{napi_build_version}` text substitution string *must* be present in the `module_path` property. In addition, the `{napi_build_version}` text substitution string *must* be present in either the `remote_path` or `package_name` property. (No problem if it's in both.) Here's an example: ```js "binary": { "module_name": "your_module", "module_path": "./lib/binding/napi-v{napi_build_version}", "remote_path": "./{module_name}/v{version}/{configuration}/", "package_name": "{platform}-{arch}-napi-v{napi_build_version}.tar.gz", "host": "https://your_bucket.s3-us-west-1.amazonaws.com", "napi_versions": [1,3] } ``` ### Two additional configuration values For those who need them in legacy projects, two additional configuration values are available for all builds. 1. `napi_version` If N-API is supported by the currently executing Node instance, this value is the N-API version number supported by Node. If N-API is not supported, this value is an empty string. 2. `node_abi_napi` If the value returned for `napi_version` is non empty, this value is `'napi'`. If the value returned for `napi_version` is empty, this value is the value returned for `node_abi`. These values are present for use in the `binding.gyp` file and may be used as `{napi_version}` and `{node_abi_napi}` for text substituion in the `binary` properties of the `package.json` file. ## S3 Hosting You can host wherever you choose but S3 is cheap, `node-pre-gyp publish` expects it, and S3 can be integrated well with [Travis.ci](http://travis-ci.org) to automate builds for OS X and Ubuntu, and with [Appveyor](http://appveyor.com) to automate builds for Windows. Here is an approach to do this: First, get setup locally and test the workflow: #### 1) Create an S3 bucket And have your **key** and **secret key** ready for writing to the bucket. It is recommended to create a IAM user with a policy that only gives permissions to the specific bucket you plan to publish to. This can be done in the [IAM console](https://console.aws.amazon.com/iam/) by: 1) adding a new user, 2) choosing `Attach User Policy`, 3) Using the `Policy Generator`, 4) selecting `Amazon S3` for the service, 5) adding the actions: `DeleteObject`, `GetObject`, `GetObjectAcl`, `ListBucket`, `PutObject`, `PutObjectAcl`, 6) adding an ARN of `arn:aws:s3:::bucket/*` (replacing `bucket` with your bucket name), and finally 7) clicking `Add Statement` and saving the policy. It should generate a policy like: ```js { "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1394587197000", "Effect": "Allow", "Action": [ "s3:DeleteObject", "s3:GetObject", "s3:GetObjectAcl", "s3:ListBucket", "s3:PutObject", "s3:PutObjectAcl" ], "Resource": [ "arn:aws:s3:::node-pre-gyp-tests/*" ] } ] } ``` #### 2) Install node-pre-gyp Either install it globally: npm install node-pre-gyp -g Or put the local version on your PATH export PATH=`pwd`/node_modules/.bin/:$PATH #### 3) Configure AWS credentials There are several ways to do this. You can use any of the methods described at http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html. Or you can create a `~/.node_pre_gyprc` Or pass options in any way supported by [RC](https://github.com/dominictarr/rc#standards) A `~/.node_pre_gyprc` looks like: ```js { "accessKeyId": "xxx", "secretAccessKey": "xxx" } ``` Another way is to use your environment: export node_pre_gyp_accessKeyId=xxx export node_pre_gyp_secretAccessKey=xxx You may also need to specify the `region` if it is not explicit in the `host` value you use. The `bucket` can also be specified but it is optional because `node-pre-gyp` will detect it from the `host` value. #### 4) Package and publish your build Install the `aws-sdk`: npm install aws-sdk Then publish: node-pre-gyp package publish Note: if you hit an error like `Hostname/IP doesn't match certificate's altnames` it may mean that you need to provide the `region` option in your config. ## Appveyor Automation [Appveyor](http://www.appveyor.com/) can build binaries and publish the results per commit and supports: - Windows Visual Studio 2013 and related compilers - Both 64 bit (x64) and 32 bit (x86) build configurations - Multiple Node.js versions For an example of doing this see [node-sqlite3's appveyor.yml](https://github.com/mapbox/node-sqlite3/blob/master/appveyor.yml). Below is a guide to getting set up: #### 1) Create a free Appveyor account Go to https://ci.appveyor.com/signup/free and sign in with your GitHub account. #### 2) Create a new project Go to https://ci.appveyor.com/projects/new and select the GitHub repo for your module #### 3) Add appveyor.yml and push it Once you have committed an `appveyor.yml` ([appveyor.yml reference](http://www.appveyor.com/docs/appveyor-yml)) to your GitHub repo and pushed it AppVeyor should automatically start building your project. #### 4) Create secure variables Encrypt your S3 AWS keys by going to and hitting the `encrypt` button. Then paste the result into your `appveyor.yml` ```yml environment: node_pre_gyp_accessKeyId: secure: Dn9HKdLNYvDgPdQOzRq/DqZ/MPhjknRHB1o+/lVU8MA= node_pre_gyp_secretAccessKey: secure: W1rwNoSnOku1r+28gnoufO8UA8iWADmL1LiiwH9IOkIVhDTNGdGPJqAlLjNqwLnL ``` NOTE: keys are per account but not per repo (this is difference than Travis where keys are per repo but not related to the account used to encrypt them). #### 5) Hook up publishing Just put `node-pre-gyp package publish` in your `appveyor.yml` after `npm install`. #### 6) Publish when you want You might wish to publish binaries only on a specific commit. To do this you could borrow from the [Travis CI idea of commit keywords](http://about.travis-ci.org/docs/user/how-to-skip-a-build/) and add special handling for commit messages with `[publish binary]`: SET CM=%APPVEYOR_REPO_COMMIT_MESSAGE% if not "%CM%" == "%CM:[publish binary]=%" node-pre-gyp --msvs_version=2013 publish If your commit message contains special characters (e.g. `&`) this method might fail. An alternative is to use PowerShell, which gives you additional possibilities, like ignoring case by using `ToLower()`: ps: if($env:APPVEYOR_REPO_COMMIT_MESSAGE.ToLower().Contains('[publish binary]')) { node-pre-gyp --msvs_version=2013 publish } Remember this publishing is not the same as `npm publish`. We're just talking about the binary module here and not your entire npm package. ## Travis Automation [Travis](https://travis-ci.org/) can push to S3 after a successful build and supports both: - Ubuntu Precise and OS X (64 bit) - Multiple Node.js versions For an example of doing this see [node-add-example's .travis.yml](https://github.com/springmeyer/node-addon-example/blob/2ff60a8ded7f042864ad21db00c3a5a06cf47075/.travis.yml). Note: if you need 32 bit binaries, this can be done from a 64 bit Travis machine. See [the node-sqlite3 scripts for an example of doing this](https://github.com/mapbox/node-sqlite3/blob/bae122aa6a2b8a45f6b717fab24e207740e32b5d/scripts/build_against_node.sh#L54-L74). Below is a guide to getting set up: #### 1) Install the Travis gem gem install travis #### 2) Create secure variables Make sure you run this command from within the directory of your module. Use `travis-encrypt` like: travis encrypt node_pre_gyp_accessKeyId=${node_pre_gyp_accessKeyId} travis encrypt node_pre_gyp_secretAccessKey=${node_pre_gyp_secretAccessKey} Then put those values in your `.travis.yml` like: ```yaml env: global: - secure: F+sEL/v56CzHqmCSSES4pEyC9NeQlkoR0Gs/ZuZxX1ytrj8SKtp3MKqBj7zhIclSdXBz4Ev966Da5ctmcTd410p0b240MV6BVOkLUtkjZJyErMBOkeb8n8yVfSoeMx8RiIhBmIvEn+rlQq+bSFis61/JkE9rxsjkGRZi14hHr4M= - secure: o2nkUQIiABD139XS6L8pxq3XO5gch27hvm/gOdV+dzNKc/s2KomVPWcOyXNxtJGhtecAkABzaW8KHDDi5QL1kNEFx6BxFVMLO8rjFPsMVaBG9Ks6JiDQkkmrGNcnVdxI/6EKTLHTH5WLsz8+J7caDBzvKbEfTux5EamEhxIWgrI= ``` More details on Travis encryption at http://about.travis-ci.org/docs/user/encryption-keys/. #### 3) Hook up publishing Just put `node-pre-gyp package publish` in your `.travis.yml` after `npm install`. ##### OS X publishing If you want binaries for OS X in addition to linux you can enable [multi-os for Travis](http://docs.travis-ci.com/user/multi-os/#Setting-.travis.yml) Use a configuration like: ```yml language: cpp os: - linux - osx env: matrix: - NODE_VERSION="4" - NODE_VERSION="6" before_install: - rm -rf ~/.nvm/ && git clone --depth 1 https://github.com/creationix/nvm.git ~/.nvm - source ~/.nvm/nvm.sh - nvm install $NODE_VERSION - nvm use $NODE_VERSION ``` See [Travis OS X Gotchas](#travis-os-x-gotchas) for why we replace `language: node_js` and `node_js:` sections with `language: cpp` and a custom matrix. Also create platform specific sections for any deps that need install. For example if you need libpng: ```yml - if [ $(uname -s) == 'Linux' ]; then apt-get install libpng-dev; fi; - if [ $(uname -s) == 'Darwin' ]; then brew install libpng; fi; ``` For detailed multi-OS examples see [node-mapnik](https://github.com/mapnik/node-mapnik/blob/master/.travis.yml) and [node-sqlite3](https://github.com/mapbox/node-sqlite3/blob/master/.travis.yml). ##### Travis OS X Gotchas First, unlike the Travis Linux machines, the OS X machines do not put `node-pre-gyp` on PATH by default. To do so you will need to: ```sh export PATH=$(pwd)/node_modules/.bin:${PATH} ``` Second, the OS X machines do not support using a matrix for installing different Node.js versions. So you need to bootstrap the installation of Node.js in a cross platform way. By doing: ```yml env: matrix: - NODE_VERSION="4" - NODE_VERSION="6" before_install: - rm -rf ~/.nvm/ && git clone --depth 1 https://github.com/creationix/nvm.git ~/.nvm - source ~/.nvm/nvm.sh - nvm install $NODE_VERSION - nvm use $NODE_VERSION ``` You can easily recreate the previous behavior of this matrix: ```yml node_js: - "4" - "6" ``` #### 4) Publish when you want You might wish to publish binaries only on a specific commit. To do this you could borrow from the [Travis CI idea of commit keywords](http://about.travis-ci.org/docs/user/how-to-skip-a-build/) and add special handling for commit messages with `[publish binary]`: COMMIT_MESSAGE=$(git log --format=%B --no-merges -n 1 | tr -d '\n') if [[ ${COMMIT_MESSAGE} =~ "[publish binary]" ]]; then node-pre-gyp publish; fi; Then you can trigger new binaries to be built like: git commit -a -m "[publish binary]" Or, if you don't have any changes to make simply run: git commit --allow-empty -m "[publish binary]" WARNING: if you are working in a pull request and publishing binaries from there then you will want to avoid double publishing when Travis CI builds both the `push` and `pr`. You only want to run the publish on the `push` commit. See https://github.com/Project-OSRM/node-osrm/blob/8eb837abe2e2e30e595093d16e5354bc5c573575/scripts/is_pr_merge.sh which is called from https://github.com/Project-OSRM/node-osrm/blob/8eb837abe2e2e30e595093d16e5354bc5c573575/scripts/publish.sh for an example of how to do this. Remember this publishing is not the same as `npm publish`. We're just talking about the binary module here and not your entire npm package. To automate the publishing of your entire package to npm on Travis see http://about.travis-ci.org/docs/user/deployment/npm/ # Versioning The `binary` properties of `module_path`, `remote_path`, and `package_name` support variable substitution. The strings are evaluated by `node-pre-gyp` depending on your system and any custom build flags you passed. - `node_abi`: The node C++ `ABI` number. This value is available in Javascript as `process.versions.modules` as of [`>= v0.10.4 >= v0.11.7`](https://github.com/joyent/node/commit/ccabd4a6fa8a6eb79d29bc3bbe9fe2b6531c2d8e) and in C++ as the `NODE_MODULE_VERSION` define much earlier. For versions of Node before this was available we fallback to the V8 major and minor version. - `platform` matches node's `process.platform` like `linux`, `darwin`, and `win32` unless the user passed the `--target_platform` option to override. - `arch` matches node's `process.arch` like `x64` or `ia32` unless the user passes the `--target_arch` option to override. - `libc` matches `require('detect-libc').family` like `glibc` or `musl` unless the user passes the `--target_libc` option to override. - `configuration` - Either 'Release' or 'Debug' depending on if `--debug` is passed during the build. - `module_name` - the `binary.module_name` attribute from `package.json`. - `version` - the semver `version` value for your module from `package.json` (NOTE: ignores the `semver.build` property). - `major`, `minor`, `patch`, and `prelease` match the individual semver values for your module's `version` - `build` - the sevmer `build` value. For example it would be `this.that` if your package.json `version` was `v1.0.0+this.that` - `prerelease` - the semver `prerelease` value. For example it would be `alpha.beta` if your package.json `version` was `v1.0.0-alpha.beta` The options are visible in the code at # Download binary files from a mirror S3 is broken in China for the well known reason. Using the `npm` config argument: `--{module_name}_binary_host_mirror` can download binary files through a mirror. e.g.: Install [v8-profiler](https://www.npmjs.com/package/v8-profiler) from `npm`. ```bash $ npm install v8-profiler --profiler_binary_host_mirror=https://npm.taobao.org/mirrors/node-inspector/ ``` node-pre-gyp-0.10.2/appveyor.yml000066400000000000000000000015121331361613700164730ustar00rootroot00000000000000os: Visual Studio 2015 environment: matrix: - nodejs_version: 6 - nodejs_version: 8 - nodejs_version: 9 - nodejs_version: 10 platform: - x64 - x86 shallow_clone: true install: - ps: Install-Product node $env:nodejs_version $env:Platform - ps: Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force - npm config get - node --version - npm --version - node -e "console.log(process.arch);" - IF /I "%PLATFORM%" == "x64" set PATH=C:\Python27-x64;%PATH% - IF /I "%PLATFORM%" == "x86" SET PATH=C:\python27;%PATH% - IF /I "%PLATFORM%" == "x64" CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 - IF /I "%PLATFORM%" == "x86" CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 - npm install - npm test build: off test: off deploy: off node-pre-gyp-0.10.2/bin/000077500000000000000000000000001331361613700146545ustar00rootroot00000000000000node-pre-gyp-0.10.2/bin/node-pre-gyp000077500000000000000000000063011331361613700171100ustar00rootroot00000000000000#!/usr/bin/env node "use strict"; /** * Set the title. */ process.title = 'node-pre-gyp'; /** * Module dependencies. */ var node_pre_gyp = require('../'); var log = require('npmlog'); /** * Process and execute the selected commands. */ var prog = new node_pre_gyp.Run(); var completed = false; prog.parseArgv(process.argv); if (prog.todo.length === 0) { if (~process.argv.indexOf('-v') || ~process.argv.indexOf('--version')) { console.log('v%s', prog.version); return process.exit(0); } else if (~process.argv.indexOf('-h') || ~process.argv.indexOf('--help')) { console.log('%s', prog.usage()); return process.exit(0); } console.log('%s', prog.usage()); return process.exit(1); } // if --no-color is passed if (prog.opts && prog.opts.hasOwnProperty('color') && !prog.opts.color) { log.disableColor(); } log.info('it worked if it ends with', 'ok'); log.verbose('cli', process.argv); log.info('using', process.title + '@%s', prog.version); log.info('using', 'node@%s | %s | %s', process.versions.node, process.platform, process.arch); /** * Change dir if -C/--directory was passed. */ var dir = prog.opts.directory; if (dir) { var fs = require('fs'); try { var stat = fs.statSync(dir); if (stat.isDirectory()) { log.info('chdir', dir); process.chdir(dir); } else { log.warn('chdir', dir + ' is not a directory'); } } catch (e) { if (e.code === 'ENOENT') { log.warn('chdir', dir + ' is not a directory'); } else { log.warn('chdir', 'error during chdir() "%s"', e.message); } } } function run () { var command = prog.todo.shift(); if (!command) { // done! completed = true; log.info('ok'); return; } prog.commands[command.name](command.args, function (err) { if (err) { log.error(command.name + ' error'); log.error('stack', err.stack); errorMessage(); log.error('not ok'); console.log(err.message); return process.exit(1); } var args_array = [].slice.call(arguments, 1); if (args_array.length) { console.log.apply(console, args_array); } // now run the next command in the queue process.nextTick(run); }); } process.on('exit', function (code) { if (!completed && !code) { log.error('Completion callback never invoked!'); issueMessage(); process.exit(6); } }); process.on('uncaughtException', function (err) { log.error('UNCAUGHT EXCEPTION'); log.error('stack', err.stack); issueMessage(); process.exit(7); }); function errorMessage () { // copied from npm's lib/util/error-handler.js var os = require('os'); log.error('System', os.type() + ' ' + os.release()); log.error('command', process.argv.map(JSON.stringify).join(' ')); log.error('cwd', process.cwd()); log.error('node -v', process.version); log.error(process.title+' -v', 'v' + prog.package.version); } function issueMessage () { errorMessage(); log.error('', [ 'This is a bug in `'+process.title+'`.', 'Try to update '+process.title+' and file an issue if it does not help:', ' ', ].join('\n')); } // start running the given commands! run(); node-pre-gyp-0.10.2/bin/node-pre-gyp.cmd000066400000000000000000000000501331361613700176420ustar00rootroot00000000000000@echo off node "%~dp0\node-pre-gyp" %* node-pre-gyp-0.10.2/contributing.md000066400000000000000000000004401331361613700171330ustar00rootroot00000000000000# Contributing ### Releasing a new version: - Ensure tests are passing on travis and appveyor - Run `node scripts/abi_crosswalk.js` and commit any changes - Update the changelog - Tag a new release like: `git tag -a v0.6.34 -m "tagging v0.6.34" && git push --tags` - Run `npm publish` node-pre-gyp-0.10.2/lib/000077500000000000000000000000001331361613700146525ustar00rootroot00000000000000node-pre-gyp-0.10.2/lib/build.js000066400000000000000000000035751331361613700163210ustar00rootroot00000000000000"use strict"; module.exports = exports = build; exports.usage = 'Attempts to compile the module by dispatching to node-gyp or nw-gyp'; var napi = require('./util/napi.js'); var compile = require('./util/compile.js'); var handle_gyp_opts = require('./util/handle_gyp_opts.js'); var configure = require('./configure.js'); function do_build(gyp,argv,callback) { handle_gyp_opts(gyp,argv,function(err,result) { var final_args = ['build'].concat(result.gyp).concat(result.pre); if (result.unparsed.length > 0) { final_args = final_args. concat(['--']). concat(result.unparsed); } if (!err && result.opts.napi_build_version) { napi.swap_build_dir_in(result.opts.napi_build_version); } compile.run_gyp(final_args,result.opts,function(err) { if (!err && result.opts.napi_build_version) { napi.swap_build_dir_out(result.opts.napi_build_version); } return callback(err); }); }); } function build(gyp, argv, callback) { // Form up commands to pass to node-gyp: // We map `node-pre-gyp build` to `node-gyp configure build` so that we do not // trigger a clean and therefore do not pay the penalty of a full recompile if (argv.length && (argv.indexOf('rebuild') > -1)) { argv.shift(); // remove `rebuild` // here we map `node-pre-gyp rebuild` to `node-gyp rebuild` which internally means // "clean + configure + build" and triggers a full recompile compile.run_gyp(['clean'],{},function(err) { if (err) return callback(err); configure(gyp,argv,function(err) { if (err) return callback(err); return do_build(gyp,argv,callback); }); }); } else { return do_build(gyp,argv,callback); } } node-pre-gyp-0.10.2/lib/clean.js000066400000000000000000000023251331361613700162740ustar00rootroot00000000000000"use strict"; module.exports = exports = clean; exports.usage = 'Removes the entire folder containing the compiled .node module'; var fs = require('fs'); var rm = require('rimraf'); var exists = require('fs').exists || require('path').exists; var versioning = require('./util/versioning.js'); var napi = require('./util/napi.js'); var path = require('path'); function clean (gyp, argv, callback) { var package_json = JSON.parse(fs.readFileSync('./package.json')); var napi_build_version = napi.get_napi_build_version_from_command_args(argv); var opts = versioning.evaluate(package_json, gyp.opts, napi_build_version); var to_delete = opts.module_path; if (!to_delete) { return callback(new Error("module_path is empty, refusing to delete")); } else if (path.normalize(to_delete) == path.normalize(process.cwd())) { return callback(new Error("module_path is not set, refusing to delete")); } else { exists(to_delete, function(found) { if (found) { if (!gyp.opts.silent_clean) console.log('['+package_json.name+'] Removing "%s"', to_delete); return rm(to_delete, callback); } return callback(); }); } } node-pre-gyp-0.10.2/lib/configure.js000066400000000000000000000041651331361613700171770ustar00rootroot00000000000000"use strict"; module.exports = exports = configure; exports.usage = 'Attempts to configure node-gyp or nw-gyp build'; var napi = require('./util/napi.js'); var compile = require('./util/compile.js'); var handle_gyp_opts = require('./util/handle_gyp_opts.js'); function configure(gyp, argv, callback) { handle_gyp_opts(gyp,argv,function(err,result) { var final_args = result.gyp.concat(result.pre); // pull select node-gyp configure options out of the npm environ var known_gyp_args = ['dist-url','python','nodedir','msvs_version']; known_gyp_args.forEach(function(key) { var val = gyp.opts[key] || gyp.opts[key.replace('-','_')]; if (val) { final_args.push('--'+key+'='+val); } }); // --ensure=false tell node-gyp to re-install node development headers // but it is only respected by node-gyp install, so we have to call install // as a separate step if the user passes it if (gyp.opts.ensure === false) { var install_args = final_args.concat(['install','--ensure=false']); compile.run_gyp(install_args,result.opts,function(err) { if (err) return callback(err); if (result.unparsed.length > 0) { final_args = final_args. concat(['--']). concat(result.unparsed); } compile.run_gyp(['configure'].concat(final_args),result.opts,function(err) { return callback(err); }); }); } else { if (result.unparsed.length > 0) { final_args = final_args. concat(['--']). concat(result.unparsed); } compile.run_gyp(['configure'].concat(final_args),result.opts,function(err) { if (!err && result.opts.napi_build_version) { napi.swap_build_dir_out(result.opts.napi_build_version); } return callback(err); }); } }); } node-pre-gyp-0.10.2/lib/info.js000066400000000000000000000027411331361613700161470ustar00rootroot00000000000000"use strict"; module.exports = exports = unpublish; exports.usage = 'Lists all published binaries (requires aws-sdk)'; var fs = require('fs'); var log = require('npmlog'); var versioning = require('./util/versioning.js'); var s3_setup = require('./util/s3_setup.js'); var config = require('rc')("node_pre_gyp",{acl:"public-read"}); function unpublish(gyp, argv, callback) { var AWS = require("aws-sdk"); var package_json = JSON.parse(fs.readFileSync('./package.json')); var opts = versioning.evaluate(package_json, gyp.opts); s3_setup.detect(opts.hosted_path,config); AWS.config.update(config); var s3 = new AWS.S3(); var s3_opts = { Bucket: config.bucket, Prefix: config.prefix }; s3.listObjects(s3_opts, function(err, meta){ if (err && err.code == 'NotFound') { return callback(new Error('['+package_json.name+'] Not found: https://' + s3_opts.Bucket + '.s3.amazonaws.com/'+config.prefix)); } else if(err) { return callback(err); } else { log.verbose(JSON.stringify(meta,null,1)); if (meta && meta.Contents) { meta.Contents.forEach(function(obj) { console.log(obj.Key); }); } else { console.error('['+package_json.name+'] No objects found at https://' + s3_opts.Bucket + '.s3.amazonaws.com/'+config.prefix ); } return callback(); } }); } node-pre-gyp-0.10.2/lib/install.js000066400000000000000000000205051331361613700166600ustar00rootroot00000000000000"use strict"; module.exports = exports = install; exports.usage = 'Attempts to install pre-built binary for module'; var fs = require('fs'); var path = require('path'); var log = require('npmlog'); var existsAsync = fs.exists || path.exists; var versioning = require('./util/versioning.js'); var napi = require('./util/napi.js'); var mkdirp = require('mkdirp'); var npgVersion = 'unknown'; try { // Read own package.json to get the current node-pre-pyp version. var ownPackageJSON = fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'); npgVersion = JSON.parse(ownPackageJSON).version; } catch (e) {} function download(uri,opts,callback) { log.http('GET', uri); var req = null; // Try getting version info from the currently running npm. var envVersionInfo = process.env.npm_config_user_agent || 'node ' + process.version; var requestOpts = { uri: uri.replace('+','%2B'), headers: { 'User-Agent': 'node-pre-gyp (v' + npgVersion + ', ' + envVersionInfo + ')' }, follow_max: 10, }; if (opts.cafile) { try { requestOpts.ca = fs.readFileSync(opts.cafile); } catch (e) { return callback(e); } } else if (opts.ca) { requestOpts.ca = opts.ca; } var proxyUrl = opts.proxy || process.env.http_proxy || process.env.HTTP_PROXY || process.env.npm_config_proxy; if (proxyUrl) { if (/^https?:\/\//i.test(proxyUrl)) { log.verbose('download', 'using proxy url: "%s"', proxyUrl); requestOpts.proxy = proxyUrl; } else { log.warn('download', 'ignoring invalid "proxy" config setting: "%s"', proxyUrl); } } try { req = require('needle').get(requestOpts.uri, requestOpts); } catch (e) { return callback(e); } if (req) { req.on('response', function (res) { log.http(res.statusCode, uri); }); } return callback(null,req); } function place_binary(from,to,opts,callback) { download(from,opts,function(err,req) { if (err) return callback(err); if (!req) return callback(new Error("empty req")); var badDownload = false; var extractCount = 0; var tar = require('tar'); function afterTarball(err) { if (err) return callback(err); if (badDownload) return callback(new Error("bad download")); if (extractCount === 0) { return callback(new Error('There was a fatal problem while downloading/extracting the tarball')); } log.info('tarball', 'done parsing tarball'); callback(); } function filter_func(entry) { log.info('install','unpacking ' + entry.path); extractCount++; } req.on('err', function(err) { badDownload = true; return callback(err); }); req.on('close', function () { if (extractCount === 0) { return callback(new Error('Connection closed while downloading tarball file')); } }); req.on('response', function(res) { // ignore redirects, needle handles these automatically. if (res.headers.hasOwnProperty('location') && res.headers.location !== '') { return; } if (res.statusCode !== 200) { badDownload = true; var err = new Error(res.statusCode + ' status code downloading tarball ' + from); err.statusCode = res.statusCode; return callback(err); } // start unzipping and untaring req.pipe(tar.extract({ cwd: to, strip: 1, onentry: filter_func }).on('close', afterTarball).on('error', callback)); }); }); } function do_build(gyp,argv,callback) { var args = ['rebuild'].concat(argv); gyp.todo.push( { name: 'build', args: args } ); process.nextTick(callback); } function print_fallback_error(err,opts,package_json) { var fallback_message = ' (falling back to source compile with node-gyp)'; var full_message = ''; if (err.statusCode !== undefined) { // If we got a network response it but failed to download // it means remote binaries are not available, so let's try to help // the user/developer with the info to debug why full_message = "Pre-built binaries not found for " + package_json.name + "@" + package_json.version; full_message += " and " + opts.runtime + "@" + (opts.target || process.versions.node) + " (" + opts.node_abi + " ABI, " + opts.libc + ")"; full_message += fallback_message; log.warn("Tried to download(" + err.statusCode + "): " + opts.hosted_tarball); log.warn(full_message); log.http(err.message); } else { // If we do not have a statusCode that means an unexpected error // happened and prevented an http response, so we output the exact error full_message = "Pre-built binaries not installable for " + package_json.name + "@" + package_json.version; full_message += " and " + opts.runtime + "@" + (opts.target || process.versions.node) + " (" + opts.node_abi + " ABI, " + opts.libc + ")"; full_message += fallback_message; log.warn(full_message); log.warn("Hit error " + err.message); } } function install(gyp, argv, callback) { var package_json = JSON.parse(fs.readFileSync('./package.json')); var napi_build_version = napi.get_napi_build_version_from_command_args(argv); var source_build = gyp.opts['build-from-source'] || gyp.opts.build_from_source; var update_binary = gyp.opts['update-binary'] || gyp.opts.update_binary; var should_do_source_build = source_build === package_json.name || (source_build === true || source_build === 'true'); if (should_do_source_build) { log.info('build','requesting source compile'); return do_build(gyp,argv,callback); } else { var fallback_to_build = gyp.opts['fallback-to-build'] || gyp.opts.fallback_to_build; var should_do_fallback_build = fallback_to_build === package_json.name || (fallback_to_build === true || fallback_to_build === 'true'); // but allow override from npm if (process.env.npm_config_argv) { var cooked = JSON.parse(process.env.npm_config_argv).cooked; var match = cooked.indexOf("--fallback-to-build"); if (match > -1 && cooked.length > match && cooked[match+1] == "false") { should_do_fallback_build = false; log.info('install','Build fallback disabled via npm flag: --fallback-to-build=false'); } } var opts; try { opts = versioning.evaluate(package_json, gyp.opts, napi_build_version); } catch (err) { return callback(err); } opts.ca = gyp.opts.ca; opts.cafile = gyp.opts.cafile; var from = opts.hosted_tarball; var to = opts.module_path; var binary_module = path.join(to,opts.module_name + '.node'); existsAsync(binary_module,function(found) { if (found && !update_binary) { console.log('['+package_json.name+'] Success: "' + binary_module + '" already installed'); console.log('Pass --update-binary to reinstall or --build-from-source to recompile'); return callback(); } else { if (!update_binary) log.info('check','checked for "' + binary_module + '" (not found)'); mkdirp(to,function(err) { if (err) { after_place(err); } else { place_binary(from,to,opts,after_place); } }); } function after_place(err) { if (err && should_do_fallback_build) { print_fallback_error(err,opts,package_json); return do_build(gyp,argv,callback); } else if (err) { return callback(err); } else { console.log('['+package_json.name+'] Success: "' + binary_module + '" is installed via remote'); return callback(); } } }); } } node-pre-gyp-0.10.2/lib/node-pre-gyp.js000066400000000000000000000111241331361613700175150ustar00rootroot00000000000000"use strict"; /** * Module exports. */ module.exports = exports; /** * Module dependencies. */ var fs = require('fs'); var path = require('path'); var nopt = require('nopt'); var log = require('npmlog'); log.disableProgress(); var napi = require('./util/napi.js'); var EE = require('events').EventEmitter; var inherits = require('util').inherits; var commands = [ 'clean', 'install', 'reinstall', 'build', 'rebuild', 'package', 'testpackage', 'publish', 'unpublish', 'info', 'testbinary', 'reveal', 'configure' ]; var aliases = {}; // differentiate node-pre-gyp's logs from npm's log.heading = 'node-pre-gyp'; exports.find = require('./pre-binding').find; function Run() { var self = this; this.commands = {}; commands.forEach(function (command) { self.commands[command] = function (argv, callback) { log.verbose('command', command, argv); return require('./' + command)(self, argv, callback); }; }); } inherits(Run, EE); exports.Run = Run; var proto = Run.prototype; /** * Export the contents of the package.json. */ proto.package = require('../package.json'); /** * nopt configuration definitions */ proto.configDefs = { help: Boolean, // everywhere arch: String, // 'configure' debug: Boolean, // 'build' directory: String, // bin proxy: String, // 'install' loglevel: String, // everywhere }; /** * nopt shorthands */ proto.shorthands = { release: '--no-debug', C: '--directory', debug: '--debug', j: '--jobs', silent: '--loglevel=silent', silly: '--loglevel=silly', verbose: '--loglevel=verbose', }; /** * expose the command aliases for the bin file to use. */ proto.aliases = aliases; /** * Parses the given argv array and sets the 'opts', * 'argv' and 'command' properties. */ proto.parseArgv = function parseOpts (argv) { this.opts = nopt(this.configDefs, this.shorthands, argv); this.argv = this.opts.argv.remain.slice(); var commands = this.todo = []; // create a copy of the argv array with aliases mapped argv = this.argv.map(function (arg) { // is this an alias? if (arg in this.aliases) { arg = this.aliases[arg]; } return arg; }, this); // process the mapped args into "command" objects ("name" and "args" props) argv.slice().forEach(function (arg) { if (arg in this.commands) { var args = argv.splice(0, argv.indexOf(arg)); argv.shift(); if (commands.length > 0) { commands[commands.length - 1].args = args; } commands.push({ name: arg, args: [] }); } }, this); if (commands.length > 0) { commands[commands.length - 1].args = argv.splice(0); } // expand commands entries for multiple napi builds var dir = this.opts.directory; if (dir == null) dir = process.cwd(); var package_json = JSON.parse(fs.readFileSync(path.join(dir,'package.json'))); this.todo = napi.expand_commands (package_json, commands); // support for inheriting config env variables from npm var npm_config_prefix = 'npm_config_'; Object.keys(process.env).forEach(function (name) { if (name.indexOf(npm_config_prefix) !== 0) return; var val = process.env[name]; if (name === npm_config_prefix + 'loglevel') { log.level = val; } else { // add the user-defined options to the config name = name.substring(npm_config_prefix.length); // avoid npm argv clobber already present args // which avoids problem of 'npm test' calling // script that runs unique npm install commands if (name === 'argv') { if (this.opts.argv && this.opts.argv.remain && this.opts.argv.remain.length) { // do nothing } else { this.opts[name] = val; } } else { this.opts[name] = val; } } }, this); if (this.opts.loglevel) { log.level = this.opts.loglevel; } log.resume(); }; /** * Returns the usage instructions for node-pre-gyp. */ proto.usage = function usage () { var str = [ '', ' Usage: node-pre-gyp [options]', '', ' where is one of:', commands.map(function (c) { return ' - ' + c + ' - ' + require('./' + c).usage; }).join('\n'), '', 'node-pre-gyp@' + this.version + ' ' + path.resolve(__dirname, '..'), 'node@' + process.versions.node ].join('\n'); return str; }; /** * Version number getter. */ Object.defineProperty(proto, 'version', { get: function () { return this.package.version; }, enumerable: true }); node-pre-gyp-0.10.2/lib/package.js000066400000000000000000000042731331361613700166110ustar00rootroot00000000000000"use strict"; module.exports = exports = _package; exports.usage = 'Packs binary (and enclosing directory) into locally staged tarball'; var fs = require('fs'); var path = require('path'); var log = require('npmlog'); var versioning = require('./util/versioning.js'); var napi = require('./util/napi.js'); var write = require('fs').createWriteStream; var existsAsync = fs.exists || path.exists; var mkdirp = require('mkdirp'); var tar = require('tar'); function _package(gyp, argv, callback) { var packlist = require('npm-packlist'); var package_json = JSON.parse(fs.readFileSync('./package.json')); var napi_build_version = napi.get_napi_build_version_from_command_args(argv); var opts = versioning.evaluate(package_json, gyp.opts, napi_build_version); var from = opts.module_path; var binary_module = path.join(from,opts.module_name + '.node'); existsAsync(binary_module,function(found) { if (!found) { return callback(new Error("Cannot package because " + binary_module + " missing: run `node-pre-gyp rebuild` first")); } var tarball = opts.staged_tarball; var filter_func = function(entry) { // ensure directories are +x // https://github.com/mapnik/node-mapnik/issues/262 log.info('package','packing ' + entry.path); return true; }; mkdirp(path.dirname(tarball),function(err) { if (err) return callback(err); packlist({ path: from }).then(function(files) { var base = path.basename(from); files = files.map(function(file) { return path.join(base, file); }); tar.create({ portable: true, gzip: true, onentry: filter_func, file: tarball, cwd: path.dirname(from) }, files, function(err) { if (err) console.error('['+package_json.name+'] ' + err.message); else log.info('package','Binary staged at "' + tarball + '"'); return callback(err); }); }, callback); }); }); } node-pre-gyp-0.10.2/lib/pre-binding.js000066400000000000000000000020311331361613700174020ustar00rootroot00000000000000"use strict"; var versioning = require('../lib/util/versioning.js'); var napi = require('../lib/util/napi.js'); var existsSync = require('fs').existsSync || require('path').existsSync; var path = require('path'); module.exports = exports; exports.usage = 'Finds the require path for the node-pre-gyp installed module'; exports.validate = function(package_json) { versioning.validate_config(package_json); }; exports.find = function(package_json_path,opts) { if (!existsSync(package_json_path)) { throw new Error("package.json does not exist at " + package_json_path); } var package_json = require(package_json_path); versioning.validate_config(package_json); var napi_build_version; if (napi.get_napi_build_versions (package_json)) { napi_build_version = napi.get_best_napi_build_version(package_json); } opts = opts || {}; if (!opts.module_root) opts.module_root = path.dirname(package_json_path); var meta = versioning.evaluate(package_json,opts,napi_build_version); return meta.module; }; node-pre-gyp-0.10.2/lib/publish.js000066400000000000000000000073241331361613700166640ustar00rootroot00000000000000"use strict"; module.exports = exports = publish; exports.usage = 'Publishes pre-built binary (requires aws-sdk)'; var fs = require('fs'); var path = require('path'); var log = require('npmlog'); var versioning = require('./util/versioning.js'); var napi = require('./util/napi.js'); var s3_setup = require('./util/s3_setup.js'); var existsAsync = fs.exists || path.exists; var url = require('url'); var config = require('rc')("node_pre_gyp",{acl:"public-read"}); function publish(gyp, argv, callback) { var AWS = require("aws-sdk"); var package_json = JSON.parse(fs.readFileSync('./package.json')); var napi_build_version = napi.get_napi_build_version_from_command_args(argv); var opts = versioning.evaluate(package_json, gyp.opts, napi_build_version); var tarball = opts.staged_tarball; existsAsync(tarball,function(found) { if (!found) { return callback(new Error("Cannot publish because " + tarball + " missing: run `node-pre-gyp package` first")); } log.info('publish', 'Detecting s3 credentials'); s3_setup.detect(opts.hosted_path,config); var key_name = url.resolve(config.prefix,opts.package_name); log.info('publish', 'Authenticating with s3'); AWS.config.update(config); var s3 = new AWS.S3(); var s3_opts = { Bucket: config.bucket, Key: key_name }; var remote_package = 'https://' + s3_opts.Bucket + '.s3.amazonaws.com/' + s3_opts.Key; log.info('publish', 'Checking for existing binary at ' + remote_package); s3.headObject(s3_opts, function(err, meta){ if (meta) log.info('publish', JSON.stringify(meta)); if (err && err.code == 'NotFound') { // we are safe to publish because // the object does not already exist log.info('publish', 'Preparing to put object'); var s3_put = new AWS.S3(); var s3_put_opts = { ACL: config.acl, Body: fs.createReadStream(tarball), Bucket: config.bucket, Key: key_name }; log.info('publish', 'Putting object'); try { s3_put.putObject(s3_put_opts, function(err, resp){ log.info('publish', 'returned from putting object'); if(err) { log.info('publish', 's3 putObject error: "' + err + '"'); return callback(err); } if (resp) log.info('publish', 's3 putObject response: "' + JSON.stringify(resp) + '"'); log.info('publish', 'successfully put object'); console.log('['+package_json.name+'] published to ' + remote_package); return callback(); }); } catch (err) { log.info('publish', 's3 putObject error: "' + err + '"'); return callback(err); } } else if (err) { log.info('publish', 's3 headObject error: "' + err + '"'); return callback(err); } else { log.error('publish','Cannot publish over existing version'); log.error('publish',"Update the 'version' field in package.json and try again"); log.error('publish','If the previous version was published in error see:'); log.error('publish','\t node-pre-gyp unpublish'); return callback(new Error('Failed publishing to ' + remote_package)); } }); }); } node-pre-gyp-0.10.2/lib/rebuild.js000066400000000000000000000010551331361613700166370ustar00rootroot00000000000000"use strict"; module.exports = exports = rebuild; exports.usage = 'Runs "clean" and "build" at once'; var fs = require('fs'); var napi = require('./util/napi.js'); function rebuild (gyp, argv, callback) { var package_json = JSON.parse(fs.readFileSync('./package.json')); var commands = [ { name: 'clean', args: [] }, { name: 'build', args: ['rebuild'] } ]; commands = napi.expand_commands(package_json, commands); for (var i = commands.length; i !== 0; i--) { gyp.todo.unshift(commands[i-1]); } process.nextTick(callback); } node-pre-gyp-0.10.2/lib/reinstall.js000066400000000000000000000011421331361613700172030ustar00rootroot00000000000000"use strict"; module.exports = exports = rebuild; exports.usage = 'Runs "clean" and "install" at once'; var fs = require('fs'); var napi = require('./util/napi.js'); function rebuild (gyp, argv, callback) { var package_json = JSON.parse(fs.readFileSync('./package.json')); var installArgs = []; var napi_build_version = napi.get_best_napi_build_version(package_json); if (napi_build_version != null) installArgs = [ napi.get_command_arg (napi_build_version) ]; gyp.todo.unshift( { name: 'clean', args: [] }, { name: 'install', args: installArgs } ); process.nextTick(callback); } node-pre-gyp-0.10.2/lib/reveal.js000066400000000000000000000020751331361613700164720ustar00rootroot00000000000000"use strict"; module.exports = exports = reveal; exports.usage = 'Reveals data on the versioned binary'; var fs = require('fs'); var versioning = require('./util/versioning.js'); var napi = require('./util/napi.js'); function unix_paths(key, val) { return val && val.replace ? val.replace(/\\/g, '/') : val; } function reveal(gyp, argv, callback) { var package_json = JSON.parse(fs.readFileSync('./package.json')); var napi_build_version = napi.get_napi_build_version_from_command_args(argv); var opts = versioning.evaluate(package_json, gyp.opts, napi_build_version); var hit = false; // if a second arg is passed look to see // if it is a known option //console.log(JSON.stringify(gyp.opts,null,1)) var remain = gyp.opts.argv.remain[gyp.opts.argv.remain.length-1]; if (remain && opts.hasOwnProperty(remain)) { console.log(opts[remain].replace(/\\/g, '/')); hit = true; } // otherwise return all options as json if (!hit) { console.log(JSON.stringify(opts,unix_paths,2)); } return callback(); } node-pre-gyp-0.10.2/lib/testbinary.js000066400000000000000000000062141331361613700173770ustar00rootroot00000000000000"use strict"; module.exports = exports = testbinary; exports.usage = 'Tests that the binary.node can be required'; var fs = require('fs'); var path = require('path'); var log = require('npmlog'); var cp = require('child_process'); var versioning = require('./util/versioning.js'); var napi = require('./util/napi.js'); var path = require('path'); function testbinary(gyp, argv, callback) { var args = []; var options = {}; var shell_cmd = process.execPath; var package_json = JSON.parse(fs.readFileSync('./package.json')); var napi_build_version = napi.get_napi_build_version_from_command_args(argv); var opts = versioning.evaluate(package_json, gyp.opts, napi_build_version); // skip validation for runtimes we don't explicitly support (like electron) if (opts.runtime && opts.runtime !== 'node-webkit' && opts.runtime !== 'node') { return callback(); } var nw = (opts.runtime && opts.runtime === 'node-webkit'); // ensure on windows that / are used for require path var binary_module = opts.module.replace(/\\/g, '/'); if ((process.arch != opts.target_arch) || (process.platform != opts.target_platform)) { var msg = "skipping validation since host platform/arch ("; msg += process.platform+'/'+process.arch+")"; msg += " does not match target ("; msg += opts.target_platform+'/'+opts.target_arch+")"; log.info('validate', msg); return callback(); } if (nw) { options.timeout = 5000; if (process.platform === 'darwin') { shell_cmd = 'node-webkit'; } else if (process.platform === 'win32') { shell_cmd = 'nw.exe'; } else { shell_cmd = 'nw'; } var modulePath = path.resolve(binary_module); var appDir = path.join(__dirname, 'util', 'nw-pre-gyp'); args.push(appDir); args.push(modulePath); log.info("validate","Running test command: '" + shell_cmd + ' ' + args.join(' ') + "'"); cp.execFile(shell_cmd, args, options, function(err, stdout, stderr) { // check for normal timeout for node-webkit if (err) { if (err.killed === true && err.signal && err.signal.indexOf('SIG') > -1) { return callback(); } var stderrLog = stderr.toString(); log.info('stderr', stderrLog); if( /^\s*Xlib:\s*extension\s*"RANDR"\s*missing\s*on\s*display\s*":\d+\.\d+"\.\s*$/.test(stderrLog) ){ log.info('RANDR', 'stderr contains only RANDR error, ignored'); return callback(); } return callback(err); } return callback(); }); return; } args.push('--eval'); args.push("require('" + binary_module.replace(/'/g, '\'') +"')"); log.info("validate","Running test command: '" + shell_cmd + ' ' + args.join(' ') + "'"); cp.execFile(shell_cmd, args, options, function(err, stdout, stderr) { if (err) { return callback(err, { stdout:stdout, stderr:stderr}); } return callback(); }); } node-pre-gyp-0.10.2/lib/testpackage.js000066400000000000000000000034241331361613700175060ustar00rootroot00000000000000"use strict"; module.exports = exports = testpackage; exports.usage = 'Tests that the staged package is valid'; var fs = require('fs'); var path = require('path'); var log = require('npmlog'); var existsAsync = fs.exists || path.exists; var versioning = require('./util/versioning.js'); var napi = require('./util/napi.js'); var testbinary = require('./testbinary.js'); var tar = require('tar'); var mkdirp = require('mkdirp'); function testpackage(gyp, argv, callback) { var package_json = JSON.parse(fs.readFileSync('./package.json')); var napi_build_version = napi.get_napi_build_version_from_command_args(argv); var opts = versioning.evaluate(package_json, gyp.opts, napi_build_version); var tarball = opts.staged_tarball; existsAsync(tarball, function(found) { if (!found) { return callback(new Error("Cannot test package because " + tarball + " missing: run `node-pre-gyp package` first")); } var to = opts.module_path; function filter_func(entry) { log.info('install','unpacking [' + entry.path + ']'); } mkdirp(to, function(err) { if (err) { return callback(err); } else { tar.extract({ file: tarball, cwd: to, strip: 1, onentry: filter_func }).then(after_extract, callback); } }); function after_extract() { testbinary(gyp,argv,function(err) { if (err) { return callback(err); } else { console.log('['+package_json.name+'] Package appears valid'); return callback(); } }); } }); } node-pre-gyp-0.10.2/lib/unpublish.js000066400000000000000000000032731331361613700172260ustar00rootroot00000000000000"use strict"; module.exports = exports = unpublish; exports.usage = 'Unpublishes pre-built binary (requires aws-sdk)'; var fs = require('fs'); var log = require('npmlog'); var versioning = require('./util/versioning.js'); var napi = require('./util/napi.js'); var s3_setup = require('./util/s3_setup.js'); var url = require('url'); var config = require('rc')("node_pre_gyp",{acl:"public-read"}); function unpublish(gyp, argv, callback) { var AWS = require("aws-sdk"); var package_json = JSON.parse(fs.readFileSync('./package.json')); var napi_build_version = napi.get_napi_build_version_from_command_args(argv); var opts = versioning.evaluate(package_json, gyp.opts, napi_build_version); s3_setup.detect(opts.hosted_path,config); AWS.config.update(config); var key_name = url.resolve(config.prefix,opts.package_name); var s3 = new AWS.S3(); var s3_opts = { Bucket: config.bucket, Key: key_name }; s3.headObject(s3_opts, function(err, meta) { if (err && err.code == 'NotFound') { console.log('['+package_json.name+'] Not found: https://' + s3_opts.Bucket + '.s3.amazonaws.com/' + s3_opts.Key); return callback(); } else if(err) { return callback(err); } else { log.info('unpublish', JSON.stringify(meta)); s3.deleteObject(s3_opts, function(err, resp) { if (err) return callback(err); log.info(JSON.stringify(resp)); console.log('['+package_json.name+'] Success: removed https://' + s3_opts.Bucket + '.s3.amazonaws.com/' + s3_opts.Key); return callback(); }); } }); } node-pre-gyp-0.10.2/lib/util/000077500000000000000000000000001331361613700156275ustar00rootroot00000000000000node-pre-gyp-0.10.2/lib/util/abi_crosswalk.json000066400000000000000000000574261331361613700213630ustar00rootroot00000000000000{ "0.1.14": { "node_abi": null, "v8": "1.3" }, "0.1.15": { "node_abi": null, "v8": "1.3" }, "0.1.16": { "node_abi": null, "v8": "1.3" }, "0.1.17": { "node_abi": null, "v8": "1.3" }, "0.1.18": { "node_abi": null, "v8": "1.3" }, "0.1.19": { "node_abi": null, "v8": "2.0" }, "0.1.20": { "node_abi": null, "v8": "2.0" }, "0.1.21": { "node_abi": null, "v8": "2.0" }, "0.1.22": { "node_abi": null, "v8": "2.0" }, "0.1.23": { "node_abi": null, "v8": "2.0" }, "0.1.24": { "node_abi": null, "v8": "2.0" }, "0.1.25": { "node_abi": null, "v8": "2.0" }, "0.1.26": { "node_abi": null, "v8": "2.0" }, "0.1.27": { "node_abi": null, "v8": "2.1" }, "0.1.28": { "node_abi": null, "v8": "2.1" }, "0.1.29": { "node_abi": null, "v8": "2.1" }, "0.1.30": { "node_abi": null, "v8": "2.1" }, "0.1.31": { "node_abi": null, "v8": "2.1" }, "0.1.32": { "node_abi": null, "v8": "2.1" }, "0.1.33": { "node_abi": null, "v8": "2.1" }, "0.1.90": { "node_abi": null, "v8": "2.2" }, "0.1.91": { "node_abi": null, "v8": "2.2" }, "0.1.92": { "node_abi": null, "v8": "2.2" }, "0.1.93": { "node_abi": null, "v8": "2.2" }, "0.1.94": { "node_abi": null, "v8": "2.2" }, "0.1.95": { "node_abi": null, "v8": "2.2" }, "0.1.96": { "node_abi": null, "v8": "2.2" }, "0.1.97": { "node_abi": null, "v8": "2.2" }, "0.1.98": { "node_abi": null, "v8": "2.2" }, "0.1.99": { "node_abi": null, "v8": "2.2" }, "0.1.100": { "node_abi": null, "v8": "2.2" }, "0.1.101": { "node_abi": null, "v8": "2.3" }, "0.1.102": { "node_abi": null, "v8": "2.3" }, "0.1.103": { "node_abi": null, "v8": "2.3" }, "0.1.104": { "node_abi": null, "v8": "2.3" }, "0.2.0": { "node_abi": 1, "v8": "2.3" }, "0.2.1": { "node_abi": 1, "v8": "2.3" }, "0.2.2": { "node_abi": 1, "v8": "2.3" }, "0.2.3": { "node_abi": 1, "v8": "2.3" }, "0.2.4": { "node_abi": 1, "v8": "2.3" }, "0.2.5": { "node_abi": 1, "v8": "2.3" }, "0.2.6": { "node_abi": 1, "v8": "2.3" }, "0.3.0": { "node_abi": 1, "v8": "2.5" }, "0.3.1": { "node_abi": 1, "v8": "2.5" }, "0.3.2": { "node_abi": 1, "v8": "3.0" }, "0.3.3": { "node_abi": 1, "v8": "3.0" }, "0.3.4": { "node_abi": 1, "v8": "3.0" }, "0.3.5": { "node_abi": 1, "v8": "3.0" }, "0.3.6": { "node_abi": 1, "v8": "3.0" }, "0.3.7": { "node_abi": 1, "v8": "3.0" }, "0.3.8": { "node_abi": 1, "v8": "3.1" }, "0.4.0": { "node_abi": 1, "v8": "3.1" }, "0.4.1": { "node_abi": 1, "v8": "3.1" }, "0.4.2": { "node_abi": 1, "v8": "3.1" }, "0.4.3": { "node_abi": 1, "v8": "3.1" }, "0.4.4": { "node_abi": 1, "v8": "3.1" }, "0.4.5": { "node_abi": 1, "v8": "3.1" }, "0.4.6": { "node_abi": 1, "v8": "3.1" }, "0.4.7": { "node_abi": 1, "v8": "3.1" }, "0.4.8": { "node_abi": 1, "v8": "3.1" }, "0.4.9": { "node_abi": 1, "v8": "3.1" }, "0.4.10": { "node_abi": 1, "v8": "3.1" }, "0.4.11": { "node_abi": 1, "v8": "3.1" }, "0.4.12": { "node_abi": 1, "v8": "3.1" }, "0.5.0": { "node_abi": 1, "v8": "3.1" }, "0.5.1": { "node_abi": 1, "v8": "3.4" }, "0.5.2": { "node_abi": 1, "v8": "3.4" }, "0.5.3": { "node_abi": 1, "v8": "3.4" }, "0.5.4": { "node_abi": 1, "v8": "3.5" }, "0.5.5": { "node_abi": 1, "v8": "3.5" }, "0.5.6": { "node_abi": 1, "v8": "3.6" }, "0.5.7": { "node_abi": 1, "v8": "3.6" }, "0.5.8": { "node_abi": 1, "v8": "3.6" }, "0.5.9": { "node_abi": 1, "v8": "3.6" }, "0.5.10": { "node_abi": 1, "v8": "3.7" }, "0.6.0": { "node_abi": 1, "v8": "3.6" }, "0.6.1": { "node_abi": 1, "v8": "3.6" }, "0.6.2": { "node_abi": 1, "v8": "3.6" }, "0.6.3": { "node_abi": 1, "v8": "3.6" }, "0.6.4": { "node_abi": 1, "v8": "3.6" }, "0.6.5": { "node_abi": 1, "v8": "3.6" }, "0.6.6": { "node_abi": 1, "v8": "3.6" }, "0.6.7": { "node_abi": 1, "v8": "3.6" }, "0.6.8": { "node_abi": 1, "v8": "3.6" }, "0.6.9": { "node_abi": 1, "v8": "3.6" }, "0.6.10": { "node_abi": 1, "v8": "3.6" }, "0.6.11": { "node_abi": 1, "v8": "3.6" }, "0.6.12": { "node_abi": 1, "v8": "3.6" }, "0.6.13": { "node_abi": 1, "v8": "3.6" }, "0.6.14": { "node_abi": 1, "v8": "3.6" }, "0.6.15": { "node_abi": 1, "v8": "3.6" }, "0.6.16": { "node_abi": 1, "v8": "3.6" }, "0.6.17": { "node_abi": 1, "v8": "3.6" }, "0.6.18": { "node_abi": 1, "v8": "3.6" }, "0.6.19": { "node_abi": 1, "v8": "3.6" }, "0.6.20": { "node_abi": 1, "v8": "3.6" }, "0.6.21": { "node_abi": 1, "v8": "3.6" }, "0.7.0": { "node_abi": 1, "v8": "3.8" }, "0.7.1": { "node_abi": 1, "v8": "3.8" }, "0.7.2": { "node_abi": 1, "v8": "3.8" }, "0.7.3": { "node_abi": 1, "v8": "3.9" }, "0.7.4": { "node_abi": 1, "v8": "3.9" }, "0.7.5": { "node_abi": 1, "v8": "3.9" }, "0.7.6": { "node_abi": 1, "v8": "3.9" }, "0.7.7": { "node_abi": 1, "v8": "3.9" }, "0.7.8": { "node_abi": 1, "v8": "3.9" }, "0.7.9": { "node_abi": 1, "v8": "3.11" }, "0.7.10": { "node_abi": 1, "v8": "3.9" }, "0.7.11": { "node_abi": 1, "v8": "3.11" }, "0.7.12": { "node_abi": 1, "v8": "3.11" }, "0.8.0": { "node_abi": 1, "v8": "3.11" }, "0.8.1": { "node_abi": 1, "v8": "3.11" }, "0.8.2": { "node_abi": 1, "v8": "3.11" }, "0.8.3": { "node_abi": 1, "v8": "3.11" }, "0.8.4": { "node_abi": 1, "v8": "3.11" }, "0.8.5": { "node_abi": 1, "v8": "3.11" }, "0.8.6": { "node_abi": 1, "v8": "3.11" }, "0.8.7": { "node_abi": 1, "v8": "3.11" }, "0.8.8": { "node_abi": 1, "v8": "3.11" }, "0.8.9": { "node_abi": 1, "v8": "3.11" }, "0.8.10": { "node_abi": 1, "v8": "3.11" }, "0.8.11": { "node_abi": 1, "v8": "3.11" }, "0.8.12": { "node_abi": 1, "v8": "3.11" }, "0.8.13": { "node_abi": 1, "v8": "3.11" }, "0.8.14": { "node_abi": 1, "v8": "3.11" }, "0.8.15": { "node_abi": 1, "v8": "3.11" }, "0.8.16": { "node_abi": 1, "v8": "3.11" }, "0.8.17": { "node_abi": 1, "v8": "3.11" }, "0.8.18": { "node_abi": 1, "v8": "3.11" }, "0.8.19": { "node_abi": 1, "v8": "3.11" }, "0.8.20": { "node_abi": 1, "v8": "3.11" }, "0.8.21": { "node_abi": 1, "v8": "3.11" }, "0.8.22": { "node_abi": 1, "v8": "3.11" }, "0.8.23": { "node_abi": 1, "v8": "3.11" }, "0.8.24": { "node_abi": 1, "v8": "3.11" }, "0.8.25": { "node_abi": 1, "v8": "3.11" }, "0.8.26": { "node_abi": 1, "v8": "3.11" }, "0.8.27": { "node_abi": 1, "v8": "3.11" }, "0.8.28": { "node_abi": 1, "v8": "3.11" }, "0.9.0": { "node_abi": 1, "v8": "3.11" }, "0.9.1": { "node_abi": 10, "v8": "3.11" }, "0.9.2": { "node_abi": 10, "v8": "3.11" }, "0.9.3": { "node_abi": 10, "v8": "3.13" }, "0.9.4": { "node_abi": 10, "v8": "3.13" }, "0.9.5": { "node_abi": 10, "v8": "3.13" }, "0.9.6": { "node_abi": 10, "v8": "3.15" }, "0.9.7": { "node_abi": 10, "v8": "3.15" }, "0.9.8": { "node_abi": 10, "v8": "3.15" }, "0.9.9": { "node_abi": 11, "v8": "3.15" }, "0.9.10": { "node_abi": 11, "v8": "3.15" }, "0.9.11": { "node_abi": 11, "v8": "3.14" }, "0.9.12": { "node_abi": 11, "v8": "3.14" }, "0.10.0": { "node_abi": 11, "v8": "3.14" }, "0.10.1": { "node_abi": 11, "v8": "3.14" }, "0.10.2": { "node_abi": 11, "v8": "3.14" }, "0.10.3": { "node_abi": 11, "v8": "3.14" }, "0.10.4": { "node_abi": 11, "v8": "3.14" }, "0.10.5": { "node_abi": 11, "v8": "3.14" }, "0.10.6": { "node_abi": 11, "v8": "3.14" }, "0.10.7": { "node_abi": 11, "v8": "3.14" }, "0.10.8": { "node_abi": 11, "v8": "3.14" }, "0.10.9": { "node_abi": 11, "v8": "3.14" }, "0.10.10": { "node_abi": 11, "v8": "3.14" }, "0.10.11": { "node_abi": 11, "v8": "3.14" }, "0.10.12": { "node_abi": 11, "v8": "3.14" }, "0.10.13": { "node_abi": 11, "v8": "3.14" }, "0.10.14": { "node_abi": 11, "v8": "3.14" }, "0.10.15": { "node_abi": 11, "v8": "3.14" }, "0.10.16": { "node_abi": 11, "v8": "3.14" }, "0.10.17": { "node_abi": 11, "v8": "3.14" }, "0.10.18": { "node_abi": 11, "v8": "3.14" }, "0.10.19": { "node_abi": 11, "v8": "3.14" }, "0.10.20": { "node_abi": 11, "v8": "3.14" }, "0.10.21": { "node_abi": 11, "v8": "3.14" }, "0.10.22": { "node_abi": 11, "v8": "3.14" }, "0.10.23": { "node_abi": 11, "v8": "3.14" }, "0.10.24": { "node_abi": 11, "v8": "3.14" }, "0.10.25": { "node_abi": 11, "v8": "3.14" }, "0.10.26": { "node_abi": 11, "v8": "3.14" }, "0.10.27": { "node_abi": 11, "v8": "3.14" }, "0.10.28": { "node_abi": 11, "v8": "3.14" }, "0.10.29": { "node_abi": 11, "v8": "3.14" }, "0.10.30": { "node_abi": 11, "v8": "3.14" }, "0.10.31": { "node_abi": 11, "v8": "3.14" }, "0.10.32": { "node_abi": 11, "v8": "3.14" }, "0.10.33": { "node_abi": 11, "v8": "3.14" }, "0.10.34": { "node_abi": 11, "v8": "3.14" }, "0.10.35": { "node_abi": 11, "v8": "3.14" }, "0.10.36": { "node_abi": 11, "v8": "3.14" }, "0.10.37": { "node_abi": 11, "v8": "3.14" }, "0.10.38": { "node_abi": 11, "v8": "3.14" }, "0.10.39": { "node_abi": 11, "v8": "3.14" }, "0.10.40": { "node_abi": 11, "v8": "3.14" }, "0.10.41": { "node_abi": 11, "v8": "3.14" }, "0.10.42": { "node_abi": 11, "v8": "3.14" }, "0.10.43": { "node_abi": 11, "v8": "3.14" }, "0.10.44": { "node_abi": 11, "v8": "3.14" }, "0.10.45": { "node_abi": 11, "v8": "3.14" }, "0.10.46": { "node_abi": 11, "v8": "3.14" }, "0.10.47": { "node_abi": 11, "v8": "3.14" }, "0.10.48": { "node_abi": 11, "v8": "3.14" }, "0.11.0": { "node_abi": 12, "v8": "3.17" }, "0.11.1": { "node_abi": 12, "v8": "3.18" }, "0.11.2": { "node_abi": 12, "v8": "3.19" }, "0.11.3": { "node_abi": 12, "v8": "3.19" }, "0.11.4": { "node_abi": 12, "v8": "3.20" }, "0.11.5": { "node_abi": 12, "v8": "3.20" }, "0.11.6": { "node_abi": 12, "v8": "3.20" }, "0.11.7": { "node_abi": 12, "v8": "3.20" }, "0.11.8": { "node_abi": 13, "v8": "3.21" }, "0.11.9": { "node_abi": 13, "v8": "3.22" }, "0.11.10": { "node_abi": 13, "v8": "3.22" }, "0.11.11": { "node_abi": 14, "v8": "3.22" }, "0.11.12": { "node_abi": 14, "v8": "3.22" }, "0.11.13": { "node_abi": 14, "v8": "3.25" }, "0.11.14": { "node_abi": 14, "v8": "3.26" }, "0.11.15": { "node_abi": 14, "v8": "3.28" }, "0.11.16": { "node_abi": 14, "v8": "3.28" }, "0.12.0": { "node_abi": 14, "v8": "3.28" }, "0.12.1": { "node_abi": 14, "v8": "3.28" }, "0.12.2": { "node_abi": 14, "v8": "3.28" }, "0.12.3": { "node_abi": 14, "v8": "3.28" }, "0.12.4": { "node_abi": 14, "v8": "3.28" }, "0.12.5": { "node_abi": 14, "v8": "3.28" }, "0.12.6": { "node_abi": 14, "v8": "3.28" }, "0.12.7": { "node_abi": 14, "v8": "3.28" }, "0.12.8": { "node_abi": 14, "v8": "3.28" }, "0.12.9": { "node_abi": 14, "v8": "3.28" }, "0.12.10": { "node_abi": 14, "v8": "3.28" }, "0.12.11": { "node_abi": 14, "v8": "3.28" }, "0.12.12": { "node_abi": 14, "v8": "3.28" }, "0.12.13": { "node_abi": 14, "v8": "3.28" }, "0.12.14": { "node_abi": 14, "v8": "3.28" }, "0.12.15": { "node_abi": 14, "v8": "3.28" }, "0.12.16": { "node_abi": 14, "v8": "3.28" }, "0.12.17": { "node_abi": 14, "v8": "3.28" }, "0.12.18": { "node_abi": 14, "v8": "3.28" }, "1.0.0": { "node_abi": 42, "v8": "3.31" }, "1.0.1": { "node_abi": 42, "v8": "3.31" }, "1.0.2": { "node_abi": 42, "v8": "3.31" }, "1.0.3": { "node_abi": 42, "v8": "4.1" }, "1.0.4": { "node_abi": 42, "v8": "4.1" }, "1.1.0": { "node_abi": 43, "v8": "4.1" }, "1.2.0": { "node_abi": 43, "v8": "4.1" }, "1.3.0": { "node_abi": 43, "v8": "4.1" }, "1.4.1": { "node_abi": 43, "v8": "4.1" }, "1.4.2": { "node_abi": 43, "v8": "4.1" }, "1.4.3": { "node_abi": 43, "v8": "4.1" }, "1.5.0": { "node_abi": 43, "v8": "4.1" }, "1.5.1": { "node_abi": 43, "v8": "4.1" }, "1.6.0": { "node_abi": 43, "v8": "4.1" }, "1.6.1": { "node_abi": 43, "v8": "4.1" }, "1.6.2": { "node_abi": 43, "v8": "4.1" }, "1.6.3": { "node_abi": 43, "v8": "4.1" }, "1.6.4": { "node_abi": 43, "v8": "4.1" }, "1.7.1": { "node_abi": 43, "v8": "4.1" }, "1.8.1": { "node_abi": 43, "v8": "4.1" }, "1.8.2": { "node_abi": 43, "v8": "4.1" }, "1.8.3": { "node_abi": 43, "v8": "4.1" }, "1.8.4": { "node_abi": 43, "v8": "4.1" }, "2.0.0": { "node_abi": 44, "v8": "4.2" }, "2.0.1": { "node_abi": 44, "v8": "4.2" }, "2.0.2": { "node_abi": 44, "v8": "4.2" }, "2.1.0": { "node_abi": 44, "v8": "4.2" }, "2.2.0": { "node_abi": 44, "v8": "4.2" }, "2.2.1": { "node_abi": 44, "v8": "4.2" }, "2.3.0": { "node_abi": 44, "v8": "4.2" }, "2.3.1": { "node_abi": 44, "v8": "4.2" }, "2.3.2": { "node_abi": 44, "v8": "4.2" }, "2.3.3": { "node_abi": 44, "v8": "4.2" }, "2.3.4": { "node_abi": 44, "v8": "4.2" }, "2.4.0": { "node_abi": 44, "v8": "4.2" }, "2.5.0": { "node_abi": 44, "v8": "4.2" }, "3.0.0": { "node_abi": 45, "v8": "4.4" }, "3.1.0": { "node_abi": 45, "v8": "4.4" }, "3.2.0": { "node_abi": 45, "v8": "4.4" }, "3.3.0": { "node_abi": 45, "v8": "4.4" }, "3.3.1": { "node_abi": 45, "v8": "4.4" }, "4.0.0": { "node_abi": 46, "v8": "4.5" }, "4.1.0": { "node_abi": 46, "v8": "4.5" }, "4.1.1": { "node_abi": 46, "v8": "4.5" }, "4.1.2": { "node_abi": 46, "v8": "4.5" }, "4.2.0": { "node_abi": 46, "v8": "4.5" }, "4.2.1": { "node_abi": 46, "v8": "4.5" }, "4.2.2": { "node_abi": 46, "v8": "4.5" }, "4.2.3": { "node_abi": 46, "v8": "4.5" }, "4.2.4": { "node_abi": 46, "v8": "4.5" }, "4.2.5": { "node_abi": 46, "v8": "4.5" }, "4.2.6": { "node_abi": 46, "v8": "4.5" }, "4.3.0": { "node_abi": 46, "v8": "4.5" }, "4.3.1": { "node_abi": 46, "v8": "4.5" }, "4.3.2": { "node_abi": 46, "v8": "4.5" }, "4.4.0": { "node_abi": 46, "v8": "4.5" }, "4.4.1": { "node_abi": 46, "v8": "4.5" }, "4.4.2": { "node_abi": 46, "v8": "4.5" }, "4.4.3": { "node_abi": 46, "v8": "4.5" }, "4.4.4": { "node_abi": 46, "v8": "4.5" }, "4.4.5": { "node_abi": 46, "v8": "4.5" }, "4.4.6": { "node_abi": 46, "v8": "4.5" }, "4.4.7": { "node_abi": 46, "v8": "4.5" }, "4.5.0": { "node_abi": 46, "v8": "4.5" }, "4.6.0": { "node_abi": 46, "v8": "4.5" }, "4.6.1": { "node_abi": 46, "v8": "4.5" }, "4.6.2": { "node_abi": 46, "v8": "4.5" }, "4.7.0": { "node_abi": 46, "v8": "4.5" }, "4.7.1": { "node_abi": 46, "v8": "4.5" }, "4.7.2": { "node_abi": 46, "v8": "4.5" }, "4.7.3": { "node_abi": 46, "v8": "4.5" }, "4.8.0": { "node_abi": 46, "v8": "4.5" }, "4.8.1": { "node_abi": 46, "v8": "4.5" }, "4.8.2": { "node_abi": 46, "v8": "4.5" }, "4.8.3": { "node_abi": 46, "v8": "4.5" }, "4.8.4": { "node_abi": 46, "v8": "4.5" }, "4.8.5": { "node_abi": 46, "v8": "4.5" }, "4.8.6": { "node_abi": 46, "v8": "4.5" }, "4.8.7": { "node_abi": 46, "v8": "4.5" }, "4.9.0": { "node_abi": 46, "v8": "4.5" }, "4.9.1": { "node_abi": 46, "v8": "4.5" }, "5.0.0": { "node_abi": 47, "v8": "4.6" }, "5.1.0": { "node_abi": 47, "v8": "4.6" }, "5.1.1": { "node_abi": 47, "v8": "4.6" }, "5.2.0": { "node_abi": 47, "v8": "4.6" }, "5.3.0": { "node_abi": 47, "v8": "4.6" }, "5.4.0": { "node_abi": 47, "v8": "4.6" }, "5.4.1": { "node_abi": 47, "v8": "4.6" }, "5.5.0": { "node_abi": 47, "v8": "4.6" }, "5.6.0": { "node_abi": 47, "v8": "4.6" }, "5.7.0": { "node_abi": 47, "v8": "4.6" }, "5.7.1": { "node_abi": 47, "v8": "4.6" }, "5.8.0": { "node_abi": 47, "v8": "4.6" }, "5.9.0": { "node_abi": 47, "v8": "4.6" }, "5.9.1": { "node_abi": 47, "v8": "4.6" }, "5.10.0": { "node_abi": 47, "v8": "4.6" }, "5.10.1": { "node_abi": 47, "v8": "4.6" }, "5.11.0": { "node_abi": 47, "v8": "4.6" }, "5.11.1": { "node_abi": 47, "v8": "4.6" }, "5.12.0": { "node_abi": 47, "v8": "4.6" }, "6.0.0": { "node_abi": 48, "v8": "5.0" }, "6.1.0": { "node_abi": 48, "v8": "5.0" }, "6.2.0": { "node_abi": 48, "v8": "5.0" }, "6.2.1": { "node_abi": 48, "v8": "5.0" }, "6.2.2": { "node_abi": 48, "v8": "5.0" }, "6.3.0": { "node_abi": 48, "v8": "5.0" }, "6.3.1": { "node_abi": 48, "v8": "5.0" }, "6.4.0": { "node_abi": 48, "v8": "5.0" }, "6.5.0": { "node_abi": 48, "v8": "5.1" }, "6.6.0": { "node_abi": 48, "v8": "5.1" }, "6.7.0": { "node_abi": 48, "v8": "5.1" }, "6.8.0": { "node_abi": 48, "v8": "5.1" }, "6.8.1": { "node_abi": 48, "v8": "5.1" }, "6.9.0": { "node_abi": 48, "v8": "5.1" }, "6.9.1": { "node_abi": 48, "v8": "5.1" }, "6.9.2": { "node_abi": 48, "v8": "5.1" }, "6.9.3": { "node_abi": 48, "v8": "5.1" }, "6.9.4": { "node_abi": 48, "v8": "5.1" }, "6.9.5": { "node_abi": 48, "v8": "5.1" }, "6.10.0": { "node_abi": 48, "v8": "5.1" }, "6.10.1": { "node_abi": 48, "v8": "5.1" }, "6.10.2": { "node_abi": 48, "v8": "5.1" }, "6.10.3": { "node_abi": 48, "v8": "5.1" }, "6.11.0": { "node_abi": 48, "v8": "5.1" }, "6.11.1": { "node_abi": 48, "v8": "5.1" }, "6.11.2": { "node_abi": 48, "v8": "5.1" }, "6.11.3": { "node_abi": 48, "v8": "5.1" }, "6.11.4": { "node_abi": 48, "v8": "5.1" }, "6.11.5": { "node_abi": 48, "v8": "5.1" }, "6.12.0": { "node_abi": 48, "v8": "5.1" }, "6.12.1": { "node_abi": 48, "v8": "5.1" }, "6.12.2": { "node_abi": 48, "v8": "5.1" }, "6.12.3": { "node_abi": 48, "v8": "5.1" }, "6.13.0": { "node_abi": 48, "v8": "5.1" }, "6.13.1": { "node_abi": 48, "v8": "5.1" }, "6.14.0": { "node_abi": 48, "v8": "5.1" }, "6.14.1": { "node_abi": 48, "v8": "5.1" }, "6.14.2": { "node_abi": 48, "v8": "5.1" }, "6.14.3": { "node_abi": 48, "v8": "5.1" }, "7.0.0": { "node_abi": 51, "v8": "5.4" }, "7.1.0": { "node_abi": 51, "v8": "5.4" }, "7.2.0": { "node_abi": 51, "v8": "5.4" }, "7.2.1": { "node_abi": 51, "v8": "5.4" }, "7.3.0": { "node_abi": 51, "v8": "5.4" }, "7.4.0": { "node_abi": 51, "v8": "5.4" }, "7.5.0": { "node_abi": 51, "v8": "5.4" }, "7.6.0": { "node_abi": 51, "v8": "5.5" }, "7.7.0": { "node_abi": 51, "v8": "5.5" }, "7.7.1": { "node_abi": 51, "v8": "5.5" }, "7.7.2": { "node_abi": 51, "v8": "5.5" }, "7.7.3": { "node_abi": 51, "v8": "5.5" }, "7.7.4": { "node_abi": 51, "v8": "5.5" }, "7.8.0": { "node_abi": 51, "v8": "5.5" }, "7.9.0": { "node_abi": 51, "v8": "5.5" }, "7.10.0": { "node_abi": 51, "v8": "5.5" }, "7.10.1": { "node_abi": 51, "v8": "5.5" }, "8.0.0": { "node_abi": 57, "v8": "5.8" }, "8.1.0": { "node_abi": 57, "v8": "5.8" }, "8.1.1": { "node_abi": 57, "v8": "5.8" }, "8.1.2": { "node_abi": 57, "v8": "5.8" }, "8.1.3": { "node_abi": 57, "v8": "5.8" }, "8.1.4": { "node_abi": 57, "v8": "5.8" }, "8.2.0": { "node_abi": 57, "v8": "5.8" }, "8.2.1": { "node_abi": 57, "v8": "5.8" }, "8.3.0": { "node_abi": 57, "v8": "6.0" }, "8.4.0": { "node_abi": 57, "v8": "6.0" }, "8.5.0": { "node_abi": 57, "v8": "6.0" }, "8.6.0": { "node_abi": 57, "v8": "6.0" }, "8.7.0": { "node_abi": 57, "v8": "6.1" }, "8.8.0": { "node_abi": 57, "v8": "6.1" }, "8.8.1": { "node_abi": 57, "v8": "6.1" }, "8.9.0": { "node_abi": 57, "v8": "6.1" }, "8.9.1": { "node_abi": 57, "v8": "6.1" }, "8.9.2": { "node_abi": 57, "v8": "6.1" }, "8.9.3": { "node_abi": 57, "v8": "6.1" }, "8.9.4": { "node_abi": 57, "v8": "6.1" }, "8.10.0": { "node_abi": 57, "v8": "6.2" }, "8.11.0": { "node_abi": 57, "v8": "6.2" }, "8.11.1": { "node_abi": 57, "v8": "6.2" }, "8.11.2": { "node_abi": 57, "v8": "6.2" }, "8.11.3": { "node_abi": 57, "v8": "6.2" }, "9.0.0": { "node_abi": 59, "v8": "6.2" }, "9.1.0": { "node_abi": 59, "v8": "6.2" }, "9.2.0": { "node_abi": 59, "v8": "6.2" }, "9.2.1": { "node_abi": 59, "v8": "6.2" }, "9.3.0": { "node_abi": 59, "v8": "6.2" }, "9.4.0": { "node_abi": 59, "v8": "6.2" }, "9.5.0": { "node_abi": 59, "v8": "6.2" }, "9.6.0": { "node_abi": 59, "v8": "6.2" }, "9.6.1": { "node_abi": 59, "v8": "6.2" }, "9.7.0": { "node_abi": 59, "v8": "6.2" }, "9.7.1": { "node_abi": 59, "v8": "6.2" }, "9.8.0": { "node_abi": 59, "v8": "6.2" }, "9.9.0": { "node_abi": 59, "v8": "6.2" }, "9.10.0": { "node_abi": 59, "v8": "6.2" }, "9.10.1": { "node_abi": 59, "v8": "6.2" }, "9.11.0": { "node_abi": 59, "v8": "6.2" }, "9.11.1": { "node_abi": 59, "v8": "6.2" }, "9.11.2": { "node_abi": 59, "v8": "6.2" }, "10.0.0": { "node_abi": 64, "v8": "6.6" }, "10.1.0": { "node_abi": 64, "v8": "6.6" }, "10.2.0": { "node_abi": 64, "v8": "6.6" }, "10.2.1": { "node_abi": 64, "v8": "6.6" }, "10.3.0": { "node_abi": 64, "v8": "6.6" }, "10.4.0": { "node_abi": 64, "v8": "6.7" }, "10.4.1": { "node_abi": 64, "v8": "6.7" }, "10.5.0": { "node_abi": 64, "v8": "6.7" } }node-pre-gyp-0.10.2/lib/util/compile.js000066400000000000000000000056661331361613700176320ustar00rootroot00000000000000"use strict"; module.exports = exports; var fs = require('fs'); var path = require('path'); var win = process.platform == 'win32'; var existsSync = fs.existsSync || path.existsSync; var cp = require('child_process'); // try to build up the complete path to node-gyp /* priority: - node-gyp on ENV:npm_config_node_gyp (https://github.com/npm/npm/pull/4887) - node-gyp on NODE_PATH - node-gyp inside npm on NODE_PATH (ignore on iojs) - node-gyp inside npm beside node exe */ function which_node_gyp() { var node_gyp_bin; if (process.env.npm_config_node_gyp) { try { node_gyp_bin = process.env.npm_config_node_gyp; if (existsSync(node_gyp_bin)) { return node_gyp_bin; } } catch (err) { } } try { var node_gyp_main = require.resolve('node-gyp'); node_gyp_bin = path.join(path.dirname( path.dirname(node_gyp_main)), 'bin/node-gyp.js'); if (existsSync(node_gyp_bin)) { return node_gyp_bin; } } catch (err) { } if (process.execPath.indexOf('iojs') === -1) { try { var npm_main = require.resolve('npm'); node_gyp_bin = path.join(path.dirname( path.dirname(npm_main)), 'node_modules/node-gyp/bin/node-gyp.js'); if (existsSync(node_gyp_bin)) { return node_gyp_bin; } } catch (err) { } } var npm_base = path.join(path.dirname( path.dirname(process.execPath)), 'lib/node_modules/npm/'); node_gyp_bin = path.join(npm_base, 'node_modules/node-gyp/bin/node-gyp.js'); if (existsSync(node_gyp_bin)) { return node_gyp_bin; } } module.exports.run_gyp = function(args,opts,callback) { var shell_cmd = ''; var cmd_args = []; if (opts.runtime && opts.runtime == 'node-webkit') { shell_cmd = 'nw-gyp'; if (win) shell_cmd += '.cmd'; } else { var node_gyp_path = which_node_gyp(); if (node_gyp_path) { shell_cmd = process.execPath; cmd_args.push(node_gyp_path); } else { shell_cmd = 'node-gyp'; if (win) shell_cmd += '.cmd'; } } var final_args = cmd_args.concat(args); var cmd = cp.spawn(shell_cmd, final_args, {cwd: undefined, env: process.env, stdio: [ 0, 1, 2]}); cmd.on('error', function (err) { if (err) { return callback(new Error("Failed to execute '" + shell_cmd + ' ' + final_args.join(' ') + "' (" + err + ")")); } callback(null,opts); }); cmd.on('close', function (code) { if (code && code !== 0) { return callback(new Error("Failed to execute '" + shell_cmd + ' ' + final_args.join(' ') + "' (" + code + ")")); } callback(null,opts); }); }; node-pre-gyp-0.10.2/lib/util/handle_gyp_opts.js000066400000000000000000000067301331361613700213520ustar00rootroot00000000000000"use strict"; module.exports = exports = handle_gyp_opts; var fs = require('fs'); var versioning = require('./versioning.js'); var napi = require('./napi.js'); /* Here we gather node-pre-gyp generated options (from versioning) and pass them along to node-gyp. We massage the args and options slightly to account for differences in what commands mean between node-pre-gyp and node-gyp (e.g. see the difference between "build" and "rebuild" below) Keep in mind: the values inside `argv` and `gyp.opts` below are different depending on whether node-pre-gyp is called directory, or if it is called in a `run-script` phase of npm. We also try to preserve any command line options that might have been passed to npm or node-pre-gyp. But this is fairly difficult without passing way to much through. For example `gyp.opts` contains all the process.env and npm pushes a lot of variables into process.env which node-pre-gyp inherits. So we have to be very selective about what we pass through. For example: `npm install --build-from-source` will give: argv == [ 'rebuild' ] gyp.opts.argv == { remain: [ 'install' ], cooked: [ 'install', '--fallback-to-build' ], original: [ 'install', '--fallback-to-build' ] } `./bin/node-pre-gyp build` will give: argv == [] gyp.opts.argv == { remain: [ 'build' ], cooked: [ 'build' ], original: [ '-C', 'test/app1', 'build' ] } */ // select set of node-pre-gyp versioning info // to share with node-gyp var share_with_node_gyp = [ 'module', 'module_name', 'module_path', 'napi_version', 'node_abi_napi', 'napi_build_version' ]; function handle_gyp_opts(gyp, argv, callback) { // Collect node-pre-gyp specific variables to pass to node-gyp var node_pre_gyp_options = []; // generate custom node-pre-gyp versioning info var napi_build_version = napi.get_napi_build_version_from_command_args(argv); var opts = versioning.evaluate(JSON.parse(fs.readFileSync('./package.json')), gyp.opts, napi_build_version); share_with_node_gyp.forEach(function(key) { var val = opts[key]; if (val) { node_pre_gyp_options.push('--' + key + '=' + val); } else { if (key !== 'napi_version' && key !== 'node_abi_napi' && key !== 'napi_build_version') return callback(new Error("Option " + key + " required but not found by node-pre-gyp")); } }); // Collect options that follow the special -- which disables nopt parsing var unparsed_options = []; var double_hyphen_found = false; gyp.opts.argv.original.forEach(function(opt) { if (double_hyphen_found) { unparsed_options.push(opt); } if (opt == '--') { double_hyphen_found = true; } }); // We try respect and pass through remaining command // line options (like --foo=bar) to node-gyp var cooked = gyp.opts.argv.cooked; var node_gyp_options = []; cooked.forEach(function(value) { if (value.length > 2 && value.slice(0,2) == '--') { var key = value.slice(2); var val = cooked[cooked.indexOf(value)+1]; if (val && val.indexOf('--') === -1) { // handle '--foo=bar' or ['--foo','bar'] node_gyp_options.push('--' + key + '=' + val); } else { // pass through --foo node_gyp_options.push(value); } } }); var result = {'opts':opts,'gyp':node_gyp_options,'pre':node_pre_gyp_options,'unparsed':unparsed_options}; return callback(null,result); } node-pre-gyp-0.10.2/lib/util/napi.js000066400000000000000000000130331331361613700171140ustar00rootroot00000000000000"use strict"; var fs = require('fs'); var rm = require('rimraf'); module.exports = exports; var versionArray = process.version .substr(1) .replace(/-.*$/, '') .split('.') .map(function(item) { return +item; }); var napi_multiple_commands = [ 'build', 'clean', 'configure', 'package', 'publish', 'reveal', 'testbinary', 'testpackage', 'unpublish' ]; var napi_build_version_tag = 'napi_build_version='; module.exports.get_napi_version = function() { // returns the non-zero numeric napi version or undefined if napi is not supported. var version = process.versions.napi; // can be undefined if (!version) { // this code should never need to be updated if (versionArray[0] === 9 && versionArray[1] >= 3) version = 2; // 9.3.0+ else if (versionArray[0] === 8) version = 1; // 8.0.0+ } return version; }; module.exports.get_napi_version_as_string = function() { // returns the napi version as a string or an empty string if napi is not supported. var version = module.exports.get_napi_version(); return version ? ''+version : ''; }; module.exports.validate_package_json = function(package_json) { // return err var binary = package_json.binary; var module_path_ok = binary.module_path && binary.module_path.indexOf('{napi_build_version}') !== -1; var remote_path_ok = binary.remote_path && binary.remote_path.indexOf('{napi_build_version}') !== -1; var package_name_ok = binary.package_name && binary.package_name.indexOf('{napi_build_version}') !== -1; var napi_build_versions = module.exports.get_napi_build_versions(package_json); if (napi_build_versions) { napi_build_versions.forEach(function(napi_build_version){ if (!(parseInt(napi_build_version,10) === napi_build_version && napi_build_version > 0)) { throw new Error("All values specified in napi_versions must be positive integers."); } }); } if (napi_build_versions && (!module_path_ok || (!remote_path_ok && !package_name_ok))) { throw new Error("When napi_versions is specified; module_path and either remote_path or " + "package_name must contain the substitution string '{napi_build_version}`."); } if ((module_path_ok || remote_path_ok || package_name_ok) && !napi_build_versions) { throw new Error("When the substitution string '{napi_build_version}` is specified in " + "module_path, remote_path, or package_name; napi_versions must also be specified."); } if (napi_build_versions && !module.exports.get_best_napi_build_version(package_json)) { throw new Error( 'The N-API version of this Node instance is ' + module.exports.get_napi_version() + '. ' + 'This module supports N-API version(s) ' + module.exports.get_napi_build_versions(package_json) + '. ' + 'This Node instance cannot run this module.'); } }; module.exports.expand_commands = function(package_json, commands) { var expanded_commands = []; var napi_build_versions = module.exports.get_napi_build_versions(package_json); commands.forEach(function(command){ if (napi_build_versions && command.name === 'install') { var napi_build_version = module.exports.get_best_napi_build_version(package_json); var args = napi_build_version ? [ napi_build_version_tag+napi_build_version ] : [ ]; expanded_commands.push ({ name: command.name, args: args }); } else if (napi_build_versions && napi_multiple_commands.includes(command.name)) { napi_build_versions.forEach(function(napi_build_version){ var args = command.args.slice(); args.push (napi_build_version_tag+napi_build_version); expanded_commands.push ({ name: command.name, args: args }); }); } else { expanded_commands.push (command); } }); return expanded_commands; }; module.exports.get_napi_build_versions = function(package_json) { var napi_build_versions = []; if (package_json.binary && package_json.binary.napi_versions) { // remove duplicates package_json.binary.napi_versions.forEach(function(napi_version) { if (!napi_build_versions.includes(napi_version)) napi_build_versions.push(napi_version); }); } return napi_build_versions.length ? napi_build_versions : undefined; }; module.exports.get_command_arg = function(napi_build_version) { return napi_build_version_tag + napi_build_version; }; module.exports.get_napi_build_version_from_command_args = function(command_args) { for (var i = 0; i < command_args.length; i++) { var arg = command_args[i]; if (arg.indexOf(napi_build_version_tag) === 0) { return parseInt(arg.substr(napi_build_version_tag.length),10); } } return undefined; }; module.exports.swap_build_dir_out = function(napi_build_version) { if (napi_build_version) { rm.sync(module.exports.get_build_dir(napi_build_version)); fs.renameSync('build', module.exports.get_build_dir(napi_build_version)); } }; module.exports.swap_build_dir_in = function(napi_build_version) { if (napi_build_version) { rm.sync('build'); fs.renameSync(module.exports.get_build_dir(napi_build_version), 'build'); } }; module.exports.get_build_dir = function(napi_build_version) { return 'build-tmp-napi-v'+napi_build_version; }; module.exports.get_best_napi_build_version = function(package_json) { var best_napi_build_version = 0; var napi_build_versions = module.exports.get_napi_build_versions (package_json); if (napi_build_versions) { var our_napi_version = module.exports.get_napi_version(); napi_build_versions.forEach(function(napi_build_version){ if (napi_build_version > best_napi_build_version && napi_build_version <= our_napi_version) { best_napi_build_version = napi_build_version; } }); } return best_napi_build_version === 0 ? undefined : best_napi_build_version; }; node-pre-gyp-0.10.2/lib/util/nw-pre-gyp/000077500000000000000000000000001331361613700176345ustar00rootroot00000000000000node-pre-gyp-0.10.2/lib/util/nw-pre-gyp/index.html000066400000000000000000000010361331361613700216310ustar00rootroot00000000000000 Node-webkit-based module test

Node-webkit-based module test

node-pre-gyp-0.10.2/lib/util/nw-pre-gyp/package.json000066400000000000000000000002401331361613700221160ustar00rootroot00000000000000{ "main": "index.html", "name": "nw-pre-gyp-module-test", "description": "Node-webkit-based module test.", "version": "0.0.1", "window": { "show": false } } node-pre-gyp-0.10.2/lib/util/s3_setup.js000066400000000000000000000014011331361613700177260ustar00rootroot00000000000000"use strict"; module.exports = exports; var url = require('url'); var URI_REGEX="^(.*)\.(s3(?:-.*)?)\.amazonaws\.com$"; module.exports.detect = function(to,config) { var uri = url.parse(to); var hostname_matches = uri.hostname.match(URI_REGEX); config.prefix = (!uri.pathname || uri.pathname == '/') ? '' : uri.pathname.replace('/',''); if(!hostname_matches) { return; } if (!config.bucket) { config.bucket = hostname_matches[1]; } if (!config.region) { var s3_domain = hostname_matches[2]; if (s3_domain.slice(0,3) == 's3-' && s3_domain.length >= 3) { // it appears the region is explicit in the url config.region = s3_domain.replace('s3-',''); } } }; node-pre-gyp-0.10.2/lib/util/versioning.js000066400000000000000000000356161331361613700203630ustar00rootroot00000000000000"use strict"; module.exports = exports; var path = require('path'); var semver = require('semver'); var url = require('url'); var detect_libc = require('detect-libc'); var napi = require('./napi.js'); var abi_crosswalk; // This is used for unit testing to provide a fake // ABI crosswalk that emulates one that is not updated // for the current version if (process.env.NODE_PRE_GYP_ABI_CROSSWALK) { abi_crosswalk = require(process.env.NODE_PRE_GYP_ABI_CROSSWALK); } else { abi_crosswalk = require('./abi_crosswalk.json'); } var major_versions = {}; Object.keys(abi_crosswalk).forEach(function(v) { var major = v.split('.')[0]; if (!major_versions[major]) { major_versions[major] = v; } }); function get_electron_abi(runtime, target_version) { if (!runtime) { throw new Error("get_electron_abi requires valid runtime arg"); } if (typeof target_version === 'undefined') { // erroneous CLI call throw new Error("Empty target version is not supported if electron is the target."); } // Electron guarantees that patch version update won't break native modules. var sem_ver = semver.parse(target_version); return runtime + '-v' + sem_ver.major + '.' + sem_ver.minor; } module.exports.get_electron_abi = get_electron_abi; function get_node_webkit_abi(runtime, target_version) { if (!runtime) { throw new Error("get_node_webkit_abi requires valid runtime arg"); } if (typeof target_version === 'undefined') { // erroneous CLI call throw new Error("Empty target version is not supported if node-webkit is the target."); } return runtime + '-v' + target_version; } module.exports.get_node_webkit_abi = get_node_webkit_abi; function get_node_abi(runtime, versions) { if (!runtime) { throw new Error("get_node_abi requires valid runtime arg"); } if (!versions) { throw new Error("get_node_abi requires valid process.versions object"); } var sem_ver = semver.parse(versions.node); if (sem_ver.major === 0 && sem_ver.minor % 2) { // odd series // https://github.com/mapbox/node-pre-gyp/issues/124 return runtime+'-v'+versions.node; } else { // process.versions.modules added in >= v0.10.4 and v0.11.7 // https://github.com/joyent/node/commit/ccabd4a6fa8a6eb79d29bc3bbe9fe2b6531c2d8e return versions.modules ? runtime+'-v' + (+versions.modules) : 'v8-' + versions.v8.split('.').slice(0,2).join('.'); } } module.exports.get_node_abi = get_node_abi; function get_runtime_abi(runtime, target_version) { if (!runtime) { throw new Error("get_runtime_abi requires valid runtime arg"); } if (runtime === 'node-webkit') { return get_node_webkit_abi(runtime, target_version || process.versions['node-webkit']); } else if (runtime === 'electron') { return get_electron_abi(runtime, target_version || process.versions.electron); } else { if (runtime != 'node') { throw new Error("Unknown Runtime: '" + runtime + "'"); } if (!target_version) { return get_node_abi(runtime,process.versions); } else { var cross_obj; // abi_crosswalk generated with ./scripts/abi_crosswalk.js if (abi_crosswalk[target_version]) { cross_obj = abi_crosswalk[target_version]; } else { var target_parts = target_version.split('.').map(function(i) { return +i; }); if (target_parts.length != 3) { // parse failed throw new Error("Unknown target version: " + target_version); } /* The below code tries to infer the last known ABI compatible version that we have recorded in the abi_crosswalk.json when an exact match is not possible. The reasons for this to exist are complicated: - We support passing --target to be able to allow developers to package binaries for versions of node that are not the same one as they are running. This might also be used in combination with the --target_arch or --target_platform flags to also package binaries for alternative platforms - When --target is passed we can't therefore determine the ABI (process.versions.modules) from the node version that is running in memory - So, therefore node-pre-gyp keeps an "ABI crosswalk" (lib/util/abi_crosswalk.json) to be able to look this info up for all versions - But we cannot easily predict what the future ABI will be for released versions - And node-pre-gyp needs to be a `bundledDependency` in apps that depend on it in order to work correctly by being fully available at install time. - So, the speed of node releases and the bundled nature of node-pre-gyp mean that a new node-pre-gyp release need to happen for every node.js/io.js/node-webkit/nw.js/atom-shell/etc release that might come online if you want the `--target` flag to keep working for the latest version - Which is impractical ^^ - Hence the below code guesses about future ABI to make the need to update node-pre-gyp less demanding. In practice then you can have a dependency of your app like `node-sqlite3` that bundles a `node-pre-gyp` that only knows about node v0.10.33 in the `abi_crosswalk.json` but target node v0.10.34 (which is assumed to be ABI compatible with v0.10.33). TODO: use semver module instead of custom version parsing */ var major = target_parts[0]; var minor = target_parts[1]; var patch = target_parts[2]; // io.js: yeah if node.js ever releases 1.x this will break // but that is unlikely to happen: https://github.com/iojs/io.js/pull/253#issuecomment-69432616 if (major === 1) { // look for last release that is the same major version // e.g. we assume io.js 1.x is ABI compatible with >= 1.0.0 while (true) { if (minor > 0) --minor; if (patch > 0) --patch; var new_iojs_target = '' + major + '.' + minor + '.' + patch; if (abi_crosswalk[new_iojs_target]) { cross_obj = abi_crosswalk[new_iojs_target]; console.log('Warning: node-pre-gyp could not find exact match for ' + target_version); console.log('Warning: but node-pre-gyp successfully choose ' + new_iojs_target + ' as ABI compatible target'); break; } if (minor === 0 && patch === 0) { break; } } } else if (major >= 2) { // look for last release that is the same major version if (major_versions[major]) { cross_obj = abi_crosswalk[major_versions[major]]; console.log('Warning: node-pre-gyp could not find exact match for ' + target_version); console.log('Warning: but node-pre-gyp successfully choose ' + major_versions[major] + ' as ABI compatible target'); } } else if (major === 0) { // node.js if (target_parts[1] % 2 === 0) { // for stable/even node.js series // look for the last release that is the same minor release // e.g. we assume node 0.10.x is ABI compatible with >= 0.10.0 while (--patch > 0) { var new_node_target = '' + major + '.' + minor + '.' + patch; if (abi_crosswalk[new_node_target]) { cross_obj = abi_crosswalk[new_node_target]; console.log('Warning: node-pre-gyp could not find exact match for ' + target_version); console.log('Warning: but node-pre-gyp successfully choose ' + new_node_target + ' as ABI compatible target'); break; } } } } } if (!cross_obj) { throw new Error("Unsupported target version: " + target_version); } // emulate process.versions var versions_obj = { node: target_version, v8: cross_obj.v8+'.0', // abi_crosswalk uses 1 for node versions lacking process.versions.modules // process.versions.modules added in >= v0.10.4 and v0.11.7 modules: cross_obj.node_abi > 1 ? cross_obj.node_abi : undefined }; return get_node_abi(runtime, versions_obj); } } } module.exports.get_runtime_abi = get_runtime_abi; var required_parameters = [ 'module_name', 'module_path', 'host' ]; function validate_config(package_json) { var msg = package_json.name + ' package.json is not node-pre-gyp ready:\n'; var missing = []; if (!package_json.main) { missing.push('main'); } if (!package_json.version) { missing.push('version'); } if (!package_json.name) { missing.push('name'); } if (!package_json.binary) { missing.push('binary'); } var o = package_json.binary; required_parameters.forEach(function(p) { if (missing.indexOf('binary') > -1) { missing.pop('binary'); } if (!o || o[p] === undefined || o[p] === "") { missing.push('binary.' + p); } }); if (missing.length >= 1) { throw new Error(msg+"package.json must declare these properties: \n" + missing.join('\n')); } if (o) { // enforce https over http var protocol = url.parse(o.host).protocol; if (protocol === 'http:') { throw new Error("'host' protocol ("+protocol+") is invalid - only 'https:' is accepted"); } } napi.validate_package_json(package_json); } module.exports.validate_config = validate_config; function eval_template(template,opts) { Object.keys(opts).forEach(function(key) { var pattern = '{'+key+'}'; while (template.indexOf(pattern) > -1) { template = template.replace(pattern,opts[key]); } }); return template; } // url.resolve needs single trailing slash // to behave correctly, otherwise a double slash // may end up in the url which breaks requests // and a lacking slash may not lead to proper joining function fix_slashes(pathname) { if (pathname.slice(-1) != '/') { return pathname + '/'; } return pathname; } // remove double slashes // note: path.normalize will not work because // it will convert forward to back slashes function drop_double_slashes(pathname) { return pathname.replace(/\/\//g,'/'); } function get_process_runtime(versions) { var runtime = 'node'; if (versions['node-webkit']) { runtime = 'node-webkit'; } else if (versions.electron) { runtime = 'electron'; } return runtime; } module.exports.get_process_runtime = get_process_runtime; var default_package_name = '{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz'; var default_remote_path = ''; module.exports.evaluate = function(package_json,options,napi_build_version) { options = options || {}; validate_config(package_json); var v = package_json.version; var module_version = semver.parse(v); var runtime = options.runtime || get_process_runtime(process.versions); var opts = { name: package_json.name, configuration: Boolean(options.debug) ? 'Debug' : 'Release', debug: options.debug, module_name: package_json.binary.module_name, version: module_version.version, prerelease: module_version.prerelease.length ? module_version.prerelease.join('.') : '', build: module_version.build.length ? module_version.build.join('.') : '', major: module_version.major, minor: module_version.minor, patch: module_version.patch, runtime: runtime, node_abi: get_runtime_abi(runtime,options.target), node_abi_napi: napi.get_napi_version() ? 'napi' : get_runtime_abi(runtime,options.target), napi_version: napi.get_napi_version(), // non-zero numeric, undefined if unsupported napi_build_version: napi_build_version, // undefined if not specified target: options.target || '', platform: options.target_platform || process.platform, target_platform: options.target_platform || process.platform, arch: options.target_arch || process.arch, target_arch: options.target_arch || process.arch, libc: options.target_libc || detect_libc.family || 'unknown', module_main: package_json.main, toolset : options.toolset || '' // address https://github.com/mapbox/node-pre-gyp/issues/119 }; // support host mirror with npm config `--{module_name}_binary_host_mirror` // e.g.: https://github.com/node-inspector/v8-profiler/blob/master/package.json#L25 // > npm install v8-profiler --profiler_binary_host_mirror=https://npm.taobao.org/mirrors/node-inspector/ var host = process.env['npm_config_' + opts.module_name + '_binary_host_mirror'] || package_json.binary.host; opts.host = fix_slashes(eval_template(host,opts)); opts.module_path = eval_template(package_json.binary.module_path,opts); // now we resolve the module_path to ensure it is absolute so that binding.gyp variables work predictably if (options.module_root) { // resolve relative to known module root: works for pre-binding require opts.module_path = path.join(options.module_root,opts.module_path); } else { // resolve relative to current working directory: works for node-pre-gyp commands opts.module_path = path.resolve(opts.module_path); } opts.module = path.join(opts.module_path,opts.module_name + '.node'); opts.remote_path = package_json.binary.remote_path ? drop_double_slashes(fix_slashes(eval_template(package_json.binary.remote_path,opts))) : default_remote_path; var package_name = package_json.binary.package_name ? package_json.binary.package_name : default_package_name; opts.package_name = eval_template(package_name,opts); opts.staged_tarball = path.join('build/stage',opts.remote_path,opts.package_name); opts.hosted_path = url.resolve(opts.host,opts.remote_path); opts.hosted_tarball = url.resolve(opts.hosted_path,opts.package_name); return opts; }; node-pre-gyp-0.10.2/package.json000066400000000000000000000024311331361613700163720ustar00rootroot00000000000000{ "name": "node-pre-gyp", "description": "Node.js native addon binary install tool", "version": "0.10.2", "keywords": [ "native", "addon", "module", "c", "c++", "bindings", "binary" ], "license": "BSD-3-Clause", "author": "Dane Springmeyer ", "repository": { "type": "git", "url": "git://github.com/mapbox/node-pre-gyp.git" }, "bin": "./bin/node-pre-gyp", "main": "./lib/node-pre-gyp.js", "dependencies": { "detect-libc": "^1.0.2", "mkdirp": "^0.5.1", "needle": "^2.2.0", "nopt": "^4.0.1", "npm-packlist": "^1.1.6", "npmlog": "^4.0.2", "rc": "^1.2.7", "rimraf": "^2.6.1", "semver": "^5.3.0", "tar": "^4" }, "devDependencies": { "aws-sdk": "^2.28.0", "jshint": "^2.9.5", "nock": "^9.2.3", "retire": "^1.2.12", "tape": "^4.6.3" }, "jshintConfig": { "node": true, "globalstrict": true, "undef": true, "unused": false, "noarg": true }, "scripts": { "pretest": "jshint test/build.test.js test/s3_setup.test.js test/versioning.test.js test/fetch.test.js lib lib/util scripts bin/node-pre-gyp", "update-crosswalk": "node scripts/abi_crosswalk.js", "test": "jshint lib lib/util scripts bin/node-pre-gyp && tape test/*test.js" } } node-pre-gyp-0.10.2/scripts/000077500000000000000000000000001331361613700155735ustar00rootroot00000000000000node-pre-gyp-0.10.2/scripts/abi_crosswalk.js000066400000000000000000000037531331361613700207640ustar00rootroot00000000000000"use strict"; var https = require("https"); var fs = require('fs'); var semver = require('semver'); /* usage: node scripts/abi_crosswalk.js */ var cross = {}; // IO.js // thanks to rvagg, this is so simple // https://github.com/iojs/build/issues/94 https.get('https://iojs.org/download/release/index.json', function(res) { if (res.statusCode != 200 ) { throw new Error("server returned " + res.statusCode + ' for iojs.org'); } res.setEncoding('utf8'); var body = ''; res.on('data', function (chunk) { body += chunk; }); res.on('end',function(err) { if (err) throw err; var releases = JSON.parse(body); releases.forEach(function(release) { cross[release.version.replace('v','')] = {node_abi:+release.modules,v8:release.v8.split('.').slice(0,2).join('.')}; }); }); }); https.get('https://nodejs.org/download/release/index.json', function(res) { if (res.statusCode != 200 ) { throw new Error("server returned " + res.statusCode + ' for nodejs.org'); } res.setEncoding('utf8'); var body = ''; res.on('data', function (chunk) { body += chunk; }); res.on('end',function(err) { if (err) throw err; var releases = JSON.parse(body); releases.forEach(function(release) { cross[release.version.replace('v','')] = {node_abi:+release.modules,v8:release.v8.split('.').slice(0,2).join('.')}; }); }); }); var sortObjectByKey = function(obj){ var keys = []; var sorted_obj = {}; for(var key in obj){ if(obj.hasOwnProperty(key)){ keys.push(key); } } // sort keys keys.sort(function(a,b) { if (semver.gt(a, b)) { return 1; } return -1; }); var len = keys.length; for (var i = 0; i < len; i++) { key = keys[i]; sorted_obj[key] = obj[key]; } return sorted_obj; }; process.on('exit', function(err) { if (err) throw err; fs.writeFileSync('./lib/util/abi_crosswalk.json',JSON.stringify(sortObjectByKey(cross),null,2)); });node-pre-gyp-0.10.2/scripts/clear_bucket.js000066400000000000000000000025001331361613700205510ustar00rootroot00000000000000"use strict"; var fs = require('fs'); var versioning = require('../lib/util/versioning.js'); var s3_setup = require('../lib/util/s3_setup.js'); var config = require('rc')("node_pre_gyp",{acl:"public-read"}); if(!config.accessKeyId || !config.secretAccessKey) { throw new Error("Unknown S3 `accessKeyId` and `secretAccessKey`"); } else { var AWS = require("aws-sdk"); var package_json = JSON.parse(fs.readFileSync('./test/app1/package.json')); var opts = versioning.evaluate(package_json, {}); s3_setup.detect(opts.hosted_path,config); AWS.config.update(config); var s3 = new AWS.S3(); var s3_opts = { Bucket: config.bucket, Prefix: config.prefix }; s3.listObjects(s3_opts, function(err, meta){ if (err) { throw new Error('['+package_json.name+'] Not found: https://' + s3_opts.Bucket + '.s3.amazonaws.com/'+config.prefix); } else { meta.Contents.forEach(function(item) { var s3_obj_opts = { Bucket: config.bucket, Key: item.Key }; s3.deleteObject(s3_obj_opts, function(err) { if (err) console.log(err); console.log('deleted '+ item.Key); }); }); } }); } node-pre-gyp-0.10.2/scripts/install_node.sh000077500000000000000000000005351331361613700206100ustar00rootroot00000000000000# here we set up the node version on the fly based on the matrix value. # This is done manually so that the build works the same on OS X rm -rf ~/.nvm/ && git clone --depth 1 https://github.com/creationix/nvm.git ~/.nvm NODE_VERSION=$1 source ~/.nvm/nvm.sh nvm install ${NODE_VERSION} nvm use ${NODE_VERSION} node --version npm --version which node node-pre-gyp-0.10.2/scripts/latest-by-abi.js000066400000000000000000000011421331361613700205640ustar00rootroot00000000000000"use strict"; var semver = require('semver'); var data = require('../lib/util/abi_crosswalk.json'); var targets = {}; Object.keys(data).forEach(function(v) { var o = data[v]; var abi; if (o.node_abi == 1) { abi = 'v8-'+o.v8; } else { abi = 'node-v'+o.node_abi; } if (targets[abi] === undefined) { targets[abi] = v; } else { var cur = targets[abi]; if (semver.gt(v,cur)) { targets[abi] = v; } } }); Object.keys(targets).forEach(function(k) { var version = targets[k]; console.log(version,data[version]); }); node-pre-gyp-0.10.2/scripts/test-node-webkit.sh000077500000000000000000000035171331361613700213250ustar00rootroot00000000000000#!/bin/bash set -eu set -o pipefail # put local copy of node-pre-gyp on NODE_PATH/PATH export NODE_PATH=`pwd`/lib export PATH=`pwd`/bin:$PATH BASE=$(pwd) export NODE_WEBKIT_VERSION="0.8.5" # TODO - consider using https://github.com/shama/nodewebkit to install node-webkit if [[ `uname -s` == 'Darwin' ]]; then if [[ ! -f node-webkit-v${NODE_WEBKIT_VERSION}-osx-ia32.zip ]]; then wget https://s3.amazonaws.com/node-webkit/v${NODE_WEBKIT_VERSION}/node-webkit-v${NODE_WEBKIT_VERSION}-osx-ia32.zip fi if [[ ! -d node-webkit.app ]]; then unzip node-webkit-v${NODE_WEBKIT_VERSION}-osx-ia32.zip fi export PATH=${BASE}/node-webkit.app/Contents/MacOS:${PATH} else # assume 64 bit linux wget https://s3.amazonaws.com/node-webkit/v${NODE_WEBKIT_VERSION}/node-webkit-v${NODE_WEBKIT_VERSION}-linux-x64.tar.gz tar xf node-webkit-v${NODE_WEBKIT_VERSION}-linux-x64.tar.gz export DISPLAY=:99.0; sh -e /etc/init.d/xvfb start; export PATH=${BASE}/node-webkit-v0.8.5-linux-x64:${PATH} fi # install nw-gyp npm install nw-gyp export PATH=${BASE}/node_modules/.bin:${PATH} cd test/app1 node-pre-gyp rebuild --runtime=node-webkit --target=${NODE_WEBKIT_VERSION} node-pre-gyp package --runtime=node-webkit --target=${NODE_WEBKIT_VERSION} node-pre-gyp clean --runtime=node-webkit --target=${NODE_WEBKIT_VERSION} # now test publishing and installing from remote if [[ "${node_pre_gyp_accessKeyId:-false}" != false ]] || [[ -f $HOME/.node_pre_gyprc ]] ; then node-pre-gyp unpublish publish --runtime=node-webkit --target=${NODE_WEBKIT_VERSION} node-pre-gyp clean --runtime=node-webkit --target=${NODE_WEBKIT_VERSION} rm -rf build/ rm -rf lib/binding/ npm install --runtime=node-webkit --target=${NODE_WEBKIT_VERSION} # cleanup node-pre-gyp unpublish --runtime=node-webkit --target=${NODE_WEBKIT_VERSION} fi node-pre-gyp-0.10.2/test/000077500000000000000000000000001331361613700150635ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app1/000077500000000000000000000000001331361613700157245ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app1/.gitignore000066400000000000000000000000701331361613700177110ustar00rootroot00000000000000.DS_Store build/ lib/binding/ node_modules npm-debug.lognode-pre-gyp-0.10.2/test/app1/README.md000066400000000000000000000001101331361613700171730ustar00rootroot00000000000000# Test app Demonstrates a simple configuration that uses node-pre-gyp. node-pre-gyp-0.10.2/test/app1/app1.cc000066400000000000000000000015001331361613700170700ustar00rootroot00000000000000// v8 #include // node.js #include #include #if (NODE_MODULE_VERSION > 0x000B) static void get_hello(const v8::FunctionCallbackInfo& args) { v8::HandleScope scope(v8::Isolate::GetCurrent()); args.GetReturnValue().Set(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(),"hello")); } #else static v8::Handle get_hello(const v8::Arguments& args) { v8::HandleScope scope; return scope.Close(v8::String::New("hello")); } #endif extern "C" { static void start(v8::Handle target) { #if (NODE_MODULE_VERSION > 0x000B) v8::HandleScope scope(v8::Isolate::GetCurrent()); #else v8::HandleScope scope; #endif NODE_SET_METHOD(target, "hello", get_hello); } } NODE_MODULE(app1, start) node-pre-gyp-0.10.2/test/app1/binding.gyp000066400000000000000000000004171331361613700200610ustar00rootroot00000000000000{ "targets": [ { "target_name": "<(module_name)", "sources": [ "<(module_name).cc" ], 'product_dir': '<(module_path)', "xcode_settings": { "MACOSX_DEPLOYMENT_TARGET":"10.9", "CLANG_CXX_LIBRARY": "libc++" } } ] } node-pre-gyp-0.10.2/test/app1/index.js000066400000000000000000000003551331361613700173740ustar00rootroot00000000000000var binary = require('node-pre-gyp'); var path = require('path') var binding_path = binary.find(path.resolve(path.join(__dirname,'./package.json'))); var binding = require(binding_path); require('assert').equal(binding.hello(),"hello");node-pre-gyp-0.10.2/test/app1/package.json000066400000000000000000000011341331361613700202110ustar00rootroot00000000000000{ "name": "node-pre-gyp-test-app1", "author": "Dane Springmeyer ", "description": "node-pre-gyp test", "repository": { "type": "git", "url": "git://github.com/mapbox/node-pre-gyp.git" }, "license": "BSD-3-Clause", "version": "0.1.0", "main": "./index.js", "binary": { "module_name": "app1", "module_path": "./lib/binding/", "host": "https://node-pre-gyp-tests.s3-us-west-1.amazonaws.com" }, "scripts": { "install": "node-pre-gyp install --fallback-to-build", "test": "node index.js" } } node-pre-gyp-0.10.2/test/app2/000077500000000000000000000000001331361613700157255ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app2/.gitignore000066400000000000000000000000701331361613700177120ustar00rootroot00000000000000.DS_Store build/ lib/binding/ node_modules npm-debug.lognode-pre-gyp-0.10.2/test/app2/README.md000066400000000000000000000002241331361613700172020ustar00rootroot00000000000000# Test app Demonstrates a very custom situation where an option must be passed to node-gyp in order for the binding.gyp to be properly configured. node-pre-gyp-0.10.2/test/app2/app2.cc000066400000000000000000000015361331361613700171030ustar00rootroot00000000000000// v8 #include // node.js #include #include #include #if (NODE_MODULE_VERSION > 0x000B) static void get_hello(const v8::FunctionCallbackInfo& args) { v8::HandleScope scope(v8::Isolate::GetCurrent()); args.GetReturnValue().Set(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(),HELLO_WORLD)); } #else static v8::Handle get_hello(const v8::Arguments& args) { v8::HandleScope scope; return scope.Close(v8::String::New(HELLO_WORLD)); } #endif extern "C" { static void start(v8::Handle target) { #if (NODE_MODULE_VERSION > 0x000B) v8::HandleScope scope(v8::Isolate::GetCurrent()); #else v8::HandleScope scope; #endif NODE_SET_METHOD(target, "hello", get_hello); } } NODE_MODULE(app2, start) node-pre-gyp-0.10.2/test/app2/binding.gyp000066400000000000000000000005221331361613700200570ustar00rootroot00000000000000{ "targets": [ { "target_name": "<(module_name)", "sources": [ "<(module_name).cc" ], 'include_dirs': [ '<(custom_include_path)' ], 'product_dir': '<(module_path)', "xcode_settings": { "MACOSX_DEPLOYMENT_TARGET":"10.9", "CLANG_CXX_LIBRARY": "libc++" } } ] } node-pre-gyp-0.10.2/test/app2/include/000077500000000000000000000000001331361613700173505ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app2/include/foo.hpp000066400000000000000000000001051331361613700206400ustar00rootroot00000000000000#ifndef FOO_HPP #define FOO_HPP #define HELLO_WORLD "hello" #endif node-pre-gyp-0.10.2/test/app2/index.js000066400000000000000000000000311331361613700173640ustar00rootroot00000000000000require('./lib/index.js')node-pre-gyp-0.10.2/test/app2/lib/000077500000000000000000000000001331361613700164735ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app2/lib/index.js000066400000000000000000000010741331361613700201420ustar00rootroot00000000000000var binary = require('node-pre-gyp'); var path = require('path') var package_json_path = path.resolve(path.join(__dirname,'../package.json')); var binding_release_path = binary.find(package_json_path); var binding_debug_path = binary.find(package_json_path,{debug:true}); try { var binding = require(binding_debug_path); console.log('Loaded Debug build from',binding_debug_path); } catch (err) { var binding = require(binding_release_path); console.log('Loaded Release build from',binding_release_path); } require('assert').equal(binding.hello(),"hello");node-pre-gyp-0.10.2/test/app2/package.json000066400000000000000000000015451331361613700202200ustar00rootroot00000000000000{ "name": "node-pre-gyp-test-app2", "author": "Dane Springmeyer ", "description":"node-pre-gyp test", "repository" : { "type" : "git", "url" : "git://github.com/mapbox/node-pre-gyp.git" }, "license": "BSD-3-Clause", "version": "0.1.0-release1.release2+build1.build2", "main": "./lib/index.js", "binary": { "module_name": "app2", "module_path": "./lib/binding/{configuration}/{name}", "remote_path": "./{name}/v{version}/{configuration}/{version}/{toolset}/", "package_name": "{module_name}-v{major}.{minor}.{patch}-{prerelease}+{build}-{node_abi}-{platform}-{arch}.tar.gz", "host":"https://node-pre-gyp-tests.s3-us-west-1.amazonaws.com" }, "scripts": { "install":"node-pre-gyp install --fallback-to-build", "test":"node index.js" } } node-pre-gyp-0.10.2/test/app3/000077500000000000000000000000001331361613700157265ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app3/.gitignore000066400000000000000000000000701331361613700177130ustar00rootroot00000000000000.DS_Store build/ lib/binding/ node_modules npm-debug.lognode-pre-gyp-0.10.2/test/app3/README.md000066400000000000000000000004261331361613700172070ustar00rootroot00000000000000# Test app Demonstrates an example Node.js C++ app that depends on an external static library. Because the external `mylib.a` library is statically built and linked it will be available inside the `app3.node` binary. See the `app4` example for how to handle shared libraries. node-pre-gyp-0.10.2/test/app3/app3.cc000066400000000000000000000020261331361613700171000ustar00rootroot00000000000000// v8 #include // node.js #include #include #include #if (NODE_MODULE_VERSION > 0x000B) static void get_hello(const v8::FunctionCallbackInfo& args) { v8::HandleScope scope(v8::Isolate::GetCurrent()); MyLib::Message msg("hello"); std::string msg_string = msg.get(); args.GetReturnValue().Set(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(),msg_string.c_str())); } #else static v8::Handle get_hello(const v8::Arguments& args) { v8::HandleScope scope; MyLib::Message msg("hello"); std::string msg_string = msg.get(); return scope.Close(v8::String::New(msg_string.c_str())); } #endif extern "C" { static void start(v8::Handle target) { #if (NODE_MODULE_VERSION > 0x000B) v8::HandleScope scope(v8::Isolate::GetCurrent()); #else v8::HandleScope scope; #endif NODE_SET_METHOD(target, "hello", get_hello); } } NODE_MODULE(app3, start) node-pre-gyp-0.10.2/test/app3/binding.gyp000066400000000000000000000005161331361613700200630ustar00rootroot00000000000000{ "targets": [ { "target_name": "<(module_name)", "sources": [ "<(module_name).cc" ], "dependencies": [ "deps/mylib.gyp:mylib" ], 'product_dir': '<(module_path)', "xcode_settings": { "MACOSX_DEPLOYMENT_TARGET":"10.9", "CLANG_CXX_LIBRARY": "libc++" } } ] } node-pre-gyp-0.10.2/test/app3/deps/000077500000000000000000000000001331361613700166615ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app3/deps/README.md000066400000000000000000000001201331361613700201310ustar00rootroot00000000000000# sample C++ library Example based on https://github.com/springmeyer/hello-gyp node-pre-gyp-0.10.2/test/app3/deps/include/000077500000000000000000000000001331361613700203045ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app3/deps/include/mylib/000077500000000000000000000000001331361613700214205ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app3/deps/include/mylib/interface.h000066400000000000000000000005121331361613700235270ustar00rootroot00000000000000#ifndef INCLUDE_MYLIB_INTERFACE_H_ #define INCLUDE_MYLIB_INTERFACE_H_ #include namespace MyLib { class Message { public: explicit Message(std::string const& data); std::string const& get(); void set(std::string const& data); private: std::string m_data; }; }; #endif // INCLUDE_MYLIB_INTERFACE_H_ node-pre-gyp-0.10.2/test/app3/deps/mylib.gyp000066400000000000000000000010541331361613700205160ustar00rootroot00000000000000{ "targets": [ { "target_name": "mylib", "product_name": "mylib", "type": "static_library", "sources": [ "src/implementation.cc" ], "include_dirs": [ "include" ], 'direct_dependent_settings': { 'include_dirs': [ 'include/' ], }, "xcode_settings": { "MACOSX_DEPLOYMENT_TARGET":"10.9", "CLANG_CXX_LIBRARY": "libc++" } } ] } node-pre-gyp-0.10.2/test/app3/deps/src/000077500000000000000000000000001331361613700174505ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app3/deps/src/implementation.cc000066400000000000000000000004031331361613700230010ustar00rootroot00000000000000#include #include namespace MyLib { Message::Message(std::string const& data) : m_data(data) {} std::string const& Message::get() { return m_data; } void Message::set(std::string const& data) { m_data = data; } }; node-pre-gyp-0.10.2/test/app3/index.js000066400000000000000000000003551331361613700173760ustar00rootroot00000000000000var binary = require('node-pre-gyp'); var path = require('path') var binding_path = binary.find(path.resolve(path.join(__dirname,'./package.json'))); var binding = require(binding_path); require('assert').equal(binding.hello(),"hello");node-pre-gyp-0.10.2/test/app3/package.json000066400000000000000000000013631331361613700202170ustar00rootroot00000000000000{ "name": "node-pre-gyp-test-app3", "author": "Dane Springmeyer ", "description":"node-pre-gyp test", "repository" : { "type" : "git", "url" : "git://github.com/mapbox/node-pre-gyp.git" }, "license": "BSD-3-Clause", "version": "0.1.0-dev.4", "main": "./index.js", "binary": { "module_name": "app3", "module_path": "./lib/binding/{node_abi}-{platform}-{arch}", "remote_path": "./{module_name}/v{version}", "package_name": "{node_abi}-{platform}-{arch}.tar.gz", "host":"https://node-pre-gyp-tests.s3-us-west-1.amazonaws.com" }, "scripts": { "install":"node-pre-gyp install --fallback-to-build", "test":"node index.js" } } node-pre-gyp-0.10.2/test/app4/000077500000000000000000000000001331361613700157275ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app4/.gitignore000066400000000000000000000000701331361613700177140ustar00rootroot00000000000000.DS_Store build/ lib/binding/ node_modules npm-debug.lognode-pre-gyp-0.10.2/test/app4/README.md000066400000000000000000000004261331361613700172100ustar00rootroot00000000000000# Test app Demonstrates an example Node.js C++ app that depends on an external shared library. See the `app3` example for how to handle static libraries. See https://code.google.com/p/gyp/issues/detail?id=315 for gory details about rpath decisions/defaults for gyp on linux. node-pre-gyp-0.10.2/test/app4/app4.cpp000066400000000000000000000020261331361613700172770ustar00rootroot00000000000000// v8 #include // node.js #include #include #include #if (NODE_MODULE_VERSION > 0x000B) static void get_hello(const v8::FunctionCallbackInfo& args) { v8::HandleScope scope(v8::Isolate::GetCurrent()); MyLib::Message msg("hello"); std::string msg_string = msg.get(); args.GetReturnValue().Set(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(),msg_string.c_str())); } #else static v8::Handle get_hello(const v8::Arguments& args) { v8::HandleScope scope; MyLib::Message msg("hello"); std::string msg_string = msg.get(); return scope.Close(v8::String::New(msg_string.c_str())); } #endif extern "C" { static void start(v8::Handle target) { #if (NODE_MODULE_VERSION > 0x000B) v8::HandleScope scope(v8::Isolate::GetCurrent()); #else v8::HandleScope scope; #endif NODE_SET_METHOD(target, "hello", get_hello); } } NODE_MODULE(app4, start) node-pre-gyp-0.10.2/test/app4/binding.gyp000066400000000000000000000020601331361613700200600ustar00rootroot00000000000000{ "targets": [ { "target_name": "<(module_name)", "sources": [ "<(module_name).cpp" ], "dependencies": [ "deps/mylib.gyp:mylib" ], "xcode_settings": { "MACOSX_DEPLOYMENT_TARGET":"10.9", "CLANG_CXX_LIBRARY": "libc++" } }, { "target_name": "action_after_build", "type": "none", "dependencies": [ "<(module_name)" ], "copies": [ { "files": [ "<(PRODUCT_DIR)/<(module_name).node" ], "destination": "<(module_path)/" }, ], 'conditions': [ ['OS == "win"', { "copies": [ { "files": [ "<(PRODUCT_DIR)/mylib<(SHARED_LIB_SUFFIX)" ], "destination": "<(module_path)/" } ] }, { "copies": [ { "files": [ "<(PRODUCT_DIR)/mylib<(SHARED_LIB_SUFFIX)" ], "destination": "<(module_path)/lib.target/" } ] } ] ] } ] } node-pre-gyp-0.10.2/test/app4/deps/000077500000000000000000000000001331361613700166625ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app4/deps/README.md000066400000000000000000000001201331361613700201320ustar00rootroot00000000000000# Sample C++ library Example based on https://github.com/springmeyer/hello-gyp node-pre-gyp-0.10.2/test/app4/deps/include/000077500000000000000000000000001331361613700203055ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app4/deps/include/mylib/000077500000000000000000000000001331361613700214215ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app4/deps/include/mylib/interface.h000066400000000000000000000010771331361613700235370ustar00rootroot00000000000000#ifndef INCLUDE_MYLIB_INTERFACE_H_ #define INCLUDE_MYLIB_INTERFACE_H_ #include #ifdef _WIN64 #define MYLIB_EXPORT __declspec (dllexport) #elif _WIN32 #define MYLIB_EXPORT __declspec (dllexport) #elif __GNUC__ >= 4 #define MYLIB_EXPORT __attribute__ ((visibility ("default"))) #else #define MYLIB_EXPORT #endif namespace MyLib { class MYLIB_EXPORT Message { public: explicit Message(std::string const& data); std::string const& get(); void set(std::string const& data); private: std::string m_data; }; }; #endif // INCLUDE_MYLIB_INTERFACE_H_ node-pre-gyp-0.10.2/test/app4/deps/mylib.gyp000066400000000000000000000011551331361613700205210ustar00rootroot00000000000000{ "targets": [ { "target_name": "mylib", "product_name": "mylib", "type": "shared_library", "sources": [ "src/implementation.cc" ], "include_dirs": [ "include" ], 'direct_dependent_settings': { 'include_dirs': [ 'include/' ], }, 'xcode_settings': { 'DYLIB_INSTALL_NAME_BASE': '@loader_path/lib.target/', "MACOSX_DEPLOYMENT_TARGET":"10.9", "CLANG_CXX_LIBRARY": "libc++" } } ] } node-pre-gyp-0.10.2/test/app4/deps/src/000077500000000000000000000000001331361613700174515ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app4/deps/src/implementation.cc000066400000000000000000000004031331361613700230020ustar00rootroot00000000000000#include #include namespace MyLib { Message::Message(std::string const& data) : m_data(data) {} std::string const& Message::get() { return m_data; } void Message::set(std::string const& data) { m_data = data; } }; node-pre-gyp-0.10.2/test/app4/index.js000066400000000000000000000003551331361613700173770ustar00rootroot00000000000000var binary = require('node-pre-gyp'); var path = require('path') var binding_path = binary.find(path.resolve(path.join(__dirname,'./package.json'))); var binding = require(binding_path); require('assert').equal(binding.hello(),"hello");node-pre-gyp-0.10.2/test/app4/package.json000066400000000000000000000013631331361613700202200ustar00rootroot00000000000000{ "name": "node-pre-gyp-test-app3", "author": "Dane Springmeyer ", "description":"node-pre-gyp test", "repository" : { "type" : "git", "url" : "git://github.com/mapbox/node-pre-gyp.git" }, "license": "BSD-3-Clause", "version": "0.1.0-dev.4", "main": "./index.js", "binary": { "module_name": "app4", "module_path": "./lib/binding/{node_abi}-{platform}-{arch}", "remote_path": "./{module_name}/v{version}", "package_name": "{node_abi}-{platform}-{arch}.tar.gz", "host":"https://node-pre-gyp-tests.s3-us-west-1.amazonaws.com" }, "scripts": { "install":"node-pre-gyp install --fallback-to-build", "test":"node index.js" } } node-pre-gyp-0.10.2/test/app5/000077500000000000000000000000001331361613700157305ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app5/.gitignore000066400000000000000000000000701331361613700177150ustar00rootroot00000000000000.DS_Store build/ lib/binding/ node_modules npm-debug.lognode-pre-gyp-0.10.2/test/app5/README.md000066400000000000000000000003221331361613700172040ustar00rootroot00000000000000# Test app Tests installing a module that depends on node-pre-gyp (arbitrarily) and depends on a module that needs node-pre-gyp at build time. This is to test https://github.com/mapbox/node-pre-gyp/issues/61.node-pre-gyp-0.10.2/test/app5/index.js000066400000000000000000000003551331361613700174000ustar00rootroot00000000000000var binary = require('node-pre-gyp'); var path = require('path') var binding_path = binary.find(path.resolve(path.join(__dirname,'./package.json'))); var binding = require(binding_path); require('assert').equal(binding.hello(),"hello");node-pre-gyp-0.10.2/test/app5/package.json000066400000000000000000000007371331361613700202250ustar00rootroot00000000000000{ "name": "node-pre-gyp-test-dependents", "author": "Dane Springmeyer ", "description":"node-pre-gyp test", "repository" : { "type" : "git", "url" : "git://github.com/mapbox/node-pre-gyp.git" }, "license": "BSD-3-Clause", "version": "0.1.0", "main": "./index.js", "dependencies": { "node-addon-example": "0.1.5", "node-pre-gyp": "0.5.x" }, "scripts": { "test":"node index.js" } } node-pre-gyp-0.10.2/test/app6/000077500000000000000000000000001331361613700157315ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app6/.gitignore000066400000000000000000000000701331361613700177160ustar00rootroot00000000000000.DS_Store build/ lib/binding/ node_modules npm-debug.lognode-pre-gyp-0.10.2/test/app6/README.md000066400000000000000000000001471331361613700172120ustar00rootroot00000000000000# Test app Tests installing a module that depends on two modules that use node-pre-gyp at build time. node-pre-gyp-0.10.2/test/app6/index.js000066400000000000000000000003551331361613700174010ustar00rootroot00000000000000var binary = require('node-pre-gyp'); var path = require('path') var binding_path = binary.find(path.resolve(path.join(__dirname,'./package.json'))); var binding = require(binding_path); require('assert').equal(binding.hello(),"hello");node-pre-gyp-0.10.2/test/app6/package.json000066400000000000000000000003411331361613700202150ustar00rootroot00000000000000{ "name": "app6", "description": "node-pre-gyp fail testcase", "version": "0.0.0", "engines": { "node": "0.10.x" }, "dependencies": { "node-addon-example": "0.1.3", "node-addon-example2": "0.1.3" } }node-pre-gyp-0.10.2/test/app7/000077500000000000000000000000001331361613700157325ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app7/.gitignore000066400000000000000000000000701331361613700177170ustar00rootroot00000000000000.DS_Store build/ lib/binding/ node_modules npm-debug.lognode-pre-gyp-0.10.2/test/app7/README.md000066400000000000000000000001131331361613700172040ustar00rootroot00000000000000# Test app Demonstrates using N-API to return a JavaScript string object. node-pre-gyp-0.10.2/test/app7/app7.cc000066400000000000000000000013531331361613700171120ustar00rootroot00000000000000// https://github.com/nodejs/abi-stable-node-addon-examples/blob/master/1_hello_world/napi/hello.cc #include #include napi_value Method(napi_env env, napi_callback_info info) { napi_status status; napi_value world; status = napi_create_string_utf8(env, "world", 5, &world); assert(status == napi_ok); return world; } #define DECLARE_NAPI_METHOD(name, func) \ { name, 0, func, 0, 0, 0, napi_default, 0 } napi_value Init(napi_env env, napi_value exports) { napi_status status; napi_property_descriptor desc = DECLARE_NAPI_METHOD("hello", Method); status = napi_define_properties(env, exports, 1, &desc); assert(status == napi_ok); return exports; } NAPI_MODULE(hello, Init) node-pre-gyp-0.10.2/test/app7/binding.gyp000066400000000000000000000004171331361613700200670ustar00rootroot00000000000000{ "targets": [ { "target_name": "<(module_name)", "sources": [ "<(module_name).cc" ], 'product_dir': '<(module_path)', "xcode_settings": { "MACOSX_DEPLOYMENT_TARGET":"10.9", "CLANG_CXX_LIBRARY": "libc++" } } ] } node-pre-gyp-0.10.2/test/app7/index.js000066400000000000000000000003551331361613700174020ustar00rootroot00000000000000var binary = require('node-pre-gyp'); var path = require('path') var binding_path = binary.find(path.resolve(path.join(__dirname,'./package.json'))); var binding = require(binding_path); require('assert').equal(binding.hello(),"world");node-pre-gyp-0.10.2/test/app7/package.json000066400000000000000000000015201331361613700202160ustar00rootroot00000000000000{ "name": "node-pre-gyp-test-app7", "author": "Jim Schlight ", "description": "node-pre-gyp napi test", "repository": { "type": "git", "url": "git://github.com/mapbox/node-pre-gyp.git" }, "license": "BSD-3-Clause", "version": "0.1.0", "main": "./index.js", "binary": { "module_name": "app7", "module_path": "./lib/binding/napi-v{napi_build_version}", "remote_path": "./{module_name}/v{version}/{configuration}/", "package_name": "{module_name}-v{version}-{platform}-{arch}-napi-v{napi_build_version}.tar.gz", "host": "https://node-pre-gyp-tests.s3-us-west-1.amazonaws.com", "napi_versions": [ 1, 2 ] }, "scripts": { "install": "node-pre-gyp install --fallback-to-build" } } node-pre-gyp-0.10.2/test/app8/000077500000000000000000000000001331361613700157335ustar00rootroot00000000000000node-pre-gyp-0.10.2/test/app8/.gitignore000066400000000000000000000000611331361613700177200ustar00rootroot00000000000000.DS_Store build/ lib/ node_modules npm-debug.log node-pre-gyp-0.10.2/test/app8/README.md000066400000000000000000000001111331361613700172030ustar00rootroot00000000000000# Test app Demonstrates a simpler configuration that uses node-pre-gyp. node-pre-gyp-0.10.2/test/app8/app8.cc000066400000000000000000000015001331361613700171060ustar00rootroot00000000000000// v8 #include // node.js #include #include #if (NODE_MODULE_VERSION > 0x000B) static void get_hello(const v8::FunctionCallbackInfo& args) { v8::HandleScope scope(v8::Isolate::GetCurrent()); args.GetReturnValue().Set(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(),"hello")); } #else static v8::Handle get_hello(const v8::Arguments& args) { v8::HandleScope scope; return scope.Close(v8::String::New("hello")); } #endif extern "C" { static void start(v8::Handle target) { #if (NODE_MODULE_VERSION > 0x000B) v8::HandleScope scope(v8::Isolate::GetCurrent()); #else v8::HandleScope scope; #endif NODE_SET_METHOD(target, "hello", get_hello); } } NODE_MODULE(app8, start) node-pre-gyp-0.10.2/test/app8/binding.gyp000066400000000000000000000004171331361613700200700ustar00rootroot00000000000000{ "targets": [ { "target_name": "<(module_name)", "sources": [ "<(module_name).cc" ], "product_dir": "<(module_path)", "xcode_settings": { "MACOSX_DEPLOYMENT_TARGET":"10.9", "CLANG_CXX_LIBRARY": "libc++" } } ] } node-pre-gyp-0.10.2/test/app8/index.js000066400000000000000000000003551331361613700174030ustar00rootroot00000000000000var binary = require('node-pre-gyp'); var path = require('path') var binding_path = binary.find(path.resolve(path.join(__dirname,'./package.json'))); var binding = require(binding_path); require('assert').equal(binding.hello(),"hello");node-pre-gyp-0.10.2/test/app8/package.json000066400000000000000000000011231331361613700202160ustar00rootroot00000000000000{ "name": "node-pre-gyp-test-app8", "author": "Dane Springmeyer ", "description": "node-pre-gyp test", "repository": { "type": "git", "url": "git://github.com/mapbox/node-pre-gyp.git" }, "license": "BSD-3-Clause", "version": "0.1.0", "main": "./index.js", "binary": { "module_name": "app8", "module_path": "./lib", "host": "https://node-pre-gyp-tests.s3-us-west-1.amazonaws.com" }, "scripts": { "install": "node-pre-gyp install --fallback-to-build", "test": "node index.js" } } node-pre-gyp-0.10.2/test/build.test.js000066400000000000000000000451231331361613700175030ustar00rootroot00000000000000"use strict"; var test = require('tape'); var run = require('./run.util.js'); var existsSync = require('fs').existsSync || require('path').existsSync; var fs = require('fs'); var rm = require('rimraf'); var path = require('path'); var getPrevious = require('./target_version.util.js'); var napi = require ('../lib/util/napi.js'); var versioning = require('../lib/util/versioning.js'); var tar = require('tar'); var localVer = [versioning.get_runtime_abi('node'), process.platform, process.arch].join('-'); var SOEXT = {'darwin': 'dylib', 'linux': 'so', 'win32': 'dll'}[process.platform]; // The list of different sample apps that we use to test var apps = [ { 'name': 'app1', 'args': '', 'files': { 'base': ['binding/app1.node'], 'win32': { 'base': [ 'binding/app1.exp', 'binding/app1.lib', 'binding/app1.map', 'binding/app1.node' ], 'node-v59': [ 'binding/app1.exp', 'binding/app1.iobj', 'binding/app1.ipdb', 'binding/app1.lib', 'binding/app1.map', 'binding/app1.node' ], 'node-v64': [ 'binding/app1.exp', 'binding/app1.iobj', 'binding/app1.ipdb', 'binding/app1.lib', 'binding/app1.map', 'binding/app1.node' ] } } }, { 'name': 'app2', 'args': '--custom_include_path=../include --debug', 'files': { 'base': ['node-pre-gyp-test-app2/app2.node'], 'win32': [ 'node-pre-gyp-test-app2/app2.exp', 'node-pre-gyp-test-app2/app2.ilk', 'node-pre-gyp-test-app2/app2.lib', 'node-pre-gyp-test-app2/app2.map', 'node-pre-gyp-test-app2/app2.node' ] } }, { 'name': 'app2', 'args': '--custom_include_path=../include --toolset=cpp11', 'files': { 'base': ['node-pre-gyp-test-app2/app2.node'], 'win32': { 'base': [ 'node-pre-gyp-test-app2/app2.exp', 'node-pre-gyp-test-app2/app2.lib', 'node-pre-gyp-test-app2/app2.map', 'node-pre-gyp-test-app2/app2.node' ], 'node-v59': [ 'node-pre-gyp-test-app2/app2.exp', 'node-pre-gyp-test-app2/app2.iobj', 'node-pre-gyp-test-app2/app2.ipdb', 'node-pre-gyp-test-app2/app2.lib', 'node-pre-gyp-test-app2/app2.map', 'node-pre-gyp-test-app2/app2.node' ], 'node-v64': [ 'node-pre-gyp-test-app2/app2.exp', 'node-pre-gyp-test-app2/app2.iobj', 'node-pre-gyp-test-app2/app2.ipdb', 'node-pre-gyp-test-app2/app2.lib', 'node-pre-gyp-test-app2/app2.map', 'node-pre-gyp-test-app2/app2.node' ] } } }, { 'name': 'app3', 'args': '', 'files': { 'base': [[localVer, 'app3.node'].join('/')], 'win32': { 'base': [ [localVer, 'app3.exp'].join('/'), [localVer, 'app3.lib'].join('/'), [localVer, 'app3.map'].join('/'), [localVer, 'app3.node'].join('/') ], 'node-v59': [ [localVer, 'app3.exp'].join('/'), [localVer, 'app3.iobj'].join('/'), [localVer, 'app3.ipdb'].join('/'), [localVer, 'app3.lib'].join('/'), [localVer, 'app3.map'].join('/'), [localVer, 'app3.node'].join('/'), ], 'node-v64': [ [localVer, 'app3.exp'].join('/'), [localVer, 'app3.iobj'].join('/'), [localVer, 'app3.ipdb'].join('/'), [localVer, 'app3.lib'].join('/'), [localVer, 'app3.map'].join('/'), [localVer, 'app3.node'].join('/'), ] } } }, { 'name': 'app4', 'args': '', 'files': { 'base': [[localVer, 'app4.node'].join('/'), [localVer, 'lib.target', 'mylib.' + SOEXT].join('/')], 'win32': [[localVer, 'app4.node'].join('/'), [localVer, 'mylib.' + SOEXT].join('/')] } }, { 'name': 'app7', 'args': '' }, { 'name': 'app8', 'args': '', 'files': { 'base': ['lib/app8.node'], 'win32': { 'base': [ 'lib/app8.exp', 'lib/app8.lib', 'lib/app8.map', 'lib/app8.node' ], 'node-v59': [ 'lib/app8.exp', 'lib/app8.iobj', 'lib/app8.ipdb', 'lib/app8.lib', 'lib/app8.map', 'lib/app8.node' ], 'node-v64': [ 'lib/app8.exp', 'lib/app8.iobj', 'lib/app8.ipdb', 'lib/app8.lib', 'lib/app8.map', 'lib/app8.node' ] } } } ]; // https://stackoverflow.com/questions/38599457/how-to-write-a-custom-assertion-for-testing-node-or-javascript-with-tape-or-che test.Test.prototype.stringContains = function(actual, contents, message) { this._assert(actual.indexOf(contents) > -1, { message: message || 'should contain '+contents, operator: 'stringContains', actual: actual, expected: contents }); }; // Because the below tests only ensure that flags can be correctly passed to node-gyp is it not // likely they will behave differently for different apps. So we save time by avoiding running these for each app. var app = apps[0]; // make sure node-gyp options are passed by passing invalid values // and ensuring the expected errors are returned from node-gyp test(app.name + ' passes --nodedir down to node-gyp via node-pre-gyp ' + app.args, function(t) { run('node-pre-gyp', 'configure', '--nodedir=invalid-value', app, {}, function(err,stdout,stderr) { t.ok(err,'Expected command to fail'); t.stringContains(stderr,"common.gypi not found"); t.end(); }); }); // NOTE: currently fails with npm v3.x on windows (hence downgrade in appveyor.yml) test(app.name + ' passes --nodedir down to node-gyp via npm' + app.args, function(t) { run('npm', 'install', '--build-from-source --nodedir=invalid-value', app, {}, function(err,stdout,stderr) { t.ok(err, 'Expected command to fail'); t.stringContains(stderr,"common.gypi not found"); t.end(); }); }); // these will not fail on windows because node-gyp falls back to the python launcher instead of erroring out: // https://github.com/nodejs/node-gyp/blob/c84a54194781410743efe353d18ca7d20fc9d3a3/lib/configure.js#L396-L397 if (process.platform !== 'win32') { test(app.name + ' passes --python down to node-gyp via node-pre-gyp ' + app.args, function(t) { run('node-pre-gyp', 'configure', '--python=invalid-value', app, {}, function(err,stdout,stderr) { t.ok(err, 'Expected command to fail'); t.stringContains(stderr,"Can't find Python executable"); t.end(); }); }); test(app.name + ' passes --python down to node-gyp via npm ' + app.args, function(t) { run('node-pre-gyp', 'configure', '--build-from-source --python=invalid-value', app, {}, function(err,stdout,stderr) { t.ok(err, 'Expected command to fail'); t.stringContains(stderr,"Can't find Python executable"); t.end(); }); }); } // note: --ensure=false tells node-gyp to attempt to re-download the node headers // even if they already exist on disk at ~/.node-gyp/{version} test(app.name + ' passes --dist-url down to node-gyp via node-pre-gyp ' + app.args, function(t) { run('node-pre-gyp', 'configure', '--ensure=false --dist-url=invalid-value', app, {}, function(err,stdout,stderr) { t.ok(err, 'Expected command to fail'); t.end(); }); }); test(app.name + ' passes --dist-url down to node-gyp via npm ' + app.args, function(t) { run('npm', 'install', '--build-from-source --ensure=false --dist-url=invalid-value', app, {}, function(err,stdout,stderr) { t.ok(err, 'Expected command to fail'); t.end(); }); }); // Tests run for all apps apps.forEach(function(app) { if (app.name === 'app7' && !napi.get_napi_version()) return; // clear out entire binding directory // to ensure no stale builds. This is needed // because "node-pre-gyp clean" only removes // the current target and not alternative builds test('cleanup of app', function(t) { var binding_directory = path.join(__dirname,app.name,'lib/binding'); if (fs.existsSync(binding_directory)) { rm.sync(binding_directory); } t.end(); }); test(app.name + ' configures ' + app.args, function(t) { run('node-pre-gyp', 'configure', '--loglevel=error', app, {}, function(err,stdout,stderr) { t.ifError(err); t.end(); }); }); test(app.name + ' configures with unparsed options ' + app.args, function(t) { run('node-pre-gyp', 'configure', '--loglevel=info -- -Dfoo=bar', app, {}, function(err,stdout,stderr) { t.ifError(err); t.ok(stderr.search(/(gyp info spawn args).*(-Dfoo=bar)/) > -1); t.end(); }); }); test(app.name + ' builds with unparsed options ' + app.args, function(t) { // clean and build as separate steps here because configure only works with -Dfoo=bar // and build only works with FOO=bar run('node-pre-gyp', 'clean', '', app, {}, function(err) { t.ifError(err); var propertyPrefix = (process.platform === 'win32') ? '/p:' : ''; run('node-pre-gyp', 'build', '--loglevel=info -- ' + propertyPrefix + 'FOO=bar', app, {}, function(err,stdout,stderr) { t.ifError(err); t.ok(stderr.search(/(gyp info spawn args).*(FOO=bar)/) > -1); if (process.platform !== 'win32') { if (app.args.indexOf('--debug') > -1) { t.stringContains(stdout,'Debug/'+app.name+'.node'); } else { t.stringContains(stdout,'Release/'+app.name+'.node'); } } t.end(); }); }); }); test(app.name + ' builds ' + app.args, function(t) { run('node-pre-gyp', 'rebuild', '--fallback-to-build --loglevel=error', app, {}, function(err,stdout,stderr) { t.ifError(err); if (process.platform !== 'win32') { if (app.args.indexOf('--debug') > -1) { t.stringContains(stdout,'Debug/'+app.name+'.node'); } else { t.stringContains(stdout,'Release/'+app.name+'.node'); } } t.end(); }); }); test(app.name + ' is found ' + app.args, function(t) { run('node-pre-gyp', 'reveal', 'module_path --silent', app, {}, function(err,stdout,stderr) { t.ifError(err); var module_path = stdout.trim(); if (module_path.indexOf('\n') !== -1) { // take just the first line module_path = module_path.substr(0,module_path.indexOf('\n')); } t.stringContains(module_path,app.name); t.ok(existsSync(module_path),'is valid path to existing binary: '+ module_path); var module_binary = path.join(module_path,app.name+'.node'); t.ok(existsSync(module_binary)); t.end(); }); }); test(app.name + ' passes tests ' + app.args, function(t) { run('npm','test','', app, {cwd: path.join(__dirname,app.name)}, function(err,stdout,stderr) { t.ifError(err); // we expect app2 to console.log on success if (app.name == 'app2') { if (app.args.indexOf('--debug') > -1) { t.stringContains(stdout,'Loaded Debug build'); } else { t.stringContains(stdout,'Loaded Release build'); } } else { // we expect some npm output t.notEqual(stdout,''); } t.end(); }); }); test(app.name + ' packages ' + app.args, function(t) { run('node-pre-gyp', 'package', '', app, {}, function(err,stdout,stderr) { t.ifError(err); // Make sure a tarball was created run('node-pre-gyp', 'reveal', 'staged_tarball --silent', app, {}, function(err,stdout,stderr) { t.ifError(err); var staged_tarball = stdout.trim(); if (staged_tarball.indexOf('\n') !== -1) { // take just the first line staged_tarball = staged_tarball.substr(0,staged_tarball.indexOf('\n')); } var tarball_path = path.join(__dirname, app.name, staged_tarball); t.ok(existsSync(tarball_path),'staged tarball is a valid file'); if (!app.files) { return t.end(); } // Make sure the package contains what we expect var entries = []; tar.t({ file: tarball_path, sync: true, onentry: function (entry) { entries.push(entry.path); } }); var files = app.files.base; var nodever = versioning.get_runtime_abi('node'); // Look for a more specific choice if (app.files.hasOwnProperty(process.platform)) { if (app.files[process.platform].hasOwnProperty(nodever)) { files = app.files[process.platform][nodever]; } else if (app.files[process.platform].hasOwnProperty('base')) { files = app.files[process.platform].base; } else { files = app.files[process.platform]; } } t.same(entries.sort(), files.sort(), 'staged tarball contains the right files'); t.end(); }); }); }); test(app.name + ' package is valid ' + app.args, function(t) { run('node-pre-gyp', 'testpackage', '', app, {}, function(err,stdout,stderr) { t.ifError(err); t.end(); }); }); if (process.env.AWS_ACCESS_KEY_ID || process.env.node_pre_gyp_accessKeyId) { test(app.name + ' publishes ' + app.args, function(t) { run('node-pre-gyp', 'unpublish publish', '', app, {}, function(err,stdout,stderr) { t.ifError(err); t.notEqual(stdout,''); t.end(); }); }); test(app.name + ' info shows it ' + app.args, function(t) { run('node-pre-gyp', 'reveal', 'package_name', app, {}, function(err,stdout,stderr) { t.ifError(err); var package_name = stdout.trim(); if (package_name.indexOf('\n') !== -1) { // take just the first line package_name = package_name.substr(0,package_name.indexOf('\n')); } run('node-pre-gyp', 'info', '', app, {}, function(err,stdout,stderr) { t.ifError(err); t.stringContains(stdout,package_name); t.end(); }); }); }); test(app.name + ' can be uninstalled ' + app.args, function(t) { run('node-pre-gyp', 'clean', '', app, {}, function(err,stdout,stderr) { t.ifError(err); t.notEqual(stdout,''); t.end(); }); }); test(app.name + ' can be installed via remote ' + app.args, function(t) { run('npm', 'install', '--fallback-to-build=false', app, {cwd: path.join(__dirname,app.name)}, function(err,stdout,stderr) { t.ifError(err); t.notEqual(stdout,''); t.end(); }); }); test(app.name + ' can be reinstalled via remote ' + app.args, function(t) { run('npm', 'install', '--update-binary --fallback-to-build=false', app, {cwd: path.join(__dirname,app.name)}, function(err,stdout,stderr) { t.ifError(err); t.notEqual(stdout,''); t.end(); }); }); test(app.name + ' via remote passes tests ' + app.args, function(t) { run('npm', 'install', '', app, {cwd: path.join(__dirname,app.name)}, function(err,stdout,stderr) { t.ifError(err); t.notEqual(stdout,''); t.end(); }); }); } else { test.skip(app.name + ' publishes ' + app.args, function() {}); } // note: the above test will result in a non-runnable binary, so the below test must succeed otherwise all following tests will fail test(app.name + ' builds with custom --target ' + app.args, function(t) { run('node-pre-gyp', 'rebuild', '--loglevel=error --fallback-to-build --target='+process.versions.node, app, {}, function(err,stdout,stderr) { t.ifError(err); t.end(); }); }); }); node-pre-gyp-0.10.2/test/fetch.test.js000066400000000000000000000017531331361613700174760ustar00rootroot00000000000000"use strict"; var test = require('tape'); var nock = require('nock'); var install = require('../lib/install.js'); test('should follow redirects', function(t) { // Dummy tar.gz data, contains a blank directory. var targz = 'H4sICPr8u1oCA3kudGFyANPTZ6A5MDAwMDc1VQDTZhAaCGA0hGNobGRqZm5uZmxupGBgaGhiZsKgYMpAB1BaXJJYBHRKYk5pcioedeUZqak5+D2J5CkFhlEwCkbBKBjkAAAyG1ofAAYAAA=='; // Mock an HTTP redirect var n = nock('https://node-pre-gyp-tests.s3-us-west-1.amazonaws.com') .get(/\/app1-v0.1.0-node-v\d+-\S+.tar.gz/) .reply(302, '', { 'Location': 'https://node-pre-gyp-tests.s3-us-west-1.amazonaws.com/otherapp.tar.gz' }) .get('/otherapp.tar.gz') .reply(200, Buffer.from(targz, 'base64')); var opts = { opts: { 'build-from-source': false, 'update-binary': true } }; process.chdir('test/app1'); install(opts, [], function(err) { t.ifError(err); // Worked fine t.ok(n.isDone()); // All mocks consumed t.end(); }); }); node-pre-gyp-0.10.2/test/run.util.js000066400000000000000000000052071331361613700172050ustar00rootroot00000000000000var cp = require('child_process'); var path = require('path'); /* Convenience function to call out to local node-pre-gyp or npm */ var cmd_path = path.join(__dirname,'../bin/'); var sep = ':'; if (process.platform === 'win32') { sep = ';'; } function run(prog,command,args,app,opts,cb) { // validate args if (!prog) throw new Error("prog arg undefined"); if (!command) throw new Error("command arg undefined"); if (!app) throw new Error("app arg undefined"); if (!app.name) throw new Error("app.name undefined"); // start forming up the command we will execute. // here we add the program and the command var final_cmd = prog + ' ' + command; // if we are calling out to `node-pre-gyp` let's ensure we directly // call the local version at a relative path (to avoid the change) we might // use some external version on PATH if (final_cmd.indexOf('node-pre-gyp') > -1) { final_cmd = cmd_path + final_cmd; } // if npm we need to put our local node_gyp on path if (final_cmd.indexOf('npm') > -1) { opts.env = process.env; // needed for npm to find node-pre-gyp locally opts.env.PATH = cmd_path + sep + process.env.PATH; // needed for apps that require node-pre-gyp to find local module // since they don't install a copy in their node_modules opts.env.NODE_PATH = NODE_PATH = path.join(__dirname,'../lib/'); } // unless explicitly provided, lets execute the command inside the app specific directory if (!opts.cwd) { opts.cwd = path.join(__dirname,app.name); } // avoid breakage when compiling with clang++ and node v0.10.x // This is harmless to add for other versions and platforms final_cmd += ' --clang=1'; // Test building with msvs 2015 since that is more edge case than 2013 if (process.platform === 'win32') { final_cmd += ' --msvs_version=2015 '; } // finish appending all arguments final_cmd += ' ' + app.args; final_cmd += ' ' + args; // On unix we want to display compile args (rather than have them hidden) // for easier debugging of unexpected compile failures. // We do this by pre-pending the magic variable that make responds to. if (process.platform !== 'win32') { final_cmd = 'V=1 ' + final_cmd; } // Finally, execute the command cp.exec(final_cmd,opts,function(err,stdout,stderr) { if (err) { var error = new Error("Command failed '" + final_cmd + "'"); error.stack = stderr; return cb(error,stdout,stderr); } return cb(err,stdout,stderr); }); } module.exports = run;node-pre-gyp-0.10.2/test/s3_setup.test.js000066400000000000000000000012551331361613700201470ustar00rootroot00000000000000"use strict"; var s3_setup = require('../lib/util/s3_setup.js'); var test = require('tape'); test('should propertly detect s3 bucket and prefix', function(t) { var url = "https://node-pre-gyp-tests.s3-us-west-1.amazonaws.com"; var result = {}; s3_setup.detect(url, result); t.equal(result.prefix,''); t.equal(result.bucket,'node-pre-gyp-tests'); t.end(); }); test('should propertly detect s3 bucket and prefix with dots', function(t) { var url = "https://bucket.with.dots.s3.amazonaws.com/prefix"; var result = {}; s3_setup.detect(url, result); t.equal(result.prefix,'prefix'); t.equal(result.bucket,'bucket.with.dots'); t.end(); }); node-pre-gyp-0.10.2/test/target_version.test.js000066400000000000000000000076131331361613700214410ustar00rootroot00000000000000"use strict"; var getPrevious = require('./target_version.util.js'); var run = require('./run.util.js'); var abi_crosswalk = require('../lib/util/abi_crosswalk.json'); var os = require('os'); var fs = require('fs'); var path = require('path'); var test = require('tape'); test('should properly calculate previous version', function(t) { t.equal(getPrevious('1.0.0',abi_crosswalk),undefined); t.equal(getPrevious('1.0.1',abi_crosswalk),'1.0.0'); t.equal(getPrevious('1.0.2',abi_crosswalk),'1.0.1'); t.end(); }); /* Context: node-pre-gyp can "cross-install" which means that you can install binaries for a given node version that is different than the node version you are running. This is possible by passing the `--target` flag with a value for a given node version you want to target like `--target=4.3.4`. Internally node-pre-gyp will take this version (4.3.4), figure out the ABI version for it (aka `process.versions.modules`) and then install the right binary. */ // Get all major values for released node versions we know about var versions = []; Object.keys(abi_crosswalk).forEach(function(v) { var major = +v.split('.')[0]; //console.log(major) if (!(versions.indexOf(major) > -1)) { versions.push(major); } }); test('every major version should have a unique ABI that is consistent across all major versions', function(t) { var abis = {}; Object.keys(abi_crosswalk).forEach(function(v) { var major = +v.split('.')[0]; if (major >= 2) { var o = abi_crosswalk[v]; if (!abis[major]) { abis[major] = o.node_abi; } else { t.equal(abis[major],o.node_abi,v + ' should have abi: ' + o.node_abi); } } }); t.end(); }); var found = false; var current_version = process.versions.node; var major = +(current_version.split('.')[0]); test('ensure crosswalk has major version of current node', function(t) { found = versions.indexOf(major) > -1; t.ok(found); t.end(); }); /* If we know: - the current version is in the crosswalk - it has a previous patch version (it is at least x.x.1) - and that x.x.1 has been released Then we test the --target flag by: - pretending current version is the previous version - the current version does not exist in the abi_crosswalk (by mocking it) */ var previous_patch_version = getPrevious(current_version,abi_crosswalk); if (previous_patch_version && previous_patch_version !== current_version) { var app = {'name': 'app1', 'args': '' }; test(app.name + ' builds with custom --target='+previous_patch_version+' that is greater than known version in ABI crosswalk ' + app.args, function(t) { if (found) { // construct a mock abi_crosswalk that contains only the previous node version // and not the current node version var target_abi = {}; target_abi[previous_patch_version] = abi_crosswalk[previous_patch_version]; // write this crosswalk to disk var testing_crosswalk = path.join(os.tmpdir(),'fake_abi_crosswalk.json'); fs.writeFileSync(testing_crosswalk,JSON.stringify(target_abi)); // pass mock crosswalk to env so that the node-pre-gyp we shell out to // uses the mock crosswalk var new_env = JSON.parse(JSON.stringify(process.env)); new_env.NODE_PRE_GYP_ABI_CROSSWALK = testing_crosswalk; var opts = { env : new_env }; run('node-pre-gyp', 'rebuild', '--loglevel=error --fallback-to-build --target='+previous_patch_version, app, opts, function(err,stdout,stderr) { t.ifError(err); run('node-pre-gyp', 'clean', '--target='+current_version, app, opts, function(err,stdout,stderr) { t.ifError(err); t.notEqual(stdout,''); t.end(); }); }); } }); } node-pre-gyp-0.10.2/test/target_version.util.js000066400000000000000000000015421331361613700214320ustar00rootroot00000000000000 /* Takes the current version (major.minor.patch) and returns the previous patch version. For a version like `v1.0.0` this would return `undefined` For a version like `v1.0.1` this would return `v1.0.0` */ function getPreviousVersion(current_version, abi_crosswalk) { var current_parts = current_version.split('.').map(function(i) { return +i; }); var major = current_parts[0]; var minor = current_parts[1]; var patch = current_parts[2]; while (patch > 0) { --patch; var new_target = '' + major + '.' + minor + '.' + patch; if (new_target == current_version) { break; } if (abi_crosswalk[new_target]) { return new_target; } } // failed to find suitable future version that we expect is ABI compatible return undefined; } module.exports = getPreviousVersion;node-pre-gyp-0.10.2/test/versioning.test.js000066400000000000000000000130501331361613700205610ustar00rootroot00000000000000"use strict"; var path = require('path'); var versioning = require('../lib/util/versioning.js'); var test = require('tape'); var detect_libc = require('detect-libc'); test('should normalize double slash', function(t) { var mock_package_json = { "name" : "test", "main" : "test.js", "version": "0.1.0", "binary" : { "module_name" : "test", "module_path" : "./lib/binding/{configuration}/{toolset}/{name}", "remote_path" : "./{name}/v{version}/{configuration}/{version}/{toolset}/", "package_name": "{module_name}-v{major}.{minor}.{patch}-{prerelease}+{build}-{toolset}-{node_abi}-{platform}-{arch}.tar.gz", "host" : "https://node-pre-gyp-tests.s3-us-west-1.amazonaws.com" } }; var opts = versioning.evaluate(mock_package_json, {}); t.equal(opts.remote_path,"./test/v0.1.0/Release/0.1.0/"); // Node v0.11.x on windows lowercases C:// when path.join is called // https://github.com/joyent/node/issues/7031 t.equal(path.normalize(opts.module_path),path.join(process.cwd(),"lib/binding/Release/test")); var opts_toolset = versioning.evaluate(mock_package_json, {toolset:"custom-toolset"}); t.equal(opts_toolset.remote_path,"./test/v0.1.0/Release/0.1.0/custom-toolset/"); t.end(); }); test('should detect abi for node process', function(t) { var mock_process_versions = { node: '0.10.33', v8: '3.14.5.9', modules: '11', }; var abi = versioning.get_node_abi('node',mock_process_versions); t.equal(abi,'node-v11'); t.equal(versioning.get_runtime_abi('node',undefined),versioning.get_node_abi('node',process.versions)); t.end(); }); test('should detect abi for odd node target', function(t) { var mock_process_versions = { node: '0.11.1000000', modules: 'bogus', }; var abi = versioning.get_node_abi('node',mock_process_versions); t.equal(abi,'node-v0.11.1000000'); t.end(); }); test('should detect abi for custom node target', function(t) { var mock_process_versions = { "node": '0.10.0', "modules": '11', }; t.equal(versioning.get_runtime_abi('node','0.10.0'),versioning.get_node_abi('node',mock_process_versions)); var mock_process_versions2 = { "node": '0.8.0', "v8": "3.11" }; t.equal(versioning.get_runtime_abi('node','0.8.0'),versioning.get_node_abi('node',mock_process_versions2)); t.end(); }); test('should detect runtime for node-webkit and electron', function(t) { var mock_process_versions = { "electron": '0.37.3', }; t.equal(versioning.get_process_runtime(mock_process_versions),'electron'); var mock_process_versions2 = { "node": '0.8.0', }; t.equal(versioning.get_process_runtime(mock_process_versions2),'node'); var mock_process_versions3 = { "node-webkit": '0.37.3', }; t.equal(versioning.get_process_runtime(mock_process_versions3),'node-webkit'); t.end(); }); test('should detect abi for electron runtime', function(t) { t.equal(versioning.get_runtime_abi('electron','0.37.3'),versioning.get_electron_abi('electron','0.37.3')); t.end(); }); test('should detect abi for node-webkit runtime', function(t) { t.equal(versioning.get_runtime_abi('node-webkit','0.10.5'),versioning.get_node_webkit_abi('node-webkit','0.10.5')); t.end(); }); test('should detect custom binary host from env', function(t) { var mock_package_json = { "name" : "test", "main" : "test.js", "version": "0.1.0", "binary" : { "module_name" : "test", "module_path" : "./lib/binding/{configuration}/{toolset}/{name}", "remote_path" : "./{name}/v{version}/{configuration}/{version}/{toolset}/", "package_name": "{module_name}-v{major}.{minor}.{patch}-{prerelease}+{build}-{toolset}-{node_abi}-{platform}-{arch}.tar.gz", "host" : "https://node-pre-gyp-tests.s3-us-west-1.amazonaws.com" } }; // mock npm_config_test_binary_host_mirror env process.env.npm_config_test_binary_host_mirror = 'https://npm.taobao.org/mirrors/node-inspector/'; var opts = versioning.evaluate(mock_package_json, {}); t.equal(opts.host,'https://npm.taobao.org/mirrors/node-inspector/'); delete process.env.npm_config_test_binary_host_mirror; t.end(); }); test('should detect libc', function(t) { var mock_package_json = { "name" : "test", "main" : "test.js", "version": "0.1.0", "binary" : { "module_name" : "test", "module_path" : "./lib/binding/{name}-{libc}", "remote_path" : "./{name}/{libc}/", "package_name": "{module_name}-{libc}.tar.gz", "host" : "https://node-pre-gyp-tests.s3-us-west-1.amazonaws.com" } }; var opts = versioning.evaluate(mock_package_json, { module_root: '/root' }); var expected_libc_token = detect_libc.family || 'unknown'; t.comment('performing test with the following libc token: ' + expected_libc_token); t.equal(opts.module_path, path.normalize("/root/lib/binding/test-" + expected_libc_token)); t.equal(opts.module, path.normalize("/root/lib/binding/test-" + expected_libc_token + '/test.node')); t.equal(opts.remote_path, "./test/" + expected_libc_token + "/"); t.equal(opts.package_name, "test-" + expected_libc_token + ".tar.gz"); t.equal(opts.hosted_tarball, "https://node-pre-gyp-tests.s3-us-west-1.amazonaws.com/test/" + expected_libc_token + "/test-" + expected_libc_token + ".tar.gz"); t.end(); });