mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-08 06:02:34 -05:00
Improve version data logging
This commit is contained in:
@@ -89,12 +89,21 @@ module.exports = function install (ctx, pkgSpec, modules, options) {
|
||||
|
||||
return resolve(pkg.spec)
|
||||
.then(saveResolution)
|
||||
.then(_ => log('resolved', pkg.fullname))
|
||||
.then(_ => log('resolved', pkg))
|
||||
.then(_ => make(join(modules, pkg.spec.name), false, _ =>
|
||||
Promise.resolve()
|
||||
.then(_ => buildToStoreCached(ctx, paths, pkg, log))
|
||||
.then(_ => mkdirp(paths.modules))
|
||||
.then(_ => symlinkToModules(paths.target, paths.modules))))
|
||||
|
||||
// package.json data isn't logged if it was already installed before,
|
||||
// so do it again to be sure. it's not always available though
|
||||
.then(_ => {
|
||||
try {
|
||||
return log('package.json', requireJson(join(paths.target, 'package.json')))
|
||||
} catch (e) { } })
|
||||
|
||||
// done
|
||||
.then(_ => log('done'))
|
||||
.catch(err => {
|
||||
log('error', err)
|
||||
@@ -104,6 +113,7 @@ module.exports = function install (ctx, pkgSpec, modules, options) {
|
||||
// set metadata as fetched from resolve()
|
||||
function saveResolution (res) {
|
||||
pkg.fullname = res.fullname
|
||||
pkg.version = res.version
|
||||
pkg.dist = res.dist
|
||||
paths.target = join(ctx.store, res.fullname)
|
||||
}
|
||||
@@ -160,6 +170,7 @@ function buildInStore (ctx, paths, pkg, log) {
|
||||
|
||||
return Promise.resolve()
|
||||
.then(_ => { fulldata = requireJson(abspath(join(paths.tmp, 'package.json'))) })
|
||||
.then(_ => log('package.json', fulldata))
|
||||
|
||||
// link node_modules/.bin
|
||||
.then(_ => linkBins(paths.modules, paths.tmp, paths.target))
|
||||
|
||||
@@ -5,7 +5,8 @@ observatory.settings({ prefix: ' ', width: 74 })
|
||||
|
||||
module.exports = function logger () {
|
||||
return function (pkg) {
|
||||
var pkgData
|
||||
var pkgData // package.json
|
||||
var res // resolution
|
||||
|
||||
var t = observatory.add(pkg.name + ' ' +
|
||||
chalk.gray(pkg.rawSpec || ''))
|
||||
@@ -19,9 +20,13 @@ module.exports = function logger () {
|
||||
// log('error', err)
|
||||
function status (status, args) {
|
||||
if (status === 'resolved') {
|
||||
pkgData = args
|
||||
res = args
|
||||
} else if (status === 'downloading') {
|
||||
t.status(chalk.yellow('downloading ' + pkgData.version + ' ·'))
|
||||
if (res.version) {
|
||||
t.status(chalk.yellow('downloading ' + res.version + ' ·'))
|
||||
} else {
|
||||
t.status(chalk.yellow('downloading ·'))
|
||||
}
|
||||
if (args && args.total && args.done < args.total) {
|
||||
t.details('' + Math.round(args.done / args.total * 100) + '%')
|
||||
} else {
|
||||
@@ -35,6 +40,8 @@ module.exports = function logger () {
|
||||
t.status(chalk.green('OK ✓'))
|
||||
.details('')
|
||||
}
|
||||
} else if (status === 'package.json') {
|
||||
pkgData = args
|
||||
} else if (status === 'dependencies') {
|
||||
t.status(chalk.gray('' + pkgData.version + ' ·'))
|
||||
.details('')
|
||||
|
||||
@@ -27,6 +27,7 @@ module.exports = function resolveNpm (pkg) {
|
||||
.then(res => {
|
||||
return {
|
||||
fullname: '' + res.name.replace('/', '!') + '@' + res.version,
|
||||
version: res.version, // used for displaying
|
||||
dist: res.dist
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user