-
-
Notifications
You must be signed in to change notification settings - Fork 936
/
index.ts
121 lines (116 loc) · 4.1 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import { Config } from '@pnpm/config'
import * as logs from '@pnpm/core-loggers'
import { LogLevel } from '@pnpm/logger'
import * as Rx from 'rxjs'
import { throttleTime } from 'rxjs/operators'
import reportBigTarballsProgress from './reportBigTarballsProgress'
import reportContext from './reportContext'
import reportDeprecations from './reportDeprecations'
import reportHooks from './reportHooks'
import reportInstallChecks from './reportInstallChecks'
import reportLifecycleScripts from './reportLifecycleScripts'
import reportMisc from './reportMisc'
import reportPeerDependencyIssues from './reportPeerDependencyIssues'
import reportProgress from './reportProgress'
import reportRequestRetry from './reportRequestRetry'
import reportScope from './reportScope'
import reportSkippedOptionalDependencies from './reportSkippedOptionalDependencies'
import reportStats from './reportStats'
import reportSummary from './reportSummary'
import reportUpdateCheck from './reportUpdateCheck'
export default function (
log$: {
context: Rx.Observable<logs.ContextLog>
fetchingProgress: Rx.Observable<logs.FetchingProgressLog>
progress: Rx.Observable<logs.ProgressLog>
stage: Rx.Observable<logs.StageLog>
deprecation: Rx.Observable<logs.DeprecationLog>
summary: Rx.Observable<logs.SummaryLog>
lifecycle: Rx.Observable<logs.LifecycleLog>
stats: Rx.Observable<logs.StatsLog>
installCheck: Rx.Observable<logs.InstallCheckLog>
registry: Rx.Observable<logs.RegistryLog>
root: Rx.Observable<logs.RootLog>
packageManifest: Rx.Observable<logs.PackageManifestLog>
peerDependencyIssues: Rx.Observable<logs.PeerDependencyIssuesLog>
requestRetry: Rx.Observable<logs.RequestRetryLog>
link: Rx.Observable<logs.LinkLog>
other: Rx.Observable<logs.Log>
hook: Rx.Observable<logs.HookLog>
scope: Rx.Observable<logs.ScopeLog>
skippedOptionalDependency: Rx.Observable<logs.SkippedOptionalDependencyLog>
packageImportMethod: Rx.Observable<logs.PackageImportMethodLog>
updateCheck: Rx.Observable<logs.UpdateCheckLog>
},
opts: {
appendOnly?: boolean
cmd: string
config?: Config
env: NodeJS.ProcessEnv
isRecursive: boolean
logLevel?: LogLevel
pnpmConfig?: Config
streamLifecycleOutput?: boolean
aggregateOutput?: boolean
throttleProgress?: number
width?: number
}
): Array<Rx.Observable<Rx.Observable<{msg: string}>>> {
const width = opts.width ?? process.stdout.columns ?? 80
const cwd = opts.pnpmConfig?.dir ?? process.cwd()
const throttle = typeof opts.throttleProgress === 'number' && opts.throttleProgress > 0
? throttleTime(opts.throttleProgress, undefined, { leading: true, trailing: true })
: undefined
const outputs: Array<Rx.Observable<Rx.Observable<{msg: string}>>> = [
reportProgress(log$, {
cwd,
throttle,
}),
reportPeerDependencyIssues(log$),
reportLifecycleScripts(log$, {
appendOnly: opts.appendOnly === true || opts.streamLifecycleOutput,
aggregateOutput: opts.aggregateOutput,
cwd,
width,
}),
reportDeprecations(log$.deprecation, {
cwd,
isRecursive: opts.isRecursive,
logLevel: opts.logLevel,
}),
reportMisc(
log$,
{
appendOnly: opts.appendOnly === true,
config: opts.config,
cwd,
logLevel: opts.logLevel,
zoomOutCurrent: opts.isRecursive,
}
),
...reportStats(log$, {
cmd: opts.cmd,
cwd,
isRecursive: opts.isRecursive,
width,
}),
reportInstallChecks(log$.installCheck, { cwd }),
reportRequestRetry(log$.requestRetry),
reportScope(log$.scope, { isRecursive: opts.isRecursive, cmd: opts.cmd }),
reportSkippedOptionalDependencies(log$.skippedOptionalDependency, { cwd }),
reportHooks(log$.hook, { cwd, isRecursive: opts.isRecursive }),
reportContext(log$, { cwd }),
reportUpdateCheck(log$.updateCheck),
]
if (!opts.appendOnly) {
outputs.push(reportBigTarballsProgress(log$))
}
if (!opts.isRecursive) {
outputs.push(reportSummary(log$, {
cwd,
env: opts.env,
pnpmConfig: opts.pnpmConfig,
}))
}
return outputs
}