This repository has been archived by the owner on Jul 3, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api): use npa@5 for spec parsing (#78)
BREAKING CHANGE: spec objects can no longer be realize-package-specifier objects. Pass a string or generate npa@>=5 spec objects to pass in.
- Loading branch information
Showing
20 changed files
with
91 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
'use strict' | ||
|
||
const BB = require('bluebird') | ||
|
||
module.exports = manifest | ||
function manifest () { | ||
// The tarball handler will take care of it! | ||
return Promise.resolve(null) | ||
return BB.resolve(null) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,47 @@ | ||
'use strict' | ||
|
||
const BB = require('bluebird') | ||
|
||
const finalizeManifest = require('./lib/finalize-manifest') | ||
const optCheck = require('./lib/util/opt-check') | ||
const pinflight = require('promise-inflight') | ||
const rps = BB.promisify(require('realize-package-specifier')) | ||
const npa = require('npm-package-arg') | ||
|
||
let handlers = {} | ||
|
||
module.exports = manifest | ||
function manifest (spec, opts) { | ||
opts = optCheck(opts) | ||
spec = typeof spec === 'string' ? npa(spec, opts.where) : spec | ||
|
||
const res = typeof spec === 'string' | ||
? rps(spec, opts.where) | ||
: BB.resolve(spec) | ||
|
||
return res.then(res => { | ||
const label = [ | ||
res.raw, | ||
res.spec, | ||
res.type, | ||
opts.cache, | ||
opts.registry, | ||
opts.scope | ||
].join(':') | ||
return pinflight(label, () => { | ||
const startTime = Date.now() | ||
const fetcher = ( | ||
handlers[res.type] || | ||
( | ||
handlers[res.type] = | ||
require('./lib/handlers/' + res.type + '/manifest') | ||
) | ||
const label = [ | ||
spec.name, | ||
spec.saveSpec || spec.fetchSpec, | ||
spec.type, | ||
opts.cache, | ||
opts.registry, | ||
opts.scope | ||
].join(':') | ||
return pinflight(label, () => { | ||
const startTime = Date.now() | ||
const fetcher = ( | ||
handlers[spec.type] || | ||
( | ||
handlers[spec.type] = | ||
require('./lib/handlers/' + spec.type + '/manifest') | ||
) | ||
return fetcher(res, opts).then(manifest => { | ||
return finalizeManifest(manifest, res, opts) | ||
}).then(manifest => { | ||
// Metadata about the way this manifest was requested | ||
if (opts.annotate) { | ||
manifest._requested = res | ||
manifest._spec = spec | ||
manifest._where = opts.where | ||
} | ||
) | ||
return fetcher(spec, opts).then(manifest => { | ||
return finalizeManifest(manifest, spec, opts) | ||
}).then(manifest => { | ||
// Metadata about the way this manifest was requested | ||
if (opts.annotate) { | ||
manifest._requested = spec | ||
manifest._spec = spec.raw | ||
manifest._where = opts.where | ||
} | ||
|
||
const elapsedTime = Date.now() - startTime | ||
opts.log.verbose('pacote', `${res.type} manifest for ${res.name}@${res.spec} fetched in ${elapsedTime}ms`) | ||
return manifest | ||
}) | ||
const elapsedTime = Date.now() - startTime | ||
opts.log.verbose('pacote', `${spec.type} manifest for ${spec.name}@${spec.saveSpec || spec.fetchSpec} fetched in ${elapsedTime}ms`) | ||
return manifest | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.