pacote 9.2.3 → 9.5.0

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,52 @@
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.0"></a>
6
+ # [9.5.0](https://github.com/zkat/pacote/compare/v9.4.1...v9.5.0) (2019-02-18)
7
+
8
+
9
+ ### Features
10
+
11
+ * **enjoy-by:** add `before` as an alias to enjoy-by ([75d62b7](https://github.com/zkat/pacote/commit/75d62b7))
12
+
13
+
14
+
15
+ <a name="9.4.1"></a>
16
+ ## [9.4.1](https://github.com/zkat/pacote/compare/v9.4.0...v9.4.1) (2019-01-24)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * **directory, finalize-manifest:** strip byte order marker from JSON ([723ad63](https://github.com/zkat/pacote/commit/723ad63))
22
+
23
+
24
+
25
+ <a name="9.4.0"></a>
26
+ # [9.4.0](https://github.com/zkat/pacote/compare/v9.3.0...v9.4.0) (2019-01-14)
27
+
28
+
29
+ ### Features
30
+
31
+ * **registry:** fall back to fullfat if something might be wrong with corgis ([0e71d6b](https://github.com/zkat/pacote/commit/0e71d6b))
32
+
33
+
34
+
35
+ <a name="9.3.0"></a>
36
+ # [9.3.0](https://github.com/zkat/pacote/compare/v9.2.3...v9.3.0) (2018-12-21)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * **git, file:** properly catch otherwise unhandled errors ([89d4897](https://github.com/zkat/pacote/commit/89d4897))
42
+ * **test:** set umask opt to fix extract-stream 'accepts dmode/fmode/umask opts' ([e51de83](https://github.com/zkat/pacote/commit/e51de83))
43
+
44
+
45
+ ### Features
46
+
47
+ * **git:** accept git path option ([#164](https://github.com/zkat/pacote/issues/164)) ([f06c8c5](https://github.com/zkat/pacote/commit/f06c8c5))
48
+
49
+
50
+
5
51
  <a name="9.2.3"></a>
6
52
  ## [9.2.3](https://github.com/zkat/pacote/compare/v9.2.2...v9.2.3) (2018-10-31)
7
53
 
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
 
@@ -57,6 +57,7 @@ function extractStream (spec, dest, opts) {
57
57
  onwarn: msg => opts.log && opts.log.warn('tar', msg),
58
58
  uid: opts.uid,
59
59
  gid: opts.gid,
60
+ umask: opts.umask,
60
61
  transform: opts.resolved && pkgJsonTransform(spec, opts),
61
62
  onentry (entry) {
62
63
  if (entry.type.toLowerCase() === 'file') {
@@ -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
@@ -68,7 +68,7 @@ Fetcher.impl(fetchFile, {
68
68
  return pipe(fs.createReadStream(src), stream)
69
69
  })
70
70
  }
71
- }, err => stream.emit('error', err))
71
+ }).catch(err => stream.emit('error', err))
72
72
  return stream
73
73
  },
74
74
 
@@ -45,7 +45,7 @@ Fetcher.impl(fetchGit, {
45
45
  manifest, spec, opts
46
46
  ).on('integrity', i => stream.emit('integrity', i)), stream
47
47
  )
48
- }, err => stream.emit('error', err))
48
+ }).catch(err => stream.emit('error', err))
49
49
  return stream
50
50
  },
51
51
 
@@ -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
@@ -74,10 +74,10 @@ function fullClone (repo, committish, target, opts) {
74
74
  if (process.platform === 'win32') {
75
75
  gitArgs.push('--config', 'core.longpaths=true')
76
76
  }
77
- return execGit(gitArgs, { cwd: target }).then(() => {
78
- return execGit(['init'], { cwd: target })
77
+ return execGit(gitArgs, { cwd: target }, opts).then(() => {
78
+ return execGit(['init'], { cwd: target }, opts)
79
79
  }).then(() => {
80
- return execGit(['checkout', committish || 'HEAD'], { cwd: target })
80
+ return execGit(['checkout', committish || 'HEAD'], { cwd: target }, opts)
81
81
  }).then(() => {
82
82
  return updateSubmodules(target, opts)
83
83
  }).then(() => headSha(target, opts))
@@ -182,7 +182,7 @@ function revs (repo, opts) {
182
182
  module.exports._exec = execGit
183
183
  function execGit (gitArgs, gitOpts, opts) {
184
184
  opts = optCheck(opts)
185
- return checkGit().then(gitPath => {
185
+ return checkGit(opts).then(gitPath => {
186
186
  return promiseRetry((retry, number) => {
187
187
  if (number !== 1) {
188
188
  opts.log.silly('pacote', 'Retrying git command: ' + gitArgs.join(' ') + ' attempt # ' + number)
@@ -206,7 +206,7 @@ function execGit (gitArgs, gitOpts, opts) {
206
206
  module.exports._spawn = spawnGit
207
207
  function spawnGit (gitArgs, gitOpts, opts) {
208
208
  opts = optCheck(opts)
209
- return checkGit().then(gitPath => {
209
+ return checkGit(opts).then(gitPath => {
210
210
  return promiseRetry((retry, number) => {
211
211
  if (number !== 1) {
212
212
  opts.log.silly('pacote', 'Retrying git command: ' + gitArgs.join(' ') + ' attempt # ' + number)
@@ -246,8 +246,10 @@ function mkOpts (_gitOpts, opts) {
246
246
  return gitOpts
247
247
  }
248
248
 
249
- function checkGit () {
250
- if (!GITPATH) {
249
+ function checkGit (opts) {
250
+ if (opts.git) {
251
+ return BB.resolve(opts.git)
252
+ } else if (!GITPATH) {
251
253
  const err = new Error('No git binary found in $PATH')
252
254
  err.code = 'ENOGIT'
253
255
  return BB.reject(err)
@@ -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 },
@@ -21,6 +22,7 @@ module.exports = figgyPudding({
21
22
  fullMetadata: 'full-metadata',
22
23
  'full-metadata': { default: false },
23
24
  gid: {},
25
+ git: {},
24
26
  includeDeprecated: { default: true },
25
27
  'include-deprecated': 'includeDeprecated',
26
28
  integrity: {},
@@ -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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacote",
3
- "version": "9.2.3",
3
+ "version": "9.5.0",
4
4
  "description": "JavaScript package downloader",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -41,12 +41,12 @@
41
41
  ],
42
42
  "license": "MIT",
43
43
  "dependencies": {
44
- "bluebird": "^3.5.2",
45
- "cacache": "^11.2.0",
44
+ "bluebird": "^3.5.3",
45
+ "cacache": "^11.3.2",
46
46
  "figgy-pudding": "^3.5.1",
47
47
  "get-stream": "^4.1.0",
48
48
  "glob": "^7.1.3",
49
- "lru-cache": "^4.1.3",
49
+ "lru-cache": "^5.1.1",
50
50
  "make-fetch-happen": "^4.0.1",
51
51
  "minimatch": "^3.0.4",
52
52
  "minipass": "^2.3.5",
@@ -65,19 +65,19 @@
65
65
  "safe-buffer": "^5.1.2",
66
66
  "semver": "^5.6.0",
67
67
  "ssri": "^6.0.1",
68
- "tar": "^4.4.6",
68
+ "tar": "^4.4.8",
69
69
  "unique-filename": "^1.1.1",
70
70
  "which": "^1.3.1"
71
71
  },
72
72
  "devDependencies": {
73
- "nock": "^10.0.1",
73
+ "nock": "^10.0.3",
74
74
  "npmlog": "^4.1.2",
75
75
  "nyc": "^13.1.0",
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.0.1",
80
+ "tap": "^12.1.0",
81
81
  "tar-stream": "^1.6.2",
82
82
  "weallbehave": "^1.2.0",
83
83
  "weallcontribute": "^1.0.7"