From 43635e6bbb7078f03c23b05ab540169eec42e50d Mon Sep 17 00:00:00 2001 From: zkochan Date: Tue, 11 Jul 2017 22:55:00 +0300 Subject: [PATCH] feat: reporter has a Log type --- src/types.ts | 3 ++- test/install/misc.ts | 23 ++++++++++++----------- test/install/reporting.ts | 3 ++- test/uninstall.ts | 3 ++- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/types.ts b/src/types.ts index a7d0c5f5aa..6b66c069ce 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,5 @@ import {PackageMeta} from 'package-store' +import {Log} from 'pnpm-logger' export type PnpmOptions = { rawNpmConfig?: Object, @@ -54,7 +55,7 @@ export type PnpmOptions = { // cannot be specified via configs update?: boolean, - reporter?: (logObj: Object) => void, + reporter?: (logObj: Log) => void, packageManager?: { name: string, version: string, diff --git a/test/install/misc.ts b/test/install/misc.ts index e2109f4282..d244fbac38 100644 --- a/test/install/misc.ts +++ b/test/install/misc.ts @@ -23,6 +23,7 @@ import exists = require('path-exists') import isWindows = require('is-windows') import deepRequireCwd = require('deep-require-cwd') import sinon = require('sinon') +import {StageLog, RootLog, ProgressLog} from 'pnpm-logger' const IS_WINDOWS = isWindows() @@ -45,7 +46,7 @@ test('no dependencies (lodash)', async (t: tape.Test) => { await installPkgs(['lodash@4.0.0'], testDefaults({reporter})) - t.ok(reporter.calledWithMatch({ + t.ok(reporter.calledWithMatch({ name: 'pnpm:stage', level: 'debug', message: 'resolution_done', @@ -58,7 +59,7 @@ test('no dependencies (lodash)', async (t: tape.Test) => { level: 'info', message: 'Adding 1 packages to node_modules', }), 'informed about adding new packages to node_modules') - t.ok(reporter.calledWithMatch({ + t.ok(reporter.calledWithMatch({ name: 'pnpm:root', level: 'info', added: { @@ -131,7 +132,7 @@ test('update a package when installing with a dist-tag', async function (t: tape await installPkgs(['dep-of-pkg-with-1-dep@beta'], testDefaults({saveDev: true, reporter})) - t.ok(reporter.calledWithMatch({ + t.ok(reporter.calledWithMatch({ name: 'pnpm:root', level: 'info', removed: { @@ -140,7 +141,7 @@ test('update a package when installing with a dist-tag', async function (t: tape }, }), 'reported old version removed from the root') - t.ok(reporter.calledWithMatch({ + t.ok(reporter.calledWithMatch({ name: 'pnpm:root', level: 'info', added: { @@ -194,7 +195,7 @@ test('idempotency (rimraf)', async (t: tape.Test) => { await installPkgs(['rimraf@2.5.1'], opts) - t.ok(reporter.calledWithMatch({ + t.ok(reporter.calledWithMatch({ name: 'pnpm:root', level: 'info', added: { @@ -207,7 +208,7 @@ test('idempotency (rimraf)', async (t: tape.Test) => { await installPkgs(['rimraf@2.5.1'], opts) - t.notOk(reporter.calledWithMatch({ + t.notOk(reporter.calledWithMatch({ name: 'pnpm:root', level: 'info', added: { @@ -230,7 +231,7 @@ test('reporting adding root package', async (t: tape.Test) => { await installPkgs(['flatten@1.0.2'], testDefaults({reporter})) - t.ok(reporter.calledWithMatch({ + t.ok(reporter.calledWithMatch({ name: 'pnpm:root', level: 'info', added: { @@ -652,12 +653,12 @@ test('shrinkwrap locks npm dependencies', async function (t: tape.Test) { await installPkgs(['pkg-with-1-dep'], testDefaults({save: true, reporter})) - t.ok(reporter.calledWithMatch({ + t.ok(reporter.calledWithMatch({ level: 'debug', status: 'resolving_content', pkgId: 'localhost+4873/pkg-with-1-dep/100.0.0', }), 'logs that package is being resolved') - t.ok(reporter.calledWithMatch({ + t.ok(reporter.calledWithMatch({ level: 'debug', status: 'fetched', pkgId: 'localhost+4873/pkg-with-1-dep/100.0.0', @@ -672,12 +673,12 @@ test('shrinkwrap locks npm dependencies', async function (t: tape.Test) { reporter.reset() await install(testDefaults({reporter})) - t.ok(reporter.calledWithMatch({ + t.ok(reporter.calledWithMatch({ level: 'debug', status: 'resolving_content', pkgId: 'localhost+4873/pkg-with-1-dep/100.0.0', }), 'logs that package is being resolved') - t.ok(reporter.calledWithMatch({ + t.ok(reporter.calledWithMatch({ level: 'debug', status: 'found_in_store', pkgId: 'localhost+4873/pkg-with-1-dep/100.0.0', diff --git a/test/install/reporting.ts b/test/install/reporting.ts index 48fe25fd65..29ceafbaa5 100644 --- a/test/install/reporting.ts +++ b/test/install/reporting.ts @@ -3,6 +3,7 @@ import promisifyTape from 'tape-promise' import {prepare, testDefaults} from '../utils' import {installPkgs} from '../../src' import sinon = require('sinon') +import {DeprecationLog} from 'pnpm-logger' const test = promisifyTape(tape) // TODO: use a smaller package for testing deprecation @@ -13,7 +14,7 @@ test('reports warning when installing deprecated packages', async (t: tape.Test) await installPkgs(['jade'], testDefaults({reporter})) - t.ok(reporter.calledWithMatch({ + t.ok(reporter.calledWithMatch({ name: 'pnpm:deprecation', level: 'warn', pkgId: 'localhost+4873/jade/1.11.0', diff --git a/test/uninstall.ts b/test/uninstall.ts index 07ec38dd92..4e47f9405a 100644 --- a/test/uninstall.ts +++ b/test/uninstall.ts @@ -20,6 +20,7 @@ import { } from '../src' import thenify = require('thenify') import sinon = require('sinon') +import {RootLog} from 'pnpm-logger' const ncp = thenify(ncpCB.ncp) @@ -34,7 +35,7 @@ test('uninstall package with no dependencies', async (t: tape.Test) => { level: 'info', message: 'Removing 1 orphan packages from node_modules', }), 'reported info message about removing orphans') - t.ok(reporter.calledWithMatch({ + t.ok(reporter.calledWithMatch({ name: 'pnpm:root', level: 'info', removed: {