From da20e93f5bc76de1a712722d2be1bfb092aab000 Mon Sep 17 00:00:00 2001 From: zkochan Date: Fri, 7 Apr 2017 01:44:26 +0300 Subject: [PATCH] fix(reporter): log all installation steps for top deps --- package.json | 4 ++-- src/install/fetch.ts | 12 ++++++------ src/install/fetchResolution.ts | 8 ++++---- src/install/installMultiple.ts | 7 +++---- src/link/index.ts | 5 +++++ 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 8bb9b07f99..9501c83d71 100644 --- a/package.json +++ b/package.json @@ -63,10 +63,10 @@ "parse-npm-tarball-url": "^1.0.1", "path-exists": "^3.0.0", "path-name": "^1.0.0", - "pnpm-default-reporter": "^0.5.1", + "pnpm-default-reporter": "^0.6.0", "pnpm-file-reporter": "^0.0.1", "pnpm-install-checks": "^1.1.0", - "pnpm-logger": "^0.2.0", + "pnpm-logger": "^0.3.0", "proper-lockfile": "^2.0.0", "ramda": "^0.23.0", "rc": "^1.2.0", diff --git a/src/install/fetch.ts b/src/install/fetch.ts index 43eae904e8..3ed484ae3e 100644 --- a/src/install/fetch.ts +++ b/src/install/fetch.ts @@ -61,7 +61,6 @@ export default async function fetch ( metaCache: options.metaCache, offline: options.offline, }) - logStatus({status: 'resolved', pkg: options.loggedPkg}) // keep the shrinkwrap resolution when possible // to keep the original shasum if (pkgId !== resolveResult.id || !resolution) { @@ -72,15 +71,16 @@ export default async function fetch ( fetchingPkg = Promise.resolve(resolveResult.package) } } - const id = pkgId + logStatus({status: 'resolved', pkgId: id, pkg: options.loggedPkg}) + const target = path.join(options.storePath, id) const fetchingFiles = options.fetchingLocker(id, () => fetchToStore({ target, resolution: resolution, - loggedPkg: options.loggedPkg, + pkgId: id, got: options.got, localRegistry: options.localRegistry, offline: options.offline, @@ -116,7 +116,7 @@ export default async function fetch ( async function fetchToStore (opts: { target: string, resolution: Resolution, - loggedPkg: LoggedPkg, + pkgId: string, got: Got, localRegistry: string, offline: boolean, @@ -142,13 +142,13 @@ async function fetchToStore (opts: { await fetchResolution(opts.resolution, targetStage, { got: opts.got, - loggedPkg: opts.loggedPkg, + pkgId: opts.pkgId, localRegistry: opts.localRegistry, offline: opts.offline, }) logStatus({ status: 'fetched', - pkg: opts.loggedPkg // TODO: add version + pkgId: opts.pkgId, }) // fs.rename(oldPath, newPath) is an atomic operation, so we do it at the diff --git a/src/install/fetchResolution.ts b/src/install/fetchResolution.ts index f44264dfeb..ae48ceb47a 100644 --- a/src/install/fetchResolution.ts +++ b/src/install/fetchResolution.ts @@ -1,4 +1,4 @@ -import logger, {LoggedPkg} from 'pnpm-logger' +import logger from 'pnpm-logger' import fs = require('mz/fs') import path = require('path') import spawn = require('cross-spawn') @@ -19,7 +19,7 @@ const gitLogger = logger('git') const fetchLogger = logger('fetch') export type FetchOptions = { - loggedPkg: LoggedPkg, + pkgId: string, got: Got, localRegistry: string, offline: boolean, @@ -117,11 +117,11 @@ export async function fetchFromRemoteTarball (dir: string, dist: PackageDist, op } await opts.got.download(dist.tarball, localTarballPath, { shasum: dist.shasum, - onStart: () => logStatus({status: 'fetching', pkg: opts.loggedPkg}), + onStart: () => logStatus({status: 'fetching', pkgId: opts.pkgId}), onProgress: (done: number, total: number) => logStatus({ status: 'fetching', - pkg: opts.loggedPkg, + pkgId: opts.pkgId, progress: { done, total }, }) }) diff --git a/src/install/installMultiple.ts b/src/install/installMultiple.ts index 00a77e4679..3f1ba21a83 100644 --- a/src/install/installMultiple.ts +++ b/src/install/installMultiple.ts @@ -201,6 +201,8 @@ async function install ( }) const pkg = await fetchedPkg.fetchingPkg + logStatus({status: 'downloaded_manifest', pkgId: fetchedPkg.id, pkgVersion: pkg.version}) + let dependencyIds: string[] | void const isInstallable = options.isInstallable !== false && (options.force || await getIsInstallable(fetchedPkg.id, pkg, fetchedPkg, options)) @@ -238,10 +240,7 @@ async function install ( addInstalledPkg(ctx.installs, dependency) - logStatus({ - status: 'installed', - pkg: Object.assign({}, loggedPkg, {version: pkg.version}), - }) + logStatus({status: 'dependencies_installed', pkgId: fetchedPkg.id}) return dependency } diff --git a/src/link/index.ts b/src/link/index.ts index d4e228fb21..d516aa47c0 100644 --- a/src/link/index.ts +++ b/src/link/index.ts @@ -12,6 +12,7 @@ import {InstalledPackages} from '../api/install' import linkBins from './linkBins' import {Package, Dependencies} from '../types' import resolvePeers, {DependencyTreeNode, DependencyTreeNodeMap} from './resolvePeers' +import logStatus from '../logging/logInstallStatus' export type LinkedPackage = { id: string, @@ -68,6 +69,10 @@ export default async function ( for (let pkg of flatResolvedDeps.filter(pkg => pkg.depth === 0)) { await symlinkDependencyTo(pkg, opts.baseNodeModules) + logStatus({ + status: 'installed', + pkgId: pkg.id, + }) } const binPath = opts.global ? globalBinPath() : path.join(opts.baseNodeModules, '.bin') await linkBins(opts.baseNodeModules, binPath)