node-datachannel 0.1.10 → 0.1.14-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CMakeLists.txt +13 -3
  2. package/README.md +2 -7
  3. package/node_modules/delegates/package.json +0 -1
  4. package/node_modules/has-unicode/package.json +0 -1
  5. package/node_modules/ini/ini.js +49 -37
  6. package/node_modules/ini/package.json +22 -19
  7. package/node_modules/node-abi/.github/workflows/update-abi.yml +1 -1
  8. package/node_modules/node-abi/.travis.yml +2 -4
  9. package/node_modules/node-abi/README.md +1 -1
  10. package/node_modules/node-abi/abi_registry.json +46 -1
  11. package/node_modules/node-abi/index.js +7 -1
  12. package/node_modules/node-abi/package.json +10 -11
  13. package/node_modules/node-abi/scripts/update-abi-registry.js +11 -5
  14. package/node_modules/prebuild-install/CHANGELOG.md +75 -1
  15. package/node_modules/prebuild-install/README.md +43 -12
  16. package/node_modules/prebuild-install/asset.js +1 -5
  17. package/node_modules/prebuild-install/bin.js +4 -11
  18. package/node_modules/prebuild-install/download.js +55 -43
  19. package/node_modules/prebuild-install/help.txt +2 -0
  20. package/node_modules/prebuild-install/log.js +12 -0
  21. package/node_modules/prebuild-install/package.json +14 -15
  22. package/node_modules/prebuild-install/proxy.js +2 -5
  23. package/node_modules/prebuild-install/rc.js +11 -32
  24. package/node_modules/prebuild-install/util.js +49 -3
  25. package/node_modules/readable-stream/package.json +0 -1
  26. package/node_modules/safe-buffer/package.json +0 -1
  27. package/node_modules/string-width/package.json +2 -3
  28. package/package.json +19 -10
  29. package/src/data-channel-wrapper.cpp +62 -30
  30. package/src/data-channel-wrapper.h +19 -9
  31. package/src/peer-connection-wrapper.cpp +56 -28
  32. package/src/peer-connection-wrapper.h +19 -9
  33. package/src/rtc-wrapper.cpp +11 -1
  34. package/src/rtc-wrapper.h +3 -1
  35. package/src/thread-safe-callback.cpp +69 -0
  36. package/src/thread-safe-callback.h +57 -0
  37. package/test/connectivity.js +2 -1
  38. package/test/test.js +111 -112
  39. package/node_modules/noop-logger/.npmignore +0 -1
  40. package/node_modules/noop-logger/History.md +0 -16
  41. package/node_modules/noop-logger/Makefile +0 -8
  42. package/node_modules/noop-logger/Readme.md +0 -27
  43. package/node_modules/noop-logger/circle.yml +0 -9
  44. package/node_modules/noop-logger/lib/index.js +0 -25
  45. package/node_modules/noop-logger/package.json +0 -51
  46. package/node_modules/noop-logger/test/index.js +0 -18
  47. package/node_modules/prebuild-install/.travis.yml +0 -12
  48. package/node_modules/prebuild-install/appveyor.yml +0 -40
  49. package/node_modules/which-pm-runs/LICENSE +0 -21
  50. package/node_modules/which-pm-runs/README.md +0 -29
  51. package/node_modules/which-pm-runs/index.js +0 -17
  52. package/node_modules/which-pm-runs/package.json +0 -64
@@ -1,19 +1,36 @@
1
1
  # prebuild-install
2
2
 
3
- > A command line tool to easily install prebuilt binaries for multiple version of node/iojs on a specific platform.
3
+ > **A command line tool to easily install prebuilt binaries for multiple versions of Node.js & Electron on a specific platform.**
4
+ > By default it downloads prebuilt binaries from a GitHub release.
4
5
 
5
6
  [![npm](https://img.shields.io/npm/v/prebuild-install.svg)](https://www.npmjs.com/package/prebuild-install)
6
7
  ![Node version](https://img.shields.io/node/v/prebuild-install.svg)
7
- [![Build Status](https://travis-ci.org/prebuild/prebuild-install.svg?branch=master)](https://travis-ci.org/prebuild/prebuild-install)
8
- [![Build status](https://ci.appveyor.com/api/projects/status/6v6hxxwgjrr99pc8/branch/master?svg=true)](https://ci.appveyor.com/project/mathiask88/prebuild-install)
8
+ [![Test](https://github.com/prebuild/prebuild-install/actions/workflows/test.yml/badge.svg)](https://github.com/prebuild/prebuild-install/actions/workflows/test.yml)
9
9
  [![david](https://david-dm.org/prebuild/prebuild-install.svg)](https://david-dm.org/prebuild/prebuild-install)
10
10
  [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
11
11
 
12
- `prebuild-install` supports installing prebuilt binaries from GitHub by default.
12
+ ## Note
13
+
14
+ **Instead of [`prebuild`](https://github.com/prebuild/prebuild) paired with [`prebuild-install`](https://github.com/prebuild/prebuild-install), we recommend [`prebuildify`](https://github.com/prebuild/prebuildify) paired with [`node-gyp-build`](https://github.com/prebuild/node-gyp-build).**
15
+
16
+ With `prebuildify`, all prebuilt binaries are shipped inside the package that is published to npm, which means there's no need for a separate download step like you find in `prebuild`. The irony of this approach is that it is faster to download all prebuilt binaries for every platform when they are bundled than it is to download a single prebuilt binary as an install script.
17
+
18
+ Upsides:
19
+
20
+ 1. No extra download step, making it more reliable and faster to install.
21
+ 2. Supports changing runtime versions locally and using the same install between Node.js and Electron. Reinstalling or rebuilding is not necessary, as all prebuilt binaries are in the npm tarball and the correct one is simply picked on runtime.
22
+ 3. The `node-gyp-build` runtime dependency is dependency-free and will remain so out of principle, because introducing dependencies would negate the shorter install time.
23
+ 4. Prebuilt binaries work even if npm install scripts are disabled.
24
+ 5. The npm package checksum covers prebuilt binaries too.
25
+
26
+ Downsides:
27
+
28
+ 1. The installed npm package is larger on disk. Using [Node-API](https://nodejs.org/api/n-api.html) alleviates this because Node-API binaries are runtime-agnostic and forward-compatible.
29
+ 2. Publishing is mildly more complicated, because `npm publish` must be done after compiling and fetching prebuilt binaries (typically in CI).
13
30
 
14
31
  ## Usage
15
32
 
16
- Change your package.json install script to:
33
+ Use [`prebuild`](https://github.com/prebuild/prebuild) to create and upload prebuilt binaries. Then change your package.json install script to:
17
34
 
18
35
  ```json
19
36
  {
@@ -23,10 +40,6 @@ Change your package.json install script to:
23
40
  }
24
41
  ```
25
42
 
26
- ### Requirements
27
-
28
- You need to provide prebuilds made by [`prebuild`](https://github.com/prebuild/prebuild).
29
-
30
43
  ### Help
31
44
 
32
45
  ```
@@ -37,6 +50,8 @@ prebuild-install [options]
37
50
  --runtime -r runtime (Node runtime [node, napi or electron] to build or install for, default is node)
38
51
  --path -p path (make a prebuild-install here)
39
52
  --token -T gh-token (github token for private repos)
53
+ --arch arch (target CPU architecture, see Node OS module docs, default is current arch)
54
+ --platform platform (target platform, see Node OS module docs, default is current platform)
40
55
  --tag-prefix <prefix> (github tag prefix, default is "v")
41
56
  --build-from-source (skip prebuild download)
42
57
  --verbose (log verbosely)
@@ -45,9 +60,9 @@ prebuild-install [options]
45
60
  --version (print prebuild-install version and exit)
46
61
  ```
47
62
 
48
- When `prebuild-install` is run via an `npm` script, options
49
- `--build-from-source`, `--debug` and `--download`, may be passed through via
50
- arguments given to the `npm` command.
63
+ When `prebuild-install` is run via an `npm` script, options `--build-from-source`, `--debug`, `--download`, `--target`, `--runtime`, `--arch` and `--platform` may be passed through via arguments given to the `npm` command.
64
+
65
+ Alternatively you can set environment variables `npm_config_build_from_source=true`, `npm_config_platform`, `npm_config_arch`, `npm_config_target` and `npm_config_runtime`.
51
66
 
52
67
  ### Private Repositories
53
68
 
@@ -95,6 +110,22 @@ So if you are installing `leveldown@1.2.3` the resulting url will be:
95
110
  http://overriden-host.com/overriden-path/v1.2.3/leveldown-v1.2.3-node-v57-win32-x64.tar.gz
96
111
  ```
97
112
 
113
+ #### Local prebuilds
114
+
115
+ If you want to use prebuilds from your local filesystem, you can use the `% your package name %_local_prebuilds` .npmrc variable to set a path to the folder containing prebuilds. For example:
116
+
117
+ ```
118
+ leveldown_local_prebuilds=/path/to/prebuilds
119
+ ```
120
+
121
+ This option will look directly in that folder for bundles created with `prebuild`, for example:
122
+
123
+ ```
124
+ /path/to/prebuilds/leveldown-v1.2.3-node-v57-win32-x64.tar.gz
125
+ ```
126
+
127
+ Non-absolute paths resolve relative to the directory of the package invoking prebuild-install, e.g. for nested dependencies.
128
+
98
129
  ### Cache
99
130
 
100
131
  All prebuilt binaries are cached to minimize traffic. So first `prebuild-install` picks binaries from the cache and if no binary could be found, it will be downloaded. Depending on the environment, the cache folder is determined in the following order:
@@ -1,15 +1,11 @@
1
1
  var get = require('simple-get')
2
2
  var util = require('./util')
3
3
  var proxy = require('./proxy')
4
- var noop = Object.assign({
5
- http: function () {},
6
- silly: function () {}
7
- }, require('noop-logger'))
8
4
 
9
5
  function findAssetId (opts, cb) {
10
6
  var downloadUrl = util.getDownloadUrl(opts)
11
7
  var apiUrl = util.getApiUrl(opts)
12
- var log = opts.log || noop
8
+ var log = opts.log || util.noopLogger
13
9
 
14
10
  log.http('request', 'GET ' + apiUrl)
15
11
  var reqOpts = proxy({
@@ -2,7 +2,6 @@
2
2
 
3
3
  var path = require('path')
4
4
  var fs = require('fs')
5
- var whichPmRuns = require('which-pm-runs')
6
5
  var napi = require('napi-build-utils')
7
6
 
8
7
  var pkg = require(path.resolve('package.json'))
@@ -42,21 +41,15 @@ var opts = Object.assign({}, rc, { pkg: pkg, log: log })
42
41
 
43
42
  if (napi.isNapiRuntime(rc.runtime)) napi.logUnsupportedVersion(rc.target, log)
44
43
 
45
- var pm = whichPmRuns()
46
- var isNpm = !pm || pm.name === 'npm'
44
+ var origin = util.packageOrigin(process.env, pkg)
47
45
 
48
- if (!isNpm && /node_modules/.test(process.cwd())) {
49
- // From yarn repository
50
- } else if (opts.force) {
46
+ if (opts.force) {
51
47
  log.warn('install', 'prebuilt binaries enforced with --force!')
52
48
  log.warn('install', 'prebuilt binaries may be out of date!')
53
- } else if (!(typeof pkg._from === 'string')) {
54
- log.info('install', 'installing standalone, skipping download.')
55
- process.exit(1)
56
- } else if (pkg._from.length > 4 && pkg._from.substr(0, 4) === 'git+') {
49
+ } else if (origin && origin.length > 4 && origin.substr(0, 4) === 'git+') {
57
50
  log.info('install', 'installing from git repository, skipping download.')
58
51
  process.exit(1)
59
- } else if (opts.compile === true || opts.prebuild === false) {
52
+ } else if (opts.buildFromSource) {
60
53
  log.info('install', '--build-from-source specified, not attempting download.')
61
54
  process.exit(1)
62
55
  }
@@ -3,10 +3,6 @@ var fs = require('fs')
3
3
  var get = require('simple-get')
4
4
  var pump = require('pump')
5
5
  var tfs = require('tar-fs')
6
- var noop = Object.assign({
7
- http: function () {},
8
- silly: function () {}
9
- }, require('noop-logger'))
10
6
  var zlib = require('zlib')
11
7
  var util = require('./util')
12
8
  var error = require('./error')
@@ -15,58 +11,74 @@ var mkdirp = require('mkdirp-classic')
15
11
 
16
12
  function downloadPrebuild (downloadUrl, opts, cb) {
17
13
  var cachedPrebuild = util.cachedPrebuild(downloadUrl)
14
+ var localPrebuild = util.localPrebuild(downloadUrl, opts)
18
15
  var tempFile = util.tempFile(cachedPrebuild)
19
- var log = opts.log || noop
16
+ var log = opts.log || util.noopLogger
20
17
 
21
- ensureNpmCacheDir(function (err) {
22
- if (err) return onerror(err)
18
+ if (opts.nolocal) return download()
23
19
 
24
- log.info('looking for cached prebuild @', cachedPrebuild)
25
- fs.access(cachedPrebuild, fs.R_OK | fs.W_OK, function (err) {
26
- if (!(err && err.code === 'ENOENT')) {
27
- log.info('found cached prebuild')
28
- return unpack()
29
- }
20
+ log.info('looking for local prebuild @', localPrebuild)
21
+ fs.access(localPrebuild, fs.R_OK | fs.W_OK, function (err) {
22
+ if (err && err.code === 'ENOENT') {
23
+ return download()
24
+ }
30
25
 
31
- log.http('request', 'GET ' + downloadUrl)
32
- var reqOpts = proxy({ url: downloadUrl }, opts)
26
+ log.info('found local prebuild')
27
+ cachedPrebuild = localPrebuild
28
+ unpack()
29
+ })
33
30
 
34
- if (opts.token) {
35
- reqOpts.url += '?access_token=' + opts.token
36
- reqOpts.headers = {
37
- 'User-Agent': 'simple-get',
38
- Accept: 'application/octet-stream'
31
+ function download () {
32
+ ensureNpmCacheDir(function (err) {
33
+ if (err) return onerror(err)
34
+
35
+ log.info('looking for cached prebuild @', cachedPrebuild)
36
+ fs.access(cachedPrebuild, fs.R_OK | fs.W_OK, function (err) {
37
+ if (!(err && err.code === 'ENOENT')) {
38
+ log.info('found cached prebuild')
39
+ return unpack()
39
40
  }
40
- }
41
41
 
42
- var req = get(reqOpts, function (err, res) {
43
- if (err) return onerror(err)
44
- log.http(res.statusCode, downloadUrl)
45
- if (res.statusCode !== 200) return onerror()
46
- mkdirp(util.prebuildCache(), function () {
47
- log.info('downloading to @', tempFile)
48
- pump(res, fs.createWriteStream(tempFile), function (err) {
49
- if (err) return onerror(err)
50
- fs.rename(tempFile, cachedPrebuild, function (err) {
51
- if (err) return cb(err)
52
- log.info('renaming to @', cachedPrebuild)
53
- unpack()
42
+ log.http('request', 'GET ' + downloadUrl)
43
+ var reqOpts = proxy({ url: downloadUrl }, opts)
44
+
45
+ if (opts.token) {
46
+ reqOpts.headers = {
47
+ 'User-Agent': 'simple-get',
48
+ Accept: 'application/octet-stream',
49
+ Authorization: 'token ' + opts.token
50
+ }
51
+ }
52
+
53
+ var req = get(reqOpts, function (err, res) {
54
+ if (err) return onerror(err)
55
+ log.http(res.statusCode, downloadUrl)
56
+ if (res.statusCode !== 200) return onerror()
57
+ mkdirp(util.prebuildCache(), function () {
58
+ log.info('downloading to @', tempFile)
59
+ pump(res, fs.createWriteStream(tempFile), function (err) {
60
+ if (err) return onerror(err)
61
+ fs.rename(tempFile, cachedPrebuild, function (err) {
62
+ if (err) return cb(err)
63
+ log.info('renaming to @', cachedPrebuild)
64
+ unpack()
65
+ })
54
66
  })
55
67
  })
56
68
  })
57
- })
58
69
 
59
- req.setTimeout(30 * 1000, function () {
60
- req.abort()
70
+ req.setTimeout(30 * 1000, function () {
71
+ req.abort()
72
+ })
61
73
  })
62
- })
63
74
 
64
- function onerror (err) {
65
- fs.unlink(tempFile, function () {
66
- cb(err || error.noPrebuilts(opts))
67
- })
68
- }
69
- })
75
+ function onerror (err) {
76
+ fs.unlink(tempFile, function () {
77
+ cb(err || error.noPrebuilts(opts))
78
+ })
79
+ }
80
+ })
81
+ }
70
82
 
71
83
  function unpack () {
72
84
  var binaryName
@@ -5,6 +5,8 @@ prebuild-install [options]
5
5
  --runtime -r runtime (Node runtime [node or electron] to build or install for, default is node)
6
6
  --path -p path (make a prebuild-install here)
7
7
  --token -T gh-token (github token for private repos)
8
+ --arch arch (target CPU architecture, see Node OS module docs, default is current arch)
9
+ --platform platform (target platform, see Node OS module docs, default is current platform)
8
10
  --tag-prefix <prefix> (github tag prefix, default is "v")
9
11
  --force (always use prebuilt binaries when available)
10
12
  --build-from-source (skip prebuild download)
@@ -1,4 +1,6 @@
1
1
  var log = require('npmlog')
2
+ var fs = require('fs')
3
+ var path = require('path')
2
4
 
3
5
  module.exports = function (rc, env) {
4
6
  log.heading = 'prebuild-install'
@@ -9,5 +11,15 @@ module.exports = function (rc, env) {
9
11
  log.level = env.npm_config_loglevel || 'notice'
10
12
  }
11
13
 
14
+ // Temporary workaround for npm 7 which swallows our output
15
+ if (process.env.npm_config_prebuild_install_logfile) {
16
+ var fp = path.resolve(process.env.npm_config_prebuild_install_logfile)
17
+
18
+ log.on('log', function (msg) {
19
+ // Only for tests, don't care about performance
20
+ fs.appendFileSync(fp, [log.heading, msg.level, msg.prefix, msg.message].join(' ') + '\n')
21
+ })
22
+ }
23
+
12
24
  return log
13
25
  }
@@ -1,31 +1,31 @@
1
1
  {
2
2
  "_args": [
3
3
  [
4
- "prebuild-install@5.3.6",
4
+ "prebuild-install@6.1.4",
5
5
  "/home/runner/work/node-datachannel/node-datachannel"
6
6
  ]
7
7
  ],
8
- "_from": "prebuild-install@5.3.6",
9
- "_id": "prebuild-install@5.3.6",
8
+ "_from": "prebuild-install@6.1.4",
9
+ "_id": "prebuild-install@6.1.4",
10
10
  "_inBundle": false,
11
- "_integrity": "sha512-s8Aai8++QQGi4sSbs/M1Qku62PFK49Jm1CbgXklGz4nmHveDq0wzJkg7Na5QbnO1uNH8K7iqx2EQ/mV0MZEmOg==",
11
+ "_integrity": "sha512-Z4vpywnK1lBg+zdPCVCsKq0xO66eEV9rWo2zrROGGiRS4JtueBOdlB1FnY8lcy7JsUud/Q3ijUxyWN26Ika0vQ==",
12
12
  "_location": "/prebuild-install",
13
13
  "_phantomChildren": {},
14
14
  "_requested": {
15
15
  "type": "version",
16
16
  "registry": true,
17
- "raw": "prebuild-install@5.3.6",
17
+ "raw": "prebuild-install@6.1.4",
18
18
  "name": "prebuild-install",
19
19
  "escapedName": "prebuild-install",
20
- "rawSpec": "5.3.6",
20
+ "rawSpec": "6.1.4",
21
21
  "saveSpec": null,
22
- "fetchSpec": "5.3.6"
22
+ "fetchSpec": "6.1.4"
23
23
  },
24
24
  "_requiredBy": [
25
25
  "/"
26
26
  ],
27
- "_resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.6.tgz",
28
- "_spec": "5.3.6",
27
+ "_resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-6.1.4.tgz",
28
+ "_spec": "6.1.4",
29
29
  "_where": "/home/runner/work/node-datachannel/node-datachannel",
30
30
  "author": {
31
31
  "name": "Mathias Buus",
@@ -81,15 +81,13 @@
81
81
  "minimist": "^1.2.3",
82
82
  "mkdirp-classic": "^0.5.3",
83
83
  "napi-build-utils": "^1.0.1",
84
- "node-abi": "^2.7.0",
85
- "noop-logger": "^0.1.1",
84
+ "node-abi": "^2.21.0",
86
85
  "npmlog": "^4.0.1",
87
86
  "pump": "^3.0.0",
88
87
  "rc": "^1.2.7",
89
88
  "simple-get": "^3.0.3",
90
89
  "tar-fs": "^2.0.0",
91
- "tunnel-agent": "^0.6.0",
92
- "which-pm-runs": "^1.0.0"
90
+ "tunnel-agent": "^0.6.0"
93
91
  },
94
92
  "description": "A command line tool to easily install prebuilt binaries for multiple version of node/iojs on a specific platform",
95
93
  "devDependencies": {
@@ -98,7 +96,8 @@
98
96
  "nock": "^10.0.6",
99
97
  "rimraf": "^2.5.2",
100
98
  "standard": "^13.0.2",
101
- "tape": "^4.5.1"
99
+ "tape": "^4.5.1",
100
+ "tempy": "0.2.1"
102
101
  },
103
102
  "engines": {
104
103
  "node": ">=6"
@@ -127,5 +126,5 @@
127
126
  "lint": "standard && hallmark",
128
127
  "test": "tape test/*-test.js && npm run lint"
129
128
  },
130
- "version": "5.3.6"
129
+ "version": "6.1.4"
131
130
  }
@@ -1,12 +1,9 @@
1
1
  var url = require('url')
2
2
  var tunnel = require('tunnel-agent')
3
- var noop = Object.assign({
4
- http: function () {},
5
- silly: function () {}
6
- }, require('noop-logger'))
3
+ var util = require('./util')
7
4
 
8
5
  function applyProxy (reqOpts, opts) {
9
- var log = opts.log || noop
6
+ var log = opts.log || util.noopLogger
10
7
 
11
8
  var proxy = opts['https-proxy'] || opts.proxy
12
9
 
@@ -1,52 +1,34 @@
1
+ var path = require('path')
1
2
  var minimist = require('minimist')
2
3
  var getAbi = require('node-abi').getAbi
3
4
  var detectLibc = require('detect-libc')
4
5
  var napi = require('napi-build-utils')
5
6
 
6
7
  var env = process.env
7
-
8
8
  var libc = env.LIBC || (detectLibc.isNonGlibcLinux && detectLibc.family) || ''
9
9
 
10
- // Get `prebuild-install` arguments that were passed to the `npm` command
11
- if (env.npm_config_argv) {
12
- var npmargs = ['prebuild', 'compile', 'build-from-source', 'debug', 'verbose']
13
- try {
14
- var npmArgv = JSON.parse(env.npm_config_argv).cooked
15
- for (var i = 0; i < npmargs.length; ++i) {
16
- if (npmArgv.indexOf('--' + npmargs[i]) !== -1) {
17
- process.argv.push('--' + npmargs[i])
18
- }
19
- if (npmArgv.indexOf('--no-' + npmargs[i]) !== -1) {
20
- process.argv.push('--no-' + npmargs[i])
21
- }
22
- }
23
- if ((i = npmArgv.indexOf('--download')) !== -1) {
24
- process.argv.push(npmArgv[i], npmArgv[i + 1])
25
- }
26
- } catch (e) { }
27
- }
28
-
29
10
  // Get the configuration
30
11
  module.exports = function (pkg) {
31
12
  var pkgConf = pkg.config || {}
32
- var sourceBuild = env.npm_config_build_from_source
33
- var buildFromSource = sourceBuild === pkg.name || sourceBuild === 'true'
13
+ var buildFromSource = env.npm_config_build_from_source
14
+
34
15
  var rc = require('rc')('prebuild-install', {
35
16
  target: pkgConf.target || env.npm_config_target || process.versions.node,
36
17
  runtime: pkgConf.runtime || env.npm_config_runtime || 'node',
37
18
  arch: pkgConf.arch || env.npm_config_arch || process.arch,
38
19
  libc: libc,
39
20
  platform: env.npm_config_platform || process.platform,
40
- debug: false,
21
+ debug: env.npm_config_debug === 'true',
41
22
  force: false,
42
- verbose: false,
43
- prebuild: true,
44
- compile: buildFromSource,
23
+ verbose: env.npm_config_verbose === 'true',
24
+ buildFromSource: buildFromSource === pkg.name || buildFromSource === 'true',
45
25
  path: '.',
46
26
  proxy: env.npm_config_proxy || env['http_proxy'] || env['HTTP_PROXY'],
47
27
  'https-proxy': env.npm_config_https_proxy || env['https_proxy'] || env['HTTPS_PROXY'],
48
28
  'local-address': env.npm_config_local_address,
49
- 'tag-prefix': 'v'
29
+ 'local-prebuilds': 'prebuilds',
30
+ 'tag-prefix': 'v',
31
+ download: env.npm_config_download
50
32
  }, minimist(process.argv, {
51
33
  alias: {
52
34
  target: 't',
@@ -56,15 +38,12 @@ module.exports = function (pkg) {
56
38
  path: 'p',
57
39
  version: 'v',
58
40
  download: 'd',
59
- 'build-from-source': 'compile',
60
- compile: 'c',
41
+ buildFromSource: 'build-from-source',
61
42
  token: 'T'
62
43
  }
63
44
  }))
64
45
 
65
- if (rc.path === true) {
66
- delete rc.path
67
- }
46
+ rc.path = path.resolve(rc.path === true ? '.' : rc.path || '.')
68
47
 
69
48
  if (napi.isNapiRuntime(rc.runtime) && rc.target === process.versions.node) {
70
49
  rc.target = napi.getBestNapiBuildVersion()
@@ -5,7 +5,7 @@ var crypto = require('crypto')
5
5
  var expandTemplate = require('expand-template')()
6
6
 
7
7
  function getDownloadUrl (opts) {
8
- var pkgName = opts.pkg.name.replace(/^@\w+\//, '')
8
+ var pkgName = opts.pkg.name.replace(/^@[a-zA-Z0-9_\-.~]+\//, '')
9
9
  return expandTemplate(urlTemplate(opts), {
10
10
  name: pkgName,
11
11
  package_name: pkgName,
@@ -23,7 +23,7 @@ function getDownloadUrl (opts) {
23
23
  libc: opts.libc || process.env.LIBC || '',
24
24
  configuration: (opts.debug ? 'Debug' : 'Release'),
25
25
  module_name: opts.pkg.binary && opts.pkg.binary.module_name,
26
- tag_prefix: opts['tag-prefix'] || 'v'
26
+ tag_prefix: opts['tag-prefix']
27
27
  })
28
28
  }
29
29
 
@@ -60,8 +60,12 @@ function urlTemplate (opts) {
60
60
  return github(opts.pkg) + '/releases/download/{tag_prefix}{version}/' + packageName
61
61
  }
62
62
 
63
+ function getEnvPrefix (pkgName) {
64
+ return 'npm_config_' + (pkgName || '').replace(/[^a-zA-Z0-9]/g, '_').replace(/^_/, '')
65
+ }
66
+
63
67
  function getHostMirrorUrl (opts) {
64
- var propName = 'npm_config_' + (opts.pkg.name || '').replace(/[^a-zA-Z0-9]/g, '_') + '_binary_host'
68
+ var propName = getEnvPrefix(opts.pkg.name) + '_binary_host'
65
69
  return process.env[propName] || process.env[propName + '_mirror']
66
70
  }
67
71
 
@@ -87,11 +91,53 @@ function tempFile (cached) {
87
91
  return cached + '.' + process.pid + '-' + Math.random().toString(16).slice(2) + '.tmp'
88
92
  }
89
93
 
94
+ function packageOrigin (env, pkg) {
95
+ // npm <= 6: metadata is stored on disk in node_modules
96
+ if (pkg._from) {
97
+ return pkg._from
98
+ }
99
+
100
+ // npm 7: metadata is exposed to environment by arborist
101
+ if (env.npm_package_from) {
102
+ // NOTE: seems undefined atm (npm 7.0.2)
103
+ return env.npm_package_from
104
+ }
105
+
106
+ if (env.npm_package_resolved) {
107
+ // NOTE: not sure about the difference with _from, but it's all we have
108
+ return env.npm_package_resolved
109
+ }
110
+ }
111
+
112
+ function localPrebuild (url, opts) {
113
+ var propName = getEnvPrefix(opts.pkg.name) + '_local_prebuilds'
114
+ var prefix = process.env[propName] || opts['local-prebuilds'] || 'prebuilds'
115
+ return path.join(prefix, path.basename(url))
116
+ }
117
+
118
+ var noopLogger = {
119
+ http: function () {},
120
+ silly: function () {},
121
+ debug: function () {},
122
+ info: function () {},
123
+ warn: function () {},
124
+ error: function () {},
125
+ critical: function () {},
126
+ alert: function () {},
127
+ emergency: function () {},
128
+ notice: function () {},
129
+ verbose: function () {},
130
+ fatal: function () {}
131
+ }
132
+
90
133
  exports.getDownloadUrl = getDownloadUrl
91
134
  exports.getApiUrl = getApiUrl
92
135
  exports.getAssetUrl = getAssetUrl
93
136
  exports.urlTemplate = urlTemplate
94
137
  exports.cachedPrebuild = cachedPrebuild
138
+ exports.localPrebuild = localPrebuild
95
139
  exports.prebuildCache = prebuildCache
96
140
  exports.npmCache = npmCache
97
141
  exports.tempFile = tempFile
142
+ exports.packageOrigin = packageOrigin
143
+ exports.noopLogger = noopLogger
@@ -23,7 +23,6 @@
23
23
  },
24
24
  "_requiredBy": [
25
25
  "/are-we-there-yet",
26
- "/cmake-js/are-we-there-yet",
27
26
  "/duplexer2",
28
27
  "/node-ninja/are-we-there-yet",
29
28
  "/npmlog/are-we-there-yet"
@@ -27,7 +27,6 @@
27
27
  "/readable-stream",
28
28
  "/request",
29
29
  "/string_decoder",
30
- "/tar",
31
30
  "/tunnel-agent"
32
31
  ],
33
32
  "_resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
@@ -23,11 +23,10 @@
23
23
  },
24
24
  "_requiredBy": [
25
25
  "/cliui",
26
- "/cmake-js/yargs",
27
26
  "/npmlog/gauge",
28
- "/prebuild/yargs",
29
27
  "/wide-align",
30
- "/wrap-ansi"
28
+ "/wrap-ansi",
29
+ "/yargs"
31
30
  ],
32
31
  "_resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
33
32
  "_spec": "1.0.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-datachannel",
3
- "version": "0.1.10",
3
+ "version": "0.1.14-dev",
4
4
  "description": "libdatachannel node bindings",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "build": "cmake-js build",
16
16
  "_prebuild": "prebuild --backend cmake-js",
17
17
  "clean": "cmake-js clean",
18
- "test": "jest --forceExit"
18
+ "test": "jest"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
@@ -24,7 +24,16 @@
24
24
  "keywords": [
25
25
  "libdatachannel"
26
26
  ],
27
- "author": "Murat Doğan",
27
+ "contributors": [
28
+ {
29
+ "name": "Murat Doğan",
30
+ "url": "https://github.com/murat-dogan"
31
+ },
32
+ {
33
+ "name": "Paul-Louis Ageneau",
34
+ "url": "https://github.com/paullouisageneau"
35
+ }
36
+ ],
28
37
  "license": "GPL-2.0-or-later",
29
38
  "gypfile": true,
30
39
  "bugs": {
@@ -32,17 +41,17 @@
32
41
  },
33
42
  "homepage": "https://github.com/murat-dogan/node-datachannel#readme",
34
43
  "devDependencies": {
35
- "cmake-js": "^6.1.0",
36
- "jest": "^27.0.6",
37
- "nan": "^2.14.2",
38
- "napi-thread-safe-callback": "0.0.6",
39
- "node-addon-api": "^3.1.0",
40
- "prebuild": "^10.0.1"
44
+ "cmake-js": "^6.2.1",
45
+ "jest": "^27.2.5",
46
+ "nan": "^2.15.0",
47
+ "napi-thread-safe-callback-cancellable": "^0.0.7",
48
+ "node-addon-api": "^4.2.0",
49
+ "prebuild": "^11.0.0"
41
50
  },
42
51
  "bundledDependencies": [
43
52
  "prebuild-install"
44
53
  ],
45
54
  "dependencies": {
46
- "prebuild-install": "^5.3.6"
55
+ "prebuild-install": "^6.1.4"
47
56
  }
48
57
  }