pacote 9.3.0 → 9.5.1

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,48 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ <a name="9.5.1"></a>
6
+ ## [9.5.1](https://github.com/zkat/pacote/compare/v9.5.0...v9.5.1) (2019-06-17)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **audit:** npm audit fix ([127a28b](https://github.com/zkat/pacote/commit/127a28b))
12
+ * **errors:** Fix "TypeError: err.code.match is not a function" error ([#170](https://github.com/zkat/pacote/issues/170)) ([92f5e4c](https://github.com/zkat/pacote/commit/92f5e4c))
13
+ * **git:** limit retry times, avoid unlimited retries ([#172](https://github.com/zkat/pacote/issues/172)) ([8bbd051](https://github.com/zkat/pacote/commit/8bbd051))
14
+
15
+
16
+
17
+ <a name="9.5.0"></a>
18
+ # [9.5.0](https://github.com/zkat/pacote/compare/v9.4.1...v9.5.0) (2019-02-18)
19
+
20
+
21
+ ### Features
22
+
23
+ * **enjoy-by:** add `before` as an alias to enjoy-by ([75d62b7](https://github.com/zkat/pacote/commit/75d62b7))
24
+
25
+
26
+
27
+ <a name="9.4.1"></a>
28
+ ## [9.4.1](https://github.com/zkat/pacote/compare/v9.4.0...v9.4.1) (2019-01-24)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * **directory, finalize-manifest:** strip byte order marker from JSON ([723ad63](https://github.com/zkat/pacote/commit/723ad63))
34
+
35
+
36
+
37
+ <a name="9.4.0"></a>
38
+ # [9.4.0](https://github.com/zkat/pacote/compare/v9.3.0...v9.4.0) (2019-01-14)
39
+
40
+
41
+ ### Features
42
+
43
+ * **registry:** fall back to fullfat if something might be wrong with corgis ([0e71d6b](https://github.com/zkat/pacote/commit/0e71d6b))
44
+
45
+
46
+
5
47
  <a name="9.3.0"></a>
6
48
  # [9.3.0](https://github.com/zkat/pacote/compare/v9.2.3...v9.3.0) (2018-12-21)
7
49
 
package/README.md CHANGED
@@ -231,7 +231,7 @@ even though npm itself does.
231
231
 
232
232
  ##### <a name="opts-enjoy-by"></a> `opts.enjoy-by`
233
233
 
234
- * Alias: `opts.enjoyBy`
234
+ * Alias: `opts.enjoyBy`, `opts.before`
235
235
  * Type: Date-able
236
236
  * Default: undefined
237
237
 
@@ -5,6 +5,7 @@ const BB = require('bluebird')
5
5
  const Fetcher = require('../fetch')
6
6
  const glob = BB.promisify(require('glob'))
7
7
  const packDir = require('../util/pack-dir')
8
+ const readJson = require('../util/read-json')
8
9
  const path = require('path')
9
10
  const pipe = BB.promisify(require('mississippi').pipe)
10
11
  const through = require('mississippi').through
@@ -34,11 +35,11 @@ Fetcher.impl(fetchDirectory, {
34
35
  const pkgPath = path.join(spec.fetchSpec, 'package.json')
35
36
  const srPath = path.join(spec.fetchSpec, 'npm-shrinkwrap.json')
36
37
  return BB.join(
37
- readFileAsync(pkgPath).then(JSON.parse).catch({ code: 'ENOENT' }, err => {
38
+ readFileAsync(pkgPath).then(readJson).catch({ code: 'ENOENT' }, err => {
38
39
  err.code = 'ENOPACKAGEJSON'
39
40
  throw err
40
41
  }),
41
- readFileAsync(srPath).then(JSON.parse).catch({ code: 'ENOENT' }, () => null),
42
+ readFileAsync(srPath).then(readJson).catch({ code: 'ENOENT' }, () => null),
42
43
  (pkg, sr) => {
43
44
  pkg._shrinkwrap = sr
44
45
  pkg._hasShrinkwrap = !!sr
@@ -16,9 +16,10 @@ function manifest (spec, opts) {
16
16
  }
17
17
 
18
18
  function getManifest (spec, opts) {
19
- return fetchPackument(spec, opts.concat({
19
+ opts = opts.concat({
20
20
  fullMetadata: opts.enjoyBy ? true : opts.fullMetadata
21
- })).then(packument => {
21
+ })
22
+ return fetchPackument(spec, opts).then(packument => {
22
23
  try {
23
24
  return pickManifest(packument, spec.fetchSpec, {
24
25
  defaultTag: opts.defaultTag,
@@ -29,14 +30,15 @@ function getManifest (spec, opts) {
29
30
  if (err.code === 'ETARGET' && packument._cached && !opts.offline) {
30
31
  opts.log.silly(
31
32
  'registry:manifest',
32
- `no matching version for ${spec.name}@${spec.fetchSpec} in the cache. Forcing revalidation`
33
+ `no matching version for ${spec.name}@${spec.fetchSpec} in the cache. Forcing revalidation.`
33
34
  )
34
35
  opts = opts.concat({
35
36
  preferOffline: false,
36
37
  preferOnline: true
37
38
  })
38
39
  return fetchPackument(spec, opts.concat({
39
- fullMetadata: opts.enjoyBy ? true : opts.fullMetadata
40
+ // Fetch full metadata in case ETARGET was due to corgi delay
41
+ fullMetadata: true
40
42
  })).then(packument => {
41
43
  return pickManifest(packument, spec.fetchSpec, {
42
44
  defaultTag: opts.defaultTag,
@@ -59,7 +59,15 @@ function fetchPackument (uri, registry, spec, opts) {
59
59
  mem.set(memoKey, packument)
60
60
  }
61
61
  return packument
62
- }))
62
+ })).catch(err => {
63
+ if (err.code === 'E404' && !opts.fullMetadata) {
64
+ return fetchPackument(uri, registry, spec, opts.concat({
65
+ fullMetadata: true
66
+ }))
67
+ } else {
68
+ throw err
69
+ }
70
+ })
63
71
  }
64
72
 
65
73
  class ObjProxy {
@@ -13,6 +13,7 @@ const path = require('path')
13
13
  const pipe = BB.promisify(require('mississippi').pipe)
14
14
  const ssri = require('ssri')
15
15
  const tar = require('tar')
16
+ const readJson = require('./util/read-json')
16
17
 
17
18
  // `finalizeManifest` takes as input the various kinds of manifests that
18
19
  // manifest handlers ('lib/fetchers/*.js#manifest()') return, and makes sure
@@ -212,7 +213,7 @@ function jsonFromStream (filename, dataStream) {
212
213
  entry.on('error', cb)
213
214
  finished(entry).then(() => {
214
215
  try {
215
- cb(null, JSON.parse(data))
216
+ cb(null, readJson(data))
216
217
  } catch (err) {
217
218
  cb(err)
218
219
  }
package/lib/util/git.js CHANGED
@@ -40,8 +40,10 @@ const GIT_TRANSIENT_ERRORS = [
40
40
 
41
41
  const GIT_TRANSIENT_ERROR_RE = new RegExp(GIT_TRANSIENT_ERRORS)
42
42
 
43
- function shouldRetry (error) {
44
- return GIT_TRANSIENT_ERROR_RE.test(error)
43
+ const GIT_TRANSIENT_ERROR_MAX_RETRY_NUMBER = 3
44
+
45
+ function shouldRetry (error, number) {
46
+ return GIT_TRANSIENT_ERROR_RE.test(error) && (number < GIT_TRANSIENT_ERROR_MAX_RETRY_NUMBER)
45
47
  }
46
48
 
47
49
  const GIT_ = 'GIT_'
@@ -188,7 +190,7 @@ function execGit (gitArgs, gitOpts, opts) {
188
190
  opts.log.silly('pacote', 'Retrying git command: ' + gitArgs.join(' ') + ' attempt # ' + number)
189
191
  }
190
192
  return execFileAsync(gitPath, gitArgs, mkOpts(gitOpts, opts)).catch((err) => {
191
- if (shouldRetry(err)) {
193
+ if (shouldRetry(err, number)) {
192
194
  retry(err)
193
195
  } else {
194
196
  throw err
@@ -219,7 +221,7 @@ function spawnGit (gitArgs, gitOpts, opts) {
219
221
  child.stderr.on('data', d => { stderr += d })
220
222
 
221
223
  return finished(child, true).catch(err => {
222
- if (shouldRetry(stderr)) {
224
+ if (shouldRetry(stderr, number)) {
223
225
  retry(err)
224
226
  } else {
225
227
  err.stderr = stderr
@@ -13,6 +13,7 @@ module.exports = figgyPudding({
13
13
  dmode: {},
14
14
  'enjoy-by': 'enjoyBy',
15
15
  enjoyBy: {},
16
+ before: 'enjoyBy',
16
17
  fmode: {},
17
18
  'fetch-retries': { default: 2 },
18
19
  'fetch-retry-factor': { default: 10 },
@@ -0,0 +1,15 @@
1
+ 'use strict'
2
+
3
+ module.exports = function (content) {
4
+ // Code also yanked from read-package-json.
5
+ function stripBOM (content) {
6
+ content = content.toString()
7
+ // Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
8
+ // because the buffer-to-string conversion in `fs.readFileSync()`
9
+ // translates it to FEFF, the UTF-16 BOM.
10
+ if (content.charCodeAt(0) === 0xFEFF) return content.slice(1)
11
+ return content
12
+ }
13
+
14
+ return JSON.parse(stripBOM(content))
15
+ }
@@ -107,7 +107,7 @@ function withTarballStream (spec, opts, streamHandler) {
107
107
  // Retry once if we have a cache, to clear up any weird conditions.
108
108
  // Don't retry network errors, though -- make-fetch-happen has already
109
109
  // taken care of making sure we're all set on that front.
110
- if (opts.cache && err.code && !err.code.match(/^E\d{3}$/)) {
110
+ if (opts.cache && err.code && !String(err.code).match(/^E\d{3}$/)) {
111
111
  if (err.code === 'EINTEGRITY' || err.code === 'Z_DATA_ERROR') {
112
112
  opts.log.warn('tarball', `tarball data for ${spec} (${opts.integrity}) seems to be corrupted. Trying one more time.`)
113
113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacote",
3
- "version": "9.3.0",
3
+ "version": "9.5.1",
4
4
  "description": "JavaScript package downloader",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -72,12 +72,12 @@
72
72
  "devDependencies": {
73
73
  "nock": "^10.0.3",
74
74
  "npmlog": "^4.1.2",
75
- "nyc": "^13.1.0",
75
+ "nyc": "^14.1.1",
76
76
  "require-inject": "^1.4.3",
77
77
  "standard": "^12.0.1",
78
78
  "standard-version": "^4.4.0",
79
79
  "tacks": "^1.2.7",
80
- "tap": "^12.1.0",
80
+ "tap": "^12.7.0",
81
81
  "tar-stream": "^1.6.2",
82
82
  "weallbehave": "^1.2.0",
83
83
  "weallcontribute": "^1.0.7"